@integrity-labs/agt-cli 0.28.40 → 0.28.41
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/bin/agt.js +104 -12
- package/dist/bin/agt.js.map +1 -1
- package/dist/{chunk-57MHPANB.js → chunk-2BRF2FDJ.js} +24 -116
- package/dist/chunk-2BRF2FDJ.js.map +1 -0
- package/dist/{chunk-DA776TZO.js → chunk-GBST6UWT.js} +253 -24
- package/dist/chunk-GBST6UWT.js.map +1 -0
- package/dist/{chunk-X5E2Q3W2.js → chunk-SJUD2BWU.js} +3030 -2936
- package/dist/chunk-SJUD2BWU.js.map +1 -0
- package/dist/{claude-pair-runtime-LOL5YGXP.js → claude-pair-runtime-YPTMIWJF.js} +2 -2
- package/dist/lib/manager-worker.js +19 -227
- package/dist/lib/manager-worker.js.map +1 -1
- package/dist/mcp/augmented-admin.js +59 -3
- package/dist/{persistent-session-CFELQZI7.js → persistent-session-PNY26VBX.js} +3 -3
- package/dist/{responsiveness-probe-YOT3EKKN.js → responsiveness-probe-4YMZ6LXO.js} +3 -3
- package/package.json +1 -1
- package/dist/chunk-57MHPANB.js.map +0 -1
- package/dist/chunk-DA776TZO.js.map +0 -1
- package/dist/chunk-X5E2Q3W2.js.map +0 -1
- /package/dist/{claude-pair-runtime-LOL5YGXP.js.map → claude-pair-runtime-YPTMIWJF.js.map} +0 -0
- /package/dist/{persistent-session-CFELQZI7.js.map → persistent-session-PNY26VBX.js.map} +0 -0
- /package/dist/{responsiveness-probe-YOT3EKKN.js.map → responsiveness-probe-4YMZ6LXO.js.map} +0 -0
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
claudeModelAlias,
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
formatMissingVar,
|
|
4
|
+
isClaudeFastMode,
|
|
5
|
+
probeMcpEnvSubstitution
|
|
6
|
+
} from "./chunk-SJUD2BWU.js";
|
|
5
7
|
import {
|
|
6
8
|
reapOrphanChannelMcps
|
|
7
9
|
} from "./chunk-XWVM4KPK.js";
|
|
@@ -10,7 +12,7 @@ import {
|
|
|
10
12
|
import { spawn, execSync, execFileSync as execFileSync3 } from "child_process";
|
|
11
13
|
import { join as join2, dirname } from "path";
|
|
12
14
|
import { homedir as homedir2, platform, userInfo } from "os";
|
|
13
|
-
import { existsSync as
|
|
15
|
+
import { existsSync as existsSync2, readFileSync as readFileSync3, readdirSync as readdirSync2, writeFileSync as writeFileSync3, appendFileSync, mkdirSync as mkdirSync2, chmodSync, copyFileSync, rmSync } from "fs";
|
|
14
16
|
|
|
15
17
|
// src/lib/mcp-sanitize.ts
|
|
16
18
|
import { readFileSync, writeFileSync } from "fs";
|
|
@@ -61,102 +63,12 @@ function buildAllowedTools(mcpServerNames) {
|
|
|
61
63
|
return [...mcpPatterns, ...BASE_TOOLS].join(",");
|
|
62
64
|
}
|
|
63
65
|
|
|
64
|
-
// src/lib/mcp-env-probe.ts
|
|
65
|
-
import { existsSync, readFileSync as readFileSync2 } from "fs";
|
|
66
|
-
var LATE_BOUND_VARS = /* @__PURE__ */ new Set([
|
|
67
|
-
"AGT_RUN_ID",
|
|
68
|
-
"AGT_TOKEN",
|
|
69
|
-
"ANCHOR_BROWSER_SESSION_ID"
|
|
70
|
-
]);
|
|
71
|
-
var TEMPLATE_VAR_RE = /\$\{([A-Za-z_][A-Za-z0-9_]*)\}/g;
|
|
72
|
-
function collectVarsFromValue(value, into) {
|
|
73
|
-
if (typeof value === "string") {
|
|
74
|
-
for (const m of value.matchAll(TEMPLATE_VAR_RE)) into.add(m[1]);
|
|
75
|
-
} else if (Array.isArray(value)) {
|
|
76
|
-
for (const v of value) collectVarsFromValue(v, into);
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
function findMissingSubstitutionVars(mcpConfig, env) {
|
|
80
|
-
const findings = [];
|
|
81
|
-
if (typeof mcpConfig !== "object" || mcpConfig === null) return findings;
|
|
82
|
-
const servers = mcpConfig.mcpServers;
|
|
83
|
-
if (typeof servers !== "object" || servers === null) return findings;
|
|
84
|
-
for (const [server, raw] of Object.entries(servers)) {
|
|
85
|
-
if (typeof raw !== "object" || raw === null) continue;
|
|
86
|
-
const entry = raw;
|
|
87
|
-
const vars = /* @__PURE__ */ new Set();
|
|
88
|
-
collectVarsFromValue(entry["command"], vars);
|
|
89
|
-
collectVarsFromValue(entry["args"], vars);
|
|
90
|
-
collectVarsFromValue(entry["url"], vars);
|
|
91
|
-
for (const block of [entry["env"], entry["headers"]]) {
|
|
92
|
-
if (typeof block !== "object" || block === null) continue;
|
|
93
|
-
for (const v of Object.values(block)) collectVarsFromValue(v, vars);
|
|
94
|
-
}
|
|
95
|
-
for (const varName of vars) {
|
|
96
|
-
if (LATE_BOUND_VARS.has(varName)) continue;
|
|
97
|
-
const value = env[varName];
|
|
98
|
-
if (value === void 0) {
|
|
99
|
-
findings.push({ varName, server, state: "unset" });
|
|
100
|
-
} else if (value.trim() === "") {
|
|
101
|
-
findings.push({ varName, server, state: "empty" });
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
return findings;
|
|
106
|
-
}
|
|
107
|
-
function formatMissingVar(f) {
|
|
108
|
-
return `[mcp-env-substitution] missing var=${f.varName} server=${f.server} state=${f.state}`;
|
|
109
|
-
}
|
|
110
|
-
function expandTemplateVars(value, env) {
|
|
111
|
-
const unresolved = /* @__PURE__ */ new Set();
|
|
112
|
-
const expanded = value.replace(TEMPLATE_VAR_RE, (literal, name) => {
|
|
113
|
-
if (LATE_BOUND_VARS.has(name)) {
|
|
114
|
-
unresolved.add(name);
|
|
115
|
-
return literal;
|
|
116
|
-
}
|
|
117
|
-
const resolved = env[name];
|
|
118
|
-
if (resolved !== void 0 && resolved.trim() !== "") return resolved;
|
|
119
|
-
unresolved.add(name);
|
|
120
|
-
return literal;
|
|
121
|
-
});
|
|
122
|
-
return { value: expanded, unresolved: [...unresolved] };
|
|
123
|
-
}
|
|
124
|
-
function parseEnvIntegrations(content) {
|
|
125
|
-
const out = {};
|
|
126
|
-
for (const line of content.split("\n")) {
|
|
127
|
-
if (!line || line.startsWith("#") || !line.includes("=")) continue;
|
|
128
|
-
const eqIdx = line.indexOf("=");
|
|
129
|
-
const key = line.slice(0, eqIdx);
|
|
130
|
-
let value = line.slice(eqIdx + 1);
|
|
131
|
-
if (value.length >= 2 && value.startsWith("'") && value.endsWith("'")) {
|
|
132
|
-
value = value.slice(1, -1).replaceAll("'\\''", "'");
|
|
133
|
-
}
|
|
134
|
-
out[key] = value;
|
|
135
|
-
}
|
|
136
|
-
return out;
|
|
137
|
-
}
|
|
138
|
-
function probeMcpEnvSubstitution(args) {
|
|
139
|
-
try {
|
|
140
|
-
const config = JSON.parse(readFileSync2(args.mcpConfigPath, "utf-8"));
|
|
141
|
-
let env = args.baseEnv;
|
|
142
|
-
if (args.envIntegrationsPath && existsSync(args.envIntegrationsPath)) {
|
|
143
|
-
env = {
|
|
144
|
-
...args.baseEnv,
|
|
145
|
-
...parseEnvIntegrations(readFileSync2(args.envIntegrationsPath, "utf-8"))
|
|
146
|
-
};
|
|
147
|
-
}
|
|
148
|
-
return findMissingSubstitutionVars(config, env);
|
|
149
|
-
} catch {
|
|
150
|
-
return [];
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
|
|
154
66
|
// src/lib/persistent-session.ts
|
|
155
67
|
import { randomUUID as randomUUID2 } from "crypto";
|
|
156
68
|
|
|
157
69
|
// src/lib/daily-session.ts
|
|
158
70
|
import { randomUUID } from "crypto";
|
|
159
|
-
import { existsSync
|
|
71
|
+
import { existsSync, mkdirSync, readFileSync as readFileSync2, readdirSync, renameSync, statSync, writeFileSync as writeFileSync2 } from "fs";
|
|
160
72
|
import { homedir } from "os";
|
|
161
73
|
import { join } from "path";
|
|
162
74
|
var HISTORY_DAYS = 7;
|
|
@@ -186,9 +98,9 @@ function todayLocalIso(now = /* @__PURE__ */ new Date(), timezone) {
|
|
|
186
98
|
}
|
|
187
99
|
function readFile(codeName) {
|
|
188
100
|
const path = dailySessionPath(codeName);
|
|
189
|
-
if (!
|
|
101
|
+
if (!existsSync(path)) return { current: null, history: [] };
|
|
190
102
|
try {
|
|
191
|
-
const raw =
|
|
103
|
+
const raw = readFileSync2(path, "utf-8");
|
|
192
104
|
const parsed = JSON.parse(raw);
|
|
193
105
|
return {
|
|
194
106
|
current: parsed.current ?? null,
|
|
@@ -276,7 +188,7 @@ function sessionFileExists(projectDir, sessionId) {
|
|
|
276
188
|
encodeProjectPath(projectDir),
|
|
277
189
|
`${sessionId}.jsonl`
|
|
278
190
|
);
|
|
279
|
-
return
|
|
191
|
+
return existsSync(path);
|
|
280
192
|
}
|
|
281
193
|
function sessionTranscriptDir(projectDir) {
|
|
282
194
|
return join(homedir(), ".claude", "projects", encodeProjectPath(projectDir));
|
|
@@ -314,7 +226,7 @@ function subagentActivityAgeSeconds(projectDir, sessionId, now = /* @__PURE__ */
|
|
|
314
226
|
}
|
|
315
227
|
function isAgentIdle(projectDir, sessionId, idleSeconds = 60, now = /* @__PURE__ */ new Date()) {
|
|
316
228
|
const path = sessionFilePath(projectDir, sessionId);
|
|
317
|
-
if (!
|
|
229
|
+
if (!existsSync(path)) return true;
|
|
318
230
|
try {
|
|
319
231
|
const mtimeMs = statSync(path).mtimeMs;
|
|
320
232
|
return now.getTime() - mtimeMs >= idleSeconds * 1e3;
|
|
@@ -611,7 +523,7 @@ function syncClaudeCredsToRoot() {
|
|
|
611
523
|
if (platform() !== "linux") return true;
|
|
612
524
|
if (typeof process.getuid !== "function" || process.getuid() !== 0) return true;
|
|
613
525
|
for (const filename of [".credentials.json", "credentials.json"]) {
|
|
614
|
-
if (
|
|
526
|
+
if (existsSync2(join2("/root/.claude", filename))) return true;
|
|
615
527
|
}
|
|
616
528
|
let sourcePath = null;
|
|
617
529
|
try {
|
|
@@ -620,7 +532,7 @@ function syncClaudeCredsToRoot() {
|
|
|
620
532
|
if (!entry.isDirectory()) continue;
|
|
621
533
|
for (const filename of [".credentials.json", "credentials.json"]) {
|
|
622
534
|
const candidate = join2("/home", entry.name, ".claude", filename);
|
|
623
|
-
if (
|
|
535
|
+
if (existsSync2(candidate)) {
|
|
624
536
|
sourcePath = candidate;
|
|
625
537
|
break outer;
|
|
626
538
|
}
|
|
@@ -633,7 +545,7 @@ function syncClaudeCredsToRoot() {
|
|
|
633
545
|
const sourceFilename = sourcePath.endsWith("credentials.json") && !sourcePath.endsWith(".credentials.json") ? "credentials.json" : ".credentials.json";
|
|
634
546
|
const targetPath = join2(targetDir, sourceFilename);
|
|
635
547
|
try {
|
|
636
|
-
if (!
|
|
548
|
+
if (!existsSync2(targetDir)) mkdirSync2(targetDir, { recursive: true, mode: 448 });
|
|
637
549
|
copyFileSync(sourcePath, targetPath);
|
|
638
550
|
chmodSync(targetPath, 384);
|
|
639
551
|
return true;
|
|
@@ -645,13 +557,13 @@ var cachedClaudePath = null;
|
|
|
645
557
|
function resolveClaudeBinary() {
|
|
646
558
|
if (cachedClaudePath) return cachedClaudePath;
|
|
647
559
|
const override = process.env.CLAUDE_PATH;
|
|
648
|
-
if (override &&
|
|
560
|
+
if (override && existsSync2(override)) {
|
|
649
561
|
cachedClaudePath = override;
|
|
650
562
|
return override;
|
|
651
563
|
}
|
|
652
564
|
try {
|
|
653
565
|
const out = execSync("which claude 2>/dev/null", { encoding: "utf-8" }).trim();
|
|
654
|
-
if (out &&
|
|
566
|
+
if (out && existsSync2(out)) {
|
|
655
567
|
cachedClaudePath = out;
|
|
656
568
|
return out;
|
|
657
569
|
}
|
|
@@ -663,7 +575,7 @@ function resolveClaudeBinary() {
|
|
|
663
575
|
"/usr/local/bin/claude"
|
|
664
576
|
];
|
|
665
577
|
for (const p of candidates) {
|
|
666
|
-
if (
|
|
578
|
+
if (existsSync2(p)) {
|
|
667
579
|
cachedClaudePath = p;
|
|
668
580
|
return p;
|
|
669
581
|
}
|
|
@@ -681,7 +593,7 @@ function writePersistentClaudeWrapper(args) {
|
|
|
681
593
|
// --dangerously-skip-permissions on dedicated EC2 hosts.
|
|
682
594
|
"export IS_SANDBOX=1"
|
|
683
595
|
];
|
|
684
|
-
if (
|
|
596
|
+
if (existsSync2(envIntegrationsPath)) {
|
|
685
597
|
wrapperLines.push(
|
|
686
598
|
"set -a",
|
|
687
599
|
`source ${JSON.stringify(envIntegrationsPath)}`,
|
|
@@ -698,9 +610,9 @@ function writePersistentClaudeWrapper(args) {
|
|
|
698
610
|
return wrapperPath;
|
|
699
611
|
}
|
|
700
612
|
function collectMcpServerNames(mcpConfigPath) {
|
|
701
|
-
if (!
|
|
613
|
+
if (!existsSync2(mcpConfigPath)) return [];
|
|
702
614
|
try {
|
|
703
|
-
const data = JSON.parse(
|
|
615
|
+
const data = JSON.parse(readFileSync3(mcpConfigPath, "utf-8"));
|
|
704
616
|
const servers = data.mcpServers;
|
|
705
617
|
return servers ? Object.keys(servers) : [];
|
|
706
618
|
} catch {
|
|
@@ -734,9 +646,9 @@ function setupPaneLog(tmuxSession, codeName, log) {
|
|
|
734
646
|
}
|
|
735
647
|
function readPaneLogTail(codeName, lines = PANE_TAIL_LINES) {
|
|
736
648
|
const logPath = paneLogPath(codeName);
|
|
737
|
-
if (!
|
|
649
|
+
if (!existsSync2(logPath)) return null;
|
|
738
650
|
try {
|
|
739
|
-
const raw =
|
|
651
|
+
const raw = readFileSync3(logPath, "utf-8");
|
|
740
652
|
if (!raw) return null;
|
|
741
653
|
const stripped = raw.replace(/\x1b\[[0-9;?]*[A-Za-z]/g, "");
|
|
742
654
|
const all = stripped.split("\n").filter((l) => l.length > 0);
|
|
@@ -861,7 +773,7 @@ function spawnSession(config, session) {
|
|
|
861
773
|
const claudeDir = join2(homedir2(), ".claude");
|
|
862
774
|
for (const filename of [".credentials.json", "credentials.json"]) {
|
|
863
775
|
const p = join2(claudeDir, filename);
|
|
864
|
-
if (
|
|
776
|
+
if (existsSync2(p)) {
|
|
865
777
|
try {
|
|
866
778
|
rmSync(p, { force: true });
|
|
867
779
|
log(`[persistent-session] Removed ${p} (api_key mode active \u2014 preventing OAuth fallback)`);
|
|
@@ -906,7 +818,7 @@ function spawnSession(config, session) {
|
|
|
906
818
|
if (channels.length > 0) args.push("--channels", ...channels);
|
|
907
819
|
if (devChannels.length > 0) args.push("--dangerously-load-development-channels", ...devChannels);
|
|
908
820
|
args.push("--mcp-config", mcpConfigPath);
|
|
909
|
-
if (
|
|
821
|
+
if (existsSync2(claudeMdPath)) args.push("--system-prompt-file", claudeMdPath);
|
|
910
822
|
const modelAlias = claudeModelAlias(config.primaryModel);
|
|
911
823
|
if (modelAlias) args.push("--model", modelAlias);
|
|
912
824
|
args.push("--allow-dangerously-skip-permissions");
|
|
@@ -1445,10 +1357,6 @@ function getProjectDir(codeName) {
|
|
|
1445
1357
|
}
|
|
1446
1358
|
|
|
1447
1359
|
export {
|
|
1448
|
-
formatMissingVar,
|
|
1449
|
-
expandTemplateVars,
|
|
1450
|
-
parseEnvIntegrations,
|
|
1451
|
-
probeMcpEnvSubstitution,
|
|
1452
1360
|
sanitizeMcpJson,
|
|
1453
1361
|
buildAllowedTools,
|
|
1454
1362
|
sessionTranscriptDir,
|
|
@@ -1487,4 +1395,4 @@ export {
|
|
|
1487
1395
|
stopAllSessionsAndWait,
|
|
1488
1396
|
getProjectDir
|
|
1489
1397
|
};
|
|
1490
|
-
//# sourceMappingURL=chunk-
|
|
1398
|
+
//# sourceMappingURL=chunk-2BRF2FDJ.js.map
|