@integrity-labs/agt-cli 0.28.1178 → 0.28.1179
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin/agt.js +6 -6
- package/dist/{chunk-MO5JQVBG.js → chunk-2FHYCFZM.js} +2 -2
- package/dist/{chunk-3XURNDW5.js → chunk-GJD536LU.js} +6 -4
- package/dist/chunk-GJD536LU.js.map +1 -0
- package/dist/{chunk-R2NQG77N.js → chunk-KDYZNWZW.js} +2 -2
- package/dist/{chunk-DAIXT5DR.js → chunk-O5P2OS36.js} +5 -5
- package/dist/{chunk-MHSZBN6M.js → chunk-PINFVWGX.js} +109 -2
- package/dist/chunk-PINFVWGX.js.map +1 -0
- package/dist/{claude-code-updater-F2O3LAWX.js → claude-code-updater-LL7KVAU3.js} +3 -3
- package/dist/{claude-pair-runtime-I6KVCUBG.js → claude-pair-runtime-R5MNSUM7.js} +3 -3
- package/dist/lib/manager-worker.js +397 -261
- package/dist/lib/manager-worker.js.map +1 -1
- package/dist/mcp/direct-chat-channel.js +14 -1
- package/dist/mcp/index.js +147 -63
- package/dist/mcp/origami.js +14 -1
- package/dist/mcp/slack-channel.js +14 -1
- package/dist/mcp/telegram-channel.js +14 -1
- package/dist/{persistent-session-7HP4KOED.js → persistent-session-34QXCPJK.js} +4 -4
- package/dist/{responsiveness-probe-EPG7NOKI.js → responsiveness-probe-ZT6ITMYI.js} +4 -4
- package/dist/{session-auth-dead-IG3MKV2W.js → session-auth-dead-KAHV2ES2.js} +3 -3
- package/package.json +1 -1
- package/dist/chunk-3XURNDW5.js.map +0 -1
- package/dist/chunk-MHSZBN6M.js.map +0 -1
- /package/dist/{chunk-MO5JQVBG.js.map → chunk-2FHYCFZM.js.map} +0 -0
- /package/dist/{chunk-R2NQG77N.js.map → chunk-KDYZNWZW.js.map} +0 -0
- /package/dist/{chunk-DAIXT5DR.js.map → chunk-O5P2OS36.js.map} +0 -0
- /package/dist/{claude-code-updater-F2O3LAWX.js.map → claude-code-updater-LL7KVAU3.js.map} +0 -0
- /package/dist/{claude-pair-runtime-I6KVCUBG.js.map → claude-pair-runtime-R5MNSUM7.js.map} +0 -0
- /package/dist/{persistent-session-7HP4KOED.js.map → persistent-session-34QXCPJK.js.map} +0 -0
- /package/dist/{responsiveness-probe-EPG7NOKI.js.map → responsiveness-probe-ZT6ITMYI.js.map} +0 -0
- /package/dist/{session-auth-dead-IG3MKV2W.js.map → session-auth-dead-KAHV2ES2.js.map} +0 -0
|
@@ -82,7 +82,7 @@ import {
|
|
|
82
82
|
tripClass,
|
|
83
83
|
writeEtcEnvironment,
|
|
84
84
|
writeProfileDScript
|
|
85
|
-
} from "../chunk-
|
|
85
|
+
} from "../chunk-O5P2OS36.js";
|
|
86
86
|
import {
|
|
87
87
|
CLAUDE_CODE_SECURITY_FLOOR,
|
|
88
88
|
SELF_UPDATE_TIMEOUTS,
|
|
@@ -96,7 +96,7 @@ import {
|
|
|
96
96
|
runSafeCleanup,
|
|
97
97
|
tightestDiskStat,
|
|
98
98
|
withPackageCacheLock
|
|
99
|
-
} from "../chunk-
|
|
99
|
+
} from "../chunk-KDYZNWZW.js";
|
|
100
100
|
import {
|
|
101
101
|
rewriteSupervisorApiKey,
|
|
102
102
|
supervisorChannelsRefusing
|
|
@@ -139,6 +139,7 @@ import {
|
|
|
139
139
|
injectMessage,
|
|
140
140
|
injectMessageWithStatus,
|
|
141
141
|
injectOpencodeMessage,
|
|
142
|
+
isActivelyProcessing,
|
|
142
143
|
isConfirmedRespawn,
|
|
143
144
|
isOpencodeSessionHealthy,
|
|
144
145
|
isSessionHealthy,
|
|
@@ -187,7 +188,7 @@ import {
|
|
|
187
188
|
webFetchBaselineValue,
|
|
188
189
|
webFetchRestartNeeded,
|
|
189
190
|
writeEgressAllowlist
|
|
190
|
-
} from "../chunk-
|
|
191
|
+
} from "../chunk-GJD536LU.js";
|
|
191
192
|
import {
|
|
192
193
|
isAgentIdle,
|
|
193
194
|
isStaleForToday,
|
|
@@ -196,12 +197,13 @@ import {
|
|
|
196
197
|
sessionTranscriptDir,
|
|
197
198
|
subagentActivityAgeSeconds,
|
|
198
199
|
transcriptActivityAgeSeconds
|
|
199
|
-
} from "../chunk-
|
|
200
|
+
} from "../chunk-2FHYCFZM.js";
|
|
200
201
|
import {
|
|
201
202
|
classifyUnanswerablePane,
|
|
202
203
|
focusedConfirmDialogBlock,
|
|
203
204
|
isParkedOnToolPermissionPrompt,
|
|
204
205
|
paneRemedy,
|
|
206
|
+
parkedModalKind,
|
|
205
207
|
sendDialogKeys,
|
|
206
208
|
simpleTextHash
|
|
207
209
|
} from "../chunk-OO36JBFI.js";
|
|
@@ -235,6 +237,7 @@ import {
|
|
|
235
237
|
MANAGER_LIVENESS_HEARTBEAT_INTERVAL_MS,
|
|
236
238
|
MAX_AVATAR_ENV_URL_BYTES,
|
|
237
239
|
NO_FAILING_TURN_RUN,
|
|
240
|
+
NO_TRANSCRIPT_ACTIVITY,
|
|
238
241
|
SCHEDULED_TURN_MARKER_FILENAME,
|
|
239
242
|
SKILLS_INDEX_SECTION_END,
|
|
240
243
|
SKILLS_INDEX_SECTION_START,
|
|
@@ -309,13 +312,15 @@ import {
|
|
|
309
312
|
resolveChannels,
|
|
310
313
|
resolveCrossTeamPeerIntraOrg,
|
|
311
314
|
resolveDmTarget,
|
|
315
|
+
resolveSessionActivityState,
|
|
312
316
|
scrubPreservingIdentifiers,
|
|
313
317
|
senderPolicyIsEnforcedOn,
|
|
314
318
|
serializeAccountEnforcementMarker,
|
|
315
319
|
shouldMintReplacementKey,
|
|
316
320
|
stabiliseResetInstant,
|
|
317
|
-
sumTranscriptUsageInWindow
|
|
318
|
-
|
|
321
|
+
sumTranscriptUsageInWindow,
|
|
322
|
+
summarizeTranscriptActivity
|
|
323
|
+
} from "../chunk-PINFVWGX.js";
|
|
319
324
|
import {
|
|
320
325
|
CLAUDE_CONFIG_DIR_ENV,
|
|
321
326
|
claudeConfigDirFor,
|
|
@@ -327,7 +332,7 @@ import "../chunk-DGUM43GV.js";
|
|
|
327
332
|
|
|
328
333
|
// src/lib/manager-worker.ts
|
|
329
334
|
import { createHash as createHash20 } from "crypto";
|
|
330
|
-
import { readFileSync as readFileSync34, writeFileSync as writeFileSync18, mkdirSync as mkdirSync16, existsSync as existsSync19, rmSync as rmSync8, readdirSync as
|
|
335
|
+
import { readFileSync as readFileSync34, writeFileSync as writeFileSync18, mkdirSync as mkdirSync16, existsSync as existsSync19, rmSync as rmSync8, readdirSync as readdirSync14, statSync as statSync15, unlinkSync as unlinkSync6, renameSync as renameSync11, utimesSync as utimesSync4, readlinkSync as readlinkSync2 } from "fs";
|
|
331
336
|
|
|
332
337
|
// src/lib/atomic-file-replace.ts
|
|
333
338
|
import { copyFileSync, renameSync, unlinkSync } from "fs";
|
|
@@ -744,7 +749,7 @@ function clearEpisode(codeName) {
|
|
|
744
749
|
}
|
|
745
750
|
|
|
746
751
|
// src/lib/manager-worker.ts
|
|
747
|
-
import { join as
|
|
752
|
+
import { join as join44, dirname as dirname11, delimiter as pathDelimiter } from "path";
|
|
748
753
|
import { homedir as homedir17, hostname, platform as platform3 } from "os";
|
|
749
754
|
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
750
755
|
|
|
@@ -4820,9 +4825,130 @@ function failingTurnLoops(now = Date.now(), threshold = failingTurnThreshold(),
|
|
|
4820
4825
|
return [...failing, ...recovered];
|
|
4821
4826
|
}
|
|
4822
4827
|
|
|
4823
|
-
// src/lib/
|
|
4824
|
-
import { readdirSync as readdirSync3,
|
|
4828
|
+
// src/lib/session-activity.ts
|
|
4829
|
+
import { readdirSync as readdirSync3, statSync as statSync3 } from "fs";
|
|
4825
4830
|
import { join as join18 } from "path";
|
|
4831
|
+
var RULE = /^[─━]{10,}/;
|
|
4832
|
+
var CARET_LINE = /^\s*❯(\s|$)/;
|
|
4833
|
+
var NON_BLOCKING_PICKER = { title: "We recommend compacting earlier", footer: "esc not now", kind: "compaction-suggestion" };
|
|
4834
|
+
var TOOL_NAME_MAX = 120;
|
|
4835
|
+
var MIN_TRANSCRIPT_CHECK_MS = 3e4;
|
|
4836
|
+
function classifyPane(screen, tmuxAlive) {
|
|
4837
|
+
if (!tmuxAlive) return { state: "no_session", promptKind: null };
|
|
4838
|
+
if (!screen || !screen.trim()) return null;
|
|
4839
|
+
const kind = parkedModalKind(screen);
|
|
4840
|
+
if (kind) return { state: "blocked_on_prompt", promptKind: kind };
|
|
4841
|
+
const lines = screen.split("\n");
|
|
4842
|
+
const rules = lines.flatMap((l, i) => RULE.test(l.trim()) ? [i] : []);
|
|
4843
|
+
const lastRule = rules[rules.length - 1] ?? -1;
|
|
4844
|
+
const carets = lines.flatMap((l, i) => CARET_LINE.test(l) ? [i] : []);
|
|
4845
|
+
const lastCaret = carets[carets.length - 1] ?? -1;
|
|
4846
|
+
if (lastCaret > lastRule) {
|
|
4847
|
+
const below = lines.slice(lastRule + 1);
|
|
4848
|
+
const footer = below.filter((l) => l.trim()).at(-1) ?? "";
|
|
4849
|
+
if (below.some((l) => l.includes(NON_BLOCKING_PICKER.title)) && footer.includes(NON_BLOCKING_PICKER.footer)) {
|
|
4850
|
+
return isActivelyProcessing(screen) ? { state: "mid_turn", promptKind: null } : { state: "idle_at_prompt", promptKind: NON_BLOCKING_PICKER.kind };
|
|
4851
|
+
}
|
|
4852
|
+
return { state: "blocked_on_prompt", promptKind: "unknown" };
|
|
4853
|
+
}
|
|
4854
|
+
if (isActivelyProcessing(screen)) return { state: "mid_turn", promptKind: null };
|
|
4855
|
+
const prevRule = rules[rules.length - 2] ?? -1;
|
|
4856
|
+
const hasInputBox = lastCaret > prevRule && lastCaret < lastRule && prevRule >= 0;
|
|
4857
|
+
if (!hasInputBox) return { state: "blocked_on_prompt", promptKind: "unknown" };
|
|
4858
|
+
return { state: "idle_at_prompt", promptKind: null };
|
|
4859
|
+
}
|
|
4860
|
+
var cache = /* @__PURE__ */ new Map();
|
|
4861
|
+
function newestTranscript(dir) {
|
|
4862
|
+
let names;
|
|
4863
|
+
try {
|
|
4864
|
+
names = readdirSync3(dir);
|
|
4865
|
+
} catch {
|
|
4866
|
+
return null;
|
|
4867
|
+
}
|
|
4868
|
+
let best = null;
|
|
4869
|
+
for (const name of names) {
|
|
4870
|
+
if (!name.endsWith(".jsonl")) continue;
|
|
4871
|
+
const path = join18(dir, name);
|
|
4872
|
+
try {
|
|
4873
|
+
const st = statSync3(path);
|
|
4874
|
+
if (st.isFile() && (best === null || st.mtimeMs > best.mtimeMs)) {
|
|
4875
|
+
best = { path, mtimeMs: st.mtimeMs, size: st.size };
|
|
4876
|
+
}
|
|
4877
|
+
} catch {
|
|
4878
|
+
continue;
|
|
4879
|
+
}
|
|
4880
|
+
}
|
|
4881
|
+
return best;
|
|
4882
|
+
}
|
|
4883
|
+
function sessionTranscript(dir, sessionId) {
|
|
4884
|
+
if (!sessionId) return newestTranscript(dir);
|
|
4885
|
+
const path = join18(dir, `${sessionId}.jsonl`);
|
|
4886
|
+
try {
|
|
4887
|
+
const st = statSync3(path);
|
|
4888
|
+
return st.isFile() ? { path, mtimeMs: st.mtimeMs, size: st.size } : null;
|
|
4889
|
+
} catch {
|
|
4890
|
+
return null;
|
|
4891
|
+
}
|
|
4892
|
+
}
|
|
4893
|
+
function readTranscript(codeName, dir, sessionId, nowMs) {
|
|
4894
|
+
const session = sessionId ?? null;
|
|
4895
|
+
const prev = cache.get(codeName)?.sessionId === session ? cache.get(codeName) : void 0;
|
|
4896
|
+
if (prev && nowMs - prev.checkedAt < MIN_TRANSCRIPT_CHECK_MS) return prev;
|
|
4897
|
+
const file = sessionTranscript(dir, sessionId);
|
|
4898
|
+
if (!file) {
|
|
4899
|
+
const none = { checkedAt: nowMs, sessionId: session, path: null, mtimeMs: null, size: 0, activity: NO_TRANSCRIPT_ACTIVITY };
|
|
4900
|
+
cache.set(codeName, none);
|
|
4901
|
+
return none;
|
|
4902
|
+
}
|
|
4903
|
+
if (prev && prev.path === file.path && prev.mtimeMs === file.mtimeMs && prev.size === file.size) {
|
|
4904
|
+
prev.checkedAt = nowMs;
|
|
4905
|
+
return prev;
|
|
4906
|
+
}
|
|
4907
|
+
const next = {
|
|
4908
|
+
checkedAt: nowMs,
|
|
4909
|
+
sessionId: session,
|
|
4910
|
+
path: file.path,
|
|
4911
|
+
mtimeMs: file.mtimeMs,
|
|
4912
|
+
size: file.size,
|
|
4913
|
+
activity: summarizeTranscriptActivity(readTail(file.path, file.size))
|
|
4914
|
+
};
|
|
4915
|
+
cache.set(codeName, next);
|
|
4916
|
+
return next;
|
|
4917
|
+
}
|
|
4918
|
+
function iso(ms) {
|
|
4919
|
+
return ms === null ? null : new Date(ms).toISOString();
|
|
4920
|
+
}
|
|
4921
|
+
function buildSessionActivityReport(args) {
|
|
4922
|
+
const nowMs = args.now ?? Date.now();
|
|
4923
|
+
try {
|
|
4924
|
+
const pane = classifyPane(args.screenCapture, args.tmuxAlive);
|
|
4925
|
+
if (!pane) return null;
|
|
4926
|
+
const transcript = readTranscript(args.codeName, args.transcriptDir, args.sessionId, nowMs);
|
|
4927
|
+
const state10 = resolveSessionActivityState({
|
|
4928
|
+
pane,
|
|
4929
|
+
transcript: transcript.activity,
|
|
4930
|
+
transcriptMtimeMs: transcript.mtimeMs,
|
|
4931
|
+
// When the mtime was read, not now: it can be up to 30s old, and a stale read
|
|
4932
|
+
// must not age a transcript that has since moved into `turn_killed`.
|
|
4933
|
+
nowMs: transcript.checkedAt
|
|
4934
|
+
});
|
|
4935
|
+
return {
|
|
4936
|
+
state: state10,
|
|
4937
|
+
promptKind: state10 === "blocked_on_prompt" || state10 === "idle_at_prompt" ? pane.promptKind : null,
|
|
4938
|
+
lastToolName: transcript.activity.lastToolName?.slice(0, TOOL_NAME_MAX) ?? null,
|
|
4939
|
+
lastToolAt: iso(transcript.activity.lastToolAtMs),
|
|
4940
|
+
lastCompletedTurnAt: iso(transcript.activity.lastCompletedTurnAtMs),
|
|
4941
|
+
transcriptMtime: iso(transcript.mtimeMs)
|
|
4942
|
+
};
|
|
4943
|
+
} catch (err) {
|
|
4944
|
+
args.log?.(`[session-activity] failed for '${args.codeName}': ${err.message}`);
|
|
4945
|
+
return null;
|
|
4946
|
+
}
|
|
4947
|
+
}
|
|
4948
|
+
|
|
4949
|
+
// src/lib/workflow-run-reconciler.ts
|
|
4950
|
+
import { readdirSync as readdirSync4, readFileSync as readFileSync12, statSync as statSync4 } from "fs";
|
|
4951
|
+
import { join as join19 } from "path";
|
|
4826
4952
|
var MIN_CHECK_INTERVAL_MS4 = 5 * 6e4;
|
|
4827
4953
|
var SETTLE_MS = 3e4;
|
|
4828
4954
|
var TRANSCRIPT_MTIME_WINDOW_MS2 = 2 * 24 * 60 * 60 * 1e3;
|
|
@@ -4856,15 +4982,15 @@ function collectJsonlRecursive(dir, minMtimeMs, out, depth) {
|
|
|
4856
4982
|
if (depth > MAX_SUBAGENT_DEPTH) return;
|
|
4857
4983
|
let entries;
|
|
4858
4984
|
try {
|
|
4859
|
-
entries =
|
|
4985
|
+
entries = readdirSync4(dir);
|
|
4860
4986
|
} catch {
|
|
4861
4987
|
return;
|
|
4862
4988
|
}
|
|
4863
4989
|
for (const name of entries) {
|
|
4864
|
-
const p =
|
|
4990
|
+
const p = join19(dir, name);
|
|
4865
4991
|
let st;
|
|
4866
4992
|
try {
|
|
4867
|
-
st =
|
|
4993
|
+
st = statSync4(p);
|
|
4868
4994
|
} catch {
|
|
4869
4995
|
continue;
|
|
4870
4996
|
}
|
|
@@ -4879,15 +5005,15 @@ function enumerateTranscriptFiles(transcriptDir, nowMs, minMtimeMs = nowMs - TRA
|
|
|
4879
5005
|
const out = [];
|
|
4880
5006
|
let entries;
|
|
4881
5007
|
try {
|
|
4882
|
-
entries =
|
|
5008
|
+
entries = readdirSync4(transcriptDir);
|
|
4883
5009
|
} catch {
|
|
4884
5010
|
return out;
|
|
4885
5011
|
}
|
|
4886
5012
|
for (const name of entries) {
|
|
4887
|
-
const path =
|
|
5013
|
+
const path = join19(transcriptDir, name);
|
|
4888
5014
|
let st;
|
|
4889
5015
|
try {
|
|
4890
|
-
st =
|
|
5016
|
+
st = statSync4(path);
|
|
4891
5017
|
} catch {
|
|
4892
5018
|
continue;
|
|
4893
5019
|
}
|
|
@@ -4896,7 +5022,7 @@ function enumerateTranscriptFiles(transcriptDir, nowMs, minMtimeMs = nowMs - TRA
|
|
|
4896
5022
|
continue;
|
|
4897
5023
|
}
|
|
4898
5024
|
if (st.isDirectory()) {
|
|
4899
|
-
collectJsonlRecursive(
|
|
5025
|
+
collectJsonlRecursive(join19(path, "subagents"), minMtimeMs, out, 0);
|
|
4900
5026
|
}
|
|
4901
5027
|
}
|
|
4902
5028
|
return out;
|
|
@@ -4985,8 +5111,8 @@ async function maybeReconcileWorkflowRunTokens(args) {
|
|
|
4985
5111
|
}
|
|
4986
5112
|
|
|
4987
5113
|
// src/lib/conversation-evaluator.ts
|
|
4988
|
-
import { readdirSync as
|
|
4989
|
-
import { join as
|
|
5114
|
+
import { readdirSync as readdirSync5, readFileSync as readFileSync13, statSync as statSync5 } from "fs";
|
|
5115
|
+
import { join as join20 } from "path";
|
|
4990
5116
|
|
|
4991
5117
|
// src/lib/detect-meta-egress.ts
|
|
4992
5118
|
var REPOST_PREAMBLE_WINDOW = 200;
|
|
@@ -5466,12 +5592,12 @@ function readRecentTurns(dir, nowMs) {
|
|
|
5466
5592
|
const visit = (d) => {
|
|
5467
5593
|
let entries;
|
|
5468
5594
|
try {
|
|
5469
|
-
entries =
|
|
5595
|
+
entries = readdirSync5(d, { withFileTypes: true });
|
|
5470
5596
|
} catch {
|
|
5471
5597
|
return;
|
|
5472
5598
|
}
|
|
5473
5599
|
for (const ent of entries) {
|
|
5474
|
-
const full =
|
|
5600
|
+
const full = join20(d, ent.name);
|
|
5475
5601
|
if (ent.isDirectory()) {
|
|
5476
5602
|
visit(full);
|
|
5477
5603
|
continue;
|
|
@@ -5479,7 +5605,7 @@ function readRecentTurns(dir, nowMs) {
|
|
|
5479
5605
|
if (!ent.isFile() || !ent.name.endsWith(".jsonl")) continue;
|
|
5480
5606
|
let mtimeMs;
|
|
5481
5607
|
try {
|
|
5482
|
-
mtimeMs =
|
|
5608
|
+
mtimeMs = statSync5(full).mtimeMs;
|
|
5483
5609
|
} catch {
|
|
5484
5610
|
continue;
|
|
5485
5611
|
}
|
|
@@ -5859,17 +5985,17 @@ async function reportSkip2(api2, agentId, conversationId, log2, codeName) {
|
|
|
5859
5985
|
|
|
5860
5986
|
// src/lib/tool-call-audit.ts
|
|
5861
5987
|
import { homedir as homedir11 } from "os";
|
|
5862
|
-
import { join as
|
|
5988
|
+
import { join as join25 } from "path";
|
|
5863
5989
|
|
|
5864
5990
|
// src/lib/agent-logging-mode.ts
|
|
5865
5991
|
import { readFileSync as readFileSync14 } from "fs";
|
|
5866
5992
|
import { homedir as homedir8 } from "os";
|
|
5867
|
-
import { join as
|
|
5993
|
+
import { join as join21 } from "path";
|
|
5868
5994
|
var LOGGING_MODES = ["hash-only", "redacted", "full-local"];
|
|
5869
5995
|
function charterPath(codeName, homeDir) {
|
|
5870
5996
|
const home = homeDir ?? (process.env["HOME"]?.trim() || homedir8());
|
|
5871
5997
|
const key = agentRuntimeKey(codeName, homeDir);
|
|
5872
|
-
return
|
|
5998
|
+
return join21(home, ".augmented", key, "provision", "CHARTER.md");
|
|
5873
5999
|
}
|
|
5874
6000
|
function readAgentLoggingMode(codeName, homeDir) {
|
|
5875
6001
|
let raw;
|
|
@@ -5900,13 +6026,13 @@ function loggingModeWithholdsTargets(reading) {
|
|
|
5900
6026
|
import { randomBytes } from "crypto";
|
|
5901
6027
|
import { existsSync as existsSync4, mkdirSync as mkdirSync6, readFileSync as readFileSync15, renameSync as renameSync4, unlinkSync as unlinkSync2, writeFileSync as writeFileSync7 } from "fs";
|
|
5902
6028
|
import { homedir as homedir9 } from "os";
|
|
5903
|
-
import { dirname as dirname7, join as
|
|
6029
|
+
import { dirname as dirname7, join as join22 } from "path";
|
|
5904
6030
|
var SALT_BYTES = 32;
|
|
5905
6031
|
var SALT_RE = /^[0-9a-f]{64}$/;
|
|
5906
6032
|
function pathSaltPath(codeName, homeDir) {
|
|
5907
6033
|
const home = homeDir ?? (process.env["HOME"]?.trim() || homedir9());
|
|
5908
6034
|
const key = agentRuntimeKey(codeName, homeDir);
|
|
5909
|
-
return
|
|
6035
|
+
return join22(home, ".augmented", key, "tool-call-path-salt");
|
|
5910
6036
|
}
|
|
5911
6037
|
function readToolCallPathSalt(codeName, homeDir) {
|
|
5912
6038
|
let file;
|
|
@@ -5940,11 +6066,11 @@ function readToolCallPathSalt(codeName, homeDir) {
|
|
|
5940
6066
|
}
|
|
5941
6067
|
|
|
5942
6068
|
// src/lib/tool-call-scan.ts
|
|
5943
|
-
import { statSync as
|
|
6069
|
+
import { statSync as statSync6 } from "fs";
|
|
5944
6070
|
|
|
5945
6071
|
// src/lib/tool-call-extractor.ts
|
|
5946
|
-
import { closeSync as closeSync2, fstatSync, openSync as openSync2, readFileSync as readFileSync16, readSync as readSync2, readdirSync as
|
|
5947
|
-
import { basename as basename2, join as
|
|
6072
|
+
import { closeSync as closeSync2, fstatSync, openSync as openSync2, readFileSync as readFileSync16, readSync as readSync2, readdirSync as readdirSync6 } from "fs";
|
|
6073
|
+
import { basename as basename2, join as join23, relative } from "path";
|
|
5948
6074
|
import { StringDecoder } from "string_decoder";
|
|
5949
6075
|
|
|
5950
6076
|
// src/lib/tool-call-redaction.ts
|
|
@@ -6073,7 +6199,7 @@ function redactToolTargetInner(toolName, input, ctx) {
|
|
|
6073
6199
|
var EXTRACTOR_VERSION = "e1";
|
|
6074
6200
|
function enumerateSessionTranscripts(transcriptDir, sessionId, projectsRoot) {
|
|
6075
6201
|
const files = [];
|
|
6076
|
-
const mainAbs =
|
|
6202
|
+
const mainAbs = join23(transcriptDir, `${sessionId}.jsonl`);
|
|
6077
6203
|
files.push({
|
|
6078
6204
|
absPath: mainAbs,
|
|
6079
6205
|
relPath: relative(projectsRoot, mainAbs),
|
|
@@ -6081,16 +6207,16 @@ function enumerateSessionTranscripts(transcriptDir, sessionId, projectsRoot) {
|
|
|
6081
6207
|
isSubagent: false,
|
|
6082
6208
|
subagentId: null
|
|
6083
6209
|
});
|
|
6084
|
-
const subDir =
|
|
6210
|
+
const subDir = join23(transcriptDir, sessionId, "subagents");
|
|
6085
6211
|
let entries;
|
|
6086
6212
|
try {
|
|
6087
|
-
entries =
|
|
6213
|
+
entries = readdirSync6(subDir);
|
|
6088
6214
|
} catch {
|
|
6089
6215
|
return files;
|
|
6090
6216
|
}
|
|
6091
6217
|
for (const name of entries) {
|
|
6092
6218
|
if (!name.endsWith(".jsonl")) continue;
|
|
6093
|
-
const abs =
|
|
6219
|
+
const abs = join23(subDir, name);
|
|
6094
6220
|
const stem = basename2(name, ".jsonl");
|
|
6095
6221
|
files.push({
|
|
6096
6222
|
absPath: abs,
|
|
@@ -6290,7 +6416,7 @@ function extractTranscriptWindow(file, opts, from) {
|
|
|
6290
6416
|
// src/lib/tool-call-cursor.ts
|
|
6291
6417
|
import { existsSync as existsSync5, readFileSync as readFileSync17 } from "fs";
|
|
6292
6418
|
import { homedir as homedir10 } from "os";
|
|
6293
|
-
import { join as
|
|
6419
|
+
import { join as join24 } from "path";
|
|
6294
6420
|
var COVERAGE_DISPOSITIONS = [
|
|
6295
6421
|
"ok",
|
|
6296
6422
|
"not_entitled",
|
|
@@ -6345,7 +6471,7 @@ function parseCursorKey(key) {
|
|
|
6345
6471
|
function cursorStatePath(codeName, homeDir) {
|
|
6346
6472
|
const home = homeDir ?? (process.env["HOME"]?.trim() || homedir10());
|
|
6347
6473
|
const key = agentRuntimeKey(codeName, homeDir);
|
|
6348
|
-
return
|
|
6474
|
+
return join24(home, ".augmented", key, "tool-call-cursors.json");
|
|
6349
6475
|
}
|
|
6350
6476
|
function loadCursors(path) {
|
|
6351
6477
|
const out = /* @__PURE__ */ new Map();
|
|
@@ -6494,7 +6620,7 @@ function nextCursor(args) {
|
|
|
6494
6620
|
};
|
|
6495
6621
|
}
|
|
6496
6622
|
function initialCursor(args) {
|
|
6497
|
-
const
|
|
6623
|
+
const iso2 = new Date(args.nowMs).toISOString();
|
|
6498
6624
|
return {
|
|
6499
6625
|
byteOffset: args.startByte,
|
|
6500
6626
|
lineOffset: args.startLine,
|
|
@@ -6510,8 +6636,8 @@ function initialCursor(args) {
|
|
|
6510
6636
|
runScopeId: null,
|
|
6511
6637
|
unpairedSince: null,
|
|
6512
6638
|
lastDisposition: "ok",
|
|
6513
|
-
lastScanAt:
|
|
6514
|
-
firstScanAt:
|
|
6639
|
+
lastScanAt: iso2,
|
|
6640
|
+
firstScanAt: iso2,
|
|
6515
6641
|
transcriptRelPath: args.transcriptRelPath
|
|
6516
6642
|
};
|
|
6517
6643
|
}
|
|
@@ -6567,7 +6693,7 @@ function chunk(items, size) {
|
|
|
6567
6693
|
}
|
|
6568
6694
|
function endOfFile(absPath) {
|
|
6569
6695
|
try {
|
|
6570
|
-
return { byteOffset:
|
|
6696
|
+
return { byteOffset: statSync6(absPath).size, lineOffset: 0 };
|
|
6571
6697
|
} catch {
|
|
6572
6698
|
return null;
|
|
6573
6699
|
}
|
|
@@ -6758,7 +6884,7 @@ async function maybeScanToolCalls(args) {
|
|
|
6758
6884
|
log2(`[tool-call-audit] ${codeName}: no path-hash salt available \u2014 file targets withheld`);
|
|
6759
6885
|
}
|
|
6760
6886
|
const home = args.homeDir ?? (process.env["HOME"]?.trim() || homedir11());
|
|
6761
|
-
const projectsRoot = args.projectsRoot ??
|
|
6887
|
+
const projectsRoot = args.projectsRoot ?? join25(home, ".claude", "projects");
|
|
6762
6888
|
const transcriptDir = args.transcriptDir ?? sessionTranscriptDir(getProjectDir(codeName));
|
|
6763
6889
|
const current = peekCurrentSession(codeName);
|
|
6764
6890
|
const sessionIds = current ? [current.sessionId] : [];
|
|
@@ -6789,9 +6915,9 @@ async function maybeScanToolCalls(args) {
|
|
|
6789
6915
|
// src/lib/activity-cache-monitor.ts
|
|
6790
6916
|
import { existsSync as existsSync6, readFileSync as readFileSync18 } from "fs";
|
|
6791
6917
|
import { homedir as homedir12 } from "os";
|
|
6792
|
-
import { join as
|
|
6918
|
+
import { join as join26 } from "path";
|
|
6793
6919
|
var MIN_CHECK_INTERVAL_MS8 = 6e4;
|
|
6794
|
-
var STATS_CACHE_PATH =
|
|
6920
|
+
var STATS_CACHE_PATH = join26(homedir12(), ".claude", "stats-cache.json");
|
|
6795
6921
|
var ISO_DATE_RE = /^\d{4}-\d{2}-\d{2}$/;
|
|
6796
6922
|
var state8 = { lastObservedDate: null, lastCheckedAt: 0 };
|
|
6797
6923
|
function selectNewDailyRows(raw, lastObservedDate) {
|
|
@@ -7082,11 +7208,11 @@ function bundleFingerprint(files) {
|
|
|
7082
7208
|
}
|
|
7083
7209
|
|
|
7084
7210
|
// src/lib/self-update-device-state-hold.ts
|
|
7085
|
-
import { statSync as
|
|
7211
|
+
import { statSync as statSync7 } from "fs";
|
|
7086
7212
|
import { platform as osPlatform } from "os";
|
|
7087
7213
|
function realStat(path) {
|
|
7088
7214
|
try {
|
|
7089
|
-
return { isFile:
|
|
7215
|
+
return { isFile: statSync7(path).isFile() };
|
|
7090
7216
|
} catch (err) {
|
|
7091
7217
|
return { errno: err?.code ?? "UNKNOWN" };
|
|
7092
7218
|
}
|
|
@@ -7162,14 +7288,14 @@ import {
|
|
|
7162
7288
|
existsSync as existsSync7,
|
|
7163
7289
|
mkdirSync as mkdirSync7,
|
|
7164
7290
|
readFileSync as readFileSync19,
|
|
7165
|
-
readdirSync as
|
|
7291
|
+
readdirSync as readdirSync7,
|
|
7166
7292
|
renameSync as renameSync5,
|
|
7167
7293
|
rmSync as rmSync3,
|
|
7168
|
-
statSync as
|
|
7294
|
+
statSync as statSync8,
|
|
7169
7295
|
utimesSync,
|
|
7170
7296
|
writeFileSync as writeFileSync8
|
|
7171
7297
|
} from "fs";
|
|
7172
|
-
import { join as
|
|
7298
|
+
import { join as join27 } from "path";
|
|
7173
7299
|
var KNOWLEDGE_FETCH_CHUNK = 100;
|
|
7174
7300
|
var CACHE_TTL_MS = 30 * 24 * 60 * 60 * 1e3;
|
|
7175
7301
|
var SWEEP_INTERVAL_MS = 24 * 60 * 60 * 1e3;
|
|
@@ -7178,7 +7304,7 @@ function knowledgeHash(content) {
|
|
|
7178
7304
|
return createHash9("sha256").update(content, "utf8").digest("hex");
|
|
7179
7305
|
}
|
|
7180
7306
|
function cachePath(cacheDir, hash) {
|
|
7181
|
-
return
|
|
7307
|
+
return join27(cacheDir, hash);
|
|
7182
7308
|
}
|
|
7183
7309
|
function readCachedKnowledge(cacheDir, hash) {
|
|
7184
7310
|
const path = cachePath(cacheDir, hash);
|
|
@@ -7211,10 +7337,10 @@ function sweepKnowledgeCache(cacheDir, now = Date.now()) {
|
|
|
7211
7337
|
lastSweepAt = now;
|
|
7212
7338
|
try {
|
|
7213
7339
|
if (!existsSync7(cacheDir)) return;
|
|
7214
|
-
for (const name of
|
|
7215
|
-
const path =
|
|
7340
|
+
for (const name of readdirSync7(cacheDir)) {
|
|
7341
|
+
const path = join27(cacheDir, name);
|
|
7216
7342
|
try {
|
|
7217
|
-
if (now -
|
|
7343
|
+
if (now - statSync8(path).mtimeMs > CACHE_TTL_MS) rmSync3(path, { force: true });
|
|
7218
7344
|
} catch {
|
|
7219
7345
|
}
|
|
7220
7346
|
}
|
|
@@ -7265,14 +7391,14 @@ import {
|
|
|
7265
7391
|
existsSync as existsSync8,
|
|
7266
7392
|
mkdirSync as mkdirSync8,
|
|
7267
7393
|
readFileSync as readFileSync20,
|
|
7268
|
-
readdirSync as
|
|
7394
|
+
readdirSync as readdirSync8,
|
|
7269
7395
|
renameSync as renameSync6,
|
|
7270
7396
|
rmSync as rmSync4,
|
|
7271
|
-
statSync as
|
|
7397
|
+
statSync as statSync9,
|
|
7272
7398
|
utimesSync as utimesSync2,
|
|
7273
7399
|
writeFileSync as writeFileSync9
|
|
7274
7400
|
} from "fs";
|
|
7275
|
-
import { join as
|
|
7401
|
+
import { join as join28 } from "path";
|
|
7276
7402
|
var MEMORY_FETCH_CHUNK = 100;
|
|
7277
7403
|
var CACHE_TTL_MS2 = 30 * 24 * 60 * 60 * 1e3;
|
|
7278
7404
|
var SWEEP_INTERVAL_MS2 = 24 * 60 * 60 * 1e3;
|
|
@@ -7281,7 +7407,7 @@ function memoryHash(content) {
|
|
|
7281
7407
|
return createHash10("sha256").update(content, "utf8").digest("hex");
|
|
7282
7408
|
}
|
|
7283
7409
|
function cachePath2(cacheDir, hash) {
|
|
7284
|
-
return
|
|
7410
|
+
return join28(cacheDir, hash);
|
|
7285
7411
|
}
|
|
7286
7412
|
function readCachedMemory(cacheDir, hash) {
|
|
7287
7413
|
const path = cachePath2(cacheDir, hash);
|
|
@@ -7314,10 +7440,10 @@ function sweepMemoryCache(cacheDir, now = Date.now()) {
|
|
|
7314
7440
|
lastSweepAt2.set(cacheDir, now);
|
|
7315
7441
|
try {
|
|
7316
7442
|
if (!existsSync8(cacheDir)) return;
|
|
7317
|
-
for (const name of
|
|
7318
|
-
const path =
|
|
7443
|
+
for (const name of readdirSync8(cacheDir)) {
|
|
7444
|
+
const path = join28(cacheDir, name);
|
|
7319
7445
|
try {
|
|
7320
|
-
if (now -
|
|
7446
|
+
if (now - statSync9(path).mtimeMs > CACHE_TTL_MS2) rmSync4(path, { force: true });
|
|
7321
7447
|
} catch {
|
|
7322
7448
|
}
|
|
7323
7449
|
}
|
|
@@ -7374,14 +7500,14 @@ import {
|
|
|
7374
7500
|
existsSync as existsSync9,
|
|
7375
7501
|
mkdirSync as mkdirSync9,
|
|
7376
7502
|
readFileSync as readFileSync21,
|
|
7377
|
-
readdirSync as
|
|
7503
|
+
readdirSync as readdirSync9,
|
|
7378
7504
|
renameSync as renameSync7,
|
|
7379
7505
|
rmSync as rmSync5,
|
|
7380
|
-
statSync as
|
|
7506
|
+
statSync as statSync10,
|
|
7381
7507
|
utimesSync as utimesSync3,
|
|
7382
7508
|
writeFileSync as writeFileSync10
|
|
7383
7509
|
} from "fs";
|
|
7384
|
-
import { join as
|
|
7510
|
+
import { join as join29 } from "path";
|
|
7385
7511
|
var SKILL_FETCH_CHUNK = 100;
|
|
7386
7512
|
var CACHE_TTL_MS3 = 30 * 24 * 60 * 60 * 1e3;
|
|
7387
7513
|
var SWEEP_INTERVAL_MS3 = 24 * 60 * 60 * 1e3;
|
|
@@ -7390,7 +7516,7 @@ function skillHash(content) {
|
|
|
7390
7516
|
return createHash11("sha256").update(content, "utf8").digest("hex");
|
|
7391
7517
|
}
|
|
7392
7518
|
function cachePath3(cacheDir, hash) {
|
|
7393
|
-
return
|
|
7519
|
+
return join29(cacheDir, hash);
|
|
7394
7520
|
}
|
|
7395
7521
|
function readCachedSkill(cacheDir, hash) {
|
|
7396
7522
|
const path = cachePath3(cacheDir, hash);
|
|
@@ -7423,10 +7549,10 @@ function sweepSkillCache(cacheDir, now = Date.now()) {
|
|
|
7423
7549
|
lastSweepAt3 = now;
|
|
7424
7550
|
try {
|
|
7425
7551
|
if (!existsSync9(cacheDir)) return;
|
|
7426
|
-
for (const name of
|
|
7427
|
-
const path =
|
|
7552
|
+
for (const name of readdirSync9(cacheDir)) {
|
|
7553
|
+
const path = join29(cacheDir, name);
|
|
7428
7554
|
try {
|
|
7429
|
-
if (now -
|
|
7555
|
+
if (now - statSync10(path).mtimeMs > CACHE_TTL_MS3) rmSync5(path, { force: true });
|
|
7430
7556
|
} catch {
|
|
7431
7557
|
}
|
|
7432
7558
|
}
|
|
@@ -7754,10 +7880,10 @@ function resolveConditionalResponse(wire, hasCachedBody) {
|
|
|
7754
7880
|
|
|
7755
7881
|
// src/lib/channel-hash-cache.ts
|
|
7756
7882
|
import { existsSync as existsSync10, readFileSync as readFileSync22, writeFileSync as writeFileSync11 } from "fs";
|
|
7757
|
-
import { join as
|
|
7883
|
+
import { join as join30 } from "path";
|
|
7758
7884
|
var CACHE_FILENAME = "channel-hash-cache.json";
|
|
7759
7885
|
function getChannelHashCacheFile(configDir) {
|
|
7760
|
-
return
|
|
7886
|
+
return join30(configDir, CACHE_FILENAME);
|
|
7761
7887
|
}
|
|
7762
7888
|
function loadChannelHashCache(target, configDir) {
|
|
7763
7889
|
const path = getChannelHashCacheFile(configDir);
|
|
@@ -7785,7 +7911,7 @@ function saveChannelHashCache(source, configDir) {
|
|
|
7785
7911
|
|
|
7786
7912
|
// src/lib/sender-policy-baseline.ts
|
|
7787
7913
|
import { existsSync as existsSync11, readFileSync as readFileSync23 } from "fs";
|
|
7788
|
-
import { join as
|
|
7914
|
+
import { join as join31 } from "path";
|
|
7789
7915
|
var BASELINE_FILENAME = "sender-policy-baseline.json";
|
|
7790
7916
|
var SENDER_POLICY_BASELINE_VERSION = 1;
|
|
7791
7917
|
var BASELINE_CONCERNS = [
|
|
@@ -7832,7 +7958,7 @@ function createDeliveryBaselineMaps() {
|
|
|
7832
7958
|
};
|
|
7833
7959
|
}
|
|
7834
7960
|
function getSenderPolicyBaselineFile(configDir) {
|
|
7835
|
-
return
|
|
7961
|
+
return join31(configDir, BASELINE_FILENAME);
|
|
7836
7962
|
}
|
|
7837
7963
|
function loadSenderPolicyBaseline(target, configDir, log2) {
|
|
7838
7964
|
const path = getSenderPolicyBaselineFile(configDir);
|
|
@@ -7889,7 +8015,7 @@ function saveSenderPolicyBaseline(source, configDir, log2) {
|
|
|
7889
8015
|
|
|
7890
8016
|
// src/lib/stuck-streak-store.ts
|
|
7891
8017
|
import { existsSync as existsSync12, readFileSync as readFileSync24 } from "fs";
|
|
7892
|
-
import { join as
|
|
8018
|
+
import { join as join32 } from "path";
|
|
7893
8019
|
var STORE_FILENAME = "stuck-streaks.json";
|
|
7894
8020
|
var STUCK_STREAK_STORE_VERSION = 1;
|
|
7895
8021
|
var STUCK_STREAK_CONCERNS = ["channelSync", "realtimeRebind"];
|
|
@@ -7897,7 +8023,7 @@ function createStuckStreakMaps() {
|
|
|
7897
8023
|
return { channelSync: /* @__PURE__ */ new Map(), realtimeRebind: /* @__PURE__ */ new Map() };
|
|
7898
8024
|
}
|
|
7899
8025
|
function getStuckStreakStoreFile(configDir) {
|
|
7900
|
-
return
|
|
8026
|
+
return join32(configDir, STORE_FILENAME);
|
|
7901
8027
|
}
|
|
7902
8028
|
function isValidPersistedStreak(value) {
|
|
7903
8029
|
if (!value || typeof value !== "object" || Array.isArray(value)) return false;
|
|
@@ -7982,13 +8108,13 @@ function pruneStuckStreaksToAgents(maps, activeAgentIds) {
|
|
|
7982
8108
|
}
|
|
7983
8109
|
|
|
7984
8110
|
// src/lib/claude-device-state.ts
|
|
7985
|
-
import { readFileSync as readFileSync25, statSync as
|
|
8111
|
+
import { readFileSync as readFileSync25, statSync as statSync11 } from "fs";
|
|
7986
8112
|
function claudeDeviceStatePath(env = process.env) {
|
|
7987
8113
|
return effectiveClaudeJsonPath(void 0, env);
|
|
7988
8114
|
}
|
|
7989
8115
|
function probeClaudeDeviceStatePresence(path = claudeDeviceStatePath()) {
|
|
7990
8116
|
try {
|
|
7991
|
-
return
|
|
8117
|
+
return statSync11(path).isFile() ? { present: true } : { present: false, reason: "not-a-file" };
|
|
7992
8118
|
} catch (err) {
|
|
7993
8119
|
return {
|
|
7994
8120
|
present: false,
|
|
@@ -7998,7 +8124,7 @@ function probeClaudeDeviceStatePresence(path = claudeDeviceStatePath()) {
|
|
|
7998
8124
|
}
|
|
7999
8125
|
function checkClaudeDeviceState(path = claudeDeviceStatePath()) {
|
|
8000
8126
|
try {
|
|
8001
|
-
if (!
|
|
8127
|
+
if (!statSync11(path).isFile()) return { usable: false, reason: "not-a-file" };
|
|
8002
8128
|
} catch (err) {
|
|
8003
8129
|
return {
|
|
8004
8130
|
usable: false,
|
|
@@ -8685,32 +8811,32 @@ function planGlobalSkillSync(globalSkills, prevIds, hashOf, knownHash, options)
|
|
|
8685
8811
|
}
|
|
8686
8812
|
|
|
8687
8813
|
// src/lib/manager/integration-skill-cache.ts
|
|
8688
|
-
import { join as
|
|
8814
|
+
import { join as join33 } from "path";
|
|
8689
8815
|
function integrationSkillHashKey(agentId, skillId) {
|
|
8690
8816
|
return `plugin-skill:${agentId}:${skillId}`;
|
|
8691
8817
|
}
|
|
8692
|
-
function shouldWriteIntegrationSkill(
|
|
8693
|
-
return
|
|
8818
|
+
function shouldWriteIntegrationSkill(cache3, agentId, skillId, contentHash) {
|
|
8819
|
+
return cache3.get(integrationSkillHashKey(agentId, skillId)) !== contentHash;
|
|
8694
8820
|
}
|
|
8695
|
-
function rememberIntegrationSkill(
|
|
8696
|
-
|
|
8821
|
+
function rememberIntegrationSkill(cache3, agentId, skillId, contentHash) {
|
|
8822
|
+
cache3.set(integrationSkillHashKey(agentId, skillId), contentHash);
|
|
8697
8823
|
}
|
|
8698
|
-
function forgetIntegrationSkill(
|
|
8699
|
-
|
|
8824
|
+
function forgetIntegrationSkill(cache3, agentId, skillId) {
|
|
8825
|
+
cache3.delete(integrationSkillHashKey(agentId, skillId));
|
|
8700
8826
|
}
|
|
8701
8827
|
function removeIntegrationSkillFolder(opts) {
|
|
8702
8828
|
forgetIntegrationSkill(opts.cache, opts.agentId, opts.entry);
|
|
8703
8829
|
for (const dir of opts.dirs) {
|
|
8704
|
-
opts.removeDir(
|
|
8830
|
+
opts.removeDir(join33(dir, opts.entry));
|
|
8705
8831
|
}
|
|
8706
8832
|
}
|
|
8707
8833
|
|
|
8708
8834
|
// src/lib/manager/managed-skill-manifest.ts
|
|
8709
8835
|
import { existsSync as existsSync13, mkdirSync as mkdirSync10, readFileSync as readFileSync26, writeFileSync as writeFileSync12 } from "fs";
|
|
8710
|
-
import { dirname as dirname8, join as
|
|
8836
|
+
import { dirname as dirname8, join as join34 } from "path";
|
|
8711
8837
|
var MANIFEST_VERSION = 1;
|
|
8712
8838
|
function managedSkillManifestPath(agentRootDir) {
|
|
8713
|
-
return
|
|
8839
|
+
return join34(agentRootDir, "managed-skills.json");
|
|
8714
8840
|
}
|
|
8715
8841
|
function readManagedSkillManifest(path) {
|
|
8716
8842
|
try {
|
|
@@ -8845,7 +8971,7 @@ function resolveModelChain(refreshData) {
|
|
|
8845
8971
|
|
|
8846
8972
|
// src/lib/manager/claude-auth.ts
|
|
8847
8973
|
import { chmodSync as chmodSync2, existsSync as existsSync14, lstatSync as lstatSync3, mkdirSync as mkdirSync11, rmSync as rmSync6 } from "fs";
|
|
8848
|
-
import { join as
|
|
8974
|
+
import { join as join35 } from "path";
|
|
8849
8975
|
import { homedir as homedir13 } from "os";
|
|
8850
8976
|
async function applyClaudeAuthToEnv(childEnv, label, options = {}) {
|
|
8851
8977
|
const apiKey = getApiKey();
|
|
@@ -8864,7 +8990,7 @@ async function applyClaudeAuthToEnv(childEnv, label, options = {}) {
|
|
|
8864
8990
|
}
|
|
8865
8991
|
const claudeDir = claudeConfigDirForChild(childEnv);
|
|
8866
8992
|
for (const filename of [".credentials.json", "credentials.json"]) {
|
|
8867
|
-
const p =
|
|
8993
|
+
const p = join35(claudeDir, filename);
|
|
8868
8994
|
if (existsSync14(p)) {
|
|
8869
8995
|
try {
|
|
8870
8996
|
rmSync6(p, { force: true });
|
|
@@ -8879,7 +9005,7 @@ async function applyClaudeAuthToEnv(childEnv, label, options = {}) {
|
|
|
8879
9005
|
return { isolated: false };
|
|
8880
9006
|
}
|
|
8881
9007
|
function claudeConfigDirForChild(childEnv) {
|
|
8882
|
-
return childEnv.CLAUDE_CONFIG_DIR?.trim() ||
|
|
9008
|
+
return childEnv.CLAUDE_CONFIG_DIR?.trim() || join35(homedir13(), ".claude");
|
|
8883
9009
|
}
|
|
8884
9010
|
function ensurePrivateConfigDir(dir, platform4 = process.platform, chmod = chmodSync2) {
|
|
8885
9011
|
mkdirSync11(dir, { recursive: true, mode: 448 });
|
|
@@ -8895,7 +9021,7 @@ function ensurePrivateConfigDir(dir, platform4 = process.platform, chmod = chmod
|
|
|
8895
9021
|
}
|
|
8896
9022
|
}
|
|
8897
9023
|
function oneShotIsolatedConfigDir() {
|
|
8898
|
-
return
|
|
9024
|
+
return join35(homedir13(), ".augmented", "claude-oneshot");
|
|
8899
9025
|
}
|
|
8900
9026
|
|
|
8901
9027
|
// src/lib/claude-runtime-auth-probe.ts
|
|
@@ -9241,11 +9367,11 @@ function formatBoardForPrompt(items, template) {
|
|
|
9241
9367
|
|
|
9242
9368
|
// src/lib/manager/kanban/nudge-state-cache.ts
|
|
9243
9369
|
import { existsSync as existsSync15, readFileSync as readFileSync27, writeFileSync as writeFileSync13 } from "fs";
|
|
9244
|
-
import { join as
|
|
9370
|
+
import { join as join36 } from "path";
|
|
9245
9371
|
var CACHE_FILENAME2 = "kanban-nudge-state.json";
|
|
9246
9372
|
var KANBAN_NUDGE_STATE_VERSION = 1;
|
|
9247
9373
|
function getKanbanNudgeStateFile(configDir) {
|
|
9248
|
-
return
|
|
9374
|
+
return join36(configDir, CACHE_FILENAME2);
|
|
9249
9375
|
}
|
|
9250
9376
|
function loadKanbanNudgeState(target, configDir) {
|
|
9251
9377
|
const path = getKanbanNudgeStateFile(configDir);
|
|
@@ -9872,7 +9998,7 @@ function closeSessionRunForCode(codeName, outcome, reason) {
|
|
|
9872
9998
|
import { createHash as createHash15 } from "crypto";
|
|
9873
9999
|
import { writeFileSync as writeFileSync14, renameSync as renameSync8, mkdirSync as mkdirSync12, readFileSync as readFileSync28, unlinkSync as unlinkSync3 } from "fs";
|
|
9874
10000
|
import { homedir as homedir14 } from "os";
|
|
9875
|
-
import { join as
|
|
10001
|
+
import { join as join37, dirname as dirname9 } from "path";
|
|
9876
10002
|
|
|
9877
10003
|
// src/lib/manager/scheduler/notify.ts
|
|
9878
10004
|
import { createHash as createHash14 } from "crypto";
|
|
@@ -10231,7 +10357,7 @@ function resolveScheduledSlackTarget(task) {
|
|
|
10231
10357
|
}
|
|
10232
10358
|
function stampScheduledTurnMarker(codeName, taskId, target) {
|
|
10233
10359
|
try {
|
|
10234
|
-
const file =
|
|
10360
|
+
const file = join37(homedir14(), ".augmented", codeName, SCHEDULED_TURN_MARKER_FILENAME);
|
|
10235
10361
|
const marker = { ts: Date.now(), task_id: taskId, ...target ? { target } : {} };
|
|
10236
10362
|
const tmp = `${file}.tmp`;
|
|
10237
10363
|
writeFileSync14(tmp, JSON.stringify(marker), "utf8");
|
|
@@ -10241,7 +10367,7 @@ function stampScheduledTurnMarker(codeName, taskId, target) {
|
|
|
10241
10367
|
}
|
|
10242
10368
|
}
|
|
10243
10369
|
function clearScheduledTurnMarkerForTask(codeName, taskId) {
|
|
10244
|
-
const file =
|
|
10370
|
+
const file = join37(homedir14(), ".augmented", codeName, SCHEDULED_TURN_MARKER_FILENAME);
|
|
10245
10371
|
try {
|
|
10246
10372
|
const raw = JSON.parse(readFileSync28(file, "utf8"));
|
|
10247
10373
|
if (typeof raw?.task_id !== "string" || raw.task_id !== taskId) return;
|
|
@@ -10463,11 +10589,11 @@ async function processClaudeTaskResult(codeName, agentId, templateId, rawOutput,
|
|
|
10463
10589
|
// src/lib/manager/scheduler/execution.ts
|
|
10464
10590
|
import { createHash as createHash16 } from "crypto";
|
|
10465
10591
|
import { homedir as homedir15 } from "os";
|
|
10466
|
-
import { join as
|
|
10592
|
+
import { join as join39 } from "path";
|
|
10467
10593
|
|
|
10468
10594
|
// src/lib/agent-serving-probe.ts
|
|
10469
|
-
import { readFileSync as readFileSync29, readdirSync as
|
|
10470
|
-
import { join as
|
|
10595
|
+
import { readFileSync as readFileSync29, readdirSync as readdirSync10, statSync as statSync12 } from "fs";
|
|
10596
|
+
import { join as join38 } from "path";
|
|
10471
10597
|
var RATE_LIMIT_WINDOW_MS = 6 * 60 * 60 * 1e3;
|
|
10472
10598
|
function probeRateLimit(args) {
|
|
10473
10599
|
const now = args.now ?? /* @__PURE__ */ new Date();
|
|
@@ -10476,16 +10602,16 @@ function probeRateLimit(args) {
|
|
|
10476
10602
|
const dir = args.transcriptDir ?? sessionTranscriptDir(args.projectDir);
|
|
10477
10603
|
let entries;
|
|
10478
10604
|
try {
|
|
10479
|
-
entries =
|
|
10605
|
+
entries = readdirSync10(dir);
|
|
10480
10606
|
} catch {
|
|
10481
10607
|
return UNKNOWN_RATE_LIMIT;
|
|
10482
10608
|
}
|
|
10483
10609
|
let newest = UNKNOWN_RATE_LIMIT;
|
|
10484
10610
|
for (const name of entries) {
|
|
10485
10611
|
if (!name.endsWith(".jsonl")) continue;
|
|
10486
|
-
const path =
|
|
10612
|
+
const path = join38(dir, name);
|
|
10487
10613
|
try {
|
|
10488
|
-
const st =
|
|
10614
|
+
const st = statSync12(path);
|
|
10489
10615
|
if (!st.isFile() || st.mtimeMs < startMs) continue;
|
|
10490
10616
|
} catch {
|
|
10491
10617
|
continue;
|
|
@@ -10554,7 +10680,7 @@ function shouldLogUsageCapDeferral(site, codeName, limitedUntil) {
|
|
|
10554
10680
|
|
|
10555
10681
|
// src/lib/manager/scheduler/execution.ts
|
|
10556
10682
|
function claudePidFilePath() {
|
|
10557
|
-
return
|
|
10683
|
+
return join39(homedir15(), ".augmented", "manager-claude-pids.json");
|
|
10558
10684
|
}
|
|
10559
10685
|
var inFlightClaudePids = /* @__PURE__ */ new Map();
|
|
10560
10686
|
function registerClaudeSpawn(record) {
|
|
@@ -10795,8 +10921,8 @@ var BlockedPromptReportCadence = class {
|
|
|
10795
10921
|
};
|
|
10796
10922
|
|
|
10797
10923
|
// src/lib/occupancy-gate.ts
|
|
10798
|
-
import { closeSync as closeSync3, openSync as openSync3, readdirSync as
|
|
10799
|
-
import { join as
|
|
10924
|
+
import { closeSync as closeSync3, openSync as openSync3, readdirSync as readdirSync11, readSync as readSync3, statSync as statSync13 } from "fs";
|
|
10925
|
+
import { join as join40 } from "path";
|
|
10800
10926
|
function rostersMeasuredZero(mode, attested, runtimeRunning) {
|
|
10801
10927
|
return mode === "enforce" && attested && runtimeRunning;
|
|
10802
10928
|
}
|
|
@@ -10805,12 +10931,12 @@ var MAX_RECORD_ALIGN_BYTES = 8 * 1024 * 1024;
|
|
|
10805
10931
|
var GATE_MAX_BUCKET_AGE_MS = 30 * 6e4;
|
|
10806
10932
|
var MAX_BRACKET_DEFERRAL_MS = 25 * 6e4;
|
|
10807
10933
|
var TRANSCRIPT_MTIME_WINDOW_MS4 = GATE_MAX_BUCKET_AGE_MS + DEFAULT_NEIGHBOURHOOD_MS + 6e4;
|
|
10808
|
-
var
|
|
10934
|
+
var cache2 = /* @__PURE__ */ new Map();
|
|
10809
10935
|
var brackets = /* @__PURE__ */ new Map();
|
|
10810
10936
|
function readAlignedTail(path, tailBytes, maxAlignBytes) {
|
|
10811
10937
|
let fd = null;
|
|
10812
10938
|
try {
|
|
10813
|
-
const size =
|
|
10939
|
+
const size = statSync13(path).size;
|
|
10814
10940
|
if (size <= 0) return { content: "", complete: true, truncated: false };
|
|
10815
10941
|
fd = openSync3(path, "r");
|
|
10816
10942
|
let readStart = Math.max(0, size - tailBytes);
|
|
@@ -10880,26 +11006,26 @@ function candidateTranscriptPaths(dir) {
|
|
|
10880
11006
|
const paths = [];
|
|
10881
11007
|
let top;
|
|
10882
11008
|
try {
|
|
10883
|
-
top =
|
|
11009
|
+
top = readdirSync11(dir);
|
|
10884
11010
|
} catch {
|
|
10885
11011
|
return { paths, complete: false };
|
|
10886
11012
|
}
|
|
10887
11013
|
let complete = true;
|
|
10888
11014
|
for (const name of top) {
|
|
10889
11015
|
if (name.endsWith(".jsonl")) {
|
|
10890
|
-
paths.push(
|
|
11016
|
+
paths.push(join40(dir, name));
|
|
10891
11017
|
continue;
|
|
10892
11018
|
}
|
|
10893
|
-
const subDir =
|
|
11019
|
+
const subDir = join40(dir, name, "subagents");
|
|
10894
11020
|
let subs;
|
|
10895
11021
|
try {
|
|
10896
|
-
subs =
|
|
11022
|
+
subs = readdirSync11(subDir);
|
|
10897
11023
|
} catch (err) {
|
|
10898
11024
|
if (!isAbsentDirError(err)) complete = false;
|
|
10899
11025
|
continue;
|
|
10900
11026
|
}
|
|
10901
11027
|
for (const sub of subs) {
|
|
10902
|
-
if (sub.endsWith(".jsonl")) paths.push(
|
|
11028
|
+
if (sub.endsWith(".jsonl")) paths.push(join40(subDir, sub));
|
|
10903
11029
|
}
|
|
10904
11030
|
}
|
|
10905
11031
|
return { paths, complete };
|
|
@@ -10940,7 +11066,7 @@ function collectQualifyingTurns(codeName, nowMs, opts = {}) {
|
|
|
10940
11066
|
const tailBytes = opts.tailBytes ?? TAIL_BYTES;
|
|
10941
11067
|
const maxAlignBytes = opts.maxAlignBytes ?? MAX_RECORD_ALIGN_BYTES;
|
|
10942
11068
|
const sinceMs = nowMs - TRANSCRIPT_MTIME_WINDOW_MS4;
|
|
10943
|
-
const agentCache =
|
|
11069
|
+
const agentCache = cache2.get(codeName) ?? /* @__PURE__ */ new Map();
|
|
10944
11070
|
const nextCache = /* @__PURE__ */ new Map();
|
|
10945
11071
|
const all = /* @__PURE__ */ new Set();
|
|
10946
11072
|
const eventsByPath = /* @__PURE__ */ new Map();
|
|
@@ -10954,7 +11080,7 @@ function collectQualifyingTurns(codeName, nowMs, opts = {}) {
|
|
|
10954
11080
|
for (const path of paths) {
|
|
10955
11081
|
let st;
|
|
10956
11082
|
try {
|
|
10957
|
-
st =
|
|
11083
|
+
st = statSync13(path);
|
|
10958
11084
|
} catch (err) {
|
|
10959
11085
|
if (!isAbsentDirError(err)) complete = false;
|
|
10960
11086
|
continue;
|
|
@@ -10993,7 +11119,7 @@ function collectQualifyingTurns(codeName, nowMs, opts = {}) {
|
|
|
10993
11119
|
}
|
|
10994
11120
|
for (const t of turns) all.add(t);
|
|
10995
11121
|
}
|
|
10996
|
-
|
|
11122
|
+
cache2.set(codeName, nextCache);
|
|
10997
11123
|
const { toolCallBrackets, openToolCalls } = foldToolCallBrackets(codeName, eventsByPath, nowMs);
|
|
10998
11124
|
return {
|
|
10999
11125
|
turns: [...all].sort((a, b) => a - b),
|
|
@@ -11060,7 +11186,7 @@ function qualifyBuckets(buckets, qualifying, mode, nowMs, neighbourhoodMs = DEFA
|
|
|
11060
11186
|
}
|
|
11061
11187
|
|
|
11062
11188
|
// src/lib/pane-occupancy-sampler.ts
|
|
11063
|
-
import { statSync as
|
|
11189
|
+
import { statSync as statSync14 } from "fs";
|
|
11064
11190
|
var SAMPLE_INTERVAL_MS = 1e4;
|
|
11065
11191
|
var IDLE_GAP_MS = 12e4;
|
|
11066
11192
|
var POST_IDLE_CREDIT_MS = 6e4;
|
|
@@ -11074,7 +11200,7 @@ function hasFreshPaneObservation(codeName, nowMs, maxAgeMs = OBSERVATION_FRESH_M
|
|
|
11074
11200
|
}
|
|
11075
11201
|
function paneMtimeMs(codeName) {
|
|
11076
11202
|
try {
|
|
11077
|
-
return
|
|
11203
|
+
return statSync14(paneLogPath(codeName)).mtimeMs;
|
|
11078
11204
|
} catch {
|
|
11079
11205
|
return null;
|
|
11080
11206
|
}
|
|
@@ -12537,7 +12663,7 @@ async function fireOpencodeScheduledTask(agent, task) {
|
|
|
12537
12663
|
import { createHash as createHash19 } from "crypto";
|
|
12538
12664
|
import { existsSync as existsSync17, mkdirSync as mkdirSync13, readFileSync as readFileSync31, renameSync as renameSync9, unlinkSync as unlinkSync4, writeFileSync as writeFileSync15 } from "fs";
|
|
12539
12665
|
import { randomUUID } from "crypto";
|
|
12540
|
-
import { join as
|
|
12666
|
+
import { join as join41 } from "path";
|
|
12541
12667
|
|
|
12542
12668
|
// src/lib/telegram-ingest.ts
|
|
12543
12669
|
import https2 from "https";
|
|
@@ -13190,7 +13316,7 @@ function createFileOffsetStore(codeName, log2, currentBotId) {
|
|
|
13190
13316
|
let filePath;
|
|
13191
13317
|
try {
|
|
13192
13318
|
dir = getFramework("opencode").getAgentDir(codeName);
|
|
13193
|
-
filePath =
|
|
13319
|
+
filePath = join41(dir, "telegram-getupdates-offset-opencode.json");
|
|
13194
13320
|
} catch {
|
|
13195
13321
|
dir = null;
|
|
13196
13322
|
filePath = null;
|
|
@@ -13474,24 +13600,24 @@ function partitionActionableByPoison(actionable, states, config2) {
|
|
|
13474
13600
|
}
|
|
13475
13601
|
|
|
13476
13602
|
// src/lib/restart-flags.ts
|
|
13477
|
-
import { existsSync as existsSync18, mkdirSync as mkdirSync14, readdirSync as
|
|
13603
|
+
import { existsSync as existsSync18, mkdirSync as mkdirSync14, readdirSync as readdirSync12, readFileSync as readFileSync32, renameSync as renameSync10, rmSync as rmSync7, writeFileSync as writeFileSync16 } from "fs";
|
|
13478
13604
|
import { homedir as homedir16 } from "os";
|
|
13479
|
-
import { join as
|
|
13605
|
+
import { join as join42 } from "path";
|
|
13480
13606
|
import { randomUUID as randomUUID2 } from "crypto";
|
|
13481
13607
|
function restartFlagsDir() {
|
|
13482
|
-
return
|
|
13608
|
+
return join42(homedir16(), ".augmented", "restart-flags");
|
|
13483
13609
|
}
|
|
13484
13610
|
function flagPath(codeName) {
|
|
13485
|
-
return
|
|
13611
|
+
return join42(restartFlagsDir(), `${codeName}.flag`);
|
|
13486
13612
|
}
|
|
13487
13613
|
function readRestartFlags() {
|
|
13488
13614
|
const dir = restartFlagsDir();
|
|
13489
13615
|
if (!existsSync18(dir)) return [];
|
|
13490
13616
|
const out = [];
|
|
13491
|
-
for (const entry of
|
|
13617
|
+
for (const entry of readdirSync12(dir)) {
|
|
13492
13618
|
if (!entry.endsWith(".flag")) continue;
|
|
13493
13619
|
try {
|
|
13494
|
-
const raw = readFileSync32(
|
|
13620
|
+
const raw = readFileSync32(join42(dir, entry), "utf8");
|
|
13495
13621
|
const parsed = JSON.parse(raw);
|
|
13496
13622
|
if (typeof parsed.codeName !== "string" || parsed.codeName.length === 0) {
|
|
13497
13623
|
parsed.codeName = entry.replace(/\.flag$/, "");
|
|
@@ -13609,8 +13735,8 @@ async function sendError(flag, opts, text) {
|
|
|
13609
13735
|
}
|
|
13610
13736
|
|
|
13611
13737
|
// src/lib/restart-context.ts
|
|
13612
|
-
import { readdirSync as
|
|
13613
|
-
import { dirname as dirname10, join as
|
|
13738
|
+
import { readdirSync as readdirSync13, readFileSync as readFileSync33, writeFileSync as writeFileSync17, mkdirSync as mkdirSync15, unlinkSync as unlinkSync5 } from "fs";
|
|
13739
|
+
import { dirname as dirname10, join as join43 } from "path";
|
|
13614
13740
|
var SLACK_PENDING_INBOUND_DIRNAME = "slack-pending-inbound";
|
|
13615
13741
|
var SLACK_RESTART_CONTEXT_DIRNAME = "slack-restart-context";
|
|
13616
13742
|
var MAX_TOPIC_CHARS = 140;
|
|
@@ -13622,10 +13748,10 @@ function augmentedAgentDir(codeName) {
|
|
|
13622
13748
|
return dirname10(getProjectDir(codeName));
|
|
13623
13749
|
}
|
|
13624
13750
|
function slackPendingInboundDir(codeName) {
|
|
13625
|
-
return
|
|
13751
|
+
return join43(augmentedAgentDir(codeName), SLACK_PENDING_INBOUND_DIRNAME);
|
|
13626
13752
|
}
|
|
13627
13753
|
function slackRestartContextDir(codeName) {
|
|
13628
|
-
return
|
|
13754
|
+
return join43(augmentedAgentDir(codeName), SLACK_RESTART_CONTEXT_DIRNAME);
|
|
13629
13755
|
}
|
|
13630
13756
|
function sanitizeTopic(raw) {
|
|
13631
13757
|
const cleaned = raw.replace(/\s+/g, " ").trim().replace(/[<>]/g, " ").replace(/\s+/g, " ").trim();
|
|
@@ -13660,7 +13786,7 @@ function computeRestartContextHints(markers, allTurns, nowMs, reconstruct = reco
|
|
|
13660
13786
|
}
|
|
13661
13787
|
function safeReaddir(dir) {
|
|
13662
13788
|
try {
|
|
13663
|
-
return
|
|
13789
|
+
return readdirSync13(dir);
|
|
13664
13790
|
} catch {
|
|
13665
13791
|
return [];
|
|
13666
13792
|
}
|
|
@@ -13685,7 +13811,7 @@ function pruneHintsExcept(codeName, freshFilenames) {
|
|
|
13685
13811
|
if (!filename.endsWith(".json")) continue;
|
|
13686
13812
|
if (freshFilenames.has(filename)) continue;
|
|
13687
13813
|
try {
|
|
13688
|
-
unlinkSync5(
|
|
13814
|
+
unlinkSync5(join43(ctxDir, filename));
|
|
13689
13815
|
} catch {
|
|
13690
13816
|
}
|
|
13691
13817
|
}
|
|
@@ -13706,7 +13832,7 @@ function refreshSlackRestartContextHints(codeNames, opts = {}) {
|
|
|
13706
13832
|
}
|
|
13707
13833
|
const markers = [];
|
|
13708
13834
|
for (const filename of markerFilenames.slice(0, cap)) {
|
|
13709
|
-
const parsed = readStrandedMarker(
|
|
13835
|
+
const parsed = readStrandedMarker(join43(markerDir, filename));
|
|
13710
13836
|
if (parsed) markers.push({ filename, channel: parsed.channel, thread_ts: parsed.thread_ts });
|
|
13711
13837
|
}
|
|
13712
13838
|
if (markers.length === 0) {
|
|
@@ -13720,7 +13846,7 @@ function refreshSlackRestartContextHints(codeNames, opts = {}) {
|
|
|
13720
13846
|
const freshFilenames = /* @__PURE__ */ new Set();
|
|
13721
13847
|
for (const { filename, hint } of hints) {
|
|
13722
13848
|
try {
|
|
13723
|
-
writeHintFile(
|
|
13849
|
+
writeHintFile(join43(ctxDir, filename), ctxDir, hint);
|
|
13724
13850
|
freshFilenames.add(filename);
|
|
13725
13851
|
} catch (err) {
|
|
13726
13852
|
log2(`[restart-context] ${codeName}: hint write failed for ${filename}: ${err.message}`);
|
|
@@ -14514,7 +14640,7 @@ async function runDangerousRmBackstop(agentId, codeName, pane) {
|
|
|
14514
14640
|
return;
|
|
14515
14641
|
}
|
|
14516
14642
|
const policy = readRmPolicyText(
|
|
14517
|
-
() => readFileSync34(
|
|
14643
|
+
() => readFileSync34(join44(getFramework("claude-code").getAgentDir(codeName), RM_POLICY_RELATIVE_PATH), "utf-8")
|
|
14518
14644
|
);
|
|
14519
14645
|
const decision = decideDangerousRm(action.prompt, policy, {
|
|
14520
14646
|
isolated: isolationMode(codeName) === "docker"
|
|
@@ -15235,7 +15361,7 @@ var pendingDayRolloverReset = /* @__PURE__ */ new Set();
|
|
|
15235
15361
|
var dayRolloverInboundHold = /* @__PURE__ */ new Map();
|
|
15236
15362
|
var INBOUND_HOLD_EPISODE_GAP_MS = 12e4;
|
|
15237
15363
|
async function channelInboundActivityAgeSecondsFor(codeName) {
|
|
15238
|
-
const { newestPendingInboundActivityMtimeMs } = await import("../responsiveness-probe-
|
|
15364
|
+
const { newestPendingInboundActivityMtimeMs } = await import("../responsiveness-probe-ZT6ITMYI.js");
|
|
15239
15365
|
const newest = newestPendingInboundActivityMtimeMs(dirname11(paneLogPath(codeName)));
|
|
15240
15366
|
if (newest === null) return null;
|
|
15241
15367
|
return Math.max(0, Math.floor((Date.now() - newest) / 1e3));
|
|
@@ -15432,7 +15558,7 @@ function performLazyDayRolloverReset(codeName, agentTimezone) {
|
|
|
15432
15558
|
}
|
|
15433
15559
|
function paneLogAgeSecondsFor(codeName) {
|
|
15434
15560
|
try {
|
|
15435
|
-
const mtimeMs =
|
|
15561
|
+
const mtimeMs = statSync15(paneLogPath(codeName)).mtimeMs;
|
|
15436
15562
|
return Math.max(0, Math.floor((Date.now() - mtimeMs) / 1e3));
|
|
15437
15563
|
} catch (err) {
|
|
15438
15564
|
if (err?.code === "ENOENT") return null;
|
|
@@ -15604,7 +15730,7 @@ var runningChannelSecretHashes = /* @__PURE__ */ new Map();
|
|
|
15604
15730
|
var sessionLaunchManagedStructure = /* @__PURE__ */ new Map();
|
|
15605
15731
|
function projectMcpHash(_codeName, projectDir) {
|
|
15606
15732
|
try {
|
|
15607
|
-
const raw = readFileSync34(
|
|
15733
|
+
const raw = readFileSync34(join44(projectDir, ".mcp.json"), "utf-8");
|
|
15608
15734
|
return createHash20("sha256").update(canonicalJson(JSON.parse(raw))).digest("hex");
|
|
15609
15735
|
} catch {
|
|
15610
15736
|
return null;
|
|
@@ -15612,7 +15738,7 @@ function projectMcpHash(_codeName, projectDir) {
|
|
|
15612
15738
|
}
|
|
15613
15739
|
function projectMcpKeys(_codeName, projectDir) {
|
|
15614
15740
|
try {
|
|
15615
|
-
const raw = readFileSync34(
|
|
15741
|
+
const raw = readFileSync34(join44(projectDir, ".mcp.json"), "utf-8");
|
|
15616
15742
|
const parsed = JSON.parse(raw);
|
|
15617
15743
|
const servers = parsed.mcpServers;
|
|
15618
15744
|
if (!servers || typeof servers !== "object") return /* @__PURE__ */ new Set();
|
|
@@ -15630,7 +15756,7 @@ function seedSessionLaunchBaselines(codeName, projectDir) {
|
|
|
15630
15756
|
else runningMcpServerKeys.delete(codeName);
|
|
15631
15757
|
let launchStructure = null;
|
|
15632
15758
|
try {
|
|
15633
|
-
const raw = readFileSync34(
|
|
15759
|
+
const raw = readFileSync34(join44(projectDir, ".mcp.json"), "utf-8");
|
|
15634
15760
|
launchStructure = managedMcpStructureHashFromFile(
|
|
15635
15761
|
JSON.parse(raw),
|
|
15636
15762
|
isManagedMcpServerKey
|
|
@@ -15767,7 +15893,7 @@ async function runAgentSessionToolBindProbes(agent, integrations, projectDir, op
|
|
|
15767
15893
|
if (result && result.rebindCandidates.length > 0 && hostFlagStore().getBoolean("session-tool-rebind")) {
|
|
15768
15894
|
let mcpJsonForRebind = null;
|
|
15769
15895
|
try {
|
|
15770
|
-
mcpJsonForRebind = JSON.parse(readFileSync34(
|
|
15896
|
+
mcpJsonForRebind = JSON.parse(readFileSync34(join44(projectDir, ".mcp.json"), "utf-8"));
|
|
15771
15897
|
} catch {
|
|
15772
15898
|
mcpJsonForRebind = null;
|
|
15773
15899
|
}
|
|
@@ -15916,7 +16042,7 @@ function shouldInjectChannelSecrets(agentId) {
|
|
|
15916
16042
|
function projectChannelSecretHash(projectDir) {
|
|
15917
16043
|
try {
|
|
15918
16044
|
const entries = parseEnvIntegrations(
|
|
15919
|
-
readFileSync34(
|
|
16045
|
+
readFileSync34(join44(projectDir, ".env.integrations"), "utf-8")
|
|
15920
16046
|
);
|
|
15921
16047
|
return channelSecretValueHash(entries, CHANNEL_SECRET_ENV_KEYS);
|
|
15922
16048
|
} catch {
|
|
@@ -16032,7 +16158,7 @@ var agentRestartTimezoneInputs = /* @__PURE__ */ new Map();
|
|
|
16032
16158
|
var lastVersionCheckAt = 0;
|
|
16033
16159
|
var VERSION_CHECK_INTERVAL_MS = 5 * 60 * 1e3;
|
|
16034
16160
|
var lastResponsivenessProbeAt = 0;
|
|
16035
|
-
var agtCliVersion = true ? "0.28.
|
|
16161
|
+
var agtCliVersion = true ? "0.28.1179" : "dev";
|
|
16036
16162
|
function resolveBrewPath(execFileSync3) {
|
|
16037
16163
|
try {
|
|
16038
16164
|
const out = execFileSync3("which", ["brew"], { timeout: 5e3 }).toString().trim();
|
|
@@ -16592,7 +16718,7 @@ function runAsync(cmd, args, opts) {
|
|
|
16592
16718
|
});
|
|
16593
16719
|
}
|
|
16594
16720
|
function claudeManagedSettingsPath() {
|
|
16595
|
-
return
|
|
16721
|
+
return join44(CLAUDE_MANAGED_SETTINGS_DIR, "managed-settings.json");
|
|
16596
16722
|
}
|
|
16597
16723
|
var MANAGED_SETTINGS_KEYS = ["channelsEnabled", "enableAllProjectMcpServers"];
|
|
16598
16724
|
var MANAGED_SETTINGS_ENV = { DISABLE_AUTOUPDATER: "1" };
|
|
@@ -16670,7 +16796,7 @@ async function ensureOpencodeBinary() {
|
|
|
16670
16796
|
try {
|
|
16671
16797
|
const prefix = execFileSync3("npm", ["prefix", "-g"], { encoding: "utf-8", timeout: 1e4 }).trim();
|
|
16672
16798
|
if (prefix) {
|
|
16673
|
-
const npmBin =
|
|
16799
|
+
const npmBin = join44(prefix, "bin");
|
|
16674
16800
|
const current = (process.env.PATH ?? "").split(pathDelimiter);
|
|
16675
16801
|
if (!current.includes(npmBin)) {
|
|
16676
16802
|
process.env.PATH = [npmBin, ...current.filter(Boolean)].join(pathDelimiter);
|
|
@@ -16810,7 +16936,7 @@ async function maybeUpgradeClaudeCode() {
|
|
|
16810
16936
|
}
|
|
16811
16937
|
var UPDATE_CHECK_INTERVAL_MS = 5 * 60 * 1e3;
|
|
16812
16938
|
function selfUpdateAppliedMarkerPath() {
|
|
16813
|
-
return
|
|
16939
|
+
return join44(homedir17(), ".augmented", ".last-self-update-applied");
|
|
16814
16940
|
}
|
|
16815
16941
|
var selfUpdateUpToDateLogged = false;
|
|
16816
16942
|
var selfUpdatePinnedLogged = false;
|
|
@@ -16861,7 +16987,7 @@ async function checkAndUpdateCli(opts) {
|
|
|
16861
16987
|
const isNpmGlobal = !isBrewFormula && resolvedPath.includes("node_modules");
|
|
16862
16988
|
if (!isBrewFormula && !isNpmGlobal) return "noop";
|
|
16863
16989
|
const { readFileSync: readF, writeFileSync: writeF } = await import("fs");
|
|
16864
|
-
const markerPath =
|
|
16990
|
+
const markerPath = join44(homedir17(), ".augmented", ".last-update-check");
|
|
16865
16991
|
if (!force) {
|
|
16866
16992
|
try {
|
|
16867
16993
|
const lastCheck = parseInt(readF(markerPath, "utf-8").trim(), 10);
|
|
@@ -17365,12 +17491,12 @@ async function checkClaudeAuth() {
|
|
|
17365
17491
|
var evalEmptyMcpConfigPath = null;
|
|
17366
17492
|
function ensureEvalEmptyMcpConfig() {
|
|
17367
17493
|
if (evalEmptyMcpConfigPath && existsSync19(evalEmptyMcpConfigPath)) return evalEmptyMcpConfigPath;
|
|
17368
|
-
const dir =
|
|
17494
|
+
const dir = join44(homedir17(), ".augmented");
|
|
17369
17495
|
try {
|
|
17370
17496
|
mkdirSync16(dir, { recursive: true });
|
|
17371
17497
|
} catch {
|
|
17372
17498
|
}
|
|
17373
|
-
const p =
|
|
17499
|
+
const p = join44(dir, ".eval-empty-mcp.json");
|
|
17374
17500
|
writeFileSync18(p, JSON.stringify({ mcpServers: {} }));
|
|
17375
17501
|
evalEmptyMcpConfigPath = p;
|
|
17376
17502
|
return p;
|
|
@@ -17461,10 +17587,10 @@ function resolveConversationEvalBackend() {
|
|
|
17461
17587
|
return conversationEvalBackend;
|
|
17462
17588
|
}
|
|
17463
17589
|
function getStateFile() {
|
|
17464
|
-
return
|
|
17590
|
+
return join44(config?.configDir ?? join44(process.env["HOME"] ?? "/tmp", ".augmented"), "manager-state.json");
|
|
17465
17591
|
}
|
|
17466
17592
|
function channelHashCacheDir() {
|
|
17467
|
-
return config?.configDir ??
|
|
17593
|
+
return config?.configDir ?? join44(process.env["HOME"] ?? "/tmp", ".augmented");
|
|
17468
17594
|
}
|
|
17469
17595
|
function loadChannelHashCache2() {
|
|
17470
17596
|
loadChannelHashCache(agentState.knownChannelConfigHashes, channelHashCacheDir());
|
|
@@ -17677,7 +17803,7 @@ function removeDeliveryBaselineEntries(agentId) {
|
|
|
17677
17803
|
var _channelQuarantineStore = null;
|
|
17678
17804
|
function channelQuarantineStore() {
|
|
17679
17805
|
if (!_channelQuarantineStore) {
|
|
17680
|
-
const dir = config?.configDir ??
|
|
17806
|
+
const dir = config?.configDir ?? join44(process.env["HOME"] ?? "/tmp", ".augmented");
|
|
17681
17807
|
_channelQuarantineStore = new ChannelQuarantineStore(defaultQuarantinePath(dir));
|
|
17682
17808
|
}
|
|
17683
17809
|
return _channelQuarantineStore;
|
|
@@ -17685,7 +17811,7 @@ function channelQuarantineStore() {
|
|
|
17685
17811
|
var _channelResumeHistoryStore = null;
|
|
17686
17812
|
function channelResumeHistoryStore() {
|
|
17687
17813
|
if (!_channelResumeHistoryStore) {
|
|
17688
|
-
const dir = config?.configDir ??
|
|
17814
|
+
const dir = config?.configDir ?? join44(process.env["HOME"] ?? "/tmp", ".augmented");
|
|
17689
17815
|
_channelResumeHistoryStore = new ChannelResumeHistoryStore(defaultResumeHistoryPath(dir));
|
|
17690
17816
|
}
|
|
17691
17817
|
return _channelResumeHistoryStore;
|
|
@@ -17710,14 +17836,24 @@ function claudeMdSizeFor(codeName) {
|
|
|
17710
17836
|
logClaudeMdGraftTransition(codeName, report, log);
|
|
17711
17837
|
return report;
|
|
17712
17838
|
}
|
|
17839
|
+
function sessionActivityFor(codeName, pane) {
|
|
17840
|
+
return buildSessionActivityReport({
|
|
17841
|
+
codeName,
|
|
17842
|
+
transcriptDir: sessionTranscriptDir(getProjectDir(codeName)),
|
|
17843
|
+
sessionId: getSessionState(codeName)?.currentSessionId ?? null,
|
|
17844
|
+
tmuxAlive: pane.tmuxAlive,
|
|
17845
|
+
screenCapture: pane.screenCapture,
|
|
17846
|
+
log: (msg) => console.error(msg)
|
|
17847
|
+
});
|
|
17848
|
+
}
|
|
17713
17849
|
function forwardedToolsFor(codeName) {
|
|
17714
17850
|
if (!config?.configDir) return null;
|
|
17715
|
-
return readForwardedToolsReport(
|
|
17851
|
+
return readForwardedToolsReport(join44(config.configDir, codeName));
|
|
17716
17852
|
}
|
|
17717
17853
|
var _hostFlagStore = null;
|
|
17718
17854
|
function hostFlagStore() {
|
|
17719
17855
|
if (!_hostFlagStore) {
|
|
17720
|
-
const dir = config?.configDir ??
|
|
17856
|
+
const dir = config?.configDir ?? join44(process.env["HOME"] ?? "/tmp", ".augmented");
|
|
17721
17857
|
_hostFlagStore = new HostFlagStore({ cachePath: defaultFlagsCachePath(dir), log });
|
|
17722
17858
|
}
|
|
17723
17859
|
return _hostFlagStore;
|
|
@@ -17790,13 +17926,13 @@ function parseSkillFrontmatter(content) {
|
|
|
17790
17926
|
return out;
|
|
17791
17927
|
}
|
|
17792
17928
|
async function refreshSkillsIndexInClaudeMd(configDir, codeName, log2) {
|
|
17793
|
-
const { readdirSync:
|
|
17794
|
-
const skillsDir =
|
|
17795
|
-
const claudeMdPath =
|
|
17929
|
+
const { readdirSync: readdirSync15, readFileSync: rfs, existsSync: ex, writeFileSync: writeFileSync19 } = await import("fs");
|
|
17930
|
+
const skillsDir = join44(configDir, codeName, "project", ".claude", "skills");
|
|
17931
|
+
const claudeMdPath = join44(configDir, codeName, "project", "CLAUDE.md");
|
|
17796
17932
|
if (!ex(skillsDir) || !ex(claudeMdPath)) return;
|
|
17797
17933
|
const entries = [];
|
|
17798
|
-
for (const dir of
|
|
17799
|
-
const skillFile =
|
|
17934
|
+
for (const dir of readdirSync15(skillsDir).sort()) {
|
|
17935
|
+
const skillFile = join44(skillsDir, dir, "SKILL.md");
|
|
17800
17936
|
if (!ex(skillFile)) continue;
|
|
17801
17937
|
try {
|
|
17802
17938
|
const { name, description } = parseSkillFrontmatter(rfs(skillFile, "utf-8"));
|
|
@@ -17920,10 +18056,10 @@ function flushRestartedAgentDiagnostics(hostId, codeNames) {
|
|
|
17920
18056
|
if (codeNames.length === 0) return;
|
|
17921
18057
|
void (async () => {
|
|
17922
18058
|
try {
|
|
17923
|
-
const { collectDiagnostics } = await import("../persistent-session-
|
|
18059
|
+
const { collectDiagnostics } = await import("../persistent-session-34QXCPJK.js");
|
|
17924
18060
|
await api.post("/host/heartbeat", {
|
|
17925
18061
|
host_id: hostId,
|
|
17926
|
-
agent_diagnostics: collectDiagnostics(codeNames, quarantineEntriesFor, claudeMdSizeFor, spawnOutcomeForDiagnostics, pidPressureFor, forwardedToolsFor, runtimeVersionFor)
|
|
18062
|
+
agent_diagnostics: collectDiagnostics(codeNames, quarantineEntriesFor, claudeMdSizeFor, spawnOutcomeForDiagnostics, pidPressureFor, forwardedToolsFor, runtimeVersionFor, sessionActivityFor)
|
|
17927
18063
|
});
|
|
17928
18064
|
} catch (err) {
|
|
17929
18065
|
log(`[restart] post-respawn diagnostics flush failed: ${err.message}`);
|
|
@@ -18063,9 +18199,9 @@ async function pollCycleInner() {
|
|
|
18063
18199
|
}
|
|
18064
18200
|
try {
|
|
18065
18201
|
const { detectHostSecurity } = await import("../host-security-KQYYZZVW.js");
|
|
18066
|
-
const { collectDiagnostics } = await import("../persistent-session-
|
|
18202
|
+
const { collectDiagnostics } = await import("../persistent-session-34QXCPJK.js");
|
|
18067
18203
|
const diagCodeNames = [...agentState.persistentSessionAgents];
|
|
18068
|
-
const agentDiagnostics = diagCodeNames.length > 0 ? collectDiagnostics(diagCodeNames, quarantineEntriesFor, claudeMdSizeFor, spawnOutcomeForDiagnostics, pidPressureFor, forwardedToolsFor, runtimeVersionFor) : void 0;
|
|
18204
|
+
const agentDiagnostics = diagCodeNames.length > 0 ? collectDiagnostics(diagCodeNames, quarantineEntriesFor, claudeMdSizeFor, spawnOutcomeForDiagnostics, pidPressureFor, forwardedToolsFor, runtimeVersionFor, sessionActivityFor) : void 0;
|
|
18069
18205
|
let tailscaleHostname;
|
|
18070
18206
|
try {
|
|
18071
18207
|
const { execSync: es } = await import("child_process");
|
|
@@ -18318,7 +18454,7 @@ async function pollCycleInner() {
|
|
|
18318
18454
|
}
|
|
18319
18455
|
try {
|
|
18320
18456
|
const desiredClaudeCodeVersion = hbResp?.desired_claude_code_version?.trim();
|
|
18321
|
-
const { maybeUpdateClaudeCode, shouldRunClaudeCodeUpdater } = await import("../claude-code-updater-
|
|
18457
|
+
const { maybeUpdateClaudeCode, shouldRunClaudeCodeUpdater } = await import("../claude-code-updater-LL7KVAU3.js");
|
|
18322
18458
|
const securityFloor = currentSecurityFloor();
|
|
18323
18459
|
claudeUpdaterInFlight = true;
|
|
18324
18460
|
if (desiredClaudeCodeVersion && (claudePairLoop.busy || claudePairingInProgress())) {
|
|
@@ -18353,7 +18489,7 @@ async function pollCycleInner() {
|
|
|
18353
18489
|
collectPanelessActivityProbes,
|
|
18354
18490
|
getResponsivenessIntervalMs,
|
|
18355
18491
|
occupancyQualificationClassifications
|
|
18356
|
-
} = await import("../responsiveness-probe-
|
|
18492
|
+
} = await import("../responsiveness-probe-ZT6ITMYI.js");
|
|
18357
18493
|
const probeIntervalMs = getResponsivenessIntervalMs();
|
|
18358
18494
|
if (now - lastResponsivenessProbeAt > probeIntervalMs) {
|
|
18359
18495
|
const probeCodeNames = [...agentState.persistentSessionAgents];
|
|
@@ -18470,7 +18606,7 @@ async function pollCycleInner() {
|
|
|
18470
18606
|
collectResponsivenessProbes,
|
|
18471
18607
|
livePendingInboundOldestAgeSeconds,
|
|
18472
18608
|
parkPendingInbound
|
|
18473
|
-
} = await import("../responsiveness-probe-
|
|
18609
|
+
} = await import("../responsiveness-probe-ZT6ITMYI.js");
|
|
18474
18610
|
const { getProjectDir: wedgeProjectDir } = await import("../scheduler-engine-M6AFZWNU.js");
|
|
18475
18611
|
const wedgeNow = /* @__PURE__ */ new Date();
|
|
18476
18612
|
const liveAgents = agentState.persistentSessionAgents;
|
|
@@ -18562,10 +18698,10 @@ async function pollCycleInner() {
|
|
|
18562
18698
|
const paneTail = readFileSync34(paneLogPath(codeName), "utf8").slice(-65536);
|
|
18563
18699
|
const transient = detectTransientApiErrorInLog(paneTail);
|
|
18564
18700
|
if (transient) {
|
|
18565
|
-
const wedgeHome =
|
|
18701
|
+
const wedgeHome = join44(homedir17(), ".augmented", codeName);
|
|
18566
18702
|
if (existsSync19(wedgeHome)) {
|
|
18567
18703
|
atomicWriteFileSync(
|
|
18568
|
-
|
|
18704
|
+
join44(wedgeHome, "watchdog-give-up.json"),
|
|
18569
18705
|
JSON.stringify({
|
|
18570
18706
|
gave_up_at: wedgeNow.toISOString(),
|
|
18571
18707
|
reason: "transient_overload"
|
|
@@ -18627,7 +18763,7 @@ async function pollCycleInner() {
|
|
|
18627
18763
|
try {
|
|
18628
18764
|
const {
|
|
18629
18765
|
AlertHeartbeat,
|
|
18630
|
-
classifyPane,
|
|
18766
|
+
classifyPane: classifyPane2,
|
|
18631
18767
|
decidePaneFatalAction,
|
|
18632
18768
|
pruneRestartHistory,
|
|
18633
18769
|
resolvePaneFatalConfig
|
|
@@ -18670,7 +18806,7 @@ async function pollCycleInner() {
|
|
|
18670
18806
|
} catch {
|
|
18671
18807
|
pane = null;
|
|
18672
18808
|
}
|
|
18673
|
-
const verdict =
|
|
18809
|
+
const verdict = classifyPane2(pane);
|
|
18674
18810
|
const kind = verdict.kind;
|
|
18675
18811
|
if (!verdict.transcriptBanner) bannerBeat.clear(codeName);
|
|
18676
18812
|
if (kind === null) {
|
|
@@ -18756,7 +18892,7 @@ async function pollCycleInner() {
|
|
|
18756
18892
|
}
|
|
18757
18893
|
}
|
|
18758
18894
|
);
|
|
18759
|
-
const { parkPendingInbound } = await import("../responsiveness-probe-
|
|
18895
|
+
const { parkPendingInbound } = await import("../responsiveness-probe-ZT6ITMYI.js");
|
|
18760
18896
|
const { parked, deadLettered } = parkPendingInbound(codeName, new Date(fatalNowMs));
|
|
18761
18897
|
paneFatalStreak.delete(codeName);
|
|
18762
18898
|
paneFatalRestarts.set(codeName, [...history, fatalNowMs]);
|
|
@@ -18787,7 +18923,7 @@ async function pollCycleInner() {
|
|
|
18787
18923
|
TRANSCRIPT_MOUNT_ESCALATION_REFRESH_MS,
|
|
18788
18924
|
bindSourceEscalations
|
|
18789
18925
|
} = await import("../transcript-mount-health-OHE6IVJV.js");
|
|
18790
|
-
const { transcriptBindSourcesFor, ensureTranscriptBindSources } = await import("../persistent-session-
|
|
18926
|
+
const { transcriptBindSourcesFor, ensureTranscriptBindSources } = await import("../persistent-session-34QXCPJK.js");
|
|
18791
18927
|
const mountConfig = resolveTranscriptMountConfig();
|
|
18792
18928
|
const liveAgents = agentState.persistentSessionAgents;
|
|
18793
18929
|
for (const tracked of [
|
|
@@ -18856,7 +18992,7 @@ async function pollCycleInner() {
|
|
|
18856
18992
|
{ containerPath: src.projects, hostPath: src.mask },
|
|
18857
18993
|
{ containerPath: src.own, hostPath: src.own }
|
|
18858
18994
|
],
|
|
18859
|
-
stat: (path) =>
|
|
18995
|
+
stat: (path) => statSync15(path)
|
|
18860
18996
|
});
|
|
18861
18997
|
if (verdict.state !== "orphaned") {
|
|
18862
18998
|
transcriptMountStreak.delete(codeName);
|
|
@@ -18952,7 +19088,7 @@ async function pollCycleInner() {
|
|
|
18952
19088
|
}
|
|
18953
19089
|
try {
|
|
18954
19090
|
const { scrapeMcpFailedBannerCount } = await import("../pane-mcp-banner-scraper-VR5QGP3J.js");
|
|
18955
|
-
const { probeSessionAuth } = await import("../session-auth-dead-
|
|
19091
|
+
const { probeSessionAuth } = await import("../session-auth-dead-KAHV2ES2.js");
|
|
18956
19092
|
const observations = [];
|
|
18957
19093
|
const pendingCacheCommits = [];
|
|
18958
19094
|
const modelApiErrorReportingOn = hostFlagStore().getBoolean("model-api-error-reporting");
|
|
@@ -19457,7 +19593,7 @@ async function pollCycleInner() {
|
|
|
19457
19593
|
`[drain-flush] FAILED for '${prev.codeName}': ${err.message} \u2014 proceeding to teardown; this session was NOT shipped (ENG-9491)`
|
|
19458
19594
|
);
|
|
19459
19595
|
}
|
|
19460
|
-
const agentDir =
|
|
19596
|
+
const agentDir = join44(adapter.getAgentDir(prev.codeName), "provision");
|
|
19461
19597
|
await cleanupAgentFiles(prev.codeName, agentDir);
|
|
19462
19598
|
clearAgentCaches(prev.agentId, prev.codeName);
|
|
19463
19599
|
}
|
|
@@ -19536,10 +19672,10 @@ async function pollCycleInner() {
|
|
|
19536
19672
|
// pending-inbound marker. Best-effort: a write failure is logged by
|
|
19537
19673
|
// the watchdog, never fails the poll cycle.
|
|
19538
19674
|
signalGiveUp: (codeName) => {
|
|
19539
|
-
const dir =
|
|
19675
|
+
const dir = join44(homedir17(), ".augmented", codeName);
|
|
19540
19676
|
if (!existsSync19(dir)) return;
|
|
19541
19677
|
atomicWriteFileSync(
|
|
19542
|
-
|
|
19678
|
+
join44(dir, "watchdog-give-up.json"),
|
|
19543
19679
|
JSON.stringify({ gave_up_at: (/* @__PURE__ */ new Date()).toISOString() })
|
|
19544
19680
|
);
|
|
19545
19681
|
},
|
|
@@ -19567,17 +19703,17 @@ async function pollCycleInner() {
|
|
|
19567
19703
|
const dir = getFramework("claude-code").getAgentDir(codeName);
|
|
19568
19704
|
if (!existsSync19(dir)) return;
|
|
19569
19705
|
atomicWriteFileSync(
|
|
19570
|
-
|
|
19706
|
+
join44(dir, "blocked-prompt.json"),
|
|
19571
19707
|
JSON.stringify({ kind, last_seen_at: (/* @__PURE__ */ new Date()).toISOString() })
|
|
19572
19708
|
);
|
|
19573
19709
|
},
|
|
19574
19710
|
clearBlockedPromptLiveness: (codeName) => {
|
|
19575
|
-
const file =
|
|
19711
|
+
const file = join44(getFramework("claude-code").getAgentDir(codeName), "blocked-prompt.json");
|
|
19576
19712
|
if (existsSync19(file)) rmSync8(file, { force: true });
|
|
19577
19713
|
},
|
|
19578
19714
|
refreshUsageLimitLiveness: (codeName) => {
|
|
19579
19715
|
const dir = getFramework("claude-code").getAgentDir(codeName);
|
|
19580
|
-
const file =
|
|
19716
|
+
const file = join44(dir, "watchdog-give-up.json");
|
|
19581
19717
|
if (!existsSync19(file)) return;
|
|
19582
19718
|
try {
|
|
19583
19719
|
const raw = JSON.parse(readFileSync34(file, "utf8"));
|
|
@@ -19591,7 +19727,7 @@ async function pollCycleInner() {
|
|
|
19591
19727
|
const dir = getFramework("claude-code").getAgentDir(codeName);
|
|
19592
19728
|
if (!existsSync19(dir)) return;
|
|
19593
19729
|
atomicWriteFileSync(
|
|
19594
|
-
|
|
19730
|
+
join44(dir, "watchdog-give-up.json"),
|
|
19595
19731
|
JSON.stringify({
|
|
19596
19732
|
gave_up_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
19597
19733
|
reason: "usage_limit",
|
|
@@ -19866,7 +20002,7 @@ async function processAgent(agent, agentStates, managedToolkits) {
|
|
|
19866
20002
|
}
|
|
19867
20003
|
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
19868
20004
|
const adapter = resolveAgentFramework(agent.code_name);
|
|
19869
|
-
let agentDir =
|
|
20005
|
+
let agentDir = join44(adapter.getAgentDir(agent.code_name), "provision");
|
|
19870
20006
|
if (agent.status === "draft" || agent.status === "paused") {
|
|
19871
20007
|
forgetChannelSyncState(agent.agent_id);
|
|
19872
20008
|
reapLegacyTokenFileEdgeWarned(agent.code_name, log);
|
|
@@ -20014,7 +20150,7 @@ async function processAgent(agent, agentStates, managedToolkits) {
|
|
|
20014
20150
|
if (refreshData.knowledge_manifest) {
|
|
20015
20151
|
const resolved = await resolveKnowledgeFromManifest({
|
|
20016
20152
|
manifest: refreshData.knowledge_manifest,
|
|
20017
|
-
cacheDir:
|
|
20153
|
+
cacheDir: join44(config.configDir, "_knowledge"),
|
|
20018
20154
|
delivery: refreshData.agent?.knowledge_delivery ?? "both",
|
|
20019
20155
|
fetchContents: async (hashes) => {
|
|
20020
20156
|
const res = await api.post(
|
|
@@ -20031,7 +20167,7 @@ async function processAgent(agent, agentStates, managedToolkits) {
|
|
|
20031
20167
|
const resolvedSkills = await resolveSkillsFromManifest({
|
|
20032
20168
|
globals: refreshData.global_skills_manifest ?? [],
|
|
20033
20169
|
shared: refreshData.shared_skills_manifest ?? [],
|
|
20034
|
-
cacheDir:
|
|
20170
|
+
cacheDir: join44(config.configDir, "_skills"),
|
|
20035
20171
|
fetchContents: async (hashes) => {
|
|
20036
20172
|
const res = await api.post(
|
|
20037
20173
|
"/host/skills/contents",
|
|
@@ -20049,7 +20185,7 @@ async function processAgent(agent, agentStates, managedToolkits) {
|
|
|
20049
20185
|
if (refreshData.integration_skills_manifest) {
|
|
20050
20186
|
const resolvedIntegrationSkills = await resolveIntegrationSkillsFromManifest({
|
|
20051
20187
|
manifest: refreshData.integration_skills_manifest,
|
|
20052
|
-
cacheDir:
|
|
20188
|
+
cacheDir: join44(config.configDir, "_skills"),
|
|
20053
20189
|
fetchContents: async (hashes) => {
|
|
20054
20190
|
const res = await api.post(
|
|
20055
20191
|
"/host/skills/contents",
|
|
@@ -20111,7 +20247,7 @@ async function processAgent(agent, agentStates, managedToolkits) {
|
|
|
20111
20247
|
const frameworkId = refreshData.agent.framework ?? DEFAULT_FRAMEWORK;
|
|
20112
20248
|
agentFrameworkCache.set(agent.code_name, frameworkId);
|
|
20113
20249
|
const frameworkAdapter = getFramework(frameworkId);
|
|
20114
|
-
agentDir =
|
|
20250
|
+
agentDir = join44(frameworkAdapter.getAgentDir(agent.code_name), "provision");
|
|
20115
20251
|
cacheAgentDeliveryMetadata(agent.code_name, refreshData);
|
|
20116
20252
|
agentRestartTimezoneInputs.set(agent.code_name, {
|
|
20117
20253
|
agentTimezone: typeof refreshData.agent.timezone === "string" ? refreshData.agent.timezone : null,
|
|
@@ -20170,7 +20306,7 @@ async function processAgent(agent, agentStates, managedToolkits) {
|
|
|
20170
20306
|
const changedFiles = [];
|
|
20171
20307
|
mkdirSync16(agentDir, { recursive: true });
|
|
20172
20308
|
for (const artifact of artifacts) {
|
|
20173
|
-
const filePath =
|
|
20309
|
+
const filePath = join44(agentDir, artifact.relativePath);
|
|
20174
20310
|
let existingHash;
|
|
20175
20311
|
let newHash;
|
|
20176
20312
|
let writeContent = artifact.content;
|
|
@@ -20189,7 +20325,7 @@ async function processAgent(agent, agentStates, managedToolkits) {
|
|
|
20189
20325
|
};
|
|
20190
20326
|
newHash = sha256(stripDynamicSections(artifact.content));
|
|
20191
20327
|
try {
|
|
20192
|
-
const projectClaudeMd =
|
|
20328
|
+
const projectClaudeMd = join44(config.configDir, agent.code_name, "project", "CLAUDE.md");
|
|
20193
20329
|
const existing = readFileSync34(projectClaudeMd, "utf-8");
|
|
20194
20330
|
existingHash = sha256(stripDynamicSections(existing));
|
|
20195
20331
|
} catch {
|
|
@@ -20240,12 +20376,12 @@ async function processAgent(agent, agentStates, managedToolkits) {
|
|
|
20240
20376
|
}
|
|
20241
20377
|
}
|
|
20242
20378
|
if (changedFiles.length > 0) {
|
|
20243
|
-
const isFirst = !existsSync19(
|
|
20379
|
+
const isFirst = !existsSync19(join44(agentDir, "CHARTER.md"));
|
|
20244
20380
|
const verb = isFirst ? "Provisioning" : "Updating";
|
|
20245
20381
|
const fileNames = changedFiles.map((f) => f.relativePath).join(", ");
|
|
20246
20382
|
log(`${verb} '${agent.code_name}': ${fileNames}`);
|
|
20247
20383
|
for (const file of changedFiles) {
|
|
20248
|
-
const filePath =
|
|
20384
|
+
const filePath = join44(agentDir, file.relativePath);
|
|
20249
20385
|
mkdirSync16(dirname11(filePath), { recursive: true });
|
|
20250
20386
|
if (file.relativePath === ".mcp.json") {
|
|
20251
20387
|
safeWriteJsonAtomic(filePath, file.content, { mode: 384 });
|
|
@@ -20254,12 +20390,12 @@ async function processAgent(agent, agentStates, managedToolkits) {
|
|
|
20254
20390
|
}
|
|
20255
20391
|
}
|
|
20256
20392
|
try {
|
|
20257
|
-
const provSkillsDir =
|
|
20393
|
+
const provSkillsDir = join44(agentDir, ".claude", "skills");
|
|
20258
20394
|
if (existsSync19(provSkillsDir)) {
|
|
20259
|
-
for (const folder of
|
|
20395
|
+
for (const folder of readdirSync14(provSkillsDir)) {
|
|
20260
20396
|
if (folder.startsWith("knowledge-")) {
|
|
20261
20397
|
try {
|
|
20262
|
-
rmSync8(
|
|
20398
|
+
rmSync8(join44(provSkillsDir, folder), { recursive: true });
|
|
20263
20399
|
} catch {
|
|
20264
20400
|
}
|
|
20265
20401
|
}
|
|
@@ -20272,7 +20408,7 @@ async function processAgent(agent, agentStates, managedToolkits) {
|
|
|
20272
20408
|
const trackedFiles2 = frameworkAdapter.driftTrackedFiles();
|
|
20273
20409
|
const hashes = /* @__PURE__ */ new Map();
|
|
20274
20410
|
for (const file of trackedFiles2) {
|
|
20275
|
-
const h = hashFile(
|
|
20411
|
+
const h = hashFile(join44(agentDir, file));
|
|
20276
20412
|
if (h) hashes.set(file, h);
|
|
20277
20413
|
}
|
|
20278
20414
|
agentState.writtenHashes.set(agent.agent_id, hashes);
|
|
@@ -20290,14 +20426,14 @@ async function processAgent(agent, agentStates, managedToolkits) {
|
|
|
20290
20426
|
}
|
|
20291
20427
|
if (Array.isArray(refreshData.workflows)) {
|
|
20292
20428
|
try {
|
|
20293
|
-
const provWorkflowsDir =
|
|
20429
|
+
const provWorkflowsDir = join44(agentDir, ".claude", "workflows");
|
|
20294
20430
|
if (existsSync19(provWorkflowsDir)) {
|
|
20295
20431
|
const expected = new Set(refreshData.workflows.map((w) => `${w.name}.js`));
|
|
20296
|
-
for (const file of
|
|
20432
|
+
for (const file of readdirSync14(provWorkflowsDir)) {
|
|
20297
20433
|
if (!file.endsWith(".js")) continue;
|
|
20298
20434
|
if (expected.has(file)) continue;
|
|
20299
20435
|
try {
|
|
20300
|
-
rmSync8(
|
|
20436
|
+
rmSync8(join44(provWorkflowsDir, file));
|
|
20301
20437
|
} catch {
|
|
20302
20438
|
}
|
|
20303
20439
|
}
|
|
@@ -20379,7 +20515,7 @@ async function processAgent(agent, agentStates, managedToolkits) {
|
|
|
20379
20515
|
if (written && existsSync19(agentDir)) {
|
|
20380
20516
|
const driftedFiles = [];
|
|
20381
20517
|
for (const [file, expectedHash] of written) {
|
|
20382
|
-
const localHash = hashFile(
|
|
20518
|
+
const localHash = hashFile(join44(agentDir, file));
|
|
20383
20519
|
if (localHash && localHash !== expectedHash) {
|
|
20384
20520
|
driftedFiles.push(file);
|
|
20385
20521
|
}
|
|
@@ -20390,7 +20526,7 @@ async function processAgent(agent, agentStates, managedToolkits) {
|
|
|
20390
20526
|
try {
|
|
20391
20527
|
const localHashes = {};
|
|
20392
20528
|
for (const file of driftedFiles) {
|
|
20393
|
-
localHashes[file] = hashFile(
|
|
20529
|
+
localHashes[file] = hashFile(join44(agentDir, file));
|
|
20394
20530
|
}
|
|
20395
20531
|
await api.post("/host/drift", {
|
|
20396
20532
|
agent_id: agent.agent_id,
|
|
@@ -20675,7 +20811,7 @@ async function processAgent(agent, agentStates, managedToolkits) {
|
|
|
20675
20811
|
const addedChannels = [...restartDecision.added];
|
|
20676
20812
|
const writeDmNoticeMarkers = isChannelAddRestart ? () => {
|
|
20677
20813
|
try {
|
|
20678
|
-
const agentAugmentedDir =
|
|
20814
|
+
const agentAugmentedDir = join44(homedir17(), ".augmented", agent.code_name);
|
|
20679
20815
|
mkdirSync16(agentAugmentedDir, { recursive: true });
|
|
20680
20816
|
const markerJson = JSON.stringify({
|
|
20681
20817
|
version: 1,
|
|
@@ -20683,7 +20819,7 @@ async function processAgent(agent, agentStates, managedToolkits) {
|
|
|
20683
20819
|
added: addedChannels
|
|
20684
20820
|
});
|
|
20685
20821
|
for (const file of ["slack-channel-add-restart.json", "telegram-channel-add-restart.json"]) {
|
|
20686
|
-
atomicWriteFileSync(
|
|
20822
|
+
atomicWriteFileSync(join44(agentAugmentedDir, file), markerJson);
|
|
20687
20823
|
}
|
|
20688
20824
|
} catch (err) {
|
|
20689
20825
|
log(`[hot-reload] channel-add DM-notice marker write failed for '${agent.code_name}' (non-fatal): ${err.message}`);
|
|
@@ -20982,18 +21118,18 @@ async function processAgent(agent, agentStates, managedToolkits) {
|
|
|
20982
21118
|
if (agentSessionMode === "persistent" && (agentFrameworkCache.get(agent.code_name) ?? DEFAULT_FRAMEWORK) === "claude-code") {
|
|
20983
21119
|
try {
|
|
20984
21120
|
const agentProvisionDir = agentDir;
|
|
20985
|
-
const projectDir =
|
|
21121
|
+
const projectDir = join44(homedir17(), ".augmented", agent.code_name, "project");
|
|
20986
21122
|
mkdirSync16(agentProvisionDir, { recursive: true });
|
|
20987
21123
|
mkdirSync16(projectDir, { recursive: true });
|
|
20988
|
-
const provisionMcpPath =
|
|
20989
|
-
const projectMcpPath =
|
|
21124
|
+
const provisionMcpPath = join44(agentProvisionDir, ".mcp.json");
|
|
21125
|
+
const projectMcpPath = join44(projectDir, ".mcp.json");
|
|
20990
21126
|
let mcpConfig = { mcpServers: {} };
|
|
20991
21127
|
try {
|
|
20992
21128
|
mcpConfig = JSON.parse(readFileSync34(provisionMcpPath, "utf-8"));
|
|
20993
21129
|
if (!mcpConfig.mcpServers) mcpConfig.mcpServers = {};
|
|
20994
21130
|
} catch {
|
|
20995
21131
|
}
|
|
20996
|
-
const localDirectChatChannel =
|
|
21132
|
+
const localDirectChatChannel = join44(homedir17(), ".augmented", "_mcp", "direct-chat-channel.js");
|
|
20997
21133
|
const directChatTeamSettings = refreshData.team?.settings;
|
|
20998
21134
|
const directChatTz = (() => {
|
|
20999
21135
|
const tz = directChatTeamSettings?.["timezone"];
|
|
@@ -21019,7 +21155,7 @@ async function processAgent(agent, agentStates, managedToolkits) {
|
|
|
21019
21155
|
// ~/.augmented/<codeName>/.current-turn-initiator.json. Note getAgentDir
|
|
21020
21156
|
// returns the agent root (NOT the /provision subdir `agentDir` points at),
|
|
21021
21157
|
// so it byte-matches the broker readers' path.
|
|
21022
|
-
AGT_TURN_INITIATOR_FILE:
|
|
21158
|
+
AGT_TURN_INITIATOR_FILE: join44(
|
|
21023
21159
|
frameworkAdapter.getAgentDir(agent.code_name),
|
|
21024
21160
|
".current-turn-initiator.json"
|
|
21025
21161
|
)
|
|
@@ -21039,7 +21175,7 @@ async function processAgent(agent, agentStates, managedToolkits) {
|
|
|
21039
21175
|
log(`Channel credentials written for '${agent.code_name}/direct-chat'`);
|
|
21040
21176
|
}
|
|
21041
21177
|
}
|
|
21042
|
-
const staleChannelsPath =
|
|
21178
|
+
const staleChannelsPath = join44(projectDir, ".mcp-channels.json");
|
|
21043
21179
|
if (existsSync19(staleChannelsPath)) {
|
|
21044
21180
|
try {
|
|
21045
21181
|
rmSync8(staleChannelsPath, { force: true });
|
|
@@ -21149,7 +21285,7 @@ async function processAgent(agent, agentStates, managedToolkits) {
|
|
|
21149
21285
|
}
|
|
21150
21286
|
if (hostFlagStore().getBoolean("connectivity-probe")) {
|
|
21151
21287
|
try {
|
|
21152
|
-
const probeProjectDir =
|
|
21288
|
+
const probeProjectDir = join44(homedir17(), ".augmented", agent.code_name, "project");
|
|
21153
21289
|
let probeSet = integrations;
|
|
21154
21290
|
const fetchQuarantined = async () => {
|
|
21155
21291
|
const quarantined = await api.post("/host/agent-integrations/quarantined", { agent_id: agent.agent_id });
|
|
@@ -21209,7 +21345,7 @@ async function processAgent(agent, agentStates, managedToolkits) {
|
|
|
21209
21345
|
const forceDue = attemptsLeft > 0;
|
|
21210
21346
|
let probeRan = false;
|
|
21211
21347
|
try {
|
|
21212
|
-
const probeProjectDir =
|
|
21348
|
+
const probeProjectDir = join44(homedir17(), ".augmented", agent.code_name, "project");
|
|
21213
21349
|
probeRan = await runAgentSessionToolBindProbes(agent, integrations, probeProjectDir, { forceDue });
|
|
21214
21350
|
} catch (err) {
|
|
21215
21351
|
log(`Session-tool-bind probe failed for '${agent.code_name}': ${err.message}`);
|
|
@@ -21287,8 +21423,8 @@ async function processAgent(agent, agentStates, managedToolkits) {
|
|
|
21287
21423
|
const intHash = computeIntegrationsHash(integrations);
|
|
21288
21424
|
const prevIntHash = agentState.knownIntegrationHashes.get(agent.agent_id);
|
|
21289
21425
|
if (intHash !== prevIntHash) {
|
|
21290
|
-
const projectDir =
|
|
21291
|
-
const envIntPath =
|
|
21426
|
+
const projectDir = join44(homedir17(), ".augmented", agent.code_name, "project");
|
|
21427
|
+
const envIntPath = join44(projectDir, ".env.integrations");
|
|
21292
21428
|
let preWriteEnv;
|
|
21293
21429
|
try {
|
|
21294
21430
|
preWriteEnv = readFileSync34(envIntPath, "utf-8");
|
|
@@ -21311,7 +21447,7 @@ async function processAgent(agent, agentStates, managedToolkits) {
|
|
|
21311
21447
|
}
|
|
21312
21448
|
if (fw === "claude-code" && isSessionHealthy(agent.code_name)) {
|
|
21313
21449
|
try {
|
|
21314
|
-
const projectMcpPath =
|
|
21450
|
+
const projectMcpPath = join44(projectDir, ".mcp.json");
|
|
21315
21451
|
const postWriteEnv = readFileSync34(envIntPath, "utf-8");
|
|
21316
21452
|
const mcpContent = readFileSync34(projectMcpPath, "utf-8");
|
|
21317
21453
|
const changedVars = diffEnvIntegrations(preWriteEnv, postWriteEnv);
|
|
@@ -21615,23 +21751,23 @@ async function processAgent(agent, agentStates, managedToolkits) {
|
|
|
21615
21751
|
}
|
|
21616
21752
|
}
|
|
21617
21753
|
try {
|
|
21618
|
-
const { readdirSync:
|
|
21754
|
+
const { readdirSync: readdirSync15, rmSync: rmSync9 } = await import("fs");
|
|
21619
21755
|
const { homedir: homedir18 } = await import("os");
|
|
21620
21756
|
const frameworkId2 = frameworkAdapter.id;
|
|
21621
21757
|
const candidateSkillDirs = [
|
|
21622
21758
|
// Claude Code — framework runtime tree
|
|
21623
|
-
|
|
21759
|
+
join44(homedir18(), ".augmented", agent.code_name, "skills"),
|
|
21624
21760
|
// Claude Code — project tree
|
|
21625
|
-
|
|
21761
|
+
join44(homedir18(), ".augmented", agent.code_name, "project", ".claude", "skills"),
|
|
21626
21762
|
// Defensive: legacy provision-side path, not currently an
|
|
21627
21763
|
// install target but cheap to sweep.
|
|
21628
|
-
|
|
21764
|
+
join44(agentDir, ".claude", "skills")
|
|
21629
21765
|
];
|
|
21630
21766
|
const existingDirs = candidateSkillDirs.filter((d) => existsSync19(d));
|
|
21631
21767
|
const discoveredEntries = /* @__PURE__ */ new Set();
|
|
21632
21768
|
for (const dir of existingDirs) {
|
|
21633
21769
|
try {
|
|
21634
|
-
for (const entry of
|
|
21770
|
+
for (const entry of readdirSync15(dir)) {
|
|
21635
21771
|
if (entry.startsWith("plugin-") || entry.startsWith("integration-")) {
|
|
21636
21772
|
discoveredEntries.add(entry);
|
|
21637
21773
|
}
|
|
@@ -21668,7 +21804,7 @@ async function processAgent(agent, agentStates, managedToolkits) {
|
|
|
21668
21804
|
const sharedSkillsPayload = refreshAny.shared_skills;
|
|
21669
21805
|
const desiredResolved = globalSkillsPayload !== void 0 || sharedSkillsPayload !== void 0;
|
|
21670
21806
|
const manifestPath = managedSkillManifestPath(
|
|
21671
|
-
|
|
21807
|
+
join44(homedir17(), ".augmented", agent.code_name)
|
|
21672
21808
|
);
|
|
21673
21809
|
const prevIds = /* @__PURE__ */ new Set([
|
|
21674
21810
|
...agentState.knownGlobalSkillIds.get(agent.agent_id) ?? /* @__PURE__ */ new Set(),
|
|
@@ -21688,15 +21824,15 @@ async function processAgent(agent, agentStates, managedToolkits) {
|
|
|
21688
21824
|
}
|
|
21689
21825
|
if (plan.removes.length) {
|
|
21690
21826
|
const globalSkillDirs = [
|
|
21691
|
-
|
|
21692
|
-
|
|
21693
|
-
|
|
21827
|
+
join44(homedir17(), ".augmented", agent.code_name, "skills"),
|
|
21828
|
+
join44(homedir17(), ".augmented", agent.code_name, "project", ".claude", "skills"),
|
|
21829
|
+
join44(agentDir, ".claude", "skills")
|
|
21694
21830
|
];
|
|
21695
21831
|
for (const id of plan.removes) {
|
|
21696
21832
|
let prunedAny = false;
|
|
21697
21833
|
for (const dir of globalSkillDirs) {
|
|
21698
|
-
const p =
|
|
21699
|
-
if (existsSync19(p) && existsSync19(
|
|
21834
|
+
const p = join44(dir, id);
|
|
21835
|
+
if (existsSync19(p) && existsSync19(join44(p, "SKILL.md"))) {
|
|
21700
21836
|
rmSync8(p, { recursive: true, force: true });
|
|
21701
21837
|
prunedAny = true;
|
|
21702
21838
|
}
|
|
@@ -21966,7 +22102,7 @@ async function processAgent(agent, agentStates, managedToolkits) {
|
|
|
21966
22102
|
const sess = getSessionState(agent.code_name);
|
|
21967
22103
|
let mcpJsonParsed = null;
|
|
21968
22104
|
try {
|
|
21969
|
-
const mcpPath =
|
|
22105
|
+
const mcpPath = join44(getProjectDir(agent.code_name), ".mcp.json");
|
|
21970
22106
|
mcpJsonParsed = JSON.parse(readFileSync34(mcpPath, "utf-8"));
|
|
21971
22107
|
} catch {
|
|
21972
22108
|
}
|
|
@@ -22480,7 +22616,7 @@ Retried to the limit after repeated stalls \u2014 needs a look.`).catch(() => {
|
|
|
22480
22616
|
if (trackedFiles.length > 0 && existsSync19(agentDir)) {
|
|
22481
22617
|
const hashes = /* @__PURE__ */ new Map();
|
|
22482
22618
|
for (const file of trackedFiles) {
|
|
22483
|
-
const h = hashFile(
|
|
22619
|
+
const h = hashFile(join44(agentDir, file));
|
|
22484
22620
|
if (h) hashes.set(file, h);
|
|
22485
22621
|
}
|
|
22486
22622
|
agentState.writtenHashes.set(agent.agent_id, hashes);
|
|
@@ -22495,7 +22631,7 @@ Retried to the limit after repeated stalls \u2014 needs a look.`).catch(() => {
|
|
|
22495
22631
|
refreshData.agent.onboarding_state
|
|
22496
22632
|
);
|
|
22497
22633
|
const obStep = obState.step;
|
|
22498
|
-
const markerPath =
|
|
22634
|
+
const markerPath = join44(homedir17(), ".augmented", agent.code_name, "onboarding-drive.json");
|
|
22499
22635
|
const marker = readOnboardingDriveMarker(markerPath);
|
|
22500
22636
|
const obContactRaw = refreshData.agent.manager_last_contacted_at;
|
|
22501
22637
|
const obContact = typeof obContactRaw === "string" && obContactRaw ? obContactRaw : null;
|
|
@@ -22611,7 +22747,7 @@ async function ensureOpencodeRuntime(agent, refreshData, agentTimezone) {
|
|
|
22611
22747
|
}
|
|
22612
22748
|
stopOpencodeSlackIngest(codeName, log);
|
|
22613
22749
|
stopOpencodeTelegramIngest(codeName, log);
|
|
22614
|
-
const opencodeProjectDir =
|
|
22750
|
+
const opencodeProjectDir = join44(getFramework("opencode").getAgentDir(codeName), "provision");
|
|
22615
22751
|
const serveEnv = {
|
|
22616
22752
|
AGT_HOST: requireHost(),
|
|
22617
22753
|
AGT_API_KEY: getApiKey() ?? void 0,
|
|
@@ -22671,8 +22807,8 @@ async function ensurePersistentSessionUnchecked(agent, tasks, boardItems, refres
|
|
|
22671
22807
|
});
|
|
22672
22808
|
}
|
|
22673
22809
|
const projectDir = getProjectDir(codeName);
|
|
22674
|
-
const mcpConfigPath =
|
|
22675
|
-
const claudeMdPath =
|
|
22810
|
+
const mcpConfigPath = join44(projectDir, ".mcp.json");
|
|
22811
|
+
const claudeMdPath = join44(projectDir, "CLAUDE.md");
|
|
22676
22812
|
if (restartBreaker.isTripped(codeName)) {
|
|
22677
22813
|
const trip = restartBreaker.getTrip(codeName);
|
|
22678
22814
|
return {
|
|
@@ -23641,7 +23777,7 @@ async function handleRestartDoorbell(agentId, requestedAt, restartReason) {
|
|
|
23641
23777
|
try {
|
|
23642
23778
|
const freshId = rotateSessionForWedge(codeName);
|
|
23643
23779
|
consecutiveWedgeCycles.delete(codeName);
|
|
23644
|
-
const { parkPendingInbound: parkForRestart } = await import("../responsiveness-probe-
|
|
23780
|
+
const { parkPendingInbound: parkForRestart } = await import("../responsiveness-probe-ZT6ITMYI.js");
|
|
23645
23781
|
const { parked, deadLettered } = parkForRestart(codeName, /* @__PURE__ */ new Date());
|
|
23646
23782
|
const parkNote = parked > 0 ? `, ${parked} inbound parked` : "";
|
|
23647
23783
|
const deadNote = deadLettered > 0 ? `, ${deadLettered} undeliverable dead-lettered` : "";
|
|
@@ -23684,10 +23820,10 @@ async function handleRestartDoorbell(agentId, requestedAt, restartReason) {
|
|
|
23684
23820
|
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}`));
|
|
23685
23821
|
void (async () => {
|
|
23686
23822
|
try {
|
|
23687
|
-
const { collectDiagnostics } = await import("../persistent-session-
|
|
23823
|
+
const { collectDiagnostics } = await import("../persistent-session-34QXCPJK.js");
|
|
23688
23824
|
await api.post("/host/heartbeat", {
|
|
23689
23825
|
host_id: hostId,
|
|
23690
|
-
agent_diagnostics: collectDiagnostics([codeName], quarantineEntriesFor, claudeMdSizeFor, spawnOutcomeForDiagnostics, pidPressureFor, forwardedToolsFor, runtimeVersionFor)
|
|
23826
|
+
agent_diagnostics: collectDiagnostics([codeName], quarantineEntriesFor, claudeMdSizeFor, spawnOutcomeForDiagnostics, pidPressureFor, forwardedToolsFor, runtimeVersionFor, sessionActivityFor)
|
|
23691
23827
|
});
|
|
23692
23828
|
} catch (err) {
|
|
23693
23829
|
log(`[restart-lane] post-respawn diagnostics flush failed for '${codeName}': ${err.message}`);
|
|
@@ -23735,10 +23871,10 @@ async function respawnAgentAfterMcpStop(codeName, reason) {
|
|
|
23735
23871
|
}
|
|
23736
23872
|
try {
|
|
23737
23873
|
const hostId = await getHostId();
|
|
23738
|
-
const { collectDiagnostics } = await import("../persistent-session-
|
|
23874
|
+
const { collectDiagnostics } = await import("../persistent-session-34QXCPJK.js");
|
|
23739
23875
|
await api.post("/host/heartbeat", {
|
|
23740
23876
|
host_id: hostId,
|
|
23741
|
-
agent_diagnostics: collectDiagnostics([codeName], quarantineEntriesFor, claudeMdSizeFor, spawnOutcomeForDiagnostics, pidPressureFor, forwardedToolsFor, runtimeVersionFor)
|
|
23877
|
+
agent_diagnostics: collectDiagnostics([codeName], quarantineEntriesFor, claudeMdSizeFor, spawnOutcomeForDiagnostics, pidPressureFor, forwardedToolsFor, runtimeVersionFor, sessionActivityFor)
|
|
23742
23878
|
});
|
|
23743
23879
|
} catch (err) {
|
|
23744
23880
|
log(`[fast-mcp-respawn] post-respawn diagnostics flush failed for '${codeName}': ${err.message}`);
|
|
@@ -24437,7 +24573,7 @@ async function processClaudePairSessions(agents) {
|
|
|
24437
24573
|
snapshotPairConfig,
|
|
24438
24574
|
// ENG-11659: result -> report body + the manager.log line that records it.
|
|
24439
24575
|
planPairStartReport
|
|
24440
|
-
} = await import("../claude-pair-runtime-
|
|
24576
|
+
} = await import("../claude-pair-runtime-R5MNSUM7.js");
|
|
24441
24577
|
const { resetClaudeSignin, describeSigninResetForLog, describeSigninResetFailure } = await import("../claude-signin-reset-6IJMMVYG.js");
|
|
24442
24578
|
for (const pairId of pendingResp.cancelled_pair_ids ?? []) {
|
|
24443
24579
|
log(`[claude-pair] sweeping orphan tmux session for pair ${pairId.slice(0, 8)}`);
|
|
@@ -24728,10 +24864,10 @@ var lastLocalFileHash = /* @__PURE__ */ new Map();
|
|
|
24728
24864
|
var lastMemoriesBody = /* @__PURE__ */ new Map();
|
|
24729
24865
|
var memoryManifests = /* @__PURE__ */ new Map();
|
|
24730
24866
|
function memoryRetirementDir(configDir, codeName) {
|
|
24731
|
-
return
|
|
24867
|
+
return join44(configDir, "_memory-retirement", codeName);
|
|
24732
24868
|
}
|
|
24733
24869
|
function memoryManifestPath(configDir, codeName) {
|
|
24734
|
-
return
|
|
24870
|
+
return join44(memoryRetirementDir(configDir, codeName), "manifest.json");
|
|
24735
24871
|
}
|
|
24736
24872
|
function loadMemoryManifest(agentId, configDir, codeName) {
|
|
24737
24873
|
const cached = memoryManifests.get(agentId);
|
|
@@ -24766,7 +24902,7 @@ function saveMemoryManifest(agentId, configDir, codeName) {
|
|
|
24766
24902
|
}
|
|
24767
24903
|
}
|
|
24768
24904
|
function retiredMemoryDir(configDir, codeName) {
|
|
24769
|
-
return
|
|
24905
|
+
return join44(memoryRetirementDir(configDir, codeName), "retired");
|
|
24770
24906
|
}
|
|
24771
24907
|
var RETIRED_MEMORY_TTL_MS = 30 * 24 * 60 * 60 * 1e3;
|
|
24772
24908
|
var lastRetirementReport = /* @__PURE__ */ new Map();
|
|
@@ -24845,7 +24981,7 @@ function applyMemoryTombstones(opts) {
|
|
|
24845
24981
|
log2(`[memory-retire] ${agent.code_name}: KEPT '${tomb.name}' \u2014 no write record, not ours to remove`);
|
|
24846
24982
|
continue;
|
|
24847
24983
|
}
|
|
24848
|
-
const filePath =
|
|
24984
|
+
const filePath = join44(memoryDir, entry.file);
|
|
24849
24985
|
if (!existsSync19(filePath)) {
|
|
24850
24986
|
outcomes.already_gone++;
|
|
24851
24987
|
delete manifest[tomb.name];
|
|
@@ -24865,9 +25001,9 @@ function applyMemoryTombstones(opts) {
|
|
|
24865
25001
|
const destDir = retiredMemoryDir(configDir, agent.code_name);
|
|
24866
25002
|
mkdirSync16(destDir, { recursive: true });
|
|
24867
25003
|
const stamp = Date.now();
|
|
24868
|
-
let dest =
|
|
25004
|
+
let dest = join44(destDir, `${entry.file}.${stamp}.retired`);
|
|
24869
25005
|
for (let n = 1; existsSync19(dest); n++) {
|
|
24870
|
-
dest =
|
|
25006
|
+
dest = join44(destDir, `${entry.file}.${stamp}-${n}.retired`);
|
|
24871
25007
|
}
|
|
24872
25008
|
renameSync11(filePath, dest);
|
|
24873
25009
|
try {
|
|
@@ -24904,11 +25040,11 @@ function reapRetiredMemories(configDir, codeName, log2) {
|
|
|
24904
25040
|
const cutoff = Date.now() - RETIRED_MEMORY_TTL_MS;
|
|
24905
25041
|
let reaped = 0;
|
|
24906
25042
|
try {
|
|
24907
|
-
for (const file of
|
|
25043
|
+
for (const file of readdirSync14(dir)) {
|
|
24908
25044
|
if (!file.endsWith(".retired")) continue;
|
|
24909
|
-
const path =
|
|
25045
|
+
const path = join44(dir, file);
|
|
24910
25046
|
try {
|
|
24911
|
-
if (
|
|
25047
|
+
if (statSync15(path).mtimeMs < cutoff) {
|
|
24912
25048
|
unlinkSync6(path);
|
|
24913
25049
|
reaped++;
|
|
24914
25050
|
}
|
|
@@ -24921,8 +25057,8 @@ function reapRetiredMemories(configDir, codeName, log2) {
|
|
|
24921
25057
|
if (reaped > 0) log2(`[memory-retire] ${codeName}: reaped ${reaped} retired memory file(s) past TTL`);
|
|
24922
25058
|
}
|
|
24923
25059
|
async function syncMemories(agent, configDir, log2) {
|
|
24924
|
-
const projectDir =
|
|
24925
|
-
const memoryDir =
|
|
25060
|
+
const projectDir = join44(configDir, agent.code_name, "project");
|
|
25061
|
+
const memoryDir = join44(projectDir, "memory");
|
|
24926
25062
|
const isFreshSync = pendingFreshMemorySync.has(agent.agent_id);
|
|
24927
25063
|
if (isFreshSync) {
|
|
24928
25064
|
log2(`[memory-sync] Fresh-sync requested for '${agent.code_name}' \u2014 pulling DB first`);
|
|
@@ -24950,10 +25086,10 @@ async function syncMemories(agent, configDir, log2) {
|
|
|
24950
25086
|
const prevHashes = memoryFileHashes.get(agent.agent_id) ?? /* @__PURE__ */ new Map();
|
|
24951
25087
|
const currentHashes = /* @__PURE__ */ new Map();
|
|
24952
25088
|
const changedMemories = [];
|
|
24953
|
-
for (const file of
|
|
25089
|
+
for (const file of readdirSync14(memoryDir)) {
|
|
24954
25090
|
if (!file.endsWith(".md")) continue;
|
|
24955
25091
|
try {
|
|
24956
|
-
const raw = readFileSync34(
|
|
25092
|
+
const raw = readFileSync34(join44(memoryDir, file), "utf-8");
|
|
24957
25093
|
const fileHash = createHash20("sha256").update(raw).digest("hex").slice(0, 16);
|
|
24958
25094
|
currentHashes.set(file, fileHash);
|
|
24959
25095
|
if (prevHashes.get(file) === fileHash) continue;
|
|
@@ -24978,7 +25114,7 @@ async function syncMemories(agent, configDir, log2) {
|
|
|
24978
25114
|
} catch (err) {
|
|
24979
25115
|
for (const mem of changedMemories) {
|
|
24980
25116
|
for (const [file] of currentHashes) {
|
|
24981
|
-
const parsed = parseMemoryFile(readFileSync34(
|
|
25117
|
+
const parsed = parseMemoryFile(readFileSync34(join44(memoryDir, file), "utf-8"), file.replace(/\.md$/, ""));
|
|
24982
25118
|
if (parsed?.name === mem.name) currentHashes.delete(file);
|
|
24983
25119
|
}
|
|
24984
25120
|
}
|
|
@@ -25004,7 +25140,7 @@ async function syncMemories(agent, configDir, log2) {
|
|
|
25004
25140
|
}
|
|
25005
25141
|
}
|
|
25006
25142
|
async function downloadMemories(agent, memoryDir, log2, { force, configDir }) {
|
|
25007
|
-
const localFiles = existsSync19(memoryDir) ?
|
|
25143
|
+
const localFiles = existsSync19(memoryDir) ? readdirSync14(memoryDir).filter((f) => f.endsWith(".md")).sort() : [];
|
|
25008
25144
|
const localListHash = createHash20("sha256").update(localFiles.join(",")).digest("hex").slice(0, 16);
|
|
25009
25145
|
const prevLocalHash = lastLocalFileHash.get(agent.agent_id);
|
|
25010
25146
|
const prevDownload = lastDownloadHash.get(agent.agent_id);
|
|
@@ -25059,7 +25195,7 @@ async function downloadMemories(agent, memoryDir, log2, { force, configDir }) {
|
|
|
25059
25195
|
// Per-agent, not host-wide: memories are agent-private, so a shared
|
|
25060
25196
|
// store would buy almost no dedupe while exposing one agent's content
|
|
25061
25197
|
// to every other agent on the host. See memory-cache.ts's header.
|
|
25062
|
-
cacheDir:
|
|
25198
|
+
cacheDir: join44(configDir, agent.code_name, "_memory_bodies"),
|
|
25063
25199
|
fetchContents: async (hashes) => {
|
|
25064
25200
|
const res = await api.post(
|
|
25065
25201
|
"/host/memories/contents",
|
|
@@ -25097,7 +25233,7 @@ async function downloadMemories(agent, memoryDir, log2, { force, configDir }) {
|
|
|
25097
25233
|
const rawSlug = mem.name.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/(^-|-$)/g, "").slice(0, 60);
|
|
25098
25234
|
const slug = rawSlug || `memory-${i}`;
|
|
25099
25235
|
const fileName = `${slug}.md`;
|
|
25100
|
-
const filePath =
|
|
25236
|
+
const filePath = join44(memoryDir, fileName);
|
|
25101
25237
|
const desired = `---
|
|
25102
25238
|
name: ${JSON.stringify(mem.name)}
|
|
25103
25239
|
type: ${mem.type}
|
|
@@ -25135,7 +25271,7 @@ ${mem.content}
|
|
|
25135
25271
|
if (manifestDirty) saveMemoryManifest(agent.agent_id, configDir, agent.code_name);
|
|
25136
25272
|
}
|
|
25137
25273
|
if (written > 0 || overwritten > 0) {
|
|
25138
|
-
const updatedFiles =
|
|
25274
|
+
const updatedFiles = readdirSync14(memoryDir).filter((f) => f.endsWith(".md")).sort();
|
|
25139
25275
|
lastLocalFileHash.set(agent.agent_id, createHash20("sha256").update(updatedFiles.join(",")).digest("hex").slice(0, 16));
|
|
25140
25276
|
log2(`Memory download for '${agent.code_name}': wrote ${written} new, overwrote ${overwritten} stale`);
|
|
25141
25277
|
}
|
|
@@ -25547,7 +25683,7 @@ function startManager(opts) {
|
|
|
25547
25683
|
log(`[startup] state rehydration failed (continuing with empty state): ${err.message}`);
|
|
25548
25684
|
}
|
|
25549
25685
|
log(
|
|
25550
|
-
`[startup] worker pid=${process.pid} ppid=${process.ppid} node=${process.version} log=${
|
|
25686
|
+
`[startup] worker pid=${process.pid} ppid=${process.ppid} node=${process.version} log=${join44(homedir17(), ".augmented", "manager.log")}`
|
|
25551
25687
|
);
|
|
25552
25688
|
deployMcpAssets();
|
|
25553
25689
|
reapOrphanChannelMcps({ log });
|
|
@@ -25673,14 +25809,14 @@ function restartRunningChannelMcps(basenames) {
|
|
|
25673
25809
|
}
|
|
25674
25810
|
}
|
|
25675
25811
|
function deployMcpAssets() {
|
|
25676
|
-
const targetDir =
|
|
25812
|
+
const targetDir = join44(homedir17(), ".augmented", "_mcp");
|
|
25677
25813
|
mkdirSync16(targetDir, { recursive: true });
|
|
25678
25814
|
const moduleDir = dirname11(fileURLToPath2(import.meta.url));
|
|
25679
25815
|
let mcpSourceDir = "";
|
|
25680
25816
|
let dir = moduleDir;
|
|
25681
25817
|
for (let i = 0; i < 6; i++) {
|
|
25682
|
-
const candidate =
|
|
25683
|
-
if (existsSync19(
|
|
25818
|
+
const candidate = join44(dir, "dist", "mcp");
|
|
25819
|
+
if (existsSync19(join44(candidate, "index.js"))) {
|
|
25684
25820
|
mcpSourceDir = candidate;
|
|
25685
25821
|
break;
|
|
25686
25822
|
}
|
|
@@ -25780,8 +25916,8 @@ function deployMcpAssets() {
|
|
|
25780
25916
|
// natural session restart.
|
|
25781
25917
|
"computer-use-proxy.js"
|
|
25782
25918
|
]) {
|
|
25783
|
-
const src =
|
|
25784
|
-
const dst =
|
|
25919
|
+
const src = join44(mcpSourceDir, file);
|
|
25920
|
+
const dst = join44(targetDir, file);
|
|
25785
25921
|
if (!existsSync19(src)) continue;
|
|
25786
25922
|
attemptedFiles.push(file);
|
|
25787
25923
|
const before = fileHash(dst);
|
|
@@ -25807,14 +25943,14 @@ function deployMcpAssets() {
|
|
|
25807
25943
|
log(`[manager] Bundle(s) updated: ${changedBasenames.join(", ")} \u2014 signalling running instances to restart`);
|
|
25808
25944
|
restartRunningChannelMcps(changedBasenames);
|
|
25809
25945
|
}
|
|
25810
|
-
const localMcpPath =
|
|
25946
|
+
const localMcpPath = join44(targetDir, "index.js");
|
|
25811
25947
|
try {
|
|
25812
|
-
const agentsDir =
|
|
25948
|
+
const agentsDir = join44(homedir17(), ".augmented", "agents");
|
|
25813
25949
|
if (existsSync19(agentsDir)) {
|
|
25814
|
-
for (const entry of
|
|
25950
|
+
for (const entry of readdirSync14(agentsDir, { withFileTypes: true })) {
|
|
25815
25951
|
if (!entry.isDirectory()) continue;
|
|
25816
25952
|
for (const subdir of ["provision", "project"]) {
|
|
25817
|
-
const mcpJsonPath =
|
|
25953
|
+
const mcpJsonPath = join44(agentsDir, entry.name, subdir, ".mcp.json");
|
|
25818
25954
|
try {
|
|
25819
25955
|
const raw = readFileSync34(mcpJsonPath, "utf-8");
|
|
25820
25956
|
if (!raw.includes("@integrity-labs/augmented-mcp")) continue;
|