@integrity-labs/agt-cli 0.28.1249 → 0.28.1250
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-COCLODTH.js → chunk-5ALBA7KT.js} +73 -18
- package/dist/chunk-5ALBA7KT.js.map +1 -0
- package/dist/{chunk-CMCT3LOQ.js → chunk-DFJ5E5EW.js} +1 -1
- package/dist/{chunk-CMCT3LOQ.js.map → chunk-DFJ5E5EW.js.map} +1 -1
- package/dist/{chunk-G5CNX4XF.js → chunk-IUMFAYZO.js} +26 -3
- package/dist/{chunk-G5CNX4XF.js.map → chunk-IUMFAYZO.js.map} +1 -1
- package/dist/{chunk-NNB7XNZA.js → chunk-JOBL3ZF4.js} +2 -2
- package/dist/{chunk-IQ6MCAEK.js → chunk-SMD577FW.js} +2 -2
- package/dist/{claude-code-updater-EWJ6B5HX.js → claude-code-updater-5MPOBIWN.js} +3 -3
- package/dist/{claude-pair-runtime-BJLV7HMD.js → claude-pair-runtime-SNU3CU3K.js} +3 -3
- package/dist/lib/manager-worker.js +331 -104
- package/dist/lib/manager-worker.js.map +1 -1
- package/dist/{persistent-session-ZTDFRERR.js → persistent-session-SYCA6MW2.js} +4 -4
- package/dist/{responsiveness-probe-SVSMKLYS.js → responsiveness-probe-BUXWVOSA.js} +4 -4
- package/dist/{session-auth-dead-K63LMSKK.js → session-auth-dead-G5NHWSRP.js} +3 -3
- package/package.json +1 -1
- package/dist/chunk-COCLODTH.js.map +0 -1
- /package/dist/{chunk-NNB7XNZA.js.map → chunk-JOBL3ZF4.js.map} +0 -0
- /package/dist/{chunk-IQ6MCAEK.js.map → chunk-SMD577FW.js.map} +0 -0
- /package/dist/{claude-code-updater-EWJ6B5HX.js.map → claude-code-updater-5MPOBIWN.js.map} +0 -0
- /package/dist/{claude-pair-runtime-BJLV7HMD.js.map → claude-pair-runtime-SNU3CU3K.js.map} +0 -0
- /package/dist/{persistent-session-ZTDFRERR.js.map → persistent-session-SYCA6MW2.js.map} +0 -0
- /package/dist/{responsiveness-probe-SVSMKLYS.js.map → responsiveness-probe-BUXWVOSA.js.map} +0 -0
- /package/dist/{session-auth-dead-K63LMSKK.js.map → session-auth-dead-G5NHWSRP.js.map} +0 -0
|
@@ -85,7 +85,7 @@ import {
|
|
|
85
85
|
tripClass,
|
|
86
86
|
writeEtcEnvironment,
|
|
87
87
|
writeProfileDScript
|
|
88
|
-
} from "../chunk-
|
|
88
|
+
} from "../chunk-5ALBA7KT.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-JOBL3ZF4.js";
|
|
103
103
|
import {
|
|
104
104
|
rewriteSupervisorApiKey,
|
|
105
105
|
supervisorChannelsRefusing
|
|
@@ -154,6 +154,7 @@ import {
|
|
|
154
154
|
modelPolicyAuthComponent,
|
|
155
155
|
modelPolicyEgressDomains,
|
|
156
156
|
noteSessionBlockedOnPrompt,
|
|
157
|
+
opencodeTmuxSession,
|
|
157
158
|
paneLogPath,
|
|
158
159
|
parseEnvIntegrations,
|
|
159
160
|
parseModelPolicy,
|
|
@@ -195,7 +196,7 @@ import {
|
|
|
195
196
|
webFetchBaselineValue,
|
|
196
197
|
webFetchRestartNeeded,
|
|
197
198
|
writeEgressAllowlist
|
|
198
|
-
} from "../chunk-
|
|
199
|
+
} from "../chunk-IUMFAYZO.js";
|
|
199
200
|
import {
|
|
200
201
|
isAgentIdle,
|
|
201
202
|
isStaleForToday,
|
|
@@ -206,7 +207,7 @@ import {
|
|
|
206
207
|
subagentActivityAgeSeconds,
|
|
207
208
|
subagentTranscriptDir,
|
|
208
209
|
transcriptActivityAgeSeconds
|
|
209
|
-
} from "../chunk-
|
|
210
|
+
} from "../chunk-SMD577FW.js";
|
|
210
211
|
import {
|
|
211
212
|
classifyUnanswerablePane,
|
|
212
213
|
focusedConfirmDialogBlock,
|
|
@@ -337,7 +338,7 @@ import {
|
|
|
337
338
|
stabiliseResetInstant,
|
|
338
339
|
sumTranscriptUsageInWindow,
|
|
339
340
|
summarizeTranscriptActivity
|
|
340
|
-
} from "../chunk-
|
|
341
|
+
} from "../chunk-DFJ5E5EW.js";
|
|
341
342
|
import {
|
|
342
343
|
CLAUDE_CONFIG_DIR_ENV,
|
|
343
344
|
claudeConfigDirFor,
|
|
@@ -347,6 +348,176 @@ import {
|
|
|
347
348
|
} from "../chunk-AIUIMEUS.js";
|
|
348
349
|
import "../chunk-DGUM43GV.js";
|
|
349
350
|
|
|
351
|
+
// src/lib/manager-restart-gate.ts
|
|
352
|
+
import { execFileSync } from "child_process";
|
|
353
|
+
var MANAGER_RESTART_REASON = "manager-restart";
|
|
354
|
+
function decideManagerRestart(report) {
|
|
355
|
+
if (!report) return { kill: false, reason: "unknown_activity", runningBackgroundTasks: null };
|
|
356
|
+
if (report.state === "no_session") return { kill: true };
|
|
357
|
+
const running2 = typeof report.runningBackgroundTasks === "number" ? report.runningBackgroundTasks : null;
|
|
358
|
+
if (report.state === "mid_turn") return { kill: false, reason: "mid_turn", runningBackgroundTasks: running2 };
|
|
359
|
+
if (report.state === "idle_at_prompt") {
|
|
360
|
+
if (running2 === 0) return { kill: true };
|
|
361
|
+
return { kill: false, reason: running2 && running2 > 0 ? "background_tasks" : "unknown_activity", runningBackgroundTasks: running2 };
|
|
362
|
+
}
|
|
363
|
+
return { kill: false, reason: "unknown_activity", runningBackgroundTasks: running2 };
|
|
364
|
+
}
|
|
365
|
+
function laneDefersForFramework(cached, refreshed) {
|
|
366
|
+
return cached !== void 0 && cached !== refreshed;
|
|
367
|
+
}
|
|
368
|
+
function confirmsNoSession(err) {
|
|
369
|
+
const e = err;
|
|
370
|
+
if (!e || e.status !== 1 || e.signal) return false;
|
|
371
|
+
const stderr = typeof e.stderr === "string" ? e.stderr : Buffer.isBuffer(e.stderr) ? e.stderr.toString("utf8") : "";
|
|
372
|
+
return /can't find session|no server running|error connecting to .*\(No such file or directory\)/i.test(stderr);
|
|
373
|
+
}
|
|
374
|
+
function killAbortsRestart(killed, restartReason) {
|
|
375
|
+
if (killed === "timed-out") return true;
|
|
376
|
+
return killed === "failed" && restartReason === MANAGER_RESTART_REASON;
|
|
377
|
+
}
|
|
378
|
+
var TMUX_PROBE_TIMEOUT_MS = 3e3;
|
|
379
|
+
function captureAgentPane(codeName) {
|
|
380
|
+
const tmuxSession = `=agt-${codeName}`;
|
|
381
|
+
let tmuxAlive;
|
|
382
|
+
let screenCapture = null;
|
|
383
|
+
try {
|
|
384
|
+
execFileSync("tmux", ["has-session", "-t", tmuxSession], {
|
|
385
|
+
stdio: ["ignore", "ignore", "pipe"],
|
|
386
|
+
encoding: "utf-8",
|
|
387
|
+
timeout: TMUX_PROBE_TIMEOUT_MS
|
|
388
|
+
});
|
|
389
|
+
tmuxAlive = true;
|
|
390
|
+
} catch (err) {
|
|
391
|
+
tmuxAlive = confirmsNoSession(err) ? false : null;
|
|
392
|
+
}
|
|
393
|
+
if (tmuxAlive) {
|
|
394
|
+
try {
|
|
395
|
+
screenCapture = execFileSync("tmux", ["capture-pane", "-t", `${tmuxSession}:`, "-p", "-S", "-30"], {
|
|
396
|
+
encoding: "utf-8",
|
|
397
|
+
timeout: TMUX_PROBE_TIMEOUT_MS
|
|
398
|
+
}).trim();
|
|
399
|
+
} catch {
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
return { tmuxAlive, screenCapture };
|
|
403
|
+
}
|
|
404
|
+
var TMUX_KILL_TIMEOUT_MS = 1e4;
|
|
405
|
+
function killAgentPane(codeName, exec = execFileSync) {
|
|
406
|
+
try {
|
|
407
|
+
exec("tmux", ["kill-session", "-t", `=agt-${codeName}`], {
|
|
408
|
+
stdio: ["ignore", "ignore", "pipe"],
|
|
409
|
+
encoding: "utf-8",
|
|
410
|
+
timeout: TMUX_KILL_TIMEOUT_MS,
|
|
411
|
+
killSignal: "SIGKILL"
|
|
412
|
+
});
|
|
413
|
+
return "done";
|
|
414
|
+
} catch (err) {
|
|
415
|
+
if (err?.code === "ETIMEDOUT") return "timed-out";
|
|
416
|
+
return confirmsNoSession(err) ? "done" : "failed";
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
// src/lib/integration-reload-policy.ts
|
|
421
|
+
function restartReasonNeedsRender(reason) {
|
|
422
|
+
return reason != null && reason !== "manual" && reason !== MANAGER_RESTART_REASON;
|
|
423
|
+
}
|
|
424
|
+
function emptyPruneRestartsOpencode(input) {
|
|
425
|
+
return input.hadIntegrations && input.framework === "opencode" && input.serveHealthy;
|
|
426
|
+
}
|
|
427
|
+
function reloadAckAwaitsFreshIntegrations(reason, agentStatus) {
|
|
428
|
+
return reason === "integration-change" && agentRendersThisPoll(agentStatus);
|
|
429
|
+
}
|
|
430
|
+
function agentRendersThisPoll(agentStatus) {
|
|
431
|
+
return agentStatus !== "draft" && agentStatus !== "paused" && agentStatus !== "revoked";
|
|
432
|
+
}
|
|
433
|
+
function configReloadAction(input) {
|
|
434
|
+
return input.pendingRequested === input.requested ? "await-render" : "teardown";
|
|
435
|
+
}
|
|
436
|
+
function configReloadConfirmed(input) {
|
|
437
|
+
return input.pending && input.freshFetch && input.rendered;
|
|
438
|
+
}
|
|
439
|
+
var ConfigReloadLedger = class {
|
|
440
|
+
pending = /* @__PURE__ */ new Map();
|
|
441
|
+
confirmed = /* @__PURE__ */ new Set();
|
|
442
|
+
/** What the poll does with this agent's integration-change request. Records a teardown. */
|
|
443
|
+
service(agentId, requested) {
|
|
444
|
+
const action = configReloadAction({ requested, pendingRequested: this.pending.get(agentId) });
|
|
445
|
+
if (action === "teardown") {
|
|
446
|
+
this.pending.set(agentId, requested);
|
|
447
|
+
this.confirmed.delete(agentId);
|
|
448
|
+
}
|
|
449
|
+
return action;
|
|
450
|
+
}
|
|
451
|
+
isPending(agentId) {
|
|
452
|
+
return this.pending.has(agentId);
|
|
453
|
+
}
|
|
454
|
+
/** processAgent rendered fresh state for this agent's pending reload. */
|
|
455
|
+
confirm(agentId) {
|
|
456
|
+
if (this.pending.has(agentId)) this.confirmed.add(agentId);
|
|
457
|
+
}
|
|
458
|
+
/** The confirmed reloads among `agentIds`, as acks; they stop being pending. */
|
|
459
|
+
takeConfirmed(agentIds) {
|
|
460
|
+
const out = [];
|
|
461
|
+
for (const agentId of agentIds) {
|
|
462
|
+
if (!this.confirmed.has(agentId)) continue;
|
|
463
|
+
const requestedAt = this.pending.get(agentId);
|
|
464
|
+
this.confirmed.delete(agentId);
|
|
465
|
+
this.pending.delete(agentId);
|
|
466
|
+
if (requestedAt) out.push({ agentId, requestedAt });
|
|
467
|
+
}
|
|
468
|
+
return out;
|
|
469
|
+
}
|
|
470
|
+
/** The agent left this host. */
|
|
471
|
+
forget(agentId) {
|
|
472
|
+
this.pending.delete(agentId);
|
|
473
|
+
this.confirmed.delete(agentId);
|
|
474
|
+
}
|
|
475
|
+
};
|
|
476
|
+
function stampIsOlder(a, b) {
|
|
477
|
+
const ta = Date.parse(a);
|
|
478
|
+
const tb = Date.parse(b);
|
|
479
|
+
if (Number.isNaN(ta) || Number.isNaN(tb)) return a < b;
|
|
480
|
+
return ta < tb;
|
|
481
|
+
}
|
|
482
|
+
function stepConfigReload(ledger, input) {
|
|
483
|
+
if (!agentRendersThisPoll(input.agentStatus)) {
|
|
484
|
+
ledger.forget(input.agentId);
|
|
485
|
+
return "teardown-and-ack";
|
|
486
|
+
}
|
|
487
|
+
if (!reloadAckAwaitsFreshIntegrations(input.reason, input.agentStatus) && !ledger.isPending(input.agentId)) {
|
|
488
|
+
return "teardown-and-ack";
|
|
489
|
+
}
|
|
490
|
+
return ledger.service(input.agentId, input.requested) === "await-render" ? "await-render" : "teardown-await-render";
|
|
491
|
+
}
|
|
492
|
+
function orphansStillDeclared(orphanKeys, declaredAfter) {
|
|
493
|
+
return orphanKeys.filter((key) => Object.prototype.hasOwnProperty.call(declaredAfter, key));
|
|
494
|
+
}
|
|
495
|
+
function orphanPruneFailedLine(codeName, keys, reason) {
|
|
496
|
+
const servers = keys.length > 0 ? keys.map((k) => `'${k}'`).join(", ") : "(not determined: the read failed first)";
|
|
497
|
+
return `[hot-reload] ORPHAN_PRUNE_FAILED agent='${codeName}' servers=${servers} reason=${reason}. The integration-change reload stays pending and the session is NOT blocked, so a removed integration's tools may still be reachable until the prune succeeds (ENG-11912).`;
|
|
498
|
+
}
|
|
499
|
+
function readDeclaredServersForPrune(adapter, codeName) {
|
|
500
|
+
if (adapter.readMcpServersOrNull) return adapter.readMcpServersOrNull(codeName);
|
|
501
|
+
return adapter.readMcpServers ? adapter.readMcpServers(codeName) : null;
|
|
502
|
+
}
|
|
503
|
+
function orphanPruneOutcome(orphanKeys, declaredAfter) {
|
|
504
|
+
if (orphanKeys.length === 0) return { failed: false };
|
|
505
|
+
if (declaredAfter === null) {
|
|
506
|
+
return { failed: true, stuck: [...orphanKeys], reason: "the MCP config could not be re-read after removal" };
|
|
507
|
+
}
|
|
508
|
+
const stuck = orphansStillDeclared(orphanKeys, declaredAfter);
|
|
509
|
+
return stuck.length > 0 ? { failed: true, stuck, reason: "removal returned but the server is still declared (config write refused)" } : { failed: false };
|
|
510
|
+
}
|
|
511
|
+
var MCP_REPAIR_PENDING_HASH = "\0mcp-repair\0";
|
|
512
|
+
function markMcpRepairPending(hashes, agentId, unlanded) {
|
|
513
|
+
if (!unlanded) return false;
|
|
514
|
+
hashes.set(agentId, MCP_REPAIR_PENDING_HASH);
|
|
515
|
+
return true;
|
|
516
|
+
}
|
|
517
|
+
function staleSessionStopConfirmed(sessionState) {
|
|
518
|
+
return sessionState === "dead";
|
|
519
|
+
}
|
|
520
|
+
|
|
350
521
|
// src/lib/manager-worker.ts
|
|
351
522
|
import { createHash as createHash20 } from "crypto";
|
|
352
523
|
import { readFileSync as readFileSync35, writeFileSync as writeFileSync18, mkdirSync as mkdirSync16, existsSync as existsSync19, rmSync as rmSync8, readdirSync as readdirSync14, statSync as statSync15, unlinkSync as unlinkSync6, renameSync as renameSync11, utimesSync as utimesSync4, readlinkSync as readlinkSync2 } from "fs";
|
|
@@ -1256,6 +1427,10 @@ function shouldDeferBindRemediationForFirstConnect(outcome, ctx) {
|
|
|
1256
1427
|
|
|
1257
1428
|
// src/lib/integration-hash.ts
|
|
1258
1429
|
import { createHash as createHash2 } from "crypto";
|
|
1430
|
+
function remoteMcpUrlOf(i) {
|
|
1431
|
+
const url = i.remoteMcp?.url;
|
|
1432
|
+
return typeof url === "string" && url ? url : null;
|
|
1433
|
+
}
|
|
1259
1434
|
function canonicalize(value) {
|
|
1260
1435
|
if (Array.isArray(value)) return value.map(canonicalize);
|
|
1261
1436
|
if (value && typeof value === "object") {
|
|
@@ -1278,9 +1453,11 @@ function hashableConfig(config2) {
|
|
|
1278
1453
|
return out;
|
|
1279
1454
|
}
|
|
1280
1455
|
function computeIntegrationsHash(integrations) {
|
|
1281
|
-
const payload = integrations.map(
|
|
1282
|
-
|
|
1283
|
-
|
|
1456
|
+
const payload = integrations.map((i) => {
|
|
1457
|
+
const base = `${i.definition_id}:${JSON.stringify(canonicalize(i.credentials ?? {}))}:${JSON.stringify(canonicalize(hashableConfig(i.config)))}`;
|
|
1458
|
+
const url = remoteMcpUrlOf(i);
|
|
1459
|
+
return url ? `${base}:remote=${url}` : base;
|
|
1460
|
+
}).sort();
|
|
1284
1461
|
return createHash2("sha256").update(JSON.stringify(payload)).digest("hex").slice(0, 16);
|
|
1285
1462
|
}
|
|
1286
1463
|
function computeCapabilitySurfaceHash(integrations) {
|
|
@@ -5266,75 +5443,6 @@ function buildSessionActivityReport(args) {
|
|
|
5266
5443
|
}
|
|
5267
5444
|
}
|
|
5268
5445
|
|
|
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
|
-
|
|
5338
5446
|
// src/lib/workflow-run-reconciler.ts
|
|
5339
5447
|
import { readdirSync as readdirSync4, readFileSync as readFileSync13, statSync as statSync4 } from "fs";
|
|
5340
5448
|
import { join as join19 } from "path";
|
|
@@ -15953,7 +16061,7 @@ var pendingDayRolloverReset = /* @__PURE__ */ new Set();
|
|
|
15953
16061
|
var dayRolloverInboundHold = /* @__PURE__ */ new Map();
|
|
15954
16062
|
var INBOUND_HOLD_EPISODE_GAP_MS = 12e4;
|
|
15955
16063
|
async function channelInboundActivityAgeSecondsFor(codeName) {
|
|
15956
|
-
const { newestPendingInboundActivityMtimeMs } = await import("../responsiveness-probe-
|
|
16064
|
+
const { newestPendingInboundActivityMtimeMs } = await import("../responsiveness-probe-BUXWVOSA.js");
|
|
15957
16065
|
const newest = newestPendingInboundActivityMtimeMs(dirname11(paneLogPath(codeName)));
|
|
15958
16066
|
if (newest === null) return null;
|
|
15959
16067
|
return Math.max(0, Math.floor((Date.now() - newest) / 1e3));
|
|
@@ -16726,6 +16834,7 @@ function clearAgentCaches(agentId, codeName) {
|
|
|
16726
16834
|
integrationsFetchGate.forget(agentId);
|
|
16727
16835
|
quarantinedFetchGate.forget(agentId);
|
|
16728
16836
|
lastIntegrationsPayload.delete(agentId);
|
|
16837
|
+
configReloads.forget(agentId);
|
|
16729
16838
|
integrationEgressDomainsByAgent.delete(agentId);
|
|
16730
16839
|
lastQuarantinedPayload.delete(agentId);
|
|
16731
16840
|
forgetRealtimeRebindState(agentId);
|
|
@@ -16768,7 +16877,7 @@ var agentRestartTimezoneInputs = /* @__PURE__ */ new Map();
|
|
|
16768
16877
|
var lastVersionCheckAt = 0;
|
|
16769
16878
|
var VERSION_CHECK_INTERVAL_MS = 5 * 60 * 1e3;
|
|
16770
16879
|
var lastResponsivenessProbeAt = 0;
|
|
16771
|
-
var agtCliVersion = true ? "0.28.
|
|
16880
|
+
var agtCliVersion = true ? "0.28.1250" : "dev";
|
|
16772
16881
|
function resolveBrewPath(execFileSync4) {
|
|
16773
16882
|
try {
|
|
16774
16883
|
const out = execFileSync4("which", ["brew"], { timeout: 5e3 }).toString().trim();
|
|
@@ -18708,6 +18817,7 @@ var boardFetchGate = createFetchGate(MY_KANBAN_FETCH_TTL_MS);
|
|
|
18708
18817
|
var RECURRING_SPAWN_INTERVAL_MS = 6e4;
|
|
18709
18818
|
var RECURRING_SPAWN_GATE_KEY = "host";
|
|
18710
18819
|
var recurringSpawnGate = createFetchGate(RECURRING_SPAWN_INTERVAL_MS);
|
|
18820
|
+
var configReloads = new ConfigReloadLedger();
|
|
18711
18821
|
function forceIntegrationsFetch(agentId) {
|
|
18712
18822
|
integrationsFetchGate.forceNext(agentId);
|
|
18713
18823
|
quarantinedFetchGate.forceNext(agentId);
|
|
@@ -18766,7 +18876,7 @@ function flushRestartedAgentDiagnostics(hostId, codeNames) {
|
|
|
18766
18876
|
if (codeNames.length === 0) return;
|
|
18767
18877
|
void (async () => {
|
|
18768
18878
|
try {
|
|
18769
|
-
const { collectDiagnostics } = await import("../persistent-session-
|
|
18879
|
+
const { collectDiagnostics } = await import("../persistent-session-SYCA6MW2.js");
|
|
18770
18880
|
await api.post("/host/heartbeat", {
|
|
18771
18881
|
host_id: hostId,
|
|
18772
18882
|
agent_diagnostics: collectDiagnostics(codeNames, quarantineEntriesFor, claudeMdSizeFor, spawnOutcomeForDiagnostics, pidPressureFor, forwardedToolsFor, runtimeVersionFor, sessionActivityFor)
|
|
@@ -18909,7 +19019,7 @@ async function pollCycleInner() {
|
|
|
18909
19019
|
}
|
|
18910
19020
|
try {
|
|
18911
19021
|
const { detectHostSecurity } = await import("../host-security-KQYYZZVW.js");
|
|
18912
|
-
const { collectDiagnostics } = await import("../persistent-session-
|
|
19022
|
+
const { collectDiagnostics } = await import("../persistent-session-SYCA6MW2.js");
|
|
18913
19023
|
const diagCodeNames = [...agentState.persistentSessionAgents];
|
|
18914
19024
|
const agentDiagnostics = diagCodeNames.length > 0 ? collectDiagnostics(diagCodeNames, quarantineEntriesFor, claudeMdSizeFor, spawnOutcomeForDiagnostics, pidPressureFor, forwardedToolsFor, runtimeVersionFor, sessionActivityFor) : void 0;
|
|
18915
19025
|
let tailscaleHostname;
|
|
@@ -19174,7 +19284,7 @@ async function pollCycleInner() {
|
|
|
19174
19284
|
}
|
|
19175
19285
|
try {
|
|
19176
19286
|
const desiredClaudeCodeVersion = hbResp?.desired_claude_code_version?.trim();
|
|
19177
|
-
const { maybeUpdateClaudeCode, shouldRunClaudeCodeUpdater } = await import("../claude-code-updater-
|
|
19287
|
+
const { maybeUpdateClaudeCode, shouldRunClaudeCodeUpdater } = await import("../claude-code-updater-5MPOBIWN.js");
|
|
19178
19288
|
const securityFloor = currentSecurityFloor();
|
|
19179
19289
|
claudeUpdaterInFlight = true;
|
|
19180
19290
|
if (desiredClaudeCodeVersion && (claudePairLoop.busy || claudePairingInProgress())) {
|
|
@@ -19209,7 +19319,7 @@ async function pollCycleInner() {
|
|
|
19209
19319
|
collectPanelessActivityProbes,
|
|
19210
19320
|
getResponsivenessIntervalMs,
|
|
19211
19321
|
occupancyQualificationClassifications
|
|
19212
|
-
} = await import("../responsiveness-probe-
|
|
19322
|
+
} = await import("../responsiveness-probe-BUXWVOSA.js");
|
|
19213
19323
|
const probeIntervalMs = getResponsivenessIntervalMs();
|
|
19214
19324
|
if (now - lastResponsivenessProbeAt > probeIntervalMs) {
|
|
19215
19325
|
const probeCodeNames = [...agentState.persistentSessionAgents];
|
|
@@ -19326,7 +19436,7 @@ async function pollCycleInner() {
|
|
|
19326
19436
|
collectResponsivenessProbes,
|
|
19327
19437
|
livePendingInboundOldestAgeSeconds,
|
|
19328
19438
|
parkPendingInbound
|
|
19329
|
-
} = await import("../responsiveness-probe-
|
|
19439
|
+
} = await import("../responsiveness-probe-BUXWVOSA.js");
|
|
19330
19440
|
const { getProjectDir: wedgeProjectDir } = await import("../scheduler-engine-5PCBGRNY.js");
|
|
19331
19441
|
const wedgeNow = /* @__PURE__ */ new Date();
|
|
19332
19442
|
const liveAgents = agentState.persistentSessionAgents;
|
|
@@ -19612,7 +19722,7 @@ async function pollCycleInner() {
|
|
|
19612
19722
|
}
|
|
19613
19723
|
}
|
|
19614
19724
|
);
|
|
19615
|
-
const { parkPendingInbound } = await import("../responsiveness-probe-
|
|
19725
|
+
const { parkPendingInbound } = await import("../responsiveness-probe-BUXWVOSA.js");
|
|
19616
19726
|
const { parked, deadLettered } = parkPendingInbound(codeName, new Date(fatalNowMs));
|
|
19617
19727
|
paneFatalStreak.delete(codeName);
|
|
19618
19728
|
paneFatalRestarts.set(codeName, [...history, fatalNowMs]);
|
|
@@ -19643,7 +19753,7 @@ async function pollCycleInner() {
|
|
|
19643
19753
|
TRANSCRIPT_MOUNT_ESCALATION_REFRESH_MS,
|
|
19644
19754
|
bindSourceEscalations
|
|
19645
19755
|
} = await import("../transcript-mount-health-OHE6IVJV.js");
|
|
19646
|
-
const { transcriptBindSourcesFor, ensureTranscriptBindSources } = await import("../persistent-session-
|
|
19756
|
+
const { transcriptBindSourcesFor, ensureTranscriptBindSources } = await import("../persistent-session-SYCA6MW2.js");
|
|
19647
19757
|
const mountConfig = resolveTranscriptMountConfig();
|
|
19648
19758
|
const liveAgents = agentState.persistentSessionAgents;
|
|
19649
19759
|
for (const tracked of [
|
|
@@ -19808,7 +19918,7 @@ async function pollCycleInner() {
|
|
|
19808
19918
|
}
|
|
19809
19919
|
try {
|
|
19810
19920
|
const { scrapeMcpFailedBannerCount } = await import("../pane-mcp-banner-scraper-VR5QGP3J.js");
|
|
19811
|
-
const { probeSessionAuth } = await import("../session-auth-dead-
|
|
19921
|
+
const { probeSessionAuth } = await import("../session-auth-dead-G5NHWSRP.js");
|
|
19812
19922
|
const observations = [];
|
|
19813
19923
|
const pendingCacheCommits = [];
|
|
19814
19924
|
const modelApiErrorReportingOn = hostFlagStore().getBoolean("model-api-error-reporting");
|
|
@@ -19941,12 +20051,25 @@ async function pollCycleInner() {
|
|
|
19941
20051
|
log(
|
|
19942
20052
|
`[restart] Dashboard requested restart for '${agent.code_name}' at ${requested} (reason=${restartReason ?? "manual"})`
|
|
19943
20053
|
);
|
|
20054
|
+
if (restartReasonNeedsRender(restartReason)) forceIntegrationsFetch(agent.agent_id);
|
|
20055
|
+
const reloadStep = stepConfigReload(configReloads, {
|
|
20056
|
+
agentId: agent.agent_id,
|
|
20057
|
+
requested,
|
|
20058
|
+
reason: restartReason,
|
|
20059
|
+
agentStatus: agent.status
|
|
20060
|
+
});
|
|
20061
|
+
const deferAck = reloadStep !== "teardown-and-ack";
|
|
20062
|
+
if (reloadStep === "await-render") {
|
|
20063
|
+
log(`[restart] config-change reload for '${agent.code_name}' still waiting on a fresh integrations render (ENG-11912)`);
|
|
20064
|
+
continue;
|
|
20065
|
+
}
|
|
19944
20066
|
const framework = agent.framework ?? agentFrameworkCache.get(agent.code_name) ?? DEFAULT_FRAMEWORK;
|
|
19945
20067
|
if (restartTargetsOpencodeServe(framework)) {
|
|
19946
20068
|
stopOpencodeSession(agent.code_name, log);
|
|
19947
20069
|
} else {
|
|
19948
20070
|
const killed = killAgentPane(agent.code_name);
|
|
19949
20071
|
if (killAbortsRestart(killed, restartReason)) {
|
|
20072
|
+
if (reloadStep === "teardown-await-render") configReloads.forget(agent.agent_id);
|
|
19950
20073
|
log(`[restart] tmux kill for '${agent.code_name}' ${killed} (timeout ${TMUX_KILL_TIMEOUT_MS}ms) - not acking, the next poll retries [ENG-11963]`);
|
|
19951
20074
|
continue;
|
|
19952
20075
|
}
|
|
@@ -19968,6 +20091,7 @@ async function pollCycleInner() {
|
|
|
19968
20091
|
});
|
|
19969
20092
|
}
|
|
19970
20093
|
}
|
|
20094
|
+
if (deferAck) continue;
|
|
19971
20095
|
restartAcks.set(agent.agent_id, requested);
|
|
19972
20096
|
if (prev) prev.lastRestartProcessedAt = requested;
|
|
19973
20097
|
}
|
|
@@ -20283,6 +20407,16 @@ async function pollCycleInner() {
|
|
|
20283
20407
|
void maybeReportActivityCache({ api, log });
|
|
20284
20408
|
const crossAgentPrune = managedPruneLedger.summarize();
|
|
20285
20409
|
if (crossAgentPrune) log(crossAgentPrune);
|
|
20410
|
+
for (const ack of configReloads.takeConfirmed(agents.map((a) => a.agent_id))) {
|
|
20411
|
+
const already = restartAcks.get(ack.agentId) ?? state9.agents.find((a) => a.agentId === ack.agentId)?.lastRestartProcessedAt ?? null;
|
|
20412
|
+
if (already && !stampIsOlder(already, ack.requestedAt)) continue;
|
|
20413
|
+
restartAcks.set(ack.agentId, ack.requestedAt);
|
|
20414
|
+
void api.post("/host/restart-ack", {
|
|
20415
|
+
host_id: hostId,
|
|
20416
|
+
agent_id: ack.agentId,
|
|
20417
|
+
restart_requested_at: ack.requestedAt
|
|
20418
|
+
}).catch((err) => log(`[restart] clear failed for agent_id=${ack.agentId}: ${err.message}`));
|
|
20419
|
+
}
|
|
20286
20420
|
const restartAckStateChanged = applyRestartAcks({
|
|
20287
20421
|
agentStates,
|
|
20288
20422
|
priorAgents: state9.agents,
|
|
@@ -22011,17 +22145,22 @@ async function processAgent(agent, agentStates, managedToolkits) {
|
|
|
22011
22145
|
encodeIntegrationEgressDomains(egressDomains)
|
|
22012
22146
|
);
|
|
22013
22147
|
}
|
|
22014
|
-
|
|
22148
|
+
if (!Array.isArray(integrationsData.integrations)) {
|
|
22149
|
+
throw new Error("/host/agent-integrations body had no integrations array");
|
|
22150
|
+
}
|
|
22151
|
+
return integrationsData.integrations.map(withResolvedRemoteMcp);
|
|
22015
22152
|
};
|
|
22016
22153
|
const integrationsToken = integrationsFetchGate.beginFetch(agent.agent_id);
|
|
22017
22154
|
const cachedIntegrations = lastIntegrationsPayload.get(agent.agent_id);
|
|
22018
22155
|
let integrations;
|
|
22156
|
+
let integrationsFresh = false;
|
|
22019
22157
|
if (cachedIntegrations !== void 0 && !integrationsFetchGate.shouldFetch(agent.agent_id)) {
|
|
22020
22158
|
integrations = cachedIntegrations;
|
|
22021
22159
|
pollCycleIntegrationsSkips += 1;
|
|
22022
22160
|
} else {
|
|
22023
22161
|
integrations = await fetchIntegrations();
|
|
22024
22162
|
lastIntegrationsPayload.set(agent.agent_id, integrations);
|
|
22163
|
+
integrationsFresh = true;
|
|
22025
22164
|
integrationsFetchGate.markFetched(agent.agent_id, integrationsToken);
|
|
22026
22165
|
pollCycleIntegrationsFetches += 1;
|
|
22027
22166
|
}
|
|
@@ -22157,18 +22296,43 @@ async function processAgent(agent, agentStates, managedToolkits) {
|
|
|
22157
22296
|
else promptBindProbeAttempts.delete(agent.code_name);
|
|
22158
22297
|
}
|
|
22159
22298
|
}
|
|
22299
|
+
let orphanPruneFailed = false;
|
|
22160
22300
|
if (frameworkAdapter.removeMcpServer && frameworkAdapter.readMcpServers) {
|
|
22301
|
+
let orphanKeys = [];
|
|
22302
|
+
frameworkAdapter.consumeMcpWriteFailures?.(agent.code_name);
|
|
22161
22303
|
try {
|
|
22162
|
-
const declaredServers = frameworkAdapter
|
|
22163
|
-
|
|
22164
|
-
|
|
22165
|
-
|
|
22166
|
-
|
|
22167
|
-
|
|
22168
|
-
|
|
22304
|
+
const declaredServers = readDeclaredServersForPrune(frameworkAdapter, agent.code_name);
|
|
22305
|
+
if (declaredServers === null) {
|
|
22306
|
+
orphanPruneFailed = true;
|
|
22307
|
+
log(orphanPruneFailedLine(agent.code_name, [], "the MCP config could not be read"));
|
|
22308
|
+
} else {
|
|
22309
|
+
const expectedRemoteKeys = expectedRemoteMcpKeys(
|
|
22310
|
+
integrations
|
|
22311
|
+
);
|
|
22312
|
+
orphanKeys = orphanedRemoteMcpKeys(declaredServers, expectedRemoteKeys);
|
|
22313
|
+
for (const key of orphanKeys) {
|
|
22314
|
+
frameworkAdapter.removeMcpServer(agent.code_name, key);
|
|
22315
|
+
}
|
|
22316
|
+
const outcome = orphanPruneOutcome(
|
|
22317
|
+
orphanKeys,
|
|
22318
|
+
orphanKeys.length > 0 ? readDeclaredServersForPrune(frameworkAdapter, agent.code_name) : {}
|
|
22319
|
+
);
|
|
22320
|
+
if (outcome.failed) {
|
|
22321
|
+
orphanPruneFailed = true;
|
|
22322
|
+
log(orphanPruneFailedLine(agent.code_name, outcome.stuck, outcome.reason));
|
|
22323
|
+
} else if ((frameworkAdapter.consumeMcpWriteFailures?.(agent.code_name) ?? 0) > 0) {
|
|
22324
|
+
orphanPruneFailed = true;
|
|
22325
|
+
log(orphanPruneFailedLine(agent.code_name, orphanKeys, "removed from provision/.mcp.json but the project mirror the session loads was not written"));
|
|
22326
|
+
}
|
|
22327
|
+
for (const key of orphanKeys) {
|
|
22328
|
+
if (!(outcome.failed && outcome.stuck.includes(key))) {
|
|
22329
|
+
log(`[hot-reload] Removed orphaned remote MCP server '${key}' for '${agent.code_name}' (integration removed)`);
|
|
22330
|
+
}
|
|
22331
|
+
}
|
|
22169
22332
|
}
|
|
22170
22333
|
} catch (err) {
|
|
22171
|
-
|
|
22334
|
+
orphanPruneFailed = true;
|
|
22335
|
+
log(orphanPruneFailedLine(agent.code_name, orphanKeys, `prune threw: ${err.message}`));
|
|
22172
22336
|
}
|
|
22173
22337
|
}
|
|
22174
22338
|
const currentIntIds = integrations.map((i) => i.definition_id);
|
|
@@ -22203,17 +22367,39 @@ async function processAgent(agent, agentStates, managedToolkits) {
|
|
|
22203
22367
|
}
|
|
22204
22368
|
let reapNote = "";
|
|
22205
22369
|
let rotationHandled = true;
|
|
22370
|
+
let mcpWriteFailed = false;
|
|
22371
|
+
if (agentState.knownIntegrationHashes.get(agent.agent_id) === MCP_REPAIR_PENDING_HASH && frameworkAdapter.syncMcpMirror) {
|
|
22372
|
+
frameworkAdapter.consumeMcpWriteFailures?.(agent.code_name);
|
|
22373
|
+
frameworkAdapter.syncMcpMirror(agent.code_name);
|
|
22374
|
+
if ((frameworkAdapter.consumeMcpWriteFailures?.(agent.code_name) ?? 0) > 0) {
|
|
22375
|
+
mcpWriteFailed = true;
|
|
22376
|
+
log(`[hot-reload] MCP_MIRROR_REPAIR_FAILED agent='${agent.code_name}': the project MCP mirror still could not be written; the reload stays pending (ENG-11912)`);
|
|
22377
|
+
}
|
|
22378
|
+
}
|
|
22206
22379
|
const EMPTY_INTEGRATIONS_HASH = "\0empty\0";
|
|
22207
22380
|
if (integrations.length === 0 && frameworkAdapter.writeIntegrations) {
|
|
22208
22381
|
const prevIntHash = agentState.knownIntegrationHashes.get(agent.agent_id);
|
|
22209
22382
|
if (prevIntHash !== EMPTY_INTEGRATIONS_HASH) {
|
|
22210
22383
|
try {
|
|
22384
|
+
frameworkAdapter.consumeMcpWriteFailures?.(agent.code_name);
|
|
22211
22385
|
frameworkAdapter.writeIntegrations(agent.code_name, [], agent.agent_id, {
|
|
22212
22386
|
renderClaudeMdSection: renderIntegrationsSection,
|
|
22213
22387
|
log
|
|
22214
22388
|
});
|
|
22389
|
+
if ((frameworkAdapter.consumeMcpWriteFailures?.(agent.code_name) ?? 0) > 0) {
|
|
22390
|
+
mcpWriteFailed = true;
|
|
22391
|
+
throw new Error("MCP config write did not land (MCP_WRITE_REFUSED)");
|
|
22392
|
+
}
|
|
22215
22393
|
agentState.knownIntegrationHashes.set(agent.agent_id, EMPTY_INTEGRATIONS_HASH);
|
|
22216
22394
|
log(`[ENG-8035] Pruned integration-derived MCP entries for '${agent.code_name}' (integrations.length=0)`);
|
|
22395
|
+
if (emptyPruneRestartsOpencode({
|
|
22396
|
+
hadIntegrations: prevIntHash !== void 0,
|
|
22397
|
+
framework: agentFrameworkCache.get(agent.code_name) ?? DEFAULT_FRAMEWORK,
|
|
22398
|
+
serveHealthy: isOpencodeSessionHealthy(agent.code_name)
|
|
22399
|
+
})) {
|
|
22400
|
+
log(`[hot-reload] opencode lost its last integration for '${agent.code_name}' - restarting serve to drop its MCP servers`);
|
|
22401
|
+
stopOpencodeSession(agent.code_name, log);
|
|
22402
|
+
}
|
|
22217
22403
|
} catch (err) {
|
|
22218
22404
|
rotationHandled = false;
|
|
22219
22405
|
log(`[ENG-8035] Empty integration prune failed for '${agent.code_name}': ${err.message}`);
|
|
@@ -22233,10 +22419,18 @@ async function processAgent(agent, agentStates, managedToolkits) {
|
|
|
22233
22419
|
preWriteEnv = void 0;
|
|
22234
22420
|
}
|
|
22235
22421
|
if (frameworkAdapter.writeIntegrations) {
|
|
22422
|
+
frameworkAdapter.consumeMcpWriteFailures?.(agent.code_name);
|
|
22236
22423
|
frameworkAdapter.writeIntegrations(agent.code_name, integrations, agent.agent_id, {
|
|
22237
22424
|
renderClaudeMdSection: renderIntegrationsSection,
|
|
22238
22425
|
log
|
|
22239
22426
|
});
|
|
22427
|
+
const refusedWrites = frameworkAdapter.consumeMcpWriteFailures?.(agent.code_name) ?? 0;
|
|
22428
|
+
if (refusedWrites > 0) {
|
|
22429
|
+
mcpWriteFailed = true;
|
|
22430
|
+
log(
|
|
22431
|
+
`[hot-reload] MCP_WRITE_REFUSED agent='${agent.code_name}' writes=${refusedWrites}: the rendered MCP config did not fully land, so a pending integration-change reload stays pending and the integrations hash is not recorded (retried next poll) (ENG-11912)`
|
|
22432
|
+
);
|
|
22433
|
+
}
|
|
22240
22434
|
}
|
|
22241
22435
|
log(`Integrations provisioned for '${agent.code_name}' (${integrations.length} integration(s))`);
|
|
22242
22436
|
const fw = agentFrameworkCache.get(agent.code_name) ?? DEFAULT_FRAMEWORK;
|
|
@@ -22307,7 +22501,7 @@ async function processAgent(agent, agentStates, managedToolkits) {
|
|
|
22307
22501
|
log(`[hot-reload] Failed to compute / reap affected MCP servers for '${agent.code_name}': ${err.message} \u2014 will retry next tick`);
|
|
22308
22502
|
}
|
|
22309
22503
|
}
|
|
22310
|
-
const hashDecision = integrationHashDecision(rotationHandled, integrations, intHash);
|
|
22504
|
+
const hashDecision = integrationHashDecision(rotationHandled && !mcpWriteFailed, integrations, intHash);
|
|
22311
22505
|
if (hashDecision.kind === "record") {
|
|
22312
22506
|
agentState.knownIntegrationHashes.set(agent.agent_id, hashDecision.hash);
|
|
22313
22507
|
} else if (hashDecision.kind === "forget") {
|
|
@@ -22316,6 +22510,38 @@ async function processAgent(agent, agentStates, managedToolkits) {
|
|
|
22316
22510
|
}
|
|
22317
22511
|
}
|
|
22318
22512
|
}
|
|
22513
|
+
if (markMcpRepairPending(agentState.knownIntegrationHashes, agent.agent_id, orphanPruneFailed || mcpWriteFailed || !rotationHandled)) {
|
|
22514
|
+
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)`);
|
|
22515
|
+
}
|
|
22516
|
+
if (configReloadConfirmed({
|
|
22517
|
+
pending: configReloads.isPending(agent.agent_id),
|
|
22518
|
+
freshFetch: integrationsFresh,
|
|
22519
|
+
rendered: rotationHandled && !orphanPruneFailed && !mcpWriteFailed
|
|
22520
|
+
})) {
|
|
22521
|
+
const fwForReload = agentFrameworkCache.get(agent.code_name) ?? DEFAULT_FRAMEWORK;
|
|
22522
|
+
const staleTmuxSession = fwForReload === "opencode" ? opencodeTmuxSession(agent.code_name) : `agt-${agent.code_name}`;
|
|
22523
|
+
if (probeTmuxSession(staleTmuxSession) === "alive") {
|
|
22524
|
+
if (fwForReload === "opencode") {
|
|
22525
|
+
stopOpencodeSession(agent.code_name, log);
|
|
22526
|
+
} else {
|
|
22527
|
+
log(`[restart] '${agent.code_name}' is running config from before the reload's fresh render - restarting it (ENG-11912)`);
|
|
22528
|
+
try {
|
|
22529
|
+
syncExecFile("tmux", ["kill-session", "-t", `agt-${agent.code_name}`], { stdio: "ignore" });
|
|
22530
|
+
} catch {
|
|
22531
|
+
}
|
|
22532
|
+
stopPersistentSessionAndForgetMcpBaseline(agent.code_name, "integration-change");
|
|
22533
|
+
}
|
|
22534
|
+
}
|
|
22535
|
+
const staleSessionState = probeTmuxSession(staleTmuxSession);
|
|
22536
|
+
if (staleSessionStopConfirmed(staleSessionState)) {
|
|
22537
|
+
configReloads.confirm(agent.agent_id);
|
|
22538
|
+
log(`[restart] config-change reload for '${agent.code_name}' rendered from fresh integrations - acking (ENG-11912)`);
|
|
22539
|
+
} else {
|
|
22540
|
+
log(
|
|
22541
|
+
`[restart] STALE_SESSION_STOP_FAILED agent='${agent.code_name}' session_state=${staleSessionState}: 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)`
|
|
22542
|
+
);
|
|
22543
|
+
}
|
|
22544
|
+
}
|
|
22319
22545
|
if (capSurfaceHash !== prevCapSurfaceHash && rotationHandled) {
|
|
22320
22546
|
if (intFlap.flapping) {
|
|
22321
22547
|
log(`[mcp-flap-dampener] suppressed integration-update notice for '${agent.code_name}' (set flapping, ENG-6123): ${capSurfaceNames}`);
|
|
@@ -24544,9 +24770,6 @@ function ensureRealtimeDriftStarted(agentStates) {
|
|
|
24544
24770
|
});
|
|
24545
24771
|
}
|
|
24546
24772
|
var restartInFlight = /* @__PURE__ */ new Set();
|
|
24547
|
-
function restartReasonNeedsRender(reason) {
|
|
24548
|
-
return reason != null && reason !== "manual" && reason !== MANAGER_RESTART_REASON;
|
|
24549
|
-
}
|
|
24550
24773
|
async function managerRestartMayKill(agentId, codeName, requestedAt, lane, framework) {
|
|
24551
24774
|
let verdict;
|
|
24552
24775
|
if (framework !== "claude-code") {
|
|
@@ -24606,6 +24829,10 @@ async function handleRestartDoorbell(agentId, requestedAt, restartReason) {
|
|
|
24606
24829
|
triggerEarlyPoll(`config-change reload for '${codeName}' (reason=${restartReason})`, agentId);
|
|
24607
24830
|
return;
|
|
24608
24831
|
}
|
|
24832
|
+
if (configReloads.isPending(agentId)) {
|
|
24833
|
+
triggerEarlyPoll(`restart for '${codeName}' while a config-change reload is pending`, agentId);
|
|
24834
|
+
return;
|
|
24835
|
+
}
|
|
24609
24836
|
if (!hostFlagStore().getBoolean("restart-doorbell")) {
|
|
24610
24837
|
if (restartReason === MANAGER_RESTART_REASON) {
|
|
24611
24838
|
triggerEarlyPoll(`manager restart for '${codeName}' (fast lane off)`, agentId);
|
|
@@ -24619,7 +24846,7 @@ async function handleRestartDoorbell(agentId, requestedAt, restartReason) {
|
|
|
24619
24846
|
if (!refreshData) return;
|
|
24620
24847
|
const framework = refreshData.agent?.framework ?? agentFrameworkCache.get(codeName) ?? DEFAULT_FRAMEWORK;
|
|
24621
24848
|
const hostId = await getHostId();
|
|
24622
|
-
const parkForRestart = await import("../responsiveness-probe-
|
|
24849
|
+
const parkForRestart = await import("../responsiveness-probe-BUXWVOSA.js").then(
|
|
24623
24850
|
(m) => m.parkPendingInbound,
|
|
24624
24851
|
(err) => err
|
|
24625
24852
|
);
|
|
@@ -24692,7 +24919,7 @@ async function handleRestartDoorbell(agentId, requestedAt, restartReason) {
|
|
|
24692
24919
|
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}`));
|
|
24693
24920
|
void (async () => {
|
|
24694
24921
|
try {
|
|
24695
|
-
const { collectDiagnostics } = await import("../persistent-session-
|
|
24922
|
+
const { collectDiagnostics } = await import("../persistent-session-SYCA6MW2.js");
|
|
24696
24923
|
await api.post("/host/heartbeat", {
|
|
24697
24924
|
host_id: hostId,
|
|
24698
24925
|
agent_diagnostics: collectDiagnostics([codeName], quarantineEntriesFor, claudeMdSizeFor, spawnOutcomeForDiagnostics, pidPressureFor, forwardedToolsFor, runtimeVersionFor, sessionActivityFor)
|
|
@@ -24743,7 +24970,7 @@ async function respawnAgentAfterMcpStop(codeName, reason) {
|
|
|
24743
24970
|
}
|
|
24744
24971
|
try {
|
|
24745
24972
|
const hostId = await getHostId();
|
|
24746
|
-
const { collectDiagnostics } = await import("../persistent-session-
|
|
24973
|
+
const { collectDiagnostics } = await import("../persistent-session-SYCA6MW2.js");
|
|
24747
24974
|
await api.post("/host/heartbeat", {
|
|
24748
24975
|
host_id: hostId,
|
|
24749
24976
|
agent_diagnostics: collectDiagnostics([codeName], quarantineEntriesFor, claudeMdSizeFor, spawnOutcomeForDiagnostics, pidPressureFor, forwardedToolsFor, runtimeVersionFor, sessionActivityFor)
|
|
@@ -25445,7 +25672,7 @@ async function processClaudePairSessions(agents) {
|
|
|
25445
25672
|
snapshotPairConfig,
|
|
25446
25673
|
// ENG-11659: result -> report body + the manager.log line that records it.
|
|
25447
25674
|
planPairStartReport
|
|
25448
|
-
} = await import("../claude-pair-runtime-
|
|
25675
|
+
} = await import("../claude-pair-runtime-SNU3CU3K.js");
|
|
25449
25676
|
const { resetClaudeSignin, describeSigninResetForLog, describeSigninResetFailure } = await import("../claude-signin-reset-6IJMMVYG.js");
|
|
25450
25677
|
for (const pairId of pendingResp.cancelled_pair_ids ?? []) {
|
|
25451
25678
|
log(`[claude-pair] sweeping orphan tmux session for pair ${pairId.slice(0, 8)}`);
|