@integrity-labs/agt-cli 0.28.501 → 0.28.503
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-GBSMIV4P.js} +130 -88
- package/dist/chunk-GBSMIV4P.js.map +1 -0
- package/dist/{chunk-N4Y5IBZR.js → chunk-GR375XXG.js} +3 -3
- package/dist/{claude-pair-runtime-U5ES3GOY.js → claude-pair-runtime-JEMJAZPB.js} +2 -2
- package/dist/lib/manager-worker.js +55 -22
- package/dist/lib/manager-worker.js.map +1 -1
- package/dist/mcp/direct-chat-channel.js +27 -10
- package/dist/mcp/origami.js +10 -2
- package/dist/mcp/slack-channel.js +10 -2
- package/dist/mcp/telegram-channel.js +10 -2
- package/dist/{persistent-session-HL3LNPAX.js → persistent-session-4PVEGHA5.js} +2 -2
- package/dist/{responsiveness-probe-AZ44ONES.js → responsiveness-probe-PNKFXRVF.js} +6 -3
- package/dist/responsiveness-probe-PNKFXRVF.js.map +1 -0
- package/package.json +1 -1
- package/dist/chunk-XKBUTWON.js.map +0 -1
- package/dist/responsiveness-probe-AZ44ONES.js.map +0 -1
- /package/dist/{chunk-N4Y5IBZR.js.map → chunk-GR375XXG.js.map} +0 -0
- /package/dist/{claude-pair-runtime-U5ES3GOY.js.map → claude-pair-runtime-JEMJAZPB.js.map} +0 -0
- /package/dist/{persistent-session-HL3LNPAX.js.map → persistent-session-4PVEGHA5.js.map} +0 -0
|
@@ -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";
|
|
@@ -7248,6 +7248,7 @@ var AGENT_DIRECTED_NOTICE_KINDS = ["scheduled_task_nudge", "kanban_check"];
|
|
|
7248
7248
|
var AGENT_DIRECTED_KIND_SET = new Set(AGENT_DIRECTED_NOTICE_KINDS);
|
|
7249
7249
|
|
|
7250
7250
|
// ../../packages/core/dist/direct-chat/cursor-advance.js
|
|
7251
|
+
var CURSOR_ADVANCE_NON_SHORTFALL_KEYS = ["advanced", "advanced_unreported", "failed"];
|
|
7251
7252
|
var CURSOR_SHORTFALL_REASONS = [
|
|
7252
7253
|
"not_found",
|
|
7253
7254
|
// ENG-8348: `/consume` only. The row belongs to this agent+session but was
|
|
@@ -7262,9 +7263,16 @@ var CURSOR_SHORTFALL_REASONS = [
|
|
|
7262
7263
|
"unknown",
|
|
7263
7264
|
"unreported",
|
|
7264
7265
|
"malformed_count",
|
|
7265
|
-
"other"
|
|
7266
|
+
"other",
|
|
7267
|
+
// ENG-8393: the non-shortfall outcomes — two benign, plus `failed`. Written
|
|
7268
|
+
// on the paths that previously wrote nothing, so a zero on the shortfall
|
|
7269
|
+
// reasons above becomes readable — see CURSOR_ADVANCE_NON_SHORTFALL_KEYS.
|
|
7270
|
+
"advanced",
|
|
7271
|
+
"advanced_unreported",
|
|
7272
|
+
"failed"
|
|
7266
7273
|
];
|
|
7267
|
-
var
|
|
7274
|
+
var NON_SHORTFALL_KEYS = new Set(CURSOR_ADVANCE_NON_SHORTFALL_KEYS);
|
|
7275
|
+
var KNOWN_REASONS = new Set(CURSOR_SHORTFALL_REASONS.filter((k) => !NON_SHORTFALL_KEYS.has(k)));
|
|
7268
7276
|
function normalizeCursorShortfallReason(raw) {
|
|
7269
7277
|
if (raw == null || raw === "")
|
|
7270
7278
|
return "unreported";
|
|
@@ -7274,7 +7282,7 @@ function classifyCursorAdvance(input) {
|
|
|
7274
7282
|
const body = input.body ?? void 0;
|
|
7275
7283
|
if (!input.httpOk || body?.error != null) {
|
|
7276
7284
|
const error = body?.error ?? input.statusText ?? (input.httpStatus !== void 0 ? `HTTP ${input.httpStatus}` : "request failed");
|
|
7277
|
-
return { outcome: "failed", error };
|
|
7285
|
+
return { outcome: "failed", error, expected: new Set(input.messageIds).size };
|
|
7278
7286
|
}
|
|
7279
7287
|
const expected = new Set(input.messageIds).size;
|
|
7280
7288
|
const raw = body?.consumed;
|
|
@@ -7306,6 +7314,17 @@ function classifyCursorAdvance(input) {
|
|
|
7306
7314
|
function cursorShortfallKey(route, reason, partial) {
|
|
7307
7315
|
return `${route}|${reason}|${partial ? "true" : "false"}`;
|
|
7308
7316
|
}
|
|
7317
|
+
function cursorAdvanceCounterKey(route, verdict) {
|
|
7318
|
+
if (verdict.expected === 0)
|
|
7319
|
+
return null;
|
|
7320
|
+
if (verdict.outcome === "shortfall") {
|
|
7321
|
+
return cursorShortfallKey(route, verdict.reason, verdict.partial);
|
|
7322
|
+
}
|
|
7323
|
+
if (verdict.outcome === "failed") {
|
|
7324
|
+
return cursorShortfallKey(route, "failed", false);
|
|
7325
|
+
}
|
|
7326
|
+
return cursorShortfallKey(route, verdict.reported ? "advanced" : "advanced_unreported", false);
|
|
7327
|
+
}
|
|
7309
7328
|
function formatCursorAdvanceShortfall(verdict, ctx) {
|
|
7310
7329
|
const cleared = ctx.cleared.length > 0 ? ctx.cleared.join(",") : "none";
|
|
7311
7330
|
return `[direct-chat] cursor advance shortfall route=/${ctx.route} site=${ctx.site} session=${ctx.sessionId} expected=${verdict.expected} consumed=${verdict.consumed} reason=${verdict.reason} partial=${verdict.partial} cleared_anyway=${cleared}`;
|
|
@@ -10440,18 +10459,40 @@ function probeMcpEnvSubstitution(args) {
|
|
|
10440
10459
|
}
|
|
10441
10460
|
}
|
|
10442
10461
|
|
|
10462
|
+
// src/lib/agent-runtime-key.ts
|
|
10463
|
+
import { lstatSync, realpathSync } from "fs";
|
|
10464
|
+
import { basename, dirname, join } from "path";
|
|
10465
|
+
import { homedir } from "os";
|
|
10466
|
+
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;
|
|
10467
|
+
function agentRuntimeKey(codeName, homeDir) {
|
|
10468
|
+
const home = homeDir ?? (process.env.HOME?.trim() || homedir());
|
|
10469
|
+
const codeNamePath = join(home, ".augmented", codeName);
|
|
10470
|
+
try {
|
|
10471
|
+
if (lstatSync(codeNamePath).isSymbolicLink()) {
|
|
10472
|
+
const augmentedDir = realpathSync(join(home, ".augmented"));
|
|
10473
|
+
const resolvedTarget = realpathSync(codeNamePath);
|
|
10474
|
+
const target = basename(resolvedTarget);
|
|
10475
|
+
if (dirname(resolvedTarget) === augmentedDir && AGENT_ID_RE.test(target)) {
|
|
10476
|
+
return target;
|
|
10477
|
+
}
|
|
10478
|
+
}
|
|
10479
|
+
} catch {
|
|
10480
|
+
}
|
|
10481
|
+
return codeName;
|
|
10482
|
+
}
|
|
10483
|
+
|
|
10443
10484
|
// src/lib/opencode-session.ts
|
|
10444
10485
|
import { spawn, execSync } from "child_process";
|
|
10445
10486
|
import { createServer } from "net";
|
|
10446
10487
|
import { randomBytes } from "crypto";
|
|
10447
10488
|
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
|
|
10489
|
+
import { homedir as homedir4, userInfo } from "os";
|
|
10490
|
+
import { join as join4, dirname as dirname3 } from "path";
|
|
10450
10491
|
|
|
10451
10492
|
// ../../packages/core/dist/provisioning/frameworks/opencode/index.js
|
|
10452
10493
|
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";
|
|
10494
|
+
import { homedir as homedir2 } from "os";
|
|
10495
|
+
import { join as join2 } from "path";
|
|
10455
10496
|
|
|
10456
10497
|
// ../../packages/core/dist/provisioning/channel-env.js
|
|
10457
10498
|
function buildChannelCredentialEnv(channelId, config) {
|
|
@@ -11558,20 +11599,20 @@ function assertValidCodeName(codeName) {
|
|
|
11558
11599
|
}
|
|
11559
11600
|
}
|
|
11560
11601
|
function getHomeDir() {
|
|
11561
|
-
return process.env["HOME"] ?? process.env["USERPROFILE"] ??
|
|
11602
|
+
return process.env["HOME"] ?? process.env["USERPROFILE"] ?? homedir2();
|
|
11562
11603
|
}
|
|
11563
11604
|
function agentDir(codeName) {
|
|
11564
11605
|
assertValidCodeName(codeName);
|
|
11565
|
-
return
|
|
11606
|
+
return join2(getHomeDir(), ".augmented", codeName);
|
|
11566
11607
|
}
|
|
11567
11608
|
function provisionConfigDir(codeName) {
|
|
11568
|
-
return
|
|
11609
|
+
return join2(agentDir(codeName), "provision");
|
|
11569
11610
|
}
|
|
11570
11611
|
function mcpBundlePath() {
|
|
11571
|
-
return
|
|
11612
|
+
return join2(getHomeDir(), ".augmented", "_mcp", MCP_BUNDLE_BASENAME);
|
|
11572
11613
|
}
|
|
11573
11614
|
function configPath(codeName) {
|
|
11574
|
-
return
|
|
11615
|
+
return join2(provisionConfigDir(codeName), CONFIG_FILE);
|
|
11575
11616
|
}
|
|
11576
11617
|
function readConfig(codeName) {
|
|
11577
11618
|
const p2 = configPath(codeName);
|
|
@@ -11595,7 +11636,7 @@ function writeConfig(codeName, config) {
|
|
|
11595
11636
|
function upsertEnvIntegrations(codeName, updates) {
|
|
11596
11637
|
if (Object.keys(updates).length === 0)
|
|
11597
11638
|
return;
|
|
11598
|
-
const p2 =
|
|
11639
|
+
const p2 = join2(agentDir(codeName), ".env.integrations");
|
|
11599
11640
|
const lines = /* @__PURE__ */ new Map();
|
|
11600
11641
|
if (existsSync2(p2)) {
|
|
11601
11642
|
for (const line2 of readFileSync3(p2, "utf8").split("\n")) {
|
|
@@ -11611,7 +11652,7 @@ function upsertEnvIntegrations(codeName, updates) {
|
|
|
11611
11652
|
`, { mode: 384 });
|
|
11612
11653
|
}
|
|
11613
11654
|
function readEnvIntegrations(codeName) {
|
|
11614
|
-
const p2 =
|
|
11655
|
+
const p2 = join2(agentDir(codeName), ".env.integrations");
|
|
11615
11656
|
if (!existsSync2(p2))
|
|
11616
11657
|
return {};
|
|
11617
11658
|
const out = {};
|
|
@@ -11624,7 +11665,7 @@ function readEnvIntegrations(codeName) {
|
|
|
11624
11665
|
}
|
|
11625
11666
|
var INTEGRATION_KEYS_FILE = "integration-mcp-keys.json";
|
|
11626
11667
|
function readIntegrationServerKeys(codeName) {
|
|
11627
|
-
const p2 =
|
|
11668
|
+
const p2 = join2(agentDir(codeName), INTEGRATION_KEYS_FILE);
|
|
11628
11669
|
if (!existsSync2(p2))
|
|
11629
11670
|
return [];
|
|
11630
11671
|
try {
|
|
@@ -11636,7 +11677,7 @@ function readIntegrationServerKeys(codeName) {
|
|
|
11636
11677
|
}
|
|
11637
11678
|
function writeIntegrationServerKeys(codeName, keys) {
|
|
11638
11679
|
mkdirSync(agentDir(codeName), { recursive: true });
|
|
11639
|
-
writeFileSync2(
|
|
11680
|
+
writeFileSync2(join2(agentDir(codeName), INTEGRATION_KEYS_FILE), JSON.stringify([...keys].sort(), null, 2));
|
|
11640
11681
|
}
|
|
11641
11682
|
var ENV_SUBSTITUTION = /^\{env:([A-Za-z_][A-Za-z0-9_]*)\}$/;
|
|
11642
11683
|
function readChannelServerEnv(codeName, channelId) {
|
|
@@ -11701,25 +11742,25 @@ var opencodeAdapter = {
|
|
|
11701
11742
|
return configPath(codeName);
|
|
11702
11743
|
},
|
|
11703
11744
|
async getRegisteredAgents() {
|
|
11704
|
-
const root =
|
|
11745
|
+
const root = join2(getHomeDir(), ".augmented");
|
|
11705
11746
|
if (!existsSync2(root))
|
|
11706
11747
|
return /* @__PURE__ */ new Set();
|
|
11707
11748
|
const registered = /* @__PURE__ */ new Set();
|
|
11708
11749
|
for (const entry of readdirSync(root, { withFileTypes: true })) {
|
|
11709
11750
|
if (!entry.isDirectory())
|
|
11710
11751
|
continue;
|
|
11711
|
-
if (existsSync2(
|
|
11752
|
+
if (existsSync2(join2(root, entry.name, "registration.json")))
|
|
11712
11753
|
registered.add(entry.name);
|
|
11713
11754
|
}
|
|
11714
11755
|
return registered;
|
|
11715
11756
|
},
|
|
11716
11757
|
async registerAgent(codeName) {
|
|
11717
11758
|
mkdirSync(agentDir(codeName), { recursive: true });
|
|
11718
|
-
writeFileSync2(
|
|
11759
|
+
writeFileSync2(join2(agentDir(codeName), "registration.json"), JSON.stringify({ code_name: codeName, framework: FRAMEWORK_ID }, null, 2));
|
|
11719
11760
|
return true;
|
|
11720
11761
|
},
|
|
11721
11762
|
async deregisterAgent(codeName) {
|
|
11722
|
-
const marker =
|
|
11763
|
+
const marker = join2(agentDir(codeName), "registration.json");
|
|
11723
11764
|
if (existsSync2(marker))
|
|
11724
11765
|
rmSync(marker);
|
|
11725
11766
|
return true;
|
|
@@ -11729,7 +11770,7 @@ var opencodeAdapter = {
|
|
|
11729
11770
|
const lines = profiles.filter((p2) => p2.api_key).map((p2) => `${p2.provider.toUpperCase()}_API_KEY=${p2.api_key}`);
|
|
11730
11771
|
if (lines.length === 0)
|
|
11731
11772
|
return;
|
|
11732
|
-
writeFileSync2(
|
|
11773
|
+
writeFileSync2(join2(agentDir(codeName), ".env"), `${lines.join("\n")}
|
|
11733
11774
|
`, { mode: 384 });
|
|
11734
11775
|
},
|
|
11735
11776
|
writeMcpServer(codeName, serverId, config) {
|
|
@@ -11837,7 +11878,7 @@ var opencodeAdapter = {
|
|
|
11837
11878
|
const mcp = cfg["mcp"] ?? {};
|
|
11838
11879
|
mcp[channelId] = {
|
|
11839
11880
|
type: "local",
|
|
11840
|
-
command: ["node",
|
|
11881
|
+
command: ["node", join2(getHomeDir(), ".augmented", "_mcp", serverFile)],
|
|
11841
11882
|
environment,
|
|
11842
11883
|
enabled: options?.addBinding !== false
|
|
11843
11884
|
};
|
|
@@ -11873,7 +11914,7 @@ var opencodeAdapter = {
|
|
|
11873
11914
|
delivery_to: t.delivery_to ?? null
|
|
11874
11915
|
}));
|
|
11875
11916
|
mkdirSync(agentDir(codeName), { recursive: true });
|
|
11876
|
-
writeFileSync2(
|
|
11917
|
+
writeFileSync2(join2(agentDir(codeName), SCHEDULES_FILE), JSON.stringify({ schedules }, null, 2));
|
|
11877
11918
|
},
|
|
11878
11919
|
removeChannelCredentials(codeName, channelId) {
|
|
11879
11920
|
this.removeMcpServer?.(codeName, channelId);
|
|
@@ -11884,8 +11925,8 @@ registerFramework(opencodeAdapter);
|
|
|
11884
11925
|
// src/lib/manager/runtime.ts
|
|
11885
11926
|
import { createHash } from "crypto";
|
|
11886
11927
|
import { readFileSync as readFileSync4, appendFileSync, mkdirSync as mkdirSync2, chmodSync, existsSync as existsSync3 } from "fs";
|
|
11887
|
-
import { join as
|
|
11888
|
-
import { homedir as
|
|
11928
|
+
import { join as join3, dirname as dirname2 } from "path";
|
|
11929
|
+
import { homedir as homedir3 } from "os";
|
|
11889
11930
|
function redactForDiskLog(value) {
|
|
11890
11931
|
try {
|
|
11891
11932
|
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 +11946,8 @@ function log(msg) {
|
|
|
11905
11946
|
`;
|
|
11906
11947
|
if (!managerLogPath) {
|
|
11907
11948
|
try {
|
|
11908
|
-
managerLogPath =
|
|
11909
|
-
mkdirSync2(
|
|
11949
|
+
managerLogPath = join3(homedir3(), ".augmented", "manager.log");
|
|
11950
|
+
mkdirSync2(dirname2(managerLogPath), { recursive: true });
|
|
11910
11951
|
if (existsSync3(managerLogPath)) {
|
|
11911
11952
|
chmodSync(managerLogPath, 384);
|
|
11912
11953
|
}
|
|
@@ -12263,10 +12304,10 @@ function opencodeTmuxSession(codeName) {
|
|
|
12263
12304
|
return `agt-oc-${codeName}`;
|
|
12264
12305
|
}
|
|
12265
12306
|
function opencodePaneLogPath(codeName) {
|
|
12266
|
-
return
|
|
12307
|
+
return join4(homedir4(), ".augmented", codeName, "opencode-serve.log");
|
|
12267
12308
|
}
|
|
12268
12309
|
function opencodeTranscriptPath(codeName) {
|
|
12269
|
-
return
|
|
12310
|
+
return join4(dirname3(opencodePaneLogPath(codeName)), "opencode-transcript.json");
|
|
12270
12311
|
}
|
|
12271
12312
|
var TRANSCRIPT_REFRESH_MS = 3e3;
|
|
12272
12313
|
var TRANSCRIPT_MAX_MESSAGES = 100;
|
|
@@ -12307,7 +12348,7 @@ async function refreshOpencodeTranscript(codeName) {
|
|
|
12307
12348
|
}
|
|
12308
12349
|
try {
|
|
12309
12350
|
const target = opencodeTranscriptPath(codeName);
|
|
12310
|
-
mkdirSync3(
|
|
12351
|
+
mkdirSync3(dirname3(target), { recursive: true });
|
|
12311
12352
|
writeFileSync3(target, JSON.stringify(transcript), { mode: 384 });
|
|
12312
12353
|
try {
|
|
12313
12354
|
chmodSync2(target, 384);
|
|
@@ -12333,7 +12374,7 @@ function stopTranscriptRefresher(codeName) {
|
|
|
12333
12374
|
}
|
|
12334
12375
|
}
|
|
12335
12376
|
function readProvisionedOpencodeModel(agentDir2) {
|
|
12336
|
-
return readOpencodeModelString(
|
|
12377
|
+
return readOpencodeModelString(join4(agentDir2, "provision", "opencode.json"));
|
|
12337
12378
|
}
|
|
12338
12379
|
function readOpencodeModelString(configPath2) {
|
|
12339
12380
|
try {
|
|
@@ -12344,7 +12385,7 @@ function readOpencodeModelString(configPath2) {
|
|
|
12344
12385
|
}
|
|
12345
12386
|
}
|
|
12346
12387
|
function readOpencodeModelFromConfigDir(configDir) {
|
|
12347
|
-
return parseOpencodeModelRef(readOpencodeModelString(
|
|
12388
|
+
return parseOpencodeModelRef(readOpencodeModelString(join4(configDir, "opencode.json")));
|
|
12348
12389
|
}
|
|
12349
12390
|
function materializeEnvPlaceholders(raw, env2) {
|
|
12350
12391
|
return raw.replace(/\{env:([A-Za-z_][A-Za-z0-9_]*)\}/g, (whole, name) => {
|
|
@@ -12355,8 +12396,8 @@ function materializeEnvPlaceholders(raw, env2) {
|
|
|
12355
12396
|
var MATERIALIZED_CONFIG_BASENAME = "opencode.jsonc";
|
|
12356
12397
|
function opencodeGlobalConfigPath(serveEnv) {
|
|
12357
12398
|
const xdg = serveEnv["XDG_CONFIG_HOME"]?.trim();
|
|
12358
|
-
const base = xdg && xdg.length > 0 ? xdg :
|
|
12359
|
-
return
|
|
12399
|
+
const base = xdg && xdg.length > 0 ? xdg : join4(serveEnv["HOME"]?.trim() || homedir4(), ".config");
|
|
12400
|
+
return join4(base, "opencode", "opencode.json");
|
|
12360
12401
|
}
|
|
12361
12402
|
function buildGlobalMcpConfig(materializedConfig) {
|
|
12362
12403
|
let parsed;
|
|
@@ -12376,7 +12417,7 @@ function buildGlobalMcpConfig(materializedConfig) {
|
|
|
12376
12417
|
}
|
|
12377
12418
|
function writeConfigFile600(target, content, codeName, log2) {
|
|
12378
12419
|
try {
|
|
12379
|
-
mkdirSync3(
|
|
12420
|
+
mkdirSync3(dirname3(target), { recursive: true });
|
|
12380
12421
|
writeFileSync3(target, content, { mode: 384 });
|
|
12381
12422
|
try {
|
|
12382
12423
|
chmodSync2(target, 384);
|
|
@@ -12389,11 +12430,11 @@ function writeConfigFile600(target, content, codeName, log2) {
|
|
|
12389
12430
|
}
|
|
12390
12431
|
}
|
|
12391
12432
|
function writeMaterializedOpencodeConfig(codeName, projectDir, serveEnv, log2) {
|
|
12392
|
-
const projectTarget =
|
|
12433
|
+
const projectTarget = join4(projectDir, MATERIALIZED_CONFIG_BASENAME);
|
|
12393
12434
|
const globalTarget = opencodeGlobalConfigPath(serveEnv);
|
|
12394
12435
|
let raw;
|
|
12395
12436
|
try {
|
|
12396
|
-
raw = readFileSync5(
|
|
12437
|
+
raw = readFileSync5(join4(projectDir, "opencode.json"), "utf-8");
|
|
12397
12438
|
} catch {
|
|
12398
12439
|
for (const t of [projectTarget, globalTarget]) {
|
|
12399
12440
|
try {
|
|
@@ -12502,7 +12543,7 @@ async function startOpencodeSession(config) {
|
|
|
12502
12543
|
}
|
|
12503
12544
|
async function spawnServe(config, session) {
|
|
12504
12545
|
const { codeName, projectDir, log: log2 } = config;
|
|
12505
|
-
if (!existsSync4(
|
|
12546
|
+
if (!existsSync4(join4(projectDir, "opencode.json"))) {
|
|
12506
12547
|
log2(`[opencode-session] warning: no opencode.json in ${projectDir} for '${codeName}' (provisioning may not have run)`);
|
|
12507
12548
|
}
|
|
12508
12549
|
const tmuxSession = opencodeTmuxSession(codeName);
|
|
@@ -12512,7 +12553,7 @@ async function spawnServe(config, session) {
|
|
|
12512
12553
|
execSync(`tmux kill-session -t ${tmuxSession} 2>/dev/null`, { stdio: "ignore" });
|
|
12513
12554
|
} catch {
|
|
12514
12555
|
}
|
|
12515
|
-
mkdirSync3(
|
|
12556
|
+
mkdirSync3(join4(homedir4(), ".augmented", codeName), { recursive: true });
|
|
12516
12557
|
const serveEnv = {
|
|
12517
12558
|
...process.env,
|
|
12518
12559
|
// ENG-7976: integration + channel credential secrets so the adapter's
|
|
@@ -12524,7 +12565,7 @@ async function spawnServe(config, session) {
|
|
|
12524
12565
|
...readAgentProviderEnv(codeName),
|
|
12525
12566
|
...stripUndefined(config.serveEnv ?? {}),
|
|
12526
12567
|
OPENCODE_SERVER_PASSWORD: password,
|
|
12527
|
-
HOME: process.env.HOME?.trim() ||
|
|
12568
|
+
HOME: process.env.HOME?.trim() || homedir4(),
|
|
12528
12569
|
USER: process.env.USER?.trim() || userInfo().username
|
|
12529
12570
|
};
|
|
12530
12571
|
if (config.runId) serveEnv["AGT_RUN_ID"] = config.runId;
|
|
@@ -12740,7 +12781,7 @@ function stripUndefined(env2) {
|
|
|
12740
12781
|
}
|
|
12741
12782
|
var PROVIDER_KEY_RE = /^[A-Z][A-Z0-9_]*_API_KEY$/;
|
|
12742
12783
|
function readAgentProviderEnv(codeName, dir) {
|
|
12743
|
-
const file =
|
|
12784
|
+
const file = join4(dir ?? join4(homedir4(), ".augmented", codeName), ".env");
|
|
12744
12785
|
const out = {};
|
|
12745
12786
|
try {
|
|
12746
12787
|
if (!existsSync4(file)) return out;
|
|
@@ -12776,7 +12817,7 @@ var INTEGRATIONS_ENV_BLOCKLIST = /* @__PURE__ */ new Set([
|
|
|
12776
12817
|
"DYLD_LIBRARY_PATH"
|
|
12777
12818
|
]);
|
|
12778
12819
|
function readAgentIntegrationsEnv(codeName, dir) {
|
|
12779
|
-
const file =
|
|
12820
|
+
const file = join4(dir ?? join4(homedir4(), ".augmented", codeName), ".env.integrations");
|
|
12780
12821
|
const out = {};
|
|
12781
12822
|
try {
|
|
12782
12823
|
if (!existsSync4(file)) return out;
|
|
@@ -12804,14 +12845,14 @@ import { randomUUID as randomUUID2 } from "crypto";
|
|
|
12804
12845
|
// src/lib/daily-session.ts
|
|
12805
12846
|
import { randomUUID } from "crypto";
|
|
12806
12847
|
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
|
|
12848
|
+
import { homedir as homedir5 } from "os";
|
|
12849
|
+
import { join as join5 } from "path";
|
|
12809
12850
|
var HISTORY_DAYS = 7;
|
|
12810
12851
|
function profileDir(codeName) {
|
|
12811
|
-
return
|
|
12852
|
+
return join5(homedir5(), ".augmented", codeName);
|
|
12812
12853
|
}
|
|
12813
12854
|
function dailySessionPath(codeName) {
|
|
12814
|
-
return
|
|
12855
|
+
return join5(profileDir(codeName), "daily-session.json");
|
|
12815
12856
|
}
|
|
12816
12857
|
function todayLocalIso(now = /* @__PURE__ */ new Date(), timezone) {
|
|
12817
12858
|
if (timezone) {
|
|
@@ -12914,8 +12955,8 @@ function rotateDailySession(codeName, now = /* @__PURE__ */ new Date(), timezone
|
|
|
12914
12955
|
}
|
|
12915
12956
|
var encodeProjectPath = encodeClaudeProjectPath;
|
|
12916
12957
|
function sessionFileExists(projectDir, sessionId) {
|
|
12917
|
-
const path =
|
|
12918
|
-
|
|
12958
|
+
const path = join5(
|
|
12959
|
+
homedir5(),
|
|
12919
12960
|
".claude",
|
|
12920
12961
|
"projects",
|
|
12921
12962
|
encodeProjectPath(projectDir),
|
|
@@ -12924,10 +12965,10 @@ function sessionFileExists(projectDir, sessionId) {
|
|
|
12924
12965
|
return existsSync5(path);
|
|
12925
12966
|
}
|
|
12926
12967
|
function sessionTranscriptDir(projectDir) {
|
|
12927
|
-
return
|
|
12968
|
+
return join5(homedir5(), ".claude", "projects", encodeProjectPath(projectDir));
|
|
12928
12969
|
}
|
|
12929
12970
|
function sessionFilePath(projectDir, sessionId) {
|
|
12930
|
-
return
|
|
12971
|
+
return join5(sessionTranscriptDir(projectDir), `${sessionId}.jsonl`);
|
|
12931
12972
|
}
|
|
12932
12973
|
function transcriptActivityAgeSeconds(projectDir, sessionId, now = /* @__PURE__ */ new Date()) {
|
|
12933
12974
|
if (!sessionId) return null;
|
|
@@ -12940,13 +12981,13 @@ function transcriptActivityAgeSeconds(projectDir, sessionId, now = /* @__PURE__
|
|
|
12940
12981
|
}
|
|
12941
12982
|
function subagentActivityAgeSeconds(projectDir, sessionId, now = /* @__PURE__ */ new Date()) {
|
|
12942
12983
|
if (!sessionId) return null;
|
|
12943
|
-
const dir =
|
|
12984
|
+
const dir = join5(sessionTranscriptDir(projectDir), sessionId, "subagents");
|
|
12944
12985
|
try {
|
|
12945
12986
|
let freshestMtimeMs = null;
|
|
12946
12987
|
for (const name of readdirSync2(dir)) {
|
|
12947
12988
|
if (!name.endsWith(".jsonl")) continue;
|
|
12948
12989
|
try {
|
|
12949
|
-
const mtimeMs = statSync(
|
|
12990
|
+
const mtimeMs = statSync(join5(dir, name)).mtimeMs;
|
|
12950
12991
|
if (freshestMtimeMs === null || mtimeMs > freshestMtimeMs) freshestMtimeMs = mtimeMs;
|
|
12951
12992
|
} catch {
|
|
12952
12993
|
}
|
|
@@ -13345,7 +13386,7 @@ function syncClaudeCredsToRoot() {
|
|
|
13345
13386
|
if (platform() !== "linux") return true;
|
|
13346
13387
|
if (typeof process.getuid !== "function" || process.getuid() !== 0) return true;
|
|
13347
13388
|
for (const filename of [".credentials.json", "credentials.json"]) {
|
|
13348
|
-
if (existsSync6(
|
|
13389
|
+
if (existsSync6(join6("/root/.claude", filename))) return true;
|
|
13349
13390
|
}
|
|
13350
13391
|
let sourcePath = null;
|
|
13351
13392
|
try {
|
|
@@ -13353,7 +13394,7 @@ function syncClaudeCredsToRoot() {
|
|
|
13353
13394
|
outer: for (const entry of entries) {
|
|
13354
13395
|
if (!entry.isDirectory()) continue;
|
|
13355
13396
|
for (const filename of [".credentials.json", "credentials.json"]) {
|
|
13356
|
-
const candidate =
|
|
13397
|
+
const candidate = join6("/home", entry.name, ".claude", filename);
|
|
13357
13398
|
if (existsSync6(candidate)) {
|
|
13358
13399
|
sourcePath = candidate;
|
|
13359
13400
|
break outer;
|
|
@@ -13365,7 +13406,7 @@ function syncClaudeCredsToRoot() {
|
|
|
13365
13406
|
if (!sourcePath) return false;
|
|
13366
13407
|
const targetDir = "/root/.claude";
|
|
13367
13408
|
const sourceFilename = sourcePath.endsWith("credentials.json") && !sourcePath.endsWith(".credentials.json") ? "credentials.json" : ".credentials.json";
|
|
13368
|
-
const targetPath =
|
|
13409
|
+
const targetPath = join6(targetDir, sourceFilename);
|
|
13369
13410
|
try {
|
|
13370
13411
|
if (!existsSync6(targetDir)) mkdirSync5(targetDir, { recursive: true, mode: 448 });
|
|
13371
13412
|
copyFileSync(sourcePath, targetPath);
|
|
@@ -13444,12 +13485,12 @@ function buildEgressAllowlist(toolsFrontmatter) {
|
|
|
13444
13485
|
return [...domains].sort();
|
|
13445
13486
|
}
|
|
13446
13487
|
function egressAllowlistHostPath(codeName, homeDir) {
|
|
13447
|
-
const home = homeDir ?? (process.env.HOME?.trim() ||
|
|
13448
|
-
return
|
|
13488
|
+
const home = homeDir ?? (process.env.HOME?.trim() || homedir6());
|
|
13489
|
+
return join6(home, ".augmented", "_egress", `${agentRuntimeKey(codeName, home)}.txt`);
|
|
13449
13490
|
}
|
|
13450
13491
|
function writeEgressAllowlist(codeName, domains, homeDir) {
|
|
13451
13492
|
const p2 = egressAllowlistHostPath(codeName, homeDir);
|
|
13452
|
-
mkdirSync5(
|
|
13493
|
+
mkdirSync5(dirname4(p2), { recursive: true });
|
|
13453
13494
|
writeFileSync5(p2, domains.join("\n") + "\n", { mode: 420 });
|
|
13454
13495
|
return p2;
|
|
13455
13496
|
}
|
|
@@ -13486,11 +13527,11 @@ function restartEgressSidecar(codeName) {
|
|
|
13486
13527
|
function buildDockerRunCommand(args) {
|
|
13487
13528
|
const { codeName, agentId, wrapperPath, projectDir, homeDir, runId, passApiKey, passOpenRouter, egress, forwardSlackReplyBinding, forwardBlockTurnEndAllMarkers, forwardKanbanWaiting, forwardNotifyDispatch, forwardTurnFailureNotice } = args;
|
|
13488
13529
|
const q = (s) => `'${s.replace(/'/g, `'\\''`)}'`;
|
|
13489
|
-
const agentDir2 =
|
|
13490
|
-
const agentIdDir =
|
|
13491
|
-
const mcpDir =
|
|
13492
|
-
const claudeHome =
|
|
13493
|
-
const claudeJson =
|
|
13530
|
+
const agentDir2 = join6(homeDir, ".augmented", codeName);
|
|
13531
|
+
const agentIdDir = join6(homeDir, ".augmented", agentId);
|
|
13532
|
+
const mcpDir = join6(homeDir, ".augmented", "_mcp");
|
|
13533
|
+
const claudeHome = join6(homeDir, ".claude");
|
|
13534
|
+
const claudeJson = join6(homeDir, ".claude.json");
|
|
13494
13535
|
const mounts = [
|
|
13495
13536
|
`-v ${q(`${agentDir2}:${agentDir2}`)}`,
|
|
13496
13537
|
`-v ${q(`${agentIdDir}:${agentIdDir}`)}`,
|
|
@@ -13503,7 +13544,7 @@ function buildDockerRunCommand(args) {
|
|
|
13503
13544
|
const cpus = process.env.AGT_ISOLATION_CPUS || "1.0";
|
|
13504
13545
|
const pids = process.env.AGT_ISOLATION_PIDS || "512";
|
|
13505
13546
|
const envArgs = [`-e ${q(`HOME=${homeDir}`)}`];
|
|
13506
|
-
envArgs.push(`-e ${q(`npm_config_cache=${
|
|
13547
|
+
envArgs.push(`-e ${q(`npm_config_cache=${join6(agentDir2, ".npm-cache")}`)}`);
|
|
13507
13548
|
if (passApiKey) envArgs.push("-e ANTHROPIC_API_KEY");
|
|
13508
13549
|
if (passOpenRouter) {
|
|
13509
13550
|
envArgs.push("-e ANTHROPIC_BASE_URL");
|
|
@@ -13571,8 +13612,8 @@ function buildDockerRunCommand(args) {
|
|
|
13571
13612
|
}
|
|
13572
13613
|
function writePersistentClaudeWrapper(args) {
|
|
13573
13614
|
const { projectDir, claudeBin, initPrompt, claudeArgsJoined } = args;
|
|
13574
|
-
const envIntegrationsPath =
|
|
13575
|
-
const wrapperPath =
|
|
13615
|
+
const envIntegrationsPath = join6(projectDir, ".env.integrations");
|
|
13616
|
+
const wrapperPath = join6(projectDir, ".claude", "persistent-claude.sh");
|
|
13576
13617
|
const wrapperLines = [
|
|
13577
13618
|
"#!/usr/bin/env bash",
|
|
13578
13619
|
"set -e",
|
|
@@ -13591,7 +13632,7 @@ function writePersistentClaudeWrapper(args) {
|
|
|
13591
13632
|
wrapperLines.push(
|
|
13592
13633
|
`exec ${JSON.stringify(claudeBin)} ${initPromptArg}${claudeArgsJoined}`
|
|
13593
13634
|
);
|
|
13594
|
-
mkdirSync5(
|
|
13635
|
+
mkdirSync5(join6(projectDir, ".claude"), { recursive: true });
|
|
13595
13636
|
writeFileSync5(wrapperPath, wrapperLines.join("\n") + "\n", { mode: 448 });
|
|
13596
13637
|
chmodSync3(wrapperPath, 448);
|
|
13597
13638
|
return wrapperPath;
|
|
@@ -13607,15 +13648,15 @@ function collectMcpServerNames(mcpConfigPath) {
|
|
|
13607
13648
|
}
|
|
13608
13649
|
}
|
|
13609
13650
|
var sessions2 = /* @__PURE__ */ new Map();
|
|
13610
|
-
var PANE_LOG_DIR =
|
|
13651
|
+
var PANE_LOG_DIR = join6(homedir6(), ".augmented");
|
|
13611
13652
|
var PANE_TAIL_LINES = 20;
|
|
13612
13653
|
function paneLogPath(codeName) {
|
|
13613
|
-
return
|
|
13654
|
+
return join6(PANE_LOG_DIR, codeName, "pane.log");
|
|
13614
13655
|
}
|
|
13615
13656
|
function setupPaneLog2(tmuxSession, codeName, log2) {
|
|
13616
13657
|
const logPath = paneLogPath(codeName);
|
|
13617
13658
|
try {
|
|
13618
|
-
mkdirSync5(
|
|
13659
|
+
mkdirSync5(dirname4(logPath), { recursive: true });
|
|
13619
13660
|
appendFileSync2(
|
|
13620
13661
|
logPath,
|
|
13621
13662
|
`
|
|
@@ -13637,11 +13678,11 @@ function rotatePaneLogForDayRollover(codeName, log2, agentTimezone, now = /* @__
|
|
|
13637
13678
|
if (!existsSync6(logPath)) return null;
|
|
13638
13679
|
if (statSync2(logPath).size === 0) return null;
|
|
13639
13680
|
const stamp = todayLocalIso(now, agentTimezone ?? void 0).replace(/-/g, "");
|
|
13640
|
-
const dir =
|
|
13641
|
-
let target =
|
|
13681
|
+
const dir = dirname4(logPath);
|
|
13682
|
+
let target = join6(dir, `pane.log-${stamp}`);
|
|
13642
13683
|
if (existsSync6(target)) {
|
|
13643
13684
|
const hhmmss = now.toISOString().slice(11, 19).replace(/:/g, "");
|
|
13644
|
-
target =
|
|
13685
|
+
target = join6(dir, `pane.log-${stamp}-${hhmmss}`);
|
|
13645
13686
|
}
|
|
13646
13687
|
renameSync2(logPath, target);
|
|
13647
13688
|
writeFileSync5(logPath, "", "utf-8");
|
|
@@ -13728,7 +13769,7 @@ function resolveSessionSpawnDecision(args) {
|
|
|
13728
13769
|
};
|
|
13729
13770
|
}
|
|
13730
13771
|
function directChatSessionStatePath(agentId) {
|
|
13731
|
-
return
|
|
13772
|
+
return join6(homedir6(), ".augmented", agentId, "direct-chat-session.json");
|
|
13732
13773
|
}
|
|
13733
13774
|
function readDirectChatSessionState(agentId) {
|
|
13734
13775
|
try {
|
|
@@ -13743,7 +13784,7 @@ function readDirectChatSessionState(agentId) {
|
|
|
13743
13784
|
}
|
|
13744
13785
|
function writeDirectChatSessionState(agentId, state) {
|
|
13745
13786
|
const p2 = directChatSessionStatePath(agentId);
|
|
13746
|
-
mkdirSync5(
|
|
13787
|
+
mkdirSync5(dirname4(p2), { recursive: true });
|
|
13747
13788
|
writeFileSync5(p2, JSON.stringify(state));
|
|
13748
13789
|
}
|
|
13749
13790
|
function startPersistentSession(config) {
|
|
@@ -13800,9 +13841,9 @@ function spawnSession(config, session) {
|
|
|
13800
13841
|
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
13842
|
}
|
|
13802
13843
|
} else {
|
|
13803
|
-
const claudeDir =
|
|
13844
|
+
const claudeDir = join6(homedir6(), ".claude");
|
|
13804
13845
|
for (const filename of [".credentials.json", "credentials.json"]) {
|
|
13805
|
-
const p2 =
|
|
13846
|
+
const p2 = join6(claudeDir, filename);
|
|
13806
13847
|
if (existsSync6(p2)) {
|
|
13807
13848
|
try {
|
|
13808
13849
|
rmSync3(p2, { force: true });
|
|
@@ -13900,7 +13941,7 @@ function spawnSession(config, session) {
|
|
|
13900
13941
|
if (config.turnFailureNoticeEnabled && !process.env["AGT_WEDGE_TRANSIENT_NOTICE_ENABLED"]) {
|
|
13901
13942
|
tmuxSessionEnvArgs.push("-e", "AGT_WEDGE_TRANSIENT_NOTICE_ENABLED=true");
|
|
13902
13943
|
}
|
|
13903
|
-
const sessionHomeDir = process.env.HOME?.trim() ||
|
|
13944
|
+
const sessionHomeDir = process.env.HOME?.trim() || homedir6();
|
|
13904
13945
|
let egress;
|
|
13905
13946
|
if (egressMode(codeName) === "allowlist") {
|
|
13906
13947
|
const allowlist = config.egressAllowlist ?? buildEgressAllowlist(null);
|
|
@@ -13946,7 +13987,7 @@ function spawnSession(config, session) {
|
|
|
13946
13987
|
// Treat empty-string as missing too — `HOME=""` makes ~ resolve
|
|
13947
13988
|
// to cwd, which is the same broken outcome as no HOME, just
|
|
13948
13989
|
// better hidden.
|
|
13949
|
-
HOME: process.env.HOME?.trim() ||
|
|
13990
|
+
HOME: process.env.HOME?.trim() || homedir6(),
|
|
13950
13991
|
USER: process.env.USER?.trim() || userInfo2().username
|
|
13951
13992
|
};
|
|
13952
13993
|
if (config.runId) {
|
|
@@ -13970,7 +14011,7 @@ function spawnSession(config, session) {
|
|
|
13970
14011
|
} : { ...tmuxEnv, ...apiKeyEnv, ...openRouterEnv };
|
|
13971
14012
|
for (const f of probeMcpEnvSubstitution({
|
|
13972
14013
|
mcpConfigPath,
|
|
13973
|
-
envIntegrationsPath:
|
|
14014
|
+
envIntegrationsPath: join6(projectDir, ".env.integrations"),
|
|
13974
14015
|
baseEnv: probeBaseEnv
|
|
13975
14016
|
})) {
|
|
13976
14017
|
log2(`[persistent-session] ${formatMissingVar(f)} agent=${codeName}`);
|
|
@@ -14541,15 +14582,15 @@ async function stopAllSessionsAndWait(log2, opts) {
|
|
|
14541
14582
|
}
|
|
14542
14583
|
function resolveRealAgentPath(codeNamePath) {
|
|
14543
14584
|
try {
|
|
14544
|
-
if (
|
|
14545
|
-
return
|
|
14585
|
+
if (lstatSync2(codeNamePath).isSymbolicLink()) {
|
|
14586
|
+
return realpathSync2(codeNamePath);
|
|
14546
14587
|
}
|
|
14547
14588
|
} catch {
|
|
14548
14589
|
}
|
|
14549
14590
|
return codeNamePath;
|
|
14550
14591
|
}
|
|
14551
14592
|
function getProjectDir(codeName) {
|
|
14552
|
-
return
|
|
14593
|
+
return join6(resolveRealAgentPath(join6(homedir6(), ".augmented", codeName)), "project");
|
|
14553
14594
|
}
|
|
14554
14595
|
|
|
14555
14596
|
export {
|
|
@@ -14623,7 +14664,7 @@ export {
|
|
|
14623
14664
|
readRemoteMcpAuthConfig,
|
|
14624
14665
|
buildForwardHeaders,
|
|
14625
14666
|
classifyCursorAdvance,
|
|
14626
|
-
|
|
14667
|
+
cursorAdvanceCounterKey,
|
|
14627
14668
|
formatCursorAdvanceShortfall,
|
|
14628
14669
|
AnchorSessionClient,
|
|
14629
14670
|
isOnboardingArea,
|
|
@@ -14673,6 +14714,7 @@ export {
|
|
|
14673
14714
|
LATE_BOUND_VARS,
|
|
14674
14715
|
expandTemplateVars,
|
|
14675
14716
|
parseEnvIntegrations,
|
|
14717
|
+
agentRuntimeKey,
|
|
14676
14718
|
log,
|
|
14677
14719
|
sha256,
|
|
14678
14720
|
hashFile,
|
|
@@ -14736,4 +14778,4 @@ export {
|
|
|
14736
14778
|
stopAllSessionsAndWait,
|
|
14737
14779
|
getProjectDir
|
|
14738
14780
|
};
|
|
14739
|
-
//# sourceMappingURL=chunk-
|
|
14781
|
+
//# sourceMappingURL=chunk-GBSMIV4P.js.map
|