@integrity-labs/agt-cli 0.28.1293 → 0.28.1295

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.
@@ -15,7 +15,7 @@ import {
15
15
  mintRotatedHostKey,
16
16
  probeHostKey,
17
17
  setConfigHash
18
- } from "./chunk-YZHOUQRL.js";
18
+ } from "./chunk-BOYTADW6.js";
19
19
  import "./chunk-M3OBVJQP.js";
20
20
  import "./chunk-DGUM43GV.js";
21
21
  export {
@@ -36,4 +36,4 @@ export {
36
36
  probeHostKey,
37
37
  setConfigHash
38
38
  };
39
- //# sourceMappingURL=api-client-X6EKO72C.js.map
39
+ //# sourceMappingURL=api-client-EPU52HGW.js.map
package/dist/bin/agt.js CHANGED
@@ -31,7 +31,7 @@ import {
31
31
  success,
32
32
  table,
33
33
  warn
34
- } from "../chunk-2N3GYWTF.js";
34
+ } from "../chunk-OASIXWY3.js";
35
35
  import {
36
36
  ApiError,
37
37
  PROD_AGT_HOST,
@@ -42,7 +42,7 @@ import {
42
42
  getHost,
43
43
  getHostId,
44
44
  setActiveTeam
45
- } from "../chunk-YZHOUQRL.js";
45
+ } from "../chunk-BOYTADW6.js";
46
46
  import {
47
47
  getProjectDir,
48
48
  isSessionResumeDisabled,
@@ -5207,7 +5207,7 @@ import { execFileSync, execSync } from "child_process";
5207
5207
  import { existsSync as existsSync10, realpathSync as realpathSync2 } from "fs";
5208
5208
  import chalk17 from "chalk";
5209
5209
  import ora15 from "ora";
5210
- var cliVersion = true ? "0.28.1293" : "dev";
5210
+ var cliVersion = true ? "0.28.1295" : "dev";
5211
5211
  async function fetchLatestVersion() {
5212
5212
  const host2 = getHost();
5213
5213
  if (!host2) return null;
@@ -6467,7 +6467,7 @@ function handleError(err) {
6467
6467
  }
6468
6468
 
6469
6469
  // src/bin/agt.ts
6470
- var cliVersion2 = true ? "0.28.1293" : "dev";
6470
+ var cliVersion2 = true ? "0.28.1295" : "dev";
6471
6471
  var program = new Command();
6472
6472
  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");
6473
6473
  program.hook("preAction", async (thisCommand, actionCommand) => {
@@ -103,7 +103,7 @@ function exchangeFailureKind(err) {
103
103
  }
104
104
 
105
105
  // src/lib/api-client.ts
106
- var agtCliVersion = true ? "0.28.1293" : "dev";
106
+ var agtCliVersion = true ? "0.28.1295" : "dev";
107
107
  var lastConfigHash = null;
108
108
  function setConfigHash(hash) {
109
109
  lastConfigHash = hash && hash.length > 0 ? hash : null;
@@ -468,4 +468,4 @@ export {
468
468
  api,
469
469
  getHostId
470
470
  };
471
- //# sourceMappingURL=chunk-YZHOUQRL.js.map
471
+ //# sourceMappingURL=chunk-BOYTADW6.js.map
@@ -2,7 +2,7 @@ import {
2
2
  exchangeApiKey,
3
3
  getApiKey,
4
4
  getHost
5
- } from "./chunk-YZHOUQRL.js";
5
+ } from "./chunk-BOYTADW6.js";
6
6
  import {
7
7
  LATE_BOUND_VARS,
8
8
  PLATFORM_DENY_PERMISSIONS,
@@ -13853,4 +13853,4 @@ export {
13853
13853
  managerInstallSystemUnitCommand,
13854
13854
  managerUninstallSystemUnitCommand
13855
13855
  };
13856
- //# sourceMappingURL=chunk-2N3GYWTF.js.map
13856
+ //# sourceMappingURL=chunk-OASIXWY3.js.map
@@ -70,7 +70,7 @@ import {
70
70
  tripClass,
71
71
  writeEtcEnvironment,
72
72
  writeProfileDScript
73
- } from "../chunk-2N3GYWTF.js";
73
+ } from "../chunk-OASIXWY3.js";
74
74
  import {
75
75
  ApiError,
76
76
  adoptHostKeyInProcess,
@@ -88,7 +88,7 @@ import {
88
88
  probeHostKey,
89
89
  requireHost,
90
90
  setConfigHash
91
- } from "../chunk-YZHOUQRL.js";
91
+ } from "../chunk-BOYTADW6.js";
92
92
  import {
93
93
  BLOCKED_ON_PROMPT_DECISION,
94
94
  CHANNEL_SECRET_ENV_KEYS,
@@ -377,26 +377,73 @@ var RESULT_LINE = /^\s+⎿\s*(.*)$/;
377
377
  function isCreditExhaustedText(text) {
378
378
  return typeof text === "string" && CREDIT_EXHAUSTED_PATTERN.test(text);
379
379
  }
380
+ function lastResultLine(paneTail) {
381
+ if (typeof paneTail !== "string") return null;
382
+ let last = null;
383
+ for (const line of paneTail.split("\n")) {
384
+ const m = RESULT_LINE.exec(line);
385
+ if (m) last = (m[1] ?? "").trim();
386
+ }
387
+ return last;
388
+ }
380
389
  function isPaneCreditLine(line) {
381
390
  return typeof line === "string" && PANE_CREDIT_EXHAUSTED_PATTERN.test(line);
382
391
  }
383
- function paneResultSighting(rawLog) {
384
- if (typeof rawLog !== "string") return { ordinal: 0, latest: null };
385
- const stripped = rawLog.replace(/\x1b\[[0-9;?]*[A-Za-z]/g, "");
386
- let ordinal = 0;
387
- let latest = null;
388
- for (const line of stripped.split("\n")) {
389
- const m = RESULT_LINE.exec(line);
390
- if (m) {
391
- ordinal += 1;
392
- latest = (m[1] ?? "").trim();
392
+ var PaneResultCursor = class {
393
+ constructor(port) {
394
+ this.port = port;
395
+ }
396
+ // ino null (CodeRabbit on #7775): the file did not exist at the last look, so
397
+ // everything that appears in it is new. Only a file that EXISTS on the first
398
+ // look is baselined: a missing one holds no lines from before a restart.
399
+ at = /* @__PURE__ */ new Map();
400
+ /**
401
+ * Treat everything on disk now as already read. Used when the host key changes
402
+ * (a line written under the old key must not count for the new one) and when
403
+ * the probe confirms credit is back (a line written before that success must
404
+ * not re-flag the key: ENG-12169 item 3).
405
+ */
406
+ baseline(id, path) {
407
+ const st = this.port.stat(path);
408
+ if (st === "absent") this.at.set(id, { ino: null, offset: 0 });
409
+ else if (st) this.at.set(id, { ino: st.ino, offset: st.size });
410
+ else this.at.delete(id);
411
+ }
412
+ ids() {
413
+ return [...this.at.keys()];
414
+ }
415
+ /**
416
+ * The latest result line among the complete lines appended since the last
417
+ * call, or null. Never a sighting on the FIRST call for an agent (after a
418
+ * manager start): a line from before the restart may predate a top-up, and the
419
+ * stored flag survives a restart anyway (the heartbeat echoes it,
420
+ * {@link CreditExhaustionTracker.noteServerFlag}).
421
+ */
422
+ next(id, path) {
423
+ const st = this.port.stat(path);
424
+ let cur = this.at.get(id);
425
+ if (st === null) return null;
426
+ if (st === "absent") {
427
+ if (!cur) this.at.set(id, { ino: null, offset: 0 });
428
+ return null;
429
+ }
430
+ if (!cur) {
431
+ this.at.set(id, { ino: st.ino, offset: st.size });
432
+ return null;
433
+ }
434
+ if (st.ino !== cur.ino || st.size < cur.offset) {
435
+ cur = { ino: st.ino, offset: 0 };
436
+ this.at.set(id, cur);
393
437
  }
438
+ if (st.size === cur.offset) return null;
439
+ const chunk2 = this.port.read(path, cur.offset, st.size);
440
+ const lastNl = chunk2.lastIndexOf(10);
441
+ if (lastNl < 0) return null;
442
+ cur.offset += lastNl + 1;
443
+ const text = chunk2.subarray(0, lastNl + 1).toString("utf8");
444
+ return lastResultLine(text.replace(/\x1b\[[0-9;?]*[A-Za-z]/g, ""));
394
445
  }
395
- return { ordinal, latest };
396
- }
397
- function isNewPaneResult(args) {
398
- return args.previous !== void 0 && args.ordinal !== args.previous;
399
- }
446
+ };
400
447
  var PROBE_INTERVAL_MS = 10 * 60 * 1e3;
401
448
  var PROBE_MODEL = "claude-haiku-4-5-20251001";
402
449
  var CreditExhaustionTracker = class {
@@ -1223,7 +1270,7 @@ var SignalledHostPids = class {
1223
1270
 
1224
1271
  // src/lib/manager-worker.ts
1225
1272
  import { createHash as createHash21 } from "crypto";
1226
- import { readFileSync as readFileSync39, writeFileSync as writeFileSync20, mkdirSync as mkdirSync18, existsSync as existsSync20, rmSync as rmSync9, readdirSync as readdirSync15, statSync as statSync15, unlinkSync as unlinkSync6, renameSync as renameSync12, utimesSync as utimesSync4, readlinkSync as readlinkSync2 } from "fs";
1273
+ import { readFileSync as readFileSync39, writeFileSync as writeFileSync20, mkdirSync as mkdirSync18, existsSync as existsSync20, rmSync as rmSync9, readdirSync as readdirSync15, statSync as statSync15, unlinkSync as unlinkSync6, renameSync as renameSync12, utimesSync as utimesSync4, readlinkSync as readlinkSync2, openSync as openSync6, readSync as readSync5, closeSync as closeSync6 } from "fs";
1227
1274
 
1228
1275
  // src/lib/atomic-file-replace.ts
1229
1276
  import { copyFileSync, renameSync, unlinkSync } from "fs";
@@ -15566,7 +15613,7 @@ function createFileMigrationReportIO(codeName, log2) {
15566
15613
  };
15567
15614
  }
15568
15615
  var managerHostPost = async (path, body) => {
15569
- const { api: api2, ApiError: ApiError3 } = await import("../api-client-X6EKO72C.js");
15616
+ const { api: api2, ApiError: ApiError3 } = await import("../api-client-EPU52HGW.js");
15570
15617
  try {
15571
15618
  const json = await api2.post(path, body);
15572
15619
  return { status: 200, json };
@@ -18538,7 +18585,7 @@ var agentRestartTimezoneInputs = /* @__PURE__ */ new Map();
18538
18585
  var lastVersionCheckAt = 0;
18539
18586
  var VERSION_CHECK_INTERVAL_MS = 5 * 60 * 1e3;
18540
18587
  var lastResponsivenessProbeAt = 0;
18541
- var agtCliVersion = true ? "0.28.1293" : "dev";
18588
+ var agtCliVersion = true ? "0.28.1295" : "dev";
18542
18589
  function resolveBrewPath(execFileSync5) {
18543
18590
  try {
18544
18591
  const out = execFileSync5("which", ["brew"], { timeout: 5e3 }).toString().trim();
@@ -20391,6 +20438,7 @@ function maybeProbeHostCredit() {
20391
20438
  }
20392
20439
  if (outcome === "ok") {
20393
20440
  creditExhaustion.noteSuccess(fingerprint3, Date.now());
20441
+ rebaselineCreditPanes();
20394
20442
  log("[credit-exhaustion] probe: the host API key has credit again; reporting the recovery");
20395
20443
  } else if (outcome === "credit_exhausted") {
20396
20444
  creditExhaustion.noteError("probe", "Credit balance is too low", fingerprint3, Date.now());
@@ -20403,36 +20451,50 @@ function maybeProbeHostCredit() {
20403
20451
  });
20404
20452
  }
20405
20453
  var creditPaneCheckedAt = /* @__PURE__ */ new Map();
20406
- var creditPaneLastOrdinal = /* @__PURE__ */ new Map();
20407
20454
  var CREDIT_PANE_CHECK_INTERVAL_MS = 6e4;
20455
+ var creditPaneCursor = new PaneResultCursor({
20456
+ stat(path) {
20457
+ try {
20458
+ const st = statSync15(path);
20459
+ return { ino: st.ino, size: st.size };
20460
+ } catch (err) {
20461
+ return err.code === "ENOENT" ? "absent" : null;
20462
+ }
20463
+ },
20464
+ read(path, start, end) {
20465
+ const fd = openSync6(path, "r");
20466
+ try {
20467
+ const buf = Buffer.alloc(end - start);
20468
+ const n = readSync5(fd, buf, 0, buf.length, start);
20469
+ return buf.subarray(0, n);
20470
+ } finally {
20471
+ closeSync6(fd);
20472
+ }
20473
+ }
20474
+ });
20475
+ function rebaselineCreditPanes() {
20476
+ for (const codeName of creditPaneCursor.ids()) {
20477
+ creditPaneCursor.baseline(codeName, paneLogPath(codeName));
20478
+ }
20479
+ }
20408
20480
  function setCreditHostKey(key, fingerprint3) {
20409
20481
  const changed = creditHostKey.fingerprint !== null && fingerprint3 !== creditHostKey.fingerprint;
20410
20482
  creditHostKey.key = key;
20411
20483
  creditHostKey.fingerprint = fingerprint3;
20412
20484
  if (!changed) return;
20413
- for (const codeName of [...creditPaneLastOrdinal.keys()]) {
20414
- try {
20415
- creditPaneLastOrdinal.set(codeName, paneResultSighting(readFileSync39(paneLogPath(codeName), "utf-8")).ordinal);
20416
- } catch {
20417
- creditPaneLastOrdinal.delete(codeName);
20418
- }
20419
- }
20485
+ rebaselineCreditPanes();
20420
20486
  }
20421
20487
  function checkPaneForCreditExhaustion(codeName) {
20422
20488
  const nowMs = Date.now();
20423
20489
  const last = creditPaneCheckedAt.get(codeName);
20424
20490
  if (last !== void 0 && nowMs - last < CREDIT_PANE_CHECK_INTERVAL_MS) return;
20425
20491
  creditPaneCheckedAt.set(codeName, nowMs);
20426
- let rawLog;
20492
+ let latest;
20427
20493
  try {
20428
- rawLog = readFileSync39(paneLogPath(codeName), "utf-8");
20494
+ latest = creditPaneCursor.next(codeName, paneLogPath(codeName));
20429
20495
  } catch {
20430
20496
  return;
20431
20497
  }
20432
- const { ordinal, latest } = paneResultSighting(rawLog);
20433
- const previous = creditPaneLastOrdinal.get(codeName);
20434
- creditPaneLastOrdinal.set(codeName, ordinal);
20435
- if (!isNewPaneResult({ ordinal, previous })) return;
20436
20498
  if (isPaneCreditLine(latest)) {
20437
20499
  if (creditExhaustion.noteError("pane", latest, creditHostKey.fingerprint, nowMs)) {
20438
20500
  log(`[credit-exhaustion] '${codeName}' pane: "${latest}": this host's API key is out of Anthropic credit`);