@integrity-labs/agt-cli 0.28.500 → 0.28.502
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 +4 -4
- package/dist/{chunk-XKBUTWON.js → chunk-HMBECQIY.js} +107 -84
- package/dist/chunk-HMBECQIY.js.map +1 -0
- package/dist/{chunk-ICNRQ4L5.js → chunk-KS762LYV.js} +443 -34
- package/dist/chunk-KS762LYV.js.map +1 -0
- package/dist/{claude-pair-runtime-U5ES3GOY.js → claude-pair-runtime-5GY4G7MD.js} +2 -2
- package/dist/lib/manager-worker.js +62 -340
- package/dist/lib/manager-worker.js.map +1 -1
- package/dist/{persistent-session-HL3LNPAX.js → persistent-session-ZW5HH2SC.js} +2 -2
- package/dist/{responsiveness-probe-AZ44ONES.js → responsiveness-probe-RAHKBJEE.js} +2 -2
- package/package.json +1 -1
- package/dist/chunk-ICNRQ4L5.js.map +0 -1
- package/dist/chunk-XKBUTWON.js.map +0 -1
- /package/dist/{claude-pair-runtime-U5ES3GOY.js.map → claude-pair-runtime-5GY4G7MD.js.map} +0 -0
- /package/dist/{persistent-session-HL3LNPAX.js.map → persistent-session-ZW5HH2SC.js.map} +0 -0
- /package/dist/{responsiveness-probe-AZ44ONES.js.map → responsiveness-probe-RAHKBJEE.js.map} +0 -0
package/dist/bin/agt.js
CHANGED
|
@@ -40,7 +40,7 @@ import {
|
|
|
40
40
|
success,
|
|
41
41
|
table,
|
|
42
42
|
warn
|
|
43
|
-
} from "../chunk-
|
|
43
|
+
} from "../chunk-KS762LYV.js";
|
|
44
44
|
import {
|
|
45
45
|
AnchorSessionClient,
|
|
46
46
|
CHANNEL_REGISTRY,
|
|
@@ -71,7 +71,7 @@ import {
|
|
|
71
71
|
requiredMcpWildcard,
|
|
72
72
|
resolveChannels,
|
|
73
73
|
serializeManifestForSlackCli
|
|
74
|
-
} from "../chunk-
|
|
74
|
+
} from "../chunk-HMBECQIY.js";
|
|
75
75
|
import "../chunk-XWVM4KPK.js";
|
|
76
76
|
|
|
77
77
|
// src/bin/agt.ts
|
|
@@ -4830,7 +4830,7 @@ import { execFileSync, execSync } from "child_process";
|
|
|
4830
4830
|
import { existsSync as existsSync10, realpathSync as realpathSync2 } from "fs";
|
|
4831
4831
|
import chalk18 from "chalk";
|
|
4832
4832
|
import ora16 from "ora";
|
|
4833
|
-
var cliVersion = true ? "0.28.
|
|
4833
|
+
var cliVersion = true ? "0.28.502" : "dev";
|
|
4834
4834
|
async function fetchLatestVersion() {
|
|
4835
4835
|
const host2 = getHost();
|
|
4836
4836
|
if (!host2) return null;
|
|
@@ -6002,7 +6002,7 @@ function handleError(err) {
|
|
|
6002
6002
|
}
|
|
6003
6003
|
|
|
6004
6004
|
// src/bin/agt.ts
|
|
6005
|
-
var cliVersion2 = true ? "0.28.
|
|
6005
|
+
var cliVersion2 = true ? "0.28.502" : "dev";
|
|
6006
6006
|
var program = new Command();
|
|
6007
6007
|
program.name("agt").description("Augmented CLI \u2014 agent provisioning and management").version(cliVersion2).option("--json", "Emit machine-readable JSON output (suppress spinners and colors)").option("--skip-update-check", "Skip the automatic update check on startup");
|
|
6008
6008
|
program.hook("preAction", async (thisCommand, actionCommand) => {
|
|
@@ -4,9 +4,9 @@ import {
|
|
|
4
4
|
|
|
5
5
|
// src/lib/persistent-session.ts
|
|
6
6
|
import { spawn as spawn2, execSync as execSync2, execFileSync as execFileSync3 } from "child_process";
|
|
7
|
-
import { join as
|
|
8
|
-
import { homedir as
|
|
9
|
-
import { existsSync as existsSync6, readFileSync as readFileSync7, readdirSync as readdirSync3, writeFileSync as writeFileSync5, appendFileSync as appendFileSync2, mkdirSync as mkdirSync5, chmodSync as chmodSync3, copyFileSync, rmSync as rmSync3, lstatSync, realpathSync, renameSync as renameSync2, statSync as statSync2 } from "fs";
|
|
7
|
+
import { join as join6, dirname as dirname4 } from "path";
|
|
8
|
+
import { homedir as homedir6, platform, userInfo as userInfo2 } from "os";
|
|
9
|
+
import { existsSync as existsSync6, readFileSync as readFileSync7, readdirSync as readdirSync3, writeFileSync as writeFileSync5, appendFileSync as appendFileSync2, mkdirSync as mkdirSync5, chmodSync as chmodSync3, copyFileSync, rmSync as rmSync3, lstatSync as lstatSync2, realpathSync as realpathSync2, renameSync as renameSync2, statSync as statSync2 } from "fs";
|
|
10
10
|
|
|
11
11
|
// src/lib/mcp-sanitize.ts
|
|
12
12
|
import { readFileSync, writeFileSync } from "fs";
|
|
@@ -10440,18 +10440,40 @@ function probeMcpEnvSubstitution(args) {
|
|
|
10440
10440
|
}
|
|
10441
10441
|
}
|
|
10442
10442
|
|
|
10443
|
+
// src/lib/agent-runtime-key.ts
|
|
10444
|
+
import { lstatSync, realpathSync } from "fs";
|
|
10445
|
+
import { basename, dirname, join } from "path";
|
|
10446
|
+
import { homedir } from "os";
|
|
10447
|
+
var AGENT_ID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
10448
|
+
function agentRuntimeKey(codeName, homeDir) {
|
|
10449
|
+
const home = homeDir ?? (process.env.HOME?.trim() || homedir());
|
|
10450
|
+
const codeNamePath = join(home, ".augmented", codeName);
|
|
10451
|
+
try {
|
|
10452
|
+
if (lstatSync(codeNamePath).isSymbolicLink()) {
|
|
10453
|
+
const augmentedDir = realpathSync(join(home, ".augmented"));
|
|
10454
|
+
const resolvedTarget = realpathSync(codeNamePath);
|
|
10455
|
+
const target = basename(resolvedTarget);
|
|
10456
|
+
if (dirname(resolvedTarget) === augmentedDir && AGENT_ID_RE.test(target)) {
|
|
10457
|
+
return target;
|
|
10458
|
+
}
|
|
10459
|
+
}
|
|
10460
|
+
} catch {
|
|
10461
|
+
}
|
|
10462
|
+
return codeName;
|
|
10463
|
+
}
|
|
10464
|
+
|
|
10443
10465
|
// src/lib/opencode-session.ts
|
|
10444
10466
|
import { spawn, execSync } from "child_process";
|
|
10445
10467
|
import { createServer } from "net";
|
|
10446
10468
|
import { randomBytes } from "crypto";
|
|
10447
10469
|
import { existsSync as existsSync4, mkdirSync as mkdirSync3, readFileSync as readFileSync5, writeFileSync as writeFileSync3, rmSync as rmSync2, chmodSync as chmodSync2 } from "fs";
|
|
10448
|
-
import { homedir as
|
|
10449
|
-
import { join as
|
|
10470
|
+
import { homedir as homedir4, userInfo } from "os";
|
|
10471
|
+
import { join as join4, dirname as dirname3 } from "path";
|
|
10450
10472
|
|
|
10451
10473
|
// ../../packages/core/dist/provisioning/frameworks/opencode/index.js
|
|
10452
10474
|
import { existsSync as existsSync2, mkdirSync, readFileSync as readFileSync3, writeFileSync as writeFileSync2, readdirSync, rmSync } from "fs";
|
|
10453
|
-
import { homedir } from "os";
|
|
10454
|
-
import { join } from "path";
|
|
10475
|
+
import { homedir as homedir2 } from "os";
|
|
10476
|
+
import { join as join2 } from "path";
|
|
10455
10477
|
|
|
10456
10478
|
// ../../packages/core/dist/provisioning/channel-env.js
|
|
10457
10479
|
function buildChannelCredentialEnv(channelId, config) {
|
|
@@ -11558,20 +11580,20 @@ function assertValidCodeName(codeName) {
|
|
|
11558
11580
|
}
|
|
11559
11581
|
}
|
|
11560
11582
|
function getHomeDir() {
|
|
11561
|
-
return process.env["HOME"] ?? process.env["USERPROFILE"] ??
|
|
11583
|
+
return process.env["HOME"] ?? process.env["USERPROFILE"] ?? homedir2();
|
|
11562
11584
|
}
|
|
11563
11585
|
function agentDir(codeName) {
|
|
11564
11586
|
assertValidCodeName(codeName);
|
|
11565
|
-
return
|
|
11587
|
+
return join2(getHomeDir(), ".augmented", codeName);
|
|
11566
11588
|
}
|
|
11567
11589
|
function provisionConfigDir(codeName) {
|
|
11568
|
-
return
|
|
11590
|
+
return join2(agentDir(codeName), "provision");
|
|
11569
11591
|
}
|
|
11570
11592
|
function mcpBundlePath() {
|
|
11571
|
-
return
|
|
11593
|
+
return join2(getHomeDir(), ".augmented", "_mcp", MCP_BUNDLE_BASENAME);
|
|
11572
11594
|
}
|
|
11573
11595
|
function configPath(codeName) {
|
|
11574
|
-
return
|
|
11596
|
+
return join2(provisionConfigDir(codeName), CONFIG_FILE);
|
|
11575
11597
|
}
|
|
11576
11598
|
function readConfig(codeName) {
|
|
11577
11599
|
const p2 = configPath(codeName);
|
|
@@ -11595,7 +11617,7 @@ function writeConfig(codeName, config) {
|
|
|
11595
11617
|
function upsertEnvIntegrations(codeName, updates) {
|
|
11596
11618
|
if (Object.keys(updates).length === 0)
|
|
11597
11619
|
return;
|
|
11598
|
-
const p2 =
|
|
11620
|
+
const p2 = join2(agentDir(codeName), ".env.integrations");
|
|
11599
11621
|
const lines = /* @__PURE__ */ new Map();
|
|
11600
11622
|
if (existsSync2(p2)) {
|
|
11601
11623
|
for (const line2 of readFileSync3(p2, "utf8").split("\n")) {
|
|
@@ -11611,7 +11633,7 @@ function upsertEnvIntegrations(codeName, updates) {
|
|
|
11611
11633
|
`, { mode: 384 });
|
|
11612
11634
|
}
|
|
11613
11635
|
function readEnvIntegrations(codeName) {
|
|
11614
|
-
const p2 =
|
|
11636
|
+
const p2 = join2(agentDir(codeName), ".env.integrations");
|
|
11615
11637
|
if (!existsSync2(p2))
|
|
11616
11638
|
return {};
|
|
11617
11639
|
const out = {};
|
|
@@ -11624,7 +11646,7 @@ function readEnvIntegrations(codeName) {
|
|
|
11624
11646
|
}
|
|
11625
11647
|
var INTEGRATION_KEYS_FILE = "integration-mcp-keys.json";
|
|
11626
11648
|
function readIntegrationServerKeys(codeName) {
|
|
11627
|
-
const p2 =
|
|
11649
|
+
const p2 = join2(agentDir(codeName), INTEGRATION_KEYS_FILE);
|
|
11628
11650
|
if (!existsSync2(p2))
|
|
11629
11651
|
return [];
|
|
11630
11652
|
try {
|
|
@@ -11636,7 +11658,7 @@ function readIntegrationServerKeys(codeName) {
|
|
|
11636
11658
|
}
|
|
11637
11659
|
function writeIntegrationServerKeys(codeName, keys) {
|
|
11638
11660
|
mkdirSync(agentDir(codeName), { recursive: true });
|
|
11639
|
-
writeFileSync2(
|
|
11661
|
+
writeFileSync2(join2(agentDir(codeName), INTEGRATION_KEYS_FILE), JSON.stringify([...keys].sort(), null, 2));
|
|
11640
11662
|
}
|
|
11641
11663
|
var ENV_SUBSTITUTION = /^\{env:([A-Za-z_][A-Za-z0-9_]*)\}$/;
|
|
11642
11664
|
function readChannelServerEnv(codeName, channelId) {
|
|
@@ -11701,25 +11723,25 @@ var opencodeAdapter = {
|
|
|
11701
11723
|
return configPath(codeName);
|
|
11702
11724
|
},
|
|
11703
11725
|
async getRegisteredAgents() {
|
|
11704
|
-
const root =
|
|
11726
|
+
const root = join2(getHomeDir(), ".augmented");
|
|
11705
11727
|
if (!existsSync2(root))
|
|
11706
11728
|
return /* @__PURE__ */ new Set();
|
|
11707
11729
|
const registered = /* @__PURE__ */ new Set();
|
|
11708
11730
|
for (const entry of readdirSync(root, { withFileTypes: true })) {
|
|
11709
11731
|
if (!entry.isDirectory())
|
|
11710
11732
|
continue;
|
|
11711
|
-
if (existsSync2(
|
|
11733
|
+
if (existsSync2(join2(root, entry.name, "registration.json")))
|
|
11712
11734
|
registered.add(entry.name);
|
|
11713
11735
|
}
|
|
11714
11736
|
return registered;
|
|
11715
11737
|
},
|
|
11716
11738
|
async registerAgent(codeName) {
|
|
11717
11739
|
mkdirSync(agentDir(codeName), { recursive: true });
|
|
11718
|
-
writeFileSync2(
|
|
11740
|
+
writeFileSync2(join2(agentDir(codeName), "registration.json"), JSON.stringify({ code_name: codeName, framework: FRAMEWORK_ID }, null, 2));
|
|
11719
11741
|
return true;
|
|
11720
11742
|
},
|
|
11721
11743
|
async deregisterAgent(codeName) {
|
|
11722
|
-
const marker =
|
|
11744
|
+
const marker = join2(agentDir(codeName), "registration.json");
|
|
11723
11745
|
if (existsSync2(marker))
|
|
11724
11746
|
rmSync(marker);
|
|
11725
11747
|
return true;
|
|
@@ -11729,7 +11751,7 @@ var opencodeAdapter = {
|
|
|
11729
11751
|
const lines = profiles.filter((p2) => p2.api_key).map((p2) => `${p2.provider.toUpperCase()}_API_KEY=${p2.api_key}`);
|
|
11730
11752
|
if (lines.length === 0)
|
|
11731
11753
|
return;
|
|
11732
|
-
writeFileSync2(
|
|
11754
|
+
writeFileSync2(join2(agentDir(codeName), ".env"), `${lines.join("\n")}
|
|
11733
11755
|
`, { mode: 384 });
|
|
11734
11756
|
},
|
|
11735
11757
|
writeMcpServer(codeName, serverId, config) {
|
|
@@ -11837,7 +11859,7 @@ var opencodeAdapter = {
|
|
|
11837
11859
|
const mcp = cfg["mcp"] ?? {};
|
|
11838
11860
|
mcp[channelId] = {
|
|
11839
11861
|
type: "local",
|
|
11840
|
-
command: ["node",
|
|
11862
|
+
command: ["node", join2(getHomeDir(), ".augmented", "_mcp", serverFile)],
|
|
11841
11863
|
environment,
|
|
11842
11864
|
enabled: options?.addBinding !== false
|
|
11843
11865
|
};
|
|
@@ -11873,7 +11895,7 @@ var opencodeAdapter = {
|
|
|
11873
11895
|
delivery_to: t.delivery_to ?? null
|
|
11874
11896
|
}));
|
|
11875
11897
|
mkdirSync(agentDir(codeName), { recursive: true });
|
|
11876
|
-
writeFileSync2(
|
|
11898
|
+
writeFileSync2(join2(agentDir(codeName), SCHEDULES_FILE), JSON.stringify({ schedules }, null, 2));
|
|
11877
11899
|
},
|
|
11878
11900
|
removeChannelCredentials(codeName, channelId) {
|
|
11879
11901
|
this.removeMcpServer?.(codeName, channelId);
|
|
@@ -11884,8 +11906,8 @@ registerFramework(opencodeAdapter);
|
|
|
11884
11906
|
// src/lib/manager/runtime.ts
|
|
11885
11907
|
import { createHash } from "crypto";
|
|
11886
11908
|
import { readFileSync as readFileSync4, appendFileSync, mkdirSync as mkdirSync2, chmodSync, existsSync as existsSync3 } from "fs";
|
|
11887
|
-
import { join as
|
|
11888
|
-
import { homedir as
|
|
11909
|
+
import { join as join3, dirname as dirname2 } from "path";
|
|
11910
|
+
import { homedir as homedir3 } from "os";
|
|
11889
11911
|
function redactForDiskLog(value) {
|
|
11890
11912
|
try {
|
|
11891
11913
|
return value.replace(/\b(Bearer\s+)[A-Za-z0-9._-]+\b/gi, "$1[REDACTED]").replace(/\bxox[baprs]-[A-Za-z0-9-]+\b/g, "[REDACTED-SLACK]").replace(/\btlk_[A-Za-z0-9._-]+\b/g, "[REDACTED-HOST]").replace(/\bsk-ant-[A-Za-z0-9_-]+\b/g, "[REDACTED-ANTHROPIC]").replace(/\b\d{8,12}:[A-Za-z0-9_-]{30,}\b/g, "[REDACTED-TELEGRAM]").replace(
|
|
@@ -11905,8 +11927,8 @@ function log(msg) {
|
|
|
11905
11927
|
`;
|
|
11906
11928
|
if (!managerLogPath) {
|
|
11907
11929
|
try {
|
|
11908
|
-
managerLogPath =
|
|
11909
|
-
mkdirSync2(
|
|
11930
|
+
managerLogPath = join3(homedir3(), ".augmented", "manager.log");
|
|
11931
|
+
mkdirSync2(dirname2(managerLogPath), { recursive: true });
|
|
11910
11932
|
if (existsSync3(managerLogPath)) {
|
|
11911
11933
|
chmodSync(managerLogPath, 384);
|
|
11912
11934
|
}
|
|
@@ -12263,10 +12285,10 @@ function opencodeTmuxSession(codeName) {
|
|
|
12263
12285
|
return `agt-oc-${codeName}`;
|
|
12264
12286
|
}
|
|
12265
12287
|
function opencodePaneLogPath(codeName) {
|
|
12266
|
-
return
|
|
12288
|
+
return join4(homedir4(), ".augmented", codeName, "opencode-serve.log");
|
|
12267
12289
|
}
|
|
12268
12290
|
function opencodeTranscriptPath(codeName) {
|
|
12269
|
-
return
|
|
12291
|
+
return join4(dirname3(opencodePaneLogPath(codeName)), "opencode-transcript.json");
|
|
12270
12292
|
}
|
|
12271
12293
|
var TRANSCRIPT_REFRESH_MS = 3e3;
|
|
12272
12294
|
var TRANSCRIPT_MAX_MESSAGES = 100;
|
|
@@ -12307,7 +12329,7 @@ async function refreshOpencodeTranscript(codeName) {
|
|
|
12307
12329
|
}
|
|
12308
12330
|
try {
|
|
12309
12331
|
const target = opencodeTranscriptPath(codeName);
|
|
12310
|
-
mkdirSync3(
|
|
12332
|
+
mkdirSync3(dirname3(target), { recursive: true });
|
|
12311
12333
|
writeFileSync3(target, JSON.stringify(transcript), { mode: 384 });
|
|
12312
12334
|
try {
|
|
12313
12335
|
chmodSync2(target, 384);
|
|
@@ -12333,7 +12355,7 @@ function stopTranscriptRefresher(codeName) {
|
|
|
12333
12355
|
}
|
|
12334
12356
|
}
|
|
12335
12357
|
function readProvisionedOpencodeModel(agentDir2) {
|
|
12336
|
-
return readOpencodeModelString(
|
|
12358
|
+
return readOpencodeModelString(join4(agentDir2, "provision", "opencode.json"));
|
|
12337
12359
|
}
|
|
12338
12360
|
function readOpencodeModelString(configPath2) {
|
|
12339
12361
|
try {
|
|
@@ -12344,7 +12366,7 @@ function readOpencodeModelString(configPath2) {
|
|
|
12344
12366
|
}
|
|
12345
12367
|
}
|
|
12346
12368
|
function readOpencodeModelFromConfigDir(configDir) {
|
|
12347
|
-
return parseOpencodeModelRef(readOpencodeModelString(
|
|
12369
|
+
return parseOpencodeModelRef(readOpencodeModelString(join4(configDir, "opencode.json")));
|
|
12348
12370
|
}
|
|
12349
12371
|
function materializeEnvPlaceholders(raw, env2) {
|
|
12350
12372
|
return raw.replace(/\{env:([A-Za-z_][A-Za-z0-9_]*)\}/g, (whole, name) => {
|
|
@@ -12355,8 +12377,8 @@ function materializeEnvPlaceholders(raw, env2) {
|
|
|
12355
12377
|
var MATERIALIZED_CONFIG_BASENAME = "opencode.jsonc";
|
|
12356
12378
|
function opencodeGlobalConfigPath(serveEnv) {
|
|
12357
12379
|
const xdg = serveEnv["XDG_CONFIG_HOME"]?.trim();
|
|
12358
|
-
const base = xdg && xdg.length > 0 ? xdg :
|
|
12359
|
-
return
|
|
12380
|
+
const base = xdg && xdg.length > 0 ? xdg : join4(serveEnv["HOME"]?.trim() || homedir4(), ".config");
|
|
12381
|
+
return join4(base, "opencode", "opencode.json");
|
|
12360
12382
|
}
|
|
12361
12383
|
function buildGlobalMcpConfig(materializedConfig) {
|
|
12362
12384
|
let parsed;
|
|
@@ -12376,7 +12398,7 @@ function buildGlobalMcpConfig(materializedConfig) {
|
|
|
12376
12398
|
}
|
|
12377
12399
|
function writeConfigFile600(target, content, codeName, log2) {
|
|
12378
12400
|
try {
|
|
12379
|
-
mkdirSync3(
|
|
12401
|
+
mkdirSync3(dirname3(target), { recursive: true });
|
|
12380
12402
|
writeFileSync3(target, content, { mode: 384 });
|
|
12381
12403
|
try {
|
|
12382
12404
|
chmodSync2(target, 384);
|
|
@@ -12389,11 +12411,11 @@ function writeConfigFile600(target, content, codeName, log2) {
|
|
|
12389
12411
|
}
|
|
12390
12412
|
}
|
|
12391
12413
|
function writeMaterializedOpencodeConfig(codeName, projectDir, serveEnv, log2) {
|
|
12392
|
-
const projectTarget =
|
|
12414
|
+
const projectTarget = join4(projectDir, MATERIALIZED_CONFIG_BASENAME);
|
|
12393
12415
|
const globalTarget = opencodeGlobalConfigPath(serveEnv);
|
|
12394
12416
|
let raw;
|
|
12395
12417
|
try {
|
|
12396
|
-
raw = readFileSync5(
|
|
12418
|
+
raw = readFileSync5(join4(projectDir, "opencode.json"), "utf-8");
|
|
12397
12419
|
} catch {
|
|
12398
12420
|
for (const t of [projectTarget, globalTarget]) {
|
|
12399
12421
|
try {
|
|
@@ -12502,7 +12524,7 @@ async function startOpencodeSession(config) {
|
|
|
12502
12524
|
}
|
|
12503
12525
|
async function spawnServe(config, session) {
|
|
12504
12526
|
const { codeName, projectDir, log: log2 } = config;
|
|
12505
|
-
if (!existsSync4(
|
|
12527
|
+
if (!existsSync4(join4(projectDir, "opencode.json"))) {
|
|
12506
12528
|
log2(`[opencode-session] warning: no opencode.json in ${projectDir} for '${codeName}' (provisioning may not have run)`);
|
|
12507
12529
|
}
|
|
12508
12530
|
const tmuxSession = opencodeTmuxSession(codeName);
|
|
@@ -12512,7 +12534,7 @@ async function spawnServe(config, session) {
|
|
|
12512
12534
|
execSync(`tmux kill-session -t ${tmuxSession} 2>/dev/null`, { stdio: "ignore" });
|
|
12513
12535
|
} catch {
|
|
12514
12536
|
}
|
|
12515
|
-
mkdirSync3(
|
|
12537
|
+
mkdirSync3(join4(homedir4(), ".augmented", codeName), { recursive: true });
|
|
12516
12538
|
const serveEnv = {
|
|
12517
12539
|
...process.env,
|
|
12518
12540
|
// ENG-7976: integration + channel credential secrets so the adapter's
|
|
@@ -12524,7 +12546,7 @@ async function spawnServe(config, session) {
|
|
|
12524
12546
|
...readAgentProviderEnv(codeName),
|
|
12525
12547
|
...stripUndefined(config.serveEnv ?? {}),
|
|
12526
12548
|
OPENCODE_SERVER_PASSWORD: password,
|
|
12527
|
-
HOME: process.env.HOME?.trim() ||
|
|
12549
|
+
HOME: process.env.HOME?.trim() || homedir4(),
|
|
12528
12550
|
USER: process.env.USER?.trim() || userInfo().username
|
|
12529
12551
|
};
|
|
12530
12552
|
if (config.runId) serveEnv["AGT_RUN_ID"] = config.runId;
|
|
@@ -12740,7 +12762,7 @@ function stripUndefined(env2) {
|
|
|
12740
12762
|
}
|
|
12741
12763
|
var PROVIDER_KEY_RE = /^[A-Z][A-Z0-9_]*_API_KEY$/;
|
|
12742
12764
|
function readAgentProviderEnv(codeName, dir) {
|
|
12743
|
-
const file =
|
|
12765
|
+
const file = join4(dir ?? join4(homedir4(), ".augmented", codeName), ".env");
|
|
12744
12766
|
const out = {};
|
|
12745
12767
|
try {
|
|
12746
12768
|
if (!existsSync4(file)) return out;
|
|
@@ -12776,7 +12798,7 @@ var INTEGRATIONS_ENV_BLOCKLIST = /* @__PURE__ */ new Set([
|
|
|
12776
12798
|
"DYLD_LIBRARY_PATH"
|
|
12777
12799
|
]);
|
|
12778
12800
|
function readAgentIntegrationsEnv(codeName, dir) {
|
|
12779
|
-
const file =
|
|
12801
|
+
const file = join4(dir ?? join4(homedir4(), ".augmented", codeName), ".env.integrations");
|
|
12780
12802
|
const out = {};
|
|
12781
12803
|
try {
|
|
12782
12804
|
if (!existsSync4(file)) return out;
|
|
@@ -12804,14 +12826,14 @@ import { randomUUID as randomUUID2 } from "crypto";
|
|
|
12804
12826
|
// src/lib/daily-session.ts
|
|
12805
12827
|
import { randomUUID } from "crypto";
|
|
12806
12828
|
import { existsSync as existsSync5, mkdirSync as mkdirSync4, readFileSync as readFileSync6, readdirSync as readdirSync2, renameSync, statSync, writeFileSync as writeFileSync4 } from "fs";
|
|
12807
|
-
import { homedir as
|
|
12808
|
-
import { join as
|
|
12829
|
+
import { homedir as homedir5 } from "os";
|
|
12830
|
+
import { join as join5 } from "path";
|
|
12809
12831
|
var HISTORY_DAYS = 7;
|
|
12810
12832
|
function profileDir(codeName) {
|
|
12811
|
-
return
|
|
12833
|
+
return join5(homedir5(), ".augmented", codeName);
|
|
12812
12834
|
}
|
|
12813
12835
|
function dailySessionPath(codeName) {
|
|
12814
|
-
return
|
|
12836
|
+
return join5(profileDir(codeName), "daily-session.json");
|
|
12815
12837
|
}
|
|
12816
12838
|
function todayLocalIso(now = /* @__PURE__ */ new Date(), timezone) {
|
|
12817
12839
|
if (timezone) {
|
|
@@ -12914,8 +12936,8 @@ function rotateDailySession(codeName, now = /* @__PURE__ */ new Date(), timezone
|
|
|
12914
12936
|
}
|
|
12915
12937
|
var encodeProjectPath = encodeClaudeProjectPath;
|
|
12916
12938
|
function sessionFileExists(projectDir, sessionId) {
|
|
12917
|
-
const path =
|
|
12918
|
-
|
|
12939
|
+
const path = join5(
|
|
12940
|
+
homedir5(),
|
|
12919
12941
|
".claude",
|
|
12920
12942
|
"projects",
|
|
12921
12943
|
encodeProjectPath(projectDir),
|
|
@@ -12924,10 +12946,10 @@ function sessionFileExists(projectDir, sessionId) {
|
|
|
12924
12946
|
return existsSync5(path);
|
|
12925
12947
|
}
|
|
12926
12948
|
function sessionTranscriptDir(projectDir) {
|
|
12927
|
-
return
|
|
12949
|
+
return join5(homedir5(), ".claude", "projects", encodeProjectPath(projectDir));
|
|
12928
12950
|
}
|
|
12929
12951
|
function sessionFilePath(projectDir, sessionId) {
|
|
12930
|
-
return
|
|
12952
|
+
return join5(sessionTranscriptDir(projectDir), `${sessionId}.jsonl`);
|
|
12931
12953
|
}
|
|
12932
12954
|
function transcriptActivityAgeSeconds(projectDir, sessionId, now = /* @__PURE__ */ new Date()) {
|
|
12933
12955
|
if (!sessionId) return null;
|
|
@@ -12940,13 +12962,13 @@ function transcriptActivityAgeSeconds(projectDir, sessionId, now = /* @__PURE__
|
|
|
12940
12962
|
}
|
|
12941
12963
|
function subagentActivityAgeSeconds(projectDir, sessionId, now = /* @__PURE__ */ new Date()) {
|
|
12942
12964
|
if (!sessionId) return null;
|
|
12943
|
-
const dir =
|
|
12965
|
+
const dir = join5(sessionTranscriptDir(projectDir), sessionId, "subagents");
|
|
12944
12966
|
try {
|
|
12945
12967
|
let freshestMtimeMs = null;
|
|
12946
12968
|
for (const name of readdirSync2(dir)) {
|
|
12947
12969
|
if (!name.endsWith(".jsonl")) continue;
|
|
12948
12970
|
try {
|
|
12949
|
-
const mtimeMs = statSync(
|
|
12971
|
+
const mtimeMs = statSync(join5(dir, name)).mtimeMs;
|
|
12950
12972
|
if (freshestMtimeMs === null || mtimeMs > freshestMtimeMs) freshestMtimeMs = mtimeMs;
|
|
12951
12973
|
} catch {
|
|
12952
12974
|
}
|
|
@@ -13345,7 +13367,7 @@ function syncClaudeCredsToRoot() {
|
|
|
13345
13367
|
if (platform() !== "linux") return true;
|
|
13346
13368
|
if (typeof process.getuid !== "function" || process.getuid() !== 0) return true;
|
|
13347
13369
|
for (const filename of [".credentials.json", "credentials.json"]) {
|
|
13348
|
-
if (existsSync6(
|
|
13370
|
+
if (existsSync6(join6("/root/.claude", filename))) return true;
|
|
13349
13371
|
}
|
|
13350
13372
|
let sourcePath = null;
|
|
13351
13373
|
try {
|
|
@@ -13353,7 +13375,7 @@ function syncClaudeCredsToRoot() {
|
|
|
13353
13375
|
outer: for (const entry of entries) {
|
|
13354
13376
|
if (!entry.isDirectory()) continue;
|
|
13355
13377
|
for (const filename of [".credentials.json", "credentials.json"]) {
|
|
13356
|
-
const candidate =
|
|
13378
|
+
const candidate = join6("/home", entry.name, ".claude", filename);
|
|
13357
13379
|
if (existsSync6(candidate)) {
|
|
13358
13380
|
sourcePath = candidate;
|
|
13359
13381
|
break outer;
|
|
@@ -13365,7 +13387,7 @@ function syncClaudeCredsToRoot() {
|
|
|
13365
13387
|
if (!sourcePath) return false;
|
|
13366
13388
|
const targetDir = "/root/.claude";
|
|
13367
13389
|
const sourceFilename = sourcePath.endsWith("credentials.json") && !sourcePath.endsWith(".credentials.json") ? "credentials.json" : ".credentials.json";
|
|
13368
|
-
const targetPath =
|
|
13390
|
+
const targetPath = join6(targetDir, sourceFilename);
|
|
13369
13391
|
try {
|
|
13370
13392
|
if (!existsSync6(targetDir)) mkdirSync5(targetDir, { recursive: true, mode: 448 });
|
|
13371
13393
|
copyFileSync(sourcePath, targetPath);
|
|
@@ -13444,12 +13466,12 @@ function buildEgressAllowlist(toolsFrontmatter) {
|
|
|
13444
13466
|
return [...domains].sort();
|
|
13445
13467
|
}
|
|
13446
13468
|
function egressAllowlistHostPath(codeName, homeDir) {
|
|
13447
|
-
const home = homeDir ?? (process.env.HOME?.trim() ||
|
|
13448
|
-
return
|
|
13469
|
+
const home = homeDir ?? (process.env.HOME?.trim() || homedir6());
|
|
13470
|
+
return join6(home, ".augmented", "_egress", `${agentRuntimeKey(codeName, home)}.txt`);
|
|
13449
13471
|
}
|
|
13450
13472
|
function writeEgressAllowlist(codeName, domains, homeDir) {
|
|
13451
13473
|
const p2 = egressAllowlistHostPath(codeName, homeDir);
|
|
13452
|
-
mkdirSync5(
|
|
13474
|
+
mkdirSync5(dirname4(p2), { recursive: true });
|
|
13453
13475
|
writeFileSync5(p2, domains.join("\n") + "\n", { mode: 420 });
|
|
13454
13476
|
return p2;
|
|
13455
13477
|
}
|
|
@@ -13486,11 +13508,11 @@ function restartEgressSidecar(codeName) {
|
|
|
13486
13508
|
function buildDockerRunCommand(args) {
|
|
13487
13509
|
const { codeName, agentId, wrapperPath, projectDir, homeDir, runId, passApiKey, passOpenRouter, egress, forwardSlackReplyBinding, forwardBlockTurnEndAllMarkers, forwardKanbanWaiting, forwardNotifyDispatch, forwardTurnFailureNotice } = args;
|
|
13488
13510
|
const q = (s) => `'${s.replace(/'/g, `'\\''`)}'`;
|
|
13489
|
-
const agentDir2 =
|
|
13490
|
-
const agentIdDir =
|
|
13491
|
-
const mcpDir =
|
|
13492
|
-
const claudeHome =
|
|
13493
|
-
const claudeJson =
|
|
13511
|
+
const agentDir2 = join6(homeDir, ".augmented", codeName);
|
|
13512
|
+
const agentIdDir = join6(homeDir, ".augmented", agentId);
|
|
13513
|
+
const mcpDir = join6(homeDir, ".augmented", "_mcp");
|
|
13514
|
+
const claudeHome = join6(homeDir, ".claude");
|
|
13515
|
+
const claudeJson = join6(homeDir, ".claude.json");
|
|
13494
13516
|
const mounts = [
|
|
13495
13517
|
`-v ${q(`${agentDir2}:${agentDir2}`)}`,
|
|
13496
13518
|
`-v ${q(`${agentIdDir}:${agentIdDir}`)}`,
|
|
@@ -13503,7 +13525,7 @@ function buildDockerRunCommand(args) {
|
|
|
13503
13525
|
const cpus = process.env.AGT_ISOLATION_CPUS || "1.0";
|
|
13504
13526
|
const pids = process.env.AGT_ISOLATION_PIDS || "512";
|
|
13505
13527
|
const envArgs = [`-e ${q(`HOME=${homeDir}`)}`];
|
|
13506
|
-
envArgs.push(`-e ${q(`npm_config_cache=${
|
|
13528
|
+
envArgs.push(`-e ${q(`npm_config_cache=${join6(agentDir2, ".npm-cache")}`)}`);
|
|
13507
13529
|
if (passApiKey) envArgs.push("-e ANTHROPIC_API_KEY");
|
|
13508
13530
|
if (passOpenRouter) {
|
|
13509
13531
|
envArgs.push("-e ANTHROPIC_BASE_URL");
|
|
@@ -13571,8 +13593,8 @@ function buildDockerRunCommand(args) {
|
|
|
13571
13593
|
}
|
|
13572
13594
|
function writePersistentClaudeWrapper(args) {
|
|
13573
13595
|
const { projectDir, claudeBin, initPrompt, claudeArgsJoined } = args;
|
|
13574
|
-
const envIntegrationsPath =
|
|
13575
|
-
const wrapperPath =
|
|
13596
|
+
const envIntegrationsPath = join6(projectDir, ".env.integrations");
|
|
13597
|
+
const wrapperPath = join6(projectDir, ".claude", "persistent-claude.sh");
|
|
13576
13598
|
const wrapperLines = [
|
|
13577
13599
|
"#!/usr/bin/env bash",
|
|
13578
13600
|
"set -e",
|
|
@@ -13591,7 +13613,7 @@ function writePersistentClaudeWrapper(args) {
|
|
|
13591
13613
|
wrapperLines.push(
|
|
13592
13614
|
`exec ${JSON.stringify(claudeBin)} ${initPromptArg}${claudeArgsJoined}`
|
|
13593
13615
|
);
|
|
13594
|
-
mkdirSync5(
|
|
13616
|
+
mkdirSync5(join6(projectDir, ".claude"), { recursive: true });
|
|
13595
13617
|
writeFileSync5(wrapperPath, wrapperLines.join("\n") + "\n", { mode: 448 });
|
|
13596
13618
|
chmodSync3(wrapperPath, 448);
|
|
13597
13619
|
return wrapperPath;
|
|
@@ -13607,15 +13629,15 @@ function collectMcpServerNames(mcpConfigPath) {
|
|
|
13607
13629
|
}
|
|
13608
13630
|
}
|
|
13609
13631
|
var sessions2 = /* @__PURE__ */ new Map();
|
|
13610
|
-
var PANE_LOG_DIR =
|
|
13632
|
+
var PANE_LOG_DIR = join6(homedir6(), ".augmented");
|
|
13611
13633
|
var PANE_TAIL_LINES = 20;
|
|
13612
13634
|
function paneLogPath(codeName) {
|
|
13613
|
-
return
|
|
13635
|
+
return join6(PANE_LOG_DIR, codeName, "pane.log");
|
|
13614
13636
|
}
|
|
13615
13637
|
function setupPaneLog2(tmuxSession, codeName, log2) {
|
|
13616
13638
|
const logPath = paneLogPath(codeName);
|
|
13617
13639
|
try {
|
|
13618
|
-
mkdirSync5(
|
|
13640
|
+
mkdirSync5(dirname4(logPath), { recursive: true });
|
|
13619
13641
|
appendFileSync2(
|
|
13620
13642
|
logPath,
|
|
13621
13643
|
`
|
|
@@ -13637,11 +13659,11 @@ function rotatePaneLogForDayRollover(codeName, log2, agentTimezone, now = /* @__
|
|
|
13637
13659
|
if (!existsSync6(logPath)) return null;
|
|
13638
13660
|
if (statSync2(logPath).size === 0) return null;
|
|
13639
13661
|
const stamp = todayLocalIso(now, agentTimezone ?? void 0).replace(/-/g, "");
|
|
13640
|
-
const dir =
|
|
13641
|
-
let target =
|
|
13662
|
+
const dir = dirname4(logPath);
|
|
13663
|
+
let target = join6(dir, `pane.log-${stamp}`);
|
|
13642
13664
|
if (existsSync6(target)) {
|
|
13643
13665
|
const hhmmss = now.toISOString().slice(11, 19).replace(/:/g, "");
|
|
13644
|
-
target =
|
|
13666
|
+
target = join6(dir, `pane.log-${stamp}-${hhmmss}`);
|
|
13645
13667
|
}
|
|
13646
13668
|
renameSync2(logPath, target);
|
|
13647
13669
|
writeFileSync5(logPath, "", "utf-8");
|
|
@@ -13728,7 +13750,7 @@ function resolveSessionSpawnDecision(args) {
|
|
|
13728
13750
|
};
|
|
13729
13751
|
}
|
|
13730
13752
|
function directChatSessionStatePath(agentId) {
|
|
13731
|
-
return
|
|
13753
|
+
return join6(homedir6(), ".augmented", agentId, "direct-chat-session.json");
|
|
13732
13754
|
}
|
|
13733
13755
|
function readDirectChatSessionState(agentId) {
|
|
13734
13756
|
try {
|
|
@@ -13743,7 +13765,7 @@ function readDirectChatSessionState(agentId) {
|
|
|
13743
13765
|
}
|
|
13744
13766
|
function writeDirectChatSessionState(agentId, state) {
|
|
13745
13767
|
const p2 = directChatSessionStatePath(agentId);
|
|
13746
|
-
mkdirSync5(
|
|
13768
|
+
mkdirSync5(dirname4(p2), { recursive: true });
|
|
13747
13769
|
writeFileSync5(p2, JSON.stringify(state));
|
|
13748
13770
|
}
|
|
13749
13771
|
function startPersistentSession(config) {
|
|
@@ -13800,9 +13822,9 @@ function spawnSession(config, session) {
|
|
|
13800
13822
|
log2(`[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.`);
|
|
13801
13823
|
}
|
|
13802
13824
|
} else {
|
|
13803
|
-
const claudeDir =
|
|
13825
|
+
const claudeDir = join6(homedir6(), ".claude");
|
|
13804
13826
|
for (const filename of [".credentials.json", "credentials.json"]) {
|
|
13805
|
-
const p2 =
|
|
13827
|
+
const p2 = join6(claudeDir, filename);
|
|
13806
13828
|
if (existsSync6(p2)) {
|
|
13807
13829
|
try {
|
|
13808
13830
|
rmSync3(p2, { force: true });
|
|
@@ -13900,7 +13922,7 @@ function spawnSession(config, session) {
|
|
|
13900
13922
|
if (config.turnFailureNoticeEnabled && !process.env["AGT_WEDGE_TRANSIENT_NOTICE_ENABLED"]) {
|
|
13901
13923
|
tmuxSessionEnvArgs.push("-e", "AGT_WEDGE_TRANSIENT_NOTICE_ENABLED=true");
|
|
13902
13924
|
}
|
|
13903
|
-
const sessionHomeDir = process.env.HOME?.trim() ||
|
|
13925
|
+
const sessionHomeDir = process.env.HOME?.trim() || homedir6();
|
|
13904
13926
|
let egress;
|
|
13905
13927
|
if (egressMode(codeName) === "allowlist") {
|
|
13906
13928
|
const allowlist = config.egressAllowlist ?? buildEgressAllowlist(null);
|
|
@@ -13946,7 +13968,7 @@ function spawnSession(config, session) {
|
|
|
13946
13968
|
// Treat empty-string as missing too — `HOME=""` makes ~ resolve
|
|
13947
13969
|
// to cwd, which is the same broken outcome as no HOME, just
|
|
13948
13970
|
// better hidden.
|
|
13949
|
-
HOME: process.env.HOME?.trim() ||
|
|
13971
|
+
HOME: process.env.HOME?.trim() || homedir6(),
|
|
13950
13972
|
USER: process.env.USER?.trim() || userInfo2().username
|
|
13951
13973
|
};
|
|
13952
13974
|
if (config.runId) {
|
|
@@ -13970,7 +13992,7 @@ function spawnSession(config, session) {
|
|
|
13970
13992
|
} : { ...tmuxEnv, ...apiKeyEnv, ...openRouterEnv };
|
|
13971
13993
|
for (const f of probeMcpEnvSubstitution({
|
|
13972
13994
|
mcpConfigPath,
|
|
13973
|
-
envIntegrationsPath:
|
|
13995
|
+
envIntegrationsPath: join6(projectDir, ".env.integrations"),
|
|
13974
13996
|
baseEnv: probeBaseEnv
|
|
13975
13997
|
})) {
|
|
13976
13998
|
log2(`[persistent-session] ${formatMissingVar(f)} agent=${codeName}`);
|
|
@@ -14541,15 +14563,15 @@ async function stopAllSessionsAndWait(log2, opts) {
|
|
|
14541
14563
|
}
|
|
14542
14564
|
function resolveRealAgentPath(codeNamePath) {
|
|
14543
14565
|
try {
|
|
14544
|
-
if (
|
|
14545
|
-
return
|
|
14566
|
+
if (lstatSync2(codeNamePath).isSymbolicLink()) {
|
|
14567
|
+
return realpathSync2(codeNamePath);
|
|
14546
14568
|
}
|
|
14547
14569
|
} catch {
|
|
14548
14570
|
}
|
|
14549
14571
|
return codeNamePath;
|
|
14550
14572
|
}
|
|
14551
14573
|
function getProjectDir(codeName) {
|
|
14552
|
-
return
|
|
14574
|
+
return join6(resolveRealAgentPath(join6(homedir6(), ".augmented", codeName)), "project");
|
|
14553
14575
|
}
|
|
14554
14576
|
|
|
14555
14577
|
export {
|
|
@@ -14673,6 +14695,7 @@ export {
|
|
|
14673
14695
|
LATE_BOUND_VARS,
|
|
14674
14696
|
expandTemplateVars,
|
|
14675
14697
|
parseEnvIntegrations,
|
|
14698
|
+
agentRuntimeKey,
|
|
14676
14699
|
log,
|
|
14677
14700
|
sha256,
|
|
14678
14701
|
hashFile,
|
|
@@ -14736,4 +14759,4 @@ export {
|
|
|
14736
14759
|
stopAllSessionsAndWait,
|
|
14737
14760
|
getProjectDir
|
|
14738
14761
|
};
|
|
14739
|
-
//# sourceMappingURL=chunk-
|
|
14762
|
+
//# sourceMappingURL=chunk-HMBECQIY.js.map
|