tokentracker-cli 0.93.6 → 0.94.0
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 +1 -1
- package/README.ja.md +1 -1
- package/README.ko.md +1 -1
- package/README.md +1 -1
- package/README.zh-CN.md +1 -1
- package/dashboard/dist/assets/{AchievementBadge-DsAclDw6.js → AchievementBadge-DPqwk2zI.js} +1 -1
- package/dashboard/dist/assets/{AchievementsPage-D__EwC45.js → AchievementsPage-CELHoMQt.js} +2 -2
- package/dashboard/dist/assets/{AchievementsSection-BAZNM3Cn.js → AchievementsSection-DdAC0VCb.js} +1 -1
- package/dashboard/dist/assets/BadgeDetailModal-Dd4I1SpM.js +1 -0
- package/dashboard/dist/assets/{BotAnimated-CwrScgrI.js → BotAnimated-DL2-4mnm.js} +1 -1
- package/dashboard/dist/assets/{Card-D7GmLoqP.js → Card-B_MpSRse.js} +1 -1
- package/dashboard/dist/assets/{ClawdAnimated-BEXgb5J_.js → ClawdAnimated-BLZZ4rG6.js} +2 -2
- package/dashboard/dist/assets/{CommandPalette-B9Mn3Qt2.js → CommandPalette-B-vfdIbH.js} +1 -1
- package/dashboard/dist/assets/CommunityStatsModal-aAico565.js +1 -0
- package/dashboard/dist/assets/ConfirmModal-DLnRwUXC.js +1 -0
- package/dashboard/dist/assets/{Controls-DxnaHBzv.js → Controls-FZ8wEN5w.js} +1 -1
- package/dashboard/dist/assets/DashboardPage-BByRBsbt.js +1 -0
- package/dashboard/dist/assets/{DevicePage-4yTYf29M.js → DevicePage-D2IzPc5o.js} +1 -1
- package/dashboard/dist/assets/{DialogClose-BbderFCY.js → DialogClose-BaqQaUUk.js} +1 -1
- package/dashboard/dist/assets/DialogDescription-BUrh0Jod.js +1 -0
- package/dashboard/dist/assets/DialogTitle-DrbKjtuS.js +1 -0
- package/dashboard/dist/assets/{FadeIn-BFLojPGG.js → FadeIn-GddKDE8i.js} +1 -1
- package/dashboard/dist/assets/{HeaderGithubStar-CPBNn61n.js → HeaderGithubStar-DUu-Z5mE.js} +1 -1
- package/dashboard/dist/assets/{HoverTooltip-DbxnLj8e.js → HoverTooltip-BmDkY35A.js} +1 -1
- package/dashboard/dist/assets/{IpCheckPage-CfPtXAAF.js → IpCheckPage-CGJyqWk2.js} +1 -1
- package/dashboard/dist/assets/{LandingPage-CocswfFj.js → LandingPage-Bd91ALUj.js} +2 -2
- package/dashboard/dist/assets/{LeaderboardAvatar-iZLxxZX-.js → LeaderboardAvatar-BGGUwXFd.js} +1 -1
- package/dashboard/dist/assets/LeaderboardPage-BMEqHwif.js +2 -0
- package/dashboard/dist/assets/{LeaderboardProfileModal-BWu8jbBW.js → LeaderboardProfileModal-BSweJqm2.js} +3 -3
- package/dashboard/dist/assets/{LeaderboardProfilePage-B77gOTzr.js → LeaderboardProfilePage-CRrI3RFz.js} +1 -1
- package/dashboard/dist/assets/LimitsPage-XIRDv46K.js +5 -0
- package/dashboard/dist/assets/LocalOnlyNotice-CCD-lGWG.js +1 -0
- package/dashboard/dist/assets/{LoginCard-D592L-fh.js → LoginCard-lDuqSv4f.js} +1 -1
- package/dashboard/dist/assets/{LoginModal-C7Qm7CVf.js → LoginModal-DStt5VXN.js} +1 -1
- package/dashboard/dist/assets/{LoginPage-DkYw5ZQK.js → LoginPage-dmVPSL72.js} +1 -1
- package/dashboard/dist/assets/PetPage-ybcZRctF.js +1 -0
- package/dashboard/dist/assets/PopoverPopup-Dar_UjxF.js +1 -0
- package/dashboard/dist/assets/{ProviderIcon-d0_vhIkS.js → ProviderIcon-Ct9tILpz.js} +1 -1
- package/dashboard/dist/assets/{ResetPasswordPage-UDNlpFVu.js → ResetPasswordPage-B4yLh5zx.js} +1 -1
- package/dashboard/dist/assets/SegmentedControl-BOE1CEzq.js +1 -0
- package/dashboard/dist/assets/{Select-Z2xTQ55f.js → Select-D-bSh7Zz.js} +1 -1
- package/dashboard/dist/assets/SelectItemText-DMYjXXq4.js +1 -0
- package/dashboard/dist/assets/{ServiceStatusPage-Cfr-QDZ7.js → ServiceStatusPage-CaleS-6_.js} +1 -1
- package/dashboard/dist/assets/SessionsPage-DOaY6_E9.js +2 -0
- package/dashboard/dist/assets/SettingsPage-iJH0Yyah.js +2 -0
- package/dashboard/dist/assets/SkillsPage-BkzJOBLk.js +1 -0
- package/dashboard/dist/assets/{TokenGalaxy-CjAY6rey.js → TokenGalaxy-CuXKoMPg.js} +1 -1
- package/dashboard/dist/assets/ToolbarRootContext-Dx5GB7F5.js +1 -0
- package/dashboard/dist/assets/{TrendMonitor-DAAlILwJ.js → TrendMonitor-BuKmsznP.js} +1 -1
- package/dashboard/dist/assets/WidgetsPage-DUaIyGtu.js +1 -0
- package/dashboard/dist/assets/{WrappedPage-ByYzOeZ-.js → WrappedPage-BzqlcAUC.js} +1 -1
- package/dashboard/dist/assets/__vite-browser-external-BHz2N7Ih.css +1 -0
- package/dashboard/dist/assets/{__vite-browser-external-HdCplPKs.js → __vite-browser-external-CVIGknXl.js} +3 -3
- package/dashboard/dist/assets/{agent-logos-BW-ajJ7p.js → agent-logos-BdWWxza6.js} +1 -1
- package/dashboard/dist/assets/{arrow-up-right-CA5IJkqo.js → arrow-up-right-CANSzmm-.js} +1 -1
- package/dashboard/dist/assets/{check-BBjF3bSm.js → check-BnJpzXRZ.js} +1 -1
- package/dashboard/dist/assets/{chevron-right-DCvGp9iJ.js → chevron-right-DJm0mbG0.js} +1 -1
- package/dashboard/dist/assets/{useScrollLock-BUVUIPTX.js → composite-Ccj6KQmh.js} +1 -1
- package/dashboard/dist/assets/{copy-ahF8LGeu.js → copy-C2Yc8Evu.js} +1 -1
- package/dashboard/dist/assets/{download-DBm8dmvt.js → download-B52JTk6Y.js} +1 -1
- package/dashboard/dist/assets/{external-link-C1sJSL7J.js → external-link-DayTwZx-.js} +1 -1
- package/dashboard/dist/assets/{flame-B6xukEYd.js → flame-B8GEX2yT.js} +1 -1
- package/dashboard/dist/assets/{format-tokens-6TqXlT3q.js → format-tokens-mhkbohkb.js} +1 -1
- package/dashboard/dist/assets/{icons-pGe_pInY.js → icons-o8bPXqRP.js} +1 -1
- package/dashboard/dist/assets/{index-I9O8xChC.js → index-Bp0ZHDtz.js} +1 -1
- package/dashboard/dist/assets/{index-Chb8mb2X.js → index-CK_CduLm.js} +1 -1
- package/dashboard/dist/assets/{index-RPV0zdZ9.js → index-MBVWUKpA.js} +1 -1
- package/dashboard/dist/assets/{info-DBfJv0yu.js → info-D94QM_vX.js} +1 -1
- package/dashboard/dist/assets/{limits-providers-DPQsdVq5.js → limits-providers-BLzMyCiy.js} +1 -1
- package/dashboard/dist/assets/{link-2-DNEARrPY.js → link-2-CqBmFaDI.js} +1 -1
- package/dashboard/dist/assets/{loader-circle-BCFHUr8X.js → loader-circle-SaxUpDR6.js} +1 -1
- package/dashboard/dist/assets/{maximize-2-1EmlA2R-.js → maximize-2-BoXqARks.js} +1 -1
- package/dashboard/dist/assets/{modifiers.esm-DGXFSuEq.js → modifiers.esm-Conh_-BD.js} +1 -1
- package/dashboard/dist/assets/{monitor-smartphone-DsPPhvsT.js → monitor-smartphone-D6qLR9qd.js} +1 -1
- package/dashboard/dist/assets/plus-D51mjIc2.js +1 -0
- package/dashboard/dist/assets/{provider-display-C20LtBC5.js → provider-display-DpHPjd_s.js} +1 -1
- package/dashboard/dist/assets/{react-B4FPJgs_.js → react-D_AcI466.js} +1 -1
- package/dashboard/dist/assets/{search-mkIFPKzW.js → search-CwLcNdvZ.js} +1 -1
- package/dashboard/dist/assets/{skills-api-D24vlu2H.js → skills-api-Dqi7Mjgo.js} +1 -1
- package/dashboard/dist/assets/{sortable.esm-BNDcP0sW.js → sortable.esm-BPDlUxPb.js} +1 -1
- package/dashboard/dist/assets/store-ikeRIRGd.js +1 -0
- package/dashboard/dist/assets/{terminal-BxVMmvEx.js → terminal-BfeX3L5T.js} +1 -1
- package/dashboard/dist/assets/{trash-2-crt9lDvj.js → trash-2-5_Qlp1k7.js} +1 -1
- package/dashboard/dist/assets/{use-community-stats-CTB_uHWV.js → use-community-stats-D90Fy2_j.js} +1 -1
- package/dashboard/dist/assets/use-limits-display-prefs-D4BYFaa-.js +1 -0
- package/dashboard/dist/assets/{use-ordered-list-BVNb5QWU.js → use-ordered-list-DJxLNdXY.js} +1 -1
- package/dashboard/dist/assets/use-reduced-motion-yE3T3cat.js +1 -0
- package/dashboard/dist/assets/{use-session-efficiency-pref-Di8nY6Lr.js → use-session-efficiency-pref-CAX_GqXc.js} +1 -1
- package/dashboard/dist/assets/{use-transform-Dx9C2nBC.js → use-transform-CeW6Z5R0.js} +1 -1
- package/dashboard/dist/assets/use-usage-limits-5HP8k9a3.js +1 -0
- package/dashboard/dist/assets/{useCurrency-7dkDciam.js → useCurrency-BarGeFyK.js} +1 -1
- package/dashboard/dist/assets/{useTokenFormat-DFSIAsAb.js → useTokenFormat-DUJ9iT9H.js} +1 -1
- package/dashboard/dist/assets/{zap-Png-VJSP.js → zap--m0IWoI3.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/commands/status.js +3 -1
- package/src/commands/sync.js +8 -3
- package/src/lib/codex-rollout-parser.js +35 -4
- package/src/lib/cursor-config.js +182 -1
- package/src/lib/fs.js +12 -3
- package/src/lib/local-api.js +57 -0
- package/src/lib/pricing/seed-snapshot.json +1 -1
- package/src/lib/rollout.js +758 -195
- package/src/lib/session-analytics.js +205 -10
- package/src/lib/subscription-manager.js +293 -0
- package/src/lib/telemetry.js +2 -2
- package/src/lib/usage-limits.js +55 -14
- package/dashboard/dist/assets/BadgeDetailModal-Dgeer5oB.js +0 -1
- package/dashboard/dist/assets/CommunityStatsModal-eJ_a1FMd.js +0 -1
- package/dashboard/dist/assets/ConfirmModal-CumOr2J1.js +0 -1
- package/dashboard/dist/assets/DashboardPage-BpRRXCRr.js +0 -1
- package/dashboard/dist/assets/DialogDescription-C5Ujj254.js +0 -1
- package/dashboard/dist/assets/DialogTitle-6epeLIn0.js +0 -1
- package/dashboard/dist/assets/LeaderboardPage-yqauB4Q1.js +0 -2
- package/dashboard/dist/assets/LimitsPage-C9NeIcft.js +0 -5
- package/dashboard/dist/assets/LocalOnlyNotice-HPXWU8TT.js +0 -1
- package/dashboard/dist/assets/PetPage-BOhvAJp4.js +0 -1
- package/dashboard/dist/assets/PopoverPopup-BK9aqQn1.js +0 -1
- package/dashboard/dist/assets/SegmentedControl-DE5m1pTf.js +0 -1
- package/dashboard/dist/assets/SelectItemText-Daq-XRZg.js +0 -1
- package/dashboard/dist/assets/SessionsPage-nHPj6IAt.js +0 -2
- package/dashboard/dist/assets/SettingsPage-NvxUG_9m.js +0 -2
- package/dashboard/dist/assets/SkillsPage-zFbZa42f.js +0 -1
- package/dashboard/dist/assets/ToolbarRootContext-DnC8LT_8.js +0 -1
- package/dashboard/dist/assets/WidgetsPage-CXsfi-mq.js +0 -1
- package/dashboard/dist/assets/__vite-browser-external-CiR9-j4L.css +0 -1
- package/dashboard/dist/assets/store-B2nqaAqP.js +0 -1
- package/dashboard/dist/assets/use-limits-display-prefs-DXXZpjGY.js +0 -1
- package/dashboard/dist/assets/use-reduced-motion-aSaQtoJu.js +0 -1
- package/dashboard/dist/assets/use-usage-limits-D9vQFB1H.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{m as c}from"./__vite-browser-external-
|
|
1
|
+
import{m as c}from"./__vite-browser-external-CVIGknXl.js";const e=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],o=c("search",e);export{o as S};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{N as E,O as I,P as R,Q as $}from"./__vite-browser-external-
|
|
1
|
+
import{N as E,O as I,P as R,Q as $}from"./__vite-browser-external-CVIGknXl.js";function s(e){return typeof e=="string"?e.trim():""}function g(e){return Array.isArray(e)?[...new Set(e.map(s).filter(Boolean))]:[]}function v(e){const t=s(e).replace(/\\/g,"/");if(!t||t.startsWith("/")||/^[A-Za-z]:\//.test(t))return"";const n=t.replace(/\/+$/g,"").split("/").filter(Boolean);return!n.length||n.some(r=>r==="."||r==="..")?"":n.join("/")}function C(e){const t=s(e).replace(/\\/g,"/");return!t||t.startsWith("/")||t.includes(":/")||/[A-Za-z]:\//.test(t)?"":t}function S(e){return s(e?.key)||s(e?.id)||`local:${s(e?.directory)}`}function L(e){return(Array.isArray(e)?e:[]).filter(t=>t?.scope!=="system").map(t=>{const n=v(t?.directory),r=C(S(t));if(!r||!n)return null;const i=t?.scope==="plugin"?"plugin":t?.managed?"managed":"local",o=v(t?.sourceName);return{key:r,name:s(t?.name)||n.split("/").pop()||"Skill",directory:n,targets:g(t?.targets),managed:t?.managed===!0,readOnly:t?.readOnly===!0,scope:i,...o?{sourceName:o}:{}}}).filter(t=>!!t)}function N(e){return{id:s(e?.id),name:s(e?.device_name)||s(e?.id),platform:s(e?.platform)||null,scannedAt:s(e?.scanned_at)||null}}function m(e,t){const n=Array.isArray(e.deviceSources)?e.deviceSources:[];return n.some(r=>r.id===t.id)?e:{...e,deviceSources:[...n,t]}}function q(e,t,n){const r=(Array.isArray(e)?e:[]).filter(o=>o?.scope!=="system").map(o=>({...o})),i=new Map;r.forEach((o,a)=>i.set(S(o).toLowerCase(),a));for(const o of Array.isArray(t?.devices)?t.devices:[]){const a=N(o);if(!(!a.id||a.id===n))for(const c of Array.isArray(o?.skills)?o.skills:[]){if(c?.scope==="system")continue;const l=S(c),p=s(c?.directory);if(!l||!p)continue;const h=l.toLowerCase(),k=g(c.targets),y=i.get(h);if(y!=null){const f=r[y];if(f.remote===!0&&f.inventoryOnly===!0){const A=[...new Set([...g(f.targets),...k])],U=Object.fromEntries(A.map(_=>[_,"synced"]));r[y]=m({...f,targets:A,targetStates:U},a)}else r[y]=m(f,a);continue}const w=k,b=Object.fromEntries(w.map(f=>[f,"synced"])),j=m({id:`remote:${encodeURIComponent(l)}`,key:l,name:s(c.name)||p.split(/[\\/]/).pop()||"Skill",directory:p,description:"",targets:w,targetStates:b,managed:!1,readOnly:!0,inventoryOnly:!0,remote:!0,scope:s(c.scope)||"local",sourceName:s(c.sourceName)||null},a);i.set(h,r.length),r.push(j)}}return r.sort((o,a)=>String(o.name||o.directory).localeCompare(String(a.name||a.directory))||String(o.id||o.key).localeCompare(String(a.id||a.key)))}const T="tokentracker-skills",P="tokentracker-account-skills",J=15e3;async function d(e){const t=new URL(`/functions/${T}`,window.location.origin);if(e)for(const[i,o]of Object.entries(e))o!=null&&o!==""&&t.searchParams.set(i,String(o));const n=await fetch(t.toString(),{headers:{Accept:"application/json"},cache:"no-store"}),r=await n.json().catch(()=>null);if(!n.ok)throw new Error(r?.error||`Request failed with HTTP ${n.status}`);return r}async function u(e){const t=await $(),n=await fetch(`/functions/${T}`,{method:"POST",headers:{Accept:"application/json","Content-Type":"application/json",...t},cache:"no-store",body:JSON.stringify(e)}),r=await n.json().catch(()=>null);if(!n.ok||r?.ok===!1)throw new Error(r?.error||`Request failed with HTTP ${n.status}`);return r}function x(){return d({mode:"installed"})}function H(e={}){return d({mode:"discover",...e.force?{force:1}:{}})}function z(e,t=0,n=20){return d({mode:"search",q:e,offset:t,limit:n})}function B(){return d({mode:"repos"})}function M(e,t){return u({action:"install",skill:e,targets:t})}function D(e){return u({action:"uninstall",id:e})}function G(e){return u({action:"restore",id:e})}function Q(e,t){return u({action:"set_targets",id:e,targets:t})}function W(e,t){return u({action:"import_local",directory:e,targets:t})}function Z(e,t){return u({action:"delete_local",directory:e,targets:t||[]})}function F(e){return u({action:"add_repo",repo:e})}function V(e,t){return u({action:"remove_repo",owner:e,name:t})}function X(e={}){return d({mode:"popular",...e.force?{force:1}:{}})}function Y(e={}){return d({mode:"updates",...e.force?{force:1}:{}})}function ee(e={}){return d({mode:"skill_usage",...e.force?{force:1}:{}})}async function O({accessToken:e,method:t="GET",body:n}){if(!e||!E(e))throw new Error("Skills sync requires sign-in");const r=I();if(!r)throw new Error("InsForge base URL not configured");const i={Accept:"application/json","Content-Type":"application/json",Authorization:`Bearer ${e}`},o=R();o&&(i.apikey=o);const a=new AbortController,c=setTimeout(()=>a.abort(),J);try{const l=await fetch(`${r.replace(/\/$/,"")}/functions/${P}`,{method:t,headers:i,cache:"no-store",signal:a.signal,...n==null?{}:{body:JSON.stringify(n)}}),p=await l.json().catch(()=>null);if(!l.ok)throw new Error(p?.error||`Request failed with HTTP ${l.status}`);return p}finally{clearTimeout(c)}}function te(e){return O({accessToken:e})}function ne({accessToken:e,deviceId:t,skills:n}){return O({accessToken:e,method:"POST",body:{device_id:t,skills:L(n)}})}export{te as a,B as b,X as c,H as d,Y as e,ee as f,x as g,Z as h,M as i,Q as j,W as k,V as l,q as m,F as n,ne as p,G as r,z as s,D as u};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{r as c,d as P,a3 as Oe}from"./__vite-browser-external-
|
|
1
|
+
import{r as c,d as P,a3 as Oe}from"./__vite-browser-external-CVIGknXl.js";function Sn(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return c.useMemo(()=>r=>{t.forEach(o=>o(r))},t)}const tt=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function me(e){const t=Object.prototype.toString.call(e);return t==="[object Window]"||t==="[object global]"}function bt(e){return"nodeType"in e}function B(e){var t,n;return e?me(e)?e:bt(e)&&(t=(n=e.ownerDocument)==null?void 0:n.defaultView)!=null?t:window:window}function wt(e){const{Document:t}=B(e);return e instanceof t}function Be(e){return me(e)?!1:e instanceof B(e).HTMLElement}function Wt(e){return e instanceof B(e).SVGElement}function ye(e){return e?me(e)?e.document:bt(e)?wt(e)?e:Be(e)||Wt(e)?e.ownerDocument:document:document:document}const Q=tt?c.useLayoutEffect:c.useEffect;function mt(e){const t=c.useRef(e);return Q(()=>{t.current=e}),c.useCallback(function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return t.current==null?void 0:t.current(...r)},[])}function En(){const e=c.useRef(null),t=c.useCallback((r,o)=>{e.current=setInterval(r,o)},[]),n=c.useCallback(()=>{e.current!==null&&(clearInterval(e.current),e.current=null)},[]);return[t,n]}function ke(e,t){t===void 0&&(t=[e]);const n=c.useRef(e);return Q(()=>{n.current!==e&&(n.current=e)},t),n}function Fe(e,t){const n=c.useRef();return c.useMemo(()=>{const r=e(n.current);return n.current=r,r},[...t])}function Je(e){const t=mt(e),n=c.useRef(null),r=c.useCallback(o=>{o!==n.current&&t?.(o,n.current),n.current=o},[]);return[n,r]}function ft(e){const t=c.useRef();return c.useEffect(()=>{t.current=e},[e]),t.current}let ct={};function $e(e,t){return c.useMemo(()=>{if(t)return t;const n=ct[e]==null?0:ct[e]+1;return ct[e]=n,e+"-"+n},[e,t])}function Ht(e){return function(t){for(var n=arguments.length,r=new Array(n>1?n-1:0),o=1;o<n;o++)r[o-1]=arguments[o];return r.reduce((i,s)=>{const a=Object.entries(s);for(const[l,u]of a){const f=i[l];f!=null&&(i[l]=f+e*u)}return i},{...t})}}const we=Ht(1),ze=Ht(-1);function In(e){return"clientX"in e&&"clientY"in e}function yt(e){if(!e)return!1;const{KeyboardEvent:t}=B(e.target);return t&&e instanceof t}function Mn(e){if(!e)return!1;const{TouchEvent:t}=B(e.target);return t&&e instanceof t}function ht(e){if(Mn(e)){if(e.touches&&e.touches.length){const{clientX:t,clientY:n}=e.touches[0];return{x:t,y:n}}else if(e.changedTouches&&e.changedTouches.length){const{clientX:t,clientY:n}=e.changedTouches[0];return{x:t,y:n}}}return In(e)?{x:e.clientX,y:e.clientY}:null}const _e=Object.freeze({Translate:{toString(e){if(!e)return;const{x:t,y:n}=e;return"translate3d("+(t?Math.round(t):0)+"px, "+(n?Math.round(n):0)+"px, 0)"}},Scale:{toString(e){if(!e)return;const{scaleX:t,scaleY:n}=e;return"scaleX("+t+") scaleY("+n+")"}},Transform:{toString(e){if(e)return[_e.Translate.toString(e),_e.Scale.toString(e)].join(" ")}},Transition:{toString(e){let{property:t,duration:n,easing:r}=e;return t+" "+n+"ms "+r}}}),Tt="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function An(e){return e.matches(Tt)?e:e.querySelector(Tt)}const On={display:"none"};function Tn(e){let{id:t,value:n}=e;return P.createElement("div",{id:t,style:On},n)}function Nn(e){let{id:t,announcement:n,ariaLiveType:r="assertive"}=e;const o={position:"fixed",top:0,left:0,width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0 0 0 0)",clipPath:"inset(100%)",whiteSpace:"nowrap"};return P.createElement("div",{id:t,style:o,role:"status","aria-live":r,"aria-atomic":!0},n)}function Ln(){const[e,t]=c.useState("");return{announce:c.useCallback(r=>{r!=null&&t(r)},[]),announcement:e}}const Kt=c.createContext(null);function kn(e){const t=c.useContext(Kt);c.useEffect(()=>{if(!t)throw new Error("useDndMonitor must be used within a children of <DndContext>");return t(e)},[e,t])}function zn(){const[e]=c.useState(()=>new Set),t=c.useCallback(r=>(e.add(r),()=>e.delete(r)),[e]);return[c.useCallback(r=>{let{type:o,event:i}=r;e.forEach(s=>{var a;return(a=s[o])==null?void 0:a.call(s,i)})},[e]),t]}const Pn={draggable:`
|
|
2
2
|
To pick up a draggable item, press the space bar.
|
|
3
3
|
While dragging, use the arrow keys to move the item.
|
|
4
4
|
Press space again to drop the item in its new position, or press escape to cancel.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{Z as t}from"./__vite-browser-external-CVIGknXl.js";import{F as p,P as g}from"./composite-Ccj6KQmh.js";function d(){return new p({open:!1,transitionStatus:void 0,floatingElement:null,referenceElement:null,triggerElements:new g,floatingId:void 0,syncOnly:!1,nested:!1,onOpenChange:void 0})}function c(){return{open:!1,openProp:void 0,mounted:!1,transitionStatus:void 0,floatingRootContext:d(),floatingId:void 0,triggerCount:0,preventUnmountingOnClose:!1,payload:void 0,activeTriggerId:null,activeTriggerElement:null,triggerIdProp:void 0,popupElement:null,positionerElement:null,activeTriggerProps:t,inactiveTriggerProps:t,popupProps:t}}function m(e,n,l=!1){return new p({open:!1,transitionStatus:void 0,floatingElement:null,referenceElement:null,triggerElements:e,floatingId:n,syncOnly:!0,nested:l,onOpenChange:void 0})}const o=e=>e.triggerIdProp??e.activeTriggerId,r=e=>e.openProp??e.open,i=e=>(e.popupElement?.id??e.floatingId)||void 0;function u(e,n){return n!==void 0&&r(e)&&o(e)===n}function a(e,n){return u(e,n)?!0:n!==void 0&&r(e)&&o(e)==null&&e.triggerCount===1}const P={open:r,mounted:e=>e.mounted,transitionStatus:e=>e.transitionStatus,floatingRootContext:e=>e.floatingRootContext,triggerCount:e=>e.triggerCount,preventUnmountingOnClose:e=>e.preventUnmountingOnClose,payload:e=>e.payload,activeTriggerId:o,activeTriggerElement:e=>e.mounted?e.activeTriggerElement:null,popupId:i,isTriggerActive:(e,n)=>n!==void 0&&o(e)===n,isOpenedByTrigger:(e,n)=>u(e,n),isMountedByTrigger:(e,n)=>n!==void 0&&o(e)===n&&e.mounted,triggerProps:(e,n)=>n?e.activeTriggerProps:e.inactiveTriggerProps,triggerPopupId:(e,n)=>a(e,n)?i(e):void 0,popupProps:e=>e.popupProps,popupElement:e=>e.popupElement,positionerElement:e=>e.positionerElement};export{m as a,c,P as p};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{m as e}from"./__vite-browser-external-
|
|
1
|
+
import{m as e}from"./__vite-browser-external-CVIGknXl.js";const o=[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]],a=e("terminal",o);export{a as T};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{m as a}from"./__vite-browser-external-
|
|
1
|
+
import{m as a}from"./__vite-browser-external-CVIGknXl.js";const t=[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]],o=a("trash-2",t);export{o as T};
|
package/dashboard/dist/assets/{use-community-stats-CTB_uHWV.js → use-community-stats-D90Fy2_j.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as p,g as N,b as M}from"./__vite-browser-external-
|
|
1
|
+
import{r as p,g as N,b as M}from"./__vite-browser-external-CVIGknXl.js";const D=6e3,S=2500,E=100;function h(t,r){let o;const n=new Promise((a,i)=>{o=setTimeout(()=>i(new Error("landing stats timeout")),r)});return Promise.race([t,n]).finally(()=>{o!=null&&clearTimeout(o)})}const A=5*6e4,P=1440*6e4,k="tokentracker:community-stats:v2";let s=null;function C(t){const r=Number(t?.tokenFloor)||0,o=Number(t?.totalEntries)||0;return!(r>0)||!(o>0)?null:{tokenFloor:r,totalEntries:o,top:Array.isArray(t?.top)?t.top:[],topModels:Array.isArray(t?.topModels)?t.topModels:[],providers:Array.isArray(t?.providers)?t.providers:[],dailyGrowth:Array.isArray(t?.dailyGrowth)?t.dailyGrowth:[],tokenMix:Array.isArray(t?.tokenMix)?t.tokenMix:[],userDistribution:Array.isArray(t?.userDistribution)?t.userDistribution:[],platforms:Array.isArray(t?.platforms)?t.platforms:[],activeDevelopersTotal:Number(t?.activeDevelopersTotal)||0,activeDevelopers30d:Number(t?.activeDevelopers30d)||0,tokens30d:Number(t?.tokens30d)||0,tokenGrowthPct:t?.tokenGrowthPct!=null&&Number.isFinite(Number(t.tokenGrowthPct))?Number(t.tokenGrowthPct):null,developerGrowthPct:t?.developerGrowthPct!=null&&Number.isFinite(Number(t.developerGrowthPct))?Number(t.developerGrowthPct):null,generatedAt:typeof t?.generatedAt=="string"?t.generatedAt:null}}function G(){if(typeof window>"u"||!window.localStorage)return null;try{const t=JSON.parse(window.localStorage.getItem(k)||"null"),r=Number(t?.cachedAt)||0,o=C(t?.data),n=Date.now()-r;return!o||n<0||n>P?null:{data:o,isFresh:n<A}}catch{return null}}function I(t){if(!(typeof window>"u"||!window.localStorage))try{window.localStorage.setItem(k,JSON.stringify({cachedAt:Date.now(),data:t}))}catch{}}function F(){if(s&&Date.now()-s.at<A)return s.promise;const t=Promise.all([h(N({period:"total",limit:E,offset:0}),D),h(M(),S).catch(()=>null)]);return s={at:Date.now(),promise:t},t.catch(()=>{s?.promise===t&&(s=null)}),t}function O({enabled:t=!0}={}){const[r]=p.useState(()=>G()),[o,n]=p.useState(()=>r?{status:"ready",...r.data}:{status:"loading",tokenFloor:null,totalEntries:null,top:[]});return p.useEffect(()=>{if(!t||r?.isFresh)return;let a=!1,i=null,u=null;const y=async()=>{try{const[l,e]=await F();if(a)return;const c=Array.isArray(l?.entries)?l.entries:[],b=c.reduce((m,T)=>m+(Number(T?.total_tokens)||0),0),d=Number(e?.total_tokens)||0;d>0||(s=null);const w=Number(r?.data?.tokenFloor)||0,f=d>0?d:w>0?w:b;if(!c.length||!(f>0)){n(m=>({...m,status:"error"}));return}const g=Array.isArray(e?.top_models)?e.top_models:r?.data?.topModels||[],_={tokenFloor:f,totalEntries:Number(l?.total_entries)||c.length,top:c.slice(0,3),topModels:g,providers:Array.isArray(e?.providers)?e.providers:[],dailyGrowth:Array.isArray(e?.daily_growth)?e.daily_growth:[],tokenMix:Array.isArray(e?.token_mix)?e.token_mix:[],userDistribution:Array.isArray(e?.user_distribution)?e.user_distribution:[],platforms:Array.isArray(e?.platforms)?e.platforms:[],activeDevelopersTotal:Number(e?.active_developers_total)||0,activeDevelopers30d:Number(e?.active_developers_30d)||0,tokens30d:Number(e?.tokens_30d)||0,tokenGrowthPct:e?.token_growth_pct==null?null:Number(e.token_growth_pct),developerGrowthPct:e?.developer_growth_pct==null?null:Number(e.developer_growth_pct),generatedAt:typeof e?.generated_at=="string"?e.generated_at:null};n({status:"ready",..._}),d>0&&I(_)}catch{a||n(e=>e.status==="ready"?e:{...e,status:"error"})}};return typeof window<"u"&&"requestIdleCallback"in window?i=window.requestIdleCallback(y,{timeout:1500}):u=setTimeout(y,400),()=>{a=!0,i!=null&&typeof window.cancelIdleCallback=="function"&&window.cancelIdleCallback(i),u!=null&&clearTimeout(u)}},[t,r]),o}export{O as u};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as a,q as M,t as B,v as q,w as G}from"./__vite-browser-external-CVIGknXl.js";import{L as F}from"./limits-providers-BLzMyCiy.js";const l=F,g="tt.limits.providerOrder",A="tt.limits.providerVisibility",E="tt.limits.displayMode",I="tt.limits.showSubscriptions",m="tt.limits.updatedAt",V="limitsPreferences",H="limitsDisplayMode",S=Object.freeze({USED:"used",REMAINING:"remaining"}),O=new Set(Object.values(S)),_=new Set([g,A,E,I,m]);function v(){return[...l]}function h(){return Object.fromEntries(l.map(e=>[e,!0]))}function N(e){const t=[];if(Array.isArray(e))for(const o of e)l.includes(o)&&!t.includes(o)&&t.push(o);for(const o of l)t.includes(o)||t.push(o);return t}function k(e){const t=h();if(!e||typeof e!="object"||Array.isArray(e))return t;for(const o of l)typeof e[o]=="boolean"&&(t[o]=e[o]);return t}function W(e){return O.has(e)?e:S.USED}function P(e){return typeof e=="boolean"?e:!0}function w(e){if(e!=null){if(typeof e=="number")return Number.isSafeInteger(e)?e:void 0;if(typeof e=="string"){const t=e.trim();if(t==="")return;const o=Number(t);return Number.isSafeInteger(o)?o:void 0}}}function y(e={}){const t=e&&typeof e=="object"?e:{};return{displayMode:W(t.displayMode),providerOrder:N(t.providerOrder),providerVisibility:k(t.providerVisibility),showSubscriptions:P(t.showSubscriptions),updatedAt:w(t.updatedAt)}}function Q(){if(typeof window>"u")return v();try{const e=window.localStorage.getItem(g);return N(e?JSON.parse(e):void 0)}catch{return v()}}function X(){if(typeof window>"u")return h();try{const e=window.localStorage.getItem(A);return k(e?JSON.parse(e):void 0)}catch{return h()}}function Z(){if(typeof window>"u")return S.USED;try{const e=window.localStorage.getItem(E);return O.has(e)?e:S.USED}catch{return S.USED}}function $(){if(typeof window>"u")return!0;try{const e=window.localStorage.getItem(I);return e===null?!0:P(JSON.parse(e))}catch{return!0}}function ee(){if(!(typeof window>"u"))try{return w(window.localStorage.getItem(m))}catch{return}}function te(){if(typeof window>"u")return!1;try{for(const e of _)if(window.localStorage.getItem(e)!==null)return!0}catch{return!1}return!1}function b(){return y({displayMode:Z(),providerOrder:Q(),providerVisibility:X(),showSubscriptions:$(),updatedAt:ee()})}function re(e){if(typeof window>"u")return;const t=y(e);try{window.localStorage.setItem(g,JSON.stringify(t.providerOrder)),window.localStorage.setItem(A,JSON.stringify(t.providerVisibility)),window.localStorage.setItem(E,t.displayMode),window.localStorage.setItem(I,JSON.stringify(t.showSubscriptions)),t.updatedAt===void 0?window.localStorage.removeItem(m):window.localStorage.setItem(m,String(t.updatedAt))}catch(o){console.warn("[tokentracker] limits preferences localStorage write failed:",o)}}function ie(e){const t=y(e);return{displayMode:t.displayMode,providerOrder:[...t.providerOrder],providerVisibility:{...t.providerVisibility},showSubscriptions:t.showSubscriptions,updatedAt:t.updatedAt??null}}function ne(...e){let t;for(const d of e){const c=w(d);c!==void 0&&(t=t===void 0?c:Math.max(t,c))}const o=Date.now();return t!==void 0&&o<=t?t+1:o}function oe(e,t){return e.length===t.length&&e.every((o,d)=>o===t[d])}function se(e,t){return l.every(o=>e[o]===t[o])}function U(e,t){return e.displayMode===t.displayMode&&oe(e.providerOrder,t.providerOrder)&&se(e.providerVisibility,t.providerVisibility)&&e.showSubscriptions===t.showSubscriptions}function de(e,t){return U(e,t)&&w(e.updatedAt)===w(t.updatedAt)}function L(e,t){const o=w(e.updatedAt),d=w(t.updatedAt);return o!==void 0&&(d===void 0||o>d)}function ce(){const[e,t]=a.useState(b),o=a.useRef(e),d=a.useCallback((i,r={})=>{const n=y(i);return o.current=n,t(n),r.writeLocal&&re(n),n},[]),c=a.useCallback(i=>{M()&&B(V,ie(i))},[]),u=a.useCallback(i=>{const r=b(),n=L(r,o.current)?d(r):o.current,s=y(i(n));if(U(n,s))return;const f=ne(r.updatedAt,n.updatedAt),p=d({...s,updatedAt:f},{writeLocal:!0});c(p)},[d,c]),C=a.useCallback(i=>{O.has(i)&&u(r=>({...r,displayMode:i}))},[u]),x=a.useCallback(i=>{u(r=>({...r,showSubscriptions:!!i}))},[u]),D=a.useCallback(i=>{if(!O.has(i))return;const r=b();if(r.updatedAt!==void 0){d(r);return}d({...r,displayMode:i,updatedAt:void 0},{writeLocal:!0})},[d]);a.useEffect(()=>{if(!M())return;const i=q(r=>{const n=r?.[V];if(n&&typeof n=="object"){const s=y(n);if(!te()){d(s,{writeLocal:!0});return}const f=b();if(L(s,f))d(s,{writeLocal:!0});else{const p=d(f);de(s,f)||c(p)}return}D(r?.[H])});return G(),i},[D,d,c]),a.useEffect(()=>{if(typeof window>"u")return;const i=r=>{(r.key===null||_.has(r.key))&&d(b())};return window.addEventListener("storage",i),()=>window.removeEventListener("storage",i)},[d]);const R=a.useCallback(i=>{l.includes(i)&&u(r=>({...r,providerVisibility:{...r.providerVisibility,[i]:!r.providerVisibility[i]}}))},[u]),Y=a.useCallback(i=>{u(r=>{const n=r.providerOrder.indexOf(i);if(n<=0)return r;const s=[...r.providerOrder];return[s[n-1],s[n]]=[s[n],s[n-1]],{...r,providerOrder:s}})},[u]),T=a.useCallback(i=>{u(r=>{const n=r.providerOrder.indexOf(i);if(n<0||n>=r.providerOrder.length-1)return r;const s=[...r.providerOrder];return[s[n],s[n+1]]=[s[n+1],s[n]],{...r,providerOrder:s}})},[u]),z=a.useCallback((i,r)=>{i!==r&&u(n=>{const s=n.providerOrder.indexOf(i),f=n.providerOrder.indexOf(r);if(s<0||f<0)return n;const p=[...n.providerOrder],[J]=p.splice(s,1);return p.splice(f,0,J),{...n,providerOrder:p}})},[u]),K=a.useCallback(()=>{u(()=>({displayMode:S.USED,providerOrder:v(),providerVisibility:h(),showSubscriptions:!0}))},[u]),j=a.useMemo(()=>e.providerOrder.filter(i=>e.providerVisibility[i]!==!1),[e.providerOrder,e.providerVisibility]);return{order:e.providerOrder,visibility:e.providerVisibility,displayMode:e.displayMode,showSubscriptions:e.showSubscriptions,setDisplayMode:C,setShowSubscriptions:x,visibleOrdered:j,toggle:R,moveUp:Y,moveDown:T,moveToward:z,reset:K}}export{S as L,ce as u};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as f}from"./__vite-browser-external-
|
|
1
|
+
import{r as f}from"./__vite-browser-external-CVIGknXl.js";function O(t){if(typeof window>"u")return null;try{const n=window.localStorage.getItem(t);if(!n)return null;const i=JSON.parse(n);return Array.isArray(i)?i.filter(o=>typeof o=="string"):null}catch{return null}}function m(t,n){if(!(typeof window>"u"))try{window.localStorage.setItem(t,JSON.stringify(n))}catch{}}function S(t,n){if(!t)return n;const i=new Set(n),o=t.filter(u=>i.has(u)),c=n.filter(u=>!o.includes(u));return[...o,...c]}function p(t,n){const i=f.useMemo(()=>n.join("|"),[n]),[o,c]=f.useState(()=>S(O(t),n));f.useEffect(()=>{c(r=>{const e=S(r,n);return e.length===r.length&&e.every((l,d)=>l===r[d])?r:(m(t,e),e)})},[i,n,t]);const u=f.useCallback((r,e)=>{!r||!e||r===e||c(s=>{const l=s.indexOf(r),d=s.indexOf(e);if(l===-1||d===-1)return s;const w=s.slice(),[h]=w.splice(l,1);return w.splice(d,0,h),m(t,w),w})},[t]),a=f.useCallback(()=>{m(t,n),c(n)},[t,n]);return{order:o,reorder:u,reset:a}}export{p as u};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as o}from"./__vite-browser-external-CVIGknXl.js";import{h as r,i as t,p as s}from"./react-D_AcI466.js";function i(){!r.current&&t();const[e]=o.useState(s.current);return e}export{i as u};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{m as u,r as n}from"./__vite-browser-external-
|
|
1
|
+
import{m as u,r as n}from"./__vite-browser-external-CVIGknXl.js";const f=[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]],E=u("pencil",f),i="tt.qualityPerDollar.enabled";function l(){if(typeof window>"u")return!1;try{return window.localStorage.getItem(i)==="1"}catch{return!1}}function y(){const[r,o]=n.useState(l);n.useEffect(()=>{if(typeof window>"u")return;const t=e=>{(e.key===null||e.key===i)&&o(l())};return window.addEventListener("storage",t),()=>window.removeEventListener("storage",t)},[]);const a=n.useCallback(t=>{const e=!!t;o(e);try{window.localStorage.setItem(i,e?"1":"0")}catch{}},[]),s=n.useCallback(()=>a(!l()),[a]);return{enabled:r,setEnabled:a,toggle:s}}const d="tt.sessionEfficiency.enabled";function c(){if(typeof window>"u")return!1;try{return window.localStorage.getItem(d)==="1"}catch{return!1}}function g(){const[r,o]=n.useState(c);n.useEffect(()=>{if(typeof window>"u")return;const t=e=>{(e.key===null||e.key===d)&&o(c())};return window.addEventListener("storage",t),()=>window.removeEventListener("storage",t)},[]);const a=n.useCallback(t=>{const e=!!t;o(e);try{window.localStorage.setItem(d,e?"1":"0")}catch{}},[]),s=n.useCallback(()=>a(!c()),[a]);return{enabled:r,setEnabled:a,toggle:s}}export{E as P,g as a,y as u};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{d as y,u as l,e as A,M as p,b as h,f as C,g as V,j as u}from"./react-
|
|
1
|
+
import{d as y,u as l,e as A,M as p,b as h,f as C,g as V,j as u}from"./react-D_AcI466.js";import{r as f}from"./__vite-browser-external-CVIGknXl.js";function x(...t){const e=!Array.isArray(t[0]),n=e?0:-1,o=t[0+n],s=t[1+n],c=t[2+n],r=t[3+n],a=y(s,c,r);return e?a(o):a}function E(t){const e=l(()=>A(t)),{isStatic:n}=f.useContext(p);if(n){const[,o]=f.useState(t);f.useEffect(()=>e.on("change",o),[])}return e}function m(t,e){const n=E(e()),o=()=>n.set(e());return o(),h(()=>{const s=()=>V.preRender(o,!1,!0),c=t.map(r=>r.on("change",s));return()=>{c.forEach(r=>r()),C(o)}}),n}function L(t){u.current=[],t();const e=m(u.current,t);return u.current=void 0,e}function g(t,e,n,o){if(typeof t=="function")return L(t);const c=typeof e=="function"?e:x(e,n,o),r=Array.isArray(t)?i(t,c):i([t],([d])=>c(d)),a=Array.isArray(t)?void 0:t.accelerate;return a&&!a.isTransformed&&typeof e!="function"&&Array.isArray(n)&&o?.clamp!==!1&&(r.accelerate={...a,times:e,keyframes:n,isTransformed:!0}),r}function i(t,e){const n=l(()=>[]);return m(t,()=>{n.length=0;const o=t.length;for(let s=0;s<o;s++)n[s]=t[s].get();return e(n)})}export{g as a,E as u};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{q as b,ac as v,r as c,c as g,ad as F,ae as x,af as f}from"./__vite-browser-external-CVIGknXl.js";import{l as M}from"./limits-providers-BLzMyCiy.js";const S="native:notificationPermission";let E=null;function N(){return typeof window<"u"&&!!window.chrome?.webview}function K(){return b()?E||"unknown":N()?"granted":typeof Notification>"u"?"unsupported":Notification.permission}function L(e){if(typeof window>"u")return()=>{};const i=t=>{const a=t?.detail?.status;typeof a=="string"&&(E=a),e(K())};return window.addEventListener(S,i),e(K()),b()&&v({type:"getNotificationStatus"}),()=>window.removeEventListener(S,i)}async function I(){if(b()){v({type:"requestNotificationPermission"});return}N()||typeof Notification<"u"&&Notification.permission==="default"&&await Notification.requestPermission().catch(()=>"denied")}const p="tt.limitAlerts.enabled";function O(){try{return window.localStorage.getItem(p)==="1"}catch{return!1}}function U(){const[e,i]=c.useState(O),[t,a]=c.useState("unknown");c.useEffect(()=>L(a),[]);const y=c.useCallback(async n=>{const l=!!n;l&&await I();try{window.localStorage.setItem(p,l?"1":"0")}catch{}i(l)},[]);return{enabled:e,setEnabled:y,permissionBlocked:t==="denied"}}function A(e,i){if(!(e>0))return null;const t=(e-i)/e;return Number.isFinite(t)?Math.min(Math.max(t,0),1):null}function z(e,i,t=.03){return e>i+t}function D(e){const i=Math.max(0,Math.floor(e)),t=Math.floor(i/3600);return t>24?`${Math.floor(t/24)}d`:t>0?`${t}h`:`${Math.floor(i/60)}m`}function q(e,i){if(typeof e.windowSeconds=="number")return e.windowSeconds;if(e.windowSecondsField&&i){const t=i[e.windowSecondsField];return typeof t=="number"&&t>0?t:null}return null}function j(e){return e==null?NaN:typeof e=="number"?e*1e3:Date.parse(e)}function C({usedPercent:e,windowSeconds:i,resetMs:t,mode:a,now:y=Date.now()}){const n=Math.min(Math.max(Number(e)||0,0),100)/100,l={pacePercent:null,paceOver:!1,expectedPercent:null,runsOutEta:null,projectedEnd:null};if(!(i>0)||!Number.isFinite(t))return l;const r=Math.max(0,(t-y)/1e3),s=A(i,r);if(s==null)return l;if(l.expectedPercent=Math.round(s*100),l.paceOver=z(n,s),n>=.05){const u=a==="remaining"?1-s:s;l.pacePercent=u*100}if(s>.02&&n>0){const u=i*s,w=n/u,m=n/s;m>=1&&w>0?l.runsOutEta=D((1-n)/w):l.projectedEnd=Math.round(Math.min(m,1)*100)}return l}const R={claude:{windows(e){const i=Array.isArray(e.weekly_scoped)?e.weekly_scoped.map(t=>({key:`scoped-${t.label}`,label:t.label,window:t,pctField:"utilization",resetField:"resets_at",windowSeconds:604800})):[];return[{key:"5h",labelKey:"limits.label.claude_5h",window:e.five_hour,pctField:"utilization",resetField:"resets_at",windowSeconds:5*3600},{key:"7d",labelKey:"limits.label.claude_7d",window:e.seven_day,pctField:"utilization",resetField:"resets_at",windowSeconds:7*86400},{key:"opus",labelKey:"limits.label.claude_opus",window:e.seven_day_opus,pctField:"utilization",resetField:"resets_at",windowSeconds:7*86400},...i]}},codex:{extra:"codex_meta",windows(e){return[{key:"5h",labelKey:"limits.label.codex_5h",window:e.primary_window,windowSecondsField:"limit_window_seconds"},{key:"7d",labelKey:"limits.label.codex_7d",window:e.secondary_window,windowSecondsField:"limit_window_seconds"},{key:"credits",labelKey:"limits.label.codex_credits",window:e.credit_window},{key:"spark-5h",labelKey:"limits.label.codex_spark_5h",window:e.spark_primary_window,windowSecondsField:"limit_window_seconds"},{key:"spark-7d",labelKey:"limits.label.codex_spark_7d",window:e.spark_secondary_window,windowSecondsField:"limit_window_seconds"}]}},cursor:{windows(e){return[{key:"plan",labelKey:"limits.label.cursor_plan",window:e.primary_window,windowSecondsField:"limit_window_seconds"},{key:"auto",labelKey:"limits.label.cursor_auto",window:e.secondary_window,windowSecondsField:"limit_window_seconds"},{key:"api",labelKey:"limits.label.cursor_api",window:e.tertiary_window,windowSecondsField:"limit_window_seconds"},{key:"grok-bot",labelKey:"limits.label.cursor_grok_bot",window:e.quaternary_window,windowSecondsField:"limit_window_seconds"}]}},gemini:{windows(e){return[{key:"pro",labelKey:"limits.label.gemini_pro",window:e.primary_window},{key:"flash",labelKey:"limits.label.gemini_flash",window:e.secondary_window},{key:"lite",labelKey:"limits.label.gemini_lite",window:e.tertiary_window}]}},kimi:{extra:"kimi_parallel",windows(e){return[{key:"weekly",labelKey:"limits.label.kimi_weekly",window:e.primary_window,windowSeconds:7*86400},{key:"5h",labelKey:"limits.label.kimi_5h",window:e.secondary_window,windowSeconds:5*3600},{key:"total",labelKey:"limits.label.kimi_total",window:e.tertiary_window}]}},kiro:{extra:"kiro_credits",windows(e){return[{key:"month",labelKey:"limits.label.kiro_month",window:e.primary_window},{key:"bonus",labelKey:"limits.label.kiro_bonus",window:e.secondary_window}]}},grok:{windows(e){const i=typeof e.period_type=="string"?e.period_type:null,t=i==="weekly"?"limits.label.grok_week":i==="daily"?"limits.label.grok_day":"limits.label.grok_month",a=i==="weekly"?7*86400:i==="daily"?86400:void 0;return[{key:i==="weekly"?"week":i==="daily"?"day":"month",labelKey:t,window:e.primary_window,windowSeconds:a},{key:"ondemand",labelKey:"limits.label.grok_ondemand",window:e.secondary_window}]}},antigravity:{windows(e){return[{key:"claude-weekly",labelKey:"limits.label.antigravity_claude_weekly",window:e.primary_window},{key:"claude-5h",labelKey:"limits.label.antigravity_claude_5h",window:e.secondary_window},{key:"gemini-weekly",labelKey:"limits.label.antigravity_gemini_weekly",window:e.tertiary_window},{key:"gemini-5h",labelKey:"limits.label.antigravity_gemini_5h",window:e.quaternary_window}]}},copilot:{extra:"copilot_otel",windows(e){return[{key:"premium",labelKey:"limits.label.copilot_premium",window:e.primary_window},{key:"chat",labelKey:"limits.label.copilot_chat",window:e.secondary_window}]}},zcode:{windows(e){return e.plan_kind==="coding-plan"?[{key:"5h",labelKey:"limits.label.zcode_5h",window:e.primary_window},{key:"weekly",labelKey:"limits.label.zcode_weekly",window:e.secondary_window},{key:"tools",labelKey:"limits.label.zcode_tools",window:e.tertiary_window}]:[{key:"glm52",labelKey:"limits.label.zcode_glm52",window:e.primary_window},{key:"glm5t",labelKey:"limits.label.zcode_glm5t",window:e.secondary_window}]}},opencodeGo:{windows(e){return[{key:"5h",labelKey:"limits.label.opencode_go_5h",window:e.primary_window},{key:"weekly",labelKey:"limits.label.opencode_go_weekly",window:e.secondary_window},{key:"monthly",labelKey:"limits.label.opencode_go_monthly",window:e.tertiary_window}]}},qoder:{windows(e){return[{key:"credits",labelKey:"limits.label.qoder_credits",window:e.primary_window},{key:"ultimate",labelKey:"limits.label.qoder_ultimate",window:e.secondary_window,timeKind:"expiry"}]}},qoderCn:{windows(e){return[{key:"credits",labelKey:"limits.label.qoder_cn_credits",window:e.primary_window},{key:"ultimate",labelKey:"limits.label.qoder_cn_ultimate",window:e.secondary_window,timeKind:"expiry"}]}},codingPlan:{windows(e){return[{key:"5h",labelKey:"limits.label.ark_coding_plan_5h",window:e.primary_window},{key:"weekly",labelKey:"limits.label.ark_coding_plan_weekly",window:e.secondary_window},{key:"monthly",labelKey:"limits.label.ark_coding_plan_monthly",window:e.tertiary_window}]}}},P="tt.limitAlerts.cycles.v1";function T(){try{return JSON.parse(window.localStorage.getItem(P)||"{}")}catch{return{}}}function $(e){try{window.localStorage.setItem(P,JSON.stringify(e))}catch{}}function B(e,{now:i=Date.now()}={}){const t=[],a=R;for(const[y,n]of Object.entries(e||{})){const l=a[y];if(!(!n?.configured||n.error||!l))for(const r of l.windows(n)){if(!r.window)continue;const s=Number(r.pctField==="utilization"?r.window.utilization:r.window.used_percent),u=r.resetField==="resets_at"?r.window.resets_at:r.window.reset_at,w=j(u),m=C({usedPercent:s,windowSeconds:q(r,r.window),resetMs:w,mode:"used",now:i});!m.runsOutEta||!m.paceOver||s<20||!(w>i)||t.push({id:`${y}:${r.key}:${w}`,providerId:y,windowKey:r.key,resetMs:w,usedPercent:s,runsOutEta:m.runsOutEta})}}return t}function V(e){const i=T(),t=B(e);for(const n of t){if(i[n.id])continue;const l=M(n.providerId),r=g("limits.alert.title",{provider:l}),s=g("limits.alert.body",{eta:n.runsOutEta,percent:Math.round(n.usedPercent)});let u=F({title:r,body:s,id:n.id});!u&&typeof Notification<"u"&&Notification.permission==="granted"&&(new Notification(r,{body:s,tag:n.id}),u=!0),u&&(i[n.id]=Date.now())}const a=Date.now()-864e5,y=Object.fromEntries(Object.entries(i).filter(([n,l])=>{const r=Number(n.split(":").at(-1));return Number.isFinite(r)?r>=a:Number(l)>=a}).slice(-100));return $(y),t.length}function W(e){const i=!!e?.initialState,[t,a]=c.useState(()=>i?e?.initialState?.data??null:null),[y,n]=c.useState(()=>i?e?.initialState?.error??null:null),[l,r]=c.useState(!i),s=!!e?.initialRefresh,u=!!e?.publishToPreloadCache;c.useEffect(()=>{if(!(!t||typeof window>"u"))try{window.localStorage.getItem(p)==="1"&&V(t)}catch{}},[t]);const w=c.useCallback((o,d)=>{!u||!o||typeof o!="object"||x(o,{source:d})},[u]),m=c.useCallback(async()=>{try{const o=await f({refresh:!0}),d=o&&typeof o=="object"?o:null;a(d),n(null),w(d,"manual-refresh")}catch(o){n(o?.message||String(o))}},[w]),k=c.useCallback(async()=>{try{const o=await f(),d=o&&typeof o=="object"?o:null;a(d),n(null),w(d,"page-load")}catch(o){n(o?.message||String(o))}},[w]);return c.useEffect(()=>{if(typeof window>"u"||typeof document>"u")return;const o=15e3;let d=Date.now();const _=()=>{if(document.visibilityState!=="visible")return;const h=Date.now();h-d<o||(d=h,k())};return window.addEventListener("focus",_),document.addEventListener("visibilitychange",_),()=>{window.removeEventListener("focus",_),document.removeEventListener("visibilitychange",_)}},[k]),c.useEffect(()=>{if(i&&!s)return;let o=!1;return(async()=>{try{const d=await f();if(o)return;const _=d&&typeof d=="object"?d:null;a(_),n(null),w(_,"page-load")}catch(d){if(o)return;n(d?.message||String(d))}finally{o||r(!1)}})(),()=>{o=!0}},[i,s,w]),{data:t,error:y,isLoading:l,refresh:m}}export{R as P,q as a,U as b,C as c,j as r,V as s,W as u};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e,C as t,D as r,x as c}from"./__vite-browser-external-
|
|
1
|
+
import{r as e,C as t,D as r,x as c}from"./__vite-browser-external-CVIGknXl.js";const s=Object.freeze({currency:c,rate:1,symbol:"$",rates:{...r},rateSource:"default",rateFetchedAt:null,setCurrency:()=>{}});function a(){return e.useContext(t)??s}export{a as u};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e,T as r,n,o as a,p as s}from"./__vite-browser-external-
|
|
1
|
+
import{r as e,T as r,n,o as a,p as s}from"./__vite-browser-external-CVIGknXl.js";const T=Object.freeze({mode:n.COMPACT,setMode:()=>{},formatTokens:(o,t={})=>s(o,t),formatTokensTooltip:(o,t={})=>a(o,t)});function f(){return e.useContext(r)??T}export{f as u};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{m as a}from"./__vite-browser-external-
|
|
1
|
+
import{m as a}from"./__vite-browser-external-CVIGknXl.js";const o=[["path",{d:"M15.914 4a1.5 1.5 0 00-2.474-1.561l-9 9A1.5 1.5 0 005.5 14h4.002a.5.5 0 01.471.666L8.086 20a1.5 1.5 0 002.475 1.56l9-9A1.5 1.5 0 0018.5 10h-3.997a.5.5 0 01-.472-.667z",key:"1v7up4"}]],e=a("zap",o);export{e as Z};
|
|
@@ -264,8 +264,8 @@
|
|
|
264
264
|
]
|
|
265
265
|
}
|
|
266
266
|
</script>
|
|
267
|
-
<script type="module" crossorigin src="/assets/__vite-browser-external-
|
|
268
|
-
<link rel="stylesheet" crossorigin href="/assets/__vite-browser-external-
|
|
267
|
+
<script type="module" crossorigin src="/assets/__vite-browser-external-CVIGknXl.js"></script>
|
|
268
|
+
<link rel="stylesheet" crossorigin href="/assets/__vite-browser-external-BHz2N7Ih.css">
|
|
269
269
|
</head>
|
|
270
270
|
<body>
|
|
271
271
|
<main class="aeo-seed-content" aria-label="Token Tracker AI-readable summary">
|
|
@@ -165,8 +165,8 @@
|
|
|
165
165
|
]
|
|
166
166
|
}
|
|
167
167
|
</script>
|
|
168
|
-
<script type="module" crossorigin src="/assets/__vite-browser-external-
|
|
169
|
-
<link rel="stylesheet" crossorigin href="/assets/__vite-browser-external-
|
|
168
|
+
<script type="module" crossorigin src="/assets/__vite-browser-external-CVIGknXl.js"></script>
|
|
169
|
+
<link rel="stylesheet" crossorigin href="/assets/__vite-browser-external-BHz2N7Ih.css">
|
|
170
170
|
</head>
|
|
171
171
|
<body>
|
|
172
172
|
<main class="aeo-seed-content" aria-label="Claude IP Check AI-readable summary">
|
|
@@ -136,8 +136,8 @@
|
|
|
136
136
|
]
|
|
137
137
|
}
|
|
138
138
|
</script>
|
|
139
|
-
<script type="module" crossorigin src="/assets/__vite-browser-external-
|
|
140
|
-
<link rel="stylesheet" crossorigin href="/assets/__vite-browser-external-
|
|
139
|
+
<script type="module" crossorigin src="/assets/__vite-browser-external-CVIGknXl.js"></script>
|
|
140
|
+
<link rel="stylesheet" crossorigin href="/assets/__vite-browser-external-BHz2N7Ih.css">
|
|
141
141
|
</head>
|
|
142
142
|
<body>
|
|
143
143
|
<main class="aeo-seed-content" aria-label="AI Coding Token Usage Leaderboard AI-readable summary">
|
|
@@ -75,8 +75,8 @@
|
|
|
75
75
|
"description": "Shareable Token Tracker dashboard snapshot."
|
|
76
76
|
}
|
|
77
77
|
</script>
|
|
78
|
-
<script type="module" crossorigin src="/assets/__vite-browser-external-
|
|
79
|
-
<link rel="stylesheet" crossorigin href="/assets/__vite-browser-external-
|
|
78
|
+
<script type="module" crossorigin src="/assets/__vite-browser-external-CVIGknXl.js"></script>
|
|
79
|
+
<link rel="stylesheet" crossorigin href="/assets/__vite-browser-external-BHz2N7Ih.css">
|
|
80
80
|
</head>
|
|
81
81
|
<body>
|
|
82
82
|
<main class="aeo-seed-content" aria-label="Token Tracker share page summary">
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tokentracker-cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.94.0",
|
|
4
4
|
"description": "Local-first AI coding token usage and cost tracker for 34 tools, with a dashboard, desktop pet, widgets, achievements, and native macOS/Windows apps.",
|
|
5
5
|
"main": "src/cli.js",
|
|
6
6
|
"bin": {
|
package/src/commands/status.js
CHANGED
|
@@ -1215,8 +1215,10 @@ function formatCopilotLines({ token, otel, sessionStore, appDb }) {
|
|
|
1215
1215
|
const appDbState = appDb?.app_db_has_file
|
|
1216
1216
|
? `${appDb.app_db_mode || "set"} (${(appDb.app_db_paths || []).join(", ")})`
|
|
1217
1217
|
: `not found (${appDb?.app_db_path || "unknown"})`;
|
|
1218
|
+
const otelLocation =
|
|
1219
|
+
otel.otel_path || otel.otel_detected_paths?.[0] || otel.otel_default_dir;
|
|
1218
1220
|
const usageState = otel.otel_has_files
|
|
1219
|
-
? `set (${
|
|
1221
|
+
? `set (${otelLocation})`
|
|
1220
1222
|
: otel.otel_enabled
|
|
1221
1223
|
? "enabled but no files yet"
|
|
1222
1224
|
: "unset (OTEL export not enabled)";
|
package/src/commands/sync.js
CHANGED
|
@@ -26,6 +26,7 @@ const {
|
|
|
26
26
|
listGeminiSessionFiles,
|
|
27
27
|
listOpencodeMessageFiles,
|
|
28
28
|
readOpencodeDbMessages,
|
|
29
|
+
readOpencodeDbMessagesIncremental,
|
|
29
30
|
readMimoDbMessages,
|
|
30
31
|
readZcodeDbMessages,
|
|
31
32
|
hasZcodeNativeUsageSchema,
|
|
@@ -1164,11 +1165,15 @@ async function cmdSync(argv, context = {}) {
|
|
|
1164
1165
|
let dbResult = { messagesProcessed: 0, eventsAggregated: 0, bucketsQueued: 0 };
|
|
1165
1166
|
if (dbDir) {
|
|
1166
1167
|
const dbPath = path.join(dbDir, "opencode.db");
|
|
1167
|
-
const
|
|
1168
|
-
|
|
1168
|
+
const dbRead = readOpencodeDbMessagesIncremental(
|
|
1169
|
+
dbPath,
|
|
1170
|
+
cursors?.opencode?.dbCursor,
|
|
1171
|
+
);
|
|
1172
|
+
if (dbRead.messages.length > 0 || dbRead.cursor) {
|
|
1169
1173
|
dbResult = await parseOpencodeDbIncremental({
|
|
1170
1174
|
...options,
|
|
1171
|
-
dbMessages,
|
|
1175
|
+
dbMessages: dbRead.messages,
|
|
1176
|
+
dbCursor: dbRead.cursor,
|
|
1172
1177
|
dbPath,
|
|
1173
1178
|
});
|
|
1174
1179
|
}
|
|
@@ -568,6 +568,14 @@ async function parseCodexRolloutFile(filePath, {
|
|
|
568
568
|
let model = isResuming ? resumeState.model || null : null;
|
|
569
569
|
let provider = isResuming ? resumeState.provider || null : null;
|
|
570
570
|
let cliVersion = isResuming ? resumeState.cliVersion || null : null;
|
|
571
|
+
let forkedFromId = isResuming ? resumeState.forkedFromId || null : null;
|
|
572
|
+
let parentThreadId = isResuming ? resumeState.parentThreadId || null : null;
|
|
573
|
+
let threadSource = isResuming ? resumeState.threadSource || null : null;
|
|
574
|
+
let agentNickname = isResuming ? resumeState.agentNickname || null : null;
|
|
575
|
+
let agentRole = isResuming ? resumeState.agentRole || null : null;
|
|
576
|
+
let sessionLineageCaptured = isResuming
|
|
577
|
+
? Boolean(resumeState.sessionLineageCaptured || resumeState.sessionId)
|
|
578
|
+
: false;
|
|
571
579
|
|
|
572
580
|
const usageDeltaState = createUsageDeltaState({
|
|
573
581
|
lastTotal: isResuming ? resumeState.prevTotals || null : null,
|
|
@@ -820,10 +828,22 @@ async function parseCodexRolloutFile(filePath, {
|
|
|
820
828
|
|
|
821
829
|
if (obj.type === "session_meta") {
|
|
822
830
|
const p = obj.payload || {};
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
831
|
+
// Forked rollouts replay historical session_meta rows after their own
|
|
832
|
+
// child metadata. Only the first row describes this file's lineage.
|
|
833
|
+
if (!sessionLineageCaptured) {
|
|
834
|
+
sessionId = p.id || sessionId;
|
|
835
|
+
cwd = p.cwd || cwd;
|
|
836
|
+
cliVersion = p.cli_version || cliVersion;
|
|
837
|
+
provider = p.model_provider || provider;
|
|
838
|
+
forkedFromId = p.forked_from_id || null;
|
|
839
|
+
parentThreadId = p.parent_thread_id || null;
|
|
840
|
+
threadSource = p.thread_source || p.source || null;
|
|
841
|
+
agentNickname = p.agent_nickname || null;
|
|
842
|
+
agentRole = p.agent_role || null;
|
|
843
|
+
sessionLineageCaptured = true;
|
|
844
|
+
} else if (!sessionId) {
|
|
845
|
+
sessionId = p.id || null;
|
|
846
|
+
}
|
|
827
847
|
}
|
|
828
848
|
|
|
829
849
|
if (obj.type === "turn_context") {
|
|
@@ -878,6 +898,11 @@ async function parseCodexRolloutFile(filePath, {
|
|
|
878
898
|
model: model || provider,
|
|
879
899
|
provider,
|
|
880
900
|
version: cliVersion,
|
|
901
|
+
forkedFromId,
|
|
902
|
+
parentThreadId,
|
|
903
|
+
threadSource,
|
|
904
|
+
agentNickname,
|
|
905
|
+
agentRole,
|
|
881
906
|
filePath: primaryFilePath,
|
|
882
907
|
turnCount,
|
|
883
908
|
totals,
|
|
@@ -903,6 +928,12 @@ async function parseCodexRolloutFile(filePath, {
|
|
|
903
928
|
model,
|
|
904
929
|
provider,
|
|
905
930
|
cliVersion,
|
|
931
|
+
forkedFromId,
|
|
932
|
+
parentThreadId,
|
|
933
|
+
threadSource,
|
|
934
|
+
agentNickname,
|
|
935
|
+
agentRole,
|
|
936
|
+
sessionLineageCaptured,
|
|
906
937
|
prevTotals: usageDeltaState.lastTotal,
|
|
907
938
|
tokenUsageBaselines: snapshotUsageBaselines(usageDeltaState),
|
|
908
939
|
pendingToolNames,
|
package/src/lib/cursor-config.js
CHANGED
|
@@ -76,6 +76,18 @@ function readCursorAccessTokenFromStateDb(stateDbPath, deps = {}) {
|
|
|
76
76
|
* - other WorkOS subjects: "github|…", "oidc|…" → kept verbatim
|
|
77
77
|
*/
|
|
78
78
|
function extractCursorSessionToken({ home, platform, env, deps } = {}) {
|
|
79
|
+
const auth = extractCursorAuth({ home, platform, env, deps });
|
|
80
|
+
if (!auth) return null;
|
|
81
|
+
return { cookie: auth.cookie, userId: auth.userId };
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Extract the Cursor web session and API bearer token from Cursor's own local
|
|
86
|
+
* login state. The raw access token is needed for Cursor's first-party Connect
|
|
87
|
+
* RPCs, while callers that only need the web cookie should continue using
|
|
88
|
+
* extractCursorSessionToken so the token is not propagated unnecessarily.
|
|
89
|
+
*/
|
|
90
|
+
function extractCursorAuth({ home, platform, env, deps } = {}) {
|
|
79
91
|
const { stateDbPath, cliConfigPath } = resolveCursorPaths({ home, platform, env });
|
|
80
92
|
|
|
81
93
|
// 1. Extract JWT from SQLite
|
|
@@ -95,7 +107,7 @@ function extractCursorSessionToken({ home, platform, env, deps } = {}) {
|
|
|
95
107
|
|
|
96
108
|
// 3. Build cookie
|
|
97
109
|
const cookie = `WorkosCursorSessionToken=${userId}%3A%3A${jwt}`;
|
|
98
|
-
return { cookie, userId };
|
|
110
|
+
return { cookie, userId, accessToken: jwt };
|
|
99
111
|
}
|
|
100
112
|
|
|
101
113
|
// WorkOS OAuth subject prefixes Cursor accepts as-is in the session cookie.
|
|
@@ -136,6 +148,10 @@ function extractUserIdFromJwt(jwt) {
|
|
|
136
148
|
|
|
137
149
|
const CURSOR_CSV_URL = "https://cursor.com/api/dashboard/export-usage-events-csv?strategy=tokens";
|
|
138
150
|
const CURSOR_SUMMARY_URL = "https://cursor.com/api/usage-summary";
|
|
151
|
+
const CURSOR_RPC_ORIGIN = "https://api2.cursor.sh";
|
|
152
|
+
const CURSOR_SAND_ACCESS_URL = `${CURSOR_RPC_ORIGIN}/aiserver.v1.DashboardService/GetSandAccessStatus`;
|
|
153
|
+
const CURSOR_SAND_USAGE_URL = `${CURSOR_RPC_ORIGIN}/aiserver.v1.DashboardService/GetSandUsageStatus`;
|
|
154
|
+
const CURSOR_RPC_MAX_RESPONSE_BYTES = 64 * 1024;
|
|
139
155
|
const CURSOR_SOURCE_SCOPE = "account";
|
|
140
156
|
|
|
141
157
|
function isCursorFetchTimeout(err) {
|
|
@@ -234,6 +250,166 @@ function fetchCursorUsageSummary({ cookie, timeoutMs = 30000, fetchImpl = fetch
|
|
|
234
250
|
});
|
|
235
251
|
}
|
|
236
252
|
|
|
253
|
+
function readProtoVarint(buffer, offset) {
|
|
254
|
+
let value = 0n;
|
|
255
|
+
let shift = 0n;
|
|
256
|
+
for (let i = offset; i < buffer.length && i < offset + 10; i += 1) {
|
|
257
|
+
const byte = buffer[i];
|
|
258
|
+
value |= BigInt(byte & 0x7f) << shift;
|
|
259
|
+
if ((byte & 0x80) === 0) return { value, offset: i + 1 };
|
|
260
|
+
shift += 7n;
|
|
261
|
+
}
|
|
262
|
+
throw new Error("Cursor API returned malformed protobuf");
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
function readProtoFields(input) {
|
|
266
|
+
const buffer = Buffer.isBuffer(input) ? input : Buffer.from(input);
|
|
267
|
+
const fields = [];
|
|
268
|
+
let offset = 0;
|
|
269
|
+
while (offset < buffer.length) {
|
|
270
|
+
const tag = readProtoVarint(buffer, offset);
|
|
271
|
+
offset = tag.offset;
|
|
272
|
+
const fieldNumber = Number(tag.value >> 3n);
|
|
273
|
+
const wireType = Number(tag.value & 0x07n);
|
|
274
|
+
if (!Number.isInteger(fieldNumber) || fieldNumber <= 0) {
|
|
275
|
+
throw new Error("Cursor API returned malformed protobuf");
|
|
276
|
+
}
|
|
277
|
+
if (wireType === 0) {
|
|
278
|
+
const decoded = readProtoVarint(buffer, offset);
|
|
279
|
+
fields.push({ fieldNumber, wireType, value: decoded.value });
|
|
280
|
+
offset = decoded.offset;
|
|
281
|
+
} else if (wireType === 1) {
|
|
282
|
+
if (offset + 8 > buffer.length) throw new Error("Cursor API returned malformed protobuf");
|
|
283
|
+
fields.push({ fieldNumber, wireType, value: buffer.subarray(offset, offset + 8) });
|
|
284
|
+
offset += 8;
|
|
285
|
+
} else if (wireType === 2) {
|
|
286
|
+
const decodedLength = readProtoVarint(buffer, offset);
|
|
287
|
+
offset = decodedLength.offset;
|
|
288
|
+
const length = Number(decodedLength.value);
|
|
289
|
+
if (!Number.isSafeInteger(length) || length < 0 || offset + length > buffer.length) {
|
|
290
|
+
throw new Error("Cursor API returned malformed protobuf");
|
|
291
|
+
}
|
|
292
|
+
fields.push({ fieldNumber, wireType, value: buffer.subarray(offset, offset + length) });
|
|
293
|
+
offset += length;
|
|
294
|
+
} else if (wireType === 5) {
|
|
295
|
+
if (offset + 4 > buffer.length) throw new Error("Cursor API returned malformed protobuf");
|
|
296
|
+
fields.push({ fieldNumber, wireType, value: buffer.subarray(offset, offset + 4) });
|
|
297
|
+
offset += 4;
|
|
298
|
+
} else {
|
|
299
|
+
throw new Error("Cursor API returned unsupported protobuf wire type");
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
return fields;
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
function protoTimestampToIso(input) {
|
|
306
|
+
let seconds = null;
|
|
307
|
+
let nanos = 0n;
|
|
308
|
+
for (const field of readProtoFields(input)) {
|
|
309
|
+
if (field.fieldNumber === 1 && field.wireType === 0) seconds = field.value;
|
|
310
|
+
if (field.fieldNumber === 2 && field.wireType === 0) nanos = field.value;
|
|
311
|
+
}
|
|
312
|
+
if (seconds === null || nanos < 0n || nanos > 999_999_999n) return null;
|
|
313
|
+
const milliseconds = Number(seconds) * 1000 + Number(nanos) / 1_000_000;
|
|
314
|
+
if (!Number.isFinite(milliseconds)) return null;
|
|
315
|
+
try {
|
|
316
|
+
return new Date(milliseconds).toISOString();
|
|
317
|
+
} catch {
|
|
318
|
+
return null;
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
function decodeCursorSandAccessStatus(input) {
|
|
323
|
+
let state = 0;
|
|
324
|
+
let blockReason = 0;
|
|
325
|
+
for (const field of readProtoFields(input)) {
|
|
326
|
+
if (field.fieldNumber === 1 && field.wireType === 0) state = Number(field.value);
|
|
327
|
+
if (field.fieldNumber === 3 && field.wireType === 0) blockReason = Number(field.value);
|
|
328
|
+
}
|
|
329
|
+
return { state, blockReason, granted: state === 1 };
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
function decodeCursorSandUsageStatus(input) {
|
|
333
|
+
const result = {
|
|
334
|
+
currentPeriodStart: null,
|
|
335
|
+
nextResetAt: null,
|
|
336
|
+
usagePercent: null,
|
|
337
|
+
includedLimitZero: false,
|
|
338
|
+
availableBankedResetCount: 0,
|
|
339
|
+
usesPooledEnterpriseAllowance: false,
|
|
340
|
+
hasAvailableUsage: false,
|
|
341
|
+
hasNonZeroIncludedLimit: false,
|
|
342
|
+
};
|
|
343
|
+
for (const field of readProtoFields(input)) {
|
|
344
|
+
if (field.fieldNumber === 1 && field.wireType === 2) {
|
|
345
|
+
result.currentPeriodStart = protoTimestampToIso(field.value);
|
|
346
|
+
} else if (field.fieldNumber === 2 && field.wireType === 2) {
|
|
347
|
+
result.nextResetAt = protoTimestampToIso(field.value);
|
|
348
|
+
} else if (field.fieldNumber === 3 && field.wireType === 1) {
|
|
349
|
+
result.usagePercent = field.value.readDoubleLE(0);
|
|
350
|
+
} else if (field.fieldNumber === 4 && field.wireType === 0) {
|
|
351
|
+
result.includedLimitZero = field.value !== 0n;
|
|
352
|
+
} else if (field.fieldNumber === 5 && field.wireType === 0) {
|
|
353
|
+
result.availableBankedResetCount = Number(field.value);
|
|
354
|
+
} else if (field.fieldNumber === 6 && field.wireType === 0) {
|
|
355
|
+
result.usesPooledEnterpriseAllowance = field.value !== 0n;
|
|
356
|
+
} else if (field.fieldNumber === 7 && field.wireType === 0) {
|
|
357
|
+
result.hasAvailableUsage = field.value !== 0n;
|
|
358
|
+
} else if (field.fieldNumber === 8 && field.wireType === 0) {
|
|
359
|
+
result.hasNonZeroIncludedLimit = field.value !== 0n;
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
if (!Number.isFinite(result.usagePercent)) result.usagePercent = null;
|
|
363
|
+
return result;
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
async function fetchCursorProtoRpc({ url, accessToken, timeoutMs = 15000, fetchImpl = fetch }) {
|
|
367
|
+
const res = await fetchImpl(url, {
|
|
368
|
+
method: "POST",
|
|
369
|
+
headers: {
|
|
370
|
+
Authorization: `Bearer ${accessToken}`,
|
|
371
|
+
"Content-Type": "application/proto",
|
|
372
|
+
"Connect-Protocol-Version": "1",
|
|
373
|
+
},
|
|
374
|
+
body: Buffer.alloc(0),
|
|
375
|
+
redirect: "error",
|
|
376
|
+
signal: AbortSignal.timeout(timeoutMs),
|
|
377
|
+
});
|
|
378
|
+
if (res.status === 401 || res.status === 403) {
|
|
379
|
+
throw new Error("Cursor session expired — re-login in Cursor to refresh");
|
|
380
|
+
}
|
|
381
|
+
if (res.status !== 200) throw new Error(`Cursor API returned ${res.status}`);
|
|
382
|
+
const contentType = String(res.headers?.get?.("content-type") || "").toLowerCase();
|
|
383
|
+
if (!contentType.startsWith("application/proto")) {
|
|
384
|
+
throw new Error("Cursor API returned an unexpected response type");
|
|
385
|
+
}
|
|
386
|
+
const body = Buffer.from(await res.arrayBuffer());
|
|
387
|
+
if (body.length > CURSOR_RPC_MAX_RESPONSE_BYTES) {
|
|
388
|
+
throw new Error("Cursor API returned an oversized response");
|
|
389
|
+
}
|
|
390
|
+
return body;
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
async function fetchCursorSandAccessStatus({ accessToken, timeoutMs, fetchImpl = fetch }) {
|
|
394
|
+
const body = await fetchCursorProtoRpc({
|
|
395
|
+
url: CURSOR_SAND_ACCESS_URL,
|
|
396
|
+
accessToken,
|
|
397
|
+
timeoutMs,
|
|
398
|
+
fetchImpl,
|
|
399
|
+
});
|
|
400
|
+
return decodeCursorSandAccessStatus(body);
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
async function fetchCursorSandUsageStatus({ accessToken, timeoutMs, fetchImpl = fetch }) {
|
|
404
|
+
const body = await fetchCursorProtoRpc({
|
|
405
|
+
url: CURSOR_SAND_USAGE_URL,
|
|
406
|
+
accessToken,
|
|
407
|
+
timeoutMs,
|
|
408
|
+
fetchImpl,
|
|
409
|
+
});
|
|
410
|
+
return decodeCursorSandUsageStatus(body);
|
|
411
|
+
}
|
|
412
|
+
|
|
237
413
|
function fetchUrlRaw({ urlStr, cookie, timeoutMs = 30000, fetchImpl = fetch }) {
|
|
238
414
|
return fetchImpl(urlStr, {
|
|
239
415
|
method: "GET",
|
|
@@ -414,9 +590,14 @@ module.exports = {
|
|
|
414
590
|
resolveCursorPaths,
|
|
415
591
|
isCursorInstalled,
|
|
416
592
|
readCursorAccessTokenFromStateDb,
|
|
593
|
+
extractCursorAuth,
|
|
417
594
|
extractCursorSessionToken,
|
|
418
595
|
fetchCursorUsageCsv,
|
|
419
596
|
fetchCursorUsageSummary,
|
|
597
|
+
decodeCursorSandAccessStatus,
|
|
598
|
+
decodeCursorSandUsageStatus,
|
|
599
|
+
fetchCursorSandAccessStatus,
|
|
600
|
+
fetchCursorSandUsageStatus,
|
|
420
601
|
parseCursorCsv,
|
|
421
602
|
isCursorBillableKind,
|
|
422
603
|
normalizeCursorUsage,
|
package/src/lib/fs.js
CHANGED
|
@@ -6,12 +6,21 @@ async function ensureDir(p) {
|
|
|
6
6
|
await fs.mkdir(p, { recursive: true });
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
-
async function writeFileAtomic(filePath, content) {
|
|
9
|
+
async function writeFileAtomic(filePath, content, { mode } = {}) {
|
|
10
10
|
const dir = path.dirname(filePath);
|
|
11
11
|
await ensureDir(dir);
|
|
12
|
-
|
|
12
|
+
// Include a UUID so two writes in the same millisecond do not share a tmp
|
|
13
|
+
// path (Date.now() alone collides under concurrent writers).
|
|
14
|
+
const tmp = `${filePath}.tmp.${Date.now()}.${crypto.randomUUID()}`;
|
|
15
|
+
// mode only applies to newly created files; passing it keeps the tmp file
|
|
16
|
+
// private from creation instead of relying on a later chmod that a crash
|
|
17
|
+
// between write and chmod would skip.
|
|
13
18
|
try {
|
|
14
|
-
await fs.writeFile(
|
|
19
|
+
await fs.writeFile(
|
|
20
|
+
tmp,
|
|
21
|
+
content,
|
|
22
|
+
mode == null ? { encoding: "utf8" } : { encoding: "utf8", mode },
|
|
23
|
+
);
|
|
15
24
|
await fs.rename(tmp, filePath);
|
|
16
25
|
} catch (err) {
|
|
17
26
|
try {
|