tokentracker-cli 1.3.3 → 1.3.5
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/README.de.md +5 -5
- package/README.ja.md +3 -3
- package/README.ko.md +3 -3
- package/README.md +6 -5
- package/README.zh-CN.md +3 -3
- package/THIRD_PARTY_NOTICES.md +92 -0
- package/dashboard/dist/THIRD_PARTY_NOTICES.txt +92 -0
- package/dashboard/dist/assets/AchievementBadge-Dazs3pEa.js +1 -0
- package/dashboard/dist/assets/AchievementsPage-LWnxZvmw.js +2 -0
- package/dashboard/dist/assets/{AchievementsSection-CDUUEfIi.js → AchievementsSection-BLqczmU9.js} +1 -1
- package/dashboard/dist/assets/BadgeDetailModal-B_n4aj2S.js +1 -0
- package/dashboard/dist/assets/{BotAnimated-Dx_vvTtC.js → BotAnimated-KDWI_YcZ.js} +1 -1
- package/dashboard/dist/assets/Card-BYoxd4OC.js +1 -0
- package/dashboard/dist/assets/CloudCheckoutPage-BR2_B03P.js +1 -0
- package/dashboard/dist/assets/CloudPage-DL5RkJKK.js +1 -0
- package/dashboard/dist/assets/CloudUsageExport-C_DqZKo1.js +4 -0
- package/dashboard/dist/assets/CommandPalette-DkCaIQI4.js +1 -0
- package/dashboard/dist/assets/CommunityStatsModal-pX9OePi4.js +1 -0
- package/dashboard/dist/assets/{ConfirmModal-BQ-xB1S_.js → ConfirmModal-tkgZwz4u.js} +1 -1
- package/dashboard/dist/assets/Controls-MTUhGWy8.js +1 -0
- package/dashboard/dist/assets/DashboardPage-SOx-A7lH.js +1 -0
- package/dashboard/dist/assets/DateRangePopover-B-BMOm3O.js +1 -0
- package/dashboard/dist/assets/{DevicePage-Dg6XkIaY.js → DevicePage-DSK9lm7v.js} +1 -1
- package/dashboard/dist/assets/DialogClose-uVUNu4rg.js +1 -0
- package/dashboard/dist/assets/DialogDescription-DBqGGWNj.js +1 -0
- package/dashboard/dist/assets/DialogTitle-B-VifiA3.js +1 -0
- package/dashboard/dist/assets/{FadeIn-ChVf45WW.js → FadeIn-B6lrj4uo.js} +1 -1
- package/dashboard/dist/assets/{HeaderGithubStar-B740_G7a.js → HeaderGithubStar-Cx5zOhXa.js} +1 -1
- package/dashboard/dist/assets/{HoverTooltip-BzP5FudR.js → HoverTooltip-DY1ENf69.js} +1 -1
- package/dashboard/dist/assets/{IpCheckPage-BuZH3F14.js → IpCheckPage-D6TEq64d.js} +1 -1
- package/dashboard/dist/assets/LandingPage-OdZUfq--.js +2 -0
- package/dashboard/dist/assets/LeaderboardPage-DCK5xcAt.js +2 -0
- package/dashboard/dist/assets/LeaderboardProBadge-CBXJ1u_m.js +1 -0
- package/dashboard/dist/assets/{LeaderboardProfileModal-OUZvO6u-.js → LeaderboardProfileModal-Ccdzb7QK.js} +4 -4
- package/dashboard/dist/assets/{LeaderboardProfilePage-bHI1oTEK.js → LeaderboardProfilePage-CFXlZ0fL.js} +2 -2
- package/dashboard/dist/assets/LimitsPage-5krjm-g9.js +9 -0
- package/dashboard/dist/assets/{LocalOnlyNotice-BaEq6qN7.js → LocalOnlyNotice-Rk1B8PaZ.js} +1 -1
- package/dashboard/dist/assets/LoginCard-DTTIm8vk.js +1 -0
- package/dashboard/dist/assets/LoginModal-BNcDdjfr.js +1 -0
- package/dashboard/dist/assets/LoginPage-CQgXP7Ee.js +1 -0
- package/dashboard/dist/assets/{PetPage-BPBsUHyL.js → PetPage-Cw_kAPRs.js} +1 -1
- package/dashboard/dist/assets/PopoverPopup-NYiGE8A2.js +1 -0
- package/dashboard/dist/assets/{ProviderIcon-BshO2uER.js → ProviderIcon-Bp7iFJ_m.js} +1 -1
- package/dashboard/dist/assets/{ResetPasswordPage-RTFTD8Dr.js → ResetPasswordPage-Cf9kAWDW.js} +1 -1
- package/dashboard/dist/assets/Select-kIcvQFAo.js +1 -0
- package/dashboard/dist/assets/SelectItemText-BpIsAg3b.js +1 -0
- package/dashboard/dist/assets/{SelfHostPage-BlwTt8XM.js → SelfHostPage-Ch2vvSwI.js} +1 -1
- package/dashboard/dist/assets/{ServiceStatusPage-BkIcJpYK.js → ServiceStatusPage-hoYBvGbu.js} +1 -1
- package/dashboard/dist/assets/SessionsPage-BzRB6q-Z.js +3 -0
- package/dashboard/dist/assets/SessionsPage-GV2fuNmd.css +1 -0
- package/dashboard/dist/assets/SettingsPage-DRl2uX-i.js +2 -0
- package/dashboard/dist/assets/SkillsPage-CkqThTZL.js +1 -0
- package/dashboard/dist/assets/{TokenGalaxy-DiXUpXKF.js → TokenGalaxy-eLG-UIZY.js} +1 -1
- package/dashboard/dist/assets/TooltipPopup-bnMJyilQ.js +1 -0
- package/dashboard/dist/assets/TrendMonitor-X7-aGzIv.js +19 -0
- package/dashboard/dist/assets/WidgetsPage-CGznIzrW.js +1 -0
- package/dashboard/dist/assets/{WrappedPage-ClEo-RmR.js → WrappedPage-p31-uUoF.js} +1 -1
- package/dashboard/dist/assets/__vite-browser-external-2g_4s3ot.js +45 -0
- package/dashboard/dist/assets/__vite-browser-external-LpFw4zXh.css +1 -0
- package/dashboard/dist/assets/agent-logos-2TVT3fIE.js +1 -0
- package/dashboard/dist/assets/arrow-left-DL0hAp_7.js +1 -0
- package/dashboard/dist/assets/{arrow-right-CwBz5dwb.js → arrow-right-DFCpnV_9.js} +1 -1
- package/dashboard/dist/assets/{arrow-up-right-jPmRN562.js → arrow-up-right-DLvfE0Wu.js} +1 -1
- package/dashboard/dist/assets/calendar-days-B0aDoKSG.js +1 -0
- package/dashboard/dist/assets/{check-CKwHc4Hv.js → check-C_cfrxiz.js} +1 -1
- package/dashboard/dist/assets/chevron-down-Ck8ml43e.js +1 -0
- package/dashboard/dist/assets/cloud-checkout-PYnwNfdH.js +1 -0
- package/dashboard/dist/assets/composite-INW-ELWX.js +1 -0
- package/dashboard/dist/assets/download-B7uokeIo.js +1 -0
- package/dashboard/dist/assets/{external-link-B5yXxdPy.js → external-link-CI3crg4K.js} +1 -1
- package/dashboard/dist/assets/{flame-CKjAluj_.js → flame-DCzvFKV1.js} +1 -1
- package/dashboard/dist/assets/{format-tokens-mk49THtv.js → format-tokens-CSTEYK2m.js} +1 -1
- package/dashboard/dist/assets/gift-dEHDFMc6.js +1 -0
- package/dashboard/dist/assets/{host-mode-efKlSYjX.js → host-mode-r2SW9Mdv.js} +1 -1
- package/dashboard/dist/assets/{icons-ZB1ZthjH.js → icons-q-3zvEkh.js} +1 -1
- package/dashboard/dist/assets/{index-BImBG3eS.js → index-BV7qwUw4.js} +1 -1
- package/dashboard/dist/assets/{index-BgdM7kBl.js → index-BbrsgHf4.js} +1 -1
- package/dashboard/dist/assets/{index-DweUMAUD.js → index-CyHYj9XI.js} +1 -1
- package/dashboard/dist/assets/info-BBdY9hV4.js +1 -0
- package/dashboard/dist/assets/{link-2-Dn2soiyd.js → link-2-CLPePfXs.js} +1 -1
- package/dashboard/dist/assets/{loader-circle-CNT630zn.js → loader-circle-ETrjzfmn.js} +1 -1
- package/dashboard/dist/assets/{modifiers.esm-WPx0bc2K.js → modifiers.esm-DHqnp2ol.js} +1 -1
- package/dashboard/dist/assets/module-BNnaKM__.js +3 -0
- package/dashboard/dist/assets/monitor-smartphone-D1kdzrdb.js +1 -0
- package/dashboard/dist/assets/play-Cxp-ronD.js +1 -0
- package/dashboard/dist/assets/plus-4n94VzDK.js +1 -0
- package/dashboard/dist/assets/provider-display-CRlbeO7t.js +42 -0
- package/dashboard/dist/assets/{react-B7SkZTgg.js → react-DlHjGQFN.js} +1 -1
- package/dashboard/dist/assets/safePolygon-CVZ27a2_.js +1 -0
- package/dashboard/dist/assets/{search-Ol3OZBm4.js → search-BDPr56_h.js} +1 -1
- package/dashboard/dist/assets/{server-DFCbznC7.js → server-Bm7fHvVa.js} +1 -1
- package/dashboard/dist/assets/{shield-check-YcmLwVZ6.js → shield-check-DtT8ACzI.js} +1 -1
- package/dashboard/dist/assets/{skills-api-C-9vK884.js → skills-api-Dc1-2qu6.js} +1 -1
- package/dashboard/dist/assets/{sortable.esm-CKC9NuR-.js → sortable.esm-B-qN-Xk2.js} +1 -1
- package/dashboard/dist/assets/store-gHeBU8dQ.js +1 -0
- package/dashboard/dist/assets/{terminal-B3_fCLFs.js → terminal-D4VZbvhg.js} +1 -1
- package/dashboard/dist/assets/{trash-CZGfgbFa.js → trash-BZtLAFQy.js} +1 -1
- package/dashboard/dist/assets/{use-community-stats-CW-qkYn7.js → use-community-stats-BdqndrbB.js} +1 -1
- package/dashboard/dist/assets/{use-latest-request-guard-DHv7vfFE.js → use-latest-request-guard-DhGg1cDS.js} +1 -1
- package/dashboard/dist/assets/use-limits-display-prefs-D3HOcRFv.js +1 -0
- package/dashboard/dist/assets/{use-native-settings-CWiLqfZh.js → use-native-settings-BniKwA_n.js} +1 -1
- package/dashboard/dist/assets/{use-ordered-list-Df8pw-WJ.js → use-ordered-list-b09H7EHq.js} +1 -1
- package/dashboard/dist/assets/use-pet-settings-CPZdlq_e.js +2 -0
- package/dashboard/dist/assets/use-reduced-motion-D1gcKJUo.js +1 -0
- package/dashboard/dist/assets/{use-transform-BHwEAfmO.js → use-transform-CIdxjmI8.js} +1 -1
- package/dashboard/dist/assets/use-usage-limits-eJlU65yY.js +1 -0
- package/dashboard/dist/assets/{useCurrency-pwClnCZ5.js → useCurrency-CM22CmAq.js} +1 -1
- package/dashboard/dist/assets/usePositioner-B3l2ulTw.js +1 -0
- package/dashboard/dist/assets/{useTokenFormat-BMvVAe6V.js → useTokenFormat-D7nzgxKw.js} +1 -1
- package/dashboard/dist/assets/zap-Daxct1WV.js +1 -0
- package/dashboard/dist/index.html +14 -12
- package/dashboard/dist/ip-check.html +2 -2
- package/dashboard/dist/leaderboard.html +2 -2
- package/dashboard/dist/llms.txt +2 -2
- package/dashboard/dist/share.html +2 -2
- package/package.json +3 -2
- package/src/commands/init.js +43 -1
- package/src/commands/status.js +27 -0
- package/src/commands/sync.js +54 -4
- package/src/commands/uninstall.js +19 -0
- package/src/lib/claude-config.js +47 -15
- package/src/lib/codex-rollout-parser.js +11 -3
- package/src/lib/command-runner.js +15 -1
- package/src/lib/cursor-config.js +2 -1
- package/src/lib/gemini-config.js +3 -2
- package/src/lib/local-api.js +13 -3
- package/src/lib/notify-command.js +38 -0
- package/src/lib/openclaw-session-plugin.js +47 -14
- package/src/lib/passive-mode.js +12 -0
- package/src/lib/pricing/curated-overrides.json +42 -5
- package/src/lib/pricing/matcher.js +14 -5
- package/src/lib/pricing/seed-snapshot.json +1 -1
- package/src/lib/rollout.js +150 -28
- package/src/lib/session-analytics.js +108 -9
- package/src/lib/usage-limits.js +183 -20
- package/src/lib/zcode-limits.js +218 -18
- package/src/lib/zcode-reset-credits.js +66 -0
- package/dashboard/dist/assets/AchievementBadge-BaqdyZaV.js +0 -1
- package/dashboard/dist/assets/AchievementsPage-B4Ju0guv.js +0 -2
- package/dashboard/dist/assets/BadgeDetailModal-B-XMJAvL.js +0 -1
- package/dashboard/dist/assets/Card-D-5mABVt.js +0 -1
- package/dashboard/dist/assets/CloudCheckoutPage-BELoh56h.js +0 -1
- package/dashboard/dist/assets/CloudPage-CfBruNxe.js +0 -1
- package/dashboard/dist/assets/CloudUsageExport-BoFU7xCT.js +0 -4
- package/dashboard/dist/assets/CommandPalette-BmmKZWn-.js +0 -1
- package/dashboard/dist/assets/CommunityStatsModal-BF77zVhN.js +0 -1
- package/dashboard/dist/assets/Controls-BnTeX7T4.js +0 -1
- package/dashboard/dist/assets/DashboardPage-BWulHa5J.js +0 -1
- package/dashboard/dist/assets/DialogClose-DAyilsH-.js +0 -1
- package/dashboard/dist/assets/DialogDescription-j4XnRy6y.js +0 -1
- package/dashboard/dist/assets/DialogTitle-B1iNGD2S.js +0 -1
- package/dashboard/dist/assets/LandingPage-Dtgq_caz.js +0 -2
- package/dashboard/dist/assets/LeaderboardPage-Di1kEg2O.js +0 -2
- package/dashboard/dist/assets/LeaderboardProBadge-h8FfR0au.js +0 -1
- package/dashboard/dist/assets/LimitsPage-DKojB73_.js +0 -8
- package/dashboard/dist/assets/LoginCard-Dn5Xy4If.js +0 -1
- package/dashboard/dist/assets/LoginModal-C5h-5GOA.js +0 -1
- package/dashboard/dist/assets/LoginPage-BpX8Tgjj.js +0 -1
- package/dashboard/dist/assets/PopoverPopup-CVTiEVHs.js +0 -1
- package/dashboard/dist/assets/Select-CtTceC4T.js +0 -1
- package/dashboard/dist/assets/SelectItemText-C7xi8iGp.js +0 -1
- package/dashboard/dist/assets/SessionsPage-BngTWN7Q.css +0 -1
- package/dashboard/dist/assets/SessionsPage-okHobk_L.js +0 -3
- package/dashboard/dist/assets/SettingsPage-C-cc6wcF.js +0 -2
- package/dashboard/dist/assets/SkillsPage-D2LlKKJN.js +0 -1
- package/dashboard/dist/assets/TrendMonitor-C88S-5aa.js +0 -19
- package/dashboard/dist/assets/WidgetsPage-WsEFPNwp.js +0 -1
- package/dashboard/dist/assets/__vite-browser-external-DFRX9dp-.css +0 -1
- package/dashboard/dist/assets/__vite-browser-external-DUJeOWgd.js +0 -45
- package/dashboard/dist/assets/agent-logos-BM9jlReI.js +0 -1
- package/dashboard/dist/assets/arrow-left-BEM-HVmC.js +0 -1
- package/dashboard/dist/assets/cloud-checkout-nYNHDFoR.js +0 -1
- package/dashboard/dist/assets/composite-B4Z3F65o.js +0 -1
- package/dashboard/dist/assets/download-CJUnX1Bs.js +0 -1
- package/dashboard/dist/assets/info-CyDY7NYM.js +0 -1
- package/dashboard/dist/assets/module-WSx8viXK.js +0 -3
- package/dashboard/dist/assets/monitor-smartphone-C-qC0RAt.js +0 -1
- package/dashboard/dist/assets/plus-Cx82jb7o.js +0 -1
- package/dashboard/dist/assets/provider-display-CodMmiRb.js +0 -42
- package/dashboard/dist/assets/safePolygon-CKpREa4K.js +0 -1
- package/dashboard/dist/assets/store-C9yWYHfg.js +0 -1
- package/dashboard/dist/assets/use-limits-display-prefs-NZ-AAYD5.js +0 -1
- package/dashboard/dist/assets/use-pet-settings-Bg2CDprr.js +0 -2
- package/dashboard/dist/assets/use-reduced-motion-iDZEUyua.js +0 -1
- package/dashboard/dist/assets/use-usage-limits-CSxFFn3_.js +0 -1
- package/dashboard/dist/assets/usePositioner-B0j1orGj.js +0 -1
- package/dashboard/dist/assets/zap-DvX2aYx5.js +0 -1
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
function powershellLiteral(value) {
|
|
4
|
+
return `'${String(value || "").replace(/'/g, "''")}'`;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
function quotePosix(value) {
|
|
8
|
+
const text = String(value || "");
|
|
9
|
+
if (/^[A-Za-z0-9_\-./:@]+$/.test(text)) return text;
|
|
10
|
+
return `"${text.replace(/\\/g, "\\\\").replace(/"/g, '\\"').replace(/\$/g, '\\$').replace(/`/g, '\\`')}"`;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
function buildNotifyCommand(notifyPath, source, { platform = process.platform, execPath = process.execPath } = {}) {
|
|
14
|
+
if (!/^[a-z0-9-]+$/i.test(source)) throw new Error("Invalid notify source");
|
|
15
|
+
if (platform === "win32") {
|
|
16
|
+
return `& ${powershellLiteral(execPath)} ${powershellLiteral(notifyPath)} --source=${source}`;
|
|
17
|
+
}
|
|
18
|
+
return `/usr/bin/env node ${quotePosix(notifyPath)} --source=${source}`;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
// Recognize only our complete notify invocation, never a user command merely
|
|
22
|
+
// containing notify.cjs or additional shell actions. Used to repair old hooks.
|
|
23
|
+
function notifyIdentity(command) {
|
|
24
|
+
if (typeof command !== "string") return null;
|
|
25
|
+
const tokens = command.match(/"(?:\\.|[^"\\])*"|'(?:''|[^'])*'|[^\s]+/g) || [];
|
|
26
|
+
const decode = (token) => token.startsWith("'")
|
|
27
|
+
? token.slice(1, -1).replace(/''/g, "'")
|
|
28
|
+
: token.startsWith('"') ? token.slice(1, -1).replace(/\\([\\"$`])/g, "$1") : token;
|
|
29
|
+
const args = tokens.map(decode);
|
|
30
|
+
if (args[0] === "&") args.shift();
|
|
31
|
+
if (args[0] === "/usr/bin/env" && args[1] === "node") args.shift();
|
|
32
|
+
if (args.length !== 3 || !/(?:^|[\\/])node(?:\.exe)?$/i.test(args[0])) return null;
|
|
33
|
+
if (!/(?:^|[\\/])notify\.cjs$/i.test(args[1]) || !/^--source=[a-z0-9-]+$/i.test(args[2])) return null;
|
|
34
|
+
const file = args[1].replace(/\\/g, "/");
|
|
35
|
+
return `${/^[a-z]:\//i.test(file) ? file.toLowerCase() : file}\u0000${args[2]}`;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
module.exports = { buildNotifyCommand, notifyIdentity };
|
|
@@ -371,7 +371,7 @@ function buildSessionPluginIndex({ trackerDir, packageName = "tokentracker-cli",
|
|
|
371
371
|
` const agentId = normalize(ctx && ctx.agentId) || parseAgentId(sessionKey);\n` +
|
|
372
372
|
` if (!agentId) return;\n` +
|
|
373
373
|
`\n` +
|
|
374
|
-
` const sessionInfo = resolveSessionInfo(agentId, sessionKey);\n` +
|
|
374
|
+
` const sessionInfo = await resolveSessionInfo(agentId, sessionKey);\n` +
|
|
375
375
|
` const sessionId = normalize(sessionInfo && sessionInfo.sessionId);\n` +
|
|
376
376
|
` if (!sessionId) return;\n` +
|
|
377
377
|
`\n` +
|
|
@@ -440,25 +440,58 @@ function buildSessionPluginIndex({ trackerDir, packageName = "tokentracker-cli",
|
|
|
440
440
|
` return out;\n` +
|
|
441
441
|
`}\n` +
|
|
442
442
|
`\n` +
|
|
443
|
-
`function resolveSessionInfo(agentId, sessionKey) {\n` +
|
|
443
|
+
`async function resolveSessionInfo(agentId, sessionKey) {\n` +
|
|
444
444
|
` const key = normalize(sessionKey);\n` +
|
|
445
445
|
` if (!key) return null;\n` +
|
|
446
446
|
` const sessionsPath = path.join(openclawHome, 'agents', agentId, 'sessions', 'sessions.json');\n` +
|
|
447
|
-
`
|
|
448
|
-
`
|
|
449
|
-
`
|
|
450
|
-
`
|
|
451
|
-
`
|
|
452
|
-
`
|
|
453
|
-
`
|
|
454
|
-
`
|
|
455
|
-
`
|
|
456
|
-
`
|
|
457
|
-
` }
|
|
458
|
-
` }
|
|
447
|
+
` if (fs.existsSync(sessionsPath)) {\n` +
|
|
448
|
+
` try {\n` +
|
|
449
|
+
` const raw = fs.readFileSync(sessionsPath, 'utf8');\n` +
|
|
450
|
+
` const parsed = JSON.parse(raw);\n` +
|
|
451
|
+
` if (parsed && typeof parsed === 'object') {\n` +
|
|
452
|
+
` const entry = parsed[key];\n` +
|
|
453
|
+
` if (entry && typeof entry === 'object' && normalize(entry.sessionId)) {\n` +
|
|
454
|
+
` return { sessionKey: key, sessionId: normalize(entry.sessionId), entry };\n` +
|
|
455
|
+
` }\n` +
|
|
456
|
+
` }\n` +
|
|
457
|
+
` } catch (_) {}\n` +
|
|
458
|
+
` }\n` +
|
|
459
|
+
` // OpenClaw >= 2026.9.9 keeps session state in a per-agent SQLite\n` +
|
|
460
|
+
` // database (~/.openclaw/agents/<id>/agent/openclaw-agent.sqlite);\n` +
|
|
461
|
+
` // sessions.json is no longer written. Without this fallback the\n` +
|
|
462
|
+
` // plugin would silently no-op on every agent_end for anyone on a\n` +
|
|
463
|
+
` // current OpenClaw install (issue: openclaw migration to sqlite).\n` +
|
|
464
|
+
` return resolveSessionInfoFromSqlite(agentId, key);\n` +
|
|
465
|
+
`}\n` +
|
|
466
|
+
`\n` +
|
|
467
|
+
`async function resolveSessionInfoFromSqlite(agentId, sessionKey) {\n` +
|
|
468
|
+
` const sqliteModule = await importSqliteSync();\n` +
|
|
469
|
+
` if (!sqliteModule) return null;\n` +
|
|
470
|
+
` const { DatabaseSync } = sqliteModule;\n` +
|
|
471
|
+
` const currentSessionQuery = "SELECT w.session_id FROM session_nodes n JOIN session_windows w ON w.session_id = n.current_session_id WHERE n.session_key = ? AND COALESCE(w.reason, '') != 'compaction'";\n` +
|
|
472
|
+
` const sessionQuery = "SELECT session_id FROM session_windows WHERE session_key = ? AND COALESCE(reason, '') != 'compaction' ORDER BY updated_at DESC LIMIT 1";\n` +
|
|
473
|
+
` const dbCandidates = [path.join(openclawHome, 'agents', agentId, 'agent', 'openclaw-agent.sqlite'), path.join(openclawHome, 'agents', agentId, 'openclaw-agent.sqlite')];\n` +
|
|
474
|
+
` for (const dbPath of dbCandidates) {\n` +
|
|
475
|
+
` if (!fs.existsSync(dbPath)) continue;\n` +
|
|
476
|
+
` let db;\n` +
|
|
477
|
+
` try { db = new DatabaseSync(dbPath, { readOnly: true }); } catch (_) { continue; }\n` +
|
|
478
|
+
` try {\n` +
|
|
479
|
+
` let row;\n` +
|
|
480
|
+
` try { row = db.prepare(currentSessionQuery).get(sessionKey); } catch (_) {}\n` +
|
|
481
|
+
` if (!row || !row.session_id) row = db.prepare(sessionQuery).get(sessionKey);\n` +
|
|
482
|
+
` if (!row || !row.session_id) continue;\n` +
|
|
483
|
+
` // The passive SQLite reader owns per-event accounting; never synthesize lifetime sums.\n` +
|
|
484
|
+
` return { sessionKey, sessionId: row.session_id, entry: {} };\n` +
|
|
485
|
+
` } catch (_) {}\n` +
|
|
486
|
+
` finally { try { db.close(); } catch (_) {} }\n` +
|
|
487
|
+
` }\n` +
|
|
459
488
|
` return null;\n` +
|
|
460
489
|
`}\n` +
|
|
461
490
|
`\n` +
|
|
491
|
+
`async function importSqliteSync() {\n` +
|
|
492
|
+
` try { return await import('node:sqlite'); } catch (_) { return null; }\n` +
|
|
493
|
+
`}\n` +
|
|
494
|
+
`\n` +
|
|
462
495
|
`function parseAgentId(sessionKey) {\n` +
|
|
463
496
|
` const s = normalize(sessionKey);\n` +
|
|
464
497
|
` if (!s || !s.startsWith('agent:')) return null;\n` +
|
package/src/lib/passive-mode.js
CHANGED
|
@@ -28,6 +28,7 @@
|
|
|
28
28
|
|
|
29
29
|
const fs = require("node:fs");
|
|
30
30
|
const path = require("node:path");
|
|
31
|
+
const { expandHome } = require("./scan-roots");
|
|
31
32
|
|
|
32
33
|
/**
|
|
33
34
|
* @typedef {Object} PassiveProvider
|
|
@@ -171,6 +172,17 @@ function detectPassiveProviders({ home, hookStatus, env = process.env }) {
|
|
|
171
172
|
settingsPath: path.join(home, ".workbuddy", "settings.json"),
|
|
172
173
|
}));
|
|
173
174
|
|
|
175
|
+
// WorkBuddy AI — international build; data + hooks in ~/.workbuddy-ai
|
|
176
|
+
const workbuddyAiHome = expandHome(env.WORKBUDDY_AI_HOME, home) || path.join(home, ".workbuddy-ai");
|
|
177
|
+
out.push(buildEntry({
|
|
178
|
+
name: "workbuddy-ai",
|
|
179
|
+
hookExpected: true,
|
|
180
|
+
hookInstalled: Boolean(hookStatus?.["workbuddy-ai"]),
|
|
181
|
+
logsDir: workbuddyAiHome,
|
|
182
|
+
logsPredicate: (_full, name) => name === "projects" || name.endsWith(".jsonl"),
|
|
183
|
+
settingsPath: path.join(workbuddyAiHome, "settings.json"),
|
|
184
|
+
}));
|
|
185
|
+
|
|
174
186
|
return out;
|
|
175
187
|
}
|
|
176
188
|
|
|
@@ -3,9 +3,43 @@
|
|
|
3
3
|
"note": "Curated price overrides. Always wins over LiteLLM. Two reasons to live here: (1) self-defined alias names that LiteLLM will never carry (kiro-*, hy3-*, composer-*, kimi-for-coding, free-tier OpenRouter routes); (2) prices we want to pin even if LiteLLM has the model (e.g. cache_write fields LiteLLM often omits). Units: USD per million tokens. Edit this file to override pricing without redeploying.",
|
|
4
4
|
"units": "usd_per_million_tokens",
|
|
5
5
|
"deepseek_v4_pricing_note": "Official DeepSeek V4 pricing verified on 2026-08-21. Peak hours are 01:00-04:00 and 06:00-10:00 UTC; all other hours are off-peak at half price. Exact entries store peak rates. computeRowCost applies the time-of-use discount from each row's UTC hour_start.",
|
|
6
|
-
"iflytek_maas_pricing_note": "iFlytek MaaS inference prices supplied for AStudio on 2026-08-31. AStudio homepage: https://agent.xfyun.cn/. Official pricing source: https://maas.xfyun.cn/modelSquare. Source values are RMB per million tokens, converted at 7.2 RMB/USD, then rounded to two decimal places for billing. Models without a dedicated cache-hit price use the normal input rate; cache writes also use the normal input rate. iFlytek MaaS prices are source-scoped and do not inherit DeepSeek time-of-use discounts."
|
|
6
|
+
"iflytek_maas_pricing_note": "iFlytek MaaS inference prices supplied for AStudio on 2026-08-31. AStudio homepage: https://agent.xfyun.cn/. Official pricing source: https://maas.xfyun.cn/modelSquare. Source values are RMB per million tokens, converted at 7.2 RMB/USD, then rounded to two decimal places for billing. Models without a dedicated cache-hit price use the normal input rate; cache writes also use the normal input rate. iFlytek MaaS prices are source-scoped and do not inherit DeepSeek time-of-use discounts. Spark-X2.5 entries (spark-x2.5, spark-x2.5-4b, spark-x2.5-1.7b) were read from the model square on 2026-10-08; spark-x2.5 is listed at a limited-time 30% rate (0.96 / 3.6 / 0.14 RMB input / output / cache-hit, list price 3.2 / 12 / 0.48), and the two small models are free."
|
|
7
7
|
},
|
|
8
8
|
"exact": {
|
|
9
|
+
"claude-opus-5-5": {
|
|
10
|
+
"input": 4,
|
|
11
|
+
"output": 20,
|
|
12
|
+
"cache_read": 0.2,
|
|
13
|
+
"cache_write": 5,
|
|
14
|
+
"note": "Official Anthropic pricing verified 2026-10-11: https://platform.claude.com/docs/en/about-claude/pricing"
|
|
15
|
+
},
|
|
16
|
+
"claude-opus-5.5": {
|
|
17
|
+
"input": 4,
|
|
18
|
+
"output": 20,
|
|
19
|
+
"cache_read": 0.2,
|
|
20
|
+
"cache_write": 5,
|
|
21
|
+
"note": "Official Anthropic pricing verified 2026-10-11: https://platform.claude.com/docs/en/about-claude/pricing"
|
|
22
|
+
},
|
|
23
|
+
"claude-sonnet-5-5": {
|
|
24
|
+
"input": 2,
|
|
25
|
+
"output": 10,
|
|
26
|
+
"cache_read": 0.1,
|
|
27
|
+
"cache_write": 2.5,
|
|
28
|
+
"note": "Official Anthropic pricing verified 2026-10-11: https://platform.claude.com/docs/en/about-claude/pricing"
|
|
29
|
+
},
|
|
30
|
+
"claude-sonnet-5.5": {
|
|
31
|
+
"input": 2,
|
|
32
|
+
"output": 10,
|
|
33
|
+
"cache_read": 0.1,
|
|
34
|
+
"cache_write": 2.5,
|
|
35
|
+
"note": "Official Anthropic pricing verified 2026-10-11: https://platform.claude.com/docs/en/about-claude/pricing"
|
|
36
|
+
},
|
|
37
|
+
"k3-256k": {
|
|
38
|
+
"input": 3,
|
|
39
|
+
"output": 15,
|
|
40
|
+
"cache_read": 0.3,
|
|
41
|
+
"note": "Bare alias emitted by Kimi Code (modelAlias \"kimi-code/k3\" -> \"k3\"). Same rates as kimi-k3."
|
|
42
|
+
},
|
|
9
43
|
"cline-gateway-models": {
|
|
10
44
|
"input": 0,
|
|
11
45
|
"output": 0,
|
|
@@ -42,10 +76,10 @@
|
|
|
42
76
|
"note": "Opus 4.8 not yet in LiteLLM. Pin to the standard Opus tier (same as 4.6/4.7); remove once LiteLLM carries it."
|
|
43
77
|
},
|
|
44
78
|
"claude-sonnet-5": {
|
|
45
|
-
"input":
|
|
46
|
-
"output":
|
|
47
|
-
"cache_read": 0.
|
|
48
|
-
"cache_write":
|
|
79
|
+
"input": 2,
|
|
80
|
+
"output": 10,
|
|
81
|
+
"cache_read": 0.2,
|
|
82
|
+
"cache_write": 2.5,
|
|
49
83
|
"note": "Sonnet 5. LiteLLM added this model on ~2026-06-30 with matching rates, but pin explicitly so pricing is correct immediately rather than depending on the 24h local pricing-cache refresh cycle."
|
|
50
84
|
},
|
|
51
85
|
"claude-haiku-4-5": {
|
|
@@ -482,6 +516,9 @@
|
|
|
482
516
|
},
|
|
483
517
|
"source_exact": {
|
|
484
518
|
"acode": {
|
|
519
|
+
"spark-x2.5": { "input": 0.13, "output": 0.50, "cache_read": 0.02, "cache_write": 0.13 },
|
|
520
|
+
"spark-x2.5-4b": { "input": 0.00, "output": 0.00, "cache_read": 0.00, "cache_write": 0.00 },
|
|
521
|
+
"spark-x2.5-1.7b": { "input": 0.00, "output": 0.00, "cache_read": 0.00, "cache_write": 0.00 },
|
|
485
522
|
"xopglm53": { "input": 1.11, "output": 3.89, "cache_read": 0.28, "cache_write": 1.11 },
|
|
486
523
|
"xopdeepseekv4pro0813": { "input": 1.25, "output": 3.75, "cache_read": 0.04, "cache_write": 1.25 },
|
|
487
524
|
"xopdeepseekv4flash0731": { "input": 0.14, "output": 0.28, "cache_read": 0.03, "cache_write": 0.14 },
|
|
@@ -238,7 +238,13 @@ function lookupContainedExactCaseInsensitive(table, model) {
|
|
|
238
238
|
const lower = model.toLowerCase();
|
|
239
239
|
const keys = Object.keys(table).sort((a, b) => b.length - a.length);
|
|
240
240
|
for (const key of keys) {
|
|
241
|
-
|
|
241
|
+
const start = lower.indexOf(key.toLowerCase());
|
|
242
|
+
if (start < 0) continue;
|
|
243
|
+
// A model generation must not match a later numeric version (Opus 5.5
|
|
244
|
+
// is a separate SKU from Opus 5). Dated and provider suffixes still work.
|
|
245
|
+
const suffix = lower.slice(start + key.length);
|
|
246
|
+
if (/^[.\d]/.test(suffix)) continue;
|
|
247
|
+
return table[key];
|
|
242
248
|
}
|
|
243
249
|
return null;
|
|
244
250
|
}
|
|
@@ -256,6 +262,9 @@ function lookupPricing(model, { curated, litellm, source } = {}) {
|
|
|
256
262
|
// 0. CURATED source exact. Source-specific prices apply only to their source,
|
|
257
263
|
// preventing collisions with public prices for same-named models from other CLIs.
|
|
258
264
|
const sourceKey = typeof source === "string" ? source.toLowerCase() : "";
|
|
265
|
+
if (sourceKey === "workbuddy-ai" && lower.trim() === "auto") {
|
|
266
|
+
return { hit: false, source: "miss", value: null };
|
|
267
|
+
}
|
|
259
268
|
if (sourceKey === "cline" && lower.endsWith(":free")) {
|
|
260
269
|
return {
|
|
261
270
|
hit: true,
|
|
@@ -289,10 +298,6 @@ function lookupPricing(model, { curated, litellm, source } = {}) {
|
|
|
289
298
|
if (curatedDotExact) {
|
|
290
299
|
return { hit: true, source: "curated:exact-dot", value: curatedDotExact };
|
|
291
300
|
}
|
|
292
|
-
const curatedDotContainedExact = lookupContainedExactCaseInsensitive(curated.exact, dotForm);
|
|
293
|
-
if (curatedDotContainedExact) {
|
|
294
|
-
return { hit: true, source: "curated:exact-dot", value: curatedDotContainedExact };
|
|
295
|
-
}
|
|
296
301
|
|
|
297
302
|
// 2. LiteLLM exact
|
|
298
303
|
if (litellm && litellm[lookupModel]) {
|
|
@@ -302,6 +307,10 @@ function lookupPricing(model, { curated, litellm, source } = {}) {
|
|
|
302
307
|
if (litellmDotExact) {
|
|
303
308
|
return { hit: true, source: "litellm:exact-dot", value: litellmDotExact };
|
|
304
309
|
}
|
|
310
|
+
const curatedDotContainedExact = lookupContainedExactCaseInsensitive(curated.exact, dotForm);
|
|
311
|
+
if (curatedDotContainedExact) {
|
|
312
|
+
return { hit: true, source: "curated:exact-dot", value: curatedDotContainedExact };
|
|
313
|
+
}
|
|
305
314
|
|
|
306
315
|
// 3. CURATED alias (literal mapping like "auto" -> "composer-1")
|
|
307
316
|
if (curated.alias && curated.alias[lookupModel] && curated.exact[curated.alias[lookupModel]]) {
|