@integrity-labs/agt-cli 0.28.1318 → 0.28.1320
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-ZCSKN3SJ.js} +3 -3
- package/dist/bin/agt.js +7 -7
- package/dist/{chunk-AABYEBCU.js → chunk-2F4EHNRQ.js} +10 -6
- package/dist/chunk-2F4EHNRQ.js.map +1 -0
- 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-ZA34ZZCC.js} +3 -3
- package/dist/{chunk-KJNJNMRY.js → chunk-ZDO57BCK.js} +5 -5
- package/dist/{claude-code-updater-BIBCDTQX.js → claude-code-updater-E5QX33MA.js} +3 -3
- package/dist/{claude-pair-runtime-OR72T4SI.js → claude-pair-runtime-5EGI66ET.js} +3 -3
- package/dist/lib/manager-worker.js +445 -218
- 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-XFZ43IDB.js} +4 -4
- package/dist/{responsiveness-probe-MJOASK7A.js → responsiveness-probe-EJJNNPNB.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-ZCSKN3SJ.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-ZA34ZZCC.js.map} +0 -0
- /package/dist/{chunk-KJNJNMRY.js.map → chunk-ZDO57BCK.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-5EGI66ET.js.map} +0 -0
- /package/dist/{persistent-session-PZI32TLO.js.map → persistent-session-XFZ43IDB.js.map} +0 -0
- /package/dist/{responsiveness-probe-MJOASK7A.js.map → responsiveness-probe-EJJNNPNB.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-ZDO57BCK.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-ZA34ZZCC.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-2F4EHNRQ.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
|
}
|
|
@@ -5829,6 +5829,23 @@ function staleGrantReason(currentGrantId) {
|
|
|
5829
5829
|
function singleStartLaunchAllowed(hold, grantId) {
|
|
5830
5830
|
return !(hold.wasHeld() && !hold.grantIsCurrent(grantId));
|
|
5831
5831
|
}
|
|
5832
|
+
var WINDOW_OPENED_DURING_BOOTSTRAP_REASON = "held: the host Claude login refresh window opened during the bootstrap, before the launch (ENG-12379)";
|
|
5833
|
+
function deferredLaunchFence(opts) {
|
|
5834
|
+
const { hold, grantId } = opts;
|
|
5835
|
+
if (opts.grantedSingleStart) {
|
|
5836
|
+
return {
|
|
5837
|
+
launchStillAllowed: () => singleStartLaunchAllowed(hold, grantId),
|
|
5838
|
+
fencedReason: () => staleGrantReason(hold.currentGrantId())
|
|
5839
|
+
};
|
|
5840
|
+
}
|
|
5841
|
+
if (opts.subscriptionBacked === true) {
|
|
5842
|
+
return {
|
|
5843
|
+
launchStillAllowed: () => !hold.wasInWindow(),
|
|
5844
|
+
fencedReason: () => WINDOW_OPENED_DURING_BOOTSTRAP_REASON
|
|
5845
|
+
};
|
|
5846
|
+
}
|
|
5847
|
+
return {};
|
|
5848
|
+
}
|
|
5832
5849
|
|
|
5833
5850
|
// src/lib/manager/host-auth-refresh-hold.ts
|
|
5834
5851
|
async function readHostExpiresAtMs() {
|
|
@@ -8974,22 +8991,22 @@ function initialCursor(args) {
|
|
|
8974
8991
|
transcriptRelPath: args.transcriptRelPath
|
|
8975
8992
|
};
|
|
8976
8993
|
}
|
|
8977
|
-
function coverageRowFor(key,
|
|
8994
|
+
function coverageRowFor(key, cursor2, versions) {
|
|
8978
8995
|
const { sessionId, transcriptRef } = parseCursorKey(key);
|
|
8979
8996
|
return {
|
|
8980
8997
|
session_id: sessionId,
|
|
8981
8998
|
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:
|
|
8999
|
+
transcript_rel_path: cursor2.transcriptRelPath,
|
|
9000
|
+
through_line: cursor2.scannedThroughLine,
|
|
9001
|
+
through_byte: cursor2.scannedThroughByte,
|
|
9002
|
+
started_from_line: cursor2.startedFromLine,
|
|
9003
|
+
started_from_byte: cursor2.startedFromByte,
|
|
9004
|
+
scan_position_byte: cursor2.byteOffset,
|
|
9005
|
+
scan_position_line: cursor2.lineOffset,
|
|
9006
|
+
scan_window_truncated: cursor2.lastWindowTruncated,
|
|
9007
|
+
rewind_generation: cursor2.rewindGeneration,
|
|
9008
|
+
calls_extracted: cursor2.callsExtracted,
|
|
9009
|
+
last_disposition: cursor2.lastDisposition,
|
|
8993
9010
|
extractor_version: versions.extractor,
|
|
8994
9011
|
redaction_rule_version: versions.redaction
|
|
8995
9012
|
};
|
|
@@ -9061,17 +9078,17 @@ async function scanAgentToolCalls(args) {
|
|
|
9061
9078
|
}
|
|
9062
9079
|
const touched = [];
|
|
9063
9080
|
for (const { key, file } of files) {
|
|
9064
|
-
let
|
|
9065
|
-
if (!
|
|
9081
|
+
let cursor2 = cursors.get(key);
|
|
9082
|
+
if (!cursor2) {
|
|
9066
9083
|
const end = endOfFile(file.absPath);
|
|
9067
9084
|
if (!end) continue;
|
|
9068
|
-
|
|
9085
|
+
cursor2 = initialCursor({
|
|
9069
9086
|
startByte: args.backfill ? 0 : end.byteOffset,
|
|
9070
9087
|
startLine: 0,
|
|
9071
9088
|
transcriptRelPath: file.relPath,
|
|
9072
9089
|
nowMs: now()
|
|
9073
9090
|
});
|
|
9074
|
-
cursors.set(key,
|
|
9091
|
+
cursors.set(key, cursor2);
|
|
9075
9092
|
touched.push(key);
|
|
9076
9093
|
if (!args.backfill && end.byteOffset > 0) {
|
|
9077
9094
|
log2(
|
|
@@ -9081,17 +9098,17 @@ async function scanAgentToolCalls(args) {
|
|
|
9081
9098
|
if (!args.backfill) continue;
|
|
9082
9099
|
}
|
|
9083
9100
|
const window = extractTranscriptWindow(file, extractOpts, {
|
|
9084
|
-
byteOffset:
|
|
9085
|
-
lineOffset:
|
|
9101
|
+
byteOffset: cursor2.byteOffset,
|
|
9102
|
+
lineOffset: cursor2.lineOffset,
|
|
9086
9103
|
// ENG-8832: carry the run scope across ticks. A marker arrives once, at
|
|
9087
9104
|
// the head of its run; without this every window after the first would
|
|
9088
9105
|
// report NULL and the attribution would silently evaporate.
|
|
9089
|
-
runScopeId:
|
|
9106
|
+
runScopeId: cursor2.runScopeId,
|
|
9090
9107
|
...args.windowBudgetBytes === void 0 ? {} : { budgetBytes: args.windowBudgetBytes }
|
|
9091
9108
|
});
|
|
9092
9109
|
summary.filesScanned += 1;
|
|
9093
9110
|
if (window.missing) {
|
|
9094
|
-
cursors.set(key, { ...
|
|
9111
|
+
cursors.set(key, { ...cursor2, lastDisposition: "transcript_missing", lastScanAt: new Date(now()).toISOString() });
|
|
9095
9112
|
touched.push(key);
|
|
9096
9113
|
continue;
|
|
9097
9114
|
}
|
|
@@ -9119,7 +9136,7 @@ async function scanAgentToolCalls(args) {
|
|
|
9119
9136
|
}
|
|
9120
9137
|
summary.callsIngested += ingested;
|
|
9121
9138
|
const computed = nextCursor({
|
|
9122
|
-
previous:
|
|
9139
|
+
previous: cursor2,
|
|
9123
9140
|
endByte: window.endByte,
|
|
9124
9141
|
endLine: window.endLine,
|
|
9125
9142
|
earliestUnpaired: window.unpaired[0] ?? null,
|
|
@@ -9130,11 +9147,11 @@ async function scanAgentToolCalls(args) {
|
|
|
9130
9147
|
rewound: window.rewound,
|
|
9131
9148
|
truncated: window.truncated
|
|
9132
9149
|
});
|
|
9133
|
-
const advanced = attempted ? computed : { ...computed, lastDisposition:
|
|
9134
|
-
if (advanced.byteOffset ===
|
|
9150
|
+
const advanced = attempted ? computed : { ...computed, lastDisposition: cursor2.lastDisposition };
|
|
9151
|
+
if (advanced.byteOffset === cursor2.byteOffset && outcome.kind === "ingest_failed") {
|
|
9135
9152
|
summary.filesHeld += 1;
|
|
9136
9153
|
log2(
|
|
9137
|
-
`[tool-call-scan] HOLDING cursor for ${file.relPath} ref=${file.ref} at byte ${
|
|
9154
|
+
`[tool-call-scan] HOLDING cursor for ${file.relPath} ref=${file.ref} at byte ${cursor2.byteOffset}: ${outcome.reason}`
|
|
9138
9155
|
);
|
|
9139
9156
|
}
|
|
9140
9157
|
cursors.set(key, advanced);
|
|
@@ -10142,19 +10159,19 @@ function createFetchGate(ttlMs) {
|
|
|
10142
10159
|
const lastFetchedAt = /* @__PURE__ */ new Map();
|
|
10143
10160
|
const forceCount = /* @__PURE__ */ new Map();
|
|
10144
10161
|
const consumedForceCount = /* @__PURE__ */ new Map();
|
|
10145
|
-
let
|
|
10162
|
+
let generation2 = 0;
|
|
10146
10163
|
const fetchedAtGeneration = /* @__PURE__ */ new Map();
|
|
10147
10164
|
const pendingForces = (key) => (forceCount.get(key) ?? 0) > (consumedForceCount.get(key) ?? 0);
|
|
10148
10165
|
return {
|
|
10149
10166
|
shouldFetch(key, now = Date.now()) {
|
|
10150
10167
|
if (pendingForces(key)) return true;
|
|
10151
|
-
if ((fetchedAtGeneration.get(key) ?? -1) <
|
|
10168
|
+
if ((fetchedAtGeneration.get(key) ?? -1) < generation2) return true;
|
|
10152
10169
|
const last = lastFetchedAt.get(key);
|
|
10153
10170
|
if (last === void 0) return true;
|
|
10154
10171
|
return now - last >= ttlMs;
|
|
10155
10172
|
},
|
|
10156
10173
|
beginFetch(key) {
|
|
10157
|
-
return { forceCount: forceCount.get(key) ?? 0, generation };
|
|
10174
|
+
return { forceCount: forceCount.get(key) ?? 0, generation: generation2 };
|
|
10158
10175
|
},
|
|
10159
10176
|
markFetched(key, token, now = Date.now()) {
|
|
10160
10177
|
lastFetchedAt.set(key, now);
|
|
@@ -10165,7 +10182,7 @@ function createFetchGate(ttlMs) {
|
|
|
10165
10182
|
forceCount.set(key, (forceCount.get(key) ?? 0) + 1);
|
|
10166
10183
|
},
|
|
10167
10184
|
forceAll() {
|
|
10168
|
-
|
|
10185
|
+
generation2 += 1;
|
|
10169
10186
|
},
|
|
10170
10187
|
forget(key) {
|
|
10171
10188
|
lastFetchedAt.delete(key);
|
|
@@ -14073,13 +14090,210 @@ function stopPidPressureSampler() {
|
|
|
14073
14090
|
timer2 = null;
|
|
14074
14091
|
}
|
|
14075
14092
|
|
|
14093
|
+
// src/lib/agent-disk-sampler.ts
|
|
14094
|
+
import { execFile as execFile2 } from "child_process";
|
|
14095
|
+
import { lstat, realpath, statfs } from "fs/promises";
|
|
14096
|
+
import { homedir as homedir16 } from "os";
|
|
14097
|
+
import { join as join45 } from "path";
|
|
14098
|
+
var DISK_SAMPLE_PERIOD_MS = 60 * 6e4;
|
|
14099
|
+
var MIN_TICK_MS = 6e4;
|
|
14100
|
+
var DU_TIMEOUT_MS = 12e4;
|
|
14101
|
+
var TOP_PATHS = 10;
|
|
14102
|
+
function parseDu(stdout, root) {
|
|
14103
|
+
let total = null;
|
|
14104
|
+
const entries = [];
|
|
14105
|
+
const rootNorm = root.replace(/\/+$/, "");
|
|
14106
|
+
for (const line of stdout.split("\n")) {
|
|
14107
|
+
const m = /^(\d+)\t(.+)$/.exec(line);
|
|
14108
|
+
if (!m) continue;
|
|
14109
|
+
const bytes = Number(m[1]) * 1024;
|
|
14110
|
+
const path = m[2].replace(/\/+$/, "");
|
|
14111
|
+
if (path === rootNorm) total = bytes;
|
|
14112
|
+
else if (path.startsWith(`${rootNorm}/`)) entries.push({ path: path.slice(rootNorm.length + 1), bytes });
|
|
14113
|
+
}
|
|
14114
|
+
return total === null ? null : { total, entries };
|
|
14115
|
+
}
|
|
14116
|
+
async function dirBytes(io, dir, left) {
|
|
14117
|
+
const k = await io.kind(dir);
|
|
14118
|
+
if (k === "missing") return 0;
|
|
14119
|
+
if (k !== "dir") return null;
|
|
14120
|
+
if (left() <= 0) return null;
|
|
14121
|
+
const r = await io.du(dir, 0, left());
|
|
14122
|
+
if (r.kind !== "ok") return null;
|
|
14123
|
+
return parseDu(r.stdout, dir)?.total ?? null;
|
|
14124
|
+
}
|
|
14125
|
+
function sumKnown(parts) {
|
|
14126
|
+
let total = 0;
|
|
14127
|
+
for (const p of parts) {
|
|
14128
|
+
if (p === null) return null;
|
|
14129
|
+
total += p;
|
|
14130
|
+
}
|
|
14131
|
+
return total;
|
|
14132
|
+
}
|
|
14133
|
+
function transcriptSlug(projectDir) {
|
|
14134
|
+
return `-${projectDir.replace(/^\//, "").replace(/[/.]/g, "-")}`;
|
|
14135
|
+
}
|
|
14136
|
+
async function sampleAgentDisk(agent, io) {
|
|
14137
|
+
const home = io.home();
|
|
14138
|
+
const deadline = io.now().getTime() + DU_TIMEOUT_MS;
|
|
14139
|
+
const left = () => deadline - io.now().getTime();
|
|
14140
|
+
const areas = {};
|
|
14141
|
+
let topPaths = [];
|
|
14142
|
+
const codeDir = join45(home, ".augmented", agent.codeName);
|
|
14143
|
+
const agentDir = await io.realpath(codeDir);
|
|
14144
|
+
if (agentDir === null) {
|
|
14145
|
+
areas.agent_dir = await io.kind(codeDir) === "missing" ? 0 : null;
|
|
14146
|
+
} else {
|
|
14147
|
+
const r = await io.du(agentDir, 2, left());
|
|
14148
|
+
const parsed = r.kind === "ok" ? parseDu(r.stdout, agentDir) : null;
|
|
14149
|
+
areas.agent_dir = parsed?.total ?? null;
|
|
14150
|
+
if (parsed) {
|
|
14151
|
+
topPaths = parsed.entries.sort((a, b) => b.bytes - a.bytes || a.path.localeCompare(b.path)).slice(0, TOP_PATHS);
|
|
14152
|
+
}
|
|
14153
|
+
}
|
|
14154
|
+
if (agent.agentId) {
|
|
14155
|
+
const idDir = join45(home, ".augmented", agent.agentId);
|
|
14156
|
+
const idReal = await io.realpath(idDir);
|
|
14157
|
+
if (idReal === null || idReal !== agentDir) {
|
|
14158
|
+
areas.agent_id_dir = idReal === null ? await io.kind(idDir) === "missing" ? 0 : null : await dirBytes(io, idReal, left);
|
|
14159
|
+
}
|
|
14160
|
+
}
|
|
14161
|
+
const projectDir = join45(agentDir ?? codeDir, "project");
|
|
14162
|
+
const projectsRoot = join45(home, ".claude", "projects");
|
|
14163
|
+
const transcriptDirs = [join45(projectsRoot, transcriptSlug(projectDir))];
|
|
14164
|
+
if (agent.isolated && agent.agentId) transcriptDirs.push(join45(projectsRoot, `.agent-${agent.agentId}`));
|
|
14165
|
+
const transcriptParts = [];
|
|
14166
|
+
for (const d of transcriptDirs) transcriptParts.push(await dirBytes(io, d, left));
|
|
14167
|
+
areas.transcripts = sumKnown(transcriptParts);
|
|
14168
|
+
if (agent.isolated) {
|
|
14169
|
+
const upper = await io.containerUpperDir(agent.codeName);
|
|
14170
|
+
areas.container_rw = upper !== null ? await dirBytes(io, upper, left) : await io.containerRwBytes(agent.codeName);
|
|
14171
|
+
if (areas.container_rw === null && !containerGapReported.has(agent.codeName)) {
|
|
14172
|
+
containerGapReported.add(agent.codeName);
|
|
14173
|
+
io.warn(
|
|
14174
|
+
`[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"
|
|
14175
|
+
);
|
|
14176
|
+
}
|
|
14177
|
+
if (areas.container_rw !== null) containerGapReported.delete(agent.codeName);
|
|
14178
|
+
}
|
|
14179
|
+
const fs = await io.statfs(agentDir ?? join45(home, ".augmented"));
|
|
14180
|
+
return { sampledAt: io.now().toISOString(), areas, topPaths, fs };
|
|
14181
|
+
}
|
|
14182
|
+
function execFileResult(cmd, args, timeoutMs) {
|
|
14183
|
+
return new Promise((resolve2) => {
|
|
14184
|
+
execFile2(cmd, args, { timeout: timeoutMs, killSignal: "SIGKILL", maxBuffer: 4 * 1024 * 1024 }, (err, stdout) => {
|
|
14185
|
+
if (!err) return resolve2({ kind: "ok", stdout: String(stdout) });
|
|
14186
|
+
const e = err;
|
|
14187
|
+
if (e.killed || e.signal === "SIGKILL") return resolve2({ kind: "timed-out" });
|
|
14188
|
+
if (e.code === 1 && String(stdout).length > 0) return resolve2({ kind: "ok", stdout: String(stdout) });
|
|
14189
|
+
resolve2({ kind: "failed", detail: String(e.code ?? e.message).slice(0, 200) });
|
|
14190
|
+
});
|
|
14191
|
+
});
|
|
14192
|
+
}
|
|
14193
|
+
var realDiskSamplerIo = {
|
|
14194
|
+
du: (dir, depth, timeoutMs) => execFileResult("nice", ["-n", "19", "du", "-xk", "-d", String(depth), dir], Math.max(1, Math.min(DU_TIMEOUT_MS, timeoutMs))),
|
|
14195
|
+
async kind(path) {
|
|
14196
|
+
try {
|
|
14197
|
+
const st = await lstat(path);
|
|
14198
|
+
return st.isDirectory() ? "dir" : "other";
|
|
14199
|
+
} catch (err) {
|
|
14200
|
+
return err.code === "ENOENT" ? "missing" : "error";
|
|
14201
|
+
}
|
|
14202
|
+
},
|
|
14203
|
+
async realpath(path) {
|
|
14204
|
+
try {
|
|
14205
|
+
return await realpath(path);
|
|
14206
|
+
} catch {
|
|
14207
|
+
return null;
|
|
14208
|
+
}
|
|
14209
|
+
},
|
|
14210
|
+
async statfs(path) {
|
|
14211
|
+
try {
|
|
14212
|
+
const st = await statfs(path);
|
|
14213
|
+
return { freeBytes: Number(st.bavail) * Number(st.bsize), totalBytes: Number(st.blocks) * Number(st.bsize) };
|
|
14214
|
+
} catch {
|
|
14215
|
+
return null;
|
|
14216
|
+
}
|
|
14217
|
+
},
|
|
14218
|
+
async containerRwBytes(codeName) {
|
|
14219
|
+
const r = await execFileResult("docker", ["inspect", "--size", "-f", "{{.SizeRw}}", `agt-${codeName}`], 3e4);
|
|
14220
|
+
if (r.kind !== "ok") return null;
|
|
14221
|
+
const v = r.stdout.trim();
|
|
14222
|
+
return /^\d+$/.test(v) ? Number(v) : null;
|
|
14223
|
+
},
|
|
14224
|
+
warn: (line) => console.warn(line),
|
|
14225
|
+
async containerUpperDir(codeName) {
|
|
14226
|
+
const r = await execFileResult("docker", ["inspect", "-f", "{{.GraphDriver.Data.UpperDir}}", `agt-${codeName}`], 1e4);
|
|
14227
|
+
if (r.kind !== "ok") return null;
|
|
14228
|
+
const dir = r.stdout.trim();
|
|
14229
|
+
return dir.startsWith("/") ? dir : null;
|
|
14230
|
+
},
|
|
14231
|
+
home: () => homedir16(),
|
|
14232
|
+
now: () => /* @__PURE__ */ new Date()
|
|
14233
|
+
};
|
|
14234
|
+
var lastSample2 = /* @__PURE__ */ new Map();
|
|
14235
|
+
var cursor = 0;
|
|
14236
|
+
var inFlight = false;
|
|
14237
|
+
var containerGapReported = /* @__PURE__ */ new Set();
|
|
14238
|
+
var timer3 = null;
|
|
14239
|
+
var generation = 0;
|
|
14240
|
+
var currentAgentIdOf = null;
|
|
14241
|
+
function tickMsFor(agentCount) {
|
|
14242
|
+
return Math.max(MIN_TICK_MS, Math.floor(DISK_SAMPLE_PERIOD_MS / Math.max(1, agentCount)));
|
|
14243
|
+
}
|
|
14244
|
+
async function sampleNextAgent(agents, io = realDiskSamplerIo) {
|
|
14245
|
+
if (inFlight || agents.length === 0) return null;
|
|
14246
|
+
const agent = agents[cursor % agents.length];
|
|
14247
|
+
cursor = (cursor + 1) % Math.max(1, agents.length);
|
|
14248
|
+
inFlight = true;
|
|
14249
|
+
try {
|
|
14250
|
+
lastSample2.set(agent.codeName, { agentId: agent.agentId, sample: await sampleAgentDisk(agent, io) });
|
|
14251
|
+
return agent.codeName;
|
|
14252
|
+
} finally {
|
|
14253
|
+
inFlight = false;
|
|
14254
|
+
}
|
|
14255
|
+
}
|
|
14256
|
+
function agentDiskFor(codeName) {
|
|
14257
|
+
const entry = lastSample2.get(codeName);
|
|
14258
|
+
if (!entry) return null;
|
|
14259
|
+
if (!currentAgentIdOf) return entry.sample;
|
|
14260
|
+
const current = currentAgentIdOf(codeName);
|
|
14261
|
+
if (current === null || current !== entry.agentId) return null;
|
|
14262
|
+
return { ...entry.sample, agentId: current };
|
|
14263
|
+
}
|
|
14264
|
+
function nextDelayMs(agentCount, lastSampleElapsedMs) {
|
|
14265
|
+
return Math.max(0, tickMsFor(agentCount) - Math.max(0, lastSampleElapsedMs));
|
|
14266
|
+
}
|
|
14267
|
+
function startAgentDiskSampler(liveAgents, io = realDiskSamplerIo) {
|
|
14268
|
+
if (timer3) return;
|
|
14269
|
+
const myGeneration = ++generation;
|
|
14270
|
+
currentAgentIdOf = (codeName) => liveAgents().find((a) => a.codeName === codeName)?.agentId ?? null;
|
|
14271
|
+
const schedule = (elapsedMs) => {
|
|
14272
|
+
if (myGeneration !== generation) return;
|
|
14273
|
+
const agents = liveAgents();
|
|
14274
|
+
const live = new Set(agents.map((a) => a.codeName));
|
|
14275
|
+
for (const code of lastSample2.keys()) if (!live.has(code)) lastSample2.delete(code);
|
|
14276
|
+
timer3 = setTimeout(() => {
|
|
14277
|
+
const started = Date.now();
|
|
14278
|
+
void sampleNextAgent(liveAgents(), io).finally(() => schedule(Date.now() - started));
|
|
14279
|
+
}, nextDelayMs(agents.length, elapsedMs));
|
|
14280
|
+
timer3.unref?.();
|
|
14281
|
+
};
|
|
14282
|
+
schedule(0);
|
|
14283
|
+
}
|
|
14284
|
+
function stopAgentDiskSampler() {
|
|
14285
|
+
generation++;
|
|
14286
|
+
if (timer3) clearTimeout(timer3);
|
|
14287
|
+
timer3 = null;
|
|
14288
|
+
}
|
|
14289
|
+
|
|
14076
14290
|
// src/lib/runtime-version-sampler.ts
|
|
14077
14291
|
import { execFileSync as execFileSync4 } from "child_process";
|
|
14078
14292
|
import { execFile as execFileCb } from "child_process";
|
|
14079
14293
|
import { promisify as promisify2 } from "util";
|
|
14080
14294
|
var execFileAsync2 = promisify2(execFileCb);
|
|
14081
14295
|
var SAMPLE_INTERVAL_MS3 = 5 * 6e4;
|
|
14082
|
-
var
|
|
14296
|
+
var lastSample3 = /* @__PURE__ */ new Map();
|
|
14083
14297
|
var failureCount = /* @__PURE__ */ new Map();
|
|
14084
14298
|
async function readVersionReal(codeName) {
|
|
14085
14299
|
const timeoutMs = 1e4;
|
|
@@ -14110,7 +14324,7 @@ function parseClaudeVersion(raw) {
|
|
|
14110
14324
|
async function sampleRuntimeVersionFor(codeName, io = {}) {
|
|
14111
14325
|
const isolated = io.isolatedFor?.(codeName) ?? effectiveIsolationMode(codeName) === "docker";
|
|
14112
14326
|
if (!isolated) {
|
|
14113
|
-
|
|
14327
|
+
lastSample3.delete(codeName);
|
|
14114
14328
|
failureCount.delete(codeName);
|
|
14115
14329
|
return { state: "not-isolated", version: null, sampledAt: null, failures: 0 };
|
|
14116
14330
|
}
|
|
@@ -14121,16 +14335,16 @@ async function sampleRuntimeVersionFor(codeName, io = {}) {
|
|
|
14121
14335
|
if (dir == null) {
|
|
14122
14336
|
const failures = (failureCount.get(codeName) ?? 0) + 1;
|
|
14123
14337
|
failureCount.set(codeName, failures);
|
|
14124
|
-
|
|
14338
|
+
lastSample3.delete(codeName);
|
|
14125
14339
|
return { state: "error", version: null, sampledAt: null, failures };
|
|
14126
14340
|
}
|
|
14127
|
-
const cached =
|
|
14341
|
+
const cached = lastSample3.get(codeName);
|
|
14128
14342
|
if (cached && cached.dir === dir) return cached.sample;
|
|
14129
14343
|
const version = parseClaudeVersion(await readVersion(codeName));
|
|
14130
14344
|
if (version == null) {
|
|
14131
14345
|
const failures = (failureCount.get(codeName) ?? 0) + 1;
|
|
14132
14346
|
failureCount.set(codeName, failures);
|
|
14133
|
-
|
|
14347
|
+
lastSample3.delete(codeName);
|
|
14134
14348
|
return { state: "error", version: null, sampledAt: null, failures };
|
|
14135
14349
|
}
|
|
14136
14350
|
failureCount.delete(codeName);
|
|
@@ -14140,24 +14354,24 @@ async function sampleRuntimeVersionFor(codeName, io = {}) {
|
|
|
14140
14354
|
sampledAt: new Date(now()).toISOString(),
|
|
14141
14355
|
failures: 0
|
|
14142
14356
|
};
|
|
14143
|
-
|
|
14357
|
+
lastSample3.set(codeName, { dir, sample });
|
|
14144
14358
|
return sample;
|
|
14145
14359
|
}
|
|
14146
14360
|
async function sampleRuntimeVersionOnce(codeNames, io = {}) {
|
|
14147
14361
|
for (const codeName of codeNames) await sampleRuntimeVersionFor(codeName, io);
|
|
14148
14362
|
}
|
|
14149
14363
|
function runtimeVersionFor(codeName) {
|
|
14150
|
-
const cached =
|
|
14364
|
+
const cached = lastSample3.get(codeName);
|
|
14151
14365
|
if (cached) return cached.sample;
|
|
14152
14366
|
const failures = failureCount.get(codeName) ?? 0;
|
|
14153
14367
|
if (failures > 0) return { state: "error", version: null, sampledAt: null, failures };
|
|
14154
14368
|
return { state: "unsampled", version: null, sampledAt: null, failures: 0 };
|
|
14155
14369
|
}
|
|
14156
|
-
var
|
|
14370
|
+
var timer4 = null;
|
|
14157
14371
|
var sampling = false;
|
|
14158
14372
|
function startRuntimeVersionSampler(liveAgents, io = {}) {
|
|
14159
|
-
if (
|
|
14160
|
-
|
|
14373
|
+
if (timer4) return;
|
|
14374
|
+
timer4 = setInterval(() => {
|
|
14161
14375
|
if (sampling) return;
|
|
14162
14376
|
sampling = true;
|
|
14163
14377
|
void sampleRuntimeVersionOnce(liveAgents(), io).catch(() => {
|
|
@@ -14165,11 +14379,11 @@ function startRuntimeVersionSampler(liveAgents, io = {}) {
|
|
|
14165
14379
|
sampling = false;
|
|
14166
14380
|
});
|
|
14167
14381
|
}, SAMPLE_INTERVAL_MS3);
|
|
14168
|
-
|
|
14382
|
+
timer4.unref?.();
|
|
14169
14383
|
}
|
|
14170
14384
|
function stopRuntimeVersionSampler() {
|
|
14171
|
-
if (
|
|
14172
|
-
|
|
14385
|
+
if (timer4) clearInterval(timer4);
|
|
14386
|
+
timer4 = null;
|
|
14173
14387
|
}
|
|
14174
14388
|
|
|
14175
14389
|
// src/lib/opencode-slack-ingest.ts
|
|
@@ -15317,7 +15531,7 @@ async function fireOpencodeScheduledTask(agent, task) {
|
|
|
15317
15531
|
import { createHash as createHash20 } from "crypto";
|
|
15318
15532
|
import { existsSync as existsSync18, mkdirSync as mkdirSync15, readFileSync as readFileSync36, renameSync as renameSync10, unlinkSync as unlinkSync4, writeFileSync as writeFileSync17 } from "fs";
|
|
15319
15533
|
import { randomUUID } from "crypto";
|
|
15320
|
-
import { join as
|
|
15534
|
+
import { join as join46 } from "path";
|
|
15321
15535
|
|
|
15322
15536
|
// src/lib/telegram-ingest.ts
|
|
15323
15537
|
import https2 from "https";
|
|
@@ -16020,7 +16234,7 @@ function createFileOffsetStore(codeName, log2, currentBotId) {
|
|
|
16020
16234
|
let filePath;
|
|
16021
16235
|
try {
|
|
16022
16236
|
dir = getFramework("opencode").getAgentDir(codeName);
|
|
16023
|
-
filePath =
|
|
16237
|
+
filePath = join46(dir, "telegram-getupdates-offset-opencode.json");
|
|
16024
16238
|
} catch {
|
|
16025
16239
|
dir = null;
|
|
16026
16240
|
filePath = null;
|
|
@@ -16074,7 +16288,7 @@ function createFileMigrationReportIO(codeName, log2) {
|
|
|
16074
16288
|
let filePath;
|
|
16075
16289
|
try {
|
|
16076
16290
|
dir = getFramework("opencode").getAgentDir(codeName);
|
|
16077
|
-
filePath =
|
|
16291
|
+
filePath = join46(dir, "telegram-migration-reports-opencode.json");
|
|
16078
16292
|
} catch {
|
|
16079
16293
|
dir = null;
|
|
16080
16294
|
filePath = null;
|
|
@@ -16100,7 +16314,7 @@ function createFileMigrationReportIO(codeName, log2) {
|
|
|
16100
16314
|
};
|
|
16101
16315
|
}
|
|
16102
16316
|
var managerHostPost = async (path, body) => {
|
|
16103
|
-
const { api: api2, ApiError: ApiError3 } = await import("../api-client-
|
|
16317
|
+
const { api: api2, ApiError: ApiError3 } = await import("../api-client-ZCSKN3SJ.js");
|
|
16104
16318
|
try {
|
|
16105
16319
|
const json = await api2.post(path, body);
|
|
16106
16320
|
return { status: 200, json };
|
|
@@ -16367,14 +16581,14 @@ function partitionActionableByPoison(actionable, states, config2) {
|
|
|
16367
16581
|
|
|
16368
16582
|
// src/lib/restart-flags.ts
|
|
16369
16583
|
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
|
|
16584
|
+
import { homedir as homedir17 } from "os";
|
|
16585
|
+
import { join as join47 } from "path";
|
|
16372
16586
|
import { randomUUID as randomUUID2 } from "crypto";
|
|
16373
16587
|
function restartFlagsDir() {
|
|
16374
|
-
return
|
|
16588
|
+
return join47(homedir17(), ".augmented", "restart-flags");
|
|
16375
16589
|
}
|
|
16376
16590
|
function flagPath(codeName) {
|
|
16377
|
-
return
|
|
16591
|
+
return join47(restartFlagsDir(), `${codeName}.flag`);
|
|
16378
16592
|
}
|
|
16379
16593
|
function readRestartFlags() {
|
|
16380
16594
|
const dir = restartFlagsDir();
|
|
@@ -16383,7 +16597,7 @@ function readRestartFlags() {
|
|
|
16383
16597
|
for (const entry of readdirSync13(dir)) {
|
|
16384
16598
|
if (!entry.endsWith(".flag")) continue;
|
|
16385
16599
|
try {
|
|
16386
|
-
const raw = readFileSync37(
|
|
16600
|
+
const raw = readFileSync37(join47(dir, entry), "utf8");
|
|
16387
16601
|
const parsed = JSON.parse(raw);
|
|
16388
16602
|
if (typeof parsed.codeName !== "string" || parsed.codeName.length === 0) {
|
|
16389
16603
|
parsed.codeName = entry.replace(/\.flag$/, "");
|
|
@@ -16506,7 +16720,7 @@ async function sendError(flag, opts, text) {
|
|
|
16506
16720
|
|
|
16507
16721
|
// src/lib/restart-context.ts
|
|
16508
16722
|
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
|
|
16723
|
+
import { dirname as dirname10, join as join48 } from "path";
|
|
16510
16724
|
var SLACK_PENDING_INBOUND_DIRNAME = "slack-pending-inbound";
|
|
16511
16725
|
var SLACK_RESTART_CONTEXT_DIRNAME = "slack-restart-context";
|
|
16512
16726
|
var MAX_TOPIC_CHARS = 140;
|
|
@@ -16518,10 +16732,10 @@ function augmentedAgentDir(codeName) {
|
|
|
16518
16732
|
return dirname10(getProjectDir(codeName));
|
|
16519
16733
|
}
|
|
16520
16734
|
function slackPendingInboundDir(codeName) {
|
|
16521
|
-
return
|
|
16735
|
+
return join48(augmentedAgentDir(codeName), SLACK_PENDING_INBOUND_DIRNAME);
|
|
16522
16736
|
}
|
|
16523
16737
|
function slackRestartContextDir(codeName) {
|
|
16524
|
-
return
|
|
16738
|
+
return join48(augmentedAgentDir(codeName), SLACK_RESTART_CONTEXT_DIRNAME);
|
|
16525
16739
|
}
|
|
16526
16740
|
function sanitizeTopic(raw) {
|
|
16527
16741
|
const cleaned = raw.replace(/\s+/g, " ").trim().replace(/[<>]/g, " ").replace(/\s+/g, " ").trim();
|
|
@@ -16581,7 +16795,7 @@ function pruneHintsExcept(codeName, freshFilenames) {
|
|
|
16581
16795
|
if (!filename.endsWith(".json")) continue;
|
|
16582
16796
|
if (freshFilenames.has(filename)) continue;
|
|
16583
16797
|
try {
|
|
16584
|
-
unlinkSync5(
|
|
16798
|
+
unlinkSync5(join48(ctxDir, filename));
|
|
16585
16799
|
} catch {
|
|
16586
16800
|
}
|
|
16587
16801
|
}
|
|
@@ -16602,7 +16816,7 @@ function refreshSlackRestartContextHints(codeNames, opts = {}) {
|
|
|
16602
16816
|
}
|
|
16603
16817
|
const markers = [];
|
|
16604
16818
|
for (const filename of markerFilenames.slice(0, cap)) {
|
|
16605
|
-
const parsed = readStrandedMarker(
|
|
16819
|
+
const parsed = readStrandedMarker(join48(markerDir, filename));
|
|
16606
16820
|
if (parsed) markers.push({ filename, channel: parsed.channel, thread_ts: parsed.thread_ts });
|
|
16607
16821
|
}
|
|
16608
16822
|
if (markers.length === 0) {
|
|
@@ -16616,7 +16830,7 @@ function refreshSlackRestartContextHints(codeNames, opts = {}) {
|
|
|
16616
16830
|
const freshFilenames = /* @__PURE__ */ new Set();
|
|
16617
16831
|
for (const { filename, hint } of hints) {
|
|
16618
16832
|
try {
|
|
16619
|
-
writeHintFile(
|
|
16833
|
+
writeHintFile(join48(ctxDir, filename), ctxDir, hint);
|
|
16620
16834
|
freshFilenames.add(filename);
|
|
16621
16835
|
} catch (err) {
|
|
16622
16836
|
log2(`[restart-context] ${codeName}: hint write failed for ${filename}: ${err.message}`);
|
|
@@ -17545,7 +17759,7 @@ async function runDangerousRmBackstop(agentId, codeName, pane) {
|
|
|
17545
17759
|
return;
|
|
17546
17760
|
}
|
|
17547
17761
|
const policy = readRmPolicyText(
|
|
17548
|
-
() => readFileSync39(
|
|
17762
|
+
() => readFileSync39(join49(getFramework("claude-code").getAgentDir(codeName), RM_POLICY_RELATIVE_PATH), "utf-8")
|
|
17549
17763
|
);
|
|
17550
17764
|
const decision = decideDangerousRm(action.prompt, policy, {
|
|
17551
17765
|
// ENG-11871: where the agent ACTUALLY runs (fails safe to host rules if
|
|
@@ -18050,7 +18264,7 @@ function scheduleSessionRestart(codeName, delayMs, reason, breakerReason = "hot-
|
|
|
18050
18264
|
clearTimeout(existing.timer);
|
|
18051
18265
|
log(`[hot-reload] Coalesced restart for '${codeName}': replacing pending timer with ${reason}`);
|
|
18052
18266
|
}
|
|
18053
|
-
const
|
|
18267
|
+
const timer5 = setTimeout(() => {
|
|
18054
18268
|
pendingSessionRestarts.delete(codeName);
|
|
18055
18269
|
const gate = restartGateFor(codeName, breakerReason);
|
|
18056
18270
|
if (gate !== "bypass" && gate !== "proceed") {
|
|
@@ -18138,8 +18352,8 @@ function scheduleSessionRestart(codeName, delayMs, reason, breakerReason = "hot-
|
|
|
18138
18352
|
void respawnAgentAfterMcpStop(codeName, reason);
|
|
18139
18353
|
}
|
|
18140
18354
|
}, delayMs);
|
|
18141
|
-
|
|
18142
|
-
pendingSessionRestarts.set(codeName, { timer:
|
|
18355
|
+
timer5.unref?.();
|
|
18356
|
+
pendingSessionRestarts.set(codeName, { timer: timer5, reason, breakerReason, beforeStop, auditDetail });
|
|
18143
18357
|
}
|
|
18144
18358
|
function cancelPendingSessionRestart(codeName) {
|
|
18145
18359
|
pendingRestartVerifications.delete(codeName);
|
|
@@ -18270,7 +18484,7 @@ var pendingDayRolloverReset = /* @__PURE__ */ new Set();
|
|
|
18270
18484
|
var dayRolloverInboundHold = /* @__PURE__ */ new Map();
|
|
18271
18485
|
var INBOUND_HOLD_EPISODE_GAP_MS = 12e4;
|
|
18272
18486
|
async function channelInboundActivityAgeSecondsFor(codeName) {
|
|
18273
|
-
const { newestPendingInboundActivityMtimeMs } = await import("../responsiveness-probe-
|
|
18487
|
+
const { newestPendingInboundActivityMtimeMs } = await import("../responsiveness-probe-EJJNNPNB.js");
|
|
18274
18488
|
const newest = newestPendingInboundActivityMtimeMs(dirname11(paneLogPath(codeName)));
|
|
18275
18489
|
if (newest === null) return null;
|
|
18276
18490
|
return Math.max(0, Math.floor((Date.now() - newest) / 1e3));
|
|
@@ -18356,9 +18570,9 @@ async function hostShouldHaveClaudeDeviceState() {
|
|
|
18356
18570
|
return verdict.applies;
|
|
18357
18571
|
}
|
|
18358
18572
|
async function diskGuardDeps() {
|
|
18359
|
-
const { execFile:
|
|
18573
|
+
const { execFile: execFile3 } = await import("child_process");
|
|
18360
18574
|
const { promisify: promisify3 } = await import("util");
|
|
18361
|
-
const execFileAsync3 = promisify3(
|
|
18575
|
+
const execFileAsync3 = promisify3(execFile3);
|
|
18362
18576
|
const isRoot = typeof process.getuid === "function" && process.getuid() === 0;
|
|
18363
18577
|
const packageManagerBusy = async () => anyPackageInstallRunning();
|
|
18364
18578
|
return {
|
|
@@ -18660,7 +18874,7 @@ var runningMcpServerKeys = /* @__PURE__ */ new Map();
|
|
|
18660
18874
|
var runningChannelSecretHashes = /* @__PURE__ */ new Map();
|
|
18661
18875
|
var sessionLaunchManagedStructure = /* @__PURE__ */ new Map();
|
|
18662
18876
|
function readSpawnViewMcpConfig(codeName, projectDir) {
|
|
18663
|
-
const parsed = JSON.parse(readFileSync39(
|
|
18877
|
+
const parsed = JSON.parse(readFileSync39(join49(projectDir, ".mcp.json"), "utf-8"));
|
|
18664
18878
|
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) return parsed;
|
|
18665
18879
|
const agentId = agentState.codeNameToAgentId.get(codeName);
|
|
18666
18880
|
const integrations = agentId ? lastIntegrationsPayload.get(agentId) : void 0;
|
|
@@ -18682,7 +18896,7 @@ function reportSpawnCopyFailure(codeName, f) {
|
|
|
18682
18896
|
function refreshHeldDropped(codeName, projectDir, held) {
|
|
18683
18897
|
const agentId = agentState.codeNameToAgentId.get(codeName);
|
|
18684
18898
|
const integrations = agentId ? lastIntegrationsPayload.get(agentId) : void 0;
|
|
18685
|
-
const now = [...spawnDroppedServerKeys(
|
|
18899
|
+
const now = [...spawnDroppedServerKeys(join49(projectDir, ".mcp.json"), integrations)];
|
|
18686
18900
|
if (spawnCopyFailures.noteDropped(codeName, now)) {
|
|
18687
18901
|
log(
|
|
18688
18902
|
`[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 +18919,7 @@ function readSpawnedMcpConfig(path) {
|
|
|
18705
18919
|
}
|
|
18706
18920
|
}
|
|
18707
18921
|
function readRawMcpConfig(projectDir) {
|
|
18708
|
-
return JSON.parse(readFileSync39(
|
|
18922
|
+
return JSON.parse(readFileSync39(join49(projectDir, ".mcp.json"), "utf-8"));
|
|
18709
18923
|
}
|
|
18710
18924
|
function readMcpConfigFor(codeName, projectDir, source) {
|
|
18711
18925
|
return source === "raw" ? readRawMcpConfig(projectDir) : readSpawnViewMcpConfig(codeName, projectDir);
|
|
@@ -18738,7 +18952,7 @@ function seedSessionLaunchBaselines(codeName, projectDir, spawnMcpConfigPath) {
|
|
|
18738
18952
|
else runningMcpServerKeys.delete(codeName);
|
|
18739
18953
|
let launchStructure = null;
|
|
18740
18954
|
try {
|
|
18741
|
-
const raw = readFileSync39(
|
|
18955
|
+
const raw = readFileSync39(join49(projectDir, ".mcp.json"), "utf-8");
|
|
18742
18956
|
launchStructure = managedMcpStructureHashFromFile(
|
|
18743
18957
|
JSON.parse(raw),
|
|
18744
18958
|
isManagedMcpServerKey
|
|
@@ -18890,7 +19104,7 @@ async function runAgentSessionToolBindProbes(agent, integrations, projectDir, op
|
|
|
18890
19104
|
if (result && result.rebindCandidates.length > 0 && hostFlagStore().getBoolean("session-tool-rebind")) {
|
|
18891
19105
|
let mcpJsonForRebind = null;
|
|
18892
19106
|
try {
|
|
18893
|
-
mcpJsonForRebind = JSON.parse(readFileSync39(
|
|
19107
|
+
mcpJsonForRebind = JSON.parse(readFileSync39(join49(projectDir, ".mcp.json"), "utf-8"));
|
|
18894
19108
|
} catch {
|
|
18895
19109
|
mcpJsonForRebind = null;
|
|
18896
19110
|
}
|
|
@@ -19054,7 +19268,7 @@ function shouldInjectChannelSecrets(agentId) {
|
|
|
19054
19268
|
function projectChannelSecretHash(projectDir) {
|
|
19055
19269
|
try {
|
|
19056
19270
|
const entries = parseEnvIntegrations(
|
|
19057
|
-
readFileSync39(
|
|
19271
|
+
readFileSync39(join49(projectDir, ".env.integrations"), "utf-8")
|
|
19058
19272
|
);
|
|
19059
19273
|
return channelSecretValueHash(entries, CHANNEL_SECRET_ENV_KEYS);
|
|
19060
19274
|
} catch {
|
|
@@ -19182,7 +19396,7 @@ var agentRestartTimezoneInputs = /* @__PURE__ */ new Map();
|
|
|
19182
19396
|
var lastVersionCheckAt = 0;
|
|
19183
19397
|
var VERSION_CHECK_INTERVAL_MS = 5 * 60 * 1e3;
|
|
19184
19398
|
var lastResponsivenessProbeAt = 0;
|
|
19185
|
-
var agtCliVersion = true ? "0.28.
|
|
19399
|
+
var agtCliVersion = true ? "0.28.1320" : "dev";
|
|
19186
19400
|
function resolveBrewPath(execFileSync5) {
|
|
19187
19401
|
try {
|
|
19188
19402
|
const out = execFileSync5("which", ["brew"], { timeout: 5e3 }).toString().trim();
|
|
@@ -19247,9 +19461,9 @@ async function ensureToolkitCliInner(toolkitSlug) {
|
|
|
19247
19461
|
}
|
|
19248
19462
|
const { binary, installer, package: pkg, script } = integration.cli_tool;
|
|
19249
19463
|
const resolvedInstaller = installer ?? "manual";
|
|
19250
|
-
const { execFileSync: execFileSync5, execFile:
|
|
19464
|
+
const { execFileSync: execFileSync5, execFile: execFile3, exec } = await import("child_process");
|
|
19251
19465
|
const { promisify: promisify3 } = await import("util");
|
|
19252
|
-
const execFileAsync3 = promisify3(
|
|
19466
|
+
const execFileAsync3 = promisify3(execFile3);
|
|
19253
19467
|
const execAsync = promisify3(exec);
|
|
19254
19468
|
try {
|
|
19255
19469
|
execFileSync5("which", [binary], { timeout: 5e3, stdio: "pipe" });
|
|
@@ -19708,7 +19922,7 @@ function runAsync(cmd, args, opts) {
|
|
|
19708
19922
|
let stdout = "";
|
|
19709
19923
|
let stderr = "";
|
|
19710
19924
|
let settled = false;
|
|
19711
|
-
const
|
|
19925
|
+
const timer5 = setTimeout(() => {
|
|
19712
19926
|
child.kill("SIGTERM");
|
|
19713
19927
|
if (settled) return;
|
|
19714
19928
|
settled = true;
|
|
@@ -19729,20 +19943,20 @@ function runAsync(cmd, args, opts) {
|
|
|
19729
19943
|
child.on("error", (err) => {
|
|
19730
19944
|
if (settled) return;
|
|
19731
19945
|
settled = true;
|
|
19732
|
-
clearTimeout(
|
|
19946
|
+
clearTimeout(timer5);
|
|
19733
19947
|
reject(err);
|
|
19734
19948
|
});
|
|
19735
19949
|
child.on("close", (code) => {
|
|
19736
19950
|
if (settled) return;
|
|
19737
19951
|
settled = true;
|
|
19738
|
-
clearTimeout(
|
|
19952
|
+
clearTimeout(timer5);
|
|
19739
19953
|
resolve2({ code: code ?? -1, stdout, stderr });
|
|
19740
19954
|
});
|
|
19741
19955
|
}).catch(reject);
|
|
19742
19956
|
});
|
|
19743
19957
|
}
|
|
19744
19958
|
function claudeManagedSettingsPath() {
|
|
19745
|
-
return
|
|
19959
|
+
return join49(CLAUDE_MANAGED_SETTINGS_DIR, "managed-settings.json");
|
|
19746
19960
|
}
|
|
19747
19961
|
var MANAGED_SETTINGS_KEYS = ["channelsEnabled", "enableAllProjectMcpServers"];
|
|
19748
19962
|
var MANAGED_SETTINGS_ENV = { DISABLE_AUTOUPDATER: "1" };
|
|
@@ -19898,7 +20112,7 @@ async function ensureOpencodeBinary() {
|
|
|
19898
20112
|
try {
|
|
19899
20113
|
const prefix = execFileSync5("npm", ["prefix", "-g"], { encoding: "utf-8", timeout: 1e4 }).trim();
|
|
19900
20114
|
if (prefix) {
|
|
19901
|
-
const npmBin =
|
|
20115
|
+
const npmBin = join49(prefix, "bin");
|
|
19902
20116
|
const current = (process.env.PATH ?? "").split(pathDelimiter);
|
|
19903
20117
|
if (!current.includes(npmBin)) {
|
|
19904
20118
|
process.env.PATH = [npmBin, ...current.filter(Boolean)].join(pathDelimiter);
|
|
@@ -19969,7 +20183,7 @@ async function ensureFrameworkBinary(frameworkId) {
|
|
|
19969
20183
|
agentRuntimeAuthenticated = await checkClaudeAuth();
|
|
19970
20184
|
}
|
|
19971
20185
|
var claudeCodeUpgradeInFlight = false;
|
|
19972
|
-
var SCRATCH_HOLDS_DIR = () =>
|
|
20186
|
+
var SCRATCH_HOLDS_DIR = () => join49(homedir18(), ".augmented", ".manager-scratch-holds");
|
|
19973
20187
|
setScratchSweepPolicyResolver(
|
|
19974
20188
|
(codeName) => resolveScratchSweepPolicy({
|
|
19975
20189
|
agentId: agentState.codeNameToAgentId.get(codeName),
|
|
@@ -20048,7 +20262,7 @@ async function maybeUpgradeClaudeCode() {
|
|
|
20048
20262
|
}
|
|
20049
20263
|
var UPDATE_CHECK_INTERVAL_MS = 5 * 60 * 1e3;
|
|
20050
20264
|
function selfUpdateAppliedMarkerPath() {
|
|
20051
|
-
return
|
|
20265
|
+
return join49(homedir18(), ".augmented", ".last-self-update-applied");
|
|
20052
20266
|
}
|
|
20053
20267
|
var selfUpdateUpToDateLogged = false;
|
|
20054
20268
|
var selfUpdatePinnedLogged = false;
|
|
@@ -20099,7 +20313,7 @@ async function checkAndUpdateCli(opts) {
|
|
|
20099
20313
|
const isNpmGlobal = !isBrewFormula && resolvedPath.includes("node_modules");
|
|
20100
20314
|
if (!isBrewFormula && !isNpmGlobal) return "noop";
|
|
20101
20315
|
const { readFileSync: readF, writeFileSync: writeF } = await import("fs");
|
|
20102
|
-
const markerPath =
|
|
20316
|
+
const markerPath = join49(homedir18(), ".augmented", ".last-update-check");
|
|
20103
20317
|
if (!force) {
|
|
20104
20318
|
try {
|
|
20105
20319
|
const lastCheck = parseInt(readF(markerPath, "utf-8").trim(), 10);
|
|
@@ -20535,7 +20749,7 @@ async function runClaudeRuntimeAuthProbe() {
|
|
|
20535
20749
|
];
|
|
20536
20750
|
try {
|
|
20537
20751
|
const { stdout, stderr } = await execFilePromiseLong(resolveClaudeBinary(), args, {
|
|
20538
|
-
cwd:
|
|
20752
|
+
cwd: homedir18(),
|
|
20539
20753
|
timeout: RUNTIME_AUTH_PROBE_TIMEOUT_MS,
|
|
20540
20754
|
stdin: "ignore",
|
|
20541
20755
|
env: childEnv,
|
|
@@ -20571,7 +20785,7 @@ async function runHostUsageCommand() {
|
|
|
20571
20785
|
...hostClaudeOneShotArgs(emptyMcp)
|
|
20572
20786
|
];
|
|
20573
20787
|
const { stdout } = await execFilePromiseLong(resolveClaudeBinary(), args, {
|
|
20574
|
-
cwd:
|
|
20788
|
+
cwd: homedir18(),
|
|
20575
20789
|
timeout: HOST_USAGE_POLL_TIMEOUT_MS,
|
|
20576
20790
|
stdin: "ignore",
|
|
20577
20791
|
env: childEnv,
|
|
@@ -20618,12 +20832,12 @@ async function checkClaudeAuth() {
|
|
|
20618
20832
|
var evalEmptyMcpConfigPath = null;
|
|
20619
20833
|
function ensureEvalEmptyMcpConfig() {
|
|
20620
20834
|
if (evalEmptyMcpConfigPath && existsSync20(evalEmptyMcpConfigPath)) return evalEmptyMcpConfigPath;
|
|
20621
|
-
const dir =
|
|
20835
|
+
const dir = join49(homedir18(), ".augmented");
|
|
20622
20836
|
try {
|
|
20623
20837
|
mkdirSync18(dir, { recursive: true });
|
|
20624
20838
|
} catch {
|
|
20625
20839
|
}
|
|
20626
|
-
const p =
|
|
20840
|
+
const p = join49(dir, ".eval-empty-mcp.json");
|
|
20627
20841
|
writeFileSync20(p, JSON.stringify({ mcpServers: {} }));
|
|
20628
20842
|
evalEmptyMcpConfigPath = p;
|
|
20629
20843
|
return p;
|
|
@@ -20645,7 +20859,7 @@ async function runEvalClaude(prompt, model) {
|
|
|
20645
20859
|
...hostClaudeOneShotArgs(emptyMcp)
|
|
20646
20860
|
];
|
|
20647
20861
|
const { stdout } = await execFilePromiseLong(resolveClaudeBinary(), args, {
|
|
20648
|
-
cwd:
|
|
20862
|
+
cwd: homedir18(),
|
|
20649
20863
|
timeout: 12e4,
|
|
20650
20864
|
stdin: "ignore",
|
|
20651
20865
|
env: childEnv,
|
|
@@ -20714,10 +20928,10 @@ function resolveConversationEvalBackend() {
|
|
|
20714
20928
|
return conversationEvalBackend;
|
|
20715
20929
|
}
|
|
20716
20930
|
function getStateFile() {
|
|
20717
|
-
return
|
|
20931
|
+
return join49(config?.configDir ?? join49(process.env["HOME"] ?? "/tmp", ".augmented"), "manager-state.json");
|
|
20718
20932
|
}
|
|
20719
20933
|
function channelHashCacheDir() {
|
|
20720
|
-
return config?.configDir ??
|
|
20934
|
+
return config?.configDir ?? join49(process.env["HOME"] ?? "/tmp", ".augmented");
|
|
20721
20935
|
}
|
|
20722
20936
|
function loadChannelHashCache2() {
|
|
20723
20937
|
loadChannelHashCache(agentState.knownChannelConfigHashes, channelHashCacheDir());
|
|
@@ -20930,7 +21144,7 @@ function removeDeliveryBaselineEntries(agentId) {
|
|
|
20930
21144
|
var _channelQuarantineStore = null;
|
|
20931
21145
|
function channelQuarantineStore() {
|
|
20932
21146
|
if (!_channelQuarantineStore) {
|
|
20933
|
-
const dir = config?.configDir ??
|
|
21147
|
+
const dir = config?.configDir ?? join49(process.env["HOME"] ?? "/tmp", ".augmented");
|
|
20934
21148
|
_channelQuarantineStore = new ChannelQuarantineStore(defaultQuarantinePath(dir));
|
|
20935
21149
|
}
|
|
20936
21150
|
return _channelQuarantineStore;
|
|
@@ -20938,7 +21152,7 @@ function channelQuarantineStore() {
|
|
|
20938
21152
|
var _channelResumeHistoryStore = null;
|
|
20939
21153
|
function channelResumeHistoryStore() {
|
|
20940
21154
|
if (!_channelResumeHistoryStore) {
|
|
20941
|
-
const dir = config?.configDir ??
|
|
21155
|
+
const dir = config?.configDir ?? join49(process.env["HOME"] ?? "/tmp", ".augmented");
|
|
20942
21156
|
_channelResumeHistoryStore = new ChannelResumeHistoryStore(defaultResumeHistoryPath(dir));
|
|
20943
21157
|
}
|
|
20944
21158
|
return _channelResumeHistoryStore;
|
|
@@ -20983,12 +21197,12 @@ function sessionActivityFor(codeName, pane, opts = {}) {
|
|
|
20983
21197
|
}
|
|
20984
21198
|
function forwardedToolsFor(codeName) {
|
|
20985
21199
|
if (!config?.configDir) return null;
|
|
20986
|
-
return readForwardedToolsReport(
|
|
21200
|
+
return readForwardedToolsReport(join49(config.configDir, codeName));
|
|
20987
21201
|
}
|
|
20988
21202
|
var _hostFlagStore = null;
|
|
20989
21203
|
function hostFlagStore() {
|
|
20990
21204
|
if (!_hostFlagStore) {
|
|
20991
|
-
const dir = config?.configDir ??
|
|
21205
|
+
const dir = config?.configDir ?? join49(process.env["HOME"] ?? "/tmp", ".augmented");
|
|
20992
21206
|
_hostFlagStore = new HostFlagStore({ cachePath: defaultFlagsCachePath(dir), log });
|
|
20993
21207
|
}
|
|
20994
21208
|
return _hostFlagStore;
|
|
@@ -21174,12 +21388,12 @@ function parseSkillFrontmatter(content) {
|
|
|
21174
21388
|
}
|
|
21175
21389
|
async function refreshSkillsIndexInClaudeMd(configDir, codeName, log2) {
|
|
21176
21390
|
const { readdirSync: readdirSync16, readFileSync: rfs, existsSync: ex, writeFileSync: writeFileSync21 } = await import("fs");
|
|
21177
|
-
const skillsDir =
|
|
21178
|
-
const claudeMdPath =
|
|
21391
|
+
const skillsDir = join49(configDir, codeName, "project", ".claude", "skills");
|
|
21392
|
+
const claudeMdPath = join49(configDir, codeName, "project", "CLAUDE.md");
|
|
21179
21393
|
if (!ex(skillsDir) || !ex(claudeMdPath)) return;
|
|
21180
21394
|
const entries = [];
|
|
21181
21395
|
for (const dir of readdirSync16(skillsDir).sort()) {
|
|
21182
|
-
const skillFile =
|
|
21396
|
+
const skillFile = join49(skillsDir, dir, "SKILL.md");
|
|
21183
21397
|
if (!ex(skillFile)) continue;
|
|
21184
21398
|
try {
|
|
21185
21399
|
const { name, description } = parseSkillFrontmatter(rfs(skillFile, "utf-8"));
|
|
@@ -21318,10 +21532,10 @@ function flushRestartedAgentDiagnostics(hostId, codeNames) {
|
|
|
21318
21532
|
if (codeNames.length === 0) return;
|
|
21319
21533
|
void (async () => {
|
|
21320
21534
|
try {
|
|
21321
|
-
const { collectDiagnostics } = await import("../persistent-session-
|
|
21535
|
+
const { collectDiagnostics } = await import("../persistent-session-XFZ43IDB.js");
|
|
21322
21536
|
await api.post("/host/heartbeat", {
|
|
21323
21537
|
host_id: hostId,
|
|
21324
|
-
agent_diagnostics: collectDiagnostics(codeNames, quarantineEntriesFor, claudeMdSizeFor, spawnOutcomeForDiagnostics, pidPressureFor, forwardedToolsFor, runtimeVersionFor, sessionActivityFor)
|
|
21538
|
+
agent_diagnostics: collectDiagnostics(codeNames, quarantineEntriesFor, claudeMdSizeFor, spawnOutcomeForDiagnostics, pidPressureFor, forwardedToolsFor, runtimeVersionFor, sessionActivityFor, agentDiskFor)
|
|
21325
21539
|
});
|
|
21326
21540
|
} catch (err) {
|
|
21327
21541
|
log(`[restart] post-respawn diagnostics flush failed: ${err.message}`);
|
|
@@ -21386,7 +21600,7 @@ async function pollCycleInner() {
|
|
|
21386
21600
|
getSlackToken: (codeName) => agentChannelTokens.get(codeName)?.slack ?? null,
|
|
21387
21601
|
sendSlack: async (botToken, body) => {
|
|
21388
21602
|
const controller = new AbortController();
|
|
21389
|
-
const
|
|
21603
|
+
const timer5 = setTimeout(() => controller.abort(), 5e3);
|
|
21390
21604
|
try {
|
|
21391
21605
|
const res = await fetch("https://slack.com/api/chat.postMessage", {
|
|
21392
21606
|
method: "POST",
|
|
@@ -21403,7 +21617,7 @@ async function pollCycleInner() {
|
|
|
21403
21617
|
const isAbort = err.name === "AbortError";
|
|
21404
21618
|
return { ok: false, error: isAbort ? "timeout" : err.message };
|
|
21405
21619
|
} finally {
|
|
21406
|
-
clearTimeout(
|
|
21620
|
+
clearTimeout(timer5);
|
|
21407
21621
|
}
|
|
21408
21622
|
},
|
|
21409
21623
|
// ENG-6399: report the restart to audit_log via POST /host/restart-event.
|
|
@@ -21465,11 +21679,11 @@ async function pollCycleInner() {
|
|
|
21465
21679
|
}
|
|
21466
21680
|
try {
|
|
21467
21681
|
const { detectHostSecurity } = await import("../host-security-KQYYZZVW.js");
|
|
21468
|
-
const { collectDiagnostics } = await import("../persistent-session-
|
|
21682
|
+
const { collectDiagnostics } = await import("../persistent-session-XFZ43IDB.js");
|
|
21469
21683
|
const recordedSinceHeartbeat = new Set(spawnOutcomesSinceHeartbeat.drain());
|
|
21470
21684
|
const diagCodeNames = heartbeatDiagnosticsCodeNames(agentState.persistentSessionAgents, recordedSinceHeartbeat);
|
|
21471
21685
|
const heartbeatSpawnOutcomeFor = spawnOutcomeIfRecorded(spawnOutcomeForDiagnostics, recordedSinceHeartbeat);
|
|
21472
|
-
const agentDiagnostics = diagCodeNames.length > 0 ? collectDiagnostics(diagCodeNames, quarantineEntriesFor, claudeMdSizeFor, heartbeatSpawnOutcomeFor, pidPressureFor, forwardedToolsFor, runtimeVersionFor, sessionActivityFor) : void 0;
|
|
21686
|
+
const agentDiagnostics = diagCodeNames.length > 0 ? collectDiagnostics(diagCodeNames, quarantineEntriesFor, claudeMdSizeFor, heartbeatSpawnOutcomeFor, pidPressureFor, forwardedToolsFor, runtimeVersionFor, sessionActivityFor, agentDiskFor) : void 0;
|
|
21473
21687
|
let tailscaleHostname;
|
|
21474
21688
|
try {
|
|
21475
21689
|
const { execSync: es } = await import("child_process");
|
|
@@ -21766,7 +21980,7 @@ async function pollCycleInner() {
|
|
|
21766
21980
|
}
|
|
21767
21981
|
try {
|
|
21768
21982
|
const desiredClaudeCodeVersion = hbResp?.desired_claude_code_version?.trim();
|
|
21769
|
-
const { maybeUpdateClaudeCode, shouldRunClaudeCodeUpdater } = await import("../claude-code-updater-
|
|
21983
|
+
const { maybeUpdateClaudeCode, shouldRunClaudeCodeUpdater } = await import("../claude-code-updater-E5QX33MA.js");
|
|
21770
21984
|
const securityFloor = currentSecurityFloor();
|
|
21771
21985
|
claudeUpdaterInFlight = true;
|
|
21772
21986
|
if (desiredClaudeCodeVersion && (claudePairLoop.busy || claudePairingInProgress())) {
|
|
@@ -21801,7 +22015,7 @@ async function pollCycleInner() {
|
|
|
21801
22015
|
collectPanelessActivityProbes,
|
|
21802
22016
|
getResponsivenessIntervalMs,
|
|
21803
22017
|
occupancyQualificationClassifications
|
|
21804
|
-
} = await import("../responsiveness-probe-
|
|
22018
|
+
} = await import("../responsiveness-probe-EJJNNPNB.js");
|
|
21805
22019
|
const probeIntervalMs = getResponsivenessIntervalMs();
|
|
21806
22020
|
if (now - lastResponsivenessProbeAt > probeIntervalMs) {
|
|
21807
22021
|
const probeCodeNames = [...agentState.persistentSessionAgents];
|
|
@@ -21918,7 +22132,7 @@ async function pollCycleInner() {
|
|
|
21918
22132
|
collectResponsivenessProbes,
|
|
21919
22133
|
livePendingInboundOldestAgeSeconds,
|
|
21920
22134
|
parkPendingInbound
|
|
21921
|
-
} = await import("../responsiveness-probe-
|
|
22135
|
+
} = await import("../responsiveness-probe-EJJNNPNB.js");
|
|
21922
22136
|
const { getProjectDir: wedgeProjectDir } = await import("../scheduler-engine-5PCBGRNY.js");
|
|
21923
22137
|
const wedgeNow = /* @__PURE__ */ new Date();
|
|
21924
22138
|
const liveAgents = agentState.persistentSessionAgents;
|
|
@@ -22011,10 +22225,10 @@ async function pollCycleInner() {
|
|
|
22011
22225
|
const paneTail = readFileSync39(paneLogPath(codeName), "utf8").slice(-65536);
|
|
22012
22226
|
const transient = detectTransientApiErrorInLog(paneTail);
|
|
22013
22227
|
if (transient) {
|
|
22014
|
-
const wedgeHome =
|
|
22228
|
+
const wedgeHome = join49(homedir18(), ".augmented", codeName);
|
|
22015
22229
|
if (existsSync20(wedgeHome)) {
|
|
22016
22230
|
atomicWriteFileSync(
|
|
22017
|
-
|
|
22231
|
+
join49(wedgeHome, "watchdog-give-up.json"),
|
|
22018
22232
|
JSON.stringify({
|
|
22019
22233
|
gave_up_at: wedgeNow.toISOString(),
|
|
22020
22234
|
reason: "transient_overload"
|
|
@@ -22207,7 +22421,7 @@ async function pollCycleInner() {
|
|
|
22207
22421
|
}
|
|
22208
22422
|
);
|
|
22209
22423
|
if (!paneFatalTornDown) continue;
|
|
22210
|
-
const { parkPendingInbound } = await import("../responsiveness-probe-
|
|
22424
|
+
const { parkPendingInbound } = await import("../responsiveness-probe-EJJNNPNB.js");
|
|
22211
22425
|
const { parked, deadLettered } = parkPendingInbound(codeName, new Date(fatalNowMs));
|
|
22212
22426
|
paneFatalStreak.delete(codeName);
|
|
22213
22427
|
paneFatalRestarts.set(codeName, [...history, fatalNowMs]);
|
|
@@ -22238,7 +22452,7 @@ async function pollCycleInner() {
|
|
|
22238
22452
|
TRANSCRIPT_MOUNT_ESCALATION_REFRESH_MS,
|
|
22239
22453
|
bindSourceEscalations
|
|
22240
22454
|
} = await import("../transcript-mount-health-OHE6IVJV.js");
|
|
22241
|
-
const { transcriptBindSourcesFor, ensureTranscriptBindSources } = await import("../persistent-session-
|
|
22455
|
+
const { transcriptBindSourcesFor, ensureTranscriptBindSources } = await import("../persistent-session-XFZ43IDB.js");
|
|
22242
22456
|
const mountConfig = resolveTranscriptMountConfig();
|
|
22243
22457
|
const liveAgents = agentState.persistentSessionAgents;
|
|
22244
22458
|
for (const tracked of [
|
|
@@ -22269,7 +22483,7 @@ async function pollCycleInner() {
|
|
|
22269
22483
|
};
|
|
22270
22484
|
if (mountConfig.mode !== "off" && platform3() === "linux") {
|
|
22271
22485
|
const mountNowMs = Date.now();
|
|
22272
|
-
const homeDirForBinds = process.env.HOME?.trim() ||
|
|
22486
|
+
const homeDirForBinds = process.env.HOME?.trim() || homedir18();
|
|
22273
22487
|
for (const codeName of liveAgents) {
|
|
22274
22488
|
if (effectiveIsolationMode(codeName) !== "docker") continue;
|
|
22275
22489
|
if (!isSessionHealthy(codeName)) {
|
|
@@ -22404,7 +22618,7 @@ async function pollCycleInner() {
|
|
|
22404
22618
|
}
|
|
22405
22619
|
try {
|
|
22406
22620
|
const { scrapeMcpFailedBannerCount } = await import("../pane-mcp-banner-scraper-VR5QGP3J.js");
|
|
22407
|
-
const { probeSessionAuth } = await import("../session-auth-dead-
|
|
22621
|
+
const { probeSessionAuth } = await import("../session-auth-dead-EIVQKX5X.js");
|
|
22408
22622
|
const observations = [];
|
|
22409
22623
|
const pendingCacheCommits = [];
|
|
22410
22624
|
const modelApiErrorReportingOn = hostFlagStore().getBoolean("model-api-error-reporting");
|
|
@@ -22968,7 +23182,7 @@ async function pollCycleInner() {
|
|
|
22968
23182
|
`[drain-flush] FAILED for '${prev.codeName}': ${err.message} \u2014 proceeding to teardown; this session was NOT shipped (ENG-9491)`
|
|
22969
23183
|
);
|
|
22970
23184
|
}
|
|
22971
|
-
const agentDir =
|
|
23185
|
+
const agentDir = join49(adapter.getAgentDir(prev.codeName), "provision");
|
|
22972
23186
|
await cleanupAgentFiles(prev.codeName, agentDir);
|
|
22973
23187
|
clearAgentCaches(prev.agentId, prev.codeName);
|
|
22974
23188
|
}
|
|
@@ -23047,10 +23261,10 @@ async function pollCycleInner() {
|
|
|
23047
23261
|
// pending-inbound marker. Best-effort: a write failure is logged by
|
|
23048
23262
|
// the watchdog, never fails the poll cycle.
|
|
23049
23263
|
signalGiveUp: (codeName) => {
|
|
23050
|
-
const dir =
|
|
23264
|
+
const dir = join49(homedir18(), ".augmented", codeName);
|
|
23051
23265
|
if (!existsSync20(dir)) return;
|
|
23052
23266
|
atomicWriteFileSync(
|
|
23053
|
-
|
|
23267
|
+
join49(dir, "watchdog-give-up.json"),
|
|
23054
23268
|
JSON.stringify({ gave_up_at: (/* @__PURE__ */ new Date()).toISOString() })
|
|
23055
23269
|
);
|
|
23056
23270
|
},
|
|
@@ -23078,17 +23292,17 @@ async function pollCycleInner() {
|
|
|
23078
23292
|
const dir = getFramework("claude-code").getAgentDir(codeName);
|
|
23079
23293
|
if (!existsSync20(dir)) return;
|
|
23080
23294
|
atomicWriteFileSync(
|
|
23081
|
-
|
|
23295
|
+
join49(dir, "blocked-prompt.json"),
|
|
23082
23296
|
JSON.stringify({ kind, last_seen_at: (/* @__PURE__ */ new Date()).toISOString() })
|
|
23083
23297
|
);
|
|
23084
23298
|
},
|
|
23085
23299
|
clearBlockedPromptLiveness: (codeName) => {
|
|
23086
|
-
const file =
|
|
23300
|
+
const file = join49(getFramework("claude-code").getAgentDir(codeName), "blocked-prompt.json");
|
|
23087
23301
|
if (existsSync20(file)) rmSync9(file, { force: true });
|
|
23088
23302
|
},
|
|
23089
23303
|
refreshUsageLimitLiveness: (codeName) => {
|
|
23090
23304
|
const dir = getFramework("claude-code").getAgentDir(codeName);
|
|
23091
|
-
const file =
|
|
23305
|
+
const file = join49(dir, "watchdog-give-up.json");
|
|
23092
23306
|
if (!existsSync20(file)) return;
|
|
23093
23307
|
try {
|
|
23094
23308
|
const raw = JSON.parse(readFileSync39(file, "utf8"));
|
|
@@ -23102,7 +23316,7 @@ async function pollCycleInner() {
|
|
|
23102
23316
|
const dir = getFramework("claude-code").getAgentDir(codeName);
|
|
23103
23317
|
if (!existsSync20(dir)) return;
|
|
23104
23318
|
atomicWriteFileSync(
|
|
23105
|
-
|
|
23319
|
+
join49(dir, "watchdog-give-up.json"),
|
|
23106
23320
|
JSON.stringify({
|
|
23107
23321
|
gave_up_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
23108
23322
|
reason: "usage_limit",
|
|
@@ -23389,7 +23603,7 @@ async function processAgent(agent, agentStates, managedToolkits) {
|
|
|
23389
23603
|
}
|
|
23390
23604
|
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
23391
23605
|
const adapter = resolveAgentFramework(agent.code_name);
|
|
23392
|
-
let agentDir =
|
|
23606
|
+
let agentDir = join49(adapter.getAgentDir(agent.code_name), "provision");
|
|
23393
23607
|
if (agent.status === "draft" || agent.status === "paused") {
|
|
23394
23608
|
forgetChannelSyncState(agent.agent_id);
|
|
23395
23609
|
reapLegacyTokenFileEdgeWarned(agent.code_name, log);
|
|
@@ -23537,7 +23751,7 @@ async function processAgent(agent, agentStates, managedToolkits) {
|
|
|
23537
23751
|
if (refreshData.knowledge_manifest) {
|
|
23538
23752
|
const resolved = await resolveKnowledgeFromManifest({
|
|
23539
23753
|
manifest: refreshData.knowledge_manifest,
|
|
23540
|
-
cacheDir:
|
|
23754
|
+
cacheDir: join49(config.configDir, "_knowledge"),
|
|
23541
23755
|
delivery: refreshData.agent?.knowledge_delivery ?? "both",
|
|
23542
23756
|
fetchContents: async (hashes) => {
|
|
23543
23757
|
const res = await api.post(
|
|
@@ -23554,7 +23768,7 @@ async function processAgent(agent, agentStates, managedToolkits) {
|
|
|
23554
23768
|
const resolvedSkills = await resolveSkillsFromManifest({
|
|
23555
23769
|
globals: refreshData.global_skills_manifest ?? [],
|
|
23556
23770
|
shared: refreshData.shared_skills_manifest ?? [],
|
|
23557
|
-
cacheDir:
|
|
23771
|
+
cacheDir: join49(config.configDir, "_skills"),
|
|
23558
23772
|
fetchContents: async (hashes) => {
|
|
23559
23773
|
const res = await api.post(
|
|
23560
23774
|
"/host/skills/contents",
|
|
@@ -23572,7 +23786,7 @@ async function processAgent(agent, agentStates, managedToolkits) {
|
|
|
23572
23786
|
if (refreshData.integration_skills_manifest) {
|
|
23573
23787
|
const resolvedIntegrationSkills = await resolveIntegrationSkillsFromManifest({
|
|
23574
23788
|
manifest: refreshData.integration_skills_manifest,
|
|
23575
|
-
cacheDir:
|
|
23789
|
+
cacheDir: join49(config.configDir, "_skills"),
|
|
23576
23790
|
fetchContents: async (hashes) => {
|
|
23577
23791
|
const res = await api.post(
|
|
23578
23792
|
"/host/skills/contents",
|
|
@@ -23634,7 +23848,7 @@ async function processAgent(agent, agentStates, managedToolkits) {
|
|
|
23634
23848
|
const frameworkId = refreshData.agent.framework ?? DEFAULT_FRAMEWORK;
|
|
23635
23849
|
agentFrameworkCache.set(agent.code_name, frameworkId);
|
|
23636
23850
|
const frameworkAdapter = getFramework(frameworkId);
|
|
23637
|
-
agentDir =
|
|
23851
|
+
agentDir = join49(frameworkAdapter.getAgentDir(agent.code_name), "provision");
|
|
23638
23852
|
cacheAgentDeliveryMetadata(agent.code_name, refreshData);
|
|
23639
23853
|
agentRestartTimezoneInputs.set(agent.code_name, {
|
|
23640
23854
|
agentTimezone: typeof refreshData.agent.timezone === "string" ? refreshData.agent.timezone : null,
|
|
@@ -23712,7 +23926,7 @@ async function processAgent(agent, agentStates, managedToolkits) {
|
|
|
23712
23926
|
const changedFiles = [];
|
|
23713
23927
|
mkdirSync18(agentDir, { recursive: true });
|
|
23714
23928
|
for (const artifact of artifacts) {
|
|
23715
|
-
const filePath =
|
|
23929
|
+
const filePath = join49(agentDir, artifact.relativePath);
|
|
23716
23930
|
let existingHash;
|
|
23717
23931
|
let newHash;
|
|
23718
23932
|
let writeContent = artifact.content;
|
|
@@ -23731,7 +23945,7 @@ async function processAgent(agent, agentStates, managedToolkits) {
|
|
|
23731
23945
|
};
|
|
23732
23946
|
newHash = sha256(stripDynamicSections(artifact.content));
|
|
23733
23947
|
try {
|
|
23734
|
-
const projectClaudeMd =
|
|
23948
|
+
const projectClaudeMd = join49(config.configDir, agent.code_name, "project", "CLAUDE.md");
|
|
23735
23949
|
const existing = readFileSync39(projectClaudeMd, "utf-8");
|
|
23736
23950
|
existingHash = sha256(stripDynamicSections(existing));
|
|
23737
23951
|
} catch {
|
|
@@ -23782,12 +23996,12 @@ async function processAgent(agent, agentStates, managedToolkits) {
|
|
|
23782
23996
|
}
|
|
23783
23997
|
}
|
|
23784
23998
|
if (changedFiles.length > 0) {
|
|
23785
|
-
const isFirst = !existsSync20(
|
|
23999
|
+
const isFirst = !existsSync20(join49(agentDir, "CHARTER.md"));
|
|
23786
24000
|
const verb = isFirst ? "Provisioning" : "Updating";
|
|
23787
24001
|
const fileNames = changedFiles.map((f) => f.relativePath).join(", ");
|
|
23788
24002
|
log(`${verb} '${agent.code_name}': ${fileNames}`);
|
|
23789
24003
|
for (const file of changedFiles) {
|
|
23790
|
-
const filePath =
|
|
24004
|
+
const filePath = join49(agentDir, file.relativePath);
|
|
23791
24005
|
mkdirSync18(dirname11(filePath), { recursive: true });
|
|
23792
24006
|
if (file.relativePath === ".mcp.json") {
|
|
23793
24007
|
safeWriteJsonAtomic(filePath, file.content, { mode: 384 });
|
|
@@ -23796,12 +24010,12 @@ async function processAgent(agent, agentStates, managedToolkits) {
|
|
|
23796
24010
|
}
|
|
23797
24011
|
}
|
|
23798
24012
|
try {
|
|
23799
|
-
const provSkillsDir =
|
|
24013
|
+
const provSkillsDir = join49(agentDir, ".claude", "skills");
|
|
23800
24014
|
if (existsSync20(provSkillsDir)) {
|
|
23801
24015
|
for (const folder of readdirSync15(provSkillsDir)) {
|
|
23802
24016
|
if (folder.startsWith("knowledge-")) {
|
|
23803
24017
|
try {
|
|
23804
|
-
rmSync9(
|
|
24018
|
+
rmSync9(join49(provSkillsDir, folder), { recursive: true });
|
|
23805
24019
|
} catch {
|
|
23806
24020
|
}
|
|
23807
24021
|
}
|
|
@@ -23814,7 +24028,7 @@ async function processAgent(agent, agentStates, managedToolkits) {
|
|
|
23814
24028
|
const trackedFiles2 = frameworkAdapter.driftTrackedFiles();
|
|
23815
24029
|
const hashes = /* @__PURE__ */ new Map();
|
|
23816
24030
|
for (const file of trackedFiles2) {
|
|
23817
|
-
const h = hashFile(
|
|
24031
|
+
const h = hashFile(join49(agentDir, file));
|
|
23818
24032
|
if (h) hashes.set(file, h);
|
|
23819
24033
|
}
|
|
23820
24034
|
agentState.writtenHashes.set(agent.agent_id, hashes);
|
|
@@ -23832,14 +24046,14 @@ async function processAgent(agent, agentStates, managedToolkits) {
|
|
|
23832
24046
|
}
|
|
23833
24047
|
if (Array.isArray(refreshData.workflows)) {
|
|
23834
24048
|
try {
|
|
23835
|
-
const provWorkflowsDir =
|
|
24049
|
+
const provWorkflowsDir = join49(agentDir, ".claude", "workflows");
|
|
23836
24050
|
if (existsSync20(provWorkflowsDir)) {
|
|
23837
24051
|
const expected = new Set(refreshData.workflows.map((w) => `${w.name}.js`));
|
|
23838
24052
|
for (const file of readdirSync15(provWorkflowsDir)) {
|
|
23839
24053
|
if (!file.endsWith(".js")) continue;
|
|
23840
24054
|
if (expected.has(file)) continue;
|
|
23841
24055
|
try {
|
|
23842
|
-
rmSync9(
|
|
24056
|
+
rmSync9(join49(provWorkflowsDir, file));
|
|
23843
24057
|
} catch {
|
|
23844
24058
|
}
|
|
23845
24059
|
}
|
|
@@ -23934,7 +24148,7 @@ async function processAgent(agent, agentStates, managedToolkits) {
|
|
|
23934
24148
|
if (written && existsSync20(agentDir)) {
|
|
23935
24149
|
const driftedFiles = [];
|
|
23936
24150
|
for (const [file, expectedHash] of written) {
|
|
23937
|
-
const localHash = hashFile(
|
|
24151
|
+
const localHash = hashFile(join49(agentDir, file));
|
|
23938
24152
|
if (localHash && localHash !== expectedHash) {
|
|
23939
24153
|
driftedFiles.push(file);
|
|
23940
24154
|
}
|
|
@@ -23945,7 +24159,7 @@ async function processAgent(agent, agentStates, managedToolkits) {
|
|
|
23945
24159
|
try {
|
|
23946
24160
|
const localHashes = {};
|
|
23947
24161
|
for (const file of driftedFiles) {
|
|
23948
|
-
localHashes[file] = hashFile(
|
|
24162
|
+
localHashes[file] = hashFile(join49(agentDir, file));
|
|
23949
24163
|
}
|
|
23950
24164
|
await api.post("/host/drift", {
|
|
23951
24165
|
agent_id: agent.agent_id,
|
|
@@ -24230,7 +24444,7 @@ async function processAgent(agent, agentStates, managedToolkits) {
|
|
|
24230
24444
|
const addedChannels = [...restartDecision.added];
|
|
24231
24445
|
const writeDmNoticeMarkers = isChannelAddRestart ? () => {
|
|
24232
24446
|
try {
|
|
24233
|
-
const agentAugmentedDir =
|
|
24447
|
+
const agentAugmentedDir = join49(homedir18(), ".augmented", agent.code_name);
|
|
24234
24448
|
mkdirSync18(agentAugmentedDir, { recursive: true });
|
|
24235
24449
|
const markerJson = JSON.stringify({
|
|
24236
24450
|
version: 1,
|
|
@@ -24238,7 +24452,7 @@ async function processAgent(agent, agentStates, managedToolkits) {
|
|
|
24238
24452
|
added: addedChannels
|
|
24239
24453
|
});
|
|
24240
24454
|
for (const file of ["slack-channel-add-restart.json", "telegram-channel-add-restart.json"]) {
|
|
24241
|
-
atomicWriteFileSync(
|
|
24455
|
+
atomicWriteFileSync(join49(agentAugmentedDir, file), markerJson);
|
|
24242
24456
|
}
|
|
24243
24457
|
} catch (err) {
|
|
24244
24458
|
log(`[hot-reload] channel-add DM-notice marker write failed for '${agent.code_name}' (non-fatal): ${err.message}`);
|
|
@@ -24542,18 +24756,18 @@ async function processAgent(agent, agentStates, managedToolkits) {
|
|
|
24542
24756
|
if (agentSessionMode === "persistent" && (agentFrameworkCache.get(agent.code_name) ?? DEFAULT_FRAMEWORK) === "claude-code") {
|
|
24543
24757
|
try {
|
|
24544
24758
|
const agentProvisionDir = agentDir;
|
|
24545
|
-
const projectDir =
|
|
24759
|
+
const projectDir = join49(homedir18(), ".augmented", agent.code_name, "project");
|
|
24546
24760
|
mkdirSync18(agentProvisionDir, { recursive: true });
|
|
24547
24761
|
mkdirSync18(projectDir, { recursive: true });
|
|
24548
|
-
const provisionMcpPath =
|
|
24549
|
-
const projectMcpPath =
|
|
24762
|
+
const provisionMcpPath = join49(agentProvisionDir, ".mcp.json");
|
|
24763
|
+
const projectMcpPath = join49(projectDir, ".mcp.json");
|
|
24550
24764
|
let mcpConfig = { mcpServers: {} };
|
|
24551
24765
|
try {
|
|
24552
24766
|
mcpConfig = JSON.parse(readFileSync39(provisionMcpPath, "utf-8"));
|
|
24553
24767
|
if (!mcpConfig.mcpServers) mcpConfig.mcpServers = {};
|
|
24554
24768
|
} catch {
|
|
24555
24769
|
}
|
|
24556
|
-
const localDirectChatChannel =
|
|
24770
|
+
const localDirectChatChannel = join49(homedir18(), ".augmented", "_mcp", "direct-chat-channel.js");
|
|
24557
24771
|
const directChatTeamSettings = refreshData.team?.settings;
|
|
24558
24772
|
const directChatTz = (() => {
|
|
24559
24773
|
const tz = directChatTeamSettings?.["timezone"];
|
|
@@ -24579,7 +24793,7 @@ async function processAgent(agent, agentStates, managedToolkits) {
|
|
|
24579
24793
|
// ~/.augmented/<codeName>/.current-turn-initiator.json. Note getAgentDir
|
|
24580
24794
|
// returns the agent root (NOT the /provision subdir `agentDir` points at),
|
|
24581
24795
|
// so it byte-matches the broker readers' path.
|
|
24582
|
-
AGT_TURN_INITIATOR_FILE:
|
|
24796
|
+
AGT_TURN_INITIATOR_FILE: join49(
|
|
24583
24797
|
frameworkAdapter.getAgentDir(agent.code_name),
|
|
24584
24798
|
".current-turn-initiator.json"
|
|
24585
24799
|
)
|
|
@@ -24599,7 +24813,7 @@ async function processAgent(agent, agentStates, managedToolkits) {
|
|
|
24599
24813
|
log(`Channel credentials written for '${agent.code_name}/direct-chat'`);
|
|
24600
24814
|
}
|
|
24601
24815
|
}
|
|
24602
|
-
const staleChannelsPath =
|
|
24816
|
+
const staleChannelsPath = join49(projectDir, ".mcp-channels.json");
|
|
24603
24817
|
if (existsSync20(staleChannelsPath)) {
|
|
24604
24818
|
try {
|
|
24605
24819
|
rmSync9(staleChannelsPath, { force: true });
|
|
@@ -24727,7 +24941,7 @@ async function processAgent(agent, agentStates, managedToolkits) {
|
|
|
24727
24941
|
}
|
|
24728
24942
|
if (hostFlagStore().getBoolean("connectivity-probe")) {
|
|
24729
24943
|
try {
|
|
24730
|
-
const probeProjectDir =
|
|
24944
|
+
const probeProjectDir = join49(homedir18(), ".augmented", agent.code_name, "project");
|
|
24731
24945
|
let probeSet = integrations;
|
|
24732
24946
|
const fetchQuarantined = async () => {
|
|
24733
24947
|
const quarantined = await api.post("/host/agent-integrations/quarantined", { agent_id: agent.agent_id });
|
|
@@ -24789,7 +25003,7 @@ async function processAgent(agent, agentStates, managedToolkits) {
|
|
|
24789
25003
|
const forceDue = attemptsLeft > 0;
|
|
24790
25004
|
let probeRan = false;
|
|
24791
25005
|
try {
|
|
24792
|
-
const probeProjectDir =
|
|
25006
|
+
const probeProjectDir = join49(homedir18(), ".augmented", agent.code_name, "project");
|
|
24793
25007
|
const renderPending = integrationRenderPending(
|
|
24794
25008
|
integrations,
|
|
24795
25009
|
agentState.knownIntegrationHashes.get(agent.agent_id)
|
|
@@ -24918,8 +25132,8 @@ async function processAgent(agent, agentStates, managedToolkits) {
|
|
|
24918
25132
|
const intHash = computeIntegrationsHash(integrations);
|
|
24919
25133
|
const prevIntHash = agentState.knownIntegrationHashes.get(agent.agent_id);
|
|
24920
25134
|
if (intHash !== prevIntHash) {
|
|
24921
|
-
const projectDir =
|
|
24922
|
-
const envIntPath =
|
|
25135
|
+
const projectDir = join49(homedir18(), ".augmented", agent.code_name, "project");
|
|
25136
|
+
const envIntPath = join49(projectDir, ".env.integrations");
|
|
24923
25137
|
let preWriteEnv;
|
|
24924
25138
|
try {
|
|
24925
25139
|
preWriteEnv = readFileSync39(envIntPath, "utf-8");
|
|
@@ -24950,7 +25164,7 @@ async function processAgent(agent, agentStates, managedToolkits) {
|
|
|
24950
25164
|
}
|
|
24951
25165
|
if (fw === "claude-code" && isSessionHealthy(agent.code_name)) {
|
|
24952
25166
|
try {
|
|
24953
|
-
const projectMcpPath =
|
|
25167
|
+
const projectMcpPath = join49(projectDir, ".mcp.json");
|
|
24954
25168
|
const postWriteEnv = readFileSync39(envIntPath, "utf-8");
|
|
24955
25169
|
const mcpContent = readFileSync39(projectMcpPath, "utf-8");
|
|
24956
25170
|
const changedVars = diffEnvIntegrations(preWriteEnv, postWriteEnv);
|
|
@@ -25305,16 +25519,16 @@ async function processAgent(agent, agentStates, managedToolkits) {
|
|
|
25305
25519
|
}
|
|
25306
25520
|
try {
|
|
25307
25521
|
const { readdirSync: readdirSync16, rmSync: rmSync10 } = await import("fs");
|
|
25308
|
-
const { homedir:
|
|
25522
|
+
const { homedir: homedir19 } = await import("os");
|
|
25309
25523
|
const frameworkId2 = frameworkAdapter.id;
|
|
25310
25524
|
const candidateSkillDirs = [
|
|
25311
25525
|
// Claude Code — framework runtime tree
|
|
25312
|
-
|
|
25526
|
+
join49(homedir19(), ".augmented", agent.code_name, "skills"),
|
|
25313
25527
|
// Claude Code — project tree
|
|
25314
|
-
|
|
25528
|
+
join49(homedir19(), ".augmented", agent.code_name, "project", ".claude", "skills"),
|
|
25315
25529
|
// Defensive: legacy provision-side path, not currently an
|
|
25316
25530
|
// install target but cheap to sweep.
|
|
25317
|
-
|
|
25531
|
+
join49(agentDir, ".claude", "skills")
|
|
25318
25532
|
];
|
|
25319
25533
|
const existingDirs = candidateSkillDirs.filter((d) => existsSync20(d));
|
|
25320
25534
|
const discoveredEntries = /* @__PURE__ */ new Set();
|
|
@@ -25357,7 +25571,7 @@ async function processAgent(agent, agentStates, managedToolkits) {
|
|
|
25357
25571
|
const sharedSkillsPayload = refreshAny.shared_skills;
|
|
25358
25572
|
const desiredResolved = globalSkillsPayload !== void 0 || sharedSkillsPayload !== void 0;
|
|
25359
25573
|
const manifestPath = managedSkillManifestPath(
|
|
25360
|
-
|
|
25574
|
+
join49(homedir18(), ".augmented", agent.code_name)
|
|
25361
25575
|
);
|
|
25362
25576
|
const prevIds = /* @__PURE__ */ new Set([
|
|
25363
25577
|
...agentState.knownGlobalSkillIds.get(agent.agent_id) ?? /* @__PURE__ */ new Set(),
|
|
@@ -25377,15 +25591,15 @@ async function processAgent(agent, agentStates, managedToolkits) {
|
|
|
25377
25591
|
}
|
|
25378
25592
|
if (plan.removes.length) {
|
|
25379
25593
|
const globalSkillDirs = [
|
|
25380
|
-
|
|
25381
|
-
|
|
25382
|
-
|
|
25594
|
+
join49(homedir18(), ".augmented", agent.code_name, "skills"),
|
|
25595
|
+
join49(homedir18(), ".augmented", agent.code_name, "project", ".claude", "skills"),
|
|
25596
|
+
join49(agentDir, ".claude", "skills")
|
|
25383
25597
|
];
|
|
25384
25598
|
for (const id of plan.removes) {
|
|
25385
25599
|
let prunedAny = false;
|
|
25386
25600
|
for (const dir of globalSkillDirs) {
|
|
25387
|
-
const p =
|
|
25388
|
-
if (existsSync20(p) && existsSync20(
|
|
25601
|
+
const p = join49(dir, id);
|
|
25602
|
+
if (existsSync20(p) && existsSync20(join49(p, "SKILL.md"))) {
|
|
25389
25603
|
rmSync9(p, { recursive: true, force: true });
|
|
25390
25604
|
prunedAny = true;
|
|
25391
25605
|
}
|
|
@@ -26178,7 +26392,7 @@ Retried to the limit after repeated stalls \u2014 needs a look.`).catch(() => {
|
|
|
26178
26392
|
if (trackedFiles.length > 0 && existsSync20(agentDir)) {
|
|
26179
26393
|
const hashes = /* @__PURE__ */ new Map();
|
|
26180
26394
|
for (const file of trackedFiles) {
|
|
26181
|
-
const h = hashFile(
|
|
26395
|
+
const h = hashFile(join49(agentDir, file));
|
|
26182
26396
|
if (h) hashes.set(file, h);
|
|
26183
26397
|
}
|
|
26184
26398
|
agentState.writtenHashes.set(agent.agent_id, hashes);
|
|
@@ -26193,7 +26407,7 @@ Retried to the limit after repeated stalls \u2014 needs a look.`).catch(() => {
|
|
|
26193
26407
|
refreshData.agent.onboarding_state
|
|
26194
26408
|
);
|
|
26195
26409
|
const obStep = obState.step;
|
|
26196
|
-
const markerPath =
|
|
26410
|
+
const markerPath = join49(homedir18(), ".augmented", agent.code_name, "onboarding-drive.json");
|
|
26197
26411
|
const marker = readOnboardingDriveMarker(markerPath);
|
|
26198
26412
|
const obContactRaw = refreshData.agent.manager_last_contacted_at;
|
|
26199
26413
|
const obContact = typeof obContactRaw === "string" && obContactRaw ? obContactRaw : null;
|
|
@@ -26327,7 +26541,7 @@ async function ensureOpencodeRuntime(agent, refreshData, agentTimezone) {
|
|
|
26327
26541
|
}
|
|
26328
26542
|
stopOpencodeSlackIngest(codeName, log);
|
|
26329
26543
|
stopOpencodeTelegramIngest(codeName, log);
|
|
26330
|
-
const opencodeProjectDir =
|
|
26544
|
+
const opencodeProjectDir = join49(getFramework("opencode").getAgentDir(codeName), "provision");
|
|
26331
26545
|
const serveEnv = {
|
|
26332
26546
|
AGT_HOST: requireHost(),
|
|
26333
26547
|
AGT_API_KEY: getApiKey() ?? void 0,
|
|
@@ -26436,8 +26650,8 @@ async function ensurePersistentSessionUnchecked(agent, tasks, boardItems, refres
|
|
|
26436
26650
|
});
|
|
26437
26651
|
}
|
|
26438
26652
|
const projectDir = getProjectDir(codeName);
|
|
26439
|
-
const mcpConfigPath =
|
|
26440
|
-
const claudeMdPath =
|
|
26653
|
+
const mcpConfigPath = join49(projectDir, ".mcp.json");
|
|
26654
|
+
const claudeMdPath = join49(projectDir, "CLAUDE.md");
|
|
26441
26655
|
if (restartBreaker.isTripped(codeName)) {
|
|
26442
26656
|
const trip = restartBreaker.getTrip(codeName);
|
|
26443
26657
|
return {
|
|
@@ -27120,13 +27334,18 @@ ${truncateForLog(ctx.tail)}` : `; pane_tail_hash=sha256:${createHash21("sha256")
|
|
|
27120
27334
|
});
|
|
27121
27335
|
if (!spawnCopyFailedNow) spawnCopyFailures.noteSuccess(codeName);
|
|
27122
27336
|
const grantForLaunch = singleStartGrantId;
|
|
27123
|
-
const
|
|
27337
|
+
const launchFence = deferredLaunchFence({
|
|
27338
|
+
grantedSingleStart,
|
|
27339
|
+
subscriptionBacked,
|
|
27340
|
+
grantId: grantForLaunch,
|
|
27341
|
+
hold: hostAuthRefreshHold
|
|
27342
|
+
});
|
|
27124
27343
|
const lateRefusal = startWithIsolationBackstop(() => startPersistentSession({
|
|
27125
27344
|
codeName,
|
|
27126
27345
|
agentId: agent.agent_id,
|
|
27127
27346
|
isolationReadiness: startReadiness,
|
|
27128
|
-
launchStillAllowed,
|
|
27129
|
-
onLaunchFenced:
|
|
27347
|
+
launchStillAllowed: launchFence.launchStillAllowed,
|
|
27348
|
+
onLaunchFenced: launchFence.fencedReason ? () => closeSessionRunForCode(codeName, "cancelled", launchFence.fencedReason()) : void 0,
|
|
27130
27349
|
projectDir,
|
|
27131
27350
|
mcpConfigPath: spawnMcpConfigPath,
|
|
27132
27351
|
claudeMdPath,
|
|
@@ -27560,7 +27779,7 @@ async function managerRestartMayKill(agentId, codeName, requestedAt, lane, frame
|
|
|
27560
27779
|
);
|
|
27561
27780
|
}
|
|
27562
27781
|
if (verdict.kill && effectiveIsolationMode(codeName) !== "docker") {
|
|
27563
|
-
const dc = readDirectChatInflight(
|
|
27782
|
+
const dc = readDirectChatInflight(join49(homedir18(), ".augmented", agentId));
|
|
27564
27783
|
if (dc.inFlight) {
|
|
27565
27784
|
verdict = { kill: false, reason: "direct_chat_in_flight", runningBackgroundTasks: null };
|
|
27566
27785
|
log(`[${lane}] manager restart for '${codeName}': ${dc.ids.length} Direct Chat message(s) claimed and not yet answered [ENG-12100]`);
|
|
@@ -27638,7 +27857,7 @@ async function handleRestartDoorbell(agentId, requestedAt, restartReason) {
|
|
|
27638
27857
|
if (!refreshData) return;
|
|
27639
27858
|
const framework = refreshData.agent?.framework ?? agentFrameworkCache.get(codeName) ?? DEFAULT_FRAMEWORK;
|
|
27640
27859
|
const hostId = await getHostId();
|
|
27641
|
-
const parkForRestart = await import("../responsiveness-probe-
|
|
27860
|
+
const parkForRestart = await import("../responsiveness-probe-EJJNNPNB.js").then(
|
|
27642
27861
|
(m) => m.parkPendingInbound,
|
|
27643
27862
|
(err) => err
|
|
27644
27863
|
);
|
|
@@ -27719,10 +27938,10 @@ async function handleRestartDoorbell(agentId, requestedAt, restartReason) {
|
|
|
27719
27938
|
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
27939
|
void (async () => {
|
|
27721
27940
|
try {
|
|
27722
|
-
const { collectDiagnostics } = await import("../persistent-session-
|
|
27941
|
+
const { collectDiagnostics } = await import("../persistent-session-XFZ43IDB.js");
|
|
27723
27942
|
await api.post("/host/heartbeat", {
|
|
27724
27943
|
host_id: hostId,
|
|
27725
|
-
agent_diagnostics: collectDiagnostics([codeName], quarantineEntriesFor, claudeMdSizeFor, spawnOutcomeForDiagnostics, pidPressureFor, forwardedToolsFor, runtimeVersionFor, sessionActivityFor)
|
|
27944
|
+
agent_diagnostics: collectDiagnostics([codeName], quarantineEntriesFor, claudeMdSizeFor, spawnOutcomeForDiagnostics, pidPressureFor, forwardedToolsFor, runtimeVersionFor, sessionActivityFor, agentDiskFor)
|
|
27726
27945
|
});
|
|
27727
27946
|
} catch (err) {
|
|
27728
27947
|
log(`[restart-lane] post-respawn diagnostics flush failed for '${codeName}': ${err.message}`);
|
|
@@ -27772,10 +27991,10 @@ async function respawnAgentAfterMcpStop(codeName, reason) {
|
|
|
27772
27991
|
}
|
|
27773
27992
|
try {
|
|
27774
27993
|
const hostId = await getHostId();
|
|
27775
|
-
const { collectDiagnostics } = await import("../persistent-session-
|
|
27994
|
+
const { collectDiagnostics } = await import("../persistent-session-XFZ43IDB.js");
|
|
27776
27995
|
await api.post("/host/heartbeat", {
|
|
27777
27996
|
host_id: hostId,
|
|
27778
|
-
agent_diagnostics: collectDiagnostics([codeName], quarantineEntriesFor, claudeMdSizeFor, spawnOutcomeForDiagnostics, pidPressureFor, forwardedToolsFor, runtimeVersionFor, sessionActivityFor)
|
|
27997
|
+
agent_diagnostics: collectDiagnostics([codeName], quarantineEntriesFor, claudeMdSizeFor, spawnOutcomeForDiagnostics, pidPressureFor, forwardedToolsFor, runtimeVersionFor, sessionActivityFor, agentDiskFor)
|
|
27779
27998
|
});
|
|
27780
27999
|
} catch (err) {
|
|
27781
28000
|
log(`[fast-mcp-respawn] post-respawn diagnostics flush failed for '${codeName}': ${err.message}`);
|
|
@@ -28326,7 +28545,7 @@ async function processDirectChatMessage(agent, msg) {
|
|
|
28326
28545
|
});
|
|
28327
28546
|
if (route.kind === "ring") {
|
|
28328
28547
|
try {
|
|
28329
|
-
const doorbell = directChatDoorbellPath(agent.agentId,
|
|
28548
|
+
const doorbell = directChatDoorbellPath(agent.agentId, homedir18());
|
|
28330
28549
|
mkdirSync18(dirname11(doorbell), { recursive: true });
|
|
28331
28550
|
writeFileSync20(doorbell, String(Date.now()));
|
|
28332
28551
|
log(`[direct-chat] Doorbell rung for '${agent.codeName}' (msg=${msg.id}) \u2014 in-session MCP will pull via the cursor`);
|
|
@@ -28486,7 +28705,7 @@ ${formatRunMarker(run_id)}` : KANBAN_CHECK_COMMAND;
|
|
|
28486
28705
|
}
|
|
28487
28706
|
if (run_id) openInjectedRunByCode.set(codeName, run_id);
|
|
28488
28707
|
try {
|
|
28489
|
-
const doorbell = directChatDoorbellPath(agentId,
|
|
28708
|
+
const doorbell = directChatDoorbellPath(agentId, homedir18());
|
|
28490
28709
|
mkdirSync18(dirname11(doorbell), { recursive: true });
|
|
28491
28710
|
writeFileSync20(doorbell, String(Date.now()));
|
|
28492
28711
|
} catch (err) {
|
|
@@ -28648,7 +28867,7 @@ async function processClaudePairSessions(agents) {
|
|
|
28648
28867
|
snapshotPairConfig,
|
|
28649
28868
|
// ENG-11659: result -> report body + the manager.log line that records it.
|
|
28650
28869
|
planPairStartReport
|
|
28651
|
-
} = await import("../claude-pair-runtime-
|
|
28870
|
+
} = await import("../claude-pair-runtime-5EGI66ET.js");
|
|
28652
28871
|
const { resetClaudeSignin, describeSigninResetForLog, describeSigninResetFailure } = await import("../claude-signin-reset-6IJMMVYG.js");
|
|
28653
28872
|
for (const pairId of pendingResp.cancelled_pair_ids ?? []) {
|
|
28654
28873
|
log(`[claude-pair] sweeping orphan tmux session for pair ${pairId.slice(0, 8)}`);
|
|
@@ -28947,10 +29166,10 @@ var lastLocalFileHash = /* @__PURE__ */ new Map();
|
|
|
28947
29166
|
var lastMemoriesBody = /* @__PURE__ */ new Map();
|
|
28948
29167
|
var memoryManifests = /* @__PURE__ */ new Map();
|
|
28949
29168
|
function memoryRetirementDir(configDir, codeName) {
|
|
28950
|
-
return
|
|
29169
|
+
return join49(configDir, "_memory-retirement", codeName);
|
|
28951
29170
|
}
|
|
28952
29171
|
function memoryManifestPath(configDir, codeName) {
|
|
28953
|
-
return
|
|
29172
|
+
return join49(memoryRetirementDir(configDir, codeName), "manifest.json");
|
|
28954
29173
|
}
|
|
28955
29174
|
function loadMemoryManifest(agentId, configDir, codeName) {
|
|
28956
29175
|
const cached = memoryManifests.get(agentId);
|
|
@@ -28985,7 +29204,7 @@ function saveMemoryManifest(agentId, configDir, codeName) {
|
|
|
28985
29204
|
}
|
|
28986
29205
|
}
|
|
28987
29206
|
function retiredMemoryDir(configDir, codeName) {
|
|
28988
|
-
return
|
|
29207
|
+
return join49(memoryRetirementDir(configDir, codeName), "retired");
|
|
28989
29208
|
}
|
|
28990
29209
|
var RETIRED_MEMORY_TTL_MS = 30 * 24 * 60 * 60 * 1e3;
|
|
28991
29210
|
var lastRetirementReport = /* @__PURE__ */ new Map();
|
|
@@ -29064,7 +29283,7 @@ function applyMemoryTombstones(opts) {
|
|
|
29064
29283
|
log2(`[memory-retire] ${agent.code_name}: KEPT '${tomb.name}' \u2014 no write record, not ours to remove`);
|
|
29065
29284
|
continue;
|
|
29066
29285
|
}
|
|
29067
|
-
const filePath =
|
|
29286
|
+
const filePath = join49(memoryDir, entry.file);
|
|
29068
29287
|
if (!existsSync20(filePath)) {
|
|
29069
29288
|
outcomes.already_gone++;
|
|
29070
29289
|
delete manifest[tomb.name];
|
|
@@ -29084,9 +29303,9 @@ function applyMemoryTombstones(opts) {
|
|
|
29084
29303
|
const destDir = retiredMemoryDir(configDir, agent.code_name);
|
|
29085
29304
|
mkdirSync18(destDir, { recursive: true });
|
|
29086
29305
|
const stamp = Date.now();
|
|
29087
|
-
let dest =
|
|
29306
|
+
let dest = join49(destDir, `${entry.file}.${stamp}.retired`);
|
|
29088
29307
|
for (let n = 1; existsSync20(dest); n++) {
|
|
29089
|
-
dest =
|
|
29308
|
+
dest = join49(destDir, `${entry.file}.${stamp}-${n}.retired`);
|
|
29090
29309
|
}
|
|
29091
29310
|
renameSync12(filePath, dest);
|
|
29092
29311
|
try {
|
|
@@ -29125,7 +29344,7 @@ function reapRetiredMemories(configDir, codeName, log2) {
|
|
|
29125
29344
|
try {
|
|
29126
29345
|
for (const file of readdirSync15(dir)) {
|
|
29127
29346
|
if (!file.endsWith(".retired")) continue;
|
|
29128
|
-
const path =
|
|
29347
|
+
const path = join49(dir, file);
|
|
29129
29348
|
try {
|
|
29130
29349
|
if (statSync15(path).mtimeMs < cutoff) {
|
|
29131
29350
|
unlinkSync6(path);
|
|
@@ -29140,8 +29359,8 @@ function reapRetiredMemories(configDir, codeName, log2) {
|
|
|
29140
29359
|
if (reaped > 0) log2(`[memory-retire] ${codeName}: reaped ${reaped} retired memory file(s) past TTL`);
|
|
29141
29360
|
}
|
|
29142
29361
|
async function syncMemories(agent, configDir, log2) {
|
|
29143
|
-
const projectDir =
|
|
29144
|
-
const memoryDir =
|
|
29362
|
+
const projectDir = join49(configDir, agent.code_name, "project");
|
|
29363
|
+
const memoryDir = join49(projectDir, "memory");
|
|
29145
29364
|
const isFreshSync = pendingFreshMemorySync.has(agent.agent_id);
|
|
29146
29365
|
if (isFreshSync) {
|
|
29147
29366
|
log2(`[memory-sync] Fresh-sync requested for '${agent.code_name}' \u2014 pulling DB first`);
|
|
@@ -29172,7 +29391,7 @@ async function syncMemories(agent, configDir, log2) {
|
|
|
29172
29391
|
for (const file of readdirSync15(memoryDir)) {
|
|
29173
29392
|
if (!file.endsWith(".md")) continue;
|
|
29174
29393
|
try {
|
|
29175
|
-
const raw = readFileSync39(
|
|
29394
|
+
const raw = readFileSync39(join49(memoryDir, file), "utf-8");
|
|
29176
29395
|
const fileHash = createHash21("sha256").update(raw).digest("hex").slice(0, 16);
|
|
29177
29396
|
currentHashes.set(file, fileHash);
|
|
29178
29397
|
if (prevHashes.get(file) === fileHash) continue;
|
|
@@ -29197,7 +29416,7 @@ async function syncMemories(agent, configDir, log2) {
|
|
|
29197
29416
|
} catch (err) {
|
|
29198
29417
|
for (const mem of changedMemories) {
|
|
29199
29418
|
for (const [file] of currentHashes) {
|
|
29200
|
-
const parsed = parseMemoryFile(readFileSync39(
|
|
29419
|
+
const parsed = parseMemoryFile(readFileSync39(join49(memoryDir, file), "utf-8"), file.replace(/\.md$/, ""));
|
|
29201
29420
|
if (parsed?.name === mem.name) currentHashes.delete(file);
|
|
29202
29421
|
}
|
|
29203
29422
|
}
|
|
@@ -29278,7 +29497,7 @@ async function downloadMemories(agent, memoryDir, log2, { force, configDir }) {
|
|
|
29278
29497
|
// Per-agent, not host-wide: memories are agent-private, so a shared
|
|
29279
29498
|
// store would buy almost no dedupe while exposing one agent's content
|
|
29280
29499
|
// to every other agent on the host. See memory-cache.ts's header.
|
|
29281
|
-
cacheDir:
|
|
29500
|
+
cacheDir: join49(configDir, agent.code_name, "_memory_bodies"),
|
|
29282
29501
|
fetchContents: async (hashes) => {
|
|
29283
29502
|
const res = await api.post(
|
|
29284
29503
|
"/host/memories/contents",
|
|
@@ -29316,7 +29535,7 @@ async function downloadMemories(agent, memoryDir, log2, { force, configDir }) {
|
|
|
29316
29535
|
const rawSlug = mem.name.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/(^-|-$)/g, "").slice(0, 60);
|
|
29317
29536
|
const slug = rawSlug || `memory-${i}`;
|
|
29318
29537
|
const fileName = `${slug}.md`;
|
|
29319
|
-
const filePath =
|
|
29538
|
+
const filePath = join49(memoryDir, fileName);
|
|
29320
29539
|
const desired = `---
|
|
29321
29540
|
name: ${JSON.stringify(mem.name)}
|
|
29322
29541
|
type: ${mem.type}
|
|
@@ -29503,6 +29722,13 @@ function startPolling() {
|
|
|
29503
29722
|
claudePairLoop.start();
|
|
29504
29723
|
startPaneOccupancySampler(() => agentState.persistentSessionAgents);
|
|
29505
29724
|
startPidPressureSampler(() => agentState.persistentSessionAgents);
|
|
29725
|
+
startAgentDiskSampler(
|
|
29726
|
+
() => [...agentState.persistentSessionAgents].map((codeName) => ({
|
|
29727
|
+
codeName,
|
|
29728
|
+
agentId: agentState.codeNameToAgentId.get(codeName) ?? null,
|
|
29729
|
+
isolated: effectiveIsolationMode(codeName) === "docker"
|
|
29730
|
+
}))
|
|
29731
|
+
);
|
|
29506
29732
|
startRuntimeVersionSampler(() => agentState.persistentSessionAgents);
|
|
29507
29733
|
{
|
|
29508
29734
|
const seedOutcome = seedClaudeConfigFromLegacy({ log });
|
|
@@ -29683,6 +29909,7 @@ async function stopPolling(opts = {}) {
|
|
|
29683
29909
|
clearTimeout(pollTimer);
|
|
29684
29910
|
pollTimer = null;
|
|
29685
29911
|
}
|
|
29912
|
+
stopAgentDiskSampler();
|
|
29686
29913
|
if (livenessTimer) {
|
|
29687
29914
|
clearInterval(livenessTimer);
|
|
29688
29915
|
livenessTimer = null;
|
|
@@ -29788,7 +30015,7 @@ function startManager(opts) {
|
|
|
29788
30015
|
log(`[startup] state rehydration failed (continuing with empty state): ${err.message}`);
|
|
29789
30016
|
}
|
|
29790
30017
|
log(
|
|
29791
|
-
`[startup] worker pid=${process.pid} ppid=${process.ppid} node=${process.version} log=${
|
|
30018
|
+
`[startup] worker pid=${process.pid} ppid=${process.ppid} node=${process.version} log=${join49(homedir18(), ".augmented", "manager.log")}`
|
|
29792
30019
|
);
|
|
29793
30020
|
deployMcpAssets();
|
|
29794
30021
|
reapOrphanChannelMcps({ log });
|
|
@@ -29914,14 +30141,14 @@ function restartRunningChannelMcps(basenames) {
|
|
|
29914
30141
|
}
|
|
29915
30142
|
}
|
|
29916
30143
|
function deployMcpAssets() {
|
|
29917
|
-
const targetDir =
|
|
30144
|
+
const targetDir = join49(homedir18(), ".augmented", "_mcp");
|
|
29918
30145
|
mkdirSync18(targetDir, { recursive: true });
|
|
29919
30146
|
const moduleDir = dirname11(fileURLToPath2(import.meta.url));
|
|
29920
30147
|
let mcpSourceDir = "";
|
|
29921
30148
|
let dir = moduleDir;
|
|
29922
30149
|
for (let i = 0; i < 6; i++) {
|
|
29923
|
-
const candidate =
|
|
29924
|
-
if (existsSync20(
|
|
30150
|
+
const candidate = join49(dir, "dist", "mcp");
|
|
30151
|
+
if (existsSync20(join49(candidate, "index.js"))) {
|
|
29925
30152
|
mcpSourceDir = candidate;
|
|
29926
30153
|
break;
|
|
29927
30154
|
}
|
|
@@ -30021,8 +30248,8 @@ function deployMcpAssets() {
|
|
|
30021
30248
|
// natural session restart.
|
|
30022
30249
|
"computer-use-proxy.js"
|
|
30023
30250
|
]) {
|
|
30024
|
-
const src =
|
|
30025
|
-
const dst =
|
|
30251
|
+
const src = join49(mcpSourceDir, file);
|
|
30252
|
+
const dst = join49(targetDir, file);
|
|
30026
30253
|
if (!existsSync20(src)) continue;
|
|
30027
30254
|
attemptedFiles.push(file);
|
|
30028
30255
|
const before = fileHash(dst);
|
|
@@ -30048,14 +30275,14 @@ function deployMcpAssets() {
|
|
|
30048
30275
|
log(`[manager] Bundle(s) updated: ${changedBasenames.join(", ")} \u2014 signalling running instances to restart`);
|
|
30049
30276
|
restartRunningChannelMcps(changedBasenames);
|
|
30050
30277
|
}
|
|
30051
|
-
const localMcpPath =
|
|
30278
|
+
const localMcpPath = join49(targetDir, "index.js");
|
|
30052
30279
|
try {
|
|
30053
|
-
const agentsDir =
|
|
30280
|
+
const agentsDir = join49(homedir18(), ".augmented", "agents");
|
|
30054
30281
|
if (existsSync20(agentsDir)) {
|
|
30055
30282
|
for (const entry of readdirSync15(agentsDir, { withFileTypes: true })) {
|
|
30056
30283
|
if (!entry.isDirectory()) continue;
|
|
30057
30284
|
for (const subdir of ["provision", "project"]) {
|
|
30058
|
-
const mcpJsonPath =
|
|
30285
|
+
const mcpJsonPath = join49(agentsDir, entry.name, subdir, ".mcp.json");
|
|
30059
30286
|
try {
|
|
30060
30287
|
const raw = readFileSync39(mcpJsonPath, "utf-8");
|
|
30061
30288
|
if (!raw.includes("@integrity-labs/augmented-mcp")) continue;
|