@integrity-labs/agt-cli 0.28.1249 → 0.28.1251
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/api-client-ECOBF6BM.js +39 -0
- package/dist/bin/agt.js +17 -15
- package/dist/bin/agt.js.map +1 -1
- package/dist/chunk-2VGFSHFP.js +471 -0
- package/dist/chunk-2VGFSHFP.js.map +1 -0
- package/dist/{chunk-COCLODTH.js → chunk-4AUE34MF.js} +162 -565
- package/dist/chunk-4AUE34MF.js.map +1 -0
- package/dist/{chunk-CMCT3LOQ.js → chunk-6KY5FKXC.js} +192 -1
- package/dist/chunk-6KY5FKXC.js.map +1 -0
- package/dist/{chunk-G5CNX4XF.js → chunk-O6WRX5FE.js} +26 -3
- package/dist/{chunk-G5CNX4XF.js.map → chunk-O6WRX5FE.js.map} +1 -1
- package/dist/{chunk-NNB7XNZA.js → chunk-OAAKFU3J.js} +2 -2
- package/dist/{chunk-IQ6MCAEK.js → chunk-VOMOPWFI.js} +2 -2
- package/dist/{claude-code-updater-EWJ6B5HX.js → claude-code-updater-2TZ4TSOB.js} +3 -3
- package/dist/{claude-pair-runtime-BJLV7HMD.js → claude-pair-runtime-CTJCJNK4.js} +3 -3
- package/dist/lib/manager-worker.js +484 -146
- package/dist/lib/manager-worker.js.map +1 -1
- package/dist/mcp/direct-chat-channel.js +5 -0
- package/dist/mcp/index.js +5 -0
- package/dist/mcp/origami.js +5 -0
- package/dist/mcp/slack-channel.js +5 -0
- package/dist/mcp/telegram-channel.js +367 -186
- package/dist/{persistent-session-ZTDFRERR.js → persistent-session-TBE4KP4K.js} +4 -4
- package/dist/persistent-session-TBE4KP4K.js.map +1 -0
- package/dist/{responsiveness-probe-SVSMKLYS.js → responsiveness-probe-J7DA3AB4.js} +4 -4
- package/dist/{session-auth-dead-K63LMSKK.js → session-auth-dead-OL5ODQRN.js} +3 -3
- package/package.json +1 -1
- package/dist/chunk-CMCT3LOQ.js.map +0 -1
- package/dist/chunk-COCLODTH.js.map +0 -1
- /package/dist/{claude-code-updater-EWJ6B5HX.js.map → api-client-ECOBF6BM.js.map} +0 -0
- /package/dist/{chunk-NNB7XNZA.js.map → chunk-OAAKFU3J.js.map} +0 -0
- /package/dist/{chunk-IQ6MCAEK.js.map → chunk-VOMOPWFI.js.map} +0 -0
- /package/dist/{persistent-session-ZTDFRERR.js.map → claude-code-updater-2TZ4TSOB.js.map} +0 -0
- /package/dist/{claude-pair-runtime-BJLV7HMD.js.map → claude-pair-runtime-CTJCJNK4.js.map} +0 -0
- /package/dist/{responsiveness-probe-SVSMKLYS.js.map → responsiveness-probe-J7DA3AB4.js.map} +0 -0
- /package/dist/{session-auth-dead-K63LMSKK.js.map → session-auth-dead-OL5ODQRN.js.map} +0 -0
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
import {
|
|
2
|
+
exchangeApiKey,
|
|
3
|
+
getApiKey,
|
|
4
|
+
getHost
|
|
5
|
+
} from "./chunk-2VGFSHFP.js";
|
|
1
6
|
import {
|
|
2
7
|
LATE_BOUND_VARS,
|
|
3
8
|
PLATFORM_DENY_PERMISSIONS,
|
|
@@ -18,11 +23,11 @@ import {
|
|
|
18
23
|
requiresRemoteMcpToolGate,
|
|
19
24
|
shellQuote,
|
|
20
25
|
withheldRemoteMcpMessage
|
|
21
|
-
} from "./chunk-
|
|
26
|
+
} from "./chunk-O6WRX5FE.js";
|
|
22
27
|
import {
|
|
23
28
|
readDailySessionPin,
|
|
24
29
|
sessionTranscriptDir
|
|
25
|
-
} from "./chunk-
|
|
30
|
+
} from "./chunk-VOMOPWFI.js";
|
|
26
31
|
import {
|
|
27
32
|
classifyUnanswerablePane,
|
|
28
33
|
isConsumerTermsDialogVisible,
|
|
@@ -34,7 +39,6 @@ import {
|
|
|
34
39
|
} from "./chunk-XWVM4KPK.js";
|
|
35
40
|
import {
|
|
36
41
|
BIND_FAILURE_QUARANTINE_THRESHOLD,
|
|
37
|
-
HOST_ROTATE_KEY_CONFLICT,
|
|
38
42
|
INTEGRATIONS_SECTION_END,
|
|
39
43
|
INTEGRATIONS_SECTION_START,
|
|
40
44
|
INTEGRATION_REGISTRY,
|
|
@@ -95,7 +99,7 @@ import {
|
|
|
95
99
|
scanConfigForLiteralSecrets,
|
|
96
100
|
worseConnectivityOutcome,
|
|
97
101
|
wrapScheduledTaskPrompt
|
|
98
|
-
} from "./chunk-
|
|
102
|
+
} from "./chunk-6KY5FKXC.js";
|
|
99
103
|
import {
|
|
100
104
|
claudeJsonPathFor,
|
|
101
105
|
effectiveClaudeJsonPath,
|
|
@@ -2745,24 +2749,32 @@ function syncMcpToProject(codeName) {
|
|
|
2745
2749
|
const projectDir = getProjectDir2(codeName);
|
|
2746
2750
|
const provisionMcpPath = join5(agentDir, "provision", ".mcp.json");
|
|
2747
2751
|
const projectMcpPath = join5(projectDir, ".mcp.json");
|
|
2752
|
+
let content = null;
|
|
2748
2753
|
try {
|
|
2749
|
-
|
|
2750
|
-
|
|
2751
|
-
|
|
2752
|
-
|
|
2753
|
-
chmodSync4(projectMcpPath, MCP_FILE_MODE);
|
|
2754
|
-
} catch {
|
|
2755
|
-
}
|
|
2754
|
+
content = readFileSync5(provisionMcpPath, "utf-8");
|
|
2755
|
+
} catch {
|
|
2756
|
+
}
|
|
2757
|
+
if (content !== null)
|
|
2756
2758
|
try {
|
|
2757
|
-
|
|
2758
|
-
|
|
2759
|
-
|
|
2759
|
+
mkdirSync4(projectDir, { recursive: true });
|
|
2760
|
+
writeFileSync5(projectMcpPath, content, { mode: MCP_FILE_MODE });
|
|
2761
|
+
try {
|
|
2762
|
+
chmodSync4(projectMcpPath, MCP_FILE_MODE);
|
|
2763
|
+
} catch {
|
|
2764
|
+
}
|
|
2765
|
+
try {
|
|
2766
|
+
const mismatches = mcpMirrorParityErrors(JSON.parse(content), JSON.parse(readFileSync5(projectMcpPath, "utf-8")));
|
|
2767
|
+
for (const m of mismatches) {
|
|
2768
|
+
process.stderr.write(`${formatMirrorMismatch(m)} agent=${codeName}
|
|
2760
2769
|
`);
|
|
2770
|
+
}
|
|
2771
|
+
} catch {
|
|
2761
2772
|
}
|
|
2762
|
-
} catch {
|
|
2773
|
+
} catch (err) {
|
|
2774
|
+
noteMcpWriteFailure(codeName);
|
|
2775
|
+
process.stderr.write(`[claudecode] project .mcp.json mirror write failed for '${codeName}': ${err.message}
|
|
2776
|
+
`);
|
|
2763
2777
|
}
|
|
2764
|
-
} catch {
|
|
2765
|
-
}
|
|
2766
2778
|
renderChannelMessageHandlerForAgent(codeName);
|
|
2767
2779
|
renderAugmentedWorkerForAgent(codeName);
|
|
2768
2780
|
}
|
|
@@ -2809,9 +2821,14 @@ function renderChannelMessageHandlerForAgent(codeName) {
|
|
|
2809
2821
|
}
|
|
2810
2822
|
}
|
|
2811
2823
|
}
|
|
2824
|
+
var mcpWriteFailures = /* @__PURE__ */ new Map();
|
|
2825
|
+
function noteMcpWriteFailure(codeName) {
|
|
2826
|
+
mcpWriteFailures.set(codeName, (mcpWriteFailures.get(codeName) ?? 0) + 1);
|
|
2827
|
+
}
|
|
2812
2828
|
function writeMcpJsonGuarded(codeName, path, config) {
|
|
2813
2829
|
const result = safeWriteMcpJson(path, config);
|
|
2814
2830
|
if (!result.written) {
|
|
2831
|
+
noteMcpWriteFailure(codeName);
|
|
2815
2832
|
process.stderr.write(`[manager-worker] [mcp-validate] skipping write for '${codeName}': ${formatValidationErrors(result.errors)}
|
|
2816
2833
|
`);
|
|
2817
2834
|
return false;
|
|
@@ -7771,6 +7788,48 @@ ${sections}`
|
|
|
7771
7788
|
return {};
|
|
7772
7789
|
return mcpServers;
|
|
7773
7790
|
},
|
|
7791
|
+
syncMcpMirror(codeName) {
|
|
7792
|
+
const provisionMcpPath = join5(getAgentDir(codeName), "provision", ".mcp.json");
|
|
7793
|
+
try {
|
|
7794
|
+
readFileSync5(provisionMcpPath, "utf-8");
|
|
7795
|
+
} catch (err) {
|
|
7796
|
+
const missing = err.code === "ENOENT";
|
|
7797
|
+
if (!missing || existsSync4(join5(getProjectDir2(codeName), ".mcp.json"))) {
|
|
7798
|
+
noteMcpWriteFailure(codeName);
|
|
7799
|
+
process.stderr.write(`[claudecode] MCP mirror repair for '${codeName}': provision/.mcp.json ${missing ? "is missing" : "is unreadable"} while a project mirror exists; the mirror cannot be repaired from it
|
|
7800
|
+
`);
|
|
7801
|
+
}
|
|
7802
|
+
return;
|
|
7803
|
+
}
|
|
7804
|
+
syncMcpToProject(codeName);
|
|
7805
|
+
},
|
|
7806
|
+
consumeMcpWriteFailures(codeName) {
|
|
7807
|
+
const n = mcpWriteFailures.get(codeName) ?? 0;
|
|
7808
|
+
mcpWriteFailures.delete(codeName);
|
|
7809
|
+
return n;
|
|
7810
|
+
},
|
|
7811
|
+
readMcpServersOrNull(codeName) {
|
|
7812
|
+
let raw;
|
|
7813
|
+
try {
|
|
7814
|
+
raw = readFileSync5(join5(getAgentDir(codeName), "provision", ".mcp.json"), "utf-8");
|
|
7815
|
+
} catch (err) {
|
|
7816
|
+
return err.code === "ENOENT" ? {} : null;
|
|
7817
|
+
}
|
|
7818
|
+
let parsed;
|
|
7819
|
+
try {
|
|
7820
|
+
parsed = JSON.parse(raw);
|
|
7821
|
+
} catch {
|
|
7822
|
+
return null;
|
|
7823
|
+
}
|
|
7824
|
+
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed))
|
|
7825
|
+
return null;
|
|
7826
|
+
const mcpServers = parsed["mcpServers"];
|
|
7827
|
+
if (mcpServers === void 0)
|
|
7828
|
+
return {};
|
|
7829
|
+
if (!mcpServers || typeof mcpServers !== "object" || Array.isArray(mcpServers))
|
|
7830
|
+
return null;
|
|
7831
|
+
return mcpServers;
|
|
7832
|
+
},
|
|
7774
7833
|
removeMcpServer(codeName, serverId) {
|
|
7775
7834
|
const agentDir = getAgentDir(codeName);
|
|
7776
7835
|
const mcpJsonPath = join5(agentDir, "provision", ".mcp.json");
|
|
@@ -7994,462 +8053,20 @@ function jsonOutput(data) {
|
|
|
7994
8053
|
console.log(JSON.stringify(data, null, 2));
|
|
7995
8054
|
}
|
|
7996
8055
|
|
|
7997
|
-
// src/lib/config.ts
|
|
7998
|
-
import { readFileSync as readFileSync6, writeFileSync as writeFileSync6, mkdirSync as mkdirSync5, existsSync as existsSync5 } from "fs";
|
|
7999
|
-
import { join as join6 } from "path";
|
|
8000
|
-
import { homedir as homedir4 } from "os";
|
|
8001
|
-
var AUGMENTED_DIR = join6(homedir4(), ".augmented");
|
|
8002
|
-
var CONFIG_PATH = join6(AUGMENTED_DIR, "config.json");
|
|
8003
|
-
function ensureAugmentedDir() {
|
|
8004
|
-
if (!existsSync5(AUGMENTED_DIR)) {
|
|
8005
|
-
mkdirSync5(AUGMENTED_DIR, { recursive: true });
|
|
8006
|
-
}
|
|
8007
|
-
}
|
|
8008
|
-
function reloadFromShellProfile() {
|
|
8009
|
-
return loadFromShellProfile(true);
|
|
8010
|
-
}
|
|
8011
|
-
function loadFromShellProfile(force = false) {
|
|
8012
|
-
if (!force && process.env["AGT_HOST"] && process.env["AGT_API_KEY"]) return;
|
|
8013
|
-
const shell = process.env["SHELL"] ?? "";
|
|
8014
|
-
const home = homedir4();
|
|
8015
|
-
const candidates = shell.includes("zsh") ? [join6(home, ".zshrc"), join6(home, ".zprofile")] : shell.includes("fish") ? [join6(home, ".config", "fish", "config.fish")] : [join6(home, ".bashrc"), join6(home, ".bash_profile")];
|
|
8016
|
-
for (const profile of candidates) {
|
|
8017
|
-
try {
|
|
8018
|
-
const content = readFileSync6(profile, "utf-8");
|
|
8019
|
-
for (const key of ["AGT_HOST", "AGT_API_KEY", "AGT_TEAM"]) {
|
|
8020
|
-
if (!force && process.env[key]) continue;
|
|
8021
|
-
const match = content.split(/\r?\n/).map((line) => line.trim()).filter((line) => line.length > 0 && !line.startsWith("#")).map(
|
|
8022
|
-
(line) => line.match(
|
|
8023
|
-
new RegExp(
|
|
8024
|
-
`^(?:export\\s+${key}\\s*=\\s*["']([^"']+)["']|set\\s+-gx\\s+${key}\\s+["']([^"']+)["'])$`
|
|
8025
|
-
)
|
|
8026
|
-
)
|
|
8027
|
-
).find(Boolean);
|
|
8028
|
-
if (match) {
|
|
8029
|
-
process.env[key] = match[1] ?? match[2];
|
|
8030
|
-
}
|
|
8031
|
-
}
|
|
8032
|
-
} catch {
|
|
8033
|
-
}
|
|
8034
|
-
if (process.env["AGT_HOST"] && process.env["AGT_API_KEY"]) break;
|
|
8035
|
-
}
|
|
8036
|
-
}
|
|
8037
|
-
loadFromShellProfile();
|
|
8038
|
-
function getApiKey() {
|
|
8039
|
-
return process.env["AGT_API_KEY"] ?? null;
|
|
8040
|
-
}
|
|
8041
|
-
function getConfig() {
|
|
8042
|
-
try {
|
|
8043
|
-
const raw = readFileSync6(CONFIG_PATH, "utf-8");
|
|
8044
|
-
return JSON.parse(raw);
|
|
8045
|
-
} catch {
|
|
8046
|
-
return {};
|
|
8047
|
-
}
|
|
8048
|
-
}
|
|
8049
|
-
function saveConfig(config) {
|
|
8050
|
-
ensureAugmentedDir();
|
|
8051
|
-
writeFileSync6(CONFIG_PATH, JSON.stringify(config, null, 2));
|
|
8052
|
-
}
|
|
8053
|
-
function getActiveTeam() {
|
|
8054
|
-
const envTeam = process.env["AGT_TEAM"];
|
|
8055
|
-
if (envTeam) return envTeam;
|
|
8056
|
-
return getConfig().active_team;
|
|
8057
|
-
}
|
|
8058
|
-
function setActiveTeam(slug) {
|
|
8059
|
-
const config = getConfig();
|
|
8060
|
-
config.active_team = slug;
|
|
8061
|
-
saveConfig(config);
|
|
8062
|
-
}
|
|
8063
|
-
var PROD_AGT_HOST = "https://api.augmented.team";
|
|
8064
|
-
var AGT_HOST_UNSET_MESSAGE = "AGT_HOST is not set. Set it to the API URL for your stage before running this command:\n Production: export AGT_HOST=https://api.augmented.team\n Non-prod stage: export AGT_HOST=https://<stage>.api.staging.augmented.team\n Local development: export AGT_HOST=http://api.agt.localhost:1355\n\nFor first-time host setup, pass --api-host <url> to `agt setup` instead \u2014 the setup command does NOT silently default to prod (ENG-5831).";
|
|
8065
|
-
function getHost() {
|
|
8066
|
-
const envHost = process.env["AGT_HOST"]?.trim();
|
|
8067
|
-
if (!envHost) {
|
|
8068
|
-
throw new Error(AGT_HOST_UNSET_MESSAGE);
|
|
8069
|
-
}
|
|
8070
|
-
return envHost;
|
|
8071
|
-
}
|
|
8072
|
-
function requireHost() {
|
|
8073
|
-
return getHost();
|
|
8074
|
-
}
|
|
8075
|
-
|
|
8076
|
-
// src/lib/auth-exchange-error.ts
|
|
8077
|
-
var ApiKeyExchangeError = class extends Error {
|
|
8078
|
-
constructor(message, status, transient) {
|
|
8079
|
-
super(message);
|
|
8080
|
-
this.status = status;
|
|
8081
|
-
this.transient = transient;
|
|
8082
|
-
this.name = "ApiKeyExchangeError";
|
|
8083
|
-
}
|
|
8084
|
-
};
|
|
8085
|
-
function isTransientExchangeStatus(status) {
|
|
8086
|
-
return status >= 500 || status === 429;
|
|
8087
|
-
}
|
|
8088
|
-
function isTransientAuthFailure(err) {
|
|
8089
|
-
return err instanceof ApiKeyExchangeError && err.transient;
|
|
8090
|
-
}
|
|
8091
|
-
function exchangeFailureKind(err) {
|
|
8092
|
-
if (!(err instanceof ApiKeyExchangeError)) return "unclassified";
|
|
8093
|
-
const status = err.status === null ? "transport" : String(err.status);
|
|
8094
|
-
return err.transient ? `transient-${status}` : `verdict-${status}`;
|
|
8095
|
-
}
|
|
8096
|
-
|
|
8097
|
-
// src/lib/api-client.ts
|
|
8098
|
-
var agtCliVersion = true ? "0.28.1249" : "dev";
|
|
8099
|
-
var lastConfigHash = null;
|
|
8100
|
-
function setConfigHash(hash) {
|
|
8101
|
-
lastConfigHash = hash && hash.length > 0 ? hash : null;
|
|
8102
|
-
}
|
|
8103
|
-
var cachedExchange = null;
|
|
8104
|
-
var exchangeInFlight = null;
|
|
8105
|
-
var exchangeForceCount = 0;
|
|
8106
|
-
var consumedExchangeForceCount = 0;
|
|
8107
|
-
function forceNextExchange() {
|
|
8108
|
-
exchangeForceCount += 1;
|
|
8109
|
-
}
|
|
8110
|
-
function getCachedClaudeAuthMode() {
|
|
8111
|
-
return cachedExchange?.claudeAuthMode ?? null;
|
|
8112
|
-
}
|
|
8113
|
-
function getCachedClaudeAuthModeRaw() {
|
|
8114
|
-
return cachedExchange?.claudeAuthModeRaw ?? null;
|
|
8115
|
-
}
|
|
8116
|
-
function invalidateExchange() {
|
|
8117
|
-
cachedExchange = null;
|
|
8118
|
-
lastConfigHash = null;
|
|
8119
|
-
}
|
|
8120
|
-
async function exchangeApiKey(rawKey, retried = false, opts = {}) {
|
|
8121
|
-
const withinMaxAge = opts.maxAgeMs === void 0 || cachedExchange !== null && Date.now() - cachedExchange.fetchedAt < opts.maxAgeMs;
|
|
8122
|
-
const forcePending = exchangeForceCount > consumedExchangeForceCount;
|
|
8123
|
-
if (!opts.forceRefresh && !forcePending && withinMaxAge && cachedExchange && Date.now() < cachedExchange.expiresAt - 6e4) {
|
|
8124
|
-
return {
|
|
8125
|
-
token: cachedExchange.token,
|
|
8126
|
-
hostId: cachedExchange.hostId,
|
|
8127
|
-
teamId: cachedExchange.teamId,
|
|
8128
|
-
teamSlug: cachedExchange.teamSlug,
|
|
8129
|
-
framework: cachedExchange.framework,
|
|
8130
|
-
hostKind: cachedExchange.hostKind,
|
|
8131
|
-
claudeAuthMode: cachedExchange.claudeAuthMode,
|
|
8132
|
-
claudeAuthModeRaw: cachedExchange.claudeAuthModeRaw,
|
|
8133
|
-
anthropicApiKeyFingerprint: cachedExchange.anthropicApiKeyFingerprint,
|
|
8134
|
-
anthropicApiKey: cachedExchange.anthropicApiKey,
|
|
8135
|
-
userEmail: cachedExchange.userEmail,
|
|
8136
|
-
supabaseUrl: cachedExchange.supabaseUrl,
|
|
8137
|
-
supabaseAnonKey: cachedExchange.supabaseAnonKey
|
|
8138
|
-
};
|
|
8139
|
-
}
|
|
8140
|
-
const observedForceCount = exchangeForceCount;
|
|
8141
|
-
if (exchangeInFlight) {
|
|
8142
|
-
return exchangeInFlight;
|
|
8143
|
-
}
|
|
8144
|
-
exchangeInFlight = doExchange(rawKey, retried);
|
|
8145
|
-
try {
|
|
8146
|
-
const result = await exchangeInFlight;
|
|
8147
|
-
consumedExchangeForceCount = observedForceCount;
|
|
8148
|
-
return result;
|
|
8149
|
-
} finally {
|
|
8150
|
-
exchangeInFlight = null;
|
|
8151
|
-
}
|
|
8152
|
-
}
|
|
8153
|
-
var DEFAULT_EXCHANGE_RETRY_ATTEMPTS = 2;
|
|
8154
|
-
var DEFAULT_EXCHANGE_RETRY_BASE_MS = 500;
|
|
8155
|
-
function exchangeRetryAttempts() {
|
|
8156
|
-
const raw = process.env["AGT_AUTH_EXCHANGE_RETRY_ATTEMPTS"];
|
|
8157
|
-
const parsed = raw ? parseInt(raw, 10) : NaN;
|
|
8158
|
-
if (Number.isFinite(parsed) && parsed >= 0) return Math.min(parsed, 5);
|
|
8159
|
-
return DEFAULT_EXCHANGE_RETRY_ATTEMPTS;
|
|
8160
|
-
}
|
|
8161
|
-
function exchangeRetryBaseMs() {
|
|
8162
|
-
const raw = process.env["AGT_AUTH_EXCHANGE_RETRY_BASE_MS"];
|
|
8163
|
-
const parsed = raw ? parseInt(raw, 10) : NaN;
|
|
8164
|
-
if (Number.isFinite(parsed) && parsed > 0) return Math.min(parsed, 5e3);
|
|
8165
|
-
return DEFAULT_EXCHANGE_RETRY_BASE_MS;
|
|
8166
|
-
}
|
|
8167
|
-
function asExchangeError(err) {
|
|
8168
|
-
if (err instanceof ApiKeyExchangeError) return err;
|
|
8169
|
-
const message = err instanceof Error ? err.message : String(err);
|
|
8170
|
-
return new ApiKeyExchangeError(message, null, true);
|
|
8171
|
-
}
|
|
8172
|
-
async function doExchange(rawKey, retried) {
|
|
8173
|
-
const maxRetries = exchangeRetryAttempts();
|
|
8174
|
-
const baseMs = exchangeRetryBaseMs();
|
|
8175
|
-
let lastErr;
|
|
8176
|
-
for (let attempt = 0; attempt <= maxRetries; attempt++) {
|
|
8177
|
-
try {
|
|
8178
|
-
return await attemptExchange(rawKey, retried);
|
|
8179
|
-
} catch (err) {
|
|
8180
|
-
const exchangeErr = asExchangeError(err);
|
|
8181
|
-
if (!exchangeErr.transient || attempt === maxRetries) throw exchangeErr;
|
|
8182
|
-
lastErr = exchangeErr;
|
|
8183
|
-
await new Promise((resolve) => setTimeout(resolve, baseMs * 2 ** attempt));
|
|
8184
|
-
}
|
|
8185
|
-
}
|
|
8186
|
-
throw lastErr ?? new ApiKeyExchangeError("API key exchange failed", null, true);
|
|
8187
|
-
}
|
|
8188
|
-
async function attemptExchange(rawKey, retried) {
|
|
8189
|
-
const res = await fetch(`${requireHost()}/host/exchange`, {
|
|
8190
|
-
method: "POST",
|
|
8191
|
-
headers: { "Content-Type": "application/json" },
|
|
8192
|
-
body: JSON.stringify({ host_key: rawKey })
|
|
8193
|
-
});
|
|
8194
|
-
if (!res.ok) {
|
|
8195
|
-
const body = await res.json().catch(() => ({}));
|
|
8196
|
-
const errorMsg = String(body["error"] ?? res.statusText);
|
|
8197
|
-
const host = requireHost();
|
|
8198
|
-
const obfuscated = rawKey.length > 12 ? `${rawKey.slice(0, 8)}${"*".repeat(rawKey.length - 12)}${rawKey.slice(-4)}` : rawKey.slice(0, 4) + "****";
|
|
8199
|
-
if (res.status >= 502 && res.status <= 504) {
|
|
8200
|
-
throw new ApiKeyExchangeError(
|
|
8201
|
-
`API unreachable (${res.status}): ${host} \u2014 is the API server running?`,
|
|
8202
|
-
res.status,
|
|
8203
|
-
true
|
|
8204
|
-
);
|
|
8205
|
-
}
|
|
8206
|
-
if (errorMsg.includes("revoked") && !retried) {
|
|
8207
|
-
reloadFromShellProfile();
|
|
8208
|
-
const freshKey = getApiKey();
|
|
8209
|
-
if (freshKey && freshKey !== rawKey) {
|
|
8210
|
-
return attemptExchange(freshKey, true);
|
|
8211
|
-
}
|
|
8212
|
-
}
|
|
8213
|
-
throw new ApiKeyExchangeError(
|
|
8214
|
-
`API key exchange failed: ${errorMsg} (host=${host}, key=${obfuscated})`,
|
|
8215
|
-
res.status,
|
|
8216
|
-
isTransientExchangeStatus(res.status)
|
|
8217
|
-
);
|
|
8218
|
-
}
|
|
8219
|
-
const data = await res.json();
|
|
8220
|
-
if (!data.token) {
|
|
8221
|
-
throw new ApiKeyExchangeError("API key exchange returned no token", null, true);
|
|
8222
|
-
}
|
|
8223
|
-
const claudeAuthMode = data.claude_auth_mode === "api_key" ? "api_key" : data.claude_auth_mode === "openrouter" ? "openrouter" : "subscription";
|
|
8224
|
-
const claudeAuthModeRaw = data.claude_auth_mode ?? null;
|
|
8225
|
-
cachedExchange = {
|
|
8226
|
-
token: data.token,
|
|
8227
|
-
hostId: data.host_id,
|
|
8228
|
-
teamId: data.team_id,
|
|
8229
|
-
teamSlug: data.team_slug,
|
|
8230
|
-
framework: data.framework ?? null,
|
|
8231
|
-
hostKind: data.host_kind ?? null,
|
|
8232
|
-
claudeAuthMode,
|
|
8233
|
-
claudeAuthModeRaw,
|
|
8234
|
-
anthropicApiKeyFingerprint: data.anthropic_api_key_fingerprint ?? null,
|
|
8235
|
-
anthropicApiKey: data.anthropic_api_key ?? null,
|
|
8236
|
-
userEmail: data.user_email,
|
|
8237
|
-
supabaseUrl: data.supabase_url,
|
|
8238
|
-
supabaseAnonKey: data.supabase_anon_key,
|
|
8239
|
-
expiresAt: new Date(data.expires_at).getTime(),
|
|
8240
|
-
fetchedAt: Date.now()
|
|
8241
|
-
};
|
|
8242
|
-
return {
|
|
8243
|
-
token: data.token,
|
|
8244
|
-
hostId: data.host_id,
|
|
8245
|
-
teamId: data.team_id,
|
|
8246
|
-
teamSlug: data.team_slug,
|
|
8247
|
-
framework: data.framework ?? null,
|
|
8248
|
-
hostKind: data.host_kind ?? null,
|
|
8249
|
-
claudeAuthMode,
|
|
8250
|
-
claudeAuthModeRaw,
|
|
8251
|
-
anthropicApiKeyFingerprint: data.anthropic_api_key_fingerprint ?? null,
|
|
8252
|
-
anthropicApiKey: data.anthropic_api_key ?? null,
|
|
8253
|
-
userEmail: data.user_email,
|
|
8254
|
-
supabaseUrl: data.supabase_url,
|
|
8255
|
-
supabaseAnonKey: data.supabase_anon_key
|
|
8256
|
-
};
|
|
8257
|
-
}
|
|
8258
|
-
async function mintAgentKey(rawHostKey, agentId) {
|
|
8259
|
-
const res = await fetch(`${requireHost()}/host/agent-key`, {
|
|
8260
|
-
method: "POST",
|
|
8261
|
-
headers: { "Content-Type": "application/json" },
|
|
8262
|
-
body: JSON.stringify({ host_key: rawHostKey, agent_id: agentId })
|
|
8263
|
-
});
|
|
8264
|
-
if (!res.ok) {
|
|
8265
|
-
const body = await res.json().catch(() => ({}));
|
|
8266
|
-
const errorMsg = String(body["error"] ?? res.statusText);
|
|
8267
|
-
throw new Error(`Per-agent key mint failed (${res.status}) for agent=${agentId}: ${errorMsg}`);
|
|
8268
|
-
}
|
|
8269
|
-
const data = await res.json();
|
|
8270
|
-
if (!data.agent_key) {
|
|
8271
|
-
throw new Error(`Per-agent key mint returned no key for agent=${agentId}`);
|
|
8272
|
-
}
|
|
8273
|
-
return data.agent_key;
|
|
8274
|
-
}
|
|
8275
|
-
async function mintRotatedHostKey(rawHostKey) {
|
|
8276
|
-
const res = await fetch(`${requireHost()}/host/rotate-key`, {
|
|
8277
|
-
method: "POST",
|
|
8278
|
-
headers: { "Content-Type": "application/json" },
|
|
8279
|
-
body: JSON.stringify({ host_key: rawHostKey }),
|
|
8280
|
-
// BOUNDED, because this await is now on the poll cycle's critical path
|
|
8281
|
-
// (CodeRabbit on #7114). The rotation moved onto the heartbeat handler,
|
|
8282
|
-
// which `pollCycleInner` awaits, so an unanswered mint blocks the Claude
|
|
8283
|
-
// Code updater, the responsiveness probe, the wedge and pane-fatal checks,
|
|
8284
|
-
// the /host/agents fetch and every per-agent `processAgent` for as long as
|
|
8285
|
-
// it hangs — and Node's built-in fetch waits 300s by default. The
|
|
8286
|
-
// 5-minute retry backoff would then re-arm the same stall. 10s matches the
|
|
8287
|
-
// other short calls in this process (`telegram-ingest.ts`). A timeout
|
|
8288
|
-
// surfaces as a thrown error, which `adoptRotatedHostKey` reports as
|
|
8289
|
-
// `error` and the manager retries after the backoff. The abort cancels the
|
|
8290
|
-
// client, not the route, so the key may already be minted and recorded;
|
|
8291
|
-
// a lost response after the commit is the same case. The retry still
|
|
8292
|
-
// works: the server discards a minted key nobody has ever authenticated
|
|
8293
|
-
// with once it is older than HOST_SELF_ROTATION_STALE_MINT_MS, which is
|
|
8294
|
-
// shorter than the backoff, and mints again (ENG-11826; it used to need a
|
|
8295
|
-
// `compromised` rotation, Obi Wan `9b564171021b` on #7114). That covers
|
|
8296
|
-
// the backoff retry; a manager that restarts inside the window gets
|
|
8297
|
-
// `mint_pending`, which this version retries and older versions do not.
|
|
8298
|
-
signal: AbortSignal.timeout(1e4)
|
|
8299
|
-
});
|
|
8300
|
-
if (res.status === 403) {
|
|
8301
|
-
return null;
|
|
8302
|
-
}
|
|
8303
|
-
if (res.status === 409) {
|
|
8304
|
-
const body = await res.json().catch(() => ({}));
|
|
8305
|
-
if (body["code"] === HOST_ROTATE_KEY_CONFLICT.mintPending) {
|
|
8306
|
-
throw new Error(`Host key rotation mint deferred: ${String(body["error"] ?? "a mint is in flight")}`);
|
|
8307
|
-
}
|
|
8308
|
-
if (body["code"] === HOST_ROTATE_KEY_CONFLICT.alreadyHoldsMintedKey && typeof body["prefix"] === "string" && body["prefix"]) {
|
|
8309
|
-
return { alreadyHolds: body["prefix"] };
|
|
8310
|
-
}
|
|
8311
|
-
return { refused: String(body["error"] ?? "conflict") };
|
|
8312
|
-
}
|
|
8313
|
-
if (!res.ok) {
|
|
8314
|
-
const body = await res.json().catch(() => ({}));
|
|
8315
|
-
throw new Error(`Host key rotation mint failed (${res.status}): ${String(body["error"] ?? res.statusText)}`);
|
|
8316
|
-
}
|
|
8317
|
-
const data = await res.json();
|
|
8318
|
-
const prefix = data.key?.prefix;
|
|
8319
|
-
const rawKey = data.key?.raw_key;
|
|
8320
|
-
if (!prefix || !rawKey) return null;
|
|
8321
|
-
return { prefix, rawKey };
|
|
8322
|
-
}
|
|
8323
|
-
async function probeHostKey(rawKey) {
|
|
8324
|
-
let res;
|
|
8325
|
-
try {
|
|
8326
|
-
res = await fetch(`${requireHost()}/host/exchange`, {
|
|
8327
|
-
method: "POST",
|
|
8328
|
-
headers: { "Content-Type": "application/json" },
|
|
8329
|
-
body: JSON.stringify({ host_key: rawKey }),
|
|
8330
|
-
// Same bound as the mint, for the same reason: it runs on the poll cycle.
|
|
8331
|
-
signal: AbortSignal.timeout(1e4)
|
|
8332
|
-
});
|
|
8333
|
-
} catch {
|
|
8334
|
-
return "unknown";
|
|
8335
|
-
}
|
|
8336
|
-
if (res.ok) return "live";
|
|
8337
|
-
if (res.status === 401) {
|
|
8338
|
-
const body = await res.json().catch(() => ({}));
|
|
8339
|
-
if (body["code"] === "key_revoked" || body["code"] === "invalid_key" || body["code"] === "key_expired") {
|
|
8340
|
-
return "unusable";
|
|
8341
|
-
}
|
|
8342
|
-
}
|
|
8343
|
-
return "unknown";
|
|
8344
|
-
}
|
|
8345
|
-
function adoptHostKeyInProcess(rawKey) {
|
|
8346
|
-
process.env["AGT_API_KEY"] = rawKey;
|
|
8347
|
-
forceNextExchange();
|
|
8348
|
-
}
|
|
8349
|
-
async function resolveAuth() {
|
|
8350
|
-
const apiKey = getApiKey();
|
|
8351
|
-
if (!apiKey) {
|
|
8352
|
-
throw new Error("AGT_API_KEY is not set. Export it with your host API key (tlk_...)");
|
|
8353
|
-
}
|
|
8354
|
-
const exchange = await exchangeApiKey(apiKey);
|
|
8355
|
-
return { token: exchange.token, hostId: exchange.hostId };
|
|
8356
|
-
}
|
|
8357
|
-
async function buildHeaders() {
|
|
8358
|
-
const apiKey = getApiKey();
|
|
8359
|
-
if (!apiKey) {
|
|
8360
|
-
throw new Error("AGT_API_KEY is not set. Export it with your host API key (tlk_...)");
|
|
8361
|
-
}
|
|
8362
|
-
const exchange = await exchangeApiKey(apiKey);
|
|
8363
|
-
const headers = {
|
|
8364
|
-
"Authorization": `Bearer ${exchange.token}`,
|
|
8365
|
-
"Content-Type": "application/json",
|
|
8366
|
-
// ENG-6410: lets the API stamp audit_log.agt_cli_version for host-runtime
|
|
8367
|
-
// actions so bug rates can be tracked per CLI version.
|
|
8368
|
-
"X-Agt-Cli-Version": agtCliVersion
|
|
8369
|
-
};
|
|
8370
|
-
if (lastConfigHash) {
|
|
8371
|
-
headers["X-Config-Hash"] = lastConfigHash;
|
|
8372
|
-
}
|
|
8373
|
-
const team = getActiveTeam() ?? exchange.teamSlug;
|
|
8374
|
-
if (team) {
|
|
8375
|
-
headers["X-Team-Slug"] = team;
|
|
8376
|
-
}
|
|
8377
|
-
return headers;
|
|
8378
|
-
}
|
|
8379
|
-
var ApiError = class extends Error {
|
|
8380
|
-
constructor(status, body) {
|
|
8381
|
-
super(body["error"] ?? `HTTP ${status}`);
|
|
8382
|
-
this.status = status;
|
|
8383
|
-
this.body = body;
|
|
8384
|
-
this.name = "ApiError";
|
|
8385
|
-
}
|
|
8386
|
-
};
|
|
8387
|
-
async function fetchWithRetry(path, method, body, extraHeaders) {
|
|
8388
|
-
const baseHeaders = await buildHeaders();
|
|
8389
|
-
const headers = extraHeaders ? { ...baseHeaders, ...extraHeaders } : baseHeaders;
|
|
8390
|
-
const url = `${requireHost()}${path}`;
|
|
8391
|
-
const init = {
|
|
8392
|
-
method,
|
|
8393
|
-
headers,
|
|
8394
|
-
body: body !== void 0 ? JSON.stringify(body) : void 0
|
|
8395
|
-
};
|
|
8396
|
-
const res = await fetch(url, init);
|
|
8397
|
-
if (res.status === 401) {
|
|
8398
|
-
invalidateExchange();
|
|
8399
|
-
const freshBase = await buildHeaders();
|
|
8400
|
-
const freshHeaders = extraHeaders ? { ...freshBase, ...extraHeaders } : freshBase;
|
|
8401
|
-
return fetch(url, { ...init, headers: freshHeaders });
|
|
8402
|
-
}
|
|
8403
|
-
return res;
|
|
8404
|
-
}
|
|
8405
|
-
async function handleResponse(res) {
|
|
8406
|
-
const body = await res.json().catch(() => ({}));
|
|
8407
|
-
if (!res.ok) {
|
|
8408
|
-
throw new ApiError(res.status, body);
|
|
8409
|
-
}
|
|
8410
|
-
return body;
|
|
8411
|
-
}
|
|
8412
|
-
var api = {
|
|
8413
|
-
async get(path) {
|
|
8414
|
-
const res = await fetchWithRetry(path, "GET");
|
|
8415
|
-
return handleResponse(res);
|
|
8416
|
-
},
|
|
8417
|
-
async post(path, body, extraHeaders) {
|
|
8418
|
-
const res = await fetchWithRetry(path, "POST", body, extraHeaders);
|
|
8419
|
-
return handleResponse(res);
|
|
8420
|
-
},
|
|
8421
|
-
async patch(path, body) {
|
|
8422
|
-
const res = await fetchWithRetry(path, "PATCH", body);
|
|
8423
|
-
return handleResponse(res);
|
|
8424
|
-
},
|
|
8425
|
-
async put(path, body) {
|
|
8426
|
-
const res = await fetchWithRetry(path, "PUT", body);
|
|
8427
|
-
return handleResponse(res);
|
|
8428
|
-
},
|
|
8429
|
-
async del(path) {
|
|
8430
|
-
const res = await fetchWithRetry(path, "DELETE");
|
|
8431
|
-
return handleResponse(res);
|
|
8432
|
-
}
|
|
8433
|
-
};
|
|
8434
|
-
async function getHostId() {
|
|
8435
|
-
const { hostId } = await resolveAuth();
|
|
8436
|
-
return hostId;
|
|
8437
|
-
}
|
|
8438
|
-
|
|
8439
8056
|
// src/lib/atomic-write.ts
|
|
8440
|
-
import { closeSync, fchmodSync, fchownSync, fsyncSync, openSync,
|
|
8057
|
+
import { closeSync, fchmodSync, fchownSync, fsyncSync, openSync, writeFileSync as writeFileSync6, renameSync as renameSync5, mkdirSync as mkdirSync5, unlinkSync as unlinkSync4 } from "fs";
|
|
8441
8058
|
import { dirname as dirname4 } from "path";
|
|
8442
8059
|
function atomicWriteFileSync(path, data, own) {
|
|
8443
8060
|
const dirPath = dirname4(path);
|
|
8444
8061
|
const tmpPath = `${path}.tmp.${process.pid}.${Math.random().toString(36).slice(2, 8)}`;
|
|
8445
8062
|
try {
|
|
8446
|
-
|
|
8063
|
+
mkdirSync5(dirPath, { recursive: true });
|
|
8447
8064
|
} catch {
|
|
8448
8065
|
}
|
|
8449
8066
|
const fd = openSync(tmpPath, "w", 420);
|
|
8450
8067
|
try {
|
|
8451
8068
|
try {
|
|
8452
|
-
|
|
8069
|
+
writeFileSync6(fd, data);
|
|
8453
8070
|
if (own?.mode !== void 0) fchmodSync(fd, own.mode);
|
|
8454
8071
|
if (own?.uid !== void 0 && own.gid !== void 0) {
|
|
8455
8072
|
try {
|
|
@@ -8484,16 +8101,16 @@ function atomicWriteFileSync(path, data, own) {
|
|
|
8484
8101
|
}
|
|
8485
8102
|
|
|
8486
8103
|
// src/lib/feature-flags-host.ts
|
|
8487
|
-
import { existsSync as
|
|
8488
|
-
import { homedir as
|
|
8489
|
-
import { join as
|
|
8104
|
+
import { existsSync as existsSync5, readFileSync as readFileSync6, rmSync as rmSync3, statSync as statSync2 } from "fs";
|
|
8105
|
+
import { homedir as homedir4 } from "os";
|
|
8106
|
+
import { join as join6 } from "path";
|
|
8490
8107
|
function defaultFlagsCachePath(configDir) {
|
|
8491
|
-
return
|
|
8108
|
+
return join6(configDir, "flags-cache.json");
|
|
8492
8109
|
}
|
|
8493
8110
|
function readFlagsCache(path) {
|
|
8494
8111
|
try {
|
|
8495
|
-
if (!
|
|
8496
|
-
const parsed = JSON.parse(
|
|
8112
|
+
if (!existsSync5(path)) return null;
|
|
8113
|
+
const parsed = JSON.parse(readFileSync6(path, "utf8"));
|
|
8497
8114
|
if (!parsed || typeof parsed !== "object") return null;
|
|
8498
8115
|
const obj = parsed;
|
|
8499
8116
|
const flags = obj["flags"];
|
|
@@ -8763,12 +8380,12 @@ var HostFlagStore = class {
|
|
|
8763
8380
|
* The in-memory state stays authoritative and the next heartbeat retries.
|
|
8764
8381
|
*/
|
|
8765
8382
|
persistPerAgentCaches(updatedAt) {
|
|
8766
|
-
const root =
|
|
8383
|
+
const root = join6(homedir4(), ".augmented");
|
|
8767
8384
|
for (const agentId of this.mirrorAgentIds) {
|
|
8768
8385
|
try {
|
|
8769
|
-
const dir =
|
|
8770
|
-
if (!
|
|
8771
|
-
writeFlagsCache(
|
|
8386
|
+
const dir = join6(root, agentId);
|
|
8387
|
+
if (!existsSync5(dir)) continue;
|
|
8388
|
+
writeFlagsCache(join6(dir, "flags-cache.json"), {
|
|
8772
8389
|
schema_version: this.lastSchemaVersion,
|
|
8773
8390
|
updated_at: updatedAt,
|
|
8774
8391
|
flags: this.flagsForAgent(agentId),
|
|
@@ -8782,7 +8399,7 @@ var HostFlagStore = class {
|
|
|
8782
8399
|
} catch (err) {
|
|
8783
8400
|
let removed = "left in place";
|
|
8784
8401
|
try {
|
|
8785
|
-
rmSync3(
|
|
8402
|
+
rmSync3(join6(root, agentId, "flags-cache.json"), { force: true, recursive: true });
|
|
8786
8403
|
removed = "stale mirror removed";
|
|
8787
8404
|
} catch (rmErr) {
|
|
8788
8405
|
removed = `stale mirror could NOT be removed: ${rmErr.message}`;
|
|
@@ -10681,9 +10298,9 @@ function verdictForUnavailableMcpConfig(cause, ctx) {
|
|
|
10681
10298
|
}
|
|
10682
10299
|
|
|
10683
10300
|
// src/lib/connectivity-probe-context.ts
|
|
10684
|
-
import { delimiter as pathDelimiter, join as
|
|
10685
|
-
import { existsSync as
|
|
10686
|
-
import { homedir as
|
|
10301
|
+
import { delimiter as pathDelimiter, join as join7 } from "path";
|
|
10302
|
+
import { existsSync as existsSync6, readFileSync as readFileSync7 } from "fs";
|
|
10303
|
+
import { homedir as homedir5 } from "os";
|
|
10687
10304
|
|
|
10688
10305
|
// src/lib/probe-message-redact.ts
|
|
10689
10306
|
var MIN_SECRET_LENGTH = 8;
|
|
@@ -11469,7 +11086,7 @@ function resolveHttpServerEntry(entry, env) {
|
|
|
11469
11086
|
function readMcpHttpServerConfig(projectDir, serverKey, env) {
|
|
11470
11087
|
let servers;
|
|
11471
11088
|
try {
|
|
11472
|
-
const raw =
|
|
11089
|
+
const raw = readFileSync7(join7(projectDir, ".mcp.json"), "utf-8");
|
|
11473
11090
|
servers = JSON.parse(raw).mcpServers ?? {};
|
|
11474
11091
|
} catch {
|
|
11475
11092
|
return { ok: false, cause: "file-unreadable" };
|
|
@@ -11481,7 +11098,7 @@ function readMcpHttpServerConfig(projectDir, serverKey, env) {
|
|
|
11481
11098
|
}
|
|
11482
11099
|
function resolveDeclaredServerKey(projectDir, definitionId, derivedKey) {
|
|
11483
11100
|
try {
|
|
11484
|
-
const raw =
|
|
11101
|
+
const raw = readFileSync7(join7(projectDir, ".mcp.json"), "utf-8");
|
|
11485
11102
|
const servers = JSON.parse(raw).mcpServers ?? {};
|
|
11486
11103
|
const declared = Object.keys(servers);
|
|
11487
11104
|
if (derivedKey !== definitionId && derivedKey !== sanitizeServerKey(definitionId)) {
|
|
@@ -11523,7 +11140,7 @@ function resolveStdioServerEntry(entry, env) {
|
|
|
11523
11140
|
function readMcpStdioServerConfig(projectDir, serverKey, env) {
|
|
11524
11141
|
let servers;
|
|
11525
11142
|
try {
|
|
11526
|
-
const raw =
|
|
11143
|
+
const raw = readFileSync7(join7(projectDir, ".mcp.json"), "utf-8");
|
|
11527
11144
|
servers = JSON.parse(raw).mcpServers ?? {};
|
|
11528
11145
|
} catch {
|
|
11529
11146
|
return { ok: false, cause: "file-unreadable" };
|
|
@@ -11548,18 +11165,18 @@ function deriveMcpServerKey(input) {
|
|
|
11548
11165
|
}
|
|
11549
11166
|
var SYSTEM_PATH_FLOOR = PROBE_SYSTEM_PATH_FLOOR;
|
|
11550
11167
|
function toolkitPathDirs() {
|
|
11551
|
-
const home = process.env.HOME?.trim() ||
|
|
11168
|
+
const home = process.env.HOME?.trim() || homedir5();
|
|
11552
11169
|
return [
|
|
11553
11170
|
...PROBE_TOOLKIT_PATH_DIRS,
|
|
11554
|
-
...PROBE_HOME_RELATIVE_PATH_SEGMENTS.map((seg) =>
|
|
11171
|
+
...PROBE_HOME_RELATIVE_PATH_SEGMENTS.map((seg) => join7(home, seg))
|
|
11555
11172
|
];
|
|
11556
11173
|
}
|
|
11557
11174
|
function buildProbeEnv(projectDir, agentId) {
|
|
11558
11175
|
const probeEnv = { ...process.env };
|
|
11559
11176
|
try {
|
|
11560
|
-
const envIntPath =
|
|
11561
|
-
if (
|
|
11562
|
-
Object.assign(probeEnv, parseEnvIntegrations(
|
|
11177
|
+
const envIntPath = join7(projectDir, ".env.integrations");
|
|
11178
|
+
if (existsSync6(envIntPath)) {
|
|
11179
|
+
Object.assign(probeEnv, parseEnvIntegrations(readFileSync7(envIntPath, "utf-8")));
|
|
11563
11180
|
}
|
|
11564
11181
|
} catch {
|
|
11565
11182
|
}
|
|
@@ -11567,14 +11184,14 @@ function buildProbeEnv(projectDir, agentId) {
|
|
|
11567
11184
|
probeEnv.AGT_AGENT_ID = agentId.trim();
|
|
11568
11185
|
}
|
|
11569
11186
|
try {
|
|
11570
|
-
const agentBinDir =
|
|
11571
|
-
if (
|
|
11187
|
+
const agentBinDir = join7(projectDir, ".claude", "agt-bin");
|
|
11188
|
+
if (existsSync6(agentBinDir)) {
|
|
11572
11189
|
const parts = probeEnv.PATH ? probeEnv.PATH.split(pathDelimiter) : [];
|
|
11573
11190
|
parts.unshift(agentBinDir);
|
|
11574
11191
|
if (process.platform !== "win32") {
|
|
11575
11192
|
let insertAt = 1;
|
|
11576
11193
|
for (const dir of toolkitPathDirs()) {
|
|
11577
|
-
if (!
|
|
11194
|
+
if (!existsSync6(dir)) continue;
|
|
11578
11195
|
parts.splice(insertAt, 0, dir);
|
|
11579
11196
|
insertAt += 1;
|
|
11580
11197
|
}
|
|
@@ -11961,8 +11578,8 @@ var TunnelWatcher = class {
|
|
|
11961
11578
|
|
|
11962
11579
|
// src/lib/session-tool-bind-probe-host.ts
|
|
11963
11580
|
import { execFileSync as syncExecFile } from "child_process";
|
|
11964
|
-
import { readFileSync as
|
|
11965
|
-
import { join as
|
|
11581
|
+
import { readFileSync as readFileSync8 } from "fs";
|
|
11582
|
+
import { join as join8 } from "path";
|
|
11966
11583
|
import { dirname as dirname5 } from "path";
|
|
11967
11584
|
function termsRestrictedServerKeys(integrations, isRestricted = isProbeRestrictedByProviderTerms) {
|
|
11968
11585
|
const keys = /* @__PURE__ */ new Set();
|
|
@@ -12006,7 +11623,7 @@ async function gatherSessionToolBindProbe(agent, integrations, projectDir, opts)
|
|
|
12006
11623
|
if (integrations.length === 0) return null;
|
|
12007
11624
|
let mcpRaw = null;
|
|
12008
11625
|
try {
|
|
12009
|
-
mcpRaw =
|
|
11626
|
+
mcpRaw = readFileSync8(join8(projectDir, ".mcp.json"), "utf-8");
|
|
12010
11627
|
} catch {
|
|
12011
11628
|
mcpRaw = null;
|
|
12012
11629
|
}
|
|
@@ -12110,7 +11727,7 @@ var SLACK_MCP_SERVER_KEY = "slack";
|
|
|
12110
11727
|
function readSlackTransportDownKeys(projectDir) {
|
|
12111
11728
|
const none = /* @__PURE__ */ new Set();
|
|
12112
11729
|
try {
|
|
12113
|
-
const raw =
|
|
11730
|
+
const raw = readFileSync8(join8(dirname5(projectDir), SLACK_SOCKET_STATE_FILENAME), "utf-8");
|
|
12114
11731
|
const state = parseSlackSocketState(raw, Date.now());
|
|
12115
11732
|
return isSlackInboundTransportDown(state, SLACK_TRANSPORT_DOWN_AFTER_MS) ? /* @__PURE__ */ new Set([SLACK_MCP_SERVER_KEY]) : none;
|
|
12116
11733
|
} catch {
|
|
@@ -12195,13 +11812,13 @@ function describeWorkerModuleFailure(err) {
|
|
|
12195
11812
|
}
|
|
12196
11813
|
|
|
12197
11814
|
// src/lib/drain-transcript-flush.ts
|
|
12198
|
-
import { existsSync as
|
|
12199
|
-
import { homedir as
|
|
12200
|
-
import { dirname as dirname6, join as
|
|
11815
|
+
import { existsSync as existsSync7, readdirSync as readdirSync2 } from "fs";
|
|
11816
|
+
import { homedir as homedir6 } from "os";
|
|
11817
|
+
import { dirname as dirname6, join as join9, relative as relative2, sep } from "path";
|
|
12201
11818
|
import { spawn as spawn2 } from "child_process";
|
|
12202
11819
|
|
|
12203
11820
|
// src/lib/host-archive-address.ts
|
|
12204
|
-
import { readFileSync as
|
|
11821
|
+
import { readFileSync as readFileSync9 } from "fs";
|
|
12205
11822
|
var DEFAULT_ARCHIVE_ADDRESS_PATH = "/var/lib/augmented/session-archive-address.json";
|
|
12206
11823
|
var CACHE_TTL_MS = 5 * 60 * 1e3;
|
|
12207
11824
|
var cache2 = /* @__PURE__ */ new Map();
|
|
@@ -12217,7 +11834,7 @@ function readHostArchiveAddress(path) {
|
|
|
12217
11834
|
if (hit && now - hit.at < CACHE_TTL_MS) return hit.value;
|
|
12218
11835
|
let value = null;
|
|
12219
11836
|
try {
|
|
12220
|
-
const raw =
|
|
11837
|
+
const raw = readFileSync9(file, "utf-8");
|
|
12221
11838
|
const parsed = JSON.parse(raw);
|
|
12222
11839
|
if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) {
|
|
12223
11840
|
const obj = parsed;
|
|
@@ -12241,18 +11858,18 @@ function readHostArchiveAddress(path) {
|
|
|
12241
11858
|
|
|
12242
11859
|
// src/lib/drain-transcript-flush.ts
|
|
12243
11860
|
function sessionsBaseDir() {
|
|
12244
|
-
return
|
|
11861
|
+
return join9(homedir6(), ".claude", "projects");
|
|
12245
11862
|
}
|
|
12246
11863
|
var PER_FILE_UPLOAD_TIMEOUT_MS = 3e4;
|
|
12247
11864
|
var UPLOAD_CONCURRENCY = 4;
|
|
12248
11865
|
var DRAIN_MANIFEST_VERSION = 1;
|
|
12249
11866
|
var DRAIN_MANIFEST_FILENAME = "_augmented-drain-manifest.json";
|
|
12250
11867
|
function listJsonlFiles(dir) {
|
|
12251
|
-
if (!
|
|
11868
|
+
if (!existsSync7(dir)) return [];
|
|
12252
11869
|
const out = [];
|
|
12253
11870
|
const walk = (d) => {
|
|
12254
11871
|
for (const entry of readdirSync2(d, { withFileTypes: true })) {
|
|
12255
|
-
const full =
|
|
11872
|
+
const full = join9(d, entry.name);
|
|
12256
11873
|
if (entry.isDirectory()) walk(full);
|
|
12257
11874
|
else if (entry.isFile() && entry.name.endsWith(".jsonl")) out.push(full);
|
|
12258
11875
|
}
|
|
@@ -12269,7 +11886,7 @@ function transcriptObjectKey(keyPrefix, baseDir, file) {
|
|
|
12269
11886
|
return `${keyPrefix.replace(/\/+$/, "")}/${rel}`;
|
|
12270
11887
|
}
|
|
12271
11888
|
function drainManifestObjectKey(keyPrefix, baseDir, transcriptDir) {
|
|
12272
|
-
return transcriptObjectKey(keyPrefix, baseDir,
|
|
11889
|
+
return transcriptObjectKey(keyPrefix, baseDir, join9(transcriptDir, DRAIN_MANIFEST_FILENAME));
|
|
12273
11890
|
}
|
|
12274
11891
|
async function flushAgentTranscriptsOnDrain(codeName, deps) {
|
|
12275
11892
|
const dir = deps.resolveTranscriptDir(codeName);
|
|
@@ -12421,7 +12038,7 @@ function drainTranscriptFlushDeps(log2) {
|
|
|
12421
12038
|
// tree — the thing host-archive-address.ts's header warns about.
|
|
12422
12039
|
readSourceLayout: (codeName) => {
|
|
12423
12040
|
const agentDir = dirname6(getProjectDir(codeName));
|
|
12424
|
-
const codeNameDir =
|
|
12041
|
+
const codeNameDir = join9(homedir6(), ".augmented", codeName);
|
|
12425
12042
|
return { layout: agentDir === codeNameDir ? "codename-keyed" : "id-keyed", agentDir };
|
|
12426
12043
|
},
|
|
12427
12044
|
readSessionPin: (codeName) => readDailySessionPin(codeName),
|
|
@@ -12507,9 +12124,9 @@ function decidePin(opts) {
|
|
|
12507
12124
|
}
|
|
12508
12125
|
|
|
12509
12126
|
// src/commands/setup.ts
|
|
12510
|
-
import { existsSync as
|
|
12511
|
-
import { join as
|
|
12512
|
-
import { homedir as
|
|
12127
|
+
import { existsSync as existsSync9, readFileSync as readFileSync11, writeFileSync as writeFileSync8, mkdirSync as mkdirSync7, accessSync, constants as fsConstants } from "fs";
|
|
12128
|
+
import { join as join11, dirname as dirname7 } from "path";
|
|
12129
|
+
import { homedir as homedir7 } from "os";
|
|
12513
12130
|
import chalk3 from "chalk";
|
|
12514
12131
|
import ora from "ora";
|
|
12515
12132
|
|
|
@@ -12540,20 +12157,20 @@ function table(headers, rows) {
|
|
|
12540
12157
|
}
|
|
12541
12158
|
|
|
12542
12159
|
// src/lib/watchdog.ts
|
|
12543
|
-
import { readFileSync as
|
|
12544
|
-
import { join as
|
|
12160
|
+
import { readFileSync as readFileSync10, writeFileSync as writeFileSync7, unlinkSync as unlinkSync5, existsSync as existsSync8, mkdirSync as mkdirSync6, openSync as openSync2, closeSync as closeSync2, chmodSync as chmodSync5 } from "fs";
|
|
12161
|
+
import { join as join10 } from "path";
|
|
12545
12162
|
import { spawn as spawn3, execFileSync as execFileSync3 } from "child_process";
|
|
12546
|
-
var DEFAULT_CONFIG_DIR =
|
|
12163
|
+
var DEFAULT_CONFIG_DIR = join10(process.env["HOME"] ?? "/tmp", ".augmented");
|
|
12547
12164
|
function getManagerPaths(configDir) {
|
|
12548
12165
|
return {
|
|
12549
|
-
pidFile:
|
|
12550
|
-
stateFile:
|
|
12551
|
-
logFile:
|
|
12166
|
+
pidFile: join10(configDir, "manager.pid"),
|
|
12167
|
+
stateFile: join10(configDir, "manager-state.json"),
|
|
12168
|
+
logFile: join10(configDir, "manager.log")
|
|
12552
12169
|
};
|
|
12553
12170
|
}
|
|
12554
12171
|
function ensureDir(configDir) {
|
|
12555
|
-
if (!
|
|
12556
|
-
|
|
12172
|
+
if (!existsSync8(configDir)) {
|
|
12173
|
+
mkdirSync6(configDir, { recursive: true });
|
|
12557
12174
|
}
|
|
12558
12175
|
}
|
|
12559
12176
|
function writePidFile(configDir, pid) {
|
|
@@ -12562,7 +12179,7 @@ function writePidFile(configDir, pid) {
|
|
|
12562
12179
|
}
|
|
12563
12180
|
function readPidFile(configDir) {
|
|
12564
12181
|
try {
|
|
12565
|
-
const raw =
|
|
12182
|
+
const raw = readFileSync10(getManagerPaths(configDir).pidFile, "utf-8").trim();
|
|
12566
12183
|
const pid = parseInt(raw, 10);
|
|
12567
12184
|
return isNaN(pid) ? null : pid;
|
|
12568
12185
|
} catch {
|
|
@@ -12608,7 +12225,7 @@ function defaultPgrep() {
|
|
|
12608
12225
|
}
|
|
12609
12226
|
function readStateFile(configDir) {
|
|
12610
12227
|
try {
|
|
12611
|
-
const raw =
|
|
12228
|
+
const raw = readFileSync10(getManagerPaths(configDir).stateFile, "utf-8");
|
|
12612
12229
|
return JSON.parse(raw);
|
|
12613
12230
|
} catch {
|
|
12614
12231
|
return null;
|
|
@@ -12664,7 +12281,7 @@ function startWatchdog(opts) {
|
|
|
12664
12281
|
const deadline = Date.now() + 5e3;
|
|
12665
12282
|
const sleepBuf = new Int32Array(new SharedArrayBuffer(4));
|
|
12666
12283
|
while (Date.now() < deadline) {
|
|
12667
|
-
if (
|
|
12284
|
+
if (existsSync8(pidFile)) {
|
|
12668
12285
|
return { pid: child.pid };
|
|
12669
12286
|
}
|
|
12670
12287
|
if (child.exitCode !== null) {
|
|
@@ -12738,17 +12355,17 @@ function getManagerStatus(configDir = DEFAULT_CONFIG_DIR) {
|
|
|
12738
12355
|
// src/commands/setup.ts
|
|
12739
12356
|
function detectShellProfile() {
|
|
12740
12357
|
const shell = process.env["SHELL"] ?? "";
|
|
12741
|
-
const home =
|
|
12358
|
+
const home = homedir7();
|
|
12742
12359
|
if (shell.includes("zsh")) {
|
|
12743
|
-
return
|
|
12360
|
+
return join11(home, ".zshrc");
|
|
12744
12361
|
}
|
|
12745
12362
|
if (shell.includes("fish")) {
|
|
12746
|
-
const fishConfig =
|
|
12363
|
+
const fishConfig = join11(home, ".config", "fish", "config.fish");
|
|
12747
12364
|
return fishConfig;
|
|
12748
12365
|
}
|
|
12749
|
-
const bashrc =
|
|
12750
|
-
if (
|
|
12751
|
-
return
|
|
12366
|
+
const bashrc = join11(home, ".bashrc");
|
|
12367
|
+
if (existsSync9(bashrc)) return bashrc;
|
|
12368
|
+
return join11(home, ".bash_profile");
|
|
12752
12369
|
}
|
|
12753
12370
|
function maybeWriteSystemWideEnv(apiUrl, apiKey, consoleUrl) {
|
|
12754
12371
|
const empty = { etcEnvironment: false, profileD: false, bashrc: false };
|
|
@@ -12779,7 +12396,7 @@ function parseEtcEnvironmentValue(text, key) {
|
|
|
12779
12396
|
}
|
|
12780
12397
|
function readEtcEnvironmentValue(key) {
|
|
12781
12398
|
try {
|
|
12782
|
-
return parseEtcEnvironmentValue(
|
|
12399
|
+
return parseEtcEnvironmentValue(readFileSync11("/etc/environment", "utf-8"), key);
|
|
12783
12400
|
} catch {
|
|
12784
12401
|
return null;
|
|
12785
12402
|
}
|
|
@@ -12792,14 +12409,14 @@ function quoteForFishShell(value) {
|
|
|
12792
12409
|
}
|
|
12793
12410
|
function writeEtcEnvironment(apiUrl, apiKey, consoleUrl) {
|
|
12794
12411
|
const envPath = "/etc/environment";
|
|
12795
|
-
if (!
|
|
12412
|
+
if (!existsSync9(envPath)) return false;
|
|
12796
12413
|
try {
|
|
12797
12414
|
accessSync(envPath, fsConstants.W_OK);
|
|
12798
12415
|
} catch {
|
|
12799
12416
|
return false;
|
|
12800
12417
|
}
|
|
12801
12418
|
try {
|
|
12802
|
-
const current =
|
|
12419
|
+
const current = readFileSync11(envPath, "utf-8");
|
|
12803
12420
|
const stripped = current.split(/\r?\n/).filter((line) => !/^\s*(?:export\s+)?AGT_(?:HOST|API_KEY|CONSOLE_URL)=/.test(line)).join("\n");
|
|
12804
12421
|
const base = stripped.endsWith("\n") || stripped.length === 0 ? stripped : `${stripped}
|
|
12805
12422
|
`;
|
|
@@ -12818,7 +12435,7 @@ function writeEtcEnvironment(apiUrl, apiKey, consoleUrl) {
|
|
|
12818
12435
|
}
|
|
12819
12436
|
function writeProfileDScript(apiUrl, apiKey, consoleUrl) {
|
|
12820
12437
|
const profileD = "/etc/profile.d";
|
|
12821
|
-
if (!
|
|
12438
|
+
if (!existsSync9(profileD)) return false;
|
|
12822
12439
|
try {
|
|
12823
12440
|
accessSync(profileD, fsConstants.W_OK);
|
|
12824
12441
|
} catch {
|
|
@@ -12841,14 +12458,14 @@ function writeProfileDScript(apiUrl, apiKey, consoleUrl) {
|
|
|
12841
12458
|
}
|
|
12842
12459
|
function ensureBashrcSourcesProfileD() {
|
|
12843
12460
|
const bashrc = "/etc/bashrc";
|
|
12844
|
-
if (!
|
|
12461
|
+
if (!existsSync9(bashrc)) return false;
|
|
12845
12462
|
try {
|
|
12846
12463
|
accessSync(bashrc, fsConstants.W_OK);
|
|
12847
12464
|
} catch {
|
|
12848
12465
|
return false;
|
|
12849
12466
|
}
|
|
12850
12467
|
try {
|
|
12851
|
-
const current =
|
|
12468
|
+
const current = readFileSync11(bashrc, "utf-8");
|
|
12852
12469
|
const marker = "# Augmented (agt) \u2014 source system-wide AGT env";
|
|
12853
12470
|
if (current.includes(marker)) return true;
|
|
12854
12471
|
const snippet = [
|
|
@@ -12988,11 +12605,11 @@ async function setupCommand(token, options = {}) {
|
|
|
12988
12605
|
}
|
|
12989
12606
|
const exportLines = buildExportLines(shell, finalApiUrl, setupResult.api_key, consoleUrl);
|
|
12990
12607
|
const profileDir = dirname7(profilePath);
|
|
12991
|
-
if (!
|
|
12992
|
-
|
|
12608
|
+
if (!existsSync9(profileDir)) {
|
|
12609
|
+
mkdirSync7(profileDir, { recursive: true });
|
|
12993
12610
|
}
|
|
12994
12611
|
const marker = "# Augmented (agt) host configuration";
|
|
12995
|
-
const current =
|
|
12612
|
+
const current = existsSync9(profilePath) ? readFileSync11(profilePath, "utf-8") : "";
|
|
12996
12613
|
let updated;
|
|
12997
12614
|
if (current.includes(marker)) {
|
|
12998
12615
|
updated = current.replace(
|
|
@@ -13023,7 +12640,7 @@ async function setupCommand(token, options = {}) {
|
|
|
13023
12640
|
const managerSpinner = ora({ text: "Starting manager daemon\u2026", isSilent: json });
|
|
13024
12641
|
managerSpinner.start();
|
|
13025
12642
|
try {
|
|
13026
|
-
const configDir =
|
|
12643
|
+
const configDir = join11(homedir7(), ".augmented");
|
|
13027
12644
|
const { pid } = startWatchdog({ intervalMs: 1e4, configDir, detached: true });
|
|
13028
12645
|
managerSpinner.succeed(`Manager started (PID ${pid})`);
|
|
13029
12646
|
} catch (err) {
|
|
@@ -13062,9 +12679,9 @@ async function setupCommand(token, options = {}) {
|
|
|
13062
12679
|
|
|
13063
12680
|
// src/commands/manager.ts
|
|
13064
12681
|
import chalk4 from "chalk";
|
|
13065
|
-
import { existsSync as
|
|
13066
|
-
import { join as
|
|
13067
|
-
import { homedir as
|
|
12682
|
+
import { existsSync as existsSync10, realpathSync as realpathSync2 } from "fs";
|
|
12683
|
+
import { join as join12 } from "path";
|
|
12684
|
+
import { homedir as homedir8, userInfo } from "os";
|
|
13068
12685
|
import { spawn as spawn4 } from "child_process";
|
|
13069
12686
|
function normalizePinInEnv(env) {
|
|
13070
12687
|
const normalized = normalizePinVersion(env.AGT_CLI_PIN_VERSION);
|
|
@@ -13074,7 +12691,7 @@ function normalizePinInEnv(env) {
|
|
|
13074
12691
|
function managerStartCommand(opts) {
|
|
13075
12692
|
const json = isJsonMode();
|
|
13076
12693
|
if (!process.env.HOME || !process.env.HOME.trim()) {
|
|
13077
|
-
const fallback =
|
|
12694
|
+
const fallback = homedir8();
|
|
13078
12695
|
process.env.HOME = fallback;
|
|
13079
12696
|
if (!json) {
|
|
13080
12697
|
info(`HOME was not set in the manager env \u2014 defaulting to ${fallback}.`);
|
|
@@ -13108,7 +12725,7 @@ function managerStartCommand(opts) {
|
|
|
13108
12725
|
process.exitCode = 1;
|
|
13109
12726
|
return;
|
|
13110
12727
|
}
|
|
13111
|
-
const configDir = opts.configDir ??
|
|
12728
|
+
const configDir = opts.configDir ?? join12(homedir8(), ".augmented");
|
|
13112
12729
|
if (opts.supervise) {
|
|
13113
12730
|
if (json) {
|
|
13114
12731
|
jsonOutput({ ok: false, error: "--supervise is not supported with --json" });
|
|
@@ -13204,7 +12821,7 @@ function runSupervisorLoop(intervalSec, configDir) {
|
|
|
13204
12821
|
}
|
|
13205
12822
|
async function managerStopCommand(opts = {}) {
|
|
13206
12823
|
const json = isJsonMode();
|
|
13207
|
-
const configDir = opts.configDir ??
|
|
12824
|
+
const configDir = opts.configDir ?? join12(homedir8(), ".augmented");
|
|
13208
12825
|
try {
|
|
13209
12826
|
const result = await stopWatchdog(configDir);
|
|
13210
12827
|
if (!result.stopped && !result.pid) {
|
|
@@ -13232,7 +12849,7 @@ async function managerStopCommand(opts = {}) {
|
|
|
13232
12849
|
}
|
|
13233
12850
|
function managerStatusCommand(opts = {}) {
|
|
13234
12851
|
const json = isJsonMode();
|
|
13235
|
-
const configDir = opts.configDir ??
|
|
12852
|
+
const configDir = opts.configDir ?? join12(homedir8(), ".augmented");
|
|
13236
12853
|
const status = getManagerStatus(configDir);
|
|
13237
12854
|
if (!status) {
|
|
13238
12855
|
if (json) {
|
|
@@ -13322,7 +12939,7 @@ function resolveStableAgtBin(rawPath) {
|
|
|
13322
12939
|
if (!prefix || !formula) return rawPath;
|
|
13323
12940
|
const candidates = [`${prefix}/bin/${formula}`, `${prefix}/bin/agt`];
|
|
13324
12941
|
for (const candidate of candidates) {
|
|
13325
|
-
if (!
|
|
12942
|
+
if (!existsSync10(candidate)) continue;
|
|
13326
12943
|
try {
|
|
13327
12944
|
realpathSync2(candidate);
|
|
13328
12945
|
return candidate;
|
|
@@ -13342,7 +12959,7 @@ async function managerInstallCommand(opts = {}) {
|
|
|
13342
12959
|
process.exitCode = 1;
|
|
13343
12960
|
return;
|
|
13344
12961
|
}
|
|
13345
|
-
const configDir = opts.configDir ??
|
|
12962
|
+
const configDir = opts.configDir ?? join12(homedir8(), ".augmented");
|
|
13346
12963
|
const rawAgtBin = process.argv[1];
|
|
13347
12964
|
if (!rawAgtBin) {
|
|
13348
12965
|
const msg = "Could not resolve the agt binary path from argv. Re-run via the installed `agt` command.";
|
|
@@ -13353,9 +12970,9 @@ async function managerInstallCommand(opts = {}) {
|
|
|
13353
12970
|
}
|
|
13354
12971
|
const agtBin = resolveStableAgtBin(rawAgtBin);
|
|
13355
12972
|
if (process.platform === "darwin") {
|
|
13356
|
-
const home =
|
|
12973
|
+
const home = homedir8();
|
|
13357
12974
|
const protectedRoots = ["Documents", "Downloads", "Desktop", "Movies", "Music", "Pictures"];
|
|
13358
|
-
const offending = protectedRoots.map((r) =>
|
|
12975
|
+
const offending = protectedRoots.map((r) => join12(home, r)).find((p) => agtBin === p || agtBin.startsWith(`${p}/`));
|
|
13359
12976
|
if (offending) {
|
|
13360
12977
|
const msg = `agt binary at ${agtBin} sits inside a macOS TCC-protected folder (${offending}). launchd-spawned processes cannot read files there and the manager would EPERM on startup. Either install agt globally (\`npm install -g @integrity-labs/agt-cli\`) or copy the dist outside protected folders before running this command.`;
|
|
13361
12978
|
if (json) jsonOutput({ ok: false, error: msg });
|
|
@@ -13368,7 +12985,7 @@ async function managerInstallCommand(opts = {}) {
|
|
|
13368
12985
|
AGT_HOST: getHost(),
|
|
13369
12986
|
// ?? alone wouldn't catch `HOME=""` from a stripped systemd env.
|
|
13370
12987
|
// Treat empty / whitespace-only as missing.
|
|
13371
|
-
HOME: process.env.HOME?.trim() ||
|
|
12988
|
+
HOME: process.env.HOME?.trim() || homedir8(),
|
|
13372
12989
|
USER: process.env.USER?.trim() || userInfo().username
|
|
13373
12990
|
};
|
|
13374
12991
|
const apiKey = getApiKey();
|
|
@@ -13421,7 +13038,7 @@ async function managerInstallSystemUnitCommand(opts = {}) {
|
|
|
13421
13038
|
return;
|
|
13422
13039
|
}
|
|
13423
13040
|
const user = opts.user ?? "root";
|
|
13424
|
-
const configDir = opts.configDir ?? (user === "root" ? "/root/.augmented" :
|
|
13041
|
+
const configDir = opts.configDir ?? (user === "root" ? "/root/.augmented" : join12("/home", user, ".augmented"));
|
|
13425
13042
|
const rawAgtBin = process.argv[1];
|
|
13426
13043
|
if (!rawAgtBin) {
|
|
13427
13044
|
const msg = "Could not resolve the agt binary path from argv. Re-run via the installed `agt` command.";
|
|
@@ -13661,26 +13278,6 @@ export {
|
|
|
13661
13278
|
setJsonMode,
|
|
13662
13279
|
isJsonMode,
|
|
13663
13280
|
jsonOutput,
|
|
13664
|
-
getApiKey,
|
|
13665
|
-
getActiveTeam,
|
|
13666
|
-
setActiveTeam,
|
|
13667
|
-
PROD_AGT_HOST,
|
|
13668
|
-
getHost,
|
|
13669
|
-
requireHost,
|
|
13670
|
-
isTransientAuthFailure,
|
|
13671
|
-
exchangeFailureKind,
|
|
13672
|
-
setConfigHash,
|
|
13673
|
-
forceNextExchange,
|
|
13674
|
-
getCachedClaudeAuthMode,
|
|
13675
|
-
getCachedClaudeAuthModeRaw,
|
|
13676
|
-
exchangeApiKey,
|
|
13677
|
-
mintAgentKey,
|
|
13678
|
-
mintRotatedHostKey,
|
|
13679
|
-
probeHostKey,
|
|
13680
|
-
adoptHostKeyInProcess,
|
|
13681
|
-
ApiError,
|
|
13682
|
-
api,
|
|
13683
|
-
getHostId,
|
|
13684
13281
|
success,
|
|
13685
13282
|
error,
|
|
13686
13283
|
warn,
|
|
@@ -13750,4 +13347,4 @@ export {
|
|
|
13750
13347
|
managerInstallSystemUnitCommand,
|
|
13751
13348
|
managerUninstallSystemUnitCommand
|
|
13752
13349
|
};
|
|
13753
|
-
//# sourceMappingURL=chunk-
|
|
13350
|
+
//# sourceMappingURL=chunk-4AUE34MF.js.map
|