tokentracker-cli 1.4.12 → 1.4.14
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-BwrL59nq.js → AchievementBadge-BUYKivjx.js} +1 -1
- package/dashboard/dist/assets/{AchievementsPage-DG0dvG3d.js → AchievementsPage-YvgCj3Tf.js} +2 -2
- package/dashboard/dist/assets/{AchievementsSection-NrjlZjZK.js → AchievementsSection-C2llp4CQ.js} +1 -1
- package/dashboard/dist/assets/{BadgeDetailModal-BjgBAb-0.js → BadgeDetailModal-DH1lqy_t.js} +1 -1
- package/dashboard/dist/assets/{BotAnimated-D7gMmkaM.js → BotAnimated-BPJ80H6q.js} +1 -1
- package/dashboard/dist/assets/{Card-CgvwIS5W.js → Card-D0lZNo7p.js} +1 -1
- package/dashboard/dist/assets/{CloudCheckoutPage-DKDpT0HI.js → CloudCheckoutPage-YCIw4n94.js} +1 -1
- package/dashboard/dist/assets/{CloudPage-BOfqPAAH.js → CloudPage-D5PNgyOe.js} +2 -2
- package/dashboard/dist/assets/{CommandPalette-BfRKy_dn.js → CommandPalette-CfNOZlEo.js} +1 -1
- package/dashboard/dist/assets/{CommunityStatsModal-BcVSszit.js → CommunityStatsModal-eywEJpBo.js} +1 -1
- package/dashboard/dist/assets/{ConfirmModal-Be4EVpPT.js → ConfirmModal-MvUDUW0j.js} +1 -1
- package/dashboard/dist/assets/{Controls-vrG8LLBe.js → Controls-B3s01gQc.js} +1 -1
- package/dashboard/dist/assets/DashboardPage-7zQm3Y95.js +1 -0
- package/dashboard/dist/assets/{DateRangePopover-CZVMdPEq.js → DateRangePopover-C7T4EjRr.js} +1 -1
- package/dashboard/dist/assets/{DevicePage-BeNIjTqa.js → DevicePage-CZNBMHfk.js} +1 -1
- package/dashboard/dist/assets/{DialogClose-BaNPZ3Bu.js → DialogClose-DlVXuWgp.js} +1 -1
- package/dashboard/dist/assets/DialogDescription-C3mLrii8.js +1 -0
- package/dashboard/dist/assets/{DialogTitle-B3IwNXro.js → DialogTitle-Dc0-pI0j.js} +1 -1
- package/dashboard/dist/assets/{ElectricLogo-DC-03HL_.js → ElectricLogo-BRp4UZF4.js} +1 -1
- package/dashboard/dist/assets/{FadeIn-DhUnSf2V.js → FadeIn-DFL15trS.js} +1 -1
- package/dashboard/dist/assets/{HeaderGithubStar-BiWRLl7V.js → HeaderGithubStar-CPWpKT2q.js} +1 -1
- package/dashboard/dist/assets/{HoverTooltip-DLPiBqDu.js → HoverTooltip-DXIFAD1D.js} +1 -1
- package/dashboard/dist/assets/{IpCheckPage-DKjg0V9L.js → IpCheckPage-DBElmZxm.js} +1 -1
- package/dashboard/dist/assets/{LandingPage-XQuTnBMQ.js → LandingPage-3mpjg69k.js} +2 -2
- package/dashboard/dist/assets/{LeaderboardPage-xAbo5mzo.js → LeaderboardPage-xIQTyBSj.js} +2 -2
- package/dashboard/dist/assets/{LeaderboardProBadge-mMiEeaYS.js → LeaderboardProBadge-hMzno53J.js} +1 -1
- package/dashboard/dist/assets/{LeaderboardProfileModal-B7q0Kk6B.js → LeaderboardProfileModal-Cw0_YCXH.js} +3 -3
- package/dashboard/dist/assets/{LeaderboardProfilePage-Bru_6wgX.js → LeaderboardProfilePage-CIVWObmo.js} +1 -1
- package/dashboard/dist/assets/LimitsPage-i_AEHRcd.js +6 -0
- package/dashboard/dist/assets/{LocalOnlyNotice-B-lxih4W.js → LocalOnlyNotice-Cnzi2tn4.js} +1 -1
- package/dashboard/dist/assets/{LoginCard-ChNsRYE2.js → LoginCard-DOO_XdQm.js} +1 -1
- package/dashboard/dist/assets/{LoginModal-CRw3PgMi.js → LoginModal-B5Ec0gTs.js} +1 -1
- package/dashboard/dist/assets/{LoginPage-CVsbYn-h.js → LoginPage-BcyuULTm.js} +1 -1
- package/dashboard/dist/assets/{PetPage-BwEnQLLY.js → PetPage-DeTdSNPI.js} +2 -2
- package/dashboard/dist/assets/{PopoverPopup-CDOtxSL8.js → PopoverPopup-BqiCJJkn.js} +1 -1
- package/dashboard/dist/assets/{ProviderIcon-Dsu1p6gG.js → ProviderIcon-94H7cG7M.js} +1 -1
- package/dashboard/dist/assets/{ResetPasswordPage-BzpaSORs.js → ResetPasswordPage-BfaaiVWq.js} +1 -1
- package/dashboard/dist/assets/{Select-62UH-yLs.js → Select-Dk1g2jS1.js} +1 -1
- package/dashboard/dist/assets/{SelectItemText-aTexKmQ0.js → SelectItemText-CgY3YTCX.js} +1 -1
- package/dashboard/dist/assets/{SelfHostPage-CmhV0dms.js → SelfHostPage-CINWSnGe.js} +1 -1
- package/dashboard/dist/assets/{ServiceStatusPage-CLWO33w1.js → ServiceStatusPage-B3bZ4RLp.js} +1 -1
- package/dashboard/dist/assets/SessionsPage-Bt-zYCLB.js +3 -0
- package/dashboard/dist/assets/{SettingsPage-DybHncPO.js → SettingsPage-DgvNelAH.js} +3 -3
- package/dashboard/dist/assets/{SkillsPage-BV5R3VhT.js → SkillsPage-BeapUXZg.js} +1 -1
- package/dashboard/dist/assets/{TokenGalaxy-mNNAo6Ai.js → TokenGalaxy-BmARBReu.js} +1 -1
- package/dashboard/dist/assets/{TooltipPopup-D00SVpLP.js → TooltipPopup-DMkTj-q1.js} +1 -1
- package/dashboard/dist/assets/{TrendMonitor-aNIpzAO-.js → TrendMonitor-DErfAB4Q.js} +1 -1
- package/dashboard/dist/assets/{WidgetsPage-COjZIMo8.js → WidgetsPage-D7MRIlIQ.js} +1 -1
- package/dashboard/dist/assets/{WrappedPage-af-bDIfB.js → WrappedPage-Dwl8J96o.js} +1 -1
- package/dashboard/dist/assets/{__vite-browser-external-KHpR2q-A.js → __vite-browser-external-Bp0fEMn1.js} +3 -3
- package/dashboard/dist/assets/__vite-browser-external-Br-KAXh6.css +1 -0
- package/dashboard/dist/assets/{agent-logos-D9Uq5b6y.js → agent-logos-D5X6WoAY.js} +1 -1
- package/dashboard/dist/assets/{arrow-left-Pt53BsA4.js → arrow-left-Bmf0v8yS.js} +1 -1
- package/dashboard/dist/assets/{arrow-right-stBCZPot.js → arrow-right-CrY1rjed.js} +1 -1
- package/dashboard/dist/assets/{arrow-up-right-ltUBOD-o.js → arrow-up-right-CK7lXR6O.js} +1 -1
- package/dashboard/dist/assets/{calendar-days-BMEtkPFp.js → calendar-days-zge_5pfQ.js} +1 -1
- package/dashboard/dist/assets/{check-ax5wQf5Q.js → check-Bt-LY4Pn.js} +1 -1
- package/dashboard/dist/assets/{chevron-down-gS62rNQt.js → chevron-down-BOy_MKfd.js} +1 -1
- package/dashboard/dist/assets/{cloud-checkout-DDtdbz7C.js → cloud-checkout-4NPL78Jg.js} +1 -1
- package/dashboard/dist/assets/{composite-DVm8byy8.js → composite-UMkd0X7k.js} +1 -1
- package/dashboard/dist/assets/{copy-VbASSQO1.js → copy-DJTFZc8D.js} +1 -1
- package/dashboard/dist/assets/{download-D1g6OCRI.js → download-BJD3ff5y.js} +1 -1
- package/dashboard/dist/assets/{external-link-CGUQrKDL.js → external-link-D2m7vRGI.js} +1 -1
- package/dashboard/dist/assets/{flame-Dlvc-qIH.js → flame-D7CLiokj.js} +1 -1
- package/dashboard/dist/assets/{format-tokens-CB1QfZsj.js → format-tokens-BYDaVVT_.js} +1 -1
- package/dashboard/dist/assets/{gift-DydflDeL.js → gift-toIl7elE.js} +1 -1
- package/dashboard/dist/assets/{icons-B_xYF8_-.js → icons-DscB4AX2.js} +1 -1
- package/dashboard/dist/assets/{index-CuLrp2D2.js → index-6krHCwUe.js} +1 -1
- package/dashboard/dist/assets/{index-cidqWI7C.js → index-BGu15oeA.js} +1 -1
- package/dashboard/dist/assets/{index-ByXXZlPn.js → index-BLS9byMs.js} +1 -1
- package/dashboard/dist/assets/{index-BRNltZbP.js → index-CEsURfpC.js} +1 -1
- package/dashboard/dist/assets/{info-D6-LIywq.js → info-D73-a9a_.js} +1 -1
- package/dashboard/dist/assets/{link-2-BbuXAF5y.js → link-2-DwpvF9Sr.js} +1 -1
- package/dashboard/dist/assets/{loader-circle-DAeCHAyj.js → loader-circle-BTs6Fc8Y.js} +1 -1
- package/dashboard/dist/assets/{local-usage-transfer-BejRwzi4.js → local-usage-transfer-BXhe_z5f.js} +1 -1
- package/dashboard/dist/assets/{modifiers.esm-CV2S03sv.js → modifiers.esm-CFoTDZHy.js} +1 -1
- package/dashboard/dist/assets/{monitor-smartphone-Dj_u5s6h.js → monitor-smartphone-4ejjSL5C.js} +1 -1
- package/dashboard/dist/assets/{play-DrcSicai.js → play-Ch1IEQyR.js} +1 -1
- package/dashboard/dist/assets/{plus-BwYQW7nf.js → plus-Bc8vdvFi.js} +1 -1
- package/dashboard/dist/assets/{provider-display-Bgfy-2rn.js → provider-display-BhKfIayc.js} +1 -1
- package/dashboard/dist/assets/{react-BXby2gfP.js → react-BhuZeLEc.js} +1 -1
- package/dashboard/dist/assets/{safePolygon-B8DY85mD.js → safePolygon-ag21oDI1.js} +1 -1
- package/dashboard/dist/assets/{search-SCMosATz.js → search-BhM-pD0f.js} +1 -1
- package/dashboard/dist/assets/{server-DoD96f86.js → server-CWZM_fiB.js} +1 -1
- package/dashboard/dist/assets/{shield-check-CESJcEp7.js → shield-check-BdF9MoZ4.js} +1 -1
- package/dashboard/dist/assets/{skills-api-DE71Ylhd.js → skills-api-PC7TzIba.js} +1 -1
- package/dashboard/dist/assets/{sortable.esm-EgVv2jPt.js → sortable.esm-u_yCrBFE.js} +1 -1
- package/dashboard/dist/assets/{store-mMQPBMoh.js → store-19qppboP.js} +1 -1
- package/dashboard/dist/assets/{terminal-DxNM-IG2.js → terminal-ikPM7Gyt.js} +1 -1
- package/dashboard/dist/assets/{trash-rywOpT2_.js → trash-DuS_INdf.js} +1 -1
- package/dashboard/dist/assets/{use-community-stats-BQw06Twe.js → use-community-stats-DnRz7Akf.js} +1 -1
- package/dashboard/dist/assets/{use-latest-request-guard-BvouGm-c.js → use-latest-request-guard-CClqxkji.js} +1 -1
- package/dashboard/dist/assets/{use-limits-display-prefs-C5_9TDSy.js → use-limits-display-prefs-C2IK7QqP.js} +1 -1
- package/dashboard/dist/assets/{use-native-settings-BxuddjkP.js → use-native-settings-wciHeNL2.js} +1 -1
- package/dashboard/dist/assets/use-ordered-list-CUnip521.js +1 -0
- package/dashboard/dist/assets/use-reduced-motion-D586B7AA.js +1 -0
- package/dashboard/dist/assets/{use-transform-Dl-SvALB.js → use-transform-BFydEHQY.js} +1 -1
- package/dashboard/dist/assets/{use-usage-limits-BqmHYYc3.js → use-usage-limits-BqWWrW6O.js} +1 -1
- package/dashboard/dist/assets/{useCurrency-B1XK_Z0N.js → useCurrency-sg6d4Wea.js} +1 -1
- package/dashboard/dist/assets/{usePositioner-BvqDMGZo.js → usePositioner-CLPx448B.js} +1 -1
- package/dashboard/dist/assets/{useTokenFormat-pPWJeWRe.js → useTokenFormat-BOt7YH_Y.js} +1 -1
- package/dashboard/dist/assets/{zap-DKYjQi1B.js → zap-B6nc-Upg.js} +1 -1
- package/dashboard/dist/index.html +2 -2
- package/dashboard/dist/ip-check.html +2 -2
- package/dashboard/dist/leaderboard.html +2 -2
- package/dashboard/dist/share.html +2 -2
- package/package.json +1 -1
- package/src/lib/local-usage-transfer.js +1 -1
- package/src/lib/pricing/curated-overrides.json +12 -0
- package/src/lib/pricing/index.js +2 -1
- package/src/lib/pricing/seed-snapshot.json +1 -1
- package/src/lib/rollout.js +131 -37
- package/dashboard/dist/assets/DashboardPage-DvhF72XX.js +0 -1
- package/dashboard/dist/assets/DialogDescription-LHQ-SC4e.js +0 -1
- package/dashboard/dist/assets/LimitsPage-DQH6ziz4.js +0 -6
- package/dashboard/dist/assets/SessionsPage-BNCDKb58.js +0 -3
- package/dashboard/dist/assets/__vite-browser-external-C9a2vCBN.css +0 -1
- package/dashboard/dist/assets/use-ordered-list-Cwqc5XA8.js +0 -1
- package/dashboard/dist/assets/use-reduced-motion-DU3FvZwM.js +0 -1
package/src/lib/rollout.js
CHANGED
|
@@ -6770,13 +6770,35 @@ async function parseQoderDbIncremental({
|
|
|
6770
6770
|
//
|
|
6771
6771
|
// Qoder 2026-08 (app 0.1.2+) migrated from SharedClientCache/cache/db/local.db
|
|
6772
6772
|
// to Electron main.sqlite + ~/.qoder/projects/<slug>/<sessionId>.jsonl.
|
|
6773
|
-
//
|
|
6774
|
-
//
|
|
6775
|
-
//
|
|
6776
|
-
//
|
|
6777
|
-
//
|
|
6778
|
-
//
|
|
6779
|
-
//
|
|
6773
|
+
//
|
|
6774
|
+
// The transcript's message.usage shape has drifted at least once, and BOTH
|
|
6775
|
+
// shapes occur in real user history:
|
|
6776
|
+
// - app 0.1.8 / agent 1.1.44: Anthropic-style precise token fields, on the
|
|
6777
|
+
// main transcript AND on subagent transcripts
|
|
6778
|
+
// (see test/qoder-new-parser.test.js "Real CN record shape").
|
|
6779
|
+
// - app 0.4.x, model "qfmodel": every row is
|
|
6780
|
+
// {input_tokens:0, output_tokens:0, cache_*:0, credits:>0, billable:false}.
|
|
6781
|
+
// The old comment here claimed the credit-billed shape was `{credits, billable:
|
|
6782
|
+
// true}`; that assumption is what made the gate below drop 100% of modern Qoder
|
|
6783
|
+
// rows, so Qoder vanished from the dashboard instead of showing up as
|
|
6784
|
+
// "0 tokens / N requests". `billable` means "charged to the account", NOT
|
|
6785
|
+
// "a call happened" — free-tier models report false while still reporting
|
|
6786
|
+
// credits. Admission therefore needs all three signals, and dropping any of
|
|
6787
|
+
// them regresses a shape that used to count.
|
|
6788
|
+
//
|
|
6789
|
+
// Non-goals: credit→token conversion stays out. There is no first-party credit
|
|
6790
|
+
// → token (or → USD) rate, so fabricating one would push an invented number
|
|
6791
|
+
// into totals, trends, achievements and the cloud leaderboard. Rows without
|
|
6792
|
+
// authoritative tokens contribute conversation activity only, and
|
|
6793
|
+
// total_cost_usd stays 0. Transcript `usage.credits` is deliberately NOT copied
|
|
6794
|
+
// into bucket totals — there is no first-party credit→USD rate to book cost
|
|
6795
|
+
// from, and carrying it forward invites someone to divide by it later.
|
|
6796
|
+
//
|
|
6797
|
+
// conversation_count here follows this provider's existing per-response
|
|
6798
|
+
// convention (`: 1` per admitted main-transcript row). That field is NOT
|
|
6799
|
+
// comparable across providers — same rule as the Claude branch's isMainSession
|
|
6800
|
+
// (#307) and Claude Science's `isRoot ? 1 : 0` (see the Claude Science parser).
|
|
6801
|
+
//
|
|
6780
6802
|
// Old local.db is kept as a legacy fallback; both sources now use distinct
|
|
6781
6803
|
// cursor namespaces (qoder vs qoderNew) via disjoint messageKey prefixes
|
|
6782
6804
|
// (row: vs jsonl:) but upload under the same source="qoder".
|
|
@@ -6870,17 +6892,47 @@ function qoderNewMessageKey(record, filePath, lineIndex = 0) {
|
|
|
6870
6892
|
return `jsonl:${fallbackSuffix}|${record?.uuid || ""}`;
|
|
6871
6893
|
}
|
|
6872
6894
|
|
|
6895
|
+
// 8.64e15 is the ECMAScript TimeClip limit. A larger finite number (nanosecond
|
|
6896
|
+
// epochs, clock garbage) passes coerceEpochMs untouched, and `new Date(ms)`
|
|
6897
|
+
// yields Invalid Date whose .toISOString() THROWS RangeError — outside the
|
|
6898
|
+
// per-line JSON.parse try/catch, aborting the whole source on one bad row and
|
|
6899
|
+
// silently removing Qoder from every later sync (warnProviderParseFailure is
|
|
6900
|
+
// quiet in auto syncs). Clamp to a drop instead.
|
|
6901
|
+
const MAX_QODER_TIMESTAMP_MS = 8.64e15;
|
|
6902
|
+
|
|
6873
6903
|
function qoderNewTimestampMs(record) {
|
|
6874
|
-
|
|
6904
|
+
const ms = coerceEpochMs(record?.timestamp)
|
|
6875
6905
|
|| coerceEpochMs(record?.message?.timestamp)
|
|
6876
6906
|
|| parseIsoTimestampMs(record?.timestamp)
|
|
6877
6907
|
|| parseIsoTimestampMs(record?.message?.timestamp)
|
|
6878
6908
|
|| 0;
|
|
6909
|
+
return ms > MAX_QODER_TIMESTAMP_MS ? 0 : ms;
|
|
6910
|
+
}
|
|
6911
|
+
|
|
6912
|
+
// Nominal credits for one transcript row. `credits` and `original_credits`
|
|
6913
|
+
// coexist (the latter is the pre-discount value), and either alone can be 0,
|
|
6914
|
+
// so take the larger instead of `credits ?? original_credits` — `??` does not
|
|
6915
|
+
// skip a present-but-zero `credits`, which would drop real activity.
|
|
6916
|
+
//
|
|
6917
|
+
// The epsilon floor is load-bearing: the activity gate below only needs "some
|
|
6918
|
+
// credits were reported", and upstream float noise like 1e-9 would otherwise
|
|
6919
|
+
// admit rows that carry no usage at all. Real Qoder credits observed in the
|
|
6920
|
+
// wild start around 0.2 (2026-10 CN corpus), so 1e-6 never suppresses genuine
|
|
6921
|
+
// activity.
|
|
6922
|
+
const MIN_QODER_CREDIT_ACTIVITY = 1e-6;
|
|
6923
|
+
|
|
6924
|
+
function readQoderNominalCredits(usage) {
|
|
6925
|
+
let max = 0;
|
|
6926
|
+
for (const raw of [usage?.credits, usage?.original_credits]) {
|
|
6927
|
+
if (typeof raw !== "number" || !Number.isFinite(raw)) continue;
|
|
6928
|
+
if (raw > max) max = raw;
|
|
6929
|
+
}
|
|
6930
|
+
return max >= MIN_QODER_CREDIT_ACTIVITY ? max : 0;
|
|
6879
6931
|
}
|
|
6880
6932
|
|
|
6881
6933
|
function normalizeQoderNewTokens(usage) {
|
|
6882
6934
|
if (!usage || typeof usage !== "object") return null;
|
|
6883
|
-
const credits =
|
|
6935
|
+
const credits = readQoderNominalCredits(usage);
|
|
6884
6936
|
let input = Number(usage.input_tokens ?? 0);
|
|
6885
6937
|
let cached = Number(usage.cache_read_input_tokens ?? usage.cached_tokens ?? 0);
|
|
6886
6938
|
let cacheCreation = Number(usage.cache_creation_input_tokens ?? 0);
|
|
@@ -6907,16 +6959,31 @@ function normalizeQoderNewTokens(usage) {
|
|
|
6907
6959
|
total_tokens: inp + cach + cc + out,
|
|
6908
6960
|
billable_total_tokens: inp + cach + cc + out,
|
|
6909
6961
|
credits: Number.isFinite(credits) && credits > 0 ? credits : 0,
|
|
6962
|
+
// `credits` dies at the totals boundary — parseQoderNewIncremental never
|
|
6963
|
+
// copies it into bucket totals or the cursor, and must not start: there
|
|
6964
|
+
// is no first-party credit→token or credit→USD rate to divide it by.
|
|
6910
6965
|
usage_precision: null,
|
|
6911
6966
|
};
|
|
6912
6967
|
}
|
|
6913
|
-
// Credit-only usage without authoritative token fields
|
|
6914
|
-
//
|
|
6915
|
-
//
|
|
6916
|
-
//
|
|
6968
|
+
// Credit-only usage without authoritative token fields yields null: no token
|
|
6969
|
+
// delta, because there is no first-party credit→token rate. The caller still
|
|
6970
|
+
// counts it as conversation activity when nominal credits prove the call
|
|
6971
|
+
// really happened.
|
|
6917
6972
|
return null;
|
|
6918
6973
|
}
|
|
6919
6974
|
|
|
6975
|
+
// Subagent transcripts are internal turns of the same conversation, so they
|
|
6976
|
+
// must not add to conversation activity — same rule the Claude branch enforces
|
|
6977
|
+
// with isMainSession (#307) and Claude Science encodes with `isRoot ? 1 : 0`.
|
|
6978
|
+
// A row that carries neither tokens nor activity is still tracked in the cursor:
|
|
6979
|
+
// a streamed rewrite can hand it real tokens later, and the cursor entry is what
|
|
6980
|
+
// makes that transition subtract/add correctly. It must not touch an hourly or
|
|
6981
|
+
// project bucket though, because getHourlyBucket() creates buckets on demand and
|
|
6982
|
+
// would publish an all-zero row.
|
|
6983
|
+
function qoderRowCountsAsUsage(totals) {
|
|
6984
|
+
return (totals?.total_tokens || 0) > 0 || (totals?.conversation_count || 0) > 0;
|
|
6985
|
+
}
|
|
6986
|
+
|
|
6920
6987
|
async function parseQoderNewIncremental({
|
|
6921
6988
|
sessionFiles,
|
|
6922
6989
|
cursors,
|
|
@@ -6977,6 +7044,9 @@ async function parseQoderNewIncremental({
|
|
|
6977
7044
|
} catch (_e) {
|
|
6978
7045
|
continue;
|
|
6979
7046
|
}
|
|
7047
|
+
// Separator-agnostic: WSL installs are walked over \\wsl$ UNC paths where
|
|
7048
|
+
// path.join emits backslashes (#307).
|
|
7049
|
+
const isMainSession = !/[\\/]subagents[\\/]/.test(filePath);
|
|
6980
7050
|
const lines = raw.split("\n");
|
|
6981
7051
|
for (let lineIdx = 0; lineIdx < lines.length; lineIdx++) {
|
|
6982
7052
|
const line = lines[lineIdx];
|
|
@@ -6994,9 +7064,19 @@ async function parseQoderNewIncremental({
|
|
|
6994
7064
|
const usage = msg.usage;
|
|
6995
7065
|
if (!usage || typeof usage !== "object") continue;
|
|
6996
7066
|
const base = normalizeQoderNewTokens(usage);
|
|
6997
|
-
//
|
|
7067
|
+
// Three independent admission signals, kept as a superset of the previous
|
|
7068
|
+
// behaviour — dropping any one regresses rows that used to count:
|
|
7069
|
+
// base authoritative tokens (app 0.1.8 / agent 1.1.44 shape)
|
|
7070
|
+
// isBillable billable is absent or true (the older credit-billed shape)
|
|
7071
|
+
// nominalCredits credits > 0 even though billable is false: Qoder 0.4.x
|
|
7072
|
+
// reports billable=false for its free model while still
|
|
7073
|
+
// reporting real credits, and gate-on-billable alone
|
|
7074
|
+
// discarded every row so the whole source vanished.
|
|
7075
|
+
// Rows that are not billable AND carry no credits stay dropped: that is
|
|
7076
|
+
// the synthetic / cancelled / empty-call case we must not count.
|
|
6998
7077
|
const isBillable = usage.billable !== false;
|
|
6999
|
-
|
|
7078
|
+
const nominalCredits = readQoderNominalCredits(usage);
|
|
7079
|
+
if (!base && !isBillable && nominalCredits <= 0) continue;
|
|
7000
7080
|
const timestampMs = qoderNewTimestampMs(record);
|
|
7001
7081
|
if (!timestampMs) continue;
|
|
7002
7082
|
const bucketStart = toUtcHalfHourStart(new Date(timestampMs).toISOString());
|
|
@@ -7014,7 +7094,7 @@ async function parseQoderNewIncremental({
|
|
|
7014
7094
|
billable_total_tokens: base.billable_total_tokens,
|
|
7015
7095
|
total_cost_usd: 0,
|
|
7016
7096
|
usage_precision: base.usage_precision || undefined,
|
|
7017
|
-
conversation_count: 1,
|
|
7097
|
+
conversation_count: isMainSession ? 1 : 0,
|
|
7018
7098
|
} : {
|
|
7019
7099
|
input_tokens: 0,
|
|
7020
7100
|
cached_input_tokens: 0,
|
|
@@ -7024,7 +7104,7 @@ async function parseQoderNewIncremental({
|
|
|
7024
7104
|
total_tokens: 0,
|
|
7025
7105
|
billable_total_tokens: 0,
|
|
7026
7106
|
total_cost_usd: 0,
|
|
7027
|
-
conversation_count: 1,
|
|
7107
|
+
conversation_count: isMainSession ? 1 : 0,
|
|
7028
7108
|
};
|
|
7029
7109
|
let projectKey = null;
|
|
7030
7110
|
let projectRef = null;
|
|
@@ -7043,6 +7123,16 @@ async function parseQoderNewIncremental({
|
|
|
7043
7123
|
projectRef = context?.projectRef || null;
|
|
7044
7124
|
}
|
|
7045
7125
|
}
|
|
7126
|
+
// Same sessionId+msgId can appear in both the main transcript and a
|
|
7127
|
+
// subagent transcript (mirrored id). currentByKey is last-wins and
|
|
7128
|
+
// listQoderNewSessionFiles orders by localeCompare, so an unguarded
|
|
7129
|
+
// subagent copy (conversation_count 0) could silently replace the main
|
|
7130
|
+
// row's activity depending on file order. Precedence: a main-session
|
|
7131
|
+
// record always wins a subagent copy; within the same class, last-wins
|
|
7132
|
+
// stands so a streamed rewrite (the later, final token counts) is what
|
|
7133
|
+
// gets booked — first-wins here would under-count subagent tokens.
|
|
7134
|
+
const existing = currentByKey.get(messageKey);
|
|
7135
|
+
if (existing?.isMainSession && !isMainSession) continue;
|
|
7046
7136
|
currentByKey.set(messageKey, {
|
|
7047
7137
|
totals,
|
|
7048
7138
|
bucketStart,
|
|
@@ -7050,6 +7140,7 @@ async function parseQoderNewIncremental({
|
|
|
7050
7140
|
projectKey,
|
|
7051
7141
|
projectRef,
|
|
7052
7142
|
filePath,
|
|
7143
|
+
isMainSession,
|
|
7053
7144
|
});
|
|
7054
7145
|
}
|
|
7055
7146
|
if (cb && (fileIdx % 50 === 0 || fileIdx === files.length - 1)) {
|
|
@@ -7077,7 +7168,7 @@ async function parseQoderNewIncremental({
|
|
|
7077
7168
|
&& (prev.projectKey || null) === (cur.projectKey || null)
|
|
7078
7169
|
&& (prev.totals?.total_cost_usd || 0) === (cur.totals.total_cost_usd || 0);
|
|
7079
7170
|
if (unchanged) continue;
|
|
7080
|
-
if (prev.totals && prev.bucketStart && prev.model) {
|
|
7171
|
+
if (prev.totals && prev.bucketStart && prev.model && qoderRowCountsAsUsage(prev.totals)) {
|
|
7081
7172
|
const oldBucket = getHourlyBucket(hourlyState, sourceKey, prev.model, prev.bucketStart);
|
|
7082
7173
|
subtractTotals(oldBucket.totals, prev.totals);
|
|
7083
7174
|
touchedBuckets.add(bucketKey(sourceKey, prev.model, prev.bucketStart));
|
|
@@ -7088,16 +7179,17 @@ async function parseQoderNewIncremental({
|
|
|
7088
7179
|
}
|
|
7089
7180
|
}
|
|
7090
7181
|
if (cur) {
|
|
7091
|
-
|
|
7092
|
-
|
|
7093
|
-
|
|
7094
|
-
|
|
7095
|
-
|
|
7096
|
-
|
|
7097
|
-
|
|
7098
|
-
|
|
7099
|
-
|
|
7100
|
-
|
|
7182
|
+
if (qoderRowCountsAsUsage(cur.totals)) {
|
|
7183
|
+
const bucket = getHourlyBucket(hourlyState, sourceKey, cur.model, cur.bucketStart);
|
|
7184
|
+
addTotals(bucket.totals, cur.totals);
|
|
7185
|
+
if (cur.totals.usage_precision) bucket.usage_precision = cur.totals.usage_precision;
|
|
7186
|
+
touchedBuckets.add(bucketKey(sourceKey, cur.model, cur.bucketStart));
|
|
7187
|
+
if (projectEnabled && cur.projectKey) {
|
|
7188
|
+
const projectBucket = getProjectBucket(projectState, cur.projectKey, sourceKey, cur.bucketStart, cur.projectRef);
|
|
7189
|
+
addTotals(projectBucket.totals, cur.totals);
|
|
7190
|
+
if (cur.totals.usage_precision) projectBucket.usage_precision = cur.totals.usage_precision;
|
|
7191
|
+
projectTouchedBuckets.add(projectBucketKey(cur.projectKey, sourceKey, cur.bucketStart));
|
|
7192
|
+
}
|
|
7101
7193
|
}
|
|
7102
7194
|
qoderState.messages[key] = {
|
|
7103
7195
|
totals: cur.totals,
|
|
@@ -7118,15 +7210,17 @@ async function parseQoderNewIncremental({
|
|
|
7118
7210
|
// Add brand-new keys
|
|
7119
7211
|
for (const [key, cur] of currentByKey.entries()) {
|
|
7120
7212
|
if (qoderState.messages[key]) continue;
|
|
7121
|
-
|
|
7122
|
-
|
|
7123
|
-
|
|
7124
|
-
|
|
7125
|
-
|
|
7126
|
-
|
|
7127
|
-
|
|
7128
|
-
|
|
7129
|
-
|
|
7213
|
+
if (qoderRowCountsAsUsage(cur.totals)) {
|
|
7214
|
+
const bucket = getHourlyBucket(hourlyState, sourceKey, cur.model, cur.bucketStart);
|
|
7215
|
+
addTotals(bucket.totals, cur.totals);
|
|
7216
|
+
if (cur.totals.usage_precision) bucket.usage_precision = cur.totals.usage_precision;
|
|
7217
|
+
touchedBuckets.add(bucketKey(sourceKey, cur.model, cur.bucketStart));
|
|
7218
|
+
if (projectEnabled && cur.projectKey) {
|
|
7219
|
+
const projectBucket = getProjectBucket(projectState, cur.projectKey, sourceKey, cur.bucketStart, cur.projectRef);
|
|
7220
|
+
addTotals(projectBucket.totals, cur.totals);
|
|
7221
|
+
if (cur.totals.usage_precision) projectBucket.usage_precision = cur.totals.usage_precision;
|
|
7222
|
+
projectTouchedBuckets.add(projectBucketKey(cur.projectKey, sourceKey, cur.bucketStart));
|
|
7223
|
+
}
|
|
7130
7224
|
}
|
|
7131
7225
|
qoderState.messages[key] = {
|
|
7132
7226
|
totals: cur.totals,
|