@integrity-labs/agt-cli 0.21.0 → 0.21.1
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.
|
@@ -22,7 +22,7 @@ import {
|
|
|
22
22
|
resolveChannels,
|
|
23
23
|
resolveDmTarget,
|
|
24
24
|
wrapScheduledTaskPrompt
|
|
25
|
-
} from "../chunk-
|
|
25
|
+
} from "../chunk-NLEW5BPX.js";
|
|
26
26
|
import {
|
|
27
27
|
findTaskByTemplate,
|
|
28
28
|
getProjectDir,
|
|
@@ -92,6 +92,25 @@ function computeIntegrationsHash(integrations) {
|
|
|
92
92
|
|
|
93
93
|
// src/lib/stale-mcp-reaper.ts
|
|
94
94
|
import { execFileSync } from "child_process";
|
|
95
|
+
var rotationTimestamps = /* @__PURE__ */ new Map();
|
|
96
|
+
var DEFAULT_ROTATION_GRACE_MS = 15e3;
|
|
97
|
+
function rotationKey(codeName, serverKey) {
|
|
98
|
+
return `${codeName}\0${serverKey}`;
|
|
99
|
+
}
|
|
100
|
+
function recordStaleRotation(codeName, serverKeys, now = Date.now) {
|
|
101
|
+
const ts = now();
|
|
102
|
+
for (const key of serverKeys) {
|
|
103
|
+
rotationTimestamps.set(rotationKey(codeName, key), ts);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
function wasRecentlyRotated(codeName, serverKey, withinMs, now = Date.now) {
|
|
107
|
+
const k = rotationKey(codeName, serverKey);
|
|
108
|
+
const ts = rotationTimestamps.get(k);
|
|
109
|
+
if (ts === void 0) return false;
|
|
110
|
+
if (now() - ts < withinMs) return true;
|
|
111
|
+
rotationTimestamps.delete(k);
|
|
112
|
+
return false;
|
|
113
|
+
}
|
|
95
114
|
function parseEnvIntegrationsEntries(content) {
|
|
96
115
|
const entries = /* @__PURE__ */ new Map();
|
|
97
116
|
for (const raw of content.split(/\r?\n/)) {
|
|
@@ -264,6 +283,16 @@ function reapStaleMcpChildren(args) {
|
|
|
264
283
|
for (const pid of targets) {
|
|
265
284
|
killProcess(pid, "SIGTERM");
|
|
266
285
|
}
|
|
286
|
+
const killedKeys = /* @__PURE__ */ new Set();
|
|
287
|
+
for (const pid of targets) {
|
|
288
|
+
const argv = byPid.get(pid)?.args ?? "";
|
|
289
|
+
for (const key of serverKeys) {
|
|
290
|
+
const entry = mcpJson?.mcpServers?.[key];
|
|
291
|
+
const matchers = buildArgvMatchersForEntry(key, entry);
|
|
292
|
+
if (matchers.some((re) => re.test(argv))) killedKeys.add(key);
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
if (killedKeys.size > 0) recordStaleRotation(codeName, killedKeys);
|
|
267
296
|
setTimeout(() => {
|
|
268
297
|
try {
|
|
269
298
|
let freshPsOutput;
|
|
@@ -343,6 +372,7 @@ function reapMissingMcpSessions(args) {
|
|
|
343
372
|
sessionStartedAt,
|
|
344
373
|
stopSession,
|
|
345
374
|
graceMs = DEFAULT_COLD_START_GRACE_MS,
|
|
375
|
+
rotationGraceMs = DEFAULT_ROTATION_GRACE_MS,
|
|
346
376
|
onGiveUp,
|
|
347
377
|
onRestart
|
|
348
378
|
} = args;
|
|
@@ -369,13 +399,27 @@ function reapMissingMcpSessions(args) {
|
|
|
369
399
|
return { missing: [], restarted: false, reason: "healthy" };
|
|
370
400
|
}
|
|
371
401
|
const rows = parsePsRows(psOutput);
|
|
372
|
-
const
|
|
402
|
+
const missingRaw = findMissingMcpServers({ rows, codeName, mcpJson });
|
|
403
|
+
const rotationGraced = [];
|
|
404
|
+
const missing = [];
|
|
405
|
+
for (const key of missingRaw) {
|
|
406
|
+
if (wasRecentlyRotated(codeName, key, rotationGraceMs, now)) {
|
|
407
|
+
rotationGraced.push(key);
|
|
408
|
+
} else {
|
|
409
|
+
missing.push(key);
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
if (rotationGraced.length > 0) {
|
|
413
|
+
log2(
|
|
414
|
+
`[mcp-presence-reaper] '${codeName}': skipping [${rotationGraced.join(", ")}] within rotation grace window (${rotationGraceMs}ms) \u2014 child(ren) just SIGTERM'd by stale-mcp-reaper, awaiting respawn on next tool call (ENG-5344)`
|
|
415
|
+
);
|
|
416
|
+
}
|
|
373
417
|
const declared = mcpJson.mcpServers ?? {};
|
|
374
418
|
const liveKeys = /* @__PURE__ */ new Set();
|
|
375
419
|
for (const key of Object.keys(declared)) {
|
|
376
420
|
const entry = declared[key];
|
|
377
421
|
if (typeof entry?.command !== "string") continue;
|
|
378
|
-
if (!
|
|
422
|
+
if (!missingRaw.includes(key)) liveKeys.add(key);
|
|
379
423
|
}
|
|
380
424
|
for (const key of liveKeys) {
|
|
381
425
|
const state2 = presenceReaperState.get(stateKey(codeName, key));
|
|
@@ -387,7 +431,12 @@ function reapMissingMcpSessions(args) {
|
|
|
387
431
|
}
|
|
388
432
|
}
|
|
389
433
|
if (missing.length === 0) {
|
|
390
|
-
return {
|
|
434
|
+
return {
|
|
435
|
+
missing,
|
|
436
|
+
restarted: false,
|
|
437
|
+
reason: "healthy",
|
|
438
|
+
rotationGraced: rotationGraced.length > 0 ? rotationGraced : void 0
|
|
439
|
+
};
|
|
391
440
|
}
|
|
392
441
|
const givenUp = [];
|
|
393
442
|
const active = [];
|
|
@@ -426,7 +475,13 @@ function reapMissingMcpSessions(args) {
|
|
|
426
475
|
}
|
|
427
476
|
}
|
|
428
477
|
if (active.length === 0) {
|
|
429
|
-
return {
|
|
478
|
+
return {
|
|
479
|
+
missing,
|
|
480
|
+
restarted: false,
|
|
481
|
+
reason: "all-keys-over-cap",
|
|
482
|
+
givenUp,
|
|
483
|
+
rotationGraced: rotationGraced.length > 0 ? rotationGraced : void 0
|
|
484
|
+
};
|
|
430
485
|
}
|
|
431
486
|
const givenUpSuffix = givenUp.length > 0 ? ` (skipping over-cap: [${givenUp.join(", ")}])` : "";
|
|
432
487
|
log2(
|
|
@@ -449,7 +504,12 @@ function reapMissingMcpSessions(args) {
|
|
|
449
504
|
}
|
|
450
505
|
}
|
|
451
506
|
stopSession(codeName);
|
|
452
|
-
return {
|
|
507
|
+
return {
|
|
508
|
+
missing,
|
|
509
|
+
restarted: true,
|
|
510
|
+
givenUp: givenUp.length > 0 ? givenUp : void 0,
|
|
511
|
+
rotationGraced: rotationGraced.length > 0 ? rotationGraced : void 0
|
|
512
|
+
};
|
|
453
513
|
}
|
|
454
514
|
|
|
455
515
|
// src/lib/channel-restart-decision.ts
|
|
@@ -2338,7 +2398,7 @@ function clearAgentCaches(agentId, codeName) {
|
|
|
2338
2398
|
var cachedFrameworkVersion = null;
|
|
2339
2399
|
var lastVersionCheckAt = 0;
|
|
2340
2400
|
var VERSION_CHECK_INTERVAL_MS = 5 * 60 * 1e3;
|
|
2341
|
-
var agtCliVersion = true ? "0.21.
|
|
2401
|
+
var agtCliVersion = true ? "0.21.1" : "dev";
|
|
2342
2402
|
function resolveBrewPath(execFileSync4) {
|
|
2343
2403
|
try {
|
|
2344
2404
|
const out = execFileSync4("which", ["brew"], { timeout: 5e3 }).toString().trim();
|