@integrity-labs/agt-cli 0.24.7 → 0.24.8
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
|
@@ -26,7 +26,7 @@ import {
|
|
|
26
26
|
success,
|
|
27
27
|
table,
|
|
28
28
|
warn
|
|
29
|
-
} from "../chunk-
|
|
29
|
+
} from "../chunk-XW27YIEU.js";
|
|
30
30
|
import {
|
|
31
31
|
CHANNEL_REGISTRY,
|
|
32
32
|
DEPLOYMENT_TEMPLATES,
|
|
@@ -3736,7 +3736,7 @@ import { execFileSync, execSync } from "child_process";
|
|
|
3736
3736
|
import { existsSync as existsSync5, realpathSync } from "fs";
|
|
3737
3737
|
import chalk17 from "chalk";
|
|
3738
3738
|
import ora15 from "ora";
|
|
3739
|
-
var cliVersion = true ? "0.24.
|
|
3739
|
+
var cliVersion = true ? "0.24.8" : "dev";
|
|
3740
3740
|
async function fetchLatestVersion() {
|
|
3741
3741
|
const host2 = getHost();
|
|
3742
3742
|
if (!host2) return null;
|
|
@@ -4268,7 +4268,7 @@ function handleError(err) {
|
|
|
4268
4268
|
}
|
|
4269
4269
|
|
|
4270
4270
|
// src/bin/agt.ts
|
|
4271
|
-
var cliVersion2 = true ? "0.24.
|
|
4271
|
+
var cliVersion2 = true ? "0.24.8" : "dev";
|
|
4272
4272
|
var program = new Command();
|
|
4273
4273
|
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");
|
|
4274
4274
|
program.hook("preAction", (thisCommand) => {
|
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
provisionOrientHook,
|
|
13
13
|
provisionStopHook,
|
|
14
14
|
requireHost
|
|
15
|
-
} from "../chunk-
|
|
15
|
+
} from "../chunk-XW27YIEU.js";
|
|
16
16
|
import {
|
|
17
17
|
findTaskByTemplate,
|
|
18
18
|
getProjectDir as getProjectDir2,
|
|
@@ -2838,7 +2838,7 @@ var cachedFrameworkVersion = null;
|
|
|
2838
2838
|
var lastVersionCheckAt = 0;
|
|
2839
2839
|
var VERSION_CHECK_INTERVAL_MS = 5 * 60 * 1e3;
|
|
2840
2840
|
var lastResponsivenessProbeAt = 0;
|
|
2841
|
-
var agtCliVersion = true ? "0.24.
|
|
2841
|
+
var agtCliVersion = true ? "0.24.8" : "dev";
|
|
2842
2842
|
function resolveBrewPath(execFileSync4) {
|
|
2843
2843
|
try {
|
|
2844
2844
|
const out = execFileSync4("which", ["brew"], { timeout: 5e3 }).toString().trim();
|
|
@@ -15483,6 +15483,35 @@ function createSlackBotUserIdClient(args) {
|
|
|
15483
15483
|
return false;
|
|
15484
15484
|
}
|
|
15485
15485
|
}
|
|
15486
|
+
let lastReportedHealth = null;
|
|
15487
|
+
async function emitHealth(healthy) {
|
|
15488
|
+
const post = async () => {
|
|
15489
|
+
const token = await getToken();
|
|
15490
|
+
return fetchImpl(`${base}/host/channel-health`, {
|
|
15491
|
+
method: "POST",
|
|
15492
|
+
headers: { Authorization: `Bearer ${token}`, "Content-Type": "application/json" },
|
|
15493
|
+
body: JSON.stringify({ agent_id: agentId, channel_id: "slack", healthy }),
|
|
15494
|
+
signal: AbortSignal.timeout(REQUEST_TIMEOUT_MS2)
|
|
15495
|
+
});
|
|
15496
|
+
};
|
|
15497
|
+
try {
|
|
15498
|
+
let resp = await post();
|
|
15499
|
+
if (resp.status === 401) {
|
|
15500
|
+
cachedToken = null;
|
|
15501
|
+
cachedTokenExpiresAt = 0;
|
|
15502
|
+
resp = await post();
|
|
15503
|
+
}
|
|
15504
|
+
if (!resp.ok) {
|
|
15505
|
+
const body = await resp.text().catch(() => "");
|
|
15506
|
+
log(`channel-health: POST failed (${resp.status}) healthy=${healthy}: ${body.slice(0, 200)}`);
|
|
15507
|
+
return false;
|
|
15508
|
+
}
|
|
15509
|
+
return true;
|
|
15510
|
+
} catch (err) {
|
|
15511
|
+
log(`channel-health: emit threw healthy=${healthy}: ${err.message}`);
|
|
15512
|
+
return false;
|
|
15513
|
+
}
|
|
15514
|
+
}
|
|
15486
15515
|
return {
|
|
15487
15516
|
report(botUserId2) {
|
|
15488
15517
|
if (reportedFor === botUserId2) return;
|
|
@@ -15494,6 +15523,14 @@ function createSlackBotUserIdClient(args) {
|
|
|
15494
15523
|
reportedFor = null;
|
|
15495
15524
|
}
|
|
15496
15525
|
});
|
|
15526
|
+
},
|
|
15527
|
+
reportAuthHealth(healthy) {
|
|
15528
|
+
if (lastReportedHealth === healthy) return;
|
|
15529
|
+
const snapshot = healthy;
|
|
15530
|
+
lastReportedHealth = snapshot;
|
|
15531
|
+
void emitHealth(healthy).then((ok) => {
|
|
15532
|
+
if (!ok && lastReportedHealth === snapshot) lastReportedHealth = null;
|
|
15533
|
+
});
|
|
15497
15534
|
}
|
|
15498
15535
|
};
|
|
15499
15536
|
}
|
|
@@ -15885,7 +15922,12 @@ async function postSlackMessage(body) {
|
|
|
15885
15922
|
signal: AbortSignal.timeout(SLACK_DOWNLOAD_TIMEOUT_MS)
|
|
15886
15923
|
});
|
|
15887
15924
|
const data = await res.json();
|
|
15888
|
-
if (data.ok)
|
|
15925
|
+
if (data.ok) {
|
|
15926
|
+
recordActivity("reply");
|
|
15927
|
+
slackBotUserIdClient?.reportAuthHealth(true);
|
|
15928
|
+
} else if (data.error && SLACK_AUTH_FAILURE_CODES.has(data.error)) {
|
|
15929
|
+
slackBotUserIdClient?.reportAuthHealth(false);
|
|
15930
|
+
}
|
|
15889
15931
|
return data;
|
|
15890
15932
|
} catch (err) {
|
|
15891
15933
|
const isTimeout = err.name === "TimeoutError" || err.name === "AbortError";
|
|
@@ -16248,24 +16290,36 @@ if (AGENT_CODE_NAME) {
|
|
|
16248
16290
|
} catch {
|
|
16249
16291
|
}
|
|
16250
16292
|
}
|
|
16293
|
+
var SLACK_AUTH_FAILURE_CODES = /* @__PURE__ */ new Set([
|
|
16294
|
+
"invalid_auth",
|
|
16295
|
+
"token_revoked",
|
|
16296
|
+
"token_expired",
|
|
16297
|
+
"account_inactive",
|
|
16298
|
+
"not_authed"
|
|
16299
|
+
]);
|
|
16251
16300
|
async function getBotUserId() {
|
|
16252
16301
|
try {
|
|
16253
16302
|
const res = await fetch("https://slack.com/api/auth.test", {
|
|
16254
16303
|
headers: { Authorization: `Bearer ${BOT_TOKEN}` }
|
|
16255
16304
|
});
|
|
16256
16305
|
const data = await res.json();
|
|
16257
|
-
|
|
16306
|
+
if (data.ok) return { id: data.user_id ?? null, authFailed: false };
|
|
16307
|
+
return { id: null, authFailed: !!data.error && SLACK_AUTH_FAILURE_CODES.has(data.error) };
|
|
16258
16308
|
} catch {
|
|
16259
|
-
return null;
|
|
16309
|
+
return { id: null, authFailed: false };
|
|
16260
16310
|
}
|
|
16261
16311
|
}
|
|
16262
16312
|
async function resolveBotUserIdOrThrow() {
|
|
16313
|
+
let sawAuthFailure = false;
|
|
16263
16314
|
for (let attempt = 1; attempt <= 5; attempt++) {
|
|
16264
|
-
const id = await getBotUserId();
|
|
16315
|
+
const { id, authFailed } = await getBotUserId();
|
|
16265
16316
|
if (id) return id;
|
|
16317
|
+
if (authFailed) sawAuthFailure = true;
|
|
16266
16318
|
await new Promise((r) => setTimeout(r, attempt * 1e3));
|
|
16267
16319
|
}
|
|
16268
|
-
|
|
16320
|
+
const err = new Error("slack-channel: failed to resolve bot user_id via auth.test after 5 attempts");
|
|
16321
|
+
err.authFailed = sawAuthFailure;
|
|
16322
|
+
throw err;
|
|
16269
16323
|
}
|
|
16270
16324
|
var botUserId = null;
|
|
16271
16325
|
var slackBotUserIdClient = createSlackBotUserIdClient({
|
|
@@ -16280,11 +16334,14 @@ void resolveBotUserIdOrThrow().then((id) => {
|
|
|
16280
16334
|
process.stderr.write(`slack-channel: Bot user ID resolved (${id.slice(0, 2)}***${id.slice(-2)})
|
|
16281
16335
|
`);
|
|
16282
16336
|
slackBotUserIdClient?.report(id);
|
|
16337
|
+
slackBotUserIdClient?.reportAuthHealth(true);
|
|
16283
16338
|
}).catch((err) => {
|
|
16339
|
+
const authFailed = !!err.authFailed;
|
|
16284
16340
|
process.stderr.write(
|
|
16285
|
-
`slack-channel: bot user_id resolve failed \u2014 continuing degraded: ${err.message}
|
|
16341
|
+
`slack-channel: bot user_id resolve failed \u2014 continuing degraded${authFailed ? " (invalid_auth \u2014 channel needs reconnect)" : " (transient)"}: ${err.message}
|
|
16286
16342
|
`
|
|
16287
16343
|
);
|
|
16344
|
+
if (authFailed) slackBotUserIdClient?.reportAuthHealth(false);
|
|
16288
16345
|
});
|
|
16289
16346
|
var selfIdentityInstruction = `Mentions of your own Slack bot user are directed at you, even inside auto_followed threads.`;
|
|
16290
16347
|
var mcp = new Server(
|
package/package.json
CHANGED
|
File without changes
|