@evident-ai/cli 3.3.1-dev.4a86610 → 3.3.1-dev.6f7f428
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 +39 -17
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -7418,23 +7418,46 @@ function scheduleClaudeUsageReporting(state, options) {
|
|
|
7418
7418
|
return null;
|
|
7419
7419
|
}
|
|
7420
7420
|
let consecutiveFailures = 0;
|
|
7421
|
-
let
|
|
7421
|
+
let phase = "dormant";
|
|
7422
7422
|
let rearmRequested = false;
|
|
7423
|
-
const
|
|
7424
|
-
|
|
7425
|
-
|
|
7423
|
+
const armProbe = () => {
|
|
7424
|
+
phase = "probe-pending";
|
|
7425
|
+
state.claudeUsageTimer = setTimeout(() => void tick(true), FIRST_REPORT_DELAY_MS);
|
|
7426
|
+
};
|
|
7427
|
+
const scheduleNextTick = (reportedSuccessfully) => {
|
|
7428
|
+
if (rearmRequested) {
|
|
7429
|
+
rearmRequested = false;
|
|
7430
|
+
armProbe();
|
|
7431
|
+
return;
|
|
7432
|
+
}
|
|
7433
|
+
phase = reportedSuccessfully ? "steady-pending-healthy" : "steady-pending-retry";
|
|
7426
7434
|
state.claudeUsageTimer = setTimeout(() => void tick(false), nextReportDelayMs());
|
|
7427
7435
|
};
|
|
7428
7436
|
const rearm = () => {
|
|
7429
|
-
|
|
7430
|
-
|
|
7431
|
-
|
|
7437
|
+
switch (phase) {
|
|
7438
|
+
case "tick-in-flight":
|
|
7439
|
+
rearmRequested = true;
|
|
7440
|
+
return;
|
|
7441
|
+
case "probe-pending":
|
|
7442
|
+
return;
|
|
7443
|
+
case "steady-pending-healthy":
|
|
7444
|
+
return;
|
|
7445
|
+
case "steady-pending-retry":
|
|
7446
|
+
if (state.claudeUsageTimer) {
|
|
7447
|
+
clearTimeout(state.claudeUsageTimer);
|
|
7448
|
+
state.claudeUsageTimer = null;
|
|
7449
|
+
}
|
|
7450
|
+
rearmRequested = false;
|
|
7451
|
+
armProbe();
|
|
7452
|
+
return;
|
|
7453
|
+
case "dormant":
|
|
7454
|
+
rearmRequested = false;
|
|
7455
|
+
armProbe();
|
|
7456
|
+
return;
|
|
7432
7457
|
}
|
|
7433
|
-
rearmRequested = false;
|
|
7434
|
-
armed = true;
|
|
7435
|
-
state.claudeUsageTimer = setTimeout(() => void tick(true), FIRST_REPORT_DELAY_MS);
|
|
7436
7458
|
};
|
|
7437
7459
|
const tick = async (isProbe) => {
|
|
7460
|
+
phase = "tick-in-flight";
|
|
7438
7461
|
try {
|
|
7439
7462
|
const usage = await getClaudeUsage();
|
|
7440
7463
|
const result = await reportClaudeUsage(state.agentId, state.authHeader, usage);
|
|
@@ -7460,7 +7483,7 @@ function scheduleClaudeUsageReporting(state, options) {
|
|
|
7460
7483
|
message: `Failed to report Claude usage: ${result.error}${claudeUsageFailureStreakSuffix(consecutiveFailures)}`
|
|
7461
7484
|
});
|
|
7462
7485
|
}
|
|
7463
|
-
scheduleNextTick();
|
|
7486
|
+
scheduleNextTick(result.ok);
|
|
7464
7487
|
} catch (error2) {
|
|
7465
7488
|
if (error2 instanceof ClaudeUsageError && isLocalCredentialProblem(error2)) {
|
|
7466
7489
|
if (mode === "on") {
|
|
@@ -7469,14 +7492,14 @@ function scheduleClaudeUsageReporting(state, options) {
|
|
|
7469
7492
|
level: "warn",
|
|
7470
7493
|
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"
|
|
7471
7494
|
});
|
|
7472
|
-
scheduleNextTick();
|
|
7495
|
+
scheduleNextTick(false);
|
|
7473
7496
|
} else if (isProbe) {
|
|
7474
7497
|
logActivity(state, {
|
|
7475
7498
|
type: "info",
|
|
7476
7499
|
level: "debug",
|
|
7477
7500
|
message: `Claude usage reporting: ${error2.message}`
|
|
7478
7501
|
});
|
|
7479
|
-
|
|
7502
|
+
phase = "dormant";
|
|
7480
7503
|
if (rearmRequested) rearm();
|
|
7481
7504
|
} else {
|
|
7482
7505
|
logActivity(state, {
|
|
@@ -7484,7 +7507,7 @@ function scheduleClaudeUsageReporting(state, options) {
|
|
|
7484
7507
|
level: "debug",
|
|
7485
7508
|
message: `Claude usage reporting: ${error2.message}`
|
|
7486
7509
|
});
|
|
7487
|
-
scheduleNextTick();
|
|
7510
|
+
scheduleNextTick(false);
|
|
7488
7511
|
}
|
|
7489
7512
|
} else {
|
|
7490
7513
|
consecutiveFailures++;
|
|
@@ -7494,12 +7517,11 @@ function scheduleClaudeUsageReporting(state, options) {
|
|
|
7494
7517
|
level: claudeUsageFailureLogLevel(consecutiveFailures),
|
|
7495
7518
|
message: `Claude usage reporting failed: ${message}${claudeUsageFailureStreakSuffix(consecutiveFailures)}`
|
|
7496
7519
|
});
|
|
7497
|
-
scheduleNextTick();
|
|
7520
|
+
scheduleNextTick(false);
|
|
7498
7521
|
}
|
|
7499
7522
|
}
|
|
7500
7523
|
};
|
|
7501
|
-
|
|
7502
|
-
state.claudeUsageTimer = setTimeout(() => void tick(true), FIRST_REPORT_DELAY_MS);
|
|
7524
|
+
armProbe();
|
|
7503
7525
|
return rearm;
|
|
7504
7526
|
}
|
|
7505
7527
|
async function notifyOffline(state) {
|