@integrity-labs/agt-cli 0.28.490 → 0.28.492

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 CHANGED
@@ -40,7 +40,7 @@ import {
40
40
  success,
41
41
  table,
42
42
  warn
43
- } from "../chunk-DNRXJESD.js";
43
+ } from "../chunk-KB5KVAWJ.js";
44
44
  import {
45
45
  AnchorSessionClient,
46
46
  CHANNEL_REGISTRY,
@@ -4830,7 +4830,7 @@ import { execFileSync, execSync } from "child_process";
4830
4830
  import { existsSync as existsSync10, realpathSync as realpathSync2 } from "fs";
4831
4831
  import chalk18 from "chalk";
4832
4832
  import ora16 from "ora";
4833
- var cliVersion = true ? "0.28.490" : "dev";
4833
+ var cliVersion = true ? "0.28.492" : "dev";
4834
4834
  async function fetchLatestVersion() {
4835
4835
  const host2 = getHost();
4836
4836
  if (!host2) return null;
@@ -6002,7 +6002,7 @@ function handleError(err) {
6002
6002
  }
6003
6003
 
6004
6004
  // src/bin/agt.ts
6005
- var cliVersion2 = true ? "0.28.490" : "dev";
6005
+ var cliVersion2 = true ? "0.28.492" : "dev";
6006
6006
  var program = new Command();
6007
6007
  program.name("agt").description("Augmented CLI \u2014 agent provisioning and management").version(cliVersion2).option("--json", "Emit machine-readable JSON output (suppress spinners and colors)").option("--skip-update-check", "Skip the automatic update check on startup");
6008
6008
  program.hook("preAction", async (thisCommand, actionCommand) => {
@@ -4964,7 +4964,7 @@ function exchangeFailureKind(err) {
4964
4964
  }
4965
4965
 
4966
4966
  // src/lib/api-client.ts
4967
- var agtCliVersion = true ? "0.28.490" : "dev";
4967
+ var agtCliVersion = true ? "0.28.492" : "dev";
4968
4968
  var lastConfigHash = null;
4969
4969
  function setConfigHash(hash) {
4970
4970
  lastConfigHash = hash && hash.length > 0 ? hash : null;
@@ -6417,6 +6417,156 @@ function runCliProbe(binary, args, opts = {}) {
6417
6417
  });
6418
6418
  }
6419
6419
 
6420
+ // src/lib/session-tool-probe.ts
6421
+ function classifyMcpServer(entry) {
6422
+ if (!entry || typeof entry !== "object") return "unknown";
6423
+ const e = entry;
6424
+ if (typeof e.command === "string") {
6425
+ const env = e.env;
6426
+ if (env && typeof env === "object" && typeof env["AGT_REMOTE_MCP_URL"] === "string" && typeof env["AGT_REMOTE_MCP_TOKEN_VAR"] === "string") {
6427
+ return "oauth-proxy";
6428
+ }
6429
+ return "stdio";
6430
+ }
6431
+ if (typeof e.url === "string") return "http";
6432
+ return "unknown";
6433
+ }
6434
+ function splitServerKeysByKind(mcpJson, serverKeys) {
6435
+ const servers = mcpJson?.mcpServers ?? {};
6436
+ const stdio = [];
6437
+ const http = [];
6438
+ const proxy = [];
6439
+ for (const key of serverKeys) {
6440
+ const kind = classifyMcpServer(servers[key]);
6441
+ if (kind === "stdio") stdio.push(key);
6442
+ else if (kind === "http") http.push(key);
6443
+ else if (kind === "oauth-proxy") proxy.push(key);
6444
+ }
6445
+ return { stdio, http, proxy };
6446
+ }
6447
+ function computeSessionToolBindStatus(input) {
6448
+ const {
6449
+ stdioServerKeys,
6450
+ httpServerKeys,
6451
+ proxyServerKeys,
6452
+ missingStdioKeys,
6453
+ httpReachable,
6454
+ sessionLoadedServerKeys
6455
+ } = input;
6456
+ if (stdioServerKeys.length === 0 && httpServerKeys.length === 0 && proxyServerKeys.length === 0)
6457
+ return "unknown";
6458
+ if (stdioServerKeys.some((k) => missingStdioKeys.has(k))) return "missing";
6459
+ if (proxyServerKeys.some((k) => missingStdioKeys.has(k))) return "missing";
6460
+ for (const k of proxyServerKeys) {
6461
+ if (httpReachable.get(k) === false) return "unreachable";
6462
+ }
6463
+ let anyHttpUnconfirmed = false;
6464
+ for (const k of httpServerKeys) {
6465
+ if (!sessionLoadedServerKeys.has(k)) {
6466
+ anyHttpUnconfirmed = true;
6467
+ continue;
6468
+ }
6469
+ const reachable = httpReachable.get(k);
6470
+ if (reachable === false) return "unreachable";
6471
+ if (reachable === void 0) anyHttpUnconfirmed = true;
6472
+ }
6473
+ if (anyHttpUnconfirmed && stdioServerKeys.length === 0 && proxyServerKeys.length === 0)
6474
+ return "unknown";
6475
+ return "bound";
6476
+ }
6477
+
6478
+ // src/lib/session-tool-bind-runner.ts
6479
+ var DEFAULT_INTERVAL_MS = 60 * 60 * 1e3;
6480
+ var DEFAULT_MAX_PER_RUN = 25;
6481
+ function sanitizeServerKey(definitionId) {
6482
+ return definitionId.replace(/[^a-z0-9]/gi, "_").toLowerCase();
6483
+ }
6484
+ function resolveIntegrationServerKeys(definitionId, declaredKeys, hint) {
6485
+ const declared = new Set(declaredKeys);
6486
+ const candidates = [hint, definitionId, sanitizeServerKey(definitionId)].filter(
6487
+ (k) => typeof k === "string" && k.length > 0
6488
+ );
6489
+ const out = /* @__PURE__ */ new Set();
6490
+ for (const c of candidates) if (declared.has(c)) out.add(c);
6491
+ return [...out];
6492
+ }
6493
+ function isDue(last, now, intervalMs) {
6494
+ if (!last) return true;
6495
+ const t = Date.parse(last);
6496
+ if (Number.isNaN(t)) return true;
6497
+ return now - t >= intervalMs;
6498
+ }
6499
+ async function runSessionToolBindProbes(integrations, options) {
6500
+ const now = (options.now?.() ?? /* @__PURE__ */ new Date()).getTime();
6501
+ const intervalMs = options.intervalMs ?? DEFAULT_INTERVAL_MS;
6502
+ const maxPerRun = options.maxPerRun ?? DEFAULT_MAX_PER_RUN;
6503
+ const due = integrations.filter((i) => isDue(i.last_session_tool_bind_at, now, intervalMs)).sort((a, b) => {
6504
+ const ta = a.last_session_tool_bind_at ? Date.parse(a.last_session_tool_bind_at) : 0;
6505
+ const tb = b.last_session_tool_bind_at ? Date.parse(b.last_session_tool_bind_at) : 0;
6506
+ return ta - tb;
6507
+ });
6508
+ const batch = due.slice(0, maxPerRun);
6509
+ const declaredKeys = Object.keys(options.mcpJson?.mcpServers ?? {});
6510
+ const reports = [];
6511
+ const rebindCandidates = [];
6512
+ let skipped = 0;
6513
+ let probed = 0;
6514
+ for (const integ of batch) {
6515
+ const keys = resolveIntegrationServerKeys(
6516
+ integ.definition_id,
6517
+ declaredKeys,
6518
+ integ.mcp_server_key
6519
+ );
6520
+ if (keys.length === 0) {
6521
+ skipped += 1;
6522
+ continue;
6523
+ }
6524
+ probed += 1;
6525
+ const { stdio, http, proxy } = splitServerKeysByKind(options.mcpJson, keys);
6526
+ const httpReachable = /* @__PURE__ */ new Map();
6527
+ for (const key of [...http, ...proxy]) {
6528
+ let reachable;
6529
+ try {
6530
+ reachable = await options.probeHttp(key);
6531
+ } catch {
6532
+ reachable = void 0;
6533
+ }
6534
+ if (reachable !== void 0) httpReachable.set(key, reachable);
6535
+ }
6536
+ const status = computeSessionToolBindStatus({
6537
+ stdioServerKeys: stdio,
6538
+ httpServerKeys: http,
6539
+ proxyServerKeys: proxy,
6540
+ missingStdioKeys: options.missingStdioKeys,
6541
+ httpReachable,
6542
+ sessionLoadedServerKeys: options.sessionLoadedServerKeys ?? /* @__PURE__ */ new Set()
6543
+ });
6544
+ if (status === "unknown") {
6545
+ skipped += 1;
6546
+ continue;
6547
+ }
6548
+ reports.push({ integration_id: integ.id, scope: integ.scope, status });
6549
+ if (status === "missing" || status === "unreachable") {
6550
+ const failingKeys = /* @__PURE__ */ new Set();
6551
+ for (const k of [...stdio, ...proxy]) {
6552
+ if (options.missingStdioKeys.has(k)) failingKeys.add(k);
6553
+ }
6554
+ for (const k of proxy) {
6555
+ if (httpReachable.get(k) === false) failingKeys.add(k);
6556
+ }
6557
+ if (failingKeys.size > 0) {
6558
+ rebindCandidates.push({
6559
+ integration_id: integ.id,
6560
+ scope: integ.scope,
6561
+ status,
6562
+ serverKeys: [...failingKeys]
6563
+ });
6564
+ }
6565
+ }
6566
+ }
6567
+ return { reports, rebindCandidates, due: due.length, probed, skipped };
6568
+ }
6569
+
6420
6570
  // src/lib/connectivity-probe-context.ts
6421
6571
  function resolveHttpServerEntry(entry, env) {
6422
6572
  const unresolved = /* @__PURE__ */ new Set();
@@ -6455,6 +6605,19 @@ function readMcpHttpServerConfig(projectDir, serverKey, env) {
6455
6605
  return null;
6456
6606
  }
6457
6607
  }
6608
+ function resolveDeclaredServerKey(projectDir, definitionId, derivedKey) {
6609
+ try {
6610
+ const raw = readFileSync6(join5(projectDir, ".mcp.json"), "utf-8");
6611
+ const servers = JSON.parse(raw).mcpServers ?? {};
6612
+ const declared = Object.keys(servers);
6613
+ if (derivedKey !== definitionId && derivedKey !== sanitizeServerKey(definitionId)) {
6614
+ return declared.includes(derivedKey) ? derivedKey : null;
6615
+ }
6616
+ return resolveIntegrationServerKeys(definitionId, declared, derivedKey)[0] ?? null;
6617
+ } catch {
6618
+ return null;
6619
+ }
6620
+ }
6458
6621
  function resolveStdioServerEntry(entry, env) {
6459
6622
  if (typeof entry.command !== "string") return null;
6460
6623
  const unresolved = /* @__PURE__ */ new Set();
@@ -6522,15 +6685,16 @@ function buildConnectivityProbeDeps(projectDir, probeEnv) {
6522
6685
  fetchImpl: fetch,
6523
6686
  runCli: (binary, args) => runCliProbe(binary, args, { env: probeEnv }),
6524
6687
  mcpProbe: async (target) => {
6525
- const cfg = target.inlineServerEntry ? resolveHttpServerEntry(target.inlineServerEntry, probeEnv) : readMcpHttpServerConfig(projectDir, target.serverKey, probeEnv);
6688
+ const serverKey = target.inlineServerEntry ? target.serverKey : resolveDeclaredServerKey(projectDir, target.definitionId, target.serverKey) ?? target.serverKey;
6689
+ const cfg = target.inlineServerEntry ? resolveHttpServerEntry(target.inlineServerEntry, probeEnv) : readMcpHttpServerConfig(projectDir, serverKey, probeEnv);
6526
6690
  if (!cfg) {
6527
6691
  const src = target.inlineServerEntry ? "inline config" : ".mcp.json";
6528
- return { status: "transient_error", message: `MCP server '${target.serverKey}' not resolvable from ${src}` };
6692
+ return { status: "transient_error", message: `MCP server '${serverKey}' not resolvable from ${src}` };
6529
6693
  }
6530
6694
  if (cfg.unresolved.length > 0) {
6531
6695
  return {
6532
6696
  status: "transient_error",
6533
- message: `MCP '${target.serverKey}' auth unresolved: ${cfg.unresolved.join(", ")}`
6697
+ message: `MCP '${serverKey}' auth unresolved: ${cfg.unresolved.join(", ")}`
6534
6698
  };
6535
6699
  }
6536
6700
  return probeMcpHttp(cfg);
@@ -6542,15 +6706,16 @@ function buildConnectivityProbeDeps(projectDir, probeEnv) {
6542
6706
  // env → skip as non-escalating, never spawn a doomed server. A missing
6543
6707
  // server entry is a real `down` — the tools aren't wired.
6544
6708
  mcpStdioProbe: async (target) => {
6545
- const cfg = target.inlineServerEntry ? resolveStdioServerEntry(target.inlineServerEntry, probeEnv) : readMcpStdioServerConfig(projectDir, target.serverKey, probeEnv);
6709
+ const serverKey = target.inlineServerEntry ? target.serverKey : resolveDeclaredServerKey(projectDir, target.definitionId, target.serverKey) ?? target.serverKey;
6710
+ const cfg = target.inlineServerEntry ? resolveStdioServerEntry(target.inlineServerEntry, probeEnv) : readMcpStdioServerConfig(projectDir, serverKey, probeEnv);
6546
6711
  if (!cfg) {
6547
6712
  const src = target.inlineServerEntry ? "inline config" : ".mcp.json";
6548
- return { status: "down", message: `MCP stdio server '${target.serverKey}' not wired in ${src}` };
6713
+ return { status: "down", message: `MCP stdio server '${serverKey}' not wired in ${src}` };
6549
6714
  }
6550
6715
  if (cfg.unresolved.length > 0) {
6551
6716
  return {
6552
6717
  status: "transient_error",
6553
- message: `MCP stdio '${target.serverKey}' env unresolved: ${cfg.unresolved.join(", ")}`
6718
+ message: `MCP stdio '${serverKey}' env unresolved: ${cfg.unresolved.join(", ")}`
6554
6719
  };
6555
6720
  }
6556
6721
  return probeMcpStdio({
@@ -6615,158 +6780,6 @@ function buildConnectivityProbeDeps(projectDir, probeEnv) {
6615
6780
  import { execFileSync as syncExecFile } from "child_process";
6616
6781
  import { readFileSync as readFileSync7 } from "fs";
6617
6782
  import { join as join6 } from "path";
6618
-
6619
- // src/lib/session-tool-probe.ts
6620
- function classifyMcpServer(entry) {
6621
- if (!entry || typeof entry !== "object") return "unknown";
6622
- const e = entry;
6623
- if (typeof e.command === "string") {
6624
- const env = e.env;
6625
- if (env && typeof env === "object" && typeof env["AGT_REMOTE_MCP_URL"] === "string" && typeof env["AGT_REMOTE_MCP_TOKEN_VAR"] === "string") {
6626
- return "oauth-proxy";
6627
- }
6628
- return "stdio";
6629
- }
6630
- if (typeof e.url === "string") return "http";
6631
- return "unknown";
6632
- }
6633
- function splitServerKeysByKind(mcpJson, serverKeys) {
6634
- const servers = mcpJson?.mcpServers ?? {};
6635
- const stdio = [];
6636
- const http = [];
6637
- const proxy = [];
6638
- for (const key of serverKeys) {
6639
- const kind = classifyMcpServer(servers[key]);
6640
- if (kind === "stdio") stdio.push(key);
6641
- else if (kind === "http") http.push(key);
6642
- else if (kind === "oauth-proxy") proxy.push(key);
6643
- }
6644
- return { stdio, http, proxy };
6645
- }
6646
- function computeSessionToolBindStatus(input) {
6647
- const {
6648
- stdioServerKeys,
6649
- httpServerKeys,
6650
- proxyServerKeys,
6651
- missingStdioKeys,
6652
- httpReachable,
6653
- sessionLoadedServerKeys
6654
- } = input;
6655
- if (stdioServerKeys.length === 0 && httpServerKeys.length === 0 && proxyServerKeys.length === 0)
6656
- return "unknown";
6657
- if (stdioServerKeys.some((k) => missingStdioKeys.has(k))) return "missing";
6658
- if (proxyServerKeys.some((k) => missingStdioKeys.has(k))) return "missing";
6659
- for (const k of proxyServerKeys) {
6660
- if (httpReachable.get(k) === false) return "unreachable";
6661
- }
6662
- let anyHttpUnconfirmed = false;
6663
- for (const k of httpServerKeys) {
6664
- if (!sessionLoadedServerKeys.has(k)) {
6665
- anyHttpUnconfirmed = true;
6666
- continue;
6667
- }
6668
- const reachable = httpReachable.get(k);
6669
- if (reachable === false) return "unreachable";
6670
- if (reachable === void 0) anyHttpUnconfirmed = true;
6671
- }
6672
- if (anyHttpUnconfirmed && stdioServerKeys.length === 0 && proxyServerKeys.length === 0)
6673
- return "unknown";
6674
- return "bound";
6675
- }
6676
-
6677
- // src/lib/session-tool-bind-runner.ts
6678
- var DEFAULT_INTERVAL_MS = 60 * 60 * 1e3;
6679
- var DEFAULT_MAX_PER_RUN = 25;
6680
- function sanitizeServerKey(definitionId) {
6681
- return definitionId.replace(/[^a-z0-9]/gi, "_").toLowerCase();
6682
- }
6683
- function resolveIntegrationServerKeys(definitionId, declaredKeys, hint) {
6684
- const declared = new Set(declaredKeys);
6685
- const candidates = [hint, definitionId, sanitizeServerKey(definitionId)].filter(
6686
- (k) => typeof k === "string" && k.length > 0
6687
- );
6688
- const out = /* @__PURE__ */ new Set();
6689
- for (const c of candidates) if (declared.has(c)) out.add(c);
6690
- return [...out];
6691
- }
6692
- function isDue(last, now, intervalMs) {
6693
- if (!last) return true;
6694
- const t = Date.parse(last);
6695
- if (Number.isNaN(t)) return true;
6696
- return now - t >= intervalMs;
6697
- }
6698
- async function runSessionToolBindProbes(integrations, options) {
6699
- const now = (options.now?.() ?? /* @__PURE__ */ new Date()).getTime();
6700
- const intervalMs = options.intervalMs ?? DEFAULT_INTERVAL_MS;
6701
- const maxPerRun = options.maxPerRun ?? DEFAULT_MAX_PER_RUN;
6702
- const due = integrations.filter((i) => isDue(i.last_session_tool_bind_at, now, intervalMs)).sort((a, b) => {
6703
- const ta = a.last_session_tool_bind_at ? Date.parse(a.last_session_tool_bind_at) : 0;
6704
- const tb = b.last_session_tool_bind_at ? Date.parse(b.last_session_tool_bind_at) : 0;
6705
- return ta - tb;
6706
- });
6707
- const batch = due.slice(0, maxPerRun);
6708
- const declaredKeys = Object.keys(options.mcpJson?.mcpServers ?? {});
6709
- const reports = [];
6710
- const rebindCandidates = [];
6711
- let skipped = 0;
6712
- let probed = 0;
6713
- for (const integ of batch) {
6714
- const keys = resolveIntegrationServerKeys(
6715
- integ.definition_id,
6716
- declaredKeys,
6717
- integ.mcp_server_key
6718
- );
6719
- if (keys.length === 0) {
6720
- skipped += 1;
6721
- continue;
6722
- }
6723
- probed += 1;
6724
- const { stdio, http, proxy } = splitServerKeysByKind(options.mcpJson, keys);
6725
- const httpReachable = /* @__PURE__ */ new Map();
6726
- for (const key of [...http, ...proxy]) {
6727
- let reachable;
6728
- try {
6729
- reachable = await options.probeHttp(key);
6730
- } catch {
6731
- reachable = void 0;
6732
- }
6733
- if (reachable !== void 0) httpReachable.set(key, reachable);
6734
- }
6735
- const status = computeSessionToolBindStatus({
6736
- stdioServerKeys: stdio,
6737
- httpServerKeys: http,
6738
- proxyServerKeys: proxy,
6739
- missingStdioKeys: options.missingStdioKeys,
6740
- httpReachable,
6741
- sessionLoadedServerKeys: options.sessionLoadedServerKeys ?? /* @__PURE__ */ new Set()
6742
- });
6743
- if (status === "unknown") {
6744
- skipped += 1;
6745
- continue;
6746
- }
6747
- reports.push({ integration_id: integ.id, scope: integ.scope, status });
6748
- if (status === "missing" || status === "unreachable") {
6749
- const failingKeys = /* @__PURE__ */ new Set();
6750
- for (const k of [...stdio, ...proxy]) {
6751
- if (options.missingStdioKeys.has(k)) failingKeys.add(k);
6752
- }
6753
- for (const k of proxy) {
6754
- if (httpReachable.get(k) === false) failingKeys.add(k);
6755
- }
6756
- if (failingKeys.size > 0) {
6757
- rebindCandidates.push({
6758
- integration_id: integ.id,
6759
- scope: integ.scope,
6760
- status,
6761
- serverKeys: [...failingKeys]
6762
- });
6763
- }
6764
- }
6765
- }
6766
- return { reports, rebindCandidates, due: due.length, probed, skipped };
6767
- }
6768
-
6769
- // src/lib/session-tool-bind-probe-host.ts
6770
6783
  async function gatherSessionToolBindProbe(agent, integrations, projectDir, opts) {
6771
6784
  if (integrations.length === 0) return null;
6772
6785
  let mcpJson = null;
@@ -7699,4 +7712,4 @@ export {
7699
7712
  managerInstallSystemUnitCommand,
7700
7713
  managerUninstallSystemUnitCommand
7701
7714
  };
7702
- //# sourceMappingURL=chunk-DNRXJESD.js.map
7715
+ //# sourceMappingURL=chunk-KB5KVAWJ.js.map