@integrity-labs/agt-cli 0.28.1268 → 0.28.1270
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/{api-client-MH7MLGTA.js → api-client-TPJBEIKR.js} +3 -3
- package/dist/bin/agt.js +7 -7
- package/dist/{chunk-X2FBQPNR.js → chunk-A22SKOQ4.js} +2 -2
- package/dist/{chunk-W2GHPRPZ.js → chunk-CJFHB3HA.js} +22 -1
- package/dist/chunk-CJFHB3HA.js.map +1 -0
- package/dist/{chunk-BMO6GCK2.js → chunk-HHDHYVLS.js} +2 -2
- package/dist/{chunk-TMZDRXAK.js → chunk-PVVFL73J.js} +5 -5
- package/dist/{chunk-ERO3R3Z7.js → chunk-SXQ6YCFR.js} +3 -3
- package/dist/{chunk-EHZQAT3Q.js → chunk-YP7VUMM4.js} +3 -3
- package/dist/{claude-code-updater-XISTQTZX.js → claude-code-updater-K6PENJ7A.js} +3 -3
- package/dist/{claude-pair-runtime-3PHBCCUP.js → claude-pair-runtime-NOVMDM62.js} +3 -3
- package/dist/lib/manager-worker.js +278 -189
- package/dist/lib/manager-worker.js.map +1 -1
- package/dist/mcp/direct-chat-channel.js +193 -126
- package/dist/mcp/index.js +21 -0
- package/dist/mcp/origami.js +21 -0
- package/dist/mcp/slack-channel.js +137 -2
- package/dist/mcp/telegram-channel.js +21 -0
- package/dist/{persistent-session-BLZPYHBE.js → persistent-session-SMMVQBRS.js} +4 -4
- package/dist/{responsiveness-probe-T6O4V2XZ.js → responsiveness-probe-PX4FMO4H.js} +4 -4
- package/dist/{session-auth-dead-U62KZ342.js → session-auth-dead-47D57WMA.js} +3 -3
- package/package.json +1 -1
- package/dist/chunk-W2GHPRPZ.js.map +0 -1
- /package/dist/{api-client-MH7MLGTA.js.map → api-client-TPJBEIKR.js.map} +0 -0
- /package/dist/{chunk-X2FBQPNR.js.map → chunk-A22SKOQ4.js.map} +0 -0
- /package/dist/{chunk-BMO6GCK2.js.map → chunk-HHDHYVLS.js.map} +0 -0
- /package/dist/{chunk-TMZDRXAK.js.map → chunk-PVVFL73J.js.map} +0 -0
- /package/dist/{chunk-ERO3R3Z7.js.map → chunk-SXQ6YCFR.js.map} +0 -0
- /package/dist/{chunk-EHZQAT3Q.js.map → chunk-YP7VUMM4.js.map} +0 -0
- /package/dist/{claude-code-updater-XISTQTZX.js.map → claude-code-updater-K6PENJ7A.js.map} +0 -0
- /package/dist/{claude-pair-runtime-3PHBCCUP.js.map → claude-pair-runtime-NOVMDM62.js.map} +0 -0
- /package/dist/{persistent-session-BLZPYHBE.js.map → persistent-session-SMMVQBRS.js.map} +0 -0
- /package/dist/{responsiveness-probe-T6O4V2XZ.js.map → responsiveness-probe-PX4FMO4H.js.map} +0 -0
- /package/dist/{session-auth-dead-U62KZ342.js.map → session-auth-dead-47D57WMA.js.map} +0 -0
|
@@ -70,7 +70,7 @@ import {
|
|
|
70
70
|
tripClass,
|
|
71
71
|
writeEtcEnvironment,
|
|
72
72
|
writeProfileDScript
|
|
73
|
-
} from "../chunk-
|
|
73
|
+
} from "../chunk-PVVFL73J.js";
|
|
74
74
|
import {
|
|
75
75
|
ApiError,
|
|
76
76
|
adoptHostKeyInProcess,
|
|
@@ -88,7 +88,7 @@ import {
|
|
|
88
88
|
probeHostKey,
|
|
89
89
|
requireHost,
|
|
90
90
|
setConfigHash
|
|
91
|
-
} from "../chunk-
|
|
91
|
+
} from "../chunk-YP7VUMM4.js";
|
|
92
92
|
import {
|
|
93
93
|
BLOCKED_ON_PROMPT_DECISION,
|
|
94
94
|
CHANNEL_SECRET_ENV_KEYS,
|
|
@@ -178,7 +178,7 @@ import {
|
|
|
178
178
|
webFetchBaselineValue,
|
|
179
179
|
webFetchRestartNeeded,
|
|
180
180
|
writeEgressAllowlist
|
|
181
|
-
} from "../chunk-
|
|
181
|
+
} from "../chunk-SXQ6YCFR.js";
|
|
182
182
|
import {
|
|
183
183
|
isAgentIdle,
|
|
184
184
|
isStaleForToday,
|
|
@@ -189,7 +189,7 @@ import {
|
|
|
189
189
|
subagentActivityAgeSeconds,
|
|
190
190
|
subagentTranscriptDir,
|
|
191
191
|
transcriptActivityAgeSeconds
|
|
192
|
-
} from "../chunk-
|
|
192
|
+
} from "../chunk-A22SKOQ4.js";
|
|
193
193
|
import {
|
|
194
194
|
classifyUnanswerablePane,
|
|
195
195
|
focusedConfirmDialogBlock,
|
|
@@ -215,7 +215,7 @@ import {
|
|
|
215
215
|
runSafeCleanup,
|
|
216
216
|
tightestDiskStat,
|
|
217
217
|
withPackageCacheLock
|
|
218
|
-
} from "../chunk-
|
|
218
|
+
} from "../chunk-HHDHYVLS.js";
|
|
219
219
|
import {
|
|
220
220
|
parsePsRows,
|
|
221
221
|
reapOrphanChannelMcps
|
|
@@ -343,7 +343,7 @@ import {
|
|
|
343
343
|
stabiliseResetInstant,
|
|
344
344
|
sumTranscriptUsageInWindow,
|
|
345
345
|
summarizeTranscriptActivity
|
|
346
|
-
} from "../chunk-
|
|
346
|
+
} from "../chunk-CJFHB3HA.js";
|
|
347
347
|
import {
|
|
348
348
|
CLAUDE_CONFIG_DIR_ENV,
|
|
349
349
|
claudeConfigDirFor,
|
|
@@ -716,7 +716,7 @@ function stragglerSpawnGate(codeName, deps) {
|
|
|
716
716
|
|
|
717
717
|
// src/lib/manager-worker.ts
|
|
718
718
|
import { createHash as createHash21 } from "crypto";
|
|
719
|
-
import { readFileSync as
|
|
719
|
+
import { readFileSync as readFileSync38, writeFileSync as writeFileSync20, mkdirSync as mkdirSync18, existsSync as existsSync20, rmSync as rmSync9, readdirSync as readdirSync14, statSync as statSync15, unlinkSync as unlinkSync6, renameSync as renameSync12, utimesSync as utimesSync4, readlinkSync as readlinkSync2 } from "fs";
|
|
720
720
|
|
|
721
721
|
// src/lib/atomic-file-replace.ts
|
|
722
722
|
import { copyFileSync, renameSync, unlinkSync } from "fs";
|
|
@@ -1133,7 +1133,7 @@ function clearEpisode(codeName) {
|
|
|
1133
1133
|
}
|
|
1134
1134
|
|
|
1135
1135
|
// src/lib/manager-worker.ts
|
|
1136
|
-
import { join as
|
|
1136
|
+
import { join as join47, dirname as dirname11, delimiter as pathDelimiter } from "path";
|
|
1137
1137
|
import { homedir as homedir17, hostname, platform as platform3 } from "os";
|
|
1138
1138
|
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
1139
1139
|
|
|
@@ -3705,11 +3705,11 @@ function isPathInsideDir(candidate, dir) {
|
|
|
3705
3705
|
}
|
|
3706
3706
|
function findMissingMcpBundles(mcpConfigPath, deps = {}) {
|
|
3707
3707
|
const existsSync21 = deps.existsSync ?? nodeExistsSync;
|
|
3708
|
-
const
|
|
3708
|
+
const readFileSync39 = deps.readFileSync ?? nodeReadFileSync;
|
|
3709
3709
|
const mcpDir = deps.mcpDir ?? getSharedMcpDir();
|
|
3710
3710
|
let parsed;
|
|
3711
3711
|
try {
|
|
3712
|
-
parsed = JSON.parse(
|
|
3712
|
+
parsed = JSON.parse(readFileSync39(mcpConfigPath, "utf-8"));
|
|
3713
3713
|
} catch {
|
|
3714
3714
|
return [];
|
|
3715
3715
|
}
|
|
@@ -12210,6 +12210,57 @@ var BlockedPromptReportCadence = class {
|
|
|
12210
12210
|
}
|
|
12211
12211
|
};
|
|
12212
12212
|
|
|
12213
|
+
// ../../packages/core/dist/runtime/direct-chat-inflight.js
|
|
12214
|
+
import { renameSync as renameSync9, readFileSync as readFileSync33, writeFileSync as writeFileSync16 } from "fs";
|
|
12215
|
+
import { join as join42 } from "path";
|
|
12216
|
+
var DIRECT_CHAT_INFLIGHT_FILE = "direct-chat-inflight.json";
|
|
12217
|
+
var DIRECT_CHAT_INFLIGHT_MAX_AGE_MS = 5 * 6e4;
|
|
12218
|
+
function directChatInflightPath(agentDir) {
|
|
12219
|
+
return join42(agentDir, DIRECT_CHAT_INFLIGHT_FILE);
|
|
12220
|
+
}
|
|
12221
|
+
function decideDirectChatInflight(input) {
|
|
12222
|
+
if (input.raw === null)
|
|
12223
|
+
return { inFlight: false, reason: "absent" };
|
|
12224
|
+
if (typeof input.raw !== "string")
|
|
12225
|
+
return { inFlight: false, reason: "unreadable" };
|
|
12226
|
+
let m;
|
|
12227
|
+
try {
|
|
12228
|
+
m = JSON.parse(input.raw);
|
|
12229
|
+
} catch {
|
|
12230
|
+
return { inFlight: false, reason: "unreadable" };
|
|
12231
|
+
}
|
|
12232
|
+
const rec = m;
|
|
12233
|
+
if (!rec || typeof rec !== "object" || !Array.isArray(rec.ids) || typeof rec.since_ms !== "number" || typeof rec.pid !== "number") {
|
|
12234
|
+
return { inFlight: false, reason: "unreadable" };
|
|
12235
|
+
}
|
|
12236
|
+
const ids = rec.ids.filter((x) => typeof x === "string" && x.length > 0);
|
|
12237
|
+
if (ids.length === 0)
|
|
12238
|
+
return { inFlight: false, reason: "empty" };
|
|
12239
|
+
if (!Number.isFinite(rec.since_ms) || input.nowMs - rec.since_ms > DIRECT_CHAT_INFLIGHT_MAX_AGE_MS) {
|
|
12240
|
+
return { inFlight: false, reason: "stale" };
|
|
12241
|
+
}
|
|
12242
|
+
if (!Number.isInteger(rec.pid) || rec.pid <= 0 || !input.pidAlive(rec.pid))
|
|
12243
|
+
return { inFlight: false, reason: "pid_dead" };
|
|
12244
|
+
return { inFlight: true, ids };
|
|
12245
|
+
}
|
|
12246
|
+
function processIsAlive(pid) {
|
|
12247
|
+
try {
|
|
12248
|
+
process.kill(pid, 0);
|
|
12249
|
+
return true;
|
|
12250
|
+
} catch (err) {
|
|
12251
|
+
return err?.code === "EPERM";
|
|
12252
|
+
}
|
|
12253
|
+
}
|
|
12254
|
+
function readDirectChatInflight(agentDir, nowMs = Date.now(), pidAlive = processIsAlive, read = (p) => readFileSync33(p, "utf8")) {
|
|
12255
|
+
let raw;
|
|
12256
|
+
try {
|
|
12257
|
+
raw = read(directChatInflightPath(agentDir));
|
|
12258
|
+
} catch (err) {
|
|
12259
|
+
raw = err?.code === "ENOENT" ? null : { error: err };
|
|
12260
|
+
}
|
|
12261
|
+
return decideDirectChatInflight({ raw, nowMs, pidAlive });
|
|
12262
|
+
}
|
|
12263
|
+
|
|
12213
12264
|
// src/lib/agent-spawn-lock.ts
|
|
12214
12265
|
var tails = /* @__PURE__ */ new Map();
|
|
12215
12266
|
async function acquireAgentSpawnLock(agentId) {
|
|
@@ -12263,7 +12314,7 @@ function respawnedByAnotherCaller(decision, healthyAfter, sessionStartedAt, lane
|
|
|
12263
12314
|
|
|
12264
12315
|
// src/lib/occupancy-gate.ts
|
|
12265
12316
|
import { closeSync as closeSync5, openSync as openSync5, readdirSync as readdirSync11, readSync as readSync4, statSync as statSync13 } from "fs";
|
|
12266
|
-
import { join as
|
|
12317
|
+
import { join as join43 } from "path";
|
|
12267
12318
|
function rostersMeasuredZero(mode, attested, runtimeRunning) {
|
|
12268
12319
|
return mode === "enforce" && attested && runtimeRunning;
|
|
12269
12320
|
}
|
|
@@ -12354,10 +12405,10 @@ function candidateTranscriptPaths(dir) {
|
|
|
12354
12405
|
let complete = true;
|
|
12355
12406
|
for (const name of top) {
|
|
12356
12407
|
if (name.endsWith(".jsonl")) {
|
|
12357
|
-
paths.push(
|
|
12408
|
+
paths.push(join43(dir, name));
|
|
12358
12409
|
continue;
|
|
12359
12410
|
}
|
|
12360
|
-
const subDir =
|
|
12411
|
+
const subDir = join43(dir, name, "subagents");
|
|
12361
12412
|
let subs;
|
|
12362
12413
|
try {
|
|
12363
12414
|
subs = readdirSync11(subDir);
|
|
@@ -12366,7 +12417,7 @@ function candidateTranscriptPaths(dir) {
|
|
|
12366
12417
|
continue;
|
|
12367
12418
|
}
|
|
12368
12419
|
for (const sub of subs) {
|
|
12369
|
-
if (sub.endsWith(".jsonl")) paths.push(
|
|
12420
|
+
if (sub.endsWith(".jsonl")) paths.push(join43(subDir, sub));
|
|
12370
12421
|
}
|
|
12371
12422
|
}
|
|
12372
12423
|
return { paths, complete };
|
|
@@ -12592,7 +12643,7 @@ function stopPaneOccupancySampler() {
|
|
|
12592
12643
|
}
|
|
12593
12644
|
|
|
12594
12645
|
// src/lib/pid-pressure-sampler.ts
|
|
12595
|
-
import { existsSync as existsSync17, readFileSync as
|
|
12646
|
+
import { existsSync as existsSync17, readFileSync as readFileSync34 } from "fs";
|
|
12596
12647
|
var SAMPLE_INTERVAL_MS2 = 3e4;
|
|
12597
12648
|
function warnFraction() {
|
|
12598
12649
|
const raw = Number(process.env.AGT_PID_PRESSURE_WARN_FRACTION);
|
|
@@ -12620,7 +12671,7 @@ function parseMemoryEvents(text) {
|
|
|
12620
12671
|
}
|
|
12621
12672
|
function readTextReal(path) {
|
|
12622
12673
|
try {
|
|
12623
|
-
return
|
|
12674
|
+
return readFileSync34(path, "utf-8");
|
|
12624
12675
|
} catch {
|
|
12625
12676
|
return null;
|
|
12626
12677
|
}
|
|
@@ -14002,9 +14053,9 @@ async function fireOpencodeScheduledTask(agent, task) {
|
|
|
14002
14053
|
|
|
14003
14054
|
// src/lib/opencode-telegram-ingest.ts
|
|
14004
14055
|
import { createHash as createHash20 } from "crypto";
|
|
14005
|
-
import { existsSync as existsSync18, mkdirSync as mkdirSync15, readFileSync as
|
|
14056
|
+
import { existsSync as existsSync18, mkdirSync as mkdirSync15, readFileSync as readFileSync35, renameSync as renameSync10, unlinkSync as unlinkSync4, writeFileSync as writeFileSync17 } from "fs";
|
|
14006
14057
|
import { randomUUID } from "crypto";
|
|
14007
|
-
import { join as
|
|
14058
|
+
import { join as join44 } from "path";
|
|
14008
14059
|
|
|
14009
14060
|
// src/lib/telegram-ingest.ts
|
|
14010
14061
|
import https2 from "https";
|
|
@@ -14707,7 +14758,7 @@ function createFileOffsetStore(codeName, log2, currentBotId) {
|
|
|
14707
14758
|
let filePath;
|
|
14708
14759
|
try {
|
|
14709
14760
|
dir = getFramework("opencode").getAgentDir(codeName);
|
|
14710
|
-
filePath =
|
|
14761
|
+
filePath = join44(dir, "telegram-getupdates-offset-opencode.json");
|
|
14711
14762
|
} catch {
|
|
14712
14763
|
dir = null;
|
|
14713
14764
|
filePath = null;
|
|
@@ -14716,7 +14767,7 @@ function createFileOffsetStore(codeName, log2, currentBotId) {
|
|
|
14716
14767
|
load() {
|
|
14717
14768
|
if (!filePath) return 0;
|
|
14718
14769
|
try {
|
|
14719
|
-
const parsed = JSON.parse(
|
|
14770
|
+
const parsed = JSON.parse(readFileSync35(filePath, "utf-8"));
|
|
14720
14771
|
if (currentBotId != null && typeof parsed?.bot_id === "number" && parsed.bot_id !== currentBotId) {
|
|
14721
14772
|
log2(`[telegram-ingest:${codeName}] offset cursor belongs to a different bot; ignoring (bot swap)`);
|
|
14722
14773
|
return 0;
|
|
@@ -14735,7 +14786,7 @@ function createFileOffsetStore(codeName, log2, currentBotId) {
|
|
|
14735
14786
|
const tmpPath = `${filePath}.${process.pid}.${randomUUID()}.tmp`;
|
|
14736
14787
|
try {
|
|
14737
14788
|
mkdirSync15(dir, { recursive: true, mode: 448 });
|
|
14738
|
-
|
|
14789
|
+
writeFileSync17(
|
|
14739
14790
|
tmpPath,
|
|
14740
14791
|
JSON.stringify({
|
|
14741
14792
|
offset,
|
|
@@ -14745,7 +14796,7 @@ function createFileOffsetStore(codeName, log2, currentBotId) {
|
|
|
14745
14796
|
}),
|
|
14746
14797
|
{ mode: 384 }
|
|
14747
14798
|
);
|
|
14748
|
-
|
|
14799
|
+
renameSync10(tmpPath, filePath);
|
|
14749
14800
|
} catch (err) {
|
|
14750
14801
|
log2(`[telegram-ingest:${codeName}] offset persist failed: ${err instanceof Error ? err.message : String(err)}`);
|
|
14751
14802
|
try {
|
|
@@ -14761,7 +14812,7 @@ function createFileMigrationReportIO(codeName, log2) {
|
|
|
14761
14812
|
let filePath;
|
|
14762
14813
|
try {
|
|
14763
14814
|
dir = getFramework("opencode").getAgentDir(codeName);
|
|
14764
|
-
filePath =
|
|
14815
|
+
filePath = join44(dir, "telegram-migration-reports-opencode.json");
|
|
14765
14816
|
} catch {
|
|
14766
14817
|
dir = null;
|
|
14767
14818
|
filePath = null;
|
|
@@ -14770,7 +14821,7 @@ function createFileMigrationReportIO(codeName, log2) {
|
|
|
14770
14821
|
load() {
|
|
14771
14822
|
if (!filePath) return null;
|
|
14772
14823
|
try {
|
|
14773
|
-
return
|
|
14824
|
+
return readFileSync35(filePath, "utf-8");
|
|
14774
14825
|
} catch {
|
|
14775
14826
|
return null;
|
|
14776
14827
|
}
|
|
@@ -14787,7 +14838,7 @@ function createFileMigrationReportIO(codeName, log2) {
|
|
|
14787
14838
|
};
|
|
14788
14839
|
}
|
|
14789
14840
|
var managerHostPost = async (path, body) => {
|
|
14790
|
-
const { api: api2, ApiError: ApiError3 } = await import("../api-client-
|
|
14841
|
+
const { api: api2, ApiError: ApiError3 } = await import("../api-client-TPJBEIKR.js");
|
|
14791
14842
|
try {
|
|
14792
14843
|
const json = await api2.post(path, body);
|
|
14793
14844
|
return { status: 200, json };
|
|
@@ -15053,15 +15104,15 @@ function partitionActionableByPoison(actionable, states, config2) {
|
|
|
15053
15104
|
}
|
|
15054
15105
|
|
|
15055
15106
|
// src/lib/restart-flags.ts
|
|
15056
|
-
import { existsSync as existsSync19, mkdirSync as mkdirSync16, readdirSync as readdirSync12, readFileSync as
|
|
15107
|
+
import { existsSync as existsSync19, mkdirSync as mkdirSync16, readdirSync as readdirSync12, readFileSync as readFileSync36, renameSync as renameSync11, rmSync as rmSync8, writeFileSync as writeFileSync18 } from "fs";
|
|
15057
15108
|
import { homedir as homedir16 } from "os";
|
|
15058
|
-
import { join as
|
|
15109
|
+
import { join as join45 } from "path";
|
|
15059
15110
|
import { randomUUID as randomUUID2 } from "crypto";
|
|
15060
15111
|
function restartFlagsDir() {
|
|
15061
|
-
return
|
|
15112
|
+
return join45(homedir16(), ".augmented", "restart-flags");
|
|
15062
15113
|
}
|
|
15063
15114
|
function flagPath(codeName) {
|
|
15064
|
-
return
|
|
15115
|
+
return join45(restartFlagsDir(), `${codeName}.flag`);
|
|
15065
15116
|
}
|
|
15066
15117
|
function readRestartFlags() {
|
|
15067
15118
|
const dir = restartFlagsDir();
|
|
@@ -15070,7 +15121,7 @@ function readRestartFlags() {
|
|
|
15070
15121
|
for (const entry of readdirSync12(dir)) {
|
|
15071
15122
|
if (!entry.endsWith(".flag")) continue;
|
|
15072
15123
|
try {
|
|
15073
|
-
const raw =
|
|
15124
|
+
const raw = readFileSync36(join45(dir, entry), "utf8");
|
|
15074
15125
|
const parsed = JSON.parse(raw);
|
|
15075
15126
|
if (typeof parsed.codeName !== "string" || parsed.codeName.length === 0) {
|
|
15076
15127
|
parsed.codeName = entry.replace(/\.flag$/, "");
|
|
@@ -15188,8 +15239,8 @@ async function sendError(flag, opts, text) {
|
|
|
15188
15239
|
}
|
|
15189
15240
|
|
|
15190
15241
|
// src/lib/restart-context.ts
|
|
15191
|
-
import { readdirSync as readdirSync13, readFileSync as
|
|
15192
|
-
import { dirname as dirname10, join as
|
|
15242
|
+
import { readdirSync as readdirSync13, readFileSync as readFileSync37, writeFileSync as writeFileSync19, mkdirSync as mkdirSync17, unlinkSync as unlinkSync5 } from "fs";
|
|
15243
|
+
import { dirname as dirname10, join as join46 } from "path";
|
|
15193
15244
|
var SLACK_PENDING_INBOUND_DIRNAME = "slack-pending-inbound";
|
|
15194
15245
|
var SLACK_RESTART_CONTEXT_DIRNAME = "slack-restart-context";
|
|
15195
15246
|
var MAX_TOPIC_CHARS = 140;
|
|
@@ -15201,10 +15252,10 @@ function augmentedAgentDir(codeName) {
|
|
|
15201
15252
|
return dirname10(getProjectDir(codeName));
|
|
15202
15253
|
}
|
|
15203
15254
|
function slackPendingInboundDir(codeName) {
|
|
15204
|
-
return
|
|
15255
|
+
return join46(augmentedAgentDir(codeName), SLACK_PENDING_INBOUND_DIRNAME);
|
|
15205
15256
|
}
|
|
15206
15257
|
function slackRestartContextDir(codeName) {
|
|
15207
|
-
return
|
|
15258
|
+
return join46(augmentedAgentDir(codeName), SLACK_RESTART_CONTEXT_DIRNAME);
|
|
15208
15259
|
}
|
|
15209
15260
|
function sanitizeTopic(raw) {
|
|
15210
15261
|
const cleaned = raw.replace(/\s+/g, " ").trim().replace(/[<>]/g, " ").replace(/\s+/g, " ").trim();
|
|
@@ -15246,7 +15297,7 @@ function safeReaddir(dir) {
|
|
|
15246
15297
|
}
|
|
15247
15298
|
function readStrandedMarker(path) {
|
|
15248
15299
|
try {
|
|
15249
|
-
const parsed = JSON.parse(
|
|
15300
|
+
const parsed = JSON.parse(readFileSync37(path, "utf-8"));
|
|
15250
15301
|
if (typeof parsed.channel === "string" && typeof parsed.thread_ts === "string") {
|
|
15251
15302
|
return { channel: parsed.channel, thread_ts: parsed.thread_ts };
|
|
15252
15303
|
}
|
|
@@ -15256,7 +15307,7 @@ function readStrandedMarker(path) {
|
|
|
15256
15307
|
}
|
|
15257
15308
|
function writeHintFile(path, dir, hint) {
|
|
15258
15309
|
mkdirSync17(dir, { recursive: true, mode: 448 });
|
|
15259
|
-
|
|
15310
|
+
writeFileSync19(path, JSON.stringify(hint), { mode: 384 });
|
|
15260
15311
|
}
|
|
15261
15312
|
function pruneHintsExcept(codeName, freshFilenames) {
|
|
15262
15313
|
const ctxDir = slackRestartContextDir(codeName);
|
|
@@ -15264,7 +15315,7 @@ function pruneHintsExcept(codeName, freshFilenames) {
|
|
|
15264
15315
|
if (!filename.endsWith(".json")) continue;
|
|
15265
15316
|
if (freshFilenames.has(filename)) continue;
|
|
15266
15317
|
try {
|
|
15267
|
-
unlinkSync5(
|
|
15318
|
+
unlinkSync5(join46(ctxDir, filename));
|
|
15268
15319
|
} catch {
|
|
15269
15320
|
}
|
|
15270
15321
|
}
|
|
@@ -15285,7 +15336,7 @@ function refreshSlackRestartContextHints(codeNames, opts = {}) {
|
|
|
15285
15336
|
}
|
|
15286
15337
|
const markers = [];
|
|
15287
15338
|
for (const filename of markerFilenames.slice(0, cap)) {
|
|
15288
|
-
const parsed = readStrandedMarker(
|
|
15339
|
+
const parsed = readStrandedMarker(join46(markerDir, filename));
|
|
15289
15340
|
if (parsed) markers.push({ filename, channel: parsed.channel, thread_ts: parsed.thread_ts });
|
|
15290
15341
|
}
|
|
15291
15342
|
if (markers.length === 0) {
|
|
@@ -15299,7 +15350,7 @@ function refreshSlackRestartContextHints(codeNames, opts = {}) {
|
|
|
15299
15350
|
const freshFilenames = /* @__PURE__ */ new Set();
|
|
15300
15351
|
for (const { filename, hint } of hints) {
|
|
15301
15352
|
try {
|
|
15302
|
-
writeHintFile(
|
|
15353
|
+
writeHintFile(join46(ctxDir, filename), ctxDir, hint);
|
|
15303
15354
|
freshFilenames.add(filename);
|
|
15304
15355
|
} catch (err) {
|
|
15305
15356
|
log2(`[restart-context] ${codeName}: hint write failed for ${filename}: ${err.message}`);
|
|
@@ -16114,7 +16165,7 @@ async function runDangerousRmBackstop(agentId, codeName, pane) {
|
|
|
16114
16165
|
return;
|
|
16115
16166
|
}
|
|
16116
16167
|
const policy = readRmPolicyText(
|
|
16117
|
-
() =>
|
|
16168
|
+
() => readFileSync38(join47(getFramework("claude-code").getAgentDir(codeName), RM_POLICY_RELATIVE_PATH), "utf-8")
|
|
16118
16169
|
);
|
|
16119
16170
|
const decision = decideDangerousRm(action.prompt, policy, {
|
|
16120
16171
|
isolated: isolationMode(codeName) === "docker"
|
|
@@ -16835,7 +16886,7 @@ var pendingDayRolloverReset = /* @__PURE__ */ new Set();
|
|
|
16835
16886
|
var dayRolloverInboundHold = /* @__PURE__ */ new Map();
|
|
16836
16887
|
var INBOUND_HOLD_EPISODE_GAP_MS = 12e4;
|
|
16837
16888
|
async function channelInboundActivityAgeSecondsFor(codeName) {
|
|
16838
|
-
const { newestPendingInboundActivityMtimeMs } = await import("../responsiveness-probe-
|
|
16889
|
+
const { newestPendingInboundActivityMtimeMs } = await import("../responsiveness-probe-PX4FMO4H.js");
|
|
16839
16890
|
const newest = newestPendingInboundActivityMtimeMs(dirname11(paneLogPath(codeName)));
|
|
16840
16891
|
if (newest === null) return null;
|
|
16841
16892
|
return Math.max(0, Math.floor((Date.now() - newest) / 1e3));
|
|
@@ -17203,7 +17254,7 @@ var runningMcpServerKeys = /* @__PURE__ */ new Map();
|
|
|
17203
17254
|
var runningChannelSecretHashes = /* @__PURE__ */ new Map();
|
|
17204
17255
|
var sessionLaunchManagedStructure = /* @__PURE__ */ new Map();
|
|
17205
17256
|
function readSpawnViewMcpConfig(codeName, projectDir) {
|
|
17206
|
-
const parsed = JSON.parse(
|
|
17257
|
+
const parsed = JSON.parse(readFileSync38(join47(projectDir, ".mcp.json"), "utf-8"));
|
|
17207
17258
|
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) return parsed;
|
|
17208
17259
|
const agentId = agentState.codeNameToAgentId.get(codeName);
|
|
17209
17260
|
const integrations = agentId ? lastIntegrationsPayload.get(agentId) : void 0;
|
|
@@ -17224,7 +17275,7 @@ function reportSpawnCopyFailure(codeName, f) {
|
|
|
17224
17275
|
function refreshHeldDropped(codeName, projectDir, held) {
|
|
17225
17276
|
const agentId = agentState.codeNameToAgentId.get(codeName);
|
|
17226
17277
|
const integrations = agentId ? lastIntegrationsPayload.get(agentId) : void 0;
|
|
17227
|
-
const now = [...spawnDroppedServerKeys(
|
|
17278
|
+
const now = [...spawnDroppedServerKeys(join47(projectDir, ".mcp.json"), integrations)];
|
|
17228
17279
|
if (spawnCopyFailures.noteDropped(codeName, now)) {
|
|
17229
17280
|
log(
|
|
17230
17281
|
`[spawn-mcp-filter] ORPHAN_SPAWN_UNFILTERED_CHANGED agent='${codeName}' servers=${now.map((k) => `'${k}'`).join(", ")}: the set of removed servers still loaded changed while the copy failure is held (ENG-12048)`
|
|
@@ -17240,14 +17291,14 @@ function retryHeldSpawnCopy2(codeName, projectDir, held) {
|
|
|
17240
17291
|
}
|
|
17241
17292
|
function readSpawnedMcpConfig(path) {
|
|
17242
17293
|
try {
|
|
17243
|
-
const parsed = JSON.parse(
|
|
17294
|
+
const parsed = JSON.parse(readFileSync38(path, "utf-8"));
|
|
17244
17295
|
return parsed && typeof parsed === "object" && !Array.isArray(parsed) ? parsed : null;
|
|
17245
17296
|
} catch {
|
|
17246
17297
|
return null;
|
|
17247
17298
|
}
|
|
17248
17299
|
}
|
|
17249
17300
|
function readRawMcpConfig(projectDir) {
|
|
17250
|
-
return JSON.parse(
|
|
17301
|
+
return JSON.parse(readFileSync38(join47(projectDir, ".mcp.json"), "utf-8"));
|
|
17251
17302
|
}
|
|
17252
17303
|
function readMcpConfigFor(codeName, projectDir, source) {
|
|
17253
17304
|
return source === "raw" ? readRawMcpConfig(projectDir) : readSpawnViewMcpConfig(codeName, projectDir);
|
|
@@ -17280,7 +17331,7 @@ function seedSessionLaunchBaselines(codeName, projectDir, spawnMcpConfigPath) {
|
|
|
17280
17331
|
else runningMcpServerKeys.delete(codeName);
|
|
17281
17332
|
let launchStructure = null;
|
|
17282
17333
|
try {
|
|
17283
|
-
const raw =
|
|
17334
|
+
const raw = readFileSync38(join47(projectDir, ".mcp.json"), "utf-8");
|
|
17284
17335
|
launchStructure = managedMcpStructureHashFromFile(
|
|
17285
17336
|
JSON.parse(raw),
|
|
17286
17337
|
isManagedMcpServerKey
|
|
@@ -17432,7 +17483,7 @@ async function runAgentSessionToolBindProbes(agent, integrations, projectDir, op
|
|
|
17432
17483
|
if (result && result.rebindCandidates.length > 0 && hostFlagStore().getBoolean("session-tool-rebind")) {
|
|
17433
17484
|
let mcpJsonForRebind = null;
|
|
17434
17485
|
try {
|
|
17435
|
-
mcpJsonForRebind = JSON.parse(
|
|
17486
|
+
mcpJsonForRebind = JSON.parse(readFileSync38(join47(projectDir, ".mcp.json"), "utf-8"));
|
|
17436
17487
|
} catch {
|
|
17437
17488
|
mcpJsonForRebind = null;
|
|
17438
17489
|
}
|
|
@@ -17596,7 +17647,7 @@ function shouldInjectChannelSecrets(agentId) {
|
|
|
17596
17647
|
function projectChannelSecretHash(projectDir) {
|
|
17597
17648
|
try {
|
|
17598
17649
|
const entries = parseEnvIntegrations(
|
|
17599
|
-
|
|
17650
|
+
readFileSync38(join47(projectDir, ".env.integrations"), "utf-8")
|
|
17600
17651
|
);
|
|
17601
17652
|
return channelSecretValueHash(entries, CHANNEL_SECRET_ENV_KEYS);
|
|
17602
17653
|
} catch {
|
|
@@ -17716,7 +17767,7 @@ var agentRestartTimezoneInputs = /* @__PURE__ */ new Map();
|
|
|
17716
17767
|
var lastVersionCheckAt = 0;
|
|
17717
17768
|
var VERSION_CHECK_INTERVAL_MS = 5 * 60 * 1e3;
|
|
17718
17769
|
var lastResponsivenessProbeAt = 0;
|
|
17719
|
-
var agtCliVersion = true ? "0.28.
|
|
17770
|
+
var agtCliVersion = true ? "0.28.1270" : "dev";
|
|
17720
17771
|
function resolveBrewPath(execFileSync4) {
|
|
17721
17772
|
try {
|
|
17722
17773
|
const out = execFileSync4("which", ["brew"], { timeout: 5e3 }).toString().trim();
|
|
@@ -18276,7 +18327,7 @@ function runAsync(cmd, args, opts) {
|
|
|
18276
18327
|
});
|
|
18277
18328
|
}
|
|
18278
18329
|
function claudeManagedSettingsPath() {
|
|
18279
|
-
return
|
|
18330
|
+
return join47(CLAUDE_MANAGED_SETTINGS_DIR, "managed-settings.json");
|
|
18280
18331
|
}
|
|
18281
18332
|
var MANAGED_SETTINGS_KEYS = ["channelsEnabled", "enableAllProjectMcpServers"];
|
|
18282
18333
|
var MANAGED_SETTINGS_ENV = { DISABLE_AUTOUPDATER: "1" };
|
|
@@ -18299,7 +18350,7 @@ function deniedTools(settings) {
|
|
|
18299
18350
|
}
|
|
18300
18351
|
function readCrossSessionBlockStatus(path = claudeManagedSettingsPath()) {
|
|
18301
18352
|
try {
|
|
18302
|
-
const parsed = JSON.parse(
|
|
18353
|
+
const parsed = JSON.parse(readFileSync38(path, "utf-8"));
|
|
18303
18354
|
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) return "missing";
|
|
18304
18355
|
const settings = parsed;
|
|
18305
18356
|
const deny = deniedTools(settings);
|
|
@@ -18318,7 +18369,7 @@ function managedSettingsOwnership(path) {
|
|
|
18318
18369
|
}
|
|
18319
18370
|
function writeManagedSettings(path, body, write = {
|
|
18320
18371
|
atomic: (p, d) => atomicWriteFileSync(p, d, managedSettingsOwnership(p)),
|
|
18321
|
-
inPlace: (p, d) =>
|
|
18372
|
+
inPlace: (p, d) => writeFileSync20(p, d)
|
|
18322
18373
|
}) {
|
|
18323
18374
|
try {
|
|
18324
18375
|
write.atomic(path, body);
|
|
@@ -18339,7 +18390,7 @@ function ensureClaudeManagedSettings(path = claudeManagedSettingsPath(), write =
|
|
|
18339
18390
|
try {
|
|
18340
18391
|
let settings = {};
|
|
18341
18392
|
if (existsSync20(path)) {
|
|
18342
|
-
const raw =
|
|
18393
|
+
const raw = readFileSync38(path, "utf-8").trim();
|
|
18343
18394
|
if (raw) {
|
|
18344
18395
|
let parsed;
|
|
18345
18396
|
try {
|
|
@@ -18432,7 +18483,7 @@ async function ensureOpencodeBinary() {
|
|
|
18432
18483
|
try {
|
|
18433
18484
|
const prefix = execFileSync4("npm", ["prefix", "-g"], { encoding: "utf-8", timeout: 1e4 }).trim();
|
|
18434
18485
|
if (prefix) {
|
|
18435
|
-
const npmBin =
|
|
18486
|
+
const npmBin = join47(prefix, "bin");
|
|
18436
18487
|
const current = (process.env.PATH ?? "").split(pathDelimiter);
|
|
18437
18488
|
if (!current.includes(npmBin)) {
|
|
18438
18489
|
process.env.PATH = [npmBin, ...current.filter(Boolean)].join(pathDelimiter);
|
|
@@ -18503,7 +18554,7 @@ async function ensureFrameworkBinary(frameworkId) {
|
|
|
18503
18554
|
agentRuntimeAuthenticated = await checkClaudeAuth();
|
|
18504
18555
|
}
|
|
18505
18556
|
var claudeCodeUpgradeInFlight = false;
|
|
18506
|
-
var SCRATCH_HOLDS_DIR = () =>
|
|
18557
|
+
var SCRATCH_HOLDS_DIR = () => join47(homedir17(), ".augmented", ".manager-scratch-holds");
|
|
18507
18558
|
setScratchSweepPolicyResolver(
|
|
18508
18559
|
(codeName) => resolveScratchSweepPolicy({
|
|
18509
18560
|
agentId: agentState.codeNameToAgentId.get(codeName),
|
|
@@ -18582,7 +18633,7 @@ async function maybeUpgradeClaudeCode() {
|
|
|
18582
18633
|
}
|
|
18583
18634
|
var UPDATE_CHECK_INTERVAL_MS = 5 * 60 * 1e3;
|
|
18584
18635
|
function selfUpdateAppliedMarkerPath() {
|
|
18585
|
-
return
|
|
18636
|
+
return join47(homedir17(), ".augmented", ".last-self-update-applied");
|
|
18586
18637
|
}
|
|
18587
18638
|
var selfUpdateUpToDateLogged = false;
|
|
18588
18639
|
var selfUpdatePinnedLogged = false;
|
|
@@ -18633,7 +18684,7 @@ async function checkAndUpdateCli(opts) {
|
|
|
18633
18684
|
const isNpmGlobal = !isBrewFormula && resolvedPath.includes("node_modules");
|
|
18634
18685
|
if (!isBrewFormula && !isNpmGlobal) return "noop";
|
|
18635
18686
|
const { readFileSync: readF, writeFileSync: writeF } = await import("fs");
|
|
18636
|
-
const markerPath =
|
|
18687
|
+
const markerPath = join47(homedir17(), ".augmented", ".last-update-check");
|
|
18637
18688
|
if (!force) {
|
|
18638
18689
|
try {
|
|
18639
18690
|
const lastCheck = parseInt(readF(markerPath, "utf-8").trim(), 10);
|
|
@@ -19137,13 +19188,13 @@ async function checkClaudeAuth() {
|
|
|
19137
19188
|
var evalEmptyMcpConfigPath = null;
|
|
19138
19189
|
function ensureEvalEmptyMcpConfig() {
|
|
19139
19190
|
if (evalEmptyMcpConfigPath && existsSync20(evalEmptyMcpConfigPath)) return evalEmptyMcpConfigPath;
|
|
19140
|
-
const dir =
|
|
19191
|
+
const dir = join47(homedir17(), ".augmented");
|
|
19141
19192
|
try {
|
|
19142
19193
|
mkdirSync18(dir, { recursive: true });
|
|
19143
19194
|
} catch {
|
|
19144
19195
|
}
|
|
19145
|
-
const p =
|
|
19146
|
-
|
|
19196
|
+
const p = join47(dir, ".eval-empty-mcp.json");
|
|
19197
|
+
writeFileSync20(p, JSON.stringify({ mcpServers: {} }));
|
|
19147
19198
|
evalEmptyMcpConfigPath = p;
|
|
19148
19199
|
return p;
|
|
19149
19200
|
}
|
|
@@ -19233,10 +19284,10 @@ function resolveConversationEvalBackend() {
|
|
|
19233
19284
|
return conversationEvalBackend;
|
|
19234
19285
|
}
|
|
19235
19286
|
function getStateFile() {
|
|
19236
|
-
return
|
|
19287
|
+
return join47(config?.configDir ?? join47(process.env["HOME"] ?? "/tmp", ".augmented"), "manager-state.json");
|
|
19237
19288
|
}
|
|
19238
19289
|
function channelHashCacheDir() {
|
|
19239
|
-
return config?.configDir ??
|
|
19290
|
+
return config?.configDir ?? join47(process.env["HOME"] ?? "/tmp", ".augmented");
|
|
19240
19291
|
}
|
|
19241
19292
|
function loadChannelHashCache2() {
|
|
19242
19293
|
loadChannelHashCache(agentState.knownChannelConfigHashes, channelHashCacheDir());
|
|
@@ -19449,7 +19500,7 @@ function removeDeliveryBaselineEntries(agentId) {
|
|
|
19449
19500
|
var _channelQuarantineStore = null;
|
|
19450
19501
|
function channelQuarantineStore() {
|
|
19451
19502
|
if (!_channelQuarantineStore) {
|
|
19452
|
-
const dir = config?.configDir ??
|
|
19503
|
+
const dir = config?.configDir ?? join47(process.env["HOME"] ?? "/tmp", ".augmented");
|
|
19453
19504
|
_channelQuarantineStore = new ChannelQuarantineStore(defaultQuarantinePath(dir));
|
|
19454
19505
|
}
|
|
19455
19506
|
return _channelQuarantineStore;
|
|
@@ -19457,7 +19508,7 @@ function channelQuarantineStore() {
|
|
|
19457
19508
|
var _channelResumeHistoryStore = null;
|
|
19458
19509
|
function channelResumeHistoryStore() {
|
|
19459
19510
|
if (!_channelResumeHistoryStore) {
|
|
19460
|
-
const dir = config?.configDir ??
|
|
19511
|
+
const dir = config?.configDir ?? join47(process.env["HOME"] ?? "/tmp", ".augmented");
|
|
19461
19512
|
_channelResumeHistoryStore = new ChannelResumeHistoryStore(defaultResumeHistoryPath(dir));
|
|
19462
19513
|
}
|
|
19463
19514
|
return _channelResumeHistoryStore;
|
|
@@ -19502,12 +19553,12 @@ function sessionActivityFor(codeName, pane, opts = {}) {
|
|
|
19502
19553
|
}
|
|
19503
19554
|
function forwardedToolsFor(codeName) {
|
|
19504
19555
|
if (!config?.configDir) return null;
|
|
19505
|
-
return readForwardedToolsReport(
|
|
19556
|
+
return readForwardedToolsReport(join47(config.configDir, codeName));
|
|
19506
19557
|
}
|
|
19507
19558
|
var _hostFlagStore = null;
|
|
19508
19559
|
function hostFlagStore() {
|
|
19509
19560
|
if (!_hostFlagStore) {
|
|
19510
|
-
const dir = config?.configDir ??
|
|
19561
|
+
const dir = config?.configDir ?? join47(process.env["HOME"] ?? "/tmp", ".augmented");
|
|
19511
19562
|
_hostFlagStore = new HostFlagStore({ cachePath: defaultFlagsCachePath(dir), log });
|
|
19512
19563
|
}
|
|
19513
19564
|
return _hostFlagStore;
|
|
@@ -19580,13 +19631,13 @@ function parseSkillFrontmatter(content) {
|
|
|
19580
19631
|
return out;
|
|
19581
19632
|
}
|
|
19582
19633
|
async function refreshSkillsIndexInClaudeMd(configDir, codeName, log2) {
|
|
19583
|
-
const { readdirSync: readdirSync15, readFileSync: rfs, existsSync: ex, writeFileSync:
|
|
19584
|
-
const skillsDir =
|
|
19585
|
-
const claudeMdPath =
|
|
19634
|
+
const { readdirSync: readdirSync15, readFileSync: rfs, existsSync: ex, writeFileSync: writeFileSync21 } = await import("fs");
|
|
19635
|
+
const skillsDir = join47(configDir, codeName, "project", ".claude", "skills");
|
|
19636
|
+
const claudeMdPath = join47(configDir, codeName, "project", "CLAUDE.md");
|
|
19586
19637
|
if (!ex(skillsDir) || !ex(claudeMdPath)) return;
|
|
19587
19638
|
const entries = [];
|
|
19588
19639
|
for (const dir of readdirSync15(skillsDir).sort()) {
|
|
19589
|
-
const skillFile =
|
|
19640
|
+
const skillFile = join47(skillsDir, dir, "SKILL.md");
|
|
19590
19641
|
if (!ex(skillFile)) continue;
|
|
19591
19642
|
try {
|
|
19592
19643
|
const { name, description } = parseSkillFrontmatter(rfs(skillFile, "utf-8"));
|
|
@@ -19630,7 +19681,7 @@ ${SKILLS_INDEX_END}`;
|
|
|
19630
19681
|
next = current.trimEnd() + "\n\n" + section + "\n";
|
|
19631
19682
|
}
|
|
19632
19683
|
if (next !== current) {
|
|
19633
|
-
|
|
19684
|
+
writeFileSync21(claudeMdPath, next, "utf-8");
|
|
19634
19685
|
log2(
|
|
19635
19686
|
injectSkillList ? `Refreshed skills index in CLAUDE.md for '${codeName}' (${entries.length} skills)` : `Refreshed CLAUDE.md managed block for '${codeName}' (skill list suppressed by claude-md-skills-index=false; ${entries.length} skills on disk)`
|
|
19636
19687
|
);
|
|
@@ -19725,7 +19776,7 @@ function flushRestartedAgentDiagnostics(hostId, codeNames) {
|
|
|
19725
19776
|
if (codeNames.length === 0) return;
|
|
19726
19777
|
void (async () => {
|
|
19727
19778
|
try {
|
|
19728
|
-
const { collectDiagnostics } = await import("../persistent-session-
|
|
19779
|
+
const { collectDiagnostics } = await import("../persistent-session-SMMVQBRS.js");
|
|
19729
19780
|
await api.post("/host/heartbeat", {
|
|
19730
19781
|
host_id: hostId,
|
|
19731
19782
|
agent_diagnostics: collectDiagnostics(codeNames, quarantineEntriesFor, claudeMdSizeFor, spawnOutcomeForDiagnostics, pidPressureFor, forwardedToolsFor, runtimeVersionFor, sessionActivityFor)
|
|
@@ -19868,7 +19919,7 @@ async function pollCycleInner() {
|
|
|
19868
19919
|
}
|
|
19869
19920
|
try {
|
|
19870
19921
|
const { detectHostSecurity } = await import("../host-security-KQYYZZVW.js");
|
|
19871
|
-
const { collectDiagnostics } = await import("../persistent-session-
|
|
19922
|
+
const { collectDiagnostics } = await import("../persistent-session-SMMVQBRS.js");
|
|
19872
19923
|
const diagCodeNames = [...agentState.persistentSessionAgents];
|
|
19873
19924
|
const agentDiagnostics = diagCodeNames.length > 0 ? collectDiagnostics(diagCodeNames, quarantineEntriesFor, claudeMdSizeFor, spawnOutcomeForDiagnostics, pidPressureFor, forwardedToolsFor, runtimeVersionFor, sessionActivityFor) : void 0;
|
|
19874
19925
|
let tailscaleHostname;
|
|
@@ -20139,7 +20190,7 @@ async function pollCycleInner() {
|
|
|
20139
20190
|
}
|
|
20140
20191
|
try {
|
|
20141
20192
|
const desiredClaudeCodeVersion = hbResp?.desired_claude_code_version?.trim();
|
|
20142
|
-
const { maybeUpdateClaudeCode, shouldRunClaudeCodeUpdater } = await import("../claude-code-updater-
|
|
20193
|
+
const { maybeUpdateClaudeCode, shouldRunClaudeCodeUpdater } = await import("../claude-code-updater-K6PENJ7A.js");
|
|
20143
20194
|
const securityFloor = currentSecurityFloor();
|
|
20144
20195
|
claudeUpdaterInFlight = true;
|
|
20145
20196
|
if (desiredClaudeCodeVersion && (claudePairLoop.busy || claudePairingInProgress())) {
|
|
@@ -20174,7 +20225,7 @@ async function pollCycleInner() {
|
|
|
20174
20225
|
collectPanelessActivityProbes,
|
|
20175
20226
|
getResponsivenessIntervalMs,
|
|
20176
20227
|
occupancyQualificationClassifications
|
|
20177
|
-
} = await import("../responsiveness-probe-
|
|
20228
|
+
} = await import("../responsiveness-probe-PX4FMO4H.js");
|
|
20178
20229
|
const probeIntervalMs = getResponsivenessIntervalMs();
|
|
20179
20230
|
if (now - lastResponsivenessProbeAt > probeIntervalMs) {
|
|
20180
20231
|
const probeCodeNames = [...agentState.persistentSessionAgents];
|
|
@@ -20291,7 +20342,7 @@ async function pollCycleInner() {
|
|
|
20291
20342
|
collectResponsivenessProbes,
|
|
20292
20343
|
livePendingInboundOldestAgeSeconds,
|
|
20293
20344
|
parkPendingInbound
|
|
20294
|
-
} = await import("../responsiveness-probe-
|
|
20345
|
+
} = await import("../responsiveness-probe-PX4FMO4H.js");
|
|
20295
20346
|
const { getProjectDir: wedgeProjectDir } = await import("../scheduler-engine-5PCBGRNY.js");
|
|
20296
20347
|
const wedgeNow = /* @__PURE__ */ new Date();
|
|
20297
20348
|
const liveAgents = agentState.persistentSessionAgents;
|
|
@@ -20380,13 +20431,13 @@ async function pollCycleInner() {
|
|
|
20380
20431
|
);
|
|
20381
20432
|
if (hostFlagStore().getBoolean("wedge-transient-notice")) {
|
|
20382
20433
|
try {
|
|
20383
|
-
const paneTail =
|
|
20434
|
+
const paneTail = readFileSync38(paneLogPath(codeName), "utf8").slice(-65536);
|
|
20384
20435
|
const transient = detectTransientApiErrorInLog(paneTail);
|
|
20385
20436
|
if (transient) {
|
|
20386
|
-
const wedgeHome =
|
|
20437
|
+
const wedgeHome = join47(homedir17(), ".augmented", codeName);
|
|
20387
20438
|
if (existsSync20(wedgeHome)) {
|
|
20388
20439
|
atomicWriteFileSync(
|
|
20389
|
-
|
|
20440
|
+
join47(wedgeHome, "watchdog-give-up.json"),
|
|
20390
20441
|
JSON.stringify({
|
|
20391
20442
|
gave_up_at: wedgeNow.toISOString(),
|
|
20392
20443
|
reason: "transient_overload"
|
|
@@ -20577,7 +20628,7 @@ async function pollCycleInner() {
|
|
|
20577
20628
|
}
|
|
20578
20629
|
}
|
|
20579
20630
|
);
|
|
20580
|
-
const { parkPendingInbound } = await import("../responsiveness-probe-
|
|
20631
|
+
const { parkPendingInbound } = await import("../responsiveness-probe-PX4FMO4H.js");
|
|
20581
20632
|
const { parked, deadLettered } = parkPendingInbound(codeName, new Date(fatalNowMs));
|
|
20582
20633
|
paneFatalStreak.delete(codeName);
|
|
20583
20634
|
paneFatalRestarts.set(codeName, [...history, fatalNowMs]);
|
|
@@ -20608,7 +20659,7 @@ async function pollCycleInner() {
|
|
|
20608
20659
|
TRANSCRIPT_MOUNT_ESCALATION_REFRESH_MS,
|
|
20609
20660
|
bindSourceEscalations
|
|
20610
20661
|
} = await import("../transcript-mount-health-OHE6IVJV.js");
|
|
20611
|
-
const { transcriptBindSourcesFor, ensureTranscriptBindSources } = await import("../persistent-session-
|
|
20662
|
+
const { transcriptBindSourcesFor, ensureTranscriptBindSources } = await import("../persistent-session-SMMVQBRS.js");
|
|
20612
20663
|
const mountConfig = resolveTranscriptMountConfig();
|
|
20613
20664
|
const liveAgents = agentState.persistentSessionAgents;
|
|
20614
20665
|
for (const tracked of [
|
|
@@ -20773,7 +20824,7 @@ async function pollCycleInner() {
|
|
|
20773
20824
|
}
|
|
20774
20825
|
try {
|
|
20775
20826
|
const { scrapeMcpFailedBannerCount } = await import("../pane-mcp-banner-scraper-VR5QGP3J.js");
|
|
20776
|
-
const { probeSessionAuth } = await import("../session-auth-dead-
|
|
20827
|
+
const { probeSessionAuth } = await import("../session-auth-dead-47D57WMA.js");
|
|
20777
20828
|
const observations = [];
|
|
20778
20829
|
const pendingCacheCommits = [];
|
|
20779
20830
|
const modelApiErrorReportingOn = hostFlagStore().getBoolean("model-api-error-reporting");
|
|
@@ -21327,7 +21378,7 @@ async function pollCycleInner() {
|
|
|
21327
21378
|
`[drain-flush] FAILED for '${prev.codeName}': ${err.message} \u2014 proceeding to teardown; this session was NOT shipped (ENG-9491)`
|
|
21328
21379
|
);
|
|
21329
21380
|
}
|
|
21330
|
-
const agentDir =
|
|
21381
|
+
const agentDir = join47(adapter.getAgentDir(prev.codeName), "provision");
|
|
21331
21382
|
await cleanupAgentFiles(prev.codeName, agentDir);
|
|
21332
21383
|
clearAgentCaches(prev.agentId, prev.codeName);
|
|
21333
21384
|
}
|
|
@@ -21406,10 +21457,10 @@ async function pollCycleInner() {
|
|
|
21406
21457
|
// pending-inbound marker. Best-effort: a write failure is logged by
|
|
21407
21458
|
// the watchdog, never fails the poll cycle.
|
|
21408
21459
|
signalGiveUp: (codeName) => {
|
|
21409
|
-
const dir =
|
|
21460
|
+
const dir = join47(homedir17(), ".augmented", codeName);
|
|
21410
21461
|
if (!existsSync20(dir)) return;
|
|
21411
21462
|
atomicWriteFileSync(
|
|
21412
|
-
|
|
21463
|
+
join47(dir, "watchdog-give-up.json"),
|
|
21413
21464
|
JSON.stringify({ gave_up_at: (/* @__PURE__ */ new Date()).toISOString() })
|
|
21414
21465
|
);
|
|
21415
21466
|
},
|
|
@@ -21437,20 +21488,20 @@ async function pollCycleInner() {
|
|
|
21437
21488
|
const dir = getFramework("claude-code").getAgentDir(codeName);
|
|
21438
21489
|
if (!existsSync20(dir)) return;
|
|
21439
21490
|
atomicWriteFileSync(
|
|
21440
|
-
|
|
21491
|
+
join47(dir, "blocked-prompt.json"),
|
|
21441
21492
|
JSON.stringify({ kind, last_seen_at: (/* @__PURE__ */ new Date()).toISOString() })
|
|
21442
21493
|
);
|
|
21443
21494
|
},
|
|
21444
21495
|
clearBlockedPromptLiveness: (codeName) => {
|
|
21445
|
-
const file =
|
|
21496
|
+
const file = join47(getFramework("claude-code").getAgentDir(codeName), "blocked-prompt.json");
|
|
21446
21497
|
if (existsSync20(file)) rmSync9(file, { force: true });
|
|
21447
21498
|
},
|
|
21448
21499
|
refreshUsageLimitLiveness: (codeName) => {
|
|
21449
21500
|
const dir = getFramework("claude-code").getAgentDir(codeName);
|
|
21450
|
-
const file =
|
|
21501
|
+
const file = join47(dir, "watchdog-give-up.json");
|
|
21451
21502
|
if (!existsSync20(file)) return;
|
|
21452
21503
|
try {
|
|
21453
|
-
const raw = JSON.parse(
|
|
21504
|
+
const raw = JSON.parse(readFileSync38(file, "utf8"));
|
|
21454
21505
|
if (raw["reason"] !== "usage_limit") return;
|
|
21455
21506
|
raw["usage_limit_last_seen_at"] = (/* @__PURE__ */ new Date()).toISOString();
|
|
21456
21507
|
atomicWriteFileSync(file, JSON.stringify(raw));
|
|
@@ -21461,7 +21512,7 @@ async function pollCycleInner() {
|
|
|
21461
21512
|
const dir = getFramework("claude-code").getAgentDir(codeName);
|
|
21462
21513
|
if (!existsSync20(dir)) return;
|
|
21463
21514
|
atomicWriteFileSync(
|
|
21464
|
-
|
|
21515
|
+
join47(dir, "watchdog-give-up.json"),
|
|
21465
21516
|
JSON.stringify({
|
|
21466
21517
|
gave_up_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
21467
21518
|
reason: "usage_limit",
|
|
@@ -21738,7 +21789,7 @@ async function processAgent(agent, agentStates, managedToolkits) {
|
|
|
21738
21789
|
}
|
|
21739
21790
|
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
21740
21791
|
const adapter = resolveAgentFramework(agent.code_name);
|
|
21741
|
-
let agentDir =
|
|
21792
|
+
let agentDir = join47(adapter.getAgentDir(agent.code_name), "provision");
|
|
21742
21793
|
if (agent.status === "draft" || agent.status === "paused") {
|
|
21743
21794
|
forgetChannelSyncState(agent.agent_id);
|
|
21744
21795
|
reapLegacyTokenFileEdgeWarned(agent.code_name, log);
|
|
@@ -21886,7 +21937,7 @@ async function processAgent(agent, agentStates, managedToolkits) {
|
|
|
21886
21937
|
if (refreshData.knowledge_manifest) {
|
|
21887
21938
|
const resolved = await resolveKnowledgeFromManifest({
|
|
21888
21939
|
manifest: refreshData.knowledge_manifest,
|
|
21889
|
-
cacheDir:
|
|
21940
|
+
cacheDir: join47(config.configDir, "_knowledge"),
|
|
21890
21941
|
delivery: refreshData.agent?.knowledge_delivery ?? "both",
|
|
21891
21942
|
fetchContents: async (hashes) => {
|
|
21892
21943
|
const res = await api.post(
|
|
@@ -21903,7 +21954,7 @@ async function processAgent(agent, agentStates, managedToolkits) {
|
|
|
21903
21954
|
const resolvedSkills = await resolveSkillsFromManifest({
|
|
21904
21955
|
globals: refreshData.global_skills_manifest ?? [],
|
|
21905
21956
|
shared: refreshData.shared_skills_manifest ?? [],
|
|
21906
|
-
cacheDir:
|
|
21957
|
+
cacheDir: join47(config.configDir, "_skills"),
|
|
21907
21958
|
fetchContents: async (hashes) => {
|
|
21908
21959
|
const res = await api.post(
|
|
21909
21960
|
"/host/skills/contents",
|
|
@@ -21921,7 +21972,7 @@ async function processAgent(agent, agentStates, managedToolkits) {
|
|
|
21921
21972
|
if (refreshData.integration_skills_manifest) {
|
|
21922
21973
|
const resolvedIntegrationSkills = await resolveIntegrationSkillsFromManifest({
|
|
21923
21974
|
manifest: refreshData.integration_skills_manifest,
|
|
21924
|
-
cacheDir:
|
|
21975
|
+
cacheDir: join47(config.configDir, "_skills"),
|
|
21925
21976
|
fetchContents: async (hashes) => {
|
|
21926
21977
|
const res = await api.post(
|
|
21927
21978
|
"/host/skills/contents",
|
|
@@ -21983,7 +22034,7 @@ async function processAgent(agent, agentStates, managedToolkits) {
|
|
|
21983
22034
|
const frameworkId = refreshData.agent.framework ?? DEFAULT_FRAMEWORK;
|
|
21984
22035
|
agentFrameworkCache.set(agent.code_name, frameworkId);
|
|
21985
22036
|
const frameworkAdapter = getFramework(frameworkId);
|
|
21986
|
-
agentDir =
|
|
22037
|
+
agentDir = join47(frameworkAdapter.getAgentDir(agent.code_name), "provision");
|
|
21987
22038
|
cacheAgentDeliveryMetadata(agent.code_name, refreshData);
|
|
21988
22039
|
agentRestartTimezoneInputs.set(agent.code_name, {
|
|
21989
22040
|
agentTimezone: typeof refreshData.agent.timezone === "string" ? refreshData.agent.timezone : null,
|
|
@@ -22061,7 +22112,7 @@ async function processAgent(agent, agentStates, managedToolkits) {
|
|
|
22061
22112
|
const changedFiles = [];
|
|
22062
22113
|
mkdirSync18(agentDir, { recursive: true });
|
|
22063
22114
|
for (const artifact of artifacts) {
|
|
22064
|
-
const filePath =
|
|
22115
|
+
const filePath = join47(agentDir, artifact.relativePath);
|
|
22065
22116
|
let existingHash;
|
|
22066
22117
|
let newHash;
|
|
22067
22118
|
let writeContent = artifact.content;
|
|
@@ -22080,8 +22131,8 @@ async function processAgent(agent, agentStates, managedToolkits) {
|
|
|
22080
22131
|
};
|
|
22081
22132
|
newHash = sha256(stripDynamicSections(artifact.content));
|
|
22082
22133
|
try {
|
|
22083
|
-
const projectClaudeMd =
|
|
22084
|
-
const existing =
|
|
22134
|
+
const projectClaudeMd = join47(config.configDir, agent.code_name, "project", "CLAUDE.md");
|
|
22135
|
+
const existing = readFileSync38(projectClaudeMd, "utf-8");
|
|
22085
22136
|
existingHash = sha256(stripDynamicSections(existing));
|
|
22086
22137
|
} catch {
|
|
22087
22138
|
existingHash = null;
|
|
@@ -22099,7 +22150,7 @@ async function processAgent(agent, agentStates, managedToolkits) {
|
|
|
22099
22150
|
const generatorKeys = Object.keys(generatorServers);
|
|
22100
22151
|
let existingRaw = "";
|
|
22101
22152
|
try {
|
|
22102
|
-
existingRaw =
|
|
22153
|
+
existingRaw = readFileSync38(filePath, "utf-8");
|
|
22103
22154
|
} catch {
|
|
22104
22155
|
}
|
|
22105
22156
|
const existingServers = parseMcp(existingRaw);
|
|
@@ -22115,7 +22166,7 @@ async function processAgent(agent, agentStates, managedToolkits) {
|
|
|
22115
22166
|
} else if (artifact.relativePath === "opencode.json") {
|
|
22116
22167
|
let existingRaw = null;
|
|
22117
22168
|
try {
|
|
22118
|
-
existingRaw =
|
|
22169
|
+
existingRaw = readFileSync38(filePath, "utf-8");
|
|
22119
22170
|
} catch {
|
|
22120
22171
|
}
|
|
22121
22172
|
const mergeResult = mergeOpencodeConfigArtifact(artifact.content, existingRaw);
|
|
@@ -22131,26 +22182,26 @@ async function processAgent(agent, agentStates, managedToolkits) {
|
|
|
22131
22182
|
}
|
|
22132
22183
|
}
|
|
22133
22184
|
if (changedFiles.length > 0) {
|
|
22134
|
-
const isFirst = !existsSync20(
|
|
22185
|
+
const isFirst = !existsSync20(join47(agentDir, "CHARTER.md"));
|
|
22135
22186
|
const verb = isFirst ? "Provisioning" : "Updating";
|
|
22136
22187
|
const fileNames = changedFiles.map((f) => f.relativePath).join(", ");
|
|
22137
22188
|
log(`${verb} '${agent.code_name}': ${fileNames}`);
|
|
22138
22189
|
for (const file of changedFiles) {
|
|
22139
|
-
const filePath =
|
|
22190
|
+
const filePath = join47(agentDir, file.relativePath);
|
|
22140
22191
|
mkdirSync18(dirname11(filePath), { recursive: true });
|
|
22141
22192
|
if (file.relativePath === ".mcp.json") {
|
|
22142
22193
|
safeWriteJsonAtomic(filePath, file.content, { mode: 384 });
|
|
22143
22194
|
} else {
|
|
22144
|
-
|
|
22195
|
+
writeFileSync20(filePath, file.content);
|
|
22145
22196
|
}
|
|
22146
22197
|
}
|
|
22147
22198
|
try {
|
|
22148
|
-
const provSkillsDir =
|
|
22199
|
+
const provSkillsDir = join47(agentDir, ".claude", "skills");
|
|
22149
22200
|
if (existsSync20(provSkillsDir)) {
|
|
22150
22201
|
for (const folder of readdirSync14(provSkillsDir)) {
|
|
22151
22202
|
if (folder.startsWith("knowledge-")) {
|
|
22152
22203
|
try {
|
|
22153
|
-
rmSync9(
|
|
22204
|
+
rmSync9(join47(provSkillsDir, folder), { recursive: true });
|
|
22154
22205
|
} catch {
|
|
22155
22206
|
}
|
|
22156
22207
|
}
|
|
@@ -22163,7 +22214,7 @@ async function processAgent(agent, agentStates, managedToolkits) {
|
|
|
22163
22214
|
const trackedFiles2 = frameworkAdapter.driftTrackedFiles();
|
|
22164
22215
|
const hashes = /* @__PURE__ */ new Map();
|
|
22165
22216
|
for (const file of trackedFiles2) {
|
|
22166
|
-
const h = hashFile(
|
|
22217
|
+
const h = hashFile(join47(agentDir, file));
|
|
22167
22218
|
if (h) hashes.set(file, h);
|
|
22168
22219
|
}
|
|
22169
22220
|
agentState.writtenHashes.set(agent.agent_id, hashes);
|
|
@@ -22181,14 +22232,14 @@ async function processAgent(agent, agentStates, managedToolkits) {
|
|
|
22181
22232
|
}
|
|
22182
22233
|
if (Array.isArray(refreshData.workflows)) {
|
|
22183
22234
|
try {
|
|
22184
|
-
const provWorkflowsDir =
|
|
22235
|
+
const provWorkflowsDir = join47(agentDir, ".claude", "workflows");
|
|
22185
22236
|
if (existsSync20(provWorkflowsDir)) {
|
|
22186
22237
|
const expected = new Set(refreshData.workflows.map((w) => `${w.name}.js`));
|
|
22187
22238
|
for (const file of readdirSync14(provWorkflowsDir)) {
|
|
22188
22239
|
if (!file.endsWith(".js")) continue;
|
|
22189
22240
|
if (expected.has(file)) continue;
|
|
22190
22241
|
try {
|
|
22191
|
-
rmSync9(
|
|
22242
|
+
rmSync9(join47(provWorkflowsDir, file));
|
|
22192
22243
|
} catch {
|
|
22193
22244
|
}
|
|
22194
22245
|
}
|
|
@@ -22283,7 +22334,7 @@ async function processAgent(agent, agentStates, managedToolkits) {
|
|
|
22283
22334
|
if (written && existsSync20(agentDir)) {
|
|
22284
22335
|
const driftedFiles = [];
|
|
22285
22336
|
for (const [file, expectedHash] of written) {
|
|
22286
|
-
const localHash = hashFile(
|
|
22337
|
+
const localHash = hashFile(join47(agentDir, file));
|
|
22287
22338
|
if (localHash && localHash !== expectedHash) {
|
|
22288
22339
|
driftedFiles.push(file);
|
|
22289
22340
|
}
|
|
@@ -22294,7 +22345,7 @@ async function processAgent(agent, agentStates, managedToolkits) {
|
|
|
22294
22345
|
try {
|
|
22295
22346
|
const localHashes = {};
|
|
22296
22347
|
for (const file of driftedFiles) {
|
|
22297
|
-
localHashes[file] = hashFile(
|
|
22348
|
+
localHashes[file] = hashFile(join47(agentDir, file));
|
|
22298
22349
|
}
|
|
22299
22350
|
await api.post("/host/drift", {
|
|
22300
22351
|
agent_id: agent.agent_id,
|
|
@@ -22579,7 +22630,7 @@ async function processAgent(agent, agentStates, managedToolkits) {
|
|
|
22579
22630
|
const addedChannels = [...restartDecision.added];
|
|
22580
22631
|
const writeDmNoticeMarkers = isChannelAddRestart ? () => {
|
|
22581
22632
|
try {
|
|
22582
|
-
const agentAugmentedDir =
|
|
22633
|
+
const agentAugmentedDir = join47(homedir17(), ".augmented", agent.code_name);
|
|
22583
22634
|
mkdirSync18(agentAugmentedDir, { recursive: true });
|
|
22584
22635
|
const markerJson = JSON.stringify({
|
|
22585
22636
|
version: 1,
|
|
@@ -22587,7 +22638,7 @@ async function processAgent(agent, agentStates, managedToolkits) {
|
|
|
22587
22638
|
added: addedChannels
|
|
22588
22639
|
});
|
|
22589
22640
|
for (const file of ["slack-channel-add-restart.json", "telegram-channel-add-restart.json"]) {
|
|
22590
|
-
atomicWriteFileSync(
|
|
22641
|
+
atomicWriteFileSync(join47(agentAugmentedDir, file), markerJson);
|
|
22591
22642
|
}
|
|
22592
22643
|
} catch (err) {
|
|
22593
22644
|
log(`[hot-reload] channel-add DM-notice marker write failed for '${agent.code_name}' (non-fatal): ${err.message}`);
|
|
@@ -22891,18 +22942,18 @@ async function processAgent(agent, agentStates, managedToolkits) {
|
|
|
22891
22942
|
if (agentSessionMode === "persistent" && (agentFrameworkCache.get(agent.code_name) ?? DEFAULT_FRAMEWORK) === "claude-code") {
|
|
22892
22943
|
try {
|
|
22893
22944
|
const agentProvisionDir = agentDir;
|
|
22894
|
-
const projectDir =
|
|
22945
|
+
const projectDir = join47(homedir17(), ".augmented", agent.code_name, "project");
|
|
22895
22946
|
mkdirSync18(agentProvisionDir, { recursive: true });
|
|
22896
22947
|
mkdirSync18(projectDir, { recursive: true });
|
|
22897
|
-
const provisionMcpPath =
|
|
22898
|
-
const projectMcpPath =
|
|
22948
|
+
const provisionMcpPath = join47(agentProvisionDir, ".mcp.json");
|
|
22949
|
+
const projectMcpPath = join47(projectDir, ".mcp.json");
|
|
22899
22950
|
let mcpConfig = { mcpServers: {} };
|
|
22900
22951
|
try {
|
|
22901
|
-
mcpConfig = JSON.parse(
|
|
22952
|
+
mcpConfig = JSON.parse(readFileSync38(provisionMcpPath, "utf-8"));
|
|
22902
22953
|
if (!mcpConfig.mcpServers) mcpConfig.mcpServers = {};
|
|
22903
22954
|
} catch {
|
|
22904
22955
|
}
|
|
22905
|
-
const localDirectChatChannel =
|
|
22956
|
+
const localDirectChatChannel = join47(homedir17(), ".augmented", "_mcp", "direct-chat-channel.js");
|
|
22906
22957
|
const directChatTeamSettings = refreshData.team?.settings;
|
|
22907
22958
|
const directChatTz = (() => {
|
|
22908
22959
|
const tz = directChatTeamSettings?.["timezone"];
|
|
@@ -22928,7 +22979,7 @@ async function processAgent(agent, agentStates, managedToolkits) {
|
|
|
22928
22979
|
// ~/.augmented/<codeName>/.current-turn-initiator.json. Note getAgentDir
|
|
22929
22980
|
// returns the agent root (NOT the /provision subdir `agentDir` points at),
|
|
22930
22981
|
// so it byte-matches the broker readers' path.
|
|
22931
|
-
AGT_TURN_INITIATOR_FILE:
|
|
22982
|
+
AGT_TURN_INITIATOR_FILE: join47(
|
|
22932
22983
|
frameworkAdapter.getAgentDir(agent.code_name),
|
|
22933
22984
|
".current-turn-initiator.json"
|
|
22934
22985
|
)
|
|
@@ -22948,7 +22999,7 @@ async function processAgent(agent, agentStates, managedToolkits) {
|
|
|
22948
22999
|
log(`Channel credentials written for '${agent.code_name}/direct-chat'`);
|
|
22949
23000
|
}
|
|
22950
23001
|
}
|
|
22951
|
-
const staleChannelsPath =
|
|
23002
|
+
const staleChannelsPath = join47(projectDir, ".mcp-channels.json");
|
|
22952
23003
|
if (existsSync20(staleChannelsPath)) {
|
|
22953
23004
|
try {
|
|
22954
23005
|
rmSync9(staleChannelsPath, { force: true });
|
|
@@ -23076,7 +23127,7 @@ async function processAgent(agent, agentStates, managedToolkits) {
|
|
|
23076
23127
|
}
|
|
23077
23128
|
if (hostFlagStore().getBoolean("connectivity-probe")) {
|
|
23078
23129
|
try {
|
|
23079
|
-
const probeProjectDir =
|
|
23130
|
+
const probeProjectDir = join47(homedir17(), ".augmented", agent.code_name, "project");
|
|
23080
23131
|
let probeSet = integrations;
|
|
23081
23132
|
const fetchQuarantined = async () => {
|
|
23082
23133
|
const quarantined = await api.post("/host/agent-integrations/quarantined", { agent_id: agent.agent_id });
|
|
@@ -23136,7 +23187,7 @@ async function processAgent(agent, agentStates, managedToolkits) {
|
|
|
23136
23187
|
const forceDue = attemptsLeft > 0;
|
|
23137
23188
|
let probeRan = false;
|
|
23138
23189
|
try {
|
|
23139
|
-
const probeProjectDir =
|
|
23190
|
+
const probeProjectDir = join47(homedir17(), ".augmented", agent.code_name, "project");
|
|
23140
23191
|
const renderPending = integrationRenderPending(
|
|
23141
23192
|
integrations,
|
|
23142
23193
|
agentState.knownIntegrationHashes.get(agent.agent_id)
|
|
@@ -23265,11 +23316,11 @@ async function processAgent(agent, agentStates, managedToolkits) {
|
|
|
23265
23316
|
const intHash = computeIntegrationsHash(integrations);
|
|
23266
23317
|
const prevIntHash = agentState.knownIntegrationHashes.get(agent.agent_id);
|
|
23267
23318
|
if (intHash !== prevIntHash) {
|
|
23268
|
-
const projectDir =
|
|
23269
|
-
const envIntPath =
|
|
23319
|
+
const projectDir = join47(homedir17(), ".augmented", agent.code_name, "project");
|
|
23320
|
+
const envIntPath = join47(projectDir, ".env.integrations");
|
|
23270
23321
|
let preWriteEnv;
|
|
23271
23322
|
try {
|
|
23272
|
-
preWriteEnv =
|
|
23323
|
+
preWriteEnv = readFileSync38(envIntPath, "utf-8");
|
|
23273
23324
|
} catch {
|
|
23274
23325
|
preWriteEnv = void 0;
|
|
23275
23326
|
}
|
|
@@ -23297,9 +23348,9 @@ async function processAgent(agent, agentStates, managedToolkits) {
|
|
|
23297
23348
|
}
|
|
23298
23349
|
if (fw === "claude-code" && isSessionHealthy(agent.code_name)) {
|
|
23299
23350
|
try {
|
|
23300
|
-
const projectMcpPath =
|
|
23301
|
-
const postWriteEnv =
|
|
23302
|
-
const mcpContent =
|
|
23351
|
+
const projectMcpPath = join47(projectDir, ".mcp.json");
|
|
23352
|
+
const postWriteEnv = readFileSync38(envIntPath, "utf-8");
|
|
23353
|
+
const mcpContent = readFileSync38(projectMcpPath, "utf-8");
|
|
23303
23354
|
const changedVars = diffEnvIntegrations(preWriteEnv, postWriteEnv);
|
|
23304
23355
|
const mcpJsonForReap = JSON.parse(mcpContent);
|
|
23305
23356
|
const affectedServerKeys = findMcpServersUsingVars(mcpJsonForReap, changedVars);
|
|
@@ -23652,12 +23703,12 @@ async function processAgent(agent, agentStates, managedToolkits) {
|
|
|
23652
23703
|
const frameworkId2 = frameworkAdapter.id;
|
|
23653
23704
|
const candidateSkillDirs = [
|
|
23654
23705
|
// Claude Code — framework runtime tree
|
|
23655
|
-
|
|
23706
|
+
join47(homedir18(), ".augmented", agent.code_name, "skills"),
|
|
23656
23707
|
// Claude Code — project tree
|
|
23657
|
-
|
|
23708
|
+
join47(homedir18(), ".augmented", agent.code_name, "project", ".claude", "skills"),
|
|
23658
23709
|
// Defensive: legacy provision-side path, not currently an
|
|
23659
23710
|
// install target but cheap to sweep.
|
|
23660
|
-
|
|
23711
|
+
join47(agentDir, ".claude", "skills")
|
|
23661
23712
|
];
|
|
23662
23713
|
const existingDirs = candidateSkillDirs.filter((d) => existsSync20(d));
|
|
23663
23714
|
const discoveredEntries = /* @__PURE__ */ new Set();
|
|
@@ -23700,7 +23751,7 @@ async function processAgent(agent, agentStates, managedToolkits) {
|
|
|
23700
23751
|
const sharedSkillsPayload = refreshAny.shared_skills;
|
|
23701
23752
|
const desiredResolved = globalSkillsPayload !== void 0 || sharedSkillsPayload !== void 0;
|
|
23702
23753
|
const manifestPath = managedSkillManifestPath(
|
|
23703
|
-
|
|
23754
|
+
join47(homedir17(), ".augmented", agent.code_name)
|
|
23704
23755
|
);
|
|
23705
23756
|
const prevIds = /* @__PURE__ */ new Set([
|
|
23706
23757
|
...agentState.knownGlobalSkillIds.get(agent.agent_id) ?? /* @__PURE__ */ new Set(),
|
|
@@ -23720,15 +23771,15 @@ async function processAgent(agent, agentStates, managedToolkits) {
|
|
|
23720
23771
|
}
|
|
23721
23772
|
if (plan.removes.length) {
|
|
23722
23773
|
const globalSkillDirs = [
|
|
23723
|
-
|
|
23724
|
-
|
|
23725
|
-
|
|
23774
|
+
join47(homedir17(), ".augmented", agent.code_name, "skills"),
|
|
23775
|
+
join47(homedir17(), ".augmented", agent.code_name, "project", ".claude", "skills"),
|
|
23776
|
+
join47(agentDir, ".claude", "skills")
|
|
23726
23777
|
];
|
|
23727
23778
|
for (const id of plan.removes) {
|
|
23728
23779
|
let prunedAny = false;
|
|
23729
23780
|
for (const dir of globalSkillDirs) {
|
|
23730
|
-
const p =
|
|
23731
|
-
if (existsSync20(p) && existsSync20(
|
|
23781
|
+
const p = join47(dir, id);
|
|
23782
|
+
if (existsSync20(p) && existsSync20(join47(p, "SKILL.md"))) {
|
|
23732
23783
|
rmSync9(p, { recursive: true, force: true });
|
|
23733
23784
|
prunedAny = true;
|
|
23734
23785
|
}
|
|
@@ -24514,7 +24565,7 @@ Retried to the limit after repeated stalls \u2014 needs a look.`).catch(() => {
|
|
|
24514
24565
|
if (trackedFiles.length > 0 && existsSync20(agentDir)) {
|
|
24515
24566
|
const hashes = /* @__PURE__ */ new Map();
|
|
24516
24567
|
for (const file of trackedFiles) {
|
|
24517
|
-
const h = hashFile(
|
|
24568
|
+
const h = hashFile(join47(agentDir, file));
|
|
24518
24569
|
if (h) hashes.set(file, h);
|
|
24519
24570
|
}
|
|
24520
24571
|
agentState.writtenHashes.set(agent.agent_id, hashes);
|
|
@@ -24529,7 +24580,7 @@ Retried to the limit after repeated stalls \u2014 needs a look.`).catch(() => {
|
|
|
24529
24580
|
refreshData.agent.onboarding_state
|
|
24530
24581
|
);
|
|
24531
24582
|
const obStep = obState.step;
|
|
24532
|
-
const markerPath =
|
|
24583
|
+
const markerPath = join47(homedir17(), ".augmented", agent.code_name, "onboarding-drive.json");
|
|
24533
24584
|
const marker = readOnboardingDriveMarker(markerPath);
|
|
24534
24585
|
const obContactRaw = refreshData.agent.manager_last_contacted_at;
|
|
24535
24586
|
const obContact = typeof obContactRaw === "string" && obContactRaw ? obContactRaw : null;
|
|
@@ -24662,7 +24713,7 @@ async function ensureOpencodeRuntime(agent, refreshData, agentTimezone) {
|
|
|
24662
24713
|
}
|
|
24663
24714
|
stopOpencodeSlackIngest(codeName, log);
|
|
24664
24715
|
stopOpencodeTelegramIngest(codeName, log);
|
|
24665
|
-
const opencodeProjectDir =
|
|
24716
|
+
const opencodeProjectDir = join47(getFramework("opencode").getAgentDir(codeName), "provision");
|
|
24666
24717
|
const serveEnv = {
|
|
24667
24718
|
AGT_HOST: requireHost(),
|
|
24668
24719
|
AGT_API_KEY: getApiKey() ?? void 0,
|
|
@@ -24733,8 +24784,8 @@ async function ensurePersistentSessionUnchecked(agent, tasks, boardItems, refres
|
|
|
24733
24784
|
});
|
|
24734
24785
|
}
|
|
24735
24786
|
const projectDir = getProjectDir(codeName);
|
|
24736
|
-
const mcpConfigPath =
|
|
24737
|
-
const claudeMdPath =
|
|
24787
|
+
const mcpConfigPath = join47(projectDir, ".mcp.json");
|
|
24788
|
+
const claudeMdPath = join47(projectDir, "CLAUDE.md");
|
|
24738
24789
|
if (restartBreaker.isTripped(codeName)) {
|
|
24739
24790
|
const trip = restartBreaker.getTrip(codeName);
|
|
24740
24791
|
return {
|
|
@@ -25675,12 +25726,16 @@ function ensureRealtimeStarted(agentStates) {
|
|
|
25675
25726
|
if (!agent) return;
|
|
25676
25727
|
if (directChatInFlight.has(msg.id)) return;
|
|
25677
25728
|
directChatInFlight.add(msg.id);
|
|
25678
|
-
|
|
25729
|
+
void dispatchDirectChatMessage({
|
|
25679
25730
|
id: msg.id,
|
|
25680
|
-
|
|
25681
|
-
|
|
25682
|
-
|
|
25683
|
-
|
|
25731
|
+
codeName: agent.codeName,
|
|
25732
|
+
process: () => processDirectChatMessage(agent, {
|
|
25733
|
+
id: msg.id,
|
|
25734
|
+
session_id: msg.session_id,
|
|
25735
|
+
content: msg.content
|
|
25736
|
+
}),
|
|
25737
|
+
inFlight: directChatInFlight,
|
|
25738
|
+
log
|
|
25684
25739
|
});
|
|
25685
25740
|
},
|
|
25686
25741
|
onError: (err) => {
|
|
@@ -25745,6 +25800,13 @@ async function managerRestartMayKill(agentId, codeName, requestedAt, lane, frame
|
|
|
25745
25800
|
pane.tmuxAlive === null ? null : sessionActivityFor(codeName, { tmuxAlive: pane.tmuxAlive, screenCapture: pane.screenCapture }, { fresh: true })
|
|
25746
25801
|
);
|
|
25747
25802
|
}
|
|
25803
|
+
if (verdict.kill && isolationMode(codeName) !== "docker") {
|
|
25804
|
+
const dc = readDirectChatInflight(join47(homedir17(), ".augmented", agentId));
|
|
25805
|
+
if (dc.inFlight) {
|
|
25806
|
+
verdict = { kill: false, reason: "direct_chat_in_flight", runningBackgroundTasks: null };
|
|
25807
|
+
log(`[${lane}] manager restart for '${codeName}': ${dc.ids.length} Direct Chat message(s) claimed and not yet answered [ENG-12100]`);
|
|
25808
|
+
}
|
|
25809
|
+
}
|
|
25748
25810
|
if (verdict.kill) {
|
|
25749
25811
|
log(`[${lane}] manager restart for '${codeName}': re-check passed (idle, nothing in the background) - restarting [ENG-11963]`);
|
|
25750
25812
|
return { kill: true, declined: false };
|
|
@@ -25813,7 +25875,7 @@ async function handleRestartDoorbell(agentId, requestedAt, restartReason) {
|
|
|
25813
25875
|
if (!refreshData) return;
|
|
25814
25876
|
const framework = refreshData.agent?.framework ?? agentFrameworkCache.get(codeName) ?? DEFAULT_FRAMEWORK;
|
|
25815
25877
|
const hostId = await getHostId();
|
|
25816
|
-
const parkForRestart = await import("../responsiveness-probe-
|
|
25878
|
+
const parkForRestart = await import("../responsiveness-probe-PX4FMO4H.js").then(
|
|
25817
25879
|
(m) => m.parkPendingInbound,
|
|
25818
25880
|
(err) => err
|
|
25819
25881
|
);
|
|
@@ -25890,7 +25952,7 @@ async function handleRestartDoorbell(agentId, requestedAt, restartReason) {
|
|
|
25890
25952
|
void api.post("/host/restart-ack", { host_id: hostId, agent_id: agentId, restart_requested_at: requestedAt }).catch((err) => log(`[restart-lane] ack failed for '${codeName}': ${err.message}`));
|
|
25891
25953
|
void (async () => {
|
|
25892
25954
|
try {
|
|
25893
|
-
const { collectDiagnostics } = await import("../persistent-session-
|
|
25955
|
+
const { collectDiagnostics } = await import("../persistent-session-SMMVQBRS.js");
|
|
25894
25956
|
await api.post("/host/heartbeat", {
|
|
25895
25957
|
host_id: hostId,
|
|
25896
25958
|
agent_diagnostics: collectDiagnostics([codeName], quarantineEntriesFor, claudeMdSizeFor, spawnOutcomeForDiagnostics, pidPressureFor, forwardedToolsFor, runtimeVersionFor, sessionActivityFor)
|
|
@@ -25943,7 +26005,7 @@ async function respawnAgentAfterMcpStop(codeName, reason) {
|
|
|
25943
26005
|
}
|
|
25944
26006
|
try {
|
|
25945
26007
|
const hostId = await getHostId();
|
|
25946
|
-
const { collectDiagnostics } = await import("../persistent-session-
|
|
26008
|
+
const { collectDiagnostics } = await import("../persistent-session-SMMVQBRS.js");
|
|
25947
26009
|
await api.post("/host/heartbeat", {
|
|
25948
26010
|
host_id: hostId,
|
|
25949
26011
|
agent_diagnostics: collectDiagnostics([codeName], quarantineEntriesFor, claudeMdSizeFor, spawnOutcomeForDiagnostics, pidPressureFor, forwardedToolsFor, runtimeVersionFor, sessionActivityFor)
|
|
@@ -26198,6 +26260,27 @@ function triggerEarlyPoll(reason, agentId) {
|
|
|
26198
26260
|
}, 0);
|
|
26199
26261
|
}
|
|
26200
26262
|
var directChatInFlight = /* @__PURE__ */ new Set();
|
|
26263
|
+
function describeRejection(err) {
|
|
26264
|
+
try {
|
|
26265
|
+
if (err instanceof Error) return typeof err.message === "string" ? err.message : "Error with no message";
|
|
26266
|
+
if (typeof err === "string") return err;
|
|
26267
|
+
return `non-Error rejection (${err === null ? "null" : typeof err})`;
|
|
26268
|
+
} catch {
|
|
26269
|
+
return "unreadable rejection";
|
|
26270
|
+
}
|
|
26271
|
+
}
|
|
26272
|
+
async function dispatchDirectChatMessage(args) {
|
|
26273
|
+
try {
|
|
26274
|
+
await args.process();
|
|
26275
|
+
} catch (err) {
|
|
26276
|
+
const message = describeRejection(err);
|
|
26277
|
+
args.log(
|
|
26278
|
+
`[direct-chat] ENG-12155: processing failed for '${args.codeName}' (msg=${args.id}): ${message} - left for retry (the row is reclaimed by the poll after the processing reaper requeues it)`
|
|
26279
|
+
);
|
|
26280
|
+
} finally {
|
|
26281
|
+
args.inFlight.delete(args.id);
|
|
26282
|
+
}
|
|
26283
|
+
}
|
|
26201
26284
|
async function pollDirectChatMessages(agentStates) {
|
|
26202
26285
|
for (const agent of agentStates) {
|
|
26203
26286
|
if (agent.status !== "active") continue;
|
|
@@ -26206,8 +26289,12 @@ async function pollDirectChatMessages(agentStates) {
|
|
|
26206
26289
|
for (const msg of data.messages) {
|
|
26207
26290
|
if (directChatInFlight.has(msg.id)) continue;
|
|
26208
26291
|
directChatInFlight.add(msg.id);
|
|
26209
|
-
|
|
26210
|
-
|
|
26292
|
+
void dispatchDirectChatMessage({
|
|
26293
|
+
id: msg.id,
|
|
26294
|
+
codeName: agent.codeName,
|
|
26295
|
+
process: () => processDirectChatMessage(agent, msg),
|
|
26296
|
+
inFlight: directChatInFlight,
|
|
26297
|
+
log
|
|
26211
26298
|
});
|
|
26212
26299
|
}
|
|
26213
26300
|
} catch (err) {
|
|
@@ -26356,7 +26443,7 @@ async function processDirectChatMessage(agent, msg) {
|
|
|
26356
26443
|
try {
|
|
26357
26444
|
const doorbell = directChatDoorbellPath(agent.agentId, homedir17());
|
|
26358
26445
|
mkdirSync18(dirname11(doorbell), { recursive: true });
|
|
26359
|
-
|
|
26446
|
+
writeFileSync20(doorbell, String(Date.now()));
|
|
26360
26447
|
log(`[direct-chat] Doorbell rung for '${agent.codeName}' (msg=${msg.id}) \u2014 in-session MCP will pull via the cursor`);
|
|
26361
26448
|
return;
|
|
26362
26449
|
} catch (err) {
|
|
@@ -26485,7 +26572,7 @@ ${formatRunMarker(run_id)}` : KANBAN_CHECK_COMMAND;
|
|
|
26485
26572
|
try {
|
|
26486
26573
|
const doorbell = directChatDoorbellPath(agentId, homedir17());
|
|
26487
26574
|
mkdirSync18(dirname11(doorbell), { recursive: true });
|
|
26488
|
-
|
|
26575
|
+
writeFileSync20(doorbell, String(Date.now()));
|
|
26489
26576
|
} catch (err) {
|
|
26490
26577
|
log(`[kanban] doorbell ring failed for '${codeName}': ${err.message} (notice still queued)`);
|
|
26491
26578
|
}
|
|
@@ -26645,7 +26732,7 @@ async function processClaudePairSessions(agents) {
|
|
|
26645
26732
|
snapshotPairConfig,
|
|
26646
26733
|
// ENG-11659: result -> report body + the manager.log line that records it.
|
|
26647
26734
|
planPairStartReport
|
|
26648
|
-
} = await import("../claude-pair-runtime-
|
|
26735
|
+
} = await import("../claude-pair-runtime-NOVMDM62.js");
|
|
26649
26736
|
const { resetClaudeSignin, describeSigninResetForLog, describeSigninResetFailure } = await import("../claude-signin-reset-6IJMMVYG.js");
|
|
26650
26737
|
for (const pairId of pendingResp.cancelled_pair_ids ?? []) {
|
|
26651
26738
|
log(`[claude-pair] sweeping orphan tmux session for pair ${pairId.slice(0, 8)}`);
|
|
@@ -26944,17 +27031,17 @@ var lastLocalFileHash = /* @__PURE__ */ new Map();
|
|
|
26944
27031
|
var lastMemoriesBody = /* @__PURE__ */ new Map();
|
|
26945
27032
|
var memoryManifests = /* @__PURE__ */ new Map();
|
|
26946
27033
|
function memoryRetirementDir(configDir, codeName) {
|
|
26947
|
-
return
|
|
27034
|
+
return join47(configDir, "_memory-retirement", codeName);
|
|
26948
27035
|
}
|
|
26949
27036
|
function memoryManifestPath(configDir, codeName) {
|
|
26950
|
-
return
|
|
27037
|
+
return join47(memoryRetirementDir(configDir, codeName), "manifest.json");
|
|
26951
27038
|
}
|
|
26952
27039
|
function loadMemoryManifest(agentId, configDir, codeName) {
|
|
26953
27040
|
const cached = memoryManifests.get(agentId);
|
|
26954
27041
|
if (cached) return cached;
|
|
26955
27042
|
let manifest = {};
|
|
26956
27043
|
try {
|
|
26957
|
-
const raw =
|
|
27044
|
+
const raw = readFileSync38(memoryManifestPath(configDir, codeName), "utf-8");
|
|
26958
27045
|
const parsed = JSON.parse(raw);
|
|
26959
27046
|
if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) {
|
|
26960
27047
|
for (const [name, entry] of Object.entries(parsed)) {
|
|
@@ -26976,13 +27063,13 @@ function saveMemoryManifest(agentId, configDir, codeName) {
|
|
|
26976
27063
|
const path = memoryManifestPath(configDir, codeName);
|
|
26977
27064
|
mkdirSync18(memoryRetirementDir(configDir, codeName), { recursive: true });
|
|
26978
27065
|
const tmp = `${path}.tmp`;
|
|
26979
|
-
|
|
26980
|
-
|
|
27066
|
+
writeFileSync20(tmp, JSON.stringify(manifest, null, 2));
|
|
27067
|
+
renameSync12(tmp, path);
|
|
26981
27068
|
} catch {
|
|
26982
27069
|
}
|
|
26983
27070
|
}
|
|
26984
27071
|
function retiredMemoryDir(configDir, codeName) {
|
|
26985
|
-
return
|
|
27072
|
+
return join47(memoryRetirementDir(configDir, codeName), "retired");
|
|
26986
27073
|
}
|
|
26987
27074
|
var RETIRED_MEMORY_TTL_MS = 30 * 24 * 60 * 60 * 1e3;
|
|
26988
27075
|
var lastRetirementReport = /* @__PURE__ */ new Map();
|
|
@@ -27061,7 +27148,7 @@ function applyMemoryTombstones(opts) {
|
|
|
27061
27148
|
log2(`[memory-retire] ${agent.code_name}: KEPT '${tomb.name}' \u2014 no write record, not ours to remove`);
|
|
27062
27149
|
continue;
|
|
27063
27150
|
}
|
|
27064
|
-
const filePath =
|
|
27151
|
+
const filePath = join47(memoryDir, entry.file);
|
|
27065
27152
|
if (!existsSync20(filePath)) {
|
|
27066
27153
|
outcomes.already_gone++;
|
|
27067
27154
|
delete manifest[tomb.name];
|
|
@@ -27069,7 +27156,7 @@ function applyMemoryTombstones(opts) {
|
|
|
27069
27156
|
continue;
|
|
27070
27157
|
}
|
|
27071
27158
|
try {
|
|
27072
|
-
const actual = createHash21("sha256").update(
|
|
27159
|
+
const actual = createHash21("sha256").update(readFileSync38(filePath)).digest("hex");
|
|
27073
27160
|
if (actual !== entry.sha) {
|
|
27074
27161
|
outcomes.kept_modified++;
|
|
27075
27162
|
outcomes.unapplied.push({ name: tomb.name, reason: "kept_modified" });
|
|
@@ -27081,11 +27168,11 @@ function applyMemoryTombstones(opts) {
|
|
|
27081
27168
|
const destDir = retiredMemoryDir(configDir, agent.code_name);
|
|
27082
27169
|
mkdirSync18(destDir, { recursive: true });
|
|
27083
27170
|
const stamp = Date.now();
|
|
27084
|
-
let dest =
|
|
27171
|
+
let dest = join47(destDir, `${entry.file}.${stamp}.retired`);
|
|
27085
27172
|
for (let n = 1; existsSync20(dest); n++) {
|
|
27086
|
-
dest =
|
|
27173
|
+
dest = join47(destDir, `${entry.file}.${stamp}-${n}.retired`);
|
|
27087
27174
|
}
|
|
27088
|
-
|
|
27175
|
+
renameSync12(filePath, dest);
|
|
27089
27176
|
try {
|
|
27090
27177
|
const now = Date.now() / 1e3;
|
|
27091
27178
|
utimesSync4(dest, now, now);
|
|
@@ -27122,7 +27209,7 @@ function reapRetiredMemories(configDir, codeName, log2) {
|
|
|
27122
27209
|
try {
|
|
27123
27210
|
for (const file of readdirSync14(dir)) {
|
|
27124
27211
|
if (!file.endsWith(".retired")) continue;
|
|
27125
|
-
const path =
|
|
27212
|
+
const path = join47(dir, file);
|
|
27126
27213
|
try {
|
|
27127
27214
|
if (statSync15(path).mtimeMs < cutoff) {
|
|
27128
27215
|
unlinkSync6(path);
|
|
@@ -27137,8 +27224,8 @@ function reapRetiredMemories(configDir, codeName, log2) {
|
|
|
27137
27224
|
if (reaped > 0) log2(`[memory-retire] ${codeName}: reaped ${reaped} retired memory file(s) past TTL`);
|
|
27138
27225
|
}
|
|
27139
27226
|
async function syncMemories(agent, configDir, log2) {
|
|
27140
|
-
const projectDir =
|
|
27141
|
-
const memoryDir =
|
|
27227
|
+
const projectDir = join47(configDir, agent.code_name, "project");
|
|
27228
|
+
const memoryDir = join47(projectDir, "memory");
|
|
27142
27229
|
const isFreshSync = pendingFreshMemorySync.has(agent.agent_id);
|
|
27143
27230
|
if (isFreshSync) {
|
|
27144
27231
|
log2(`[memory-sync] Fresh-sync requested for '${agent.code_name}' \u2014 pulling DB first`);
|
|
@@ -27169,7 +27256,7 @@ async function syncMemories(agent, configDir, log2) {
|
|
|
27169
27256
|
for (const file of readdirSync14(memoryDir)) {
|
|
27170
27257
|
if (!file.endsWith(".md")) continue;
|
|
27171
27258
|
try {
|
|
27172
|
-
const raw =
|
|
27259
|
+
const raw = readFileSync38(join47(memoryDir, file), "utf-8");
|
|
27173
27260
|
const fileHash = createHash21("sha256").update(raw).digest("hex").slice(0, 16);
|
|
27174
27261
|
currentHashes.set(file, fileHash);
|
|
27175
27262
|
if (prevHashes.get(file) === fileHash) continue;
|
|
@@ -27194,7 +27281,7 @@ async function syncMemories(agent, configDir, log2) {
|
|
|
27194
27281
|
} catch (err) {
|
|
27195
27282
|
for (const mem of changedMemories) {
|
|
27196
27283
|
for (const [file] of currentHashes) {
|
|
27197
|
-
const parsed = parseMemoryFile(
|
|
27284
|
+
const parsed = parseMemoryFile(readFileSync38(join47(memoryDir, file), "utf-8"), file.replace(/\.md$/, ""));
|
|
27198
27285
|
if (parsed?.name === mem.name) currentHashes.delete(file);
|
|
27199
27286
|
}
|
|
27200
27287
|
}
|
|
@@ -27275,7 +27362,7 @@ async function downloadMemories(agent, memoryDir, log2, { force, configDir }) {
|
|
|
27275
27362
|
// Per-agent, not host-wide: memories are agent-private, so a shared
|
|
27276
27363
|
// store would buy almost no dedupe while exposing one agent's content
|
|
27277
27364
|
// to every other agent on the host. See memory-cache.ts's header.
|
|
27278
|
-
cacheDir:
|
|
27365
|
+
cacheDir: join47(configDir, agent.code_name, "_memory_bodies"),
|
|
27279
27366
|
fetchContents: async (hashes) => {
|
|
27280
27367
|
const res = await api.post(
|
|
27281
27368
|
"/host/memories/contents",
|
|
@@ -27313,7 +27400,7 @@ async function downloadMemories(agent, memoryDir, log2, { force, configDir }) {
|
|
|
27313
27400
|
const rawSlug = mem.name.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/(^-|-$)/g, "").slice(0, 60);
|
|
27314
27401
|
const slug = rawSlug || `memory-${i}`;
|
|
27315
27402
|
const fileName = `${slug}.md`;
|
|
27316
|
-
const filePath =
|
|
27403
|
+
const filePath = join47(memoryDir, fileName);
|
|
27317
27404
|
const desired = `---
|
|
27318
27405
|
name: ${JSON.stringify(mem.name)}
|
|
27319
27406
|
type: ${mem.type}
|
|
@@ -27333,7 +27420,7 @@ ${mem.content}
|
|
|
27333
27420
|
if (existsSync20(filePath)) {
|
|
27334
27421
|
let existing = "";
|
|
27335
27422
|
try {
|
|
27336
|
-
existing =
|
|
27423
|
+
existing = readFileSync38(filePath, "utf-8");
|
|
27337
27424
|
} catch {
|
|
27338
27425
|
}
|
|
27339
27426
|
if (existing === desired) {
|
|
@@ -27341,10 +27428,10 @@ ${mem.content}
|
|
|
27341
27428
|
if (manifestDirty) saveMemoryManifest(agent.agent_id, configDir, agent.code_name);
|
|
27342
27429
|
continue;
|
|
27343
27430
|
}
|
|
27344
|
-
|
|
27431
|
+
writeFileSync20(filePath, desired);
|
|
27345
27432
|
overwritten++;
|
|
27346
27433
|
} else {
|
|
27347
|
-
|
|
27434
|
+
writeFileSync20(filePath, desired);
|
|
27348
27435
|
written++;
|
|
27349
27436
|
}
|
|
27350
27437
|
if (record()) manifestDirty = true;
|
|
@@ -27734,7 +27821,7 @@ function startManager(opts) {
|
|
|
27734
27821
|
try {
|
|
27735
27822
|
const stateFile = getStateFile();
|
|
27736
27823
|
if (existsSync20(stateFile)) {
|
|
27737
|
-
const raw =
|
|
27824
|
+
const raw = readFileSync38(stateFile, "utf-8");
|
|
27738
27825
|
const parsed = JSON.parse(raw);
|
|
27739
27826
|
if (Array.isArray(parsed.agents)) {
|
|
27740
27827
|
state9.agents = parsed.agents;
|
|
@@ -27768,7 +27855,7 @@ function startManager(opts) {
|
|
|
27768
27855
|
log(`[startup] state rehydration failed (continuing with empty state): ${err.message}`);
|
|
27769
27856
|
}
|
|
27770
27857
|
log(
|
|
27771
|
-
`[startup] worker pid=${process.pid} ppid=${process.ppid} node=${process.version} log=${
|
|
27858
|
+
`[startup] worker pid=${process.pid} ppid=${process.ppid} node=${process.version} log=${join47(homedir17(), ".augmented", "manager.log")}`
|
|
27772
27859
|
);
|
|
27773
27860
|
deployMcpAssets();
|
|
27774
27861
|
reapOrphanChannelMcps({ log });
|
|
@@ -27797,7 +27884,7 @@ async function reapOrphanedClaudePids() {
|
|
|
27797
27884
|
const looksLikeClaude = (pid) => {
|
|
27798
27885
|
if (process.platform !== "linux") return true;
|
|
27799
27886
|
try {
|
|
27800
|
-
const comm =
|
|
27887
|
+
const comm = readFileSync38(`/proc/${pid}/comm`, "utf-8").trim().toLowerCase();
|
|
27801
27888
|
return comm.includes("claude");
|
|
27802
27889
|
} catch {
|
|
27803
27890
|
return false;
|
|
@@ -27894,14 +27981,14 @@ function restartRunningChannelMcps(basenames) {
|
|
|
27894
27981
|
}
|
|
27895
27982
|
}
|
|
27896
27983
|
function deployMcpAssets() {
|
|
27897
|
-
const targetDir =
|
|
27984
|
+
const targetDir = join47(homedir17(), ".augmented", "_mcp");
|
|
27898
27985
|
mkdirSync18(targetDir, { recursive: true });
|
|
27899
27986
|
const moduleDir = dirname11(fileURLToPath2(import.meta.url));
|
|
27900
27987
|
let mcpSourceDir = "";
|
|
27901
27988
|
let dir = moduleDir;
|
|
27902
27989
|
for (let i = 0; i < 6; i++) {
|
|
27903
|
-
const candidate =
|
|
27904
|
-
if (existsSync20(
|
|
27990
|
+
const candidate = join47(dir, "dist", "mcp");
|
|
27991
|
+
if (existsSync20(join47(candidate, "index.js"))) {
|
|
27905
27992
|
mcpSourceDir = candidate;
|
|
27906
27993
|
break;
|
|
27907
27994
|
}
|
|
@@ -27919,7 +28006,7 @@ function deployMcpAssets() {
|
|
|
27919
28006
|
const fileHash = (p) => {
|
|
27920
28007
|
try {
|
|
27921
28008
|
if (!existsSync20(p)) return null;
|
|
27922
|
-
return createHash21("sha256").update(
|
|
28009
|
+
return createHash21("sha256").update(readFileSync38(p)).digest("hex");
|
|
27923
28010
|
} catch {
|
|
27924
28011
|
return null;
|
|
27925
28012
|
}
|
|
@@ -28001,8 +28088,8 @@ function deployMcpAssets() {
|
|
|
28001
28088
|
// natural session restart.
|
|
28002
28089
|
"computer-use-proxy.js"
|
|
28003
28090
|
]) {
|
|
28004
|
-
const src =
|
|
28005
|
-
const dst =
|
|
28091
|
+
const src = join47(mcpSourceDir, file);
|
|
28092
|
+
const dst = join47(targetDir, file);
|
|
28006
28093
|
if (!existsSync20(src)) continue;
|
|
28007
28094
|
attemptedFiles.push(file);
|
|
28008
28095
|
const before = fileHash(dst);
|
|
@@ -28028,23 +28115,23 @@ function deployMcpAssets() {
|
|
|
28028
28115
|
log(`[manager] Bundle(s) updated: ${changedBasenames.join(", ")} \u2014 signalling running instances to restart`);
|
|
28029
28116
|
restartRunningChannelMcps(changedBasenames);
|
|
28030
28117
|
}
|
|
28031
|
-
const localMcpPath =
|
|
28118
|
+
const localMcpPath = join47(targetDir, "index.js");
|
|
28032
28119
|
try {
|
|
28033
|
-
const agentsDir =
|
|
28120
|
+
const agentsDir = join47(homedir17(), ".augmented", "agents");
|
|
28034
28121
|
if (existsSync20(agentsDir)) {
|
|
28035
28122
|
for (const entry of readdirSync14(agentsDir, { withFileTypes: true })) {
|
|
28036
28123
|
if (!entry.isDirectory()) continue;
|
|
28037
28124
|
for (const subdir of ["provision", "project"]) {
|
|
28038
|
-
const mcpJsonPath =
|
|
28125
|
+
const mcpJsonPath = join47(agentsDir, entry.name, subdir, ".mcp.json");
|
|
28039
28126
|
try {
|
|
28040
|
-
const raw =
|
|
28127
|
+
const raw = readFileSync38(mcpJsonPath, "utf-8");
|
|
28041
28128
|
if (!raw.includes("@integrity-labs/augmented-mcp")) continue;
|
|
28042
28129
|
const mcpConfig = JSON.parse(raw);
|
|
28043
28130
|
const augServer = mcpConfig.mcpServers?.["augmented"];
|
|
28044
28131
|
if (!augServer) continue;
|
|
28045
28132
|
augServer.command = "node";
|
|
28046
28133
|
augServer.args = [localMcpPath];
|
|
28047
|
-
|
|
28134
|
+
writeFileSync20(mcpJsonPath, JSON.stringify(mcpConfig, null, 2));
|
|
28048
28135
|
log(`[manager] Patched ${entry.name}/${subdir}/.mcp.json: npx \u2192 node`);
|
|
28049
28136
|
} catch {
|
|
28050
28137
|
}
|
|
@@ -28116,6 +28203,8 @@ export {
|
|
|
28116
28203
|
crossSessionBlockReport,
|
|
28117
28204
|
dashboardRestartBreakerReason,
|
|
28118
28205
|
decideDayRolloverAction,
|
|
28206
|
+
describeRejection,
|
|
28207
|
+
dispatchDirectChatMessage,
|
|
28119
28208
|
ensureClaudeManagedSettings,
|
|
28120
28209
|
extractCharterSlackPeers,
|
|
28121
28210
|
extractCharterTelegramPeers,
|