@integrity-labs/agt-cli 0.7.5 → 0.7.7
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 +5 -5
- package/dist/bin/agt.js.map +1 -1
- package/dist/{chunk-GBTJNYNP.js → chunk-QS2GCIWQ.js} +24 -7
- package/dist/chunk-QS2GCIWQ.js.map +1 -0
- package/dist/lib/manager-worker.js +72 -10
- package/dist/lib/manager-worker.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunk-GBTJNYNP.js.map +0 -1
|
@@ -2500,8 +2500,11 @@ function ensureAugmentedDir() {
|
|
|
2500
2500
|
mkdirSync4(AUGMENTED_DIR2, { recursive: true });
|
|
2501
2501
|
}
|
|
2502
2502
|
}
|
|
2503
|
-
function
|
|
2504
|
-
|
|
2503
|
+
function reloadFromShellProfile() {
|
|
2504
|
+
return loadFromShellProfile(true);
|
|
2505
|
+
}
|
|
2506
|
+
function loadFromShellProfile(force = false) {
|
|
2507
|
+
if (!force && process.env["AGT_HOST"] && process.env["AGT_API_KEY"]) return;
|
|
2505
2508
|
const shell = process.env["SHELL"] ?? "";
|
|
2506
2509
|
const home = homedir3();
|
|
2507
2510
|
const candidates = shell.includes("zsh") ? [join4(home, ".zshrc"), join4(home, ".zprofile")] : shell.includes("fish") ? [join4(home, ".config", "fish", "config.fish")] : [join4(home, ".bashrc"), join4(home, ".bash_profile")];
|
|
@@ -2509,8 +2512,14 @@ function loadFromShellProfile() {
|
|
|
2509
2512
|
try {
|
|
2510
2513
|
const content = readFileSync4(profile, "utf-8");
|
|
2511
2514
|
for (const key of ["AGT_HOST", "AGT_API_KEY", "AGT_TEAM"]) {
|
|
2512
|
-
if (process.env[key]) continue;
|
|
2513
|
-
const match = content.
|
|
2515
|
+
if (!force && process.env[key]) continue;
|
|
2516
|
+
const match = content.split(/\r?\n/).map((line) => line.trim()).filter((line) => line.length > 0 && !line.startsWith("#")).map(
|
|
2517
|
+
(line) => line.match(
|
|
2518
|
+
new RegExp(
|
|
2519
|
+
`^(?:export\\s+${key}\\s*=\\s*["']([^"']+)["']|set\\s+-gx\\s+${key}\\s+["']([^"']+)["'])$`
|
|
2520
|
+
)
|
|
2521
|
+
)
|
|
2522
|
+
).find(Boolean);
|
|
2514
2523
|
if (match) {
|
|
2515
2524
|
process.env[key] = match[1] ?? match[2];
|
|
2516
2525
|
}
|
|
@@ -2556,7 +2565,7 @@ function requireHost() {
|
|
|
2556
2565
|
|
|
2557
2566
|
// src/lib/api-client.ts
|
|
2558
2567
|
var cachedExchange = null;
|
|
2559
|
-
async function exchangeApiKey(rawKey) {
|
|
2568
|
+
async function exchangeApiKey(rawKey, retried = false) {
|
|
2560
2569
|
if (cachedExchange && Date.now() < cachedExchange.expiresAt - 6e4) {
|
|
2561
2570
|
return {
|
|
2562
2571
|
token: cachedExchange.token,
|
|
@@ -2575,9 +2584,17 @@ async function exchangeApiKey(rawKey) {
|
|
|
2575
2584
|
});
|
|
2576
2585
|
if (!res.ok) {
|
|
2577
2586
|
const body = await res.json().catch(() => ({}));
|
|
2587
|
+
const errorMsg = String(body["error"] ?? res.statusText);
|
|
2588
|
+
if (errorMsg.includes("revoked") && !retried) {
|
|
2589
|
+
reloadFromShellProfile();
|
|
2590
|
+
const freshKey = getApiKey();
|
|
2591
|
+
if (freshKey && freshKey !== rawKey) {
|
|
2592
|
+
return exchangeApiKey(freshKey, true);
|
|
2593
|
+
}
|
|
2594
|
+
}
|
|
2578
2595
|
const host = requireHost();
|
|
2579
2596
|
const obfuscated = rawKey.length > 12 ? `${rawKey.slice(0, 8)}${"*".repeat(rawKey.length - 12)}${rawKey.slice(-4)}` : rawKey.slice(0, 4) + "****";
|
|
2580
|
-
throw new Error(`API key exchange failed: ${
|
|
2597
|
+
throw new Error(`API key exchange failed: ${errorMsg} (host=${host}, key=${obfuscated})`);
|
|
2581
2598
|
}
|
|
2582
2599
|
const data = await res.json();
|
|
2583
2600
|
if (!data.token) {
|
|
@@ -4581,4 +4598,4 @@ export {
|
|
|
4581
4598
|
detectDrift,
|
|
4582
4599
|
provision
|
|
4583
4600
|
};
|
|
4584
|
-
//# sourceMappingURL=chunk-
|
|
4601
|
+
//# sourceMappingURL=chunk-QS2GCIWQ.js.map
|