@integrity-labs/agt-cli 0.28.1267 → 0.28.1269
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{api-client-NGXHG4YA.js → api-client-54VZB3MY.js} +3 -3
- package/dist/bin/agt.js +7 -7
- package/dist/{chunk-UA2UPXYC.js → chunk-BM4Q7VW6.js} +86 -4
- package/dist/chunk-BM4Q7VW6.js.map +1 -0
- package/dist/{chunk-DCI6M6TF.js → chunk-ES3U3RIS.js} +3 -3
- package/dist/{chunk-BMO6GCK2.js → chunk-GLIROXKE.js} +2 -2
- package/dist/{chunk-W2GHPRPZ.js → chunk-LTQTHV7E.js} +1 -1
- package/dist/chunk-LTQTHV7E.js.map +1 -0
- package/dist/{chunk-X2FBQPNR.js → chunk-RNA2BFCX.js} +2 -2
- package/dist/{chunk-SR72T5SB.js → chunk-YB4W3NF3.js} +5 -5
- package/dist/{claude-code-updater-XISTQTZX.js → claude-code-updater-OHXLB7WR.js} +3 -3
- package/dist/{claude-pair-runtime-ASGVKZ5N.js → claude-pair-runtime-XTRWHN5Q.js} +3 -3
- package/dist/lib/manager-worker.js +461 -192
- package/dist/lib/manager-worker.js.map +1 -1
- package/dist/mcp/direct-chat-channel.js +178 -127
- package/dist/mcp/slack-channel.js +6 -1
- package/dist/mcp/telegram-channel.js +6 -1
- package/dist/{persistent-session-FMY2FZEL.js → persistent-session-MX6UHWLR.js} +18 -4
- package/dist/{responsiveness-probe-26TFNDWB.js → responsiveness-probe-GXI34QDS.js} +4 -4
- package/dist/{session-auth-dead-U62KZ342.js → session-auth-dead-UM6LYQ2W.js} +3 -3
- package/package.json +1 -1
- package/dist/chunk-UA2UPXYC.js.map +0 -1
- package/dist/chunk-W2GHPRPZ.js.map +0 -1
- /package/dist/{api-client-NGXHG4YA.js.map → api-client-54VZB3MY.js.map} +0 -0
- /package/dist/{chunk-DCI6M6TF.js.map → chunk-ES3U3RIS.js.map} +0 -0
- /package/dist/{chunk-BMO6GCK2.js.map → chunk-GLIROXKE.js.map} +0 -0
- /package/dist/{chunk-X2FBQPNR.js.map → chunk-RNA2BFCX.js.map} +0 -0
- /package/dist/{chunk-SR72T5SB.js.map → chunk-YB4W3NF3.js.map} +0 -0
- /package/dist/{claude-code-updater-XISTQTZX.js.map → claude-code-updater-OHXLB7WR.js.map} +0 -0
- /package/dist/{claude-pair-runtime-ASGVKZ5N.js.map → claude-pair-runtime-XTRWHN5Q.js.map} +0 -0
- /package/dist/{persistent-session-FMY2FZEL.js.map → persistent-session-MX6UHWLR.js.map} +0 -0
- /package/dist/{responsiveness-probe-26TFNDWB.js.map → responsiveness-probe-GXI34QDS.js.map} +0 -0
- /package/dist/{session-auth-dead-U62KZ342.js.map → session-auth-dead-UM6LYQ2W.js.map} +0 -0
|
@@ -70,7 +70,7 @@ import {
|
|
|
70
70
|
tripClass,
|
|
71
71
|
writeEtcEnvironment,
|
|
72
72
|
writeProfileDScript
|
|
73
|
-
} from "../chunk-
|
|
73
|
+
} from "../chunk-YB4W3NF3.js";
|
|
74
74
|
import {
|
|
75
75
|
ApiError,
|
|
76
76
|
adoptHostKeyInProcess,
|
|
@@ -88,7 +88,7 @@ import {
|
|
|
88
88
|
probeHostKey,
|
|
89
89
|
requireHost,
|
|
90
90
|
setConfigHash
|
|
91
|
-
} from "../chunk-
|
|
91
|
+
} from "../chunk-ES3U3RIS.js";
|
|
92
92
|
import {
|
|
93
93
|
BLOCKED_ON_PROMPT_DECISION,
|
|
94
94
|
CHANNEL_SECRET_ENV_KEYS,
|
|
@@ -125,6 +125,7 @@ import {
|
|
|
125
125
|
isOpencodeSessionHealthy,
|
|
126
126
|
isSessionHealthy,
|
|
127
127
|
isolationMode,
|
|
128
|
+
killStragglerProcess,
|
|
128
129
|
log,
|
|
129
130
|
mergeOpencodeConfigArtifact,
|
|
130
131
|
modelPolicyAuthComponent,
|
|
@@ -138,6 +139,8 @@ import {
|
|
|
138
139
|
policyResolvedModel,
|
|
139
140
|
prepareForRespawn,
|
|
140
141
|
probeClaudeProcessInTmux,
|
|
142
|
+
probeSessionProcess,
|
|
143
|
+
probeSessionProcessOlderThan,
|
|
141
144
|
probeTmuxSession,
|
|
142
145
|
readChannelServerEnv,
|
|
143
146
|
readDirectChatSessionState,
|
|
@@ -175,7 +178,7 @@ import {
|
|
|
175
178
|
webFetchBaselineValue,
|
|
176
179
|
webFetchRestartNeeded,
|
|
177
180
|
writeEgressAllowlist
|
|
178
|
-
} from "../chunk-
|
|
181
|
+
} from "../chunk-BM4Q7VW6.js";
|
|
179
182
|
import {
|
|
180
183
|
isAgentIdle,
|
|
181
184
|
isStaleForToday,
|
|
@@ -186,7 +189,7 @@ import {
|
|
|
186
189
|
subagentActivityAgeSeconds,
|
|
187
190
|
subagentTranscriptDir,
|
|
188
191
|
transcriptActivityAgeSeconds
|
|
189
|
-
} from "../chunk-
|
|
192
|
+
} from "../chunk-RNA2BFCX.js";
|
|
190
193
|
import {
|
|
191
194
|
classifyUnanswerablePane,
|
|
192
195
|
focusedConfirmDialogBlock,
|
|
@@ -212,7 +215,7 @@ import {
|
|
|
212
215
|
runSafeCleanup,
|
|
213
216
|
tightestDiskStat,
|
|
214
217
|
withPackageCacheLock
|
|
215
|
-
} from "../chunk-
|
|
218
|
+
} from "../chunk-GLIROXKE.js";
|
|
216
219
|
import {
|
|
217
220
|
parsePsRows,
|
|
218
221
|
reapOrphanChannelMcps
|
|
@@ -340,7 +343,7 @@ import {
|
|
|
340
343
|
stabiliseResetInstant,
|
|
341
344
|
sumTranscriptUsageInWindow,
|
|
342
345
|
summarizeTranscriptActivity
|
|
343
|
-
} from "../chunk-
|
|
346
|
+
} from "../chunk-LTQTHV7E.js";
|
|
344
347
|
import {
|
|
345
348
|
CLAUDE_CONFIG_DIR_ENV,
|
|
346
349
|
claudeConfigDirFor,
|
|
@@ -454,15 +457,31 @@ function configReloadConfirmed(input) {
|
|
|
454
457
|
var ConfigReloadLedger = class {
|
|
455
458
|
pending = /* @__PURE__ */ new Map();
|
|
456
459
|
confirmed = /* @__PURE__ */ new Set();
|
|
460
|
+
/**
|
|
461
|
+
* ENG-12052: when the FIRST fresh render for the pending reload landed. A
|
|
462
|
+
* session started at or after it was started from fresh config, so the
|
|
463
|
+
* reload retry must never stop it (stopping it is the kill/respawn loop
|
|
464
|
+
* b4cfce82 hit). Cleared whenever the reload is re-torn-down or acked.
|
|
465
|
+
*/
|
|
466
|
+
freshRenderAt = /* @__PURE__ */ new Map();
|
|
457
467
|
/** What the poll does with this agent's integration-change request. Records a teardown. */
|
|
458
468
|
service(agentId, requested) {
|
|
459
469
|
const action = configReloadAction({ requested, pendingRequested: this.pending.get(agentId) });
|
|
460
470
|
if (action === "teardown") {
|
|
461
471
|
this.pending.set(agentId, requested);
|
|
462
472
|
this.confirmed.delete(agentId);
|
|
473
|
+
this.freshRenderAt.delete(agentId);
|
|
463
474
|
}
|
|
464
475
|
return action;
|
|
465
476
|
}
|
|
477
|
+
/** ENG-12052: a fresh render landed for the pending reload; keeps the earliest. */
|
|
478
|
+
noteFreshRender(agentId, atMs) {
|
|
479
|
+
if (this.pending.has(agentId) && !this.freshRenderAt.has(agentId)) this.freshRenderAt.set(agentId, atMs);
|
|
480
|
+
}
|
|
481
|
+
/** ENG-12052: when the pending reload's first fresh render landed, or null. */
|
|
482
|
+
freshRenderedAt(agentId) {
|
|
483
|
+
return this.freshRenderAt.get(agentId) ?? null;
|
|
484
|
+
}
|
|
466
485
|
isPending(agentId) {
|
|
467
486
|
return this.pending.has(agentId);
|
|
468
487
|
}
|
|
@@ -478,6 +497,7 @@ var ConfigReloadLedger = class {
|
|
|
478
497
|
const requestedAt = this.pending.get(agentId);
|
|
479
498
|
this.confirmed.delete(agentId);
|
|
480
499
|
this.pending.delete(agentId);
|
|
500
|
+
this.freshRenderAt.delete(agentId);
|
|
481
501
|
if (requestedAt) out.push({ agentId, requestedAt });
|
|
482
502
|
}
|
|
483
503
|
return out;
|
|
@@ -486,6 +506,7 @@ var ConfigReloadLedger = class {
|
|
|
486
506
|
forget(agentId) {
|
|
487
507
|
this.pending.delete(agentId);
|
|
488
508
|
this.confirmed.delete(agentId);
|
|
509
|
+
this.freshRenderAt.delete(agentId);
|
|
489
510
|
}
|
|
490
511
|
};
|
|
491
512
|
function stampIsOlder(a, b) {
|
|
@@ -534,38 +555,168 @@ function staleSessionStopConfirmed(sessionState) {
|
|
|
534
555
|
}
|
|
535
556
|
|
|
536
557
|
// src/lib/config-reload-confirm.ts
|
|
558
|
+
var UNKNOWN_ALERT_AFTER_MS = 10 * 6e4;
|
|
537
559
|
function staleReloadTmuxSession(framework, codeName) {
|
|
538
560
|
return framework === "opencode" ? opencodeTmuxSession(codeName) : `agt-${codeName}`;
|
|
539
561
|
}
|
|
562
|
+
var UnknownStreak = class {
|
|
563
|
+
since = /* @__PURE__ */ new Map();
|
|
564
|
+
alertedAt = /* @__PURE__ */ new Map();
|
|
565
|
+
count = /* @__PURE__ */ new Map();
|
|
566
|
+
/** `count` is how many times in a row this key was noted (1 on the first). */
|
|
567
|
+
note(agentId, nowMs) {
|
|
568
|
+
const start = this.since.get(agentId) ?? nowMs;
|
|
569
|
+
this.since.set(agentId, start);
|
|
570
|
+
const count = (this.count.get(agentId) ?? 0) + 1;
|
|
571
|
+
this.count.set(agentId, count);
|
|
572
|
+
const forMs = nowMs - start;
|
|
573
|
+
const last = this.alertedAt.get(agentId);
|
|
574
|
+
const due = forMs >= UNKNOWN_ALERT_AFTER_MS && (last === void 0 || nowMs - last >= UNKNOWN_ALERT_AFTER_MS);
|
|
575
|
+
if (due) this.alertedAt.set(agentId, nowMs);
|
|
576
|
+
return { alert: due, forMs, count };
|
|
577
|
+
}
|
|
578
|
+
clear(agentId) {
|
|
579
|
+
this.since.delete(agentId);
|
|
580
|
+
this.alertedAt.delete(agentId);
|
|
581
|
+
this.count.delete(agentId);
|
|
582
|
+
}
|
|
583
|
+
};
|
|
540
584
|
function confirmConfigReload(input, deps) {
|
|
585
|
+
let held = false;
|
|
586
|
+
const out = confirmConfigReloadOnce(input, deps, () => {
|
|
587
|
+
held = true;
|
|
588
|
+
});
|
|
589
|
+
if (!held && !(out.action === "not_ready" && input.pending)) deps.unknownStreak?.clear(input.agentId);
|
|
590
|
+
return out;
|
|
591
|
+
}
|
|
592
|
+
function confirmConfigReloadOnce(input, deps, onHold) {
|
|
541
593
|
if (!configReloadConfirmed({ pending: input.pending, freshFetch: input.freshFetch, rendered: input.rendered })) {
|
|
542
594
|
return { action: "not_ready" };
|
|
543
595
|
}
|
|
596
|
+
const now = deps.now ?? Date.now;
|
|
597
|
+
const claudeCode = input.framework !== "opencode";
|
|
544
598
|
const session = staleReloadTmuxSession(input.framework, input.codeName);
|
|
599
|
+
const holdUnknown = (what) => {
|
|
600
|
+
onHold();
|
|
601
|
+
const streak = deps.unknownStreak?.note(input.agentId, now());
|
|
602
|
+
if (streak?.alert) {
|
|
603
|
+
deps.alert?.(
|
|
604
|
+
input.agentId,
|
|
605
|
+
`config-change reload for '${input.codeName}' has been unconfirmable for ${Math.round(streak.forMs / 6e4)} min (${what}); it stays pending, and the agent may still be running pre-reload config (ENG-12052)`
|
|
606
|
+
);
|
|
607
|
+
}
|
|
608
|
+
};
|
|
545
609
|
let stopped = false;
|
|
546
610
|
if (deps.probe(session) === "alive") {
|
|
611
|
+
const spawnedAt = claudeCode && deps.sessionSpawnedAt ? deps.sessionSpawnedAt(input.codeName) : void 0;
|
|
612
|
+
const freshAt = input.freshRenderedAt ?? null;
|
|
613
|
+
if (spawnedAt !== void 0 && spawnedAt !== null && freshAt !== null && spawnedAt >= freshAt) {
|
|
614
|
+
const blind = claudeCode && deps.spawnedBlind?.(input.codeName);
|
|
615
|
+
const olderState = blind && deps.probeProcessOlderThan ? deps.probeProcessOlderThan(input.codeName, (now() - spawnedAt) / 1e3 + BLIND_SPAWN_AGE_MARGIN_S) : "unknown";
|
|
616
|
+
if (blind && olderState === "dead") {
|
|
617
|
+
deps.clearBlind?.(input.codeName);
|
|
618
|
+
deps.log(
|
|
619
|
+
`[restart] RELOAD_FRESH_SESSION_VERIFIED agent='${input.codeName}': no session process predates the blind spawn, so no pre-reload straggler survived it (ENG-12052)`
|
|
620
|
+
);
|
|
621
|
+
} else if (blind) {
|
|
622
|
+
deps.log(
|
|
623
|
+
`[restart] RELOAD_FRESH_SESSION_UNVERIFIED agent='${input.codeName}': the running session was started from the fresh render, but while it could not be told whether a pre-reload process was still running, so the reload stays pending (ENG-12052)`
|
|
624
|
+
);
|
|
625
|
+
holdUnknown(
|
|
626
|
+
olderState === "alive" ? "a session process older than the current session is still running beside it (a pre-reload straggler)" : "the session was started while the previous session process could not be probed"
|
|
627
|
+
);
|
|
628
|
+
return { action: "process_unconfirmed", processState: olderState === "alive" ? "alive" : "unknown", stopped: false };
|
|
629
|
+
}
|
|
630
|
+
deps.unknownStreak?.clear(input.agentId);
|
|
631
|
+
deps.confirm(input.agentId);
|
|
632
|
+
deps.log(
|
|
633
|
+
`[restart] config-change reload for '${input.codeName}': the running session was started from the fresh render - acking without a restart (ENG-12052)`
|
|
634
|
+
);
|
|
635
|
+
return { action: "acked", stopped: false, fresh: true };
|
|
636
|
+
}
|
|
637
|
+
if (spawnedAt !== void 0 && (spawnedAt === null || freshAt === null)) {
|
|
638
|
+
deps.log(
|
|
639
|
+
`[restart] RELOAD_GENERATION_UNKNOWN agent='${input.codeName}' spawned_at=${spawnedAt ?? "unknown"} fresh_render_at=${freshAt ?? "unknown"}: cannot tell whether the running session predates the fresh render, so it is not stopped and the reload stays pending (ENG-12052)`
|
|
640
|
+
);
|
|
641
|
+
holdUnknown("the running session's start time or the fresh render time is unknown");
|
|
642
|
+
return { action: "generation_unknown" };
|
|
643
|
+
}
|
|
547
644
|
deps.log(
|
|
548
645
|
`[restart] '${input.codeName}' is running config from before the reload's fresh render - restarting it (ENG-11912)`
|
|
549
646
|
);
|
|
550
|
-
if (
|
|
551
|
-
else deps.
|
|
647
|
+
if (claudeCode) deps.stopClaudeCode(input.codeName);
|
|
648
|
+
else deps.stopOpencode(input.codeName);
|
|
552
649
|
stopped = true;
|
|
553
650
|
}
|
|
554
651
|
const sessionState = deps.probe(session);
|
|
555
|
-
if (staleSessionStopConfirmed(sessionState)) {
|
|
556
|
-
deps.
|
|
557
|
-
|
|
558
|
-
|
|
652
|
+
if (!staleSessionStopConfirmed(sessionState)) {
|
|
653
|
+
deps.log(
|
|
654
|
+
`[restart] STALE_SESSION_STOP_FAILED agent='${input.codeName}' session_state=${sessionState}: the session spawned from pre-reload config is still running or could not be probed, so the config-change reload stays pending and the stop is retried next poll (ENG-11912)`
|
|
655
|
+
);
|
|
656
|
+
if (sessionState === "unknown") holdUnknown("the tmux probe cannot answer");
|
|
657
|
+
return { action: "stop_unconfirmed", sessionState, stopped };
|
|
658
|
+
}
|
|
659
|
+
if (claudeCode && deps.probeProcess) {
|
|
660
|
+
const processState = deps.probeProcess(input.codeName);
|
|
661
|
+
if (processState !== "dead") {
|
|
662
|
+
deps.log(
|
|
663
|
+
`[restart] STALE_SESSION_PROCESS_ALIVE agent='${input.codeName}' process_state=${processState}: tmux is gone but a session process ${processState === "alive" ? "is still running" : "could not be probed"} with pre-reload config, so the reload stays pending; the spawn gate stops a live straggler before any respawn (ENG-12052)`
|
|
664
|
+
);
|
|
665
|
+
if (processState === "unknown") holdUnknown("the session process probe cannot answer");
|
|
666
|
+
return { action: "process_unconfirmed", processState, stopped };
|
|
667
|
+
}
|
|
668
|
+
}
|
|
669
|
+
deps.unknownStreak?.clear(input.agentId);
|
|
670
|
+
deps.confirm(input.agentId);
|
|
671
|
+
deps.log(`[restart] config-change reload for '${input.codeName}' rendered from fresh integrations - acking (ENG-11912)`);
|
|
672
|
+
return { action: "acked", stopped };
|
|
673
|
+
}
|
|
674
|
+
var BLIND_SPAWN_AGE_MARGIN_S = 5;
|
|
675
|
+
var STRAGGLER_TERM_ATTEMPTS = 2;
|
|
676
|
+
function stragglerSpawnGate(codeName, deps) {
|
|
677
|
+
const tmux = deps.probeTmux?.(codeName) ?? "dead";
|
|
678
|
+
if (tmux !== "dead") {
|
|
679
|
+
deps.deferStreak?.clear(codeName);
|
|
680
|
+
deps.log(
|
|
681
|
+
`[persistent-session] '${codeName}': STRAGGLER_GATE_TMUX_${tmux.toUpperCase()} - tmux does not confirm the session is gone, so a claude process for it may be the current session; nothing signalled (ENG-12052)`
|
|
682
|
+
);
|
|
683
|
+
return "spawn-unknown";
|
|
684
|
+
}
|
|
685
|
+
const state10 = deps.probeProcess(codeName);
|
|
686
|
+
if (state10 !== "alive") deps.deferStreak?.clear(codeName);
|
|
687
|
+
if (state10 === "dead") return "spawn";
|
|
688
|
+
if (state10 === "unknown") {
|
|
689
|
+
deps.log(
|
|
690
|
+
`[persistent-session] '${codeName}': STRAGGLER_PROBE_UNKNOWN - cannot tell whether a previous session process is still running; spawning anyway so the agent is not held offline (ENG-12052)`
|
|
691
|
+
);
|
|
692
|
+
return "spawn-unknown";
|
|
559
693
|
}
|
|
694
|
+
if (deps.isDocker(codeName)) {
|
|
695
|
+
deps.deferStreak?.clear(codeName);
|
|
696
|
+
deps.log(
|
|
697
|
+
`[persistent-session] '${codeName}': a previous session's container is still running; the spawn's docker rm -f removes it before the new one starts (ENG-12052)`
|
|
698
|
+
);
|
|
699
|
+
return "spawn-docker-replaces";
|
|
700
|
+
}
|
|
701
|
+
const streak = deps.deferStreak?.note(codeName, (deps.now ?? Date.now)());
|
|
702
|
+
const attempt = streak?.count ?? 1;
|
|
703
|
+
const signal = attempt > STRAGGLER_TERM_ATTEMPTS ? "KILL" : "TERM";
|
|
704
|
+
const signalled = deps.killStraggler(codeName, signal);
|
|
560
705
|
deps.log(
|
|
561
|
-
`[
|
|
706
|
+
`[persistent-session] '${codeName}': deferring spawn - STRAGGLER_ALIVE (attempt ${attempt}): a previous claude process outlived its tmux session and still runs pre-reload config; ${signalled ? `sent it SIG${signal}` : `SIG${signal} matched nothing or failed`}. Not counted as a restart; the next poll re-probes before spawning (ENG-12052)`
|
|
562
707
|
);
|
|
563
|
-
|
|
708
|
+
if (streak?.alert) {
|
|
709
|
+
deps.alert?.(
|
|
710
|
+
codeName,
|
|
711
|
+
`agent '${codeName}' has been held offline for ${Math.round(streak.forMs / 6e4)} min by a previous claude process that survives ${signal === "KILL" ? "SIGTERM and SIGKILL" : "SIGTERM (SIGKILL follows from the next attempt)"} (${attempt} attempts); it is not respawned beside it because it runs pre-reload config. Kill it by hand if it persists (ENG-12052)`
|
|
712
|
+
);
|
|
713
|
+
}
|
|
714
|
+
return "defer";
|
|
564
715
|
}
|
|
565
716
|
|
|
566
717
|
// src/lib/manager-worker.ts
|
|
567
718
|
import { createHash as createHash21 } from "crypto";
|
|
568
|
-
import { readFileSync as
|
|
719
|
+
import { readFileSync as readFileSync38, writeFileSync as writeFileSync20, mkdirSync as mkdirSync18, existsSync as existsSync20, rmSync as rmSync9, readdirSync as readdirSync14, statSync as statSync15, unlinkSync as unlinkSync6, renameSync as renameSync12, utimesSync as utimesSync4, readlinkSync as readlinkSync2 } from "fs";
|
|
569
720
|
|
|
570
721
|
// src/lib/atomic-file-replace.ts
|
|
571
722
|
import { copyFileSync, renameSync, unlinkSync } from "fs";
|
|
@@ -982,7 +1133,7 @@ function clearEpisode(codeName) {
|
|
|
982
1133
|
}
|
|
983
1134
|
|
|
984
1135
|
// src/lib/manager-worker.ts
|
|
985
|
-
import { join as
|
|
1136
|
+
import { join as join47, dirname as dirname11, delimiter as pathDelimiter } from "path";
|
|
986
1137
|
import { homedir as homedir17, hostname, platform as platform3 } from "os";
|
|
987
1138
|
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
988
1139
|
|
|
@@ -3554,11 +3705,11 @@ function isPathInsideDir(candidate, dir) {
|
|
|
3554
3705
|
}
|
|
3555
3706
|
function findMissingMcpBundles(mcpConfigPath, deps = {}) {
|
|
3556
3707
|
const existsSync21 = deps.existsSync ?? nodeExistsSync;
|
|
3557
|
-
const
|
|
3708
|
+
const readFileSync39 = deps.readFileSync ?? nodeReadFileSync;
|
|
3558
3709
|
const mcpDir = deps.mcpDir ?? getSharedMcpDir();
|
|
3559
3710
|
let parsed;
|
|
3560
3711
|
try {
|
|
3561
|
-
parsed = JSON.parse(
|
|
3712
|
+
parsed = JSON.parse(readFileSync39(mcpConfigPath, "utf-8"));
|
|
3562
3713
|
} catch {
|
|
3563
3714
|
return [];
|
|
3564
3715
|
}
|
|
@@ -12059,6 +12210,57 @@ var BlockedPromptReportCadence = class {
|
|
|
12059
12210
|
}
|
|
12060
12211
|
};
|
|
12061
12212
|
|
|
12213
|
+
// ../../packages/core/dist/runtime/direct-chat-inflight.js
|
|
12214
|
+
import { renameSync as renameSync9, readFileSync as readFileSync33, writeFileSync as writeFileSync16 } from "fs";
|
|
12215
|
+
import { join as join42 } from "path";
|
|
12216
|
+
var DIRECT_CHAT_INFLIGHT_FILE = "direct-chat-inflight.json";
|
|
12217
|
+
var DIRECT_CHAT_INFLIGHT_MAX_AGE_MS = 5 * 6e4;
|
|
12218
|
+
function directChatInflightPath(agentDir) {
|
|
12219
|
+
return join42(agentDir, DIRECT_CHAT_INFLIGHT_FILE);
|
|
12220
|
+
}
|
|
12221
|
+
function decideDirectChatInflight(input) {
|
|
12222
|
+
if (input.raw === null)
|
|
12223
|
+
return { inFlight: false, reason: "absent" };
|
|
12224
|
+
if (typeof input.raw !== "string")
|
|
12225
|
+
return { inFlight: false, reason: "unreadable" };
|
|
12226
|
+
let m;
|
|
12227
|
+
try {
|
|
12228
|
+
m = JSON.parse(input.raw);
|
|
12229
|
+
} catch {
|
|
12230
|
+
return { inFlight: false, reason: "unreadable" };
|
|
12231
|
+
}
|
|
12232
|
+
const rec = m;
|
|
12233
|
+
if (!rec || typeof rec !== "object" || !Array.isArray(rec.ids) || typeof rec.since_ms !== "number" || typeof rec.pid !== "number") {
|
|
12234
|
+
return { inFlight: false, reason: "unreadable" };
|
|
12235
|
+
}
|
|
12236
|
+
const ids = rec.ids.filter((x) => typeof x === "string" && x.length > 0);
|
|
12237
|
+
if (ids.length === 0)
|
|
12238
|
+
return { inFlight: false, reason: "empty" };
|
|
12239
|
+
if (!Number.isFinite(rec.since_ms) || input.nowMs - rec.since_ms > DIRECT_CHAT_INFLIGHT_MAX_AGE_MS) {
|
|
12240
|
+
return { inFlight: false, reason: "stale" };
|
|
12241
|
+
}
|
|
12242
|
+
if (!Number.isInteger(rec.pid) || rec.pid <= 0 || !input.pidAlive(rec.pid))
|
|
12243
|
+
return { inFlight: false, reason: "pid_dead" };
|
|
12244
|
+
return { inFlight: true, ids };
|
|
12245
|
+
}
|
|
12246
|
+
function processIsAlive(pid) {
|
|
12247
|
+
try {
|
|
12248
|
+
process.kill(pid, 0);
|
|
12249
|
+
return true;
|
|
12250
|
+
} catch (err) {
|
|
12251
|
+
return err?.code === "EPERM";
|
|
12252
|
+
}
|
|
12253
|
+
}
|
|
12254
|
+
function readDirectChatInflight(agentDir, nowMs = Date.now(), pidAlive = processIsAlive, read = (p) => readFileSync33(p, "utf8")) {
|
|
12255
|
+
let raw;
|
|
12256
|
+
try {
|
|
12257
|
+
raw = read(directChatInflightPath(agentDir));
|
|
12258
|
+
} catch (err) {
|
|
12259
|
+
raw = err?.code === "ENOENT" ? null : { error: err };
|
|
12260
|
+
}
|
|
12261
|
+
return decideDirectChatInflight({ raw, nowMs, pidAlive });
|
|
12262
|
+
}
|
|
12263
|
+
|
|
12062
12264
|
// src/lib/agent-spawn-lock.ts
|
|
12063
12265
|
var tails = /* @__PURE__ */ new Map();
|
|
12064
12266
|
async function acquireAgentSpawnLock(agentId) {
|
|
@@ -12112,7 +12314,7 @@ function respawnedByAnotherCaller(decision, healthyAfter, sessionStartedAt, lane
|
|
|
12112
12314
|
|
|
12113
12315
|
// src/lib/occupancy-gate.ts
|
|
12114
12316
|
import { closeSync as closeSync5, openSync as openSync5, readdirSync as readdirSync11, readSync as readSync4, statSync as statSync13 } from "fs";
|
|
12115
|
-
import { join as
|
|
12317
|
+
import { join as join43 } from "path";
|
|
12116
12318
|
function rostersMeasuredZero(mode, attested, runtimeRunning) {
|
|
12117
12319
|
return mode === "enforce" && attested && runtimeRunning;
|
|
12118
12320
|
}
|
|
@@ -12203,10 +12405,10 @@ function candidateTranscriptPaths(dir) {
|
|
|
12203
12405
|
let complete = true;
|
|
12204
12406
|
for (const name of top) {
|
|
12205
12407
|
if (name.endsWith(".jsonl")) {
|
|
12206
|
-
paths.push(
|
|
12408
|
+
paths.push(join43(dir, name));
|
|
12207
12409
|
continue;
|
|
12208
12410
|
}
|
|
12209
|
-
const subDir =
|
|
12411
|
+
const subDir = join43(dir, name, "subagents");
|
|
12210
12412
|
let subs;
|
|
12211
12413
|
try {
|
|
12212
12414
|
subs = readdirSync11(subDir);
|
|
@@ -12215,7 +12417,7 @@ function candidateTranscriptPaths(dir) {
|
|
|
12215
12417
|
continue;
|
|
12216
12418
|
}
|
|
12217
12419
|
for (const sub of subs) {
|
|
12218
|
-
if (sub.endsWith(".jsonl")) paths.push(
|
|
12420
|
+
if (sub.endsWith(".jsonl")) paths.push(join43(subDir, sub));
|
|
12219
12421
|
}
|
|
12220
12422
|
}
|
|
12221
12423
|
return { paths, complete };
|
|
@@ -12441,7 +12643,7 @@ function stopPaneOccupancySampler() {
|
|
|
12441
12643
|
}
|
|
12442
12644
|
|
|
12443
12645
|
// src/lib/pid-pressure-sampler.ts
|
|
12444
|
-
import { existsSync as existsSync17, readFileSync as
|
|
12646
|
+
import { existsSync as existsSync17, readFileSync as readFileSync34 } from "fs";
|
|
12445
12647
|
var SAMPLE_INTERVAL_MS2 = 3e4;
|
|
12446
12648
|
function warnFraction() {
|
|
12447
12649
|
const raw = Number(process.env.AGT_PID_PRESSURE_WARN_FRACTION);
|
|
@@ -12469,7 +12671,7 @@ function parseMemoryEvents(text) {
|
|
|
12469
12671
|
}
|
|
12470
12672
|
function readTextReal(path) {
|
|
12471
12673
|
try {
|
|
12472
|
-
return
|
|
12674
|
+
return readFileSync34(path, "utf-8");
|
|
12473
12675
|
} catch {
|
|
12474
12676
|
return null;
|
|
12475
12677
|
}
|
|
@@ -13851,9 +14053,9 @@ async function fireOpencodeScheduledTask(agent, task) {
|
|
|
13851
14053
|
|
|
13852
14054
|
// src/lib/opencode-telegram-ingest.ts
|
|
13853
14055
|
import { createHash as createHash20 } from "crypto";
|
|
13854
|
-
import { existsSync as existsSync18, mkdirSync as mkdirSync15, readFileSync as
|
|
14056
|
+
import { existsSync as existsSync18, mkdirSync as mkdirSync15, readFileSync as readFileSync35, renameSync as renameSync10, unlinkSync as unlinkSync4, writeFileSync as writeFileSync17 } from "fs";
|
|
13855
14057
|
import { randomUUID } from "crypto";
|
|
13856
|
-
import { join as
|
|
14058
|
+
import { join as join44 } from "path";
|
|
13857
14059
|
|
|
13858
14060
|
// src/lib/telegram-ingest.ts
|
|
13859
14061
|
import https2 from "https";
|
|
@@ -14556,7 +14758,7 @@ function createFileOffsetStore(codeName, log2, currentBotId) {
|
|
|
14556
14758
|
let filePath;
|
|
14557
14759
|
try {
|
|
14558
14760
|
dir = getFramework("opencode").getAgentDir(codeName);
|
|
14559
|
-
filePath =
|
|
14761
|
+
filePath = join44(dir, "telegram-getupdates-offset-opencode.json");
|
|
14560
14762
|
} catch {
|
|
14561
14763
|
dir = null;
|
|
14562
14764
|
filePath = null;
|
|
@@ -14565,7 +14767,7 @@ function createFileOffsetStore(codeName, log2, currentBotId) {
|
|
|
14565
14767
|
load() {
|
|
14566
14768
|
if (!filePath) return 0;
|
|
14567
14769
|
try {
|
|
14568
|
-
const parsed = JSON.parse(
|
|
14770
|
+
const parsed = JSON.parse(readFileSync35(filePath, "utf-8"));
|
|
14569
14771
|
if (currentBotId != null && typeof parsed?.bot_id === "number" && parsed.bot_id !== currentBotId) {
|
|
14570
14772
|
log2(`[telegram-ingest:${codeName}] offset cursor belongs to a different bot; ignoring (bot swap)`);
|
|
14571
14773
|
return 0;
|
|
@@ -14584,7 +14786,7 @@ function createFileOffsetStore(codeName, log2, currentBotId) {
|
|
|
14584
14786
|
const tmpPath = `${filePath}.${process.pid}.${randomUUID()}.tmp`;
|
|
14585
14787
|
try {
|
|
14586
14788
|
mkdirSync15(dir, { recursive: true, mode: 448 });
|
|
14587
|
-
|
|
14789
|
+
writeFileSync17(
|
|
14588
14790
|
tmpPath,
|
|
14589
14791
|
JSON.stringify({
|
|
14590
14792
|
offset,
|
|
@@ -14594,7 +14796,7 @@ function createFileOffsetStore(codeName, log2, currentBotId) {
|
|
|
14594
14796
|
}),
|
|
14595
14797
|
{ mode: 384 }
|
|
14596
14798
|
);
|
|
14597
|
-
|
|
14799
|
+
renameSync10(tmpPath, filePath);
|
|
14598
14800
|
} catch (err) {
|
|
14599
14801
|
log2(`[telegram-ingest:${codeName}] offset persist failed: ${err instanceof Error ? err.message : String(err)}`);
|
|
14600
14802
|
try {
|
|
@@ -14610,7 +14812,7 @@ function createFileMigrationReportIO(codeName, log2) {
|
|
|
14610
14812
|
let filePath;
|
|
14611
14813
|
try {
|
|
14612
14814
|
dir = getFramework("opencode").getAgentDir(codeName);
|
|
14613
|
-
filePath =
|
|
14815
|
+
filePath = join44(dir, "telegram-migration-reports-opencode.json");
|
|
14614
14816
|
} catch {
|
|
14615
14817
|
dir = null;
|
|
14616
14818
|
filePath = null;
|
|
@@ -14619,7 +14821,7 @@ function createFileMigrationReportIO(codeName, log2) {
|
|
|
14619
14821
|
load() {
|
|
14620
14822
|
if (!filePath) return null;
|
|
14621
14823
|
try {
|
|
14622
|
-
return
|
|
14824
|
+
return readFileSync35(filePath, "utf-8");
|
|
14623
14825
|
} catch {
|
|
14624
14826
|
return null;
|
|
14625
14827
|
}
|
|
@@ -14636,7 +14838,7 @@ function createFileMigrationReportIO(codeName, log2) {
|
|
|
14636
14838
|
};
|
|
14637
14839
|
}
|
|
14638
14840
|
var managerHostPost = async (path, body) => {
|
|
14639
|
-
const { api: api2, ApiError: ApiError3 } = await import("../api-client-
|
|
14841
|
+
const { api: api2, ApiError: ApiError3 } = await import("../api-client-54VZB3MY.js");
|
|
14640
14842
|
try {
|
|
14641
14843
|
const json = await api2.post(path, body);
|
|
14642
14844
|
return { status: 200, json };
|
|
@@ -14902,15 +15104,15 @@ function partitionActionableByPoison(actionable, states, config2) {
|
|
|
14902
15104
|
}
|
|
14903
15105
|
|
|
14904
15106
|
// src/lib/restart-flags.ts
|
|
14905
|
-
import { existsSync as existsSync19, mkdirSync as mkdirSync16, readdirSync as readdirSync12, readFileSync as
|
|
15107
|
+
import { existsSync as existsSync19, mkdirSync as mkdirSync16, readdirSync as readdirSync12, readFileSync as readFileSync36, renameSync as renameSync11, rmSync as rmSync8, writeFileSync as writeFileSync18 } from "fs";
|
|
14906
15108
|
import { homedir as homedir16 } from "os";
|
|
14907
|
-
import { join as
|
|
15109
|
+
import { join as join45 } from "path";
|
|
14908
15110
|
import { randomUUID as randomUUID2 } from "crypto";
|
|
14909
15111
|
function restartFlagsDir() {
|
|
14910
|
-
return
|
|
15112
|
+
return join45(homedir16(), ".augmented", "restart-flags");
|
|
14911
15113
|
}
|
|
14912
15114
|
function flagPath(codeName) {
|
|
14913
|
-
return
|
|
15115
|
+
return join45(restartFlagsDir(), `${codeName}.flag`);
|
|
14914
15116
|
}
|
|
14915
15117
|
function readRestartFlags() {
|
|
14916
15118
|
const dir = restartFlagsDir();
|
|
@@ -14919,7 +15121,7 @@ function readRestartFlags() {
|
|
|
14919
15121
|
for (const entry of readdirSync12(dir)) {
|
|
14920
15122
|
if (!entry.endsWith(".flag")) continue;
|
|
14921
15123
|
try {
|
|
14922
|
-
const raw =
|
|
15124
|
+
const raw = readFileSync36(join45(dir, entry), "utf8");
|
|
14923
15125
|
const parsed = JSON.parse(raw);
|
|
14924
15126
|
if (typeof parsed.codeName !== "string" || parsed.codeName.length === 0) {
|
|
14925
15127
|
parsed.codeName = entry.replace(/\.flag$/, "");
|
|
@@ -15037,8 +15239,8 @@ async function sendError(flag, opts, text) {
|
|
|
15037
15239
|
}
|
|
15038
15240
|
|
|
15039
15241
|
// src/lib/restart-context.ts
|
|
15040
|
-
import { readdirSync as readdirSync13, readFileSync as
|
|
15041
|
-
import { dirname as dirname10, join as
|
|
15242
|
+
import { readdirSync as readdirSync13, readFileSync as readFileSync37, writeFileSync as writeFileSync19, mkdirSync as mkdirSync17, unlinkSync as unlinkSync5 } from "fs";
|
|
15243
|
+
import { dirname as dirname10, join as join46 } from "path";
|
|
15042
15244
|
var SLACK_PENDING_INBOUND_DIRNAME = "slack-pending-inbound";
|
|
15043
15245
|
var SLACK_RESTART_CONTEXT_DIRNAME = "slack-restart-context";
|
|
15044
15246
|
var MAX_TOPIC_CHARS = 140;
|
|
@@ -15050,10 +15252,10 @@ function augmentedAgentDir(codeName) {
|
|
|
15050
15252
|
return dirname10(getProjectDir(codeName));
|
|
15051
15253
|
}
|
|
15052
15254
|
function slackPendingInboundDir(codeName) {
|
|
15053
|
-
return
|
|
15255
|
+
return join46(augmentedAgentDir(codeName), SLACK_PENDING_INBOUND_DIRNAME);
|
|
15054
15256
|
}
|
|
15055
15257
|
function slackRestartContextDir(codeName) {
|
|
15056
|
-
return
|
|
15258
|
+
return join46(augmentedAgentDir(codeName), SLACK_RESTART_CONTEXT_DIRNAME);
|
|
15057
15259
|
}
|
|
15058
15260
|
function sanitizeTopic(raw) {
|
|
15059
15261
|
const cleaned = raw.replace(/\s+/g, " ").trim().replace(/[<>]/g, " ").replace(/\s+/g, " ").trim();
|
|
@@ -15095,7 +15297,7 @@ function safeReaddir(dir) {
|
|
|
15095
15297
|
}
|
|
15096
15298
|
function readStrandedMarker(path) {
|
|
15097
15299
|
try {
|
|
15098
|
-
const parsed = JSON.parse(
|
|
15300
|
+
const parsed = JSON.parse(readFileSync37(path, "utf-8"));
|
|
15099
15301
|
if (typeof parsed.channel === "string" && typeof parsed.thread_ts === "string") {
|
|
15100
15302
|
return { channel: parsed.channel, thread_ts: parsed.thread_ts };
|
|
15101
15303
|
}
|
|
@@ -15105,7 +15307,7 @@ function readStrandedMarker(path) {
|
|
|
15105
15307
|
}
|
|
15106
15308
|
function writeHintFile(path, dir, hint) {
|
|
15107
15309
|
mkdirSync17(dir, { recursive: true, mode: 448 });
|
|
15108
|
-
|
|
15310
|
+
writeFileSync19(path, JSON.stringify(hint), { mode: 384 });
|
|
15109
15311
|
}
|
|
15110
15312
|
function pruneHintsExcept(codeName, freshFilenames) {
|
|
15111
15313
|
const ctxDir = slackRestartContextDir(codeName);
|
|
@@ -15113,7 +15315,7 @@ function pruneHintsExcept(codeName, freshFilenames) {
|
|
|
15113
15315
|
if (!filename.endsWith(".json")) continue;
|
|
15114
15316
|
if (freshFilenames.has(filename)) continue;
|
|
15115
15317
|
try {
|
|
15116
|
-
unlinkSync5(
|
|
15318
|
+
unlinkSync5(join46(ctxDir, filename));
|
|
15117
15319
|
} catch {
|
|
15118
15320
|
}
|
|
15119
15321
|
}
|
|
@@ -15134,7 +15336,7 @@ function refreshSlackRestartContextHints(codeNames, opts = {}) {
|
|
|
15134
15336
|
}
|
|
15135
15337
|
const markers = [];
|
|
15136
15338
|
for (const filename of markerFilenames.slice(0, cap)) {
|
|
15137
|
-
const parsed = readStrandedMarker(
|
|
15339
|
+
const parsed = readStrandedMarker(join46(markerDir, filename));
|
|
15138
15340
|
if (parsed) markers.push({ filename, channel: parsed.channel, thread_ts: parsed.thread_ts });
|
|
15139
15341
|
}
|
|
15140
15342
|
if (markers.length === 0) {
|
|
@@ -15148,7 +15350,7 @@ function refreshSlackRestartContextHints(codeNames, opts = {}) {
|
|
|
15148
15350
|
const freshFilenames = /* @__PURE__ */ new Set();
|
|
15149
15351
|
for (const { filename, hint } of hints) {
|
|
15150
15352
|
try {
|
|
15151
|
-
writeHintFile(
|
|
15353
|
+
writeHintFile(join46(ctxDir, filename), ctxDir, hint);
|
|
15152
15354
|
freshFilenames.add(filename);
|
|
15153
15355
|
} catch (err) {
|
|
15154
15356
|
log2(`[restart-context] ${codeName}: hint write failed for ${filename}: ${err.message}`);
|
|
@@ -15922,6 +16124,15 @@ function recordConfigChurnEvent(agentId, codeName, channel, signature) {
|
|
|
15922
16124
|
);
|
|
15923
16125
|
});
|
|
15924
16126
|
}
|
|
16127
|
+
var reloadUnknownStreak = new UnknownStreak();
|
|
16128
|
+
var reloadBlindSpawns = /* @__PURE__ */ new Set();
|
|
16129
|
+
var stragglerDeferStreak = new UnknownStreak();
|
|
16130
|
+
function reloadSessionSpawnedAt(codeName) {
|
|
16131
|
+
const s = getSessionState(codeName);
|
|
16132
|
+
if (!s || s.startedAt === null) return null;
|
|
16133
|
+
if (s.estimatedStartedAt != null && s.estimatedStartedAt === s.startedAt) return null;
|
|
16134
|
+
return s.startedAt;
|
|
16135
|
+
}
|
|
15925
16136
|
async function reportReaperEvent(agentId, reaper, action, reason) {
|
|
15926
16137
|
try {
|
|
15927
16138
|
await api.post("/host/reaper-event", {
|
|
@@ -15954,7 +16165,7 @@ async function runDangerousRmBackstop(agentId, codeName, pane) {
|
|
|
15954
16165
|
return;
|
|
15955
16166
|
}
|
|
15956
16167
|
const policy = readRmPolicyText(
|
|
15957
|
-
() =>
|
|
16168
|
+
() => readFileSync38(join47(getFramework("claude-code").getAgentDir(codeName), RM_POLICY_RELATIVE_PATH), "utf-8")
|
|
15958
16169
|
);
|
|
15959
16170
|
const decision = decideDangerousRm(action.prompt, policy, {
|
|
15960
16171
|
isolated: isolationMode(codeName) === "docker"
|
|
@@ -16675,7 +16886,7 @@ var pendingDayRolloverReset = /* @__PURE__ */ new Set();
|
|
|
16675
16886
|
var dayRolloverInboundHold = /* @__PURE__ */ new Map();
|
|
16676
16887
|
var INBOUND_HOLD_EPISODE_GAP_MS = 12e4;
|
|
16677
16888
|
async function channelInboundActivityAgeSecondsFor(codeName) {
|
|
16678
|
-
const { newestPendingInboundActivityMtimeMs } = await import("../responsiveness-probe-
|
|
16889
|
+
const { newestPendingInboundActivityMtimeMs } = await import("../responsiveness-probe-GXI34QDS.js");
|
|
16679
16890
|
const newest = newestPendingInboundActivityMtimeMs(dirname11(paneLogPath(codeName)));
|
|
16680
16891
|
if (newest === null) return null;
|
|
16681
16892
|
return Math.max(0, Math.floor((Date.now() - newest) / 1e3));
|
|
@@ -17043,7 +17254,7 @@ var runningMcpServerKeys = /* @__PURE__ */ new Map();
|
|
|
17043
17254
|
var runningChannelSecretHashes = /* @__PURE__ */ new Map();
|
|
17044
17255
|
var sessionLaunchManagedStructure = /* @__PURE__ */ new Map();
|
|
17045
17256
|
function readSpawnViewMcpConfig(codeName, projectDir) {
|
|
17046
|
-
const parsed = JSON.parse(
|
|
17257
|
+
const parsed = JSON.parse(readFileSync38(join47(projectDir, ".mcp.json"), "utf-8"));
|
|
17047
17258
|
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) return parsed;
|
|
17048
17259
|
const agentId = agentState.codeNameToAgentId.get(codeName);
|
|
17049
17260
|
const integrations = agentId ? lastIntegrationsPayload.get(agentId) : void 0;
|
|
@@ -17064,7 +17275,7 @@ function reportSpawnCopyFailure(codeName, f) {
|
|
|
17064
17275
|
function refreshHeldDropped(codeName, projectDir, held) {
|
|
17065
17276
|
const agentId = agentState.codeNameToAgentId.get(codeName);
|
|
17066
17277
|
const integrations = agentId ? lastIntegrationsPayload.get(agentId) : void 0;
|
|
17067
|
-
const now = [...spawnDroppedServerKeys(
|
|
17278
|
+
const now = [...spawnDroppedServerKeys(join47(projectDir, ".mcp.json"), integrations)];
|
|
17068
17279
|
if (spawnCopyFailures.noteDropped(codeName, now)) {
|
|
17069
17280
|
log(
|
|
17070
17281
|
`[spawn-mcp-filter] ORPHAN_SPAWN_UNFILTERED_CHANGED agent='${codeName}' servers=${now.map((k) => `'${k}'`).join(", ")}: the set of removed servers still loaded changed while the copy failure is held (ENG-12048)`
|
|
@@ -17080,14 +17291,14 @@ function retryHeldSpawnCopy2(codeName, projectDir, held) {
|
|
|
17080
17291
|
}
|
|
17081
17292
|
function readSpawnedMcpConfig(path) {
|
|
17082
17293
|
try {
|
|
17083
|
-
const parsed = JSON.parse(
|
|
17294
|
+
const parsed = JSON.parse(readFileSync38(path, "utf-8"));
|
|
17084
17295
|
return parsed && typeof parsed === "object" && !Array.isArray(parsed) ? parsed : null;
|
|
17085
17296
|
} catch {
|
|
17086
17297
|
return null;
|
|
17087
17298
|
}
|
|
17088
17299
|
}
|
|
17089
17300
|
function readRawMcpConfig(projectDir) {
|
|
17090
|
-
return JSON.parse(
|
|
17301
|
+
return JSON.parse(readFileSync38(join47(projectDir, ".mcp.json"), "utf-8"));
|
|
17091
17302
|
}
|
|
17092
17303
|
function readMcpConfigFor(codeName, projectDir, source) {
|
|
17093
17304
|
return source === "raw" ? readRawMcpConfig(projectDir) : readSpawnViewMcpConfig(codeName, projectDir);
|
|
@@ -17120,7 +17331,7 @@ function seedSessionLaunchBaselines(codeName, projectDir, spawnMcpConfigPath) {
|
|
|
17120
17331
|
else runningMcpServerKeys.delete(codeName);
|
|
17121
17332
|
let launchStructure = null;
|
|
17122
17333
|
try {
|
|
17123
|
-
const raw =
|
|
17334
|
+
const raw = readFileSync38(join47(projectDir, ".mcp.json"), "utf-8");
|
|
17124
17335
|
launchStructure = managedMcpStructureHashFromFile(
|
|
17125
17336
|
JSON.parse(raw),
|
|
17126
17337
|
isManagedMcpServerKey
|
|
@@ -17272,7 +17483,7 @@ async function runAgentSessionToolBindProbes(agent, integrations, projectDir, op
|
|
|
17272
17483
|
if (result && result.rebindCandidates.length > 0 && hostFlagStore().getBoolean("session-tool-rebind")) {
|
|
17273
17484
|
let mcpJsonForRebind = null;
|
|
17274
17485
|
try {
|
|
17275
|
-
mcpJsonForRebind = JSON.parse(
|
|
17486
|
+
mcpJsonForRebind = JSON.parse(readFileSync38(join47(projectDir, ".mcp.json"), "utf-8"));
|
|
17276
17487
|
} catch {
|
|
17277
17488
|
mcpJsonForRebind = null;
|
|
17278
17489
|
}
|
|
@@ -17436,7 +17647,7 @@ function shouldInjectChannelSecrets(agentId) {
|
|
|
17436
17647
|
function projectChannelSecretHash(projectDir) {
|
|
17437
17648
|
try {
|
|
17438
17649
|
const entries = parseEnvIntegrations(
|
|
17439
|
-
|
|
17650
|
+
readFileSync38(join47(projectDir, ".env.integrations"), "utf-8")
|
|
17440
17651
|
);
|
|
17441
17652
|
return channelSecretValueHash(entries, CHANNEL_SECRET_ENV_KEYS);
|
|
17442
17653
|
} catch {
|
|
@@ -17556,7 +17767,7 @@ var agentRestartTimezoneInputs = /* @__PURE__ */ new Map();
|
|
|
17556
17767
|
var lastVersionCheckAt = 0;
|
|
17557
17768
|
var VERSION_CHECK_INTERVAL_MS = 5 * 60 * 1e3;
|
|
17558
17769
|
var lastResponsivenessProbeAt = 0;
|
|
17559
|
-
var agtCliVersion = true ? "0.28.
|
|
17770
|
+
var agtCliVersion = true ? "0.28.1269" : "dev";
|
|
17560
17771
|
function resolveBrewPath(execFileSync4) {
|
|
17561
17772
|
try {
|
|
17562
17773
|
const out = execFileSync4("which", ["brew"], { timeout: 5e3 }).toString().trim();
|
|
@@ -18116,7 +18327,7 @@ function runAsync(cmd, args, opts) {
|
|
|
18116
18327
|
});
|
|
18117
18328
|
}
|
|
18118
18329
|
function claudeManagedSettingsPath() {
|
|
18119
|
-
return
|
|
18330
|
+
return join47(CLAUDE_MANAGED_SETTINGS_DIR, "managed-settings.json");
|
|
18120
18331
|
}
|
|
18121
18332
|
var MANAGED_SETTINGS_KEYS = ["channelsEnabled", "enableAllProjectMcpServers"];
|
|
18122
18333
|
var MANAGED_SETTINGS_ENV = { DISABLE_AUTOUPDATER: "1" };
|
|
@@ -18139,7 +18350,7 @@ function deniedTools(settings) {
|
|
|
18139
18350
|
}
|
|
18140
18351
|
function readCrossSessionBlockStatus(path = claudeManagedSettingsPath()) {
|
|
18141
18352
|
try {
|
|
18142
|
-
const parsed = JSON.parse(
|
|
18353
|
+
const parsed = JSON.parse(readFileSync38(path, "utf-8"));
|
|
18143
18354
|
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) return "missing";
|
|
18144
18355
|
const settings = parsed;
|
|
18145
18356
|
const deny = deniedTools(settings);
|
|
@@ -18158,7 +18369,7 @@ function managedSettingsOwnership(path) {
|
|
|
18158
18369
|
}
|
|
18159
18370
|
function writeManagedSettings(path, body, write = {
|
|
18160
18371
|
atomic: (p, d) => atomicWriteFileSync(p, d, managedSettingsOwnership(p)),
|
|
18161
|
-
inPlace: (p, d) =>
|
|
18372
|
+
inPlace: (p, d) => writeFileSync20(p, d)
|
|
18162
18373
|
}) {
|
|
18163
18374
|
try {
|
|
18164
18375
|
write.atomic(path, body);
|
|
@@ -18179,7 +18390,7 @@ function ensureClaudeManagedSettings(path = claudeManagedSettingsPath(), write =
|
|
|
18179
18390
|
try {
|
|
18180
18391
|
let settings = {};
|
|
18181
18392
|
if (existsSync20(path)) {
|
|
18182
|
-
const raw =
|
|
18393
|
+
const raw = readFileSync38(path, "utf-8").trim();
|
|
18183
18394
|
if (raw) {
|
|
18184
18395
|
let parsed;
|
|
18185
18396
|
try {
|
|
@@ -18272,7 +18483,7 @@ async function ensureOpencodeBinary() {
|
|
|
18272
18483
|
try {
|
|
18273
18484
|
const prefix = execFileSync4("npm", ["prefix", "-g"], { encoding: "utf-8", timeout: 1e4 }).trim();
|
|
18274
18485
|
if (prefix) {
|
|
18275
|
-
const npmBin =
|
|
18486
|
+
const npmBin = join47(prefix, "bin");
|
|
18276
18487
|
const current = (process.env.PATH ?? "").split(pathDelimiter);
|
|
18277
18488
|
if (!current.includes(npmBin)) {
|
|
18278
18489
|
process.env.PATH = [npmBin, ...current.filter(Boolean)].join(pathDelimiter);
|
|
@@ -18343,7 +18554,7 @@ async function ensureFrameworkBinary(frameworkId) {
|
|
|
18343
18554
|
agentRuntimeAuthenticated = await checkClaudeAuth();
|
|
18344
18555
|
}
|
|
18345
18556
|
var claudeCodeUpgradeInFlight = false;
|
|
18346
|
-
var SCRATCH_HOLDS_DIR = () =>
|
|
18557
|
+
var SCRATCH_HOLDS_DIR = () => join47(homedir17(), ".augmented", ".manager-scratch-holds");
|
|
18347
18558
|
setScratchSweepPolicyResolver(
|
|
18348
18559
|
(codeName) => resolveScratchSweepPolicy({
|
|
18349
18560
|
agentId: agentState.codeNameToAgentId.get(codeName),
|
|
@@ -18422,7 +18633,7 @@ async function maybeUpgradeClaudeCode() {
|
|
|
18422
18633
|
}
|
|
18423
18634
|
var UPDATE_CHECK_INTERVAL_MS = 5 * 60 * 1e3;
|
|
18424
18635
|
function selfUpdateAppliedMarkerPath() {
|
|
18425
|
-
return
|
|
18636
|
+
return join47(homedir17(), ".augmented", ".last-self-update-applied");
|
|
18426
18637
|
}
|
|
18427
18638
|
var selfUpdateUpToDateLogged = false;
|
|
18428
18639
|
var selfUpdatePinnedLogged = false;
|
|
@@ -18473,7 +18684,7 @@ async function checkAndUpdateCli(opts) {
|
|
|
18473
18684
|
const isNpmGlobal = !isBrewFormula && resolvedPath.includes("node_modules");
|
|
18474
18685
|
if (!isBrewFormula && !isNpmGlobal) return "noop";
|
|
18475
18686
|
const { readFileSync: readF, writeFileSync: writeF } = await import("fs");
|
|
18476
|
-
const markerPath =
|
|
18687
|
+
const markerPath = join47(homedir17(), ".augmented", ".last-update-check");
|
|
18477
18688
|
if (!force) {
|
|
18478
18689
|
try {
|
|
18479
18690
|
const lastCheck = parseInt(readF(markerPath, "utf-8").trim(), 10);
|
|
@@ -18977,13 +19188,13 @@ async function checkClaudeAuth() {
|
|
|
18977
19188
|
var evalEmptyMcpConfigPath = null;
|
|
18978
19189
|
function ensureEvalEmptyMcpConfig() {
|
|
18979
19190
|
if (evalEmptyMcpConfigPath && existsSync20(evalEmptyMcpConfigPath)) return evalEmptyMcpConfigPath;
|
|
18980
|
-
const dir =
|
|
19191
|
+
const dir = join47(homedir17(), ".augmented");
|
|
18981
19192
|
try {
|
|
18982
19193
|
mkdirSync18(dir, { recursive: true });
|
|
18983
19194
|
} catch {
|
|
18984
19195
|
}
|
|
18985
|
-
const p =
|
|
18986
|
-
|
|
19196
|
+
const p = join47(dir, ".eval-empty-mcp.json");
|
|
19197
|
+
writeFileSync20(p, JSON.stringify({ mcpServers: {} }));
|
|
18987
19198
|
evalEmptyMcpConfigPath = p;
|
|
18988
19199
|
return p;
|
|
18989
19200
|
}
|
|
@@ -19073,10 +19284,10 @@ function resolveConversationEvalBackend() {
|
|
|
19073
19284
|
return conversationEvalBackend;
|
|
19074
19285
|
}
|
|
19075
19286
|
function getStateFile() {
|
|
19076
|
-
return
|
|
19287
|
+
return join47(config?.configDir ?? join47(process.env["HOME"] ?? "/tmp", ".augmented"), "manager-state.json");
|
|
19077
19288
|
}
|
|
19078
19289
|
function channelHashCacheDir() {
|
|
19079
|
-
return config?.configDir ??
|
|
19290
|
+
return config?.configDir ?? join47(process.env["HOME"] ?? "/tmp", ".augmented");
|
|
19080
19291
|
}
|
|
19081
19292
|
function loadChannelHashCache2() {
|
|
19082
19293
|
loadChannelHashCache(agentState.knownChannelConfigHashes, channelHashCacheDir());
|
|
@@ -19289,7 +19500,7 @@ function removeDeliveryBaselineEntries(agentId) {
|
|
|
19289
19500
|
var _channelQuarantineStore = null;
|
|
19290
19501
|
function channelQuarantineStore() {
|
|
19291
19502
|
if (!_channelQuarantineStore) {
|
|
19292
|
-
const dir = config?.configDir ??
|
|
19503
|
+
const dir = config?.configDir ?? join47(process.env["HOME"] ?? "/tmp", ".augmented");
|
|
19293
19504
|
_channelQuarantineStore = new ChannelQuarantineStore(defaultQuarantinePath(dir));
|
|
19294
19505
|
}
|
|
19295
19506
|
return _channelQuarantineStore;
|
|
@@ -19297,7 +19508,7 @@ function channelQuarantineStore() {
|
|
|
19297
19508
|
var _channelResumeHistoryStore = null;
|
|
19298
19509
|
function channelResumeHistoryStore() {
|
|
19299
19510
|
if (!_channelResumeHistoryStore) {
|
|
19300
|
-
const dir = config?.configDir ??
|
|
19511
|
+
const dir = config?.configDir ?? join47(process.env["HOME"] ?? "/tmp", ".augmented");
|
|
19301
19512
|
_channelResumeHistoryStore = new ChannelResumeHistoryStore(defaultResumeHistoryPath(dir));
|
|
19302
19513
|
}
|
|
19303
19514
|
return _channelResumeHistoryStore;
|
|
@@ -19342,12 +19553,12 @@ function sessionActivityFor(codeName, pane, opts = {}) {
|
|
|
19342
19553
|
}
|
|
19343
19554
|
function forwardedToolsFor(codeName) {
|
|
19344
19555
|
if (!config?.configDir) return null;
|
|
19345
|
-
return readForwardedToolsReport(
|
|
19556
|
+
return readForwardedToolsReport(join47(config.configDir, codeName));
|
|
19346
19557
|
}
|
|
19347
19558
|
var _hostFlagStore = null;
|
|
19348
19559
|
function hostFlagStore() {
|
|
19349
19560
|
if (!_hostFlagStore) {
|
|
19350
|
-
const dir = config?.configDir ??
|
|
19561
|
+
const dir = config?.configDir ?? join47(process.env["HOME"] ?? "/tmp", ".augmented");
|
|
19351
19562
|
_hostFlagStore = new HostFlagStore({ cachePath: defaultFlagsCachePath(dir), log });
|
|
19352
19563
|
}
|
|
19353
19564
|
return _hostFlagStore;
|
|
@@ -19420,13 +19631,13 @@ function parseSkillFrontmatter(content) {
|
|
|
19420
19631
|
return out;
|
|
19421
19632
|
}
|
|
19422
19633
|
async function refreshSkillsIndexInClaudeMd(configDir, codeName, log2) {
|
|
19423
|
-
const { readdirSync: readdirSync15, readFileSync: rfs, existsSync: ex, writeFileSync:
|
|
19424
|
-
const skillsDir =
|
|
19425
|
-
const claudeMdPath =
|
|
19634
|
+
const { readdirSync: readdirSync15, readFileSync: rfs, existsSync: ex, writeFileSync: writeFileSync21 } = await import("fs");
|
|
19635
|
+
const skillsDir = join47(configDir, codeName, "project", ".claude", "skills");
|
|
19636
|
+
const claudeMdPath = join47(configDir, codeName, "project", "CLAUDE.md");
|
|
19426
19637
|
if (!ex(skillsDir) || !ex(claudeMdPath)) return;
|
|
19427
19638
|
const entries = [];
|
|
19428
19639
|
for (const dir of readdirSync15(skillsDir).sort()) {
|
|
19429
|
-
const skillFile =
|
|
19640
|
+
const skillFile = join47(skillsDir, dir, "SKILL.md");
|
|
19430
19641
|
if (!ex(skillFile)) continue;
|
|
19431
19642
|
try {
|
|
19432
19643
|
const { name, description } = parseSkillFrontmatter(rfs(skillFile, "utf-8"));
|
|
@@ -19470,7 +19681,7 @@ ${SKILLS_INDEX_END}`;
|
|
|
19470
19681
|
next = current.trimEnd() + "\n\n" + section + "\n";
|
|
19471
19682
|
}
|
|
19472
19683
|
if (next !== current) {
|
|
19473
|
-
|
|
19684
|
+
writeFileSync21(claudeMdPath, next, "utf-8");
|
|
19474
19685
|
log2(
|
|
19475
19686
|
injectSkillList ? `Refreshed skills index in CLAUDE.md for '${codeName}' (${entries.length} skills)` : `Refreshed CLAUDE.md managed block for '${codeName}' (skill list suppressed by claude-md-skills-index=false; ${entries.length} skills on disk)`
|
|
19476
19687
|
);
|
|
@@ -19565,7 +19776,7 @@ function flushRestartedAgentDiagnostics(hostId, codeNames) {
|
|
|
19565
19776
|
if (codeNames.length === 0) return;
|
|
19566
19777
|
void (async () => {
|
|
19567
19778
|
try {
|
|
19568
|
-
const { collectDiagnostics } = await import("../persistent-session-
|
|
19779
|
+
const { collectDiagnostics } = await import("../persistent-session-MX6UHWLR.js");
|
|
19569
19780
|
await api.post("/host/heartbeat", {
|
|
19570
19781
|
host_id: hostId,
|
|
19571
19782
|
agent_diagnostics: collectDiagnostics(codeNames, quarantineEntriesFor, claudeMdSizeFor, spawnOutcomeForDiagnostics, pidPressureFor, forwardedToolsFor, runtimeVersionFor, sessionActivityFor)
|
|
@@ -19708,7 +19919,7 @@ async function pollCycleInner() {
|
|
|
19708
19919
|
}
|
|
19709
19920
|
try {
|
|
19710
19921
|
const { detectHostSecurity } = await import("../host-security-KQYYZZVW.js");
|
|
19711
|
-
const { collectDiagnostics } = await import("../persistent-session-
|
|
19922
|
+
const { collectDiagnostics } = await import("../persistent-session-MX6UHWLR.js");
|
|
19712
19923
|
const diagCodeNames = [...agentState.persistentSessionAgents];
|
|
19713
19924
|
const agentDiagnostics = diagCodeNames.length > 0 ? collectDiagnostics(diagCodeNames, quarantineEntriesFor, claudeMdSizeFor, spawnOutcomeForDiagnostics, pidPressureFor, forwardedToolsFor, runtimeVersionFor, sessionActivityFor) : void 0;
|
|
19714
19925
|
let tailscaleHostname;
|
|
@@ -19979,7 +20190,7 @@ async function pollCycleInner() {
|
|
|
19979
20190
|
}
|
|
19980
20191
|
try {
|
|
19981
20192
|
const desiredClaudeCodeVersion = hbResp?.desired_claude_code_version?.trim();
|
|
19982
|
-
const { maybeUpdateClaudeCode, shouldRunClaudeCodeUpdater } = await import("../claude-code-updater-
|
|
20193
|
+
const { maybeUpdateClaudeCode, shouldRunClaudeCodeUpdater } = await import("../claude-code-updater-OHXLB7WR.js");
|
|
19983
20194
|
const securityFloor = currentSecurityFloor();
|
|
19984
20195
|
claudeUpdaterInFlight = true;
|
|
19985
20196
|
if (desiredClaudeCodeVersion && (claudePairLoop.busy || claudePairingInProgress())) {
|
|
@@ -20014,7 +20225,7 @@ async function pollCycleInner() {
|
|
|
20014
20225
|
collectPanelessActivityProbes,
|
|
20015
20226
|
getResponsivenessIntervalMs,
|
|
20016
20227
|
occupancyQualificationClassifications
|
|
20017
|
-
} = await import("../responsiveness-probe-
|
|
20228
|
+
} = await import("../responsiveness-probe-GXI34QDS.js");
|
|
20018
20229
|
const probeIntervalMs = getResponsivenessIntervalMs();
|
|
20019
20230
|
if (now - lastResponsivenessProbeAt > probeIntervalMs) {
|
|
20020
20231
|
const probeCodeNames = [...agentState.persistentSessionAgents];
|
|
@@ -20131,7 +20342,7 @@ async function pollCycleInner() {
|
|
|
20131
20342
|
collectResponsivenessProbes,
|
|
20132
20343
|
livePendingInboundOldestAgeSeconds,
|
|
20133
20344
|
parkPendingInbound
|
|
20134
|
-
} = await import("../responsiveness-probe-
|
|
20345
|
+
} = await import("../responsiveness-probe-GXI34QDS.js");
|
|
20135
20346
|
const { getProjectDir: wedgeProjectDir } = await import("../scheduler-engine-5PCBGRNY.js");
|
|
20136
20347
|
const wedgeNow = /* @__PURE__ */ new Date();
|
|
20137
20348
|
const liveAgents = agentState.persistentSessionAgents;
|
|
@@ -20220,13 +20431,13 @@ async function pollCycleInner() {
|
|
|
20220
20431
|
);
|
|
20221
20432
|
if (hostFlagStore().getBoolean("wedge-transient-notice")) {
|
|
20222
20433
|
try {
|
|
20223
|
-
const paneTail =
|
|
20434
|
+
const paneTail = readFileSync38(paneLogPath(codeName), "utf8").slice(-65536);
|
|
20224
20435
|
const transient = detectTransientApiErrorInLog(paneTail);
|
|
20225
20436
|
if (transient) {
|
|
20226
|
-
const wedgeHome =
|
|
20437
|
+
const wedgeHome = join47(homedir17(), ".augmented", codeName);
|
|
20227
20438
|
if (existsSync20(wedgeHome)) {
|
|
20228
20439
|
atomicWriteFileSync(
|
|
20229
|
-
|
|
20440
|
+
join47(wedgeHome, "watchdog-give-up.json"),
|
|
20230
20441
|
JSON.stringify({
|
|
20231
20442
|
gave_up_at: wedgeNow.toISOString(),
|
|
20232
20443
|
reason: "transient_overload"
|
|
@@ -20417,7 +20628,7 @@ async function pollCycleInner() {
|
|
|
20417
20628
|
}
|
|
20418
20629
|
}
|
|
20419
20630
|
);
|
|
20420
|
-
const { parkPendingInbound } = await import("../responsiveness-probe-
|
|
20631
|
+
const { parkPendingInbound } = await import("../responsiveness-probe-GXI34QDS.js");
|
|
20421
20632
|
const { parked, deadLettered } = parkPendingInbound(codeName, new Date(fatalNowMs));
|
|
20422
20633
|
paneFatalStreak.delete(codeName);
|
|
20423
20634
|
paneFatalRestarts.set(codeName, [...history, fatalNowMs]);
|
|
@@ -20448,7 +20659,7 @@ async function pollCycleInner() {
|
|
|
20448
20659
|
TRANSCRIPT_MOUNT_ESCALATION_REFRESH_MS,
|
|
20449
20660
|
bindSourceEscalations
|
|
20450
20661
|
} = await import("../transcript-mount-health-OHE6IVJV.js");
|
|
20451
|
-
const { transcriptBindSourcesFor, ensureTranscriptBindSources } = await import("../persistent-session-
|
|
20662
|
+
const { transcriptBindSourcesFor, ensureTranscriptBindSources } = await import("../persistent-session-MX6UHWLR.js");
|
|
20452
20663
|
const mountConfig = resolveTranscriptMountConfig();
|
|
20453
20664
|
const liveAgents = agentState.persistentSessionAgents;
|
|
20454
20665
|
for (const tracked of [
|
|
@@ -20613,7 +20824,7 @@ async function pollCycleInner() {
|
|
|
20613
20824
|
}
|
|
20614
20825
|
try {
|
|
20615
20826
|
const { scrapeMcpFailedBannerCount } = await import("../pane-mcp-banner-scraper-VR5QGP3J.js");
|
|
20616
|
-
const { probeSessionAuth } = await import("../session-auth-dead-
|
|
20827
|
+
const { probeSessionAuth } = await import("../session-auth-dead-UM6LYQ2W.js");
|
|
20617
20828
|
const observations = [];
|
|
20618
20829
|
const pendingCacheCommits = [];
|
|
20619
20830
|
const modelApiErrorReportingOn = hostFlagStore().getBoolean("model-api-error-reporting");
|
|
@@ -21167,7 +21378,7 @@ async function pollCycleInner() {
|
|
|
21167
21378
|
`[drain-flush] FAILED for '${prev.codeName}': ${err.message} \u2014 proceeding to teardown; this session was NOT shipped (ENG-9491)`
|
|
21168
21379
|
);
|
|
21169
21380
|
}
|
|
21170
|
-
const agentDir =
|
|
21381
|
+
const agentDir = join47(adapter.getAgentDir(prev.codeName), "provision");
|
|
21171
21382
|
await cleanupAgentFiles(prev.codeName, agentDir);
|
|
21172
21383
|
clearAgentCaches(prev.agentId, prev.codeName);
|
|
21173
21384
|
}
|
|
@@ -21246,10 +21457,10 @@ async function pollCycleInner() {
|
|
|
21246
21457
|
// pending-inbound marker. Best-effort: a write failure is logged by
|
|
21247
21458
|
// the watchdog, never fails the poll cycle.
|
|
21248
21459
|
signalGiveUp: (codeName) => {
|
|
21249
|
-
const dir =
|
|
21460
|
+
const dir = join47(homedir17(), ".augmented", codeName);
|
|
21250
21461
|
if (!existsSync20(dir)) return;
|
|
21251
21462
|
atomicWriteFileSync(
|
|
21252
|
-
|
|
21463
|
+
join47(dir, "watchdog-give-up.json"),
|
|
21253
21464
|
JSON.stringify({ gave_up_at: (/* @__PURE__ */ new Date()).toISOString() })
|
|
21254
21465
|
);
|
|
21255
21466
|
},
|
|
@@ -21277,20 +21488,20 @@ async function pollCycleInner() {
|
|
|
21277
21488
|
const dir = getFramework("claude-code").getAgentDir(codeName);
|
|
21278
21489
|
if (!existsSync20(dir)) return;
|
|
21279
21490
|
atomicWriteFileSync(
|
|
21280
|
-
|
|
21491
|
+
join47(dir, "blocked-prompt.json"),
|
|
21281
21492
|
JSON.stringify({ kind, last_seen_at: (/* @__PURE__ */ new Date()).toISOString() })
|
|
21282
21493
|
);
|
|
21283
21494
|
},
|
|
21284
21495
|
clearBlockedPromptLiveness: (codeName) => {
|
|
21285
|
-
const file =
|
|
21496
|
+
const file = join47(getFramework("claude-code").getAgentDir(codeName), "blocked-prompt.json");
|
|
21286
21497
|
if (existsSync20(file)) rmSync9(file, { force: true });
|
|
21287
21498
|
},
|
|
21288
21499
|
refreshUsageLimitLiveness: (codeName) => {
|
|
21289
21500
|
const dir = getFramework("claude-code").getAgentDir(codeName);
|
|
21290
|
-
const file =
|
|
21501
|
+
const file = join47(dir, "watchdog-give-up.json");
|
|
21291
21502
|
if (!existsSync20(file)) return;
|
|
21292
21503
|
try {
|
|
21293
|
-
const raw = JSON.parse(
|
|
21504
|
+
const raw = JSON.parse(readFileSync38(file, "utf8"));
|
|
21294
21505
|
if (raw["reason"] !== "usage_limit") return;
|
|
21295
21506
|
raw["usage_limit_last_seen_at"] = (/* @__PURE__ */ new Date()).toISOString();
|
|
21296
21507
|
atomicWriteFileSync(file, JSON.stringify(raw));
|
|
@@ -21301,7 +21512,7 @@ async function pollCycleInner() {
|
|
|
21301
21512
|
const dir = getFramework("claude-code").getAgentDir(codeName);
|
|
21302
21513
|
if (!existsSync20(dir)) return;
|
|
21303
21514
|
atomicWriteFileSync(
|
|
21304
|
-
|
|
21515
|
+
join47(dir, "watchdog-give-up.json"),
|
|
21305
21516
|
JSON.stringify({
|
|
21306
21517
|
gave_up_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
21307
21518
|
reason: "usage_limit",
|
|
@@ -21578,7 +21789,7 @@ async function processAgent(agent, agentStates, managedToolkits) {
|
|
|
21578
21789
|
}
|
|
21579
21790
|
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
21580
21791
|
const adapter = resolveAgentFramework(agent.code_name);
|
|
21581
|
-
let agentDir =
|
|
21792
|
+
let agentDir = join47(adapter.getAgentDir(agent.code_name), "provision");
|
|
21582
21793
|
if (agent.status === "draft" || agent.status === "paused") {
|
|
21583
21794
|
forgetChannelSyncState(agent.agent_id);
|
|
21584
21795
|
reapLegacyTokenFileEdgeWarned(agent.code_name, log);
|
|
@@ -21726,7 +21937,7 @@ async function processAgent(agent, agentStates, managedToolkits) {
|
|
|
21726
21937
|
if (refreshData.knowledge_manifest) {
|
|
21727
21938
|
const resolved = await resolveKnowledgeFromManifest({
|
|
21728
21939
|
manifest: refreshData.knowledge_manifest,
|
|
21729
|
-
cacheDir:
|
|
21940
|
+
cacheDir: join47(config.configDir, "_knowledge"),
|
|
21730
21941
|
delivery: refreshData.agent?.knowledge_delivery ?? "both",
|
|
21731
21942
|
fetchContents: async (hashes) => {
|
|
21732
21943
|
const res = await api.post(
|
|
@@ -21743,7 +21954,7 @@ async function processAgent(agent, agentStates, managedToolkits) {
|
|
|
21743
21954
|
const resolvedSkills = await resolveSkillsFromManifest({
|
|
21744
21955
|
globals: refreshData.global_skills_manifest ?? [],
|
|
21745
21956
|
shared: refreshData.shared_skills_manifest ?? [],
|
|
21746
|
-
cacheDir:
|
|
21957
|
+
cacheDir: join47(config.configDir, "_skills"),
|
|
21747
21958
|
fetchContents: async (hashes) => {
|
|
21748
21959
|
const res = await api.post(
|
|
21749
21960
|
"/host/skills/contents",
|
|
@@ -21761,7 +21972,7 @@ async function processAgent(agent, agentStates, managedToolkits) {
|
|
|
21761
21972
|
if (refreshData.integration_skills_manifest) {
|
|
21762
21973
|
const resolvedIntegrationSkills = await resolveIntegrationSkillsFromManifest({
|
|
21763
21974
|
manifest: refreshData.integration_skills_manifest,
|
|
21764
|
-
cacheDir:
|
|
21975
|
+
cacheDir: join47(config.configDir, "_skills"),
|
|
21765
21976
|
fetchContents: async (hashes) => {
|
|
21766
21977
|
const res = await api.post(
|
|
21767
21978
|
"/host/skills/contents",
|
|
@@ -21823,7 +22034,7 @@ async function processAgent(agent, agentStates, managedToolkits) {
|
|
|
21823
22034
|
const frameworkId = refreshData.agent.framework ?? DEFAULT_FRAMEWORK;
|
|
21824
22035
|
agentFrameworkCache.set(agent.code_name, frameworkId);
|
|
21825
22036
|
const frameworkAdapter = getFramework(frameworkId);
|
|
21826
|
-
agentDir =
|
|
22037
|
+
agentDir = join47(frameworkAdapter.getAgentDir(agent.code_name), "provision");
|
|
21827
22038
|
cacheAgentDeliveryMetadata(agent.code_name, refreshData);
|
|
21828
22039
|
agentRestartTimezoneInputs.set(agent.code_name, {
|
|
21829
22040
|
agentTimezone: typeof refreshData.agent.timezone === "string" ? refreshData.agent.timezone : null,
|
|
@@ -21901,7 +22112,7 @@ async function processAgent(agent, agentStates, managedToolkits) {
|
|
|
21901
22112
|
const changedFiles = [];
|
|
21902
22113
|
mkdirSync18(agentDir, { recursive: true });
|
|
21903
22114
|
for (const artifact of artifacts) {
|
|
21904
|
-
const filePath =
|
|
22115
|
+
const filePath = join47(agentDir, artifact.relativePath);
|
|
21905
22116
|
let existingHash;
|
|
21906
22117
|
let newHash;
|
|
21907
22118
|
let writeContent = artifact.content;
|
|
@@ -21920,8 +22131,8 @@ async function processAgent(agent, agentStates, managedToolkits) {
|
|
|
21920
22131
|
};
|
|
21921
22132
|
newHash = sha256(stripDynamicSections(artifact.content));
|
|
21922
22133
|
try {
|
|
21923
|
-
const projectClaudeMd =
|
|
21924
|
-
const existing =
|
|
22134
|
+
const projectClaudeMd = join47(config.configDir, agent.code_name, "project", "CLAUDE.md");
|
|
22135
|
+
const existing = readFileSync38(projectClaudeMd, "utf-8");
|
|
21925
22136
|
existingHash = sha256(stripDynamicSections(existing));
|
|
21926
22137
|
} catch {
|
|
21927
22138
|
existingHash = null;
|
|
@@ -21939,7 +22150,7 @@ async function processAgent(agent, agentStates, managedToolkits) {
|
|
|
21939
22150
|
const generatorKeys = Object.keys(generatorServers);
|
|
21940
22151
|
let existingRaw = "";
|
|
21941
22152
|
try {
|
|
21942
|
-
existingRaw =
|
|
22153
|
+
existingRaw = readFileSync38(filePath, "utf-8");
|
|
21943
22154
|
} catch {
|
|
21944
22155
|
}
|
|
21945
22156
|
const existingServers = parseMcp(existingRaw);
|
|
@@ -21955,7 +22166,7 @@ async function processAgent(agent, agentStates, managedToolkits) {
|
|
|
21955
22166
|
} else if (artifact.relativePath === "opencode.json") {
|
|
21956
22167
|
let existingRaw = null;
|
|
21957
22168
|
try {
|
|
21958
|
-
existingRaw =
|
|
22169
|
+
existingRaw = readFileSync38(filePath, "utf-8");
|
|
21959
22170
|
} catch {
|
|
21960
22171
|
}
|
|
21961
22172
|
const mergeResult = mergeOpencodeConfigArtifact(artifact.content, existingRaw);
|
|
@@ -21971,26 +22182,26 @@ async function processAgent(agent, agentStates, managedToolkits) {
|
|
|
21971
22182
|
}
|
|
21972
22183
|
}
|
|
21973
22184
|
if (changedFiles.length > 0) {
|
|
21974
|
-
const isFirst = !existsSync20(
|
|
22185
|
+
const isFirst = !existsSync20(join47(agentDir, "CHARTER.md"));
|
|
21975
22186
|
const verb = isFirst ? "Provisioning" : "Updating";
|
|
21976
22187
|
const fileNames = changedFiles.map((f) => f.relativePath).join(", ");
|
|
21977
22188
|
log(`${verb} '${agent.code_name}': ${fileNames}`);
|
|
21978
22189
|
for (const file of changedFiles) {
|
|
21979
|
-
const filePath =
|
|
22190
|
+
const filePath = join47(agentDir, file.relativePath);
|
|
21980
22191
|
mkdirSync18(dirname11(filePath), { recursive: true });
|
|
21981
22192
|
if (file.relativePath === ".mcp.json") {
|
|
21982
22193
|
safeWriteJsonAtomic(filePath, file.content, { mode: 384 });
|
|
21983
22194
|
} else {
|
|
21984
|
-
|
|
22195
|
+
writeFileSync20(filePath, file.content);
|
|
21985
22196
|
}
|
|
21986
22197
|
}
|
|
21987
22198
|
try {
|
|
21988
|
-
const provSkillsDir =
|
|
22199
|
+
const provSkillsDir = join47(agentDir, ".claude", "skills");
|
|
21989
22200
|
if (existsSync20(provSkillsDir)) {
|
|
21990
22201
|
for (const folder of readdirSync14(provSkillsDir)) {
|
|
21991
22202
|
if (folder.startsWith("knowledge-")) {
|
|
21992
22203
|
try {
|
|
21993
|
-
rmSync9(
|
|
22204
|
+
rmSync9(join47(provSkillsDir, folder), { recursive: true });
|
|
21994
22205
|
} catch {
|
|
21995
22206
|
}
|
|
21996
22207
|
}
|
|
@@ -22003,7 +22214,7 @@ async function processAgent(agent, agentStates, managedToolkits) {
|
|
|
22003
22214
|
const trackedFiles2 = frameworkAdapter.driftTrackedFiles();
|
|
22004
22215
|
const hashes = /* @__PURE__ */ new Map();
|
|
22005
22216
|
for (const file of trackedFiles2) {
|
|
22006
|
-
const h = hashFile(
|
|
22217
|
+
const h = hashFile(join47(agentDir, file));
|
|
22007
22218
|
if (h) hashes.set(file, h);
|
|
22008
22219
|
}
|
|
22009
22220
|
agentState.writtenHashes.set(agent.agent_id, hashes);
|
|
@@ -22021,14 +22232,14 @@ async function processAgent(agent, agentStates, managedToolkits) {
|
|
|
22021
22232
|
}
|
|
22022
22233
|
if (Array.isArray(refreshData.workflows)) {
|
|
22023
22234
|
try {
|
|
22024
|
-
const provWorkflowsDir =
|
|
22235
|
+
const provWorkflowsDir = join47(agentDir, ".claude", "workflows");
|
|
22025
22236
|
if (existsSync20(provWorkflowsDir)) {
|
|
22026
22237
|
const expected = new Set(refreshData.workflows.map((w) => `${w.name}.js`));
|
|
22027
22238
|
for (const file of readdirSync14(provWorkflowsDir)) {
|
|
22028
22239
|
if (!file.endsWith(".js")) continue;
|
|
22029
22240
|
if (expected.has(file)) continue;
|
|
22030
22241
|
try {
|
|
22031
|
-
rmSync9(
|
|
22242
|
+
rmSync9(join47(provWorkflowsDir, file));
|
|
22032
22243
|
} catch {
|
|
22033
22244
|
}
|
|
22034
22245
|
}
|
|
@@ -22123,7 +22334,7 @@ async function processAgent(agent, agentStates, managedToolkits) {
|
|
|
22123
22334
|
if (written && existsSync20(agentDir)) {
|
|
22124
22335
|
const driftedFiles = [];
|
|
22125
22336
|
for (const [file, expectedHash] of written) {
|
|
22126
|
-
const localHash = hashFile(
|
|
22337
|
+
const localHash = hashFile(join47(agentDir, file));
|
|
22127
22338
|
if (localHash && localHash !== expectedHash) {
|
|
22128
22339
|
driftedFiles.push(file);
|
|
22129
22340
|
}
|
|
@@ -22134,7 +22345,7 @@ async function processAgent(agent, agentStates, managedToolkits) {
|
|
|
22134
22345
|
try {
|
|
22135
22346
|
const localHashes = {};
|
|
22136
22347
|
for (const file of driftedFiles) {
|
|
22137
|
-
localHashes[file] = hashFile(
|
|
22348
|
+
localHashes[file] = hashFile(join47(agentDir, file));
|
|
22138
22349
|
}
|
|
22139
22350
|
await api.post("/host/drift", {
|
|
22140
22351
|
agent_id: agent.agent_id,
|
|
@@ -22419,7 +22630,7 @@ async function processAgent(agent, agentStates, managedToolkits) {
|
|
|
22419
22630
|
const addedChannels = [...restartDecision.added];
|
|
22420
22631
|
const writeDmNoticeMarkers = isChannelAddRestart ? () => {
|
|
22421
22632
|
try {
|
|
22422
|
-
const agentAugmentedDir =
|
|
22633
|
+
const agentAugmentedDir = join47(homedir17(), ".augmented", agent.code_name);
|
|
22423
22634
|
mkdirSync18(agentAugmentedDir, { recursive: true });
|
|
22424
22635
|
const markerJson = JSON.stringify({
|
|
22425
22636
|
version: 1,
|
|
@@ -22427,7 +22638,7 @@ async function processAgent(agent, agentStates, managedToolkits) {
|
|
|
22427
22638
|
added: addedChannels
|
|
22428
22639
|
});
|
|
22429
22640
|
for (const file of ["slack-channel-add-restart.json", "telegram-channel-add-restart.json"]) {
|
|
22430
|
-
atomicWriteFileSync(
|
|
22641
|
+
atomicWriteFileSync(join47(agentAugmentedDir, file), markerJson);
|
|
22431
22642
|
}
|
|
22432
22643
|
} catch (err) {
|
|
22433
22644
|
log(`[hot-reload] channel-add DM-notice marker write failed for '${agent.code_name}' (non-fatal): ${err.message}`);
|
|
@@ -22731,18 +22942,18 @@ async function processAgent(agent, agentStates, managedToolkits) {
|
|
|
22731
22942
|
if (agentSessionMode === "persistent" && (agentFrameworkCache.get(agent.code_name) ?? DEFAULT_FRAMEWORK) === "claude-code") {
|
|
22732
22943
|
try {
|
|
22733
22944
|
const agentProvisionDir = agentDir;
|
|
22734
|
-
const projectDir =
|
|
22945
|
+
const projectDir = join47(homedir17(), ".augmented", agent.code_name, "project");
|
|
22735
22946
|
mkdirSync18(agentProvisionDir, { recursive: true });
|
|
22736
22947
|
mkdirSync18(projectDir, { recursive: true });
|
|
22737
|
-
const provisionMcpPath =
|
|
22738
|
-
const projectMcpPath =
|
|
22948
|
+
const provisionMcpPath = join47(agentProvisionDir, ".mcp.json");
|
|
22949
|
+
const projectMcpPath = join47(projectDir, ".mcp.json");
|
|
22739
22950
|
let mcpConfig = { mcpServers: {} };
|
|
22740
22951
|
try {
|
|
22741
|
-
mcpConfig = JSON.parse(
|
|
22952
|
+
mcpConfig = JSON.parse(readFileSync38(provisionMcpPath, "utf-8"));
|
|
22742
22953
|
if (!mcpConfig.mcpServers) mcpConfig.mcpServers = {};
|
|
22743
22954
|
} catch {
|
|
22744
22955
|
}
|
|
22745
|
-
const localDirectChatChannel =
|
|
22956
|
+
const localDirectChatChannel = join47(homedir17(), ".augmented", "_mcp", "direct-chat-channel.js");
|
|
22746
22957
|
const directChatTeamSettings = refreshData.team?.settings;
|
|
22747
22958
|
const directChatTz = (() => {
|
|
22748
22959
|
const tz = directChatTeamSettings?.["timezone"];
|
|
@@ -22768,7 +22979,7 @@ async function processAgent(agent, agentStates, managedToolkits) {
|
|
|
22768
22979
|
// ~/.augmented/<codeName>/.current-turn-initiator.json. Note getAgentDir
|
|
22769
22980
|
// returns the agent root (NOT the /provision subdir `agentDir` points at),
|
|
22770
22981
|
// so it byte-matches the broker readers' path.
|
|
22771
|
-
AGT_TURN_INITIATOR_FILE:
|
|
22982
|
+
AGT_TURN_INITIATOR_FILE: join47(
|
|
22772
22983
|
frameworkAdapter.getAgentDir(agent.code_name),
|
|
22773
22984
|
".current-turn-initiator.json"
|
|
22774
22985
|
)
|
|
@@ -22788,7 +22999,7 @@ async function processAgent(agent, agentStates, managedToolkits) {
|
|
|
22788
22999
|
log(`Channel credentials written for '${agent.code_name}/direct-chat'`);
|
|
22789
23000
|
}
|
|
22790
23001
|
}
|
|
22791
|
-
const staleChannelsPath =
|
|
23002
|
+
const staleChannelsPath = join47(projectDir, ".mcp-channels.json");
|
|
22792
23003
|
if (existsSync20(staleChannelsPath)) {
|
|
22793
23004
|
try {
|
|
22794
23005
|
rmSync9(staleChannelsPath, { force: true });
|
|
@@ -22916,7 +23127,7 @@ async function processAgent(agent, agentStates, managedToolkits) {
|
|
|
22916
23127
|
}
|
|
22917
23128
|
if (hostFlagStore().getBoolean("connectivity-probe")) {
|
|
22918
23129
|
try {
|
|
22919
|
-
const probeProjectDir =
|
|
23130
|
+
const probeProjectDir = join47(homedir17(), ".augmented", agent.code_name, "project");
|
|
22920
23131
|
let probeSet = integrations;
|
|
22921
23132
|
const fetchQuarantined = async () => {
|
|
22922
23133
|
const quarantined = await api.post("/host/agent-integrations/quarantined", { agent_id: agent.agent_id });
|
|
@@ -22976,7 +23187,7 @@ async function processAgent(agent, agentStates, managedToolkits) {
|
|
|
22976
23187
|
const forceDue = attemptsLeft > 0;
|
|
22977
23188
|
let probeRan = false;
|
|
22978
23189
|
try {
|
|
22979
|
-
const probeProjectDir =
|
|
23190
|
+
const probeProjectDir = join47(homedir17(), ".augmented", agent.code_name, "project");
|
|
22980
23191
|
const renderPending = integrationRenderPending(
|
|
22981
23192
|
integrations,
|
|
22982
23193
|
agentState.knownIntegrationHashes.get(agent.agent_id)
|
|
@@ -23105,11 +23316,11 @@ async function processAgent(agent, agentStates, managedToolkits) {
|
|
|
23105
23316
|
const intHash = computeIntegrationsHash(integrations);
|
|
23106
23317
|
const prevIntHash = agentState.knownIntegrationHashes.get(agent.agent_id);
|
|
23107
23318
|
if (intHash !== prevIntHash) {
|
|
23108
|
-
const projectDir =
|
|
23109
|
-
const envIntPath =
|
|
23319
|
+
const projectDir = join47(homedir17(), ".augmented", agent.code_name, "project");
|
|
23320
|
+
const envIntPath = join47(projectDir, ".env.integrations");
|
|
23110
23321
|
let preWriteEnv;
|
|
23111
23322
|
try {
|
|
23112
|
-
preWriteEnv =
|
|
23323
|
+
preWriteEnv = readFileSync38(envIntPath, "utf-8");
|
|
23113
23324
|
} catch {
|
|
23114
23325
|
preWriteEnv = void 0;
|
|
23115
23326
|
}
|
|
@@ -23137,9 +23348,9 @@ async function processAgent(agent, agentStates, managedToolkits) {
|
|
|
23137
23348
|
}
|
|
23138
23349
|
if (fw === "claude-code" && isSessionHealthy(agent.code_name)) {
|
|
23139
23350
|
try {
|
|
23140
|
-
const projectMcpPath =
|
|
23141
|
-
const postWriteEnv =
|
|
23142
|
-
const mcpContent =
|
|
23351
|
+
const projectMcpPath = join47(projectDir, ".mcp.json");
|
|
23352
|
+
const postWriteEnv = readFileSync38(envIntPath, "utf-8");
|
|
23353
|
+
const mcpContent = readFileSync38(projectMcpPath, "utf-8");
|
|
23143
23354
|
const changedVars = diffEnvIntegrations(preWriteEnv, postWriteEnv);
|
|
23144
23355
|
const mcpJsonForReap = JSON.parse(mcpContent);
|
|
23145
23356
|
const affectedServerKeys = findMcpServersUsingVars(mcpJsonForReap, changedVars);
|
|
@@ -23208,6 +23419,10 @@ async function processAgent(agent, agentStates, managedToolkits) {
|
|
|
23208
23419
|
if (markMcpRepairPending(agentState.knownIntegrationHashes, agent.agent_id, orphanPruneFailed || mcpWriteFailed || !rotationHandled)) {
|
|
23209
23420
|
log(`[hot-reload] '${agent.code_name}': MCP config writes did not all land this poll; the next poll re-renders to repair them (ENG-11912)`);
|
|
23210
23421
|
}
|
|
23422
|
+
const reloadRendered = rotationHandled && !orphanPruneFailed && !mcpWriteFailed;
|
|
23423
|
+
if (configReloads.isPending(agent.agent_id) && integrationsFresh && reloadRendered) {
|
|
23424
|
+
configReloads.noteFreshRender(agent.agent_id, Date.now());
|
|
23425
|
+
}
|
|
23211
23426
|
confirmConfigReload(
|
|
23212
23427
|
{
|
|
23213
23428
|
agentId: agent.agent_id,
|
|
@@ -23215,7 +23430,8 @@ async function processAgent(agent, agentStates, managedToolkits) {
|
|
|
23215
23430
|
framework: agentFrameworkCache.get(agent.code_name) ?? DEFAULT_FRAMEWORK,
|
|
23216
23431
|
pending: configReloads.isPending(agent.agent_id),
|
|
23217
23432
|
freshFetch: integrationsFresh,
|
|
23218
|
-
rendered:
|
|
23433
|
+
rendered: reloadRendered,
|
|
23434
|
+
freshRenderedAt: configReloads.freshRenderedAt(agent.agent_id)
|
|
23219
23435
|
},
|
|
23220
23436
|
{
|
|
23221
23437
|
// CodeRabbit on ba9356f4: the tri-state probe, not the boolean health
|
|
@@ -23231,7 +23447,15 @@ async function processAgent(agent, agentStates, managedToolkits) {
|
|
|
23231
23447
|
stopPersistentSessionAndForgetMcpBaseline(code, "integration-change");
|
|
23232
23448
|
},
|
|
23233
23449
|
confirm: (agentId) => configReloads.confirm(agentId),
|
|
23234
|
-
log
|
|
23450
|
+
log,
|
|
23451
|
+
// ENG-12052: the session process, not just its tmux session.
|
|
23452
|
+
probeProcess: probeSessionProcess,
|
|
23453
|
+
sessionSpawnedAt: reloadSessionSpawnedAt,
|
|
23454
|
+
spawnedBlind: (code) => reloadBlindSpawns.has(code),
|
|
23455
|
+
probeProcessOlderThan: probeSessionProcessOlderThan,
|
|
23456
|
+
clearBlind: (code) => void reloadBlindSpawns.delete(code),
|
|
23457
|
+
unknownStreak: reloadUnknownStreak,
|
|
23458
|
+
alert: (agentId, reason) => void reportReaperEvent(agentId, "reload-confirm", "alert", reason)
|
|
23235
23459
|
}
|
|
23236
23460
|
);
|
|
23237
23461
|
if (capSurfaceHash !== prevCapSurfaceHash && rotationHandled) {
|
|
@@ -23479,12 +23703,12 @@ async function processAgent(agent, agentStates, managedToolkits) {
|
|
|
23479
23703
|
const frameworkId2 = frameworkAdapter.id;
|
|
23480
23704
|
const candidateSkillDirs = [
|
|
23481
23705
|
// Claude Code — framework runtime tree
|
|
23482
|
-
|
|
23706
|
+
join47(homedir18(), ".augmented", agent.code_name, "skills"),
|
|
23483
23707
|
// Claude Code — project tree
|
|
23484
|
-
|
|
23708
|
+
join47(homedir18(), ".augmented", agent.code_name, "project", ".claude", "skills"),
|
|
23485
23709
|
// Defensive: legacy provision-side path, not currently an
|
|
23486
23710
|
// install target but cheap to sweep.
|
|
23487
|
-
|
|
23711
|
+
join47(agentDir, ".claude", "skills")
|
|
23488
23712
|
];
|
|
23489
23713
|
const existingDirs = candidateSkillDirs.filter((d) => existsSync20(d));
|
|
23490
23714
|
const discoveredEntries = /* @__PURE__ */ new Set();
|
|
@@ -23527,7 +23751,7 @@ async function processAgent(agent, agentStates, managedToolkits) {
|
|
|
23527
23751
|
const sharedSkillsPayload = refreshAny.shared_skills;
|
|
23528
23752
|
const desiredResolved = globalSkillsPayload !== void 0 || sharedSkillsPayload !== void 0;
|
|
23529
23753
|
const manifestPath = managedSkillManifestPath(
|
|
23530
|
-
|
|
23754
|
+
join47(homedir17(), ".augmented", agent.code_name)
|
|
23531
23755
|
);
|
|
23532
23756
|
const prevIds = /* @__PURE__ */ new Set([
|
|
23533
23757
|
...agentState.knownGlobalSkillIds.get(agent.agent_id) ?? /* @__PURE__ */ new Set(),
|
|
@@ -23547,15 +23771,15 @@ async function processAgent(agent, agentStates, managedToolkits) {
|
|
|
23547
23771
|
}
|
|
23548
23772
|
if (plan.removes.length) {
|
|
23549
23773
|
const globalSkillDirs = [
|
|
23550
|
-
|
|
23551
|
-
|
|
23552
|
-
|
|
23774
|
+
join47(homedir17(), ".augmented", agent.code_name, "skills"),
|
|
23775
|
+
join47(homedir17(), ".augmented", agent.code_name, "project", ".claude", "skills"),
|
|
23776
|
+
join47(agentDir, ".claude", "skills")
|
|
23553
23777
|
];
|
|
23554
23778
|
for (const id of plan.removes) {
|
|
23555
23779
|
let prunedAny = false;
|
|
23556
23780
|
for (const dir of globalSkillDirs) {
|
|
23557
|
-
const p =
|
|
23558
|
-
if (existsSync20(p) && existsSync20(
|
|
23781
|
+
const p = join47(dir, id);
|
|
23782
|
+
if (existsSync20(p) && existsSync20(join47(p, "SKILL.md"))) {
|
|
23559
23783
|
rmSync9(p, { recursive: true, force: true });
|
|
23560
23784
|
prunedAny = true;
|
|
23561
23785
|
}
|
|
@@ -24341,7 +24565,7 @@ Retried to the limit after repeated stalls \u2014 needs a look.`).catch(() => {
|
|
|
24341
24565
|
if (trackedFiles.length > 0 && existsSync20(agentDir)) {
|
|
24342
24566
|
const hashes = /* @__PURE__ */ new Map();
|
|
24343
24567
|
for (const file of trackedFiles) {
|
|
24344
|
-
const h = hashFile(
|
|
24568
|
+
const h = hashFile(join47(agentDir, file));
|
|
24345
24569
|
if (h) hashes.set(file, h);
|
|
24346
24570
|
}
|
|
24347
24571
|
agentState.writtenHashes.set(agent.agent_id, hashes);
|
|
@@ -24356,7 +24580,7 @@ Retried to the limit after repeated stalls \u2014 needs a look.`).catch(() => {
|
|
|
24356
24580
|
refreshData.agent.onboarding_state
|
|
24357
24581
|
);
|
|
24358
24582
|
const obStep = obState.step;
|
|
24359
|
-
const markerPath =
|
|
24583
|
+
const markerPath = join47(homedir17(), ".augmented", agent.code_name, "onboarding-drive.json");
|
|
24360
24584
|
const marker = readOnboardingDriveMarker(markerPath);
|
|
24361
24585
|
const obContactRaw = refreshData.agent.manager_last_contacted_at;
|
|
24362
24586
|
const obContact = typeof obContactRaw === "string" && obContactRaw ? obContactRaw : null;
|
|
@@ -24489,7 +24713,7 @@ async function ensureOpencodeRuntime(agent, refreshData, agentTimezone) {
|
|
|
24489
24713
|
}
|
|
24490
24714
|
stopOpencodeSlackIngest(codeName, log);
|
|
24491
24715
|
stopOpencodeTelegramIngest(codeName, log);
|
|
24492
|
-
const opencodeProjectDir =
|
|
24716
|
+
const opencodeProjectDir = join47(getFramework("opencode").getAgentDir(codeName), "provision");
|
|
24493
24717
|
const serveEnv = {
|
|
24494
24718
|
AGT_HOST: requireHost(),
|
|
24495
24719
|
AGT_API_KEY: getApiKey() ?? void 0,
|
|
@@ -24560,8 +24784,8 @@ async function ensurePersistentSessionUnchecked(agent, tasks, boardItems, refres
|
|
|
24560
24784
|
});
|
|
24561
24785
|
}
|
|
24562
24786
|
const projectDir = getProjectDir(codeName);
|
|
24563
|
-
const mcpConfigPath =
|
|
24564
|
-
const claudeMdPath =
|
|
24787
|
+
const mcpConfigPath = join47(projectDir, ".mcp.json");
|
|
24788
|
+
const claudeMdPath = join47(projectDir, "CLAUDE.md");
|
|
24565
24789
|
if (restartBreaker.isTripped(codeName)) {
|
|
24566
24790
|
const trip = restartBreaker.getTrip(codeName);
|
|
24567
24791
|
return {
|
|
@@ -24590,6 +24814,37 @@ async function ensurePersistentSessionUnchecked(agent, tasks, boardItems, refres
|
|
|
24590
24814
|
};
|
|
24591
24815
|
}
|
|
24592
24816
|
}
|
|
24817
|
+
let stragglerGateRan = false;
|
|
24818
|
+
const runStragglerGate = () => {
|
|
24819
|
+
stragglerGateRan = true;
|
|
24820
|
+
const gate = stragglerSpawnGate(codeName, {
|
|
24821
|
+
probeProcess: probeSessionProcess,
|
|
24822
|
+
probeTmux: (c) => probeTmuxSession(`agt-${c}`),
|
|
24823
|
+
isDocker: (c) => effectiveIsolationMode(c) === "docker",
|
|
24824
|
+
killStraggler: killStragglerProcess,
|
|
24825
|
+
log,
|
|
24826
|
+
deferStreak: stragglerDeferStreak,
|
|
24827
|
+
// Obi Wan 417cd9e6ce9a: under 'reload-confirm', which /host/reaper-event
|
|
24828
|
+
// accepts (REAPER_EVENT_ALLOWLIST); an unlisted reaper name is a 400 and
|
|
24829
|
+
// the alert would never open.
|
|
24830
|
+
alert: (_code, reason) => void reportReaperEvent(agent.agent_id, "reload-confirm", "alert", reason)
|
|
24831
|
+
});
|
|
24832
|
+
if (gate === "spawn-unknown" && effectiveIsolationMode(codeName) !== "docker") reloadBlindSpawns.add(codeName);
|
|
24833
|
+
else if (gate !== "defer") reloadBlindSpawns.delete(codeName);
|
|
24834
|
+
if (gate === "defer") {
|
|
24835
|
+
return {
|
|
24836
|
+
decision: "skipped-straggler-alive",
|
|
24837
|
+
spawnAttempted: false,
|
|
24838
|
+
sessionHealthyAfter: false,
|
|
24839
|
+
detail: "a previous claude process for this agent is still running (sent SIGTERM)"
|
|
24840
|
+
};
|
|
24841
|
+
}
|
|
24842
|
+
return null;
|
|
24843
|
+
};
|
|
24844
|
+
if ((agentFrameworkCache.get(codeName) ?? DEFAULT_FRAMEWORK) === "claude-code" && !isSessionHealthy(codeName)) {
|
|
24845
|
+
const deferred = runStragglerGate();
|
|
24846
|
+
if (deferred) return deferred;
|
|
24847
|
+
}
|
|
24593
24848
|
const teamSettingsForTz = refreshData.team?.settings;
|
|
24594
24849
|
const agentTimezone = (() => {
|
|
24595
24850
|
const ownTzRaw = refreshData.agent?.timezone;
|
|
@@ -25074,6 +25329,13 @@ ${truncateForLog(ctx.tail)}` : `; pane_tail_hash=sha256:${createHash21("sha256")
|
|
|
25074
25329
|
`[persistent-session] '${codeName}' (host_kind=${hostKind ?? "dedicated"}): injecting per-agent org-scoped key (ADR-0042 pt3b)`
|
|
25075
25330
|
);
|
|
25076
25331
|
}
|
|
25332
|
+
if (!stragglerGateRan && (agentFrameworkCache.get(codeName) ?? DEFAULT_FRAMEWORK) === "claude-code" && !isSessionHealthy(codeName)) {
|
|
25333
|
+
const deferred = runStragglerGate();
|
|
25334
|
+
if (deferred) {
|
|
25335
|
+
closeSessionRunForCode(codeName, "failed", "a previous claude process is still running");
|
|
25336
|
+
return deferred;
|
|
25337
|
+
}
|
|
25338
|
+
}
|
|
25077
25339
|
let spawnCopyFailedNow = false;
|
|
25078
25340
|
const spawnMcpConfigPath = prepareSpawnMcpConfig({
|
|
25079
25341
|
codeName,
|
|
@@ -25534,6 +25796,13 @@ async function managerRestartMayKill(agentId, codeName, requestedAt, lane, frame
|
|
|
25534
25796
|
pane.tmuxAlive === null ? null : sessionActivityFor(codeName, { tmuxAlive: pane.tmuxAlive, screenCapture: pane.screenCapture }, { fresh: true })
|
|
25535
25797
|
);
|
|
25536
25798
|
}
|
|
25799
|
+
if (verdict.kill && isolationMode(codeName) !== "docker") {
|
|
25800
|
+
const dc = readDirectChatInflight(join47(homedir17(), ".augmented", agentId));
|
|
25801
|
+
if (dc.inFlight) {
|
|
25802
|
+
verdict = { kill: false, reason: "direct_chat_in_flight", runningBackgroundTasks: null };
|
|
25803
|
+
log(`[${lane}] manager restart for '${codeName}': ${dc.ids.length} Direct Chat message(s) claimed and not yet answered [ENG-12100]`);
|
|
25804
|
+
}
|
|
25805
|
+
}
|
|
25537
25806
|
if (verdict.kill) {
|
|
25538
25807
|
log(`[${lane}] manager restart for '${codeName}': re-check passed (idle, nothing in the background) - restarting [ENG-11963]`);
|
|
25539
25808
|
return { kill: true, declined: false };
|
|
@@ -25602,7 +25871,7 @@ async function handleRestartDoorbell(agentId, requestedAt, restartReason) {
|
|
|
25602
25871
|
if (!refreshData) return;
|
|
25603
25872
|
const framework = refreshData.agent?.framework ?? agentFrameworkCache.get(codeName) ?? DEFAULT_FRAMEWORK;
|
|
25604
25873
|
const hostId = await getHostId();
|
|
25605
|
-
const parkForRestart = await import("../responsiveness-probe-
|
|
25874
|
+
const parkForRestart = await import("../responsiveness-probe-GXI34QDS.js").then(
|
|
25606
25875
|
(m) => m.parkPendingInbound,
|
|
25607
25876
|
(err) => err
|
|
25608
25877
|
);
|
|
@@ -25679,7 +25948,7 @@ async function handleRestartDoorbell(agentId, requestedAt, restartReason) {
|
|
|
25679
25948
|
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}`));
|
|
25680
25949
|
void (async () => {
|
|
25681
25950
|
try {
|
|
25682
|
-
const { collectDiagnostics } = await import("../persistent-session-
|
|
25951
|
+
const { collectDiagnostics } = await import("../persistent-session-MX6UHWLR.js");
|
|
25683
25952
|
await api.post("/host/heartbeat", {
|
|
25684
25953
|
host_id: hostId,
|
|
25685
25954
|
agent_diagnostics: collectDiagnostics([codeName], quarantineEntriesFor, claudeMdSizeFor, spawnOutcomeForDiagnostics, pidPressureFor, forwardedToolsFor, runtimeVersionFor, sessionActivityFor)
|
|
@@ -25732,7 +26001,7 @@ async function respawnAgentAfterMcpStop(codeName, reason) {
|
|
|
25732
26001
|
}
|
|
25733
26002
|
try {
|
|
25734
26003
|
const hostId = await getHostId();
|
|
25735
|
-
const { collectDiagnostics } = await import("../persistent-session-
|
|
26004
|
+
const { collectDiagnostics } = await import("../persistent-session-MX6UHWLR.js");
|
|
25736
26005
|
await api.post("/host/heartbeat", {
|
|
25737
26006
|
host_id: hostId,
|
|
25738
26007
|
agent_diagnostics: collectDiagnostics([codeName], quarantineEntriesFor, claudeMdSizeFor, spawnOutcomeForDiagnostics, pidPressureFor, forwardedToolsFor, runtimeVersionFor, sessionActivityFor)
|
|
@@ -26145,7 +26414,7 @@ async function processDirectChatMessage(agent, msg) {
|
|
|
26145
26414
|
try {
|
|
26146
26415
|
const doorbell = directChatDoorbellPath(agent.agentId, homedir17());
|
|
26147
26416
|
mkdirSync18(dirname11(doorbell), { recursive: true });
|
|
26148
|
-
|
|
26417
|
+
writeFileSync20(doorbell, String(Date.now()));
|
|
26149
26418
|
log(`[direct-chat] Doorbell rung for '${agent.codeName}' (msg=${msg.id}) \u2014 in-session MCP will pull via the cursor`);
|
|
26150
26419
|
return;
|
|
26151
26420
|
} catch (err) {
|
|
@@ -26274,7 +26543,7 @@ ${formatRunMarker(run_id)}` : KANBAN_CHECK_COMMAND;
|
|
|
26274
26543
|
try {
|
|
26275
26544
|
const doorbell = directChatDoorbellPath(agentId, homedir17());
|
|
26276
26545
|
mkdirSync18(dirname11(doorbell), { recursive: true });
|
|
26277
|
-
|
|
26546
|
+
writeFileSync20(doorbell, String(Date.now()));
|
|
26278
26547
|
} catch (err) {
|
|
26279
26548
|
log(`[kanban] doorbell ring failed for '${codeName}': ${err.message} (notice still queued)`);
|
|
26280
26549
|
}
|
|
@@ -26434,7 +26703,7 @@ async function processClaudePairSessions(agents) {
|
|
|
26434
26703
|
snapshotPairConfig,
|
|
26435
26704
|
// ENG-11659: result -> report body + the manager.log line that records it.
|
|
26436
26705
|
planPairStartReport
|
|
26437
|
-
} = await import("../claude-pair-runtime-
|
|
26706
|
+
} = await import("../claude-pair-runtime-XTRWHN5Q.js");
|
|
26438
26707
|
const { resetClaudeSignin, describeSigninResetForLog, describeSigninResetFailure } = await import("../claude-signin-reset-6IJMMVYG.js");
|
|
26439
26708
|
for (const pairId of pendingResp.cancelled_pair_ids ?? []) {
|
|
26440
26709
|
log(`[claude-pair] sweeping orphan tmux session for pair ${pairId.slice(0, 8)}`);
|
|
@@ -26733,17 +27002,17 @@ var lastLocalFileHash = /* @__PURE__ */ new Map();
|
|
|
26733
27002
|
var lastMemoriesBody = /* @__PURE__ */ new Map();
|
|
26734
27003
|
var memoryManifests = /* @__PURE__ */ new Map();
|
|
26735
27004
|
function memoryRetirementDir(configDir, codeName) {
|
|
26736
|
-
return
|
|
27005
|
+
return join47(configDir, "_memory-retirement", codeName);
|
|
26737
27006
|
}
|
|
26738
27007
|
function memoryManifestPath(configDir, codeName) {
|
|
26739
|
-
return
|
|
27008
|
+
return join47(memoryRetirementDir(configDir, codeName), "manifest.json");
|
|
26740
27009
|
}
|
|
26741
27010
|
function loadMemoryManifest(agentId, configDir, codeName) {
|
|
26742
27011
|
const cached = memoryManifests.get(agentId);
|
|
26743
27012
|
if (cached) return cached;
|
|
26744
27013
|
let manifest = {};
|
|
26745
27014
|
try {
|
|
26746
|
-
const raw =
|
|
27015
|
+
const raw = readFileSync38(memoryManifestPath(configDir, codeName), "utf-8");
|
|
26747
27016
|
const parsed = JSON.parse(raw);
|
|
26748
27017
|
if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) {
|
|
26749
27018
|
for (const [name, entry] of Object.entries(parsed)) {
|
|
@@ -26765,13 +27034,13 @@ function saveMemoryManifest(agentId, configDir, codeName) {
|
|
|
26765
27034
|
const path = memoryManifestPath(configDir, codeName);
|
|
26766
27035
|
mkdirSync18(memoryRetirementDir(configDir, codeName), { recursive: true });
|
|
26767
27036
|
const tmp = `${path}.tmp`;
|
|
26768
|
-
|
|
26769
|
-
|
|
27037
|
+
writeFileSync20(tmp, JSON.stringify(manifest, null, 2));
|
|
27038
|
+
renameSync12(tmp, path);
|
|
26770
27039
|
} catch {
|
|
26771
27040
|
}
|
|
26772
27041
|
}
|
|
26773
27042
|
function retiredMemoryDir(configDir, codeName) {
|
|
26774
|
-
return
|
|
27043
|
+
return join47(memoryRetirementDir(configDir, codeName), "retired");
|
|
26775
27044
|
}
|
|
26776
27045
|
var RETIRED_MEMORY_TTL_MS = 30 * 24 * 60 * 60 * 1e3;
|
|
26777
27046
|
var lastRetirementReport = /* @__PURE__ */ new Map();
|
|
@@ -26850,7 +27119,7 @@ function applyMemoryTombstones(opts) {
|
|
|
26850
27119
|
log2(`[memory-retire] ${agent.code_name}: KEPT '${tomb.name}' \u2014 no write record, not ours to remove`);
|
|
26851
27120
|
continue;
|
|
26852
27121
|
}
|
|
26853
|
-
const filePath =
|
|
27122
|
+
const filePath = join47(memoryDir, entry.file);
|
|
26854
27123
|
if (!existsSync20(filePath)) {
|
|
26855
27124
|
outcomes.already_gone++;
|
|
26856
27125
|
delete manifest[tomb.name];
|
|
@@ -26858,7 +27127,7 @@ function applyMemoryTombstones(opts) {
|
|
|
26858
27127
|
continue;
|
|
26859
27128
|
}
|
|
26860
27129
|
try {
|
|
26861
|
-
const actual = createHash21("sha256").update(
|
|
27130
|
+
const actual = createHash21("sha256").update(readFileSync38(filePath)).digest("hex");
|
|
26862
27131
|
if (actual !== entry.sha) {
|
|
26863
27132
|
outcomes.kept_modified++;
|
|
26864
27133
|
outcomes.unapplied.push({ name: tomb.name, reason: "kept_modified" });
|
|
@@ -26870,11 +27139,11 @@ function applyMemoryTombstones(opts) {
|
|
|
26870
27139
|
const destDir = retiredMemoryDir(configDir, agent.code_name);
|
|
26871
27140
|
mkdirSync18(destDir, { recursive: true });
|
|
26872
27141
|
const stamp = Date.now();
|
|
26873
|
-
let dest =
|
|
27142
|
+
let dest = join47(destDir, `${entry.file}.${stamp}.retired`);
|
|
26874
27143
|
for (let n = 1; existsSync20(dest); n++) {
|
|
26875
|
-
dest =
|
|
27144
|
+
dest = join47(destDir, `${entry.file}.${stamp}-${n}.retired`);
|
|
26876
27145
|
}
|
|
26877
|
-
|
|
27146
|
+
renameSync12(filePath, dest);
|
|
26878
27147
|
try {
|
|
26879
27148
|
const now = Date.now() / 1e3;
|
|
26880
27149
|
utimesSync4(dest, now, now);
|
|
@@ -26911,7 +27180,7 @@ function reapRetiredMemories(configDir, codeName, log2) {
|
|
|
26911
27180
|
try {
|
|
26912
27181
|
for (const file of readdirSync14(dir)) {
|
|
26913
27182
|
if (!file.endsWith(".retired")) continue;
|
|
26914
|
-
const path =
|
|
27183
|
+
const path = join47(dir, file);
|
|
26915
27184
|
try {
|
|
26916
27185
|
if (statSync15(path).mtimeMs < cutoff) {
|
|
26917
27186
|
unlinkSync6(path);
|
|
@@ -26926,8 +27195,8 @@ function reapRetiredMemories(configDir, codeName, log2) {
|
|
|
26926
27195
|
if (reaped > 0) log2(`[memory-retire] ${codeName}: reaped ${reaped} retired memory file(s) past TTL`);
|
|
26927
27196
|
}
|
|
26928
27197
|
async function syncMemories(agent, configDir, log2) {
|
|
26929
|
-
const projectDir =
|
|
26930
|
-
const memoryDir =
|
|
27198
|
+
const projectDir = join47(configDir, agent.code_name, "project");
|
|
27199
|
+
const memoryDir = join47(projectDir, "memory");
|
|
26931
27200
|
const isFreshSync = pendingFreshMemorySync.has(agent.agent_id);
|
|
26932
27201
|
if (isFreshSync) {
|
|
26933
27202
|
log2(`[memory-sync] Fresh-sync requested for '${agent.code_name}' \u2014 pulling DB first`);
|
|
@@ -26958,7 +27227,7 @@ async function syncMemories(agent, configDir, log2) {
|
|
|
26958
27227
|
for (const file of readdirSync14(memoryDir)) {
|
|
26959
27228
|
if (!file.endsWith(".md")) continue;
|
|
26960
27229
|
try {
|
|
26961
|
-
const raw =
|
|
27230
|
+
const raw = readFileSync38(join47(memoryDir, file), "utf-8");
|
|
26962
27231
|
const fileHash = createHash21("sha256").update(raw).digest("hex").slice(0, 16);
|
|
26963
27232
|
currentHashes.set(file, fileHash);
|
|
26964
27233
|
if (prevHashes.get(file) === fileHash) continue;
|
|
@@ -26983,7 +27252,7 @@ async function syncMemories(agent, configDir, log2) {
|
|
|
26983
27252
|
} catch (err) {
|
|
26984
27253
|
for (const mem of changedMemories) {
|
|
26985
27254
|
for (const [file] of currentHashes) {
|
|
26986
|
-
const parsed = parseMemoryFile(
|
|
27255
|
+
const parsed = parseMemoryFile(readFileSync38(join47(memoryDir, file), "utf-8"), file.replace(/\.md$/, ""));
|
|
26987
27256
|
if (parsed?.name === mem.name) currentHashes.delete(file);
|
|
26988
27257
|
}
|
|
26989
27258
|
}
|
|
@@ -27064,7 +27333,7 @@ async function downloadMemories(agent, memoryDir, log2, { force, configDir }) {
|
|
|
27064
27333
|
// Per-agent, not host-wide: memories are agent-private, so a shared
|
|
27065
27334
|
// store would buy almost no dedupe while exposing one agent's content
|
|
27066
27335
|
// to every other agent on the host. See memory-cache.ts's header.
|
|
27067
|
-
cacheDir:
|
|
27336
|
+
cacheDir: join47(configDir, agent.code_name, "_memory_bodies"),
|
|
27068
27337
|
fetchContents: async (hashes) => {
|
|
27069
27338
|
const res = await api.post(
|
|
27070
27339
|
"/host/memories/contents",
|
|
@@ -27102,7 +27371,7 @@ async function downloadMemories(agent, memoryDir, log2, { force, configDir }) {
|
|
|
27102
27371
|
const rawSlug = mem.name.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/(^-|-$)/g, "").slice(0, 60);
|
|
27103
27372
|
const slug = rawSlug || `memory-${i}`;
|
|
27104
27373
|
const fileName = `${slug}.md`;
|
|
27105
|
-
const filePath =
|
|
27374
|
+
const filePath = join47(memoryDir, fileName);
|
|
27106
27375
|
const desired = `---
|
|
27107
27376
|
name: ${JSON.stringify(mem.name)}
|
|
27108
27377
|
type: ${mem.type}
|
|
@@ -27122,7 +27391,7 @@ ${mem.content}
|
|
|
27122
27391
|
if (existsSync20(filePath)) {
|
|
27123
27392
|
let existing = "";
|
|
27124
27393
|
try {
|
|
27125
|
-
existing =
|
|
27394
|
+
existing = readFileSync38(filePath, "utf-8");
|
|
27126
27395
|
} catch {
|
|
27127
27396
|
}
|
|
27128
27397
|
if (existing === desired) {
|
|
@@ -27130,10 +27399,10 @@ ${mem.content}
|
|
|
27130
27399
|
if (manifestDirty) saveMemoryManifest(agent.agent_id, configDir, agent.code_name);
|
|
27131
27400
|
continue;
|
|
27132
27401
|
}
|
|
27133
|
-
|
|
27402
|
+
writeFileSync20(filePath, desired);
|
|
27134
27403
|
overwritten++;
|
|
27135
27404
|
} else {
|
|
27136
|
-
|
|
27405
|
+
writeFileSync20(filePath, desired);
|
|
27137
27406
|
written++;
|
|
27138
27407
|
}
|
|
27139
27408
|
if (record()) manifestDirty = true;
|
|
@@ -27523,7 +27792,7 @@ function startManager(opts) {
|
|
|
27523
27792
|
try {
|
|
27524
27793
|
const stateFile = getStateFile();
|
|
27525
27794
|
if (existsSync20(stateFile)) {
|
|
27526
|
-
const raw =
|
|
27795
|
+
const raw = readFileSync38(stateFile, "utf-8");
|
|
27527
27796
|
const parsed = JSON.parse(raw);
|
|
27528
27797
|
if (Array.isArray(parsed.agents)) {
|
|
27529
27798
|
state9.agents = parsed.agents;
|
|
@@ -27557,7 +27826,7 @@ function startManager(opts) {
|
|
|
27557
27826
|
log(`[startup] state rehydration failed (continuing with empty state): ${err.message}`);
|
|
27558
27827
|
}
|
|
27559
27828
|
log(
|
|
27560
|
-
`[startup] worker pid=${process.pid} ppid=${process.ppid} node=${process.version} log=${
|
|
27829
|
+
`[startup] worker pid=${process.pid} ppid=${process.ppid} node=${process.version} log=${join47(homedir17(), ".augmented", "manager.log")}`
|
|
27561
27830
|
);
|
|
27562
27831
|
deployMcpAssets();
|
|
27563
27832
|
reapOrphanChannelMcps({ log });
|
|
@@ -27586,7 +27855,7 @@ async function reapOrphanedClaudePids() {
|
|
|
27586
27855
|
const looksLikeClaude = (pid) => {
|
|
27587
27856
|
if (process.platform !== "linux") return true;
|
|
27588
27857
|
try {
|
|
27589
|
-
const comm =
|
|
27858
|
+
const comm = readFileSync38(`/proc/${pid}/comm`, "utf-8").trim().toLowerCase();
|
|
27590
27859
|
return comm.includes("claude");
|
|
27591
27860
|
} catch {
|
|
27592
27861
|
return false;
|
|
@@ -27683,14 +27952,14 @@ function restartRunningChannelMcps(basenames) {
|
|
|
27683
27952
|
}
|
|
27684
27953
|
}
|
|
27685
27954
|
function deployMcpAssets() {
|
|
27686
|
-
const targetDir =
|
|
27955
|
+
const targetDir = join47(homedir17(), ".augmented", "_mcp");
|
|
27687
27956
|
mkdirSync18(targetDir, { recursive: true });
|
|
27688
27957
|
const moduleDir = dirname11(fileURLToPath2(import.meta.url));
|
|
27689
27958
|
let mcpSourceDir = "";
|
|
27690
27959
|
let dir = moduleDir;
|
|
27691
27960
|
for (let i = 0; i < 6; i++) {
|
|
27692
|
-
const candidate =
|
|
27693
|
-
if (existsSync20(
|
|
27961
|
+
const candidate = join47(dir, "dist", "mcp");
|
|
27962
|
+
if (existsSync20(join47(candidate, "index.js"))) {
|
|
27694
27963
|
mcpSourceDir = candidate;
|
|
27695
27964
|
break;
|
|
27696
27965
|
}
|
|
@@ -27708,7 +27977,7 @@ function deployMcpAssets() {
|
|
|
27708
27977
|
const fileHash = (p) => {
|
|
27709
27978
|
try {
|
|
27710
27979
|
if (!existsSync20(p)) return null;
|
|
27711
|
-
return createHash21("sha256").update(
|
|
27980
|
+
return createHash21("sha256").update(readFileSync38(p)).digest("hex");
|
|
27712
27981
|
} catch {
|
|
27713
27982
|
return null;
|
|
27714
27983
|
}
|
|
@@ -27790,8 +28059,8 @@ function deployMcpAssets() {
|
|
|
27790
28059
|
// natural session restart.
|
|
27791
28060
|
"computer-use-proxy.js"
|
|
27792
28061
|
]) {
|
|
27793
|
-
const src =
|
|
27794
|
-
const dst =
|
|
28062
|
+
const src = join47(mcpSourceDir, file);
|
|
28063
|
+
const dst = join47(targetDir, file);
|
|
27795
28064
|
if (!existsSync20(src)) continue;
|
|
27796
28065
|
attemptedFiles.push(file);
|
|
27797
28066
|
const before = fileHash(dst);
|
|
@@ -27817,23 +28086,23 @@ function deployMcpAssets() {
|
|
|
27817
28086
|
log(`[manager] Bundle(s) updated: ${changedBasenames.join(", ")} \u2014 signalling running instances to restart`);
|
|
27818
28087
|
restartRunningChannelMcps(changedBasenames);
|
|
27819
28088
|
}
|
|
27820
|
-
const localMcpPath =
|
|
28089
|
+
const localMcpPath = join47(targetDir, "index.js");
|
|
27821
28090
|
try {
|
|
27822
|
-
const agentsDir =
|
|
28091
|
+
const agentsDir = join47(homedir17(), ".augmented", "agents");
|
|
27823
28092
|
if (existsSync20(agentsDir)) {
|
|
27824
28093
|
for (const entry of readdirSync14(agentsDir, { withFileTypes: true })) {
|
|
27825
28094
|
if (!entry.isDirectory()) continue;
|
|
27826
28095
|
for (const subdir of ["provision", "project"]) {
|
|
27827
|
-
const mcpJsonPath =
|
|
28096
|
+
const mcpJsonPath = join47(agentsDir, entry.name, subdir, ".mcp.json");
|
|
27828
28097
|
try {
|
|
27829
|
-
const raw =
|
|
28098
|
+
const raw = readFileSync38(mcpJsonPath, "utf-8");
|
|
27830
28099
|
if (!raw.includes("@integrity-labs/augmented-mcp")) continue;
|
|
27831
28100
|
const mcpConfig = JSON.parse(raw);
|
|
27832
28101
|
const augServer = mcpConfig.mcpServers?.["augmented"];
|
|
27833
28102
|
if (!augServer) continue;
|
|
27834
28103
|
augServer.command = "node";
|
|
27835
28104
|
augServer.args = [localMcpPath];
|
|
27836
|
-
|
|
28105
|
+
writeFileSync20(mcpJsonPath, JSON.stringify(mcpConfig, null, 2));
|
|
27837
28106
|
log(`[manager] Patched ${entry.name}/${subdir}/.mcp.json: npx \u2192 node`);
|
|
27838
28107
|
} catch {
|
|
27839
28108
|
}
|