@integrity-labs/agt-cli 0.28.1318 → 0.28.1319
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-2MEHL5RP.js → api-client-RRGOSC4A.js} +3 -3
- package/dist/bin/agt.js +7 -7
- package/dist/{chunk-KJNJNMRY.js → chunk-4D2JQ2HP.js} +5 -5
- package/dist/{chunk-4ATDVGN4.js → chunk-BMHXW6TG.js} +2 -2
- package/dist/{chunk-U6WANH5Z.js → chunk-HGLJ2T4J.js} +2 -1
- package/dist/{chunk-U6WANH5Z.js.map → chunk-HGLJ2T4J.js.map} +1 -1
- package/dist/{chunk-K4HGH6N2.js → chunk-PKE4GUZQ.js} +2 -2
- package/dist/{chunk-2FY3WW6O.js → chunk-R7ZAJKMK.js} +3 -3
- package/dist/{chunk-AABYEBCU.js → chunk-RR3LB5VH.js} +9 -5
- package/dist/chunk-RR3LB5VH.js.map +1 -0
- package/dist/{claude-code-updater-BIBCDTQX.js → claude-code-updater-E5QX33MA.js} +3 -3
- package/dist/{claude-pair-runtime-OR72T4SI.js → claude-pair-runtime-DGLYU2HX.js} +3 -3
- package/dist/lib/manager-worker.js +420 -215
- package/dist/lib/manager-worker.js.map +1 -1
- package/dist/mcp/direct-chat-channel.js +1 -0
- package/dist/mcp/index.js +1 -0
- package/dist/mcp/origami.js +1 -0
- package/dist/mcp/slack-channel.js +1 -0
- package/dist/mcp/telegram-channel.js +1 -0
- package/dist/{persistent-session-PZI32TLO.js → persistent-session-4AGRIK5W.js} +4 -4
- package/dist/{responsiveness-probe-MJOASK7A.js → responsiveness-probe-SDVMWEM3.js} +4 -4
- package/dist/{session-auth-dead-KYFRPM4G.js → session-auth-dead-EIVQKX5X.js} +3 -3
- package/package.json +1 -1
- package/dist/chunk-AABYEBCU.js.map +0 -1
- /package/dist/{api-client-2MEHL5RP.js.map → api-client-RRGOSC4A.js.map} +0 -0
- /package/dist/{chunk-KJNJNMRY.js.map → chunk-4D2JQ2HP.js.map} +0 -0
- /package/dist/{chunk-4ATDVGN4.js.map → chunk-BMHXW6TG.js.map} +0 -0
- /package/dist/{chunk-K4HGH6N2.js.map → chunk-PKE4GUZQ.js.map} +0 -0
- /package/dist/{chunk-2FY3WW6O.js.map → chunk-R7ZAJKMK.js.map} +0 -0
- /package/dist/{claude-code-updater-BIBCDTQX.js.map → claude-code-updater-E5QX33MA.js.map} +0 -0
- /package/dist/{claude-pair-runtime-OR72T4SI.js.map → claude-pair-runtime-DGLYU2HX.js.map} +0 -0
- /package/dist/{persistent-session-PZI32TLO.js.map → persistent-session-4AGRIK5W.js.map} +0 -0
- /package/dist/{responsiveness-probe-MJOASK7A.js.map → responsiveness-probe-SDVMWEM3.js.map} +0 -0
- /package/dist/{session-auth-dead-KYFRPM4G.js.map → session-auth-dead-EIVQKX5X.js.map} +0 -0
|
@@ -70,7 +70,7 @@ import {
|
|
|
70
70
|
tripClass,
|
|
71
71
|
writeEtcEnvironment,
|
|
72
72
|
writeProfileDScript
|
|
73
|
-
} from "../chunk-
|
|
73
|
+
} from "../chunk-4D2JQ2HP.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-R7ZAJKMK.js";
|
|
92
92
|
import {
|
|
93
93
|
BLOCKED_ON_PROMPT_DECISION,
|
|
94
94
|
CHANNEL_SECRET_ENV_KEYS,
|
|
@@ -185,7 +185,7 @@ import {
|
|
|
185
185
|
webFetchBaselineValue,
|
|
186
186
|
webFetchRestartNeeded,
|
|
187
187
|
writeEgressAllowlist
|
|
188
|
-
} from "../chunk-
|
|
188
|
+
} from "../chunk-RR3LB5VH.js";
|
|
189
189
|
import {
|
|
190
190
|
isAgentIdle,
|
|
191
191
|
isStaleForToday,
|
|
@@ -197,7 +197,7 @@ import {
|
|
|
197
197
|
subagentActivityAgeSeconds,
|
|
198
198
|
subagentTranscriptDir,
|
|
199
199
|
transcriptActivityAgeSeconds
|
|
200
|
-
} from "../chunk-
|
|
200
|
+
} from "../chunk-BMHXW6TG.js";
|
|
201
201
|
import {
|
|
202
202
|
classifyUnanswerablePane,
|
|
203
203
|
focusedConfirmDialogBlock,
|
|
@@ -223,7 +223,7 @@ import {
|
|
|
223
223
|
runSafeCleanup,
|
|
224
224
|
tightestDiskStat,
|
|
225
225
|
withPackageCacheLock
|
|
226
|
-
} from "../chunk-
|
|
226
|
+
} from "../chunk-PKE4GUZQ.js";
|
|
227
227
|
import {
|
|
228
228
|
parsePsRows,
|
|
229
229
|
reapOrphanChannelMcps
|
|
@@ -352,7 +352,7 @@ import {
|
|
|
352
352
|
stabiliseResetInstant,
|
|
353
353
|
sumTranscriptUsageInWindow,
|
|
354
354
|
summarizeTranscriptActivity
|
|
355
|
-
} from "../chunk-
|
|
355
|
+
} from "../chunk-HGLJ2T4J.js";
|
|
356
356
|
import {
|
|
357
357
|
CLAUDE_CONFIG_DIR_ENV,
|
|
358
358
|
claudeConfigDirFor,
|
|
@@ -1704,8 +1704,8 @@ function clearEpisode(codeName) {
|
|
|
1704
1704
|
}
|
|
1705
1705
|
|
|
1706
1706
|
// src/lib/manager-worker.ts
|
|
1707
|
-
import { join as
|
|
1708
|
-
import { homedir as
|
|
1707
|
+
import { join as join49, dirname as dirname11, delimiter as pathDelimiter } from "path";
|
|
1708
|
+
import { homedir as homedir18, hostname as hostname2, platform as platform3 } from "os";
|
|
1709
1709
|
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
1710
1710
|
|
|
1711
1711
|
// ../../packages/core/dist/provisioning/channel-policy-env.js
|
|
@@ -1818,13 +1818,13 @@ async function installToolkitClis(opts) {
|
|
|
1818
1818
|
}
|
|
1819
1819
|
return { awaited, background };
|
|
1820
1820
|
}
|
|
1821
|
-
function singleFlight(
|
|
1822
|
-
const existing =
|
|
1821
|
+
function singleFlight(inFlight2, key, fn) {
|
|
1822
|
+
const existing = inFlight2.get(key);
|
|
1823
1823
|
if (existing) return existing;
|
|
1824
1824
|
const run = Promise.resolve().then(fn).finally(() => {
|
|
1825
|
-
if (
|
|
1825
|
+
if (inFlight2.get(key) === run) inFlight2.delete(key);
|
|
1826
1826
|
});
|
|
1827
|
-
|
|
1827
|
+
inFlight2.set(key, run);
|
|
1828
1828
|
return run;
|
|
1829
1829
|
}
|
|
1830
1830
|
|
|
@@ -2508,7 +2508,7 @@ function commandReadings(lines) {
|
|
|
2508
2508
|
return [lines.join(""), lines.join(" "), lines.join("\n")];
|
|
2509
2509
|
}
|
|
2510
2510
|
function decideDangerousRm(prompt, policy, opts = {}) {
|
|
2511
|
-
const
|
|
2511
|
+
const lstat2 = opts.lstat ?? lstatSync;
|
|
2512
2512
|
const command = prompt.commandLines ? commandReadings(prompt.commandLines)[0] : null;
|
|
2513
2513
|
const no = (rule, alert, target2 = null) => ({
|
|
2514
2514
|
answer: "no",
|
|
@@ -2533,7 +2533,7 @@ function decideDangerousRm(prompt, policy, opts = {}) {
|
|
|
2533
2533
|
}
|
|
2534
2534
|
if (opts.isolated) return no("isolated-agent", false, target);
|
|
2535
2535
|
try {
|
|
2536
|
-
if (!
|
|
2536
|
+
if (!lstat2(target).isFile()) return no("not-regular-file", true, target);
|
|
2537
2537
|
} catch {
|
|
2538
2538
|
return no("not-regular-file", true, target);
|
|
2539
2539
|
}
|
|
@@ -2543,17 +2543,17 @@ var OPTION_ROW = /^\s*(❯\s*)?(\d)\.\s+(.*?)\s*$/;
|
|
|
2543
2543
|
function promptAnswerKeys(pane, answer) {
|
|
2544
2544
|
const block = focusedConfirmDialogBlock(pane);
|
|
2545
2545
|
if (!block) return answer === "no" ? ["Escape"] : null;
|
|
2546
|
-
let
|
|
2546
|
+
let cursor2 = -1;
|
|
2547
2547
|
let target = -1;
|
|
2548
2548
|
for (let i = 0; i < block.length; i++) {
|
|
2549
2549
|
const m = OPTION_ROW.exec(block[i]);
|
|
2550
2550
|
if (!m) continue;
|
|
2551
|
-
if (m[1])
|
|
2551
|
+
if (m[1]) cursor2 = i;
|
|
2552
2552
|
const label = m[3];
|
|
2553
2553
|
if (target < 0 && (answer === "yes" ? label === "Yes" : /^No\b/.test(label))) target = i;
|
|
2554
2554
|
}
|
|
2555
|
-
if (
|
|
2556
|
-
const d = target -
|
|
2555
|
+
if (cursor2 < 0 || target < 0) return answer === "no" ? ["Escape"] : null;
|
|
2556
|
+
const d = target - cursor2;
|
|
2557
2557
|
return [...Array(Math.abs(d)).fill(d > 0 ? "Down" : "Up"), "Enter"];
|
|
2558
2558
|
}
|
|
2559
2559
|
var DangerousRmBackstop = class {
|
|
@@ -2827,7 +2827,7 @@ var ONBOARDING_REINJECT_INTERVAL_MS = 45 * 6e4;
|
|
|
2827
2827
|
var ONBOARDING_MAX_NUDGES = 3;
|
|
2828
2828
|
var ONBOARDING_MIN_STANDDOWN_AGE_MS = 60 * 6e4;
|
|
2829
2829
|
var ONBOARDING_MAX_INJECTS = 8;
|
|
2830
|
-
function decideOnboardingDrive(step, marker, nowMs,
|
|
2830
|
+
function decideOnboardingDrive(step, marker, nowMs, generation2 = 0, opts = {}) {
|
|
2831
2831
|
const {
|
|
2832
2832
|
managerContactedAt = null,
|
|
2833
2833
|
reinjectIntervalMs = ONBOARDING_REINJECT_INTERVAL_MS,
|
|
@@ -2838,7 +2838,7 @@ function decideOnboardingDrive(step, marker, nowMs, generation = 0, opts = {}) {
|
|
|
2838
2838
|
if (isOnboardingArea(step)) {
|
|
2839
2839
|
const sameStep = marker?.step === step;
|
|
2840
2840
|
const current = sameStep ? marker : null;
|
|
2841
|
-
const genChanged = current !== null && current.generation !==
|
|
2841
|
+
const genChanged = current !== null && current.generation !== generation2;
|
|
2842
2842
|
if (genChanged) {
|
|
2843
2843
|
return {
|
|
2844
2844
|
inject: true,
|
|
@@ -2856,7 +2856,7 @@ function decideOnboardingDrive(step, marker, nowMs, generation = 0, opts = {}) {
|
|
|
2856
2856
|
// does not reset it).
|
|
2857
2857
|
lastContactSeen: managerContactedAt ?? current.lastContactSeen ?? null,
|
|
2858
2858
|
gaveUp: false,
|
|
2859
|
-
generation
|
|
2859
|
+
generation: generation2
|
|
2860
2860
|
},
|
|
2861
2861
|
reminder: false,
|
|
2862
2862
|
standDown: false,
|
|
@@ -2895,7 +2895,7 @@ function decideOnboardingDrive(step, marker, nowMs, generation = 0, opts = {}) {
|
|
|
2895
2895
|
// /onboard generation being counted again here.
|
|
2896
2896
|
lastContactSeen: managerContactedAt ?? current?.lastContactSeen ?? null,
|
|
2897
2897
|
gaveUp: isFinal,
|
|
2898
|
-
generation
|
|
2898
|
+
generation: generation2
|
|
2899
2899
|
},
|
|
2900
2900
|
// A middle re-fire (not fresh, not final) is a gentle "still waiting"
|
|
2901
2901
|
// reminder; the final one is a stand-down, not a reminder.
|
|
@@ -2956,7 +2956,7 @@ function readOnboardingDriveMarker(path) {
|
|
|
2956
2956
|
const nudgeCount = hasNewCounters ? typeof raw.nudgeCount === "number" && Number.isFinite(raw.nudgeCount) && raw.nudgeCount >= 0 ? Math.floor(raw.nudgeCount) : 1 : 0;
|
|
2957
2957
|
const lastContactSeen = typeof raw.lastContactSeen === "string" ? raw.lastContactSeen : null;
|
|
2958
2958
|
const firstNudgeAtMs = typeof raw.firstNudgeAtMs === "number" && Number.isFinite(raw.firstNudgeAtMs) ? raw.firstNudgeAtMs : raw.injectedAtMs;
|
|
2959
|
-
const
|
|
2959
|
+
const generation2 = typeof raw.generation === "number" && Number.isFinite(raw.generation) && raw.generation >= 0 ? Math.floor(raw.generation) : 0;
|
|
2960
2960
|
return {
|
|
2961
2961
|
step: raw.step,
|
|
2962
2962
|
injectedAtMs: raw.injectedAtMs,
|
|
@@ -2964,7 +2964,7 @@ function readOnboardingDriveMarker(path) {
|
|
|
2964
2964
|
injectCount,
|
|
2965
2965
|
firstNudgeAtMs,
|
|
2966
2966
|
lastContactSeen,
|
|
2967
|
-
generation,
|
|
2967
|
+
generation: generation2,
|
|
2968
2968
|
gaveUp: raw.gaveUp === true
|
|
2969
2969
|
};
|
|
2970
2970
|
}
|
|
@@ -8974,22 +8974,22 @@ function initialCursor(args) {
|
|
|
8974
8974
|
transcriptRelPath: args.transcriptRelPath
|
|
8975
8975
|
};
|
|
8976
8976
|
}
|
|
8977
|
-
function coverageRowFor(key,
|
|
8977
|
+
function coverageRowFor(key, cursor2, versions) {
|
|
8978
8978
|
const { sessionId, transcriptRef } = parseCursorKey(key);
|
|
8979
8979
|
return {
|
|
8980
8980
|
session_id: sessionId,
|
|
8981
8981
|
transcript_ref: transcriptRef,
|
|
8982
|
-
transcript_rel_path:
|
|
8983
|
-
through_line:
|
|
8984
|
-
through_byte:
|
|
8985
|
-
started_from_line:
|
|
8986
|
-
started_from_byte:
|
|
8987
|
-
scan_position_byte:
|
|
8988
|
-
scan_position_line:
|
|
8989
|
-
scan_window_truncated:
|
|
8990
|
-
rewind_generation:
|
|
8991
|
-
calls_extracted:
|
|
8992
|
-
last_disposition:
|
|
8982
|
+
transcript_rel_path: cursor2.transcriptRelPath,
|
|
8983
|
+
through_line: cursor2.scannedThroughLine,
|
|
8984
|
+
through_byte: cursor2.scannedThroughByte,
|
|
8985
|
+
started_from_line: cursor2.startedFromLine,
|
|
8986
|
+
started_from_byte: cursor2.startedFromByte,
|
|
8987
|
+
scan_position_byte: cursor2.byteOffset,
|
|
8988
|
+
scan_position_line: cursor2.lineOffset,
|
|
8989
|
+
scan_window_truncated: cursor2.lastWindowTruncated,
|
|
8990
|
+
rewind_generation: cursor2.rewindGeneration,
|
|
8991
|
+
calls_extracted: cursor2.callsExtracted,
|
|
8992
|
+
last_disposition: cursor2.lastDisposition,
|
|
8993
8993
|
extractor_version: versions.extractor,
|
|
8994
8994
|
redaction_rule_version: versions.redaction
|
|
8995
8995
|
};
|
|
@@ -9061,17 +9061,17 @@ async function scanAgentToolCalls(args) {
|
|
|
9061
9061
|
}
|
|
9062
9062
|
const touched = [];
|
|
9063
9063
|
for (const { key, file } of files) {
|
|
9064
|
-
let
|
|
9065
|
-
if (!
|
|
9064
|
+
let cursor2 = cursors.get(key);
|
|
9065
|
+
if (!cursor2) {
|
|
9066
9066
|
const end = endOfFile(file.absPath);
|
|
9067
9067
|
if (!end) continue;
|
|
9068
|
-
|
|
9068
|
+
cursor2 = initialCursor({
|
|
9069
9069
|
startByte: args.backfill ? 0 : end.byteOffset,
|
|
9070
9070
|
startLine: 0,
|
|
9071
9071
|
transcriptRelPath: file.relPath,
|
|
9072
9072
|
nowMs: now()
|
|
9073
9073
|
});
|
|
9074
|
-
cursors.set(key,
|
|
9074
|
+
cursors.set(key, cursor2);
|
|
9075
9075
|
touched.push(key);
|
|
9076
9076
|
if (!args.backfill && end.byteOffset > 0) {
|
|
9077
9077
|
log2(
|
|
@@ -9081,17 +9081,17 @@ async function scanAgentToolCalls(args) {
|
|
|
9081
9081
|
if (!args.backfill) continue;
|
|
9082
9082
|
}
|
|
9083
9083
|
const window = extractTranscriptWindow(file, extractOpts, {
|
|
9084
|
-
byteOffset:
|
|
9085
|
-
lineOffset:
|
|
9084
|
+
byteOffset: cursor2.byteOffset,
|
|
9085
|
+
lineOffset: cursor2.lineOffset,
|
|
9086
9086
|
// ENG-8832: carry the run scope across ticks. A marker arrives once, at
|
|
9087
9087
|
// the head of its run; without this every window after the first would
|
|
9088
9088
|
// report NULL and the attribution would silently evaporate.
|
|
9089
|
-
runScopeId:
|
|
9089
|
+
runScopeId: cursor2.runScopeId,
|
|
9090
9090
|
...args.windowBudgetBytes === void 0 ? {} : { budgetBytes: args.windowBudgetBytes }
|
|
9091
9091
|
});
|
|
9092
9092
|
summary.filesScanned += 1;
|
|
9093
9093
|
if (window.missing) {
|
|
9094
|
-
cursors.set(key, { ...
|
|
9094
|
+
cursors.set(key, { ...cursor2, lastDisposition: "transcript_missing", lastScanAt: new Date(now()).toISOString() });
|
|
9095
9095
|
touched.push(key);
|
|
9096
9096
|
continue;
|
|
9097
9097
|
}
|
|
@@ -9119,7 +9119,7 @@ async function scanAgentToolCalls(args) {
|
|
|
9119
9119
|
}
|
|
9120
9120
|
summary.callsIngested += ingested;
|
|
9121
9121
|
const computed = nextCursor({
|
|
9122
|
-
previous:
|
|
9122
|
+
previous: cursor2,
|
|
9123
9123
|
endByte: window.endByte,
|
|
9124
9124
|
endLine: window.endLine,
|
|
9125
9125
|
earliestUnpaired: window.unpaired[0] ?? null,
|
|
@@ -9130,11 +9130,11 @@ async function scanAgentToolCalls(args) {
|
|
|
9130
9130
|
rewound: window.rewound,
|
|
9131
9131
|
truncated: window.truncated
|
|
9132
9132
|
});
|
|
9133
|
-
const advanced = attempted ? computed : { ...computed, lastDisposition:
|
|
9134
|
-
if (advanced.byteOffset ===
|
|
9133
|
+
const advanced = attempted ? computed : { ...computed, lastDisposition: cursor2.lastDisposition };
|
|
9134
|
+
if (advanced.byteOffset === cursor2.byteOffset && outcome.kind === "ingest_failed") {
|
|
9135
9135
|
summary.filesHeld += 1;
|
|
9136
9136
|
log2(
|
|
9137
|
-
`[tool-call-scan] HOLDING cursor for ${file.relPath} ref=${file.ref} at byte ${
|
|
9137
|
+
`[tool-call-scan] HOLDING cursor for ${file.relPath} ref=${file.ref} at byte ${cursor2.byteOffset}: ${outcome.reason}`
|
|
9138
9138
|
);
|
|
9139
9139
|
}
|
|
9140
9140
|
cursors.set(key, advanced);
|
|
@@ -10142,19 +10142,19 @@ function createFetchGate(ttlMs) {
|
|
|
10142
10142
|
const lastFetchedAt = /* @__PURE__ */ new Map();
|
|
10143
10143
|
const forceCount = /* @__PURE__ */ new Map();
|
|
10144
10144
|
const consumedForceCount = /* @__PURE__ */ new Map();
|
|
10145
|
-
let
|
|
10145
|
+
let generation2 = 0;
|
|
10146
10146
|
const fetchedAtGeneration = /* @__PURE__ */ new Map();
|
|
10147
10147
|
const pendingForces = (key) => (forceCount.get(key) ?? 0) > (consumedForceCount.get(key) ?? 0);
|
|
10148
10148
|
return {
|
|
10149
10149
|
shouldFetch(key, now = Date.now()) {
|
|
10150
10150
|
if (pendingForces(key)) return true;
|
|
10151
|
-
if ((fetchedAtGeneration.get(key) ?? -1) <
|
|
10151
|
+
if ((fetchedAtGeneration.get(key) ?? -1) < generation2) return true;
|
|
10152
10152
|
const last = lastFetchedAt.get(key);
|
|
10153
10153
|
if (last === void 0) return true;
|
|
10154
10154
|
return now - last >= ttlMs;
|
|
10155
10155
|
},
|
|
10156
10156
|
beginFetch(key) {
|
|
10157
|
-
return { forceCount: forceCount.get(key) ?? 0, generation };
|
|
10157
|
+
return { forceCount: forceCount.get(key) ?? 0, generation: generation2 };
|
|
10158
10158
|
},
|
|
10159
10159
|
markFetched(key, token, now = Date.now()) {
|
|
10160
10160
|
lastFetchedAt.set(key, now);
|
|
@@ -10165,7 +10165,7 @@ function createFetchGate(ttlMs) {
|
|
|
10165
10165
|
forceCount.set(key, (forceCount.get(key) ?? 0) + 1);
|
|
10166
10166
|
},
|
|
10167
10167
|
forceAll() {
|
|
10168
|
-
|
|
10168
|
+
generation2 += 1;
|
|
10169
10169
|
},
|
|
10170
10170
|
forget(key) {
|
|
10171
10171
|
lastFetchedAt.delete(key);
|
|
@@ -14073,13 +14073,210 @@ function stopPidPressureSampler() {
|
|
|
14073
14073
|
timer2 = null;
|
|
14074
14074
|
}
|
|
14075
14075
|
|
|
14076
|
+
// src/lib/agent-disk-sampler.ts
|
|
14077
|
+
import { execFile as execFile2 } from "child_process";
|
|
14078
|
+
import { lstat, realpath, statfs } from "fs/promises";
|
|
14079
|
+
import { homedir as homedir16 } from "os";
|
|
14080
|
+
import { join as join45 } from "path";
|
|
14081
|
+
var DISK_SAMPLE_PERIOD_MS = 60 * 6e4;
|
|
14082
|
+
var MIN_TICK_MS = 6e4;
|
|
14083
|
+
var DU_TIMEOUT_MS = 12e4;
|
|
14084
|
+
var TOP_PATHS = 10;
|
|
14085
|
+
function parseDu(stdout, root) {
|
|
14086
|
+
let total = null;
|
|
14087
|
+
const entries = [];
|
|
14088
|
+
const rootNorm = root.replace(/\/+$/, "");
|
|
14089
|
+
for (const line of stdout.split("\n")) {
|
|
14090
|
+
const m = /^(\d+)\t(.+)$/.exec(line);
|
|
14091
|
+
if (!m) continue;
|
|
14092
|
+
const bytes = Number(m[1]) * 1024;
|
|
14093
|
+
const path = m[2].replace(/\/+$/, "");
|
|
14094
|
+
if (path === rootNorm) total = bytes;
|
|
14095
|
+
else if (path.startsWith(`${rootNorm}/`)) entries.push({ path: path.slice(rootNorm.length + 1), bytes });
|
|
14096
|
+
}
|
|
14097
|
+
return total === null ? null : { total, entries };
|
|
14098
|
+
}
|
|
14099
|
+
async function dirBytes(io, dir, left) {
|
|
14100
|
+
const k = await io.kind(dir);
|
|
14101
|
+
if (k === "missing") return 0;
|
|
14102
|
+
if (k !== "dir") return null;
|
|
14103
|
+
if (left() <= 0) return null;
|
|
14104
|
+
const r = await io.du(dir, 0, left());
|
|
14105
|
+
if (r.kind !== "ok") return null;
|
|
14106
|
+
return parseDu(r.stdout, dir)?.total ?? null;
|
|
14107
|
+
}
|
|
14108
|
+
function sumKnown(parts) {
|
|
14109
|
+
let total = 0;
|
|
14110
|
+
for (const p of parts) {
|
|
14111
|
+
if (p === null) return null;
|
|
14112
|
+
total += p;
|
|
14113
|
+
}
|
|
14114
|
+
return total;
|
|
14115
|
+
}
|
|
14116
|
+
function transcriptSlug(projectDir) {
|
|
14117
|
+
return `-${projectDir.replace(/^\//, "").replace(/[/.]/g, "-")}`;
|
|
14118
|
+
}
|
|
14119
|
+
async function sampleAgentDisk(agent, io) {
|
|
14120
|
+
const home = io.home();
|
|
14121
|
+
const deadline = io.now().getTime() + DU_TIMEOUT_MS;
|
|
14122
|
+
const left = () => deadline - io.now().getTime();
|
|
14123
|
+
const areas = {};
|
|
14124
|
+
let topPaths = [];
|
|
14125
|
+
const codeDir = join45(home, ".augmented", agent.codeName);
|
|
14126
|
+
const agentDir = await io.realpath(codeDir);
|
|
14127
|
+
if (agentDir === null) {
|
|
14128
|
+
areas.agent_dir = await io.kind(codeDir) === "missing" ? 0 : null;
|
|
14129
|
+
} else {
|
|
14130
|
+
const r = await io.du(agentDir, 2, left());
|
|
14131
|
+
const parsed = r.kind === "ok" ? parseDu(r.stdout, agentDir) : null;
|
|
14132
|
+
areas.agent_dir = parsed?.total ?? null;
|
|
14133
|
+
if (parsed) {
|
|
14134
|
+
topPaths = parsed.entries.sort((a, b) => b.bytes - a.bytes || a.path.localeCompare(b.path)).slice(0, TOP_PATHS);
|
|
14135
|
+
}
|
|
14136
|
+
}
|
|
14137
|
+
if (agent.agentId) {
|
|
14138
|
+
const idDir = join45(home, ".augmented", agent.agentId);
|
|
14139
|
+
const idReal = await io.realpath(idDir);
|
|
14140
|
+
if (idReal === null || idReal !== agentDir) {
|
|
14141
|
+
areas.agent_id_dir = idReal === null ? await io.kind(idDir) === "missing" ? 0 : null : await dirBytes(io, idReal, left);
|
|
14142
|
+
}
|
|
14143
|
+
}
|
|
14144
|
+
const projectDir = join45(agentDir ?? codeDir, "project");
|
|
14145
|
+
const projectsRoot = join45(home, ".claude", "projects");
|
|
14146
|
+
const transcriptDirs = [join45(projectsRoot, transcriptSlug(projectDir))];
|
|
14147
|
+
if (agent.isolated && agent.agentId) transcriptDirs.push(join45(projectsRoot, `.agent-${agent.agentId}`));
|
|
14148
|
+
const transcriptParts = [];
|
|
14149
|
+
for (const d of transcriptDirs) transcriptParts.push(await dirBytes(io, d, left));
|
|
14150
|
+
areas.transcripts = sumKnown(transcriptParts);
|
|
14151
|
+
if (agent.isolated) {
|
|
14152
|
+
const upper = await io.containerUpperDir(agent.codeName);
|
|
14153
|
+
areas.container_rw = upper !== null ? await dirBytes(io, upper, left) : await io.containerRwBytes(agent.codeName);
|
|
14154
|
+
if (areas.container_rw === null && !containerGapReported.has(agent.codeName)) {
|
|
14155
|
+
containerGapReported.add(agent.codeName);
|
|
14156
|
+
io.warn(
|
|
14157
|
+
`[disk-sampler] ENG-12338 container_rw unknown for agt-${agent.codeName}: ` + (upper === null ? "no overlay upperdir and no SizeRw from the daemon" : "the upperdir could not be measured") + "; this agent's disk total stays a lower bound and an open disk alert cannot close as recovered"
|
|
14158
|
+
);
|
|
14159
|
+
}
|
|
14160
|
+
if (areas.container_rw !== null) containerGapReported.delete(agent.codeName);
|
|
14161
|
+
}
|
|
14162
|
+
const fs = await io.statfs(agentDir ?? join45(home, ".augmented"));
|
|
14163
|
+
return { sampledAt: io.now().toISOString(), areas, topPaths, fs };
|
|
14164
|
+
}
|
|
14165
|
+
function execFileResult(cmd, args, timeoutMs) {
|
|
14166
|
+
return new Promise((resolve2) => {
|
|
14167
|
+
execFile2(cmd, args, { timeout: timeoutMs, killSignal: "SIGKILL", maxBuffer: 4 * 1024 * 1024 }, (err, stdout) => {
|
|
14168
|
+
if (!err) return resolve2({ kind: "ok", stdout: String(stdout) });
|
|
14169
|
+
const e = err;
|
|
14170
|
+
if (e.killed || e.signal === "SIGKILL") return resolve2({ kind: "timed-out" });
|
|
14171
|
+
if (e.code === 1 && String(stdout).length > 0) return resolve2({ kind: "ok", stdout: String(stdout) });
|
|
14172
|
+
resolve2({ kind: "failed", detail: String(e.code ?? e.message).slice(0, 200) });
|
|
14173
|
+
});
|
|
14174
|
+
});
|
|
14175
|
+
}
|
|
14176
|
+
var realDiskSamplerIo = {
|
|
14177
|
+
du: (dir, depth, timeoutMs) => execFileResult("nice", ["-n", "19", "du", "-xk", "-d", String(depth), dir], Math.max(1, Math.min(DU_TIMEOUT_MS, timeoutMs))),
|
|
14178
|
+
async kind(path) {
|
|
14179
|
+
try {
|
|
14180
|
+
const st = await lstat(path);
|
|
14181
|
+
return st.isDirectory() ? "dir" : "other";
|
|
14182
|
+
} catch (err) {
|
|
14183
|
+
return err.code === "ENOENT" ? "missing" : "error";
|
|
14184
|
+
}
|
|
14185
|
+
},
|
|
14186
|
+
async realpath(path) {
|
|
14187
|
+
try {
|
|
14188
|
+
return await realpath(path);
|
|
14189
|
+
} catch {
|
|
14190
|
+
return null;
|
|
14191
|
+
}
|
|
14192
|
+
},
|
|
14193
|
+
async statfs(path) {
|
|
14194
|
+
try {
|
|
14195
|
+
const st = await statfs(path);
|
|
14196
|
+
return { freeBytes: Number(st.bavail) * Number(st.bsize), totalBytes: Number(st.blocks) * Number(st.bsize) };
|
|
14197
|
+
} catch {
|
|
14198
|
+
return null;
|
|
14199
|
+
}
|
|
14200
|
+
},
|
|
14201
|
+
async containerRwBytes(codeName) {
|
|
14202
|
+
const r = await execFileResult("docker", ["inspect", "--size", "-f", "{{.SizeRw}}", `agt-${codeName}`], 3e4);
|
|
14203
|
+
if (r.kind !== "ok") return null;
|
|
14204
|
+
const v = r.stdout.trim();
|
|
14205
|
+
return /^\d+$/.test(v) ? Number(v) : null;
|
|
14206
|
+
},
|
|
14207
|
+
warn: (line) => console.warn(line),
|
|
14208
|
+
async containerUpperDir(codeName) {
|
|
14209
|
+
const r = await execFileResult("docker", ["inspect", "-f", "{{.GraphDriver.Data.UpperDir}}", `agt-${codeName}`], 1e4);
|
|
14210
|
+
if (r.kind !== "ok") return null;
|
|
14211
|
+
const dir = r.stdout.trim();
|
|
14212
|
+
return dir.startsWith("/") ? dir : null;
|
|
14213
|
+
},
|
|
14214
|
+
home: () => homedir16(),
|
|
14215
|
+
now: () => /* @__PURE__ */ new Date()
|
|
14216
|
+
};
|
|
14217
|
+
var lastSample2 = /* @__PURE__ */ new Map();
|
|
14218
|
+
var cursor = 0;
|
|
14219
|
+
var inFlight = false;
|
|
14220
|
+
var containerGapReported = /* @__PURE__ */ new Set();
|
|
14221
|
+
var timer3 = null;
|
|
14222
|
+
var generation = 0;
|
|
14223
|
+
var currentAgentIdOf = null;
|
|
14224
|
+
function tickMsFor(agentCount) {
|
|
14225
|
+
return Math.max(MIN_TICK_MS, Math.floor(DISK_SAMPLE_PERIOD_MS / Math.max(1, agentCount)));
|
|
14226
|
+
}
|
|
14227
|
+
async function sampleNextAgent(agents, io = realDiskSamplerIo) {
|
|
14228
|
+
if (inFlight || agents.length === 0) return null;
|
|
14229
|
+
const agent = agents[cursor % agents.length];
|
|
14230
|
+
cursor = (cursor + 1) % Math.max(1, agents.length);
|
|
14231
|
+
inFlight = true;
|
|
14232
|
+
try {
|
|
14233
|
+
lastSample2.set(agent.codeName, { agentId: agent.agentId, sample: await sampleAgentDisk(agent, io) });
|
|
14234
|
+
return agent.codeName;
|
|
14235
|
+
} finally {
|
|
14236
|
+
inFlight = false;
|
|
14237
|
+
}
|
|
14238
|
+
}
|
|
14239
|
+
function agentDiskFor(codeName) {
|
|
14240
|
+
const entry = lastSample2.get(codeName);
|
|
14241
|
+
if (!entry) return null;
|
|
14242
|
+
if (!currentAgentIdOf) return entry.sample;
|
|
14243
|
+
const current = currentAgentIdOf(codeName);
|
|
14244
|
+
if (current === null || current !== entry.agentId) return null;
|
|
14245
|
+
return { ...entry.sample, agentId: current };
|
|
14246
|
+
}
|
|
14247
|
+
function nextDelayMs(agentCount, lastSampleElapsedMs) {
|
|
14248
|
+
return Math.max(0, tickMsFor(agentCount) - Math.max(0, lastSampleElapsedMs));
|
|
14249
|
+
}
|
|
14250
|
+
function startAgentDiskSampler(liveAgents, io = realDiskSamplerIo) {
|
|
14251
|
+
if (timer3) return;
|
|
14252
|
+
const myGeneration = ++generation;
|
|
14253
|
+
currentAgentIdOf = (codeName) => liveAgents().find((a) => a.codeName === codeName)?.agentId ?? null;
|
|
14254
|
+
const schedule = (elapsedMs) => {
|
|
14255
|
+
if (myGeneration !== generation) return;
|
|
14256
|
+
const agents = liveAgents();
|
|
14257
|
+
const live = new Set(agents.map((a) => a.codeName));
|
|
14258
|
+
for (const code of lastSample2.keys()) if (!live.has(code)) lastSample2.delete(code);
|
|
14259
|
+
timer3 = setTimeout(() => {
|
|
14260
|
+
const started = Date.now();
|
|
14261
|
+
void sampleNextAgent(liveAgents(), io).finally(() => schedule(Date.now() - started));
|
|
14262
|
+
}, nextDelayMs(agents.length, elapsedMs));
|
|
14263
|
+
timer3.unref?.();
|
|
14264
|
+
};
|
|
14265
|
+
schedule(0);
|
|
14266
|
+
}
|
|
14267
|
+
function stopAgentDiskSampler() {
|
|
14268
|
+
generation++;
|
|
14269
|
+
if (timer3) clearTimeout(timer3);
|
|
14270
|
+
timer3 = null;
|
|
14271
|
+
}
|
|
14272
|
+
|
|
14076
14273
|
// src/lib/runtime-version-sampler.ts
|
|
14077
14274
|
import { execFileSync as execFileSync4 } from "child_process";
|
|
14078
14275
|
import { execFile as execFileCb } from "child_process";
|
|
14079
14276
|
import { promisify as promisify2 } from "util";
|
|
14080
14277
|
var execFileAsync2 = promisify2(execFileCb);
|
|
14081
14278
|
var SAMPLE_INTERVAL_MS3 = 5 * 6e4;
|
|
14082
|
-
var
|
|
14279
|
+
var lastSample3 = /* @__PURE__ */ new Map();
|
|
14083
14280
|
var failureCount = /* @__PURE__ */ new Map();
|
|
14084
14281
|
async function readVersionReal(codeName) {
|
|
14085
14282
|
const timeoutMs = 1e4;
|
|
@@ -14110,7 +14307,7 @@ function parseClaudeVersion(raw) {
|
|
|
14110
14307
|
async function sampleRuntimeVersionFor(codeName, io = {}) {
|
|
14111
14308
|
const isolated = io.isolatedFor?.(codeName) ?? effectiveIsolationMode(codeName) === "docker";
|
|
14112
14309
|
if (!isolated) {
|
|
14113
|
-
|
|
14310
|
+
lastSample3.delete(codeName);
|
|
14114
14311
|
failureCount.delete(codeName);
|
|
14115
14312
|
return { state: "not-isolated", version: null, sampledAt: null, failures: 0 };
|
|
14116
14313
|
}
|
|
@@ -14121,16 +14318,16 @@ async function sampleRuntimeVersionFor(codeName, io = {}) {
|
|
|
14121
14318
|
if (dir == null) {
|
|
14122
14319
|
const failures = (failureCount.get(codeName) ?? 0) + 1;
|
|
14123
14320
|
failureCount.set(codeName, failures);
|
|
14124
|
-
|
|
14321
|
+
lastSample3.delete(codeName);
|
|
14125
14322
|
return { state: "error", version: null, sampledAt: null, failures };
|
|
14126
14323
|
}
|
|
14127
|
-
const cached =
|
|
14324
|
+
const cached = lastSample3.get(codeName);
|
|
14128
14325
|
if (cached && cached.dir === dir) return cached.sample;
|
|
14129
14326
|
const version = parseClaudeVersion(await readVersion(codeName));
|
|
14130
14327
|
if (version == null) {
|
|
14131
14328
|
const failures = (failureCount.get(codeName) ?? 0) + 1;
|
|
14132
14329
|
failureCount.set(codeName, failures);
|
|
14133
|
-
|
|
14330
|
+
lastSample3.delete(codeName);
|
|
14134
14331
|
return { state: "error", version: null, sampledAt: null, failures };
|
|
14135
14332
|
}
|
|
14136
14333
|
failureCount.delete(codeName);
|
|
@@ -14140,24 +14337,24 @@ async function sampleRuntimeVersionFor(codeName, io = {}) {
|
|
|
14140
14337
|
sampledAt: new Date(now()).toISOString(),
|
|
14141
14338
|
failures: 0
|
|
14142
14339
|
};
|
|
14143
|
-
|
|
14340
|
+
lastSample3.set(codeName, { dir, sample });
|
|
14144
14341
|
return sample;
|
|
14145
14342
|
}
|
|
14146
14343
|
async function sampleRuntimeVersionOnce(codeNames, io = {}) {
|
|
14147
14344
|
for (const codeName of codeNames) await sampleRuntimeVersionFor(codeName, io);
|
|
14148
14345
|
}
|
|
14149
14346
|
function runtimeVersionFor(codeName) {
|
|
14150
|
-
const cached =
|
|
14347
|
+
const cached = lastSample3.get(codeName);
|
|
14151
14348
|
if (cached) return cached.sample;
|
|
14152
14349
|
const failures = failureCount.get(codeName) ?? 0;
|
|
14153
14350
|
if (failures > 0) return { state: "error", version: null, sampledAt: null, failures };
|
|
14154
14351
|
return { state: "unsampled", version: null, sampledAt: null, failures: 0 };
|
|
14155
14352
|
}
|
|
14156
|
-
var
|
|
14353
|
+
var timer4 = null;
|
|
14157
14354
|
var sampling = false;
|
|
14158
14355
|
function startRuntimeVersionSampler(liveAgents, io = {}) {
|
|
14159
|
-
if (
|
|
14160
|
-
|
|
14356
|
+
if (timer4) return;
|
|
14357
|
+
timer4 = setInterval(() => {
|
|
14161
14358
|
if (sampling) return;
|
|
14162
14359
|
sampling = true;
|
|
14163
14360
|
void sampleRuntimeVersionOnce(liveAgents(), io).catch(() => {
|
|
@@ -14165,11 +14362,11 @@ function startRuntimeVersionSampler(liveAgents, io = {}) {
|
|
|
14165
14362
|
sampling = false;
|
|
14166
14363
|
});
|
|
14167
14364
|
}, SAMPLE_INTERVAL_MS3);
|
|
14168
|
-
|
|
14365
|
+
timer4.unref?.();
|
|
14169
14366
|
}
|
|
14170
14367
|
function stopRuntimeVersionSampler() {
|
|
14171
|
-
if (
|
|
14172
|
-
|
|
14368
|
+
if (timer4) clearInterval(timer4);
|
|
14369
|
+
timer4 = null;
|
|
14173
14370
|
}
|
|
14174
14371
|
|
|
14175
14372
|
// src/lib/opencode-slack-ingest.ts
|
|
@@ -15317,7 +15514,7 @@ async function fireOpencodeScheduledTask(agent, task) {
|
|
|
15317
15514
|
import { createHash as createHash20 } from "crypto";
|
|
15318
15515
|
import { existsSync as existsSync18, mkdirSync as mkdirSync15, readFileSync as readFileSync36, renameSync as renameSync10, unlinkSync as unlinkSync4, writeFileSync as writeFileSync17 } from "fs";
|
|
15319
15516
|
import { randomUUID } from "crypto";
|
|
15320
|
-
import { join as
|
|
15517
|
+
import { join as join46 } from "path";
|
|
15321
15518
|
|
|
15322
15519
|
// src/lib/telegram-ingest.ts
|
|
15323
15520
|
import https2 from "https";
|
|
@@ -16020,7 +16217,7 @@ function createFileOffsetStore(codeName, log2, currentBotId) {
|
|
|
16020
16217
|
let filePath;
|
|
16021
16218
|
try {
|
|
16022
16219
|
dir = getFramework("opencode").getAgentDir(codeName);
|
|
16023
|
-
filePath =
|
|
16220
|
+
filePath = join46(dir, "telegram-getupdates-offset-opencode.json");
|
|
16024
16221
|
} catch {
|
|
16025
16222
|
dir = null;
|
|
16026
16223
|
filePath = null;
|
|
@@ -16074,7 +16271,7 @@ function createFileMigrationReportIO(codeName, log2) {
|
|
|
16074
16271
|
let filePath;
|
|
16075
16272
|
try {
|
|
16076
16273
|
dir = getFramework("opencode").getAgentDir(codeName);
|
|
16077
|
-
filePath =
|
|
16274
|
+
filePath = join46(dir, "telegram-migration-reports-opencode.json");
|
|
16078
16275
|
} catch {
|
|
16079
16276
|
dir = null;
|
|
16080
16277
|
filePath = null;
|
|
@@ -16100,7 +16297,7 @@ function createFileMigrationReportIO(codeName, log2) {
|
|
|
16100
16297
|
};
|
|
16101
16298
|
}
|
|
16102
16299
|
var managerHostPost = async (path, body) => {
|
|
16103
|
-
const { api: api2, ApiError: ApiError3 } = await import("../api-client-
|
|
16300
|
+
const { api: api2, ApiError: ApiError3 } = await import("../api-client-RRGOSC4A.js");
|
|
16104
16301
|
try {
|
|
16105
16302
|
const json = await api2.post(path, body);
|
|
16106
16303
|
return { status: 200, json };
|
|
@@ -16367,14 +16564,14 @@ function partitionActionableByPoison(actionable, states, config2) {
|
|
|
16367
16564
|
|
|
16368
16565
|
// src/lib/restart-flags.ts
|
|
16369
16566
|
import { existsSync as existsSync19, mkdirSync as mkdirSync16, readdirSync as readdirSync13, readFileSync as readFileSync37, renameSync as renameSync11, rmSync as rmSync8, writeFileSync as writeFileSync18 } from "fs";
|
|
16370
|
-
import { homedir as
|
|
16371
|
-
import { join as
|
|
16567
|
+
import { homedir as homedir17 } from "os";
|
|
16568
|
+
import { join as join47 } from "path";
|
|
16372
16569
|
import { randomUUID as randomUUID2 } from "crypto";
|
|
16373
16570
|
function restartFlagsDir() {
|
|
16374
|
-
return
|
|
16571
|
+
return join47(homedir17(), ".augmented", "restart-flags");
|
|
16375
16572
|
}
|
|
16376
16573
|
function flagPath(codeName) {
|
|
16377
|
-
return
|
|
16574
|
+
return join47(restartFlagsDir(), `${codeName}.flag`);
|
|
16378
16575
|
}
|
|
16379
16576
|
function readRestartFlags() {
|
|
16380
16577
|
const dir = restartFlagsDir();
|
|
@@ -16383,7 +16580,7 @@ function readRestartFlags() {
|
|
|
16383
16580
|
for (const entry of readdirSync13(dir)) {
|
|
16384
16581
|
if (!entry.endsWith(".flag")) continue;
|
|
16385
16582
|
try {
|
|
16386
|
-
const raw = readFileSync37(
|
|
16583
|
+
const raw = readFileSync37(join47(dir, entry), "utf8");
|
|
16387
16584
|
const parsed = JSON.parse(raw);
|
|
16388
16585
|
if (typeof parsed.codeName !== "string" || parsed.codeName.length === 0) {
|
|
16389
16586
|
parsed.codeName = entry.replace(/\.flag$/, "");
|
|
@@ -16506,7 +16703,7 @@ async function sendError(flag, opts, text) {
|
|
|
16506
16703
|
|
|
16507
16704
|
// src/lib/restart-context.ts
|
|
16508
16705
|
import { readdirSync as readdirSync14, readFileSync as readFileSync38, writeFileSync as writeFileSync19, mkdirSync as mkdirSync17, unlinkSync as unlinkSync5 } from "fs";
|
|
16509
|
-
import { dirname as dirname10, join as
|
|
16706
|
+
import { dirname as dirname10, join as join48 } from "path";
|
|
16510
16707
|
var SLACK_PENDING_INBOUND_DIRNAME = "slack-pending-inbound";
|
|
16511
16708
|
var SLACK_RESTART_CONTEXT_DIRNAME = "slack-restart-context";
|
|
16512
16709
|
var MAX_TOPIC_CHARS = 140;
|
|
@@ -16518,10 +16715,10 @@ function augmentedAgentDir(codeName) {
|
|
|
16518
16715
|
return dirname10(getProjectDir(codeName));
|
|
16519
16716
|
}
|
|
16520
16717
|
function slackPendingInboundDir(codeName) {
|
|
16521
|
-
return
|
|
16718
|
+
return join48(augmentedAgentDir(codeName), SLACK_PENDING_INBOUND_DIRNAME);
|
|
16522
16719
|
}
|
|
16523
16720
|
function slackRestartContextDir(codeName) {
|
|
16524
|
-
return
|
|
16721
|
+
return join48(augmentedAgentDir(codeName), SLACK_RESTART_CONTEXT_DIRNAME);
|
|
16525
16722
|
}
|
|
16526
16723
|
function sanitizeTopic(raw) {
|
|
16527
16724
|
const cleaned = raw.replace(/\s+/g, " ").trim().replace(/[<>]/g, " ").replace(/\s+/g, " ").trim();
|
|
@@ -16581,7 +16778,7 @@ function pruneHintsExcept(codeName, freshFilenames) {
|
|
|
16581
16778
|
if (!filename.endsWith(".json")) continue;
|
|
16582
16779
|
if (freshFilenames.has(filename)) continue;
|
|
16583
16780
|
try {
|
|
16584
|
-
unlinkSync5(
|
|
16781
|
+
unlinkSync5(join48(ctxDir, filename));
|
|
16585
16782
|
} catch {
|
|
16586
16783
|
}
|
|
16587
16784
|
}
|
|
@@ -16602,7 +16799,7 @@ function refreshSlackRestartContextHints(codeNames, opts = {}) {
|
|
|
16602
16799
|
}
|
|
16603
16800
|
const markers = [];
|
|
16604
16801
|
for (const filename of markerFilenames.slice(0, cap)) {
|
|
16605
|
-
const parsed = readStrandedMarker(
|
|
16802
|
+
const parsed = readStrandedMarker(join48(markerDir, filename));
|
|
16606
16803
|
if (parsed) markers.push({ filename, channel: parsed.channel, thread_ts: parsed.thread_ts });
|
|
16607
16804
|
}
|
|
16608
16805
|
if (markers.length === 0) {
|
|
@@ -16616,7 +16813,7 @@ function refreshSlackRestartContextHints(codeNames, opts = {}) {
|
|
|
16616
16813
|
const freshFilenames = /* @__PURE__ */ new Set();
|
|
16617
16814
|
for (const { filename, hint } of hints) {
|
|
16618
16815
|
try {
|
|
16619
|
-
writeHintFile(
|
|
16816
|
+
writeHintFile(join48(ctxDir, filename), ctxDir, hint);
|
|
16620
16817
|
freshFilenames.add(filename);
|
|
16621
16818
|
} catch (err) {
|
|
16622
16819
|
log2(`[restart-context] ${codeName}: hint write failed for ${filename}: ${err.message}`);
|
|
@@ -17545,7 +17742,7 @@ async function runDangerousRmBackstop(agentId, codeName, pane) {
|
|
|
17545
17742
|
return;
|
|
17546
17743
|
}
|
|
17547
17744
|
const policy = readRmPolicyText(
|
|
17548
|
-
() => readFileSync39(
|
|
17745
|
+
() => readFileSync39(join49(getFramework("claude-code").getAgentDir(codeName), RM_POLICY_RELATIVE_PATH), "utf-8")
|
|
17549
17746
|
);
|
|
17550
17747
|
const decision = decideDangerousRm(action.prompt, policy, {
|
|
17551
17748
|
// ENG-11871: where the agent ACTUALLY runs (fails safe to host rules if
|
|
@@ -18050,7 +18247,7 @@ function scheduleSessionRestart(codeName, delayMs, reason, breakerReason = "hot-
|
|
|
18050
18247
|
clearTimeout(existing.timer);
|
|
18051
18248
|
log(`[hot-reload] Coalesced restart for '${codeName}': replacing pending timer with ${reason}`);
|
|
18052
18249
|
}
|
|
18053
|
-
const
|
|
18250
|
+
const timer5 = setTimeout(() => {
|
|
18054
18251
|
pendingSessionRestarts.delete(codeName);
|
|
18055
18252
|
const gate = restartGateFor(codeName, breakerReason);
|
|
18056
18253
|
if (gate !== "bypass" && gate !== "proceed") {
|
|
@@ -18138,8 +18335,8 @@ function scheduleSessionRestart(codeName, delayMs, reason, breakerReason = "hot-
|
|
|
18138
18335
|
void respawnAgentAfterMcpStop(codeName, reason);
|
|
18139
18336
|
}
|
|
18140
18337
|
}, delayMs);
|
|
18141
|
-
|
|
18142
|
-
pendingSessionRestarts.set(codeName, { timer:
|
|
18338
|
+
timer5.unref?.();
|
|
18339
|
+
pendingSessionRestarts.set(codeName, { timer: timer5, reason, breakerReason, beforeStop, auditDetail });
|
|
18143
18340
|
}
|
|
18144
18341
|
function cancelPendingSessionRestart(codeName) {
|
|
18145
18342
|
pendingRestartVerifications.delete(codeName);
|
|
@@ -18270,7 +18467,7 @@ var pendingDayRolloverReset = /* @__PURE__ */ new Set();
|
|
|
18270
18467
|
var dayRolloverInboundHold = /* @__PURE__ */ new Map();
|
|
18271
18468
|
var INBOUND_HOLD_EPISODE_GAP_MS = 12e4;
|
|
18272
18469
|
async function channelInboundActivityAgeSecondsFor(codeName) {
|
|
18273
|
-
const { newestPendingInboundActivityMtimeMs } = await import("../responsiveness-probe-
|
|
18470
|
+
const { newestPendingInboundActivityMtimeMs } = await import("../responsiveness-probe-SDVMWEM3.js");
|
|
18274
18471
|
const newest = newestPendingInboundActivityMtimeMs(dirname11(paneLogPath(codeName)));
|
|
18275
18472
|
if (newest === null) return null;
|
|
18276
18473
|
return Math.max(0, Math.floor((Date.now() - newest) / 1e3));
|
|
@@ -18356,9 +18553,9 @@ async function hostShouldHaveClaudeDeviceState() {
|
|
|
18356
18553
|
return verdict.applies;
|
|
18357
18554
|
}
|
|
18358
18555
|
async function diskGuardDeps() {
|
|
18359
|
-
const { execFile:
|
|
18556
|
+
const { execFile: execFile3 } = await import("child_process");
|
|
18360
18557
|
const { promisify: promisify3 } = await import("util");
|
|
18361
|
-
const execFileAsync3 = promisify3(
|
|
18558
|
+
const execFileAsync3 = promisify3(execFile3);
|
|
18362
18559
|
const isRoot = typeof process.getuid === "function" && process.getuid() === 0;
|
|
18363
18560
|
const packageManagerBusy = async () => anyPackageInstallRunning();
|
|
18364
18561
|
return {
|
|
@@ -18660,7 +18857,7 @@ var runningMcpServerKeys = /* @__PURE__ */ new Map();
|
|
|
18660
18857
|
var runningChannelSecretHashes = /* @__PURE__ */ new Map();
|
|
18661
18858
|
var sessionLaunchManagedStructure = /* @__PURE__ */ new Map();
|
|
18662
18859
|
function readSpawnViewMcpConfig(codeName, projectDir) {
|
|
18663
|
-
const parsed = JSON.parse(readFileSync39(
|
|
18860
|
+
const parsed = JSON.parse(readFileSync39(join49(projectDir, ".mcp.json"), "utf-8"));
|
|
18664
18861
|
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) return parsed;
|
|
18665
18862
|
const agentId = agentState.codeNameToAgentId.get(codeName);
|
|
18666
18863
|
const integrations = agentId ? lastIntegrationsPayload.get(agentId) : void 0;
|
|
@@ -18682,7 +18879,7 @@ function reportSpawnCopyFailure(codeName, f) {
|
|
|
18682
18879
|
function refreshHeldDropped(codeName, projectDir, held) {
|
|
18683
18880
|
const agentId = agentState.codeNameToAgentId.get(codeName);
|
|
18684
18881
|
const integrations = agentId ? lastIntegrationsPayload.get(agentId) : void 0;
|
|
18685
|
-
const now = [...spawnDroppedServerKeys(
|
|
18882
|
+
const now = [...spawnDroppedServerKeys(join49(projectDir, ".mcp.json"), integrations)];
|
|
18686
18883
|
if (spawnCopyFailures.noteDropped(codeName, now)) {
|
|
18687
18884
|
log(
|
|
18688
18885
|
`[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)`
|
|
@@ -18705,7 +18902,7 @@ function readSpawnedMcpConfig(path) {
|
|
|
18705
18902
|
}
|
|
18706
18903
|
}
|
|
18707
18904
|
function readRawMcpConfig(projectDir) {
|
|
18708
|
-
return JSON.parse(readFileSync39(
|
|
18905
|
+
return JSON.parse(readFileSync39(join49(projectDir, ".mcp.json"), "utf-8"));
|
|
18709
18906
|
}
|
|
18710
18907
|
function readMcpConfigFor(codeName, projectDir, source) {
|
|
18711
18908
|
return source === "raw" ? readRawMcpConfig(projectDir) : readSpawnViewMcpConfig(codeName, projectDir);
|
|
@@ -18738,7 +18935,7 @@ function seedSessionLaunchBaselines(codeName, projectDir, spawnMcpConfigPath) {
|
|
|
18738
18935
|
else runningMcpServerKeys.delete(codeName);
|
|
18739
18936
|
let launchStructure = null;
|
|
18740
18937
|
try {
|
|
18741
|
-
const raw = readFileSync39(
|
|
18938
|
+
const raw = readFileSync39(join49(projectDir, ".mcp.json"), "utf-8");
|
|
18742
18939
|
launchStructure = managedMcpStructureHashFromFile(
|
|
18743
18940
|
JSON.parse(raw),
|
|
18744
18941
|
isManagedMcpServerKey
|
|
@@ -18890,7 +19087,7 @@ async function runAgentSessionToolBindProbes(agent, integrations, projectDir, op
|
|
|
18890
19087
|
if (result && result.rebindCandidates.length > 0 && hostFlagStore().getBoolean("session-tool-rebind")) {
|
|
18891
19088
|
let mcpJsonForRebind = null;
|
|
18892
19089
|
try {
|
|
18893
|
-
mcpJsonForRebind = JSON.parse(readFileSync39(
|
|
19090
|
+
mcpJsonForRebind = JSON.parse(readFileSync39(join49(projectDir, ".mcp.json"), "utf-8"));
|
|
18894
19091
|
} catch {
|
|
18895
19092
|
mcpJsonForRebind = null;
|
|
18896
19093
|
}
|
|
@@ -19054,7 +19251,7 @@ function shouldInjectChannelSecrets(agentId) {
|
|
|
19054
19251
|
function projectChannelSecretHash(projectDir) {
|
|
19055
19252
|
try {
|
|
19056
19253
|
const entries = parseEnvIntegrations(
|
|
19057
|
-
readFileSync39(
|
|
19254
|
+
readFileSync39(join49(projectDir, ".env.integrations"), "utf-8")
|
|
19058
19255
|
);
|
|
19059
19256
|
return channelSecretValueHash(entries, CHANNEL_SECRET_ENV_KEYS);
|
|
19060
19257
|
} catch {
|
|
@@ -19182,7 +19379,7 @@ var agentRestartTimezoneInputs = /* @__PURE__ */ new Map();
|
|
|
19182
19379
|
var lastVersionCheckAt = 0;
|
|
19183
19380
|
var VERSION_CHECK_INTERVAL_MS = 5 * 60 * 1e3;
|
|
19184
19381
|
var lastResponsivenessProbeAt = 0;
|
|
19185
|
-
var agtCliVersion = true ? "0.28.
|
|
19382
|
+
var agtCliVersion = true ? "0.28.1319" : "dev";
|
|
19186
19383
|
function resolveBrewPath(execFileSync5) {
|
|
19187
19384
|
try {
|
|
19188
19385
|
const out = execFileSync5("which", ["brew"], { timeout: 5e3 }).toString().trim();
|
|
@@ -19247,9 +19444,9 @@ async function ensureToolkitCliInner(toolkitSlug) {
|
|
|
19247
19444
|
}
|
|
19248
19445
|
const { binary, installer, package: pkg, script } = integration.cli_tool;
|
|
19249
19446
|
const resolvedInstaller = installer ?? "manual";
|
|
19250
|
-
const { execFileSync: execFileSync5, execFile:
|
|
19447
|
+
const { execFileSync: execFileSync5, execFile: execFile3, exec } = await import("child_process");
|
|
19251
19448
|
const { promisify: promisify3 } = await import("util");
|
|
19252
|
-
const execFileAsync3 = promisify3(
|
|
19449
|
+
const execFileAsync3 = promisify3(execFile3);
|
|
19253
19450
|
const execAsync = promisify3(exec);
|
|
19254
19451
|
try {
|
|
19255
19452
|
execFileSync5("which", [binary], { timeout: 5e3, stdio: "pipe" });
|
|
@@ -19708,7 +19905,7 @@ function runAsync(cmd, args, opts) {
|
|
|
19708
19905
|
let stdout = "";
|
|
19709
19906
|
let stderr = "";
|
|
19710
19907
|
let settled = false;
|
|
19711
|
-
const
|
|
19908
|
+
const timer5 = setTimeout(() => {
|
|
19712
19909
|
child.kill("SIGTERM");
|
|
19713
19910
|
if (settled) return;
|
|
19714
19911
|
settled = true;
|
|
@@ -19729,20 +19926,20 @@ function runAsync(cmd, args, opts) {
|
|
|
19729
19926
|
child.on("error", (err) => {
|
|
19730
19927
|
if (settled) return;
|
|
19731
19928
|
settled = true;
|
|
19732
|
-
clearTimeout(
|
|
19929
|
+
clearTimeout(timer5);
|
|
19733
19930
|
reject(err);
|
|
19734
19931
|
});
|
|
19735
19932
|
child.on("close", (code) => {
|
|
19736
19933
|
if (settled) return;
|
|
19737
19934
|
settled = true;
|
|
19738
|
-
clearTimeout(
|
|
19935
|
+
clearTimeout(timer5);
|
|
19739
19936
|
resolve2({ code: code ?? -1, stdout, stderr });
|
|
19740
19937
|
});
|
|
19741
19938
|
}).catch(reject);
|
|
19742
19939
|
});
|
|
19743
19940
|
}
|
|
19744
19941
|
function claudeManagedSettingsPath() {
|
|
19745
|
-
return
|
|
19942
|
+
return join49(CLAUDE_MANAGED_SETTINGS_DIR, "managed-settings.json");
|
|
19746
19943
|
}
|
|
19747
19944
|
var MANAGED_SETTINGS_KEYS = ["channelsEnabled", "enableAllProjectMcpServers"];
|
|
19748
19945
|
var MANAGED_SETTINGS_ENV = { DISABLE_AUTOUPDATER: "1" };
|
|
@@ -19898,7 +20095,7 @@ async function ensureOpencodeBinary() {
|
|
|
19898
20095
|
try {
|
|
19899
20096
|
const prefix = execFileSync5("npm", ["prefix", "-g"], { encoding: "utf-8", timeout: 1e4 }).trim();
|
|
19900
20097
|
if (prefix) {
|
|
19901
|
-
const npmBin =
|
|
20098
|
+
const npmBin = join49(prefix, "bin");
|
|
19902
20099
|
const current = (process.env.PATH ?? "").split(pathDelimiter);
|
|
19903
20100
|
if (!current.includes(npmBin)) {
|
|
19904
20101
|
process.env.PATH = [npmBin, ...current.filter(Boolean)].join(pathDelimiter);
|
|
@@ -19969,7 +20166,7 @@ async function ensureFrameworkBinary(frameworkId) {
|
|
|
19969
20166
|
agentRuntimeAuthenticated = await checkClaudeAuth();
|
|
19970
20167
|
}
|
|
19971
20168
|
var claudeCodeUpgradeInFlight = false;
|
|
19972
|
-
var SCRATCH_HOLDS_DIR = () =>
|
|
20169
|
+
var SCRATCH_HOLDS_DIR = () => join49(homedir18(), ".augmented", ".manager-scratch-holds");
|
|
19973
20170
|
setScratchSweepPolicyResolver(
|
|
19974
20171
|
(codeName) => resolveScratchSweepPolicy({
|
|
19975
20172
|
agentId: agentState.codeNameToAgentId.get(codeName),
|
|
@@ -20048,7 +20245,7 @@ async function maybeUpgradeClaudeCode() {
|
|
|
20048
20245
|
}
|
|
20049
20246
|
var UPDATE_CHECK_INTERVAL_MS = 5 * 60 * 1e3;
|
|
20050
20247
|
function selfUpdateAppliedMarkerPath() {
|
|
20051
|
-
return
|
|
20248
|
+
return join49(homedir18(), ".augmented", ".last-self-update-applied");
|
|
20052
20249
|
}
|
|
20053
20250
|
var selfUpdateUpToDateLogged = false;
|
|
20054
20251
|
var selfUpdatePinnedLogged = false;
|
|
@@ -20099,7 +20296,7 @@ async function checkAndUpdateCli(opts) {
|
|
|
20099
20296
|
const isNpmGlobal = !isBrewFormula && resolvedPath.includes("node_modules");
|
|
20100
20297
|
if (!isBrewFormula && !isNpmGlobal) return "noop";
|
|
20101
20298
|
const { readFileSync: readF, writeFileSync: writeF } = await import("fs");
|
|
20102
|
-
const markerPath =
|
|
20299
|
+
const markerPath = join49(homedir18(), ".augmented", ".last-update-check");
|
|
20103
20300
|
if (!force) {
|
|
20104
20301
|
try {
|
|
20105
20302
|
const lastCheck = parseInt(readF(markerPath, "utf-8").trim(), 10);
|
|
@@ -20535,7 +20732,7 @@ async function runClaudeRuntimeAuthProbe() {
|
|
|
20535
20732
|
];
|
|
20536
20733
|
try {
|
|
20537
20734
|
const { stdout, stderr } = await execFilePromiseLong(resolveClaudeBinary(), args, {
|
|
20538
|
-
cwd:
|
|
20735
|
+
cwd: homedir18(),
|
|
20539
20736
|
timeout: RUNTIME_AUTH_PROBE_TIMEOUT_MS,
|
|
20540
20737
|
stdin: "ignore",
|
|
20541
20738
|
env: childEnv,
|
|
@@ -20571,7 +20768,7 @@ async function runHostUsageCommand() {
|
|
|
20571
20768
|
...hostClaudeOneShotArgs(emptyMcp)
|
|
20572
20769
|
];
|
|
20573
20770
|
const { stdout } = await execFilePromiseLong(resolveClaudeBinary(), args, {
|
|
20574
|
-
cwd:
|
|
20771
|
+
cwd: homedir18(),
|
|
20575
20772
|
timeout: HOST_USAGE_POLL_TIMEOUT_MS,
|
|
20576
20773
|
stdin: "ignore",
|
|
20577
20774
|
env: childEnv,
|
|
@@ -20618,12 +20815,12 @@ async function checkClaudeAuth() {
|
|
|
20618
20815
|
var evalEmptyMcpConfigPath = null;
|
|
20619
20816
|
function ensureEvalEmptyMcpConfig() {
|
|
20620
20817
|
if (evalEmptyMcpConfigPath && existsSync20(evalEmptyMcpConfigPath)) return evalEmptyMcpConfigPath;
|
|
20621
|
-
const dir =
|
|
20818
|
+
const dir = join49(homedir18(), ".augmented");
|
|
20622
20819
|
try {
|
|
20623
20820
|
mkdirSync18(dir, { recursive: true });
|
|
20624
20821
|
} catch {
|
|
20625
20822
|
}
|
|
20626
|
-
const p =
|
|
20823
|
+
const p = join49(dir, ".eval-empty-mcp.json");
|
|
20627
20824
|
writeFileSync20(p, JSON.stringify({ mcpServers: {} }));
|
|
20628
20825
|
evalEmptyMcpConfigPath = p;
|
|
20629
20826
|
return p;
|
|
@@ -20645,7 +20842,7 @@ async function runEvalClaude(prompt, model) {
|
|
|
20645
20842
|
...hostClaudeOneShotArgs(emptyMcp)
|
|
20646
20843
|
];
|
|
20647
20844
|
const { stdout } = await execFilePromiseLong(resolveClaudeBinary(), args, {
|
|
20648
|
-
cwd:
|
|
20845
|
+
cwd: homedir18(),
|
|
20649
20846
|
timeout: 12e4,
|
|
20650
20847
|
stdin: "ignore",
|
|
20651
20848
|
env: childEnv,
|
|
@@ -20714,10 +20911,10 @@ function resolveConversationEvalBackend() {
|
|
|
20714
20911
|
return conversationEvalBackend;
|
|
20715
20912
|
}
|
|
20716
20913
|
function getStateFile() {
|
|
20717
|
-
return
|
|
20914
|
+
return join49(config?.configDir ?? join49(process.env["HOME"] ?? "/tmp", ".augmented"), "manager-state.json");
|
|
20718
20915
|
}
|
|
20719
20916
|
function channelHashCacheDir() {
|
|
20720
|
-
return config?.configDir ??
|
|
20917
|
+
return config?.configDir ?? join49(process.env["HOME"] ?? "/tmp", ".augmented");
|
|
20721
20918
|
}
|
|
20722
20919
|
function loadChannelHashCache2() {
|
|
20723
20920
|
loadChannelHashCache(agentState.knownChannelConfigHashes, channelHashCacheDir());
|
|
@@ -20930,7 +21127,7 @@ function removeDeliveryBaselineEntries(agentId) {
|
|
|
20930
21127
|
var _channelQuarantineStore = null;
|
|
20931
21128
|
function channelQuarantineStore() {
|
|
20932
21129
|
if (!_channelQuarantineStore) {
|
|
20933
|
-
const dir = config?.configDir ??
|
|
21130
|
+
const dir = config?.configDir ?? join49(process.env["HOME"] ?? "/tmp", ".augmented");
|
|
20934
21131
|
_channelQuarantineStore = new ChannelQuarantineStore(defaultQuarantinePath(dir));
|
|
20935
21132
|
}
|
|
20936
21133
|
return _channelQuarantineStore;
|
|
@@ -20938,7 +21135,7 @@ function channelQuarantineStore() {
|
|
|
20938
21135
|
var _channelResumeHistoryStore = null;
|
|
20939
21136
|
function channelResumeHistoryStore() {
|
|
20940
21137
|
if (!_channelResumeHistoryStore) {
|
|
20941
|
-
const dir = config?.configDir ??
|
|
21138
|
+
const dir = config?.configDir ?? join49(process.env["HOME"] ?? "/tmp", ".augmented");
|
|
20942
21139
|
_channelResumeHistoryStore = new ChannelResumeHistoryStore(defaultResumeHistoryPath(dir));
|
|
20943
21140
|
}
|
|
20944
21141
|
return _channelResumeHistoryStore;
|
|
@@ -20983,12 +21180,12 @@ function sessionActivityFor(codeName, pane, opts = {}) {
|
|
|
20983
21180
|
}
|
|
20984
21181
|
function forwardedToolsFor(codeName) {
|
|
20985
21182
|
if (!config?.configDir) return null;
|
|
20986
|
-
return readForwardedToolsReport(
|
|
21183
|
+
return readForwardedToolsReport(join49(config.configDir, codeName));
|
|
20987
21184
|
}
|
|
20988
21185
|
var _hostFlagStore = null;
|
|
20989
21186
|
function hostFlagStore() {
|
|
20990
21187
|
if (!_hostFlagStore) {
|
|
20991
|
-
const dir = config?.configDir ??
|
|
21188
|
+
const dir = config?.configDir ?? join49(process.env["HOME"] ?? "/tmp", ".augmented");
|
|
20992
21189
|
_hostFlagStore = new HostFlagStore({ cachePath: defaultFlagsCachePath(dir), log });
|
|
20993
21190
|
}
|
|
20994
21191
|
return _hostFlagStore;
|
|
@@ -21174,12 +21371,12 @@ function parseSkillFrontmatter(content) {
|
|
|
21174
21371
|
}
|
|
21175
21372
|
async function refreshSkillsIndexInClaudeMd(configDir, codeName, log2) {
|
|
21176
21373
|
const { readdirSync: readdirSync16, readFileSync: rfs, existsSync: ex, writeFileSync: writeFileSync21 } = await import("fs");
|
|
21177
|
-
const skillsDir =
|
|
21178
|
-
const claudeMdPath =
|
|
21374
|
+
const skillsDir = join49(configDir, codeName, "project", ".claude", "skills");
|
|
21375
|
+
const claudeMdPath = join49(configDir, codeName, "project", "CLAUDE.md");
|
|
21179
21376
|
if (!ex(skillsDir) || !ex(claudeMdPath)) return;
|
|
21180
21377
|
const entries = [];
|
|
21181
21378
|
for (const dir of readdirSync16(skillsDir).sort()) {
|
|
21182
|
-
const skillFile =
|
|
21379
|
+
const skillFile = join49(skillsDir, dir, "SKILL.md");
|
|
21183
21380
|
if (!ex(skillFile)) continue;
|
|
21184
21381
|
try {
|
|
21185
21382
|
const { name, description } = parseSkillFrontmatter(rfs(skillFile, "utf-8"));
|
|
@@ -21318,10 +21515,10 @@ function flushRestartedAgentDiagnostics(hostId, codeNames) {
|
|
|
21318
21515
|
if (codeNames.length === 0) return;
|
|
21319
21516
|
void (async () => {
|
|
21320
21517
|
try {
|
|
21321
|
-
const { collectDiagnostics } = await import("../persistent-session-
|
|
21518
|
+
const { collectDiagnostics } = await import("../persistent-session-4AGRIK5W.js");
|
|
21322
21519
|
await api.post("/host/heartbeat", {
|
|
21323
21520
|
host_id: hostId,
|
|
21324
|
-
agent_diagnostics: collectDiagnostics(codeNames, quarantineEntriesFor, claudeMdSizeFor, spawnOutcomeForDiagnostics, pidPressureFor, forwardedToolsFor, runtimeVersionFor, sessionActivityFor)
|
|
21521
|
+
agent_diagnostics: collectDiagnostics(codeNames, quarantineEntriesFor, claudeMdSizeFor, spawnOutcomeForDiagnostics, pidPressureFor, forwardedToolsFor, runtimeVersionFor, sessionActivityFor, agentDiskFor)
|
|
21325
21522
|
});
|
|
21326
21523
|
} catch (err) {
|
|
21327
21524
|
log(`[restart] post-respawn diagnostics flush failed: ${err.message}`);
|
|
@@ -21386,7 +21583,7 @@ async function pollCycleInner() {
|
|
|
21386
21583
|
getSlackToken: (codeName) => agentChannelTokens.get(codeName)?.slack ?? null,
|
|
21387
21584
|
sendSlack: async (botToken, body) => {
|
|
21388
21585
|
const controller = new AbortController();
|
|
21389
|
-
const
|
|
21586
|
+
const timer5 = setTimeout(() => controller.abort(), 5e3);
|
|
21390
21587
|
try {
|
|
21391
21588
|
const res = await fetch("https://slack.com/api/chat.postMessage", {
|
|
21392
21589
|
method: "POST",
|
|
@@ -21403,7 +21600,7 @@ async function pollCycleInner() {
|
|
|
21403
21600
|
const isAbort = err.name === "AbortError";
|
|
21404
21601
|
return { ok: false, error: isAbort ? "timeout" : err.message };
|
|
21405
21602
|
} finally {
|
|
21406
|
-
clearTimeout(
|
|
21603
|
+
clearTimeout(timer5);
|
|
21407
21604
|
}
|
|
21408
21605
|
},
|
|
21409
21606
|
// ENG-6399: report the restart to audit_log via POST /host/restart-event.
|
|
@@ -21465,11 +21662,11 @@ async function pollCycleInner() {
|
|
|
21465
21662
|
}
|
|
21466
21663
|
try {
|
|
21467
21664
|
const { detectHostSecurity } = await import("../host-security-KQYYZZVW.js");
|
|
21468
|
-
const { collectDiagnostics } = await import("../persistent-session-
|
|
21665
|
+
const { collectDiagnostics } = await import("../persistent-session-4AGRIK5W.js");
|
|
21469
21666
|
const recordedSinceHeartbeat = new Set(spawnOutcomesSinceHeartbeat.drain());
|
|
21470
21667
|
const diagCodeNames = heartbeatDiagnosticsCodeNames(agentState.persistentSessionAgents, recordedSinceHeartbeat);
|
|
21471
21668
|
const heartbeatSpawnOutcomeFor = spawnOutcomeIfRecorded(spawnOutcomeForDiagnostics, recordedSinceHeartbeat);
|
|
21472
|
-
const agentDiagnostics = diagCodeNames.length > 0 ? collectDiagnostics(diagCodeNames, quarantineEntriesFor, claudeMdSizeFor, heartbeatSpawnOutcomeFor, pidPressureFor, forwardedToolsFor, runtimeVersionFor, sessionActivityFor) : void 0;
|
|
21669
|
+
const agentDiagnostics = diagCodeNames.length > 0 ? collectDiagnostics(diagCodeNames, quarantineEntriesFor, claudeMdSizeFor, heartbeatSpawnOutcomeFor, pidPressureFor, forwardedToolsFor, runtimeVersionFor, sessionActivityFor, agentDiskFor) : void 0;
|
|
21473
21670
|
let tailscaleHostname;
|
|
21474
21671
|
try {
|
|
21475
21672
|
const { execSync: es } = await import("child_process");
|
|
@@ -21766,7 +21963,7 @@ async function pollCycleInner() {
|
|
|
21766
21963
|
}
|
|
21767
21964
|
try {
|
|
21768
21965
|
const desiredClaudeCodeVersion = hbResp?.desired_claude_code_version?.trim();
|
|
21769
|
-
const { maybeUpdateClaudeCode, shouldRunClaudeCodeUpdater } = await import("../claude-code-updater-
|
|
21966
|
+
const { maybeUpdateClaudeCode, shouldRunClaudeCodeUpdater } = await import("../claude-code-updater-E5QX33MA.js");
|
|
21770
21967
|
const securityFloor = currentSecurityFloor();
|
|
21771
21968
|
claudeUpdaterInFlight = true;
|
|
21772
21969
|
if (desiredClaudeCodeVersion && (claudePairLoop.busy || claudePairingInProgress())) {
|
|
@@ -21801,7 +21998,7 @@ async function pollCycleInner() {
|
|
|
21801
21998
|
collectPanelessActivityProbes,
|
|
21802
21999
|
getResponsivenessIntervalMs,
|
|
21803
22000
|
occupancyQualificationClassifications
|
|
21804
|
-
} = await import("../responsiveness-probe-
|
|
22001
|
+
} = await import("../responsiveness-probe-SDVMWEM3.js");
|
|
21805
22002
|
const probeIntervalMs = getResponsivenessIntervalMs();
|
|
21806
22003
|
if (now - lastResponsivenessProbeAt > probeIntervalMs) {
|
|
21807
22004
|
const probeCodeNames = [...agentState.persistentSessionAgents];
|
|
@@ -21918,7 +22115,7 @@ async function pollCycleInner() {
|
|
|
21918
22115
|
collectResponsivenessProbes,
|
|
21919
22116
|
livePendingInboundOldestAgeSeconds,
|
|
21920
22117
|
parkPendingInbound
|
|
21921
|
-
} = await import("../responsiveness-probe-
|
|
22118
|
+
} = await import("../responsiveness-probe-SDVMWEM3.js");
|
|
21922
22119
|
const { getProjectDir: wedgeProjectDir } = await import("../scheduler-engine-5PCBGRNY.js");
|
|
21923
22120
|
const wedgeNow = /* @__PURE__ */ new Date();
|
|
21924
22121
|
const liveAgents = agentState.persistentSessionAgents;
|
|
@@ -22011,10 +22208,10 @@ async function pollCycleInner() {
|
|
|
22011
22208
|
const paneTail = readFileSync39(paneLogPath(codeName), "utf8").slice(-65536);
|
|
22012
22209
|
const transient = detectTransientApiErrorInLog(paneTail);
|
|
22013
22210
|
if (transient) {
|
|
22014
|
-
const wedgeHome =
|
|
22211
|
+
const wedgeHome = join49(homedir18(), ".augmented", codeName);
|
|
22015
22212
|
if (existsSync20(wedgeHome)) {
|
|
22016
22213
|
atomicWriteFileSync(
|
|
22017
|
-
|
|
22214
|
+
join49(wedgeHome, "watchdog-give-up.json"),
|
|
22018
22215
|
JSON.stringify({
|
|
22019
22216
|
gave_up_at: wedgeNow.toISOString(),
|
|
22020
22217
|
reason: "transient_overload"
|
|
@@ -22207,7 +22404,7 @@ async function pollCycleInner() {
|
|
|
22207
22404
|
}
|
|
22208
22405
|
);
|
|
22209
22406
|
if (!paneFatalTornDown) continue;
|
|
22210
|
-
const { parkPendingInbound } = await import("../responsiveness-probe-
|
|
22407
|
+
const { parkPendingInbound } = await import("../responsiveness-probe-SDVMWEM3.js");
|
|
22211
22408
|
const { parked, deadLettered } = parkPendingInbound(codeName, new Date(fatalNowMs));
|
|
22212
22409
|
paneFatalStreak.delete(codeName);
|
|
22213
22410
|
paneFatalRestarts.set(codeName, [...history, fatalNowMs]);
|
|
@@ -22238,7 +22435,7 @@ async function pollCycleInner() {
|
|
|
22238
22435
|
TRANSCRIPT_MOUNT_ESCALATION_REFRESH_MS,
|
|
22239
22436
|
bindSourceEscalations
|
|
22240
22437
|
} = await import("../transcript-mount-health-OHE6IVJV.js");
|
|
22241
|
-
const { transcriptBindSourcesFor, ensureTranscriptBindSources } = await import("../persistent-session-
|
|
22438
|
+
const { transcriptBindSourcesFor, ensureTranscriptBindSources } = await import("../persistent-session-4AGRIK5W.js");
|
|
22242
22439
|
const mountConfig = resolveTranscriptMountConfig();
|
|
22243
22440
|
const liveAgents = agentState.persistentSessionAgents;
|
|
22244
22441
|
for (const tracked of [
|
|
@@ -22269,7 +22466,7 @@ async function pollCycleInner() {
|
|
|
22269
22466
|
};
|
|
22270
22467
|
if (mountConfig.mode !== "off" && platform3() === "linux") {
|
|
22271
22468
|
const mountNowMs = Date.now();
|
|
22272
|
-
const homeDirForBinds = process.env.HOME?.trim() ||
|
|
22469
|
+
const homeDirForBinds = process.env.HOME?.trim() || homedir18();
|
|
22273
22470
|
for (const codeName of liveAgents) {
|
|
22274
22471
|
if (effectiveIsolationMode(codeName) !== "docker") continue;
|
|
22275
22472
|
if (!isSessionHealthy(codeName)) {
|
|
@@ -22404,7 +22601,7 @@ async function pollCycleInner() {
|
|
|
22404
22601
|
}
|
|
22405
22602
|
try {
|
|
22406
22603
|
const { scrapeMcpFailedBannerCount } = await import("../pane-mcp-banner-scraper-VR5QGP3J.js");
|
|
22407
|
-
const { probeSessionAuth } = await import("../session-auth-dead-
|
|
22604
|
+
const { probeSessionAuth } = await import("../session-auth-dead-EIVQKX5X.js");
|
|
22408
22605
|
const observations = [];
|
|
22409
22606
|
const pendingCacheCommits = [];
|
|
22410
22607
|
const modelApiErrorReportingOn = hostFlagStore().getBoolean("model-api-error-reporting");
|
|
@@ -22968,7 +23165,7 @@ async function pollCycleInner() {
|
|
|
22968
23165
|
`[drain-flush] FAILED for '${prev.codeName}': ${err.message} \u2014 proceeding to teardown; this session was NOT shipped (ENG-9491)`
|
|
22969
23166
|
);
|
|
22970
23167
|
}
|
|
22971
|
-
const agentDir =
|
|
23168
|
+
const agentDir = join49(adapter.getAgentDir(prev.codeName), "provision");
|
|
22972
23169
|
await cleanupAgentFiles(prev.codeName, agentDir);
|
|
22973
23170
|
clearAgentCaches(prev.agentId, prev.codeName);
|
|
22974
23171
|
}
|
|
@@ -23047,10 +23244,10 @@ async function pollCycleInner() {
|
|
|
23047
23244
|
// pending-inbound marker. Best-effort: a write failure is logged by
|
|
23048
23245
|
// the watchdog, never fails the poll cycle.
|
|
23049
23246
|
signalGiveUp: (codeName) => {
|
|
23050
|
-
const dir =
|
|
23247
|
+
const dir = join49(homedir18(), ".augmented", codeName);
|
|
23051
23248
|
if (!existsSync20(dir)) return;
|
|
23052
23249
|
atomicWriteFileSync(
|
|
23053
|
-
|
|
23250
|
+
join49(dir, "watchdog-give-up.json"),
|
|
23054
23251
|
JSON.stringify({ gave_up_at: (/* @__PURE__ */ new Date()).toISOString() })
|
|
23055
23252
|
);
|
|
23056
23253
|
},
|
|
@@ -23078,17 +23275,17 @@ async function pollCycleInner() {
|
|
|
23078
23275
|
const dir = getFramework("claude-code").getAgentDir(codeName);
|
|
23079
23276
|
if (!existsSync20(dir)) return;
|
|
23080
23277
|
atomicWriteFileSync(
|
|
23081
|
-
|
|
23278
|
+
join49(dir, "blocked-prompt.json"),
|
|
23082
23279
|
JSON.stringify({ kind, last_seen_at: (/* @__PURE__ */ new Date()).toISOString() })
|
|
23083
23280
|
);
|
|
23084
23281
|
},
|
|
23085
23282
|
clearBlockedPromptLiveness: (codeName) => {
|
|
23086
|
-
const file =
|
|
23283
|
+
const file = join49(getFramework("claude-code").getAgentDir(codeName), "blocked-prompt.json");
|
|
23087
23284
|
if (existsSync20(file)) rmSync9(file, { force: true });
|
|
23088
23285
|
},
|
|
23089
23286
|
refreshUsageLimitLiveness: (codeName) => {
|
|
23090
23287
|
const dir = getFramework("claude-code").getAgentDir(codeName);
|
|
23091
|
-
const file =
|
|
23288
|
+
const file = join49(dir, "watchdog-give-up.json");
|
|
23092
23289
|
if (!existsSync20(file)) return;
|
|
23093
23290
|
try {
|
|
23094
23291
|
const raw = JSON.parse(readFileSync39(file, "utf8"));
|
|
@@ -23102,7 +23299,7 @@ async function pollCycleInner() {
|
|
|
23102
23299
|
const dir = getFramework("claude-code").getAgentDir(codeName);
|
|
23103
23300
|
if (!existsSync20(dir)) return;
|
|
23104
23301
|
atomicWriteFileSync(
|
|
23105
|
-
|
|
23302
|
+
join49(dir, "watchdog-give-up.json"),
|
|
23106
23303
|
JSON.stringify({
|
|
23107
23304
|
gave_up_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
23108
23305
|
reason: "usage_limit",
|
|
@@ -23389,7 +23586,7 @@ async function processAgent(agent, agentStates, managedToolkits) {
|
|
|
23389
23586
|
}
|
|
23390
23587
|
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
23391
23588
|
const adapter = resolveAgentFramework(agent.code_name);
|
|
23392
|
-
let agentDir =
|
|
23589
|
+
let agentDir = join49(adapter.getAgentDir(agent.code_name), "provision");
|
|
23393
23590
|
if (agent.status === "draft" || agent.status === "paused") {
|
|
23394
23591
|
forgetChannelSyncState(agent.agent_id);
|
|
23395
23592
|
reapLegacyTokenFileEdgeWarned(agent.code_name, log);
|
|
@@ -23537,7 +23734,7 @@ async function processAgent(agent, agentStates, managedToolkits) {
|
|
|
23537
23734
|
if (refreshData.knowledge_manifest) {
|
|
23538
23735
|
const resolved = await resolveKnowledgeFromManifest({
|
|
23539
23736
|
manifest: refreshData.knowledge_manifest,
|
|
23540
|
-
cacheDir:
|
|
23737
|
+
cacheDir: join49(config.configDir, "_knowledge"),
|
|
23541
23738
|
delivery: refreshData.agent?.knowledge_delivery ?? "both",
|
|
23542
23739
|
fetchContents: async (hashes) => {
|
|
23543
23740
|
const res = await api.post(
|
|
@@ -23554,7 +23751,7 @@ async function processAgent(agent, agentStates, managedToolkits) {
|
|
|
23554
23751
|
const resolvedSkills = await resolveSkillsFromManifest({
|
|
23555
23752
|
globals: refreshData.global_skills_manifest ?? [],
|
|
23556
23753
|
shared: refreshData.shared_skills_manifest ?? [],
|
|
23557
|
-
cacheDir:
|
|
23754
|
+
cacheDir: join49(config.configDir, "_skills"),
|
|
23558
23755
|
fetchContents: async (hashes) => {
|
|
23559
23756
|
const res = await api.post(
|
|
23560
23757
|
"/host/skills/contents",
|
|
@@ -23572,7 +23769,7 @@ async function processAgent(agent, agentStates, managedToolkits) {
|
|
|
23572
23769
|
if (refreshData.integration_skills_manifest) {
|
|
23573
23770
|
const resolvedIntegrationSkills = await resolveIntegrationSkillsFromManifest({
|
|
23574
23771
|
manifest: refreshData.integration_skills_manifest,
|
|
23575
|
-
cacheDir:
|
|
23772
|
+
cacheDir: join49(config.configDir, "_skills"),
|
|
23576
23773
|
fetchContents: async (hashes) => {
|
|
23577
23774
|
const res = await api.post(
|
|
23578
23775
|
"/host/skills/contents",
|
|
@@ -23634,7 +23831,7 @@ async function processAgent(agent, agentStates, managedToolkits) {
|
|
|
23634
23831
|
const frameworkId = refreshData.agent.framework ?? DEFAULT_FRAMEWORK;
|
|
23635
23832
|
agentFrameworkCache.set(agent.code_name, frameworkId);
|
|
23636
23833
|
const frameworkAdapter = getFramework(frameworkId);
|
|
23637
|
-
agentDir =
|
|
23834
|
+
agentDir = join49(frameworkAdapter.getAgentDir(agent.code_name), "provision");
|
|
23638
23835
|
cacheAgentDeliveryMetadata(agent.code_name, refreshData);
|
|
23639
23836
|
agentRestartTimezoneInputs.set(agent.code_name, {
|
|
23640
23837
|
agentTimezone: typeof refreshData.agent.timezone === "string" ? refreshData.agent.timezone : null,
|
|
@@ -23712,7 +23909,7 @@ async function processAgent(agent, agentStates, managedToolkits) {
|
|
|
23712
23909
|
const changedFiles = [];
|
|
23713
23910
|
mkdirSync18(agentDir, { recursive: true });
|
|
23714
23911
|
for (const artifact of artifacts) {
|
|
23715
|
-
const filePath =
|
|
23912
|
+
const filePath = join49(agentDir, artifact.relativePath);
|
|
23716
23913
|
let existingHash;
|
|
23717
23914
|
let newHash;
|
|
23718
23915
|
let writeContent = artifact.content;
|
|
@@ -23731,7 +23928,7 @@ async function processAgent(agent, agentStates, managedToolkits) {
|
|
|
23731
23928
|
};
|
|
23732
23929
|
newHash = sha256(stripDynamicSections(artifact.content));
|
|
23733
23930
|
try {
|
|
23734
|
-
const projectClaudeMd =
|
|
23931
|
+
const projectClaudeMd = join49(config.configDir, agent.code_name, "project", "CLAUDE.md");
|
|
23735
23932
|
const existing = readFileSync39(projectClaudeMd, "utf-8");
|
|
23736
23933
|
existingHash = sha256(stripDynamicSections(existing));
|
|
23737
23934
|
} catch {
|
|
@@ -23782,12 +23979,12 @@ async function processAgent(agent, agentStates, managedToolkits) {
|
|
|
23782
23979
|
}
|
|
23783
23980
|
}
|
|
23784
23981
|
if (changedFiles.length > 0) {
|
|
23785
|
-
const isFirst = !existsSync20(
|
|
23982
|
+
const isFirst = !existsSync20(join49(agentDir, "CHARTER.md"));
|
|
23786
23983
|
const verb = isFirst ? "Provisioning" : "Updating";
|
|
23787
23984
|
const fileNames = changedFiles.map((f) => f.relativePath).join(", ");
|
|
23788
23985
|
log(`${verb} '${agent.code_name}': ${fileNames}`);
|
|
23789
23986
|
for (const file of changedFiles) {
|
|
23790
|
-
const filePath =
|
|
23987
|
+
const filePath = join49(agentDir, file.relativePath);
|
|
23791
23988
|
mkdirSync18(dirname11(filePath), { recursive: true });
|
|
23792
23989
|
if (file.relativePath === ".mcp.json") {
|
|
23793
23990
|
safeWriteJsonAtomic(filePath, file.content, { mode: 384 });
|
|
@@ -23796,12 +23993,12 @@ async function processAgent(agent, agentStates, managedToolkits) {
|
|
|
23796
23993
|
}
|
|
23797
23994
|
}
|
|
23798
23995
|
try {
|
|
23799
|
-
const provSkillsDir =
|
|
23996
|
+
const provSkillsDir = join49(agentDir, ".claude", "skills");
|
|
23800
23997
|
if (existsSync20(provSkillsDir)) {
|
|
23801
23998
|
for (const folder of readdirSync15(provSkillsDir)) {
|
|
23802
23999
|
if (folder.startsWith("knowledge-")) {
|
|
23803
24000
|
try {
|
|
23804
|
-
rmSync9(
|
|
24001
|
+
rmSync9(join49(provSkillsDir, folder), { recursive: true });
|
|
23805
24002
|
} catch {
|
|
23806
24003
|
}
|
|
23807
24004
|
}
|
|
@@ -23814,7 +24011,7 @@ async function processAgent(agent, agentStates, managedToolkits) {
|
|
|
23814
24011
|
const trackedFiles2 = frameworkAdapter.driftTrackedFiles();
|
|
23815
24012
|
const hashes = /* @__PURE__ */ new Map();
|
|
23816
24013
|
for (const file of trackedFiles2) {
|
|
23817
|
-
const h = hashFile(
|
|
24014
|
+
const h = hashFile(join49(agentDir, file));
|
|
23818
24015
|
if (h) hashes.set(file, h);
|
|
23819
24016
|
}
|
|
23820
24017
|
agentState.writtenHashes.set(agent.agent_id, hashes);
|
|
@@ -23832,14 +24029,14 @@ async function processAgent(agent, agentStates, managedToolkits) {
|
|
|
23832
24029
|
}
|
|
23833
24030
|
if (Array.isArray(refreshData.workflows)) {
|
|
23834
24031
|
try {
|
|
23835
|
-
const provWorkflowsDir =
|
|
24032
|
+
const provWorkflowsDir = join49(agentDir, ".claude", "workflows");
|
|
23836
24033
|
if (existsSync20(provWorkflowsDir)) {
|
|
23837
24034
|
const expected = new Set(refreshData.workflows.map((w) => `${w.name}.js`));
|
|
23838
24035
|
for (const file of readdirSync15(provWorkflowsDir)) {
|
|
23839
24036
|
if (!file.endsWith(".js")) continue;
|
|
23840
24037
|
if (expected.has(file)) continue;
|
|
23841
24038
|
try {
|
|
23842
|
-
rmSync9(
|
|
24039
|
+
rmSync9(join49(provWorkflowsDir, file));
|
|
23843
24040
|
} catch {
|
|
23844
24041
|
}
|
|
23845
24042
|
}
|
|
@@ -23934,7 +24131,7 @@ async function processAgent(agent, agentStates, managedToolkits) {
|
|
|
23934
24131
|
if (written && existsSync20(agentDir)) {
|
|
23935
24132
|
const driftedFiles = [];
|
|
23936
24133
|
for (const [file, expectedHash] of written) {
|
|
23937
|
-
const localHash = hashFile(
|
|
24134
|
+
const localHash = hashFile(join49(agentDir, file));
|
|
23938
24135
|
if (localHash && localHash !== expectedHash) {
|
|
23939
24136
|
driftedFiles.push(file);
|
|
23940
24137
|
}
|
|
@@ -23945,7 +24142,7 @@ async function processAgent(agent, agentStates, managedToolkits) {
|
|
|
23945
24142
|
try {
|
|
23946
24143
|
const localHashes = {};
|
|
23947
24144
|
for (const file of driftedFiles) {
|
|
23948
|
-
localHashes[file] = hashFile(
|
|
24145
|
+
localHashes[file] = hashFile(join49(agentDir, file));
|
|
23949
24146
|
}
|
|
23950
24147
|
await api.post("/host/drift", {
|
|
23951
24148
|
agent_id: agent.agent_id,
|
|
@@ -24230,7 +24427,7 @@ async function processAgent(agent, agentStates, managedToolkits) {
|
|
|
24230
24427
|
const addedChannels = [...restartDecision.added];
|
|
24231
24428
|
const writeDmNoticeMarkers = isChannelAddRestart ? () => {
|
|
24232
24429
|
try {
|
|
24233
|
-
const agentAugmentedDir =
|
|
24430
|
+
const agentAugmentedDir = join49(homedir18(), ".augmented", agent.code_name);
|
|
24234
24431
|
mkdirSync18(agentAugmentedDir, { recursive: true });
|
|
24235
24432
|
const markerJson = JSON.stringify({
|
|
24236
24433
|
version: 1,
|
|
@@ -24238,7 +24435,7 @@ async function processAgent(agent, agentStates, managedToolkits) {
|
|
|
24238
24435
|
added: addedChannels
|
|
24239
24436
|
});
|
|
24240
24437
|
for (const file of ["slack-channel-add-restart.json", "telegram-channel-add-restart.json"]) {
|
|
24241
|
-
atomicWriteFileSync(
|
|
24438
|
+
atomicWriteFileSync(join49(agentAugmentedDir, file), markerJson);
|
|
24242
24439
|
}
|
|
24243
24440
|
} catch (err) {
|
|
24244
24441
|
log(`[hot-reload] channel-add DM-notice marker write failed for '${agent.code_name}' (non-fatal): ${err.message}`);
|
|
@@ -24542,18 +24739,18 @@ async function processAgent(agent, agentStates, managedToolkits) {
|
|
|
24542
24739
|
if (agentSessionMode === "persistent" && (agentFrameworkCache.get(agent.code_name) ?? DEFAULT_FRAMEWORK) === "claude-code") {
|
|
24543
24740
|
try {
|
|
24544
24741
|
const agentProvisionDir = agentDir;
|
|
24545
|
-
const projectDir =
|
|
24742
|
+
const projectDir = join49(homedir18(), ".augmented", agent.code_name, "project");
|
|
24546
24743
|
mkdirSync18(agentProvisionDir, { recursive: true });
|
|
24547
24744
|
mkdirSync18(projectDir, { recursive: true });
|
|
24548
|
-
const provisionMcpPath =
|
|
24549
|
-
const projectMcpPath =
|
|
24745
|
+
const provisionMcpPath = join49(agentProvisionDir, ".mcp.json");
|
|
24746
|
+
const projectMcpPath = join49(projectDir, ".mcp.json");
|
|
24550
24747
|
let mcpConfig = { mcpServers: {} };
|
|
24551
24748
|
try {
|
|
24552
24749
|
mcpConfig = JSON.parse(readFileSync39(provisionMcpPath, "utf-8"));
|
|
24553
24750
|
if (!mcpConfig.mcpServers) mcpConfig.mcpServers = {};
|
|
24554
24751
|
} catch {
|
|
24555
24752
|
}
|
|
24556
|
-
const localDirectChatChannel =
|
|
24753
|
+
const localDirectChatChannel = join49(homedir18(), ".augmented", "_mcp", "direct-chat-channel.js");
|
|
24557
24754
|
const directChatTeamSettings = refreshData.team?.settings;
|
|
24558
24755
|
const directChatTz = (() => {
|
|
24559
24756
|
const tz = directChatTeamSettings?.["timezone"];
|
|
@@ -24579,7 +24776,7 @@ async function processAgent(agent, agentStates, managedToolkits) {
|
|
|
24579
24776
|
// ~/.augmented/<codeName>/.current-turn-initiator.json. Note getAgentDir
|
|
24580
24777
|
// returns the agent root (NOT the /provision subdir `agentDir` points at),
|
|
24581
24778
|
// so it byte-matches the broker readers' path.
|
|
24582
|
-
AGT_TURN_INITIATOR_FILE:
|
|
24779
|
+
AGT_TURN_INITIATOR_FILE: join49(
|
|
24583
24780
|
frameworkAdapter.getAgentDir(agent.code_name),
|
|
24584
24781
|
".current-turn-initiator.json"
|
|
24585
24782
|
)
|
|
@@ -24599,7 +24796,7 @@ async function processAgent(agent, agentStates, managedToolkits) {
|
|
|
24599
24796
|
log(`Channel credentials written for '${agent.code_name}/direct-chat'`);
|
|
24600
24797
|
}
|
|
24601
24798
|
}
|
|
24602
|
-
const staleChannelsPath =
|
|
24799
|
+
const staleChannelsPath = join49(projectDir, ".mcp-channels.json");
|
|
24603
24800
|
if (existsSync20(staleChannelsPath)) {
|
|
24604
24801
|
try {
|
|
24605
24802
|
rmSync9(staleChannelsPath, { force: true });
|
|
@@ -24727,7 +24924,7 @@ async function processAgent(agent, agentStates, managedToolkits) {
|
|
|
24727
24924
|
}
|
|
24728
24925
|
if (hostFlagStore().getBoolean("connectivity-probe")) {
|
|
24729
24926
|
try {
|
|
24730
|
-
const probeProjectDir =
|
|
24927
|
+
const probeProjectDir = join49(homedir18(), ".augmented", agent.code_name, "project");
|
|
24731
24928
|
let probeSet = integrations;
|
|
24732
24929
|
const fetchQuarantined = async () => {
|
|
24733
24930
|
const quarantined = await api.post("/host/agent-integrations/quarantined", { agent_id: agent.agent_id });
|
|
@@ -24789,7 +24986,7 @@ async function processAgent(agent, agentStates, managedToolkits) {
|
|
|
24789
24986
|
const forceDue = attemptsLeft > 0;
|
|
24790
24987
|
let probeRan = false;
|
|
24791
24988
|
try {
|
|
24792
|
-
const probeProjectDir =
|
|
24989
|
+
const probeProjectDir = join49(homedir18(), ".augmented", agent.code_name, "project");
|
|
24793
24990
|
const renderPending = integrationRenderPending(
|
|
24794
24991
|
integrations,
|
|
24795
24992
|
agentState.knownIntegrationHashes.get(agent.agent_id)
|
|
@@ -24918,8 +25115,8 @@ async function processAgent(agent, agentStates, managedToolkits) {
|
|
|
24918
25115
|
const intHash = computeIntegrationsHash(integrations);
|
|
24919
25116
|
const prevIntHash = agentState.knownIntegrationHashes.get(agent.agent_id);
|
|
24920
25117
|
if (intHash !== prevIntHash) {
|
|
24921
|
-
const projectDir =
|
|
24922
|
-
const envIntPath =
|
|
25118
|
+
const projectDir = join49(homedir18(), ".augmented", agent.code_name, "project");
|
|
25119
|
+
const envIntPath = join49(projectDir, ".env.integrations");
|
|
24923
25120
|
let preWriteEnv;
|
|
24924
25121
|
try {
|
|
24925
25122
|
preWriteEnv = readFileSync39(envIntPath, "utf-8");
|
|
@@ -24950,7 +25147,7 @@ async function processAgent(agent, agentStates, managedToolkits) {
|
|
|
24950
25147
|
}
|
|
24951
25148
|
if (fw === "claude-code" && isSessionHealthy(agent.code_name)) {
|
|
24952
25149
|
try {
|
|
24953
|
-
const projectMcpPath =
|
|
25150
|
+
const projectMcpPath = join49(projectDir, ".mcp.json");
|
|
24954
25151
|
const postWriteEnv = readFileSync39(envIntPath, "utf-8");
|
|
24955
25152
|
const mcpContent = readFileSync39(projectMcpPath, "utf-8");
|
|
24956
25153
|
const changedVars = diffEnvIntegrations(preWriteEnv, postWriteEnv);
|
|
@@ -25305,16 +25502,16 @@ async function processAgent(agent, agentStates, managedToolkits) {
|
|
|
25305
25502
|
}
|
|
25306
25503
|
try {
|
|
25307
25504
|
const { readdirSync: readdirSync16, rmSync: rmSync10 } = await import("fs");
|
|
25308
|
-
const { homedir:
|
|
25505
|
+
const { homedir: homedir19 } = await import("os");
|
|
25309
25506
|
const frameworkId2 = frameworkAdapter.id;
|
|
25310
25507
|
const candidateSkillDirs = [
|
|
25311
25508
|
// Claude Code — framework runtime tree
|
|
25312
|
-
|
|
25509
|
+
join49(homedir19(), ".augmented", agent.code_name, "skills"),
|
|
25313
25510
|
// Claude Code — project tree
|
|
25314
|
-
|
|
25511
|
+
join49(homedir19(), ".augmented", agent.code_name, "project", ".claude", "skills"),
|
|
25315
25512
|
// Defensive: legacy provision-side path, not currently an
|
|
25316
25513
|
// install target but cheap to sweep.
|
|
25317
|
-
|
|
25514
|
+
join49(agentDir, ".claude", "skills")
|
|
25318
25515
|
];
|
|
25319
25516
|
const existingDirs = candidateSkillDirs.filter((d) => existsSync20(d));
|
|
25320
25517
|
const discoveredEntries = /* @__PURE__ */ new Set();
|
|
@@ -25357,7 +25554,7 @@ async function processAgent(agent, agentStates, managedToolkits) {
|
|
|
25357
25554
|
const sharedSkillsPayload = refreshAny.shared_skills;
|
|
25358
25555
|
const desiredResolved = globalSkillsPayload !== void 0 || sharedSkillsPayload !== void 0;
|
|
25359
25556
|
const manifestPath = managedSkillManifestPath(
|
|
25360
|
-
|
|
25557
|
+
join49(homedir18(), ".augmented", agent.code_name)
|
|
25361
25558
|
);
|
|
25362
25559
|
const prevIds = /* @__PURE__ */ new Set([
|
|
25363
25560
|
...agentState.knownGlobalSkillIds.get(agent.agent_id) ?? /* @__PURE__ */ new Set(),
|
|
@@ -25377,15 +25574,15 @@ async function processAgent(agent, agentStates, managedToolkits) {
|
|
|
25377
25574
|
}
|
|
25378
25575
|
if (plan.removes.length) {
|
|
25379
25576
|
const globalSkillDirs = [
|
|
25380
|
-
|
|
25381
|
-
|
|
25382
|
-
|
|
25577
|
+
join49(homedir18(), ".augmented", agent.code_name, "skills"),
|
|
25578
|
+
join49(homedir18(), ".augmented", agent.code_name, "project", ".claude", "skills"),
|
|
25579
|
+
join49(agentDir, ".claude", "skills")
|
|
25383
25580
|
];
|
|
25384
25581
|
for (const id of plan.removes) {
|
|
25385
25582
|
let prunedAny = false;
|
|
25386
25583
|
for (const dir of globalSkillDirs) {
|
|
25387
|
-
const p =
|
|
25388
|
-
if (existsSync20(p) && existsSync20(
|
|
25584
|
+
const p = join49(dir, id);
|
|
25585
|
+
if (existsSync20(p) && existsSync20(join49(p, "SKILL.md"))) {
|
|
25389
25586
|
rmSync9(p, { recursive: true, force: true });
|
|
25390
25587
|
prunedAny = true;
|
|
25391
25588
|
}
|
|
@@ -26178,7 +26375,7 @@ Retried to the limit after repeated stalls \u2014 needs a look.`).catch(() => {
|
|
|
26178
26375
|
if (trackedFiles.length > 0 && existsSync20(agentDir)) {
|
|
26179
26376
|
const hashes = /* @__PURE__ */ new Map();
|
|
26180
26377
|
for (const file of trackedFiles) {
|
|
26181
|
-
const h = hashFile(
|
|
26378
|
+
const h = hashFile(join49(agentDir, file));
|
|
26182
26379
|
if (h) hashes.set(file, h);
|
|
26183
26380
|
}
|
|
26184
26381
|
agentState.writtenHashes.set(agent.agent_id, hashes);
|
|
@@ -26193,7 +26390,7 @@ Retried to the limit after repeated stalls \u2014 needs a look.`).catch(() => {
|
|
|
26193
26390
|
refreshData.agent.onboarding_state
|
|
26194
26391
|
);
|
|
26195
26392
|
const obStep = obState.step;
|
|
26196
|
-
const markerPath =
|
|
26393
|
+
const markerPath = join49(homedir18(), ".augmented", agent.code_name, "onboarding-drive.json");
|
|
26197
26394
|
const marker = readOnboardingDriveMarker(markerPath);
|
|
26198
26395
|
const obContactRaw = refreshData.agent.manager_last_contacted_at;
|
|
26199
26396
|
const obContact = typeof obContactRaw === "string" && obContactRaw ? obContactRaw : null;
|
|
@@ -26327,7 +26524,7 @@ async function ensureOpencodeRuntime(agent, refreshData, agentTimezone) {
|
|
|
26327
26524
|
}
|
|
26328
26525
|
stopOpencodeSlackIngest(codeName, log);
|
|
26329
26526
|
stopOpencodeTelegramIngest(codeName, log);
|
|
26330
|
-
const opencodeProjectDir =
|
|
26527
|
+
const opencodeProjectDir = join49(getFramework("opencode").getAgentDir(codeName), "provision");
|
|
26331
26528
|
const serveEnv = {
|
|
26332
26529
|
AGT_HOST: requireHost(),
|
|
26333
26530
|
AGT_API_KEY: getApiKey() ?? void 0,
|
|
@@ -26436,8 +26633,8 @@ async function ensurePersistentSessionUnchecked(agent, tasks, boardItems, refres
|
|
|
26436
26633
|
});
|
|
26437
26634
|
}
|
|
26438
26635
|
const projectDir = getProjectDir(codeName);
|
|
26439
|
-
const mcpConfigPath =
|
|
26440
|
-
const claudeMdPath =
|
|
26636
|
+
const mcpConfigPath = join49(projectDir, ".mcp.json");
|
|
26637
|
+
const claudeMdPath = join49(projectDir, "CLAUDE.md");
|
|
26441
26638
|
if (restartBreaker.isTripped(codeName)) {
|
|
26442
26639
|
const trip = restartBreaker.getTrip(codeName);
|
|
26443
26640
|
return {
|
|
@@ -27560,7 +27757,7 @@ async function managerRestartMayKill(agentId, codeName, requestedAt, lane, frame
|
|
|
27560
27757
|
);
|
|
27561
27758
|
}
|
|
27562
27759
|
if (verdict.kill && effectiveIsolationMode(codeName) !== "docker") {
|
|
27563
|
-
const dc = readDirectChatInflight(
|
|
27760
|
+
const dc = readDirectChatInflight(join49(homedir18(), ".augmented", agentId));
|
|
27564
27761
|
if (dc.inFlight) {
|
|
27565
27762
|
verdict = { kill: false, reason: "direct_chat_in_flight", runningBackgroundTasks: null };
|
|
27566
27763
|
log(`[${lane}] manager restart for '${codeName}': ${dc.ids.length} Direct Chat message(s) claimed and not yet answered [ENG-12100]`);
|
|
@@ -27638,7 +27835,7 @@ async function handleRestartDoorbell(agentId, requestedAt, restartReason) {
|
|
|
27638
27835
|
if (!refreshData) return;
|
|
27639
27836
|
const framework = refreshData.agent?.framework ?? agentFrameworkCache.get(codeName) ?? DEFAULT_FRAMEWORK;
|
|
27640
27837
|
const hostId = await getHostId();
|
|
27641
|
-
const parkForRestart = await import("../responsiveness-probe-
|
|
27838
|
+
const parkForRestart = await import("../responsiveness-probe-SDVMWEM3.js").then(
|
|
27642
27839
|
(m) => m.parkPendingInbound,
|
|
27643
27840
|
(err) => err
|
|
27644
27841
|
);
|
|
@@ -27719,10 +27916,10 @@ async function handleRestartDoorbell(agentId, requestedAt, restartReason) {
|
|
|
27719
27916
|
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}`));
|
|
27720
27917
|
void (async () => {
|
|
27721
27918
|
try {
|
|
27722
|
-
const { collectDiagnostics } = await import("../persistent-session-
|
|
27919
|
+
const { collectDiagnostics } = await import("../persistent-session-4AGRIK5W.js");
|
|
27723
27920
|
await api.post("/host/heartbeat", {
|
|
27724
27921
|
host_id: hostId,
|
|
27725
|
-
agent_diagnostics: collectDiagnostics([codeName], quarantineEntriesFor, claudeMdSizeFor, spawnOutcomeForDiagnostics, pidPressureFor, forwardedToolsFor, runtimeVersionFor, sessionActivityFor)
|
|
27922
|
+
agent_diagnostics: collectDiagnostics([codeName], quarantineEntriesFor, claudeMdSizeFor, spawnOutcomeForDiagnostics, pidPressureFor, forwardedToolsFor, runtimeVersionFor, sessionActivityFor, agentDiskFor)
|
|
27726
27923
|
});
|
|
27727
27924
|
} catch (err) {
|
|
27728
27925
|
log(`[restart-lane] post-respawn diagnostics flush failed for '${codeName}': ${err.message}`);
|
|
@@ -27772,10 +27969,10 @@ async function respawnAgentAfterMcpStop(codeName, reason) {
|
|
|
27772
27969
|
}
|
|
27773
27970
|
try {
|
|
27774
27971
|
const hostId = await getHostId();
|
|
27775
|
-
const { collectDiagnostics } = await import("../persistent-session-
|
|
27972
|
+
const { collectDiagnostics } = await import("../persistent-session-4AGRIK5W.js");
|
|
27776
27973
|
await api.post("/host/heartbeat", {
|
|
27777
27974
|
host_id: hostId,
|
|
27778
|
-
agent_diagnostics: collectDiagnostics([codeName], quarantineEntriesFor, claudeMdSizeFor, spawnOutcomeForDiagnostics, pidPressureFor, forwardedToolsFor, runtimeVersionFor, sessionActivityFor)
|
|
27975
|
+
agent_diagnostics: collectDiagnostics([codeName], quarantineEntriesFor, claudeMdSizeFor, spawnOutcomeForDiagnostics, pidPressureFor, forwardedToolsFor, runtimeVersionFor, sessionActivityFor, agentDiskFor)
|
|
27779
27976
|
});
|
|
27780
27977
|
} catch (err) {
|
|
27781
27978
|
log(`[fast-mcp-respawn] post-respawn diagnostics flush failed for '${codeName}': ${err.message}`);
|
|
@@ -28326,7 +28523,7 @@ async function processDirectChatMessage(agent, msg) {
|
|
|
28326
28523
|
});
|
|
28327
28524
|
if (route.kind === "ring") {
|
|
28328
28525
|
try {
|
|
28329
|
-
const doorbell = directChatDoorbellPath(agent.agentId,
|
|
28526
|
+
const doorbell = directChatDoorbellPath(agent.agentId, homedir18());
|
|
28330
28527
|
mkdirSync18(dirname11(doorbell), { recursive: true });
|
|
28331
28528
|
writeFileSync20(doorbell, String(Date.now()));
|
|
28332
28529
|
log(`[direct-chat] Doorbell rung for '${agent.codeName}' (msg=${msg.id}) \u2014 in-session MCP will pull via the cursor`);
|
|
@@ -28486,7 +28683,7 @@ ${formatRunMarker(run_id)}` : KANBAN_CHECK_COMMAND;
|
|
|
28486
28683
|
}
|
|
28487
28684
|
if (run_id) openInjectedRunByCode.set(codeName, run_id);
|
|
28488
28685
|
try {
|
|
28489
|
-
const doorbell = directChatDoorbellPath(agentId,
|
|
28686
|
+
const doorbell = directChatDoorbellPath(agentId, homedir18());
|
|
28490
28687
|
mkdirSync18(dirname11(doorbell), { recursive: true });
|
|
28491
28688
|
writeFileSync20(doorbell, String(Date.now()));
|
|
28492
28689
|
} catch (err) {
|
|
@@ -28648,7 +28845,7 @@ async function processClaudePairSessions(agents) {
|
|
|
28648
28845
|
snapshotPairConfig,
|
|
28649
28846
|
// ENG-11659: result -> report body + the manager.log line that records it.
|
|
28650
28847
|
planPairStartReport
|
|
28651
|
-
} = await import("../claude-pair-runtime-
|
|
28848
|
+
} = await import("../claude-pair-runtime-DGLYU2HX.js");
|
|
28652
28849
|
const { resetClaudeSignin, describeSigninResetForLog, describeSigninResetFailure } = await import("../claude-signin-reset-6IJMMVYG.js");
|
|
28653
28850
|
for (const pairId of pendingResp.cancelled_pair_ids ?? []) {
|
|
28654
28851
|
log(`[claude-pair] sweeping orphan tmux session for pair ${pairId.slice(0, 8)}`);
|
|
@@ -28947,10 +29144,10 @@ var lastLocalFileHash = /* @__PURE__ */ new Map();
|
|
|
28947
29144
|
var lastMemoriesBody = /* @__PURE__ */ new Map();
|
|
28948
29145
|
var memoryManifests = /* @__PURE__ */ new Map();
|
|
28949
29146
|
function memoryRetirementDir(configDir, codeName) {
|
|
28950
|
-
return
|
|
29147
|
+
return join49(configDir, "_memory-retirement", codeName);
|
|
28951
29148
|
}
|
|
28952
29149
|
function memoryManifestPath(configDir, codeName) {
|
|
28953
|
-
return
|
|
29150
|
+
return join49(memoryRetirementDir(configDir, codeName), "manifest.json");
|
|
28954
29151
|
}
|
|
28955
29152
|
function loadMemoryManifest(agentId, configDir, codeName) {
|
|
28956
29153
|
const cached = memoryManifests.get(agentId);
|
|
@@ -28985,7 +29182,7 @@ function saveMemoryManifest(agentId, configDir, codeName) {
|
|
|
28985
29182
|
}
|
|
28986
29183
|
}
|
|
28987
29184
|
function retiredMemoryDir(configDir, codeName) {
|
|
28988
|
-
return
|
|
29185
|
+
return join49(memoryRetirementDir(configDir, codeName), "retired");
|
|
28989
29186
|
}
|
|
28990
29187
|
var RETIRED_MEMORY_TTL_MS = 30 * 24 * 60 * 60 * 1e3;
|
|
28991
29188
|
var lastRetirementReport = /* @__PURE__ */ new Map();
|
|
@@ -29064,7 +29261,7 @@ function applyMemoryTombstones(opts) {
|
|
|
29064
29261
|
log2(`[memory-retire] ${agent.code_name}: KEPT '${tomb.name}' \u2014 no write record, not ours to remove`);
|
|
29065
29262
|
continue;
|
|
29066
29263
|
}
|
|
29067
|
-
const filePath =
|
|
29264
|
+
const filePath = join49(memoryDir, entry.file);
|
|
29068
29265
|
if (!existsSync20(filePath)) {
|
|
29069
29266
|
outcomes.already_gone++;
|
|
29070
29267
|
delete manifest[tomb.name];
|
|
@@ -29084,9 +29281,9 @@ function applyMemoryTombstones(opts) {
|
|
|
29084
29281
|
const destDir = retiredMemoryDir(configDir, agent.code_name);
|
|
29085
29282
|
mkdirSync18(destDir, { recursive: true });
|
|
29086
29283
|
const stamp = Date.now();
|
|
29087
|
-
let dest =
|
|
29284
|
+
let dest = join49(destDir, `${entry.file}.${stamp}.retired`);
|
|
29088
29285
|
for (let n = 1; existsSync20(dest); n++) {
|
|
29089
|
-
dest =
|
|
29286
|
+
dest = join49(destDir, `${entry.file}.${stamp}-${n}.retired`);
|
|
29090
29287
|
}
|
|
29091
29288
|
renameSync12(filePath, dest);
|
|
29092
29289
|
try {
|
|
@@ -29125,7 +29322,7 @@ function reapRetiredMemories(configDir, codeName, log2) {
|
|
|
29125
29322
|
try {
|
|
29126
29323
|
for (const file of readdirSync15(dir)) {
|
|
29127
29324
|
if (!file.endsWith(".retired")) continue;
|
|
29128
|
-
const path =
|
|
29325
|
+
const path = join49(dir, file);
|
|
29129
29326
|
try {
|
|
29130
29327
|
if (statSync15(path).mtimeMs < cutoff) {
|
|
29131
29328
|
unlinkSync6(path);
|
|
@@ -29140,8 +29337,8 @@ function reapRetiredMemories(configDir, codeName, log2) {
|
|
|
29140
29337
|
if (reaped > 0) log2(`[memory-retire] ${codeName}: reaped ${reaped} retired memory file(s) past TTL`);
|
|
29141
29338
|
}
|
|
29142
29339
|
async function syncMemories(agent, configDir, log2) {
|
|
29143
|
-
const projectDir =
|
|
29144
|
-
const memoryDir =
|
|
29340
|
+
const projectDir = join49(configDir, agent.code_name, "project");
|
|
29341
|
+
const memoryDir = join49(projectDir, "memory");
|
|
29145
29342
|
const isFreshSync = pendingFreshMemorySync.has(agent.agent_id);
|
|
29146
29343
|
if (isFreshSync) {
|
|
29147
29344
|
log2(`[memory-sync] Fresh-sync requested for '${agent.code_name}' \u2014 pulling DB first`);
|
|
@@ -29172,7 +29369,7 @@ async function syncMemories(agent, configDir, log2) {
|
|
|
29172
29369
|
for (const file of readdirSync15(memoryDir)) {
|
|
29173
29370
|
if (!file.endsWith(".md")) continue;
|
|
29174
29371
|
try {
|
|
29175
|
-
const raw = readFileSync39(
|
|
29372
|
+
const raw = readFileSync39(join49(memoryDir, file), "utf-8");
|
|
29176
29373
|
const fileHash = createHash21("sha256").update(raw).digest("hex").slice(0, 16);
|
|
29177
29374
|
currentHashes.set(file, fileHash);
|
|
29178
29375
|
if (prevHashes.get(file) === fileHash) continue;
|
|
@@ -29197,7 +29394,7 @@ async function syncMemories(agent, configDir, log2) {
|
|
|
29197
29394
|
} catch (err) {
|
|
29198
29395
|
for (const mem of changedMemories) {
|
|
29199
29396
|
for (const [file] of currentHashes) {
|
|
29200
|
-
const parsed = parseMemoryFile(readFileSync39(
|
|
29397
|
+
const parsed = parseMemoryFile(readFileSync39(join49(memoryDir, file), "utf-8"), file.replace(/\.md$/, ""));
|
|
29201
29398
|
if (parsed?.name === mem.name) currentHashes.delete(file);
|
|
29202
29399
|
}
|
|
29203
29400
|
}
|
|
@@ -29278,7 +29475,7 @@ async function downloadMemories(agent, memoryDir, log2, { force, configDir }) {
|
|
|
29278
29475
|
// Per-agent, not host-wide: memories are agent-private, so a shared
|
|
29279
29476
|
// store would buy almost no dedupe while exposing one agent's content
|
|
29280
29477
|
// to every other agent on the host. See memory-cache.ts's header.
|
|
29281
|
-
cacheDir:
|
|
29478
|
+
cacheDir: join49(configDir, agent.code_name, "_memory_bodies"),
|
|
29282
29479
|
fetchContents: async (hashes) => {
|
|
29283
29480
|
const res = await api.post(
|
|
29284
29481
|
"/host/memories/contents",
|
|
@@ -29316,7 +29513,7 @@ async function downloadMemories(agent, memoryDir, log2, { force, configDir }) {
|
|
|
29316
29513
|
const rawSlug = mem.name.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/(^-|-$)/g, "").slice(0, 60);
|
|
29317
29514
|
const slug = rawSlug || `memory-${i}`;
|
|
29318
29515
|
const fileName = `${slug}.md`;
|
|
29319
|
-
const filePath =
|
|
29516
|
+
const filePath = join49(memoryDir, fileName);
|
|
29320
29517
|
const desired = `---
|
|
29321
29518
|
name: ${JSON.stringify(mem.name)}
|
|
29322
29519
|
type: ${mem.type}
|
|
@@ -29503,6 +29700,13 @@ function startPolling() {
|
|
|
29503
29700
|
claudePairLoop.start();
|
|
29504
29701
|
startPaneOccupancySampler(() => agentState.persistentSessionAgents);
|
|
29505
29702
|
startPidPressureSampler(() => agentState.persistentSessionAgents);
|
|
29703
|
+
startAgentDiskSampler(
|
|
29704
|
+
() => [...agentState.persistentSessionAgents].map((codeName) => ({
|
|
29705
|
+
codeName,
|
|
29706
|
+
agentId: agentState.codeNameToAgentId.get(codeName) ?? null,
|
|
29707
|
+
isolated: effectiveIsolationMode(codeName) === "docker"
|
|
29708
|
+
}))
|
|
29709
|
+
);
|
|
29506
29710
|
startRuntimeVersionSampler(() => agentState.persistentSessionAgents);
|
|
29507
29711
|
{
|
|
29508
29712
|
const seedOutcome = seedClaudeConfigFromLegacy({ log });
|
|
@@ -29683,6 +29887,7 @@ async function stopPolling(opts = {}) {
|
|
|
29683
29887
|
clearTimeout(pollTimer);
|
|
29684
29888
|
pollTimer = null;
|
|
29685
29889
|
}
|
|
29890
|
+
stopAgentDiskSampler();
|
|
29686
29891
|
if (livenessTimer) {
|
|
29687
29892
|
clearInterval(livenessTimer);
|
|
29688
29893
|
livenessTimer = null;
|
|
@@ -29788,7 +29993,7 @@ function startManager(opts) {
|
|
|
29788
29993
|
log(`[startup] state rehydration failed (continuing with empty state): ${err.message}`);
|
|
29789
29994
|
}
|
|
29790
29995
|
log(
|
|
29791
|
-
`[startup] worker pid=${process.pid} ppid=${process.ppid} node=${process.version} log=${
|
|
29996
|
+
`[startup] worker pid=${process.pid} ppid=${process.ppid} node=${process.version} log=${join49(homedir18(), ".augmented", "manager.log")}`
|
|
29792
29997
|
);
|
|
29793
29998
|
deployMcpAssets();
|
|
29794
29999
|
reapOrphanChannelMcps({ log });
|
|
@@ -29914,14 +30119,14 @@ function restartRunningChannelMcps(basenames) {
|
|
|
29914
30119
|
}
|
|
29915
30120
|
}
|
|
29916
30121
|
function deployMcpAssets() {
|
|
29917
|
-
const targetDir =
|
|
30122
|
+
const targetDir = join49(homedir18(), ".augmented", "_mcp");
|
|
29918
30123
|
mkdirSync18(targetDir, { recursive: true });
|
|
29919
30124
|
const moduleDir = dirname11(fileURLToPath2(import.meta.url));
|
|
29920
30125
|
let mcpSourceDir = "";
|
|
29921
30126
|
let dir = moduleDir;
|
|
29922
30127
|
for (let i = 0; i < 6; i++) {
|
|
29923
|
-
const candidate =
|
|
29924
|
-
if (existsSync20(
|
|
30128
|
+
const candidate = join49(dir, "dist", "mcp");
|
|
30129
|
+
if (existsSync20(join49(candidate, "index.js"))) {
|
|
29925
30130
|
mcpSourceDir = candidate;
|
|
29926
30131
|
break;
|
|
29927
30132
|
}
|
|
@@ -30021,8 +30226,8 @@ function deployMcpAssets() {
|
|
|
30021
30226
|
// natural session restart.
|
|
30022
30227
|
"computer-use-proxy.js"
|
|
30023
30228
|
]) {
|
|
30024
|
-
const src =
|
|
30025
|
-
const dst =
|
|
30229
|
+
const src = join49(mcpSourceDir, file);
|
|
30230
|
+
const dst = join49(targetDir, file);
|
|
30026
30231
|
if (!existsSync20(src)) continue;
|
|
30027
30232
|
attemptedFiles.push(file);
|
|
30028
30233
|
const before = fileHash(dst);
|
|
@@ -30048,14 +30253,14 @@ function deployMcpAssets() {
|
|
|
30048
30253
|
log(`[manager] Bundle(s) updated: ${changedBasenames.join(", ")} \u2014 signalling running instances to restart`);
|
|
30049
30254
|
restartRunningChannelMcps(changedBasenames);
|
|
30050
30255
|
}
|
|
30051
|
-
const localMcpPath =
|
|
30256
|
+
const localMcpPath = join49(targetDir, "index.js");
|
|
30052
30257
|
try {
|
|
30053
|
-
const agentsDir =
|
|
30258
|
+
const agentsDir = join49(homedir18(), ".augmented", "agents");
|
|
30054
30259
|
if (existsSync20(agentsDir)) {
|
|
30055
30260
|
for (const entry of readdirSync15(agentsDir, { withFileTypes: true })) {
|
|
30056
30261
|
if (!entry.isDirectory()) continue;
|
|
30057
30262
|
for (const subdir of ["provision", "project"]) {
|
|
30058
|
-
const mcpJsonPath =
|
|
30263
|
+
const mcpJsonPath = join49(agentsDir, entry.name, subdir, ".mcp.json");
|
|
30059
30264
|
try {
|
|
30060
30265
|
const raw = readFileSync39(mcpJsonPath, "utf-8");
|
|
30061
30266
|
if (!raw.includes("@integrity-labs/augmented-mcp")) continue;
|