agents-deck 1.20.0 → 1.20.1
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/web/index.html
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
6
6
|
<title>agents-deck</title>
|
|
7
7
|
<link rel="icon" href="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Ctext y='84' font-size='84'%3E%E2%97%89%3C/text%3E%3C/svg%3E" />
|
|
8
|
-
<script type="module" crossorigin src="/assets/index-
|
|
8
|
+
<script type="module" crossorigin src="/assets/index-Bf_B--gp.js"></script>
|
|
9
9
|
<link rel="stylesheet" crossorigin href="/assets/index-_qWQOt8_.css">
|
|
10
10
|
</head>
|
|
11
11
|
<body>
|
package/package.json
CHANGED
package/src/server/quota.mjs
CHANGED
|
@@ -11,8 +11,9 @@ import { homedir, platform } from "node:os";
|
|
|
11
11
|
const execAsync = promisify(exec);
|
|
12
12
|
const IS_WIN = platform() === "win32";
|
|
13
13
|
|
|
14
|
-
let _cache
|
|
15
|
-
let _cacheAt
|
|
14
|
+
let _cache = null;
|
|
15
|
+
let _cacheAt = 0;
|
|
16
|
+
let _inflight = null; // deduplicates concurrent exec() calls
|
|
16
17
|
const CACHE_MS = 60_000;
|
|
17
18
|
|
|
18
19
|
function stripAnsi(s) {
|
|
@@ -122,10 +123,20 @@ export async function fetchClaudeQuota({ force = false } = {}) {
|
|
|
122
123
|
const now = Date.now();
|
|
123
124
|
if (!force && _cache && now - _cacheAt < CACHE_MS) return _cache;
|
|
124
125
|
|
|
126
|
+
// If another exec() is already in flight, wait for it instead of spawning a
|
|
127
|
+
// second concurrent process (which can return empty output and overwrite the
|
|
128
|
+
// good result with 0%).
|
|
129
|
+
if (_inflight) return _inflight;
|
|
130
|
+
|
|
131
|
+
_inflight = _doFetch(now).finally(() => { _inflight = null; });
|
|
132
|
+
return _inflight;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
async function _doFetch(now) {
|
|
125
136
|
const shellCmd = buildQuotaShellCmd();
|
|
126
137
|
let parsed = null;
|
|
127
|
-
|
|
128
138
|
let cliOk = false;
|
|
139
|
+
|
|
129
140
|
try {
|
|
130
141
|
const { stdout, stderr } = await execAsync(shellCmd, {
|
|
131
142
|
timeout: 15_000,
|
|
@@ -133,7 +144,6 @@ export async function fetchClaudeQuota({ force = false } = {}) {
|
|
|
133
144
|
maxBuffer: 1024 * 1024,
|
|
134
145
|
});
|
|
135
146
|
const combined = stdout + "\n" + stderr;
|
|
136
|
-
// CLI ran successfully if we see the subscription preamble.
|
|
137
147
|
cliOk = /subscription/i.test(combined) || /claude code usage/i.test(combined);
|
|
138
148
|
parsed = parseUsageText(combined);
|
|
139
149
|
} catch (err) {
|
|
@@ -146,9 +156,13 @@ export async function fetchClaudeQuota({ force = false } = {}) {
|
|
|
146
156
|
}
|
|
147
157
|
}
|
|
148
158
|
|
|
149
|
-
// CLI ran OK but quota lines
|
|
150
|
-
//
|
|
151
|
-
|
|
159
|
+
// CLI ran OK but quota lines absent — this happens when:
|
|
160
|
+
// (a) near-zero usage in the rolling window (Claude omits bars below ~1%), or
|
|
161
|
+
// (b) CLI cold-start: the server-side rolling window hasn't been computed yet.
|
|
162
|
+
// In case (b) the real value appears within ~60s. Use a 5s short-cache so
|
|
163
|
+
// the UI polls again quickly and shows real values as soon as they're ready.
|
|
164
|
+
const shortCache = cliOk && !parsed;
|
|
165
|
+
if (shortCache) {
|
|
152
166
|
parsed = {
|
|
153
167
|
session5hPct: 0, session5hWindowSec: 18000,
|
|
154
168
|
week7dPct: 0, week7dWindowSec: 604800,
|
|
@@ -159,8 +173,9 @@ export async function fetchClaudeQuota({ force = false } = {}) {
|
|
|
159
173
|
? { ok: true, ...parsed, fetchedAt: now }
|
|
160
174
|
: { ok: false, fetchedAt: now };
|
|
161
175
|
|
|
162
|
-
_cache
|
|
163
|
-
|
|
176
|
+
_cache = result;
|
|
177
|
+
// Short-cache the 0% fallback so the UI retries in ~5s rather than 60s.
|
|
178
|
+
_cacheAt = shortCache ? now - (CACHE_MS - 5_000) : now;
|
|
164
179
|
return result;
|
|
165
180
|
}
|
|
166
181
|
|