@integrity-labs/agt-cli 0.14.12 → 0.14.14

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
@@ -8,6 +8,7 @@ import {
8
8
  SlackApiError,
9
9
  api,
10
10
  createSlackApp,
11
+ deriveConsoleUrl,
11
12
  detectDrift,
12
13
  error,
13
14
  exchangeApiKey,
@@ -44,7 +45,7 @@ import {
44
45
  success,
45
46
  table,
46
47
  warn
47
- } from "../chunk-NSHSUWZQ.js";
48
+ } from "../chunk-VWCF6BOZ.js";
48
49
 
49
50
  // src/bin/agt.ts
50
51
  import { join as join9 } from "path";
@@ -2608,13 +2609,13 @@ function detectShellProfile() {
2608
2609
  if (existsSync3(bashrc)) return bashrc;
2609
2610
  return join8(home, ".bash_profile");
2610
2611
  }
2611
- function maybeWriteSystemWideEnv(apiUrl, apiKey) {
2612
+ function maybeWriteSystemWideEnv(apiUrl, apiKey, consoleUrl) {
2612
2613
  const empty = { etcEnvironment: false, profileD: false, bashrc: false };
2613
2614
  if (process.platform === "win32") return empty;
2614
2615
  if (typeof process.getuid !== "function" || process.getuid() !== 0) return empty;
2615
2616
  return {
2616
- etcEnvironment: writeEtcEnvironment(apiUrl, apiKey),
2617
- profileD: writeProfileDScript(apiUrl, apiKey),
2617
+ etcEnvironment: writeEtcEnvironment(apiUrl, apiKey, consoleUrl),
2618
+ profileD: writeProfileDScript(apiUrl, apiKey, consoleUrl),
2618
2619
  // Run for its side-effect (wiring /etc/bashrc to source agt.sh) but
2619
2620
  // treat it as a supporting channel, not proof that env values were
2620
2621
  // persisted. Success reporting should reflect actual value writes.
@@ -2627,7 +2628,10 @@ function quoteForEtcEnvironment(value) {
2627
2628
  function quoteForPosixShell(value) {
2628
2629
  return `'${value.replace(/'/g, `'\\''`)}'`;
2629
2630
  }
2630
- function writeEtcEnvironment(apiUrl, apiKey) {
2631
+ function quoteForFishShell(value) {
2632
+ return `'${value.replace(/\\/g, "\\\\").replace(/'/g, `\\'`)}'`;
2633
+ }
2634
+ function writeEtcEnvironment(apiUrl, apiKey, consoleUrl) {
2631
2635
  const envPath = "/etc/environment";
2632
2636
  if (!existsSync3(envPath)) return false;
2633
2637
  try {
@@ -2637,11 +2641,15 @@ function writeEtcEnvironment(apiUrl, apiKey) {
2637
2641
  }
2638
2642
  try {
2639
2643
  const current = readFileSync3(envPath, "utf-8");
2640
- const stripped = current.split(/\r?\n/).filter((line) => !/^\s*(?:export\s+)?AGT_(?:HOST|API_KEY)=/.test(line)).join("\n");
2644
+ const stripped = current.split(/\r?\n/).filter((line) => !/^\s*(?:export\s+)?AGT_(?:HOST|API_KEY|CONSOLE_URL)=/.test(line)).join("\n");
2641
2645
  const base = stripped.endsWith("\n") || stripped.length === 0 ? stripped : `${stripped}
2642
2646
  `;
2643
- const appended = `${base}AGT_HOST=${quoteForEtcEnvironment(apiUrl)}
2644
- AGT_API_KEY=${quoteForEtcEnvironment(apiKey)}
2647
+ const lines = [
2648
+ `AGT_HOST=${quoteForEtcEnvironment(apiUrl)}`,
2649
+ `AGT_API_KEY=${quoteForEtcEnvironment(apiKey)}`
2650
+ ];
2651
+ if (consoleUrl) lines.push(`AGT_CONSOLE_URL=${quoteForEtcEnvironment(consoleUrl)}`);
2652
+ const appended = `${base}${lines.join("\n")}
2645
2653
  `;
2646
2654
  writeFileSync4(envPath, appended, { mode: 420 });
2647
2655
  return true;
@@ -2649,7 +2657,7 @@ AGT_API_KEY=${quoteForEtcEnvironment(apiKey)}
2649
2657
  return false;
2650
2658
  }
2651
2659
  }
2652
- function writeProfileDScript(apiUrl, apiKey) {
2660
+ function writeProfileDScript(apiUrl, apiKey, consoleUrl) {
2653
2661
  const profileD = "/etc/profile.d";
2654
2662
  if (!existsSync3(profileD)) return false;
2655
2663
  try {
@@ -2659,13 +2667,14 @@ function writeProfileDScript(apiUrl, apiKey) {
2659
2667
  }
2660
2668
  try {
2661
2669
  const scriptPath = `${profileD}/agt.sh`;
2662
- const content = [
2670
+ const lines = [
2663
2671
  "# Augmented \u2014 auto-generated by `agt setup`. Do not edit.",
2664
2672
  `export AGT_HOST=${quoteForPosixShell(apiUrl)}`,
2665
- `export AGT_API_KEY=${quoteForPosixShell(apiKey)}`,
2666
- ""
2667
- ].join("\n");
2668
- writeFileSync4(scriptPath, content, { mode: 420 });
2673
+ `export AGT_API_KEY=${quoteForPosixShell(apiKey)}`
2674
+ ];
2675
+ if (consoleUrl) lines.push(`export AGT_CONSOLE_URL=${quoteForPosixShell(consoleUrl)}`);
2676
+ lines.push("");
2677
+ writeFileSync4(scriptPath, lines.join("\n"), { mode: 420 });
2669
2678
  return true;
2670
2679
  } catch {
2671
2680
  return false;
@@ -2697,23 +2706,27 @@ function ensureBashrcSourcesProfileD() {
2697
2706
  return false;
2698
2707
  }
2699
2708
  }
2700
- function buildExportLines(shell, apiUrl, apiKey) {
2709
+ function buildExportLines(shell, apiUrl, apiKey, consoleUrl) {
2701
2710
  if (shell.includes("fish")) {
2702
- return [
2711
+ const lines2 = [
2703
2712
  "",
2704
2713
  "# Augmented (agt) host configuration",
2705
- `set -gx AGT_HOST "${apiUrl}"`,
2706
- `set -gx AGT_API_KEY "${apiKey}"`,
2707
- ""
2708
- ].join("\n");
2714
+ `set -gx AGT_HOST ${quoteForFishShell(apiUrl)}`,
2715
+ `set -gx AGT_API_KEY ${quoteForFishShell(apiKey)}`
2716
+ ];
2717
+ if (consoleUrl) lines2.push(`set -gx AGT_CONSOLE_URL ${quoteForFishShell(consoleUrl)}`);
2718
+ lines2.push("");
2719
+ return lines2.join("\n");
2709
2720
  }
2710
- return [
2721
+ const lines = [
2711
2722
  "",
2712
2723
  "# Augmented (agt) host configuration",
2713
- `export AGT_HOST="${apiUrl}"`,
2714
- `export AGT_API_KEY="${apiKey}"`,
2715
- ""
2716
- ].join("\n");
2724
+ `export AGT_HOST=${quoteForPosixShell(apiUrl)}`,
2725
+ `export AGT_API_KEY=${quoteForPosixShell(apiKey)}`
2726
+ ];
2727
+ if (consoleUrl) lines.push(`export AGT_CONSOLE_URL=${quoteForPosixShell(consoleUrl)}`);
2728
+ lines.push("");
2729
+ return lines.join("\n");
2717
2730
  }
2718
2731
  async function setupCommand(token) {
2719
2732
  const json = isJsonMode();
@@ -2792,7 +2805,16 @@ async function setupCommand(token) {
2792
2805
  }
2793
2806
  const profilePath = detectShellProfile();
2794
2807
  const shell = process.env["SHELL"] ?? "bash";
2795
- const exportLines = buildExportLines(shell, finalApiUrl, setupResult.api_key);
2808
+ const consoleUrl = deriveConsoleUrl(finalApiUrl);
2809
+ if (consoleUrl) {
2810
+ process.env["AGT_CONSOLE_URL"] = consoleUrl;
2811
+ }
2812
+ if (!json && !consoleUrl) {
2813
+ warn(
2814
+ `Could not derive AGT_CONSOLE_URL from ${finalApiUrl} \u2014 scheduled-delivery deep links will be disabled until you set it manually.`
2815
+ );
2816
+ }
2817
+ const exportLines = buildExportLines(shell, finalApiUrl, setupResult.api_key, consoleUrl);
2796
2818
  const profileDir = dirname(profilePath);
2797
2819
  if (!existsSync3(profileDir)) {
2798
2820
  mkdirSync4(profileDir, { recursive: true });
@@ -2816,7 +2838,7 @@ async function setupCommand(token) {
2816
2838
  if (!json) {
2817
2839
  success(`Environment variables written to ${chalk15.bold(profilePath)}`);
2818
2840
  }
2819
- const sys = maybeWriteSystemWideEnv(finalApiUrl, setupResult.api_key);
2841
+ const sys = maybeWriteSystemWideEnv(finalApiUrl, setupResult.api_key, consoleUrl);
2820
2842
  const valueChannelsWritten = sys.etcEnvironment || sys.profileD;
2821
2843
  if (!json && valueChannelsWritten) {
2822
2844
  const channels2 = [
@@ -3380,7 +3402,7 @@ import { execFileSync, execSync } from "child_process";
3380
3402
  import { existsSync as existsSync4, realpathSync } from "fs";
3381
3403
  import chalk17 from "chalk";
3382
3404
  import ora15 from "ora";
3383
- var cliVersion = true ? "0.14.12" : "dev";
3405
+ var cliVersion = true ? "0.14.14" : "dev";
3384
3406
  async function fetchLatestVersion() {
3385
3407
  const host2 = getHost();
3386
3408
  if (!host2) return null;
@@ -3829,7 +3851,7 @@ function handleError(err) {
3829
3851
  }
3830
3852
 
3831
3853
  // src/bin/agt.ts
3832
- var cliVersion2 = true ? "0.14.12" : "dev";
3854
+ var cliVersion2 = true ? "0.14.14" : "dev";
3833
3855
  var program = new Command();
3834
3856
  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");
3835
3857
  program.hook("preAction", (thisCommand) => {