tokentracker-cli 0.93.4 → 0.93.6
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/{AchievementBadge-BcNvxrVM.js → AchievementBadge-DsAclDw6.js} +1 -1
- package/dashboard/dist/assets/{AchievementsPage-DhipQygJ.js → AchievementsPage-D__EwC45.js} +2 -2
- package/dashboard/dist/assets/{AchievementsSection-BJyb_mIr.js → AchievementsSection-BAZNM3Cn.js} +1 -1
- package/dashboard/dist/assets/{BadgeDetailModal-CoZv7o6t.js → BadgeDetailModal-Dgeer5oB.js} +1 -1
- package/dashboard/dist/assets/{BotAnimated-eVBNtvcG.js → BotAnimated-CwrScgrI.js} +1 -1
- package/dashboard/dist/assets/{Card-BEfG2im9.js → Card-D7GmLoqP.js} +1 -1
- package/dashboard/dist/assets/{ClawdAnimated-C-30t4dC.js → ClawdAnimated-BEXgb5J_.js} +2 -2
- package/dashboard/dist/assets/{CommandPalette-DF-TGB1C.js → CommandPalette-B9Mn3Qt2.js} +1 -1
- package/dashboard/dist/assets/{CommunityStatsModal-D-0eI3Pz.js → CommunityStatsModal-eJ_a1FMd.js} +1 -1
- package/dashboard/dist/assets/{ConfirmModal-BQ7Aor1C.js → ConfirmModal-CumOr2J1.js} +1 -1
- package/dashboard/dist/assets/{Controls-COThRtMS.js → Controls-DxnaHBzv.js} +1 -1
- package/dashboard/dist/assets/{DashboardPage-Ci_Gb5I1.js → DashboardPage-BpRRXCRr.js} +1 -1
- package/dashboard/dist/assets/{DevicePage-BmlmimUg.js → DevicePage-4yTYf29M.js} +1 -1
- package/dashboard/dist/assets/{DialogClose-BdALEZzc.js → DialogClose-BbderFCY.js} +1 -1
- package/dashboard/dist/assets/DialogDescription-C5Ujj254.js +1 -0
- package/dashboard/dist/assets/{DialogTitle-F6W1aTiE.js → DialogTitle-6epeLIn0.js} +1 -1
- package/dashboard/dist/assets/{FadeIn-S2d3D28d.js → FadeIn-BFLojPGG.js} +1 -1
- package/dashboard/dist/assets/{HeaderGithubStar-DBBwOwc_.js → HeaderGithubStar-CPBNn61n.js} +1 -1
- package/dashboard/dist/assets/{HoverTooltip-rLWQC9Va.js → HoverTooltip-DbxnLj8e.js} +1 -1
- package/dashboard/dist/assets/{IpCheckPage-BpPoAIry.js → IpCheckPage-CfPtXAAF.js} +1 -1
- package/dashboard/dist/assets/{LandingPage-BUm_ZMew.js → LandingPage-CocswfFj.js} +2 -2
- package/dashboard/dist/assets/{LeaderboardAvatar-DQxbOYZb.js → LeaderboardAvatar-iZLxxZX-.js} +1 -1
- package/dashboard/dist/assets/{LeaderboardPage-DzLrFQm8.js → LeaderboardPage-yqauB4Q1.js} +2 -2
- package/dashboard/dist/assets/{LeaderboardProfileModal-Cq4B8Les.js → LeaderboardProfileModal-BWu8jbBW.js} +3 -3
- package/dashboard/dist/assets/{LeaderboardProfilePage-C-Xj65xf.js → LeaderboardProfilePage-B77gOTzr.js} +1 -1
- package/dashboard/dist/assets/{LimitsPage-Bjcmr0bd.js → LimitsPage-C9NeIcft.js} +1 -1
- package/dashboard/dist/assets/{LocalOnlyNotice-9mWINkVj.js → LocalOnlyNotice-HPXWU8TT.js} +1 -1
- package/dashboard/dist/assets/{LoginCard-BlKleF8M.js → LoginCard-D592L-fh.js} +1 -1
- package/dashboard/dist/assets/{LoginModal-BUYa13hj.js → LoginModal-C7Qm7CVf.js} +1 -1
- package/dashboard/dist/assets/{LoginPage-DbQhApOd.js → LoginPage-DkYw5ZQK.js} +1 -1
- package/dashboard/dist/assets/{PetPage-DuAf3OOf.js → PetPage-BOhvAJp4.js} +1 -1
- package/dashboard/dist/assets/{PopoverPopup-CG76MkbK.js → PopoverPopup-BK9aqQn1.js} +1 -1
- package/dashboard/dist/assets/{ProviderIcon-N7OTtgte.js → ProviderIcon-d0_vhIkS.js} +1 -1
- package/dashboard/dist/assets/{ResetPasswordPage-D48--1wC.js → ResetPasswordPage-UDNlpFVu.js} +1 -1
- package/dashboard/dist/assets/{SegmentedControl-zRvbFqyY.js → SegmentedControl-DE5m1pTf.js} +1 -1
- package/dashboard/dist/assets/{Select-Bi3B21Fb.js → Select-Z2xTQ55f.js} +1 -1
- package/dashboard/dist/assets/{SelectItemText-Bg8I618N.js → SelectItemText-Daq-XRZg.js} +1 -1
- package/dashboard/dist/assets/{ServiceStatusPage-CeeYx4XY.js → ServiceStatusPage-Cfr-QDZ7.js} +1 -1
- package/dashboard/dist/assets/{SessionsPage-CZF3qLEm.js → SessionsPage-nHPj6IAt.js} +1 -1
- package/dashboard/dist/assets/{SettingsPage-D2wa8i5u.js → SettingsPage-NvxUG_9m.js} +2 -2
- package/dashboard/dist/assets/{SkillsPage-OxW2w6up.js → SkillsPage-zFbZa42f.js} +1 -1
- package/dashboard/dist/assets/{TokenGalaxy-DmtP_r86.js → TokenGalaxy-CjAY6rey.js} +1 -1
- package/dashboard/dist/assets/{ToolbarRootContext-DC6BLLoO.js → ToolbarRootContext-DnC8LT_8.js} +1 -1
- package/dashboard/dist/assets/{TrendMonitor-OvvLCD3K.js → TrendMonitor-DAAlILwJ.js} +1 -1
- package/dashboard/dist/assets/{WidgetsPage-DhOC8rae.js → WidgetsPage-CXsfi-mq.js} +1 -1
- package/dashboard/dist/assets/{WrappedPage-C0boSobK.js → WrappedPage-ByYzOeZ-.js} +1 -1
- package/dashboard/dist/assets/__vite-browser-external-HdCplPKs.js +45 -0
- package/dashboard/dist/assets/{agent-logos-Dzyq5cDh.js → agent-logos-BW-ajJ7p.js} +1 -1
- package/dashboard/dist/assets/{arrow-up-right-DrLfm7Vy.js → arrow-up-right-CA5IJkqo.js} +1 -1
- package/dashboard/dist/assets/{check-DAsdH-MF.js → check-BBjF3bSm.js} +1 -1
- package/dashboard/dist/assets/{chevron-right-CdSgby9-.js → chevron-right-DCvGp9iJ.js} +1 -1
- package/dashboard/dist/assets/{copy-TuVoW7qK.js → copy-ahF8LGeu.js} +1 -1
- package/dashboard/dist/assets/{download-BZ61xuhi.js → download-DBm8dmvt.js} +1 -1
- package/dashboard/dist/assets/{external-link-DJrRSKF9.js → external-link-C1sJSL7J.js} +1 -1
- package/dashboard/dist/assets/{flame-9JS9yMju.js → flame-B6xukEYd.js} +1 -1
- package/dashboard/dist/assets/{format-tokens-Blp6lI_n.js → format-tokens-6TqXlT3q.js} +1 -1
- package/dashboard/dist/assets/{icons-CbF0cL6i.js → icons-pGe_pInY.js} +1 -1
- package/dashboard/dist/assets/{index-I81NzV7H.js → index-Chb8mb2X.js} +1 -1
- package/dashboard/dist/assets/{index-FnWiMfqV.js → index-I9O8xChC.js} +1 -1
- package/dashboard/dist/assets/{index-Bu3I2hmd.js → index-RPV0zdZ9.js} +1 -1
- package/dashboard/dist/assets/{info-B_iryt84.js → info-DBfJv0yu.js} +1 -1
- package/dashboard/dist/assets/{limits-providers-Cli4pkKC.js → limits-providers-DPQsdVq5.js} +1 -1
- package/dashboard/dist/assets/{link-2-pB3-7Waa.js → link-2-DNEARrPY.js} +1 -1
- package/dashboard/dist/assets/{loader-circle-DivA-LsF.js → loader-circle-BCFHUr8X.js} +1 -1
- package/dashboard/dist/assets/{maximize-2-WNMF5NUU.js → maximize-2-1EmlA2R-.js} +1 -1
- package/dashboard/dist/assets/{modifiers.esm-BaJJxzf2.js → modifiers.esm-DGXFSuEq.js} +1 -1
- package/dashboard/dist/assets/module-D2D5r9gC.js +3 -0
- package/dashboard/dist/assets/{monitor-smartphone-pAR3IHow.js → monitor-smartphone-DsPPhvsT.js} +1 -1
- package/dashboard/dist/assets/{provider-display-CyYhYVar.js → provider-display-C20LtBC5.js} +1 -1
- package/dashboard/dist/assets/{react-BldsIPA1.js → react-B4FPJgs_.js} +1 -1
- package/dashboard/dist/assets/{search-xIfdCEo0.js → search-mkIFPKzW.js} +1 -1
- package/dashboard/dist/assets/{skills-api-DZNsCHPo.js → skills-api-D24vlu2H.js} +1 -1
- package/dashboard/dist/assets/{sortable.esm-DMaj448G.js → sortable.esm-BNDcP0sW.js} +1 -1
- package/dashboard/dist/assets/{store-VTEegajU.js → store-B2nqaAqP.js} +1 -1
- package/dashboard/dist/assets/{terminal-Bj8SotRv.js → terminal-BxVMmvEx.js} +1 -1
- package/dashboard/dist/assets/{trash-2-CWgY_FBc.js → trash-2-crt9lDvj.js} +1 -1
- package/dashboard/dist/assets/{use-community-stats-BOVvh_Gv.js → use-community-stats-CTB_uHWV.js} +1 -1
- package/dashboard/dist/assets/{use-limits-display-prefs-MtLsQ5kN.js → use-limits-display-prefs-DXXZpjGY.js} +1 -1
- package/dashboard/dist/assets/{use-ordered-list-DjCZVinv.js → use-ordered-list-BVNb5QWU.js} +1 -1
- package/dashboard/dist/assets/use-reduced-motion-aSaQtoJu.js +1 -0
- package/dashboard/dist/assets/{use-session-efficiency-pref-DASihY0W.js → use-session-efficiency-pref-Di8nY6Lr.js} +1 -1
- package/dashboard/dist/assets/{use-transform-tHlm2id8.js → use-transform-Dx9C2nBC.js} +1 -1
- package/dashboard/dist/assets/{use-usage-limits-BBEHNJKl.js → use-usage-limits-D9vQFB1H.js} +1 -1
- package/dashboard/dist/assets/{useCurrency-DgTCDMXb.js → useCurrency-7dkDciam.js} +1 -1
- package/dashboard/dist/assets/{useScrollLock-C3TFkbz0.js → useScrollLock-BUVUIPTX.js} +1 -1
- package/dashboard/dist/assets/{useTokenFormat-BtqPANfZ.js → useTokenFormat-DFSIAsAb.js} +1 -1
- package/dashboard/dist/assets/{zap-CJNTZ87b.js → zap-Png-VJSP.js} +1 -1
- package/dashboard/dist/index.html +1 -1
- package/dashboard/dist/ip-check.html +1 -1
- package/dashboard/dist/leaderboard.html +1 -1
- package/dashboard/dist/share.html +1 -1
- package/package.json +1 -1
- package/src/commands/serve.js +115 -4
- package/src/commands/sync.js +159 -9
- package/src/lib/opencode-go-limits.js +11 -3
- package/src/lib/pricing/seed-snapshot.json +1 -1
- package/src/lib/rollout.js +252 -22
- package/src/lib/usage-limits.js +119 -1
- package/dashboard/dist/assets/DialogDescription-DAKoQCEv.js +0 -1
- package/dashboard/dist/assets/__vite-browser-external-D_dICEUB.js +0 -1575
- package/dashboard/dist/assets/module-CV1mYFsv.js +0 -3
- package/dashboard/dist/assets/use-reduced-motion-DjWNXuSi.js +0 -1
package/src/commands/sync.js
CHANGED
|
@@ -28,6 +28,7 @@ const {
|
|
|
28
28
|
readOpencodeDbMessages,
|
|
29
29
|
readMimoDbMessages,
|
|
30
30
|
readZcodeDbMessages,
|
|
31
|
+
hasZcodeNativeUsageSchema,
|
|
31
32
|
resolveQoderDbPaths,
|
|
32
33
|
resolveQoderCnDbPaths,
|
|
33
34
|
readQoderDbMessages,
|
|
@@ -257,6 +258,7 @@ const CODEX_COLD_SCAN_AUDIT_MAX_SYNCS = 288;
|
|
|
257
258
|
// state so the next sync (providerID-filtered reader) rebuilds it correctly.
|
|
258
259
|
const MIMO_PROVIDER_REPAIR_KEY = "mimoClaudeMislabelRepair_2026_06";
|
|
259
260
|
const DSH_LEGACY_SOURCE_MIGRATION_KEY = "deepseekHarnessSourceMigration_2026_08";
|
|
261
|
+
const ZCODE_NATIVE_USAGE_REPAIR_KEY = "zcodeNativeUsageRepair_2026_08";
|
|
260
262
|
const AUTO_SYNC_SOURCE_ALIASES = new Map([
|
|
261
263
|
["code", "every-code"],
|
|
262
264
|
["deepseek", "dsh"],
|
|
@@ -468,6 +470,9 @@ async function cmdSync(argv, context = {}) {
|
|
|
468
470
|
const traeCnNowMs = context && typeof context === "object"
|
|
469
471
|
? context.traeCnNowMs
|
|
470
472
|
: undefined;
|
|
473
|
+
const cursorSyncDeps = context && typeof context.cursorSyncDeps === "object"
|
|
474
|
+
? context.cursorSyncDeps
|
|
475
|
+
: {};
|
|
471
476
|
const syncDiagnostics = diagnostics && typeof diagnostics === "object" ? diagnostics : null;
|
|
472
477
|
const home = os.homedir();
|
|
473
478
|
const { trackerDir } = await resolveTrackerPaths({ home });
|
|
@@ -719,14 +724,21 @@ async function cmdSync(argv, context = {}) {
|
|
|
719
724
|
? cursors.codexDayInventoryCache
|
|
720
725
|
: { version: 1, days: {} };
|
|
721
726
|
if (sourceAllowed("codex")) cursors.codexDayInventoryCache = codexDayInventoryCache;
|
|
722
|
-
|
|
723
|
-
if (seenSessions.has(entry.sessionsDir))
|
|
727
|
+
const uniqueSources = sources.filter((entry) => {
|
|
728
|
+
if (seenSessions.has(entry.sessionsDir)) return false;
|
|
724
729
|
seenSessions.add(entry.sessionsDir);
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
730
|
+
return true;
|
|
731
|
+
});
|
|
732
|
+
const sourceFileGroups = await Promise.all(uniqueSources.map((entry) => (
|
|
733
|
+
entry.deep
|
|
734
|
+
? listRolloutFilesDeep(entry.sessionsDir)
|
|
735
|
+
: listRolloutFiles(entry.sessionsDir, entry.codexInventoryCache
|
|
728
736
|
? { dayInventoryCache: codexDayInventoryCache }
|
|
729
|
-
: undefined)
|
|
737
|
+
: undefined)
|
|
738
|
+
)));
|
|
739
|
+
for (let sourceIndex = 0; sourceIndex < uniqueSources.length; sourceIndex++) {
|
|
740
|
+
const entry = uniqueSources[sourceIndex];
|
|
741
|
+
const files = sourceFileGroups[sourceIndex];
|
|
730
742
|
for (const filePath of files) {
|
|
731
743
|
rolloutFiles.push({ path: filePath, source: entry.source });
|
|
732
744
|
}
|
|
@@ -1403,6 +1415,18 @@ async function cmdSync(argv, context = {}) {
|
|
|
1403
1415
|
if (zcodePaths.native || zcodePaths.wsl) {
|
|
1404
1416
|
if (progress?.enabled) progress.start(`Parsing ZCode ${renderBar(0)} | buckets 0`);
|
|
1405
1417
|
try {
|
|
1418
|
+
const nativeUsageAvailable = [zcodePaths.native, zcodePaths.wsl]
|
|
1419
|
+
.filter(Boolean)
|
|
1420
|
+
.some((dbPath) => hasZcodeNativeUsageSchema(dbPath));
|
|
1421
|
+
if (nativeUsageAvailable) {
|
|
1422
|
+
await repairZcodeNativeUsageMigration({
|
|
1423
|
+
cursors,
|
|
1424
|
+
queuePath,
|
|
1425
|
+
queueStatePath,
|
|
1426
|
+
projectQueuePath,
|
|
1427
|
+
projectQueueStatePath,
|
|
1428
|
+
});
|
|
1429
|
+
}
|
|
1406
1430
|
zcodeResult = await multiInstallParse({
|
|
1407
1431
|
paths: zcodePaths, parserFn: parseOpencodeDbForInstall, providerName: "zcode",
|
|
1408
1432
|
cursors, getParams: (p) => ({ dbPath: p, readFn: readZcodeDbMessages, source: "zcode", cursorKey: "zcode" }),
|
|
@@ -1640,14 +1664,17 @@ async function cmdSync(argv, context = {}) {
|
|
|
1640
1664
|
}
|
|
1641
1665
|
|
|
1642
1666
|
let cursorResult = { recordsProcessed: 0, eventsAggregated: 0, bucketsQueued: 0 };
|
|
1643
|
-
|
|
1644
|
-
|
|
1667
|
+
const cursorInstalled = cursorSyncDeps.isInstalled || isCursorInstalled;
|
|
1668
|
+
const cursorAuthExtractor = cursorSyncDeps.extractAuth || extractCursorSessionToken;
|
|
1669
|
+
const cursorUsageFetcher = cursorSyncDeps.fetchUsageCsv || fetchCursorUsageCsv;
|
|
1670
|
+
if (sourceAllowed("cursor") && cursorInstalled({ home })) {
|
|
1671
|
+
const cursorAuth = cursorAuthExtractor({ home });
|
|
1645
1672
|
if (cursorAuth) {
|
|
1646
1673
|
try {
|
|
1647
1674
|
if (progress?.enabled) {
|
|
1648
1675
|
progress.start(`Fetching Cursor usage...`);
|
|
1649
1676
|
}
|
|
1650
|
-
const csvText = await
|
|
1677
|
+
const csvText = await cursorUsageFetcher({ cookie: cursorAuth.cookie });
|
|
1651
1678
|
const records = parseCursorCsv(csvText);
|
|
1652
1679
|
if (records.length > 0) {
|
|
1653
1680
|
if (progress?.enabled) {
|
|
@@ -3105,6 +3132,7 @@ module.exports = {
|
|
|
3105
3132
|
repairCodexInterleavedUsageInflation,
|
|
3106
3133
|
repairDroidDuplicateSessionInflation,
|
|
3107
3134
|
repairMimoClaudeMislabel,
|
|
3135
|
+
repairZcodeNativeUsageMigration,
|
|
3108
3136
|
reincludeClaudeMemObserverFiles,
|
|
3109
3137
|
repairGrokQueueFromSessionSnapshots,
|
|
3110
3138
|
applyCloudConversationsBackfill,
|
|
@@ -4083,6 +4111,128 @@ async function repairMimoClaudeMislabel({
|
|
|
4083
4111
|
return true;
|
|
4084
4112
|
}
|
|
4085
4113
|
|
|
4114
|
+
async function resetUploadOffsetForZcodeNativeRepair(queueStatePath) {
|
|
4115
|
+
if (typeof queueStatePath !== "string" || !queueStatePath) return false;
|
|
4116
|
+
let state = {};
|
|
4117
|
+
try {
|
|
4118
|
+
state = JSON.parse(await fs.readFile(queueStatePath, "utf8"));
|
|
4119
|
+
} catch (_error) {
|
|
4120
|
+
state = {};
|
|
4121
|
+
}
|
|
4122
|
+
state.offset = 0;
|
|
4123
|
+
state.updatedAt = new Date().toISOString();
|
|
4124
|
+
state.note = "reset_after_zcode_native_usage_repair_2026_08";
|
|
4125
|
+
await ensureDir(path.dirname(queueStatePath));
|
|
4126
|
+
await fs.writeFile(queueStatePath, JSON.stringify(state, null, 2) + "\n", "utf8");
|
|
4127
|
+
return true;
|
|
4128
|
+
}
|
|
4129
|
+
|
|
4130
|
+
async function dropZcodeQueueRows(filePath, { retainRetractions = false } = {}) {
|
|
4131
|
+
let raw;
|
|
4132
|
+
try {
|
|
4133
|
+
raw = await fs.readFile(filePath, "utf8");
|
|
4134
|
+
} catch (error) {
|
|
4135
|
+
if (error?.code === "ENOENT") return { removed: 0, retractions: 0 };
|
|
4136
|
+
throw error;
|
|
4137
|
+
}
|
|
4138
|
+
const kept = [];
|
|
4139
|
+
const retractions = new Map();
|
|
4140
|
+
let removed = 0;
|
|
4141
|
+
for (const line of raw.split("\n")) {
|
|
4142
|
+
if (!line.trim()) continue;
|
|
4143
|
+
let row;
|
|
4144
|
+
try {
|
|
4145
|
+
row = JSON.parse(line);
|
|
4146
|
+
} catch (_error) {
|
|
4147
|
+
kept.push(line);
|
|
4148
|
+
continue;
|
|
4149
|
+
}
|
|
4150
|
+
if (row?.source === "zcode") {
|
|
4151
|
+
removed += 1;
|
|
4152
|
+
const model = typeof row.model === "string" && row.model.trim()
|
|
4153
|
+
? row.model.trim()
|
|
4154
|
+
: "unknown";
|
|
4155
|
+
const hourStart = typeof row.hour_start === "string" ? row.hour_start : "";
|
|
4156
|
+
if (retainRetractions && hourStart) {
|
|
4157
|
+
retractions.set(`${model}|${hourStart}`, {
|
|
4158
|
+
source: "zcode",
|
|
4159
|
+
model,
|
|
4160
|
+
hour_start: hourStart,
|
|
4161
|
+
input_tokens: 0,
|
|
4162
|
+
cached_input_tokens: 0,
|
|
4163
|
+
cache_creation_input_tokens: 0,
|
|
4164
|
+
output_tokens: 0,
|
|
4165
|
+
reasoning_output_tokens: 0,
|
|
4166
|
+
total_tokens: 0,
|
|
4167
|
+
conversation_count: 0,
|
|
4168
|
+
});
|
|
4169
|
+
}
|
|
4170
|
+
continue;
|
|
4171
|
+
}
|
|
4172
|
+
kept.push(line);
|
|
4173
|
+
}
|
|
4174
|
+
if (removed === 0) return { removed: 0, retractions: 0 };
|
|
4175
|
+
await backupExistingFile(filePath);
|
|
4176
|
+
const tmp = `${filePath}.zcoderepair.${process.pid}.${Date.now()}`;
|
|
4177
|
+
const rewritten = [
|
|
4178
|
+
...kept,
|
|
4179
|
+
...[...retractions.values()].map((row) => JSON.stringify(row)),
|
|
4180
|
+
];
|
|
4181
|
+
await fs.writeFile(tmp, rewritten.length ? rewritten.join("\n") + "\n" : "", "utf8");
|
|
4182
|
+
await fs.rename(tmp, filePath);
|
|
4183
|
+
return { removed, retractions: retractions.size };
|
|
4184
|
+
}
|
|
4185
|
+
|
|
4186
|
+
async function repairZcodeNativeUsageMigration({
|
|
4187
|
+
cursors,
|
|
4188
|
+
queuePath,
|
|
4189
|
+
queueStatePath,
|
|
4190
|
+
projectQueuePath,
|
|
4191
|
+
projectQueueStatePath,
|
|
4192
|
+
} = {}) {
|
|
4193
|
+
if (!cursors || typeof cursors !== "object") return false;
|
|
4194
|
+
const migrations = (cursors.migrations ||= {});
|
|
4195
|
+
if (migrations[ZCODE_NATIVE_USAGE_REPAIR_KEY]) return false;
|
|
4196
|
+
|
|
4197
|
+
const mainRepair = await dropZcodeQueueRows(queuePath, { retainRetractions: true });
|
|
4198
|
+
const projectRepair = projectQueuePath
|
|
4199
|
+
? await dropZcodeQueueRows(projectQueuePath)
|
|
4200
|
+
: { removed: 0, retractions: 0 };
|
|
4201
|
+
|
|
4202
|
+
const hourly = cursors.hourly && typeof cursors.hourly === "object" ? cursors.hourly : null;
|
|
4203
|
+
if (hourly?.buckets) {
|
|
4204
|
+
for (const key of Object.keys(hourly.buckets)) {
|
|
4205
|
+
if (key.startsWith("zcode|")) delete hourly.buckets[key];
|
|
4206
|
+
}
|
|
4207
|
+
}
|
|
4208
|
+
if (hourly?.groupQueued) {
|
|
4209
|
+
for (const key of Object.keys(hourly.groupQueued)) {
|
|
4210
|
+
if (key.startsWith("zcode|")) delete hourly.groupQueued[key];
|
|
4211
|
+
}
|
|
4212
|
+
}
|
|
4213
|
+
const projectHourly = cursors.projectHourly && typeof cursors.projectHourly === "object"
|
|
4214
|
+
? cursors.projectHourly
|
|
4215
|
+
: null;
|
|
4216
|
+
if (projectHourly?.buckets) {
|
|
4217
|
+
for (const key of Object.keys(projectHourly.buckets)) {
|
|
4218
|
+
if (key.includes("|zcode|")) delete projectHourly.buckets[key];
|
|
4219
|
+
}
|
|
4220
|
+
}
|
|
4221
|
+
delete cursors.zcode;
|
|
4222
|
+
|
|
4223
|
+
if (mainRepair.removed > 0) await resetUploadOffsetForZcodeNativeRepair(queueStatePath);
|
|
4224
|
+
if (projectRepair.removed > 0) {
|
|
4225
|
+
await resetUploadOffsetForZcodeNativeRepair(projectQueueStatePath);
|
|
4226
|
+
}
|
|
4227
|
+
migrations[ZCODE_NATIVE_USAGE_REPAIR_KEY] = {
|
|
4228
|
+
appliedAt: new Date().toISOString(),
|
|
4229
|
+
removedMain: mainRepair.removed,
|
|
4230
|
+
removedProject: projectRepair.removed,
|
|
4231
|
+
retractions: mainRepair.retractions,
|
|
4232
|
+
};
|
|
4233
|
+
return true;
|
|
4234
|
+
}
|
|
4235
|
+
|
|
4086
4236
|
async function repairGrokQueueFromSessionSnapshots({ cursors, queuePath, queueStatePath } = {}) {
|
|
4087
4237
|
if (!cursors || typeof cursors !== "object") return false;
|
|
4088
4238
|
const grokState = (cursors.grok ||= {});
|
|
@@ -266,6 +266,9 @@ async function resolveWorkspaceId(authCookie, fetchImpl, timeoutMs) {
|
|
|
266
266
|
headers: postHeaders,
|
|
267
267
|
body: "[]"
|
|
268
268
|
});
|
|
269
|
+
if (response.status === 401 || response.status === 403) {
|
|
270
|
+
throw new Error("Unauthorized or forbidden (401/403)");
|
|
271
|
+
}
|
|
269
272
|
text = await response.text();
|
|
270
273
|
ids = parseWorkspaceIds(text);
|
|
271
274
|
} catch (postErr) {
|
|
@@ -649,7 +652,13 @@ async function scrapeOpencodeGoWeb({ cfg, fetchImpl, nowMs, timeoutMs }) {
|
|
|
649
652
|
try {
|
|
650
653
|
workspaceId = await resolveWorkspaceId(cfg.authCookie, fetchImpl, timeoutMs);
|
|
651
654
|
} catch (err) {
|
|
652
|
-
|
|
655
|
+
const msg = sanitizeMessage(err?.message || err);
|
|
656
|
+
const isAuth = /401|403|Unauthorized or forbidden/i.test(msg);
|
|
657
|
+
return {
|
|
658
|
+
configured: true,
|
|
659
|
+
error: `Failed to resolve Workspace ID: ${msg}`,
|
|
660
|
+
...(isAuth ? { auth_error: true } : {}),
|
|
661
|
+
};
|
|
653
662
|
}
|
|
654
663
|
if (!workspaceId) {
|
|
655
664
|
return { configured: true, error: "Could not auto-resolve OpenCode Workspace ID from cookie. Please set OPENCODE_GO_WORKSPACE_ID manually." };
|
|
@@ -743,8 +752,7 @@ async function fetchOpencodeGoLimits({
|
|
|
743
752
|
return { ...api, source: "api" };
|
|
744
753
|
}
|
|
745
754
|
if (api?.auth_error) {
|
|
746
|
-
|
|
747
|
-
return result;
|
|
755
|
+
return { ...api, source: "api" };
|
|
748
756
|
}
|
|
749
757
|
if (!cfg) return api || { configured: true, error: "OpenCode Go unavailable" };
|
|
750
758
|
}
|