@integrity-labs/agt-cli 0.28.1055 → 0.28.1057

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
@@ -40,7 +40,7 @@ import {
40
40
  success,
41
41
  table,
42
42
  warn
43
- } from "../chunk-TBHLHBXJ.js";
43
+ } from "../chunk-BWN4QFSK.js";
44
44
  import {
45
45
  getProjectDir,
46
46
  isSessionResumeDisabled,
@@ -5474,7 +5474,7 @@ import { execFileSync, execSync } from "child_process";
5474
5474
  import { existsSync as existsSync11, realpathSync as realpathSync2 } from "fs";
5475
5475
  import chalk18 from "chalk";
5476
5476
  import ora16 from "ora";
5477
- var cliVersion = true ? "0.28.1055" : "dev";
5477
+ var cliVersion = true ? "0.28.1057" : "dev";
5478
5478
  async function fetchLatestVersion() {
5479
5479
  const host2 = getHost();
5480
5480
  if (!host2) return null;
@@ -6734,7 +6734,7 @@ function handleError(err) {
6734
6734
  }
6735
6735
 
6736
6736
  // src/bin/agt.ts
6737
- var cliVersion2 = true ? "0.28.1055" : "dev";
6737
+ var cliVersion2 = true ? "0.28.1057" : "dev";
6738
6738
  var program = new Command();
6739
6739
  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");
6740
6740
  program.hook("preAction", async (thisCommand, actionCommand) => {
@@ -7122,7 +7122,7 @@ function exchangeFailureKind(err) {
7122
7122
  }
7123
7123
 
7124
7124
  // src/lib/api-client.ts
7125
- var agtCliVersion = true ? "0.28.1055" : "dev";
7125
+ var agtCliVersion = true ? "0.28.1057" : "dev";
7126
7126
  var lastConfigHash = null;
7127
7127
  function setConfigHash(hash) {
7128
7128
  lastConfigHash = hash && hash.length > 0 ? hash : null;
@@ -12089,4 +12089,4 @@ export {
12089
12089
  managerInstallSystemUnitCommand,
12090
12090
  managerUninstallSystemUnitCommand
12091
12091
  };
12092
- //# sourceMappingURL=chunk-TBHLHBXJ.js.map
12092
+ //# sourceMappingURL=chunk-BWN4QFSK.js.map
@@ -67,7 +67,7 @@ import {
67
67
  safeWriteJsonAtomic,
68
68
  setConfigHash,
69
69
  tripClass
70
- } from "../chunk-TBHLHBXJ.js";
70
+ } from "../chunk-BWN4QFSK.js";
71
71
  import {
72
72
  getProjectDir as getProjectDir2,
73
73
  getReadyTasks,
@@ -2799,6 +2799,17 @@ function heartbeatAccountEmailField(rawMode, detected) {
2799
2799
  if (!mayReportAccountEmail(rawMode)) return void 0;
2800
2800
  return detected ?? void 0;
2801
2801
  }
2802
+ function accountFileUnreadableTransition(prevKey, observation) {
2803
+ const key = observation.email === null && observation.why === "unreadable" ? observation.codes.join(",") : null;
2804
+ if (key === prevKey) return { key, line: null };
2805
+ if (key !== null) {
2806
+ return {
2807
+ key,
2808
+ line: `[account-email] a Claude account file exists but cannot be read (${key}); claude_account_email will not be reported, so the stored label may be stale (ENG-10796)`
2809
+ };
2810
+ }
2811
+ return { key, line: "[account-email] Claude account file readable again (ENG-10796)" };
2812
+ }
2802
2813
 
2803
2814
  // src/lib/manager/auth-resolve-decision.ts
2804
2815
  function decideAuthResolveFailureAction(args) {
@@ -3430,12 +3441,25 @@ async function claudeConfigCandidatePaths() {
3430
3441
  function hashAccount(accountUuid, organizationUuid) {
3431
3442
  return createHash6("sha256").update(`claude-account:${accountUuid}:${organizationUuid ?? ""}`).digest("hex").slice(0, 12);
3432
3443
  }
3433
- async function detectClaudeAccountFingerprint(paths) {
3434
- const candidates = paths ?? await claudeConfigCandidatePaths();
3435
- for (const path of candidates) {
3444
+ var ABSENT_CODES = /* @__PURE__ */ new Set(["ENOENT", "ENOTDIR"]);
3445
+ function errnoCode(err) {
3446
+ const code = err?.code;
3447
+ return typeof code === "string" && code.length > 0 ? code : "UNKNOWN";
3448
+ }
3449
+ async function resolveClaudeAccount(paths) {
3450
+ const unreadable = [];
3451
+ for (const path of paths) {
3452
+ let raw;
3453
+ try {
3454
+ raw = await readFile3(path, "utf-8");
3455
+ } catch (err) {
3456
+ const code = errnoCode(err);
3457
+ if (!ABSENT_CODES.has(code)) unreadable.push(code);
3458
+ continue;
3459
+ }
3436
3460
  let parsed;
3437
3461
  try {
3438
- parsed = JSON.parse(await readFile3(path, "utf-8"));
3462
+ parsed = JSON.parse(raw);
3439
3463
  } catch {
3440
3464
  continue;
3441
3465
  }
@@ -3444,46 +3468,45 @@ async function detectClaudeAccountFingerprint(paths) {
3444
3468
  if (typeof account !== "object" || account === null) continue;
3445
3469
  const accountUuid = account.accountUuid;
3446
3470
  if (typeof accountUuid !== "string" || accountUuid.trim().length === 0) continue;
3447
- const organizationUuid = account.organizationUuid;
3448
- return hashAccount(
3449
- accountUuid.trim(),
3450
- typeof organizationUuid === "string" && organizationUuid.trim().length > 0 ? organizationUuid.trim() : null
3451
- );
3471
+ return {
3472
+ status: "found",
3473
+ account
3474
+ };
3452
3475
  }
3453
- return null;
3476
+ return unreadable.length > 0 ? { status: "unreadable", codes: [...new Set(unreadable)].sort() } : { status: "not-found" };
3477
+ }
3478
+ async function detectClaudeAccountFingerprint(paths) {
3479
+ const resolution = await resolveClaudeAccount(paths ?? await claudeConfigCandidatePaths());
3480
+ if (resolution.status !== "found") return null;
3481
+ const { account } = resolution;
3482
+ const organizationUuid = account["organizationUuid"];
3483
+ return hashAccount(
3484
+ account.accountUuid.trim(),
3485
+ typeof organizationUuid === "string" && organizationUuid.trim().length > 0 ? organizationUuid.trim() : null
3486
+ );
3454
3487
  }
3455
3488
  var lastKnownFingerprint = null;
3456
3489
  var lastDetectAtMs = 0;
3457
3490
  var lastEmailResult = null;
3458
3491
  var lastEmailDetectAtMs = 0;
3459
3492
  var DETECT_TTL_MS = 6e4;
3460
- async function detectClaudeAccountEmail(paths) {
3461
- const candidates = paths ?? await claudeConfigCandidatePaths();
3462
- for (const path of candidates) {
3463
- let parsed;
3464
- try {
3465
- parsed = JSON.parse(await readFile3(path, "utf-8"));
3466
- } catch {
3467
- continue;
3468
- }
3469
- if (typeof parsed !== "object" || parsed === null) continue;
3470
- const account = parsed.oauthAccount;
3471
- if (typeof account !== "object" || account === null) continue;
3472
- const accountUuid = account.accountUuid;
3473
- if (typeof accountUuid !== "string" || accountUuid.trim().length === 0) continue;
3474
- const email = account.emailAddress;
3475
- if (typeof email !== "string") return null;
3476
- const trimmed = email.trim().toLowerCase();
3477
- if (trimmed.length === 0) return null;
3478
- return trimmed;
3479
- }
3480
- return null;
3481
- }
3482
- async function getClaudeAccountEmail(paths, nowMs = Date.now()) {
3483
- if (!paths && nowMs - lastEmailDetectAtMs < DETECT_TTL_MS) {
3493
+ async function detectClaudeAccountEmailObservation(paths) {
3494
+ const resolution = await resolveClaudeAccount(paths ?? await claudeConfigCandidatePaths());
3495
+ if (resolution.status === "unreadable") {
3496
+ return { email: null, why: "unreadable", codes: resolution.codes };
3497
+ }
3498
+ if (resolution.status === "not-found") return { email: null, why: "not-found" };
3499
+ const email = resolution.account["emailAddress"];
3500
+ if (typeof email !== "string") return { email: null, why: "no-address" };
3501
+ const trimmed = email.trim().toLowerCase();
3502
+ if (trimmed.length === 0) return { email: null, why: "no-address" };
3503
+ return { email: trimmed };
3504
+ }
3505
+ async function getClaudeAccountEmailObservation(paths, nowMs = Date.now()) {
3506
+ if (!paths && lastEmailResult !== null && nowMs - lastEmailDetectAtMs < DETECT_TTL_MS) {
3484
3507
  return lastEmailResult;
3485
3508
  }
3486
- const detected = await detectClaudeAccountEmail(paths);
3509
+ const detected = await detectClaudeAccountEmailObservation(paths);
3487
3510
  if (!paths) {
3488
3511
  lastEmailDetectAtMs = nowMs;
3489
3512
  lastEmailResult = detected;
@@ -13218,6 +13241,7 @@ function stopRealtimeChat() {
13218
13241
  function escapeRegExp(s) {
13219
13242
  return s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
13220
13243
  }
13244
+ var accountFileUnreadableKey = null;
13221
13245
  function applyRestartAcks(args) {
13222
13246
  const { agentStates, priorAgents, restartAcks } = args;
13223
13247
  if (agentStates.length === 0) return false;
@@ -14847,7 +14871,7 @@ var agentRestartTimezoneInputs = /* @__PURE__ */ new Map();
14847
14871
  var lastVersionCheckAt = 0;
14848
14872
  var VERSION_CHECK_INTERVAL_MS = 5 * 60 * 1e3;
14849
14873
  var lastResponsivenessProbeAt = 0;
14850
- var agtCliVersion = true ? "0.28.1055" : "dev";
14874
+ var agtCliVersion = true ? "0.28.1057" : "dev";
14851
14875
  function resolveBrewPath(execFileSync3) {
14852
14876
  try {
14853
14877
  const out = execFileSync3("which", ["brew"], { timeout: 5e3 }).toString().trim();
@@ -16661,7 +16685,11 @@ async function pollCycleInner() {
16661
16685
  const claudeAuthModeRaw = getCachedClaudeAuthModeRaw();
16662
16686
  if (mayReportAccountEmail(claudeAuthModeRaw)) {
16663
16687
  try {
16664
- claudeAccountEmail = await getClaudeAccountEmail();
16688
+ const observation = await getClaudeAccountEmailObservation();
16689
+ claudeAccountEmail = observation.email;
16690
+ const transition = accountFileUnreadableTransition(accountFileUnreadableKey, observation);
16691
+ accountFileUnreadableKey = transition.key;
16692
+ if (transition.line) log(transition.line);
16665
16693
  } catch {
16666
16694
  claudeAccountEmail = null;
16667
16695
  }