@integrity-labs/agt-cli 0.28.1219 → 0.28.1221

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.
Files changed (29) hide show
  1. package/dist/bin/agt.js +6 -6
  2. package/dist/{chunk-F5R622EX.js → chunk-QGBIF6QK.js} +3 -3
  3. package/dist/{chunk-MJXBNSJY.js → chunk-R7UGBRUR.js} +12 -1
  4. package/dist/{chunk-MJXBNSJY.js.map → chunk-R7UGBRUR.js.map} +1 -1
  5. package/dist/{chunk-QGMGROLF.js → chunk-U5CKO3OD.js} +5 -5
  6. package/dist/{chunk-QI5C2VCI.js → chunk-WXJXO5TE.js} +2 -2
  7. package/dist/{chunk-HAQXH2J4.js → chunk-YR5PKAAL.js} +2 -2
  8. package/dist/{claude-code-updater-XZTIAQQ3.js → claude-code-updater-FWBF4JTA.js} +3 -3
  9. package/dist/{claude-pair-runtime-N7TZVTF7.js → claude-pair-runtime-6BSR5RTE.js} +3 -3
  10. package/dist/lib/manager-worker.js +26 -20
  11. package/dist/lib/manager-worker.js.map +1 -1
  12. package/dist/mcp/direct-chat-channel.js +11 -0
  13. package/dist/mcp/index.js +208 -25
  14. package/dist/mcp/origami.js +11 -0
  15. package/dist/mcp/slack-channel.js +11 -0
  16. package/dist/mcp/telegram-channel.js +11 -0
  17. package/dist/{persistent-session-NQMAJQF2.js → persistent-session-YMVE4OG5.js} +4 -4
  18. package/dist/{responsiveness-probe-JGMZCQCI.js → responsiveness-probe-DD7LCTAS.js} +4 -4
  19. package/dist/{session-auth-dead-DPMMX7QL.js → session-auth-dead-QZOUWP4O.js} +3 -3
  20. package/package.json +1 -1
  21. /package/dist/{chunk-F5R622EX.js.map → chunk-QGBIF6QK.js.map} +0 -0
  22. /package/dist/{chunk-QGMGROLF.js.map → chunk-U5CKO3OD.js.map} +0 -0
  23. /package/dist/{chunk-QI5C2VCI.js.map → chunk-WXJXO5TE.js.map} +0 -0
  24. /package/dist/{chunk-HAQXH2J4.js.map → chunk-YR5PKAAL.js.map} +0 -0
  25. /package/dist/{claude-code-updater-XZTIAQQ3.js.map → claude-code-updater-FWBF4JTA.js.map} +0 -0
  26. /package/dist/{claude-pair-runtime-N7TZVTF7.js.map → claude-pair-runtime-6BSR5RTE.js.map} +0 -0
  27. /package/dist/{persistent-session-NQMAJQF2.js.map → persistent-session-YMVE4OG5.js.map} +0 -0
  28. /package/dist/{responsiveness-probe-JGMZCQCI.js.map → responsiveness-probe-DD7LCTAS.js.map} +0 -0
  29. /package/dist/{session-auth-dead-DPMMX7QL.js.map → session-auth-dead-QZOUWP4O.js.map} +0 -0
@@ -44791,6 +44791,17 @@ var FLAG_REGISTRY = [
44791
44791
  defaultValue: false,
44792
44792
  envVar: "AGT_SESSION_TOOL_PROBE_ENABLED"
44793
44793
  },
44794
+ {
44795
+ key: "mcp-tool-rediscovery",
44796
+ description: "Slow re-check of the forwarded tool list on a healthy `augmented` MCP server (ENG-11708): every 30 minutes, with jitter, per running session. It heals tools lost to a broker that failed closed, which returns an empty list and looks healthy. Adds tools only and never removes one. Boolean gate; ships dark because it adds per-session database load to every healthy session, so canary a host first. Turning it off does not stop the load from unhealthy sessions: one with a failed or partial discovery, or a tool that has not registered, retries without this flag and settles at the same 30-minute full discovery until it recovers or restarts. AGT_MCP_TOOL_REDISCOVERY_ENABLED is the highest-precedence operator override; precedence is env override > flag value > this default.",
44797
+ flagType: "boolean",
44798
+ defaultValue: false,
44799
+ envVar: "AGT_MCP_TOOL_REDISCOVERY_ENABLED",
44800
+ // DELIBERATE UNREACHABLE PLACEHOLDER, as on the entries above: the first agt-cli
44801
+ // carrying this reader is not knowable before merge, and a low guess would promise
44802
+ // reach to hosts without it. Replace with the real version once it publishes.
44803
+ since: "0.29.0"
44804
+ },
44794
44805
  {
44795
44806
  key: "session-tool-rebind",
44796
44807
  description: "Auto-rebind MCP tools that fell out of a running session (ENG-7318, ENG-7053 Slice A). When ON, the session-tool-bind probe does not just report a hard-negative verdict - the manager SIGTERMs just that integration's MCP child so Claude Code's transport respawns it (no full agent restart, conversation context preserved). Fires on `missing` (a dead stdio/proxy child - the ENG-7301/Phil case) and on `unreachable` (an alive ENG-6859 OAuth-proxy child whose upstream stopped answering tools/list after a token rotated under the live session - the ENG-7318/Pepper case). Requires the `session-tool-probe` flag (it consumes that probe's verdict). The reap is debounced (the probe's ~1h cadence plus a per-integration cooldown) so a persistently-broken integration is rebound at most once per window, never every cycle. Boolean gate; ships dark - canary per host (agt-aws-1) before any fleet flip. AGT_SESSION_TOOL_REBIND_ENABLED is the highest-precedence operator override; precedence is env override > flag value > this default.",
package/dist/mcp/index.js CHANGED
@@ -30473,6 +30473,17 @@ var FLAG_REGISTRY = [
30473
30473
  defaultValue: false,
30474
30474
  envVar: "AGT_SESSION_TOOL_PROBE_ENABLED"
30475
30475
  },
30476
+ {
30477
+ key: "mcp-tool-rediscovery",
30478
+ description: "Slow re-check of the forwarded tool list on a healthy `augmented` MCP server (ENG-11708): every 30 minutes, with jitter, per running session. It heals tools lost to a broker that failed closed, which returns an empty list and looks healthy. Adds tools only and never removes one. Boolean gate; ships dark because it adds per-session database load to every healthy session, so canary a host first. Turning it off does not stop the load from unhealthy sessions: one with a failed or partial discovery, or a tool that has not registered, retries without this flag and settles at the same 30-minute full discovery until it recovers or restarts. AGT_MCP_TOOL_REDISCOVERY_ENABLED is the highest-precedence operator override; precedence is env override > flag value > this default.",
30479
+ flagType: "boolean",
30480
+ defaultValue: false,
30481
+ envVar: "AGT_MCP_TOOL_REDISCOVERY_ENABLED",
30482
+ // DELIBERATE UNREACHABLE PLACEHOLDER, as on the entries above: the first agt-cli
30483
+ // carrying this reader is not knowable before merge, and a low guess would promise
30484
+ // reach to hosts without it. Replace with the real version once it publishes.
30485
+ since: "0.29.0"
30486
+ },
30476
30487
  {
30477
30488
  key: "session-tool-rebind",
30478
30489
  description: "Auto-rebind MCP tools that fell out of a running session (ENG-7318, ENG-7053 Slice A). When ON, the session-tool-bind probe does not just report a hard-negative verdict - the manager SIGTERMs just that integration's MCP child so Claude Code's transport respawns it (no full agent restart, conversation context preserved). Fires on `missing` (a dead stdio/proxy child - the ENG-7301/Phil case) and on `unreachable` (an alive ENG-6859 OAuth-proxy child whose upstream stopped answering tools/list after a token rotated under the live session - the ENG-7318/Pepper case). Requires the `session-tool-probe` flag (it consumes that probe's verdict). The reap is debounced (the probe's ~1h cadence plus a per-integration cooldown) so a persistently-broken integration is rebound at most once per window, never every cycle. Boolean gate; ships dark - canary per host (agt-aws-1) before any fleet flip. AGT_SESSION_TOOL_REBIND_ENABLED is the highest-precedence operator override; precedence is env override > flag value > this default.",
@@ -47696,6 +47707,27 @@ function envBoolean(raw) {
47696
47707
  if (v === "0" || v === "false" || v === "no" || v === "off") return false;
47697
47708
  return void 0;
47698
47709
  }
47710
+ function cachedBoolean(key, path) {
47711
+ try {
47712
+ if (!existsSync2(path)) return void 0;
47713
+ const parsed = JSON.parse(readFileSync4(path, "utf8"));
47714
+ if (!parsed || typeof parsed !== "object") return void 0;
47715
+ const flags = parsed.flags;
47716
+ if (!flags || typeof flags !== "object") return void 0;
47717
+ const value = flags[key];
47718
+ return typeof value === "boolean" ? value : void 0;
47719
+ } catch {
47720
+ return void 0;
47721
+ }
47722
+ }
47723
+ function resolveHostBooleanFlag(opts) {
47724
+ const env2 = opts.env ?? process.env;
47725
+ const envValue = envBoolean(env2[opts.envVar]);
47726
+ if (envValue !== void 0) return envValue;
47727
+ const cached2 = cachedBoolean(opts.key, opts.cachePath ?? defaultFlagsCachePath(env2));
47728
+ if (cached2 !== void 0) return cached2;
47729
+ return opts.defaultValue;
47730
+ }
47699
47731
  var MAINTENANCE_FLAG_KEY = "platform-maintenance-mode";
47700
47732
  function parseMaintenanceMode(raw) {
47701
47733
  if (raw === void 0) return void 0;
@@ -48961,6 +48993,73 @@ function writeForwardedToolsReport(agentDir, report) {
48961
48993
  }
48962
48994
  }
48963
48995
 
48996
+ // src/forwarded-tool-rediscovery.ts
48997
+ var UNHEALTHY_RETRY_DELAYS_MS = [3e4, 6e4, 12e4, 3e5];
48998
+ var FAST_RETRY_ATTEMPTS = 6;
48999
+ var HEALTHY_RECHECK_MS = 30 * 60 * 1e3;
49000
+ var DELAY_JITTER_RATIO = 0.2;
49001
+ function nextDiscoveryDelayMs(consecutiveUnhealthy, healthyRecheckEnabled, random = Math.random) {
49002
+ let base;
49003
+ if (consecutiveUnhealthy > FAST_RETRY_ATTEMPTS) {
49004
+ base = HEALTHY_RECHECK_MS;
49005
+ } else if (consecutiveUnhealthy > 0) {
49006
+ const step = Math.min(consecutiveUnhealthy, UNHEALTHY_RETRY_DELAYS_MS.length) - 1;
49007
+ base = UNHEALTHY_RETRY_DELAYS_MS[step];
49008
+ } else if (healthyRecheckEnabled) {
49009
+ base = HEALTHY_RECHECK_MS;
49010
+ } else {
49011
+ return null;
49012
+ }
49013
+ return Math.round(base * (1 - DELAY_JITTER_RATIO + random() * 2 * DELAY_JITTER_RATIO));
49014
+ }
49015
+ function retryStatusFor(status, failedRegistrations) {
49016
+ return status === "ok" && failedRegistrations > 0 ? "degraded" : status;
49017
+ }
49018
+ function reportSignature(i) {
49019
+ return JSON.stringify([i.status, [...i.degradedBrokers ?? []].sort(), [...i.failed].sort()]);
49020
+ }
49021
+ function shouldReportRetry(i) {
49022
+ return i.status === "ok" || !i.hadCleanDiscovery || i.addedTools > 0 || i.signature !== i.lastReportedSignature;
49023
+ }
49024
+ function startForwardedToolRediscovery(initial, deps) {
49025
+ const setTimer = deps.setTimer ?? ((fn, ms) => {
49026
+ const timer = setTimeout(fn, ms);
49027
+ timer.unref?.();
49028
+ return timer;
49029
+ });
49030
+ let stopped = false;
49031
+ let unhealthy = initial === "ok" ? 0 : 1;
49032
+ const schedule = () => {
49033
+ if (stopped) return;
49034
+ const delay = nextDiscoveryDelayMs(unhealthy, deps.healthyRecheckEnabled(), deps.random);
49035
+ if (delay === null) {
49036
+ setTimer(schedule, HEALTHY_RECHECK_MS);
49037
+ return;
49038
+ }
49039
+ setTimer(() => void tick(), delay);
49040
+ };
49041
+ const tick = async () => {
49042
+ if (stopped) return;
49043
+ if (unhealthy === 0 && !deps.healthyRecheckEnabled()) {
49044
+ schedule();
49045
+ return;
49046
+ }
49047
+ let status;
49048
+ try {
49049
+ status = await deps.attempt();
49050
+ } catch (err) {
49051
+ deps.log?.(`augmented-mcp: tool rediscovery threw: ${err.message}`);
49052
+ status = "failed";
49053
+ }
49054
+ unhealthy = status === "ok" ? 0 : unhealthy + 1;
49055
+ schedule();
49056
+ };
49057
+ schedule();
49058
+ return () => {
49059
+ stopped = true;
49060
+ };
49061
+ }
49062
+
48964
49063
  // src/in-container.ts
48965
49064
  function isInContainer(env2 = process.env) {
48966
49065
  const raw = (env2.AGT_IN_CONTAINER ?? "").trim().toLowerCase();
@@ -49549,6 +49648,9 @@ function describeKanbanRespondOutcome(data) {
49549
49648
  return data.delivered === false ? `Answer added as a note on the card and it is on ${who}'s board as a reply they owe. The instant notice did not go out, so they will see it at their next board walk. It is off your plate.` : `Answer delivered to ${who} as a note on the card. It shows on their board until they answer, and their answer comes back to yours. It is off your plate.`;
49550
49649
  }
49551
49650
  if (data.ok && data.delivered !== false) {
49651
+ if (data.answered_as === "manager") {
49652
+ return "Answer delivered as their manager. Their card is un-parked and back on their board, so it is off your plate. The person it was parked on was not told; if they need to know the decision is made, tell them.";
49653
+ }
49552
49654
  return "Answer delivered. Their card is un-parked and back on their board \u2014 they will pick it up from here, so it is off your plate.";
49553
49655
  }
49554
49656
  if (data.reason === "recorded_undelivered" || data.ok && data.delivered === false) {
@@ -49562,13 +49664,31 @@ function describeKanbanRespondOutcome(data) {
49562
49664
  return data.error ?? "Could not send your answer.";
49563
49665
  }
49564
49666
  var REFUSAL_MESSAGES = {
49565
- not_found: () => 'No card is parked on you or owed a reply by you with that id. Re-read kanban_list \u2014 only cards under "You are blocking these" or "Replies you owe" can be answered here, and the id must be copied exactly.',
49667
+ not_found: () => `No card you can answer has that id. Re-read kanban_list for a card under "You are blocking these" or "Replies you owe", or, as a manager, kanban_parked for a DIRECT report's card parked on a person (ENG-11927). Copy the id exactly. A grand-report's card, or one on another team, cannot be answered here.`,
49566
49668
  self_block: () => "That card is parked on YOU by you \u2014 a self-block, almost always a mistyped code_name when it was parked. Fix it on your own card rather than answering it.",
49567
49669
  already_responded: () => "Someone already answered that card, so it has resumed. Nothing more to do.",
49568
49670
  not_actionable: (d) => `That card is no longer parked (status: ${d.status ?? "unknown"}), so there is nothing to un-park. The agent has moved on.`,
49671
+ // ENG-11927 ask 3: a manager may answer a report's card only when it is parked on a person.
49672
+ not_human_wait: (d) => d.waiting_kind === "approval" ? "That card is parked on a pending approval, and the approval decides it, not an answer here. Nothing was changed. Use approval_annotate to add your recommendation instead." : `That card is parked on "${d.waiting_kind ?? "something other than a person"}", not on a person, so a manager cannot answer it here. Nothing was changed. If it is parked on another agent, that agent answers it.`,
49569
49673
  recorded_not_unparked: () => "Your answer was recorded but the card could not be un-parked, so the agent is still blocked \u2014 tell them directly and check the card."
49570
49674
  };
49571
49675
  var HANDLED_REFUSAL_REASONS = Object.keys(REFUSAL_MESSAGES).sort();
49676
+ function describeKanbanRespondRejection(status, body) {
49677
+ if (status !== 404 && status !== 409) return null;
49678
+ if (!body) return null;
49679
+ let parsed;
49680
+ try {
49681
+ parsed = JSON.parse(body);
49682
+ } catch {
49683
+ return null;
49684
+ }
49685
+ if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) return null;
49686
+ const data = parsed;
49687
+ if (data.ok !== false || typeof data.reason !== "string" || !HANDLED_REFUSAL_REASONS.includes(data.reason)) {
49688
+ return null;
49689
+ }
49690
+ return describeKanbanRespondOutcome(data);
49691
+ }
49572
49692
 
49573
49693
  // src/kanban-update.ts
49574
49694
  function buildKanbanUpdateItem(id, fields) {
@@ -49929,9 +50049,10 @@ async function getToken() {
49929
50049
  return AGT_TOKEN;
49930
50050
  }
49931
50051
  var ApiPostError = class extends Error {
49932
- constructor(message, status) {
50052
+ constructor(message, status, responseBody = null) {
49933
50053
  super(message);
49934
50054
  this.status = status;
50055
+ this.responseBody = responseBody;
49935
50056
  this.name = "ApiPostError";
49936
50057
  }
49937
50058
  };
@@ -49971,7 +50092,8 @@ async function apiPost(path, body, retried = false, timeoutMs = 15e3, toolName,
49971
50092
  status: res.status,
49972
50093
  body: text
49973
50094
  }),
49974
- res.status
50095
+ res.status,
50096
+ text
49975
50097
  );
49976
50098
  }
49977
50099
  try {
@@ -50879,7 +51001,7 @@ server.tool(
50879
51001
  );
50880
51002
  server.tool(
50881
51003
  "kanban_parked",
50882
- "List the cards of an agent that reports directly to you, oldest first. By default its parked cards (needs_attention and waiting); pass column for its active cards, for example to find out what a todo card sitting for hours is. Each card shows its title, column, age, why it was parked where that is recorded (origin, waiting kind, waiting-on line), and the ticket or PR reference stored on it. Read-only: it changes nothing on the board. It never returns descriptions, results or notes. References are as stored, with no live ticket or PR state, and a linked reference can be a chat thread rather than a ticket. Only the direct reports-to manager can read this, the agent must be on your own team, and a manager-only agent refuses it. Use kanban_peek for counts on any teammate. Don't know the agent's code_name? Call directory_lookup first.",
51004
+ "List the cards of an agent that reports directly to you, oldest first. By default its parked cards (needs_attention and waiting); pass column for its active cards, for example to find out what a todo card sitting for hours is. Each card shows its title, column, age, why it was parked where that is recorded (origin, waiting kind, waiting-on line), and the ticket or PR reference stored on it. Read-only: it changes nothing on the board. It never returns descriptions, results or notes. A card waiting on a person (waiting kind human) is a decision you can make: answer it in place with kanban_respond and its id (ENG-11927). References are as stored, with no live ticket or PR state, and a linked reference can be a chat thread rather than a ticket. Only the direct reports-to manager can read this, the agent must be on your own team, and a manager-only agent refuses it. Use kanban_peek for counts on any teammate. Don't know the agent's code_name? Call directory_lookup first.",
50883
51005
  {
50884
51006
  target_agent: external_exports.string().describe("The agent that reports to you: its agent code_name (kebab-case) or agent UUID."),
50885
51007
  column: external_exports.enum(["needs_attention", "waiting", "in_progress", "todo", "backlog", "active"]).optional().describe('Only this column. "active" means in_progress, todo and backlog together. Omit for needs_attention and waiting.'),
@@ -51083,10 +51205,10 @@ server.tool(
51083
51205
  );
51084
51206
  server.tool(
51085
51207
  "kanban_respond",
51086
- 'Answer another agent on a card that is not yours to move. Two cases, both listed by kanban_list: (1) "You are blocking these" - a card another agent PARKED on you; it has stopped until you act, and your answer is delivered onto that card and un-parks it. (2) "Replies you owe" - a note another agent left you on a card (ENG-11483); your answer is added as a note and goes back to their board, and passing expects_reply: false ends the exchange quietly. A reply owed on one of YOUR OWN active cards stays in its status section, marked "[reply owed to @x]" - answer that the same way. Either way, do the thing asked, then send the answer here. Do NOT create a second card to carry it - it would sit beside the one it answers, joined by nothing. Only the agent the card names (the one it is parked on, or the one owing the reply) can answer it.',
51208
+ `Answer another agent on a card that is not yours to move. Two cases, both listed by kanban_list: (1) "You are blocking these" - a card another agent PARKED on you; it has stopped until you act, and your answer is delivered onto that card and un-parks it. (2) "Replies you owe" - a note another agent left you on a card (ENG-11483); your answer is added as a note and goes back to their board, and passing expects_reply: false ends the exchange quietly. A reply owed on one of YOUR OWN active cards stays in its status section, marked "[reply owed to @x]" - answer that the same way. Either way, do the thing asked, then send the answer here. Do NOT create a second card to carry it - it would sit beside the one it answers, joined by nothing. Only the agent the card names (the one it is parked on, or the one owing the reply) can answer it, with one addition (ENG-11927): a manager agent can also answer its DIRECT report's card that is parked on a PERSON (waiting_kind "human", as kanban_parked lists it), in place, so the person does not have to route a decision that is yours to make. Not a grand-report's card, not a card parked on an approval or anything other than a person.`,
51087
51209
  {
51088
51210
  card_id: external_exports.string().describe(
51089
- 'The card id, exactly as kanban_list shows it: under "You are blocking these", under "Replies you owe", or on your own card marked "[reply owed to @x]".'
51211
+ `The card id, exactly as kanban_list shows it: under "You are blocking these", under "Replies you owe", or on your own card marked "[reply owed to @x]". As a manager, the id kanban_parked shows for a direct report's card parked on a person.`
51090
51212
  ),
51091
51213
  text: external_exports.string().optional().describe(
51092
51214
  "Your answer, self-contained. This is what the blocked agent resumes on, so give it the ANSWER rather than a pointer to one - it cannot see your board, your session or your files. Required unless you are picking a choice with `value`."
@@ -51109,6 +51231,8 @@ server.tool(
51109
51231
  ...typeof params.expects_reply === "boolean" ? { expects_reply: params.expects_reply } : {}
51110
51232
  });
51111
51233
  } catch (err) {
51234
+ const refusal = err instanceof ApiPostError ? describeKanbanRespondRejection(err.status, err.responseBody) : null;
51235
+ if (refusal !== null) return { content: [{ type: "text", text: refusal }] };
51112
51236
  return {
51113
51237
  content: [{ type: "text", text: `Could not send your answer: ${err.message}` }]
51114
51238
  };
@@ -53160,7 +53284,7 @@ server.tool(
53160
53284
  }
53161
53285
  );
53162
53286
  async function discoverApiTools() {
53163
- if (!AGT_AGENT_ID) return [];
53287
+ if (!AGT_AGENT_ID) return { tools: [], status: "ok", degradedBrokers: [] };
53164
53288
  try {
53165
53289
  const res = await apiPost(
53166
53290
  "/host/mcp/tools/list",
@@ -53168,14 +53292,22 @@ async function discoverApiTools() {
53168
53292
  );
53169
53293
  if (res.error) {
53170
53294
  console.error(`augmented-mcp: tools/list returned error: ${res.error}`);
53171
- return [];
53295
+ return { tools: [], status: "failed", degradedBrokers: [] };
53172
53296
  }
53173
- return res.tools ?? [];
53297
+ const degradedBrokers = res.degraded_brokers ?? [];
53298
+ return {
53299
+ tools: res.tools ?? [],
53300
+ status: degradedBrokers.length > 0 ? "degraded" : "ok",
53301
+ degradedBrokers
53302
+ };
53174
53303
  } catch (err) {
53175
53304
  console.error(`augmented-mcp: tools/list failed: ${err.message}`);
53176
- return [];
53305
+ return { tools: [], status: "failed", degradedBrokers: [] };
53177
53306
  }
53178
53307
  }
53308
+ var registeredForwardedTools = /* @__PURE__ */ new Set();
53309
+ var lateRegisteredForwardedTools = /* @__PURE__ */ new Set();
53310
+ var unresolvedForwardedTools = /* @__PURE__ */ new Set();
53179
53311
  function canonicalAgentDir(dir) {
53180
53312
  try {
53181
53313
  return realpathSync(dir);
@@ -53436,8 +53568,8 @@ var LOCAL_TOOL_NAMES = /* @__PURE__ */ new Set([
53436
53568
  // direct-chat (button_click). Always registered; no API tool shares this name.
53437
53569
  "request_buttons"
53438
53570
  ]);
53439
- async function registerForwardedApiTools() {
53440
- const apiTools = await discoverApiTools();
53571
+ async function registerForwardedApiTools(isStartup = true) {
53572
+ const { tools: apiTools, status, degradedBrokers } = await discoverApiTools();
53441
53573
  const localToolNames = LOCAL_TOOL_NAMES;
53442
53574
  let registered = 0;
53443
53575
  let skipped = 0;
@@ -53447,6 +53579,10 @@ async function registerForwardedApiTools() {
53447
53579
  skipped++;
53448
53580
  continue;
53449
53581
  }
53582
+ if (registeredForwardedTools.has(tool.name)) {
53583
+ registered++;
53584
+ continue;
53585
+ }
53450
53586
  try {
53451
53587
  const shape = jsonSchemaToZodShape(tool.inputSchema);
53452
53588
  server.registerTool(
@@ -53460,15 +53596,19 @@ async function registerForwardedApiTools() {
53460
53596
  return result;
53461
53597
  }
53462
53598
  );
53599
+ registeredForwardedTools.add(tool.name);
53600
+ unresolvedForwardedTools.delete(tool.name);
53601
+ if (!isStartup) lateRegisteredForwardedTools.add(tool.name);
53463
53602
  registered++;
53464
53603
  } catch (err) {
53465
53604
  failed.push(tool.name);
53605
+ unresolvedForwardedTools.add(tool.name);
53466
53606
  console.error(
53467
53607
  `augmented-mcp: failed to register forwarded tool '${tool.name}': ${err.message}`
53468
53608
  );
53469
53609
  }
53470
53610
  }
53471
- return { expected: apiTools.length, registered, skipped, failed };
53611
+ return { expected: apiTools.length, registered, skipped, failed, status, degradedBrokers };
53472
53612
  }
53473
53613
  async function listPublishedArtefactsText(params) {
53474
53614
  const data = await apiPost(
@@ -54194,9 +54334,36 @@ if (isSelfRestartEnabled(process.env) && AGT_AGENT_CODE_NAME) {
54194
54334
  }
54195
54335
  );
54196
54336
  }
54337
+ var lastReportedSignature = null;
54338
+ function forwardedReportSignature(result) {
54339
+ return reportSignature({ status: result.status, degradedBrokers: result.degradedBrokers, failed: unresolvedForwardedTools });
54340
+ }
54341
+ function reportForwardedTools(result) {
54342
+ if (!AGT_AGENT_CODE_NAME) return;
54343
+ const wrote = writeForwardedToolsReport(selfRestartAgentDir(AGT_AGENT_CODE_NAME), {
54344
+ expected: result.expected,
54345
+ // ENG-11708: what this session holds, which a failed retry cannot reduce.
54346
+ registered: registeredForwardedTools.size,
54347
+ skipped: result.skipped,
54348
+ failed: [...unresolvedForwardedTools],
54349
+ at: (/* @__PURE__ */ new Date()).toISOString(),
54350
+ discovery: result.status,
54351
+ degradedBrokers: result.degradedBrokers,
54352
+ lateRegistered: [...lateRegisteredForwardedTools]
54353
+ });
54354
+ if (!wrote) {
54355
+ console.error("augmented-mcp: could not write the forwarded-tools report");
54356
+ return;
54357
+ }
54358
+ lastReportedSignature = forwardedReportSignature(result);
54359
+ }
54197
54360
  async function main() {
54361
+ let startupDiscovery = "failed";
54362
+ let hadCleanDiscovery = false;
54198
54363
  try {
54199
54364
  const result = await registerForwardedApiTools();
54365
+ startupDiscovery = retryStatusFor(result.status, unresolvedForwardedTools.size);
54366
+ hadCleanDiscovery = result.status === "ok";
54200
54367
  if (result.expected > 0) {
54201
54368
  console.error(
54202
54369
  `augmented-mcp: forwarded ${result.registered} of ${result.expected} API tool(s), skipped ${result.skipped} local override(s)`
@@ -54207,23 +54374,39 @@ async function main() {
54207
54374
  `augmented-mcp: ${result.failed.length} forwarded tool(s) FAILED to register: ${result.failed.join(", ")}`
54208
54375
  );
54209
54376
  }
54210
- if (AGT_AGENT_CODE_NAME) {
54211
- const wrote = writeForwardedToolsReport(selfRestartAgentDir(AGT_AGENT_CODE_NAME), {
54212
- expected: result.expected,
54213
- registered: result.registered,
54214
- skipped: result.skipped,
54215
- failed: result.failed,
54216
- at: (/* @__PURE__ */ new Date()).toISOString()
54217
- });
54218
- if (!wrote) {
54219
- console.error("augmented-mcp: could not write the forwarded-tools report");
54220
- }
54221
- }
54377
+ reportForwardedTools(result);
54222
54378
  } catch (err) {
54223
54379
  console.error(`augmented-mcp: tool discovery threw: ${err.message}`);
54224
54380
  }
54225
54381
  const transport = new StdioServerTransport();
54226
54382
  await server.connect(transport);
54383
+ startForwardedToolRediscovery(startupDiscovery, {
54384
+ attempt: async () => {
54385
+ const before = registeredForwardedTools.size;
54386
+ const result = await registerForwardedApiTools(false);
54387
+ const added = registeredForwardedTools.size - before;
54388
+ if (added > 0) {
54389
+ console.error(`augmented-mcp: registered ${added} forwarded tool(s) after startup`);
54390
+ }
54391
+ if (shouldReportRetry({
54392
+ status: result.status,
54393
+ hadCleanDiscovery,
54394
+ addedTools: added,
54395
+ signature: forwardedReportSignature(result),
54396
+ lastReportedSignature
54397
+ })) {
54398
+ reportForwardedTools(result);
54399
+ }
54400
+ if (result.status === "ok") hadCleanDiscovery = true;
54401
+ return retryStatusFor(result.status, unresolvedForwardedTools.size);
54402
+ },
54403
+ healthyRecheckEnabled: () => resolveHostBooleanFlag({
54404
+ key: "mcp-tool-rediscovery",
54405
+ envVar: "AGT_MCP_TOOL_REDISCOVERY_ENABLED",
54406
+ defaultValue: false
54407
+ }),
54408
+ log: (line2) => console.error(line2)
54409
+ });
54227
54410
  }
54228
54411
  main().catch((err) => {
54229
54412
  console.error("augmented-mcp: Fatal error:", err);
@@ -44275,6 +44275,17 @@ var FLAG_REGISTRY = [
44275
44275
  defaultValue: false,
44276
44276
  envVar: "AGT_SESSION_TOOL_PROBE_ENABLED"
44277
44277
  },
44278
+ {
44279
+ key: "mcp-tool-rediscovery",
44280
+ description: "Slow re-check of the forwarded tool list on a healthy `augmented` MCP server (ENG-11708): every 30 minutes, with jitter, per running session. It heals tools lost to a broker that failed closed, which returns an empty list and looks healthy. Adds tools only and never removes one. Boolean gate; ships dark because it adds per-session database load to every healthy session, so canary a host first. Turning it off does not stop the load from unhealthy sessions: one with a failed or partial discovery, or a tool that has not registered, retries without this flag and settles at the same 30-minute full discovery until it recovers or restarts. AGT_MCP_TOOL_REDISCOVERY_ENABLED is the highest-precedence operator override; precedence is env override > flag value > this default.",
44281
+ flagType: "boolean",
44282
+ defaultValue: false,
44283
+ envVar: "AGT_MCP_TOOL_REDISCOVERY_ENABLED",
44284
+ // DELIBERATE UNREACHABLE PLACEHOLDER, as on the entries above: the first agt-cli
44285
+ // carrying this reader is not knowable before merge, and a low guess would promise
44286
+ // reach to hosts without it. Replace with the real version once it publishes.
44287
+ since: "0.29.0"
44288
+ },
44278
44289
  {
44279
44290
  key: "session-tool-rebind",
44280
44291
  description: "Auto-rebind MCP tools that fell out of a running session (ENG-7318, ENG-7053 Slice A). When ON, the session-tool-bind probe does not just report a hard-negative verdict - the manager SIGTERMs just that integration's MCP child so Claude Code's transport respawns it (no full agent restart, conversation context preserved). Fires on `missing` (a dead stdio/proxy child - the ENG-7301/Phil case) and on `unreachable` (an alive ENG-6859 OAuth-proxy child whose upstream stopped answering tools/list after a token rotated under the live session - the ENG-7318/Pepper case). Requires the `session-tool-probe` flag (it consumes that probe's verdict). The reap is debounced (the probe's ~1h cadence plus a per-integration cooldown) so a persistently-broken integration is rebound at most once per window, never every cycle. Boolean gate; ships dark - canary per host (agt-aws-1) before any fleet flip. AGT_SESSION_TOOL_REBIND_ENABLED is the highest-precedence operator override; precedence is env override > flag value > this default.",
@@ -39127,6 +39127,17 @@ var FLAG_REGISTRY = [
39127
39127
  defaultValue: false,
39128
39128
  envVar: "AGT_SESSION_TOOL_PROBE_ENABLED"
39129
39129
  },
39130
+ {
39131
+ key: "mcp-tool-rediscovery",
39132
+ description: "Slow re-check of the forwarded tool list on a healthy `augmented` MCP server (ENG-11708): every 30 minutes, with jitter, per running session. It heals tools lost to a broker that failed closed, which returns an empty list and looks healthy. Adds tools only and never removes one. Boolean gate; ships dark because it adds per-session database load to every healthy session, so canary a host first. Turning it off does not stop the load from unhealthy sessions: one with a failed or partial discovery, or a tool that has not registered, retries without this flag and settles at the same 30-minute full discovery until it recovers or restarts. AGT_MCP_TOOL_REDISCOVERY_ENABLED is the highest-precedence operator override; precedence is env override > flag value > this default.",
39133
+ flagType: "boolean",
39134
+ defaultValue: false,
39135
+ envVar: "AGT_MCP_TOOL_REDISCOVERY_ENABLED",
39136
+ // DELIBERATE UNREACHABLE PLACEHOLDER, as on the entries above: the first agt-cli
39137
+ // carrying this reader is not knowable before merge, and a low guess would promise
39138
+ // reach to hosts without it. Replace with the real version once it publishes.
39139
+ since: "0.29.0"
39140
+ },
39130
39141
  {
39131
39142
  key: "session-tool-rebind",
39132
39143
  description: "Auto-rebind MCP tools that fell out of a running session (ENG-7318, ENG-7053 Slice A). When ON, the session-tool-bind probe does not just report a hard-negative verdict - the manager SIGTERMs just that integration's MCP child so Claude Code's transport respawns it (no full agent restart, conversation context preserved). Fires on `missing` (a dead stdio/proxy child - the ENG-7301/Phil case) and on `unreachable` (an alive ENG-6859 OAuth-proxy child whose upstream stopped answering tools/list after a token rotated under the live session - the ENG-7318/Pepper case). Requires the `session-tool-probe` flag (it consumes that probe's verdict). The reap is debounced (the probe's ~1h cadence plus a per-integration cooldown) so a persistently-broken integration is rebound at most once per window, never every cycle. Boolean gate; ships dark - canary per host (agt-aws-1) before any fleet flip. AGT_SESSION_TOOL_REBIND_ENABLED is the highest-precedence operator override; precedence is env override > flag value > this default.",
@@ -39318,6 +39318,17 @@ var FLAG_REGISTRY = [
39318
39318
  defaultValue: false,
39319
39319
  envVar: "AGT_SESSION_TOOL_PROBE_ENABLED"
39320
39320
  },
39321
+ {
39322
+ key: "mcp-tool-rediscovery",
39323
+ description: "Slow re-check of the forwarded tool list on a healthy `augmented` MCP server (ENG-11708): every 30 minutes, with jitter, per running session. It heals tools lost to a broker that failed closed, which returns an empty list and looks healthy. Adds tools only and never removes one. Boolean gate; ships dark because it adds per-session database load to every healthy session, so canary a host first. Turning it off does not stop the load from unhealthy sessions: one with a failed or partial discovery, or a tool that has not registered, retries without this flag and settles at the same 30-minute full discovery until it recovers or restarts. AGT_MCP_TOOL_REDISCOVERY_ENABLED is the highest-precedence operator override; precedence is env override > flag value > this default.",
39324
+ flagType: "boolean",
39325
+ defaultValue: false,
39326
+ envVar: "AGT_MCP_TOOL_REDISCOVERY_ENABLED",
39327
+ // DELIBERATE UNREACHABLE PLACEHOLDER, as on the entries above: the first agt-cli
39328
+ // carrying this reader is not knowable before merge, and a low guess would promise
39329
+ // reach to hosts without it. Replace with the real version once it publishes.
39330
+ since: "0.29.0"
39331
+ },
39321
39332
  {
39322
39333
  key: "session-tool-rebind",
39323
39334
  description: "Auto-rebind MCP tools that fell out of a running session (ENG-7318, ENG-7053 Slice A). When ON, the session-tool-bind probe does not just report a hard-negative verdict - the manager SIGTERMs just that integration's MCP child so Claude Code's transport respawns it (no full agent restart, conversation context preserved). Fires on `missing` (a dead stdio/proxy child - the ENG-7301/Phil case) and on `unreachable` (an alive ENG-6859 OAuth-proxy child whose upstream stopped answering tools/list after a token rotated under the live session - the ENG-7318/Pepper case). Requires the `session-tool-probe` flag (it consumes that probe's verdict). The reap is debounced (the probe's ~1h cadence plus a per-integration cooldown) so a persistently-broken integration is rebound at most once per window, never every cycle. Boolean gate; ships dark - canary per host (agt-aws-1) before any fleet flip. AGT_SESSION_TOOL_REBIND_ENABLED is the highest-precedence operator override; precedence is env override > flag value > this default.",
@@ -68,12 +68,12 @@ import {
68
68
  writeDirectChatSessionState,
69
69
  writeEgressAllowlist,
70
70
  writePersistentClaudeWrapper
71
- } from "./chunk-F5R622EX.js";
72
- import "./chunk-HAQXH2J4.js";
71
+ } from "./chunk-QGBIF6QK.js";
72
+ import "./chunk-YR5PKAAL.js";
73
73
  import "./chunk-HYQ7VOC3.js";
74
74
  import "./chunk-6HBXEJHO.js";
75
75
  import "./chunk-XWVM4KPK.js";
76
- import "./chunk-MJXBNSJY.js";
76
+ import "./chunk-R7UGBRUR.js";
77
77
  import "./chunk-AIUIMEUS.js";
78
78
  import "./chunk-DGUM43GV.js";
79
79
  export {
@@ -147,4 +147,4 @@ export {
147
147
  writeEgressAllowlist,
148
148
  writePersistentClaudeWrapper
149
149
  };
150
- //# sourceMappingURL=persistent-session-NQMAJQF2.js.map
150
+ //# sourceMappingURL=persistent-session-YMVE4OG5.js.map
@@ -1,11 +1,11 @@
1
1
  import {
2
2
  paneLogPath
3
- } from "./chunk-F5R622EX.js";
4
- import "./chunk-HAQXH2J4.js";
3
+ } from "./chunk-QGBIF6QK.js";
4
+ import "./chunk-YR5PKAAL.js";
5
5
  import "./chunk-HYQ7VOC3.js";
6
6
  import "./chunk-6HBXEJHO.js";
7
7
  import "./chunk-XWVM4KPK.js";
8
- import "./chunk-MJXBNSJY.js";
8
+ import "./chunk-R7UGBRUR.js";
9
9
  import "./chunk-AIUIMEUS.js";
10
10
  import "./chunk-DGUM43GV.js";
11
11
 
@@ -804,4 +804,4 @@ export {
804
804
  readAndResetSlackReplyBindingClassifications,
805
805
  readAndResetSlackReplyTargetClassifications
806
806
  };
807
- //# sourceMappingURL=responsiveness-probe-JGMZCQCI.js.map
807
+ //# sourceMappingURL=responsiveness-probe-DD7LCTAS.js.map
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  sessionTranscriptDir
3
- } from "./chunk-HAQXH2J4.js";
4
- import "./chunk-MJXBNSJY.js";
3
+ } from "./chunk-YR5PKAAL.js";
4
+ import "./chunk-R7UGBRUR.js";
5
5
  import "./chunk-DGUM43GV.js";
6
6
 
7
7
  // src/lib/session-auth-dead.ts
@@ -205,4 +205,4 @@ export {
205
205
  decideSessionAuthState,
206
206
  probeSessionAuth
207
207
  };
208
- //# sourceMappingURL=session-auth-dead-DPMMX7QL.js.map
208
+ //# sourceMappingURL=session-auth-dead-QZOUWP4O.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@integrity-labs/agt-cli",
3
- "version": "0.28.1219",
3
+ "version": "0.28.1221",
4
4
  "description": "Augmented Team CLI — agent provisioning and management",
5
5
  "type": "module",
6
6
  "engines": {