@integrity-labs/agt-cli 0.27.150-test.15 → 0.27.151
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-24FTY53Z.js → chunk-EI2FRRGG.js} +141 -50
- package/dist/chunk-EI2FRRGG.js.map +1 -0
- package/dist/{chunk-WOOYOAPG.js → chunk-K5XUY6PS.js} +127 -1
- package/dist/chunk-K5XUY6PS.js.map +1 -0
- package/dist/{chunk-7GKJZBTB.js → chunk-UF6HY7TN.js} +209 -52
- package/dist/chunk-UF6HY7TN.js.map +1 -0
- package/dist/{claude-pair-runtime-GIUCD7IG.js → claude-pair-runtime-AYMNAIYY.js} +2 -2
- package/dist/lib/manager-worker.js +395 -164
- package/dist/lib/manager-worker.js.map +1 -1
- package/dist/{persistent-session-35PWSTLO.js → persistent-session-CZQPV267.js} +3 -4
- package/dist/{responsiveness-probe-MA4M2QM4.js → responsiveness-probe-EW2ZLSZL.js} +3 -4
- package/dist/{responsiveness-probe-MA4M2QM4.js.map → responsiveness-probe-EW2ZLSZL.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-AYMNAIYY.js.map} +0 -0
- /package/dist/{daily-session-PNQX5URX.js.map → persistent-session-CZQPV267.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-K5XUY6PS.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, 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,165 @@ 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, 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 isAgentIdle(projectDir, sessionId, idleSeconds = 60, now = /* @__PURE__ */ new Date()) {
|
|
298
|
+
const path = sessionFilePath(projectDir, sessionId);
|
|
299
|
+
if (!existsSync2(path)) return true;
|
|
300
|
+
try {
|
|
301
|
+
const mtimeMs = statSync(path).mtimeMs;
|
|
302
|
+
return now.getTime() - mtimeMs >= idleSeconds * 1e3;
|
|
303
|
+
} catch {
|
|
304
|
+
return false;
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
function isStaleForToday(codeName, now = /* @__PURE__ */ new Date(), timezone) {
|
|
308
|
+
const file = readFile(codeName);
|
|
309
|
+
if (!file.current) return false;
|
|
310
|
+
return file.current.date !== todayLocalIso(now, timezone);
|
|
311
|
+
}
|
|
312
|
+
function peekCurrentSession(codeName) {
|
|
313
|
+
return readFile(codeName).current;
|
|
314
|
+
}
|
|
163
315
|
|
|
164
316
|
// ../../packages/core/dist/runtime/session-probe.js
|
|
165
317
|
import { execFileSync } from "child_process";
|
|
@@ -441,7 +593,7 @@ function syncClaudeCredsToRoot() {
|
|
|
441
593
|
if (platform() !== "linux") return true;
|
|
442
594
|
if (typeof process.getuid !== "function" || process.getuid() !== 0) return true;
|
|
443
595
|
for (const filename of [".credentials.json", "credentials.json"]) {
|
|
444
|
-
if (
|
|
596
|
+
if (existsSync3(join2("/root/.claude", filename))) return true;
|
|
445
597
|
}
|
|
446
598
|
let sourcePath = null;
|
|
447
599
|
try {
|
|
@@ -449,8 +601,8 @@ function syncClaudeCredsToRoot() {
|
|
|
449
601
|
outer: for (const entry of entries) {
|
|
450
602
|
if (!entry.isDirectory()) continue;
|
|
451
603
|
for (const filename of [".credentials.json", "credentials.json"]) {
|
|
452
|
-
const candidate =
|
|
453
|
-
if (
|
|
604
|
+
const candidate = join2("/home", entry.name, ".claude", filename);
|
|
605
|
+
if (existsSync3(candidate)) {
|
|
454
606
|
sourcePath = candidate;
|
|
455
607
|
break outer;
|
|
456
608
|
}
|
|
@@ -461,9 +613,9 @@ function syncClaudeCredsToRoot() {
|
|
|
461
613
|
if (!sourcePath) return false;
|
|
462
614
|
const targetDir = "/root/.claude";
|
|
463
615
|
const sourceFilename = sourcePath.endsWith("credentials.json") && !sourcePath.endsWith(".credentials.json") ? "credentials.json" : ".credentials.json";
|
|
464
|
-
const targetPath =
|
|
616
|
+
const targetPath = join2(targetDir, sourceFilename);
|
|
465
617
|
try {
|
|
466
|
-
if (!
|
|
618
|
+
if (!existsSync3(targetDir)) mkdirSync2(targetDir, { recursive: true, mode: 448 });
|
|
467
619
|
copyFileSync(sourcePath, targetPath);
|
|
468
620
|
chmodSync(targetPath, 384);
|
|
469
621
|
return true;
|
|
@@ -475,13 +627,13 @@ var cachedClaudePath = null;
|
|
|
475
627
|
function resolveClaudeBinary() {
|
|
476
628
|
if (cachedClaudePath) return cachedClaudePath;
|
|
477
629
|
const override = process.env.CLAUDE_PATH;
|
|
478
|
-
if (override &&
|
|
630
|
+
if (override && existsSync3(override)) {
|
|
479
631
|
cachedClaudePath = override;
|
|
480
632
|
return override;
|
|
481
633
|
}
|
|
482
634
|
try {
|
|
483
635
|
const out = execSync("which claude 2>/dev/null", { encoding: "utf-8" }).trim();
|
|
484
|
-
if (out &&
|
|
636
|
+
if (out && existsSync3(out)) {
|
|
485
637
|
cachedClaudePath = out;
|
|
486
638
|
return out;
|
|
487
639
|
}
|
|
@@ -493,7 +645,7 @@ function resolveClaudeBinary() {
|
|
|
493
645
|
"/usr/local/bin/claude"
|
|
494
646
|
];
|
|
495
647
|
for (const p of candidates) {
|
|
496
|
-
if (
|
|
648
|
+
if (existsSync3(p)) {
|
|
497
649
|
cachedClaudePath = p;
|
|
498
650
|
return p;
|
|
499
651
|
}
|
|
@@ -502,8 +654,8 @@ function resolveClaudeBinary() {
|
|
|
502
654
|
}
|
|
503
655
|
function writePersistentClaudeWrapper(args) {
|
|
504
656
|
const { projectDir, claudeBin, initPrompt, claudeArgsJoined } = args;
|
|
505
|
-
const envIntegrationsPath =
|
|
506
|
-
const wrapperPath =
|
|
657
|
+
const envIntegrationsPath = join2(projectDir, ".env.integrations");
|
|
658
|
+
const wrapperPath = join2(projectDir, ".claude", "persistent-claude.sh");
|
|
507
659
|
const wrapperLines = [
|
|
508
660
|
"#!/usr/bin/env bash",
|
|
509
661
|
"set -e",
|
|
@@ -511,7 +663,7 @@ function writePersistentClaudeWrapper(args) {
|
|
|
511
663
|
// --dangerously-skip-permissions on dedicated EC2 hosts.
|
|
512
664
|
"export IS_SANDBOX=1"
|
|
513
665
|
];
|
|
514
|
-
if (
|
|
666
|
+
if (existsSync3(envIntegrationsPath)) {
|
|
515
667
|
wrapperLines.push(
|
|
516
668
|
"set -a",
|
|
517
669
|
`source ${JSON.stringify(envIntegrationsPath)}`,
|
|
@@ -522,15 +674,15 @@ function writePersistentClaudeWrapper(args) {
|
|
|
522
674
|
wrapperLines.push(
|
|
523
675
|
`exec ${JSON.stringify(claudeBin)} ${initPromptArg}${claudeArgsJoined}`
|
|
524
676
|
);
|
|
525
|
-
|
|
526
|
-
|
|
677
|
+
mkdirSync2(join2(projectDir, ".claude"), { recursive: true });
|
|
678
|
+
writeFileSync3(wrapperPath, wrapperLines.join("\n") + "\n", { mode: 448 });
|
|
527
679
|
chmodSync(wrapperPath, 448);
|
|
528
680
|
return wrapperPath;
|
|
529
681
|
}
|
|
530
682
|
function collectMcpServerNames(mcpConfigPath) {
|
|
531
|
-
if (!
|
|
683
|
+
if (!existsSync3(mcpConfigPath)) return [];
|
|
532
684
|
try {
|
|
533
|
-
const data = JSON.parse(
|
|
685
|
+
const data = JSON.parse(readFileSync4(mcpConfigPath, "utf-8"));
|
|
534
686
|
const servers = data.mcpServers;
|
|
535
687
|
return servers ? Object.keys(servers) : [];
|
|
536
688
|
} catch {
|
|
@@ -543,8 +695,8 @@ function getAcpxBin() {
|
|
|
543
695
|
const moduleDir = dirname(fileURLToPath(import.meta.url));
|
|
544
696
|
let dir = moduleDir;
|
|
545
697
|
for (let i = 0; i < 6; i++) {
|
|
546
|
-
const candidate =
|
|
547
|
-
if (
|
|
698
|
+
const candidate = join2(dir, "node_modules", ".bin", "acpx");
|
|
699
|
+
if (existsSync3(candidate)) {
|
|
548
700
|
_acpxBin = candidate;
|
|
549
701
|
return _acpxBin;
|
|
550
702
|
}
|
|
@@ -592,15 +744,15 @@ function hasAcpxSession(acpxBin, projectDir, codeName) {
|
|
|
592
744
|
return available;
|
|
593
745
|
}
|
|
594
746
|
var sessions = /* @__PURE__ */ new Map();
|
|
595
|
-
var PANE_LOG_DIR =
|
|
747
|
+
var PANE_LOG_DIR = join2(homedir2(), ".augmented");
|
|
596
748
|
var PANE_TAIL_LINES = 20;
|
|
597
749
|
function paneLogPath(codeName) {
|
|
598
|
-
return
|
|
750
|
+
return join2(PANE_LOG_DIR, codeName, "pane.log");
|
|
599
751
|
}
|
|
600
752
|
function setupPaneLog(tmuxSession, codeName, log) {
|
|
601
753
|
const logPath = paneLogPath(codeName);
|
|
602
754
|
try {
|
|
603
|
-
|
|
755
|
+
mkdirSync2(dirname(logPath), { recursive: true });
|
|
604
756
|
appendFileSync(
|
|
605
757
|
logPath,
|
|
606
758
|
`
|
|
@@ -618,9 +770,9 @@ function setupPaneLog(tmuxSession, codeName, log) {
|
|
|
618
770
|
}
|
|
619
771
|
function readPaneLogTail(codeName, lines = PANE_TAIL_LINES) {
|
|
620
772
|
const logPath = paneLogPath(codeName);
|
|
621
|
-
if (!
|
|
773
|
+
if (!existsSync3(logPath)) return null;
|
|
622
774
|
try {
|
|
623
|
-
const raw =
|
|
775
|
+
const raw = readFileSync4(logPath, "utf-8");
|
|
624
776
|
if (!raw) return null;
|
|
625
777
|
const stripped = raw.replace(/\x1b\[[0-9;?]*[A-Za-z]/g, "");
|
|
626
778
|
const all = stripped.split("\n").filter((l) => l.length > 0);
|
|
@@ -675,7 +827,7 @@ function resolveSessionSpawnDecision(args) {
|
|
|
675
827
|
const disableFlag = process.env["AGT_DISABLE_SESSION_RESUME"];
|
|
676
828
|
const resumeDisabled = disableFlag === "1" || disableFlag?.toLowerCase() === "true";
|
|
677
829
|
if (resumeDisabled) {
|
|
678
|
-
return { flag: "--session-id", sessionId:
|
|
830
|
+
return { flag: "--session-id", sessionId: randomUUID2(), reason: "resume-disabled" };
|
|
679
831
|
}
|
|
680
832
|
const daily = getOrCreateDailySession(codeName, now, agentTimezone);
|
|
681
833
|
if (!daily.isNew && sessionFileExists(projectDir, daily.sessionId)) {
|
|
@@ -735,10 +887,10 @@ function spawnSession(config, session) {
|
|
|
735
887
|
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
888
|
}
|
|
737
889
|
} else {
|
|
738
|
-
const claudeDir =
|
|
890
|
+
const claudeDir = join2(homedir2(), ".claude");
|
|
739
891
|
for (const filename of [".credentials.json", "credentials.json"]) {
|
|
740
|
-
const p =
|
|
741
|
-
if (
|
|
892
|
+
const p = join2(claudeDir, filename);
|
|
893
|
+
if (existsSync3(p)) {
|
|
742
894
|
try {
|
|
743
895
|
rmSync(p, { force: true });
|
|
744
896
|
log(`[persistent-session] Removed ${p} (api_key mode active \u2014 preventing OAuth fallback)`);
|
|
@@ -772,7 +924,7 @@ function spawnSession(config, session) {
|
|
|
772
924
|
if (channels.length > 0) args.push("--channels", ...channels);
|
|
773
925
|
if (devChannels.length > 0) args.push("--dangerously-load-development-channels", ...devChannels);
|
|
774
926
|
args.push("--mcp-config", mcpConfigPath);
|
|
775
|
-
if (
|
|
927
|
+
if (existsSync3(claudeMdPath)) args.push("--system-prompt-file", claudeMdPath);
|
|
776
928
|
const modelAlias = claudeModelAlias(config.primaryModel);
|
|
777
929
|
if (modelAlias) args.push("--model", modelAlias);
|
|
778
930
|
args.push("--allow-dangerously-skip-permissions");
|
|
@@ -800,7 +952,7 @@ function spawnSession(config, session) {
|
|
|
800
952
|
// Treat empty-string as missing too — `HOME=""` makes ~ resolve
|
|
801
953
|
// to cwd, which is the same broken outcome as no HOME, just
|
|
802
954
|
// better hidden.
|
|
803
|
-
HOME: process.env.HOME?.trim() ||
|
|
955
|
+
HOME: process.env.HOME?.trim() || homedir2(),
|
|
804
956
|
USER: process.env.USER?.trim() || userInfo().username
|
|
805
957
|
};
|
|
806
958
|
if (config.runId) {
|
|
@@ -808,7 +960,7 @@ function spawnSession(config, session) {
|
|
|
808
960
|
}
|
|
809
961
|
for (const f of probeMcpEnvSubstitution({
|
|
810
962
|
mcpConfigPath,
|
|
811
|
-
envIntegrationsPath:
|
|
963
|
+
envIntegrationsPath: join2(projectDir, ".env.integrations"),
|
|
812
964
|
baseEnv: {
|
|
813
965
|
...tmuxEnv,
|
|
814
966
|
...claudeAuthMode === "api_key" && config.anthropicApiKey ? { ANTHROPIC_API_KEY: config.anthropicApiKey } : {}
|
|
@@ -1124,10 +1276,10 @@ async function injectMessageWithStatus(codeName, type, content, meta, log) {
|
|
|
1124
1276
|
const acpx = getAcpxBin();
|
|
1125
1277
|
if (acpx && hasAcpxSession(acpx, projectDir, codeName)) {
|
|
1126
1278
|
try {
|
|
1127
|
-
const tmpDir =
|
|
1128
|
-
|
|
1129
|
-
const tmpFile =
|
|
1130
|
-
|
|
1279
|
+
const tmpDir = join2(projectDir, ".claude");
|
|
1280
|
+
mkdirSync2(tmpDir, { recursive: true });
|
|
1281
|
+
const tmpFile = join2(tmpDir, ".agt-inject-prompt.txt");
|
|
1282
|
+
writeFileSync3(tmpFile, text);
|
|
1131
1283
|
_log(`[inject] acpx exec (fire-and-forget): cwd=${projectDir}, file=${tmpFile}`);
|
|
1132
1284
|
const child = spawn(acpx, ["claude", "exec", "-f", tmpFile], {
|
|
1133
1285
|
cwd: projectDir,
|
|
@@ -1377,7 +1529,7 @@ async function stopAllSessionsAndWait(log, opts) {
|
|
|
1377
1529
|
await new Promise((resolve) => setTimeout(resolve, Math.min(opts.timeoutMs, 2e3)));
|
|
1378
1530
|
}
|
|
1379
1531
|
function getProjectDir(codeName) {
|
|
1380
|
-
return
|
|
1532
|
+
return join2(homedir2(), ".augmented", codeName, "project");
|
|
1381
1533
|
}
|
|
1382
1534
|
function writeAcpxConfig(config) {
|
|
1383
1535
|
const {
|
|
@@ -1393,7 +1545,7 @@ function writeAcpxConfig(config) {
|
|
|
1393
1545
|
if (channels.length > 0) claudeArgs.push("--channels", ...channels);
|
|
1394
1546
|
if (devChannels.length > 0) claudeArgs.push("--dangerously-load-development-channels", ...devChannels);
|
|
1395
1547
|
claudeArgs.push("--mcp-config", mcpConfigPath);
|
|
1396
|
-
if (
|
|
1548
|
+
if (existsSync3(claudeMdPath)) claudeArgs.push("--system-prompt-file", claudeMdPath);
|
|
1397
1549
|
const acpModelAlias = claudeModelAlias(config.primaryModel);
|
|
1398
1550
|
if (acpModelAlias) claudeArgs.push("--model", acpModelAlias);
|
|
1399
1551
|
claudeArgs.push("--allow-dangerously-skip-permissions");
|
|
@@ -1402,18 +1554,18 @@ function writeAcpxConfig(config) {
|
|
|
1402
1554
|
const mcpServerNames2 = collectMcpServerNames(mcpConfigPath);
|
|
1403
1555
|
claudeArgs.push("--allowedTools", buildAllowedTools(mcpServerNames2));
|
|
1404
1556
|
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 =
|
|
1557
|
+
const envIntegrationsPath = join2(projectDir, ".env.integrations");
|
|
1558
|
+
const wrapperPath = join2(projectDir, ".claude", "acpx-agent.sh");
|
|
1407
1559
|
const wrapperLines = ["#!/usr/bin/env bash"];
|
|
1408
|
-
if (
|
|
1560
|
+
if (existsSync3(envIntegrationsPath)) {
|
|
1409
1561
|
wrapperLines.push(`set -a`, `source ${JSON.stringify(envIntegrationsPath)}`, `set +a`);
|
|
1410
1562
|
}
|
|
1411
1563
|
if (claudeAuthMode === "api_key" && anthropicApiKey) {
|
|
1412
1564
|
wrapperLines.push(`export ANTHROPIC_API_KEY=${JSON.stringify(anthropicApiKey)}`);
|
|
1413
1565
|
}
|
|
1414
1566
|
wrapperLines.push(`exec ${acpCmd}`);
|
|
1415
|
-
|
|
1416
|
-
|
|
1567
|
+
mkdirSync2(join2(projectDir, ".claude"), { recursive: true });
|
|
1568
|
+
writeFileSync3(wrapperPath, wrapperLines.join("\n") + "\n", { mode: 493 });
|
|
1417
1569
|
chmodSync(wrapperPath, 493);
|
|
1418
1570
|
const acpxConfig = {
|
|
1419
1571
|
defaultAgent: "claude",
|
|
@@ -1424,7 +1576,7 @@ function writeAcpxConfig(config) {
|
|
|
1424
1576
|
}
|
|
1425
1577
|
}
|
|
1426
1578
|
};
|
|
1427
|
-
|
|
1579
|
+
writeFileSync3(join2(projectDir, ".acpxrc.json"), JSON.stringify(acpxConfig, null, 2));
|
|
1428
1580
|
}
|
|
1429
1581
|
|
|
1430
1582
|
export {
|
|
@@ -1434,6 +1586,11 @@ export {
|
|
|
1434
1586
|
probeMcpEnvSubstitution,
|
|
1435
1587
|
sanitizeMcpJson,
|
|
1436
1588
|
buildAllowedTools,
|
|
1589
|
+
sessionTranscriptDir,
|
|
1590
|
+
transcriptActivityAgeSeconds,
|
|
1591
|
+
isAgentIdle,
|
|
1592
|
+
isStaleForToday,
|
|
1593
|
+
peekCurrentSession,
|
|
1437
1594
|
checkChannelInputs,
|
|
1438
1595
|
takeWatchdogGiveUpCount,
|
|
1439
1596
|
creditWatchdogGiveUpCount,
|
|
@@ -1464,4 +1621,4 @@ export {
|
|
|
1464
1621
|
stopAllSessionsAndWait,
|
|
1465
1622
|
getProjectDir
|
|
1466
1623
|
};
|
|
1467
|
-
//# sourceMappingURL=chunk-
|
|
1624
|
+
//# sourceMappingURL=chunk-UF6HY7TN.js.map
|