@integrity-labs/agt-cli 0.10.11 → 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 +86 -3
- package/dist/bin/agt.js.map +1 -1
- package/package.json +1 -1
package/dist/bin/agt.js
CHANGED
|
@@ -2915,7 +2915,7 @@ async function kanbanRecurringDisableCommand(titleOrId, opts) {
|
|
|
2915
2915
|
}
|
|
2916
2916
|
|
|
2917
2917
|
// src/commands/setup.ts
|
|
2918
|
-
import { existsSync as existsSync4, readFileSync as readFileSync4, writeFileSync as writeFileSync5, mkdirSync as mkdirSync5 } from "fs";
|
|
2918
|
+
import { existsSync as existsSync4, readFileSync as readFileSync4, writeFileSync as writeFileSync5, mkdirSync as mkdirSync5, accessSync, constants as fsConstants } from "fs";
|
|
2919
2919
|
import { join as join10, dirname } from "path";
|
|
2920
2920
|
import { homedir as homedir2 } from "os";
|
|
2921
2921
|
import chalk18 from "chalk";
|
|
@@ -2934,6 +2934,85 @@ function detectShellProfile() {
|
|
|
2934
2934
|
if (existsSync4(bashrc)) return bashrc;
|
|
2935
2935
|
return join10(home, ".bash_profile");
|
|
2936
2936
|
}
|
|
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;
|
|
2945
|
+
}
|
|
2946
|
+
function writeEtcEnvironment(apiUrl, apiKey) {
|
|
2947
|
+
const envPath = "/etc/environment";
|
|
2948
|
+
if (!existsSync4(envPath)) return false;
|
|
2949
|
+
try {
|
|
2950
|
+
accessSync(envPath, fsConstants.W_OK);
|
|
2951
|
+
} catch {
|
|
2952
|
+
return false;
|
|
2953
|
+
}
|
|
2954
|
+
try {
|
|
2955
|
+
const current = readFileSync4(envPath, "utf-8");
|
|
2956
|
+
const stripped = current.split(/\r?\n/).filter((line) => !/^\s*(?:export\s+)?AGT_(?:HOST|API_KEY)=/.test(line)).join("\n");
|
|
2957
|
+
const base = stripped.endsWith("\n") || stripped.length === 0 ? stripped : `${stripped}
|
|
2958
|
+
`;
|
|
2959
|
+
const appended = `${base}AGT_HOST="${apiUrl}"
|
|
2960
|
+
AGT_API_KEY="${apiKey}"
|
|
2961
|
+
`;
|
|
2962
|
+
writeFileSync5(envPath, appended, { mode: 420 });
|
|
2963
|
+
return true;
|
|
2964
|
+
} catch {
|
|
2965
|
+
return false;
|
|
2966
|
+
}
|
|
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
|
+
}
|
|
2937
3016
|
function buildExportLines(shell, apiUrl, apiKey) {
|
|
2938
3017
|
if (shell.includes("fish")) {
|
|
2939
3018
|
return [
|
|
@@ -3053,6 +3132,10 @@ async function setupCommand(token) {
|
|
|
3053
3132
|
if (!json) {
|
|
3054
3133
|
success(`Environment variables written to ${chalk18.bold(profilePath)}`);
|
|
3055
3134
|
}
|
|
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");
|
|
3138
|
+
}
|
|
3056
3139
|
const managerSpinner = ora13({ text: "Starting manager daemon\u2026", isSilent: json });
|
|
3057
3140
|
managerSpinner.start();
|
|
3058
3141
|
try {
|
|
@@ -3606,7 +3689,7 @@ async function acpxCloseCommand(agent2, _opts, cmd) {
|
|
|
3606
3689
|
import { execSync } from "child_process";
|
|
3607
3690
|
import chalk20 from "chalk";
|
|
3608
3691
|
import ora15 from "ora";
|
|
3609
|
-
var cliVersion = true ? "0.10.
|
|
3692
|
+
var cliVersion = true ? "0.10.13" : "dev";
|
|
3610
3693
|
async function fetchLatestVersion() {
|
|
3611
3694
|
const host2 = getHost();
|
|
3612
3695
|
if (!host2) return null;
|
|
@@ -4005,7 +4088,7 @@ function handleError(err) {
|
|
|
4005
4088
|
}
|
|
4006
4089
|
|
|
4007
4090
|
// src/bin/agt.ts
|
|
4008
|
-
var cliVersion2 = true ? "0.10.
|
|
4091
|
+
var cliVersion2 = true ? "0.10.13" : "dev";
|
|
4009
4092
|
var program = new Command();
|
|
4010
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");
|
|
4011
4094
|
program.hook("preAction", (thisCommand) => {
|