claude-rpc 0.13.3 → 0.13.4
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/package.json +1 -1
- package/src/community.js +11 -2
- package/src/version.js +1 -1
package/package.json
CHANGED
package/src/community.js
CHANGED
|
@@ -53,6 +53,15 @@ export function osFamily() {
|
|
|
53
53
|
return 'linux';
|
|
54
54
|
}
|
|
55
55
|
|
|
56
|
+
// Per-report caps. These mirror the worker's validateReport limits — the
|
|
57
|
+
// client CLAMPS each delta to them so a large first-time backfill (a heavy
|
|
58
|
+
// user's whole lifetime total on the very first report) STREAMS over multiple
|
|
59
|
+
// flushes instead of being rejected. Without this, anyone with >5B lifetime
|
|
60
|
+
// tokens would 400 forever (the cursor never advances on a rejected report) and
|
|
61
|
+
// be silently dropped from the community totals.
|
|
62
|
+
const MAX_REPORT_SESSIONS = 100_000;
|
|
63
|
+
const MAX_REPORT_TOKENS = 5_000_000_000;
|
|
64
|
+
|
|
56
65
|
// Pure: given an aggregate and a cursor, produce the next payload. The
|
|
57
66
|
// worker's validateReport must accept this shape; if you add a field
|
|
58
67
|
// here, add it there too.
|
|
@@ -64,8 +73,8 @@ export function buildPayload(aggregate, cursor, { instanceId, now = Date.now() }
|
|
|
64
73
|
+ (aggregate?.cacheWriteTokens || 0);
|
|
65
74
|
return {
|
|
66
75
|
instanceId,
|
|
67
|
-
sessionsDelta: Math.max(0, sessions - (cursor.sessions || 0)),
|
|
68
|
-
tokensDelta: Math.max(0, tokens - (cursor.tokens || 0)),
|
|
76
|
+
sessionsDelta: Math.min(MAX_REPORT_SESSIONS, Math.max(0, sessions - (cursor.sessions || 0))),
|
|
77
|
+
tokensDelta: Math.min(MAX_REPORT_TOKENS, Math.max(0, tokens - (cursor.tokens || 0))),
|
|
69
78
|
version: VERSION,
|
|
70
79
|
osFamily: osFamily(),
|
|
71
80
|
ts: now,
|