@usagefleet/cli 1.2.165 → 1.2.167

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/collector.js CHANGED
@@ -321,15 +321,53 @@ function pruneMissingFiles(state, scanned) {
321
321
  function planWall() {
322
322
  return `device outside your plan's device limit · free a slot or upgrade at ${ENDPOINT}/fleet · nothing is lost, uploads resume once it fits`;
323
323
  }
324
+ /** Report the Claude Code login's limits, then those of any other account jcode or pj has active. */
325
+ export async function reportLimitsOnce(cfg, log = () => {
326
+ /* empty */
327
+ }) {
328
+ const report = await reportClaudeCodeLimits(cfg, log);
329
+ await reportJcodeLimits(cfg, report?.account?.extId, log);
330
+ return report;
331
+ }
332
+ /**
333
+ * jcode and pj keep their own Anthropic logins, so the account one of them has active
334
+ * can differ from Claude Code's; with no reading of its own that account's limits go
335
+ * stale on the server and its group stops blocking.
336
+ */
337
+ async function reportJcodeLimits(cfg, reportedExtId, log) {
338
+ const reported = new Set(reportedExtId ? [reportedExtId] : []);
339
+ for (const sessionsDir of [cfg.jcodeDir, cfg.pjDir]) {
340
+ if (!sessionsDir) {
341
+ continue;
342
+ }
343
+ // Never refreshed here: rotating the refresh token would sign jcode or pj out.
344
+ const token = activeJcodeToken(join(dirname(sessionsDir), 'auth.json'));
345
+ const extId = token ? await tokenOwner(token) : null;
346
+ if (!token || !extId || reported.has(extId)) {
347
+ continue;
348
+ }
349
+ reported.add(extId);
350
+ let report;
351
+ try {
352
+ report = await fetchLimits({ source: 'sub', token });
353
+ }
354
+ catch (error) {
355
+ log('warn', `limits fetch failed for the ${tilde(dirname(sessionsDir))} login · ${error.message}`);
356
+ continue;
357
+ }
358
+ const outcome = await postLimits({ ...report, account: { email: null, extId, org: null } }, cfg);
359
+ if (outcome !== 'ok') {
360
+ log('warn', `limits upload failed for the ${tilde(dirname(sessionsDir))} login · ${outcome}`);
361
+ }
362
+ }
363
+ }
324
364
  /**
325
365
  * Auto-detect the local Claude login, read the real 5h/weekly utilization
326
366
  * (oauth/usage for subscription logins, rate-limit headers for API keys), and
327
367
  * report it to the server. Best-effort — returns null (and logs) when no login
328
368
  * is found or the request fails.
329
369
  */
330
- export async function reportLimitsOnce(cfg, log = () => {
331
- /* empty */
332
- }) {
370
+ async function reportClaudeCodeLimits(cfg, log) {
333
371
  const creds = await detectClaudeCreds();
334
372
  if (!creds) {
335
373
  if (process.platform === 'darwin' && macKeychainDenied()) {
package/dist/release.js CHANGED
@@ -1,2 +1,2 @@
1
1
  // Generated by .github/workflows/release.yml.
2
- export const RELEASE_VERSION = "1.2.165";
2
+ export const RELEASE_VERSION = "1.2.167";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@usagefleet/cli",
3
- "version": "1.2.165",
3
+ "version": "1.2.167",
4
4
  "description": "Tails Claude Code, Claude Desktop, and pi agent JSONL logs and reports token usage to a UsageFleet server.",
5
5
  "keywords": [
6
6
  "claude",