@integrity-labs/agt-cli 0.10.12 → 0.10.13

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
@@ -2934,9 +2934,16 @@ function detectShellProfile() {
2934
2934
  if (existsSync4(bashrc)) return bashrc;
2935
2935
  return join10(home, ".bash_profile");
2936
2936
  }
2937
- function maybeWriteEtcEnvironment(apiUrl, apiKey) {
2937
+ function maybeWriteSystemWideEnv(apiUrl, apiKey) {
2938
2938
  if (process.platform === "win32") return false;
2939
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;
2945
+ }
2946
+ function writeEtcEnvironment(apiUrl, apiKey) {
2940
2947
  const envPath = "/etc/environment";
2941
2948
  if (!existsSync4(envPath)) return false;
2942
2949
  try {
@@ -2958,6 +2965,54 @@ AGT_API_KEY="${apiKey}"
2958
2965
  return false;
2959
2966
  }
2960
2967
  }
2968
+ function writeProfileDScript(apiUrl, apiKey) {
2969
+ const profileD = "/etc/profile.d";
2970
+ if (!existsSync4(profileD)) return false;
2971
+ try {
2972
+ accessSync(profileD, fsConstants.W_OK);
2973
+ } catch {
2974
+ return false;
2975
+ }
2976
+ try {
2977
+ const scriptPath = `${profileD}/agt.sh`;
2978
+ const content = [
2979
+ "# Augmented \u2014 auto-generated by `agt setup`. Do not edit.",
2980
+ `export AGT_HOST="${apiUrl}"`,
2981
+ `export AGT_API_KEY="${apiKey}"`,
2982
+ ""
2983
+ ].join("\n");
2984
+ writeFileSync5(scriptPath, content, { mode: 420 });
2985
+ return true;
2986
+ } catch {
2987
+ return false;
2988
+ }
2989
+ }
2990
+ function ensureBashrcSourcesProfileD() {
2991
+ const bashrc = "/etc/bashrc";
2992
+ if (!existsSync4(bashrc)) return false;
2993
+ try {
2994
+ accessSync(bashrc, fsConstants.W_OK);
2995
+ } catch {
2996
+ return false;
2997
+ }
2998
+ try {
2999
+ const current = readFileSync4(bashrc, "utf-8");
3000
+ const marker = "# Augmented (agt) \u2014 source system-wide AGT env";
3001
+ if (current.includes(marker)) return true;
3002
+ const snippet = [
3003
+ "",
3004
+ marker,
3005
+ "if [ -r /etc/profile.d/agt.sh ]; then",
3006
+ " . /etc/profile.d/agt.sh",
3007
+ "fi",
3008
+ ""
3009
+ ].join("\n");
3010
+ writeFileSync5(bashrc, current + snippet);
3011
+ return true;
3012
+ } catch {
3013
+ return false;
3014
+ }
3015
+ }
2961
3016
  function buildExportLines(shell, apiUrl, apiKey) {
2962
3017
  if (shell.includes("fish")) {
2963
3018
  return [
@@ -3077,9 +3132,9 @@ async function setupCommand(token) {
3077
3132
  if (!json) {
3078
3133
  success(`Environment variables written to ${chalk18.bold(profilePath)}`);
3079
3134
  }
3080
- const envWritten = maybeWriteEtcEnvironment(finalApiUrl, setupResult.api_key);
3135
+ const envWritten = maybeWriteSystemWideEnv(finalApiUrl, setupResult.api_key);
3081
3136
  if (!json && envWritten) {
3082
- success(`System-wide env written to ${chalk18.bold("/etc/environment")}`);
3137
+ success("System-wide env written to /etc/environment + /etc/profile.d/agt.sh");
3083
3138
  }
3084
3139
  const managerSpinner = ora13({ text: "Starting manager daemon\u2026", isSilent: json });
3085
3140
  managerSpinner.start();
@@ -3634,7 +3689,7 @@ async function acpxCloseCommand(agent2, _opts, cmd) {
3634
3689
  import { execSync } from "child_process";
3635
3690
  import chalk20 from "chalk";
3636
3691
  import ora15 from "ora";
3637
- var cliVersion = true ? "0.10.12" : "dev";
3692
+ var cliVersion = true ? "0.10.13" : "dev";
3638
3693
  async function fetchLatestVersion() {
3639
3694
  const host2 = getHost();
3640
3695
  if (!host2) return null;
@@ -4033,7 +4088,7 @@ function handleError(err) {
4033
4088
  }
4034
4089
 
4035
4090
  // src/bin/agt.ts
4036
- var cliVersion2 = true ? "0.10.12" : "dev";
4091
+ var cliVersion2 = true ? "0.10.13" : "dev";
4037
4092
  var program = new Command();
4038
4093
  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");
4039
4094
  program.hook("preAction", (thisCommand) => {