@integrity-labs/agt-cli 0.28.1246 → 0.28.1248
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin/agt.js +6 -6
- package/dist/{chunk-OSXVD3YF.js → chunk-73NMB6QK.js} +16 -1
- package/dist/chunk-73NMB6QK.js.map +1 -0
- package/dist/{chunk-22GBHBJZ.js → chunk-EKFRF2GR.js} +2 -2
- package/dist/{chunk-V47ZQJ3Y.js → chunk-OYLLSEI5.js} +2 -2
- package/dist/{chunk-EGMQVUAO.js → chunk-RSFDRIIC.js} +3 -3
- package/dist/{chunk-ZHLBICZL.js → chunk-VGL726BP.js} +5 -5
- package/dist/{claude-code-updater-6QVV5JHB.js → claude-code-updater-G4Y3CMTI.js} +3 -3
- package/dist/{claude-pair-runtime-IOUQF6RF.js → claude-pair-runtime-ZGYYBH3G.js} +3 -3
- package/dist/lib/manager-worker.js +289 -118
- package/dist/lib/manager-worker.js.map +1 -1
- package/dist/mcp/direct-chat-channel.js +15 -0
- package/dist/mcp/index.js +15 -0
- package/dist/mcp/origami.js +15 -0
- package/dist/mcp/slack-channel.js +15 -0
- package/dist/mcp/telegram-channel.js +15 -0
- package/dist/{persistent-session-4HI235XH.js → persistent-session-R2RY5NJ3.js} +4 -4
- package/dist/{responsiveness-probe-AD6WIPDA.js → responsiveness-probe-MU5WMZSZ.js} +4 -4
- package/dist/{session-auth-dead-6FSKTBLA.js → session-auth-dead-B6JRV3QH.js} +3 -3
- package/package.json +1 -1
- package/dist/chunk-OSXVD3YF.js.map +0 -1
- /package/dist/{chunk-22GBHBJZ.js.map → chunk-EKFRF2GR.js.map} +0 -0
- /package/dist/{chunk-V47ZQJ3Y.js.map → chunk-OYLLSEI5.js.map} +0 -0
- /package/dist/{chunk-EGMQVUAO.js.map → chunk-RSFDRIIC.js.map} +0 -0
- /package/dist/{chunk-ZHLBICZL.js.map → chunk-VGL726BP.js.map} +0 -0
- /package/dist/{claude-code-updater-6QVV5JHB.js.map → claude-code-updater-G4Y3CMTI.js.map} +0 -0
- /package/dist/{claude-pair-runtime-IOUQF6RF.js.map → claude-pair-runtime-ZGYYBH3G.js.map} +0 -0
- /package/dist/{persistent-session-4HI235XH.js.map → persistent-session-R2RY5NJ3.js.map} +0 -0
- /package/dist/{responsiveness-probe-AD6WIPDA.js.map → responsiveness-probe-MU5WMZSZ.js.map} +0 -0
- /package/dist/{session-auth-dead-6FSKTBLA.js.map → session-auth-dead-B6JRV3QH.js.map} +0 -0
|
@@ -85,7 +85,7 @@ import {
|
|
|
85
85
|
tripClass,
|
|
86
86
|
writeEtcEnvironment,
|
|
87
87
|
writeProfileDScript
|
|
88
|
-
} from "../chunk-
|
|
88
|
+
} from "../chunk-VGL726BP.js";
|
|
89
89
|
import {
|
|
90
90
|
CLAUDE_CODE_SECURITY_FLOOR,
|
|
91
91
|
SELF_UPDATE_TIMEOUTS,
|
|
@@ -99,7 +99,7 @@ import {
|
|
|
99
99
|
runSafeCleanup,
|
|
100
100
|
tightestDiskStat,
|
|
101
101
|
withPackageCacheLock
|
|
102
|
-
} from "../chunk-
|
|
102
|
+
} from "../chunk-EKFRF2GR.js";
|
|
103
103
|
import {
|
|
104
104
|
rewriteSupervisorApiKey,
|
|
105
105
|
supervisorChannelsRefusing
|
|
@@ -195,7 +195,7 @@ import {
|
|
|
195
195
|
webFetchBaselineValue,
|
|
196
196
|
webFetchRestartNeeded,
|
|
197
197
|
writeEgressAllowlist
|
|
198
|
-
} from "../chunk-
|
|
198
|
+
} from "../chunk-RSFDRIIC.js";
|
|
199
199
|
import {
|
|
200
200
|
isAgentIdle,
|
|
201
201
|
isStaleForToday,
|
|
@@ -206,7 +206,7 @@ import {
|
|
|
206
206
|
subagentActivityAgeSeconds,
|
|
207
207
|
subagentTranscriptDir,
|
|
208
208
|
transcriptActivityAgeSeconds
|
|
209
|
-
} from "../chunk-
|
|
209
|
+
} from "../chunk-OYLLSEI5.js";
|
|
210
210
|
import {
|
|
211
211
|
classifyUnanswerablePane,
|
|
212
212
|
focusedConfirmDialogBlock,
|
|
@@ -337,7 +337,7 @@ import {
|
|
|
337
337
|
stabiliseResetInstant,
|
|
338
338
|
sumTranscriptUsageInWindow,
|
|
339
339
|
summarizeTranscriptActivity
|
|
340
|
-
} from "../chunk-
|
|
340
|
+
} from "../chunk-73NMB6QK.js";
|
|
341
341
|
import {
|
|
342
342
|
CLAUDE_CONFIG_DIR_ENV,
|
|
343
343
|
claudeConfigDirFor,
|
|
@@ -5016,10 +5016,10 @@ function sessionTranscript(dir, sessionId) {
|
|
|
5016
5016
|
return null;
|
|
5017
5017
|
}
|
|
5018
5018
|
}
|
|
5019
|
-
function readTranscript(cacheKey, dir, sessionId, nowMs) {
|
|
5019
|
+
function readTranscript(cacheKey, dir, sessionId, nowMs, minCheckMs = MIN_TRANSCRIPT_CHECK_MS) {
|
|
5020
5020
|
const session = sessionId ?? null;
|
|
5021
5021
|
const prev = cache.get(cacheKey)?.sessionId === session ? cache.get(cacheKey) : void 0;
|
|
5022
|
-
if (prev && nowMs - prev.checkedAt <
|
|
5022
|
+
if (prev && minCheckMs > 0 && nowMs - prev.checkedAt < minCheckMs) return prev;
|
|
5023
5023
|
const file = sessionTranscript(dir, sessionId);
|
|
5024
5024
|
if (!file) {
|
|
5025
5025
|
const none = { checkedAt: nowMs, sessionId: session, path: null, mtimeMs: null, size: 0, activity: NO_TRANSCRIPT_ACTIVITY };
|
|
@@ -5121,11 +5121,11 @@ function drainScan(scan, dir, log2) {
|
|
|
5121
5121
|
}
|
|
5122
5122
|
return budget > 0;
|
|
5123
5123
|
}
|
|
5124
|
-
function readBackgroundActivity(codeName, dir, sessionId, spawnedAtMs, isSpawnSession, nowMs, log2) {
|
|
5124
|
+
function readBackgroundActivity(codeName, dir, sessionId, spawnedAtMs, isSpawnSession, nowMs, log2, minCheckMs = MIN_TRANSCRIPT_CHECK_MS) {
|
|
5125
5125
|
if (!sessionId || !SESSION_ID.test(sessionId)) return NO_BACKGROUND_SIGNAL;
|
|
5126
5126
|
const prev = backgroundScans.get(codeName);
|
|
5127
5127
|
const sameRun = prev?.sessionId === sessionId && prev.spawnedAtMs === spawnedAtMs;
|
|
5128
|
-
if (prev && sameRun && nowMs - prev.checkedAt <
|
|
5128
|
+
if (prev && sameRun && minCheckMs > 0 && nowMs - prev.checkedAt < minCheckMs) return prev;
|
|
5129
5129
|
try {
|
|
5130
5130
|
const main = join18(dir, `${sessionId}.jsonl`);
|
|
5131
5131
|
let size;
|
|
@@ -5201,6 +5201,7 @@ function iso(ms) {
|
|
|
5201
5201
|
}
|
|
5202
5202
|
function buildSessionActivityReport(args) {
|
|
5203
5203
|
const nowMs = args.now ?? Date.now();
|
|
5204
|
+
const minCheckMs = args.fresh ? 0 : MIN_TRANSCRIPT_CHECK_MS;
|
|
5204
5205
|
try {
|
|
5205
5206
|
const pane = classifyPane(args.screenCapture, args.tmuxAlive);
|
|
5206
5207
|
if (!pane) return null;
|
|
@@ -5210,7 +5211,7 @@ function buildSessionActivityReport(args) {
|
|
|
5210
5211
|
spawnedAtMs: args.spawnedAtMs,
|
|
5211
5212
|
recorded: args.recordedSession
|
|
5212
5213
|
});
|
|
5213
|
-
let transcript = readTranscript(args.codeName, args.transcriptDir, liveId, nowMs);
|
|
5214
|
+
let transcript = readTranscript(args.codeName, args.transcriptDir, liveId, nowMs, minCheckMs);
|
|
5214
5215
|
const seen = noteLiveSession(args.codeName, liveId);
|
|
5215
5216
|
seen.record(transcript.activity.hasTurn);
|
|
5216
5217
|
const switchedAtMs = liveId !== spawnId ? args.recordedSession?.recordedAtMs ?? null : args.spawnedAtMs ?? null;
|
|
@@ -5222,7 +5223,7 @@ function buildSessionActivityReport(args) {
|
|
|
5222
5223
|
if (candidates.length > 0 && switchedAtMs !== null && !hasTurnActivity(transcript.activity)) {
|
|
5223
5224
|
let previous = null;
|
|
5224
5225
|
for (const [i, id] of candidates.entries()) {
|
|
5225
|
-
const read = readTranscript(`${args.codeName}\0previous${i}`, args.transcriptDir, id, nowMs);
|
|
5226
|
+
const read = readTranscript(`${args.codeName}\0previous${i}`, args.transcriptDir, id, nowMs, minCheckMs);
|
|
5226
5227
|
if (!read.activity.hasTurn || read.mtimeMs === null) continue;
|
|
5227
5228
|
if (previous === null || (previous.mtimeMs ?? 0) < read.mtimeMs) previous = read;
|
|
5228
5229
|
}
|
|
@@ -5246,7 +5247,8 @@ function buildSessionActivityReport(args) {
|
|
|
5246
5247
|
processStartMs,
|
|
5247
5248
|
liveId === spawnId,
|
|
5248
5249
|
nowMs,
|
|
5249
|
-
args.log
|
|
5250
|
+
args.log,
|
|
5251
|
+
minCheckMs
|
|
5250
5252
|
);
|
|
5251
5253
|
return {
|
|
5252
5254
|
state: state10,
|
|
@@ -5264,6 +5266,75 @@ function buildSessionActivityReport(args) {
|
|
|
5264
5266
|
}
|
|
5265
5267
|
}
|
|
5266
5268
|
|
|
5269
|
+
// src/lib/manager-restart-gate.ts
|
|
5270
|
+
import { execFileSync } from "child_process";
|
|
5271
|
+
var MANAGER_RESTART_REASON = "manager-restart";
|
|
5272
|
+
function decideManagerRestart(report) {
|
|
5273
|
+
if (!report) return { kill: false, reason: "unknown_activity", runningBackgroundTasks: null };
|
|
5274
|
+
if (report.state === "no_session") return { kill: true };
|
|
5275
|
+
const running2 = typeof report.runningBackgroundTasks === "number" ? report.runningBackgroundTasks : null;
|
|
5276
|
+
if (report.state === "mid_turn") return { kill: false, reason: "mid_turn", runningBackgroundTasks: running2 };
|
|
5277
|
+
if (report.state === "idle_at_prompt") {
|
|
5278
|
+
if (running2 === 0) return { kill: true };
|
|
5279
|
+
return { kill: false, reason: running2 && running2 > 0 ? "background_tasks" : "unknown_activity", runningBackgroundTasks: running2 };
|
|
5280
|
+
}
|
|
5281
|
+
return { kill: false, reason: "unknown_activity", runningBackgroundTasks: running2 };
|
|
5282
|
+
}
|
|
5283
|
+
function laneDefersForFramework(cached, refreshed) {
|
|
5284
|
+
return cached !== void 0 && cached !== refreshed;
|
|
5285
|
+
}
|
|
5286
|
+
function confirmsNoSession(err) {
|
|
5287
|
+
const e = err;
|
|
5288
|
+
if (!e || e.status !== 1 || e.signal) return false;
|
|
5289
|
+
const stderr = typeof e.stderr === "string" ? e.stderr : Buffer.isBuffer(e.stderr) ? e.stderr.toString("utf8") : "";
|
|
5290
|
+
return /can't find session|no server running|error connecting to .*\(No such file or directory\)/i.test(stderr);
|
|
5291
|
+
}
|
|
5292
|
+
function killAbortsRestart(killed, restartReason) {
|
|
5293
|
+
if (killed === "timed-out") return true;
|
|
5294
|
+
return killed === "failed" && restartReason === MANAGER_RESTART_REASON;
|
|
5295
|
+
}
|
|
5296
|
+
var TMUX_PROBE_TIMEOUT_MS = 3e3;
|
|
5297
|
+
function captureAgentPane(codeName) {
|
|
5298
|
+
const tmuxSession = `=agt-${codeName}`;
|
|
5299
|
+
let tmuxAlive;
|
|
5300
|
+
let screenCapture = null;
|
|
5301
|
+
try {
|
|
5302
|
+
execFileSync("tmux", ["has-session", "-t", tmuxSession], {
|
|
5303
|
+
stdio: ["ignore", "ignore", "pipe"],
|
|
5304
|
+
encoding: "utf-8",
|
|
5305
|
+
timeout: TMUX_PROBE_TIMEOUT_MS
|
|
5306
|
+
});
|
|
5307
|
+
tmuxAlive = true;
|
|
5308
|
+
} catch (err) {
|
|
5309
|
+
tmuxAlive = confirmsNoSession(err) ? false : null;
|
|
5310
|
+
}
|
|
5311
|
+
if (tmuxAlive) {
|
|
5312
|
+
try {
|
|
5313
|
+
screenCapture = execFileSync("tmux", ["capture-pane", "-t", `${tmuxSession}:`, "-p", "-S", "-30"], {
|
|
5314
|
+
encoding: "utf-8",
|
|
5315
|
+
timeout: TMUX_PROBE_TIMEOUT_MS
|
|
5316
|
+
}).trim();
|
|
5317
|
+
} catch {
|
|
5318
|
+
}
|
|
5319
|
+
}
|
|
5320
|
+
return { tmuxAlive, screenCapture };
|
|
5321
|
+
}
|
|
5322
|
+
var TMUX_KILL_TIMEOUT_MS = 1e4;
|
|
5323
|
+
function killAgentPane(codeName, exec = execFileSync) {
|
|
5324
|
+
try {
|
|
5325
|
+
exec("tmux", ["kill-session", "-t", `=agt-${codeName}`], {
|
|
5326
|
+
stdio: ["ignore", "ignore", "pipe"],
|
|
5327
|
+
encoding: "utf-8",
|
|
5328
|
+
timeout: TMUX_KILL_TIMEOUT_MS,
|
|
5329
|
+
killSignal: "SIGKILL"
|
|
5330
|
+
});
|
|
5331
|
+
return "done";
|
|
5332
|
+
} catch (err) {
|
|
5333
|
+
if (err?.code === "ETIMEDOUT") return "timed-out";
|
|
5334
|
+
return confirmsNoSession(err) ? "done" : "failed";
|
|
5335
|
+
}
|
|
5336
|
+
}
|
|
5337
|
+
|
|
5267
5338
|
// src/lib/workflow-run-reconciler.ts
|
|
5268
5339
|
import { readdirSync as readdirSync4, readFileSync as readFileSync13, statSync as statSync4 } from "fs";
|
|
5269
5340
|
import { join as join19 } from "path";
|
|
@@ -8601,7 +8672,7 @@ var DeviceStateRotationGate = class {
|
|
|
8601
8672
|
};
|
|
8602
8673
|
|
|
8603
8674
|
// src/lib/channel-sweep.ts
|
|
8604
|
-
import { execFileSync } from "child_process";
|
|
8675
|
+
import { execFileSync as execFileSync2 } from "child_process";
|
|
8605
8676
|
var CHANNEL_BASENAMES = [
|
|
8606
8677
|
"slack-channel",
|
|
8607
8678
|
"direct-chat-channel",
|
|
@@ -8764,7 +8835,7 @@ function resolveLiveAnchorPids(agentCodeNames) {
|
|
|
8764
8835
|
for (const codeName of agentCodeNames) {
|
|
8765
8836
|
const pids = /* @__PURE__ */ new Set();
|
|
8766
8837
|
try {
|
|
8767
|
-
const out =
|
|
8838
|
+
const out = execFileSync2("tmux", ["list-panes", "-t", `agt-${codeName}`, "-F", "#{pane_pid}"], {
|
|
8768
8839
|
encoding: "utf-8",
|
|
8769
8840
|
timeout: 2e3,
|
|
8770
8841
|
stdio: ["ignore", "pipe", "ignore"]
|
|
@@ -8784,7 +8855,7 @@ async function sweepChannelProcesses(opts) {
|
|
|
8784
8855
|
const kill = opts.killFn ?? defaultKill;
|
|
8785
8856
|
let psOutput = "";
|
|
8786
8857
|
try {
|
|
8787
|
-
psOutput =
|
|
8858
|
+
psOutput = execFileSync2("ps", ["eww", "-o", "pid=,ppid=,etime=,command="], {
|
|
8788
8859
|
encoding: "utf-8",
|
|
8789
8860
|
timeout: 5e3,
|
|
8790
8861
|
maxBuffer: 10 * 1024 * 1024
|
|
@@ -8821,7 +8892,7 @@ function defaultKillSignal(pid, signal) {
|
|
|
8821
8892
|
}
|
|
8822
8893
|
}
|
|
8823
8894
|
function defaultPs() {
|
|
8824
|
-
return
|
|
8895
|
+
return execFileSync2("ps", ["eww", "-o", "pid=,ppid=,etime=,command="], {
|
|
8825
8896
|
encoding: "utf-8",
|
|
8826
8897
|
timeout: 5e3,
|
|
8827
8898
|
maxBuffer: 10 * 1024 * 1024
|
|
@@ -11920,7 +11991,7 @@ function stopPidPressureSampler() {
|
|
|
11920
11991
|
}
|
|
11921
11992
|
|
|
11922
11993
|
// src/lib/runtime-version-sampler.ts
|
|
11923
|
-
import { execFileSync as
|
|
11994
|
+
import { execFileSync as execFileSync3 } from "child_process";
|
|
11924
11995
|
import { execFile as execFileCb } from "child_process";
|
|
11925
11996
|
import { promisify as promisify2 } from "util";
|
|
11926
11997
|
var execFileAsync2 = promisify2(execFileCb);
|
|
@@ -11929,7 +12000,7 @@ var lastSample2 = /* @__PURE__ */ new Map();
|
|
|
11929
12000
|
var failureCount = /* @__PURE__ */ new Map();
|
|
11930
12001
|
async function readVersionReal(codeName) {
|
|
11931
12002
|
const timeoutMs = 1e4;
|
|
11932
|
-
timeoutBinaryAvailable ??= hasTimeoutBinary(
|
|
12003
|
+
timeoutBinaryAvailable ??= hasTimeoutBinary(execFileSync3);
|
|
11933
12004
|
const { execFile: file, execArgs } = boundedArgv(
|
|
11934
12005
|
"docker",
|
|
11935
12006
|
["exec", `agt-${codeName}`, "claude", "--version"],
|
|
@@ -14943,16 +15014,27 @@ function applyRestartAcks(args) {
|
|
|
14943
15014
|
for (const ack of agentStates) {
|
|
14944
15015
|
const freshAck = restartAcks.get(ack.agentId);
|
|
14945
15016
|
const carryForward = priorAcks.get(ack.agentId);
|
|
14946
|
-
|
|
15017
|
+
const freshLosesToPrior = freshAck != null && carryForward != null && Date.parse(carryForward) > Date.parse(freshAck);
|
|
15018
|
+
if (freshAck && !freshLosesToPrior) {
|
|
14947
15019
|
if (ack.lastRestartProcessedAt !== freshAck) changed = true;
|
|
14948
15020
|
ack.lastRestartProcessedAt = freshAck;
|
|
14949
15021
|
} else if (carryForward) {
|
|
14950
|
-
|
|
15022
|
+
const have = ack.lastRestartProcessedAt;
|
|
15023
|
+
if (have && Date.parse(have) >= Date.parse(carryForward)) continue;
|
|
15024
|
+
changed = true;
|
|
14951
15025
|
ack.lastRestartProcessedAt = carryForward;
|
|
14952
15026
|
}
|
|
14953
15027
|
}
|
|
14954
15028
|
return changed;
|
|
14955
15029
|
}
|
|
15030
|
+
function stampRestartServiced(agents, agentId, prev, requestedAt) {
|
|
15031
|
+
for (const row of [agents.find((a) => a.agentId === agentId), prev]) {
|
|
15032
|
+
if (!row) continue;
|
|
15033
|
+
const have = row.lastRestartProcessedAt;
|
|
15034
|
+
if (have && Date.parse(have) > Date.parse(requestedAt)) continue;
|
|
15035
|
+
row.lastRestartProcessedAt = requestedAt;
|
|
15036
|
+
}
|
|
15037
|
+
}
|
|
14956
15038
|
var CHANNEL_SWEEP_INTERVAL_MS = (() => {
|
|
14957
15039
|
const raw = parseInt(process.env["AGT_CHANNEL_SWEEP_INTERVAL_MS"] ?? "", 10);
|
|
14958
15040
|
if (!Number.isFinite(raw)) return 5 * 60 * 1e3;
|
|
@@ -15871,7 +15953,7 @@ var pendingDayRolloverReset = /* @__PURE__ */ new Set();
|
|
|
15871
15953
|
var dayRolloverInboundHold = /* @__PURE__ */ new Map();
|
|
15872
15954
|
var INBOUND_HOLD_EPISODE_GAP_MS = 12e4;
|
|
15873
15955
|
async function channelInboundActivityAgeSecondsFor(codeName) {
|
|
15874
|
-
const { newestPendingInboundActivityMtimeMs } = await import("../responsiveness-probe-
|
|
15956
|
+
const { newestPendingInboundActivityMtimeMs } = await import("../responsiveness-probe-MU5WMZSZ.js");
|
|
15875
15957
|
const newest = newestPendingInboundActivityMtimeMs(dirname11(paneLogPath(codeName)));
|
|
15876
15958
|
if (newest === null) return null;
|
|
15877
15959
|
return Math.max(0, Math.floor((Date.now() - newest) / 1e3));
|
|
@@ -16686,10 +16768,10 @@ var agentRestartTimezoneInputs = /* @__PURE__ */ new Map();
|
|
|
16686
16768
|
var lastVersionCheckAt = 0;
|
|
16687
16769
|
var VERSION_CHECK_INTERVAL_MS = 5 * 60 * 1e3;
|
|
16688
16770
|
var lastResponsivenessProbeAt = 0;
|
|
16689
|
-
var agtCliVersion = true ? "0.28.
|
|
16690
|
-
function resolveBrewPath(
|
|
16771
|
+
var agtCliVersion = true ? "0.28.1248" : "dev";
|
|
16772
|
+
function resolveBrewPath(execFileSync4) {
|
|
16691
16773
|
try {
|
|
16692
|
-
const out =
|
|
16774
|
+
const out = execFileSync4("which", ["brew"], { timeout: 5e3 }).toString().trim();
|
|
16693
16775
|
if (out) return out;
|
|
16694
16776
|
} catch {
|
|
16695
16777
|
}
|
|
@@ -16703,7 +16785,7 @@ function resolveBrewPath(execFileSync3) {
|
|
|
16703
16785
|
}
|
|
16704
16786
|
return null;
|
|
16705
16787
|
}
|
|
16706
|
-
function claudeBinaryInstalled(
|
|
16788
|
+
function claudeBinaryInstalled(execFileSync4) {
|
|
16707
16789
|
const canonical = [
|
|
16708
16790
|
"/home/linuxbrew/.linuxbrew/bin/claude",
|
|
16709
16791
|
"/opt/homebrew/bin/claude",
|
|
@@ -16711,7 +16793,7 @@ function claudeBinaryInstalled(execFileSync3) {
|
|
|
16711
16793
|
];
|
|
16712
16794
|
if (canonical.some((path) => existsSync19(path))) return true;
|
|
16713
16795
|
try {
|
|
16714
|
-
|
|
16796
|
+
execFileSync4("which", ["claude"], { timeout: 5e3 });
|
|
16715
16797
|
return true;
|
|
16716
16798
|
} catch {
|
|
16717
16799
|
return false;
|
|
@@ -16751,12 +16833,12 @@ async function ensureToolkitCliInner(toolkitSlug) {
|
|
|
16751
16833
|
}
|
|
16752
16834
|
const { binary, installer, package: pkg, script } = integration.cli_tool;
|
|
16753
16835
|
const resolvedInstaller = installer ?? "manual";
|
|
16754
|
-
const { execFileSync:
|
|
16836
|
+
const { execFileSync: execFileSync4, execFile: execFile2, exec } = await import("child_process");
|
|
16755
16837
|
const { promisify: promisify3 } = await import("util");
|
|
16756
16838
|
const execFileAsync3 = promisify3(execFile2);
|
|
16757
16839
|
const execAsync = promisify3(exec);
|
|
16758
16840
|
try {
|
|
16759
|
-
|
|
16841
|
+
execFileSync4("which", [binary], { timeout: 5e3, stdio: "pipe" });
|
|
16760
16842
|
toolkitCliEnsured.add(toolkitSlug);
|
|
16761
16843
|
toolkitCliRetryAfter.delete(toolkitSlug);
|
|
16762
16844
|
toolkitCliFailureCount.delete(toolkitSlug);
|
|
@@ -16787,7 +16869,7 @@ async function ensureToolkitCliInner(toolkitSlug) {
|
|
|
16787
16869
|
toolkitCliEnsured.add(toolkitSlug);
|
|
16788
16870
|
return;
|
|
16789
16871
|
}
|
|
16790
|
-
const brewPath = resolveBrewPath(
|
|
16872
|
+
const brewPath = resolveBrewPath(execFileSync4);
|
|
16791
16873
|
if (!brewPath) {
|
|
16792
16874
|
log(`[toolkit-install] ${toolkitSlug}: installer=brew but Homebrew not available \u2014 install manually: brew install ${pkg}`);
|
|
16793
16875
|
toolkitCliEnsured.add(toolkitSlug);
|
|
@@ -16821,7 +16903,7 @@ async function ensureToolkitCliInner(toolkitSlug) {
|
|
|
16821
16903
|
process.env.PATH = `${brewBinDir}:${process.env.PATH ?? ""}`;
|
|
16822
16904
|
}
|
|
16823
16905
|
try {
|
|
16824
|
-
|
|
16906
|
+
execFileSync4("which", [binary], { timeout: 5e3, stdio: "pipe" });
|
|
16825
16907
|
log(`[toolkit-install] ${toolkitSlug}: installed \u2014 ${binary} now on PATH`);
|
|
16826
16908
|
toolkitCliEnsured.add(toolkitSlug);
|
|
16827
16909
|
toolkitCliRetryAfter.delete(toolkitSlug);
|
|
@@ -17038,9 +17120,9 @@ async function ensureHostNodeVersion(rawPin) {
|
|
|
17038
17120
|
hostNodeConvergence.recordSuccess(pin);
|
|
17039
17121
|
return;
|
|
17040
17122
|
}
|
|
17041
|
-
const { execFileSync:
|
|
17123
|
+
const { execFileSync: execFileSync4 } = await import("child_process");
|
|
17042
17124
|
try {
|
|
17043
|
-
|
|
17125
|
+
execFileSync4("which", ["dnf"], { timeout: 5e3, stdio: "pipe" });
|
|
17044
17126
|
} catch {
|
|
17045
17127
|
if (!hostNodeNoDnfLogged) {
|
|
17046
17128
|
hostNodeNoDnfLogged = true;
|
|
@@ -17090,16 +17172,16 @@ async function ensureIsolationImage(imageUri) {
|
|
|
17090
17172
|
}
|
|
17091
17173
|
isolationImageInFlight.add(imageUri);
|
|
17092
17174
|
try {
|
|
17093
|
-
const { execFileSync:
|
|
17175
|
+
const { execFileSync: execFileSync4 } = await import("child_process");
|
|
17094
17176
|
try {
|
|
17095
|
-
|
|
17177
|
+
execFileSync4("which", ["docker"], { timeout: 5e3, stdio: "pipe" });
|
|
17096
17178
|
} catch {
|
|
17097
17179
|
recordIsolationImageFailure(imageUri, `'docker' not found on host - required to pull the isolation image (install it, then the manager retries)`);
|
|
17098
17180
|
return;
|
|
17099
17181
|
}
|
|
17100
17182
|
const hasAws = (() => {
|
|
17101
17183
|
try {
|
|
17102
|
-
|
|
17184
|
+
execFileSync4("which", ["aws"], { timeout: 5e3, stdio: "pipe" });
|
|
17103
17185
|
return true;
|
|
17104
17186
|
} catch {
|
|
17105
17187
|
return false;
|
|
@@ -17108,11 +17190,11 @@ async function ensureIsolationImage(imageUri) {
|
|
|
17108
17190
|
if (isPublic) {
|
|
17109
17191
|
if (hasAws) {
|
|
17110
17192
|
try {
|
|
17111
|
-
const password =
|
|
17193
|
+
const password = execFileSync4("aws", ["ecr-public", "get-login-password", "--region", "us-east-1"], {
|
|
17112
17194
|
timeout: 3e4,
|
|
17113
17195
|
stdio: ["ignore", "pipe", "pipe"]
|
|
17114
17196
|
}).toString().trim();
|
|
17115
|
-
|
|
17197
|
+
execFileSync4("docker", ["login", "--username", "AWS", "--password-stdin", "public.ecr.aws"], {
|
|
17116
17198
|
input: password,
|
|
17117
17199
|
timeout: 3e4,
|
|
17118
17200
|
stdio: ["pipe", "pipe", "pipe"]
|
|
@@ -17127,11 +17209,11 @@ async function ensureIsolationImage(imageUri) {
|
|
|
17127
17209
|
return;
|
|
17128
17210
|
}
|
|
17129
17211
|
try {
|
|
17130
|
-
const password =
|
|
17212
|
+
const password = execFileSync4("aws", ["ecr", "get-login-password", "--region", privRegion], {
|
|
17131
17213
|
timeout: 3e4,
|
|
17132
17214
|
stdio: ["ignore", "pipe", "pipe"]
|
|
17133
17215
|
}).toString().trim();
|
|
17134
|
-
|
|
17216
|
+
execFileSync4("docker", ["login", "--username", "AWS", "--password-stdin", registry], {
|
|
17135
17217
|
input: password,
|
|
17136
17218
|
timeout: 3e4,
|
|
17137
17219
|
stdio: ["pipe", "pipe", "pipe"]
|
|
@@ -17372,11 +17454,11 @@ function ensureClaudeManagedSettings(path = claudeManagedSettingsPath(), write =
|
|
|
17372
17454
|
}
|
|
17373
17455
|
var OPENCODE_NPM_VERSION = "1.18.3";
|
|
17374
17456
|
async function ensureOpencodeBinary() {
|
|
17375
|
-
const { execFileSync:
|
|
17457
|
+
const { execFileSync: execFileSync4 } = await import("child_process");
|
|
17376
17458
|
const bin = process.env["AGT_OPENCODE_BIN"]?.trim() || "opencode";
|
|
17377
17459
|
const probe = () => {
|
|
17378
17460
|
try {
|
|
17379
|
-
|
|
17461
|
+
execFileSync4(bin, ["--version"], { stdio: "ignore", timeout: 1e4 });
|
|
17380
17462
|
return true;
|
|
17381
17463
|
} catch {
|
|
17382
17464
|
return false;
|
|
@@ -17400,7 +17482,7 @@ async function ensureOpencodeBinary() {
|
|
|
17400
17482
|
return false;
|
|
17401
17483
|
}
|
|
17402
17484
|
try {
|
|
17403
|
-
const prefix =
|
|
17485
|
+
const prefix = execFileSync4("npm", ["prefix", "-g"], { encoding: "utf-8", timeout: 1e4 }).trim();
|
|
17404
17486
|
if (prefix) {
|
|
17405
17487
|
const npmBin = join44(prefix, "bin");
|
|
17406
17488
|
const current = (process.env.PATH ?? "").split(pathDelimiter);
|
|
@@ -17432,8 +17514,8 @@ async function ensureFrameworkBinary(frameworkId) {
|
|
|
17432
17514
|
}
|
|
17433
17515
|
frameworkBinaryChecked.add(frameworkId);
|
|
17434
17516
|
lastManagedSettingsStatus = ensureClaudeManagedSettings();
|
|
17435
|
-
const { execFileSync:
|
|
17436
|
-
const brewPath = resolveBrewPath(
|
|
17517
|
+
const { execFileSync: execFileSync4 } = await import("child_process");
|
|
17518
|
+
const brewPath = resolveBrewPath(execFileSync4);
|
|
17437
17519
|
if (!brewPath) {
|
|
17438
17520
|
log("Homebrew not found (no `brew` on PATH, no /home/linuxbrew/.linuxbrew/bin/brew). Cannot auto-install Claude Code. Install manually: https://claude.ai/download");
|
|
17439
17521
|
return;
|
|
@@ -17446,7 +17528,7 @@ async function ensureFrameworkBinary(frameworkId) {
|
|
|
17446
17528
|
}
|
|
17447
17529
|
return runAsync(brewPath, args, opts);
|
|
17448
17530
|
};
|
|
17449
|
-
const claudeExists = claudeBinaryInstalled(
|
|
17531
|
+
const claudeExists = claudeBinaryInstalled(execFileSync4);
|
|
17450
17532
|
if (!claudeExists) {
|
|
17451
17533
|
log(`Claude Code binary not found \u2014 installing via Homebrew${isRoot ? " (as ec2-user via sudo)" : ""}...`);
|
|
17452
17534
|
try {
|
|
@@ -17481,13 +17563,13 @@ async function maybeUpgradeClaudeCode() {
|
|
|
17481
17563
|
}
|
|
17482
17564
|
claudeCodeUpgradeInFlight = true;
|
|
17483
17565
|
stampClaudeCodeUpgradeMarker();
|
|
17484
|
-
const { execFileSync:
|
|
17485
|
-
const brewPath = resolveBrewPath(
|
|
17566
|
+
const { execFileSync: execFileSync4 } = await import("child_process");
|
|
17567
|
+
const brewPath = resolveBrewPath(execFileSync4);
|
|
17486
17568
|
if (!brewPath) {
|
|
17487
17569
|
claudeCodeUpgradeInFlight = false;
|
|
17488
17570
|
return;
|
|
17489
17571
|
}
|
|
17490
|
-
if (!claudeBinaryInstalled(
|
|
17572
|
+
if (!claudeBinaryInstalled(execFileSync4)) {
|
|
17491
17573
|
claudeCodeUpgradeInFlight = false;
|
|
17492
17574
|
return;
|
|
17493
17575
|
}
|
|
@@ -17617,8 +17699,8 @@ async function checkAndUpdateCli(opts) {
|
|
|
17617
17699
|
}
|
|
17618
17700
|
}
|
|
17619
17701
|
async function checkAndUpdateCliViaBrew(force = false) {
|
|
17620
|
-
const { execFileSync:
|
|
17621
|
-
const brewPath = resolveBrewPath(
|
|
17702
|
+
const { execFileSync: execFileSync4 } = await import("child_process");
|
|
17703
|
+
const brewPath = resolveBrewPath(execFileSync4);
|
|
17622
17704
|
if (!brewPath) return "noop";
|
|
17623
17705
|
{
|
|
17624
17706
|
const brewPinRaw = resolveAgtCliPinRaw();
|
|
@@ -17645,13 +17727,13 @@ async function checkAndUpdateCliViaBrew(force = false) {
|
|
|
17645
17727
|
}
|
|
17646
17728
|
let metadataFresh = true;
|
|
17647
17729
|
try {
|
|
17648
|
-
|
|
17730
|
+
execFileSync4(brewPath, ["update", "--quiet"], { timeout: SELF_UPDATE_TIMEOUTS.brewUpdateMs, stdio: "pipe" });
|
|
17649
17731
|
} catch (err) {
|
|
17650
17732
|
metadataFresh = false;
|
|
17651
17733
|
log(`[self-update] brew update failed (continuing with stale cache): ${err.message}`);
|
|
17652
17734
|
}
|
|
17653
17735
|
try {
|
|
17654
|
-
const outdated =
|
|
17736
|
+
const outdated = execFileSync4(brewPath, ["outdated", "--json=v2"], {
|
|
17655
17737
|
timeout: SELF_UPDATE_TIMEOUTS.brewOutdatedMs,
|
|
17656
17738
|
encoding: "utf-8"
|
|
17657
17739
|
});
|
|
@@ -17692,7 +17774,7 @@ async function checkAndUpdateCliViaBrew(force = false) {
|
|
|
17692
17774
|
}
|
|
17693
17775
|
try {
|
|
17694
17776
|
try {
|
|
17695
|
-
|
|
17777
|
+
execFileSync4(brewPath, ["upgrade", "integrity-labs/tap/agt"], {
|
|
17696
17778
|
timeout: SELF_UPDATE_TIMEOUTS.brewUpgradeMs,
|
|
17697
17779
|
stdio: "pipe"
|
|
17698
17780
|
});
|
|
@@ -17872,7 +17954,7 @@ async function fetchUrgentDistTagVersion() {
|
|
|
17872
17954
|
}
|
|
17873
17955
|
}
|
|
17874
17956
|
async function installAgtCliViaNpm(version, reasonLabel, force = false) {
|
|
17875
|
-
const { execFileSync:
|
|
17957
|
+
const { execFileSync: execFileSync4 } = await import("child_process");
|
|
17876
17958
|
const isRoot = typeof process.getuid === "function" && process.getuid() === 0;
|
|
17877
17959
|
const cmd = isRoot ? "npm" : "sudo";
|
|
17878
17960
|
const installArgs = [
|
|
@@ -17890,7 +17972,7 @@ async function installAgtCliViaNpm(version, reasonLabel, force = false) {
|
|
|
17890
17972
|
return npmInstallHold;
|
|
17891
17973
|
}
|
|
17892
17974
|
try {
|
|
17893
|
-
|
|
17975
|
+
execFileSync4(cmd, args, { timeout: SELF_UPDATE_TIMEOUTS.npmInstallMs, stdio: "pipe" });
|
|
17894
17976
|
} catch (err) {
|
|
17895
17977
|
log(`[self-update] npm upgrade failed: ${err.message}`);
|
|
17896
17978
|
return "failed";
|
|
@@ -17899,7 +17981,7 @@ async function installAgtCliViaNpm(version, reasonLabel, force = false) {
|
|
|
17899
17981
|
}
|
|
17900
17982
|
let smokeOk = false;
|
|
17901
17983
|
try {
|
|
17902
|
-
const out =
|
|
17984
|
+
const out = execFileSync4("agt", ["--version"], { timeout: SELF_UPDATE_TIMEOUTS.smokeCheckMs, stdio: "pipe" }).toString();
|
|
17903
17985
|
smokeOk = isAgtVersionSmokeOk(out, version);
|
|
17904
17986
|
if (!smokeOk) {
|
|
17905
17987
|
log(
|
|
@@ -17964,8 +18046,8 @@ function effectiveRuntimeAuthenticated() {
|
|
|
17964
18046
|
async function maybeProbeClaudeRuntimeAuth() {
|
|
17965
18047
|
if (runtimeAuthProbeInFlight) return;
|
|
17966
18048
|
if (Date.now() - lastRuntimeAuthProbeAt < RUNTIME_AUTH_PROBE_INTERVAL_MS) return;
|
|
17967
|
-
const { execFileSync:
|
|
17968
|
-
if (!claudeBinaryInstalled(
|
|
18049
|
+
const { execFileSync: execFileSync4 } = await import("child_process");
|
|
18050
|
+
if (!claudeBinaryInstalled(execFileSync4)) return;
|
|
17969
18051
|
runtimeAuthProbeInFlight = true;
|
|
17970
18052
|
lastRuntimeAuthProbeAt = Date.now();
|
|
17971
18053
|
try {
|
|
@@ -18064,8 +18146,8 @@ async function runHostUsageCommand() {
|
|
|
18064
18146
|
}
|
|
18065
18147
|
}
|
|
18066
18148
|
async function maybePollHostUsageFromCycle() {
|
|
18067
|
-
const { execFileSync:
|
|
18068
|
-
if (!claudeBinaryInstalled(
|
|
18149
|
+
const { execFileSync: execFileSync4 } = await import("child_process");
|
|
18150
|
+
if (!claudeBinaryInstalled(execFileSync4)) return;
|
|
18069
18151
|
await maybePollHostUsage({
|
|
18070
18152
|
api,
|
|
18071
18153
|
runUsageCommand: runHostUsageCommand,
|
|
@@ -18442,7 +18524,7 @@ function claudeMdSizeFor(codeName) {
|
|
|
18442
18524
|
logClaudeMdGraftTransition(codeName, report, log);
|
|
18443
18525
|
return report;
|
|
18444
18526
|
}
|
|
18445
|
-
function sessionActivityFor(codeName, pane) {
|
|
18527
|
+
function sessionActivityFor(codeName, pane, opts = {}) {
|
|
18446
18528
|
const session = getSessionState(codeName);
|
|
18447
18529
|
const projectDir = getProjectDir(codeName);
|
|
18448
18530
|
return buildSessionActivityReport({
|
|
@@ -18456,7 +18538,8 @@ function sessionActivityFor(codeName, pane) {
|
|
|
18456
18538
|
previousSessionId: peekPreviousSession(codeName)?.sessionId ?? null,
|
|
18457
18539
|
tmuxAlive: pane.tmuxAlive,
|
|
18458
18540
|
screenCapture: pane.screenCapture,
|
|
18459
|
-
log: (msg) => console.error(msg)
|
|
18541
|
+
log: (msg) => console.error(msg),
|
|
18542
|
+
fresh: opts.fresh === true
|
|
18460
18543
|
});
|
|
18461
18544
|
}
|
|
18462
18545
|
function forwardedToolsFor(codeName) {
|
|
@@ -18683,7 +18766,7 @@ function flushRestartedAgentDiagnostics(hostId, codeNames) {
|
|
|
18683
18766
|
if (codeNames.length === 0) return;
|
|
18684
18767
|
void (async () => {
|
|
18685
18768
|
try {
|
|
18686
|
-
const { collectDiagnostics } = await import("../persistent-session-
|
|
18769
|
+
const { collectDiagnostics } = await import("../persistent-session-R2RY5NJ3.js");
|
|
18687
18770
|
await api.post("/host/heartbeat", {
|
|
18688
18771
|
host_id: hostId,
|
|
18689
18772
|
agent_diagnostics: collectDiagnostics(codeNames, quarantineEntriesFor, claudeMdSizeFor, spawnOutcomeForDiagnostics, pidPressureFor, forwardedToolsFor, runtimeVersionFor, sessionActivityFor)
|
|
@@ -18826,7 +18909,7 @@ async function pollCycleInner() {
|
|
|
18826
18909
|
}
|
|
18827
18910
|
try {
|
|
18828
18911
|
const { detectHostSecurity } = await import("../host-security-KQYYZZVW.js");
|
|
18829
|
-
const { collectDiagnostics } = await import("../persistent-session-
|
|
18912
|
+
const { collectDiagnostics } = await import("../persistent-session-R2RY5NJ3.js");
|
|
18830
18913
|
const diagCodeNames = [...agentState.persistentSessionAgents];
|
|
18831
18914
|
const agentDiagnostics = diagCodeNames.length > 0 ? collectDiagnostics(diagCodeNames, quarantineEntriesFor, claudeMdSizeFor, spawnOutcomeForDiagnostics, pidPressureFor, forwardedToolsFor, runtimeVersionFor, sessionActivityFor) : void 0;
|
|
18832
18915
|
let tailscaleHostname;
|
|
@@ -19091,7 +19174,7 @@ async function pollCycleInner() {
|
|
|
19091
19174
|
}
|
|
19092
19175
|
try {
|
|
19093
19176
|
const desiredClaudeCodeVersion = hbResp?.desired_claude_code_version?.trim();
|
|
19094
|
-
const { maybeUpdateClaudeCode, shouldRunClaudeCodeUpdater } = await import("../claude-code-updater-
|
|
19177
|
+
const { maybeUpdateClaudeCode, shouldRunClaudeCodeUpdater } = await import("../claude-code-updater-G4Y3CMTI.js");
|
|
19095
19178
|
const securityFloor = currentSecurityFloor();
|
|
19096
19179
|
claudeUpdaterInFlight = true;
|
|
19097
19180
|
if (desiredClaudeCodeVersion && (claudePairLoop.busy || claudePairingInProgress())) {
|
|
@@ -19126,7 +19209,7 @@ async function pollCycleInner() {
|
|
|
19126
19209
|
collectPanelessActivityProbes,
|
|
19127
19210
|
getResponsivenessIntervalMs,
|
|
19128
19211
|
occupancyQualificationClassifications
|
|
19129
|
-
} = await import("../responsiveness-probe-
|
|
19212
|
+
} = await import("../responsiveness-probe-MU5WMZSZ.js");
|
|
19130
19213
|
const probeIntervalMs = getResponsivenessIntervalMs();
|
|
19131
19214
|
if (now - lastResponsivenessProbeAt > probeIntervalMs) {
|
|
19132
19215
|
const probeCodeNames = [...agentState.persistentSessionAgents];
|
|
@@ -19243,7 +19326,7 @@ async function pollCycleInner() {
|
|
|
19243
19326
|
collectResponsivenessProbes,
|
|
19244
19327
|
livePendingInboundOldestAgeSeconds,
|
|
19245
19328
|
parkPendingInbound
|
|
19246
|
-
} = await import("../responsiveness-probe-
|
|
19329
|
+
} = await import("../responsiveness-probe-MU5WMZSZ.js");
|
|
19247
19330
|
const { getProjectDir: wedgeProjectDir } = await import("../scheduler-engine-5PCBGRNY.js");
|
|
19248
19331
|
const wedgeNow = /* @__PURE__ */ new Date();
|
|
19249
19332
|
const liveAgents = agentState.persistentSessionAgents;
|
|
@@ -19529,7 +19612,7 @@ async function pollCycleInner() {
|
|
|
19529
19612
|
}
|
|
19530
19613
|
}
|
|
19531
19614
|
);
|
|
19532
|
-
const { parkPendingInbound } = await import("../responsiveness-probe-
|
|
19615
|
+
const { parkPendingInbound } = await import("../responsiveness-probe-MU5WMZSZ.js");
|
|
19533
19616
|
const { parked, deadLettered } = parkPendingInbound(codeName, new Date(fatalNowMs));
|
|
19534
19617
|
paneFatalStreak.delete(codeName);
|
|
19535
19618
|
paneFatalRestarts.set(codeName, [...history, fatalNowMs]);
|
|
@@ -19560,7 +19643,7 @@ async function pollCycleInner() {
|
|
|
19560
19643
|
TRANSCRIPT_MOUNT_ESCALATION_REFRESH_MS,
|
|
19561
19644
|
bindSourceEscalations
|
|
19562
19645
|
} = await import("../transcript-mount-health-OHE6IVJV.js");
|
|
19563
|
-
const { transcriptBindSourcesFor, ensureTranscriptBindSources } = await import("../persistent-session-
|
|
19646
|
+
const { transcriptBindSourcesFor, ensureTranscriptBindSources } = await import("../persistent-session-R2RY5NJ3.js");
|
|
19564
19647
|
const mountConfig = resolveTranscriptMountConfig();
|
|
19565
19648
|
const liveAgents = agentState.persistentSessionAgents;
|
|
19566
19649
|
for (const tracked of [
|
|
@@ -19725,7 +19808,7 @@ async function pollCycleInner() {
|
|
|
19725
19808
|
}
|
|
19726
19809
|
try {
|
|
19727
19810
|
const { scrapeMcpFailedBannerCount } = await import("../pane-mcp-banner-scraper-VR5QGP3J.js");
|
|
19728
|
-
const { probeSessionAuth } = await import("../session-auth-dead-
|
|
19811
|
+
const { probeSessionAuth } = await import("../session-auth-dead-B6JRV3QH.js");
|
|
19729
19812
|
const observations = [];
|
|
19730
19813
|
const pendingCacheCommits = [];
|
|
19731
19814
|
const modelApiErrorReportingOn = hostFlagStore().getBoolean("model-api-error-reporting");
|
|
@@ -19826,48 +19909,72 @@ async function pollCycleInner() {
|
|
|
19826
19909
|
}
|
|
19827
19910
|
}
|
|
19828
19911
|
const restartAcks = /* @__PURE__ */ new Map();
|
|
19912
|
+
const restartDeclines = /* @__PURE__ */ new Map();
|
|
19829
19913
|
const restartClears = [];
|
|
19830
19914
|
for (const agent of agents) {
|
|
19831
19915
|
const requested = agent.restart_requested_at ?? null;
|
|
19832
19916
|
if (!requested) continue;
|
|
19833
19917
|
if (restartInFlight.has(agent.agent_id)) continue;
|
|
19834
|
-
|
|
19835
|
-
|
|
19836
|
-
|
|
19837
|
-
|
|
19838
|
-
const
|
|
19839
|
-
|
|
19840
|
-
|
|
19841
|
-
|
|
19842
|
-
|
|
19843
|
-
|
|
19844
|
-
|
|
19845
|
-
|
|
19846
|
-
|
|
19847
|
-
|
|
19848
|
-
|
|
19849
|
-
|
|
19918
|
+
restartInFlight.add(agent.agent_id);
|
|
19919
|
+
try {
|
|
19920
|
+
const prev = state9.agents.find((a) => a.agentId === agent.agent_id);
|
|
19921
|
+
const lastProcessed = prev?.lastRestartProcessedAt ?? null;
|
|
19922
|
+
const alreadyServiced = lastProcessed != null && Date.parse(lastProcessed) >= Date.parse(requested);
|
|
19923
|
+
if (!alreadyServiced && (agent.restart_reason ?? null) === MANAGER_RESTART_REASON) {
|
|
19924
|
+
const gate = await managerRestartMayKill(
|
|
19925
|
+
agent.agent_id,
|
|
19926
|
+
agent.code_name,
|
|
19927
|
+
requested,
|
|
19928
|
+
"restart",
|
|
19929
|
+
agent.framework ?? agentFrameworkCache.get(agent.code_name) ?? DEFAULT_FRAMEWORK
|
|
19930
|
+
);
|
|
19931
|
+
if (!gate.kill) {
|
|
19932
|
+
if (gate.declined) {
|
|
19933
|
+
restartDeclines.set(agent.agent_id, requested);
|
|
19934
|
+
if (prev) prev.lastRestartProcessedAt = requested;
|
|
19935
|
+
}
|
|
19936
|
+
continue;
|
|
19850
19937
|
}
|
|
19851
|
-
|
|
19852
|
-
|
|
19853
|
-
|
|
19854
|
-
|
|
19855
|
-
|
|
19856
|
-
|
|
19857
|
-
|
|
19858
|
-
|
|
19859
|
-
);
|
|
19860
|
-
|
|
19861
|
-
const
|
|
19862
|
-
|
|
19863
|
-
|
|
19864
|
-
|
|
19865
|
-
}
|
|
19938
|
+
}
|
|
19939
|
+
if (!alreadyServiced) {
|
|
19940
|
+
const restartReason = agent.restart_reason ?? null;
|
|
19941
|
+
log(
|
|
19942
|
+
`[restart] Dashboard requested restart for '${agent.code_name}' at ${requested} (reason=${restartReason ?? "manual"})`
|
|
19943
|
+
);
|
|
19944
|
+
const framework = agent.framework ?? agentFrameworkCache.get(agent.code_name) ?? DEFAULT_FRAMEWORK;
|
|
19945
|
+
if (restartTargetsOpencodeServe(framework)) {
|
|
19946
|
+
stopOpencodeSession(agent.code_name, log);
|
|
19947
|
+
} else {
|
|
19948
|
+
const killed = killAgentPane(agent.code_name);
|
|
19949
|
+
if (killAbortsRestart(killed, restartReason)) {
|
|
19950
|
+
log(`[restart] tmux kill for '${agent.code_name}' ${killed} (timeout ${TMUX_KILL_TIMEOUT_MS}ms) - not acking, the next poll retries [ENG-11963]`);
|
|
19951
|
+
continue;
|
|
19952
|
+
}
|
|
19953
|
+
if (killed === "failed") log(`[restart] tmux kill for '${agent.code_name}' failed; a ${restartReason ?? "manual"} restart goes ahead as before [ENG-11963]`);
|
|
19954
|
+
const breakerReason = dashboardRestartBreakerReason(restartReason, agent.restart_actor);
|
|
19955
|
+
stopPersistentSessionAndForgetMcpBaseline(agent.code_name, breakerReason);
|
|
19956
|
+
if (breakerReason && restartReasonBindsNewMcp(breakerReason)) {
|
|
19957
|
+
noteRestartRequested(agent.code_name, requested);
|
|
19958
|
+
beginRestartTiming(
|
|
19959
|
+
agent.code_name,
|
|
19960
|
+
{ reason: "integration-change (dashboard restart)", delivered: null, injectDelayMs: null },
|
|
19961
|
+
log
|
|
19962
|
+
);
|
|
19963
|
+
markRestartStopped(agent.code_name, log);
|
|
19964
|
+
const prior = pendingRestartVerifications.get(agent.code_name);
|
|
19965
|
+
pendingRestartVerifications.set(agent.code_name, {
|
|
19966
|
+
firedAt: Date.now(),
|
|
19967
|
+
attempts: prior?.attempts ?? 0
|
|
19968
|
+
});
|
|
19969
|
+
}
|
|
19866
19970
|
}
|
|
19971
|
+
restartAcks.set(agent.agent_id, requested);
|
|
19972
|
+
if (prev) prev.lastRestartProcessedAt = requested;
|
|
19867
19973
|
}
|
|
19868
|
-
|
|
19974
|
+
restartClears.push({ agentId: agent.agent_id, requestedAt: requested });
|
|
19975
|
+
} finally {
|
|
19976
|
+
restartInFlight.delete(agent.agent_id);
|
|
19869
19977
|
}
|
|
19870
|
-
restartClears.push({ agentId: agent.agent_id, requestedAt: requested });
|
|
19871
19978
|
}
|
|
19872
19979
|
for (const clear of restartClears) {
|
|
19873
19980
|
void api.post("/host/restart-ack", {
|
|
@@ -20179,7 +20286,8 @@ async function pollCycleInner() {
|
|
|
20179
20286
|
const restartAckStateChanged = applyRestartAcks({
|
|
20180
20287
|
agentStates,
|
|
20181
20288
|
priorAgents: state9.agents,
|
|
20182
|
-
|
|
20289
|
+
// Declines persist as serviced, and nothing else reads them.
|
|
20290
|
+
restartAcks: new Map([...restartDeclines, ...restartAcks])
|
|
20183
20291
|
});
|
|
20184
20292
|
if (restartAckStateChanged) {
|
|
20185
20293
|
try {
|
|
@@ -20418,6 +20526,7 @@ async function pollCycleInner() {
|
|
|
20418
20526
|
}
|
|
20419
20527
|
} catch {
|
|
20420
20528
|
}
|
|
20529
|
+
applyRestartAcks({ agentStates, priorAgents: state9.agents, restartAcks: /* @__PURE__ */ new Map() });
|
|
20421
20530
|
state9 = {
|
|
20422
20531
|
...state9,
|
|
20423
20532
|
lastPollAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
@@ -24436,7 +24545,39 @@ function ensureRealtimeDriftStarted(agentStates) {
|
|
|
24436
24545
|
}
|
|
24437
24546
|
var restartInFlight = /* @__PURE__ */ new Set();
|
|
24438
24547
|
function restartReasonNeedsRender(reason) {
|
|
24439
|
-
return reason != null && reason !== "manual";
|
|
24548
|
+
return reason != null && reason !== "manual" && reason !== MANAGER_RESTART_REASON;
|
|
24549
|
+
}
|
|
24550
|
+
async function managerRestartMayKill(agentId, codeName, requestedAt, lane, framework) {
|
|
24551
|
+
let verdict;
|
|
24552
|
+
if (framework !== "claude-code") {
|
|
24553
|
+
verdict = decideManagerRestart(null);
|
|
24554
|
+
} else {
|
|
24555
|
+
const pane = captureAgentPane(codeName);
|
|
24556
|
+
verdict = decideManagerRestart(
|
|
24557
|
+
pane.tmuxAlive === null ? null : sessionActivityFor(codeName, { tmuxAlive: pane.tmuxAlive, screenCapture: pane.screenCapture }, { fresh: true })
|
|
24558
|
+
);
|
|
24559
|
+
}
|
|
24560
|
+
if (verdict.kill) {
|
|
24561
|
+
log(`[${lane}] manager restart for '${codeName}': re-check passed (idle, nothing in the background) - restarting [ENG-11963]`);
|
|
24562
|
+
return { kill: true, declined: false };
|
|
24563
|
+
}
|
|
24564
|
+
log(
|
|
24565
|
+
`[${lane}] manager restart for '${codeName}' DECLINED: ${verdict.reason}${verdict.runningBackgroundTasks ? ` (${verdict.runningBackgroundTasks} background task(s))` : ""} - not killing [ENG-11963]`
|
|
24566
|
+
);
|
|
24567
|
+
try {
|
|
24568
|
+
const hostId = await getHostId();
|
|
24569
|
+
await api.post("/host/restart-decline", {
|
|
24570
|
+
host_id: hostId,
|
|
24571
|
+
agent_id: agentId,
|
|
24572
|
+
restart_requested_at: requestedAt,
|
|
24573
|
+
reason: verdict.reason,
|
|
24574
|
+
running_background_tasks: verdict.runningBackgroundTasks
|
|
24575
|
+
});
|
|
24576
|
+
return { kill: false, declined: true };
|
|
24577
|
+
} catch (err) {
|
|
24578
|
+
log(`[${lane}] restart-decline post failed for '${codeName}': ${err.message} - will re-check next poll`);
|
|
24579
|
+
return { kill: false, declined: false };
|
|
24580
|
+
}
|
|
24440
24581
|
}
|
|
24441
24582
|
function restartReasonStampsTiming(reason) {
|
|
24442
24583
|
return reason === "integration-change";
|
|
@@ -24465,21 +24606,50 @@ async function handleRestartDoorbell(agentId, requestedAt, restartReason) {
|
|
|
24465
24606
|
triggerEarlyPoll(`config-change reload for '${codeName}' (reason=${restartReason})`, agentId);
|
|
24466
24607
|
return;
|
|
24467
24608
|
}
|
|
24468
|
-
if (!hostFlagStore().getBoolean("restart-doorbell"))
|
|
24609
|
+
if (!hostFlagStore().getBoolean("restart-doorbell")) {
|
|
24610
|
+
if (restartReason === MANAGER_RESTART_REASON) {
|
|
24611
|
+
triggerEarlyPoll(`manager restart for '${codeName}' (fast lane off)`, agentId);
|
|
24612
|
+
}
|
|
24613
|
+
return;
|
|
24614
|
+
}
|
|
24469
24615
|
if (restartInFlight.has(agentId)) return;
|
|
24470
24616
|
restartInFlight.add(agentId);
|
|
24471
24617
|
try {
|
|
24472
|
-
log(`[restart-lane] Fast restart for '${codeName}' at ${requestedAt}`);
|
|
24473
|
-
const hostId = await getHostId();
|
|
24474
24618
|
const refreshData = await fetchSpawnRefreshData(agentId, codeName, "restart-lane");
|
|
24475
24619
|
if (!refreshData) return;
|
|
24620
|
+
const framework = refreshData.agent?.framework ?? agentFrameworkCache.get(codeName) ?? DEFAULT_FRAMEWORK;
|
|
24621
|
+
const hostId = await getHostId();
|
|
24622
|
+
const parkForRestart = await import("../responsiveness-probe-MU5WMZSZ.js").then(
|
|
24623
|
+
(m) => m.parkPendingInbound,
|
|
24624
|
+
(err) => err
|
|
24625
|
+
);
|
|
24626
|
+
if (restartReason === MANAGER_RESTART_REASON) {
|
|
24627
|
+
const cached = agentFrameworkCache.get(codeName);
|
|
24628
|
+
if (laneDefersForFramework(cached, framework)) {
|
|
24629
|
+
log(`[restart-lane] manager restart for '${codeName}': framework ${cached} -> ${framework} not yet provisioned - leaving it to the poll [ENG-11963]`);
|
|
24630
|
+
return;
|
|
24631
|
+
}
|
|
24632
|
+
const gate = await managerRestartMayKill(agentId, codeName, requestedAt, "restart-lane", framework);
|
|
24633
|
+
if (!gate.kill) {
|
|
24634
|
+
if (gate.declined) {
|
|
24635
|
+
stampRestartServiced(state9.agents, agentId, prev, requestedAt);
|
|
24636
|
+
try {
|
|
24637
|
+
atomicWriteFileSync(getStateFile(), JSON.stringify(state9, null, 2));
|
|
24638
|
+
} catch (err) {
|
|
24639
|
+
log(`[restart-lane] failed to persist decline for '${codeName}': ${err.message}`);
|
|
24640
|
+
}
|
|
24641
|
+
}
|
|
24642
|
+
return;
|
|
24643
|
+
}
|
|
24644
|
+
}
|
|
24645
|
+
log(`[restart-lane] Fast restart for '${codeName}' at ${requestedAt}`);
|
|
24476
24646
|
const displayName = refreshData.agent?.display_name ?? codeName;
|
|
24477
24647
|
const wedgeStreakAtRestart = consecutiveWedgeCycles.get(codeName) ?? 0;
|
|
24478
24648
|
if (shouldForceFreshOnManualRestart(wedgeStreakAtRestart, resolveWedgeConfig())) {
|
|
24479
24649
|
try {
|
|
24480
24650
|
const freshId = rotateSessionForWedge(codeName);
|
|
24481
24651
|
consecutiveWedgeCycles.delete(codeName);
|
|
24482
|
-
|
|
24652
|
+
if (parkForRestart instanceof Error) throw parkForRestart;
|
|
24483
24653
|
const { parked, deadLettered } = parkForRestart(codeName, /* @__PURE__ */ new Date());
|
|
24484
24654
|
const parkNote = parked > 0 ? `, ${parked} inbound parked` : "";
|
|
24485
24655
|
const deadNote = deadLettered > 0 ? `, ${deadLettered} undeliverable dead-lettered` : "";
|
|
@@ -24492,15 +24662,15 @@ async function handleRestartDoorbell(agentId, requestedAt, restartReason) {
|
|
|
24492
24662
|
);
|
|
24493
24663
|
}
|
|
24494
24664
|
}
|
|
24495
|
-
const framework = refreshData.agent?.framework ?? agentFrameworkCache.get(codeName) ?? DEFAULT_FRAMEWORK;
|
|
24496
24665
|
if (restartTargetsOpencodeServe(framework)) {
|
|
24497
24666
|
stopOpencodeSession(codeName, log);
|
|
24498
24667
|
} else {
|
|
24499
|
-
|
|
24500
|
-
|
|
24501
|
-
|
|
24502
|
-
|
|
24668
|
+
const killed = killAgentPane(codeName);
|
|
24669
|
+
if (killAbortsRestart(killed, restartReason)) {
|
|
24670
|
+
log(`[restart-lane] tmux kill for '${codeName}' ${killed} (timeout ${TMUX_KILL_TIMEOUT_MS}ms) - not acking, the poll retries [ENG-11963]`);
|
|
24671
|
+
return;
|
|
24503
24672
|
}
|
|
24673
|
+
if (killed === "failed") log(`[restart-lane] tmux kill for '${codeName}' failed; a ${restartReason ?? "manual"} restart goes ahead as before [ENG-11963]`);
|
|
24504
24674
|
stopPersistentSessionAndForgetMcpBaseline(codeName);
|
|
24505
24675
|
}
|
|
24506
24676
|
const result = await ensurePersistentSession(
|
|
@@ -24522,7 +24692,7 @@ async function handleRestartDoorbell(agentId, requestedAt, restartReason) {
|
|
|
24522
24692
|
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}`));
|
|
24523
24693
|
void (async () => {
|
|
24524
24694
|
try {
|
|
24525
|
-
const { collectDiagnostics } = await import("../persistent-session-
|
|
24695
|
+
const { collectDiagnostics } = await import("../persistent-session-R2RY5NJ3.js");
|
|
24526
24696
|
await api.post("/host/heartbeat", {
|
|
24527
24697
|
host_id: hostId,
|
|
24528
24698
|
agent_diagnostics: collectDiagnostics([codeName], quarantineEntriesFor, claudeMdSizeFor, spawnOutcomeForDiagnostics, pidPressureFor, forwardedToolsFor, runtimeVersionFor, sessionActivityFor)
|
|
@@ -24531,7 +24701,7 @@ async function handleRestartDoorbell(agentId, requestedAt, restartReason) {
|
|
|
24531
24701
|
log(`[restart-lane] post-respawn diagnostics flush failed for '${codeName}': ${err.message}`);
|
|
24532
24702
|
}
|
|
24533
24703
|
})();
|
|
24534
|
-
|
|
24704
|
+
stampRestartServiced(state9.agents, agentId, prev, requestedAt);
|
|
24535
24705
|
try {
|
|
24536
24706
|
atomicWriteFileSync(getStateFile(), JSON.stringify(state9, null, 2));
|
|
24537
24707
|
} catch (err) {
|
|
@@ -24573,7 +24743,7 @@ async function respawnAgentAfterMcpStop(codeName, reason) {
|
|
|
24573
24743
|
}
|
|
24574
24744
|
try {
|
|
24575
24745
|
const hostId = await getHostId();
|
|
24576
|
-
const { collectDiagnostics } = await import("../persistent-session-
|
|
24746
|
+
const { collectDiagnostics } = await import("../persistent-session-R2RY5NJ3.js");
|
|
24577
24747
|
await api.post("/host/heartbeat", {
|
|
24578
24748
|
host_id: hostId,
|
|
24579
24749
|
agent_diagnostics: collectDiagnostics([codeName], quarantineEntriesFor, claudeMdSizeFor, spawnOutcomeForDiagnostics, pidPressureFor, forwardedToolsFor, runtimeVersionFor, sessionActivityFor)
|
|
@@ -25275,7 +25445,7 @@ async function processClaudePairSessions(agents) {
|
|
|
25275
25445
|
snapshotPairConfig,
|
|
25276
25446
|
// ENG-11659: result -> report body + the manager.log line that records it.
|
|
25277
25447
|
planPairStartReport
|
|
25278
|
-
} = await import("../claude-pair-runtime-
|
|
25448
|
+
} = await import("../claude-pair-runtime-ZGYYBH3G.js");
|
|
25279
25449
|
const { resetClaudeSignin, describeSigninResetForLog, describeSigninResetFailure } = await import("../claude-signin-reset-6IJMMVYG.js");
|
|
25280
25450
|
for (const pairId of pendingResp.cancelled_pair_ids ?? []) {
|
|
25281
25451
|
log(`[claude-pair] sweeping orphan tmux session for pair ${pairId.slice(0, 8)}`);
|
|
@@ -26789,6 +26959,7 @@ export {
|
|
|
26789
26959
|
shouldSkipRevokedCleanup,
|
|
26790
26960
|
shouldUpdateOnLatest,
|
|
26791
26961
|
stampClaudeCodeUpgradeMarker,
|
|
26962
|
+
stampRestartServiced,
|
|
26792
26963
|
startManager,
|
|
26793
26964
|
stopManager,
|
|
26794
26965
|
stuckChannelSyncs,
|