@integrity-labs/agt-cli 0.28.1259 → 0.28.1261
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-ATRLQZOU.js → api-client-2YLFNHFZ.js} +3 -3
- package/dist/bin/agt.js +7 -7
- package/dist/{chunk-5433KPH4.js → chunk-335HKIDZ.js} +2 -2
- package/dist/{chunk-BOITSKCM.js → chunk-6NHFZYUP.js} +3 -3
- package/dist/{chunk-RBC22FRC.js → chunk-I2NQQOMD.js} +3 -3
- package/dist/{chunk-F6U3ZJCG.js → chunk-JYSPPCHG.js} +2 -2
- package/dist/{chunk-NRNPYXG6.js → chunk-QFLR5EFT.js} +98 -6
- package/dist/chunk-QFLR5EFT.js.map +1 -0
- package/dist/{chunk-UAO5VMYK.js → chunk-ZEJUBTXJ.js} +441 -254
- package/dist/chunk-ZEJUBTXJ.js.map +1 -0
- package/dist/{claude-code-updater-SUL3OSGB.js → claude-code-updater-B2BWPRFE.js} +3 -3
- package/dist/{claude-pair-runtime-D6ZRO2FC.js → claude-pair-runtime-FNDHAPXR.js} +3 -3
- package/dist/lib/manager-worker.js +580 -427
- package/dist/lib/manager-worker.js.map +1 -1
- package/dist/mcp/direct-chat-channel.js +94 -2
- package/dist/mcp/index.js +94 -2
- package/dist/mcp/origami.js +94 -2
- package/dist/mcp/slack-channel.js +94 -2
- package/dist/mcp/telegram-channel.js +94 -2
- package/dist/{persistent-session-UC56OJVB.js → persistent-session-LHQLLU4U.js} +4 -4
- package/dist/{responsiveness-probe-KGBRCJQW.js → responsiveness-probe-KDSNPKUY.js} +4 -4
- package/dist/{session-auth-dead-AVYJASOL.js → session-auth-dead-3IHR4M2B.js} +3 -3
- package/package.json +1 -1
- package/dist/chunk-NRNPYXG6.js.map +0 -1
- package/dist/chunk-UAO5VMYK.js.map +0 -1
- /package/dist/{api-client-ATRLQZOU.js.map → api-client-2YLFNHFZ.js.map} +0 -0
- /package/dist/{chunk-5433KPH4.js.map → chunk-335HKIDZ.js.map} +0 -0
- /package/dist/{chunk-BOITSKCM.js.map → chunk-6NHFZYUP.js.map} +0 -0
- /package/dist/{chunk-RBC22FRC.js.map → chunk-I2NQQOMD.js.map} +0 -0
- /package/dist/{chunk-F6U3ZJCG.js.map → chunk-JYSPPCHG.js.map} +0 -0
- /package/dist/{claude-code-updater-SUL3OSGB.js.map → claude-code-updater-B2BWPRFE.js.map} +0 -0
- /package/dist/{claude-pair-runtime-D6ZRO2FC.js.map → claude-pair-runtime-FNDHAPXR.js.map} +0 -0
- /package/dist/{persistent-session-UC56OJVB.js.map → persistent-session-LHQLLU4U.js.map} +0 -0
- /package/dist/{responsiveness-probe-KGBRCJQW.js.map → responsiveness-probe-KDSNPKUY.js.map} +0 -0
- /package/dist/{session-auth-dead-AVYJASOL.js.map → session-auth-dead-3IHR4M2B.js.map} +0 -0
|
@@ -65,11 +65,12 @@ import {
|
|
|
65
65
|
redactKnownValues,
|
|
66
66
|
resolveEffectivePinRaw,
|
|
67
67
|
safeWriteJsonAtomic,
|
|
68
|
+
setScratchSweepPolicyResolver,
|
|
68
69
|
shellGuard,
|
|
69
70
|
tripClass,
|
|
70
71
|
writeEtcEnvironment,
|
|
71
72
|
writeProfileDScript
|
|
72
|
-
} from "../chunk-
|
|
73
|
+
} from "../chunk-ZEJUBTXJ.js";
|
|
73
74
|
import {
|
|
74
75
|
ApiError,
|
|
75
76
|
adoptHostKeyInProcess,
|
|
@@ -87,7 +88,7 @@ import {
|
|
|
87
88
|
probeHostKey,
|
|
88
89
|
requireHost,
|
|
89
90
|
setConfigHash
|
|
90
|
-
} from "../chunk-
|
|
91
|
+
} from "../chunk-6NHFZYUP.js";
|
|
91
92
|
import {
|
|
92
93
|
BLOCKED_ON_PROMPT_DECISION,
|
|
93
94
|
CHANNEL_SECRET_ENV_KEYS,
|
|
@@ -172,7 +173,7 @@ import {
|
|
|
172
173
|
webFetchBaselineValue,
|
|
173
174
|
webFetchRestartNeeded,
|
|
174
175
|
writeEgressAllowlist
|
|
175
|
-
} from "../chunk-
|
|
176
|
+
} from "../chunk-I2NQQOMD.js";
|
|
176
177
|
import {
|
|
177
178
|
isAgentIdle,
|
|
178
179
|
isStaleForToday,
|
|
@@ -183,7 +184,7 @@ import {
|
|
|
183
184
|
subagentActivityAgeSeconds,
|
|
184
185
|
subagentTranscriptDir,
|
|
185
186
|
transcriptActivityAgeSeconds
|
|
186
|
-
} from "../chunk-
|
|
187
|
+
} from "../chunk-JYSPPCHG.js";
|
|
187
188
|
import {
|
|
188
189
|
classifyUnanswerablePane,
|
|
189
190
|
focusedConfirmDialogBlock,
|
|
@@ -207,7 +208,7 @@ import {
|
|
|
207
208
|
runSafeCleanup,
|
|
208
209
|
tightestDiskStat,
|
|
209
210
|
withPackageCacheLock
|
|
210
|
-
} from "../chunk-
|
|
211
|
+
} from "../chunk-335HKIDZ.js";
|
|
211
212
|
import {
|
|
212
213
|
parsePsRows,
|
|
213
214
|
reapOrphanChannelMcps
|
|
@@ -335,7 +336,7 @@ import {
|
|
|
335
336
|
stabiliseResetInstant,
|
|
336
337
|
sumTranscriptUsageInWindow,
|
|
337
338
|
summarizeTranscriptActivity
|
|
338
|
-
} from "../chunk-
|
|
339
|
+
} from "../chunk-QFLR5EFT.js";
|
|
339
340
|
import {
|
|
340
341
|
CLAUDE_CONFIG_DIR_ENV,
|
|
341
342
|
claudeConfigDirFor,
|
|
@@ -560,7 +561,7 @@ function confirmConfigReload(input, deps) {
|
|
|
560
561
|
|
|
561
562
|
// src/lib/manager-worker.ts
|
|
562
563
|
import { createHash as createHash20 } from "crypto";
|
|
563
|
-
import { readFileSync as
|
|
564
|
+
import { readFileSync as readFileSync36, writeFileSync as writeFileSync19, mkdirSync as mkdirSync17, existsSync as existsSync20, rmSync as rmSync9, readdirSync as readdirSync14, statSync as statSync15, unlinkSync as unlinkSync6, renameSync as renameSync11, utimesSync as utimesSync4, readlinkSync as readlinkSync2 } from "fs";
|
|
564
565
|
|
|
565
566
|
// src/lib/atomic-file-replace.ts
|
|
566
567
|
import { copyFileSync, renameSync, unlinkSync } from "fs";
|
|
@@ -977,7 +978,7 @@ function clearEpisode(codeName) {
|
|
|
977
978
|
}
|
|
978
979
|
|
|
979
980
|
// src/lib/manager-worker.ts
|
|
980
|
-
import { join as
|
|
981
|
+
import { join as join45, dirname as dirname11, delimiter as pathDelimiter } from "path";
|
|
981
982
|
import { homedir as homedir17, hostname, platform as platform3 } from "os";
|
|
982
983
|
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
983
984
|
|
|
@@ -3293,12 +3294,12 @@ function isPathInsideDir(candidate, dir) {
|
|
|
3293
3294
|
return resolvedCandidate.startsWith(resolvedDir.endsWith(sep) ? resolvedDir : resolvedDir + sep);
|
|
3294
3295
|
}
|
|
3295
3296
|
function findMissingMcpBundles(mcpConfigPath, deps = {}) {
|
|
3296
|
-
const
|
|
3297
|
-
const
|
|
3297
|
+
const existsSync21 = deps.existsSync ?? nodeExistsSync;
|
|
3298
|
+
const readFileSync37 = deps.readFileSync ?? nodeReadFileSync;
|
|
3298
3299
|
const mcpDir = deps.mcpDir ?? getSharedMcpDir();
|
|
3299
3300
|
let parsed;
|
|
3300
3301
|
try {
|
|
3301
|
-
parsed = JSON.parse(
|
|
3302
|
+
parsed = JSON.parse(readFileSync37(mcpConfigPath, "utf-8"));
|
|
3302
3303
|
} catch {
|
|
3303
3304
|
return [];
|
|
3304
3305
|
}
|
|
@@ -3318,7 +3319,7 @@ function findMissingMcpBundles(mcpConfigPath, deps = {}) {
|
|
|
3318
3319
|
if (seenPaths.has(resolvedBundlePath)) continue;
|
|
3319
3320
|
let present;
|
|
3320
3321
|
try {
|
|
3321
|
-
present =
|
|
3322
|
+
present = existsSync21(bundlePath);
|
|
3322
3323
|
} catch {
|
|
3323
3324
|
continue;
|
|
3324
3325
|
}
|
|
@@ -3699,8 +3700,8 @@ function formatDrainShutdownLine(opts) {
|
|
|
3699
3700
|
const killed = opts.killedPids && opts.killedPids.length > 0 ? ` killed_pids=${opts.killedPids.join(",")}` : "";
|
|
3700
3701
|
const scanned = opts.scanned === void 0 ? "" : ` scanned=${opts.scanned}`;
|
|
3701
3702
|
const acted = opts.acted === void 0 ? "" : ` acted=${opts.acted}`;
|
|
3702
|
-
const
|
|
3703
|
-
return `[drain] step=${opts.step} elapsed_ms=${opts.elapsedMs}${killed}${scanned}${acted}${
|
|
3703
|
+
const note2 = opts.note ? ` note="${opts.note.replace(/"/g, '\\"')}"` : "";
|
|
3704
|
+
return `[drain] step=${opts.step} elapsed_ms=${opts.elapsedMs}${killed}${scanned}${acted}${note2}`;
|
|
3704
3705
|
}
|
|
3705
3706
|
function formatReaperBootLine(opts) {
|
|
3706
3707
|
return `[drain] step=boot-reaper total=${opts.totalRecorded} killed=${opts.killed} already_dead=${opts.alreadyDead} pid_reused_skipped=${opts.pidReusedSkipped}`;
|
|
@@ -3820,9 +3821,145 @@ function provisionReviewPoster(codeName, sourceDir = resolveBundledReviewAssetDi
|
|
|
3820
3821
|
}
|
|
3821
3822
|
}
|
|
3822
3823
|
|
|
3823
|
-
// src/lib/
|
|
3824
|
-
import { existsSync as existsSync3,
|
|
3824
|
+
// src/lib/scratch-sweep-policy.ts
|
|
3825
|
+
import { existsSync as existsSync3, mkdirSync as mkdirSync5, readFileSync as readFileSync10, rmSync as rmSync2, writeFileSync as writeFileSync5 } from "fs";
|
|
3825
3826
|
import { join as join10 } from "path";
|
|
3827
|
+
var SCRATCH_POLICY_LOG_INTERVAL_MS = 60 * 60 * 1e3;
|
|
3828
|
+
var SCRATCH_HOLD_LIFT_DELAY_MS = 10 * 60 * 1e3;
|
|
3829
|
+
var SCRATCH_HOLD_MAX_OBSERVATION_GAP_MS = 5 * 60 * 1e3;
|
|
3830
|
+
var HELD = { held: true, perFile: false, dryRun: false };
|
|
3831
|
+
var TREE_RULE = { held: false, perFile: false, dryRun: false };
|
|
3832
|
+
var HELD_MARKER = "held\n";
|
|
3833
|
+
var OFF_SINCE = /^off-since (\d+)(?: seen (\d+))?\n$/;
|
|
3834
|
+
var offSince = (since, seen) => `off-since ${since} seen ${seen}
|
|
3835
|
+
`;
|
|
3836
|
+
var unrecordedHolds = /* @__PURE__ */ new Set();
|
|
3837
|
+
var lastLoggedAt = /* @__PURE__ */ new Map();
|
|
3838
|
+
function note(input, why) {
|
|
3839
|
+
const now = (input.now ?? Date.now)();
|
|
3840
|
+
const key = `${input.codeName}:${why}`;
|
|
3841
|
+
const last = lastLoggedAt.get(key);
|
|
3842
|
+
if (last !== void 0 && now - last < SCRATCH_POLICY_LOG_INTERVAL_MS) return;
|
|
3843
|
+
lastLoggedAt.set(key, now);
|
|
3844
|
+
(input.log ?? ((line) => process.stderr.write(line)))(`[scratch] [sweep-policy] agent=${input.codeName} ${why}
|
|
3845
|
+
`);
|
|
3846
|
+
}
|
|
3847
|
+
function resolveScratchSweepPolicy(input) {
|
|
3848
|
+
try {
|
|
3849
|
+
if (!input.agentId) {
|
|
3850
|
+
note(input, "kept=all reason=agent-id-unknown");
|
|
3851
|
+
return HELD;
|
|
3852
|
+
}
|
|
3853
|
+
if (!/^[A-Za-z0-9-]+$/.test(input.agentId)) {
|
|
3854
|
+
note(input, "kept=all reason=invalid-agent-id");
|
|
3855
|
+
return HELD;
|
|
3856
|
+
}
|
|
3857
|
+
const marker = join10(input.holdsDir, input.agentId);
|
|
3858
|
+
if (unrecordedHolds.has(input.agentId) || input.flag("scratch-sweep-held", input.agentId)) {
|
|
3859
|
+
mkdirSync5(input.holdsDir, { recursive: true });
|
|
3860
|
+
writeFileSync5(marker, HELD_MARKER);
|
|
3861
|
+
unrecordedHolds.delete(input.agentId);
|
|
3862
|
+
return HELD;
|
|
3863
|
+
}
|
|
3864
|
+
const state10 = input.flagState(input.agentId);
|
|
3865
|
+
if (existsSync3(marker)) {
|
|
3866
|
+
if (state10 !== "confirmed") {
|
|
3867
|
+
writeFileSync5(marker, HELD_MARKER);
|
|
3868
|
+
note(input, `kept=all reason=hold-marker flags=${state10}`);
|
|
3869
|
+
return HELD;
|
|
3870
|
+
}
|
|
3871
|
+
const now = (input.now ?? Date.now)();
|
|
3872
|
+
const off = OFF_SINCE.exec(readFileSync10(marker, "utf8"));
|
|
3873
|
+
if (!off) {
|
|
3874
|
+
writeFileSync5(marker, offSince(now, now));
|
|
3875
|
+
return HELD;
|
|
3876
|
+
}
|
|
3877
|
+
const since = Number(off[1]);
|
|
3878
|
+
const seen = Number(off[2] ?? off[1]);
|
|
3879
|
+
if (!Number.isFinite(since) || !Number.isFinite(seen) || since > seen || seen > now) {
|
|
3880
|
+
writeFileSync5(marker, offSince(now, now));
|
|
3881
|
+
return HELD;
|
|
3882
|
+
}
|
|
3883
|
+
if (now - seen > SCRATCH_HOLD_MAX_OBSERVATION_GAP_MS) {
|
|
3884
|
+
writeFileSync5(marker, offSince(now, now));
|
|
3885
|
+
note(input, "kept=all reason=hold-off-observation-gap");
|
|
3886
|
+
return HELD;
|
|
3887
|
+
}
|
|
3888
|
+
if (now - since < SCRATCH_HOLD_LIFT_DELAY_MS) {
|
|
3889
|
+
writeFileSync5(marker, offSince(since, now));
|
|
3890
|
+
return HELD;
|
|
3891
|
+
}
|
|
3892
|
+
rmSync2(marker, { force: true });
|
|
3893
|
+
}
|
|
3894
|
+
if (state10 === "not-evaluated") {
|
|
3895
|
+
mkdirSync5(input.holdsDir, { recursive: true });
|
|
3896
|
+
writeFileSync5(marker, HELD_MARKER);
|
|
3897
|
+
note(input, "kept=all reason=agent-not-evaluated");
|
|
3898
|
+
return HELD;
|
|
3899
|
+
}
|
|
3900
|
+
if (state10 === "unknown") {
|
|
3901
|
+
note(input, "tree-rule-only reason=flags-not-evaluated");
|
|
3902
|
+
return TREE_RULE;
|
|
3903
|
+
}
|
|
3904
|
+
return {
|
|
3905
|
+
held: false,
|
|
3906
|
+
perFile: input.flag("scratch-sweep-per-file", input.agentId),
|
|
3907
|
+
dryRun: input.flag("scratch-sweep-dry-run", input.agentId)
|
|
3908
|
+
};
|
|
3909
|
+
} catch (err) {
|
|
3910
|
+
const code = err?.code ?? "unknown";
|
|
3911
|
+
note(input, `kept=all reason=policy-error code=${code}`);
|
|
3912
|
+
return HELD;
|
|
3913
|
+
}
|
|
3914
|
+
}
|
|
3915
|
+
function recordScratchHoldsFromHeartbeat(input) {
|
|
3916
|
+
if (!Array.isArray(input.evaluatedAgentIds)) return;
|
|
3917
|
+
const log2 = input.log ?? ((line) => process.stderr.write(line));
|
|
3918
|
+
const safe = (id) => typeof id === "string" && /^[A-Za-z0-9-]+$/.test(id);
|
|
3919
|
+
const now = (input.now ?? Date.now)();
|
|
3920
|
+
const evaluated = new Set(input.evaluatedAgentIds.filter(safe));
|
|
3921
|
+
for (const id of evaluated) {
|
|
3922
|
+
let held = false;
|
|
3923
|
+
try {
|
|
3924
|
+
held = input.flag("scratch-sweep-held", id);
|
|
3925
|
+
const marker = join10(input.holdsDir, id);
|
|
3926
|
+
if (held) {
|
|
3927
|
+
mkdirSync5(input.holdsDir, { recursive: true });
|
|
3928
|
+
writeFileSync5(marker, HELD_MARKER);
|
|
3929
|
+
unrecordedHolds.delete(id);
|
|
3930
|
+
continue;
|
|
3931
|
+
}
|
|
3932
|
+
if (!existsSync3(marker)) continue;
|
|
3933
|
+
const off = OFF_SINCE.exec(readFileSync10(marker, "utf8"));
|
|
3934
|
+
if (!off) continue;
|
|
3935
|
+
const since = Number(off[1]);
|
|
3936
|
+
const seen = Number(off[2] ?? off[1]);
|
|
3937
|
+
const usable = Number.isFinite(since) && Number.isFinite(seen) && since <= seen && seen <= now;
|
|
3938
|
+
writeFileSync5(marker, !usable || now - seen > SCRATCH_HOLD_MAX_OBSERVATION_GAP_MS ? offSince(now, now) : offSince(since, now));
|
|
3939
|
+
} catch (err) {
|
|
3940
|
+
if (held) unrecordedHolds.add(id);
|
|
3941
|
+
const code = err?.code ?? "unknown";
|
|
3942
|
+
log2(`[scratch] [sweep-policy] agent-id=${id} hold-record-failed code=${code}
|
|
3943
|
+
`);
|
|
3944
|
+
}
|
|
3945
|
+
}
|
|
3946
|
+
for (const id of input.hostAgentIds ?? []) {
|
|
3947
|
+
if (!safe(id) || evaluated.has(id)) continue;
|
|
3948
|
+
try {
|
|
3949
|
+
mkdirSync5(input.holdsDir, { recursive: true });
|
|
3950
|
+
writeFileSync5(join10(input.holdsDir, id), HELD_MARKER);
|
|
3951
|
+
} catch (err) {
|
|
3952
|
+
unrecordedHolds.add(id);
|
|
3953
|
+
const code = err?.code ?? "unknown";
|
|
3954
|
+
log2(`[scratch] [sweep-policy] agent-id=${id} not-evaluated-record-failed code=${code}
|
|
3955
|
+
`);
|
|
3956
|
+
}
|
|
3957
|
+
}
|
|
3958
|
+
}
|
|
3959
|
+
|
|
3960
|
+
// src/lib/id-keyed-migration.ts
|
|
3961
|
+
import { existsSync as existsSync4, lstatSync as lstatSync2, readlinkSync, renameSync as renameSync2 } from "fs";
|
|
3962
|
+
import { join as join11 } from "path";
|
|
3826
3963
|
import { homedir as homedir3 } from "os";
|
|
3827
3964
|
var ID_KEYED_MIGRATION_FLAG = "id-keyed-layout-migration";
|
|
3828
3965
|
function agentHasActiveWhatsapp(channelConfigs, codeNameDir) {
|
|
@@ -3830,7 +3967,7 @@ function agentHasActiveWhatsapp(channelConfigs, codeNameDir) {
|
|
|
3830
3967
|
return true;
|
|
3831
3968
|
}
|
|
3832
3969
|
try {
|
|
3833
|
-
if (
|
|
3970
|
+
if (existsSync4(join11(codeNameDir, "whatsapp-pending-inbound"))) return true;
|
|
3834
3971
|
} catch {
|
|
3835
3972
|
}
|
|
3836
3973
|
return false;
|
|
@@ -3842,12 +3979,12 @@ function finishTranscriptMove(oldCwd, newCwd, codeName, log2) {
|
|
|
3842
3979
|
let fromExists = false;
|
|
3843
3980
|
let toExists = false;
|
|
3844
3981
|
try {
|
|
3845
|
-
fromExists =
|
|
3982
|
+
fromExists = existsSync4(from);
|
|
3846
3983
|
} catch {
|
|
3847
3984
|
}
|
|
3848
3985
|
if (!fromExists) return;
|
|
3849
3986
|
try {
|
|
3850
|
-
toExists =
|
|
3987
|
+
toExists = existsSync4(to);
|
|
3851
3988
|
} catch {
|
|
3852
3989
|
}
|
|
3853
3990
|
if (toExists) {
|
|
@@ -3862,17 +3999,17 @@ function finishTranscriptMove(oldCwd, newCwd, codeName, log2) {
|
|
|
3862
3999
|
function maybeMigrateAgentToIdKeyedLayout(agent, deps) {
|
|
3863
4000
|
const home = deps.home ?? homedir3();
|
|
3864
4001
|
const { code_name: codeName, agent_id: agentId } = agent;
|
|
3865
|
-
const codeNamePath =
|
|
3866
|
-
const idPath =
|
|
3867
|
-
const oldCwd =
|
|
3868
|
-
const newCwd =
|
|
4002
|
+
const codeNamePath = join11(home, ".augmented", codeName);
|
|
4003
|
+
const idPath = join11(home, ".augmented", agentId);
|
|
4004
|
+
const oldCwd = join11(home, ".augmented", codeName, "project");
|
|
4005
|
+
const newCwd = join11(idPath, "project");
|
|
3869
4006
|
let codeNameKind;
|
|
3870
4007
|
try {
|
|
3871
4008
|
codeNameKind = lstatSync2(codeNamePath).isSymbolicLink() ? "symlink" : "realdir";
|
|
3872
4009
|
} catch {
|
|
3873
4010
|
codeNameKind = "absent";
|
|
3874
4011
|
}
|
|
3875
|
-
const idExists =
|
|
4012
|
+
const idExists = existsSync4(idPath);
|
|
3876
4013
|
try {
|
|
3877
4014
|
if (codeNameKind === "symlink") {
|
|
3878
4015
|
const target = readlinkSync(codeNamePath);
|
|
@@ -4164,8 +4301,8 @@ function collectEnvGates(env) {
|
|
|
4164
4301
|
}
|
|
4165
4302
|
|
|
4166
4303
|
// ../../packages/core/dist/direct-chat/cursor-advance-telemetry.js
|
|
4167
|
-
import { readFileSync as
|
|
4168
|
-
import { join as
|
|
4304
|
+
import { readFileSync as readFileSync11, writeFileSync as writeFileSync6 } from "fs";
|
|
4305
|
+
import { join as join12 } from "path";
|
|
4169
4306
|
var CURSOR_SHORTFALL_COUNTER_SUFFIX = "-cursor-advance-classifications.json";
|
|
4170
4307
|
function recordCursorAdvanceOutcome(agentDir, source, route, verdict) {
|
|
4171
4308
|
if (!agentDir)
|
|
@@ -4173,10 +4310,10 @@ function recordCursorAdvanceOutcome(agentDir, source, route, verdict) {
|
|
|
4173
4310
|
const key = cursorAdvanceCounterKey(route, verdict);
|
|
4174
4311
|
if (key === null)
|
|
4175
4312
|
return;
|
|
4176
|
-
const path =
|
|
4313
|
+
const path = join12(agentDir, `${source}${CURSOR_SHORTFALL_COUNTER_SUFFIX}`);
|
|
4177
4314
|
const counts = {};
|
|
4178
4315
|
try {
|
|
4179
|
-
const parsed = JSON.parse(
|
|
4316
|
+
const parsed = JSON.parse(readFileSync11(path, "utf-8"));
|
|
4180
4317
|
if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) {
|
|
4181
4318
|
for (const [k, v] of Object.entries(parsed)) {
|
|
4182
4319
|
if (typeof v === "number" && Number.isInteger(v) && v >= 0)
|
|
@@ -4187,13 +4324,13 @@ function recordCursorAdvanceOutcome(agentDir, source, route, verdict) {
|
|
|
4187
4324
|
}
|
|
4188
4325
|
counts[key] = (counts[key] ?? 0) + 1;
|
|
4189
4326
|
try {
|
|
4190
|
-
|
|
4327
|
+
writeFileSync6(path, JSON.stringify(counts), { mode: 384 });
|
|
4191
4328
|
} catch {
|
|
4192
4329
|
}
|
|
4193
4330
|
}
|
|
4194
4331
|
|
|
4195
4332
|
// src/lib/artifact-stream.ts
|
|
4196
|
-
import { join as
|
|
4333
|
+
import { join as join13 } from "path";
|
|
4197
4334
|
import { homedir as homedir4 } from "os";
|
|
4198
4335
|
import { readdir, stat, readFile } from "fs/promises";
|
|
4199
4336
|
var ARTEFACT_ENTRY_FILE = "index.html";
|
|
@@ -4279,7 +4416,7 @@ var ArtifactStreamScanner = class {
|
|
|
4279
4416
|
return;
|
|
4280
4417
|
}
|
|
4281
4418
|
for (const name of names) {
|
|
4282
|
-
const file =
|
|
4419
|
+
const file = join13(this.artifactsDir, name, ARTEFACT_ENTRY_FILE);
|
|
4283
4420
|
const mtime = await this.fsDeps.mtimeMs(file).catch(() => null);
|
|
4284
4421
|
if (mtime === null) continue;
|
|
4285
4422
|
if (this.seenMtime.get(name) === mtime) continue;
|
|
@@ -4310,7 +4447,7 @@ var ArtifactStreamScanner = class {
|
|
|
4310
4447
|
}
|
|
4311
4448
|
};
|
|
4312
4449
|
function artifactsDirFor(codeName) {
|
|
4313
|
-
return
|
|
4450
|
+
return join13(homedir4(), ".augmented", codeName, "artifacts");
|
|
4314
4451
|
}
|
|
4315
4452
|
var nodeArtifactFs = {
|
|
4316
4453
|
async listArtefactNames(artifactsDir) {
|
|
@@ -4586,12 +4723,12 @@ async function maybePollHostUsage(deps) {
|
|
|
4586
4723
|
import { createHash as createHash6 } from "crypto";
|
|
4587
4724
|
import { readFile as readFile3, readdir as readdir3 } from "fs/promises";
|
|
4588
4725
|
import { homedir as homedir6, platform as platform2 } from "os";
|
|
4589
|
-
import { dirname as dirname6, join as
|
|
4726
|
+
import { dirname as dirname6, join as join15 } from "path";
|
|
4590
4727
|
|
|
4591
4728
|
// src/lib/claude-auth-detect.ts
|
|
4592
4729
|
import { readFile as readFile2, readdir as readdir2 } from "fs/promises";
|
|
4593
4730
|
import { homedir as homedir5, platform } from "os";
|
|
4594
|
-
import { join as
|
|
4731
|
+
import { join as join14 } from "path";
|
|
4595
4732
|
import { execFile } from "child_process";
|
|
4596
4733
|
import { promisify } from "util";
|
|
4597
4734
|
var execFileAsync = promisify(execFile);
|
|
@@ -4606,16 +4743,16 @@ async function detectClaudeAuth() {
|
|
|
4606
4743
|
}
|
|
4607
4744
|
async function findClaudeCredentialsPaths() {
|
|
4608
4745
|
const candidates = [
|
|
4609
|
-
|
|
4610
|
-
|
|
4746
|
+
join14(homedir5(), ".claude", ".credentials.json"),
|
|
4747
|
+
join14(homedir5(), ".claude", "credentials.json")
|
|
4611
4748
|
];
|
|
4612
4749
|
const isLinuxRoot = platform() === "linux" && typeof process.getuid === "function" && process.getuid() === 0;
|
|
4613
4750
|
if (isLinuxRoot) {
|
|
4614
4751
|
try {
|
|
4615
4752
|
const entries = await readdir2("/home", { withFileTypes: true });
|
|
4616
4753
|
for (const entry of entries.filter((entry2) => entry2.isDirectory()).sort((a, b) => a.name.localeCompare(b.name))) {
|
|
4617
|
-
candidates.push(
|
|
4618
|
-
candidates.push(
|
|
4754
|
+
candidates.push(join14("/home", entry.name, ".claude", ".credentials.json"));
|
|
4755
|
+
candidates.push(join14("/home", entry.name, ".claude", "credentials.json"));
|
|
4619
4756
|
}
|
|
4620
4757
|
} catch {
|
|
4621
4758
|
}
|
|
@@ -4699,7 +4836,7 @@ async function candidateHomes() {
|
|
|
4699
4836
|
try {
|
|
4700
4837
|
const entries = await readdir3("/home", { withFileTypes: true });
|
|
4701
4838
|
for (const entry of entries.filter((e) => e.isDirectory()).sort((a, b) => a.name.localeCompare(b.name))) {
|
|
4702
|
-
homes.push(
|
|
4839
|
+
homes.push(join15("/home", entry.name));
|
|
4703
4840
|
}
|
|
4704
4841
|
} catch {
|
|
4705
4842
|
}
|
|
@@ -4719,11 +4856,11 @@ async function homeOfActiveCredentials() {
|
|
|
4719
4856
|
async function claudeConfigCandidatePaths() {
|
|
4720
4857
|
const paths = [];
|
|
4721
4858
|
const configDir = process.env["CLAUDE_CONFIG_DIR"]?.trim();
|
|
4722
|
-
if (configDir) paths.push(
|
|
4859
|
+
if (configDir) paths.push(join15(configDir, ".claude.json"));
|
|
4723
4860
|
const activeHome = await homeOfActiveCredentials();
|
|
4724
|
-
if (activeHome) paths.push(
|
|
4861
|
+
if (activeHome) paths.push(join15(activeHome, ".claude.json"));
|
|
4725
4862
|
for (const home of await candidateHomes()) {
|
|
4726
|
-
const path =
|
|
4863
|
+
const path = join15(home, ".claude.json");
|
|
4727
4864
|
if (!paths.includes(path)) paths.push(path);
|
|
4728
4865
|
}
|
|
4729
4866
|
return paths;
|
|
@@ -4887,11 +5024,11 @@ function diffAuthTuples(recorded, current) {
|
|
|
4887
5024
|
}
|
|
4888
5025
|
|
|
4889
5026
|
// src/lib/account-enforcement-marker.ts
|
|
4890
|
-
import { mkdirSync as
|
|
5027
|
+
import { mkdirSync as mkdirSync6, renameSync as renameSync3, rmSync as rmSync3, writeFileSync as writeFileSync7 } from "fs";
|
|
4891
5028
|
import { homedir as homedir7 } from "os";
|
|
4892
|
-
import { join as
|
|
5029
|
+
import { join as join16 } from "path";
|
|
4893
5030
|
function accountEnforcementMarkerPath(codeName) {
|
|
4894
|
-
return
|
|
5031
|
+
return join16(homedir7(), ".augmented", codeName, ACCOUNT_ENFORCEMENT_MARKER_FILENAME);
|
|
4895
5032
|
}
|
|
4896
5033
|
function syncAccountEnforcementMarker(codeName, level, log2 = (m) => process.stderr.write(`${m}
|
|
4897
5034
|
`), text) {
|
|
@@ -4899,16 +5036,16 @@ function syncAccountEnforcementMarker(codeName, level, log2 = (m) => process.std
|
|
|
4899
5036
|
clearAccountEnforcementMarker(codeName, log2);
|
|
4900
5037
|
return;
|
|
4901
5038
|
}
|
|
4902
|
-
const dir =
|
|
4903
|
-
const path =
|
|
5039
|
+
const dir = join16(homedir7(), ".augmented", codeName);
|
|
5040
|
+
const path = join16(dir, ACCOUNT_ENFORCEMENT_MARKER_FILENAME);
|
|
4904
5041
|
const tempPath = `${path}.${process.pid}.tmp`;
|
|
4905
5042
|
try {
|
|
4906
|
-
|
|
4907
|
-
|
|
5043
|
+
mkdirSync6(dir, { recursive: true });
|
|
5044
|
+
writeFileSync7(tempPath, serializeAccountEnforcementMarker(level, text), "utf-8");
|
|
4908
5045
|
renameSync3(tempPath, path);
|
|
4909
5046
|
} catch (err) {
|
|
4910
5047
|
try {
|
|
4911
|
-
|
|
5048
|
+
rmSync3(tempPath, { force: true });
|
|
4912
5049
|
} catch {
|
|
4913
5050
|
}
|
|
4914
5051
|
log2(`[account-enforcement] marker sync failed for '${codeName}': ${err.message}`);
|
|
@@ -4918,15 +5055,15 @@ function clearAccountEnforcementMarker(codeName, log2 = (m) => process.stderr.wr
|
|
|
4918
5055
|
`)) {
|
|
4919
5056
|
const path = accountEnforcementMarkerPath(codeName);
|
|
4920
5057
|
try {
|
|
4921
|
-
|
|
5058
|
+
rmSync3(path, { force: true });
|
|
4922
5059
|
} catch (err) {
|
|
4923
5060
|
log2(`[account-enforcement] marker clear failed for '${codeName}': ${err.message}`);
|
|
4924
5061
|
}
|
|
4925
5062
|
}
|
|
4926
5063
|
|
|
4927
5064
|
// src/lib/token-usage-monitor.ts
|
|
4928
|
-
import { readdirSync, readFileSync as
|
|
4929
|
-
import { join as
|
|
5065
|
+
import { readdirSync, readFileSync as readFileSync12, statSync } from "fs";
|
|
5066
|
+
import { join as join17 } from "path";
|
|
4930
5067
|
var MIN_CHECK_INTERVAL_MS2 = 6e4;
|
|
4931
5068
|
var TRANSCRIPT_MTIME_WINDOW_MS = 2 * 24 * 60 * 60 * 1e3;
|
|
4932
5069
|
var MAX_ENTRIES_PER_POST = 200;
|
|
@@ -4955,7 +5092,7 @@ async function maybeReportTokenUsage(args) {
|
|
|
4955
5092
|
if (!name.endsWith(".jsonl")) continue;
|
|
4956
5093
|
const sessionId = name.slice(0, -".jsonl".length);
|
|
4957
5094
|
if (!sessionId) continue;
|
|
4958
|
-
const path =
|
|
5095
|
+
const path = join17(dir, name);
|
|
4959
5096
|
let st;
|
|
4960
5097
|
try {
|
|
4961
5098
|
st = statSync(path);
|
|
@@ -4971,7 +5108,7 @@ async function maybeReportTokenUsage(args) {
|
|
|
4971
5108
|
}
|
|
4972
5109
|
let content;
|
|
4973
5110
|
try {
|
|
4974
|
-
content =
|
|
5111
|
+
content = readFileSync12(path, "utf-8");
|
|
4975
5112
|
} catch (err) {
|
|
4976
5113
|
log2(`[token-usage] read failed for '${codeName}/${name}': ${err.message}`);
|
|
4977
5114
|
continue;
|
|
@@ -5053,7 +5190,7 @@ async function maybeReportTokenUsage(args) {
|
|
|
5053
5190
|
|
|
5054
5191
|
// src/lib/failing-turn-monitor.ts
|
|
5055
5192
|
import { closeSync, openSync, readdirSync as readdirSync2, readSync, statSync as statSync2 } from "fs";
|
|
5056
|
-
import { join as
|
|
5193
|
+
import { join as join18 } from "path";
|
|
5057
5194
|
var MIN_CHECK_INTERVAL_MS3 = 3e4;
|
|
5058
5195
|
var FAILING_TURN_TAIL_BYTES = 512 * 1024;
|
|
5059
5196
|
var ACTIVE_TRANSCRIPT_WINDOW_MS = 60 * 60 * 1e3;
|
|
@@ -5085,7 +5222,7 @@ function newestActiveTranscript(dir, nowMs) {
|
|
|
5085
5222
|
let best = null;
|
|
5086
5223
|
for (const name of names) {
|
|
5087
5224
|
if (!name.endsWith(".jsonl")) continue;
|
|
5088
|
-
const path =
|
|
5225
|
+
const path = join18(dir, name);
|
|
5089
5226
|
try {
|
|
5090
5227
|
const st = statSync2(path);
|
|
5091
5228
|
if (!st.isFile() || nowMs - st.mtimeMs > ACTIVE_TRANSCRIPT_WINDOW_MS) continue;
|
|
@@ -5157,8 +5294,8 @@ function failingTurnLoops(now = Date.now(), threshold = failingTurnThreshold(),
|
|
|
5157
5294
|
}
|
|
5158
5295
|
|
|
5159
5296
|
// src/lib/session-activity.ts
|
|
5160
|
-
import { closeSync as closeSync2, openSync as openSync2, readFileSync as
|
|
5161
|
-
import { join as
|
|
5297
|
+
import { closeSync as closeSync2, openSync as openSync2, readFileSync as readFileSync13, readSync as readSync2, readdirSync as readdirSync3, statSync as statSync3 } from "fs";
|
|
5298
|
+
import { join as join19 } from "path";
|
|
5162
5299
|
var RULE = /^[─━]{10,}/;
|
|
5163
5300
|
var CARET_LINE = /^\s*❯(\s|$)/;
|
|
5164
5301
|
var NON_BLOCKING_PICKER = { title: "We recommend compacting earlier", footer: "esc not now", kind: "compaction-suggestion" };
|
|
@@ -5218,7 +5355,7 @@ function newestTranscript(dir) {
|
|
|
5218
5355
|
let best = null;
|
|
5219
5356
|
for (const name of names) {
|
|
5220
5357
|
if (!name.endsWith(".jsonl")) continue;
|
|
5221
|
-
const path =
|
|
5358
|
+
const path = join19(dir, name);
|
|
5222
5359
|
try {
|
|
5223
5360
|
const st = statSync3(path);
|
|
5224
5361
|
if (st.isFile() && (best === null || st.mtimeMs > best.mtimeMs)) {
|
|
@@ -5232,7 +5369,7 @@ function newestTranscript(dir) {
|
|
|
5232
5369
|
}
|
|
5233
5370
|
function sessionTranscript(dir, sessionId) {
|
|
5234
5371
|
if (!sessionId) return newestTranscript(dir);
|
|
5235
|
-
const path =
|
|
5372
|
+
const path = join19(dir, `${sessionId}.jsonl`);
|
|
5236
5373
|
try {
|
|
5237
5374
|
const st = statSync3(path);
|
|
5238
5375
|
return st.isFile() ? { path, mtimeMs: st.mtimeMs, size: st.size } : null;
|
|
@@ -5320,7 +5457,7 @@ function subagentFiles(dir) {
|
|
|
5320
5457
|
}
|
|
5321
5458
|
return names.flatMap((name) => {
|
|
5322
5459
|
if (!name.endsWith(".jsonl")) return [];
|
|
5323
|
-
const path =
|
|
5460
|
+
const path = join19(dir, name);
|
|
5324
5461
|
try {
|
|
5325
5462
|
const st = statSync3(path);
|
|
5326
5463
|
return st.isFile() ? [{ path, mtimeMs: st.mtimeMs, size: st.size }] : [];
|
|
@@ -5334,7 +5471,7 @@ function knownProcessStartMs(session) {
|
|
|
5334
5471
|
return session.startedAt === session.estimatedStartedAt ? null : session.startedAt;
|
|
5335
5472
|
}
|
|
5336
5473
|
function drainScan(scan, dir, log2) {
|
|
5337
|
-
const main =
|
|
5474
|
+
const main = join19(dir, `${scan.sessionId}.jsonl`);
|
|
5338
5475
|
let budget = BACKGROUND_SCAN_BYTES_PER_POLL;
|
|
5339
5476
|
try {
|
|
5340
5477
|
budget -= scanNewLines(main, statSync3(main).size, scan, budget, log2);
|
|
@@ -5351,7 +5488,7 @@ function readBackgroundActivity(codeName, dir, sessionId, spawnedAtMs, isSpawnSe
|
|
|
5351
5488
|
const sameRun = prev?.sessionId === sessionId && prev.spawnedAtMs === spawnedAtMs;
|
|
5352
5489
|
if (prev && sameRun && minCheckMs > 0 && nowMs - prev.checkedAt < minCheckMs) return prev;
|
|
5353
5490
|
try {
|
|
5354
|
-
const main =
|
|
5491
|
+
const main = join19(dir, `${sessionId}.jsonl`);
|
|
5355
5492
|
let size;
|
|
5356
5493
|
try {
|
|
5357
5494
|
size = statSync3(main).size;
|
|
@@ -5399,7 +5536,7 @@ function readBackgroundActivity(codeName, dir, sessionId, spawnedAtMs, isSpawnSe
|
|
|
5399
5536
|
}
|
|
5400
5537
|
function readRecordedSession(agentDir) {
|
|
5401
5538
|
try {
|
|
5402
|
-
const parsed = JSON.parse(
|
|
5539
|
+
const parsed = JSON.parse(readFileSync13(join19(agentDir, "session-state.json"), "utf-8"));
|
|
5403
5540
|
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) return null;
|
|
5404
5541
|
const { session_id: sessionId, recorded_at: recordedAtMs } = parsed;
|
|
5405
5542
|
if (typeof sessionId !== "string" || typeof recordedAtMs !== "number" || !Number.isFinite(recordedAtMs)) return null;
|
|
@@ -5491,8 +5628,8 @@ function buildSessionActivityReport(args) {
|
|
|
5491
5628
|
}
|
|
5492
5629
|
|
|
5493
5630
|
// src/lib/workflow-run-reconciler.ts
|
|
5494
|
-
import { readdirSync as readdirSync4, readFileSync as
|
|
5495
|
-
import { join as
|
|
5631
|
+
import { readdirSync as readdirSync4, readFileSync as readFileSync14, statSync as statSync4 } from "fs";
|
|
5632
|
+
import { join as join20 } from "path";
|
|
5496
5633
|
var MIN_CHECK_INTERVAL_MS4 = 5 * 6e4;
|
|
5497
5634
|
var SETTLE_MS = 3e4;
|
|
5498
5635
|
var TRANSCRIPT_MTIME_WINDOW_MS2 = 2 * 24 * 60 * 60 * 1e3;
|
|
@@ -5531,7 +5668,7 @@ function collectJsonlRecursive(dir, minMtimeMs, out, depth) {
|
|
|
5531
5668
|
return;
|
|
5532
5669
|
}
|
|
5533
5670
|
for (const name of entries) {
|
|
5534
|
-
const p =
|
|
5671
|
+
const p = join20(dir, name);
|
|
5535
5672
|
let st;
|
|
5536
5673
|
try {
|
|
5537
5674
|
st = statSync4(p);
|
|
@@ -5554,7 +5691,7 @@ function enumerateTranscriptFiles(transcriptDir, nowMs, minMtimeMs = nowMs - TRA
|
|
|
5554
5691
|
return out;
|
|
5555
5692
|
}
|
|
5556
5693
|
for (const name of entries) {
|
|
5557
|
-
const path =
|
|
5694
|
+
const path = join20(transcriptDir, name);
|
|
5558
5695
|
let st;
|
|
5559
5696
|
try {
|
|
5560
5697
|
st = statSync4(path);
|
|
@@ -5566,7 +5703,7 @@ function enumerateTranscriptFiles(transcriptDir, nowMs, minMtimeMs = nowMs - TRA
|
|
|
5566
5703
|
continue;
|
|
5567
5704
|
}
|
|
5568
5705
|
if (st.isDirectory()) {
|
|
5569
|
-
collectJsonlRecursive(
|
|
5706
|
+
collectJsonlRecursive(join20(path, "subagents"), minMtimeMs, out, 0);
|
|
5570
5707
|
}
|
|
5571
5708
|
}
|
|
5572
5709
|
return out;
|
|
@@ -5610,7 +5747,7 @@ async function maybeReconcileWorkflowRunTokens(args) {
|
|
|
5610
5747
|
const contents = [];
|
|
5611
5748
|
for (const path of files) {
|
|
5612
5749
|
try {
|
|
5613
|
-
contents.push(
|
|
5750
|
+
contents.push(readFileSync14(path, "utf-8"));
|
|
5614
5751
|
} catch {
|
|
5615
5752
|
}
|
|
5616
5753
|
}
|
|
@@ -5655,8 +5792,8 @@ async function maybeReconcileWorkflowRunTokens(args) {
|
|
|
5655
5792
|
}
|
|
5656
5793
|
|
|
5657
5794
|
// src/lib/conversation-evaluator.ts
|
|
5658
|
-
import { readdirSync as readdirSync5, readFileSync as
|
|
5659
|
-
import { join as
|
|
5795
|
+
import { readdirSync as readdirSync5, readFileSync as readFileSync15, statSync as statSync5 } from "fs";
|
|
5796
|
+
import { join as join21 } from "path";
|
|
5660
5797
|
|
|
5661
5798
|
// src/lib/detect-meta-egress.ts
|
|
5662
5799
|
var REPOST_PREAMBLE_WINDOW = 200;
|
|
@@ -6141,7 +6278,7 @@ function readRecentTurns(dir, nowMs) {
|
|
|
6141
6278
|
return;
|
|
6142
6279
|
}
|
|
6143
6280
|
for (const ent of entries) {
|
|
6144
|
-
const full =
|
|
6281
|
+
const full = join21(d, ent.name);
|
|
6145
6282
|
if (ent.isDirectory()) {
|
|
6146
6283
|
visit(full);
|
|
6147
6284
|
continue;
|
|
@@ -6156,7 +6293,7 @@ function readRecentTurns(dir, nowMs) {
|
|
|
6156
6293
|
if (nowMs - mtimeMs > TRANSCRIPT_MTIME_WINDOW_MS3) continue;
|
|
6157
6294
|
let content;
|
|
6158
6295
|
try {
|
|
6159
|
-
content =
|
|
6296
|
+
content = readFileSync15(full, "utf8");
|
|
6160
6297
|
} catch {
|
|
6161
6298
|
continue;
|
|
6162
6299
|
}
|
|
@@ -6529,22 +6666,22 @@ async function reportSkip2(api2, agentId, conversationId, log2, codeName) {
|
|
|
6529
6666
|
|
|
6530
6667
|
// src/lib/tool-call-audit.ts
|
|
6531
6668
|
import { homedir as homedir11 } from "os";
|
|
6532
|
-
import { join as
|
|
6669
|
+
import { join as join26 } from "path";
|
|
6533
6670
|
|
|
6534
6671
|
// src/lib/agent-logging-mode.ts
|
|
6535
|
-
import { readFileSync as
|
|
6672
|
+
import { readFileSync as readFileSync16 } from "fs";
|
|
6536
6673
|
import { homedir as homedir8 } from "os";
|
|
6537
|
-
import { join as
|
|
6674
|
+
import { join as join22 } from "path";
|
|
6538
6675
|
var LOGGING_MODES = ["hash-only", "redacted", "full-local"];
|
|
6539
6676
|
function charterPath(codeName, homeDir) {
|
|
6540
6677
|
const home = homeDir ?? (process.env["HOME"]?.trim() || homedir8());
|
|
6541
6678
|
const key = agentRuntimeKey(codeName, homeDir);
|
|
6542
|
-
return
|
|
6679
|
+
return join22(home, ".augmented", key, "provision", "CHARTER.md");
|
|
6543
6680
|
}
|
|
6544
6681
|
function readAgentLoggingMode(codeName, homeDir) {
|
|
6545
6682
|
let raw;
|
|
6546
6683
|
try {
|
|
6547
|
-
raw =
|
|
6684
|
+
raw = readFileSync16(charterPath(codeName, homeDir), "utf-8");
|
|
6548
6685
|
} catch {
|
|
6549
6686
|
return { mode: null, reason: "no-charter" };
|
|
6550
6687
|
}
|
|
@@ -6568,15 +6705,15 @@ function loggingModeWithholdsTargets(reading) {
|
|
|
6568
6705
|
|
|
6569
6706
|
// src/lib/tool-call-path-salt.ts
|
|
6570
6707
|
import { randomBytes } from "crypto";
|
|
6571
|
-
import { existsSync as
|
|
6708
|
+
import { existsSync as existsSync5, mkdirSync as mkdirSync7, readFileSync as readFileSync17, renameSync as renameSync4, unlinkSync as unlinkSync2, writeFileSync as writeFileSync8 } from "fs";
|
|
6572
6709
|
import { homedir as homedir9 } from "os";
|
|
6573
|
-
import { dirname as dirname7, join as
|
|
6710
|
+
import { dirname as dirname7, join as join23 } from "path";
|
|
6574
6711
|
var SALT_BYTES = 32;
|
|
6575
6712
|
var SALT_RE = /^[0-9a-f]{64}$/;
|
|
6576
6713
|
function pathSaltPath(codeName, homeDir) {
|
|
6577
6714
|
const home = homeDir ?? (process.env["HOME"]?.trim() || homedir9());
|
|
6578
6715
|
const key = agentRuntimeKey(codeName, homeDir);
|
|
6579
|
-
return
|
|
6716
|
+
return join23(home, ".augmented", key, "tool-call-path-salt");
|
|
6580
6717
|
}
|
|
6581
6718
|
function readToolCallPathSalt(codeName, homeDir) {
|
|
6582
6719
|
let file;
|
|
@@ -6586,8 +6723,8 @@ function readToolCallPathSalt(codeName, homeDir) {
|
|
|
6586
6723
|
return null;
|
|
6587
6724
|
}
|
|
6588
6725
|
try {
|
|
6589
|
-
if (
|
|
6590
|
-
const existing =
|
|
6726
|
+
if (existsSync5(file)) {
|
|
6727
|
+
const existing = readFileSync17(file, "utf-8").trim();
|
|
6591
6728
|
if (SALT_RE.test(existing)) return existing;
|
|
6592
6729
|
}
|
|
6593
6730
|
} catch {
|
|
@@ -6595,8 +6732,8 @@ function readToolCallPathSalt(codeName, homeDir) {
|
|
|
6595
6732
|
const salt = randomBytes(SALT_BYTES).toString("hex");
|
|
6596
6733
|
const tmp = `${file}.tmp.${process.pid}`;
|
|
6597
6734
|
try {
|
|
6598
|
-
|
|
6599
|
-
|
|
6735
|
+
mkdirSync7(dirname7(file), { recursive: true, mode: 448 });
|
|
6736
|
+
writeFileSync8(tmp, `${salt}
|
|
6600
6737
|
`, { encoding: "utf-8", mode: 384 });
|
|
6601
6738
|
renameSync4(tmp, file);
|
|
6602
6739
|
} catch {
|
|
@@ -6613,8 +6750,8 @@ function readToolCallPathSalt(codeName, homeDir) {
|
|
|
6613
6750
|
import { statSync as statSync6 } from "fs";
|
|
6614
6751
|
|
|
6615
6752
|
// src/lib/tool-call-extractor.ts
|
|
6616
|
-
import { closeSync as closeSync3, fstatSync, openSync as openSync3, readFileSync as
|
|
6617
|
-
import { basename as basename2, join as
|
|
6753
|
+
import { closeSync as closeSync3, fstatSync, openSync as openSync3, readFileSync as readFileSync18, readSync as readSync3, readdirSync as readdirSync6 } from "fs";
|
|
6754
|
+
import { basename as basename2, join as join24, relative } from "path";
|
|
6618
6755
|
import { StringDecoder } from "string_decoder";
|
|
6619
6756
|
|
|
6620
6757
|
// src/lib/tool-call-redaction.ts
|
|
@@ -6743,7 +6880,7 @@ function redactToolTargetInner(toolName, input, ctx) {
|
|
|
6743
6880
|
var EXTRACTOR_VERSION = "e1";
|
|
6744
6881
|
function enumerateSessionTranscripts(transcriptDir, sessionId, projectsRoot) {
|
|
6745
6882
|
const files = [];
|
|
6746
|
-
const mainAbs =
|
|
6883
|
+
const mainAbs = join24(transcriptDir, `${sessionId}.jsonl`);
|
|
6747
6884
|
files.push({
|
|
6748
6885
|
absPath: mainAbs,
|
|
6749
6886
|
relPath: relative(projectsRoot, mainAbs),
|
|
@@ -6751,7 +6888,7 @@ function enumerateSessionTranscripts(transcriptDir, sessionId, projectsRoot) {
|
|
|
6751
6888
|
isSubagent: false,
|
|
6752
6889
|
subagentId: null
|
|
6753
6890
|
});
|
|
6754
|
-
const subDir =
|
|
6891
|
+
const subDir = join24(transcriptDir, sessionId, "subagents");
|
|
6755
6892
|
let entries;
|
|
6756
6893
|
try {
|
|
6757
6894
|
entries = readdirSync6(subDir);
|
|
@@ -6760,7 +6897,7 @@ function enumerateSessionTranscripts(transcriptDir, sessionId, projectsRoot) {
|
|
|
6760
6897
|
}
|
|
6761
6898
|
for (const name of entries) {
|
|
6762
6899
|
if (!name.endsWith(".jsonl")) continue;
|
|
6763
|
-
const abs =
|
|
6900
|
+
const abs = join24(subDir, name);
|
|
6764
6901
|
const stem = basename2(name, ".jsonl");
|
|
6765
6902
|
files.push({
|
|
6766
6903
|
absPath: abs,
|
|
@@ -6958,9 +7095,9 @@ function extractTranscriptWindow(file, opts, from) {
|
|
|
6958
7095
|
}
|
|
6959
7096
|
|
|
6960
7097
|
// src/lib/tool-call-cursor.ts
|
|
6961
|
-
import { existsSync as
|
|
7098
|
+
import { existsSync as existsSync6, readFileSync as readFileSync19 } from "fs";
|
|
6962
7099
|
import { homedir as homedir10 } from "os";
|
|
6963
|
-
import { join as
|
|
7100
|
+
import { join as join25 } from "path";
|
|
6964
7101
|
var COVERAGE_DISPOSITIONS = [
|
|
6965
7102
|
"ok",
|
|
6966
7103
|
"not_entitled",
|
|
@@ -7015,13 +7152,13 @@ function parseCursorKey(key) {
|
|
|
7015
7152
|
function cursorStatePath(codeName, homeDir) {
|
|
7016
7153
|
const home = homeDir ?? (process.env["HOME"]?.trim() || homedir10());
|
|
7017
7154
|
const key = agentRuntimeKey(codeName, homeDir);
|
|
7018
|
-
return
|
|
7155
|
+
return join25(home, ".augmented", key, "tool-call-cursors.json");
|
|
7019
7156
|
}
|
|
7020
7157
|
function loadCursors(path) {
|
|
7021
7158
|
const out = /* @__PURE__ */ new Map();
|
|
7022
|
-
if (!
|
|
7159
|
+
if (!existsSync6(path)) return out;
|
|
7023
7160
|
try {
|
|
7024
|
-
const parsed = JSON.parse(
|
|
7161
|
+
const parsed = JSON.parse(readFileSync19(path, "utf-8"));
|
|
7025
7162
|
if (!parsed || parsed.version !== 1 || typeof parsed.files !== "object") return out;
|
|
7026
7163
|
for (const [k, v] of Object.entries(parsed.files)) {
|
|
7027
7164
|
if (!v || typeof v !== "object") continue;
|
|
@@ -7428,7 +7565,7 @@ async function maybeScanToolCalls(args) {
|
|
|
7428
7565
|
log2(`[tool-call-audit] ${codeName}: no path-hash salt available \u2014 file targets withheld`);
|
|
7429
7566
|
}
|
|
7430
7567
|
const home = args.homeDir ?? (process.env["HOME"]?.trim() || homedir11());
|
|
7431
|
-
const projectsRoot = args.projectsRoot ??
|
|
7568
|
+
const projectsRoot = args.projectsRoot ?? join26(home, ".claude", "projects");
|
|
7432
7569
|
const transcriptDir = args.transcriptDir ?? sessionTranscriptDir(getProjectDir(codeName));
|
|
7433
7570
|
const current = peekCurrentSession(codeName);
|
|
7434
7571
|
const sessionIds = current ? [current.sessionId] : [];
|
|
@@ -7457,11 +7594,11 @@ async function maybeScanToolCalls(args) {
|
|
|
7457
7594
|
}
|
|
7458
7595
|
|
|
7459
7596
|
// src/lib/activity-cache-monitor.ts
|
|
7460
|
-
import { existsSync as
|
|
7597
|
+
import { existsSync as existsSync7, readFileSync as readFileSync20 } from "fs";
|
|
7461
7598
|
import { homedir as homedir12 } from "os";
|
|
7462
|
-
import { join as
|
|
7599
|
+
import { join as join27 } from "path";
|
|
7463
7600
|
var MIN_CHECK_INTERVAL_MS8 = 6e4;
|
|
7464
|
-
var STATS_CACHE_PATH =
|
|
7601
|
+
var STATS_CACHE_PATH = join27(homedir12(), ".claude", "stats-cache.json");
|
|
7465
7602
|
var ISO_DATE_RE = /^\d{4}-\d{2}-\d{2}$/;
|
|
7466
7603
|
var state8 = { lastObservedDate: null, lastCheckedAt: 0 };
|
|
7467
7604
|
function selectNewDailyRows(raw, lastObservedDate) {
|
|
@@ -7504,12 +7641,12 @@ async function maybeReportActivityCache(args) {
|
|
|
7504
7641
|
const nowMs = now.getTime();
|
|
7505
7642
|
if (nowMs - state8.lastCheckedAt < MIN_CHECK_INTERVAL_MS8) return;
|
|
7506
7643
|
state8.lastCheckedAt = nowMs;
|
|
7507
|
-
if (!
|
|
7644
|
+
if (!existsSync7(STATS_CACHE_PATH)) {
|
|
7508
7645
|
return;
|
|
7509
7646
|
}
|
|
7510
7647
|
let raw;
|
|
7511
7648
|
try {
|
|
7512
|
-
raw =
|
|
7649
|
+
raw = readFileSync20(STATS_CACHE_PATH, "utf-8");
|
|
7513
7650
|
} catch (err) {
|
|
7514
7651
|
log2(`[activity-cache] readFileSync failed: ${err.message}`);
|
|
7515
7652
|
return;
|
|
@@ -7829,17 +7966,17 @@ function computeChannelConfigHash(input) {
|
|
|
7829
7966
|
// src/lib/knowledge-cache.ts
|
|
7830
7967
|
import { createHash as createHash9 } from "crypto";
|
|
7831
7968
|
import {
|
|
7832
|
-
existsSync as
|
|
7833
|
-
mkdirSync as
|
|
7834
|
-
readFileSync as
|
|
7969
|
+
existsSync as existsSync8,
|
|
7970
|
+
mkdirSync as mkdirSync8,
|
|
7971
|
+
readFileSync as readFileSync21,
|
|
7835
7972
|
readdirSync as readdirSync7,
|
|
7836
7973
|
renameSync as renameSync5,
|
|
7837
|
-
rmSync as
|
|
7974
|
+
rmSync as rmSync4,
|
|
7838
7975
|
statSync as statSync8,
|
|
7839
7976
|
utimesSync,
|
|
7840
|
-
writeFileSync as
|
|
7977
|
+
writeFileSync as writeFileSync9
|
|
7841
7978
|
} from "fs";
|
|
7842
|
-
import { join as
|
|
7979
|
+
import { join as join28 } from "path";
|
|
7843
7980
|
var KNOWLEDGE_FETCH_CHUNK = 100;
|
|
7844
7981
|
var CACHE_TTL_MS = 30 * 24 * 60 * 60 * 1e3;
|
|
7845
7982
|
var SWEEP_INTERVAL_MS = 24 * 60 * 60 * 1e3;
|
|
@@ -7848,12 +7985,12 @@ function knowledgeHash(content) {
|
|
|
7848
7985
|
return createHash9("sha256").update(content, "utf8").digest("hex");
|
|
7849
7986
|
}
|
|
7850
7987
|
function cachePath(cacheDir, hash) {
|
|
7851
|
-
return
|
|
7988
|
+
return join28(cacheDir, hash);
|
|
7852
7989
|
}
|
|
7853
7990
|
function readCachedKnowledge(cacheDir, hash) {
|
|
7854
7991
|
const path = cachePath(cacheDir, hash);
|
|
7855
7992
|
try {
|
|
7856
|
-
const content =
|
|
7993
|
+
const content = readFileSync21(path, "utf-8");
|
|
7857
7994
|
try {
|
|
7858
7995
|
const now = /* @__PURE__ */ new Date();
|
|
7859
7996
|
utimesSync(path, now, now);
|
|
@@ -7867,9 +8004,9 @@ function readCachedKnowledge(cacheDir, hash) {
|
|
|
7867
8004
|
function writeCachedKnowledge(cacheDir, hash, content) {
|
|
7868
8005
|
if (knowledgeHash(content) !== hash) return false;
|
|
7869
8006
|
try {
|
|
7870
|
-
|
|
8007
|
+
mkdirSync8(cacheDir, { recursive: true });
|
|
7871
8008
|
const tmp = `${cachePath(cacheDir, hash)}.tmp-${process.pid}`;
|
|
7872
|
-
|
|
8009
|
+
writeFileSync9(tmp, content, "utf-8");
|
|
7873
8010
|
renameSync5(tmp, cachePath(cacheDir, hash));
|
|
7874
8011
|
return true;
|
|
7875
8012
|
} catch {
|
|
@@ -7880,11 +8017,11 @@ function sweepKnowledgeCache(cacheDir, now = Date.now()) {
|
|
|
7880
8017
|
if (now - lastSweepAt < SWEEP_INTERVAL_MS) return;
|
|
7881
8018
|
lastSweepAt = now;
|
|
7882
8019
|
try {
|
|
7883
|
-
if (!
|
|
8020
|
+
if (!existsSync8(cacheDir)) return;
|
|
7884
8021
|
for (const name of readdirSync7(cacheDir)) {
|
|
7885
|
-
const path =
|
|
8022
|
+
const path = join28(cacheDir, name);
|
|
7886
8023
|
try {
|
|
7887
|
-
if (now - statSync8(path).mtimeMs > CACHE_TTL_MS)
|
|
8024
|
+
if (now - statSync8(path).mtimeMs > CACHE_TTL_MS) rmSync4(path, { force: true });
|
|
7888
8025
|
} catch {
|
|
7889
8026
|
}
|
|
7890
8027
|
}
|
|
@@ -7932,17 +8069,17 @@ async function resolveKnowledgeFromManifest(args) {
|
|
|
7932
8069
|
// src/lib/memory-cache.ts
|
|
7933
8070
|
import { createHash as createHash10 } from "crypto";
|
|
7934
8071
|
import {
|
|
7935
|
-
existsSync as
|
|
7936
|
-
mkdirSync as
|
|
7937
|
-
readFileSync as
|
|
8072
|
+
existsSync as existsSync9,
|
|
8073
|
+
mkdirSync as mkdirSync9,
|
|
8074
|
+
readFileSync as readFileSync22,
|
|
7938
8075
|
readdirSync as readdirSync8,
|
|
7939
8076
|
renameSync as renameSync6,
|
|
7940
|
-
rmSync as
|
|
8077
|
+
rmSync as rmSync5,
|
|
7941
8078
|
statSync as statSync9,
|
|
7942
8079
|
utimesSync as utimesSync2,
|
|
7943
|
-
writeFileSync as
|
|
8080
|
+
writeFileSync as writeFileSync10
|
|
7944
8081
|
} from "fs";
|
|
7945
|
-
import { join as
|
|
8082
|
+
import { join as join29 } from "path";
|
|
7946
8083
|
var MEMORY_FETCH_CHUNK = 100;
|
|
7947
8084
|
var CACHE_TTL_MS2 = 30 * 24 * 60 * 60 * 1e3;
|
|
7948
8085
|
var SWEEP_INTERVAL_MS2 = 24 * 60 * 60 * 1e3;
|
|
@@ -7951,12 +8088,12 @@ function memoryHash(content) {
|
|
|
7951
8088
|
return createHash10("sha256").update(content, "utf8").digest("hex");
|
|
7952
8089
|
}
|
|
7953
8090
|
function cachePath2(cacheDir, hash) {
|
|
7954
|
-
return
|
|
8091
|
+
return join29(cacheDir, hash);
|
|
7955
8092
|
}
|
|
7956
8093
|
function readCachedMemory(cacheDir, hash) {
|
|
7957
8094
|
const path = cachePath2(cacheDir, hash);
|
|
7958
8095
|
try {
|
|
7959
|
-
const content =
|
|
8096
|
+
const content = readFileSync22(path, "utf-8");
|
|
7960
8097
|
try {
|
|
7961
8098
|
const now = /* @__PURE__ */ new Date();
|
|
7962
8099
|
utimesSync2(path, now, now);
|
|
@@ -7970,9 +8107,9 @@ function readCachedMemory(cacheDir, hash) {
|
|
|
7970
8107
|
function writeCachedMemory(cacheDir, hash, content) {
|
|
7971
8108
|
if (memoryHash(content) !== hash) return false;
|
|
7972
8109
|
try {
|
|
7973
|
-
|
|
8110
|
+
mkdirSync9(cacheDir, { recursive: true });
|
|
7974
8111
|
const tmp = `${cachePath2(cacheDir, hash)}.tmp-${process.pid}`;
|
|
7975
|
-
|
|
8112
|
+
writeFileSync10(tmp, content, "utf-8");
|
|
7976
8113
|
renameSync6(tmp, cachePath2(cacheDir, hash));
|
|
7977
8114
|
return true;
|
|
7978
8115
|
} catch {
|
|
@@ -7983,11 +8120,11 @@ function sweepMemoryCache(cacheDir, now = Date.now()) {
|
|
|
7983
8120
|
if (now - (lastSweepAt2.get(cacheDir) ?? 0) < SWEEP_INTERVAL_MS2) return;
|
|
7984
8121
|
lastSweepAt2.set(cacheDir, now);
|
|
7985
8122
|
try {
|
|
7986
|
-
if (!
|
|
8123
|
+
if (!existsSync9(cacheDir)) return;
|
|
7987
8124
|
for (const name of readdirSync8(cacheDir)) {
|
|
7988
|
-
const path =
|
|
8125
|
+
const path = join29(cacheDir, name);
|
|
7989
8126
|
try {
|
|
7990
|
-
if (now - statSync9(path).mtimeMs > CACHE_TTL_MS2)
|
|
8127
|
+
if (now - statSync9(path).mtimeMs > CACHE_TTL_MS2) rmSync5(path, { force: true });
|
|
7991
8128
|
} catch {
|
|
7992
8129
|
}
|
|
7993
8130
|
}
|
|
@@ -8041,17 +8178,17 @@ async function resolveMemoriesFromManifest(args) {
|
|
|
8041
8178
|
// src/lib/skill-cache.ts
|
|
8042
8179
|
import { createHash as createHash11 } from "crypto";
|
|
8043
8180
|
import {
|
|
8044
|
-
existsSync as
|
|
8045
|
-
mkdirSync as
|
|
8046
|
-
readFileSync as
|
|
8181
|
+
existsSync as existsSync10,
|
|
8182
|
+
mkdirSync as mkdirSync10,
|
|
8183
|
+
readFileSync as readFileSync23,
|
|
8047
8184
|
readdirSync as readdirSync9,
|
|
8048
8185
|
renameSync as renameSync7,
|
|
8049
|
-
rmSync as
|
|
8186
|
+
rmSync as rmSync6,
|
|
8050
8187
|
statSync as statSync10,
|
|
8051
8188
|
utimesSync as utimesSync3,
|
|
8052
|
-
writeFileSync as
|
|
8189
|
+
writeFileSync as writeFileSync11
|
|
8053
8190
|
} from "fs";
|
|
8054
|
-
import { join as
|
|
8191
|
+
import { join as join30 } from "path";
|
|
8055
8192
|
var SKILL_FETCH_CHUNK = 100;
|
|
8056
8193
|
var CACHE_TTL_MS3 = 30 * 24 * 60 * 60 * 1e3;
|
|
8057
8194
|
var SWEEP_INTERVAL_MS3 = 24 * 60 * 60 * 1e3;
|
|
@@ -8060,12 +8197,12 @@ function skillHash(content) {
|
|
|
8060
8197
|
return createHash11("sha256").update(content, "utf8").digest("hex");
|
|
8061
8198
|
}
|
|
8062
8199
|
function cachePath3(cacheDir, hash) {
|
|
8063
|
-
return
|
|
8200
|
+
return join30(cacheDir, hash);
|
|
8064
8201
|
}
|
|
8065
8202
|
function readCachedSkill(cacheDir, hash) {
|
|
8066
8203
|
const path = cachePath3(cacheDir, hash);
|
|
8067
8204
|
try {
|
|
8068
|
-
const content =
|
|
8205
|
+
const content = readFileSync23(path, "utf-8");
|
|
8069
8206
|
try {
|
|
8070
8207
|
const now = /* @__PURE__ */ new Date();
|
|
8071
8208
|
utimesSync3(path, now, now);
|
|
@@ -8079,9 +8216,9 @@ function readCachedSkill(cacheDir, hash) {
|
|
|
8079
8216
|
function writeCachedSkill(cacheDir, hash, content) {
|
|
8080
8217
|
if (skillHash(content) !== hash) return "mismatch";
|
|
8081
8218
|
try {
|
|
8082
|
-
|
|
8219
|
+
mkdirSync10(cacheDir, { recursive: true });
|
|
8083
8220
|
const tmp = `${cachePath3(cacheDir, hash)}.tmp-${process.pid}`;
|
|
8084
|
-
|
|
8221
|
+
writeFileSync11(tmp, content, "utf-8");
|
|
8085
8222
|
renameSync7(tmp, cachePath3(cacheDir, hash));
|
|
8086
8223
|
return "written";
|
|
8087
8224
|
} catch {
|
|
@@ -8092,11 +8229,11 @@ function sweepSkillCache(cacheDir, now = Date.now()) {
|
|
|
8092
8229
|
if (now - lastSweepAt3 < SWEEP_INTERVAL_MS3) return;
|
|
8093
8230
|
lastSweepAt3 = now;
|
|
8094
8231
|
try {
|
|
8095
|
-
if (!
|
|
8232
|
+
if (!existsSync10(cacheDir)) return;
|
|
8096
8233
|
for (const name of readdirSync9(cacheDir)) {
|
|
8097
|
-
const path =
|
|
8234
|
+
const path = join30(cacheDir, name);
|
|
8098
8235
|
try {
|
|
8099
|
-
if (now - statSync10(path).mtimeMs > CACHE_TTL_MS3)
|
|
8236
|
+
if (now - statSync10(path).mtimeMs > CACHE_TTL_MS3) rmSync6(path, { force: true });
|
|
8100
8237
|
} catch {
|
|
8101
8238
|
}
|
|
8102
8239
|
}
|
|
@@ -8423,18 +8560,18 @@ function resolveConditionalResponse(wire, hasCachedBody) {
|
|
|
8423
8560
|
}
|
|
8424
8561
|
|
|
8425
8562
|
// src/lib/channel-hash-cache.ts
|
|
8426
|
-
import { existsSync as
|
|
8427
|
-
import { join as
|
|
8563
|
+
import { existsSync as existsSync11, readFileSync as readFileSync24, writeFileSync as writeFileSync12 } from "fs";
|
|
8564
|
+
import { join as join31 } from "path";
|
|
8428
8565
|
var CACHE_FILENAME = "channel-hash-cache.json";
|
|
8429
8566
|
function getChannelHashCacheFile(configDir) {
|
|
8430
|
-
return
|
|
8567
|
+
return join31(configDir, CACHE_FILENAME);
|
|
8431
8568
|
}
|
|
8432
8569
|
function loadChannelHashCache(target, configDir) {
|
|
8433
8570
|
const path = getChannelHashCacheFile(configDir);
|
|
8434
|
-
if (!
|
|
8571
|
+
if (!existsSync11(path)) return;
|
|
8435
8572
|
let parsed;
|
|
8436
8573
|
try {
|
|
8437
|
-
parsed = JSON.parse(
|
|
8574
|
+
parsed = JSON.parse(readFileSync24(path, "utf-8"));
|
|
8438
8575
|
} catch {
|
|
8439
8576
|
return;
|
|
8440
8577
|
}
|
|
@@ -8448,14 +8585,14 @@ function saveChannelHashCache(source, configDir) {
|
|
|
8448
8585
|
const obj = {};
|
|
8449
8586
|
for (const [key, value] of source) obj[key] = value;
|
|
8450
8587
|
try {
|
|
8451
|
-
|
|
8588
|
+
writeFileSync12(path, JSON.stringify(obj, null, 2));
|
|
8452
8589
|
} catch {
|
|
8453
8590
|
}
|
|
8454
8591
|
}
|
|
8455
8592
|
|
|
8456
8593
|
// src/lib/sender-policy-baseline.ts
|
|
8457
|
-
import { existsSync as
|
|
8458
|
-
import { join as
|
|
8594
|
+
import { existsSync as existsSync12, readFileSync as readFileSync25 } from "fs";
|
|
8595
|
+
import { join as join32 } from "path";
|
|
8459
8596
|
var BASELINE_FILENAME = "sender-policy-baseline.json";
|
|
8460
8597
|
var SENDER_POLICY_BASELINE_VERSION = 1;
|
|
8461
8598
|
var BASELINE_CONCERNS = [
|
|
@@ -8511,14 +8648,14 @@ function createDeliveryBaselineMaps() {
|
|
|
8511
8648
|
};
|
|
8512
8649
|
}
|
|
8513
8650
|
function getSenderPolicyBaselineFile(configDir) {
|
|
8514
|
-
return
|
|
8651
|
+
return join32(configDir, BASELINE_FILENAME);
|
|
8515
8652
|
}
|
|
8516
8653
|
function loadSenderPolicyBaseline(target, configDir, log2) {
|
|
8517
8654
|
const path = getSenderPolicyBaselineFile(configDir);
|
|
8518
|
-
if (!
|
|
8655
|
+
if (!existsSync12(path)) return;
|
|
8519
8656
|
let parsed;
|
|
8520
8657
|
try {
|
|
8521
|
-
parsed = JSON.parse(
|
|
8658
|
+
parsed = JSON.parse(readFileSync25(path, "utf-8"));
|
|
8522
8659
|
} catch (err) {
|
|
8523
8660
|
log2?.(
|
|
8524
8661
|
`[sender-policy] discarding corrupt ${BASELINE_FILENAME} (${err.message}) - restrictive-policy agents will take one fail-closed restart`
|
|
@@ -8597,8 +8734,8 @@ function resolveIntegrationEgressDomains(fetched, persisted) {
|
|
|
8597
8734
|
}
|
|
8598
8735
|
|
|
8599
8736
|
// src/lib/stuck-streak-store.ts
|
|
8600
|
-
import { existsSync as
|
|
8601
|
-
import { join as
|
|
8737
|
+
import { existsSync as existsSync13, readFileSync as readFileSync26 } from "fs";
|
|
8738
|
+
import { join as join33 } from "path";
|
|
8602
8739
|
var STORE_FILENAME = "stuck-streaks.json";
|
|
8603
8740
|
var STUCK_STREAK_STORE_VERSION = 1;
|
|
8604
8741
|
var STUCK_STREAK_CONCERNS = ["channelSync", "realtimeRebind"];
|
|
@@ -8606,7 +8743,7 @@ function createStuckStreakMaps() {
|
|
|
8606
8743
|
return { channelSync: /* @__PURE__ */ new Map(), realtimeRebind: /* @__PURE__ */ new Map() };
|
|
8607
8744
|
}
|
|
8608
8745
|
function getStuckStreakStoreFile(configDir) {
|
|
8609
|
-
return
|
|
8746
|
+
return join33(configDir, STORE_FILENAME);
|
|
8610
8747
|
}
|
|
8611
8748
|
function isValidPersistedStreak(value) {
|
|
8612
8749
|
if (!value || typeof value !== "object" || Array.isArray(value)) return false;
|
|
@@ -8645,10 +8782,10 @@ function buildStuckStreakPayload(source) {
|
|
|
8645
8782
|
}
|
|
8646
8783
|
function loadStuckStreaks(target, configDir, log2) {
|
|
8647
8784
|
const path = getStuckStreakStoreFile(configDir);
|
|
8648
|
-
if (!
|
|
8785
|
+
if (!existsSync13(path)) return;
|
|
8649
8786
|
let parsed;
|
|
8650
8787
|
try {
|
|
8651
|
-
parsed = JSON.parse(
|
|
8788
|
+
parsed = JSON.parse(readFileSync26(path, "utf-8"));
|
|
8652
8789
|
} catch (err) {
|
|
8653
8790
|
log2?.(
|
|
8654
8791
|
`[stuck-streaks] discarding corrupt ${STORE_FILENAME} (${err.message}) \u2014 stuck-streak ages restart from zero and one spurious "recovered" close may follow`
|
|
@@ -8691,7 +8828,7 @@ function pruneStuckStreaksToAgents(maps, activeAgentIds) {
|
|
|
8691
8828
|
}
|
|
8692
8829
|
|
|
8693
8830
|
// src/lib/claude-device-state.ts
|
|
8694
|
-
import { readFileSync as
|
|
8831
|
+
import { readFileSync as readFileSync27, statSync as statSync11 } from "fs";
|
|
8695
8832
|
function claudeDeviceStatePath(env = process.env) {
|
|
8696
8833
|
return effectiveClaudeJsonPath(void 0, env);
|
|
8697
8834
|
}
|
|
@@ -8716,7 +8853,7 @@ function checkClaudeDeviceState(path = claudeDeviceStatePath()) {
|
|
|
8716
8853
|
}
|
|
8717
8854
|
let raw;
|
|
8718
8855
|
try {
|
|
8719
|
-
raw =
|
|
8856
|
+
raw = readFileSync27(path, "utf-8");
|
|
8720
8857
|
} catch {
|
|
8721
8858
|
return { usable: false, reason: "unreadable" };
|
|
8722
8859
|
}
|
|
@@ -9408,7 +9545,7 @@ function planGlobalSkillSync(globalSkills, prevIds, hashOf, knownHash, options)
|
|
|
9408
9545
|
}
|
|
9409
9546
|
|
|
9410
9547
|
// src/lib/manager/integration-skill-cache.ts
|
|
9411
|
-
import { join as
|
|
9548
|
+
import { join as join34 } from "path";
|
|
9412
9549
|
function integrationSkillHashKey(agentId, skillId) {
|
|
9413
9550
|
return `plugin-skill:${agentId}:${skillId}`;
|
|
9414
9551
|
}
|
|
@@ -9424,21 +9561,21 @@ function forgetIntegrationSkill(cache3, agentId, skillId) {
|
|
|
9424
9561
|
function removeIntegrationSkillFolder(opts) {
|
|
9425
9562
|
forgetIntegrationSkill(opts.cache, opts.agentId, opts.entry);
|
|
9426
9563
|
for (const dir of opts.dirs) {
|
|
9427
|
-
opts.removeDir(
|
|
9564
|
+
opts.removeDir(join34(dir, opts.entry));
|
|
9428
9565
|
}
|
|
9429
9566
|
}
|
|
9430
9567
|
|
|
9431
9568
|
// src/lib/manager/managed-skill-manifest.ts
|
|
9432
|
-
import { existsSync as
|
|
9433
|
-
import { dirname as dirname8, join as
|
|
9569
|
+
import { existsSync as existsSync14, mkdirSync as mkdirSync11, readFileSync as readFileSync28, writeFileSync as writeFileSync13 } from "fs";
|
|
9570
|
+
import { dirname as dirname8, join as join35 } from "path";
|
|
9434
9571
|
var MANIFEST_VERSION = 1;
|
|
9435
9572
|
function managedSkillManifestPath(agentRootDir) {
|
|
9436
|
-
return
|
|
9573
|
+
return join35(agentRootDir, "managed-skills.json");
|
|
9437
9574
|
}
|
|
9438
9575
|
function readManagedSkillManifest(path) {
|
|
9439
9576
|
try {
|
|
9440
|
-
if (!
|
|
9441
|
-
const parsed = JSON.parse(
|
|
9577
|
+
if (!existsSync14(path)) return /* @__PURE__ */ new Set();
|
|
9578
|
+
const parsed = JSON.parse(readFileSync28(path, "utf-8"));
|
|
9442
9579
|
const ids = Array.isArray(parsed?.globalSkillIds) ? parsed.globalSkillIds : [];
|
|
9443
9580
|
return new Set(ids.filter((id) => typeof id === "string" && id.length > 0));
|
|
9444
9581
|
} catch {
|
|
@@ -9447,12 +9584,12 @@ function readManagedSkillManifest(path) {
|
|
|
9447
9584
|
}
|
|
9448
9585
|
function writeManagedSkillManifest(path, ids) {
|
|
9449
9586
|
try {
|
|
9450
|
-
|
|
9587
|
+
mkdirSync11(dirname8(path), { recursive: true });
|
|
9451
9588
|
const body = {
|
|
9452
9589
|
version: MANIFEST_VERSION,
|
|
9453
9590
|
globalSkillIds: [...ids].sort()
|
|
9454
9591
|
};
|
|
9455
|
-
|
|
9592
|
+
writeFileSync13(path, JSON.stringify(body, null, 2));
|
|
9456
9593
|
} catch {
|
|
9457
9594
|
}
|
|
9458
9595
|
}
|
|
@@ -9587,8 +9724,8 @@ function resolveModelChain(refreshData) {
|
|
|
9587
9724
|
}
|
|
9588
9725
|
|
|
9589
9726
|
// src/lib/manager/claude-auth.ts
|
|
9590
|
-
import { chmodSync as chmodSync2, existsSync as
|
|
9591
|
-
import { join as
|
|
9727
|
+
import { chmodSync as chmodSync2, existsSync as existsSync15, lstatSync as lstatSync3, mkdirSync as mkdirSync12, rmSync as rmSync7 } from "fs";
|
|
9728
|
+
import { join as join36 } from "path";
|
|
9592
9729
|
import { homedir as homedir13 } from "os";
|
|
9593
9730
|
async function applyClaudeAuthToEnv(childEnv, label, options = {}) {
|
|
9594
9731
|
const apiKey = getApiKey();
|
|
@@ -9607,10 +9744,10 @@ async function applyClaudeAuthToEnv(childEnv, label, options = {}) {
|
|
|
9607
9744
|
}
|
|
9608
9745
|
const claudeDir = claudeConfigDirForChild(childEnv);
|
|
9609
9746
|
for (const filename of [".credentials.json", "credentials.json"]) {
|
|
9610
|
-
const p =
|
|
9611
|
-
if (
|
|
9747
|
+
const p = join36(claudeDir, filename);
|
|
9748
|
+
if (existsSync15(p)) {
|
|
9612
9749
|
try {
|
|
9613
|
-
|
|
9750
|
+
rmSync7(p, { force: true });
|
|
9614
9751
|
log(`[${label}] Removed ${p} (api_key mode \u2014 preventing OAuth fallback)`);
|
|
9615
9752
|
} catch {
|
|
9616
9753
|
}
|
|
@@ -9622,10 +9759,10 @@ async function applyClaudeAuthToEnv(childEnv, label, options = {}) {
|
|
|
9622
9759
|
return { isolated: false };
|
|
9623
9760
|
}
|
|
9624
9761
|
function claudeConfigDirForChild(childEnv) {
|
|
9625
|
-
return childEnv.CLAUDE_CONFIG_DIR?.trim() ||
|
|
9762
|
+
return childEnv.CLAUDE_CONFIG_DIR?.trim() || join36(homedir13(), ".claude");
|
|
9626
9763
|
}
|
|
9627
9764
|
function ensurePrivateConfigDir(dir, platform4 = process.platform, chmod = chmodSync2) {
|
|
9628
|
-
|
|
9765
|
+
mkdirSync12(dir, { recursive: true, mode: 448 });
|
|
9629
9766
|
const st = lstatSync3(dir);
|
|
9630
9767
|
if (!st.isDirectory()) {
|
|
9631
9768
|
throw new Error(`isolated Claude config dir ${dir} is not a real directory (symlink or file); refusing`);
|
|
@@ -9638,7 +9775,7 @@ function ensurePrivateConfigDir(dir, platform4 = process.platform, chmod = chmod
|
|
|
9638
9775
|
}
|
|
9639
9776
|
}
|
|
9640
9777
|
function oneShotIsolatedConfigDir() {
|
|
9641
|
-
return
|
|
9778
|
+
return join36(homedir13(), ".augmented", "claude-oneshot");
|
|
9642
9779
|
}
|
|
9643
9780
|
|
|
9644
9781
|
// src/lib/claude-runtime-auth-probe.ts
|
|
@@ -9983,19 +10120,19 @@ function formatBoardForPrompt(items, template) {
|
|
|
9983
10120
|
}
|
|
9984
10121
|
|
|
9985
10122
|
// src/lib/manager/kanban/nudge-state-cache.ts
|
|
9986
|
-
import { existsSync as
|
|
9987
|
-
import { join as
|
|
10123
|
+
import { existsSync as existsSync16, readFileSync as readFileSync29, writeFileSync as writeFileSync14 } from "fs";
|
|
10124
|
+
import { join as join37 } from "path";
|
|
9988
10125
|
var CACHE_FILENAME2 = "kanban-nudge-state.json";
|
|
9989
10126
|
var KANBAN_NUDGE_STATE_VERSION = 1;
|
|
9990
10127
|
function getKanbanNudgeStateFile(configDir) {
|
|
9991
|
-
return
|
|
10128
|
+
return join37(configDir, CACHE_FILENAME2);
|
|
9992
10129
|
}
|
|
9993
10130
|
function loadKanbanNudgeState(target, configDir) {
|
|
9994
10131
|
const path = getKanbanNudgeStateFile(configDir);
|
|
9995
|
-
if (!
|
|
10132
|
+
if (!existsSync16(path)) return;
|
|
9996
10133
|
let parsed;
|
|
9997
10134
|
try {
|
|
9998
|
-
parsed = JSON.parse(
|
|
10135
|
+
parsed = JSON.parse(readFileSync29(path, "utf-8"));
|
|
9999
10136
|
} catch {
|
|
10000
10137
|
return;
|
|
10001
10138
|
}
|
|
@@ -10027,7 +10164,7 @@ function saveKanbanNudgeState(source, configDir) {
|
|
|
10027
10164
|
const agents = {};
|
|
10028
10165
|
for (const [codeName, state10] of source) agents[codeName] = state10;
|
|
10029
10166
|
try {
|
|
10030
|
-
|
|
10167
|
+
writeFileSync14(path, JSON.stringify({ version: KANBAN_NUDGE_STATE_VERSION, agents }, null, 2));
|
|
10031
10168
|
} catch {
|
|
10032
10169
|
}
|
|
10033
10170
|
}
|
|
@@ -10705,9 +10842,9 @@ function closeSessionRunForCode(codeName, outcome, reason) {
|
|
|
10705
10842
|
|
|
10706
10843
|
// src/lib/manager/scheduler/kanban-route.ts
|
|
10707
10844
|
import { createHash as createHash15 } from "crypto";
|
|
10708
|
-
import { writeFileSync as
|
|
10845
|
+
import { writeFileSync as writeFileSync15, renameSync as renameSync8, mkdirSync as mkdirSync13, readFileSync as readFileSync30, unlinkSync as unlinkSync3 } from "fs";
|
|
10709
10846
|
import { homedir as homedir14 } from "os";
|
|
10710
|
-
import { join as
|
|
10847
|
+
import { join as join38, dirname as dirname9 } from "path";
|
|
10711
10848
|
|
|
10712
10849
|
// src/lib/manager/scheduler/notify.ts
|
|
10713
10850
|
import { createHash as createHash14 } from "crypto";
|
|
@@ -11006,9 +11143,9 @@ async function runScheduledCardDelivery(codeName, agentId, cardId, completedBy,
|
|
|
11006
11143
|
return "delivered";
|
|
11007
11144
|
}
|
|
11008
11145
|
async function recordDeliveryFailureOnCard(codeName, agentId, cardId, failure) {
|
|
11009
|
-
const
|
|
11146
|
+
const note2 = `Delivery failed: this result did not reach its destination on ${failure.medium ?? "its channel"} (${failure.error_code ?? "unknown"}). Automatic attempts are finished, so nothing will re-send it. The result is still on this card: re-send it by hand.`;
|
|
11010
11147
|
try {
|
|
11011
|
-
await api.post("/host/kanban", { agent_id: agentId, update: [{ id: cardId, notes:
|
|
11148
|
+
await api.post("/host/kanban", { agent_id: agentId, update: [{ id: cardId, notes: note2 }] });
|
|
11012
11149
|
} catch (err) {
|
|
11013
11150
|
log(`[scheduled-kanban] delivery: could not record the failed delivery on card ${cardId} on '${codeName}': ${err.message}`);
|
|
11014
11151
|
}
|
|
@@ -11070,19 +11207,19 @@ function resolveScheduledSlackTarget(task) {
|
|
|
11070
11207
|
}
|
|
11071
11208
|
function stampScheduledTurnMarker(codeName, taskId, target) {
|
|
11072
11209
|
try {
|
|
11073
|
-
const file =
|
|
11210
|
+
const file = join38(homedir14(), ".augmented", codeName, SCHEDULED_TURN_MARKER_FILENAME);
|
|
11074
11211
|
const marker = { ts: Date.now(), task_id: taskId, ...target ? { target } : {} };
|
|
11075
11212
|
const tmp = `${file}.tmp`;
|
|
11076
|
-
|
|
11213
|
+
writeFileSync15(tmp, JSON.stringify(marker), "utf8");
|
|
11077
11214
|
renameSync8(tmp, file);
|
|
11078
11215
|
} catch (err) {
|
|
11079
11216
|
log(`[scheduled-kanban] scheduled-turn marker write failed for '${codeName}': ${err.message}`);
|
|
11080
11217
|
}
|
|
11081
11218
|
}
|
|
11082
11219
|
function clearScheduledTurnMarkerForTask(codeName, taskId) {
|
|
11083
|
-
const file =
|
|
11220
|
+
const file = join38(homedir14(), ".augmented", codeName, SCHEDULED_TURN_MARKER_FILENAME);
|
|
11084
11221
|
try {
|
|
11085
|
-
const raw = JSON.parse(
|
|
11222
|
+
const raw = JSON.parse(readFileSync30(file, "utf8"));
|
|
11086
11223
|
if (typeof raw?.task_id !== "string" || raw.task_id !== taskId) return;
|
|
11087
11224
|
unlinkSync3(file);
|
|
11088
11225
|
log(`[scheduled-kanban] scheduled-turn marker cleared for '${codeName}' (task ${taskId} complete)`);
|
|
@@ -11149,8 +11286,8 @@ async function routeScheduledTaskViaKanban(codeName, agentId, task, prompt, dura
|
|
|
11149
11286
|
if (!enqueued) return false;
|
|
11150
11287
|
try {
|
|
11151
11288
|
const doorbell = directChatDoorbellPath(agentId, homedir14());
|
|
11152
|
-
|
|
11153
|
-
|
|
11289
|
+
mkdirSync13(dirname9(doorbell), { recursive: true });
|
|
11290
|
+
writeFileSync15(doorbell, String(Date.now()));
|
|
11154
11291
|
} catch (err) {
|
|
11155
11292
|
log(`[scheduled-kanban] doorbell ring failed for '${codeName}': ${err.message} (notice still queued)`);
|
|
11156
11293
|
}
|
|
@@ -11331,11 +11468,11 @@ async function processClaudeTaskResult(codeName, agentId, templateId, rawOutput,
|
|
|
11331
11468
|
// src/lib/manager/scheduler/execution.ts
|
|
11332
11469
|
import { createHash as createHash16 } from "crypto";
|
|
11333
11470
|
import { homedir as homedir15 } from "os";
|
|
11334
|
-
import { join as
|
|
11471
|
+
import { join as join40 } from "path";
|
|
11335
11472
|
|
|
11336
11473
|
// src/lib/agent-serving-probe.ts
|
|
11337
|
-
import { readFileSync as
|
|
11338
|
-
import { join as
|
|
11474
|
+
import { readFileSync as readFileSync31, readdirSync as readdirSync10, statSync as statSync12 } from "fs";
|
|
11475
|
+
import { join as join39 } from "path";
|
|
11339
11476
|
var RATE_LIMIT_WINDOW_MS = 6 * 60 * 60 * 1e3;
|
|
11340
11477
|
function probeRateLimit(args) {
|
|
11341
11478
|
const now = args.now ?? /* @__PURE__ */ new Date();
|
|
@@ -11351,7 +11488,7 @@ function probeRateLimit(args) {
|
|
|
11351
11488
|
let newest = UNKNOWN_RATE_LIMIT;
|
|
11352
11489
|
for (const name of entries) {
|
|
11353
11490
|
if (!name.endsWith(".jsonl")) continue;
|
|
11354
|
-
const path =
|
|
11491
|
+
const path = join39(dir, name);
|
|
11355
11492
|
try {
|
|
11356
11493
|
const st = statSync12(path);
|
|
11357
11494
|
if (!st.isFile() || st.mtimeMs < startMs) continue;
|
|
@@ -11360,7 +11497,7 @@ function probeRateLimit(args) {
|
|
|
11360
11497
|
}
|
|
11361
11498
|
let content;
|
|
11362
11499
|
try {
|
|
11363
|
-
content =
|
|
11500
|
+
content = readFileSync31(path, "utf-8");
|
|
11364
11501
|
} catch {
|
|
11365
11502
|
continue;
|
|
11366
11503
|
}
|
|
@@ -11422,7 +11559,7 @@ function shouldLogUsageCapDeferral(site, codeName, limitedUntil) {
|
|
|
11422
11559
|
|
|
11423
11560
|
// src/lib/manager/scheduler/execution.ts
|
|
11424
11561
|
function claudePidFilePath() {
|
|
11425
|
-
return
|
|
11562
|
+
return join40(homedir15(), ".augmented", "manager-claude-pids.json");
|
|
11426
11563
|
}
|
|
11427
11564
|
var inFlightClaudePids = /* @__PURE__ */ new Map();
|
|
11428
11565
|
function registerClaudeSpawn(record) {
|
|
@@ -11664,7 +11801,7 @@ var BlockedPromptReportCadence = class {
|
|
|
11664
11801
|
|
|
11665
11802
|
// src/lib/occupancy-gate.ts
|
|
11666
11803
|
import { closeSync as closeSync4, openSync as openSync4, readdirSync as readdirSync11, readSync as readSync4, statSync as statSync13 } from "fs";
|
|
11667
|
-
import { join as
|
|
11804
|
+
import { join as join41 } from "path";
|
|
11668
11805
|
function rostersMeasuredZero(mode, attested, runtimeRunning) {
|
|
11669
11806
|
return mode === "enforce" && attested && runtimeRunning;
|
|
11670
11807
|
}
|
|
@@ -11755,10 +11892,10 @@ function candidateTranscriptPaths(dir) {
|
|
|
11755
11892
|
let complete = true;
|
|
11756
11893
|
for (const name of top) {
|
|
11757
11894
|
if (name.endsWith(".jsonl")) {
|
|
11758
|
-
paths.push(
|
|
11895
|
+
paths.push(join41(dir, name));
|
|
11759
11896
|
continue;
|
|
11760
11897
|
}
|
|
11761
|
-
const subDir =
|
|
11898
|
+
const subDir = join41(dir, name, "subagents");
|
|
11762
11899
|
let subs;
|
|
11763
11900
|
try {
|
|
11764
11901
|
subs = readdirSync11(subDir);
|
|
@@ -11767,7 +11904,7 @@ function candidateTranscriptPaths(dir) {
|
|
|
11767
11904
|
continue;
|
|
11768
11905
|
}
|
|
11769
11906
|
for (const sub of subs) {
|
|
11770
|
-
if (sub.endsWith(".jsonl")) paths.push(
|
|
11907
|
+
if (sub.endsWith(".jsonl")) paths.push(join41(subDir, sub));
|
|
11771
11908
|
}
|
|
11772
11909
|
}
|
|
11773
11910
|
return { paths, complete };
|
|
@@ -11993,7 +12130,7 @@ function stopPaneOccupancySampler() {
|
|
|
11993
12130
|
}
|
|
11994
12131
|
|
|
11995
12132
|
// src/lib/pid-pressure-sampler.ts
|
|
11996
|
-
import { existsSync as
|
|
12133
|
+
import { existsSync as existsSync17, readFileSync as readFileSync32 } from "fs";
|
|
11997
12134
|
var SAMPLE_INTERVAL_MS2 = 3e4;
|
|
11998
12135
|
function warnFraction() {
|
|
11999
12136
|
const raw = Number(process.env.AGT_PID_PRESSURE_WARN_FRACTION);
|
|
@@ -12021,7 +12158,7 @@ function parseMemoryEvents(text) {
|
|
|
12021
12158
|
}
|
|
12022
12159
|
function readTextReal(path) {
|
|
12023
12160
|
try {
|
|
12024
|
-
return
|
|
12161
|
+
return readFileSync32(path, "utf-8");
|
|
12025
12162
|
} catch {
|
|
12026
12163
|
return null;
|
|
12027
12164
|
}
|
|
@@ -12030,7 +12167,7 @@ var cgroupDirCache = /* @__PURE__ */ new Map();
|
|
|
12030
12167
|
var resolveRetryAfter = /* @__PURE__ */ new Map();
|
|
12031
12168
|
var RESOLVE_RETRY_BACKOFF_MS = 5 * 6e4;
|
|
12032
12169
|
function resolveCgroupDirReal(codeName, deps = {}) {
|
|
12033
|
-
const exists = deps.exists ??
|
|
12170
|
+
const exists = deps.exists ?? existsSync17;
|
|
12034
12171
|
const inspectId = deps.inspectId ?? inspectContainerId;
|
|
12035
12172
|
const now = deps.now ?? Date.now;
|
|
12036
12173
|
const cached = cgroupDirCache.get(codeName);
|
|
@@ -13403,9 +13540,9 @@ async function fireOpencodeScheduledTask(agent, task) {
|
|
|
13403
13540
|
|
|
13404
13541
|
// src/lib/opencode-telegram-ingest.ts
|
|
13405
13542
|
import { createHash as createHash19 } from "crypto";
|
|
13406
|
-
import { existsSync as
|
|
13543
|
+
import { existsSync as existsSync18, mkdirSync as mkdirSync14, readFileSync as readFileSync33, renameSync as renameSync9, unlinkSync as unlinkSync4, writeFileSync as writeFileSync16 } from "fs";
|
|
13407
13544
|
import { randomUUID } from "crypto";
|
|
13408
|
-
import { join as
|
|
13545
|
+
import { join as join42 } from "path";
|
|
13409
13546
|
|
|
13410
13547
|
// src/lib/telegram-ingest.ts
|
|
13411
13548
|
import https2 from "https";
|
|
@@ -14108,7 +14245,7 @@ function createFileOffsetStore(codeName, log2, currentBotId) {
|
|
|
14108
14245
|
let filePath;
|
|
14109
14246
|
try {
|
|
14110
14247
|
dir = getFramework("opencode").getAgentDir(codeName);
|
|
14111
|
-
filePath =
|
|
14248
|
+
filePath = join42(dir, "telegram-getupdates-offset-opencode.json");
|
|
14112
14249
|
} catch {
|
|
14113
14250
|
dir = null;
|
|
14114
14251
|
filePath = null;
|
|
@@ -14117,7 +14254,7 @@ function createFileOffsetStore(codeName, log2, currentBotId) {
|
|
|
14117
14254
|
load() {
|
|
14118
14255
|
if (!filePath) return 0;
|
|
14119
14256
|
try {
|
|
14120
|
-
const parsed = JSON.parse(
|
|
14257
|
+
const parsed = JSON.parse(readFileSync33(filePath, "utf-8"));
|
|
14121
14258
|
if (currentBotId != null && typeof parsed?.bot_id === "number" && parsed.bot_id !== currentBotId) {
|
|
14122
14259
|
log2(`[telegram-ingest:${codeName}] offset cursor belongs to a different bot; ignoring (bot swap)`);
|
|
14123
14260
|
return 0;
|
|
@@ -14135,8 +14272,8 @@ function createFileOffsetStore(codeName, log2, currentBotId) {
|
|
|
14135
14272
|
if (!filePath || !dir) return;
|
|
14136
14273
|
const tmpPath = `${filePath}.${process.pid}.${randomUUID()}.tmp`;
|
|
14137
14274
|
try {
|
|
14138
|
-
|
|
14139
|
-
|
|
14275
|
+
mkdirSync14(dir, { recursive: true, mode: 448 });
|
|
14276
|
+
writeFileSync16(
|
|
14140
14277
|
tmpPath,
|
|
14141
14278
|
JSON.stringify({
|
|
14142
14279
|
offset,
|
|
@@ -14150,7 +14287,7 @@ function createFileOffsetStore(codeName, log2, currentBotId) {
|
|
|
14150
14287
|
} catch (err) {
|
|
14151
14288
|
log2(`[telegram-ingest:${codeName}] offset persist failed: ${err instanceof Error ? err.message : String(err)}`);
|
|
14152
14289
|
try {
|
|
14153
|
-
if (
|
|
14290
|
+
if (existsSync18(tmpPath)) unlinkSync4(tmpPath);
|
|
14154
14291
|
} catch {
|
|
14155
14292
|
}
|
|
14156
14293
|
}
|
|
@@ -14162,7 +14299,7 @@ function createFileMigrationReportIO(codeName, log2) {
|
|
|
14162
14299
|
let filePath;
|
|
14163
14300
|
try {
|
|
14164
14301
|
dir = getFramework("opencode").getAgentDir(codeName);
|
|
14165
|
-
filePath =
|
|
14302
|
+
filePath = join42(dir, "telegram-migration-reports-opencode.json");
|
|
14166
14303
|
} catch {
|
|
14167
14304
|
dir = null;
|
|
14168
14305
|
filePath = null;
|
|
@@ -14171,7 +14308,7 @@ function createFileMigrationReportIO(codeName, log2) {
|
|
|
14171
14308
|
load() {
|
|
14172
14309
|
if (!filePath) return null;
|
|
14173
14310
|
try {
|
|
14174
|
-
return
|
|
14311
|
+
return readFileSync33(filePath, "utf-8");
|
|
14175
14312
|
} catch {
|
|
14176
14313
|
return null;
|
|
14177
14314
|
}
|
|
@@ -14179,7 +14316,7 @@ function createFileMigrationReportIO(codeName, log2) {
|
|
|
14179
14316
|
save(data) {
|
|
14180
14317
|
if (!filePath || !dir) return;
|
|
14181
14318
|
try {
|
|
14182
|
-
|
|
14319
|
+
mkdirSync14(dir, { recursive: true, mode: 448 });
|
|
14183
14320
|
atomicWriteFileSync(filePath, data, { mode: 384 });
|
|
14184
14321
|
} catch (err) {
|
|
14185
14322
|
log2(`[telegram-ingest:${codeName}] migration-report persist failed: ${err instanceof Error ? err.message : String(err)}`);
|
|
@@ -14188,7 +14325,7 @@ function createFileMigrationReportIO(codeName, log2) {
|
|
|
14188
14325
|
};
|
|
14189
14326
|
}
|
|
14190
14327
|
var managerHostPost = async (path, body) => {
|
|
14191
|
-
const { api: api2, ApiError: ApiError3 } = await import("../api-client-
|
|
14328
|
+
const { api: api2, ApiError: ApiError3 } = await import("../api-client-2YLFNHFZ.js");
|
|
14192
14329
|
try {
|
|
14193
14330
|
const json = await api2.post(path, body);
|
|
14194
14331
|
return { status: 200, json };
|
|
@@ -14454,24 +14591,24 @@ function partitionActionableByPoison(actionable, states, config2) {
|
|
|
14454
14591
|
}
|
|
14455
14592
|
|
|
14456
14593
|
// src/lib/restart-flags.ts
|
|
14457
|
-
import { existsSync as
|
|
14594
|
+
import { existsSync as existsSync19, mkdirSync as mkdirSync15, readdirSync as readdirSync12, readFileSync as readFileSync34, renameSync as renameSync10, rmSync as rmSync8, writeFileSync as writeFileSync17 } from "fs";
|
|
14458
14595
|
import { homedir as homedir16 } from "os";
|
|
14459
|
-
import { join as
|
|
14596
|
+
import { join as join43 } from "path";
|
|
14460
14597
|
import { randomUUID as randomUUID2 } from "crypto";
|
|
14461
14598
|
function restartFlagsDir() {
|
|
14462
|
-
return
|
|
14599
|
+
return join43(homedir16(), ".augmented", "restart-flags");
|
|
14463
14600
|
}
|
|
14464
14601
|
function flagPath(codeName) {
|
|
14465
|
-
return
|
|
14602
|
+
return join43(restartFlagsDir(), `${codeName}.flag`);
|
|
14466
14603
|
}
|
|
14467
14604
|
function readRestartFlags() {
|
|
14468
14605
|
const dir = restartFlagsDir();
|
|
14469
|
-
if (!
|
|
14606
|
+
if (!existsSync19(dir)) return [];
|
|
14470
14607
|
const out = [];
|
|
14471
14608
|
for (const entry of readdirSync12(dir)) {
|
|
14472
14609
|
if (!entry.endsWith(".flag")) continue;
|
|
14473
14610
|
try {
|
|
14474
|
-
const raw =
|
|
14611
|
+
const raw = readFileSync34(join43(dir, entry), "utf8");
|
|
14475
14612
|
const parsed = JSON.parse(raw);
|
|
14476
14613
|
if (typeof parsed.codeName !== "string" || parsed.codeName.length === 0) {
|
|
14477
14614
|
parsed.codeName = entry.replace(/\.flag$/, "");
|
|
@@ -14489,8 +14626,8 @@ function readRestartFlags() {
|
|
|
14489
14626
|
}
|
|
14490
14627
|
function deleteRestartFlag(codeName) {
|
|
14491
14628
|
const path = flagPath(codeName);
|
|
14492
|
-
if (
|
|
14493
|
-
|
|
14629
|
+
if (existsSync19(path)) {
|
|
14630
|
+
rmSync8(path, { force: true });
|
|
14494
14631
|
}
|
|
14495
14632
|
}
|
|
14496
14633
|
|
|
@@ -14589,8 +14726,8 @@ async function sendError(flag, opts, text) {
|
|
|
14589
14726
|
}
|
|
14590
14727
|
|
|
14591
14728
|
// src/lib/restart-context.ts
|
|
14592
|
-
import { readdirSync as readdirSync13, readFileSync as
|
|
14593
|
-
import { dirname as dirname10, join as
|
|
14729
|
+
import { readdirSync as readdirSync13, readFileSync as readFileSync35, writeFileSync as writeFileSync18, mkdirSync as mkdirSync16, unlinkSync as unlinkSync5 } from "fs";
|
|
14730
|
+
import { dirname as dirname10, join as join44 } from "path";
|
|
14594
14731
|
var SLACK_PENDING_INBOUND_DIRNAME = "slack-pending-inbound";
|
|
14595
14732
|
var SLACK_RESTART_CONTEXT_DIRNAME = "slack-restart-context";
|
|
14596
14733
|
var MAX_TOPIC_CHARS = 140;
|
|
@@ -14602,10 +14739,10 @@ function augmentedAgentDir(codeName) {
|
|
|
14602
14739
|
return dirname10(getProjectDir(codeName));
|
|
14603
14740
|
}
|
|
14604
14741
|
function slackPendingInboundDir(codeName) {
|
|
14605
|
-
return
|
|
14742
|
+
return join44(augmentedAgentDir(codeName), SLACK_PENDING_INBOUND_DIRNAME);
|
|
14606
14743
|
}
|
|
14607
14744
|
function slackRestartContextDir(codeName) {
|
|
14608
|
-
return
|
|
14745
|
+
return join44(augmentedAgentDir(codeName), SLACK_RESTART_CONTEXT_DIRNAME);
|
|
14609
14746
|
}
|
|
14610
14747
|
function sanitizeTopic(raw) {
|
|
14611
14748
|
const cleaned = raw.replace(/\s+/g, " ").trim().replace(/[<>]/g, " ").replace(/\s+/g, " ").trim();
|
|
@@ -14647,7 +14784,7 @@ function safeReaddir(dir) {
|
|
|
14647
14784
|
}
|
|
14648
14785
|
function readStrandedMarker(path) {
|
|
14649
14786
|
try {
|
|
14650
|
-
const parsed = JSON.parse(
|
|
14787
|
+
const parsed = JSON.parse(readFileSync35(path, "utf-8"));
|
|
14651
14788
|
if (typeof parsed.channel === "string" && typeof parsed.thread_ts === "string") {
|
|
14652
14789
|
return { channel: parsed.channel, thread_ts: parsed.thread_ts };
|
|
14653
14790
|
}
|
|
@@ -14656,8 +14793,8 @@ function readStrandedMarker(path) {
|
|
|
14656
14793
|
return null;
|
|
14657
14794
|
}
|
|
14658
14795
|
function writeHintFile(path, dir, hint) {
|
|
14659
|
-
|
|
14660
|
-
|
|
14796
|
+
mkdirSync16(dir, { recursive: true, mode: 448 });
|
|
14797
|
+
writeFileSync18(path, JSON.stringify(hint), { mode: 384 });
|
|
14661
14798
|
}
|
|
14662
14799
|
function pruneHintsExcept(codeName, freshFilenames) {
|
|
14663
14800
|
const ctxDir = slackRestartContextDir(codeName);
|
|
@@ -14665,7 +14802,7 @@ function pruneHintsExcept(codeName, freshFilenames) {
|
|
|
14665
14802
|
if (!filename.endsWith(".json")) continue;
|
|
14666
14803
|
if (freshFilenames.has(filename)) continue;
|
|
14667
14804
|
try {
|
|
14668
|
-
unlinkSync5(
|
|
14805
|
+
unlinkSync5(join44(ctxDir, filename));
|
|
14669
14806
|
} catch {
|
|
14670
14807
|
}
|
|
14671
14808
|
}
|
|
@@ -14686,7 +14823,7 @@ function refreshSlackRestartContextHints(codeNames, opts = {}) {
|
|
|
14686
14823
|
}
|
|
14687
14824
|
const markers = [];
|
|
14688
14825
|
for (const filename of markerFilenames.slice(0, cap)) {
|
|
14689
|
-
const parsed = readStrandedMarker(
|
|
14826
|
+
const parsed = readStrandedMarker(join44(markerDir, filename));
|
|
14690
14827
|
if (parsed) markers.push({ filename, channel: parsed.channel, thread_ts: parsed.thread_ts });
|
|
14691
14828
|
}
|
|
14692
14829
|
if (markers.length === 0) {
|
|
@@ -14700,7 +14837,7 @@ function refreshSlackRestartContextHints(codeNames, opts = {}) {
|
|
|
14700
14837
|
const freshFilenames = /* @__PURE__ */ new Set();
|
|
14701
14838
|
for (const { filename, hint } of hints) {
|
|
14702
14839
|
try {
|
|
14703
|
-
writeHintFile(
|
|
14840
|
+
writeHintFile(join44(ctxDir, filename), ctxDir, hint);
|
|
14704
14841
|
freshFilenames.add(filename);
|
|
14705
14842
|
} catch (err) {
|
|
14706
14843
|
log2(`[restart-context] ${codeName}: hint write failed for ${filename}: ${err.message}`);
|
|
@@ -15506,7 +15643,7 @@ async function runDangerousRmBackstop(agentId, codeName, pane) {
|
|
|
15506
15643
|
return;
|
|
15507
15644
|
}
|
|
15508
15645
|
const policy = readRmPolicyText(
|
|
15509
|
-
() =>
|
|
15646
|
+
() => readFileSync36(join45(getFramework("claude-code").getAgentDir(codeName), RM_POLICY_RELATIVE_PATH), "utf-8")
|
|
15510
15647
|
);
|
|
15511
15648
|
const decision = decideDangerousRm(action.prompt, policy, {
|
|
15512
15649
|
isolated: isolationMode(codeName) === "docker"
|
|
@@ -16227,7 +16364,7 @@ var pendingDayRolloverReset = /* @__PURE__ */ new Set();
|
|
|
16227
16364
|
var dayRolloverInboundHold = /* @__PURE__ */ new Map();
|
|
16228
16365
|
var INBOUND_HOLD_EPISODE_GAP_MS = 12e4;
|
|
16229
16366
|
async function channelInboundActivityAgeSecondsFor(codeName) {
|
|
16230
|
-
const { newestPendingInboundActivityMtimeMs } = await import("../responsiveness-probe-
|
|
16367
|
+
const { newestPendingInboundActivityMtimeMs } = await import("../responsiveness-probe-KDSNPKUY.js");
|
|
16231
16368
|
const newest = newestPendingInboundActivityMtimeMs(dirname11(paneLogPath(codeName)));
|
|
16232
16369
|
if (newest === null) return null;
|
|
16233
16370
|
return Math.max(0, Math.floor((Date.now() - newest) / 1e3));
|
|
@@ -16596,7 +16733,7 @@ var runningChannelSecretHashes = /* @__PURE__ */ new Map();
|
|
|
16596
16733
|
var sessionLaunchManagedStructure = /* @__PURE__ */ new Map();
|
|
16597
16734
|
function projectMcpHash(_codeName, projectDir) {
|
|
16598
16735
|
try {
|
|
16599
|
-
const raw =
|
|
16736
|
+
const raw = readFileSync36(join45(projectDir, ".mcp.json"), "utf-8");
|
|
16600
16737
|
return createHash20("sha256").update(canonicalJson(JSON.parse(raw))).digest("hex");
|
|
16601
16738
|
} catch {
|
|
16602
16739
|
return null;
|
|
@@ -16604,7 +16741,7 @@ function projectMcpHash(_codeName, projectDir) {
|
|
|
16604
16741
|
}
|
|
16605
16742
|
function projectMcpKeys(_codeName, projectDir) {
|
|
16606
16743
|
try {
|
|
16607
|
-
const raw =
|
|
16744
|
+
const raw = readFileSync36(join45(projectDir, ".mcp.json"), "utf-8");
|
|
16608
16745
|
const parsed = JSON.parse(raw);
|
|
16609
16746
|
const servers = parsed.mcpServers;
|
|
16610
16747
|
if (!servers || typeof servers !== "object") return /* @__PURE__ */ new Set();
|
|
@@ -16622,7 +16759,7 @@ function seedSessionLaunchBaselines(codeName, projectDir) {
|
|
|
16622
16759
|
else runningMcpServerKeys.delete(codeName);
|
|
16623
16760
|
let launchStructure = null;
|
|
16624
16761
|
try {
|
|
16625
|
-
const raw =
|
|
16762
|
+
const raw = readFileSync36(join45(projectDir, ".mcp.json"), "utf-8");
|
|
16626
16763
|
launchStructure = managedMcpStructureHashFromFile(
|
|
16627
16764
|
JSON.parse(raw),
|
|
16628
16765
|
isManagedMcpServerKey
|
|
@@ -16774,7 +16911,7 @@ async function runAgentSessionToolBindProbes(agent, integrations, projectDir, op
|
|
|
16774
16911
|
if (result && result.rebindCandidates.length > 0 && hostFlagStore().getBoolean("session-tool-rebind")) {
|
|
16775
16912
|
let mcpJsonForRebind = null;
|
|
16776
16913
|
try {
|
|
16777
|
-
mcpJsonForRebind = JSON.parse(
|
|
16914
|
+
mcpJsonForRebind = JSON.parse(readFileSync36(join45(projectDir, ".mcp.json"), "utf-8"));
|
|
16778
16915
|
} catch {
|
|
16779
16916
|
mcpJsonForRebind = null;
|
|
16780
16917
|
}
|
|
@@ -16923,7 +17060,7 @@ function shouldInjectChannelSecrets(agentId) {
|
|
|
16923
17060
|
function projectChannelSecretHash(projectDir) {
|
|
16924
17061
|
try {
|
|
16925
17062
|
const entries = parseEnvIntegrations(
|
|
16926
|
-
|
|
17063
|
+
readFileSync36(join45(projectDir, ".env.integrations"), "utf-8")
|
|
16927
17064
|
);
|
|
16928
17065
|
return channelSecretValueHash(entries, CHANNEL_SECRET_ENV_KEYS);
|
|
16929
17066
|
} catch {
|
|
@@ -17043,7 +17180,7 @@ var agentRestartTimezoneInputs = /* @__PURE__ */ new Map();
|
|
|
17043
17180
|
var lastVersionCheckAt = 0;
|
|
17044
17181
|
var VERSION_CHECK_INTERVAL_MS = 5 * 60 * 1e3;
|
|
17045
17182
|
var lastResponsivenessProbeAt = 0;
|
|
17046
|
-
var agtCliVersion = true ? "0.28.
|
|
17183
|
+
var agtCliVersion = true ? "0.28.1261" : "dev";
|
|
17047
17184
|
function resolveBrewPath(execFileSync4) {
|
|
17048
17185
|
try {
|
|
17049
17186
|
const out = execFileSync4("which", ["brew"], { timeout: 5e3 }).toString().trim();
|
|
@@ -17056,7 +17193,7 @@ function resolveBrewPath(execFileSync4) {
|
|
|
17056
17193
|
"/usr/local/bin/brew"
|
|
17057
17194
|
];
|
|
17058
17195
|
for (const path of fallbacks) {
|
|
17059
|
-
if (
|
|
17196
|
+
if (existsSync20(path)) return path;
|
|
17060
17197
|
}
|
|
17061
17198
|
return null;
|
|
17062
17199
|
}
|
|
@@ -17066,7 +17203,7 @@ function claudeBinaryInstalled(execFileSync4) {
|
|
|
17066
17203
|
"/opt/homebrew/bin/claude",
|
|
17067
17204
|
"/usr/local/bin/claude"
|
|
17068
17205
|
];
|
|
17069
|
-
if (canonical.some((path) =>
|
|
17206
|
+
if (canonical.some((path) => existsSync20(path))) return true;
|
|
17070
17207
|
try {
|
|
17071
17208
|
execFileSync4("which", ["claude"], { timeout: 5e3 });
|
|
17072
17209
|
return true;
|
|
@@ -17603,7 +17740,7 @@ function runAsync(cmd, args, opts) {
|
|
|
17603
17740
|
});
|
|
17604
17741
|
}
|
|
17605
17742
|
function claudeManagedSettingsPath() {
|
|
17606
|
-
return
|
|
17743
|
+
return join45(CLAUDE_MANAGED_SETTINGS_DIR, "managed-settings.json");
|
|
17607
17744
|
}
|
|
17608
17745
|
var MANAGED_SETTINGS_KEYS = ["channelsEnabled", "enableAllProjectMcpServers"];
|
|
17609
17746
|
var MANAGED_SETTINGS_ENV = { DISABLE_AUTOUPDATER: "1" };
|
|
@@ -17626,7 +17763,7 @@ function deniedTools(settings) {
|
|
|
17626
17763
|
}
|
|
17627
17764
|
function readCrossSessionBlockStatus(path = claudeManagedSettingsPath()) {
|
|
17628
17765
|
try {
|
|
17629
|
-
const parsed = JSON.parse(
|
|
17766
|
+
const parsed = JSON.parse(readFileSync36(path, "utf-8"));
|
|
17630
17767
|
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) return "missing";
|
|
17631
17768
|
const settings = parsed;
|
|
17632
17769
|
const deny = deniedTools(settings);
|
|
@@ -17645,14 +17782,14 @@ function managedSettingsOwnership(path) {
|
|
|
17645
17782
|
}
|
|
17646
17783
|
function writeManagedSettings(path, body, write = {
|
|
17647
17784
|
atomic: (p, d) => atomicWriteFileSync(p, d, managedSettingsOwnership(p)),
|
|
17648
|
-
inPlace: (p, d) =>
|
|
17785
|
+
inPlace: (p, d) => writeFileSync19(p, d)
|
|
17649
17786
|
}) {
|
|
17650
17787
|
try {
|
|
17651
17788
|
write.atomic(path, body);
|
|
17652
17789
|
return "atomic";
|
|
17653
17790
|
} catch (err) {
|
|
17654
17791
|
const code = err.code;
|
|
17655
|
-
if ((code === "EACCES" || code === "EPERM" || code === "EROFS") &&
|
|
17792
|
+
if ((code === "EACCES" || code === "EPERM" || code === "EROFS") && existsSync20(path)) {
|
|
17656
17793
|
write.inPlace(path, body);
|
|
17657
17794
|
log(`[managed-settings] ${path}: directory refused the atomic write (${code}); wrote in place (ENG-10191)`);
|
|
17658
17795
|
return "in_place";
|
|
@@ -17665,8 +17802,8 @@ function ensureClaudeManagedSettings(path = claudeManagedSettingsPath(), write =
|
|
|
17665
17802
|
}) {
|
|
17666
17803
|
try {
|
|
17667
17804
|
let settings = {};
|
|
17668
|
-
if (
|
|
17669
|
-
const raw =
|
|
17805
|
+
if (existsSync20(path)) {
|
|
17806
|
+
const raw = readFileSync36(path, "utf-8").trim();
|
|
17670
17807
|
if (raw) {
|
|
17671
17808
|
let parsed;
|
|
17672
17809
|
try {
|
|
@@ -17707,7 +17844,7 @@ function ensureClaudeManagedSettings(path = claudeManagedSettingsPath(), write =
|
|
|
17707
17844
|
const body = `${JSON.stringify(settings, null, 2)}
|
|
17708
17845
|
`;
|
|
17709
17846
|
try {
|
|
17710
|
-
|
|
17847
|
+
mkdirSync17(dirname11(path), { recursive: true });
|
|
17711
17848
|
write(path, body);
|
|
17712
17849
|
} catch (err) {
|
|
17713
17850
|
if (channelKeysNeeded) throw err;
|
|
@@ -17759,7 +17896,7 @@ async function ensureOpencodeBinary() {
|
|
|
17759
17896
|
try {
|
|
17760
17897
|
const prefix = execFileSync4("npm", ["prefix", "-g"], { encoding: "utf-8", timeout: 1e4 }).trim();
|
|
17761
17898
|
if (prefix) {
|
|
17762
|
-
const npmBin =
|
|
17899
|
+
const npmBin = join45(prefix, "bin");
|
|
17763
17900
|
const current = (process.env.PATH ?? "").split(pathDelimiter);
|
|
17764
17901
|
if (!current.includes(npmBin)) {
|
|
17765
17902
|
process.env.PATH = [npmBin, ...current.filter(Boolean)].join(pathDelimiter);
|
|
@@ -17820,7 +17957,7 @@ async function ensureFrameworkBinary(frameworkId) {
|
|
|
17820
17957
|
if (!process.env.PATH?.split(":").includes(brewBinDir)) {
|
|
17821
17958
|
process.env.PATH = `${brewBinDir}:${process.env.PATH ?? ""}`;
|
|
17822
17959
|
}
|
|
17823
|
-
if (
|
|
17960
|
+
if (existsSync20("/home/linuxbrew/.linuxbrew/bin/claude")) {
|
|
17824
17961
|
log("Claude Code installed successfully");
|
|
17825
17962
|
} else {
|
|
17826
17963
|
log("Claude Code install completed but binary not found at expected path \u2014 check brew logs");
|
|
@@ -17830,6 +17967,16 @@ async function ensureFrameworkBinary(frameworkId) {
|
|
|
17830
17967
|
agentRuntimeAuthenticated = await checkClaudeAuth();
|
|
17831
17968
|
}
|
|
17832
17969
|
var claudeCodeUpgradeInFlight = false;
|
|
17970
|
+
var SCRATCH_HOLDS_DIR = () => join45(homedir17(), ".augmented", ".manager-scratch-holds");
|
|
17971
|
+
setScratchSweepPolicyResolver(
|
|
17972
|
+
(codeName) => resolveScratchSweepPolicy({
|
|
17973
|
+
agentId: agentState.codeNameToAgentId.get(codeName),
|
|
17974
|
+
codeName,
|
|
17975
|
+
holdsDir: SCRATCH_HOLDS_DIR(),
|
|
17976
|
+
flagState: (agentId) => hostFlagStore().perAgentFlagState(agentId),
|
|
17977
|
+
flag: (key, agentId) => hostFlagStore().getBooleanForAgent(key, agentId)
|
|
17978
|
+
})
|
|
17979
|
+
);
|
|
17833
17980
|
async function maybeUpgradeClaudeCode() {
|
|
17834
17981
|
if (claudeCodeUpgradeInFlight) return;
|
|
17835
17982
|
if (claudeCodeUpgradeThrottled()) return;
|
|
@@ -17899,7 +18046,7 @@ async function maybeUpgradeClaudeCode() {
|
|
|
17899
18046
|
}
|
|
17900
18047
|
var UPDATE_CHECK_INTERVAL_MS = 5 * 60 * 1e3;
|
|
17901
18048
|
function selfUpdateAppliedMarkerPath() {
|
|
17902
|
-
return
|
|
18049
|
+
return join45(homedir17(), ".augmented", ".last-self-update-applied");
|
|
17903
18050
|
}
|
|
17904
18051
|
var selfUpdateUpToDateLogged = false;
|
|
17905
18052
|
var selfUpdatePinnedLogged = false;
|
|
@@ -17950,7 +18097,7 @@ async function checkAndUpdateCli(opts) {
|
|
|
17950
18097
|
const isNpmGlobal = !isBrewFormula && resolvedPath.includes("node_modules");
|
|
17951
18098
|
if (!isBrewFormula && !isNpmGlobal) return "noop";
|
|
17952
18099
|
const { readFileSync: readF, writeFileSync: writeF } = await import("fs");
|
|
17953
|
-
const markerPath =
|
|
18100
|
+
const markerPath = join45(homedir17(), ".augmented", ".last-update-check");
|
|
17954
18101
|
if (!force) {
|
|
17955
18102
|
try {
|
|
17956
18103
|
const lastCheck = parseInt(readF(markerPath, "utf-8").trim(), 10);
|
|
@@ -18453,14 +18600,14 @@ async function checkClaudeAuth() {
|
|
|
18453
18600
|
}
|
|
18454
18601
|
var evalEmptyMcpConfigPath = null;
|
|
18455
18602
|
function ensureEvalEmptyMcpConfig() {
|
|
18456
|
-
if (evalEmptyMcpConfigPath &&
|
|
18457
|
-
const dir =
|
|
18603
|
+
if (evalEmptyMcpConfigPath && existsSync20(evalEmptyMcpConfigPath)) return evalEmptyMcpConfigPath;
|
|
18604
|
+
const dir = join45(homedir17(), ".augmented");
|
|
18458
18605
|
try {
|
|
18459
|
-
|
|
18606
|
+
mkdirSync17(dir, { recursive: true });
|
|
18460
18607
|
} catch {
|
|
18461
18608
|
}
|
|
18462
|
-
const p =
|
|
18463
|
-
|
|
18609
|
+
const p = join45(dir, ".eval-empty-mcp.json");
|
|
18610
|
+
writeFileSync19(p, JSON.stringify({ mcpServers: {} }));
|
|
18464
18611
|
evalEmptyMcpConfigPath = p;
|
|
18465
18612
|
return p;
|
|
18466
18613
|
}
|
|
@@ -18550,10 +18697,10 @@ function resolveConversationEvalBackend() {
|
|
|
18550
18697
|
return conversationEvalBackend;
|
|
18551
18698
|
}
|
|
18552
18699
|
function getStateFile() {
|
|
18553
|
-
return
|
|
18700
|
+
return join45(config?.configDir ?? join45(process.env["HOME"] ?? "/tmp", ".augmented"), "manager-state.json");
|
|
18554
18701
|
}
|
|
18555
18702
|
function channelHashCacheDir() {
|
|
18556
|
-
return config?.configDir ??
|
|
18703
|
+
return config?.configDir ?? join45(process.env["HOME"] ?? "/tmp", ".augmented");
|
|
18557
18704
|
}
|
|
18558
18705
|
function loadChannelHashCache2() {
|
|
18559
18706
|
loadChannelHashCache(agentState.knownChannelConfigHashes, channelHashCacheDir());
|
|
@@ -18766,7 +18913,7 @@ function removeDeliveryBaselineEntries(agentId) {
|
|
|
18766
18913
|
var _channelQuarantineStore = null;
|
|
18767
18914
|
function channelQuarantineStore() {
|
|
18768
18915
|
if (!_channelQuarantineStore) {
|
|
18769
|
-
const dir = config?.configDir ??
|
|
18916
|
+
const dir = config?.configDir ?? join45(process.env["HOME"] ?? "/tmp", ".augmented");
|
|
18770
18917
|
_channelQuarantineStore = new ChannelQuarantineStore(defaultQuarantinePath(dir));
|
|
18771
18918
|
}
|
|
18772
18919
|
return _channelQuarantineStore;
|
|
@@ -18774,7 +18921,7 @@ function channelQuarantineStore() {
|
|
|
18774
18921
|
var _channelResumeHistoryStore = null;
|
|
18775
18922
|
function channelResumeHistoryStore() {
|
|
18776
18923
|
if (!_channelResumeHistoryStore) {
|
|
18777
|
-
const dir = config?.configDir ??
|
|
18924
|
+
const dir = config?.configDir ?? join45(process.env["HOME"] ?? "/tmp", ".augmented");
|
|
18778
18925
|
_channelResumeHistoryStore = new ChannelResumeHistoryStore(defaultResumeHistoryPath(dir));
|
|
18779
18926
|
}
|
|
18780
18927
|
return _channelResumeHistoryStore;
|
|
@@ -18819,12 +18966,12 @@ function sessionActivityFor(codeName, pane, opts = {}) {
|
|
|
18819
18966
|
}
|
|
18820
18967
|
function forwardedToolsFor(codeName) {
|
|
18821
18968
|
if (!config?.configDir) return null;
|
|
18822
|
-
return readForwardedToolsReport(
|
|
18969
|
+
return readForwardedToolsReport(join45(config.configDir, codeName));
|
|
18823
18970
|
}
|
|
18824
18971
|
var _hostFlagStore = null;
|
|
18825
18972
|
function hostFlagStore() {
|
|
18826
18973
|
if (!_hostFlagStore) {
|
|
18827
|
-
const dir = config?.configDir ??
|
|
18974
|
+
const dir = config?.configDir ?? join45(process.env["HOME"] ?? "/tmp", ".augmented");
|
|
18828
18975
|
_hostFlagStore = new HostFlagStore({ cachePath: defaultFlagsCachePath(dir), log });
|
|
18829
18976
|
}
|
|
18830
18977
|
return _hostFlagStore;
|
|
@@ -18897,13 +19044,13 @@ function parseSkillFrontmatter(content) {
|
|
|
18897
19044
|
return out;
|
|
18898
19045
|
}
|
|
18899
19046
|
async function refreshSkillsIndexInClaudeMd(configDir, codeName, log2) {
|
|
18900
|
-
const { readdirSync: readdirSync15, readFileSync: rfs, existsSync: ex, writeFileSync:
|
|
18901
|
-
const skillsDir =
|
|
18902
|
-
const claudeMdPath =
|
|
19047
|
+
const { readdirSync: readdirSync15, readFileSync: rfs, existsSync: ex, writeFileSync: writeFileSync20 } = await import("fs");
|
|
19048
|
+
const skillsDir = join45(configDir, codeName, "project", ".claude", "skills");
|
|
19049
|
+
const claudeMdPath = join45(configDir, codeName, "project", "CLAUDE.md");
|
|
18903
19050
|
if (!ex(skillsDir) || !ex(claudeMdPath)) return;
|
|
18904
19051
|
const entries = [];
|
|
18905
19052
|
for (const dir of readdirSync15(skillsDir).sort()) {
|
|
18906
|
-
const skillFile =
|
|
19053
|
+
const skillFile = join45(skillsDir, dir, "SKILL.md");
|
|
18907
19054
|
if (!ex(skillFile)) continue;
|
|
18908
19055
|
try {
|
|
18909
19056
|
const { name, description } = parseSkillFrontmatter(rfs(skillFile, "utf-8"));
|
|
@@ -18947,7 +19094,7 @@ ${SKILLS_INDEX_END}`;
|
|
|
18947
19094
|
next = current.trimEnd() + "\n\n" + section + "\n";
|
|
18948
19095
|
}
|
|
18949
19096
|
if (next !== current) {
|
|
18950
|
-
|
|
19097
|
+
writeFileSync20(claudeMdPath, next, "utf-8");
|
|
18951
19098
|
log2(
|
|
18952
19099
|
injectSkillList ? `Refreshed skills index in CLAUDE.md for '${codeName}' (${entries.length} skills)` : `Refreshed CLAUDE.md managed block for '${codeName}' (skill list suppressed by claude-md-skills-index=false; ${entries.length} skills on disk)`
|
|
18953
19100
|
);
|
|
@@ -19042,7 +19189,7 @@ function flushRestartedAgentDiagnostics(hostId, codeNames) {
|
|
|
19042
19189
|
if (codeNames.length === 0) return;
|
|
19043
19190
|
void (async () => {
|
|
19044
19191
|
try {
|
|
19045
|
-
const { collectDiagnostics } = await import("../persistent-session-
|
|
19192
|
+
const { collectDiagnostics } = await import("../persistent-session-LHQLLU4U.js");
|
|
19046
19193
|
await api.post("/host/heartbeat", {
|
|
19047
19194
|
host_id: hostId,
|
|
19048
19195
|
agent_diagnostics: collectDiagnostics(codeNames, quarantineEntriesFor, claudeMdSizeFor, spawnOutcomeForDiagnostics, pidPressureFor, forwardedToolsFor, runtimeVersionFor, sessionActivityFor)
|
|
@@ -19185,7 +19332,7 @@ async function pollCycleInner() {
|
|
|
19185
19332
|
}
|
|
19186
19333
|
try {
|
|
19187
19334
|
const { detectHostSecurity } = await import("../host-security-KQYYZZVW.js");
|
|
19188
|
-
const { collectDiagnostics } = await import("../persistent-session-
|
|
19335
|
+
const { collectDiagnostics } = await import("../persistent-session-LHQLLU4U.js");
|
|
19189
19336
|
const diagCodeNames = [...agentState.persistentSessionAgents];
|
|
19190
19337
|
const agentDiagnostics = diagCodeNames.length > 0 ? collectDiagnostics(diagCodeNames, quarantineEntriesFor, claudeMdSizeFor, spawnOutcomeForDiagnostics, pidPressureFor, forwardedToolsFor, runtimeVersionFor, sessionActivityFor) : void 0;
|
|
19191
19338
|
let tailscaleHostname;
|
|
@@ -19400,7 +19547,13 @@ async function pollCycleInner() {
|
|
|
19400
19547
|
hostFlagStore().applyHeartbeat(hbResp.feature_flags, hbResp.flags_schema_version);
|
|
19401
19548
|
}
|
|
19402
19549
|
hostFlagStore().applyNotifyDispatchByAgent(hbResp?.notify_dispatch_by_agent);
|
|
19403
|
-
hostFlagStore().applyBooleanFlagsByAgent(hbResp?.feature_flags_by_agent);
|
|
19550
|
+
hostFlagStore().applyBooleanFlagsByAgent(hbResp?.feature_flags_by_agent, hbResp?.feature_flags_by_agent_evaluated);
|
|
19551
|
+
recordScratchHoldsFromHeartbeat({
|
|
19552
|
+
holdsDir: SCRATCH_HOLDS_DIR(),
|
|
19553
|
+
evaluatedAgentIds: hbResp?.feature_flags_by_agent_evaluated,
|
|
19554
|
+
hostAgentIds: agentState.codeNameToAgentId.values(),
|
|
19555
|
+
flag: (key, agentId) => hostFlagStore().getBooleanForAgent(key, agentId)
|
|
19556
|
+
});
|
|
19404
19557
|
setConfigHash(hbResp?.config_hash ?? null);
|
|
19405
19558
|
const ackDecision = nextPendingAck(pendingKeyRotationAck, hbResp);
|
|
19406
19559
|
if (ackDecision.log) log(ackDecision.log);
|
|
@@ -19450,7 +19603,7 @@ async function pollCycleInner() {
|
|
|
19450
19603
|
}
|
|
19451
19604
|
try {
|
|
19452
19605
|
const desiredClaudeCodeVersion = hbResp?.desired_claude_code_version?.trim();
|
|
19453
|
-
const { maybeUpdateClaudeCode, shouldRunClaudeCodeUpdater } = await import("../claude-code-updater-
|
|
19606
|
+
const { maybeUpdateClaudeCode, shouldRunClaudeCodeUpdater } = await import("../claude-code-updater-B2BWPRFE.js");
|
|
19454
19607
|
const securityFloor = currentSecurityFloor();
|
|
19455
19608
|
claudeUpdaterInFlight = true;
|
|
19456
19609
|
if (desiredClaudeCodeVersion && (claudePairLoop.busy || claudePairingInProgress())) {
|
|
@@ -19485,7 +19638,7 @@ async function pollCycleInner() {
|
|
|
19485
19638
|
collectPanelessActivityProbes,
|
|
19486
19639
|
getResponsivenessIntervalMs,
|
|
19487
19640
|
occupancyQualificationClassifications
|
|
19488
|
-
} = await import("../responsiveness-probe-
|
|
19641
|
+
} = await import("../responsiveness-probe-KDSNPKUY.js");
|
|
19489
19642
|
const probeIntervalMs = getResponsivenessIntervalMs();
|
|
19490
19643
|
if (now - lastResponsivenessProbeAt > probeIntervalMs) {
|
|
19491
19644
|
const probeCodeNames = [...agentState.persistentSessionAgents];
|
|
@@ -19602,7 +19755,7 @@ async function pollCycleInner() {
|
|
|
19602
19755
|
collectResponsivenessProbes,
|
|
19603
19756
|
livePendingInboundOldestAgeSeconds,
|
|
19604
19757
|
parkPendingInbound
|
|
19605
|
-
} = await import("../responsiveness-probe-
|
|
19758
|
+
} = await import("../responsiveness-probe-KDSNPKUY.js");
|
|
19606
19759
|
const { getProjectDir: wedgeProjectDir } = await import("../scheduler-engine-5PCBGRNY.js");
|
|
19607
19760
|
const wedgeNow = /* @__PURE__ */ new Date();
|
|
19608
19761
|
const liveAgents = agentState.persistentSessionAgents;
|
|
@@ -19691,13 +19844,13 @@ async function pollCycleInner() {
|
|
|
19691
19844
|
);
|
|
19692
19845
|
if (hostFlagStore().getBoolean("wedge-transient-notice")) {
|
|
19693
19846
|
try {
|
|
19694
|
-
const paneTail =
|
|
19847
|
+
const paneTail = readFileSync36(paneLogPath(codeName), "utf8").slice(-65536);
|
|
19695
19848
|
const transient = detectTransientApiErrorInLog(paneTail);
|
|
19696
19849
|
if (transient) {
|
|
19697
|
-
const wedgeHome =
|
|
19698
|
-
if (
|
|
19850
|
+
const wedgeHome = join45(homedir17(), ".augmented", codeName);
|
|
19851
|
+
if (existsSync20(wedgeHome)) {
|
|
19699
19852
|
atomicWriteFileSync(
|
|
19700
|
-
|
|
19853
|
+
join45(wedgeHome, "watchdog-give-up.json"),
|
|
19701
19854
|
JSON.stringify({
|
|
19702
19855
|
gave_up_at: wedgeNow.toISOString(),
|
|
19703
19856
|
reason: "transient_overload"
|
|
@@ -19888,7 +20041,7 @@ async function pollCycleInner() {
|
|
|
19888
20041
|
}
|
|
19889
20042
|
}
|
|
19890
20043
|
);
|
|
19891
|
-
const { parkPendingInbound } = await import("../responsiveness-probe-
|
|
20044
|
+
const { parkPendingInbound } = await import("../responsiveness-probe-KDSNPKUY.js");
|
|
19892
20045
|
const { parked, deadLettered } = parkPendingInbound(codeName, new Date(fatalNowMs));
|
|
19893
20046
|
paneFatalStreak.delete(codeName);
|
|
19894
20047
|
paneFatalRestarts.set(codeName, [...history, fatalNowMs]);
|
|
@@ -19919,7 +20072,7 @@ async function pollCycleInner() {
|
|
|
19919
20072
|
TRANSCRIPT_MOUNT_ESCALATION_REFRESH_MS,
|
|
19920
20073
|
bindSourceEscalations
|
|
19921
20074
|
} = await import("../transcript-mount-health-OHE6IVJV.js");
|
|
19922
|
-
const { transcriptBindSourcesFor, ensureTranscriptBindSources } = await import("../persistent-session-
|
|
20075
|
+
const { transcriptBindSourcesFor, ensureTranscriptBindSources } = await import("../persistent-session-LHQLLU4U.js");
|
|
19923
20076
|
const mountConfig = resolveTranscriptMountConfig();
|
|
19924
20077
|
const liveAgents = agentState.persistentSessionAgents;
|
|
19925
20078
|
for (const tracked of [
|
|
@@ -19961,7 +20114,7 @@ async function pollCycleInner() {
|
|
|
19961
20114
|
const agentId = agentState.codeNameToAgentId.get(codeName);
|
|
19962
20115
|
if (!agentId) continue;
|
|
19963
20116
|
let pid = containerPidCache.get(codeName) ?? null;
|
|
19964
|
-
if (pid !== null && !
|
|
20117
|
+
if (pid !== null && !existsSync20(`/proc/${pid}`)) pid = null;
|
|
19965
20118
|
if (pid === null) {
|
|
19966
20119
|
try {
|
|
19967
20120
|
const out = syncExecFile("docker", ["inspect", "-f", "{{.State.Pid}}", `agt-${codeName}`], {
|
|
@@ -20084,7 +20237,7 @@ async function pollCycleInner() {
|
|
|
20084
20237
|
}
|
|
20085
20238
|
try {
|
|
20086
20239
|
const { scrapeMcpFailedBannerCount } = await import("../pane-mcp-banner-scraper-VR5QGP3J.js");
|
|
20087
|
-
const { probeSessionAuth } = await import("../session-auth-dead-
|
|
20240
|
+
const { probeSessionAuth } = await import("../session-auth-dead-3IHR4M2B.js");
|
|
20088
20241
|
const observations = [];
|
|
20089
20242
|
const pendingCacheCommits = [];
|
|
20090
20243
|
const modelApiErrorReportingOn = hostFlagStore().getBoolean("model-api-error-reporting");
|
|
@@ -20638,7 +20791,7 @@ async function pollCycleInner() {
|
|
|
20638
20791
|
`[drain-flush] FAILED for '${prev.codeName}': ${err.message} \u2014 proceeding to teardown; this session was NOT shipped (ENG-9491)`
|
|
20639
20792
|
);
|
|
20640
20793
|
}
|
|
20641
|
-
const agentDir =
|
|
20794
|
+
const agentDir = join45(adapter.getAgentDir(prev.codeName), "provision");
|
|
20642
20795
|
await cleanupAgentFiles(prev.codeName, agentDir);
|
|
20643
20796
|
clearAgentCaches(prev.agentId, prev.codeName);
|
|
20644
20797
|
}
|
|
@@ -20717,10 +20870,10 @@ async function pollCycleInner() {
|
|
|
20717
20870
|
// pending-inbound marker. Best-effort: a write failure is logged by
|
|
20718
20871
|
// the watchdog, never fails the poll cycle.
|
|
20719
20872
|
signalGiveUp: (codeName) => {
|
|
20720
|
-
const dir =
|
|
20721
|
-
if (!
|
|
20873
|
+
const dir = join45(homedir17(), ".augmented", codeName);
|
|
20874
|
+
if (!existsSync20(dir)) return;
|
|
20722
20875
|
atomicWriteFileSync(
|
|
20723
|
-
|
|
20876
|
+
join45(dir, "watchdog-give-up.json"),
|
|
20724
20877
|
JSON.stringify({ gave_up_at: (/* @__PURE__ */ new Date()).toISOString() })
|
|
20725
20878
|
);
|
|
20726
20879
|
},
|
|
@@ -20746,22 +20899,22 @@ async function pollCycleInner() {
|
|
|
20746
20899
|
// watchdog-give-up.json, whose gave_up_at must survive a refresh.
|
|
20747
20900
|
refreshBlockedPromptLiveness: (codeName, kind) => {
|
|
20748
20901
|
const dir = getFramework("claude-code").getAgentDir(codeName);
|
|
20749
|
-
if (!
|
|
20902
|
+
if (!existsSync20(dir)) return;
|
|
20750
20903
|
atomicWriteFileSync(
|
|
20751
|
-
|
|
20904
|
+
join45(dir, "blocked-prompt.json"),
|
|
20752
20905
|
JSON.stringify({ kind, last_seen_at: (/* @__PURE__ */ new Date()).toISOString() })
|
|
20753
20906
|
);
|
|
20754
20907
|
},
|
|
20755
20908
|
clearBlockedPromptLiveness: (codeName) => {
|
|
20756
|
-
const file =
|
|
20757
|
-
if (
|
|
20909
|
+
const file = join45(getFramework("claude-code").getAgentDir(codeName), "blocked-prompt.json");
|
|
20910
|
+
if (existsSync20(file)) rmSync9(file, { force: true });
|
|
20758
20911
|
},
|
|
20759
20912
|
refreshUsageLimitLiveness: (codeName) => {
|
|
20760
20913
|
const dir = getFramework("claude-code").getAgentDir(codeName);
|
|
20761
|
-
const file =
|
|
20762
|
-
if (!
|
|
20914
|
+
const file = join45(dir, "watchdog-give-up.json");
|
|
20915
|
+
if (!existsSync20(file)) return;
|
|
20763
20916
|
try {
|
|
20764
|
-
const raw = JSON.parse(
|
|
20917
|
+
const raw = JSON.parse(readFileSync36(file, "utf8"));
|
|
20765
20918
|
if (raw["reason"] !== "usage_limit") return;
|
|
20766
20919
|
raw["usage_limit_last_seen_at"] = (/* @__PURE__ */ new Date()).toISOString();
|
|
20767
20920
|
atomicWriteFileSync(file, JSON.stringify(raw));
|
|
@@ -20770,9 +20923,9 @@ async function pollCycleInner() {
|
|
|
20770
20923
|
},
|
|
20771
20924
|
signalUsageLimit: (codeName, resetsHint) => {
|
|
20772
20925
|
const dir = getFramework("claude-code").getAgentDir(codeName);
|
|
20773
|
-
if (!
|
|
20926
|
+
if (!existsSync20(dir)) return;
|
|
20774
20927
|
atomicWriteFileSync(
|
|
20775
|
-
|
|
20928
|
+
join45(dir, "watchdog-give-up.json"),
|
|
20776
20929
|
JSON.stringify({
|
|
20777
20930
|
gave_up_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
20778
20931
|
reason: "usage_limit",
|
|
@@ -21049,7 +21202,7 @@ async function processAgent(agent, agentStates, managedToolkits) {
|
|
|
21049
21202
|
}
|
|
21050
21203
|
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
21051
21204
|
const adapter = resolveAgentFramework(agent.code_name);
|
|
21052
|
-
let agentDir =
|
|
21205
|
+
let agentDir = join45(adapter.getAgentDir(agent.code_name), "provision");
|
|
21053
21206
|
if (agent.status === "draft" || agent.status === "paused") {
|
|
21054
21207
|
forgetChannelSyncState(agent.agent_id);
|
|
21055
21208
|
reapLegacyTokenFileEdgeWarned(agent.code_name, log);
|
|
@@ -21091,7 +21244,7 @@ async function processAgent(agent, agentStates, managedToolkits) {
|
|
|
21091
21244
|
const residuals = {
|
|
21092
21245
|
gatewayRunning: false,
|
|
21093
21246
|
portAllocated: false,
|
|
21094
|
-
provisionDirExists:
|
|
21247
|
+
provisionDirExists: existsSync20(agentDir)
|
|
21095
21248
|
};
|
|
21096
21249
|
if (!hasRevokedResiduals(residuals)) {
|
|
21097
21250
|
agentStates.push({
|
|
@@ -21197,7 +21350,7 @@ async function processAgent(agent, agentStates, managedToolkits) {
|
|
|
21197
21350
|
if (refreshData.knowledge_manifest) {
|
|
21198
21351
|
const resolved = await resolveKnowledgeFromManifest({
|
|
21199
21352
|
manifest: refreshData.knowledge_manifest,
|
|
21200
|
-
cacheDir:
|
|
21353
|
+
cacheDir: join45(config.configDir, "_knowledge"),
|
|
21201
21354
|
delivery: refreshData.agent?.knowledge_delivery ?? "both",
|
|
21202
21355
|
fetchContents: async (hashes) => {
|
|
21203
21356
|
const res = await api.post(
|
|
@@ -21214,7 +21367,7 @@ async function processAgent(agent, agentStates, managedToolkits) {
|
|
|
21214
21367
|
const resolvedSkills = await resolveSkillsFromManifest({
|
|
21215
21368
|
globals: refreshData.global_skills_manifest ?? [],
|
|
21216
21369
|
shared: refreshData.shared_skills_manifest ?? [],
|
|
21217
|
-
cacheDir:
|
|
21370
|
+
cacheDir: join45(config.configDir, "_skills"),
|
|
21218
21371
|
fetchContents: async (hashes) => {
|
|
21219
21372
|
const res = await api.post(
|
|
21220
21373
|
"/host/skills/contents",
|
|
@@ -21232,7 +21385,7 @@ async function processAgent(agent, agentStates, managedToolkits) {
|
|
|
21232
21385
|
if (refreshData.integration_skills_manifest) {
|
|
21233
21386
|
const resolvedIntegrationSkills = await resolveIntegrationSkillsFromManifest({
|
|
21234
21387
|
manifest: refreshData.integration_skills_manifest,
|
|
21235
|
-
cacheDir:
|
|
21388
|
+
cacheDir: join45(config.configDir, "_skills"),
|
|
21236
21389
|
fetchContents: async (hashes) => {
|
|
21237
21390
|
const res = await api.post(
|
|
21238
21391
|
"/host/skills/contents",
|
|
@@ -21294,7 +21447,7 @@ async function processAgent(agent, agentStates, managedToolkits) {
|
|
|
21294
21447
|
const frameworkId = refreshData.agent.framework ?? DEFAULT_FRAMEWORK;
|
|
21295
21448
|
agentFrameworkCache.set(agent.code_name, frameworkId);
|
|
21296
21449
|
const frameworkAdapter = getFramework(frameworkId);
|
|
21297
|
-
agentDir =
|
|
21450
|
+
agentDir = join45(frameworkAdapter.getAgentDir(agent.code_name), "provision");
|
|
21298
21451
|
cacheAgentDeliveryMetadata(agent.code_name, refreshData);
|
|
21299
21452
|
agentRestartTimezoneInputs.set(agent.code_name, {
|
|
21300
21453
|
agentTimezone: typeof refreshData.agent.timezone === "string" ? refreshData.agent.timezone : null,
|
|
@@ -21370,9 +21523,9 @@ async function processAgent(agent, agentStates, managedToolkits) {
|
|
|
21370
21523
|
}
|
|
21371
21524
|
const artifacts = generateArtifacts(agent, provisionRefreshData, frameworkAdapter, renderIntegrationsSection);
|
|
21372
21525
|
const changedFiles = [];
|
|
21373
|
-
|
|
21526
|
+
mkdirSync17(agentDir, { recursive: true });
|
|
21374
21527
|
for (const artifact of artifacts) {
|
|
21375
|
-
const filePath =
|
|
21528
|
+
const filePath = join45(agentDir, artifact.relativePath);
|
|
21376
21529
|
let existingHash;
|
|
21377
21530
|
let newHash;
|
|
21378
21531
|
let writeContent = artifact.content;
|
|
@@ -21391,8 +21544,8 @@ async function processAgent(agent, agentStates, managedToolkits) {
|
|
|
21391
21544
|
};
|
|
21392
21545
|
newHash = sha256(stripDynamicSections(artifact.content));
|
|
21393
21546
|
try {
|
|
21394
|
-
const projectClaudeMd =
|
|
21395
|
-
const existing =
|
|
21547
|
+
const projectClaudeMd = join45(config.configDir, agent.code_name, "project", "CLAUDE.md");
|
|
21548
|
+
const existing = readFileSync36(projectClaudeMd, "utf-8");
|
|
21396
21549
|
existingHash = sha256(stripDynamicSections(existing));
|
|
21397
21550
|
} catch {
|
|
21398
21551
|
existingHash = null;
|
|
@@ -21410,7 +21563,7 @@ async function processAgent(agent, agentStates, managedToolkits) {
|
|
|
21410
21563
|
const generatorKeys = Object.keys(generatorServers);
|
|
21411
21564
|
let existingRaw = "";
|
|
21412
21565
|
try {
|
|
21413
|
-
existingRaw =
|
|
21566
|
+
existingRaw = readFileSync36(filePath, "utf-8");
|
|
21414
21567
|
} catch {
|
|
21415
21568
|
}
|
|
21416
21569
|
const existingServers = parseMcp(existingRaw);
|
|
@@ -21426,7 +21579,7 @@ async function processAgent(agent, agentStates, managedToolkits) {
|
|
|
21426
21579
|
} else if (artifact.relativePath === "opencode.json") {
|
|
21427
21580
|
let existingRaw = null;
|
|
21428
21581
|
try {
|
|
21429
|
-
existingRaw =
|
|
21582
|
+
existingRaw = readFileSync36(filePath, "utf-8");
|
|
21430
21583
|
} catch {
|
|
21431
21584
|
}
|
|
21432
21585
|
const mergeResult = mergeOpencodeConfigArtifact(artifact.content, existingRaw);
|
|
@@ -21442,26 +21595,26 @@ async function processAgent(agent, agentStates, managedToolkits) {
|
|
|
21442
21595
|
}
|
|
21443
21596
|
}
|
|
21444
21597
|
if (changedFiles.length > 0) {
|
|
21445
|
-
const isFirst = !
|
|
21598
|
+
const isFirst = !existsSync20(join45(agentDir, "CHARTER.md"));
|
|
21446
21599
|
const verb = isFirst ? "Provisioning" : "Updating";
|
|
21447
21600
|
const fileNames = changedFiles.map((f) => f.relativePath).join(", ");
|
|
21448
21601
|
log(`${verb} '${agent.code_name}': ${fileNames}`);
|
|
21449
21602
|
for (const file of changedFiles) {
|
|
21450
|
-
const filePath =
|
|
21451
|
-
|
|
21603
|
+
const filePath = join45(agentDir, file.relativePath);
|
|
21604
|
+
mkdirSync17(dirname11(filePath), { recursive: true });
|
|
21452
21605
|
if (file.relativePath === ".mcp.json") {
|
|
21453
21606
|
safeWriteJsonAtomic(filePath, file.content, { mode: 384 });
|
|
21454
21607
|
} else {
|
|
21455
|
-
|
|
21608
|
+
writeFileSync19(filePath, file.content);
|
|
21456
21609
|
}
|
|
21457
21610
|
}
|
|
21458
21611
|
try {
|
|
21459
|
-
const provSkillsDir =
|
|
21460
|
-
if (
|
|
21612
|
+
const provSkillsDir = join45(agentDir, ".claude", "skills");
|
|
21613
|
+
if (existsSync20(provSkillsDir)) {
|
|
21461
21614
|
for (const folder of readdirSync14(provSkillsDir)) {
|
|
21462
21615
|
if (folder.startsWith("knowledge-")) {
|
|
21463
21616
|
try {
|
|
21464
|
-
|
|
21617
|
+
rmSync9(join45(provSkillsDir, folder), { recursive: true });
|
|
21465
21618
|
} catch {
|
|
21466
21619
|
}
|
|
21467
21620
|
}
|
|
@@ -21474,7 +21627,7 @@ async function processAgent(agent, agentStates, managedToolkits) {
|
|
|
21474
21627
|
const trackedFiles2 = frameworkAdapter.driftTrackedFiles();
|
|
21475
21628
|
const hashes = /* @__PURE__ */ new Map();
|
|
21476
21629
|
for (const file of trackedFiles2) {
|
|
21477
|
-
const h = hashFile(
|
|
21630
|
+
const h = hashFile(join45(agentDir, file));
|
|
21478
21631
|
if (h) hashes.set(file, h);
|
|
21479
21632
|
}
|
|
21480
21633
|
agentState.writtenHashes.set(agent.agent_id, hashes);
|
|
@@ -21492,14 +21645,14 @@ async function processAgent(agent, agentStates, managedToolkits) {
|
|
|
21492
21645
|
}
|
|
21493
21646
|
if (Array.isArray(refreshData.workflows)) {
|
|
21494
21647
|
try {
|
|
21495
|
-
const provWorkflowsDir =
|
|
21496
|
-
if (
|
|
21648
|
+
const provWorkflowsDir = join45(agentDir, ".claude", "workflows");
|
|
21649
|
+
if (existsSync20(provWorkflowsDir)) {
|
|
21497
21650
|
const expected = new Set(refreshData.workflows.map((w) => `${w.name}.js`));
|
|
21498
21651
|
for (const file of readdirSync14(provWorkflowsDir)) {
|
|
21499
21652
|
if (!file.endsWith(".js")) continue;
|
|
21500
21653
|
if (expected.has(file)) continue;
|
|
21501
21654
|
try {
|
|
21502
|
-
|
|
21655
|
+
rmSync9(join45(provWorkflowsDir, file));
|
|
21503
21656
|
} catch {
|
|
21504
21657
|
}
|
|
21505
21658
|
}
|
|
@@ -21591,10 +21744,10 @@ async function processAgent(agent, agentStates, managedToolkits) {
|
|
|
21591
21744
|
}
|
|
21592
21745
|
let lastDriftCheckAt = now;
|
|
21593
21746
|
const written = agentState.writtenHashes.get(agent.agent_id);
|
|
21594
|
-
if (written &&
|
|
21747
|
+
if (written && existsSync20(agentDir)) {
|
|
21595
21748
|
const driftedFiles = [];
|
|
21596
21749
|
for (const [file, expectedHash] of written) {
|
|
21597
|
-
const localHash = hashFile(
|
|
21750
|
+
const localHash = hashFile(join45(agentDir, file));
|
|
21598
21751
|
if (localHash && localHash !== expectedHash) {
|
|
21599
21752
|
driftedFiles.push(file);
|
|
21600
21753
|
}
|
|
@@ -21605,7 +21758,7 @@ async function processAgent(agent, agentStates, managedToolkits) {
|
|
|
21605
21758
|
try {
|
|
21606
21759
|
const localHashes = {};
|
|
21607
21760
|
for (const file of driftedFiles) {
|
|
21608
|
-
localHashes[file] = hashFile(
|
|
21761
|
+
localHashes[file] = hashFile(join45(agentDir, file));
|
|
21609
21762
|
}
|
|
21610
21763
|
await api.post("/host/drift", {
|
|
21611
21764
|
agent_id: agent.agent_id,
|
|
@@ -21890,15 +22043,15 @@ async function processAgent(agent, agentStates, managedToolkits) {
|
|
|
21890
22043
|
const addedChannels = [...restartDecision.added];
|
|
21891
22044
|
const writeDmNoticeMarkers = isChannelAddRestart ? () => {
|
|
21892
22045
|
try {
|
|
21893
|
-
const agentAugmentedDir =
|
|
21894
|
-
|
|
22046
|
+
const agentAugmentedDir = join45(homedir17(), ".augmented", agent.code_name);
|
|
22047
|
+
mkdirSync17(agentAugmentedDir, { recursive: true });
|
|
21895
22048
|
const markerJson = JSON.stringify({
|
|
21896
22049
|
version: 1,
|
|
21897
22050
|
at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
21898
22051
|
added: addedChannels
|
|
21899
22052
|
});
|
|
21900
22053
|
for (const file of ["slack-channel-add-restart.json", "telegram-channel-add-restart.json"]) {
|
|
21901
|
-
atomicWriteFileSync(
|
|
22054
|
+
atomicWriteFileSync(join45(agentAugmentedDir, file), markerJson);
|
|
21902
22055
|
}
|
|
21903
22056
|
} catch (err) {
|
|
21904
22057
|
log(`[hot-reload] channel-add DM-notice marker write failed for '${agent.code_name}' (non-fatal): ${err.message}`);
|
|
@@ -22202,24 +22355,24 @@ async function processAgent(agent, agentStates, managedToolkits) {
|
|
|
22202
22355
|
if (agentSessionMode === "persistent" && (agentFrameworkCache.get(agent.code_name) ?? DEFAULT_FRAMEWORK) === "claude-code") {
|
|
22203
22356
|
try {
|
|
22204
22357
|
const agentProvisionDir = agentDir;
|
|
22205
|
-
const projectDir =
|
|
22206
|
-
|
|
22207
|
-
|
|
22208
|
-
const provisionMcpPath =
|
|
22209
|
-
const projectMcpPath =
|
|
22358
|
+
const projectDir = join45(homedir17(), ".augmented", agent.code_name, "project");
|
|
22359
|
+
mkdirSync17(agentProvisionDir, { recursive: true });
|
|
22360
|
+
mkdirSync17(projectDir, { recursive: true });
|
|
22361
|
+
const provisionMcpPath = join45(agentProvisionDir, ".mcp.json");
|
|
22362
|
+
const projectMcpPath = join45(projectDir, ".mcp.json");
|
|
22210
22363
|
let mcpConfig = { mcpServers: {} };
|
|
22211
22364
|
try {
|
|
22212
|
-
mcpConfig = JSON.parse(
|
|
22365
|
+
mcpConfig = JSON.parse(readFileSync36(provisionMcpPath, "utf-8"));
|
|
22213
22366
|
if (!mcpConfig.mcpServers) mcpConfig.mcpServers = {};
|
|
22214
22367
|
} catch {
|
|
22215
22368
|
}
|
|
22216
|
-
const localDirectChatChannel =
|
|
22369
|
+
const localDirectChatChannel = join45(homedir17(), ".augmented", "_mcp", "direct-chat-channel.js");
|
|
22217
22370
|
const directChatTeamSettings = refreshData.team?.settings;
|
|
22218
22371
|
const directChatTz = (() => {
|
|
22219
22372
|
const tz = directChatTeamSettings?.["timezone"];
|
|
22220
22373
|
return typeof tz === "string" && tz.trim() !== "" ? tz.trim() : void 0;
|
|
22221
22374
|
})();
|
|
22222
|
-
if (
|
|
22375
|
+
if (existsSync20(localDirectChatChannel)) {
|
|
22223
22376
|
const directChatEnv = {
|
|
22224
22377
|
AGT_HOST: requireHost(),
|
|
22225
22378
|
// ENG-5901 Track D: templated — the manager exports the real
|
|
@@ -22239,7 +22392,7 @@ async function processAgent(agent, agentStates, managedToolkits) {
|
|
|
22239
22392
|
// ~/.augmented/<codeName>/.current-turn-initiator.json. Note getAgentDir
|
|
22240
22393
|
// returns the agent root (NOT the /provision subdir `agentDir` points at),
|
|
22241
22394
|
// so it byte-matches the broker readers' path.
|
|
22242
|
-
AGT_TURN_INITIATOR_FILE:
|
|
22395
|
+
AGT_TURN_INITIATOR_FILE: join45(
|
|
22243
22396
|
frameworkAdapter.getAgentDir(agent.code_name),
|
|
22244
22397
|
".current-turn-initiator.json"
|
|
22245
22398
|
)
|
|
@@ -22259,10 +22412,10 @@ async function processAgent(agent, agentStates, managedToolkits) {
|
|
|
22259
22412
|
log(`Channel credentials written for '${agent.code_name}/direct-chat'`);
|
|
22260
22413
|
}
|
|
22261
22414
|
}
|
|
22262
|
-
const staleChannelsPath =
|
|
22263
|
-
if (
|
|
22415
|
+
const staleChannelsPath = join45(projectDir, ".mcp-channels.json");
|
|
22416
|
+
if (existsSync20(staleChannelsPath)) {
|
|
22264
22417
|
try {
|
|
22265
|
-
|
|
22418
|
+
rmSync9(staleChannelsPath, { force: true });
|
|
22266
22419
|
} catch {
|
|
22267
22420
|
}
|
|
22268
22421
|
}
|
|
@@ -22387,7 +22540,7 @@ async function processAgent(agent, agentStates, managedToolkits) {
|
|
|
22387
22540
|
}
|
|
22388
22541
|
if (hostFlagStore().getBoolean("connectivity-probe")) {
|
|
22389
22542
|
try {
|
|
22390
|
-
const probeProjectDir =
|
|
22543
|
+
const probeProjectDir = join45(homedir17(), ".augmented", agent.code_name, "project");
|
|
22391
22544
|
let probeSet = integrations;
|
|
22392
22545
|
const fetchQuarantined = async () => {
|
|
22393
22546
|
const quarantined = await api.post("/host/agent-integrations/quarantined", { agent_id: agent.agent_id });
|
|
@@ -22447,7 +22600,7 @@ async function processAgent(agent, agentStates, managedToolkits) {
|
|
|
22447
22600
|
const forceDue = attemptsLeft > 0;
|
|
22448
22601
|
let probeRan = false;
|
|
22449
22602
|
try {
|
|
22450
|
-
const probeProjectDir =
|
|
22603
|
+
const probeProjectDir = join45(homedir17(), ".augmented", agent.code_name, "project");
|
|
22451
22604
|
const renderPending = integrationRenderPending(
|
|
22452
22605
|
integrations,
|
|
22453
22606
|
agentState.knownIntegrationHashes.get(agent.agent_id)
|
|
@@ -22576,11 +22729,11 @@ async function processAgent(agent, agentStates, managedToolkits) {
|
|
|
22576
22729
|
const intHash = computeIntegrationsHash(integrations);
|
|
22577
22730
|
const prevIntHash = agentState.knownIntegrationHashes.get(agent.agent_id);
|
|
22578
22731
|
if (intHash !== prevIntHash) {
|
|
22579
|
-
const projectDir =
|
|
22580
|
-
const envIntPath =
|
|
22732
|
+
const projectDir = join45(homedir17(), ".augmented", agent.code_name, "project");
|
|
22733
|
+
const envIntPath = join45(projectDir, ".env.integrations");
|
|
22581
22734
|
let preWriteEnv;
|
|
22582
22735
|
try {
|
|
22583
|
-
preWriteEnv =
|
|
22736
|
+
preWriteEnv = readFileSync36(envIntPath, "utf-8");
|
|
22584
22737
|
} catch {
|
|
22585
22738
|
preWriteEnv = void 0;
|
|
22586
22739
|
}
|
|
@@ -22608,9 +22761,9 @@ async function processAgent(agent, agentStates, managedToolkits) {
|
|
|
22608
22761
|
}
|
|
22609
22762
|
if (fw === "claude-code" && isSessionHealthy(agent.code_name)) {
|
|
22610
22763
|
try {
|
|
22611
|
-
const projectMcpPath =
|
|
22612
|
-
const postWriteEnv =
|
|
22613
|
-
const mcpContent =
|
|
22764
|
+
const projectMcpPath = join45(projectDir, ".mcp.json");
|
|
22765
|
+
const postWriteEnv = readFileSync36(envIntPath, "utf-8");
|
|
22766
|
+
const mcpContent = readFileSync36(projectMcpPath, "utf-8");
|
|
22614
22767
|
const changedVars = diffEnvIntegrations(preWriteEnv, postWriteEnv);
|
|
22615
22768
|
const mcpJsonForReap = JSON.parse(mcpContent);
|
|
22616
22769
|
const affectedServerKeys = findMcpServersUsingVars(mcpJsonForReap, changedVars);
|
|
@@ -22945,19 +23098,19 @@ async function processAgent(agent, agentStates, managedToolkits) {
|
|
|
22945
23098
|
}
|
|
22946
23099
|
}
|
|
22947
23100
|
try {
|
|
22948
|
-
const { readdirSync: readdirSync15, rmSync:
|
|
23101
|
+
const { readdirSync: readdirSync15, rmSync: rmSync10 } = await import("fs");
|
|
22949
23102
|
const { homedir: homedir18 } = await import("os");
|
|
22950
23103
|
const frameworkId2 = frameworkAdapter.id;
|
|
22951
23104
|
const candidateSkillDirs = [
|
|
22952
23105
|
// Claude Code — framework runtime tree
|
|
22953
|
-
|
|
23106
|
+
join45(homedir18(), ".augmented", agent.code_name, "skills"),
|
|
22954
23107
|
// Claude Code — project tree
|
|
22955
|
-
|
|
23108
|
+
join45(homedir18(), ".augmented", agent.code_name, "project", ".claude", "skills"),
|
|
22956
23109
|
// Defensive: legacy provision-side path, not currently an
|
|
22957
23110
|
// install target but cheap to sweep.
|
|
22958
|
-
|
|
23111
|
+
join45(agentDir, ".claude", "skills")
|
|
22959
23112
|
];
|
|
22960
|
-
const existingDirs = candidateSkillDirs.filter((d) =>
|
|
23113
|
+
const existingDirs = candidateSkillDirs.filter((d) => existsSync20(d));
|
|
22961
23114
|
const discoveredEntries = /* @__PURE__ */ new Set();
|
|
22962
23115
|
for (const dir of existingDirs) {
|
|
22963
23116
|
try {
|
|
@@ -22976,8 +23129,8 @@ async function processAgent(agent, agentStates, managedToolkits) {
|
|
|
22976
23129
|
entry,
|
|
22977
23130
|
dirs: existingDirs,
|
|
22978
23131
|
removeDir: (p) => {
|
|
22979
|
-
if (
|
|
22980
|
-
|
|
23132
|
+
if (existsSync20(p)) {
|
|
23133
|
+
rmSync10(p, { recursive: true, force: true });
|
|
22981
23134
|
}
|
|
22982
23135
|
}
|
|
22983
23136
|
});
|
|
@@ -22998,7 +23151,7 @@ async function processAgent(agent, agentStates, managedToolkits) {
|
|
|
22998
23151
|
const sharedSkillsPayload = refreshAny.shared_skills;
|
|
22999
23152
|
const desiredResolved = globalSkillsPayload !== void 0 || sharedSkillsPayload !== void 0;
|
|
23000
23153
|
const manifestPath = managedSkillManifestPath(
|
|
23001
|
-
|
|
23154
|
+
join45(homedir17(), ".augmented", agent.code_name)
|
|
23002
23155
|
);
|
|
23003
23156
|
const prevIds = /* @__PURE__ */ new Set([
|
|
23004
23157
|
...agentState.knownGlobalSkillIds.get(agent.agent_id) ?? /* @__PURE__ */ new Set(),
|
|
@@ -23018,16 +23171,16 @@ async function processAgent(agent, agentStates, managedToolkits) {
|
|
|
23018
23171
|
}
|
|
23019
23172
|
if (plan.removes.length) {
|
|
23020
23173
|
const globalSkillDirs = [
|
|
23021
|
-
|
|
23022
|
-
|
|
23023
|
-
|
|
23174
|
+
join45(homedir17(), ".augmented", agent.code_name, "skills"),
|
|
23175
|
+
join45(homedir17(), ".augmented", agent.code_name, "project", ".claude", "skills"),
|
|
23176
|
+
join45(agentDir, ".claude", "skills")
|
|
23024
23177
|
];
|
|
23025
23178
|
for (const id of plan.removes) {
|
|
23026
23179
|
let prunedAny = false;
|
|
23027
23180
|
for (const dir of globalSkillDirs) {
|
|
23028
|
-
const p =
|
|
23029
|
-
if (
|
|
23030
|
-
|
|
23181
|
+
const p = join45(dir, id);
|
|
23182
|
+
if (existsSync20(p) && existsSync20(join45(p, "SKILL.md"))) {
|
|
23183
|
+
rmSync9(p, { recursive: true, force: true });
|
|
23031
23184
|
prunedAny = true;
|
|
23032
23185
|
}
|
|
23033
23186
|
}
|
|
@@ -23296,8 +23449,8 @@ async function processAgent(agent, agentStates, managedToolkits) {
|
|
|
23296
23449
|
const sess = getSessionState(agent.code_name);
|
|
23297
23450
|
let mcpJsonParsed = null;
|
|
23298
23451
|
try {
|
|
23299
|
-
const mcpPath =
|
|
23300
|
-
mcpJsonParsed = JSON.parse(
|
|
23452
|
+
const mcpPath = join45(getProjectDir(agent.code_name), ".mcp.json");
|
|
23453
|
+
mcpJsonParsed = JSON.parse(readFileSync36(mcpPath, "utf-8"));
|
|
23301
23454
|
} catch {
|
|
23302
23455
|
}
|
|
23303
23456
|
const computerUseIsolated = isolationMode(agent.code_name) === "docker";
|
|
@@ -23807,10 +23960,10 @@ Retried to the limit after repeated stalls \u2014 needs a look.`).catch(() => {
|
|
|
23807
23960
|
}
|
|
23808
23961
|
}
|
|
23809
23962
|
const trackedFiles = frameworkAdapter.driftTrackedFiles();
|
|
23810
|
-
if (trackedFiles.length > 0 &&
|
|
23963
|
+
if (trackedFiles.length > 0 && existsSync20(agentDir)) {
|
|
23811
23964
|
const hashes = /* @__PURE__ */ new Map();
|
|
23812
23965
|
for (const file of trackedFiles) {
|
|
23813
|
-
const h = hashFile(
|
|
23966
|
+
const h = hashFile(join45(agentDir, file));
|
|
23814
23967
|
if (h) hashes.set(file, h);
|
|
23815
23968
|
}
|
|
23816
23969
|
agentState.writtenHashes.set(agent.agent_id, hashes);
|
|
@@ -23825,7 +23978,7 @@ Retried to the limit after repeated stalls \u2014 needs a look.`).catch(() => {
|
|
|
23825
23978
|
refreshData.agent.onboarding_state
|
|
23826
23979
|
);
|
|
23827
23980
|
const obStep = obState.step;
|
|
23828
|
-
const markerPath =
|
|
23981
|
+
const markerPath = join45(homedir17(), ".augmented", agent.code_name, "onboarding-drive.json");
|
|
23829
23982
|
const marker = readOnboardingDriveMarker(markerPath);
|
|
23830
23983
|
const obContactRaw = refreshData.agent.manager_last_contacted_at;
|
|
23831
23984
|
const obContact = typeof obContactRaw === "string" && obContactRaw ? obContactRaw : null;
|
|
@@ -23942,7 +24095,7 @@ async function ensureOpencodeRuntime(agent, refreshData, agentTimezone) {
|
|
|
23942
24095
|
}
|
|
23943
24096
|
stopOpencodeSlackIngest(codeName, log);
|
|
23944
24097
|
stopOpencodeTelegramIngest(codeName, log);
|
|
23945
|
-
const opencodeProjectDir =
|
|
24098
|
+
const opencodeProjectDir = join45(getFramework("opencode").getAgentDir(codeName), "provision");
|
|
23946
24099
|
const serveEnv = {
|
|
23947
24100
|
AGT_HOST: requireHost(),
|
|
23948
24101
|
AGT_API_KEY: getApiKey() ?? void 0,
|
|
@@ -24002,8 +24155,8 @@ async function ensurePersistentSessionUnchecked(agent, tasks, boardItems, refres
|
|
|
24002
24155
|
});
|
|
24003
24156
|
}
|
|
24004
24157
|
const projectDir = getProjectDir(codeName);
|
|
24005
|
-
const mcpConfigPath =
|
|
24006
|
-
const claudeMdPath =
|
|
24158
|
+
const mcpConfigPath = join45(projectDir, ".mcp.json");
|
|
24159
|
+
const claudeMdPath = join45(projectDir, "CLAUDE.md");
|
|
24007
24160
|
if (restartBreaker.isTripped(codeName)) {
|
|
24008
24161
|
const trip = restartBreaker.getTrip(codeName);
|
|
24009
24162
|
return {
|
|
@@ -25019,7 +25172,7 @@ async function handleRestartDoorbell(agentId, requestedAt, restartReason) {
|
|
|
25019
25172
|
if (!refreshData) return;
|
|
25020
25173
|
const framework = refreshData.agent?.framework ?? agentFrameworkCache.get(codeName) ?? DEFAULT_FRAMEWORK;
|
|
25021
25174
|
const hostId = await getHostId();
|
|
25022
|
-
const parkForRestart = await import("../responsiveness-probe-
|
|
25175
|
+
const parkForRestart = await import("../responsiveness-probe-KDSNPKUY.js").then(
|
|
25023
25176
|
(m) => m.parkPendingInbound,
|
|
25024
25177
|
(err) => err
|
|
25025
25178
|
);
|
|
@@ -25092,7 +25245,7 @@ async function handleRestartDoorbell(agentId, requestedAt, restartReason) {
|
|
|
25092
25245
|
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}`));
|
|
25093
25246
|
void (async () => {
|
|
25094
25247
|
try {
|
|
25095
|
-
const { collectDiagnostics } = await import("../persistent-session-
|
|
25248
|
+
const { collectDiagnostics } = await import("../persistent-session-LHQLLU4U.js");
|
|
25096
25249
|
await api.post("/host/heartbeat", {
|
|
25097
25250
|
host_id: hostId,
|
|
25098
25251
|
agent_diagnostics: collectDiagnostics([codeName], quarantineEntriesFor, claudeMdSizeFor, spawnOutcomeForDiagnostics, pidPressureFor, forwardedToolsFor, runtimeVersionFor, sessionActivityFor)
|
|
@@ -25143,7 +25296,7 @@ async function respawnAgentAfterMcpStop(codeName, reason) {
|
|
|
25143
25296
|
}
|
|
25144
25297
|
try {
|
|
25145
25298
|
const hostId = await getHostId();
|
|
25146
|
-
const { collectDiagnostics } = await import("../persistent-session-
|
|
25299
|
+
const { collectDiagnostics } = await import("../persistent-session-LHQLLU4U.js");
|
|
25147
25300
|
await api.post("/host/heartbeat", {
|
|
25148
25301
|
host_id: hostId,
|
|
25149
25302
|
agent_diagnostics: collectDiagnostics([codeName], quarantineEntriesFor, claudeMdSizeFor, spawnOutcomeForDiagnostics, pidPressureFor, forwardedToolsFor, runtimeVersionFor, sessionActivityFor)
|
|
@@ -25555,8 +25708,8 @@ async function processDirectChatMessage(agent, msg) {
|
|
|
25555
25708
|
if (useDoorbell) {
|
|
25556
25709
|
try {
|
|
25557
25710
|
const doorbell = directChatDoorbellPath(agent.agentId, homedir17());
|
|
25558
|
-
|
|
25559
|
-
|
|
25711
|
+
mkdirSync17(dirname11(doorbell), { recursive: true });
|
|
25712
|
+
writeFileSync19(doorbell, String(Date.now()));
|
|
25560
25713
|
log(`[direct-chat] Doorbell rung for '${agent.codeName}' (msg=${msg.id}) \u2014 in-session MCP will pull via the cursor`);
|
|
25561
25714
|
return;
|
|
25562
25715
|
} catch (err) {
|
|
@@ -25684,8 +25837,8 @@ ${formatRunMarker(run_id)}` : KANBAN_CHECK_COMMAND;
|
|
|
25684
25837
|
if (run_id) openInjectedRunByCode.set(codeName, run_id);
|
|
25685
25838
|
try {
|
|
25686
25839
|
const doorbell = directChatDoorbellPath(agentId, homedir17());
|
|
25687
|
-
|
|
25688
|
-
|
|
25840
|
+
mkdirSync17(dirname11(doorbell), { recursive: true });
|
|
25841
|
+
writeFileSync19(doorbell, String(Date.now()));
|
|
25689
25842
|
} catch (err) {
|
|
25690
25843
|
log(`[kanban] doorbell ring failed for '${codeName}': ${err.message} (notice still queued)`);
|
|
25691
25844
|
}
|
|
@@ -25845,7 +25998,7 @@ async function processClaudePairSessions(agents) {
|
|
|
25845
25998
|
snapshotPairConfig,
|
|
25846
25999
|
// ENG-11659: result -> report body + the manager.log line that records it.
|
|
25847
26000
|
planPairStartReport
|
|
25848
|
-
} = await import("../claude-pair-runtime-
|
|
26001
|
+
} = await import("../claude-pair-runtime-FNDHAPXR.js");
|
|
25849
26002
|
const { resetClaudeSignin, describeSigninResetForLog, describeSigninResetFailure } = await import("../claude-signin-reset-6IJMMVYG.js");
|
|
25850
26003
|
for (const pairId of pendingResp.cancelled_pair_ids ?? []) {
|
|
25851
26004
|
log(`[claude-pair] sweeping orphan tmux session for pair ${pairId.slice(0, 8)}`);
|
|
@@ -26144,17 +26297,17 @@ var lastLocalFileHash = /* @__PURE__ */ new Map();
|
|
|
26144
26297
|
var lastMemoriesBody = /* @__PURE__ */ new Map();
|
|
26145
26298
|
var memoryManifests = /* @__PURE__ */ new Map();
|
|
26146
26299
|
function memoryRetirementDir(configDir, codeName) {
|
|
26147
|
-
return
|
|
26300
|
+
return join45(configDir, "_memory-retirement", codeName);
|
|
26148
26301
|
}
|
|
26149
26302
|
function memoryManifestPath(configDir, codeName) {
|
|
26150
|
-
return
|
|
26303
|
+
return join45(memoryRetirementDir(configDir, codeName), "manifest.json");
|
|
26151
26304
|
}
|
|
26152
26305
|
function loadMemoryManifest(agentId, configDir, codeName) {
|
|
26153
26306
|
const cached = memoryManifests.get(agentId);
|
|
26154
26307
|
if (cached) return cached;
|
|
26155
26308
|
let manifest = {};
|
|
26156
26309
|
try {
|
|
26157
|
-
const raw =
|
|
26310
|
+
const raw = readFileSync36(memoryManifestPath(configDir, codeName), "utf-8");
|
|
26158
26311
|
const parsed = JSON.parse(raw);
|
|
26159
26312
|
if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) {
|
|
26160
26313
|
for (const [name, entry] of Object.entries(parsed)) {
|
|
@@ -26174,15 +26327,15 @@ function saveMemoryManifest(agentId, configDir, codeName) {
|
|
|
26174
26327
|
if (!manifest) return;
|
|
26175
26328
|
try {
|
|
26176
26329
|
const path = memoryManifestPath(configDir, codeName);
|
|
26177
|
-
|
|
26330
|
+
mkdirSync17(memoryRetirementDir(configDir, codeName), { recursive: true });
|
|
26178
26331
|
const tmp = `${path}.tmp`;
|
|
26179
|
-
|
|
26332
|
+
writeFileSync19(tmp, JSON.stringify(manifest, null, 2));
|
|
26180
26333
|
renameSync11(tmp, path);
|
|
26181
26334
|
} catch {
|
|
26182
26335
|
}
|
|
26183
26336
|
}
|
|
26184
26337
|
function retiredMemoryDir(configDir, codeName) {
|
|
26185
|
-
return
|
|
26338
|
+
return join45(memoryRetirementDir(configDir, codeName), "retired");
|
|
26186
26339
|
}
|
|
26187
26340
|
var RETIRED_MEMORY_TTL_MS = 30 * 24 * 60 * 60 * 1e3;
|
|
26188
26341
|
var lastRetirementReport = /* @__PURE__ */ new Map();
|
|
@@ -26261,15 +26414,15 @@ function applyMemoryTombstones(opts) {
|
|
|
26261
26414
|
log2(`[memory-retire] ${agent.code_name}: KEPT '${tomb.name}' \u2014 no write record, not ours to remove`);
|
|
26262
26415
|
continue;
|
|
26263
26416
|
}
|
|
26264
|
-
const filePath =
|
|
26265
|
-
if (!
|
|
26417
|
+
const filePath = join45(memoryDir, entry.file);
|
|
26418
|
+
if (!existsSync20(filePath)) {
|
|
26266
26419
|
outcomes.already_gone++;
|
|
26267
26420
|
delete manifest[tomb.name];
|
|
26268
26421
|
manifestDirty = true;
|
|
26269
26422
|
continue;
|
|
26270
26423
|
}
|
|
26271
26424
|
try {
|
|
26272
|
-
const actual = createHash20("sha256").update(
|
|
26425
|
+
const actual = createHash20("sha256").update(readFileSync36(filePath)).digest("hex");
|
|
26273
26426
|
if (actual !== entry.sha) {
|
|
26274
26427
|
outcomes.kept_modified++;
|
|
26275
26428
|
outcomes.unapplied.push({ name: tomb.name, reason: "kept_modified" });
|
|
@@ -26279,11 +26432,11 @@ function applyMemoryTombstones(opts) {
|
|
|
26279
26432
|
continue;
|
|
26280
26433
|
}
|
|
26281
26434
|
const destDir = retiredMemoryDir(configDir, agent.code_name);
|
|
26282
|
-
|
|
26435
|
+
mkdirSync17(destDir, { recursive: true });
|
|
26283
26436
|
const stamp = Date.now();
|
|
26284
|
-
let dest =
|
|
26285
|
-
for (let n = 1;
|
|
26286
|
-
dest =
|
|
26437
|
+
let dest = join45(destDir, `${entry.file}.${stamp}.retired`);
|
|
26438
|
+
for (let n = 1; existsSync20(dest); n++) {
|
|
26439
|
+
dest = join45(destDir, `${entry.file}.${stamp}-${n}.retired`);
|
|
26287
26440
|
}
|
|
26288
26441
|
renameSync11(filePath, dest);
|
|
26289
26442
|
try {
|
|
@@ -26316,13 +26469,13 @@ function applyMemoryTombstones(opts) {
|
|
|
26316
26469
|
}
|
|
26317
26470
|
function reapRetiredMemories(configDir, codeName, log2) {
|
|
26318
26471
|
const dir = retiredMemoryDir(configDir, codeName);
|
|
26319
|
-
if (!
|
|
26472
|
+
if (!existsSync20(dir)) return;
|
|
26320
26473
|
const cutoff = Date.now() - RETIRED_MEMORY_TTL_MS;
|
|
26321
26474
|
let reaped = 0;
|
|
26322
26475
|
try {
|
|
26323
26476
|
for (const file of readdirSync14(dir)) {
|
|
26324
26477
|
if (!file.endsWith(".retired")) continue;
|
|
26325
|
-
const path =
|
|
26478
|
+
const path = join45(dir, file);
|
|
26326
26479
|
try {
|
|
26327
26480
|
if (statSync15(path).mtimeMs < cutoff) {
|
|
26328
26481
|
unlinkSync6(path);
|
|
@@ -26337,8 +26490,8 @@ function reapRetiredMemories(configDir, codeName, log2) {
|
|
|
26337
26490
|
if (reaped > 0) log2(`[memory-retire] ${codeName}: reaped ${reaped} retired memory file(s) past TTL`);
|
|
26338
26491
|
}
|
|
26339
26492
|
async function syncMemories(agent, configDir, log2) {
|
|
26340
|
-
const projectDir =
|
|
26341
|
-
const memoryDir =
|
|
26493
|
+
const projectDir = join45(configDir, agent.code_name, "project");
|
|
26494
|
+
const memoryDir = join45(projectDir, "memory");
|
|
26342
26495
|
const isFreshSync = pendingFreshMemorySync.has(agent.agent_id);
|
|
26343
26496
|
if (isFreshSync) {
|
|
26344
26497
|
log2(`[memory-sync] Fresh-sync requested for '${agent.code_name}' \u2014 pulling DB first`);
|
|
@@ -26362,14 +26515,14 @@ async function syncMemories(agent, configDir, log2) {
|
|
|
26362
26515
|
}
|
|
26363
26516
|
pendingFreshMemorySync.delete(agent.agent_id);
|
|
26364
26517
|
}
|
|
26365
|
-
if (
|
|
26518
|
+
if (existsSync20(memoryDir)) {
|
|
26366
26519
|
const prevHashes = memoryFileHashes.get(agent.agent_id) ?? /* @__PURE__ */ new Map();
|
|
26367
26520
|
const currentHashes = /* @__PURE__ */ new Map();
|
|
26368
26521
|
const changedMemories = [];
|
|
26369
26522
|
for (const file of readdirSync14(memoryDir)) {
|
|
26370
26523
|
if (!file.endsWith(".md")) continue;
|
|
26371
26524
|
try {
|
|
26372
|
-
const raw =
|
|
26525
|
+
const raw = readFileSync36(join45(memoryDir, file), "utf-8");
|
|
26373
26526
|
const fileHash = createHash20("sha256").update(raw).digest("hex").slice(0, 16);
|
|
26374
26527
|
currentHashes.set(file, fileHash);
|
|
26375
26528
|
if (prevHashes.get(file) === fileHash) continue;
|
|
@@ -26394,7 +26547,7 @@ async function syncMemories(agent, configDir, log2) {
|
|
|
26394
26547
|
} catch (err) {
|
|
26395
26548
|
for (const mem of changedMemories) {
|
|
26396
26549
|
for (const [file] of currentHashes) {
|
|
26397
|
-
const parsed = parseMemoryFile(
|
|
26550
|
+
const parsed = parseMemoryFile(readFileSync36(join45(memoryDir, file), "utf-8"), file.replace(/\.md$/, ""));
|
|
26398
26551
|
if (parsed?.name === mem.name) currentHashes.delete(file);
|
|
26399
26552
|
}
|
|
26400
26553
|
}
|
|
@@ -26420,7 +26573,7 @@ async function syncMemories(agent, configDir, log2) {
|
|
|
26420
26573
|
}
|
|
26421
26574
|
}
|
|
26422
26575
|
async function downloadMemories(agent, memoryDir, log2, { force, configDir }) {
|
|
26423
|
-
const localFiles =
|
|
26576
|
+
const localFiles = existsSync20(memoryDir) ? readdirSync14(memoryDir).filter((f) => f.endsWith(".md")).sort() : [];
|
|
26424
26577
|
const localListHash = createHash20("sha256").update(localFiles.join(",")).digest("hex").slice(0, 16);
|
|
26425
26578
|
const prevLocalHash = lastLocalFileHash.get(agent.agent_id);
|
|
26426
26579
|
const prevDownload = lastDownloadHash.get(agent.agent_id);
|
|
@@ -26475,7 +26628,7 @@ async function downloadMemories(agent, memoryDir, log2, { force, configDir }) {
|
|
|
26475
26628
|
// Per-agent, not host-wide: memories are agent-private, so a shared
|
|
26476
26629
|
// store would buy almost no dedupe while exposing one agent's content
|
|
26477
26630
|
// to every other agent on the host. See memory-cache.ts's header.
|
|
26478
|
-
cacheDir:
|
|
26631
|
+
cacheDir: join45(configDir, agent.code_name, "_memory_bodies"),
|
|
26479
26632
|
fetchContents: async (hashes) => {
|
|
26480
26633
|
const res = await api.post(
|
|
26481
26634
|
"/host/memories/contents",
|
|
@@ -26504,7 +26657,7 @@ async function downloadMemories(agent, memoryDir, log2, { force, configDir }) {
|
|
|
26504
26657
|
lastDownloadHash.set(agent.agent_id, responseHash);
|
|
26505
26658
|
lastLocalFileHash.set(agent.agent_id, localListHash);
|
|
26506
26659
|
if (memories?.length) {
|
|
26507
|
-
|
|
26660
|
+
mkdirSync17(memoryDir, { recursive: true });
|
|
26508
26661
|
const manifest = loadMemoryManifest(agent.agent_id, configDir, agent.code_name);
|
|
26509
26662
|
let written = 0;
|
|
26510
26663
|
let overwritten = 0;
|
|
@@ -26513,7 +26666,7 @@ async function downloadMemories(agent, memoryDir, log2, { force, configDir }) {
|
|
|
26513
26666
|
const rawSlug = mem.name.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/(^-|-$)/g, "").slice(0, 60);
|
|
26514
26667
|
const slug = rawSlug || `memory-${i}`;
|
|
26515
26668
|
const fileName = `${slug}.md`;
|
|
26516
|
-
const filePath =
|
|
26669
|
+
const filePath = join45(memoryDir, fileName);
|
|
26517
26670
|
const desired = `---
|
|
26518
26671
|
name: ${JSON.stringify(mem.name)}
|
|
26519
26672
|
type: ${mem.type}
|
|
@@ -26530,10 +26683,10 @@ ${mem.content}
|
|
|
26530
26683
|
return true;
|
|
26531
26684
|
};
|
|
26532
26685
|
let manifestDirty = false;
|
|
26533
|
-
if (
|
|
26686
|
+
if (existsSync20(filePath)) {
|
|
26534
26687
|
let existing = "";
|
|
26535
26688
|
try {
|
|
26536
|
-
existing =
|
|
26689
|
+
existing = readFileSync36(filePath, "utf-8");
|
|
26537
26690
|
} catch {
|
|
26538
26691
|
}
|
|
26539
26692
|
if (existing === desired) {
|
|
@@ -26541,10 +26694,10 @@ ${mem.content}
|
|
|
26541
26694
|
if (manifestDirty) saveMemoryManifest(agent.agent_id, configDir, agent.code_name);
|
|
26542
26695
|
continue;
|
|
26543
26696
|
}
|
|
26544
|
-
|
|
26697
|
+
writeFileSync19(filePath, desired);
|
|
26545
26698
|
overwritten++;
|
|
26546
26699
|
} else {
|
|
26547
|
-
|
|
26700
|
+
writeFileSync19(filePath, desired);
|
|
26548
26701
|
written++;
|
|
26549
26702
|
}
|
|
26550
26703
|
if (record()) manifestDirty = true;
|
|
@@ -26564,9 +26717,9 @@ ${mem.content}
|
|
|
26564
26717
|
}
|
|
26565
26718
|
async function cleanupAgentFiles(codeName, agentDir) {
|
|
26566
26719
|
reapLegacyTokenFile(codeName, log);
|
|
26567
|
-
if (
|
|
26720
|
+
if (existsSync20(agentDir)) {
|
|
26568
26721
|
try {
|
|
26569
|
-
|
|
26722
|
+
rmSync9(agentDir, { recursive: true, force: true });
|
|
26570
26723
|
log(`Removed provision directory for '${codeName}'`);
|
|
26571
26724
|
} catch (err) {
|
|
26572
26725
|
log(`Failed to remove provision dir for '${codeName}': ${err.message}`);
|
|
@@ -26933,8 +27086,8 @@ function startManager(opts) {
|
|
|
26933
27086
|
config = opts;
|
|
26934
27087
|
try {
|
|
26935
27088
|
const stateFile = getStateFile();
|
|
26936
|
-
if (
|
|
26937
|
-
const raw =
|
|
27089
|
+
if (existsSync20(stateFile)) {
|
|
27090
|
+
const raw = readFileSync36(stateFile, "utf-8");
|
|
26938
27091
|
const parsed = JSON.parse(raw);
|
|
26939
27092
|
if (Array.isArray(parsed.agents)) {
|
|
26940
27093
|
state9.agents = parsed.agents;
|
|
@@ -26968,7 +27121,7 @@ function startManager(opts) {
|
|
|
26968
27121
|
log(`[startup] state rehydration failed (continuing with empty state): ${err.message}`);
|
|
26969
27122
|
}
|
|
26970
27123
|
log(
|
|
26971
|
-
`[startup] worker pid=${process.pid} ppid=${process.ppid} node=${process.version} log=${
|
|
27124
|
+
`[startup] worker pid=${process.pid} ppid=${process.ppid} node=${process.version} log=${join45(homedir17(), ".augmented", "manager.log")}`
|
|
26972
27125
|
);
|
|
26973
27126
|
deployMcpAssets();
|
|
26974
27127
|
reapOrphanChannelMcps({ log });
|
|
@@ -26997,7 +27150,7 @@ async function reapOrphanedClaudePids() {
|
|
|
26997
27150
|
const looksLikeClaude = (pid) => {
|
|
26998
27151
|
if (process.platform !== "linux") return true;
|
|
26999
27152
|
try {
|
|
27000
|
-
const comm =
|
|
27153
|
+
const comm = readFileSync36(`/proc/${pid}/comm`, "utf-8").trim().toLowerCase();
|
|
27001
27154
|
return comm.includes("claude");
|
|
27002
27155
|
} catch {
|
|
27003
27156
|
return false;
|
|
@@ -27094,14 +27247,14 @@ function restartRunningChannelMcps(basenames) {
|
|
|
27094
27247
|
}
|
|
27095
27248
|
}
|
|
27096
27249
|
function deployMcpAssets() {
|
|
27097
|
-
const targetDir =
|
|
27098
|
-
|
|
27250
|
+
const targetDir = join45(homedir17(), ".augmented", "_mcp");
|
|
27251
|
+
mkdirSync17(targetDir, { recursive: true });
|
|
27099
27252
|
const moduleDir = dirname11(fileURLToPath2(import.meta.url));
|
|
27100
27253
|
let mcpSourceDir = "";
|
|
27101
27254
|
let dir = moduleDir;
|
|
27102
27255
|
for (let i = 0; i < 6; i++) {
|
|
27103
|
-
const candidate =
|
|
27104
|
-
if (
|
|
27256
|
+
const candidate = join45(dir, "dist", "mcp");
|
|
27257
|
+
if (existsSync20(join45(candidate, "index.js"))) {
|
|
27105
27258
|
mcpSourceDir = candidate;
|
|
27106
27259
|
break;
|
|
27107
27260
|
}
|
|
@@ -27118,8 +27271,8 @@ function deployMcpAssets() {
|
|
|
27118
27271
|
const failedFiles = [];
|
|
27119
27272
|
const fileHash = (p) => {
|
|
27120
27273
|
try {
|
|
27121
|
-
if (!
|
|
27122
|
-
return createHash20("sha256").update(
|
|
27274
|
+
if (!existsSync20(p)) return null;
|
|
27275
|
+
return createHash20("sha256").update(readFileSync36(p)).digest("hex");
|
|
27123
27276
|
} catch {
|
|
27124
27277
|
return null;
|
|
27125
27278
|
}
|
|
@@ -27201,9 +27354,9 @@ function deployMcpAssets() {
|
|
|
27201
27354
|
// natural session restart.
|
|
27202
27355
|
"computer-use-proxy.js"
|
|
27203
27356
|
]) {
|
|
27204
|
-
const src =
|
|
27205
|
-
const dst =
|
|
27206
|
-
if (!
|
|
27357
|
+
const src = join45(mcpSourceDir, file);
|
|
27358
|
+
const dst = join45(targetDir, file);
|
|
27359
|
+
if (!existsSync20(src)) continue;
|
|
27207
27360
|
attemptedFiles.push(file);
|
|
27208
27361
|
const before = fileHash(dst);
|
|
27209
27362
|
try {
|
|
@@ -27228,23 +27381,23 @@ function deployMcpAssets() {
|
|
|
27228
27381
|
log(`[manager] Bundle(s) updated: ${changedBasenames.join(", ")} \u2014 signalling running instances to restart`);
|
|
27229
27382
|
restartRunningChannelMcps(changedBasenames);
|
|
27230
27383
|
}
|
|
27231
|
-
const localMcpPath =
|
|
27384
|
+
const localMcpPath = join45(targetDir, "index.js");
|
|
27232
27385
|
try {
|
|
27233
|
-
const agentsDir =
|
|
27234
|
-
if (
|
|
27386
|
+
const agentsDir = join45(homedir17(), ".augmented", "agents");
|
|
27387
|
+
if (existsSync20(agentsDir)) {
|
|
27235
27388
|
for (const entry of readdirSync14(agentsDir, { withFileTypes: true })) {
|
|
27236
27389
|
if (!entry.isDirectory()) continue;
|
|
27237
27390
|
for (const subdir of ["provision", "project"]) {
|
|
27238
|
-
const mcpJsonPath =
|
|
27391
|
+
const mcpJsonPath = join45(agentsDir, entry.name, subdir, ".mcp.json");
|
|
27239
27392
|
try {
|
|
27240
|
-
const raw =
|
|
27393
|
+
const raw = readFileSync36(mcpJsonPath, "utf-8");
|
|
27241
27394
|
if (!raw.includes("@integrity-labs/augmented-mcp")) continue;
|
|
27242
27395
|
const mcpConfig = JSON.parse(raw);
|
|
27243
27396
|
const augServer = mcpConfig.mcpServers?.["augmented"];
|
|
27244
27397
|
if (!augServer) continue;
|
|
27245
27398
|
augServer.command = "node";
|
|
27246
27399
|
augServer.args = [localMcpPath];
|
|
27247
|
-
|
|
27400
|
+
writeFileSync19(mcpJsonPath, JSON.stringify(mcpConfig, null, 2));
|
|
27248
27401
|
log(`[manager] Patched ${entry.name}/${subdir}/.mcp.json: npx \u2192 node`);
|
|
27249
27402
|
} catch {
|
|
27250
27403
|
}
|