@integrity-labs/agt-cli 0.28.1295 → 0.28.1297
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-EPU52HGW.js → api-client-JYLMRQ5B.js} +3 -3
- package/dist/bin/agt.js +7 -7
- package/dist/{chunk-OASIXWY3.js → chunk-5RA3GYYL.js} +373 -350
- package/dist/chunk-5RA3GYYL.js.map +1 -0
- package/dist/{chunk-M3OBVJQP.js → chunk-FPJRE3WT.js} +1 -1
- package/dist/{chunk-J34KVUAW.js → chunk-FQOXKQXI.js} +15 -3
- package/dist/chunk-FQOXKQXI.js.map +1 -0
- package/dist/{chunk-BOYTADW6.js → chunk-L43TPIOQ.js} +3 -3
- package/dist/{chunk-SR46T5UD.js → chunk-LXFCVKHS.js} +2 -2
- package/dist/{chunk-624FWL4A.js → chunk-XVGLZ3BT.js} +3 -2
- package/dist/{claude-code-updater-6AJKWY22.js → claude-code-updater-DLCZAKW3.js} +3 -3
- package/dist/{claude-pair-runtime-ATC6ZI6J.js → claude-pair-runtime-43E2YV2S.js} +3 -3
- package/dist/lib/manager-worker.js +230 -35
- package/dist/lib/manager-worker.js.map +1 -1
- package/dist/{persistent-session-WLSZATFE.js → persistent-session-RGMMUKVK.js} +8 -4
- package/dist/{responsiveness-probe-F6TL3DZB.js → responsiveness-probe-I7HNQGP4.js} +4 -4
- package/dist/{session-auth-dead-HJLK5AFT.js → session-auth-dead-JVDVNJR3.js} +3 -3
- package/package.json +1 -1
- package/dist/chunk-J34KVUAW.js.map +0 -1
- package/dist/chunk-OASIXWY3.js.map +0 -1
- /package/dist/{api-client-EPU52HGW.js.map → api-client-JYLMRQ5B.js.map} +0 -0
- /package/dist/{chunk-M3OBVJQP.js.map → chunk-FPJRE3WT.js.map} +0 -0
- /package/dist/{chunk-BOYTADW6.js.map → chunk-L43TPIOQ.js.map} +0 -0
- /package/dist/{chunk-SR46T5UD.js.map → chunk-LXFCVKHS.js.map} +0 -0
- /package/dist/{chunk-624FWL4A.js.map → chunk-XVGLZ3BT.js.map} +0 -0
- /package/dist/{claude-code-updater-6AJKWY22.js.map → claude-code-updater-DLCZAKW3.js.map} +0 -0
- /package/dist/{claude-pair-runtime-ATC6ZI6J.js.map → claude-pair-runtime-43E2YV2S.js.map} +0 -0
- /package/dist/{persistent-session-WLSZATFE.js.map → persistent-session-RGMMUKVK.js.map} +0 -0
- /package/dist/{responsiveness-probe-F6TL3DZB.js.map → responsiveness-probe-I7HNQGP4.js.map} +0 -0
- /package/dist/{session-auth-dead-HJLK5AFT.js.map → session-auth-dead-JVDVNJR3.js.map} +0 -0
|
@@ -2,7 +2,7 @@ import {
|
|
|
2
2
|
exchangeApiKey,
|
|
3
3
|
getApiKey,
|
|
4
4
|
getHost
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-L43TPIOQ.js";
|
|
6
6
|
import {
|
|
7
7
|
LATE_BOUND_VARS,
|
|
8
8
|
PLATFORM_DENY_PERMISSIONS,
|
|
@@ -26,11 +26,11 @@ import {
|
|
|
26
26
|
warnIgnoredIsolationAllowlist,
|
|
27
27
|
withheldRemoteMcpMessage,
|
|
28
28
|
withheldRemoteMcpReasonFor
|
|
29
|
-
} from "./chunk-
|
|
29
|
+
} from "./chunk-FQOXKQXI.js";
|
|
30
30
|
import {
|
|
31
31
|
readDailySessionPin,
|
|
32
32
|
sessionTranscriptDir
|
|
33
|
-
} from "./chunk-
|
|
33
|
+
} from "./chunk-XVGLZ3BT.js";
|
|
34
34
|
import {
|
|
35
35
|
classifyUnanswerablePane,
|
|
36
36
|
isConsumerTermsDialogVisible,
|
|
@@ -102,7 +102,7 @@ import {
|
|
|
102
102
|
scanConfigForLiteralSecrets,
|
|
103
103
|
worseConnectivityOutcome,
|
|
104
104
|
wrapScheduledTaskPrompt
|
|
105
|
-
} from "./chunk-
|
|
105
|
+
} from "./chunk-FPJRE3WT.js";
|
|
106
106
|
import {
|
|
107
107
|
claudeJsonPathFor,
|
|
108
108
|
effectiveClaudeJsonPath,
|
|
@@ -536,8 +536,34 @@ function describeChannelWriteFailure(outcome, channelId, trigger) {
|
|
|
536
536
|
}
|
|
537
537
|
|
|
538
538
|
// ../../packages/core/dist/provisioning/frameworks/claudecode/root-rm-guard.js
|
|
539
|
-
import { mkdirSync, readFileSync as readFileSync2, writeFileSync as
|
|
540
|
-
|
|
539
|
+
import { mkdirSync, readFileSync as readFileSync2, writeFileSync as writeFileSync3 } from "fs";
|
|
540
|
+
|
|
541
|
+
// ../../packages/core/dist/provisioning/atomic-script-write.js
|
|
542
|
+
import { closeSync, fchmodSync, openSync, renameSync as renameSync2, unlinkSync as unlinkSync2, writeFileSync as writeFileSync2 } from "fs";
|
|
543
|
+
import { randomBytes } from "crypto";
|
|
544
|
+
import { basename, dirname, join as join2 } from "path";
|
|
545
|
+
function writeExecutableAtomic(path, content, mode) {
|
|
546
|
+
const tmp = join2(dirname(path), `.${basename(path)}.${process.pid}.${randomBytes(6).toString("hex")}.tmp`);
|
|
547
|
+
try {
|
|
548
|
+
const fd = openSync(tmp, "wx", mode);
|
|
549
|
+
try {
|
|
550
|
+
writeFileSync2(fd, content, "utf8");
|
|
551
|
+
fchmodSync(fd, mode);
|
|
552
|
+
} finally {
|
|
553
|
+
closeSync(fd);
|
|
554
|
+
}
|
|
555
|
+
renameSync2(tmp, path);
|
|
556
|
+
} catch (err) {
|
|
557
|
+
try {
|
|
558
|
+
unlinkSync2(tmp);
|
|
559
|
+
} catch {
|
|
560
|
+
}
|
|
561
|
+
throw err;
|
|
562
|
+
}
|
|
563
|
+
}
|
|
564
|
+
|
|
565
|
+
// ../../packages/core/dist/provisioning/frameworks/claudecode/root-rm-guard.js
|
|
566
|
+
import { join as join3 } from "path";
|
|
541
567
|
function createShellGuard() {
|
|
542
568
|
const REFUSAL = "Refused: don't create or delete files at /. Use your scratch dir (../scratch/).";
|
|
543
569
|
const SHELLS = ["bash", "sh", "zsh", "dash", "ksh"];
|
|
@@ -849,7 +875,7 @@ function createShellGuard() {
|
|
|
849
875
|
out.ok = false;
|
|
850
876
|
return out;
|
|
851
877
|
}
|
|
852
|
-
function
|
|
878
|
+
function basename2(p) {
|
|
853
879
|
const k = p.lastIndexOf("/");
|
|
854
880
|
return k < 0 ? p : p.slice(k + 1);
|
|
855
881
|
}
|
|
@@ -875,13 +901,13 @@ function createShellGuard() {
|
|
|
875
901
|
words.shift();
|
|
876
902
|
continue;
|
|
877
903
|
}
|
|
878
|
-
if (PREFIX_CMDS.indexOf(
|
|
904
|
+
if (PREFIX_CMDS.indexOf(basename2(t)) >= 0) {
|
|
879
905
|
words.shift();
|
|
880
906
|
while (words.length && /^-/.test(words[0].text))
|
|
881
907
|
words.shift();
|
|
882
908
|
continue;
|
|
883
909
|
}
|
|
884
|
-
if (
|
|
910
|
+
if (basename2(t) === "timeout") {
|
|
885
911
|
words.shift();
|
|
886
912
|
while (words.length && /^-/.test(words[0].text))
|
|
887
913
|
words.shift();
|
|
@@ -892,7 +918,7 @@ function createShellGuard() {
|
|
|
892
918
|
}
|
|
893
919
|
if (!words.length)
|
|
894
920
|
continue;
|
|
895
|
-
const cmd =
|
|
921
|
+
const cmd = basename2(words[0].text);
|
|
896
922
|
const args = words.slice(1);
|
|
897
923
|
if (cmd === "rm") {
|
|
898
924
|
const inv = { targets: [], recursive: false, targetsUnknown: false };
|
|
@@ -915,7 +941,7 @@ function createShellGuard() {
|
|
|
915
941
|
if (!/^-/.test(a.text))
|
|
916
942
|
res.writes.push(a);
|
|
917
943
|
} else if (cmd === "xargs") {
|
|
918
|
-
if (args.some((a) =>
|
|
944
|
+
if (args.some((a) => basename2(a.text) === "rm")) {
|
|
919
945
|
res.rm.push({ targets: [], recursive: false, targetsUnknown: true });
|
|
920
946
|
}
|
|
921
947
|
} else if (cmd === "find") {
|
|
@@ -1021,17 +1047,17 @@ function buildRootRmHookJs() {
|
|
|
1021
1047
|
}
|
|
1022
1048
|
function provisionRootRmHookAt(claudeDir) {
|
|
1023
1049
|
mkdirSync(claudeDir, { recursive: true });
|
|
1024
|
-
const jsPath =
|
|
1025
|
-
|
|
1026
|
-
const hookScriptPath =
|
|
1027
|
-
|
|
1050
|
+
const jsPath = join3(claudeDir, ROOT_RM_HOOK_JS_FILENAME);
|
|
1051
|
+
writeExecutableAtomic(jsPath, buildRootRmHookJs(), 420);
|
|
1052
|
+
const hookScriptPath = join3(claudeDir, ROOT_RM_HOOK_FILENAME);
|
|
1053
|
+
writeExecutableAtomic(hookScriptPath, [
|
|
1028
1054
|
"#!/usr/bin/env bash",
|
|
1029
1055
|
"# ENG-11513: refuse rm of, or writes creating, files directly under /; see root-rm-guard.ts.",
|
|
1030
1056
|
"# Fail open: no node, or any error in the matcher, allows the call.",
|
|
1031
1057
|
"command -v node >/dev/null 2>&1 || exit 0",
|
|
1032
1058
|
`exec node '${jsPath.replace(/'/g, `'\\''`)}'`
|
|
1033
|
-
].join("\n") + "\n",
|
|
1034
|
-
const settingsPath =
|
|
1059
|
+
].join("\n") + "\n", 493);
|
|
1060
|
+
const settingsPath = join3(claudeDir, "settings.local.json");
|
|
1035
1061
|
let settings = {};
|
|
1036
1062
|
try {
|
|
1037
1063
|
settings = JSON.parse(readFileSync2(settingsPath, "utf-8"));
|
|
@@ -1044,7 +1070,7 @@ function provisionRootRmHookAt(claudeDir) {
|
|
|
1044
1070
|
}
|
|
1045
1071
|
hooks["PreToolUse"] = groups;
|
|
1046
1072
|
settings["hooks"] = hooks;
|
|
1047
|
-
|
|
1073
|
+
writeFileSync3(settingsPath, JSON.stringify(settings, null, 2));
|
|
1048
1074
|
}
|
|
1049
1075
|
var RM_POLICY_ARTIFACT = "rm-policy.json";
|
|
1050
1076
|
var RM_POLICY_RELATIVE_PATH = `provision/${RM_POLICY_ARTIFACT}`;
|
|
@@ -1149,12 +1175,12 @@ function orderTitlesForDescription(entries) {
|
|
|
1149
1175
|
}
|
|
1150
1176
|
|
|
1151
1177
|
// ../../packages/core/dist/provisioning/frameworks/claudecode/index.js
|
|
1152
|
-
import { readFileSync as readFileSync5, writeFileSync as
|
|
1153
|
-
import { join as
|
|
1178
|
+
import { readFileSync as readFileSync5, writeFileSync as writeFileSync6, 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 renameSync5, opendirSync as opendirSync2 } from "fs";
|
|
1179
|
+
import { join as join7, relative as relative2, dirname as dirname4 } from "path";
|
|
1154
1180
|
|
|
1155
1181
|
// ../../packages/core/dist/provisioning/frameworks/claudecode/scratch-file-sweep.js
|
|
1156
|
-
import { closeSync, constants, lstatSync, openSync, opendirSync, readlinkSync, realpathSync, rmdirSync, unlinkSync as
|
|
1157
|
-
import { join as
|
|
1182
|
+
import { closeSync as closeSync2, constants, lstatSync, openSync as openSync2, opendirSync, readlinkSync, realpathSync, rmdirSync, unlinkSync as unlinkSync3 } from "fs";
|
|
1183
|
+
import { join as join4, relative } from "path";
|
|
1158
1184
|
var WHOLE_TREE_DIR_NAMES = /* @__PURE__ */ new Set(["node_modules", ".venv", "venv"]);
|
|
1159
1185
|
var SCRATCH_FILE_SWEEP_ENTRY_BUDGET = 2e5;
|
|
1160
1186
|
var lastChange = (s) => Math.max(s.mtimeMs, s.ctimeMs);
|
|
@@ -1169,7 +1195,7 @@ function sweepScratchFiles(scratchDir, opts) {
|
|
|
1169
1195
|
} catch {
|
|
1170
1196
|
return result;
|
|
1171
1197
|
}
|
|
1172
|
-
const placeInScratch = (dir) =>
|
|
1198
|
+
const placeInScratch = (dir) => join4(realScratch, relative(scratchDir, dir));
|
|
1173
1199
|
const stillInside = (dir) => {
|
|
1174
1200
|
try {
|
|
1175
1201
|
return realpathSync(dir) === placeInScratch(dir);
|
|
@@ -1182,7 +1208,7 @@ function sweepScratchFiles(scratchDir, opts) {
|
|
|
1182
1208
|
return stillInside(dir);
|
|
1183
1209
|
let fd;
|
|
1184
1210
|
try {
|
|
1185
|
-
fd =
|
|
1211
|
+
fd = openSync2(dir, constants.O_RDONLY | constants.O_DIRECTORY);
|
|
1186
1212
|
} catch {
|
|
1187
1213
|
return false;
|
|
1188
1214
|
}
|
|
@@ -1196,11 +1222,11 @@ function sweepScratchFiles(scratchDir, opts) {
|
|
|
1196
1222
|
}
|
|
1197
1223
|
if (actual !== placeInScratch(dir))
|
|
1198
1224
|
return false;
|
|
1199
|
-
opts.beforeRemove?.(
|
|
1200
|
-
remove(
|
|
1225
|
+
opts.beforeRemove?.(join4(dir, name));
|
|
1226
|
+
remove(join4(pinned, name));
|
|
1201
1227
|
return true;
|
|
1202
1228
|
} finally {
|
|
1203
|
-
|
|
1229
|
+
closeSync2(fd);
|
|
1204
1230
|
}
|
|
1205
1231
|
};
|
|
1206
1232
|
const childrenOf = (dir) => {
|
|
@@ -1240,7 +1266,7 @@ function sweepScratchFiles(scratchDir, opts) {
|
|
|
1240
1266
|
result.truncated = true;
|
|
1241
1267
|
return left || 1;
|
|
1242
1268
|
}
|
|
1243
|
-
const full =
|
|
1269
|
+
const full = join4(dir, name);
|
|
1244
1270
|
let stat;
|
|
1245
1271
|
try {
|
|
1246
1272
|
stat = lstatSync(full);
|
|
@@ -1252,7 +1278,7 @@ function sweepScratchFiles(scratchDir, opts) {
|
|
|
1252
1278
|
continue;
|
|
1253
1279
|
try {
|
|
1254
1280
|
opts.beforeCheck?.(full);
|
|
1255
|
-
if (!removeFrom(dir, name,
|
|
1281
|
+
if (!removeFrom(dir, name, unlinkSync3))
|
|
1256
1282
|
return left || 1;
|
|
1257
1283
|
result.files += 1;
|
|
1258
1284
|
result.bytes += stat.size;
|
|
@@ -1292,9 +1318,9 @@ import { homedir as homedir3, tmpdir } from "os";
|
|
|
1292
1318
|
import { execFile } from "child_process";
|
|
1293
1319
|
|
|
1294
1320
|
// ../../packages/core/dist/integrations/xurl-config.js
|
|
1295
|
-
import { chmodSync as chmodSync2, existsSync as existsSync2, mkdirSync as mkdirSync2, readFileSync as readFileSync3, renameSync as
|
|
1321
|
+
import { chmodSync as chmodSync2, existsSync as existsSync2, mkdirSync as mkdirSync2, readFileSync as readFileSync3, renameSync as renameSync3, unlinkSync as unlinkSync4, writeFileSync as writeFileSync4 } from "fs";
|
|
1296
1322
|
import { homedir } from "os";
|
|
1297
|
-
import { dirname, join as
|
|
1323
|
+
import { dirname as dirname2, join as join5 } from "path";
|
|
1298
1324
|
import { parse as parseYaml, stringify as stringifyYaml } from "yaml";
|
|
1299
1325
|
var XURL_FILE_MODE = 384;
|
|
1300
1326
|
var XURL_AGT_APP_PREFIX = "agt-";
|
|
@@ -1413,7 +1439,7 @@ function buildAgtXurlApps(integrations) {
|
|
|
1413
1439
|
}
|
|
1414
1440
|
function getXurlStorePath() {
|
|
1415
1441
|
const home = process.env["HOME"] ?? process.env["USERPROFILE"] ?? homedir();
|
|
1416
|
-
return
|
|
1442
|
+
return join5(home, ".xurl");
|
|
1417
1443
|
}
|
|
1418
1444
|
function writeXurlStoreForIntegrations(integrations, filePath = getXurlStorePath()) {
|
|
1419
1445
|
const agtApps = buildAgtXurlApps(integrations);
|
|
@@ -1434,14 +1460,14 @@ function writeXurlStoreForIntegrations(integrations, filePath = getXurlStorePath
|
|
|
1434
1460
|
existing = parsed;
|
|
1435
1461
|
}
|
|
1436
1462
|
const merged = mergeXurlStore(existing, agtApps);
|
|
1437
|
-
mkdirSync2(
|
|
1463
|
+
mkdirSync2(dirname2(filePath), { recursive: true });
|
|
1438
1464
|
const tmpPath = `${filePath}.tmp-${process.pid}-${Date.now()}`;
|
|
1439
|
-
|
|
1465
|
+
writeFileSync4(tmpPath, serializeXurlStore(merged), { mode: XURL_FILE_MODE });
|
|
1440
1466
|
try {
|
|
1441
|
-
|
|
1467
|
+
renameSync3(tmpPath, filePath);
|
|
1442
1468
|
} catch (err) {
|
|
1443
1469
|
try {
|
|
1444
|
-
|
|
1470
|
+
unlinkSync4(tmpPath);
|
|
1445
1471
|
} catch {
|
|
1446
1472
|
}
|
|
1447
1473
|
throw err;
|
|
@@ -1454,9 +1480,9 @@ function writeXurlStoreForIntegrations(integrations, filePath = getXurlStorePath
|
|
|
1454
1480
|
}
|
|
1455
1481
|
|
|
1456
1482
|
// ../../packages/core/dist/integrations/framer-credentials.js
|
|
1457
|
-
import { chmodSync as chmodSync3, existsSync as existsSync3, mkdirSync as mkdirSync3, readFileSync as readFileSync4, renameSync as
|
|
1483
|
+
import { chmodSync as chmodSync3, existsSync as existsSync3, mkdirSync as mkdirSync3, readFileSync as readFileSync4, renameSync as renameSync4, rmSync, statSync, unlinkSync as unlinkSync5, writeFileSync as writeFileSync5 } from "fs";
|
|
1458
1484
|
import { homedir as homedir2 } from "os";
|
|
1459
|
-
import { dirname as
|
|
1485
|
+
import { dirname as dirname3, join as join6 } from "path";
|
|
1460
1486
|
var FRAMER_PROJECTS_CONFIG_VERSION = 2;
|
|
1461
1487
|
var BARE_PROJECT_ID = /^[A-Za-z0-9]{20}$/u;
|
|
1462
1488
|
var SLUGGED_PROJECT_ID = /^.+--([A-Za-z0-9]+)/u;
|
|
@@ -1555,7 +1581,7 @@ function mergeFramerProjectsConfig(existing, inputs, options = {}) {
|
|
|
1555
1581
|
var FRAMER_FILE_MODE = 384;
|
|
1556
1582
|
var MANAGED_SIDECAR_NAME = ".augmented-managed-projects.json";
|
|
1557
1583
|
function sidecarPathFor(projectsPath) {
|
|
1558
|
-
return
|
|
1584
|
+
return join6(dirname3(projectsPath), MANAGED_SIDECAR_NAME);
|
|
1559
1585
|
}
|
|
1560
1586
|
function readManagedIds(projectsPath) {
|
|
1561
1587
|
try {
|
|
@@ -1573,12 +1599,12 @@ function writeManagedIds(projectsPath, ids) {
|
|
|
1573
1599
|
try {
|
|
1574
1600
|
if (ids.length === 0) {
|
|
1575
1601
|
try {
|
|
1576
|
-
|
|
1602
|
+
unlinkSync5(target);
|
|
1577
1603
|
} catch {
|
|
1578
1604
|
}
|
|
1579
1605
|
return;
|
|
1580
1606
|
}
|
|
1581
|
-
|
|
1607
|
+
writeFileSync5(target, `${JSON.stringify([...ids].sort(), null, " ")}
|
|
1582
1608
|
`, {
|
|
1583
1609
|
mode: FRAMER_FILE_MODE
|
|
1584
1610
|
});
|
|
@@ -1591,7 +1617,7 @@ var LOCK_MAX_ATTEMPTS = 50;
|
|
|
1591
1617
|
function withStoreLock(projectsPath, fn) {
|
|
1592
1618
|
const lockDir = `${projectsPath}.lock`;
|
|
1593
1619
|
try {
|
|
1594
|
-
mkdirSync3(
|
|
1620
|
+
mkdirSync3(dirname3(projectsPath), { recursive: true, mode: 448 });
|
|
1595
1621
|
} catch {
|
|
1596
1622
|
}
|
|
1597
1623
|
let held = false;
|
|
@@ -1631,9 +1657,9 @@ function asString2(value) {
|
|
|
1631
1657
|
function getFramerProjectsPath() {
|
|
1632
1658
|
const xdg = process.env["XDG_CONFIG_HOME"];
|
|
1633
1659
|
if (xdg)
|
|
1634
|
-
return
|
|
1660
|
+
return join6(xdg, "framer", "projects.json");
|
|
1635
1661
|
const home = process.env["HOME"] ?? process.env["USERPROFILE"] ?? homedir2();
|
|
1636
|
-
return
|
|
1662
|
+
return join6(home, ".config", "framer", "projects.json");
|
|
1637
1663
|
}
|
|
1638
1664
|
function buildFramerCredentialInputs(integrations) {
|
|
1639
1665
|
const inputs = [];
|
|
@@ -1676,14 +1702,14 @@ function writeFramerStoreForIntegrations(integrations, filePath = getFramerProje
|
|
|
1676
1702
|
}
|
|
1677
1703
|
if (!content)
|
|
1678
1704
|
return null;
|
|
1679
|
-
mkdirSync3(
|
|
1705
|
+
mkdirSync3(dirname3(filePath), { recursive: true, mode: 448 });
|
|
1680
1706
|
const tmpPath = `${filePath}.tmp-${process.pid}-${Date.now()}`;
|
|
1681
|
-
|
|
1707
|
+
writeFileSync5(tmpPath, content, { mode: FRAMER_FILE_MODE });
|
|
1682
1708
|
try {
|
|
1683
|
-
|
|
1709
|
+
renameSync4(tmpPath, filePath);
|
|
1684
1710
|
} catch (err) {
|
|
1685
1711
|
try {
|
|
1686
|
-
|
|
1712
|
+
unlinkSync5(tmpPath);
|
|
1687
1713
|
} catch {
|
|
1688
1714
|
}
|
|
1689
1715
|
throw err;
|
|
@@ -1998,7 +2024,7 @@ function buildAad(headerBytes, ctx) {
|
|
|
1998
2024
|
}
|
|
1999
2025
|
|
|
2000
2026
|
// ../../packages/core/dist/crypto/secret.js
|
|
2001
|
-
import { createCipheriv, createDecipheriv, randomBytes } from "crypto";
|
|
2027
|
+
import { createCipheriv, createDecipheriv, randomBytes as randomBytes2 } from "crypto";
|
|
2002
2028
|
|
|
2003
2029
|
// ../../packages/core/dist/crypto/dek-cache.js
|
|
2004
2030
|
var DEFAULT_DEK_CACHE_TTL_MS = 5 * 6e4;
|
|
@@ -2493,7 +2519,7 @@ var VALID_CODE_NAME = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
|
|
|
2493
2519
|
var SECRET_FILE_MODE = 384;
|
|
2494
2520
|
function writeEnvIntegrationsForAgent(codeName, args) {
|
|
2495
2521
|
const agentDir = getAgentDir(codeName);
|
|
2496
|
-
const envPath =
|
|
2522
|
+
const envPath = join7(agentDir, ".env.integrations");
|
|
2497
2523
|
let existing = null;
|
|
2498
2524
|
try {
|
|
2499
2525
|
existing = readFileSync5(envPath, "utf-8");
|
|
@@ -2502,7 +2528,7 @@ function writeEnvIntegrationsForAgent(codeName, args) {
|
|
|
2502
2528
|
if (existing === null && Object.keys(args.updates).length === 0)
|
|
2503
2529
|
return;
|
|
2504
2530
|
const content = mergeEnvIntegrationsContent(existing, args);
|
|
2505
|
-
|
|
2531
|
+
writeFileSync6(envPath, content, { mode: SECRET_FILE_MODE });
|
|
2506
2532
|
try {
|
|
2507
2533
|
chmodSync4(envPath, SECRET_FILE_MODE);
|
|
2508
2534
|
} catch {
|
|
@@ -2510,8 +2536,8 @@ function writeEnvIntegrationsForAgent(codeName, args) {
|
|
|
2510
2536
|
try {
|
|
2511
2537
|
const projectDir = getProjectDir2(codeName);
|
|
2512
2538
|
mkdirSync4(projectDir, { recursive: true });
|
|
2513
|
-
const dest =
|
|
2514
|
-
|
|
2539
|
+
const dest = join7(projectDir, ".env.integrations");
|
|
2540
|
+
writeFileSync6(dest, content, { mode: SECRET_FILE_MODE });
|
|
2515
2541
|
try {
|
|
2516
2542
|
chmodSync4(dest, SECRET_FILE_MODE);
|
|
2517
2543
|
} catch {
|
|
@@ -2531,7 +2557,7 @@ var MIGRATABLE_FIELD_TO_ENV_VAR = {
|
|
|
2531
2557
|
AGT_API_KEY: "AGT_API_KEY"
|
|
2532
2558
|
};
|
|
2533
2559
|
function migrateExistingLiteralSecrets(codeName) {
|
|
2534
|
-
const mcpJsonPath =
|
|
2560
|
+
const mcpJsonPath = join7(getAgentDir(codeName), "provision", ".mcp.json");
|
|
2535
2561
|
let config;
|
|
2536
2562
|
try {
|
|
2537
2563
|
config = JSON.parse(readFileSync5(mcpJsonPath, "utf-8"));
|
|
@@ -2540,7 +2566,7 @@ function migrateExistingLiteralSecrets(codeName) {
|
|
|
2540
2566
|
}
|
|
2541
2567
|
let existingEnvKeys = /* @__PURE__ */ new Set();
|
|
2542
2568
|
try {
|
|
2543
|
-
existingEnvKeys = new Set(parseEnvFileEntries(readFileSync5(
|
|
2569
|
+
existingEnvKeys = new Set(parseEnvFileEntries(readFileSync5(join7(getAgentDir(codeName), ".env.integrations"), "utf-8")).keys());
|
|
2544
2570
|
} catch {
|
|
2545
2571
|
}
|
|
2546
2572
|
const updates = {};
|
|
@@ -2614,8 +2640,8 @@ function ensureIdKeyedLayout(codeName, agentId) {
|
|
|
2614
2640
|
assertValidCodeName(codeName);
|
|
2615
2641
|
assertValidAgentId(agentId);
|
|
2616
2642
|
const home = getHomeDir();
|
|
2617
|
-
const codeNamePath =
|
|
2618
|
-
const idPath =
|
|
2643
|
+
const codeNamePath = join7(home, ".augmented", codeName);
|
|
2644
|
+
const idPath = join7(home, ".augmented", agentId);
|
|
2619
2645
|
let state;
|
|
2620
2646
|
try {
|
|
2621
2647
|
state = lstatSync2(codeNamePath).isSymbolicLink() ? "symlink" : "realdir";
|
|
@@ -2638,7 +2664,7 @@ function ensureIdKeyedLayout(codeName, agentId) {
|
|
|
2638
2664
|
return idPath;
|
|
2639
2665
|
}
|
|
2640
2666
|
function stagedMigrationLinkPath(home, codeName) {
|
|
2641
|
-
return
|
|
2667
|
+
return join7(home, ".augmented", `.${codeName}.migrating`);
|
|
2642
2668
|
}
|
|
2643
2669
|
function cleanupStaleStagedLink(staged) {
|
|
2644
2670
|
try {
|
|
@@ -2658,8 +2684,8 @@ function migrateAgentDirToIdKeyed(codeName, agentId, opts = {}) {
|
|
|
2658
2684
|
assertValidCodeName(codeName);
|
|
2659
2685
|
assertValidAgentId(agentId);
|
|
2660
2686
|
const home = opts.home ?? getHomeDir();
|
|
2661
|
-
const codeNamePath =
|
|
2662
|
-
const idPath =
|
|
2687
|
+
const codeNamePath = join7(home, ".augmented", codeName);
|
|
2688
|
+
const idPath = join7(home, ".augmented", agentId);
|
|
2663
2689
|
const staged = stagedMigrationLinkPath(home, codeName);
|
|
2664
2690
|
let codeNameKind;
|
|
2665
2691
|
try {
|
|
@@ -2677,7 +2703,7 @@ function migrateAgentDirToIdKeyed(codeName, agentId, opts = {}) {
|
|
|
2677
2703
|
}
|
|
2678
2704
|
if (codeNameKind === "absent" && idExists) {
|
|
2679
2705
|
if (isSymlinkTo(staged, agentId)) {
|
|
2680
|
-
|
|
2706
|
+
renameSync5(staged, codeNamePath);
|
|
2681
2707
|
} else {
|
|
2682
2708
|
cleanupStaleStagedLink(staged);
|
|
2683
2709
|
symlinkSync(agentId, codeNamePath);
|
|
@@ -2691,20 +2717,20 @@ function migrateAgentDirToIdKeyed(codeName, agentId, opts = {}) {
|
|
|
2691
2717
|
}
|
|
2692
2718
|
cleanupStaleStagedLink(staged);
|
|
2693
2719
|
symlinkSync(agentId, staged);
|
|
2694
|
-
|
|
2695
|
-
|
|
2720
|
+
renameSync5(codeNamePath, idPath);
|
|
2721
|
+
renameSync5(staged, codeNamePath);
|
|
2696
2722
|
return "migrated";
|
|
2697
2723
|
}
|
|
2698
2724
|
function getAgentDir(codeName) {
|
|
2699
2725
|
assertValidCodeName(codeName);
|
|
2700
|
-
return resolveRealAgentPath(
|
|
2726
|
+
return resolveRealAgentPath(join7(getHomeDir(), ".augmented", codeName));
|
|
2701
2727
|
}
|
|
2702
2728
|
var migratedCodeNames = /* @__PURE__ */ new Set();
|
|
2703
2729
|
function migrateLegacyClaudecodeDir(codeName, log2) {
|
|
2704
2730
|
assertValidCodeName(codeName);
|
|
2705
2731
|
if (migratedCodeNames.has(codeName))
|
|
2706
2732
|
return;
|
|
2707
|
-
const legacyRoot =
|
|
2733
|
+
const legacyRoot = join7(getHomeDir(), ".augmented", codeName, "claudecode");
|
|
2708
2734
|
if (!existsSync4(legacyRoot)) {
|
|
2709
2735
|
migratedCodeNames.add(codeName);
|
|
2710
2736
|
return;
|
|
@@ -2717,8 +2743,8 @@ function migrateLegacyClaudecodeDir(codeName, log2) {
|
|
|
2717
2743
|
const walkAndMigrate = (srcDir, destDir) => {
|
|
2718
2744
|
mkdirSync4(destDir, { recursive: true });
|
|
2719
2745
|
for (const entry of readdirSync(srcDir, { withFileTypes: true })) {
|
|
2720
|
-
const src =
|
|
2721
|
-
const dest =
|
|
2746
|
+
const src = join7(srcDir, entry.name);
|
|
2747
|
+
const dest = join7(destDir, entry.name);
|
|
2722
2748
|
if (entry.isDirectory()) {
|
|
2723
2749
|
walkAndMigrate(src, dest);
|
|
2724
2750
|
continue;
|
|
@@ -2728,7 +2754,7 @@ function migrateLegacyClaudecodeDir(codeName, log2) {
|
|
|
2728
2754
|
const oldCfg = JSON.parse(readFileSync5(src, "utf-8"));
|
|
2729
2755
|
const newCfg = JSON.parse(readFileSync5(dest, "utf-8"));
|
|
2730
2756
|
const merged = { mcpServers: { ...oldCfg.mcpServers ?? {}, ...newCfg.mcpServers ?? {} } };
|
|
2731
|
-
|
|
2757
|
+
writeFileSync6(dest, JSON.stringify(merged, null, 2));
|
|
2732
2758
|
emit(`[migrate] '${codeName}' merged .mcp.json (${Object.keys(merged.mcpServers).length} servers)`);
|
|
2733
2759
|
} catch (err) {
|
|
2734
2760
|
throw new Error(`Failed merging .mcp.json (${src} \u2192 ${dest}): ${err.message}`);
|
|
@@ -2758,25 +2784,23 @@ function migrateLegacyClaudecodeDir(codeName, log2) {
|
|
|
2758
2784
|
}
|
|
2759
2785
|
}
|
|
2760
2786
|
function syncGitHubBrokerCredentialTooling(projectDir, enabled) {
|
|
2761
|
-
const binDir =
|
|
2787
|
+
const binDir = join7(projectDir, GITHUB_BROKER_BIN_DIR);
|
|
2762
2788
|
if (!enabled) {
|
|
2763
2789
|
rmSync2(binDir, { recursive: true, force: true });
|
|
2764
2790
|
return {};
|
|
2765
2791
|
}
|
|
2766
|
-
const helperPath =
|
|
2767
|
-
const shimPath =
|
|
2792
|
+
const helperPath = join7(binDir, GIT_CREDENTIAL_HELPER_BASENAME);
|
|
2793
|
+
const shimPath = join7(binDir, GH_SHIM_BASENAME);
|
|
2768
2794
|
mkdirSync4(binDir, { recursive: true });
|
|
2769
|
-
|
|
2770
|
-
|
|
2771
|
-
writeFileSync5(shimPath, renderGhShim(), { mode: BROKER_SCRIPT_MODE });
|
|
2772
|
-
chmodSync4(shimPath, BROKER_SCRIPT_MODE);
|
|
2795
|
+
writeExecutableAtomic(helperPath, renderGitCredentialHelper(), BROKER_SCRIPT_MODE);
|
|
2796
|
+
writeExecutableAtomic(shimPath, renderGhShim(), BROKER_SCRIPT_MODE);
|
|
2773
2797
|
return buildGitCredentialEnv(helperPath);
|
|
2774
2798
|
}
|
|
2775
2799
|
function getProjectDir2(codeName) {
|
|
2776
|
-
return
|
|
2800
|
+
return join7(getAgentDir(codeName), "project");
|
|
2777
2801
|
}
|
|
2778
2802
|
function reapLegacyTokenFile(codeName, onWarn = void 0) {
|
|
2779
|
-
const tokenFilePath =
|
|
2803
|
+
const tokenFilePath = join7(getAgentDir(codeName), ".tokens.json");
|
|
2780
2804
|
try {
|
|
2781
2805
|
rmSync2(tokenFilePath, { force: true });
|
|
2782
2806
|
return true;
|
|
@@ -2786,7 +2810,7 @@ function reapLegacyTokenFile(codeName, onWarn = void 0) {
|
|
|
2786
2810
|
}
|
|
2787
2811
|
}
|
|
2788
2812
|
function getScratchDir(codeName) {
|
|
2789
|
-
return
|
|
2813
|
+
return join7(getAgentDir(codeName), "scratch");
|
|
2790
2814
|
}
|
|
2791
2815
|
function getAgentTmpDir(codeName) {
|
|
2792
2816
|
return agentTmpDirFor(getAgentDir(codeName));
|
|
@@ -2831,7 +2855,7 @@ function sweepScratchDir(codeName, now = Date.now(), policy = scratchSweepPolicy
|
|
|
2831
2855
|
}
|
|
2832
2856
|
const cutoff = now - SCRATCH_RETENTION_DAYS * 24 * 60 * 60 * 1e3;
|
|
2833
2857
|
for (const entry of entries) {
|
|
2834
|
-
const full =
|
|
2858
|
+
const full = join7(scratchDir, entry);
|
|
2835
2859
|
try {
|
|
2836
2860
|
if (isFreshWithin(full, cutoff))
|
|
2837
2861
|
continue;
|
|
@@ -2861,7 +2885,7 @@ function sweepStrandedArtefactTmpDirs(now = Date.now()) {
|
|
|
2861
2885
|
for (const entry of entries) {
|
|
2862
2886
|
if (!STRANDED_ARTEFACT_TMP_PREFIXES.some((prefix) => entry.startsWith(prefix)))
|
|
2863
2887
|
continue;
|
|
2864
|
-
const full =
|
|
2888
|
+
const full = join7(root, entry);
|
|
2865
2889
|
try {
|
|
2866
2890
|
if (isFreshWithin(full, cutoff))
|
|
2867
2891
|
continue;
|
|
@@ -2901,7 +2925,7 @@ function isFreshWithin(path, cutoff) {
|
|
|
2901
2925
|
const child = dir.readSync();
|
|
2902
2926
|
if (child === null)
|
|
2903
2927
|
break;
|
|
2904
|
-
queue.push(
|
|
2928
|
+
queue.push(join7(current, child.name));
|
|
2905
2929
|
budget -= 1;
|
|
2906
2930
|
}
|
|
2907
2931
|
} catch {
|
|
@@ -2918,8 +2942,8 @@ function isFreshWithin(path, cutoff) {
|
|
|
2918
2942
|
function syncMcpToProject(codeName, provisionContent) {
|
|
2919
2943
|
const agentDir = getAgentDir(codeName);
|
|
2920
2944
|
const projectDir = getProjectDir2(codeName);
|
|
2921
|
-
const provisionMcpPath =
|
|
2922
|
-
const projectMcpPath =
|
|
2945
|
+
const provisionMcpPath = join7(agentDir, "provision", ".mcp.json");
|
|
2946
|
+
const projectMcpPath = join7(projectDir, ".mcp.json");
|
|
2923
2947
|
let content = provisionContent ?? null;
|
|
2924
2948
|
if (content === null) {
|
|
2925
2949
|
try {
|
|
@@ -2930,7 +2954,7 @@ function syncMcpToProject(codeName, provisionContent) {
|
|
|
2930
2954
|
if (content !== null)
|
|
2931
2955
|
try {
|
|
2932
2956
|
mkdirSync4(projectDir, { recursive: true });
|
|
2933
|
-
|
|
2957
|
+
writeFileSync6(projectMcpPath, content, { mode: MCP_FILE_MODE });
|
|
2934
2958
|
try {
|
|
2935
2959
|
chmodSync4(projectMcpPath, MCP_FILE_MODE);
|
|
2936
2960
|
} catch {
|
|
@@ -2953,13 +2977,13 @@ function syncMcpToProject(codeName, provisionContent) {
|
|
|
2953
2977
|
}
|
|
2954
2978
|
var INTEGRATIONS_SUMMARY_FILE = "integrations-summary.json";
|
|
2955
2979
|
function integrationsSummaryPath(codeName) {
|
|
2956
|
-
return
|
|
2980
|
+
return join7(getAgentDir(codeName), "provision", INTEGRATIONS_SUMMARY_FILE);
|
|
2957
2981
|
}
|
|
2958
2982
|
function writeIntegrationsSummaryForAgent(codeName, summaries) {
|
|
2959
2983
|
const target = integrationsSummaryPath(codeName);
|
|
2960
2984
|
try {
|
|
2961
|
-
mkdirSync4(
|
|
2962
|
-
|
|
2985
|
+
mkdirSync4(dirname4(target), { recursive: true });
|
|
2986
|
+
writeFileSync6(target, JSON.stringify(summaries, null, 2));
|
|
2963
2987
|
} catch {
|
|
2964
2988
|
}
|
|
2965
2989
|
}
|
|
@@ -2975,7 +2999,7 @@ function readIntegrationsSummaryForAgent(codeName) {
|
|
|
2975
2999
|
function renderChannelMessageHandlerForAgent(codeName) {
|
|
2976
3000
|
const agentDir = getAgentDir(codeName);
|
|
2977
3001
|
const projectDir = getProjectDir2(codeName);
|
|
2978
|
-
const provisionMcpPath =
|
|
3002
|
+
const provisionMcpPath = join7(agentDir, "provision", ".mcp.json");
|
|
2979
3003
|
let mcpServerKeys;
|
|
2980
3004
|
try {
|
|
2981
3005
|
const config = JSON.parse(readFileSync5(provisionMcpPath, "utf-8"));
|
|
@@ -2986,10 +3010,10 @@ function renderChannelMessageHandlerForAgent(codeName) {
|
|
|
2986
3010
|
const integrations = readIntegrationsSummaryForAgent(codeName);
|
|
2987
3011
|
const content = buildChannelMessageHandlerAgent({ mcpServerKeys, integrations });
|
|
2988
3012
|
for (const baseDir of [agentDir, projectDir]) {
|
|
2989
|
-
const target =
|
|
3013
|
+
const target = join7(baseDir, ".claude", "agents", "channel-message-handler.md");
|
|
2990
3014
|
try {
|
|
2991
|
-
mkdirSync4(
|
|
2992
|
-
|
|
3015
|
+
mkdirSync4(dirname4(target), { recursive: true });
|
|
3016
|
+
writeFileSync6(target, content);
|
|
2993
3017
|
} catch {
|
|
2994
3018
|
}
|
|
2995
3019
|
}
|
|
@@ -3009,7 +3033,7 @@ function writeMcpJsonGuarded(codeName, path, config) {
|
|
|
3009
3033
|
return true;
|
|
3010
3034
|
}
|
|
3011
3035
|
function readExistingMcpEnvVar(codeName, serverId, envKey) {
|
|
3012
|
-
const mcpJsonPath =
|
|
3036
|
+
const mcpJsonPath = join7(getAgentDir(codeName), "provision", ".mcp.json");
|
|
3013
3037
|
try {
|
|
3014
3038
|
const raw = readFileSync5(mcpJsonPath, "utf-8");
|
|
3015
3039
|
const config = JSON.parse(raw);
|
|
@@ -3074,10 +3098,10 @@ function ensureWorkspaceTrusted(projectDir) {
|
|
|
3074
3098
|
entry["hasTrustDialogAccepted"] = true;
|
|
3075
3099
|
projects[projectDir] = entry;
|
|
3076
3100
|
config["projects"] = projects;
|
|
3077
|
-
mkdirSync4(
|
|
3101
|
+
mkdirSync4(dirname4(configPath), { recursive: true });
|
|
3078
3102
|
const tmpPath = `${configPath}.agt-${process.pid}.tmp`;
|
|
3079
3103
|
try {
|
|
3080
|
-
|
|
3104
|
+
writeFileSync6(tmpPath, `${JSON.stringify(config, null, 2)}
|
|
3081
3105
|
`, {
|
|
3082
3106
|
mode: 384,
|
|
3083
3107
|
flag: "wx"
|
|
@@ -3090,7 +3114,7 @@ function ensureWorkspaceTrusted(projectDir) {
|
|
|
3090
3114
|
}
|
|
3091
3115
|
throw err;
|
|
3092
3116
|
}
|
|
3093
|
-
|
|
3117
|
+
renameSync5(tmpPath, configPath);
|
|
3094
3118
|
process.stderr.write(`[workspace-trust] [accepted] project=${projectDir}
|
|
3095
3119
|
`);
|
|
3096
3120
|
} catch (err) {
|
|
@@ -3115,8 +3139,8 @@ function deployArtifactsToProject(codeName, provisionDir) {
|
|
|
3115
3139
|
const SKILLS_START = SKILLS_INDEX_SECTION_START;
|
|
3116
3140
|
const SKILLS_END = SKILLS_INDEX_SECTION_END;
|
|
3117
3141
|
for (const file of artifactFiles) {
|
|
3118
|
-
const src =
|
|
3119
|
-
const dest =
|
|
3142
|
+
const src = join7(provisionDir, file);
|
|
3143
|
+
const dest = join7(projectDir, file);
|
|
3120
3144
|
try {
|
|
3121
3145
|
const srcContent = readFileSync5(src, "utf-8");
|
|
3122
3146
|
if (file === "CLAUDE.md" && existsSync4(dest)) {
|
|
@@ -3126,31 +3150,31 @@ function deployArtifactsToProject(codeName, provisionDir) {
|
|
|
3126
3150
|
continue;
|
|
3127
3151
|
const indexMatch = destContent.match(new RegExp(`${SKILLS_START}[\\s\\S]*?${SKILLS_END}`));
|
|
3128
3152
|
if (indexMatch) {
|
|
3129
|
-
|
|
3153
|
+
writeFileSync6(dest, srcContent.trimEnd() + "\n\n" + indexMatch[0] + "\n");
|
|
3130
3154
|
continue;
|
|
3131
3155
|
}
|
|
3132
3156
|
}
|
|
3133
3157
|
if (file === ".mcp.json") {
|
|
3134
|
-
|
|
3158
|
+
writeFileSync6(dest, srcContent, { mode: MCP_FILE_MODE });
|
|
3135
3159
|
try {
|
|
3136
3160
|
chmodSync4(dest, MCP_FILE_MODE);
|
|
3137
3161
|
} catch {
|
|
3138
3162
|
}
|
|
3139
3163
|
} else {
|
|
3140
|
-
|
|
3164
|
+
writeFileSync6(dest, srcContent);
|
|
3141
3165
|
}
|
|
3142
3166
|
} catch {
|
|
3143
3167
|
}
|
|
3144
3168
|
}
|
|
3145
|
-
const skillsDir =
|
|
3146
|
-
const destSkillsDir =
|
|
3169
|
+
const skillsDir = join7(provisionDir, ".claude", "skills");
|
|
3170
|
+
const destSkillsDir = join7(projectDir, ".claude", "skills");
|
|
3147
3171
|
try {
|
|
3148
3172
|
if (existsSync4(destSkillsDir)) {
|
|
3149
3173
|
const srcFolders = existsSync4(skillsDir) ? new Set(readdirSync(skillsDir)) : /* @__PURE__ */ new Set();
|
|
3150
3174
|
for (const folder of readdirSync(destSkillsDir)) {
|
|
3151
3175
|
if (folder.startsWith("knowledge-") || folder === "core-knowledge" && !srcFolders.has(folder)) {
|
|
3152
3176
|
try {
|
|
3153
|
-
rmSync2(
|
|
3177
|
+
rmSync2(join7(destSkillsDir, folder), { recursive: true });
|
|
3154
3178
|
} catch {
|
|
3155
3179
|
}
|
|
3156
3180
|
}
|
|
@@ -3158,11 +3182,11 @@ function deployArtifactsToProject(codeName, provisionDir) {
|
|
|
3158
3182
|
}
|
|
3159
3183
|
if (existsSync4(skillsDir)) {
|
|
3160
3184
|
for (const skillFolder of readdirSync(skillsDir)) {
|
|
3161
|
-
const srcSkillFile =
|
|
3185
|
+
const srcSkillFile = join7(skillsDir, skillFolder, "SKILL.md");
|
|
3162
3186
|
if (!existsSync4(srcSkillFile))
|
|
3163
3187
|
continue;
|
|
3164
|
-
const destFolder =
|
|
3165
|
-
const destFile =
|
|
3188
|
+
const destFolder = join7(destSkillsDir, skillFolder);
|
|
3189
|
+
const destFile = join7(destFolder, "SKILL.md");
|
|
3166
3190
|
const srcContent = readFileSync5(srcSkillFile, "utf-8");
|
|
3167
3191
|
try {
|
|
3168
3192
|
if (existsSync4(destFile) && readFileSync5(destFile, "utf-8") === srcContent)
|
|
@@ -3170,13 +3194,13 @@ function deployArtifactsToProject(codeName, provisionDir) {
|
|
|
3170
3194
|
} catch {
|
|
3171
3195
|
}
|
|
3172
3196
|
mkdirSync4(destFolder, { recursive: true });
|
|
3173
|
-
|
|
3197
|
+
writeFileSync6(destFile, srcContent);
|
|
3174
3198
|
}
|
|
3175
3199
|
}
|
|
3176
3200
|
} catch {
|
|
3177
3201
|
}
|
|
3178
|
-
const agentsDir =
|
|
3179
|
-
const destAgentsDir =
|
|
3202
|
+
const agentsDir = join7(provisionDir, ".claude", "agents");
|
|
3203
|
+
const destAgentsDir = join7(projectDir, ".claude", "agents");
|
|
3180
3204
|
try {
|
|
3181
3205
|
if (existsSync4(agentsDir)) {
|
|
3182
3206
|
const sourceAgentFiles = new Set(readdirSync(agentsDir).filter((f) => f.endsWith(".md")));
|
|
@@ -3187,14 +3211,14 @@ function deployArtifactsToProject(codeName, provisionDir) {
|
|
|
3187
3211
|
if (sourceAgentFiles.has(destFile))
|
|
3188
3212
|
continue;
|
|
3189
3213
|
try {
|
|
3190
|
-
rmSync2(
|
|
3214
|
+
rmSync2(join7(destAgentsDir, destFile));
|
|
3191
3215
|
} catch {
|
|
3192
3216
|
}
|
|
3193
3217
|
}
|
|
3194
3218
|
}
|
|
3195
3219
|
for (const agentFile of sourceAgentFiles) {
|
|
3196
|
-
const srcPath =
|
|
3197
|
-
const destPath =
|
|
3220
|
+
const srcPath = join7(agentsDir, agentFile);
|
|
3221
|
+
const destPath = join7(destAgentsDir, agentFile);
|
|
3198
3222
|
const srcContent = readFileSync5(srcPath, "utf-8");
|
|
3199
3223
|
try {
|
|
3200
3224
|
if (existsSync4(destPath) && readFileSync5(destPath, "utf-8") === srcContent)
|
|
@@ -3202,13 +3226,13 @@ function deployArtifactsToProject(codeName, provisionDir) {
|
|
|
3202
3226
|
} catch {
|
|
3203
3227
|
}
|
|
3204
3228
|
mkdirSync4(destAgentsDir, { recursive: true });
|
|
3205
|
-
|
|
3229
|
+
writeFileSync6(destPath, srcContent);
|
|
3206
3230
|
}
|
|
3207
3231
|
}
|
|
3208
3232
|
} catch {
|
|
3209
3233
|
}
|
|
3210
|
-
const workflowsDir =
|
|
3211
|
-
const destWorkflowsDir =
|
|
3234
|
+
const workflowsDir = join7(provisionDir, ".claude", "workflows");
|
|
3235
|
+
const destWorkflowsDir = join7(projectDir, ".claude", "workflows");
|
|
3212
3236
|
try {
|
|
3213
3237
|
const sourceWorkflowFiles = existsSync4(workflowsDir) ? new Set(readdirSync(workflowsDir).filter((f) => f.endsWith(".js"))) : /* @__PURE__ */ new Set();
|
|
3214
3238
|
if (existsSync4(destWorkflowsDir)) {
|
|
@@ -3218,14 +3242,14 @@ function deployArtifactsToProject(codeName, provisionDir) {
|
|
|
3218
3242
|
if (sourceWorkflowFiles.has(destFile))
|
|
3219
3243
|
continue;
|
|
3220
3244
|
try {
|
|
3221
|
-
rmSync2(
|
|
3245
|
+
rmSync2(join7(destWorkflowsDir, destFile));
|
|
3222
3246
|
} catch {
|
|
3223
3247
|
}
|
|
3224
3248
|
}
|
|
3225
3249
|
}
|
|
3226
3250
|
for (const workflowFile of sourceWorkflowFiles) {
|
|
3227
|
-
const srcPath =
|
|
3228
|
-
const destPath =
|
|
3251
|
+
const srcPath = join7(workflowsDir, workflowFile);
|
|
3252
|
+
const destPath = join7(destWorkflowsDir, workflowFile);
|
|
3229
3253
|
const srcContent = readFileSync5(srcPath, "utf-8");
|
|
3230
3254
|
try {
|
|
3231
3255
|
if (existsSync4(destPath) && readFileSync5(destPath, "utf-8") === srcContent)
|
|
@@ -3233,12 +3257,12 @@ function deployArtifactsToProject(codeName, provisionDir) {
|
|
|
3233
3257
|
} catch {
|
|
3234
3258
|
}
|
|
3235
3259
|
mkdirSync4(destWorkflowsDir, { recursive: true });
|
|
3236
|
-
|
|
3260
|
+
writeFileSync6(destPath, srcContent);
|
|
3237
3261
|
}
|
|
3238
3262
|
} catch {
|
|
3239
3263
|
}
|
|
3240
|
-
const agentMcpPath =
|
|
3241
|
-
const projectMcpPath =
|
|
3264
|
+
const agentMcpPath = join7(getAgentDir(codeName), "provision", ".mcp.json");
|
|
3265
|
+
const projectMcpPath = join7(projectDir, ".mcp.json");
|
|
3242
3266
|
try {
|
|
3243
3267
|
const agentMcp = JSON.parse(readFileSync5(agentMcpPath, "utf-8"));
|
|
3244
3268
|
let projectMcp;
|
|
@@ -3254,7 +3278,7 @@ function deployArtifactsToProject(codeName, provisionDir) {
|
|
|
3254
3278
|
return !(entry && typeof entry["url"] === "string" && entry["url"].startsWith("/"));
|
|
3255
3279
|
}));
|
|
3256
3280
|
projectMcp["mcpServers"] = { ...stripRelativeUrls(projectServers), ...stripRelativeUrls(agentServers) };
|
|
3257
|
-
|
|
3281
|
+
writeFileSync6(projectMcpPath, JSON.stringify(projectMcp, null, 2), { mode: MCP_FILE_MODE });
|
|
3258
3282
|
try {
|
|
3259
3283
|
chmodSync4(projectMcpPath, MCP_FILE_MODE);
|
|
3260
3284
|
} catch {
|
|
@@ -3264,9 +3288,9 @@ function deployArtifactsToProject(codeName, provisionDir) {
|
|
|
3264
3288
|
const agentDir = getAgentDir(codeName);
|
|
3265
3289
|
for (const envFile of [".env", ".env.integrations"]) {
|
|
3266
3290
|
try {
|
|
3267
|
-
const content = readFileSync5(
|
|
3268
|
-
const envDest =
|
|
3269
|
-
|
|
3291
|
+
const content = readFileSync5(join7(agentDir, envFile), "utf-8");
|
|
3292
|
+
const envDest = join7(projectDir, envFile);
|
|
3293
|
+
writeFileSync6(envDest, content, { mode: SECRET_FILE_MODE });
|
|
3270
3294
|
try {
|
|
3271
3295
|
chmodSync4(envDest, SECRET_FILE_MODE);
|
|
3272
3296
|
} catch {
|
|
@@ -3275,16 +3299,16 @@ function deployArtifactsToProject(codeName, provisionDir) {
|
|
|
3275
3299
|
}
|
|
3276
3300
|
}
|
|
3277
3301
|
try {
|
|
3278
|
-
const gitDir =
|
|
3279
|
-
const hookSrc =
|
|
3302
|
+
const gitDir = join7(projectDir, ".git");
|
|
3303
|
+
const hookSrc = join7(provisionDir, ".git-hooks", "pre-commit");
|
|
3280
3304
|
if (existsSync4(gitDir) && existsSync4(hookSrc)) {
|
|
3281
|
-
const hooksDir =
|
|
3305
|
+
const hooksDir = join7(gitDir, "hooks");
|
|
3282
3306
|
mkdirSync4(hooksDir, { recursive: true });
|
|
3283
|
-
const hookDest =
|
|
3307
|
+
const hookDest = join7(hooksDir, "pre-commit");
|
|
3284
3308
|
const srcContent = readFileSync5(hookSrc, "utf-8");
|
|
3285
3309
|
const upToDate = existsSync4(hookDest) && readFileSync5(hookDest, "utf-8") === srcContent;
|
|
3286
3310
|
if (!upToDate)
|
|
3287
|
-
|
|
3311
|
+
writeExecutableAtomic(hookDest, srcContent, 493);
|
|
3288
3312
|
chmodSync4(hookDest, 493);
|
|
3289
3313
|
}
|
|
3290
3314
|
} catch {
|
|
@@ -3292,9 +3316,9 @@ function deployArtifactsToProject(codeName, provisionDir) {
|
|
|
3292
3316
|
}
|
|
3293
3317
|
function provisionStopHook(codeName) {
|
|
3294
3318
|
const projectDir = getProjectDir2(codeName);
|
|
3295
|
-
const claudeDir =
|
|
3319
|
+
const claudeDir = join7(projectDir, ".claude");
|
|
3296
3320
|
mkdirSync4(claudeDir, { recursive: true });
|
|
3297
|
-
const hookScriptPath =
|
|
3321
|
+
const hookScriptPath = join7(claudeDir, "agt-stop-hook.sh");
|
|
3298
3322
|
const hookScript = [
|
|
3299
3323
|
"#!/bin/bash",
|
|
3300
3324
|
"# Auto-generated by Augmented \u2014 captures persistent session task results.",
|
|
@@ -3338,8 +3362,8 @@ function provisionStopHook(codeName) {
|
|
|
3338
3362
|
"esac",
|
|
3339
3363
|
"exit 0"
|
|
3340
3364
|
].join("\n") + "\n";
|
|
3341
|
-
|
|
3342
|
-
const ghostHookPath =
|
|
3365
|
+
writeExecutableAtomic(hookScriptPath, hookScript, 493);
|
|
3366
|
+
const ghostHookPath = join7(claudeDir, "agt-ghost-reply-hook.sh");
|
|
3343
3367
|
const jqNormalizeContent = '(.message.content // .content // []) | if type == "string" then [{type: "text", text: .}] elif type == "array" then . else [] end';
|
|
3344
3368
|
const ghostHookScript = [
|
|
3345
3369
|
"#!/bin/bash",
|
|
@@ -4310,9 +4334,9 @@ function provisionStopHook(codeName) {
|
|
|
4310
4334
|
"fi",
|
|
4311
4335
|
"exit 0"
|
|
4312
4336
|
].join("\n") + "\n";
|
|
4313
|
-
|
|
4337
|
+
writeExecutableAtomic(ghostHookPath, ghostHookScript, 493);
|
|
4314
4338
|
const backlogHookPath = provisionBacklogPullHook(codeName);
|
|
4315
|
-
const settingsPath =
|
|
4339
|
+
const settingsPath = join7(claudeDir, "settings.local.json");
|
|
4316
4340
|
let settings = {};
|
|
4317
4341
|
try {
|
|
4318
4342
|
settings = JSON.parse(readFileSync5(settingsPath, "utf-8"));
|
|
@@ -4329,29 +4353,29 @@ function provisionStopHook(codeName) {
|
|
|
4329
4353
|
}
|
|
4330
4354
|
];
|
|
4331
4355
|
settings["hooks"] = hooks;
|
|
4332
|
-
|
|
4356
|
+
writeFileSync6(settingsPath, JSON.stringify(settings, null, 2));
|
|
4333
4357
|
}
|
|
4334
4358
|
function provisionIsolationHook(codeName, agentId) {
|
|
4335
4359
|
const homeDir = getHomeDir();
|
|
4336
|
-
const augmentedBase =
|
|
4360
|
+
const augmentedBase = join7(homeDir, ".augmented");
|
|
4337
4361
|
if (/["'$`\\\n]/.test(augmentedBase)) {
|
|
4338
4362
|
throw new Error(`provisionIsolationHook: home directory contains shell metacharacters: ${JSON.stringify(augmentedBase)}`);
|
|
4339
4363
|
}
|
|
4340
4364
|
const projectDir = getProjectDir2(codeName);
|
|
4341
|
-
const claudeDir =
|
|
4365
|
+
const claudeDir = join7(projectDir, ".claude");
|
|
4342
4366
|
mkdirSync4(claudeDir, { recursive: true });
|
|
4343
4367
|
const hasAgentId = agentId !== void 0;
|
|
4344
4368
|
if (hasAgentId)
|
|
4345
4369
|
assertValidAgentId(agentId);
|
|
4346
4370
|
const augmentedBaseRe = augmentedBase.replace(/[.[\]()*+?{}|^$]/g, "\\$&");
|
|
4347
|
-
const claudeProjectsBase =
|
|
4371
|
+
const claudeProjectsBase = join7(homeDir, ".claude", "projects");
|
|
4348
4372
|
const claudeProjectsBaseRe = claudeProjectsBase.replace(/[.[\]()*+?{}|^$]/g, "\\$&");
|
|
4349
4373
|
const mangledBase = augmentedBase.replace(/[^a-zA-Z0-9]/g, "-");
|
|
4350
4374
|
const ownAgentDir = getAgentDir(codeName);
|
|
4351
|
-
const logFile =
|
|
4375
|
+
const logFile = join7(ownAgentDir, "isolation.log");
|
|
4352
4376
|
const idAllowClause = hasAgentId ? ` && [ "$AGENT_DIR" != "${agentId}" ]` : "";
|
|
4353
4377
|
const idAllowClause2 = hasAgentId ? ` || [ "$OWNER" = "${agentId}" ]` : "";
|
|
4354
|
-
const hookScriptPath =
|
|
4378
|
+
const hookScriptPath = join7(claudeDir, "agt-isolation-hook.sh");
|
|
4355
4379
|
const hookScript = [
|
|
4356
4380
|
"#!/bin/bash",
|
|
4357
4381
|
"# Auto-generated by Augmented.",
|
|
@@ -4626,8 +4650,8 @@ function provisionIsolationHook(codeName, agentId) {
|
|
|
4626
4650
|
"",
|
|
4627
4651
|
"exit 0"
|
|
4628
4652
|
].join("\n") + "\n";
|
|
4629
|
-
|
|
4630
|
-
const settingsPath =
|
|
4653
|
+
writeExecutableAtomic(hookScriptPath, hookScript, 493);
|
|
4654
|
+
const settingsPath = join7(claudeDir, "settings.local.json");
|
|
4631
4655
|
let settings = {};
|
|
4632
4656
|
try {
|
|
4633
4657
|
settings = JSON.parse(readFileSync5(settingsPath, "utf-8"));
|
|
@@ -4645,13 +4669,13 @@ function provisionIsolationHook(codeName, agentId) {
|
|
|
4645
4669
|
}
|
|
4646
4670
|
];
|
|
4647
4671
|
settings["hooks"] = hooks;
|
|
4648
|
-
|
|
4672
|
+
writeFileSync6(settingsPath, JSON.stringify(settings, null, 2));
|
|
4649
4673
|
}
|
|
4650
4674
|
function provisionBacklogPullHook(codeName) {
|
|
4651
4675
|
const projectDir = getProjectDir2(codeName);
|
|
4652
|
-
const claudeDir =
|
|
4676
|
+
const claudeDir = join7(projectDir, ".claude");
|
|
4653
4677
|
mkdirSync4(claudeDir, { recursive: true });
|
|
4654
|
-
const hookScriptPath =
|
|
4678
|
+
const hookScriptPath = join7(claudeDir, "agt-backlog-pull-hook.sh");
|
|
4655
4679
|
const hookScript = `#!/usr/bin/env bash
|
|
4656
4680
|
# Auto-generated by Augmented (CS-1549) \u2014 Stop hook: don't end a turn idle
|
|
4657
4681
|
# beside a non-empty backlog. Fail-open on every path; blocks at most once per
|
|
@@ -4822,14 +4846,14 @@ If you genuinely should not pull it, say so in one line and why (it is deliberat
|
|
|
4822
4846
|
jq -cn --arg r "$REASON" '{decision:"block", reason:$r}'
|
|
4823
4847
|
exit 0
|
|
4824
4848
|
`;
|
|
4825
|
-
|
|
4849
|
+
writeExecutableAtomic(hookScriptPath, hookScript, 493);
|
|
4826
4850
|
return hookScriptPath;
|
|
4827
4851
|
}
|
|
4828
4852
|
function provisionAutoKanbanProgressHook(codeName) {
|
|
4829
4853
|
const projectDir = getProjectDir2(codeName);
|
|
4830
|
-
const claudeDir =
|
|
4854
|
+
const claudeDir = join7(projectDir, ".claude");
|
|
4831
4855
|
mkdirSync4(claudeDir, { recursive: true });
|
|
4832
|
-
const hookScriptPath =
|
|
4856
|
+
const hookScriptPath = join7(claudeDir, "agt-auto-kanban-progress-hook.sh");
|
|
4833
4857
|
const hookScript = `#!/usr/bin/env bash
|
|
4834
4858
|
# Auto-generated by Augmented (ENG-6179 / ENG-6241) \u2014 PostToolUse auto-progress.
|
|
4835
4859
|
# Maps the agent's latest tool action onto its active in-thread kanban progress
|
|
@@ -4944,8 +4968,8 @@ BODY="$(jq -nc --arg a "$AGENT_ID" --arg s "$STEP" '{agent_id:$a, step:$s}' 2>/d
|
|
|
4944
4968
|
|
|
4945
4969
|
exit 0
|
|
4946
4970
|
`;
|
|
4947
|
-
|
|
4948
|
-
const settingsPath =
|
|
4971
|
+
writeExecutableAtomic(hookScriptPath, hookScript, 493);
|
|
4972
|
+
const settingsPath = join7(claudeDir, "settings.local.json");
|
|
4949
4973
|
let settings = {};
|
|
4950
4974
|
try {
|
|
4951
4975
|
settings = JSON.parse(readFileSync5(settingsPath, "utf-8"));
|
|
@@ -4960,13 +4984,13 @@ exit 0
|
|
|
4960
4984
|
}
|
|
4961
4985
|
];
|
|
4962
4986
|
settings["hooks"] = hooks;
|
|
4963
|
-
|
|
4987
|
+
writeFileSync6(settingsPath, JSON.stringify(settings, null, 2));
|
|
4964
4988
|
}
|
|
4965
4989
|
function provisionChannelProgressHook(codeName) {
|
|
4966
4990
|
const projectDir = getProjectDir2(codeName);
|
|
4967
|
-
const claudeDir =
|
|
4991
|
+
const claudeDir = join7(projectDir, ".claude");
|
|
4968
4992
|
mkdirSync4(claudeDir, { recursive: true });
|
|
4969
|
-
const hookScriptPath =
|
|
4993
|
+
const hookScriptPath = join7(claudeDir, "agt-channel-progress-hook.sh");
|
|
4970
4994
|
const hookScript = `#!/usr/bin/env bash
|
|
4971
4995
|
# Auto-generated by Augmented (ENG-6567 Phase 2) \u2014 PostToolUse channel-progress
|
|
4972
4996
|
# heartbeat. Writes a throttled local {step, updated_at_ms} the channel MCP reads
|
|
@@ -5032,8 +5056,8 @@ else
|
|
|
5032
5056
|
fi
|
|
5033
5057
|
exit 0
|
|
5034
5058
|
`;
|
|
5035
|
-
|
|
5036
|
-
const settingsPath =
|
|
5059
|
+
writeExecutableAtomic(hookScriptPath, hookScript, 493);
|
|
5060
|
+
const settingsPath = join7(claudeDir, "settings.local.json");
|
|
5037
5061
|
let settings = {};
|
|
5038
5062
|
try {
|
|
5039
5063
|
settings = JSON.parse(readFileSync5(settingsPath, "utf-8"));
|
|
@@ -5052,7 +5076,7 @@ exit 0
|
|
|
5052
5076
|
}
|
|
5053
5077
|
hooks["PostToolUse"] = groups;
|
|
5054
5078
|
settings["hooks"] = hooks;
|
|
5055
|
-
|
|
5079
|
+
writeFileSync6(settingsPath, JSON.stringify(settings, null, 2));
|
|
5056
5080
|
}
|
|
5057
5081
|
var LONG_COMMAND_BOUNDED_TIMEOUT_MS = 12e4;
|
|
5058
5082
|
var LONG_COMMAND_HOOK_FILENAME = "agt-long-command-hook.sh";
|
|
@@ -5417,15 +5441,15 @@ function classifyCommand(words0, loop, depth) {
|
|
|
5417
5441
|
`;
|
|
5418
5442
|
var LONG_COMMAND_MAX_FOREGROUND_TIMEOUT_MS = 18e4;
|
|
5419
5443
|
function provisionRootRmHook(codeName) {
|
|
5420
|
-
provisionRootRmHookAt(
|
|
5444
|
+
provisionRootRmHookAt(join7(getProjectDir2(codeName), ".claude"));
|
|
5421
5445
|
}
|
|
5422
5446
|
function provisionLongCommandHook(codeName) {
|
|
5423
5447
|
const projectDir = getProjectDir2(codeName);
|
|
5424
|
-
const claudeDir =
|
|
5448
|
+
const claudeDir = join7(projectDir, ".claude");
|
|
5425
5449
|
mkdirSync4(claudeDir, { recursive: true });
|
|
5426
|
-
const hookScriptPath =
|
|
5427
|
-
const jsPath =
|
|
5428
|
-
|
|
5450
|
+
const hookScriptPath = join7(claudeDir, LONG_COMMAND_HOOK_FILENAME);
|
|
5451
|
+
const jsPath = join7(claudeDir, LONG_COMMAND_HOOK_JS_FILENAME);
|
|
5452
|
+
writeExecutableAtomic(jsPath, LONG_COMMAND_HOOK_JS.replace("__BOUND__", String(LONG_COMMAND_BOUNDED_TIMEOUT_MS)), 420);
|
|
5429
5453
|
const hookScript = [
|
|
5430
5454
|
"#!/usr/bin/env bash",
|
|
5431
5455
|
"# ENG-11393: refuse known-slow foreground shell commands; see index.ts.",
|
|
@@ -5433,8 +5457,8 @@ function provisionLongCommandHook(codeName) {
|
|
|
5433
5457
|
"command -v node >/dev/null 2>&1 || exit 0",
|
|
5434
5458
|
`exec node '${jsPath.replace(/'/g, `'\\''`)}'`
|
|
5435
5459
|
].join("\n") + "\n";
|
|
5436
|
-
|
|
5437
|
-
const settingsPath =
|
|
5460
|
+
writeExecutableAtomic(hookScriptPath, hookScript, 493);
|
|
5461
|
+
const settingsPath = join7(claudeDir, "settings.local.json");
|
|
5438
5462
|
let settings = {};
|
|
5439
5463
|
try {
|
|
5440
5464
|
settings = JSON.parse(readFileSync5(settingsPath, "utf-8"));
|
|
@@ -5451,15 +5475,15 @@ function provisionLongCommandHook(codeName) {
|
|
|
5451
5475
|
const env = settings["env"] ?? {};
|
|
5452
5476
|
env["BASH_MAX_TIMEOUT_MS"] = String(LONG_COMMAND_MAX_FOREGROUND_TIMEOUT_MS);
|
|
5453
5477
|
settings["env"] = env;
|
|
5454
|
-
|
|
5478
|
+
writeFileSync6(settingsPath, JSON.stringify(settings, null, 2));
|
|
5455
5479
|
}
|
|
5456
5480
|
function provisionOrientHook(codeName) {
|
|
5457
5481
|
const projectDir = getProjectDir2(codeName);
|
|
5458
|
-
const claudeDir =
|
|
5482
|
+
const claudeDir = join7(projectDir, ".claude");
|
|
5459
5483
|
mkdirSync4(claudeDir, { recursive: true });
|
|
5460
5484
|
const agentDir = getAgentDir(codeName);
|
|
5461
|
-
const codeRoots = [
|
|
5462
|
-
const hookScriptPath =
|
|
5485
|
+
const codeRoots = [join7(getHomeDir(), "code"), join7(agentDir, "code")];
|
|
5486
|
+
const hookScriptPath = join7(claudeDir, "agt-orient-hook.sh");
|
|
5463
5487
|
const hookScript = [
|
|
5464
5488
|
"#!/bin/bash",
|
|
5465
5489
|
"# Auto-generated by Augmented (ENG-5397) \u2014 SessionStart orientation hook.",
|
|
@@ -5731,8 +5755,8 @@ function provisionOrientHook(codeName) {
|
|
|
5731
5755
|
"fi",
|
|
5732
5756
|
"exit 0"
|
|
5733
5757
|
].join("\n") + "\n";
|
|
5734
|
-
|
|
5735
|
-
const settingsPath =
|
|
5758
|
+
writeExecutableAtomic(hookScriptPath, hookScript, 493);
|
|
5759
|
+
const settingsPath = join7(claudeDir, "settings.local.json");
|
|
5736
5760
|
let settings = {};
|
|
5737
5761
|
try {
|
|
5738
5762
|
settings = JSON.parse(readFileSync5(settingsPath, "utf-8"));
|
|
@@ -5755,15 +5779,15 @@ function provisionOrientHook(codeName) {
|
|
|
5755
5779
|
}
|
|
5756
5780
|
hooks["SessionStart"] = existingSessionStart;
|
|
5757
5781
|
settings["hooks"] = hooks;
|
|
5758
|
-
|
|
5782
|
+
writeFileSync6(settingsPath, JSON.stringify(settings, null, 2));
|
|
5759
5783
|
}
|
|
5760
5784
|
function provisionPreCompactHook(codeName) {
|
|
5761
5785
|
const projectDir = getProjectDir2(codeName);
|
|
5762
|
-
const claudeDir =
|
|
5786
|
+
const claudeDir = join7(projectDir, ".claude");
|
|
5763
5787
|
mkdirSync4(claudeDir, { recursive: true });
|
|
5764
5788
|
const agentDir = getAgentDir(codeName);
|
|
5765
5789
|
const jqNormalizeContent = '(.message.content // .content // []) | if type == "string" then [{type: "text", text: .}] elif type == "array" then . else [] end';
|
|
5766
|
-
const hookScriptPath =
|
|
5790
|
+
const hookScriptPath = join7(claudeDir, "agt-pre-compact-hook.sh");
|
|
5767
5791
|
const hookScript = [
|
|
5768
5792
|
"#!/bin/bash",
|
|
5769
5793
|
"# Auto-generated by Augmented (ENG-7339) - PreCompact courtesy notice.",
|
|
@@ -5867,9 +5891,8 @@ function provisionPreCompactHook(codeName) {
|
|
|
5867
5891
|
'if [ "$WROTE" = "1" ]; then date +%s > "$NOTICE_MARKER" 2>/dev/null || true; fi',
|
|
5868
5892
|
"exit 0"
|
|
5869
5893
|
].join("\n") + "\n";
|
|
5870
|
-
|
|
5871
|
-
|
|
5872
|
-
const settingsPath = join6(claudeDir, "settings.local.json");
|
|
5894
|
+
writeExecutableAtomic(hookScriptPath, hookScript, 493);
|
|
5895
|
+
const settingsPath = join7(claudeDir, "settings.local.json");
|
|
5873
5896
|
let settings = {};
|
|
5874
5897
|
try {
|
|
5875
5898
|
settings = JSON.parse(readFileSync5(settingsPath, "utf-8"));
|
|
@@ -5892,14 +5915,14 @@ function provisionPreCompactHook(codeName) {
|
|
|
5892
5915
|
}
|
|
5893
5916
|
hooks["PreCompact"] = existingPreCompact;
|
|
5894
5917
|
settings["hooks"] = hooks;
|
|
5895
|
-
|
|
5918
|
+
writeFileSync6(settingsPath, JSON.stringify(settings, null, 2));
|
|
5896
5919
|
}
|
|
5897
5920
|
function provisionSessionStateHook(codeName) {
|
|
5898
5921
|
const projectDir = getProjectDir2(codeName);
|
|
5899
|
-
const claudeDir =
|
|
5922
|
+
const claudeDir = join7(projectDir, ".claude");
|
|
5900
5923
|
mkdirSync4(claudeDir, { recursive: true });
|
|
5901
5924
|
const agentDir = getAgentDir(codeName);
|
|
5902
|
-
const hookScriptPath =
|
|
5925
|
+
const hookScriptPath = join7(claudeDir, "agt-session-state-hook.sh");
|
|
5903
5926
|
const hookScript = `#!/usr/bin/env bash
|
|
5904
5927
|
# Auto-generated by Augmented (ENG-6233 / ENG-6268) \u2014 SessionStart session-state
|
|
5905
5928
|
# recorder. Writes the model + session origin (which only the agent's own
|
|
@@ -5976,8 +5999,8 @@ fi
|
|
|
5976
5999
|
|
|
5977
6000
|
exit 0
|
|
5978
6001
|
`;
|
|
5979
|
-
|
|
5980
|
-
const settingsPath =
|
|
6002
|
+
writeExecutableAtomic(hookScriptPath, hookScript, 493);
|
|
6003
|
+
const settingsPath = join7(claudeDir, "settings.local.json");
|
|
5981
6004
|
let settings = {};
|
|
5982
6005
|
try {
|
|
5983
6006
|
settings = JSON.parse(readFileSync5(settingsPath, "utf-8"));
|
|
@@ -5996,7 +6019,7 @@ exit 0
|
|
|
5996
6019
|
}
|
|
5997
6020
|
hooks["SessionStart"] = existingSessionStart;
|
|
5998
6021
|
settings["hooks"] = hooks;
|
|
5999
|
-
|
|
6022
|
+
writeFileSync6(settingsPath, JSON.stringify(settings, null, 2));
|
|
6000
6023
|
}
|
|
6001
6024
|
function modifyJsonConfig(filePath, fn) {
|
|
6002
6025
|
let originalContent;
|
|
@@ -6013,7 +6036,7 @@ function modifyJsonConfig(filePath, fn) {
|
|
|
6013
6036
|
const newContent = JSON.stringify(config, null, 2);
|
|
6014
6037
|
if (newContent === originalContent)
|
|
6015
6038
|
return;
|
|
6016
|
-
|
|
6039
|
+
writeFileSync6(filePath, newContent);
|
|
6017
6040
|
}
|
|
6018
6041
|
var SUBAGENT_BUILTIN_TOOLS = [
|
|
6019
6042
|
"Bash",
|
|
@@ -6099,7 +6122,7 @@ function buildSettingsJson(input) {
|
|
|
6099
6122
|
const projectDir = getProjectDir2(agent.code_name);
|
|
6100
6123
|
const agentDir = getAgentDir(agent.code_name);
|
|
6101
6124
|
const homeDir = getHomeDir();
|
|
6102
|
-
const codenameAliasDir =
|
|
6125
|
+
const codenameAliasDir = join7(homeDir, ".augmented", agent.code_name);
|
|
6103
6126
|
settings["allowedDirectories"] = [
|
|
6104
6127
|
.../* @__PURE__ */ new Set([
|
|
6105
6128
|
projectDir,
|
|
@@ -6108,7 +6131,7 @@ function buildSettingsJson(input) {
|
|
|
6108
6131
|
// Agent's config dir (.env, schedules, registration)
|
|
6109
6132
|
codenameAliasDir,
|
|
6110
6133
|
// Codename symlink alias (== agentDir for legacy agents)
|
|
6111
|
-
|
|
6134
|
+
join7(homeDir, ".augmented", "_mcp"),
|
|
6112
6135
|
// Shared MCP binaries
|
|
6113
6136
|
"/tmp"
|
|
6114
6137
|
// Temp files
|
|
@@ -6208,7 +6231,7 @@ ${integrationsBlock}`;
|
|
|
6208
6231
|
function renderAugmentedWorkerForAgent(codeName) {
|
|
6209
6232
|
const agentDir = getAgentDir(codeName);
|
|
6210
6233
|
const projectDir = getProjectDir2(codeName);
|
|
6211
|
-
const provisionMcpPath =
|
|
6234
|
+
const provisionMcpPath = join7(agentDir, "provision", ".mcp.json");
|
|
6212
6235
|
let mcpServerKeys;
|
|
6213
6236
|
try {
|
|
6214
6237
|
const config = JSON.parse(readFileSync5(provisionMcpPath, "utf-8"));
|
|
@@ -6219,10 +6242,10 @@ function renderAugmentedWorkerForAgent(codeName) {
|
|
|
6219
6242
|
const integrations = readIntegrationsSummaryForAgent(codeName);
|
|
6220
6243
|
const content = buildAugmentedWorkerAgent({ mcpServerKeys, integrations });
|
|
6221
6244
|
for (const baseDir of [agentDir, projectDir]) {
|
|
6222
|
-
const target =
|
|
6245
|
+
const target = join7(baseDir, ".claude", "agents", "augmented-worker.md");
|
|
6223
6246
|
try {
|
|
6224
|
-
mkdirSync4(
|
|
6225
|
-
|
|
6247
|
+
mkdirSync4(dirname4(target), { recursive: true });
|
|
6248
|
+
writeFileSync6(target, content);
|
|
6226
6249
|
} catch {
|
|
6227
6250
|
}
|
|
6228
6251
|
}
|
|
@@ -6248,8 +6271,8 @@ function buildPostizMcpEntry(integration) {
|
|
|
6248
6271
|
}
|
|
6249
6272
|
function buildMcpJson(input) {
|
|
6250
6273
|
const mcpServers = {};
|
|
6251
|
-
const turnInitiatorFile =
|
|
6252
|
-
const localMcpPath =
|
|
6274
|
+
const turnInitiatorFile = join7(getAgentDir(input.agent.code_name), ".current-turn-initiator.json");
|
|
6275
|
+
const localMcpPath = join7(getHomeDir(), ".augmented", "_mcp", "index.js");
|
|
6253
6276
|
mcpServers["augmented"] = {
|
|
6254
6277
|
command: "node",
|
|
6255
6278
|
args: [localMcpPath],
|
|
@@ -6302,7 +6325,7 @@ function buildMcpJson(input) {
|
|
|
6302
6325
|
const xeroIntegration = input.integrations?.find((i) => i.definition_id === "xero");
|
|
6303
6326
|
if (xeroIntegration) {
|
|
6304
6327
|
const brokerMode = Boolean(xeroIntegration.id);
|
|
6305
|
-
const localXeroMcpPath =
|
|
6328
|
+
const localXeroMcpPath = join7(getHomeDir(), ".augmented", "_mcp", "xero.js");
|
|
6306
6329
|
mcpServers["xero"] = {
|
|
6307
6330
|
command: "node",
|
|
6308
6331
|
args: [localXeroMcpPath],
|
|
@@ -6342,7 +6365,7 @@ function buildMcpJson(input) {
|
|
|
6342
6365
|
// getProjectDir (the ADR-0049 seam), not the MCP child's inherited
|
|
6343
6366
|
// cwd, so the path stays correct if Claude Code ever spawns the
|
|
6344
6367
|
// server from somewhere else.
|
|
6345
|
-
XERO_EXPORT_DIR:
|
|
6368
|
+
XERO_EXPORT_DIR: join7(getProjectDir2(input.agent.code_name), "xero-exports"),
|
|
6346
6369
|
PATH: process.env["PATH"] ?? "",
|
|
6347
6370
|
HOME: process.env["HOME"] ?? ""
|
|
6348
6371
|
}
|
|
@@ -6353,8 +6376,8 @@ function buildMcpJson(input) {
|
|
|
6353
6376
|
mcpServers["postiz"] = buildPostizMcpEntry(postizIntegration);
|
|
6354
6377
|
}
|
|
6355
6378
|
const remoteOAuthProxyPaths = {
|
|
6356
|
-
proxyPath:
|
|
6357
|
-
tokenFile:
|
|
6379
|
+
proxyPath: join7(getHomeDir(), ".augmented", "_mcp", "remote-oauth-proxy.js"),
|
|
6380
|
+
tokenFile: join7(getProjectDir2(input.agent.code_name), ".env.integrations")
|
|
6358
6381
|
};
|
|
6359
6382
|
for (const integration of input.integrations ?? []) {
|
|
6360
6383
|
const connectionKey = integration.connection_key;
|
|
@@ -6440,7 +6463,7 @@ function buildMcpJson(input) {
|
|
|
6440
6463
|
}
|
|
6441
6464
|
const hasAdminDebug = input.integrations?.some((i) => i.definition_id === "augmented-admin") ?? false;
|
|
6442
6465
|
if (hasAdminDebug) {
|
|
6443
|
-
const localAdminMcpPath =
|
|
6466
|
+
const localAdminMcpPath = join7(getHomeDir(), ".augmented", "_mcp", "augmented-admin.js");
|
|
6444
6467
|
mcpServers["augmented-admin"] = {
|
|
6445
6468
|
command: "node",
|
|
6446
6469
|
args: [localAdminMcpPath],
|
|
@@ -6454,7 +6477,7 @@ function buildMcpJson(input) {
|
|
|
6454
6477
|
}
|
|
6455
6478
|
const hasSupport = input.integrations?.some((i) => i.definition_id === "augmented-support") ?? false;
|
|
6456
6479
|
if (hasSupport) {
|
|
6457
|
-
const localSupportMcpPath =
|
|
6480
|
+
const localSupportMcpPath = join7(getHomeDir(), ".augmented", "_mcp", "augmented-support.js");
|
|
6458
6481
|
mcpServers["augmented-support"] = {
|
|
6459
6482
|
command: "node",
|
|
6460
6483
|
args: [localSupportMcpPath],
|
|
@@ -6468,7 +6491,7 @@ function buildMcpJson(input) {
|
|
|
6468
6491
|
}
|
|
6469
6492
|
const hasHelpKb = input.integrations?.some((i) => i.definition_id === "augmented-help-kb") ?? false;
|
|
6470
6493
|
if (hasHelpKb) {
|
|
6471
|
-
const localHelpKbMcpPath =
|
|
6494
|
+
const localHelpKbMcpPath = join7(getHomeDir(), ".augmented", "_mcp", "augmented-help-kb.js");
|
|
6472
6495
|
mcpServers["augmented-help-kb"] = {
|
|
6473
6496
|
command: "node",
|
|
6474
6497
|
args: [localHelpKbMcpPath],
|
|
@@ -6482,7 +6505,7 @@ function buildMcpJson(input) {
|
|
|
6482
6505
|
}
|
|
6483
6506
|
const origamiIntegration = input.integrations?.find((i) => i.definition_id === "origami");
|
|
6484
6507
|
if (origamiIntegration?.stdioMcp === true && origamiIntegration.id) {
|
|
6485
|
-
const localOrigamiMcpPath =
|
|
6508
|
+
const localOrigamiMcpPath = join7(getHomeDir(), ".augmented", "_mcp", "origami.js");
|
|
6486
6509
|
mcpServers["origami"] = {
|
|
6487
6510
|
command: "node",
|
|
6488
6511
|
args: [localOrigamiMcpPath],
|
|
@@ -6501,7 +6524,7 @@ function buildMcpJson(input) {
|
|
|
6501
6524
|
agentId: input.agent.agent_id,
|
|
6502
6525
|
agentCodeName: input.agent.code_name,
|
|
6503
6526
|
config: computerUseIntegration.config,
|
|
6504
|
-
proxyPath:
|
|
6527
|
+
proxyPath: join7(getHomeDir(), ".augmented", "_mcp", "computer-use-proxy.js"),
|
|
6505
6528
|
agentDir: getAgentDir(input.agent.code_name)
|
|
6506
6529
|
});
|
|
6507
6530
|
if (rendered.entry) {
|
|
@@ -6751,14 +6774,14 @@ ${sections}`
|
|
|
6751
6774
|
},
|
|
6752
6775
|
async getRegisteredAgents(_profile) {
|
|
6753
6776
|
const homeDir = getHomeDir();
|
|
6754
|
-
const augDir =
|
|
6777
|
+
const augDir = join7(homeDir, ".augmented");
|
|
6755
6778
|
const agents = /* @__PURE__ */ new Set();
|
|
6756
6779
|
try {
|
|
6757
6780
|
const entries = readdirSync(augDir);
|
|
6758
6781
|
for (const entry of entries) {
|
|
6759
6782
|
if (entry.startsWith("_") || entry.startsWith("."))
|
|
6760
6783
|
continue;
|
|
6761
|
-
const agentRoot =
|
|
6784
|
+
const agentRoot = join7(augDir, entry);
|
|
6762
6785
|
let st;
|
|
6763
6786
|
try {
|
|
6764
6787
|
st = lstatSync2(agentRoot);
|
|
@@ -6767,11 +6790,11 @@ ${sections}`
|
|
|
6767
6790
|
}
|
|
6768
6791
|
if (st.isSymbolicLink() || !st.isDirectory())
|
|
6769
6792
|
continue;
|
|
6770
|
-
if (!existsSync4(
|
|
6793
|
+
if (!existsSync4(join7(agentRoot, "registration.json")))
|
|
6771
6794
|
continue;
|
|
6772
6795
|
let codeName = entry;
|
|
6773
6796
|
try {
|
|
6774
|
-
const reg = JSON.parse(readFileSync5(
|
|
6797
|
+
const reg = JSON.parse(readFileSync5(join7(agentRoot, "registration.json"), "utf8"));
|
|
6775
6798
|
if (reg && typeof reg.code_name === "string" && reg.code_name) {
|
|
6776
6799
|
codeName = reg.code_name;
|
|
6777
6800
|
}
|
|
@@ -6792,7 +6815,7 @@ ${sections}`
|
|
|
6792
6815
|
const projectDir = getProjectDir2(codeName);
|
|
6793
6816
|
mkdirSync4(agentDir, { recursive: true });
|
|
6794
6817
|
mkdirSync4(projectDir, { recursive: true });
|
|
6795
|
-
|
|
6818
|
+
writeFileSync6(join7(agentDir, "registration.json"), JSON.stringify({
|
|
6796
6819
|
code_name: codeName,
|
|
6797
6820
|
agent_id: agentId ?? null,
|
|
6798
6821
|
team_dir: teamDir,
|
|
@@ -6811,10 +6834,10 @@ ${sections}`
|
|
|
6811
6834
|
async deregisterAgent(codeName) {
|
|
6812
6835
|
try {
|
|
6813
6836
|
const agentDir = getAgentDir(codeName);
|
|
6814
|
-
const regFile =
|
|
6837
|
+
const regFile = join7(agentDir, "registration.json");
|
|
6815
6838
|
if (existsSync4(regFile)) {
|
|
6816
|
-
const { unlinkSync:
|
|
6817
|
-
|
|
6839
|
+
const { unlinkSync: unlinkSync8 } = await import("fs");
|
|
6840
|
+
unlinkSync8(regFile);
|
|
6818
6841
|
}
|
|
6819
6842
|
return true;
|
|
6820
6843
|
} catch {
|
|
@@ -6837,8 +6860,8 @@ ${sections}`
|
|
|
6837
6860
|
}
|
|
6838
6861
|
}
|
|
6839
6862
|
if (envLines.length > 1) {
|
|
6840
|
-
const envPath =
|
|
6841
|
-
|
|
6863
|
+
const envPath = join7(agentDir, ".env");
|
|
6864
|
+
writeFileSync6(envPath, envLines.join("\n") + "\n");
|
|
6842
6865
|
chmodSync4(envPath, SECRET_FILE_MODE);
|
|
6843
6866
|
}
|
|
6844
6867
|
},
|
|
@@ -6901,7 +6924,7 @@ ${sections}`
|
|
|
6901
6924
|
if (!botToken)
|
|
6902
6925
|
return missingCredentialField("bot_token");
|
|
6903
6926
|
const allowedChats = config["allowed_chats"];
|
|
6904
|
-
const localTelegramChannel =
|
|
6927
|
+
const localTelegramChannel = join7(getHomeDir(), ".augmented", "_mcp", "telegram-channel.js");
|
|
6905
6928
|
const resolvedAgtHostForTelegram = process.env["AGT_HOST"]?.trim() || "https://api.augmented.team";
|
|
6906
6929
|
const resolvedAgtApiKeyForTelegram = process.env["AGT_API_KEY"]?.trim();
|
|
6907
6930
|
writeEnvIntegrationsForAgent(codeName, {
|
|
@@ -6916,7 +6939,7 @@ ${sections}`
|
|
|
6916
6939
|
...options?.agentId ? { AGT_AGENT_ID: options.agentId } : {},
|
|
6917
6940
|
...tzEnv,
|
|
6918
6941
|
// ENG-6582 (D16): stamp the verified turn initiator for broker MCPs.
|
|
6919
|
-
AGT_TURN_INITIATOR_FILE:
|
|
6942
|
+
AGT_TURN_INITIATOR_FILE: join7(getAgentDir(codeName), ".current-turn-initiator.json")
|
|
6920
6943
|
};
|
|
6921
6944
|
if (allowedChats && allowedChats.length > 0) {
|
|
6922
6945
|
telegramEnv.TELEGRAM_ALLOWED_CHATS = allowedChats.join(",");
|
|
@@ -6991,8 +7014,8 @@ ${sections}`
|
|
|
6991
7014
|
args: [localTelegramChannel],
|
|
6992
7015
|
env: telegramEnv
|
|
6993
7016
|
};
|
|
6994
|
-
const provisionMcpPath =
|
|
6995
|
-
mkdirSync4(
|
|
7017
|
+
const provisionMcpPath = join7(agentDir, "provision", ".mcp.json");
|
|
7018
|
+
mkdirSync4(dirname4(provisionMcpPath), { recursive: true });
|
|
6996
7019
|
let mcpConfig2 = { mcpServers: {} };
|
|
6997
7020
|
try {
|
|
6998
7021
|
mcpConfig2 = JSON.parse(readFileSync5(provisionMcpPath, "utf-8"));
|
|
@@ -7009,13 +7032,13 @@ ${sections}`
|
|
|
7009
7032
|
}
|
|
7010
7033
|
if (isPersistent && (channelId === "discord" || channelId === "slack")) {
|
|
7011
7034
|
let wrotePersistentCredential = false;
|
|
7012
|
-
const channelDir =
|
|
7035
|
+
const channelDir = join7(getHomeDir(), ".claude", "channels", channelId);
|
|
7013
7036
|
if (channelId === "discord")
|
|
7014
7037
|
mkdirSync4(channelDir, { recursive: true });
|
|
7015
7038
|
if (channelId === "discord") {
|
|
7016
7039
|
const botToken = config["bot_token"];
|
|
7017
7040
|
if (botToken) {
|
|
7018
|
-
|
|
7041
|
+
writeFileSync6(join7(channelDir, ".env"), `DISCORD_BOT_TOKEN=${botToken}
|
|
7019
7042
|
`);
|
|
7020
7043
|
wrotePersistentCredential = true;
|
|
7021
7044
|
}
|
|
@@ -7079,7 +7102,7 @@ ${sections}`
|
|
|
7079
7102
|
...appToken ? { SLACK_APP_TOKEN: appToken } : {}
|
|
7080
7103
|
}, ["SLACK_BOT_TOKEN", "SLACK_APP_TOKEN"])
|
|
7081
7104
|
});
|
|
7082
|
-
const localSlackChannel =
|
|
7105
|
+
const localSlackChannel = join7(getHomeDir(), ".augmented", "_mcp", "slack-channel.js");
|
|
7083
7106
|
const slackAvatarEnvUrl = resolveAvatarEnvUrl(options?.agentAvatarUrl).url;
|
|
7084
7107
|
const slackEntry = {
|
|
7085
7108
|
command: existsSync4(localSlackChannel) ? "node" : "npx",
|
|
@@ -7174,11 +7197,11 @@ ${sections}`
|
|
|
7174
7197
|
...pingAllowedUsers.length > 0 ? { SLACK_PING_ALLOWED_USERS: pingAllowedUsers.join(",") } : {},
|
|
7175
7198
|
// ENG-6563 (D16): stamp the verified turn initiator so broker MCPs
|
|
7176
7199
|
// can forward it when the agent files an approval mid-turn.
|
|
7177
|
-
AGT_TURN_INITIATOR_FILE:
|
|
7200
|
+
AGT_TURN_INITIATOR_FILE: join7(agentDir, ".current-turn-initiator.json")
|
|
7178
7201
|
}
|
|
7179
7202
|
};
|
|
7180
|
-
const provisionMcpPath =
|
|
7181
|
-
mkdirSync4(
|
|
7203
|
+
const provisionMcpPath = join7(agentDir, "provision", ".mcp.json");
|
|
7204
|
+
mkdirSync4(dirname4(provisionMcpPath), { recursive: true });
|
|
7182
7205
|
let mcpConfig2 = { mcpServers: {} };
|
|
7183
7206
|
try {
|
|
7184
7207
|
mcpConfig2 = JSON.parse(readFileSync5(provisionMcpPath, "utf-8"));
|
|
@@ -7192,7 +7215,7 @@ ${sections}`
|
|
|
7192
7215
|
}
|
|
7193
7216
|
syncMcpToProject(codeName);
|
|
7194
7217
|
wrotePersistentCredential = true;
|
|
7195
|
-
const staleChannelsPath =
|
|
7218
|
+
const staleChannelsPath = join7(getProjectDir2(codeName), ".mcp-channels.json");
|
|
7196
7219
|
if (existsSync4(staleChannelsPath)) {
|
|
7197
7220
|
try {
|
|
7198
7221
|
rmSync2(staleChannelsPath, { force: true });
|
|
@@ -7206,8 +7229,8 @@ ${sections}`
|
|
|
7206
7229
|
}
|
|
7207
7230
|
return CHANNEL_WRITE_OK;
|
|
7208
7231
|
}
|
|
7209
|
-
const mcpJsonPath =
|
|
7210
|
-
mkdirSync4(
|
|
7232
|
+
const mcpJsonPath = join7(agentDir, "provision", ".mcp.json");
|
|
7233
|
+
mkdirSync4(dirname4(mcpJsonPath), { recursive: true });
|
|
7211
7234
|
let mcpConfig;
|
|
7212
7235
|
try {
|
|
7213
7236
|
mcpConfig = JSON.parse(readFileSync5(mcpJsonPath, "utf-8"));
|
|
@@ -7229,7 +7252,7 @@ ${sections}`
|
|
|
7229
7252
|
const appToken = config["app_token"];
|
|
7230
7253
|
if (!botToken)
|
|
7231
7254
|
return missingCredentialField("bot_token");
|
|
7232
|
-
const localSlackChannel =
|
|
7255
|
+
const localSlackChannel = join7(getHomeDir(), ".augmented", "_mcp", "slack-channel.js");
|
|
7233
7256
|
const slackThreadAutoFollow = config["thread_auto_follow"];
|
|
7234
7257
|
const slackAutoFollowEnv = slackThreadAutoFollow && slackThreadAutoFollow !== "off" ? { SLACK_THREAD_AUTO_FOLLOW: slackThreadAutoFollow } : {};
|
|
7235
7258
|
const slackChannelResponseMode = config["channel_response_mode"];
|
|
@@ -7318,7 +7341,7 @@ ${sections}`
|
|
|
7318
7341
|
...slackAgtAuthEnv,
|
|
7319
7342
|
...tzEnv,
|
|
7320
7343
|
// ENG-6563 (D16): stamp the verified turn initiator for broker MCPs.
|
|
7321
|
-
AGT_TURN_INITIATOR_FILE:
|
|
7344
|
+
AGT_TURN_INITIATOR_FILE: join7(getAgentDir(codeName), ".current-turn-initiator.json"),
|
|
7322
7345
|
// ENG-6155: avatar URL → bot Slack profile photo (see persistent
|
|
7323
7346
|
// branch above). Mirrored here so oneshot-mode agents get it too.
|
|
7324
7347
|
// ENG-6245: slackAvatarEnvUrl is null for data-URI / oversized values.
|
|
@@ -7343,7 +7366,7 @@ ${sections}`
|
|
|
7343
7366
|
...slackAgtAuthEnv,
|
|
7344
7367
|
...tzEnv,
|
|
7345
7368
|
// ENG-6563 (D16): stamp the verified turn initiator for broker MCPs.
|
|
7346
|
-
AGT_TURN_INITIATOR_FILE:
|
|
7369
|
+
AGT_TURN_INITIATOR_FILE: join7(getAgentDir(codeName), ".current-turn-initiator.json"),
|
|
7347
7370
|
// ENG-6155: avatar URL → bot Slack profile photo (see persistent
|
|
7348
7371
|
// branch above). Mirrored here so oneshot-mode agents get it too.
|
|
7349
7372
|
// ENG-6245: slackAvatarEnvUrl is null for data-URI / oversized values.
|
|
@@ -7357,12 +7380,12 @@ ${sections}`
|
|
|
7357
7380
|
if (!appId || !clientSecret) {
|
|
7358
7381
|
return missingCredentialField(!appId ? "app_id" : "client_secret");
|
|
7359
7382
|
}
|
|
7360
|
-
const localTeamsChannel =
|
|
7383
|
+
const localTeamsChannel = join7(getHomeDir(), ".augmented", "_mcp", "teams-channel.js");
|
|
7361
7384
|
const agentDirMs = getAgentDir(codeName);
|
|
7362
7385
|
try {
|
|
7363
|
-
mkdirSync4(
|
|
7364
|
-
mkdirSync4(
|
|
7365
|
-
mkdirSync4(
|
|
7386
|
+
mkdirSync4(join7(agentDirMs, "msteams-pending-inbound", ".markers"), { recursive: true });
|
|
7387
|
+
mkdirSync4(join7(agentDirMs, "msteams-pending-interactions"), { recursive: true });
|
|
7388
|
+
mkdirSync4(join7(agentDirMs, "msteams-recovery-outbox"), { recursive: true });
|
|
7366
7389
|
} catch {
|
|
7367
7390
|
}
|
|
7368
7391
|
const tenantId = config["tenant_id"] ?? "common";
|
|
@@ -7444,7 +7467,7 @@ ${sections}`
|
|
|
7444
7467
|
}
|
|
7445
7468
|
if (channelId === "whatsapp") {
|
|
7446
7469
|
const provider = config["provider"] ?? "kapso";
|
|
7447
|
-
const localWhatsappChannel =
|
|
7470
|
+
const localWhatsappChannel = join7(getHomeDir(), ".augmented", "_mcp", "whatsapp-channel.js");
|
|
7448
7471
|
if (provider === "baileys") {
|
|
7449
7472
|
mcpServers["whatsapp"] = {
|
|
7450
7473
|
command: "node",
|
|
@@ -7464,7 +7487,7 @@ ${sections}`
|
|
|
7464
7487
|
const phoneNumberId = config["phone_number_id"];
|
|
7465
7488
|
if (projectApiKey && phoneNumberId) {
|
|
7466
7489
|
try {
|
|
7467
|
-
mkdirSync4(
|
|
7490
|
+
mkdirSync4(join7(getAgentDir(codeName), "whatsapp-pending-inbound"), { recursive: true });
|
|
7468
7491
|
} catch {
|
|
7469
7492
|
}
|
|
7470
7493
|
writeEnvIntegrationsForAgent(codeName, {
|
|
@@ -7496,7 +7519,7 @@ ${sections}`
|
|
|
7496
7519
|
return CHANNEL_WRITE_OK;
|
|
7497
7520
|
},
|
|
7498
7521
|
hasChannelCredentials(codeName, channelId) {
|
|
7499
|
-
const provisionMcpPath =
|
|
7522
|
+
const provisionMcpPath = join7(getAgentDir(codeName), "provision", ".mcp.json");
|
|
7500
7523
|
if (!existsSync4(provisionMcpPath))
|
|
7501
7524
|
return false;
|
|
7502
7525
|
try {
|
|
@@ -7508,7 +7531,7 @@ ${sections}`
|
|
|
7508
7531
|
},
|
|
7509
7532
|
removeChannelCredentials(codeName, channelId) {
|
|
7510
7533
|
const agentDir = getAgentDir(codeName);
|
|
7511
|
-
const mcpJsonPath =
|
|
7534
|
+
const mcpJsonPath = join7(agentDir, "provision", ".mcp.json");
|
|
7512
7535
|
modifyJsonConfig(mcpJsonPath, (config) => {
|
|
7513
7536
|
const mcpServers = config["mcpServers"];
|
|
7514
7537
|
if (!mcpServers || !(channelId in mcpServers))
|
|
@@ -7520,7 +7543,7 @@ ${sections}`
|
|
|
7520
7543
|
},
|
|
7521
7544
|
async updateAgentModel(codeName, model) {
|
|
7522
7545
|
const agentDir = getAgentDir(codeName);
|
|
7523
|
-
const settingsPath =
|
|
7546
|
+
const settingsPath = join7(agentDir, "provision", "settings.json");
|
|
7524
7547
|
let changed = false;
|
|
7525
7548
|
modifyJsonConfig(settingsPath, (config) => {
|
|
7526
7549
|
config["model"] = model;
|
|
@@ -7538,15 +7561,15 @@ ${sections}`
|
|
|
7538
7561
|
seedProfileConfig(codeName) {
|
|
7539
7562
|
const agentDir = getAgentDir(codeName);
|
|
7540
7563
|
const projectDir = getProjectDir2(codeName);
|
|
7541
|
-
mkdirSync4(
|
|
7564
|
+
mkdirSync4(join7(agentDir, "provision"), { recursive: true });
|
|
7542
7565
|
mkdirSync4(projectDir, { recursive: true });
|
|
7543
7566
|
},
|
|
7544
7567
|
syncScheduledTasks(codeName, tasks) {
|
|
7545
7568
|
const agentDir = getAgentDir(codeName);
|
|
7546
|
-
const schedulesPath =
|
|
7569
|
+
const schedulesPath = join7(agentDir, "schedules.json");
|
|
7547
7570
|
const mapped = mapScheduledTasks(tasks);
|
|
7548
7571
|
mkdirSync4(agentDir, { recursive: true });
|
|
7549
|
-
|
|
7572
|
+
writeFileSync6(schedulesPath, JSON.stringify({ schedules: mapped }, null, 2));
|
|
7550
7573
|
return Promise.resolve();
|
|
7551
7574
|
},
|
|
7552
7575
|
writeIntegrations(codeName, integrations, agentId, options) {
|
|
@@ -7666,7 +7689,7 @@ ${sections}`
|
|
|
7666
7689
|
xeroEnv.AGT_AGENT_ID = agentId;
|
|
7667
7690
|
xeroEnv.AGT_INTEGRATION_ID = xeroIntegration.id;
|
|
7668
7691
|
}
|
|
7669
|
-
const localXeroMcpPath =
|
|
7692
|
+
const localXeroMcpPath = join7(getHomeDir(), ".augmented", "_mcp", "xero.js");
|
|
7670
7693
|
this.writeMcpServer(codeName, "xero", {
|
|
7671
7694
|
command: "node",
|
|
7672
7695
|
args: [localXeroMcpPath],
|
|
@@ -7678,8 +7701,8 @@ ${sections}`
|
|
|
7678
7701
|
this.writeMcpServer(codeName, "postiz", buildPostizMcpEntry(postizIntegration));
|
|
7679
7702
|
}
|
|
7680
7703
|
const remoteOAuthProxyPaths = {
|
|
7681
|
-
proxyPath:
|
|
7682
|
-
tokenFile:
|
|
7704
|
+
proxyPath: join7(getHomeDir(), ".augmented", "_mcp", "remote-oauth-proxy.js"),
|
|
7705
|
+
tokenFile: join7(getProjectDir2(codeName), ".env.integrations")
|
|
7683
7706
|
};
|
|
7684
7707
|
for (const integration of integrations) {
|
|
7685
7708
|
const connectionKey = integration.connection_key;
|
|
@@ -7738,7 +7761,7 @@ ${sections}`
|
|
|
7738
7761
|
// ENG-6586 (D16): keep incremental cloud-broker wiring in sync with
|
|
7739
7762
|
// buildMcpJson so agents that add cloud-broker post-provision still
|
|
7740
7763
|
// forward the per-turn initiator.
|
|
7741
|
-
AGT_TURN_INITIATOR_FILE:
|
|
7764
|
+
AGT_TURN_INITIATOR_FILE: join7(getAgentDir(codeName), ".current-turn-initiator.json"),
|
|
7742
7765
|
PATH: process.env["PATH"] ?? "",
|
|
7743
7766
|
HOME: process.env["HOME"] ?? ""
|
|
7744
7767
|
}
|
|
@@ -7762,7 +7785,7 @@ ${sections}`
|
|
|
7762
7785
|
// ENG-6563 (D16): keep incremental xero-broker wiring in sync with
|
|
7763
7786
|
// buildMcpJson so agents that add xero-broker post-provision still
|
|
7764
7787
|
// forward the per-turn initiator.
|
|
7765
|
-
AGT_TURN_INITIATOR_FILE:
|
|
7788
|
+
AGT_TURN_INITIATOR_FILE: join7(getAgentDir(codeName), ".current-turn-initiator.json"),
|
|
7766
7789
|
PATH: process.env["PATH"] ?? "",
|
|
7767
7790
|
HOME: process.env["HOME"] ?? ""
|
|
7768
7791
|
}
|
|
@@ -7771,7 +7794,7 @@ ${sections}`
|
|
|
7771
7794
|
}
|
|
7772
7795
|
const hasAdminDebug = integrations.some((i) => i.definition_id === "augmented-admin");
|
|
7773
7796
|
if (hasAdminDebug) {
|
|
7774
|
-
const localAdminMcpPath =
|
|
7797
|
+
const localAdminMcpPath = join7(getHomeDir(), ".augmented", "_mcp", "augmented-admin.js");
|
|
7775
7798
|
this.writeMcpServer(codeName, "augmented-admin", {
|
|
7776
7799
|
command: "node",
|
|
7777
7800
|
args: [localAdminMcpPath],
|
|
@@ -7785,7 +7808,7 @@ ${sections}`
|
|
|
7785
7808
|
}
|
|
7786
7809
|
const hasSupport = integrations.some((i) => i.definition_id === "augmented-support");
|
|
7787
7810
|
if (hasSupport) {
|
|
7788
|
-
const localSupportMcpPath =
|
|
7811
|
+
const localSupportMcpPath = join7(getHomeDir(), ".augmented", "_mcp", "augmented-support.js");
|
|
7789
7812
|
this.writeMcpServer(codeName, "augmented-support", {
|
|
7790
7813
|
command: "node",
|
|
7791
7814
|
args: [localSupportMcpPath],
|
|
@@ -7799,7 +7822,7 @@ ${sections}`
|
|
|
7799
7822
|
}
|
|
7800
7823
|
const hasHelpKb = integrations.some((i) => i.definition_id === "augmented-help-kb");
|
|
7801
7824
|
if (hasHelpKb) {
|
|
7802
|
-
const localHelpKbMcpPath =
|
|
7825
|
+
const localHelpKbMcpPath = join7(getHomeDir(), ".augmented", "_mcp", "augmented-help-kb.js");
|
|
7803
7826
|
this.writeMcpServer(codeName, "augmented-help-kb", {
|
|
7804
7827
|
command: "node",
|
|
7805
7828
|
args: [localHelpKbMcpPath],
|
|
@@ -7815,7 +7838,7 @@ ${sections}`
|
|
|
7815
7838
|
const origamiStdioAgentId = resolveBrokerAgentId(codeName) ?? agentId;
|
|
7816
7839
|
const origamiStdioExpected = Boolean(origamiStdio?.stdioMcp === true && origamiStdio.id);
|
|
7817
7840
|
if (origamiStdioExpected && origamiStdioAgentId) {
|
|
7818
|
-
const localOrigamiMcpPath =
|
|
7841
|
+
const localOrigamiMcpPath = join7(getHomeDir(), ".augmented", "_mcp", "origami.js");
|
|
7819
7842
|
this.writeMcpServer(codeName, "origami", {
|
|
7820
7843
|
command: "node",
|
|
7821
7844
|
args: [localOrigamiMcpPath],
|
|
@@ -7836,7 +7859,7 @@ ${sections}`
|
|
|
7836
7859
|
agentId: computerUseAgentId,
|
|
7837
7860
|
agentCodeName: codeName,
|
|
7838
7861
|
config: computerUseRow.config,
|
|
7839
|
-
proxyPath:
|
|
7862
|
+
proxyPath: join7(getHomeDir(), ".augmented", "_mcp", "computer-use-proxy.js"),
|
|
7840
7863
|
agentDir: getAgentDir(codeName)
|
|
7841
7864
|
});
|
|
7842
7865
|
if (rendered.entry) {
|
|
@@ -7960,7 +7983,7 @@ ${sections}`
|
|
|
7960
7983
|
}
|
|
7961
7984
|
}
|
|
7962
7985
|
const projectDir = getProjectDir2(codeName);
|
|
7963
|
-
const claudeMdPath =
|
|
7986
|
+
const claudeMdPath = join7(projectDir, "CLAUDE.md");
|
|
7964
7987
|
try {
|
|
7965
7988
|
const existing = readFileSync5(claudeMdPath, "utf-8");
|
|
7966
7989
|
const renderSection = options?.renderClaudeMdSection === true;
|
|
@@ -7979,13 +8002,13 @@ ${sections}`
|
|
|
7979
8002
|
updated = existing;
|
|
7980
8003
|
}
|
|
7981
8004
|
if (updated !== existing)
|
|
7982
|
-
|
|
8005
|
+
writeFileSync6(claudeMdPath, updated);
|
|
7983
8006
|
const agentDir2 = getAgentDir(codeName);
|
|
7984
|
-
const envSrc =
|
|
8007
|
+
const envSrc = join7(agentDir2, ".env.integrations");
|
|
7985
8008
|
try {
|
|
7986
8009
|
const envContent = readFileSync5(envSrc, "utf-8");
|
|
7987
|
-
const envDest =
|
|
7988
|
-
|
|
8010
|
+
const envDest = join7(projectDir, ".env.integrations");
|
|
8011
|
+
writeFileSync6(envDest, envContent, { mode: SECRET_FILE_MODE });
|
|
7989
8012
|
try {
|
|
7990
8013
|
chmodSync4(envDest, SECRET_FILE_MODE);
|
|
7991
8014
|
} catch {
|
|
@@ -7999,8 +8022,8 @@ ${sections}`
|
|
|
7999
8022
|
},
|
|
8000
8023
|
writeMcpServer(codeName, serverId, config) {
|
|
8001
8024
|
const agentDir = getAgentDir(codeName);
|
|
8002
|
-
const mcpJsonPath =
|
|
8003
|
-
mkdirSync4(
|
|
8025
|
+
const mcpJsonPath = join7(agentDir, "provision", ".mcp.json");
|
|
8026
|
+
mkdirSync4(join7(agentDir, "provision"), { recursive: true });
|
|
8004
8027
|
let mcpConfig;
|
|
8005
8028
|
try {
|
|
8006
8029
|
mcpConfig = JSON.parse(readFileSync5(mcpJsonPath, "utf-8"));
|
|
@@ -8047,7 +8070,7 @@ ${sections}`
|
|
|
8047
8070
|
}
|
|
8048
8071
|
},
|
|
8049
8072
|
getMcpPath(codeName) {
|
|
8050
|
-
return
|
|
8073
|
+
return join7(getAgentDir(codeName), "provision", ".mcp.json");
|
|
8051
8074
|
},
|
|
8052
8075
|
/**
|
|
8053
8076
|
* ENG-7994: the declared servers from `provision/.mcp.json`. Mirrors what the
|
|
@@ -8058,7 +8081,7 @@ ${sections}`
|
|
|
8058
8081
|
readMcpServers(codeName) {
|
|
8059
8082
|
let parsed;
|
|
8060
8083
|
try {
|
|
8061
|
-
parsed = JSON.parse(readFileSync5(
|
|
8084
|
+
parsed = JSON.parse(readFileSync5(join7(getAgentDir(codeName), "provision", ".mcp.json"), "utf-8"));
|
|
8062
8085
|
} catch {
|
|
8063
8086
|
return {};
|
|
8064
8087
|
}
|
|
@@ -8070,13 +8093,13 @@ ${sections}`
|
|
|
8070
8093
|
return mcpServers;
|
|
8071
8094
|
},
|
|
8072
8095
|
syncMcpMirror(codeName) {
|
|
8073
|
-
const provisionMcpPath =
|
|
8096
|
+
const provisionMcpPath = join7(getAgentDir(codeName), "provision", ".mcp.json");
|
|
8074
8097
|
let content;
|
|
8075
8098
|
try {
|
|
8076
8099
|
content = readFileSync5(provisionMcpPath, "utf-8");
|
|
8077
8100
|
} catch (err) {
|
|
8078
8101
|
const missing = err.code === "ENOENT";
|
|
8079
|
-
if (!missing || existsSync4(
|
|
8102
|
+
if (!missing || existsSync4(join7(getProjectDir2(codeName), ".mcp.json"))) {
|
|
8080
8103
|
noteMcpWriteFailure(codeName);
|
|
8081
8104
|
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
|
|
8082
8105
|
`);
|
|
@@ -8093,7 +8116,7 @@ ${sections}`
|
|
|
8093
8116
|
readMcpServersOrNull(codeName) {
|
|
8094
8117
|
let raw;
|
|
8095
8118
|
try {
|
|
8096
|
-
raw = readFileSync5(
|
|
8119
|
+
raw = readFileSync5(join7(getAgentDir(codeName), "provision", ".mcp.json"), "utf-8");
|
|
8097
8120
|
} catch (err) {
|
|
8098
8121
|
return err.code === "ENOENT" ? {} : null;
|
|
8099
8122
|
}
|
|
@@ -8114,7 +8137,7 @@ ${sections}`
|
|
|
8114
8137
|
},
|
|
8115
8138
|
removeMcpServer(codeName, serverId) {
|
|
8116
8139
|
const agentDir = getAgentDir(codeName);
|
|
8117
|
-
const mcpJsonPath =
|
|
8140
|
+
const mcpJsonPath = join7(agentDir, "provision", ".mcp.json");
|
|
8118
8141
|
let mcpConfig;
|
|
8119
8142
|
try {
|
|
8120
8143
|
mcpConfig = JSON.parse(readFileSync5(mcpJsonPath, "utf-8"));
|
|
@@ -8136,24 +8159,24 @@ ${sections}`
|
|
|
8136
8159
|
const READ_WRITE_MODE = 420;
|
|
8137
8160
|
const agentDir = getAgentDir(codeName);
|
|
8138
8161
|
const projectDir = getProjectDir2(codeName);
|
|
8139
|
-
for (const baseDir of [
|
|
8140
|
-
const skillDir =
|
|
8162
|
+
for (const baseDir of [join7(agentDir, "skills"), join7(projectDir, ".claude", "skills")]) {
|
|
8163
|
+
const skillDir = join7(baseDir, skillId);
|
|
8141
8164
|
mkdirSync4(skillDir, { recursive: true });
|
|
8142
8165
|
for (const file of files) {
|
|
8143
8166
|
assertSafeRelativePath(file.relativePath);
|
|
8144
|
-
const filePath =
|
|
8167
|
+
const filePath = join7(skillDir, file.relativePath);
|
|
8145
8168
|
const rel = relative2(skillDir, filePath);
|
|
8146
8169
|
if (rel.startsWith("..") || rel === "") {
|
|
8147
8170
|
throw new Error(`Path traversal detected: ${file.relativePath} resolves outside ${skillDir}`);
|
|
8148
8171
|
}
|
|
8149
|
-
mkdirSync4(
|
|
8172
|
+
mkdirSync4(join7(filePath, ".."), { recursive: true });
|
|
8150
8173
|
if (isPluginManaged && existsSync4(filePath)) {
|
|
8151
8174
|
try {
|
|
8152
8175
|
chmodSync4(filePath, READ_WRITE_MODE);
|
|
8153
8176
|
} catch {
|
|
8154
8177
|
}
|
|
8155
8178
|
}
|
|
8156
|
-
|
|
8179
|
+
writeFileSync6(filePath, file.content);
|
|
8157
8180
|
if (isPluginManaged) {
|
|
8158
8181
|
try {
|
|
8159
8182
|
chmodSync4(filePath, READ_ONLY_MODE);
|
|
@@ -8165,7 +8188,7 @@ ${sections}`
|
|
|
8165
8188
|
},
|
|
8166
8189
|
installPlugin(codeName, pluginId, pluginPath, pluginConfig) {
|
|
8167
8190
|
const agentDir = getAgentDir(codeName);
|
|
8168
|
-
const pluginsJsonPath =
|
|
8191
|
+
const pluginsJsonPath = join7(agentDir, "plugins.json");
|
|
8169
8192
|
mkdirSync4(agentDir, { recursive: true });
|
|
8170
8193
|
let pluginsConfig;
|
|
8171
8194
|
try {
|
|
@@ -8182,7 +8205,7 @@ ${sections}`
|
|
|
8182
8205
|
installed_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
8183
8206
|
...pluginConfig ? { config: pluginConfig } : {}
|
|
8184
8207
|
};
|
|
8185
|
-
|
|
8208
|
+
writeFileSync6(pluginsJsonPath, JSON.stringify(pluginsConfig, null, 2));
|
|
8186
8209
|
},
|
|
8187
8210
|
/**
|
|
8188
8211
|
* Full plugin provisioning: install scripts, register hooks, apply permissions,
|
|
@@ -8198,11 +8221,11 @@ ${sections}`
|
|
|
8198
8221
|
assertValidCodeName(codeName);
|
|
8199
8222
|
assertValidCodeName(plugin.slug);
|
|
8200
8223
|
const projectDir = getProjectDir2(codeName);
|
|
8201
|
-
const claudeDir =
|
|
8224
|
+
const claudeDir = join7(projectDir, ".claude");
|
|
8202
8225
|
mkdirSync4(claudeDir, { recursive: true });
|
|
8203
8226
|
const sourceSpec = options?.scriptSource ?? `augmented-plugin:${plugin.slug}`;
|
|
8204
8227
|
this.installPlugin(codeName, plugin.slug, sourceSpec, contextValues);
|
|
8205
|
-
const installedDir =
|
|
8228
|
+
const installedDir = join7(projectDir, ".claude", "plugins", plugin.slug);
|
|
8206
8229
|
for (const skill of plugin.skills) {
|
|
8207
8230
|
const skillId = skill.id;
|
|
8208
8231
|
assertValidCodeName(skillId);
|
|
@@ -8214,7 +8237,7 @@ ${sections}`
|
|
|
8214
8237
|
}
|
|
8215
8238
|
const scriptsConfig = plugin.scripts;
|
|
8216
8239
|
if (scriptsConfig?.hooks) {
|
|
8217
|
-
const settingsPath =
|
|
8240
|
+
const settingsPath = join7(claudeDir, "settings.local.json");
|
|
8218
8241
|
let settings = {};
|
|
8219
8242
|
try {
|
|
8220
8243
|
settings = JSON.parse(readFileSync5(settingsPath, "utf-8"));
|
|
@@ -8251,10 +8274,10 @@ ${sections}`
|
|
|
8251
8274
|
}
|
|
8252
8275
|
}
|
|
8253
8276
|
settings["hooks"] = existingHooks;
|
|
8254
|
-
|
|
8277
|
+
writeFileSync6(settingsPath, JSON.stringify(settings, null, 2));
|
|
8255
8278
|
}
|
|
8256
8279
|
if (plugin.allowed_tools.length > 0) {
|
|
8257
|
-
const settingsPath =
|
|
8280
|
+
const settingsPath = join7(claudeDir, "settings.local.json");
|
|
8258
8281
|
let settings = {};
|
|
8259
8282
|
try {
|
|
8260
8283
|
settings = JSON.parse(readFileSync5(settingsPath, "utf-8"));
|
|
@@ -8269,17 +8292,17 @@ ${sections}`
|
|
|
8269
8292
|
}
|
|
8270
8293
|
existingPerms["allow"] = allowList;
|
|
8271
8294
|
settings["permissions"] = existingPerms;
|
|
8272
|
-
|
|
8295
|
+
writeFileSync6(settingsPath, JSON.stringify(settings, null, 2));
|
|
8273
8296
|
}
|
|
8274
8297
|
if (contextValues && Object.keys(contextValues).length > 0) {
|
|
8275
|
-
const configDir =
|
|
8298
|
+
const configDir = join7(projectDir, `.${plugin.slug}`);
|
|
8276
8299
|
mkdirSync4(configDir, { recursive: true });
|
|
8277
|
-
|
|
8300
|
+
writeFileSync6(join7(configDir, "config.json"), JSON.stringify(contextValues, null, 2));
|
|
8278
8301
|
}
|
|
8279
8302
|
},
|
|
8280
8303
|
executePluginHook(ctx) {
|
|
8281
8304
|
assertValidCodeName(ctx.codeName);
|
|
8282
|
-
const agentRootDir =
|
|
8305
|
+
const agentRootDir = join7(getHomeDir(), ".augmented", ctx.codeName);
|
|
8283
8306
|
const projectDir = getProjectDir2(ctx.codeName);
|
|
8284
8307
|
mkdirSync4(agentRootDir, { recursive: true });
|
|
8285
8308
|
mkdirSync4(projectDir, { recursive: true });
|
|
@@ -8336,20 +8359,20 @@ function jsonOutput(data) {
|
|
|
8336
8359
|
}
|
|
8337
8360
|
|
|
8338
8361
|
// src/lib/atomic-write.ts
|
|
8339
|
-
import { closeSync as
|
|
8340
|
-
import { dirname as
|
|
8362
|
+
import { closeSync as closeSync3, fchmodSync as fchmodSync2, fchownSync, fsyncSync, openSync as openSync3, writeFileSync as writeFileSync7, renameSync as renameSync6, mkdirSync as mkdirSync5, unlinkSync as unlinkSync6 } from "fs";
|
|
8363
|
+
import { dirname as dirname5 } from "path";
|
|
8341
8364
|
function atomicWriteFileSync(path, data, own) {
|
|
8342
|
-
const dirPath =
|
|
8365
|
+
const dirPath = dirname5(path);
|
|
8343
8366
|
const tmpPath = `${path}.tmp.${process.pid}.${Math.random().toString(36).slice(2, 8)}`;
|
|
8344
8367
|
try {
|
|
8345
8368
|
mkdirSync5(dirPath, { recursive: true });
|
|
8346
8369
|
} catch {
|
|
8347
8370
|
}
|
|
8348
|
-
const fd =
|
|
8371
|
+
const fd = openSync3(tmpPath, "w", 420);
|
|
8349
8372
|
try {
|
|
8350
8373
|
try {
|
|
8351
|
-
|
|
8352
|
-
if (own?.mode !== void 0)
|
|
8374
|
+
writeFileSync7(fd, data);
|
|
8375
|
+
if (own?.mode !== void 0) fchmodSync2(fd, own.mode);
|
|
8353
8376
|
if (own?.uid !== void 0 && own.gid !== void 0) {
|
|
8354
8377
|
try {
|
|
8355
8378
|
fchownSync(fd, own.uid, own.gid);
|
|
@@ -8361,22 +8384,22 @@ function atomicWriteFileSync(path, data, own) {
|
|
|
8361
8384
|
} catch {
|
|
8362
8385
|
}
|
|
8363
8386
|
} finally {
|
|
8364
|
-
|
|
8387
|
+
closeSync3(fd);
|
|
8365
8388
|
}
|
|
8366
|
-
|
|
8389
|
+
renameSync6(tmpPath, path);
|
|
8367
8390
|
} catch (err) {
|
|
8368
8391
|
try {
|
|
8369
|
-
|
|
8392
|
+
unlinkSync6(tmpPath);
|
|
8370
8393
|
} catch {
|
|
8371
8394
|
}
|
|
8372
8395
|
throw err;
|
|
8373
8396
|
}
|
|
8374
8397
|
try {
|
|
8375
|
-
const dirFd =
|
|
8398
|
+
const dirFd = openSync3(dirPath, "r");
|
|
8376
8399
|
try {
|
|
8377
8400
|
fsyncSync(dirFd);
|
|
8378
8401
|
} finally {
|
|
8379
|
-
|
|
8402
|
+
closeSync3(dirFd);
|
|
8380
8403
|
}
|
|
8381
8404
|
} catch {
|
|
8382
8405
|
}
|
|
@@ -8385,9 +8408,9 @@ function atomicWriteFileSync(path, data, own) {
|
|
|
8385
8408
|
// src/lib/feature-flags-host.ts
|
|
8386
8409
|
import { existsSync as existsSync5, readFileSync as readFileSync6, rmSync as rmSync3, statSync as statSync2 } from "fs";
|
|
8387
8410
|
import { homedir as homedir4 } from "os";
|
|
8388
|
-
import { join as
|
|
8411
|
+
import { join as join8 } from "path";
|
|
8389
8412
|
function defaultFlagsCachePath(configDir) {
|
|
8390
|
-
return
|
|
8413
|
+
return join8(configDir, "flags-cache.json");
|
|
8391
8414
|
}
|
|
8392
8415
|
function readFlagsCache(path) {
|
|
8393
8416
|
try {
|
|
@@ -8676,12 +8699,12 @@ var HostFlagStore = class {
|
|
|
8676
8699
|
* The in-memory state stays authoritative and the next heartbeat retries.
|
|
8677
8700
|
*/
|
|
8678
8701
|
persistPerAgentCaches(updatedAt) {
|
|
8679
|
-
const root =
|
|
8702
|
+
const root = join8(homedir4(), ".augmented");
|
|
8680
8703
|
for (const agentId of this.mirrorAgentIds) {
|
|
8681
8704
|
try {
|
|
8682
|
-
const dir =
|
|
8705
|
+
const dir = join8(root, agentId);
|
|
8683
8706
|
if (!existsSync5(dir)) continue;
|
|
8684
|
-
writeFlagsCache(
|
|
8707
|
+
writeFlagsCache(join8(dir, "flags-cache.json"), {
|
|
8685
8708
|
schema_version: this.lastSchemaVersion,
|
|
8686
8709
|
updated_at: updatedAt,
|
|
8687
8710
|
flags: this.flagsForAgent(agentId),
|
|
@@ -8698,7 +8721,7 @@ var HostFlagStore = class {
|
|
|
8698
8721
|
} catch (err) {
|
|
8699
8722
|
let removed = "left in place";
|
|
8700
8723
|
try {
|
|
8701
|
-
rmSync3(
|
|
8724
|
+
rmSync3(join8(root, agentId, "flags-cache.json"), { force: true, recursive: true });
|
|
8702
8725
|
removed = "stale mirror removed";
|
|
8703
8726
|
} catch (rmErr) {
|
|
8704
8727
|
removed = `stale mirror could NOT be removed: ${rmErr.message}`;
|
|
@@ -9722,16 +9745,16 @@ function buildArgvMatchersForEntry(key, entry) {
|
|
|
9722
9745
|
const tail = "(?![A-Za-z0-9_-])";
|
|
9723
9746
|
if (/^@?[a-z0-9]([a-z0-9._-]*\/)?[a-z0-9._-]+$/i.test(stripped)) {
|
|
9724
9747
|
patterns.push(new RegExp(`${escapeRe(stripped)}${tail}`));
|
|
9725
|
-
const
|
|
9726
|
-
if (
|
|
9727
|
-
patterns.push(new RegExp(`${escapeRe(
|
|
9748
|
+
const basename2 = stripped.split("/").pop();
|
|
9749
|
+
if (basename2 && basename2 !== stripped) {
|
|
9750
|
+
patterns.push(new RegExp(`${escapeRe(basename2)}${tail}`));
|
|
9728
9751
|
}
|
|
9729
9752
|
break;
|
|
9730
9753
|
}
|
|
9731
9754
|
if (stripped.includes("/")) {
|
|
9732
|
-
const
|
|
9733
|
-
if (
|
|
9734
|
-
patterns.push(new RegExp(`${escapeRe(
|
|
9755
|
+
const basename2 = stripped.split("/").pop();
|
|
9756
|
+
if (basename2) {
|
|
9757
|
+
patterns.push(new RegExp(`${escapeRe(basename2)}${tail}`));
|
|
9735
9758
|
break;
|
|
9736
9759
|
}
|
|
9737
9760
|
}
|
|
@@ -10641,7 +10664,7 @@ function verdictForUnavailableMcpConfig(cause, ctx) {
|
|
|
10641
10664
|
}
|
|
10642
10665
|
|
|
10643
10666
|
// src/lib/connectivity-probe-context.ts
|
|
10644
|
-
import { delimiter as pathDelimiter, join as
|
|
10667
|
+
import { delimiter as pathDelimiter, join as join9 } from "path";
|
|
10645
10668
|
import { existsSync as existsSync6, readFileSync as readFileSync7 } from "fs";
|
|
10646
10669
|
import { homedir as homedir5 } from "os";
|
|
10647
10670
|
|
|
@@ -11576,7 +11599,7 @@ function resolveHttpServerEntry(entry, env) {
|
|
|
11576
11599
|
}
|
|
11577
11600
|
function readMcpServerEntry(projectDir, serverKey) {
|
|
11578
11601
|
try {
|
|
11579
|
-
const raw = readFileSync7(
|
|
11602
|
+
const raw = readFileSync7(join9(projectDir, ".mcp.json"), "utf-8");
|
|
11580
11603
|
const servers = JSON.parse(raw).mcpServers ?? {};
|
|
11581
11604
|
return servers[serverKey] ?? null;
|
|
11582
11605
|
} catch {
|
|
@@ -11586,7 +11609,7 @@ function readMcpServerEntry(projectDir, serverKey) {
|
|
|
11586
11609
|
function readMcpHttpServerConfig(projectDir, serverKey, env) {
|
|
11587
11610
|
let servers;
|
|
11588
11611
|
try {
|
|
11589
|
-
const raw = readFileSync7(
|
|
11612
|
+
const raw = readFileSync7(join9(projectDir, ".mcp.json"), "utf-8");
|
|
11590
11613
|
servers = JSON.parse(raw).mcpServers ?? {};
|
|
11591
11614
|
} catch {
|
|
11592
11615
|
return { ok: false, cause: "file-unreadable" };
|
|
@@ -11598,7 +11621,7 @@ function readMcpHttpServerConfig(projectDir, serverKey, env) {
|
|
|
11598
11621
|
}
|
|
11599
11622
|
function resolveDeclaredServerKey(projectDir, definitionId, derivedKey) {
|
|
11600
11623
|
try {
|
|
11601
|
-
const raw = readFileSync7(
|
|
11624
|
+
const raw = readFileSync7(join9(projectDir, ".mcp.json"), "utf-8");
|
|
11602
11625
|
const servers = JSON.parse(raw).mcpServers ?? {};
|
|
11603
11626
|
const declared = Object.keys(servers);
|
|
11604
11627
|
if (derivedKey !== definitionId && derivedKey !== sanitizeServerKey(definitionId)) {
|
|
@@ -11640,7 +11663,7 @@ function resolveStdioServerEntry(entry, env) {
|
|
|
11640
11663
|
function readMcpStdioServerConfig(projectDir, serverKey, env) {
|
|
11641
11664
|
let servers;
|
|
11642
11665
|
try {
|
|
11643
|
-
const raw = readFileSync7(
|
|
11666
|
+
const raw = readFileSync7(join9(projectDir, ".mcp.json"), "utf-8");
|
|
11644
11667
|
servers = JSON.parse(raw).mcpServers ?? {};
|
|
11645
11668
|
} catch {
|
|
11646
11669
|
return { ok: false, cause: "file-unreadable" };
|
|
@@ -11668,13 +11691,13 @@ function toolkitPathDirs() {
|
|
|
11668
11691
|
const home = process.env.HOME?.trim() || homedir5();
|
|
11669
11692
|
return [
|
|
11670
11693
|
...PROBE_TOOLKIT_PATH_DIRS,
|
|
11671
|
-
...PROBE_HOME_RELATIVE_PATH_SEGMENTS.map((seg) =>
|
|
11694
|
+
...PROBE_HOME_RELATIVE_PATH_SEGMENTS.map((seg) => join9(home, seg))
|
|
11672
11695
|
];
|
|
11673
11696
|
}
|
|
11674
11697
|
function buildProbeEnv(projectDir, agentId) {
|
|
11675
11698
|
const probeEnv = { ...process.env };
|
|
11676
11699
|
try {
|
|
11677
|
-
const envIntPath =
|
|
11700
|
+
const envIntPath = join9(projectDir, ".env.integrations");
|
|
11678
11701
|
if (existsSync6(envIntPath)) {
|
|
11679
11702
|
Object.assign(probeEnv, parseEnvIntegrations(readFileSync7(envIntPath, "utf-8")));
|
|
11680
11703
|
}
|
|
@@ -11684,7 +11707,7 @@ function buildProbeEnv(projectDir, agentId) {
|
|
|
11684
11707
|
probeEnv.AGT_AGENT_ID = agentId.trim();
|
|
11685
11708
|
}
|
|
11686
11709
|
try {
|
|
11687
|
-
const agentBinDir =
|
|
11710
|
+
const agentBinDir = join9(projectDir, ".claude", "agt-bin");
|
|
11688
11711
|
if (existsSync6(agentBinDir)) {
|
|
11689
11712
|
const parts = probeEnv.PATH ? probeEnv.PATH.split(pathDelimiter) : [];
|
|
11690
11713
|
parts.unshift(agentBinDir);
|
|
@@ -12083,8 +12106,8 @@ var TunnelWatcher = class {
|
|
|
12083
12106
|
// src/lib/session-tool-bind-probe-host.ts
|
|
12084
12107
|
import { execFileSync as syncExecFile } from "child_process";
|
|
12085
12108
|
import { readFileSync as readFileSync8 } from "fs";
|
|
12086
|
-
import { join as
|
|
12087
|
-
import { dirname as
|
|
12109
|
+
import { join as join10 } from "path";
|
|
12110
|
+
import { dirname as dirname6 } from "path";
|
|
12088
12111
|
function termsRestrictedServerKeys(integrations, isRestricted = isProbeRestrictedByProviderTerms) {
|
|
12089
12112
|
const keys = /* @__PURE__ */ new Set();
|
|
12090
12113
|
for (const i of integrations) {
|
|
@@ -12127,7 +12150,7 @@ async function gatherSessionToolBindProbe(agent, integrations, projectDir, opts)
|
|
|
12127
12150
|
if (integrations.length === 0) return null;
|
|
12128
12151
|
let mcpRaw = null;
|
|
12129
12152
|
try {
|
|
12130
|
-
mcpRaw = readFileSync8(
|
|
12153
|
+
mcpRaw = readFileSync8(join10(projectDir, ".mcp.json"), "utf-8");
|
|
12131
12154
|
} catch {
|
|
12132
12155
|
mcpRaw = null;
|
|
12133
12156
|
}
|
|
@@ -12231,7 +12254,7 @@ var SLACK_MCP_SERVER_KEY = "slack";
|
|
|
12231
12254
|
function readSlackTransportDownKeys(projectDir) {
|
|
12232
12255
|
const none = /* @__PURE__ */ new Set();
|
|
12233
12256
|
try {
|
|
12234
|
-
const raw = readFileSync8(
|
|
12257
|
+
const raw = readFileSync8(join10(dirname6(projectDir), SLACK_SOCKET_STATE_FILENAME), "utf-8");
|
|
12235
12258
|
const state = parseSlackSocketState(raw, Date.now());
|
|
12236
12259
|
return isSlackInboundTransportDown(state, SLACK_TRANSPORT_DOWN_AFTER_MS) ? /* @__PURE__ */ new Set([SLACK_MCP_SERVER_KEY]) : none;
|
|
12237
12260
|
} catch {
|
|
@@ -12318,7 +12341,7 @@ function describeWorkerModuleFailure(err) {
|
|
|
12318
12341
|
// src/lib/drain-transcript-flush.ts
|
|
12319
12342
|
import { existsSync as existsSync7, readdirSync as readdirSync2 } from "fs";
|
|
12320
12343
|
import { homedir as homedir6 } from "os";
|
|
12321
|
-
import { dirname as
|
|
12344
|
+
import { dirname as dirname7, join as join11, relative as relative3, sep } from "path";
|
|
12322
12345
|
import { spawn as spawn2 } from "child_process";
|
|
12323
12346
|
|
|
12324
12347
|
// src/lib/host-archive-address.ts
|
|
@@ -12362,7 +12385,7 @@ function readHostArchiveAddress(path) {
|
|
|
12362
12385
|
|
|
12363
12386
|
// src/lib/drain-transcript-flush.ts
|
|
12364
12387
|
function sessionsBaseDir() {
|
|
12365
|
-
return
|
|
12388
|
+
return join11(homedir6(), ".claude", "projects");
|
|
12366
12389
|
}
|
|
12367
12390
|
var PER_FILE_UPLOAD_TIMEOUT_MS = 3e4;
|
|
12368
12391
|
var UPLOAD_CONCURRENCY = 4;
|
|
@@ -12373,7 +12396,7 @@ function listJsonlFiles(dir) {
|
|
|
12373
12396
|
const out = [];
|
|
12374
12397
|
const walk = (d) => {
|
|
12375
12398
|
for (const entry of readdirSync2(d, { withFileTypes: true })) {
|
|
12376
|
-
const full =
|
|
12399
|
+
const full = join11(d, entry.name);
|
|
12377
12400
|
if (entry.isDirectory()) walk(full);
|
|
12378
12401
|
else if (entry.isFile() && entry.name.endsWith(".jsonl")) out.push(full);
|
|
12379
12402
|
}
|
|
@@ -12390,7 +12413,7 @@ function transcriptObjectKey(keyPrefix, baseDir, file) {
|
|
|
12390
12413
|
return `${keyPrefix.replace(/\/+$/, "")}/${rel}`;
|
|
12391
12414
|
}
|
|
12392
12415
|
function drainManifestObjectKey(keyPrefix, baseDir, transcriptDir) {
|
|
12393
|
-
return transcriptObjectKey(keyPrefix, baseDir,
|
|
12416
|
+
return transcriptObjectKey(keyPrefix, baseDir, join11(transcriptDir, DRAIN_MANIFEST_FILENAME));
|
|
12394
12417
|
}
|
|
12395
12418
|
async function flushAgentTranscriptsOnDrain(codeName, deps) {
|
|
12396
12419
|
const dir = deps.resolveTranscriptDir(codeName);
|
|
@@ -12541,8 +12564,8 @@ function drainTranscriptFlushDeps(log2) {
|
|
|
12541
12564
|
// Observing the resolver keeps a second copy of ADR-0049's rule out of the
|
|
12542
12565
|
// tree — the thing host-archive-address.ts's header warns about.
|
|
12543
12566
|
readSourceLayout: (codeName) => {
|
|
12544
|
-
const agentDir =
|
|
12545
|
-
const codeNameDir =
|
|
12567
|
+
const agentDir = dirname7(getProjectDir(codeName));
|
|
12568
|
+
const codeNameDir = join11(homedir6(), ".augmented", codeName);
|
|
12546
12569
|
return { layout: agentDir === codeNameDir ? "codename-keyed" : "id-keyed", agentDir };
|
|
12547
12570
|
},
|
|
12548
12571
|
readSessionPin: (codeName) => readDailySessionPin(codeName),
|
|
@@ -12628,8 +12651,8 @@ function decidePin(opts) {
|
|
|
12628
12651
|
}
|
|
12629
12652
|
|
|
12630
12653
|
// src/commands/setup.ts
|
|
12631
|
-
import { existsSync as existsSync9, readFileSync as readFileSync11, writeFileSync as
|
|
12632
|
-
import { join as
|
|
12654
|
+
import { existsSync as existsSync9, readFileSync as readFileSync11, writeFileSync as writeFileSync9, mkdirSync as mkdirSync7, accessSync, constants as fsConstants } from "fs";
|
|
12655
|
+
import { join as join13, dirname as dirname8 } from "path";
|
|
12633
12656
|
import { homedir as homedir7 } from "os";
|
|
12634
12657
|
import chalk3 from "chalk";
|
|
12635
12658
|
import ora from "ora";
|
|
@@ -12661,15 +12684,15 @@ function table(headers, rows) {
|
|
|
12661
12684
|
}
|
|
12662
12685
|
|
|
12663
12686
|
// src/lib/watchdog.ts
|
|
12664
|
-
import { readFileSync as readFileSync10, writeFileSync as
|
|
12665
|
-
import { join as
|
|
12687
|
+
import { readFileSync as readFileSync10, writeFileSync as writeFileSync8, unlinkSync as unlinkSync7, existsSync as existsSync8, mkdirSync as mkdirSync6, openSync as openSync4, closeSync as closeSync4, chmodSync as chmodSync5 } from "fs";
|
|
12688
|
+
import { join as join12 } from "path";
|
|
12666
12689
|
import { spawn as spawn3, execFileSync as execFileSync3 } from "child_process";
|
|
12667
|
-
var DEFAULT_CONFIG_DIR =
|
|
12690
|
+
var DEFAULT_CONFIG_DIR = join12(process.env["HOME"] ?? "/tmp", ".augmented");
|
|
12668
12691
|
function getManagerPaths(configDir) {
|
|
12669
12692
|
return {
|
|
12670
|
-
pidFile:
|
|
12671
|
-
stateFile:
|
|
12672
|
-
logFile:
|
|
12693
|
+
pidFile: join12(configDir, "manager.pid"),
|
|
12694
|
+
stateFile: join12(configDir, "manager-state.json"),
|
|
12695
|
+
logFile: join12(configDir, "manager.log")
|
|
12673
12696
|
};
|
|
12674
12697
|
}
|
|
12675
12698
|
function ensureDir(configDir) {
|
|
@@ -12679,7 +12702,7 @@ function ensureDir(configDir) {
|
|
|
12679
12702
|
}
|
|
12680
12703
|
function writePidFile(configDir, pid) {
|
|
12681
12704
|
ensureDir(configDir);
|
|
12682
|
-
|
|
12705
|
+
writeFileSync8(getManagerPaths(configDir).pidFile, String(pid), { mode: 384 });
|
|
12683
12706
|
}
|
|
12684
12707
|
function readPidFile(configDir) {
|
|
12685
12708
|
try {
|
|
@@ -12692,7 +12715,7 @@ function readPidFile(configDir) {
|
|
|
12692
12715
|
}
|
|
12693
12716
|
function removePidFile(configDir) {
|
|
12694
12717
|
try {
|
|
12695
|
-
|
|
12718
|
+
unlinkSync7(getManagerPaths(configDir).pidFile);
|
|
12696
12719
|
} catch {
|
|
12697
12720
|
}
|
|
12698
12721
|
}
|
|
@@ -12737,7 +12760,7 @@ function readStateFile(configDir) {
|
|
|
12737
12760
|
}
|
|
12738
12761
|
function removeStateFile(configDir) {
|
|
12739
12762
|
try {
|
|
12740
|
-
|
|
12763
|
+
unlinkSync7(getManagerPaths(configDir).stateFile);
|
|
12741
12764
|
} catch {
|
|
12742
12765
|
}
|
|
12743
12766
|
}
|
|
@@ -12761,7 +12784,7 @@ function startWatchdog(opts) {
|
|
|
12761
12784
|
if (opts.detached) {
|
|
12762
12785
|
ensureDir(configDir);
|
|
12763
12786
|
const { logFile } = getManagerPaths(configDir);
|
|
12764
|
-
const logFd =
|
|
12787
|
+
const logFd = openSync4(logFile, "a", 384);
|
|
12765
12788
|
try {
|
|
12766
12789
|
chmodSync5(logFile, 384);
|
|
12767
12790
|
} catch {
|
|
@@ -12777,7 +12800,7 @@ function startWatchdog(opts) {
|
|
|
12777
12800
|
}
|
|
12778
12801
|
);
|
|
12779
12802
|
child.unref();
|
|
12780
|
-
|
|
12803
|
+
closeSync4(logFd);
|
|
12781
12804
|
if (!child.pid) {
|
|
12782
12805
|
throw new Error("Failed to spawn detached manager process");
|
|
12783
12806
|
}
|
|
@@ -12861,15 +12884,15 @@ function detectShellProfile() {
|
|
|
12861
12884
|
const shell = process.env["SHELL"] ?? "";
|
|
12862
12885
|
const home = homedir7();
|
|
12863
12886
|
if (shell.includes("zsh")) {
|
|
12864
|
-
return
|
|
12887
|
+
return join13(home, ".zshrc");
|
|
12865
12888
|
}
|
|
12866
12889
|
if (shell.includes("fish")) {
|
|
12867
|
-
const fishConfig =
|
|
12890
|
+
const fishConfig = join13(home, ".config", "fish", "config.fish");
|
|
12868
12891
|
return fishConfig;
|
|
12869
12892
|
}
|
|
12870
|
-
const bashrc =
|
|
12893
|
+
const bashrc = join13(home, ".bashrc");
|
|
12871
12894
|
if (existsSync9(bashrc)) return bashrc;
|
|
12872
|
-
return
|
|
12895
|
+
return join13(home, ".bash_profile");
|
|
12873
12896
|
}
|
|
12874
12897
|
function maybeWriteSystemWideEnv(apiUrl, apiKey, consoleUrl) {
|
|
12875
12898
|
const empty = { etcEnvironment: false, profileD: false, bashrc: false };
|
|
@@ -12931,7 +12954,7 @@ function writeEtcEnvironment(apiUrl, apiKey, consoleUrl) {
|
|
|
12931
12954
|
if (consoleUrl) lines.push(`AGT_CONSOLE_URL=${quoteForEtcEnvironment(consoleUrl)}`);
|
|
12932
12955
|
const appended = `${base}${lines.join("\n")}
|
|
12933
12956
|
`;
|
|
12934
|
-
|
|
12957
|
+
writeFileSync9(envPath, appended, { mode: 420 });
|
|
12935
12958
|
return true;
|
|
12936
12959
|
} catch {
|
|
12937
12960
|
return false;
|
|
@@ -12954,7 +12977,7 @@ function writeProfileDScript(apiUrl, apiKey, consoleUrl) {
|
|
|
12954
12977
|
];
|
|
12955
12978
|
if (consoleUrl) lines.push(`export AGT_CONSOLE_URL=${quoteForPosixShell(consoleUrl)}`);
|
|
12956
12979
|
lines.push("");
|
|
12957
|
-
|
|
12980
|
+
writeFileSync9(scriptPath, lines.join("\n"), { mode: 420 });
|
|
12958
12981
|
return true;
|
|
12959
12982
|
} catch {
|
|
12960
12983
|
return false;
|
|
@@ -12980,7 +13003,7 @@ function ensureBashrcSourcesProfileD() {
|
|
|
12980
13003
|
"fi",
|
|
12981
13004
|
""
|
|
12982
13005
|
].join("\n");
|
|
12983
|
-
|
|
13006
|
+
writeFileSync9(bashrc, current + snippet);
|
|
12984
13007
|
return true;
|
|
12985
13008
|
} catch {
|
|
12986
13009
|
return false;
|
|
@@ -13108,7 +13131,7 @@ async function setupCommand(token, options = {}) {
|
|
|
13108
13131
|
);
|
|
13109
13132
|
}
|
|
13110
13133
|
const exportLines = buildExportLines(shell, finalApiUrl, setupResult.api_key, consoleUrl);
|
|
13111
|
-
const profileDir =
|
|
13134
|
+
const profileDir = dirname8(profilePath);
|
|
13112
13135
|
if (!existsSync9(profileDir)) {
|
|
13113
13136
|
mkdirSync7(profileDir, { recursive: true });
|
|
13114
13137
|
}
|
|
@@ -13126,7 +13149,7 @@ async function setupCommand(token, options = {}) {
|
|
|
13126
13149
|
} else {
|
|
13127
13150
|
updated = current + exportLines;
|
|
13128
13151
|
}
|
|
13129
|
-
|
|
13152
|
+
writeFileSync9(profilePath, updated.endsWith("\n") ? updated : `${updated}
|
|
13130
13153
|
`);
|
|
13131
13154
|
if (!json) {
|
|
13132
13155
|
success(`Environment variables written to ${chalk3.bold(profilePath)}`);
|
|
@@ -13144,7 +13167,7 @@ async function setupCommand(token, options = {}) {
|
|
|
13144
13167
|
const managerSpinner = ora({ text: "Starting manager daemon\u2026", isSilent: json });
|
|
13145
13168
|
managerSpinner.start();
|
|
13146
13169
|
try {
|
|
13147
|
-
const configDir =
|
|
13170
|
+
const configDir = join13(homedir7(), ".augmented");
|
|
13148
13171
|
const { pid } = startWatchdog({ intervalMs: 1e4, configDir, detached: true });
|
|
13149
13172
|
managerSpinner.succeed(`Manager started (PID ${pid})`);
|
|
13150
13173
|
} catch (err) {
|
|
@@ -13184,7 +13207,7 @@ async function setupCommand(token, options = {}) {
|
|
|
13184
13207
|
// src/commands/manager.ts
|
|
13185
13208
|
import chalk4 from "chalk";
|
|
13186
13209
|
import { existsSync as existsSync10, realpathSync as realpathSync3 } from "fs";
|
|
13187
|
-
import { join as
|
|
13210
|
+
import { join as join14 } from "path";
|
|
13188
13211
|
import { homedir as homedir8, userInfo } from "os";
|
|
13189
13212
|
import { spawn as spawn4 } from "child_process";
|
|
13190
13213
|
function normalizePinInEnv(env) {
|
|
@@ -13229,7 +13252,7 @@ function managerStartCommand(opts) {
|
|
|
13229
13252
|
process.exitCode = 1;
|
|
13230
13253
|
return;
|
|
13231
13254
|
}
|
|
13232
|
-
const configDir = opts.configDir ??
|
|
13255
|
+
const configDir = opts.configDir ?? join14(homedir8(), ".augmented");
|
|
13233
13256
|
if (opts.supervise) {
|
|
13234
13257
|
if (json) {
|
|
13235
13258
|
jsonOutput({ ok: false, error: "--supervise is not supported with --json" });
|
|
@@ -13325,7 +13348,7 @@ function runSupervisorLoop(intervalSec, configDir) {
|
|
|
13325
13348
|
}
|
|
13326
13349
|
async function managerStopCommand(opts = {}) {
|
|
13327
13350
|
const json = isJsonMode();
|
|
13328
|
-
const configDir = opts.configDir ??
|
|
13351
|
+
const configDir = opts.configDir ?? join14(homedir8(), ".augmented");
|
|
13329
13352
|
try {
|
|
13330
13353
|
const result = await stopWatchdog(configDir);
|
|
13331
13354
|
if (!result.stopped && !result.pid) {
|
|
@@ -13353,7 +13376,7 @@ async function managerStopCommand(opts = {}) {
|
|
|
13353
13376
|
}
|
|
13354
13377
|
function managerStatusCommand(opts = {}) {
|
|
13355
13378
|
const json = isJsonMode();
|
|
13356
|
-
const configDir = opts.configDir ??
|
|
13379
|
+
const configDir = opts.configDir ?? join14(homedir8(), ".augmented");
|
|
13357
13380
|
const status = getManagerStatus(configDir);
|
|
13358
13381
|
if (!status) {
|
|
13359
13382
|
if (json) {
|
|
@@ -13462,7 +13485,7 @@ async function managerInstallCommand(opts = {}) {
|
|
|
13462
13485
|
process.exitCode = 1;
|
|
13463
13486
|
return;
|
|
13464
13487
|
}
|
|
13465
|
-
const configDir = opts.configDir ??
|
|
13488
|
+
const configDir = opts.configDir ?? join14(homedir8(), ".augmented");
|
|
13466
13489
|
const rawAgtBin = process.argv[1];
|
|
13467
13490
|
if (!rawAgtBin) {
|
|
13468
13491
|
const msg = "Could not resolve the agt binary path from argv. Re-run via the installed `agt` command.";
|
|
@@ -13475,7 +13498,7 @@ async function managerInstallCommand(opts = {}) {
|
|
|
13475
13498
|
if (process.platform === "darwin") {
|
|
13476
13499
|
const home = homedir8();
|
|
13477
13500
|
const protectedRoots = ["Documents", "Downloads", "Desktop", "Movies", "Music", "Pictures"];
|
|
13478
|
-
const offending = protectedRoots.map((r) =>
|
|
13501
|
+
const offending = protectedRoots.map((r) => join14(home, r)).find((p) => agtBin === p || agtBin.startsWith(`${p}/`));
|
|
13479
13502
|
if (offending) {
|
|
13480
13503
|
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.`;
|
|
13481
13504
|
if (json) jsonOutput({ ok: false, error: msg });
|
|
@@ -13542,7 +13565,7 @@ async function managerInstallSystemUnitCommand(opts = {}) {
|
|
|
13542
13565
|
return;
|
|
13543
13566
|
}
|
|
13544
13567
|
const user = opts.user ?? "root";
|
|
13545
|
-
const configDir = opts.configDir ?? (user === "root" ? "/root/.augmented" :
|
|
13568
|
+
const configDir = opts.configDir ?? (user === "root" ? "/root/.augmented" : join14("/home", user, ".augmented"));
|
|
13546
13569
|
const rawAgtBin = process.argv[1];
|
|
13547
13570
|
if (!rawAgtBin) {
|
|
13548
13571
|
const msg = "Could not resolve the agt binary path from argv. Re-run via the installed `agt` command.";
|
|
@@ -13853,4 +13876,4 @@ export {
|
|
|
13853
13876
|
managerInstallSystemUnitCommand,
|
|
13854
13877
|
managerUninstallSystemUnitCommand
|
|
13855
13878
|
};
|
|
13856
|
-
//# sourceMappingURL=chunk-
|
|
13879
|
+
//# sourceMappingURL=chunk-5RA3GYYL.js.map
|