@integrity-labs/agt-cli 0.7.7 → 0.7.8

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
@@ -32,7 +32,7 @@ import {
32
32
  resolveChannels,
33
33
  serializeManifestForSlackCli,
34
34
  setActiveTeam
35
- } from "../chunk-QS2GCIWQ.js";
35
+ } from "../chunk-B47JW4MM.js";
36
36
 
37
37
  // src/bin/agt.ts
38
38
  import { join as join11 } from "path";
@@ -3411,7 +3411,7 @@ async function acpxCloseCommand(agent2, _opts, cmd) {
3411
3411
  import { execSync } from "child_process";
3412
3412
  import chalk19 from "chalk";
3413
3413
  import ora15 from "ora";
3414
- var cliVersion = true ? "0.7.7" : "dev";
3414
+ var cliVersion = true ? "0.7.8" : "dev";
3415
3415
  async function fetchLatestVersion() {
3416
3416
  const host2 = AGT_HOST;
3417
3417
  if (!host2) return null;
@@ -3527,7 +3527,7 @@ async function checkForUpdateOnStartup() {
3527
3527
  }
3528
3528
 
3529
3529
  // src/bin/agt.ts
3530
- var cliVersion2 = true ? "0.7.7" : "dev";
3530
+ var cliVersion2 = true ? "0.7.8" : "dev";
3531
3531
  var program = new Command();
3532
3532
  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");
3533
3533
  program.hook("preAction", (thisCommand) => {
@@ -1866,13 +1866,35 @@ Two types of memory files, both plain Markdown:
1866
1866
 
1867
1867
  ${recall}`;
1868
1868
  }
1869
+ function buildIntegrationsSection(integrations) {
1870
+ if (!integrations?.length)
1871
+ return "";
1872
+ const lines = integrations.map((i) => {
1873
+ const cli = i.cliBinary ? ` \u2014 use the \`${i.cliBinary}\` CLI` : "";
1874
+ return `- **${i.name}**${cli}${i.description ? `. ${i.description}` : ""}`;
1875
+ });
1876
+ const hasAnyCli = integrations.some((i) => i.cliBinary);
1877
+ const intro = hasAnyCli ? `You have the following integrations configured. Where a CLI is listed,
1878
+ use it instead of web fetch, curl, or MCP \u2014 the CLI handles auth
1879
+ automatically via pre-configured environment variables.` : "You have the following integrations configured.";
1880
+ return `## Integrations
1881
+
1882
+ ${intro}
1883
+
1884
+ ${lines.join("\n")}
1885
+
1886
+ Check \`.claude/skills/\` for detailed usage instructions for each integration.
1887
+
1888
+ `;
1889
+ }
1869
1890
  function generateClaudeMd(input) {
1870
- const { frontmatter, role, description, resolvedChannels, team, consoleUrl, hasQmd } = input;
1891
+ const { frontmatter, role, description, resolvedChannels, team, consoleUrl, hasQmd, integrations } = input;
1871
1892
  const channelList = resolvedChannels?.length ? resolvedChannels.join(", ") : "none";
1872
1893
  const roleDisplay = role ?? "Agent";
1873
1894
  const desc = description?.trim();
1874
1895
  const kanbanUrl = consoleUrl ? `${consoleUrl}/agents/${frontmatter.agent_id}?tab=kanban` : null;
1875
1896
  const memorySection = buildMemorySection(hasQmd);
1897
+ const integrationsSection = buildIntegrationsSection(integrations);
1876
1898
  return `# ${frontmatter.display_name}
1877
1899
 
1878
1900
  You are **${frontmatter.display_name}**, **${roleDisplay}**${team ? ` at **${team.name}**` : ""}.
@@ -1890,11 +1912,12 @@ ${desc}
1890
1912
  ## Governance
1891
1913
 
1892
1914
  This agent is governed by Augmented (ARIS). Policy, budget, and channel rules
1893
- are defined in \`CHARTER.md\`. Tool permissions are in \`TOOLS.md\`.
1915
+ are defined in \`CHARTER.md\`.
1894
1916
 
1895
1917
  - Budget: ${frontmatter.budget?.limit_tokens ? `${frontmatter.budget.limit_tokens} tokens/${frontmatter.budget.window}` : frontmatter.budget?.limit_dollars ? `$${frontmatter.budget.limit_dollars}/${frontmatter.budget.window}` : "unlimited"}
1896
1918
  - Logging: ${frontmatter.logging_mode}
1897
- - Enforcement: Follow CHARTER.md and TOOLS.md constraints strictly.
1919
+ - Enforcement: Follow CHARTER.md constraints strictly.
1920
+ - Tools: Any MCP server configured in your session is authorized \u2014 if it's connected, you may use it.
1898
1921
 
1899
1922
  ## Work Management
1900
1923
 
@@ -1915,7 +1938,7 @@ first to load your recent board state. This gives you context about completed an
1915
1938
  in-progress items so you can answer accurately.
1916
1939
 
1917
1940
  ${memorySection}
1918
- ## Rules
1941
+ ${integrationsSection}## Rules
1919
1942
 
1920
1943
  - Never expose secrets or API keys in output.
1921
1944
  - Respect channel restrictions \u2014 only operate on allowed channels.
@@ -1985,6 +2008,12 @@ function deployArtifactsToProject(codeName, provisionDir) {
1985
2008
  }
1986
2009
  const projectServers = projectMcp["mcpServers"] ?? {};
1987
2010
  const agentServers = agentMcp["mcpServers"] ?? {};
2011
+ const keysToRemove = Object.entries(projectServers).filter(([, val]) => {
2012
+ const entry = val;
2013
+ return entry && typeof entry["url"] === "string" && entry["url"].startsWith("/");
2014
+ }).map(([key]) => key);
2015
+ for (const key of keysToRemove)
2016
+ delete projectServers[key];
1988
2017
  projectMcp["mcpServers"] = { ...projectServers, ...agentServers };
1989
2018
  writeFileSync3(projectMcpPath, JSON.stringify(projectMcp, null, 2));
1990
2019
  } catch {
@@ -1998,6 +2027,61 @@ function deployArtifactsToProject(codeName, provisionDir) {
1998
2027
  }
1999
2028
  }
2000
2029
  }
2030
+ function provisionStopHook(codeName) {
2031
+ const projectDir = getProjectDir(codeName);
2032
+ const claudeDir = join3(projectDir, ".claude");
2033
+ mkdirSync3(claudeDir, { recursive: true });
2034
+ const hookScriptPath = join3(claudeDir, "agt-stop-hook.sh");
2035
+ const hookScript = [
2036
+ "#!/bin/bash",
2037
+ "# Auto-generated by Augmented \u2014 captures persistent session task results.",
2038
+ "set -euo pipefail",
2039
+ "INPUT=$(cat)",
2040
+ `TRANSCRIPT_PATH=$(echo "$INPUT" | jq -r '.transcript_path // empty')`,
2041
+ '[ -z "$TRANSCRIPT_PATH" ] || [ ! -f "$TRANSCRIPT_PATH" ] && exit 0',
2042
+ `CWD=$(echo "$INPUT" | jq -r '.cwd // empty')`,
2043
+ 'MARKER="${CWD}/.claude/.agt-pending-task.json"',
2044
+ '[ ! -f "$MARKER" ] && exit 0',
2045
+ `AGENT_ID=$(jq -r '.agent_id // empty' "$MARKER")`,
2046
+ `TEMPLATE_ID=$(jq -r '.template_id // empty' "$MARKER")`,
2047
+ '[ -z "$AGENT_ID" ] && { rm -f "$MARKER"; exit 0; }',
2048
+ `RESP=$(tail -50 "$TRANSCRIPT_PATH" | jq -rs '[.[] | select(.type == "assistant") | .message.content[]? | select(.type == "text") | .text] | last // empty' 2>/dev/null)`,
2049
+ `[ -z "$RESP" ] && RESP=$(tail -50 "$TRANSCRIPT_PATH" | jq -rs '[.[] | select(.role == "assistant") | .content[]? | select(.type == "text") | .text] | last // empty' 2>/dev/null)`,
2050
+ '[ -z "$RESP" ] && { rm -f "$MARKER"; exit 0; }',
2051
+ 'rm -f "$MARKER"',
2052
+ 'AGT_HOST="${AGT_HOST:-}"; AGT_API_KEY="${AGT_API_KEY:-}"',
2053
+ '[ -z "$AGT_HOST" ] || [ -z "$AGT_API_KEY" ] && exit 0',
2054
+ 'JWT=$(curl -sf -X POST "${AGT_HOST}/host/exchange" -H "Content-Type: application/json" -d "{\\"api_key\\": \\"${AGT_API_KEY}\\"}" | jq -r \'.token // empty\' 2>/dev/null)',
2055
+ '[ -z "$JWT" ] && exit 0',
2056
+ 'case "$TEMPLATE_ID" in',
2057
+ " daily-standup|standup|weekly-standup)",
2058
+ ` curl -sf -X POST "\${AGT_HOST}/host/agent-status" -H "Content-Type: application/json" -H "Authorization: Bearer $JWT" -d "$(jq -n --arg a \\"$AGENT_ID\\" --arg s \\"$RESP\\" '{agent_id:$a,standup:$s,current_status:"idle"}')" >/dev/null 2>&1 & ;;`,
2059
+ " *)",
2060
+ ` curl -sf -X POST "\${AGT_HOST}/host/agent-status" -H "Content-Type: application/json" -H "Authorization: Bearer $JWT" -d "$(jq -n --arg a \\"$AGENT_ID\\" --arg t \\"$RESP\\" '{agent_id:$a,current_tasks:$t}')" >/dev/null 2>&1 & ;;`,
2061
+ "esac",
2062
+ "exit 0"
2063
+ ].join("\n") + "\n";
2064
+ writeFileSync3(hookScriptPath, hookScript, { mode: 493 });
2065
+ const settingsPath = join3(claudeDir, "settings.local.json");
2066
+ let settings = {};
2067
+ try {
2068
+ settings = JSON.parse(readFileSync3(settingsPath, "utf-8"));
2069
+ } catch {
2070
+ }
2071
+ const hooks = settings["hooks"] ?? {};
2072
+ hooks["Stop"] = [
2073
+ {
2074
+ hooks: [
2075
+ {
2076
+ type: "command",
2077
+ command: hookScriptPath
2078
+ }
2079
+ ]
2080
+ }
2081
+ ];
2082
+ settings["hooks"] = hooks;
2083
+ writeFileSync3(settingsPath, JSON.stringify(settings, null, 2));
2084
+ }
2001
2085
  function modifyJsonConfig(filePath, fn) {
2002
2086
  let originalContent;
2003
2087
  let config;
@@ -2106,6 +2190,15 @@ var claudeCodeAdapter = {
2106
2190
  label: "Claude Code",
2107
2191
  cliBinary: "claude",
2108
2192
  buildArtifacts(input) {
2193
+ const integrationSummaries = (input.integrations ?? []).map((i) => {
2194
+ const def = INTEGRATION_REGISTRY.find((d) => d.id === i.definition_id);
2195
+ return {
2196
+ id: i.definition_id,
2197
+ name: i.display_name || def?.name || i.definition_id,
2198
+ cliBinary: def?.cli_tool?.binary,
2199
+ description: def?.description
2200
+ };
2201
+ });
2109
2202
  const claudeMdInput = {
2110
2203
  frontmatter: input.charterFrontmatter,
2111
2204
  role: input.agent.role,
@@ -2113,7 +2206,8 @@ var claudeCodeAdapter = {
2113
2206
  resolvedChannels: input.resolvedChannels,
2114
2207
  team: input.team,
2115
2208
  consoleUrl: process.env["NEXT_PUBLIC_APP_URL"] || process.env["AGT_CONSOLE_URL"] || void 0,
2116
- hasQmd: input.integrations?.some((i) => i.definition_id === "qmd") ?? false
2209
+ hasQmd: input.integrations?.some((i) => i.definition_id === "qmd") ?? false,
2210
+ integrations: integrationSummaries
2117
2211
  };
2118
2212
  return [
2119
2213
  { relativePath: "CLAUDE.md", content: generateClaudeMd(claudeMdInput) },
@@ -2400,6 +2494,36 @@ var claudeCodeAdapter = {
2400
2494
  if (hasQmd) {
2401
2495
  this.writeMcpServer(codeName, "qmd", { command: "qmd", args: ["mcp"] });
2402
2496
  }
2497
+ const projectDir = getProjectDir(codeName);
2498
+ const claudeMdPath = join3(projectDir, "CLAUDE.md");
2499
+ try {
2500
+ const existing = readFileSync3(claudeMdPath, "utf-8");
2501
+ const summaries = integrations.map((i) => {
2502
+ const def = INTEGRATION_REGISTRY.find((d) => d.id === i.definition_id);
2503
+ return {
2504
+ id: i.definition_id,
2505
+ name: def?.name || i.definition_id,
2506
+ cliBinary: def?.cli_tool?.binary,
2507
+ description: def?.description
2508
+ };
2509
+ });
2510
+ const newSection = buildIntegrationsSection(summaries);
2511
+ let updated;
2512
+ if (existing.includes("## Integrations")) {
2513
+ updated = existing.replace(/## Integrations[\s\S]*?(?=## Rules)/, newSection);
2514
+ } else {
2515
+ updated = existing.replace("## Rules", `${newSection}## Rules`);
2516
+ }
2517
+ writeFileSync3(claudeMdPath, updated);
2518
+ const agentDir2 = getAgentDir(codeName);
2519
+ const envSrc = join3(agentDir2, ".env.integrations");
2520
+ try {
2521
+ const envContent = readFileSync3(envSrc, "utf-8");
2522
+ writeFileSync3(join3(projectDir, ".env.integrations"), envContent);
2523
+ } catch {
2524
+ }
2525
+ } catch {
2526
+ }
2403
2527
  },
2404
2528
  writeMcpServer(codeName, serverId, config) {
2405
2529
  const agentDir = getAgentDir(codeName);
@@ -2415,15 +2539,38 @@ var claudeCodeAdapter = {
2415
2539
  mcpConfig["mcpServers"] = {};
2416
2540
  }
2417
2541
  const mcpServers = mcpConfig["mcpServers"];
2418
- const serverEntry = { command: config.command };
2419
- if (config.args?.length)
2420
- serverEntry["args"] = config.args;
2421
- if (config.env && Object.keys(config.env).length)
2422
- serverEntry["env"] = config.env;
2542
+ let serverEntry;
2543
+ if ("url" in config) {
2544
+ serverEntry = { type: "sse", url: config.url };
2545
+ if (config.headers && Object.keys(config.headers).length)
2546
+ serverEntry["headers"] = config.headers;
2547
+ } else {
2548
+ serverEntry = { command: config.command };
2549
+ if (config.args?.length)
2550
+ serverEntry["args"] = config.args;
2551
+ if (config.env && Object.keys(config.env).length)
2552
+ serverEntry["env"] = config.env;
2553
+ }
2423
2554
  mcpServers[serverId] = serverEntry;
2424
2555
  writeFileSync3(mcpJsonPath, JSON.stringify(mcpConfig, null, 2));
2425
2556
  syncMcpToProject(codeName);
2426
2557
  },
2558
+ removeMcpServer(codeName, serverId) {
2559
+ const agentDir = getAgentDir(codeName);
2560
+ const mcpJsonPath = join3(agentDir, "provision", ".mcp.json");
2561
+ let mcpConfig;
2562
+ try {
2563
+ mcpConfig = JSON.parse(readFileSync3(mcpJsonPath, "utf-8"));
2564
+ } catch {
2565
+ return;
2566
+ }
2567
+ const mcpServers = mcpConfig["mcpServers"];
2568
+ if (!mcpServers || !(serverId in mcpServers))
2569
+ return;
2570
+ delete mcpServers[serverId];
2571
+ writeFileSync3(mcpJsonPath, JSON.stringify(mcpConfig, null, 2));
2572
+ syncMcpToProject(codeName);
2573
+ },
2427
2574
  installSkillFiles(codeName, skillId, files) {
2428
2575
  assertValidCodeName(skillId);
2429
2576
  const agentDir = getAgentDir(codeName);
@@ -4568,6 +4715,7 @@ export {
4568
4715
  CHANNEL_REGISTRY,
4569
4716
  getChannel,
4570
4717
  getAllChannelIds,
4718
+ provisionStopHook,
4571
4719
  getApiKey,
4572
4720
  getActiveTeam,
4573
4721
  setActiveTeam,
@@ -4598,4 +4746,4 @@ export {
4598
4746
  detectDrift,
4599
4747
  provision
4600
4748
  };
4601
- //# sourceMappingURL=chunk-QS2GCIWQ.js.map
4749
+ //# sourceMappingURL=chunk-B47JW4MM.js.map