@integrity-labs/agt-cli 0.14.5 → 0.14.7
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.
|
@@ -18,7 +18,7 @@ import {
|
|
|
18
18
|
resolveChannels,
|
|
19
19
|
resolveDmTarget,
|
|
20
20
|
wrapScheduledTaskPrompt
|
|
21
|
-
} from "../chunk-
|
|
21
|
+
} from "../chunk-5SFAHM2Z.js";
|
|
22
22
|
import {
|
|
23
23
|
findTaskByTemplate,
|
|
24
24
|
getProjectDir,
|
|
@@ -1002,6 +1002,7 @@ var knownChannelConfigHashes = /* @__PURE__ */ new Map();
|
|
|
1002
1002
|
var knownModels = /* @__PURE__ */ new Map();
|
|
1003
1003
|
var knownTasksHashes = /* @__PURE__ */ new Map();
|
|
1004
1004
|
var knownIntegrationHashes = /* @__PURE__ */ new Map();
|
|
1005
|
+
var knownManagedMcpHashes = /* @__PURE__ */ new Map();
|
|
1005
1006
|
var knownSkillHashes = /* @__PURE__ */ new Map();
|
|
1006
1007
|
var lastCronRunTs = /* @__PURE__ */ new Map();
|
|
1007
1008
|
var lastWorkTriggerAt = /* @__PURE__ */ new Map();
|
|
@@ -1042,6 +1043,7 @@ function clearAgentCaches(agentId, codeName) {
|
|
|
1042
1043
|
knownModels.delete(agentId);
|
|
1043
1044
|
knownTasksHashes.delete(agentId);
|
|
1044
1045
|
knownIntegrationHashes.delete(agentId);
|
|
1046
|
+
knownManagedMcpHashes.delete(agentId);
|
|
1045
1047
|
agentDisplayNames.delete(codeName);
|
|
1046
1048
|
codeNameToAgentId.delete(codeName);
|
|
1047
1049
|
agentFrameworkCache.delete(codeName);
|
|
@@ -1221,6 +1223,7 @@ async function ensureFrameworkBinary(frameworkId) {
|
|
|
1221
1223
|
agentRuntimeAuthenticated = await checkClaudeAuth();
|
|
1222
1224
|
}
|
|
1223
1225
|
var UPDATE_CHECK_INTERVAL_MS = 5 * 60 * 1e3;
|
|
1226
|
+
var selfUpdateUpToDateLogged = false;
|
|
1224
1227
|
async function checkAndUpdateCli() {
|
|
1225
1228
|
const cliPath = process.argv[1] ?? "";
|
|
1226
1229
|
const isHomebrew = cliPath.includes("/Cellar/") || cliPath.includes("/homebrew/");
|
|
@@ -1267,8 +1270,9 @@ async function checkAndUpdateCli() {
|
|
|
1267
1270
|
} catch (err) {
|
|
1268
1271
|
log(`[self-update] Upgrade failed: ${err.message}`);
|
|
1269
1272
|
}
|
|
1270
|
-
} else {
|
|
1273
|
+
} else if (!selfUpdateUpToDateLogged) {
|
|
1271
1274
|
log(`[self-update] agt CLI is up to date`);
|
|
1275
|
+
selfUpdateUpToDateLogged = true;
|
|
1272
1276
|
}
|
|
1273
1277
|
} catch (err) {
|
|
1274
1278
|
log(`[self-update] brew outdated failed: ${err.message}`);
|
|
@@ -1717,6 +1721,7 @@ Automatic restart failed: ${err.message}`
|
|
|
1717
1721
|
}
|
|
1718
1722
|
async function pollCycle() {
|
|
1719
1723
|
if (!config) return;
|
|
1724
|
+
checkAndUpdateCli().catch((err) => log(`[self-update] Check failed: ${err.message}`));
|
|
1720
1725
|
try {
|
|
1721
1726
|
registeredAgentsCache.clear();
|
|
1722
1727
|
gatewaysStartedThisCycle.clear();
|
|
@@ -2438,27 +2443,42 @@ async function processAgent(agent, agentStates) {
|
|
|
2438
2443
|
});
|
|
2439
2444
|
log(`[hot-reload] Notified '${agent.code_name}' about integration update: ${names}`);
|
|
2440
2445
|
}
|
|
2441
|
-
|
|
2442
|
-
|
|
2443
|
-
|
|
2444
|
-
|
|
2445
|
-
|
|
2446
|
-
|
|
2447
|
-
|
|
2448
|
-
|
|
2449
|
-
|
|
2450
|
-
|
|
2451
|
-
|
|
2452
|
-
|
|
2453
|
-
|
|
2454
|
-
|
|
2455
|
-
|
|
2456
|
-
|
|
2457
|
-
|
|
2446
|
+
needsGatewayRestart = true;
|
|
2447
|
+
}
|
|
2448
|
+
}
|
|
2449
|
+
const fwForMcp = agentFrameworkCache.get(agent.code_name) ?? "openclaw";
|
|
2450
|
+
if (frameworkAdapter.writeMcpServer) {
|
|
2451
|
+
try {
|
|
2452
|
+
const toolkitData = await api.post("/host/managed-toolkits", { agent_ids: [agent.agent_id] });
|
|
2453
|
+
const agentToolkits = (toolkitData.toolkits ?? []).filter((tk) => tk.agent_id === agent.agent_id);
|
|
2454
|
+
const expectedServerIds = /* @__PURE__ */ new Set();
|
|
2455
|
+
const desiredEntries = [];
|
|
2456
|
+
for (const tk of agentToolkits) {
|
|
2457
|
+
const serverId = tk.toolkit_id.replace(/[^a-z0-9]/gi, "_").toLowerCase();
|
|
2458
|
+
expectedServerIds.add(serverId);
|
|
2459
|
+
const mcpUrl = tk.mcp_url;
|
|
2460
|
+
const mcpHeaders = tk.mcp_headers;
|
|
2461
|
+
const proxyUrl = tk.proxy_url.startsWith("/") ? `${requireHost()}${tk.proxy_url}` : tk.proxy_url;
|
|
2462
|
+
const url = mcpUrl ?? proxyUrl;
|
|
2463
|
+
desiredEntries.push({ serverId, url, headers: mcpHeaders, name: tk.toolkit_name });
|
|
2464
|
+
}
|
|
2465
|
+
const hashBasis = desiredEntries.slice().sort((a, b) => a.serverId.localeCompare(b.serverId)).map((e) => {
|
|
2466
|
+
const headersHash = createHash("sha256").update(canonicalJson(e.headers ?? {})).digest("hex").slice(0, 16);
|
|
2467
|
+
return `${e.serverId}|${e.url}|${headersHash}`;
|
|
2468
|
+
}).join("\n");
|
|
2469
|
+
const mcpHash = createHash("sha256").update(hashBasis).digest("hex").slice(0, 16);
|
|
2470
|
+
const prevMcpHash = knownManagedMcpHashes.get(agent.agent_id);
|
|
2471
|
+
if (mcpHash !== prevMcpHash) {
|
|
2472
|
+
for (const e of desiredEntries) {
|
|
2473
|
+
frameworkAdapter.writeMcpServer(agent.code_name, e.serverId, { url: e.url, headers: e.headers });
|
|
2474
|
+
const urlHash = createHash("sha256").update(e.url).digest("hex").slice(0, 12);
|
|
2475
|
+
log(`[managed-toolkit] ${agent.code_name}: wrote '${e.name}' (serverId=${e.serverId}, url_hash=${urlHash})`);
|
|
2476
|
+
}
|
|
2477
|
+
if (frameworkAdapter.removeMcpServer && frameworkAdapter.getMcpPath) {
|
|
2478
|
+
const mcpPath = frameworkAdapter.getMcpPath(agent.code_name);
|
|
2479
|
+
if (mcpPath) {
|
|
2458
2480
|
try {
|
|
2459
2481
|
const { readFileSync: readFileSync2 } = await import("fs");
|
|
2460
|
-
const { join: join3 } = await import("path");
|
|
2461
|
-
const mcpPath = join3(frameworkAdapter.getAgentDir(agent.code_name), "provision", ".mcp.json");
|
|
2462
2482
|
const mcpConfig = JSON.parse(readFileSync2(mcpPath, "utf-8"));
|
|
2463
2483
|
if (mcpConfig.mcpServers) {
|
|
2464
2484
|
const managedPrefixes = [
|
|
@@ -2467,7 +2487,6 @@ async function processAgent(agent, agentStates) {
|
|
|
2467
2487
|
"pipedream_",
|
|
2468
2488
|
"nango_",
|
|
2469
2489
|
"paragon_",
|
|
2470
|
-
// Legacy hyphenated format
|
|
2471
2490
|
"composio-",
|
|
2472
2491
|
"one-",
|
|
2473
2492
|
"pipedream-",
|
|
@@ -2484,30 +2503,31 @@ async function processAgent(agent, agentStates) {
|
|
|
2484
2503
|
} catch {
|
|
2485
2504
|
}
|
|
2486
2505
|
}
|
|
2487
|
-
} catch (err) {
|
|
2488
|
-
log(`[managed-toolkit] Failed to provision for '${agent.code_name}': ${err.message}`);
|
|
2489
2506
|
}
|
|
2490
|
-
|
|
2491
|
-
|
|
2492
|
-
|
|
2493
|
-
|
|
2494
|
-
|
|
2495
|
-
|
|
2496
|
-
|
|
2497
|
-
|
|
2498
|
-
|
|
2499
|
-
|
|
2500
|
-
|
|
2501
|
-
|
|
2502
|
-
|
|
2503
|
-
|
|
2504
|
-
|
|
2507
|
+
knownManagedMcpHashes.set(agent.agent_id, mcpHash);
|
|
2508
|
+
if (prevMcpHash !== void 0 && fwForMcp === "claude-code" && isSessionHealthy(agent.code_name)) {
|
|
2509
|
+
const mcpNames = agentToolkits.map((tk) => tk.toolkit_name).join(", ") || "none (all removed)";
|
|
2510
|
+
log(`[hot-reload] MCP servers changed for '${agent.code_name}': ${mcpNames} \u2014 restarting session`);
|
|
2511
|
+
const restartNotice = agentToolkits.length > 0 ? `New MCP tool servers have been configured: ${mcpNames}. Note: MCP servers require a session restart to connect. Your manager will restart your session shortly.` : "Managed MCP tool servers were removed. Your manager will restart your session shortly so the session drops those tools.";
|
|
2512
|
+
const delivered = await injectMessage(
|
|
2513
|
+
agent.code_name,
|
|
2514
|
+
"system",
|
|
2515
|
+
restartNotice,
|
|
2516
|
+
{ task_name: "mcp-update" },
|
|
2517
|
+
log
|
|
2518
|
+
).catch(() => false);
|
|
2519
|
+
const delay = delivered ? 8e3 : 3e3;
|
|
2520
|
+
if (!delivered) {
|
|
2521
|
+
log(`[hot-reload] Inject notification unconfirmed for '${agent.code_name}' \u2014 proceeding with shorter delay`);
|
|
2522
|
+
}
|
|
2523
|
+
setTimeout(() => {
|
|
2524
|
+
stopPersistentSession(agent.code_name, log);
|
|
2525
|
+
log(`[hot-reload] Session stopped for '${agent.code_name}' \u2014 will respawn with new MCP servers`);
|
|
2526
|
+
}, delay);
|
|
2505
2527
|
}
|
|
2506
|
-
setTimeout(() => {
|
|
2507
|
-
stopPersistentSession(agent.code_name, log);
|
|
2508
|
-
log(`[hot-reload] Session stopped for '${agent.code_name}' \u2014 will respawn with new MCP servers`);
|
|
2509
|
-
}, delay);
|
|
2510
2528
|
}
|
|
2529
|
+
} catch (err) {
|
|
2530
|
+
log(`[managed-toolkit] Failed to provision for '${agent.code_name}': ${err.message}`);
|
|
2511
2531
|
}
|
|
2512
2532
|
}
|
|
2513
2533
|
} catch (err) {
|
|
@@ -4992,7 +5012,6 @@ function startPolling() {
|
|
|
4992
5012
|
running = true;
|
|
4993
5013
|
void startCaffeinate();
|
|
4994
5014
|
log(`Starting poll loop (interval=${config.intervalMs}ms, configDir=${config.configDir})`);
|
|
4995
|
-
checkAndUpdateCli().catch((err) => log(`[self-update] Check failed: ${err.message}`));
|
|
4996
5015
|
void killAllAgtTmuxSessions().catch(() => {
|
|
4997
5016
|
}).then(() => migrateToProfiles()).then(() => {
|
|
4998
5017
|
startGatewayPool();
|