@integrity-labs/agt-cli 0.10.13 → 0.10.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
@@ -2935,13 +2935,23 @@ function detectShellProfile() {
2935
2935
  return join10(home, ".bash_profile");
2936
2936
  }
2937
2937
  function maybeWriteSystemWideEnv(apiUrl, apiKey) {
2938
- if (process.platform === "win32") return false;
2939
- if (typeof process.getuid !== "function" || process.getuid() !== 0) return false;
2940
- let wrote = false;
2941
- wrote = writeEtcEnvironment(apiUrl, apiKey) || wrote;
2942
- wrote = writeProfileDScript(apiUrl, apiKey) || wrote;
2943
- wrote = ensureBashrcSourcesProfileD() || wrote;
2944
- return wrote;
2938
+ const empty = { etcEnvironment: false, profileD: false, bashrc: false };
2939
+ if (process.platform === "win32") return empty;
2940
+ if (typeof process.getuid !== "function" || process.getuid() !== 0) return empty;
2941
+ return {
2942
+ etcEnvironment: writeEtcEnvironment(apiUrl, apiKey),
2943
+ profileD: writeProfileDScript(apiUrl, apiKey),
2944
+ // Run for its side-effect (wiring /etc/bashrc to source agt.sh) but
2945
+ // treat it as a supporting channel, not proof that env values were
2946
+ // persisted. Success reporting should reflect actual value writes.
2947
+ bashrc: ensureBashrcSourcesProfileD()
2948
+ };
2949
+ }
2950
+ function quoteForEtcEnvironment(value) {
2951
+ return `"${value.replace(/\\/g, "\\\\").replace(/"/g, '\\"').replace(/\r?\n/g, "\\n")}"`;
2952
+ }
2953
+ function quoteForPosixShell(value) {
2954
+ return `'${value.replace(/'/g, `'\\''`)}'`;
2945
2955
  }
2946
2956
  function writeEtcEnvironment(apiUrl, apiKey) {
2947
2957
  const envPath = "/etc/environment";
@@ -2956,8 +2966,8 @@ function writeEtcEnvironment(apiUrl, apiKey) {
2956
2966
  const stripped = current.split(/\r?\n/).filter((line) => !/^\s*(?:export\s+)?AGT_(?:HOST|API_KEY)=/.test(line)).join("\n");
2957
2967
  const base = stripped.endsWith("\n") || stripped.length === 0 ? stripped : `${stripped}
2958
2968
  `;
2959
- const appended = `${base}AGT_HOST="${apiUrl}"
2960
- AGT_API_KEY="${apiKey}"
2969
+ const appended = `${base}AGT_HOST=${quoteForEtcEnvironment(apiUrl)}
2970
+ AGT_API_KEY=${quoteForEtcEnvironment(apiKey)}
2961
2971
  `;
2962
2972
  writeFileSync5(envPath, appended, { mode: 420 });
2963
2973
  return true;
@@ -2977,8 +2987,8 @@ function writeProfileDScript(apiUrl, apiKey) {
2977
2987
  const scriptPath = `${profileD}/agt.sh`;
2978
2988
  const content = [
2979
2989
  "# Augmented \u2014 auto-generated by `agt setup`. Do not edit.",
2980
- `export AGT_HOST="${apiUrl}"`,
2981
- `export AGT_API_KEY="${apiKey}"`,
2990
+ `export AGT_HOST=${quoteForPosixShell(apiUrl)}`,
2991
+ `export AGT_API_KEY=${quoteForPosixShell(apiKey)}`,
2982
2992
  ""
2983
2993
  ].join("\n");
2984
2994
  writeFileSync5(scriptPath, content, { mode: 420 });
@@ -3132,9 +3142,15 @@ async function setupCommand(token) {
3132
3142
  if (!json) {
3133
3143
  success(`Environment variables written to ${chalk18.bold(profilePath)}`);
3134
3144
  }
3135
- const envWritten = maybeWriteSystemWideEnv(finalApiUrl, setupResult.api_key);
3136
- if (!json && envWritten) {
3137
- success("System-wide env written to /etc/environment + /etc/profile.d/agt.sh");
3145
+ const sys = maybeWriteSystemWideEnv(finalApiUrl, setupResult.api_key);
3146
+ const valueChannelsWritten = sys.etcEnvironment || sys.profileD;
3147
+ if (!json && valueChannelsWritten) {
3148
+ const channels2 = [
3149
+ sys.etcEnvironment ? "/etc/environment" : null,
3150
+ sys.profileD ? "/etc/profile.d/agt.sh" : null,
3151
+ sys.bashrc ? "/etc/bashrc" : null
3152
+ ].filter(Boolean).join(" + ");
3153
+ success(`System-wide env updated: ${channels2}`);
3138
3154
  }
3139
3155
  const managerSpinner = ora13({ text: "Starting manager daemon\u2026", isSilent: json });
3140
3156
  managerSpinner.start();
@@ -3689,7 +3705,7 @@ async function acpxCloseCommand(agent2, _opts, cmd) {
3689
3705
  import { execSync } from "child_process";
3690
3706
  import chalk20 from "chalk";
3691
3707
  import ora15 from "ora";
3692
- var cliVersion = true ? "0.10.13" : "dev";
3708
+ var cliVersion = true ? "0.10.14" : "dev";
3693
3709
  async function fetchLatestVersion() {
3694
3710
  const host2 = getHost();
3695
3711
  if (!host2) return null;
@@ -4088,7 +4104,7 @@ function handleError(err) {
4088
4104
  }
4089
4105
 
4090
4106
  // src/bin/agt.ts
4091
- var cliVersion2 = true ? "0.10.13" : "dev";
4107
+ var cliVersion2 = true ? "0.10.14" : "dev";
4092
4108
  var program = new Command();
4093
4109
  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");
4094
4110
  program.hook("preAction", (thisCommand) => {