@integrity-labs/agt-cli 0.27.150-test.15 → 0.27.150-test.17
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 +13 -6
- package/dist/bin/agt.js.map +1 -1
- package/dist/{chunk-WOOYOAPG.js → chunk-FZTGR2AQ.js} +153 -20
- package/dist/chunk-FZTGR2AQ.js.map +1 -0
- package/dist/{chunk-7GKJZBTB.js → chunk-HXMLMIR4.js} +230 -53
- package/dist/chunk-HXMLMIR4.js.map +1 -0
- package/dist/{chunk-24FTY53Z.js → chunk-L2JA4OHU.js} +115 -3
- package/dist/chunk-L2JA4OHU.js.map +1 -0
- package/dist/{claude-pair-runtime-GIUCD7IG.js → claude-pair-runtime-QYJUJUYY.js} +2 -2
- package/dist/lib/manager-worker.js +422 -165
- package/dist/lib/manager-worker.js.map +1 -1
- package/dist/mcp/augmented-admin.js +42 -4
- package/dist/{persistent-session-35PWSTLO.js → persistent-session-IKQLTZZ6.js} +3 -4
- package/dist/{responsiveness-probe-MA4M2QM4.js → responsiveness-probe-2K4QHOWW.js} +3 -4
- package/dist/{responsiveness-probe-MA4M2QM4.js.map → responsiveness-probe-2K4QHOWW.js.map} +1 -1
- package/package.json +1 -1
- package/dist/chunk-24FTY53Z.js.map +0 -1
- package/dist/chunk-354FAVQR.js +0 -173
- package/dist/chunk-354FAVQR.js.map +0 -1
- package/dist/chunk-7GKJZBTB.js.map +0 -1
- package/dist/chunk-WOOYOAPG.js.map +0 -1
- package/dist/daily-session-PNQX5URX.js +0 -27
- package/dist/persistent-session-35PWSTLO.js.map +0 -1
- /package/dist/{claude-pair-runtime-GIUCD7IG.js.map → claude-pair-runtime-QYJUJUYY.js.map} +0 -0
- /package/dist/{daily-session-PNQX5URX.js.map → persistent-session-IKQLTZZ6.js.map} +0 -0
|
@@ -1,22 +1,16 @@
|
|
|
1
1
|
import {
|
|
2
2
|
claudeModelAlias,
|
|
3
3
|
isClaudeFastMode
|
|
4
|
-
} from "./chunk-
|
|
5
|
-
import {
|
|
6
|
-
getOrCreateDailySession,
|
|
7
|
-
markDailySessionSpawn,
|
|
8
|
-
rotateDailySession,
|
|
9
|
-
sessionFileExists
|
|
10
|
-
} from "./chunk-354FAVQR.js";
|
|
4
|
+
} from "./chunk-FZTGR2AQ.js";
|
|
11
5
|
import {
|
|
12
6
|
reapOrphanChannelMcps
|
|
13
7
|
} from "./chunk-XWVM4KPK.js";
|
|
14
8
|
|
|
15
9
|
// src/lib/persistent-session.ts
|
|
16
10
|
import { spawn, execSync, execFileSync as execFileSync3 } from "child_process";
|
|
17
|
-
import { join, dirname } from "path";
|
|
18
|
-
import { homedir, platform, userInfo } from "os";
|
|
19
|
-
import { existsSync as
|
|
11
|
+
import { join as join2, dirname } from "path";
|
|
12
|
+
import { homedir as homedir2, platform, userInfo } from "os";
|
|
13
|
+
import { existsSync as existsSync3, readFileSync as readFileSync4, readdirSync as readdirSync2, writeFileSync as writeFileSync3, appendFileSync, mkdirSync as mkdirSync2, chmodSync, copyFileSync, rmSync } from "fs";
|
|
20
14
|
import { fileURLToPath } from "url";
|
|
21
15
|
|
|
22
16
|
// src/lib/mcp-sanitize.ts
|
|
@@ -159,7 +153,184 @@ function probeMcpEnvSubstitution(args) {
|
|
|
159
153
|
}
|
|
160
154
|
|
|
161
155
|
// src/lib/persistent-session.ts
|
|
156
|
+
import { randomUUID as randomUUID2 } from "crypto";
|
|
157
|
+
|
|
158
|
+
// src/lib/daily-session.ts
|
|
162
159
|
import { randomUUID } from "crypto";
|
|
160
|
+
import { existsSync as existsSync2, mkdirSync, readFileSync as readFileSync3, readdirSync, renameSync, statSync, writeFileSync as writeFileSync2 } from "fs";
|
|
161
|
+
import { homedir } from "os";
|
|
162
|
+
import { join } from "path";
|
|
163
|
+
var HISTORY_DAYS = 7;
|
|
164
|
+
function profileDir(codeName) {
|
|
165
|
+
return join(homedir(), ".augmented", codeName);
|
|
166
|
+
}
|
|
167
|
+
function dailySessionPath(codeName) {
|
|
168
|
+
return join(profileDir(codeName), "daily-session.json");
|
|
169
|
+
}
|
|
170
|
+
function todayLocalIso(now = /* @__PURE__ */ new Date(), timezone) {
|
|
171
|
+
if (timezone) {
|
|
172
|
+
try {
|
|
173
|
+
const fmt = new Intl.DateTimeFormat("en-CA", {
|
|
174
|
+
timeZone: timezone,
|
|
175
|
+
year: "numeric",
|
|
176
|
+
month: "2-digit",
|
|
177
|
+
day: "2-digit"
|
|
178
|
+
});
|
|
179
|
+
return fmt.format(now);
|
|
180
|
+
} catch {
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
const y = now.getFullYear();
|
|
184
|
+
const m = String(now.getMonth() + 1).padStart(2, "0");
|
|
185
|
+
const d = String(now.getDate()).padStart(2, "0");
|
|
186
|
+
return `${y}-${m}-${d}`;
|
|
187
|
+
}
|
|
188
|
+
function readFile(codeName) {
|
|
189
|
+
const path = dailySessionPath(codeName);
|
|
190
|
+
if (!existsSync2(path)) return { current: null, history: [] };
|
|
191
|
+
try {
|
|
192
|
+
const raw = readFileSync3(path, "utf-8");
|
|
193
|
+
const parsed = JSON.parse(raw);
|
|
194
|
+
return {
|
|
195
|
+
current: parsed.current ?? null,
|
|
196
|
+
history: Array.isArray(parsed.history) ? parsed.history : []
|
|
197
|
+
};
|
|
198
|
+
} catch {
|
|
199
|
+
return { current: null, history: [] };
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
function writeFile(codeName, data) {
|
|
203
|
+
const dir = profileDir(codeName);
|
|
204
|
+
mkdirSync(dir, { recursive: true });
|
|
205
|
+
const finalPath = dailySessionPath(codeName);
|
|
206
|
+
const tmpPath = `${finalPath}.${process.pid}.${randomUUID()}.tmp`;
|
|
207
|
+
writeFileSync2(tmpPath, JSON.stringify(data, null, 2), "utf-8");
|
|
208
|
+
renameSync(tmpPath, finalPath);
|
|
209
|
+
}
|
|
210
|
+
function trimHistory(history, now, timezone) {
|
|
211
|
+
const cutoff = new Date(now);
|
|
212
|
+
cutoff.setDate(cutoff.getDate() - HISTORY_DAYS);
|
|
213
|
+
const cutoffIso = todayLocalIso(cutoff, timezone);
|
|
214
|
+
return history.filter((h) => h.date >= cutoffIso).slice(0, HISTORY_DAYS);
|
|
215
|
+
}
|
|
216
|
+
function getOrCreateDailySession(codeName, now = /* @__PURE__ */ new Date(), timezone) {
|
|
217
|
+
const today = todayLocalIso(now, timezone);
|
|
218
|
+
const file = readFile(codeName);
|
|
219
|
+
if (file.current && file.current.date === today) {
|
|
220
|
+
return { sessionId: file.current.sessionId, isNew: false };
|
|
221
|
+
}
|
|
222
|
+
const next = {
|
|
223
|
+
date: today,
|
|
224
|
+
sessionId: randomUUID(),
|
|
225
|
+
startedAt: now.toISOString()
|
|
226
|
+
};
|
|
227
|
+
const history = trimHistory(
|
|
228
|
+
[...file.current ? [file.current] : [], ...file.history],
|
|
229
|
+
now,
|
|
230
|
+
timezone
|
|
231
|
+
);
|
|
232
|
+
writeFile(codeName, { current: next, history });
|
|
233
|
+
return { sessionId: next.sessionId, isNew: true };
|
|
234
|
+
}
|
|
235
|
+
function markDailySessionSpawn(codeName, sessionId, now = /* @__PURE__ */ new Date(), timezone) {
|
|
236
|
+
const today = todayLocalIso(now, timezone);
|
|
237
|
+
const file = readFile(codeName);
|
|
238
|
+
if (file.current && file.current.date === today && file.current.sessionId === sessionId) {
|
|
239
|
+
return;
|
|
240
|
+
}
|
|
241
|
+
const next = {
|
|
242
|
+
date: today,
|
|
243
|
+
sessionId,
|
|
244
|
+
startedAt: now.toISOString()
|
|
245
|
+
};
|
|
246
|
+
const history = trimHistory(
|
|
247
|
+
[...file.current ? [file.current] : [], ...file.history],
|
|
248
|
+
now,
|
|
249
|
+
timezone
|
|
250
|
+
);
|
|
251
|
+
writeFile(codeName, { current: next, history });
|
|
252
|
+
}
|
|
253
|
+
function rotateDailySession(codeName, now = /* @__PURE__ */ new Date(), timezone) {
|
|
254
|
+
const today = todayLocalIso(now, timezone);
|
|
255
|
+
const file = readFile(codeName);
|
|
256
|
+
const next = {
|
|
257
|
+
date: today,
|
|
258
|
+
sessionId: randomUUID(),
|
|
259
|
+
startedAt: now.toISOString()
|
|
260
|
+
};
|
|
261
|
+
const history = trimHistory(
|
|
262
|
+
[...file.current ? [file.current] : [], ...file.history],
|
|
263
|
+
now,
|
|
264
|
+
timezone
|
|
265
|
+
);
|
|
266
|
+
writeFile(codeName, { current: next, history });
|
|
267
|
+
return next.sessionId;
|
|
268
|
+
}
|
|
269
|
+
function encodeProjectPath(projectDir) {
|
|
270
|
+
return "-" + projectDir.replace(/^\//, "").replace(/[/.]/g, "-");
|
|
271
|
+
}
|
|
272
|
+
function sessionFileExists(projectDir, sessionId) {
|
|
273
|
+
const path = join(
|
|
274
|
+
homedir(),
|
|
275
|
+
".claude",
|
|
276
|
+
"projects",
|
|
277
|
+
encodeProjectPath(projectDir),
|
|
278
|
+
`${sessionId}.jsonl`
|
|
279
|
+
);
|
|
280
|
+
return existsSync2(path);
|
|
281
|
+
}
|
|
282
|
+
function sessionTranscriptDir(projectDir) {
|
|
283
|
+
return join(homedir(), ".claude", "projects", encodeProjectPath(projectDir));
|
|
284
|
+
}
|
|
285
|
+
function sessionFilePath(projectDir, sessionId) {
|
|
286
|
+
return join(sessionTranscriptDir(projectDir), `${sessionId}.jsonl`);
|
|
287
|
+
}
|
|
288
|
+
function transcriptActivityAgeSeconds(projectDir, sessionId, now = /* @__PURE__ */ new Date()) {
|
|
289
|
+
if (!sessionId) return null;
|
|
290
|
+
try {
|
|
291
|
+
const mtimeMs = statSync(sessionFilePath(projectDir, sessionId)).mtimeMs;
|
|
292
|
+
return Math.max(0, Math.floor((now.getTime() - mtimeMs) / 1e3));
|
|
293
|
+
} catch {
|
|
294
|
+
return null;
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
function subagentActivityAgeSeconds(projectDir, sessionId, now = /* @__PURE__ */ new Date()) {
|
|
298
|
+
if (!sessionId) return null;
|
|
299
|
+
const dir = join(sessionTranscriptDir(projectDir), sessionId, "subagents");
|
|
300
|
+
try {
|
|
301
|
+
let freshestMtimeMs = null;
|
|
302
|
+
for (const name of readdirSync(dir)) {
|
|
303
|
+
if (!name.endsWith(".jsonl")) continue;
|
|
304
|
+
try {
|
|
305
|
+
const mtimeMs = statSync(join(dir, name)).mtimeMs;
|
|
306
|
+
if (freshestMtimeMs === null || mtimeMs > freshestMtimeMs) freshestMtimeMs = mtimeMs;
|
|
307
|
+
} catch {
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
if (freshestMtimeMs === null) return null;
|
|
311
|
+
return Math.max(0, Math.floor((now.getTime() - freshestMtimeMs) / 1e3));
|
|
312
|
+
} catch {
|
|
313
|
+
return null;
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
function isAgentIdle(projectDir, sessionId, idleSeconds = 60, now = /* @__PURE__ */ new Date()) {
|
|
317
|
+
const path = sessionFilePath(projectDir, sessionId);
|
|
318
|
+
if (!existsSync2(path)) return true;
|
|
319
|
+
try {
|
|
320
|
+
const mtimeMs = statSync(path).mtimeMs;
|
|
321
|
+
return now.getTime() - mtimeMs >= idleSeconds * 1e3;
|
|
322
|
+
} catch {
|
|
323
|
+
return false;
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
function isStaleForToday(codeName, now = /* @__PURE__ */ new Date(), timezone) {
|
|
327
|
+
const file = readFile(codeName);
|
|
328
|
+
if (!file.current) return false;
|
|
329
|
+
return file.current.date !== todayLocalIso(now, timezone);
|
|
330
|
+
}
|
|
331
|
+
function peekCurrentSession(codeName) {
|
|
332
|
+
return readFile(codeName).current;
|
|
333
|
+
}
|
|
163
334
|
|
|
164
335
|
// ../../packages/core/dist/runtime/session-probe.js
|
|
165
336
|
import { execFileSync } from "child_process";
|
|
@@ -441,16 +612,16 @@ function syncClaudeCredsToRoot() {
|
|
|
441
612
|
if (platform() !== "linux") return true;
|
|
442
613
|
if (typeof process.getuid !== "function" || process.getuid() !== 0) return true;
|
|
443
614
|
for (const filename of [".credentials.json", "credentials.json"]) {
|
|
444
|
-
if (
|
|
615
|
+
if (existsSync3(join2("/root/.claude", filename))) return true;
|
|
445
616
|
}
|
|
446
617
|
let sourcePath = null;
|
|
447
618
|
try {
|
|
448
|
-
const entries =
|
|
619
|
+
const entries = readdirSync2("/home", { withFileTypes: true });
|
|
449
620
|
outer: for (const entry of entries) {
|
|
450
621
|
if (!entry.isDirectory()) continue;
|
|
451
622
|
for (const filename of [".credentials.json", "credentials.json"]) {
|
|
452
|
-
const candidate =
|
|
453
|
-
if (
|
|
623
|
+
const candidate = join2("/home", entry.name, ".claude", filename);
|
|
624
|
+
if (existsSync3(candidate)) {
|
|
454
625
|
sourcePath = candidate;
|
|
455
626
|
break outer;
|
|
456
627
|
}
|
|
@@ -461,9 +632,9 @@ function syncClaudeCredsToRoot() {
|
|
|
461
632
|
if (!sourcePath) return false;
|
|
462
633
|
const targetDir = "/root/.claude";
|
|
463
634
|
const sourceFilename = sourcePath.endsWith("credentials.json") && !sourcePath.endsWith(".credentials.json") ? "credentials.json" : ".credentials.json";
|
|
464
|
-
const targetPath =
|
|
635
|
+
const targetPath = join2(targetDir, sourceFilename);
|
|
465
636
|
try {
|
|
466
|
-
if (!
|
|
637
|
+
if (!existsSync3(targetDir)) mkdirSync2(targetDir, { recursive: true, mode: 448 });
|
|
467
638
|
copyFileSync(sourcePath, targetPath);
|
|
468
639
|
chmodSync(targetPath, 384);
|
|
469
640
|
return true;
|
|
@@ -475,13 +646,13 @@ var cachedClaudePath = null;
|
|
|
475
646
|
function resolveClaudeBinary() {
|
|
476
647
|
if (cachedClaudePath) return cachedClaudePath;
|
|
477
648
|
const override = process.env.CLAUDE_PATH;
|
|
478
|
-
if (override &&
|
|
649
|
+
if (override && existsSync3(override)) {
|
|
479
650
|
cachedClaudePath = override;
|
|
480
651
|
return override;
|
|
481
652
|
}
|
|
482
653
|
try {
|
|
483
654
|
const out = execSync("which claude 2>/dev/null", { encoding: "utf-8" }).trim();
|
|
484
|
-
if (out &&
|
|
655
|
+
if (out && existsSync3(out)) {
|
|
485
656
|
cachedClaudePath = out;
|
|
486
657
|
return out;
|
|
487
658
|
}
|
|
@@ -493,7 +664,7 @@ function resolveClaudeBinary() {
|
|
|
493
664
|
"/usr/local/bin/claude"
|
|
494
665
|
];
|
|
495
666
|
for (const p of candidates) {
|
|
496
|
-
if (
|
|
667
|
+
if (existsSync3(p)) {
|
|
497
668
|
cachedClaudePath = p;
|
|
498
669
|
return p;
|
|
499
670
|
}
|
|
@@ -502,8 +673,8 @@ function resolveClaudeBinary() {
|
|
|
502
673
|
}
|
|
503
674
|
function writePersistentClaudeWrapper(args) {
|
|
504
675
|
const { projectDir, claudeBin, initPrompt, claudeArgsJoined } = args;
|
|
505
|
-
const envIntegrationsPath =
|
|
506
|
-
const wrapperPath =
|
|
676
|
+
const envIntegrationsPath = join2(projectDir, ".env.integrations");
|
|
677
|
+
const wrapperPath = join2(projectDir, ".claude", "persistent-claude.sh");
|
|
507
678
|
const wrapperLines = [
|
|
508
679
|
"#!/usr/bin/env bash",
|
|
509
680
|
"set -e",
|
|
@@ -511,7 +682,7 @@ function writePersistentClaudeWrapper(args) {
|
|
|
511
682
|
// --dangerously-skip-permissions on dedicated EC2 hosts.
|
|
512
683
|
"export IS_SANDBOX=1"
|
|
513
684
|
];
|
|
514
|
-
if (
|
|
685
|
+
if (existsSync3(envIntegrationsPath)) {
|
|
515
686
|
wrapperLines.push(
|
|
516
687
|
"set -a",
|
|
517
688
|
`source ${JSON.stringify(envIntegrationsPath)}`,
|
|
@@ -522,15 +693,15 @@ function writePersistentClaudeWrapper(args) {
|
|
|
522
693
|
wrapperLines.push(
|
|
523
694
|
`exec ${JSON.stringify(claudeBin)} ${initPromptArg}${claudeArgsJoined}`
|
|
524
695
|
);
|
|
525
|
-
|
|
526
|
-
|
|
696
|
+
mkdirSync2(join2(projectDir, ".claude"), { recursive: true });
|
|
697
|
+
writeFileSync3(wrapperPath, wrapperLines.join("\n") + "\n", { mode: 448 });
|
|
527
698
|
chmodSync(wrapperPath, 448);
|
|
528
699
|
return wrapperPath;
|
|
529
700
|
}
|
|
530
701
|
function collectMcpServerNames(mcpConfigPath) {
|
|
531
|
-
if (!
|
|
702
|
+
if (!existsSync3(mcpConfigPath)) return [];
|
|
532
703
|
try {
|
|
533
|
-
const data = JSON.parse(
|
|
704
|
+
const data = JSON.parse(readFileSync4(mcpConfigPath, "utf-8"));
|
|
534
705
|
const servers = data.mcpServers;
|
|
535
706
|
return servers ? Object.keys(servers) : [];
|
|
536
707
|
} catch {
|
|
@@ -543,8 +714,8 @@ function getAcpxBin() {
|
|
|
543
714
|
const moduleDir = dirname(fileURLToPath(import.meta.url));
|
|
544
715
|
let dir = moduleDir;
|
|
545
716
|
for (let i = 0; i < 6; i++) {
|
|
546
|
-
const candidate =
|
|
547
|
-
if (
|
|
717
|
+
const candidate = join2(dir, "node_modules", ".bin", "acpx");
|
|
718
|
+
if (existsSync3(candidate)) {
|
|
548
719
|
_acpxBin = candidate;
|
|
549
720
|
return _acpxBin;
|
|
550
721
|
}
|
|
@@ -592,15 +763,15 @@ function hasAcpxSession(acpxBin, projectDir, codeName) {
|
|
|
592
763
|
return available;
|
|
593
764
|
}
|
|
594
765
|
var sessions = /* @__PURE__ */ new Map();
|
|
595
|
-
var PANE_LOG_DIR =
|
|
766
|
+
var PANE_LOG_DIR = join2(homedir2(), ".augmented");
|
|
596
767
|
var PANE_TAIL_LINES = 20;
|
|
597
768
|
function paneLogPath(codeName) {
|
|
598
|
-
return
|
|
769
|
+
return join2(PANE_LOG_DIR, codeName, "pane.log");
|
|
599
770
|
}
|
|
600
771
|
function setupPaneLog(tmuxSession, codeName, log) {
|
|
601
772
|
const logPath = paneLogPath(codeName);
|
|
602
773
|
try {
|
|
603
|
-
|
|
774
|
+
mkdirSync2(dirname(logPath), { recursive: true });
|
|
604
775
|
appendFileSync(
|
|
605
776
|
logPath,
|
|
606
777
|
`
|
|
@@ -618,9 +789,9 @@ function setupPaneLog(tmuxSession, codeName, log) {
|
|
|
618
789
|
}
|
|
619
790
|
function readPaneLogTail(codeName, lines = PANE_TAIL_LINES) {
|
|
620
791
|
const logPath = paneLogPath(codeName);
|
|
621
|
-
if (!
|
|
792
|
+
if (!existsSync3(logPath)) return null;
|
|
622
793
|
try {
|
|
623
|
-
const raw =
|
|
794
|
+
const raw = readFileSync4(logPath, "utf-8");
|
|
624
795
|
if (!raw) return null;
|
|
625
796
|
const stripped = raw.replace(/\x1b\[[0-9;?]*[A-Za-z]/g, "");
|
|
626
797
|
const all = stripped.split("\n").filter((l) => l.length > 0);
|
|
@@ -675,7 +846,7 @@ function resolveSessionSpawnDecision(args) {
|
|
|
675
846
|
const disableFlag = process.env["AGT_DISABLE_SESSION_RESUME"];
|
|
676
847
|
const resumeDisabled = disableFlag === "1" || disableFlag?.toLowerCase() === "true";
|
|
677
848
|
if (resumeDisabled) {
|
|
678
|
-
return { flag: "--session-id", sessionId:
|
|
849
|
+
return { flag: "--session-id", sessionId: randomUUID2(), reason: "resume-disabled" };
|
|
679
850
|
}
|
|
680
851
|
const daily = getOrCreateDailySession(codeName, now, agentTimezone);
|
|
681
852
|
if (!daily.isNew && sessionFileExists(projectDir, daily.sessionId)) {
|
|
@@ -735,10 +906,10 @@ function spawnSession(config, session) {
|
|
|
735
906
|
log(`[persistent-session] No Claude Code credentials found under /root/.claude or /home/*. Pair via browser from the host page, or run 'claude /login' on the host.`);
|
|
736
907
|
}
|
|
737
908
|
} else {
|
|
738
|
-
const claudeDir =
|
|
909
|
+
const claudeDir = join2(homedir2(), ".claude");
|
|
739
910
|
for (const filename of [".credentials.json", "credentials.json"]) {
|
|
740
|
-
const p =
|
|
741
|
-
if (
|
|
911
|
+
const p = join2(claudeDir, filename);
|
|
912
|
+
if (existsSync3(p)) {
|
|
742
913
|
try {
|
|
743
914
|
rmSync(p, { force: true });
|
|
744
915
|
log(`[persistent-session] Removed ${p} (api_key mode active \u2014 preventing OAuth fallback)`);
|
|
@@ -772,7 +943,7 @@ function spawnSession(config, session) {
|
|
|
772
943
|
if (channels.length > 0) args.push("--channels", ...channels);
|
|
773
944
|
if (devChannels.length > 0) args.push("--dangerously-load-development-channels", ...devChannels);
|
|
774
945
|
args.push("--mcp-config", mcpConfigPath);
|
|
775
|
-
if (
|
|
946
|
+
if (existsSync3(claudeMdPath)) args.push("--system-prompt-file", claudeMdPath);
|
|
776
947
|
const modelAlias = claudeModelAlias(config.primaryModel);
|
|
777
948
|
if (modelAlias) args.push("--model", modelAlias);
|
|
778
949
|
args.push("--allow-dangerously-skip-permissions");
|
|
@@ -800,7 +971,7 @@ function spawnSession(config, session) {
|
|
|
800
971
|
// Treat empty-string as missing too — `HOME=""` makes ~ resolve
|
|
801
972
|
// to cwd, which is the same broken outcome as no HOME, just
|
|
802
973
|
// better hidden.
|
|
803
|
-
HOME: process.env.HOME?.trim() ||
|
|
974
|
+
HOME: process.env.HOME?.trim() || homedir2(),
|
|
804
975
|
USER: process.env.USER?.trim() || userInfo().username
|
|
805
976
|
};
|
|
806
977
|
if (config.runId) {
|
|
@@ -808,7 +979,7 @@ function spawnSession(config, session) {
|
|
|
808
979
|
}
|
|
809
980
|
for (const f of probeMcpEnvSubstitution({
|
|
810
981
|
mcpConfigPath,
|
|
811
|
-
envIntegrationsPath:
|
|
982
|
+
envIntegrationsPath: join2(projectDir, ".env.integrations"),
|
|
812
983
|
baseEnv: {
|
|
813
984
|
...tmuxEnv,
|
|
814
985
|
...claudeAuthMode === "api_key" && config.anthropicApiKey ? { ANTHROPIC_API_KEY: config.anthropicApiKey } : {}
|
|
@@ -1124,10 +1295,10 @@ async function injectMessageWithStatus(codeName, type, content, meta, log) {
|
|
|
1124
1295
|
const acpx = getAcpxBin();
|
|
1125
1296
|
if (acpx && hasAcpxSession(acpx, projectDir, codeName)) {
|
|
1126
1297
|
try {
|
|
1127
|
-
const tmpDir =
|
|
1128
|
-
|
|
1129
|
-
const tmpFile =
|
|
1130
|
-
|
|
1298
|
+
const tmpDir = join2(projectDir, ".claude");
|
|
1299
|
+
mkdirSync2(tmpDir, { recursive: true });
|
|
1300
|
+
const tmpFile = join2(tmpDir, ".agt-inject-prompt.txt");
|
|
1301
|
+
writeFileSync3(tmpFile, text);
|
|
1131
1302
|
_log(`[inject] acpx exec (fire-and-forget): cwd=${projectDir}, file=${tmpFile}`);
|
|
1132
1303
|
const child = spawn(acpx, ["claude", "exec", "-f", tmpFile], {
|
|
1133
1304
|
cwd: projectDir,
|
|
@@ -1377,7 +1548,7 @@ async function stopAllSessionsAndWait(log, opts) {
|
|
|
1377
1548
|
await new Promise((resolve) => setTimeout(resolve, Math.min(opts.timeoutMs, 2e3)));
|
|
1378
1549
|
}
|
|
1379
1550
|
function getProjectDir(codeName) {
|
|
1380
|
-
return
|
|
1551
|
+
return join2(homedir2(), ".augmented", codeName, "project");
|
|
1381
1552
|
}
|
|
1382
1553
|
function writeAcpxConfig(config) {
|
|
1383
1554
|
const {
|
|
@@ -1393,7 +1564,7 @@ function writeAcpxConfig(config) {
|
|
|
1393
1564
|
if (channels.length > 0) claudeArgs.push("--channels", ...channels);
|
|
1394
1565
|
if (devChannels.length > 0) claudeArgs.push("--dangerously-load-development-channels", ...devChannels);
|
|
1395
1566
|
claudeArgs.push("--mcp-config", mcpConfigPath);
|
|
1396
|
-
if (
|
|
1567
|
+
if (existsSync3(claudeMdPath)) claudeArgs.push("--system-prompt-file", claudeMdPath);
|
|
1397
1568
|
const acpModelAlias = claudeModelAlias(config.primaryModel);
|
|
1398
1569
|
if (acpModelAlias) claudeArgs.push("--model", acpModelAlias);
|
|
1399
1570
|
claudeArgs.push("--allow-dangerously-skip-permissions");
|
|
@@ -1402,18 +1573,18 @@ function writeAcpxConfig(config) {
|
|
|
1402
1573
|
const mcpServerNames2 = collectMcpServerNames(mcpConfigPath);
|
|
1403
1574
|
claudeArgs.push("--allowedTools", buildAllowedTools(mcpServerNames2));
|
|
1404
1575
|
const acpCmd = `npx -y @agentclientprotocol/claude-agent-acp ${claudeArgs.map((a) => a.includes(" ") || a.includes("*") ? JSON.stringify(a) : a).join(" ")}`;
|
|
1405
|
-
const envIntegrationsPath =
|
|
1406
|
-
const wrapperPath =
|
|
1576
|
+
const envIntegrationsPath = join2(projectDir, ".env.integrations");
|
|
1577
|
+
const wrapperPath = join2(projectDir, ".claude", "acpx-agent.sh");
|
|
1407
1578
|
const wrapperLines = ["#!/usr/bin/env bash"];
|
|
1408
|
-
if (
|
|
1579
|
+
if (existsSync3(envIntegrationsPath)) {
|
|
1409
1580
|
wrapperLines.push(`set -a`, `source ${JSON.stringify(envIntegrationsPath)}`, `set +a`);
|
|
1410
1581
|
}
|
|
1411
1582
|
if (claudeAuthMode === "api_key" && anthropicApiKey) {
|
|
1412
1583
|
wrapperLines.push(`export ANTHROPIC_API_KEY=${JSON.stringify(anthropicApiKey)}`);
|
|
1413
1584
|
}
|
|
1414
1585
|
wrapperLines.push(`exec ${acpCmd}`);
|
|
1415
|
-
|
|
1416
|
-
|
|
1586
|
+
mkdirSync2(join2(projectDir, ".claude"), { recursive: true });
|
|
1587
|
+
writeFileSync3(wrapperPath, wrapperLines.join("\n") + "\n", { mode: 493 });
|
|
1417
1588
|
chmodSync(wrapperPath, 493);
|
|
1418
1589
|
const acpxConfig = {
|
|
1419
1590
|
defaultAgent: "claude",
|
|
@@ -1424,7 +1595,7 @@ function writeAcpxConfig(config) {
|
|
|
1424
1595
|
}
|
|
1425
1596
|
}
|
|
1426
1597
|
};
|
|
1427
|
-
|
|
1598
|
+
writeFileSync3(join2(projectDir, ".acpxrc.json"), JSON.stringify(acpxConfig, null, 2));
|
|
1428
1599
|
}
|
|
1429
1600
|
|
|
1430
1601
|
export {
|
|
@@ -1434,6 +1605,12 @@ export {
|
|
|
1434
1605
|
probeMcpEnvSubstitution,
|
|
1435
1606
|
sanitizeMcpJson,
|
|
1436
1607
|
buildAllowedTools,
|
|
1608
|
+
sessionTranscriptDir,
|
|
1609
|
+
transcriptActivityAgeSeconds,
|
|
1610
|
+
subagentActivityAgeSeconds,
|
|
1611
|
+
isAgentIdle,
|
|
1612
|
+
isStaleForToday,
|
|
1613
|
+
peekCurrentSession,
|
|
1437
1614
|
checkChannelInputs,
|
|
1438
1615
|
takeWatchdogGiveUpCount,
|
|
1439
1616
|
creditWatchdogGiveUpCount,
|
|
@@ -1464,4 +1641,4 @@ export {
|
|
|
1464
1641
|
stopAllSessionsAndWait,
|
|
1465
1642
|
getProjectDir
|
|
1466
1643
|
};
|
|
1467
|
-
//# sourceMappingURL=chunk-
|
|
1644
|
+
//# sourceMappingURL=chunk-HXMLMIR4.js.map
|