tokentracker-cli 0.5.75 → 0.5.77
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/dashboard/dist/assets/{Card-D-EuRzLE.js → Card-Cv4eTIKD.js} +1 -1
- package/dashboard/dist/assets/{DashboardPage-DP4h327m.js → DashboardPage-BLFOnvMn.js} +1 -1
- package/dashboard/dist/assets/{FadeIn-Nqb2FeSu.js → FadeIn-CIeY4GXM.js} +1 -1
- package/dashboard/dist/assets/{IpCheckPage-DKErP77B.js → IpCheckPage-IsYc44dj.js} +1 -1
- package/dashboard/dist/assets/{LeaderboardPage-D_DqH7v4.js → LeaderboardPage-Su4flsQc.js} +2 -2
- package/dashboard/dist/assets/{LeaderboardProfilePage-B4U6R6TW.js → LeaderboardProfilePage-bt2zrvtb.js} +1 -1
- package/dashboard/dist/assets/{LimitsPage-WP9IFHnS.js → LimitsPage-CojL1PZS.js} +1 -1
- package/dashboard/dist/assets/{ProviderIcon-CiAX7O9R.js → ProviderIcon-C2Qp69XI.js} +1 -1
- package/dashboard/dist/assets/{SettingsPage-BzWrP1qX.js → SettingsPage-FSVM_ozY.js} +1 -1
- package/dashboard/dist/assets/{WidgetsPage-BbV32pxZ.js → WidgetsPage-CeLvw5tR.js} +1 -1
- package/dashboard/dist/assets/{download-CXIEU-zL.js → download-BK4EqMpL.js} +1 -1
- package/dashboard/dist/assets/{leaderboard-columns-DIsoAppd.js → leaderboard-columns-CxdAz5_V.js} +1 -1
- package/dashboard/dist/assets/{main-_yO2TZgj.js → main-CPsqG3PW.js} +2 -2
- package/dashboard/dist/assets/{use-limits-display-prefs-CogaUGYH.js → use-limits-display-prefs-C-Y8vFA9.js} +1 -1
- package/dashboard/dist/assets/{use-usage-limits-Didh7hvY.js → use-usage-limits-CiHD5lbg.js} +1 -1
- package/dashboard/dist/index.html +1 -1
- package/dashboard/dist/share.html +1 -1
- package/package.json +1 -1
- package/src/commands/sync.js +1 -1
- package/src/lib/diagnostics.js +15 -2
- package/src/lib/local-api.js +45 -8
- package/src/lib/rollout.js +319 -68
package/src/commands/sync.js
CHANGED
|
@@ -385,7 +385,7 @@ async function cmdSync(argv) {
|
|
|
385
385
|
if (!progress?.enabled) return;
|
|
386
386
|
const pct = p.total > 0 ? p.index / p.total : 1;
|
|
387
387
|
progress.update(
|
|
388
|
-
`Parsing Kiro CLI ${renderBar(pct)} ${formatNumber(p.index)}/${formatNumber(p.total)}
|
|
388
|
+
`Parsing Kiro CLI ${renderBar(pct)} ${formatNumber(p.index)}/${formatNumber(p.total)} sessions | buckets ${formatNumber(p.bucketsQueued)}`,
|
|
389
389
|
);
|
|
390
390
|
},
|
|
391
391
|
});
|
package/src/lib/diagnostics.js
CHANGED
|
@@ -16,7 +16,20 @@ const { normalizeState: normalizeUploadState } = require("./upload-throttle");
|
|
|
16
16
|
const { probeOpenclawHookState } = require("./openclaw-hook");
|
|
17
17
|
const { probeOpenclawSessionPluginState } = require("./openclaw-session-plugin");
|
|
18
18
|
const { resolveTrackerPaths } = require("./tracker-paths");
|
|
19
|
-
|
|
19
|
+
// TASK-011: Kiro CLI DB path inlined here to avoid pulling the ~4000-line
|
|
20
|
+
// rollout module on every `tokentracker status` / `diagnostics` call.
|
|
21
|
+
// rollout.js still exports resolveKiroCliDbPath for external callers.
|
|
22
|
+
function resolveKiroCliDbPathInline(env, home) {
|
|
23
|
+
if (env.KIRO_CLI_DB_PATH) return env.KIRO_CLI_DB_PATH;
|
|
24
|
+
const effectiveHome = env.HOME || home;
|
|
25
|
+
return path.join(
|
|
26
|
+
effectiveHome,
|
|
27
|
+
"Library",
|
|
28
|
+
"Application Support",
|
|
29
|
+
"kiro-cli",
|
|
30
|
+
"data.sqlite3",
|
|
31
|
+
);
|
|
32
|
+
}
|
|
20
33
|
|
|
21
34
|
async function collectTrackerDiagnostics({
|
|
22
35
|
home = os.homedir(),
|
|
@@ -98,7 +111,7 @@ async function collectTrackerDiagnostics({
|
|
|
98
111
|
const kiroIdePresent =
|
|
99
112
|
(await safeStatSize(path.join(kiroIdeDevDataDir, "devdata.sqlite"))) > 0 ||
|
|
100
113
|
(await safeStatSize(path.join(kiroIdeDevDataDir, "tokens_generated.jsonl"))) > 0;
|
|
101
|
-
const kiroCliDbPath =
|
|
114
|
+
const kiroCliDbPath = resolveKiroCliDbPathInline(process.env, home);
|
|
102
115
|
const kiroCliPresent = require("node:fs").existsSync(kiroCliDbPath);
|
|
103
116
|
|
|
104
117
|
const lastSuccessAt = uploadThrottle.lastSuccessMs
|
package/src/lib/local-api.js
CHANGED
|
@@ -557,7 +557,7 @@ function createLocalApiHandler({ queuePath }) {
|
|
|
557
557
|
try {
|
|
558
558
|
// Sticky semantics: never replace an existing on-disk session with an empty cookie map.
|
|
559
559
|
if (relayCookies.size === 0) return;
|
|
560
|
-
|
|
560
|
+
|
|
561
561
|
const json = JSON.stringify(Object.fromEntries(relayCookies));
|
|
562
562
|
fs.writeFileSync(cookiePath, json, { encoding: "utf8", mode: 0o600 });
|
|
563
563
|
} catch (e) {
|
|
@@ -565,6 +565,18 @@ function createLocalApiHandler({ queuePath }) {
|
|
|
565
565
|
}
|
|
566
566
|
}
|
|
567
567
|
|
|
568
|
+
function clearRelayCookies(reason) {
|
|
569
|
+
if (relayCookies.size === 0) return;
|
|
570
|
+
relayCookies.clear();
|
|
571
|
+
try {
|
|
572
|
+
if (fs.existsSync(cookiePath)) fs.unlinkSync(cookiePath);
|
|
573
|
+
} catch (e) {
|
|
574
|
+
console.error("[LocalAPI] Failed to clear relay cookies:", e.message);
|
|
575
|
+
return;
|
|
576
|
+
}
|
|
577
|
+
if (reason) console.warn(`[LocalAPI] Cleared relay cookies: ${reason}`);
|
|
578
|
+
}
|
|
579
|
+
|
|
568
580
|
function captureSetCookies(headerValue) {
|
|
569
581
|
if (!headerValue) return;
|
|
570
582
|
const parts = headerValue.split(/,(?=\s*\w+=)/);
|
|
@@ -598,11 +610,17 @@ function createLocalApiHandler({ queuePath }) {
|
|
|
598
610
|
if (changed) persistRelayCookies();
|
|
599
611
|
}
|
|
600
612
|
|
|
613
|
+
function normalizeCookieHeader(value) {
|
|
614
|
+
if (Array.isArray(value)) return value.filter(Boolean).join("; ");
|
|
615
|
+
return typeof value === "string" ? value : "";
|
|
616
|
+
}
|
|
617
|
+
|
|
601
618
|
function buildRelayCookieHeader(clientCookieHeader) {
|
|
602
|
-
|
|
619
|
+
const normalizedClientCookieHeader = normalizeCookieHeader(clientCookieHeader);
|
|
620
|
+
if (relayCookies.size === 0) return normalizedClientCookieHeader;
|
|
603
621
|
const clientPairs = new Map();
|
|
604
|
-
if (
|
|
605
|
-
for (const part of
|
|
622
|
+
if (normalizedClientCookieHeader) {
|
|
623
|
+
for (const part of normalizedClientCookieHeader.split(";")) {
|
|
606
624
|
const eqIdx = part.indexOf("=");
|
|
607
625
|
if (eqIdx < 1) continue;
|
|
608
626
|
const n = part.substring(0, eqIdx).trim();
|
|
@@ -672,8 +690,18 @@ function createLocalApiHandler({ queuePath }) {
|
|
|
672
690
|
if (key === "host" || key === "connection") continue;
|
|
673
691
|
proxyHeaders[key] = value;
|
|
674
692
|
}
|
|
675
|
-
|
|
676
|
-
const
|
|
693
|
+
const hasClientCookie = normalizeCookieHeader(proxyHeaders["cookie"]).trim().length > 0;
|
|
694
|
+
const hasCsrfHeader = typeof proxyHeaders["x-csrf-token"] === "string" && proxyHeaders["x-csrf-token"].trim().length > 0;
|
|
695
|
+
const shouldInjectRelayCookies =
|
|
696
|
+
p !== "/api/auth/refresh" || hasClientCookie || hasCsrfHeader;
|
|
697
|
+
|
|
698
|
+
// Inject relay cookies so WebView benefits from browser's login session.
|
|
699
|
+
// Refresh requests need either a browser cookie or an explicit CSRF token;
|
|
700
|
+
// otherwise replaying a stale persisted refresh cookie just manufactures
|
|
701
|
+
// Invalid CSRF errors on startup.
|
|
702
|
+
const mergedCookie = shouldInjectRelayCookies
|
|
703
|
+
? buildRelayCookieHeader(proxyHeaders["cookie"])
|
|
704
|
+
: normalizeCookieHeader(proxyHeaders["cookie"]);
|
|
677
705
|
if (mergedCookie) proxyHeaders["cookie"] = mergedCookie;
|
|
678
706
|
|
|
679
707
|
const bodyChunks = [];
|
|
@@ -697,8 +725,17 @@ function createLocalApiHandler({ queuePath }) {
|
|
|
697
725
|
return [k, v];
|
|
698
726
|
});
|
|
699
727
|
res.writeHead(proxyRes.status, Object.fromEntries(responseHeaders));
|
|
700
|
-
const resBody = await proxyRes.arrayBuffer();
|
|
701
|
-
|
|
728
|
+
const resBody = Buffer.from(await proxyRes.arrayBuffer());
|
|
729
|
+
if (
|
|
730
|
+
p === "/api/auth/refresh"
|
|
731
|
+
&& proxyRes.status === 403
|
|
732
|
+
&& !hasClientCookie
|
|
733
|
+
&& !hasCsrfHeader
|
|
734
|
+
&& /invalid csrf token/i.test(resBody.toString("utf8"))
|
|
735
|
+
) {
|
|
736
|
+
clearRelayCookies("stale refresh cookie without local CSRF context");
|
|
737
|
+
}
|
|
738
|
+
res.end(resBody);
|
|
702
739
|
} catch (e) {
|
|
703
740
|
json(res, { error: `Auth proxy error: ${e?.message || e}` }, 502);
|
|
704
741
|
}
|