@evident-ai/cli 3.1.1-dev.7db1d8e → 3.1.1-dev.832e240
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/index.js +40 -9
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2688,6 +2688,10 @@ function nextReportDelayMs(random = Math.random) {
|
|
|
2688
2688
|
return BASE_REPORT_DELAY_MS - jitterRangeMs + random() * (2 * jitterRangeMs);
|
|
2689
2689
|
}
|
|
2690
2690
|
var FIRST_REPORT_DELAY_MS = 5e3 + Math.random() * 1e4;
|
|
2691
|
+
var CLAUDE_USAGE_FAILURE_REESCALATION_TICKS = 6;
|
|
2692
|
+
function claudeUsageFailureLogLevel(consecutiveFailures) {
|
|
2693
|
+
return consecutiveFailures === 1 || consecutiveFailures % CLAUDE_USAGE_FAILURE_REESCALATION_TICKS === 0 ? "warn" : "debug";
|
|
2694
|
+
}
|
|
2691
2695
|
|
|
2692
2696
|
// src/lib/channels/driver.ts
|
|
2693
2697
|
import { homedir as homedir2 } from "os";
|
|
@@ -6144,8 +6148,10 @@ async function driveChannels(state, driver) {
|
|
|
6144
6148
|
const proxiedActivity = state.lastProxiedActivityAt !== lastSeenProxiedActivityAt;
|
|
6145
6149
|
lastSeenProxiedActivityAt = state.lastProxiedActivityAt;
|
|
6146
6150
|
const appliedFiles = driver.fileSyncActivity().appliedFiles;
|
|
6147
|
-
const
|
|
6151
|
+
const filesApplied = appliedFiles !== lastSeenAppliedFiles;
|
|
6152
|
+
const fileActivity = carriedOverFileSync || filesApplied;
|
|
6148
6153
|
lastSeenAppliedFiles = appliedFiles;
|
|
6154
|
+
if (filesApplied) state.claudeUsageRearm?.();
|
|
6149
6155
|
if (processed > 0 || driver.hasInFlightWatchers() || proxiedActivity || fileActivity) {
|
|
6150
6156
|
idlePolls = 0;
|
|
6151
6157
|
if (processed > 0 && state.interactive) displayStatus(state);
|
|
@@ -6285,6 +6291,9 @@ function scheduleSessionCleanup(state, driver, options) {
|
|
|
6285
6291
|
);
|
|
6286
6292
|
state.sessionCleanupTimers.push(interval, firstSweep);
|
|
6287
6293
|
}
|
|
6294
|
+
function claudeUsageFailureStreakSuffix(consecutiveFailures) {
|
|
6295
|
+
return consecutiveFailures > 1 ? ` (${consecutiveFailures} consecutive failures)` : "";
|
|
6296
|
+
}
|
|
6288
6297
|
function scheduleClaudeUsageReporting(state, options) {
|
|
6289
6298
|
const { mode, warnings } = resolveClaudeUsageReportingMode(
|
|
6290
6299
|
options.claudeUsageReporting,
|
|
@@ -6303,13 +6312,26 @@ function scheduleClaudeUsageReporting(state, options) {
|
|
|
6303
6312
|
level: "debug",
|
|
6304
6313
|
message: "Claude usage reporting is off (--claude-usage-reporting off)"
|
|
6305
6314
|
});
|
|
6306
|
-
return;
|
|
6315
|
+
return null;
|
|
6307
6316
|
}
|
|
6308
6317
|
let consecutiveFailures = 0;
|
|
6318
|
+
let armed = false;
|
|
6319
|
+
let rearmRequested = false;
|
|
6309
6320
|
const scheduleNextTick = () => {
|
|
6321
|
+
armed = true;
|
|
6322
|
+
rearmRequested = false;
|
|
6310
6323
|
state.claudeUsageTimer = setTimeout(() => void tick(false), nextReportDelayMs());
|
|
6311
6324
|
};
|
|
6312
|
-
const
|
|
6325
|
+
const rearm = () => {
|
|
6326
|
+
if (armed) {
|
|
6327
|
+
rearmRequested = true;
|
|
6328
|
+
return;
|
|
6329
|
+
}
|
|
6330
|
+
rearmRequested = false;
|
|
6331
|
+
armed = true;
|
|
6332
|
+
state.claudeUsageTimer = setTimeout(() => void tick(true), FIRST_REPORT_DELAY_MS);
|
|
6333
|
+
};
|
|
6334
|
+
const tick = async (isProbe) => {
|
|
6313
6335
|
try {
|
|
6314
6336
|
const usage = await getClaudeUsage();
|
|
6315
6337
|
const result = await reportClaudeUsage(state.agentId, state.authHeader, usage);
|
|
@@ -6331,8 +6353,8 @@ function scheduleClaudeUsageReporting(state, options) {
|
|
|
6331
6353
|
consecutiveFailures++;
|
|
6332
6354
|
logActivity(state, {
|
|
6333
6355
|
type: "info",
|
|
6334
|
-
level: consecutiveFailures
|
|
6335
|
-
message: `Failed to report Claude usage: ${result.error}`
|
|
6356
|
+
level: claudeUsageFailureLogLevel(consecutiveFailures),
|
|
6357
|
+
message: `Failed to report Claude usage: ${result.error}${claudeUsageFailureStreakSuffix(consecutiveFailures)}`
|
|
6336
6358
|
});
|
|
6337
6359
|
}
|
|
6338
6360
|
scheduleNextTick();
|
|
@@ -6345,12 +6367,14 @@ function scheduleClaudeUsageReporting(state, options) {
|
|
|
6345
6367
|
message: "Claude usage reporting is forced on but no usable Claude Code login was found \u2014 run `claude` to sign in; reporting will keep retrying"
|
|
6346
6368
|
});
|
|
6347
6369
|
scheduleNextTick();
|
|
6348
|
-
} else if (
|
|
6370
|
+
} else if (isProbe) {
|
|
6349
6371
|
logActivity(state, {
|
|
6350
6372
|
type: "info",
|
|
6351
6373
|
level: "debug",
|
|
6352
6374
|
message: `Claude usage reporting: ${error2.message}`
|
|
6353
6375
|
});
|
|
6376
|
+
armed = false;
|
|
6377
|
+
if (rearmRequested) rearm();
|
|
6354
6378
|
} else {
|
|
6355
6379
|
logActivity(state, {
|
|
6356
6380
|
type: "info",
|
|
@@ -6364,14 +6388,16 @@ function scheduleClaudeUsageReporting(state, options) {
|
|
|
6364
6388
|
const message = error2 instanceof Error ? error2.message : String(error2);
|
|
6365
6389
|
logActivity(state, {
|
|
6366
6390
|
type: "info",
|
|
6367
|
-
level: consecutiveFailures
|
|
6368
|
-
message: `Claude usage reporting failed: ${message}`
|
|
6391
|
+
level: claudeUsageFailureLogLevel(consecutiveFailures),
|
|
6392
|
+
message: `Claude usage reporting failed: ${message}${claudeUsageFailureStreakSuffix(consecutiveFailures)}`
|
|
6369
6393
|
});
|
|
6370
6394
|
scheduleNextTick();
|
|
6371
6395
|
}
|
|
6372
6396
|
}
|
|
6373
6397
|
};
|
|
6398
|
+
armed = true;
|
|
6374
6399
|
state.claudeUsageTimer = setTimeout(() => void tick(true), FIRST_REPORT_DELAY_MS);
|
|
6400
|
+
return rearm;
|
|
6375
6401
|
}
|
|
6376
6402
|
async function notifyOffline(state) {
|
|
6377
6403
|
if (!state.agentId || !state.authHeader) return;
|
|
@@ -6412,6 +6438,7 @@ async function cleanup(state, opts = {}) {
|
|
|
6412
6438
|
clearTimeout(state.claudeUsageTimer);
|
|
6413
6439
|
state.claudeUsageTimer = null;
|
|
6414
6440
|
}
|
|
6441
|
+
state.claudeUsageRearm = null;
|
|
6415
6442
|
if (opts.graceful && state.channelDriver) {
|
|
6416
6443
|
state.channelDriver.stop();
|
|
6417
6444
|
log2(state, "Draining in-flight channel work before shutdown...");
|
|
@@ -6493,6 +6520,7 @@ async function run(options) {
|
|
|
6493
6520
|
lastProxiedActivityAt: null,
|
|
6494
6521
|
sessionCleanupTimers: [],
|
|
6495
6522
|
claudeUsageTimer: null,
|
|
6523
|
+
claudeUsageRearm: null,
|
|
6496
6524
|
authHeader: ""
|
|
6497
6525
|
};
|
|
6498
6526
|
setTelemetryAuthProvider(() => ({ authHeader: state.authHeader, agentId: state.agentId }));
|
|
@@ -6572,6 +6600,7 @@ async function run(options) {
|
|
|
6572
6600
|
console.log(chalk6.dim("Or run `evident login` for interactive authentication"));
|
|
6573
6601
|
blank();
|
|
6574
6602
|
process.exit(1);
|
|
6603
|
+
return;
|
|
6575
6604
|
}
|
|
6576
6605
|
blank();
|
|
6577
6606
|
console.log(chalk6.yellow("You are not logged in to Evident."));
|
|
@@ -6616,6 +6645,7 @@ async function run(options) {
|
|
|
6616
6645
|
} else {
|
|
6617
6646
|
printError(resolved.error || "Failed to resolve runner ID from key");
|
|
6618
6647
|
process.exit(1);
|
|
6648
|
+
return;
|
|
6619
6649
|
}
|
|
6620
6650
|
} else {
|
|
6621
6651
|
printError(
|
|
@@ -6629,6 +6659,7 @@ async function run(options) {
|
|
|
6629
6659
|
);
|
|
6630
6660
|
blank();
|
|
6631
6661
|
process.exit(1);
|
|
6662
|
+
return;
|
|
6632
6663
|
}
|
|
6633
6664
|
}
|
|
6634
6665
|
telemetry.info(
|
|
@@ -6876,7 +6907,7 @@ async function run(options) {
|
|
|
6876
6907
|
throw error2;
|
|
6877
6908
|
}
|
|
6878
6909
|
scheduleSessionCleanup(state, channelDriver, options);
|
|
6879
|
-
scheduleClaudeUsageReporting(state, options);
|
|
6910
|
+
state.claudeUsageRearm = scheduleClaudeUsageReporting(state, options);
|
|
6880
6911
|
if (!interactive || state.json) {
|
|
6881
6912
|
log2(state, "Driving channel messages...");
|
|
6882
6913
|
}
|