tokentracker-cli 1.1.9 → 1.1.11

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.
Files changed (103) hide show
  1. package/dashboard/dist/assets/{AchievementBadge-BeNHapqp.js → AchievementBadge-DuEuFaXg.js} +1 -1
  2. package/dashboard/dist/assets/{AchievementsPage-vNH31cFv.js → AchievementsPage-BTTFtk_Z.js} +2 -2
  3. package/dashboard/dist/assets/{AchievementsSection-ChGSmCUP.js → AchievementsSection-BZppKteZ.js} +1 -1
  4. package/dashboard/dist/assets/{BadgeDetailModal-CN0tcpEE.js → BadgeDetailModal-TzmxXy8k.js} +1 -1
  5. package/dashboard/dist/assets/{BotAnimated-CKKYEJt-.js → BotAnimated-4hWTFjwp.js} +1 -1
  6. package/dashboard/dist/assets/{Card-Dx3Pj7SE.js → Card-HigkIm_b.js} +1 -1
  7. package/dashboard/dist/assets/{ClawdAnimated-ChJEskg4.js → ClawdAnimated-BRoihVSd.js} +2 -2
  8. package/dashboard/dist/assets/{CommandPalette-D4-sgyxP.js → CommandPalette-Bx_11gJk.js} +1 -1
  9. package/dashboard/dist/assets/{CommunityStatsModal-NUDCSEve.js → CommunityStatsModal-BjDPCBol.js} +1 -1
  10. package/dashboard/dist/assets/{ConfirmModal-q4EXjOda.js → ConfirmModal-DTo93RpG.js} +1 -1
  11. package/dashboard/dist/assets/{Controls-OjbHepPz.js → Controls-BvWTXyfI.js} +1 -1
  12. package/dashboard/dist/assets/{DashboardPage-F3swcQnu.js → DashboardPage--1_GuEr-.js} +1 -1
  13. package/dashboard/dist/assets/DevicePage-BVupGt9K.js +1 -0
  14. package/dashboard/dist/assets/{DialogClose-DSp5s5nL.js → DialogClose-BlQJpi7n.js} +1 -1
  15. package/dashboard/dist/assets/DialogDescription-DE2BF-HX.js +1 -0
  16. package/dashboard/dist/assets/{DialogTitle-M5ojVj4-.js → DialogTitle-CDmxp9ap.js} +1 -1
  17. package/dashboard/dist/assets/{FadeIn-CWDRIc_C.js → FadeIn-DPercU5n.js} +1 -1
  18. package/dashboard/dist/assets/{HeaderGithubStar-DR4Px_eh.js → HeaderGithubStar-DeVzeBIo.js} +1 -1
  19. package/dashboard/dist/assets/{HoverTooltip-CsfynzUO.js → HoverTooltip-Duo2Icus.js} +1 -1
  20. package/dashboard/dist/assets/{IpCheckPage-C8Y1OFOn.js → IpCheckPage-DgYiaRrT.js} +1 -1
  21. package/dashboard/dist/assets/{LandingPage-BnmP1NUm.js → LandingPage-CYTR4PbQ.js} +2 -2
  22. package/dashboard/dist/assets/{LeaderboardAvatar-DprHPy4v.js → LeaderboardAvatar-B67pMaIl.js} +1 -1
  23. package/dashboard/dist/assets/{LeaderboardPage-BI-ryUMj.js → LeaderboardPage-2wIMkBgq.js} +2 -2
  24. package/dashboard/dist/assets/{LeaderboardProfileModal-r-wgLtCo.js → LeaderboardProfileModal-D3VxkFlx.js} +3 -3
  25. package/dashboard/dist/assets/{LeaderboardProfilePage-qBvdPj6z.js → LeaderboardProfilePage-BS01jN5M.js} +1 -1
  26. package/dashboard/dist/assets/{LimitsPage--ObDuhSD.js → LimitsPage-BGRZW-aH.js} +1 -1
  27. package/dashboard/dist/assets/{LocalOnlyNotice-Cvg81MIm.js → LocalOnlyNotice-Do9KUdi_.js} +1 -1
  28. package/dashboard/dist/assets/{LoginCard-T1vufQym.js → LoginCard-CzAXLXfZ.js} +1 -1
  29. package/dashboard/dist/assets/{LoginModal-CElUuzhg.js → LoginModal-D1J8zG0C.js} +1 -1
  30. package/dashboard/dist/assets/{LoginPage-Decz8Qyn.js → LoginPage-DeZJNMLe.js} +1 -1
  31. package/dashboard/dist/assets/{PetPage-CitsUTsW.js → PetPage-D2oqJ05F.js} +1 -1
  32. package/dashboard/dist/assets/{PopoverPopup-wx5xna8c.js → PopoverPopup-BYzzQJTD.js} +1 -1
  33. package/dashboard/dist/assets/{ProviderIcon-DeCQ9ytY.js → ProviderIcon-BfFkS-OF.js} +1 -1
  34. package/dashboard/dist/assets/{ResetPasswordPage-BklHQ_i8.js → ResetPasswordPage-BFyYvG24.js} +1 -1
  35. package/dashboard/dist/assets/{SegmentedControl-DqbXKZfk.js → SegmentedControl-D5USR3JT.js} +1 -1
  36. package/dashboard/dist/assets/{Select-BPhSzg5T.js → Select-DmFQdVA1.js} +1 -1
  37. package/dashboard/dist/assets/{SelectItemText-BEqonLIf.js → SelectItemText-B5MXGLN-.js} +1 -1
  38. package/dashboard/dist/assets/{ServiceStatusPage-DnAv3J6d.js → ServiceStatusPage-Dvm5eUJK.js} +1 -1
  39. package/dashboard/dist/assets/{SessionsPage-Fr5rFC4h.js → SessionsPage-DQKezzUW.js} +1 -1
  40. package/dashboard/dist/assets/{SettingsPage-DYB-pyw2.js → SettingsPage-DbUDye5r.js} +2 -2
  41. package/dashboard/dist/assets/{SkillsPage-B9aU8WEc.js → SkillsPage-DyX_-dcr.js} +1 -1
  42. package/dashboard/dist/assets/{TokenGalaxy-ybV8JSOT.js → TokenGalaxy-aK3jhWW0.js} +1 -1
  43. package/dashboard/dist/assets/{ToolbarRootContext-DTAiJvnu.js → ToolbarRootContext-CY_SULMC.js} +1 -1
  44. package/dashboard/dist/assets/{TrendMonitor-BCpOG6Vh.js → TrendMonitor-BH6Jx8nS.js} +1 -1
  45. package/dashboard/dist/assets/{WidgetsPage-Ypvi7zXN.js → WidgetsPage-D8tzK-7m.js} +1 -1
  46. package/dashboard/dist/assets/{WrappedPage-ZetHSH8Z.js → WrappedPage-BjZPa_al.js} +1 -1
  47. package/dashboard/dist/assets/__vite-browser-external-VmN0WaC3.js +45 -0
  48. package/dashboard/dist/assets/{agent-logos-BP-j-Uhx.js → agent-logos-QSoXRwwJ.js} +1 -1
  49. package/dashboard/dist/assets/{arrow-up-right-BDfZ3gqx.js → arrow-up-right-C3WUmTcI.js} +1 -1
  50. package/dashboard/dist/assets/{check-DMSqoEnk.js → check-Gz5mnj6f.js} +1 -1
  51. package/dashboard/dist/assets/{composite-BdUpN78Q.js → composite-DJhoahpv.js} +1 -1
  52. package/dashboard/dist/assets/{copy-CSp3uU1K.js → copy-C5RiL5JQ.js} +1 -1
  53. package/dashboard/dist/assets/{download-5KK5dq2E.js → download-CccMGCc1.js} +1 -1
  54. package/dashboard/dist/assets/{external-link-CetdvgSB.js → external-link-fdU7Lj6p.js} +1 -1
  55. package/dashboard/dist/assets/{flame-CkGhWtYT.js → flame-CYEjossP.js} +1 -1
  56. package/dashboard/dist/assets/{format-tokens-CnlGC8B4.js → format-tokens-xXCznLkf.js} +1 -1
  57. package/dashboard/dist/assets/{icons-BwUwzIE1.js → icons-CYNYszil.js} +1 -1
  58. package/dashboard/dist/assets/{index-BLiO8Wso.js → index-CQ5GHXiW.js} +1 -1
  59. package/dashboard/dist/assets/{index-D_-EkG8M.js → index-Cgfb050k.js} +1 -1
  60. package/dashboard/dist/assets/{index-DQV-HPM-.js → index-Czz7x_MZ.js} +1 -1
  61. package/dashboard/dist/assets/{info-KSAnlMrp.js → info-Zae50fSC.js} +1 -1
  62. package/dashboard/dist/assets/{link-2-BGXe__2Q.js → link-2-DW_mHLzI.js} +1 -1
  63. package/dashboard/dist/assets/{loader-circle-D7ZxwMME.js → loader-circle-Bl7dBXh1.js} +1 -1
  64. package/dashboard/dist/assets/{maximize-2-D80lpJ50.js → maximize-2-DTP25Fl_.js} +1 -1
  65. package/dashboard/dist/assets/{modifiers.esm-DStyqxn4.js → modifiers.esm-CYXpOF3i.js} +1 -1
  66. package/dashboard/dist/assets/{monitor-smartphone-D282iI2t.js → monitor-smartphone--TLNLuLe.js} +1 -1
  67. package/dashboard/dist/assets/{plus-Cn55gGq1.js → plus-DgeFv3Xc.js} +1 -1
  68. package/dashboard/dist/assets/{provider-display-DvH8Y5lo.js → provider-display-crAVn3qa.js} +1 -1
  69. package/dashboard/dist/assets/{react-B-73Uvu6.js → react-QPulAuJP.js} +1 -1
  70. package/dashboard/dist/assets/{search-DpOq2L2S.js → search-DIUmGfar.js} +1 -1
  71. package/dashboard/dist/assets/{skills-api-CCIV2ZIq.js → skills-api-09qiTRNb.js} +1 -1
  72. package/dashboard/dist/assets/{sortable.esm-BjIamCRg.js → sortable.esm-BbsbmOc2.js} +1 -1
  73. package/dashboard/dist/assets/{store-CmFrvUue.js → store-DdyzwTsy.js} +1 -1
  74. package/dashboard/dist/assets/{terminal-CqeGAXgs.js → terminal-JpDnkjVA.js} +1 -1
  75. package/dashboard/dist/assets/{trash-CMLW5F5L.js → trash-CRsyysiP.js} +1 -1
  76. package/dashboard/dist/assets/{use-community-stats-BKS7Gd-z.js → use-community-stats-D3PwUyvR.js} +1 -1
  77. package/dashboard/dist/assets/{use-latest-request-guard-I80QDt_F.js → use-latest-request-guard-DTCniVRw.js} +1 -1
  78. package/dashboard/dist/assets/{use-limits-display-prefs-CPLY7mBi.js → use-limits-display-prefs-BbYcvoh_.js} +1 -1
  79. package/dashboard/dist/assets/{use-ordered-list-wlw260-2.js → use-ordered-list-ypqFhcs4.js} +1 -1
  80. package/dashboard/dist/assets/use-reduced-motion-Cdn1VrG0.js +1 -0
  81. package/dashboard/dist/assets/{use-session-efficiency-pref-BdVVDyew.js → use-session-efficiency-pref-C5BZmpkY.js} +1 -1
  82. package/dashboard/dist/assets/{use-transform-Daiv5LsX.js → use-transform-C3bGaC_U.js} +1 -1
  83. package/dashboard/dist/assets/{use-usage-limits-CK1zK4GT.js → use-usage-limits-BRLNaZEv.js} +1 -1
  84. package/dashboard/dist/assets/{useCurrency-yxDqAL1Q.js → useCurrency-BianRgdW.js} +1 -1
  85. package/dashboard/dist/assets/{useTokenFormat-BTYDgiyJ.js → useTokenFormat-DO4vxqhW.js} +1 -1
  86. package/dashboard/dist/assets/{zap-CfNiBLFJ.js → zap-BJTChg1t.js} +1 -1
  87. package/dashboard/dist/index.html +1 -1
  88. package/dashboard/dist/ip-check.html +1 -1
  89. package/dashboard/dist/leaderboard.html +1 -1
  90. package/dashboard/dist/share.html +1 -1
  91. package/package.json +1 -1
  92. package/src/commands/init.js +1 -1
  93. package/src/commands/sync.js +28 -6
  94. package/src/lib/cloud-account.js +23 -12
  95. package/src/lib/cloud-device-token.js +74 -0
  96. package/src/lib/cloud-sync-prefs.js +14 -0
  97. package/src/lib/local-api.js +104 -46
  98. package/src/lib/pricing/seed-snapshot.json +1 -1
  99. package/src/lib/upload-throttle.js +4 -1
  100. package/dashboard/dist/assets/DevicePage-CghTfQLN.js +0 -1
  101. package/dashboard/dist/assets/DialogDescription-Ln30UAVH.js +0 -1
  102. package/dashboard/dist/assets/__vite-browser-external-C_FI6biS.js +0 -45
  103. package/dashboard/dist/assets/use-reduced-motion-ClrSsBXW.js +0 -1
@@ -1 +1 @@
1
- import{m as c}from"./__vite-browser-external-C_FI6biS.js";const e={name:"search",size:24,node:[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]]};e.node;const o=c(e);export{o as S};
1
+ import{m as c}from"./__vite-browser-external-VmN0WaC3.js";const e={name:"search",size:24,node:[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]]};e.node;const o=c(e);export{o as S};
@@ -1 +1 @@
1
- import{O as R,P as E,Q as I,S as C,U as L,V as $}from"./__vite-browser-external-C_FI6biS.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 N(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 P(e){return(Array.isArray(e)?e:[]).filter(t=>t?.scope!=="system").map(t=>{const n=v(t?.directory),r=N(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 J(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 H(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=J(o);if(!(!a.id||a.id===n))for(const c of Array.isArray(o?.skills)?o.skills:[]){if(c?.scope==="system")continue;const u=S(c),p=s(c?.directory);if(!u||!p)continue;const h=u.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])],b=Object.fromEntries(A.map(j=>[j,"synced"]));r[y]=m({...f,targets:A,targetStates:b},a)}else r[y]=m(f,a);continue}const w=k,U=Object.fromEntries(w.map(f=>[f,"synced"])),_=m({id:`remote:${encodeURIComponent(u)}`,key:u,name:s(c.name)||p.split(/[\\/]/).pop()||"Skill",directory:p,description:"",targets:w,targetStates:U,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(_)}}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",K="tokentracker-account-skills",q=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 l(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 z(){return d({mode:"installed"})}function B(e={}){return d({mode:"discover",...e.force?{force:1}:{}})}function M(e,t=0,n=20){return d({mode:"search",q:e,offset:t,limit:n})}function D(){return d({mode:"repos"})}function F(e,t){return l({action:"install",skill:e,targets:t})}function G(e){return l({action:"update_all",ids:e})}function Q(e){return l({action:"uninstall",id:e})}function V(e){return l({action:"restore",id:e})}function W(e,t){return l({action:"set_targets",id:e,targets:t})}function Z(e,t){return l({action:"import_local",directory:e,targets:t})}function X(e,t){return l({action:"delete_local",directory:e,targets:t||[]})}function Y(e){return l({action:"add_repo",repo:e})}function ee(e,t){return l({action:"remove_repo",owner:e,name:t})}function te(e={}){return d({mode:"popular",...e.force?{force:1}:{}})}function ne(e={}){return d({mode:"updates",...e.force?{force:1}:{}})}function re(e={}){return d({mode:"skill_usage",...e.force?{force:1}:{}})}async function O({accessToken:e,method:t="GET",body:n}){if(!e||!R(e))throw new Error("Skills sync requires sign-in");const r=E();if(!r)throw new Error("InsForge base URL not configured");const i={Accept:"application/json","Content-Type":"application/json",Authorization:`Bearer ${e}`},o=I();o&&(i.apikey=o);const a=new AbortController,c=setTimeout(()=>a.abort(),q);try{const u=await C(L(r,K),{method:t,headers:i,cache:"no-store",signal:a.signal,...n==null?{}:{body:JSON.stringify(n)}}),p=await u.json().catch(()=>null);if(!u.ok)throw new Error(p?.error||`Request failed with HTTP ${u.status}`);return p}finally{clearTimeout(c)}}function oe(e){return O({accessToken:e})}function se({accessToken:e,deviceId:t,skills:n}){return O({accessToken:e,method:"POST",body:{device_id:t,skills:P(n)}})}export{oe as a,D as b,te as c,B as d,ne as e,re as f,z as g,X as h,F as i,W as j,Z as k,G as l,H as m,ee as n,Y as o,se as p,V as r,M as s,Q as u};
1
+ import{O as R,P as E,Q as I,S as C,U as L,V as $}from"./__vite-browser-external-VmN0WaC3.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 N(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 P(e){return(Array.isArray(e)?e:[]).filter(t=>t?.scope!=="system").map(t=>{const n=v(t?.directory),r=N(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 J(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 H(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=J(o);if(!(!a.id||a.id===n))for(const c of Array.isArray(o?.skills)?o.skills:[]){if(c?.scope==="system")continue;const u=S(c),p=s(c?.directory);if(!u||!p)continue;const h=u.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])],b=Object.fromEntries(A.map(j=>[j,"synced"]));r[y]=m({...f,targets:A,targetStates:b},a)}else r[y]=m(f,a);continue}const w=k,U=Object.fromEntries(w.map(f=>[f,"synced"])),_=m({id:`remote:${encodeURIComponent(u)}`,key:u,name:s(c.name)||p.split(/[\\/]/).pop()||"Skill",directory:p,description:"",targets:w,targetStates:U,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(_)}}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",K="tokentracker-account-skills",q=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 l(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 z(){return d({mode:"installed"})}function B(e={}){return d({mode:"discover",...e.force?{force:1}:{}})}function M(e,t=0,n=20){return d({mode:"search",q:e,offset:t,limit:n})}function D(){return d({mode:"repos"})}function F(e,t){return l({action:"install",skill:e,targets:t})}function G(e){return l({action:"update_all",ids:e})}function Q(e){return l({action:"uninstall",id:e})}function V(e){return l({action:"restore",id:e})}function W(e,t){return l({action:"set_targets",id:e,targets:t})}function Z(e,t){return l({action:"import_local",directory:e,targets:t})}function X(e,t){return l({action:"delete_local",directory:e,targets:t||[]})}function Y(e){return l({action:"add_repo",repo:e})}function ee(e,t){return l({action:"remove_repo",owner:e,name:t})}function te(e={}){return d({mode:"popular",...e.force?{force:1}:{}})}function ne(e={}){return d({mode:"updates",...e.force?{force:1}:{}})}function re(e={}){return d({mode:"skill_usage",...e.force?{force:1}:{}})}async function O({accessToken:e,method:t="GET",body:n}){if(!e||!R(e))throw new Error("Skills sync requires sign-in");const r=E();if(!r)throw new Error("InsForge base URL not configured");const i={Accept:"application/json","Content-Type":"application/json",Authorization:`Bearer ${e}`},o=I();o&&(i.apikey=o);const a=new AbortController,c=setTimeout(()=>a.abort(),q);try{const u=await C(L(r,K),{method:t,headers:i,cache:"no-store",signal:a.signal,...n==null?{}:{body:JSON.stringify(n)}}),p=await u.json().catch(()=>null);if(!u.ok)throw new Error(p?.error||`Request failed with HTTP ${u.status}`);return p}finally{clearTimeout(c)}}function oe(e){return O({accessToken:e})}function se({accessToken:e,deviceId:t,skills:n}){return O({accessToken:e,method:"POST",body:{device_id:t,skills:P(n)}})}export{oe as a,D as b,te as c,B as d,ne as e,re as f,z as g,X as h,F as i,W as j,Z as k,G as l,H as m,ee as n,Y as o,se as p,V as r,M as s,Q as u};
@@ -1,4 +1,4 @@
1
- import{r as c,d as P,a5 as Oe}from"./__vite-browser-external-C_FI6biS.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:`
1
+ import{r as c,d as P,a5 as Oe}from"./__vite-browser-external-VmN0WaC3.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.
@@ -1 +1 @@
1
- import{E as r}from"./__vite-browser-external-C_FI6biS.js";import{F as g}from"./composite-BdUpN78Q.js";function a(e,n,u=!1){return{open:!1,openProp:void 0,mounted:!1,transitionStatus:void 0,floatingRootContext:new g({open:!1,transitionStatus:void 0,floatingElement:null,referenceElement:null,triggerElements:e,floatingId:n,syncOnly:!0,nested:u,onOpenChange:void 0}),floatingId:n,triggerCount:0,preventUnmountingOnClose:!1,payload:void 0,activeTriggerId:null,activeTriggerElement:null,triggerIdProp:void 0,popupElement:null,positionerElement:null,activeTriggerProps:r,inactiveTriggerProps:r,popupProps:r}}const o=e=>e.triggerIdProp??e.activeTriggerId,t=e=>e.openProp??e.open,i=e=>(e.popupElement?.id??e.floatingId)||void 0;function p(e,n){return n!==void 0&&t(e)&&o(e)===n}function l(e,n){return p(e,n)?!0:n!==void 0&&t(e)&&o(e)==null&&e.triggerCount===1}const c={open:t,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)=>p(e,n),isMountedByTrigger:(e,n)=>n!==void 0&&o(e)===n&&e.mounted,triggerProps:(e,n)=>n?e.activeTriggerProps:e.inactiveTriggerProps,triggerPopupId:(e,n)=>l(e,n)?i(e):void 0,popupProps:e=>e.popupProps,popupElement:e=>e.popupElement,positionerElement:e=>e.positionerElement};export{a as c,c as p};
1
+ import{E as r}from"./__vite-browser-external-VmN0WaC3.js";import{F as g}from"./composite-DJhoahpv.js";function a(e,n,u=!1){return{open:!1,openProp:void 0,mounted:!1,transitionStatus:void 0,floatingRootContext:new g({open:!1,transitionStatus:void 0,floatingElement:null,referenceElement:null,triggerElements:e,floatingId:n,syncOnly:!0,nested:u,onOpenChange:void 0}),floatingId:n,triggerCount:0,preventUnmountingOnClose:!1,payload:void 0,activeTriggerId:null,activeTriggerElement:null,triggerIdProp:void 0,popupElement:null,positionerElement:null,activeTriggerProps:r,inactiveTriggerProps:r,popupProps:r}}const o=e=>e.triggerIdProp??e.activeTriggerId,t=e=>e.openProp??e.open,i=e=>(e.popupElement?.id??e.floatingId)||void 0;function p(e,n){return n!==void 0&&t(e)&&o(e)===n}function l(e,n){return p(e,n)?!0:n!==void 0&&t(e)&&o(e)==null&&e.triggerCount===1}const c={open:t,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)=>p(e,n),isMountedByTrigger:(e,n)=>n!==void 0&&o(e)===n&&e.mounted,triggerProps:(e,n)=>n?e.activeTriggerProps:e.inactiveTriggerProps,triggerPopupId:(e,n)=>l(e,n)?i(e):void 0,popupProps:e=>e.popupProps,popupElement:e=>e.popupElement,positionerElement:e=>e.positionerElement};export{a as c,c as p};
@@ -1 +1 @@
1
- import{m as a}from"./__vite-browser-external-C_FI6biS.js";const e={name:"terminal",size:24,node:[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]]};e.node;const o=a(e);export{o as T};
1
+ import{m as a}from"./__vite-browser-external-VmN0WaC3.js";const e={name:"terminal",size:24,node:[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]]};e.node;const o=a(e);export{o as T};
@@ -1 +1 @@
1
- import{m as e}from"./__vite-browser-external-C_FI6biS.js";const a={name:"trash",size:24,node:[["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"}]],aliases:["trash-2"]};a.node;const o=e(a);export{o as T};
1
+ import{m as e}from"./__vite-browser-external-VmN0WaC3.js";const a={name:"trash",size:24,node:[["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"}]],aliases:["trash-2"]};a.node;const o=e(a);export{o as T};
@@ -1 +1 @@
1
- import{r as p,g as N,b as M}from"./__vite-browser-external-C_FI6biS.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};
1
+ import{r as p,g as N,b as M}from"./__vite-browser-external-VmN0WaC3.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};
@@ -1 +1 @@
1
- import{r as u}from"./__vite-browser-external-C_FI6biS.js";function f(r,e){return r.length===e.length&&r.every((t,n)=>Object.is(t,e[n]))}function a(r){const e=u.useRef(r),t=u.useRef(0),n=u.useRef(!0);return u.useLayoutEffect(()=>{f(e.current,r)||(e.current=r,t.current+=1)}),u.useEffect(()=>(n.current=!0,()=>{n.current=!1,t.current+=1}),[]),u.useCallback(()=>{const c=++t.current,s=e.current;return()=>n.current&&t.current===c&&e.current===s},[])}export{a as u};
1
+ import{r as u}from"./__vite-browser-external-VmN0WaC3.js";function f(r,e){return r.length===e.length&&r.every((t,n)=>Object.is(t,e[n]))}function a(r){const e=u.useRef(r),t=u.useRef(0),n=u.useRef(!0);return u.useLayoutEffect(()=>{f(e.current,r)||(e.current=r,t.current+=1)}),u.useEffect(()=>(n.current=!0,()=>{n.current=!1,t.current+=1}),[]),u.useCallback(()=>{const c=++t.current,s=e.current;return()=>n.current&&t.current===c&&e.current===s},[])}export{a as u};
@@ -1 +1 @@
1
- import{c as a,r as c,J as N,K as B,M as F,N as H}from"./__vite-browser-external-C_FI6biS.js";const Q=["claude","codex","cursor","gemini","kimi","kiro","grok","copilot","antigravity","zcode","opencodeGo","commandCode","qoder","qoderCn","codingPlan","agentPlan","devin"],W={claude:"CLAUDE",codex:"CODEX",cursor:"CURSOR",gemini:"GEMINI",kimi:"KIMI",kiro:"KIRO",grok:"GROK",copilot:"COPILOT",antigravity:"ANTIGRAVITY",zcode:"ZCODE",opencodeGo:"OPENCODE",commandCode:"COMMAND-CODE",qoder:"QODER",qoderCn:"QODER-CN",codingPlan:"VOLCANO-ARK",agentPlan:"VOLCANO-ARK",devin:"DEVIN"};function fe(e){return W[e]||null}function me(e){switch(e){case"claude":return a("limits.provider.claude");case"codex":return a("limits.provider.codex");case"cursor":return a("limits.provider.cursor");case"gemini":return a("limits.provider.gemini");case"kimi":return a("limits.provider.kimi");case"kiro":return a("limits.provider.kiro");case"grok":return a("limits.provider.grok");case"copilot":return a("limits.provider.copilot");case"antigravity":return a("limits.provider.antigravity");case"zcode":return a("limits.provider.zcode");case"opencodeGo":return a("limits.provider.opencode_go");case"commandCode":return a("limits.provider.command_code");case"qoder":return a("limits.provider.qoder");case"qoderCn":return a("limits.provider.qoder_cn");case"codingPlan":return a("limits.provider.ark_coding_plan");case"agentPlan":return a("limits.provider.ark_agent_plan");case"devin":return a("limits.provider.devin");default:return String(e||"")}}const m=Q,E="tt.limits.providerOrder",I="tt.limits.providerVisibility",A="tt.limits.displayMode",D="tt.limits.showSubscriptions",O="tt.limits.updatedAt",C="limitsPreferences",X="limitsDisplayMode",Z="tt:limits-prefs-changed",w=Object.freeze({USED:"used",REMAINING:"remaining"}),g=new Set(Object.values(w)),_=new Set([E,I,A,D,O]);function h(){return[...m]}const $=new Set(["devin"]);function b(){return Object.fromEntries(m.map(e=>[e,!$.has(e)]))}function L(e){const r=[];if(Array.isArray(e))for(const o of e)m.includes(o)&&!r.includes(o)&&r.push(o);for(const o of m)r.includes(o)||r.push(o);return r}function P(e){const r=b();if(!e||typeof e!="object"||Array.isArray(e))return r;for(const o of m)typeof e[o]=="boolean"&&(r[o]=e[o]);return r}function ee(e){return g.has(e)?e:w.USED}function k(e){return typeof e=="boolean"?e:!0}function S(e){if(e!=null){if(typeof e=="number")return Number.isSafeInteger(e)?e:void 0;if(typeof e=="string"){const r=e.trim();if(r==="")return;const o=Number(r);return Number.isSafeInteger(o)?o:void 0}}}function y(e={}){const r=e&&typeof e=="object"?e:{};return{displayMode:ee(r.displayMode),providerOrder:L(r.providerOrder),providerVisibility:P(r.providerVisibility),showSubscriptions:k(r.showSubscriptions),updatedAt:S(r.updatedAt)}}function re(){if(typeof window>"u")return h();try{const e=window.localStorage.getItem(E);return L(e?JSON.parse(e):void 0)}catch{return h()}}function R(){if(typeof window>"u")return b();try{const e=window.localStorage.getItem(I);return P(e?JSON.parse(e):void 0)}catch{return b()}}function Se(e){return e===null||_.has(e)}function we(){return R().devin===!0}function te(){if(typeof window>"u")return w.USED;try{const e=window.localStorage.getItem(A);return g.has(e)?e:w.USED}catch{return w.USED}}function ie(){if(typeof window>"u")return!0;try{const e=window.localStorage.getItem(D);return e===null?!0:k(JSON.parse(e))}catch{return!0}}function ne(){if(!(typeof window>"u"))try{return S(window.localStorage.getItem(O))}catch{return}}function oe(){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 v(){return y({displayMode:te(),providerOrder:re(),providerVisibility:R(),showSubscriptions:ie(),updatedAt:ne()})}function se(e){if(typeof window>"u")return;const r=y(e);try{window.localStorage.setItem(E,JSON.stringify(r.providerOrder)),window.localStorage.setItem(I,JSON.stringify(r.providerVisibility)),window.localStorage.setItem(A,r.displayMode),window.localStorage.setItem(D,JSON.stringify(r.showSubscriptions)),r.updatedAt===void 0?window.localStorage.removeItem(O):window.localStorage.setItem(O,String(r.updatedAt))}catch(o){console.warn("[tokentracker] limits preferences localStorage write failed:",o)}}function de(e){const r=y(e);return{displayMode:r.displayMode,providerOrder:[...r.providerOrder],providerVisibility:{...r.providerVisibility},showSubscriptions:r.showSubscriptions,updatedAt:r.updatedAt??null}}function ae(...e){let r;for(const d of e){const l=S(d);l!==void 0&&(r=r===void 0?l:Math.max(r,l))}const o=Date.now();return r!==void 0&&o<=r?r+1:o}function ce(e,r){return e.length===r.length&&e.every((o,d)=>o===r[d])}function ue(e,r){return m.every(o=>e[o]===r[o])}function K(e,r){return e.displayMode===r.displayMode&&ce(e.providerOrder,r.providerOrder)&&ue(e.providerVisibility,r.providerVisibility)&&e.showSubscriptions===r.showSubscriptions}function le(e,r){return K(e,r)&&S(e.updatedAt)===S(r.updatedAt)}function V(e,r){const o=S(e.updatedAt),d=S(r.updatedAt);return o!==void 0&&(d===void 0||o>d)}function ye(){const[e,r]=c.useState(v),o=c.useRef(e),d=c.useCallback((i,t={})=>{const n=y(i);return o.current=n,r(n),t.writeLocal&&se(n),typeof window<"u"&&window.dispatchEvent(new CustomEvent(Z)),n},[]),l=c.useCallback(i=>{N()&&B(C,de(i))},[]),u=c.useCallback(i=>{const t=v(),n=V(t,o.current)?d(t):o.current,s=y(i(n));if(K(n,s))return;const p=ae(t.updatedAt,n.updatedAt),f=d({...s,updatedAt:p},{writeLocal:!0});l(f)},[d,l]),T=c.useCallback(i=>{g.has(i)&&u(t=>({...t,displayMode:i}))},[u]),x=c.useCallback(i=>{u(t=>({...t,showSubscriptions:!!i}))},[u]),M=c.useCallback(i=>{if(!g.has(i))return;const t=v();if(t.updatedAt!==void 0){d(t);return}d({...t,displayMode:i,updatedAt:void 0},{writeLocal:!0})},[d]);c.useEffect(()=>{if(!N())return;const i=F(t=>{const n=t?.[C];if(n&&typeof n=="object"){const s=y(n);if(!oe()){d(s,{writeLocal:!0});return}const p=v();if(V(s,p))d(s,{writeLocal:!0});else{const f=d(p);le(s,p)||l(f)}return}M(t?.[X])});return H(),i},[M,d,l]),c.useEffect(()=>{if(typeof window>"u")return;const i=t=>{(t.key===null||_.has(t.key))&&d(v())};return window.addEventListener("storage",i),()=>window.removeEventListener("storage",i)},[d]);const U=c.useCallback(i=>{m.includes(i)&&u(t=>({...t,providerVisibility:{...t.providerVisibility,[i]:!t.providerVisibility[i]}}))},[u]),Y=c.useCallback(i=>{u(t=>{const n=t.providerOrder.indexOf(i);if(n<=0)return t;const s=[...t.providerOrder];return[s[n-1],s[n]]=[s[n],s[n-1]],{...t,providerOrder:s}})},[u]),z=c.useCallback(i=>{u(t=>{const n=t.providerOrder.indexOf(i);if(n<0||n>=t.providerOrder.length-1)return t;const s=[...t.providerOrder];return[s[n],s[n+1]]=[s[n+1],s[n]],{...t,providerOrder:s}})},[u]),q=c.useCallback((i,t)=>{i!==t&&u(n=>{const s=n.providerOrder.indexOf(i),p=n.providerOrder.indexOf(t);if(s<0||p<0)return n;const f=[...n.providerOrder],[j]=f.splice(s,1);return f.splice(p,0,j),{...n,providerOrder:f}})},[u]),G=c.useCallback(()=>{u(()=>({displayMode:w.USED,providerOrder:h(),providerVisibility:b(),showSubscriptions:!0}))},[u]),J=c.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:T,setShowSubscriptions:x,visibleOrdered:J,toggle:U,moveUp:Y,moveDown:z,moveToward:q,reset:G}}export{Z as L,Se as a,w as b,Q as c,fe as d,we as i,me as l,ye as u};
1
+ import{c as a,r as c,J as N,K as B,M as F,N as H}from"./__vite-browser-external-VmN0WaC3.js";const Q=["claude","codex","cursor","gemini","kimi","kiro","grok","copilot","antigravity","zcode","opencodeGo","commandCode","qoder","qoderCn","codingPlan","agentPlan","devin"],W={claude:"CLAUDE",codex:"CODEX",cursor:"CURSOR",gemini:"GEMINI",kimi:"KIMI",kiro:"KIRO",grok:"GROK",copilot:"COPILOT",antigravity:"ANTIGRAVITY",zcode:"ZCODE",opencodeGo:"OPENCODE",commandCode:"COMMAND-CODE",qoder:"QODER",qoderCn:"QODER-CN",codingPlan:"VOLCANO-ARK",agentPlan:"VOLCANO-ARK",devin:"DEVIN"};function fe(e){return W[e]||null}function me(e){switch(e){case"claude":return a("limits.provider.claude");case"codex":return a("limits.provider.codex");case"cursor":return a("limits.provider.cursor");case"gemini":return a("limits.provider.gemini");case"kimi":return a("limits.provider.kimi");case"kiro":return a("limits.provider.kiro");case"grok":return a("limits.provider.grok");case"copilot":return a("limits.provider.copilot");case"antigravity":return a("limits.provider.antigravity");case"zcode":return a("limits.provider.zcode");case"opencodeGo":return a("limits.provider.opencode_go");case"commandCode":return a("limits.provider.command_code");case"qoder":return a("limits.provider.qoder");case"qoderCn":return a("limits.provider.qoder_cn");case"codingPlan":return a("limits.provider.ark_coding_plan");case"agentPlan":return a("limits.provider.ark_agent_plan");case"devin":return a("limits.provider.devin");default:return String(e||"")}}const m=Q,E="tt.limits.providerOrder",I="tt.limits.providerVisibility",A="tt.limits.displayMode",D="tt.limits.showSubscriptions",O="tt.limits.updatedAt",C="limitsPreferences",X="limitsDisplayMode",Z="tt:limits-prefs-changed",w=Object.freeze({USED:"used",REMAINING:"remaining"}),g=new Set(Object.values(w)),_=new Set([E,I,A,D,O]);function h(){return[...m]}const $=new Set(["devin"]);function b(){return Object.fromEntries(m.map(e=>[e,!$.has(e)]))}function L(e){const r=[];if(Array.isArray(e))for(const o of e)m.includes(o)&&!r.includes(o)&&r.push(o);for(const o of m)r.includes(o)||r.push(o);return r}function P(e){const r=b();if(!e||typeof e!="object"||Array.isArray(e))return r;for(const o of m)typeof e[o]=="boolean"&&(r[o]=e[o]);return r}function ee(e){return g.has(e)?e:w.USED}function k(e){return typeof e=="boolean"?e:!0}function S(e){if(e!=null){if(typeof e=="number")return Number.isSafeInteger(e)?e:void 0;if(typeof e=="string"){const r=e.trim();if(r==="")return;const o=Number(r);return Number.isSafeInteger(o)?o:void 0}}}function y(e={}){const r=e&&typeof e=="object"?e:{};return{displayMode:ee(r.displayMode),providerOrder:L(r.providerOrder),providerVisibility:P(r.providerVisibility),showSubscriptions:k(r.showSubscriptions),updatedAt:S(r.updatedAt)}}function re(){if(typeof window>"u")return h();try{const e=window.localStorage.getItem(E);return L(e?JSON.parse(e):void 0)}catch{return h()}}function R(){if(typeof window>"u")return b();try{const e=window.localStorage.getItem(I);return P(e?JSON.parse(e):void 0)}catch{return b()}}function Se(e){return e===null||_.has(e)}function we(){return R().devin===!0}function te(){if(typeof window>"u")return w.USED;try{const e=window.localStorage.getItem(A);return g.has(e)?e:w.USED}catch{return w.USED}}function ie(){if(typeof window>"u")return!0;try{const e=window.localStorage.getItem(D);return e===null?!0:k(JSON.parse(e))}catch{return!0}}function ne(){if(!(typeof window>"u"))try{return S(window.localStorage.getItem(O))}catch{return}}function oe(){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 v(){return y({displayMode:te(),providerOrder:re(),providerVisibility:R(),showSubscriptions:ie(),updatedAt:ne()})}function se(e){if(typeof window>"u")return;const r=y(e);try{window.localStorage.setItem(E,JSON.stringify(r.providerOrder)),window.localStorage.setItem(I,JSON.stringify(r.providerVisibility)),window.localStorage.setItem(A,r.displayMode),window.localStorage.setItem(D,JSON.stringify(r.showSubscriptions)),r.updatedAt===void 0?window.localStorage.removeItem(O):window.localStorage.setItem(O,String(r.updatedAt))}catch(o){console.warn("[tokentracker] limits preferences localStorage write failed:",o)}}function de(e){const r=y(e);return{displayMode:r.displayMode,providerOrder:[...r.providerOrder],providerVisibility:{...r.providerVisibility},showSubscriptions:r.showSubscriptions,updatedAt:r.updatedAt??null}}function ae(...e){let r;for(const d of e){const l=S(d);l!==void 0&&(r=r===void 0?l:Math.max(r,l))}const o=Date.now();return r!==void 0&&o<=r?r+1:o}function ce(e,r){return e.length===r.length&&e.every((o,d)=>o===r[d])}function ue(e,r){return m.every(o=>e[o]===r[o])}function K(e,r){return e.displayMode===r.displayMode&&ce(e.providerOrder,r.providerOrder)&&ue(e.providerVisibility,r.providerVisibility)&&e.showSubscriptions===r.showSubscriptions}function le(e,r){return K(e,r)&&S(e.updatedAt)===S(r.updatedAt)}function V(e,r){const o=S(e.updatedAt),d=S(r.updatedAt);return o!==void 0&&(d===void 0||o>d)}function ye(){const[e,r]=c.useState(v),o=c.useRef(e),d=c.useCallback((i,t={})=>{const n=y(i);return o.current=n,r(n),t.writeLocal&&se(n),typeof window<"u"&&window.dispatchEvent(new CustomEvent(Z)),n},[]),l=c.useCallback(i=>{N()&&B(C,de(i))},[]),u=c.useCallback(i=>{const t=v(),n=V(t,o.current)?d(t):o.current,s=y(i(n));if(K(n,s))return;const p=ae(t.updatedAt,n.updatedAt),f=d({...s,updatedAt:p},{writeLocal:!0});l(f)},[d,l]),T=c.useCallback(i=>{g.has(i)&&u(t=>({...t,displayMode:i}))},[u]),x=c.useCallback(i=>{u(t=>({...t,showSubscriptions:!!i}))},[u]),M=c.useCallback(i=>{if(!g.has(i))return;const t=v();if(t.updatedAt!==void 0){d(t);return}d({...t,displayMode:i,updatedAt:void 0},{writeLocal:!0})},[d]);c.useEffect(()=>{if(!N())return;const i=F(t=>{const n=t?.[C];if(n&&typeof n=="object"){const s=y(n);if(!oe()){d(s,{writeLocal:!0});return}const p=v();if(V(s,p))d(s,{writeLocal:!0});else{const f=d(p);le(s,p)||l(f)}return}M(t?.[X])});return H(),i},[M,d,l]),c.useEffect(()=>{if(typeof window>"u")return;const i=t=>{(t.key===null||_.has(t.key))&&d(v())};return window.addEventListener("storage",i),()=>window.removeEventListener("storage",i)},[d]);const U=c.useCallback(i=>{m.includes(i)&&u(t=>({...t,providerVisibility:{...t.providerVisibility,[i]:!t.providerVisibility[i]}}))},[u]),Y=c.useCallback(i=>{u(t=>{const n=t.providerOrder.indexOf(i);if(n<=0)return t;const s=[...t.providerOrder];return[s[n-1],s[n]]=[s[n],s[n-1]],{...t,providerOrder:s}})},[u]),z=c.useCallback(i=>{u(t=>{const n=t.providerOrder.indexOf(i);if(n<0||n>=t.providerOrder.length-1)return t;const s=[...t.providerOrder];return[s[n],s[n+1]]=[s[n+1],s[n]],{...t,providerOrder:s}})},[u]),q=c.useCallback((i,t)=>{i!==t&&u(n=>{const s=n.providerOrder.indexOf(i),p=n.providerOrder.indexOf(t);if(s<0||p<0)return n;const f=[...n.providerOrder],[j]=f.splice(s,1);return f.splice(p,0,j),{...n,providerOrder:f}})},[u]),G=c.useCallback(()=>{u(()=>({displayMode:w.USED,providerOrder:h(),providerVisibility:b(),showSubscriptions:!0}))},[u]),J=c.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:T,setShowSubscriptions:x,visibleOrdered:J,toggle:U,moveUp:Y,moveDown:z,moveToward:q,reset:G}}export{Z as L,Se as a,w as b,Q as c,fe as d,we as i,me as l,ye as u};
@@ -1 +1 @@
1
- import{r as f}from"./__vite-browser-external-C_FI6biS.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};
1
+ import{r as f}from"./__vite-browser-external-VmN0WaC3.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-VmN0WaC3.js";import{h as r,i as t,p as s}from"./react-QPulAuJP.js";function i(){!r.current&&t();const[e]=o.useState(s.current);return e}export{i as u};
@@ -1 +1 @@
1
- import{m as f,r as n}from"./__vite-browser-external-C_FI6biS.js";const u={name:"pencil",size:24,node:[["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"}]]};u.node;const E=f(u),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
+ import{m as f,r as n}from"./__vite-browser-external-VmN0WaC3.js";const u={name:"pencil",size:24,node:[["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"}]]};u.node;const E=f(u),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-B-73Uvu6.js";import{r as f}from"./__vite-browser-external-C_FI6biS.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};
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-QPulAuJP.js";import{r as f}from"./__vite-browser-external-VmN0WaC3.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};
@@ -1 +1 @@
1
- import{J as S,ae as M,r as w,c as P,af as O,ag as R,ah as g,ai as q}from"./__vite-browser-external-C_FI6biS.js";import{l as z,i as _,L as F,a as j}from"./use-limits-display-prefs-CPLY7mBi.js";import{u as T}from"./use-latest-request-guard-I80QDt_F.js";const L="native:notificationPermission";let I=null;function D(){return typeof window<"u"&&!!window.chrome?.webview}function x(){return S()?I||"unknown":D()?"granted":typeof Notification>"u"?"unsupported":Notification.permission}function $(e){if(typeof window>"u")return()=>{};const i=n=>{const s=n?.detail?.status;typeof s=="string"&&(I=s),e(x())};return window.addEventListener(L,i),e(x()),S()&&M({type:"getNotificationStatus"}),()=>window.removeEventListener(L,i)}async function B(){if(S()){M({type:"requestNotificationPermission"});return}D()||typeof Notification<"u"&&Notification.permission==="default"&&await Notification.requestPermission().catch(()=>"denied")}const v="tt.limitAlerts.enabled";function G(){try{return window.localStorage.getItem(v)==="1"}catch{return!1}}function le(){const[e,i]=w.useState(G),[n,s]=w.useState("unknown");w.useEffect(()=>$(s),[]);const y=w.useCallback(async o=>{const l=!!o;l&&await B();try{window.localStorage.setItem(v,l?"1":"0")}catch{}i(l)},[]);return{enabled:e,setEnabled:y,permissionBlocked:n==="denied"}}function V(e,i){if(!(e>0))return null;const n=(e-i)/e;return Number.isFinite(n)?Math.min(Math.max(n,0),1):null}function H(e,i,n=.03){return e>i+n}function J(e){const i=Math.max(0,Math.floor(e)),n=Math.floor(i/3600);return n>24?`${Math.floor(n/24)}d`:n>0?`${n}h`:`${Math.floor(i/60)}m`}function U(e,i){if(typeof e.windowSeconds=="number")return e.windowSeconds;if(e.windowSecondsField&&i){const n=i[e.windowSecondsField];return typeof n=="number"&&n>0?n:null}return null}function W(e){return e==null?NaN:typeof e=="number"?e*1e3:Date.parse(e)}function Y({usedPercent:e,windowSeconds:i,resetMs:n,mode:s,now:y=Date.now()}){const o=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(n))return l;const a=Math.max(0,(n-y)/1e3),r=V(i,a);if(r==null)return l;if(l.expectedPercent=Math.round(r*100),l.paceOver=H(o,r),o>0){const m=s==="remaining"?1-r:r;l.pacePercent=m*100}if(r>.02&&o>0){const m=i*r,u=o/m,f=o/r;f>=1&&u>0?l.runsOutEta=J((1-o)/u):l.projectedEnd=Math.round(Math.min(f,1)*100)}return l}const Q={claude:{windows(e){const i=Array.isArray(e.weekly_scoped)?e.weekly_scoped.map(n=>({key:`scoped-${n.label}`,label:n.label,window:n,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,n=i==="weekly"?"limits.label.grok_week":i==="daily"?"limits.label.grok_day":"limits.label.grok_month",s=i==="weekly"?7*86400:i==="daily"?86400:void 0;return[{key:i==="weekly"?"week":i==="daily"?"day":"month",labelKey:n,window:e.primary_window,windowSeconds:s},{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){if(e.plan_kind==="coding-plan")return[{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}];const i=Array.isArray(e.buckets)?e.buckets.filter(n=>n?.label&&n.window):[];return i.length?i.map((n,s)=>({key:`bucket-${n.entitlement_id||s}`,label:n.label,window:n.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}]}},commandCode:{windows(e){return[{key:"5h",labelKey:"limits.label.command_code_5h",window:e.primary_window},{key:"weekly",labelKey:"limits.label.command_code_weekly",window:e.secondary_window}]}},agentPlan:{windows(e){return[{key:"5h",labelKey:"limits.label.ark_agent_plan_5h",window:e.primary_window},{key:"weekly",labelKey:"limits.label.ark_agent_plan_weekly",window:e.secondary_window},{key:"monthly",labelKey:"limits.label.ark_agent_plan_monthly",window:e.tertiary_window}]}},devin:{windows(e){return[{key:"daily",labelKey:"limits.label.devin_daily",window:e.primary_window,windowSecondsField:"limit_window_seconds"},{key:"weekly",labelKey:"limits.label.devin_weekly",window:e.secondary_window,windowSecondsField:"limit_window_seconds"}]}}},A="tt.limitAlerts.cycles.v1";function X(){try{return JSON.parse(window.localStorage.getItem(A)||"{}")}catch{return{}}}function Z(e){try{window.localStorage.setItem(A,JSON.stringify(e))}catch{}}function ee(e,{now:i=Date.now()}={}){const n=[],s=Q;for(const[y,o]of Object.entries(e||{})){const l=s[y];if(!(!o?.configured||o.error||!l))for(const a of l.windows(o)){if(!a.window)continue;const r=Number(a.pctField==="utilization"?a.window.utilization:a.window.used_percent),m=a.resetField==="resets_at"?a.window.resets_at:a.window.reset_at,u=W(m),f=Y({usedPercent:r,windowSeconds:U(a,a.window),resetMs:u,mode:"used",now:i});!f.runsOutEta||!f.paceOver||r<20||!(u>i)||n.push({id:`${y}:${a.key}:${u}`,providerId:y,windowKey:a.key,resetMs:u,usedPercent:r,runsOutEta:f.runsOutEta})}}return n}function ie(e){const i=X(),n=ee(e);for(const o of n){if(i[o.id])continue;const l=z(o.providerId),a=P("limits.alert.title",{provider:l}),r=P("limits.alert.body",{eta:o.runsOutEta,percent:Math.round(o.usedPercent)});let m=O({title:a,body:r,id:o.id});!m&&typeof Notification<"u"&&Notification.permission==="granted"&&(new Notification(a,{body:r,tag:o.id}),m=!0),m&&(i[o.id]=Date.now())}const s=Date.now()-864e5,y=Object.fromEntries(Object.entries(i).filter(([o,l])=>{const a=Number(o.split(":").at(-1));return Number.isFinite(a)?a>=s:Number(l)>=s}).slice(-100));return Z(y),n.length}function k(e,i){return!e||i||!e.devin||e.devin.configured===!1&&Object.keys(e.devin).length===1?e:{...e,devin:{configured:!1}}}function re(e){const i=q(),n=i&&!!e?.initialState,[s,y]=w.useState(_),[o,l]=w.useState(()=>n?k(e?.initialState?.data??null,_()):null),[a,r]=w.useState(()=>n?e?.initialState?.error??null:null),[m,u]=w.useState(i&&!n),f=!!e?.initialRefresh,K=!!e?.publishToPreloadCache,b=T([s,i]);w.useEffect(()=>{if(typeof window>"u")return;const d=()=>y(_()),t=c=>{j(c.key)&&d()};return window.addEventListener(F,d),window.addEventListener("storage",t),()=>{window.removeEventListener(F,d),window.removeEventListener("storage",t)}},[]),w.useEffect(()=>{if(!(!i||!o||typeof window>"u"))try{window.localStorage.getItem(v)==="1"&&ie(o)}catch{}},[o,i]);const p=w.useCallback((d,t)=>{!i||!K||!d||typeof d!="object"||R(k(d,_()),{source:t})},[i,K]),C=w.useCallback(async()=>{if(!i)return;const d=b();try{const t=await g({refresh:!0,devinEnabled:_()});if(!d())return;const c=t&&typeof t=="object"?t:null;l(k(c,_())),r(null),u(!1),p(c,"manual-refresh")}catch(t){if(!d())return;r(t?.message||String(t)),u(!1)}},[b,i,p]),h=w.useCallback(async()=>{if(!i)return;const d=b();try{const t=await g({devinEnabled:_()});if(!d())return;const c=t&&typeof t=="object"?t:null;l(k(c,_())),r(null),u(!1),p(c,"page-load")}catch(t){if(!d())return;r(t?.message||String(t)),u(!1)}},[b,i,p]);w.useEffect(()=>{if(!i||typeof window>"u"||typeof document>"u")return;const d=15e3;let t=Date.now();const c=()=>{if(document.visibilityState!=="visible")return;const N=Date.now();N-t<d||(t=N,h())};return window.addEventListener("focus",c),document.addEventListener("visibilitychange",c),()=>{window.removeEventListener("focus",c),document.removeEventListener("visibilitychange",c)}},[i,h]);const E=w.useRef(s);return w.useEffect(()=>{E.current!==s&&(E.current=s,i&&(s||l(d=>k(d,!1)),h()))},[s,i,h]),w.useEffect(()=>{if(!i){l(null),r(null),u(!1);return}if(n&&!f)return;const d=b();(async()=>{try{const t=await g({devinEnabled:_()});if(!d())return;const c=t&&typeof t=="object"?t:null;l(k(c,_())),r(null),p(c,"page-load")}catch(t){if(!d())return;r(t?.message||String(t))}finally{d()&&u(!1)}})()},[b,n,f,i,p]),{data:o,error:a,isLoading:m,refresh:C}}export{Q as P,U as a,le as b,Y as c,W as r,ie as s,re as u};
1
+ import{J as S,ae as M,r as w,c as P,af as O,ag as R,ah as g,ai as q}from"./__vite-browser-external-VmN0WaC3.js";import{l as z,i as _,L as F,a as j}from"./use-limits-display-prefs-BbYcvoh_.js";import{u as T}from"./use-latest-request-guard-DTCniVRw.js";const L="native:notificationPermission";let I=null;function D(){return typeof window<"u"&&!!window.chrome?.webview}function x(){return S()?I||"unknown":D()?"granted":typeof Notification>"u"?"unsupported":Notification.permission}function $(e){if(typeof window>"u")return()=>{};const i=n=>{const s=n?.detail?.status;typeof s=="string"&&(I=s),e(x())};return window.addEventListener(L,i),e(x()),S()&&M({type:"getNotificationStatus"}),()=>window.removeEventListener(L,i)}async function B(){if(S()){M({type:"requestNotificationPermission"});return}D()||typeof Notification<"u"&&Notification.permission==="default"&&await Notification.requestPermission().catch(()=>"denied")}const v="tt.limitAlerts.enabled";function G(){try{return window.localStorage.getItem(v)==="1"}catch{return!1}}function le(){const[e,i]=w.useState(G),[n,s]=w.useState("unknown");w.useEffect(()=>$(s),[]);const y=w.useCallback(async o=>{const l=!!o;l&&await B();try{window.localStorage.setItem(v,l?"1":"0")}catch{}i(l)},[]);return{enabled:e,setEnabled:y,permissionBlocked:n==="denied"}}function V(e,i){if(!(e>0))return null;const n=(e-i)/e;return Number.isFinite(n)?Math.min(Math.max(n,0),1):null}function H(e,i,n=.03){return e>i+n}function J(e){const i=Math.max(0,Math.floor(e)),n=Math.floor(i/3600);return n>24?`${Math.floor(n/24)}d`:n>0?`${n}h`:`${Math.floor(i/60)}m`}function U(e,i){if(typeof e.windowSeconds=="number")return e.windowSeconds;if(e.windowSecondsField&&i){const n=i[e.windowSecondsField];return typeof n=="number"&&n>0?n:null}return null}function W(e){return e==null?NaN:typeof e=="number"?e*1e3:Date.parse(e)}function Y({usedPercent:e,windowSeconds:i,resetMs:n,mode:s,now:y=Date.now()}){const o=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(n))return l;const a=Math.max(0,(n-y)/1e3),r=V(i,a);if(r==null)return l;if(l.expectedPercent=Math.round(r*100),l.paceOver=H(o,r),o>0){const m=s==="remaining"?1-r:r;l.pacePercent=m*100}if(r>.02&&o>0){const m=i*r,u=o/m,f=o/r;f>=1&&u>0?l.runsOutEta=J((1-o)/u):l.projectedEnd=Math.round(Math.min(f,1)*100)}return l}const Q={claude:{windows(e){const i=Array.isArray(e.weekly_scoped)?e.weekly_scoped.map(n=>({key:`scoped-${n.label}`,label:n.label,window:n,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,n=i==="weekly"?"limits.label.grok_week":i==="daily"?"limits.label.grok_day":"limits.label.grok_month",s=i==="weekly"?7*86400:i==="daily"?86400:void 0;return[{key:i==="weekly"?"week":i==="daily"?"day":"month",labelKey:n,window:e.primary_window,windowSeconds:s},{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){if(e.plan_kind==="coding-plan")return[{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}];const i=Array.isArray(e.buckets)?e.buckets.filter(n=>n?.label&&n.window):[];return i.length?i.map((n,s)=>({key:`bucket-${n.entitlement_id||s}`,label:n.label,window:n.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}]}},commandCode:{windows(e){return[{key:"5h",labelKey:"limits.label.command_code_5h",window:e.primary_window},{key:"weekly",labelKey:"limits.label.command_code_weekly",window:e.secondary_window}]}},agentPlan:{windows(e){return[{key:"5h",labelKey:"limits.label.ark_agent_plan_5h",window:e.primary_window},{key:"weekly",labelKey:"limits.label.ark_agent_plan_weekly",window:e.secondary_window},{key:"monthly",labelKey:"limits.label.ark_agent_plan_monthly",window:e.tertiary_window}]}},devin:{windows(e){return[{key:"daily",labelKey:"limits.label.devin_daily",window:e.primary_window,windowSecondsField:"limit_window_seconds"},{key:"weekly",labelKey:"limits.label.devin_weekly",window:e.secondary_window,windowSecondsField:"limit_window_seconds"}]}}},A="tt.limitAlerts.cycles.v1";function X(){try{return JSON.parse(window.localStorage.getItem(A)||"{}")}catch{return{}}}function Z(e){try{window.localStorage.setItem(A,JSON.stringify(e))}catch{}}function ee(e,{now:i=Date.now()}={}){const n=[],s=Q;for(const[y,o]of Object.entries(e||{})){const l=s[y];if(!(!o?.configured||o.error||!l))for(const a of l.windows(o)){if(!a.window)continue;const r=Number(a.pctField==="utilization"?a.window.utilization:a.window.used_percent),m=a.resetField==="resets_at"?a.window.resets_at:a.window.reset_at,u=W(m),f=Y({usedPercent:r,windowSeconds:U(a,a.window),resetMs:u,mode:"used",now:i});!f.runsOutEta||!f.paceOver||r<20||!(u>i)||n.push({id:`${y}:${a.key}:${u}`,providerId:y,windowKey:a.key,resetMs:u,usedPercent:r,runsOutEta:f.runsOutEta})}}return n}function ie(e){const i=X(),n=ee(e);for(const o of n){if(i[o.id])continue;const l=z(o.providerId),a=P("limits.alert.title",{provider:l}),r=P("limits.alert.body",{eta:o.runsOutEta,percent:Math.round(o.usedPercent)});let m=O({title:a,body:r,id:o.id});!m&&typeof Notification<"u"&&Notification.permission==="granted"&&(new Notification(a,{body:r,tag:o.id}),m=!0),m&&(i[o.id]=Date.now())}const s=Date.now()-864e5,y=Object.fromEntries(Object.entries(i).filter(([o,l])=>{const a=Number(o.split(":").at(-1));return Number.isFinite(a)?a>=s:Number(l)>=s}).slice(-100));return Z(y),n.length}function k(e,i){return!e||i||!e.devin||e.devin.configured===!1&&Object.keys(e.devin).length===1?e:{...e,devin:{configured:!1}}}function re(e){const i=q(),n=i&&!!e?.initialState,[s,y]=w.useState(_),[o,l]=w.useState(()=>n?k(e?.initialState?.data??null,_()):null),[a,r]=w.useState(()=>n?e?.initialState?.error??null:null),[m,u]=w.useState(i&&!n),f=!!e?.initialRefresh,K=!!e?.publishToPreloadCache,b=T([s,i]);w.useEffect(()=>{if(typeof window>"u")return;const d=()=>y(_()),t=c=>{j(c.key)&&d()};return window.addEventListener(F,d),window.addEventListener("storage",t),()=>{window.removeEventListener(F,d),window.removeEventListener("storage",t)}},[]),w.useEffect(()=>{if(!(!i||!o||typeof window>"u"))try{window.localStorage.getItem(v)==="1"&&ie(o)}catch{}},[o,i]);const p=w.useCallback((d,t)=>{!i||!K||!d||typeof d!="object"||R(k(d,_()),{source:t})},[i,K]),C=w.useCallback(async()=>{if(!i)return;const d=b();try{const t=await g({refresh:!0,devinEnabled:_()});if(!d())return;const c=t&&typeof t=="object"?t:null;l(k(c,_())),r(null),u(!1),p(c,"manual-refresh")}catch(t){if(!d())return;r(t?.message||String(t)),u(!1)}},[b,i,p]),h=w.useCallback(async()=>{if(!i)return;const d=b();try{const t=await g({devinEnabled:_()});if(!d())return;const c=t&&typeof t=="object"?t:null;l(k(c,_())),r(null),u(!1),p(c,"page-load")}catch(t){if(!d())return;r(t?.message||String(t)),u(!1)}},[b,i,p]);w.useEffect(()=>{if(!i||typeof window>"u"||typeof document>"u")return;const d=15e3;let t=Date.now();const c=()=>{if(document.visibilityState!=="visible")return;const N=Date.now();N-t<d||(t=N,h())};return window.addEventListener("focus",c),document.addEventListener("visibilitychange",c),()=>{window.removeEventListener("focus",c),document.removeEventListener("visibilitychange",c)}},[i,h]);const E=w.useRef(s);return w.useEffect(()=>{E.current!==s&&(E.current=s,i&&(s||l(d=>k(d,!1)),h()))},[s,i,h]),w.useEffect(()=>{if(!i){l(null),r(null),u(!1);return}if(n&&!f)return;const d=b();(async()=>{try{const t=await g({devinEnabled:_()});if(!d())return;const c=t&&typeof t=="object"?t:null;l(k(c,_())),r(null),p(c,"page-load")}catch(t){if(!d())return;r(t?.message||String(t))}finally{d()&&u(!1)}})()},[b,n,f,i,p]),{data:o,error:a,isLoading:m,refresh:C}}export{Q as P,U as a,le as b,Y as c,W as r,ie as s,re as u};
@@ -1 +1 @@
1
- import{r as e,C as t,D as r,q as c}from"./__vite-browser-external-C_FI6biS.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
+ import{r as e,C as t,D as r,q as c}from"./__vite-browser-external-VmN0WaC3.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-C_FI6biS.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
+ import{r as e,T as r,n,o as a,p as s}from"./__vite-browser-external-VmN0WaC3.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 e}from"./__vite-browser-external-C_FI6biS.js";const a={name:"zap",size:24,node:[["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"}]]};a.node;const n=e(a);export{n as Z};
1
+ import{m as e}from"./__vite-browser-external-VmN0WaC3.js";const a={name:"zap",size:24,node:[["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"}]]};a.node;const n=e(a);export{n as Z};
@@ -272,7 +272,7 @@
272
272
  ]
273
273
  }
274
274
  </script>
275
- <script type="module" crossorigin src="/assets/__vite-browser-external-C_FI6biS.js"></script>
275
+ <script type="module" crossorigin src="/assets/__vite-browser-external-VmN0WaC3.js"></script>
276
276
  <link rel="stylesheet" crossorigin href="/assets/__vite-browser-external-Bg0J-a5P.css">
277
277
  </head>
278
278
  <body>
@@ -164,7 +164,7 @@
164
164
  ]
165
165
  }
166
166
  </script>
167
- <script type="module" crossorigin src="/assets/__vite-browser-external-C_FI6biS.js"></script>
167
+ <script type="module" crossorigin src="/assets/__vite-browser-external-VmN0WaC3.js"></script>
168
168
  <link rel="stylesheet" crossorigin href="/assets/__vite-browser-external-Bg0J-a5P.css">
169
169
  </head>
170
170
  <body>
@@ -135,7 +135,7 @@
135
135
  ]
136
136
  }
137
137
  </script>
138
- <script type="module" crossorigin src="/assets/__vite-browser-external-C_FI6biS.js"></script>
138
+ <script type="module" crossorigin src="/assets/__vite-browser-external-VmN0WaC3.js"></script>
139
139
  <link rel="stylesheet" crossorigin href="/assets/__vite-browser-external-Bg0J-a5P.css">
140
140
  </head>
141
141
  <body>
@@ -75,7 +75,7 @@
75
75
  "description": "Shareable Token Tracker dashboard snapshot."
76
76
  }
77
77
  </script>
78
- <script type="module" crossorigin src="/assets/__vite-browser-external-C_FI6biS.js"></script>
78
+ <script type="module" crossorigin src="/assets/__vite-browser-external-VmN0WaC3.js"></script>
79
79
  <link rel="stylesheet" crossorigin href="/assets/__vite-browser-external-Bg0J-a5P.css">
80
80
  </head>
81
81
  <body>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tokentracker-cli",
3
- "version": "1.1.9",
3
+ "version": "1.1.11",
4
4
  "description": "Local-first AI coding token usage and cost tracker for 43 tools, with a dashboard, desktop pet, widgets, achievements, and native macOS/Windows apps.",
5
5
  "main": "src/cli.js",
6
6
  "bin": {
@@ -2261,7 +2261,7 @@ async function runFirstSyncAndRead({ trackerBinPath, trackerDir, packageName })
2261
2261
  return readFirstSyncTotals(trackerDir);
2262
2262
  }
2263
2263
  const fallbackPkg = packageName || "tokentracker-cli";
2264
- const argv = ["sync", "--drain"];
2264
+ const argv = ["sync", "--auto", "--drain"];
2265
2265
  const hasLocalRuntime = typeof trackerBinPath === "string" && fssync.existsSync(trackerBinPath);
2266
2266
  const cmd = hasLocalRuntime
2267
2267
  ? [process.execPath, trackerBinPath, ...argv]
@@ -180,6 +180,7 @@ const {
180
180
  openCursorStore,
181
181
  } = require("../lib/cursor-store");
182
182
  const { resolveTrackerPaths } = require("../lib/tracker-paths");
183
+ const { readCloudSyncEnabled } = require("../lib/cloud-sync-prefs");
183
184
  const {
184
185
  appendUniqueDirs,
185
186
  extraScanRootPaths,
@@ -529,6 +530,11 @@ async function cmdSync(argv, context = {}) {
529
530
  const syncDiagnostics = diagnostics && typeof diagnostics === "object" ? diagnostics : null;
530
531
  const home = os.homedir();
531
532
  const { trackerDir } = await resolveTrackerPaths({ home });
533
+ // Manual CLI sync is a one-time upload request, without changing the toggle.
534
+ // Hooks, native publication and detached retries must honor the saved opt-in.
535
+ const requiresCloudSyncPref = opts.auto || opts.background || opts.fromRetry || opts.fromNotify || opts.fromOpenclaw ||
536
+ Boolean(process.env.TOKENTRACKER_LOCAL_SYNC_ATTEMPT_ID);
537
+ const canUpload = () => !requiresCloudSyncPref || readCloudSyncEnabled(trackerDir);
532
538
 
533
539
  await ensureDir(trackerDir);
534
540
  if (opts.fromOpenclaw) {
@@ -563,7 +569,7 @@ async function cmdSync(argv, context = {}) {
563
569
  // Native publication owns backlog and failure-backoff retries on its next
564
570
  // five-minute tick. Remove any legacy detached retry marker immediately so
565
571
  // an already-sleeping retry process observes the missing marker and exits.
566
- if (opts.publishAccount) {
572
+ if (opts.publishAccount || !canUpload()) {
567
573
  await clearAutoRetry(trackerDir);
568
574
  }
569
575
 
@@ -3337,13 +3343,25 @@ async function cmdSync(argv, context = {}) {
3337
3343
  if (legacyBaseUrlMigration?.replacementDeviceToken) {
3338
3344
  runtimeConfig.deviceToken = legacyBaseUrlMigration.replacementDeviceToken;
3339
3345
  }
3340
- const runtime = resolveRuntimeConfig({ config: runtimeConfig, env: process.env });
3346
+ // An authenticated local API supplies this capability for this upload.
3347
+ // Keep a separately configured CLI account from overriding its owner.
3348
+ const runtime = resolveRuntimeConfig({
3349
+ cli: {
3350
+ deviceToken: process.env.TOKENTRACKER_LOCAL_SYNC_DEVICE_TOKEN,
3351
+ ...(process.env.TOKENTRACKER_LOCAL_SYNC_DEVICE_TOKEN ? {
3352
+ baseUrl: process.env.TOKENTRACKER_INSFORGE_BASE_URL,
3353
+ anonKey: process.env.TOKENTRACKER_INSFORGE_ANON_KEY,
3354
+ } : {}),
3355
+ },
3356
+ config: runtimeConfig,
3357
+ env: process.env,
3358
+ });
3341
3359
 
3342
3360
  let uploadResult = { inserted: 0, skipped: 0 };
3343
3361
  let uploadAttempted = false;
3344
3362
  let autoUploadDecision = null;
3345
3363
 
3346
- if ((opts.auto || opts.publishAccount) && runtime.deviceToken && runtime.baseUrl &&
3364
+ if (canUpload() && (opts.auto || opts.publishAccount) && runtime.deviceToken && runtime.baseUrl &&
3347
3365
  (!isBackgroundLightweightSync || opts.publishAccount)) {
3348
3366
  const uploadStateBefore = (await readJson(queueStatePath)) || { offset: 0 };
3349
3367
  const queueSizeBefore = await safeStatSize(queuePath);
@@ -3379,7 +3397,7 @@ async function cmdSync(argv, context = {}) {
3379
3397
  }
3380
3398
  }
3381
3399
 
3382
- if (runtime.deviceToken && runtime.baseUrl &&
3400
+ if (canUpload() && runtime.deviceToken && runtime.baseUrl &&
3383
3401
  (!isBackgroundLightweightSync || opts.publishAccount) &&
3384
3402
  (!autoUploadDecision || autoUploadDecision.allowed)) {
3385
3403
  uploadAttempted = true;
@@ -3403,6 +3421,7 @@ async function cmdSync(argv, context = {}) {
3403
3421
  queueStatePath,
3404
3422
  maxBatches: opts.drain ? 100 : (autoUploadDecision?.maxBatches || 5),
3405
3423
  batchSize: autoUploadDecision?.batchSize || 200,
3424
+ canUpload,
3406
3425
  });
3407
3426
  try {
3408
3427
  uploadResult = await drainWithToken(successfulDeviceToken);
@@ -3464,6 +3483,7 @@ async function cmdSync(argv, context = {}) {
3464
3483
  nowMs: Date.now(),
3465
3484
  state: uploadThrottleState,
3466
3485
  error: e,
3486
+ attemptId: process.env.TOKENTRACKER_LOCAL_SYNC_ATTEMPT_ID,
3467
3487
  });
3468
3488
  await writeJson(uploadThrottlePath, uploadThrottleState);
3469
3489
  if (!opts.auto) {
@@ -3483,7 +3503,7 @@ async function cmdSync(argv, context = {}) {
3483
3503
  // and can keep auto retry alive even after cloud sync has drained.
3484
3504
  const pendingBytes = Math.max(0, queueSize - Number(afterState.offset || 0));
3485
3505
 
3486
- if (pendingBytes <= 0) {
3506
+ if (pendingBytes <= 0 || !canUpload()) {
3487
3507
  await clearAutoRetry(trackerDir);
3488
3508
  } else if (opts.auto && uploadAttempted && !opts.publishAccount) {
3489
3509
  const retryAtMs = Number(uploadThrottleState?.nextAllowedAtMs || 0);
@@ -4137,7 +4157,7 @@ const AUTO_RETRY_MAX_DELAY_MS = 2 * 60 * 60 * 1000;
4137
4157
  const INGEST_SLUG = "tokentracker-ingest";
4138
4158
  const MAX_INGEST_BUCKETS = 500;
4139
4159
 
4140
- async function drainQueueToCloud({ baseUrl, anonKey, deviceToken, queuePath, queueStatePath, maxBatches = 5, batchSize = 200 }) {
4160
+ async function drainQueueToCloud({ baseUrl, anonKey, deviceToken, queuePath, queueStatePath, maxBatches = 5, batchSize = 200, canUpload = () => true }) {
4141
4161
  const state = (await readJson(queueStatePath)) || { offset: 0 };
4142
4162
  let offset = Number(state.offset || 0);
4143
4163
  let inserted = 0;
@@ -4162,6 +4182,8 @@ async function drainQueueToCloud({ baseUrl, anonKey, deviceToken, queuePath, que
4162
4182
  Authorization: `Bearer ${deviceToken}`,
4163
4183
  };
4164
4184
  if (anonKey) headers.apikey = anonKey;
4185
+ // Re-read after parsing/each batch so switching off stops an active drain.
4186
+ if (!canUpload()) break;
4165
4187
  const res = await fetchFunctionResponse(functionUrlFor(root, INGEST_SLUG), {
4166
4188
  method: "POST",
4167
4189
  headers,
@@ -123,16 +123,22 @@ let sessionGeneration = 0;
123
123
  // Mirrors the params `fetchAccountFunction` actually puts on the wire, so two
124
124
  // requests share an entry only when they would have produced the same URL.
125
125
  function payloadCacheKey({ root, sub, slug, searchParams }) {
126
- const pairs = [];
126
+ const params = accountFunctionParams(slug, searchParams);
127
+ params.sort();
128
+ return `${root}\0${sub}\0${slug}\0${params}`;
129
+ }
130
+
131
+ function accountFunctionParams(slug, searchParams) {
132
+ const params = new URLSearchParams();
127
133
  if (searchParams && typeof searchParams.entries === "function") {
128
134
  for (const [key, value] of searchParams.entries()) {
129
135
  if (key === "account" || key === "scope" || key === "refresh") continue;
130
136
  if (value == null || value === "") continue;
131
- pairs.push(`${key}=${String(value)}`);
137
+ params.set(key, String(value));
132
138
  }
133
139
  }
134
- pairs.sort();
135
- return `${root}\0${sub}\0${slug}\0${pairs.join("&")}`;
140
+ if (slug === HEATMAP_ACCOUNT_SLUG) params.set("format", "compact");
141
+ return params;
136
142
  }
137
143
 
138
144
  function payloadCacheGet(key, now) {
@@ -358,13 +364,7 @@ async function fetchAccountFunction({
358
364
  } = {}) {
359
365
  const root = String(baseUrl || DEFAULT_BASE_URL).replace(/\/$/, "");
360
366
  const url = new URL(functionUrlFor(root, slug));
361
- if (searchParams && typeof searchParams.entries === "function") {
362
- for (const [key, value] of searchParams.entries()) {
363
- if (key === "account" || key === "scope" || key === "refresh") continue;
364
- if (value != null && value !== "") url.searchParams.set(key, String(value));
365
- }
366
- }
367
- if (slug === HEATMAP_ACCOUNT_SLUG) url.searchParams.set("format", "compact");
367
+ url.search = accountFunctionParams(slug, searchParams).toString();
368
368
  const headers = { Accept: "application/json", Authorization: `Bearer ${accessToken}` };
369
369
  if (anonKey) headers.apikey = anonKey;
370
370
 
@@ -412,6 +412,7 @@ async function fetchAccountUsage({
412
412
  fetchImpl = fetch,
413
413
  now = Date.now,
414
414
  timeoutMs,
415
+ onSessionRefreshed,
415
416
  } = {}) {
416
417
  const slug = accountSlugFor(usageSlug);
417
418
  if (!slug) return null;
@@ -443,6 +444,15 @@ async function fetchAccountUsage({
443
444
  throw new AccountAuthError("auth_session_changed", "account session changed during token refresh");
444
445
  }
445
446
 
447
+ // The refresh already consumed the old credential. Persist its replacement
448
+ // before an edge read can wait, fail, or overlap a different account query.
449
+ if (typeof onSessionRefreshed === "function" && (minted.refreshToken || minted.csrfToken)) {
450
+ await onSessionRefreshed({ refreshToken: minted.refreshToken, csrfToken: minted.csrfToken });
451
+ if (sessionAtStart !== sessionGeneration) {
452
+ throw new AccountAuthError("auth_session_changed", "account session changed during token persistence");
453
+ }
454
+ }
455
+
446
456
  // Keyed after the mint so rotation cannot invalidate the entry, and so a
447
457
  // revoked session fails here rather than being served from cache.
448
458
  const sub = decodeJwtSub(minted.accessToken);
@@ -485,8 +495,9 @@ async function fetchAccountUsage({
485
495
  }
486
496
  return JSON.stringify(data);
487
497
  } catch (error) {
488
- if (error.status === 401 || error.status === 403) {
498
+ if ((error.status === 401 || error.status === 403) && sessionAtStart === sessionGeneration) {
489
499
  invalidateCloudAccountPayloadCache({ sessionChanged: true });
500
+ error.invalidatedSessionGeneration = sessionGeneration;
490
501
  }
491
502
  throw error;
492
503
  }
@@ -0,0 +1,74 @@
1
+ const fs = require("node:fs");
2
+ const path = require("node:path");
3
+ const crypto = require("node:crypto");
4
+
5
+ function validBinding(binding) {
6
+ return ["userId", "baseUrl", "machineId"].every(
7
+ (key) => typeof binding?.[key] === "string" && binding[key].length > 0,
8
+ );
9
+ }
10
+
11
+ // A successful auth refresh supplies the binding. This file never imports a
12
+ // CLI config token, whose owner may belong to another signed-in account.
13
+ function createCloudDeviceTokenStore(filePath) {
14
+ let loaded = false;
15
+ let entry = null;
16
+
17
+ function load() {
18
+ if (loaded) return entry;
19
+ loaded = true;
20
+ let fd;
21
+ try {
22
+ fd = fs.openSync(filePath, fs.constants.O_RDONLY | (fs.constants.O_NOFOLLOW || 0));
23
+ if (!fs.fstatSync(fd).isFile()) return null;
24
+ fs.fchmodSync(fd, 0o600);
25
+ const data = JSON.parse(fs.readFileSync(fd, "utf8"));
26
+ if (data?.version === 1 && validBinding(data) && typeof data.token === "string" && data.token) entry = data;
27
+ } catch { /* missing or invalid cache requires ordinary issuance */ }
28
+ finally { if (fd !== undefined) fs.closeSync(fd); }
29
+ return entry;
30
+ }
31
+
32
+ function clear(binding) {
33
+ if (binding && (!validBinding(binding) || ["userId", "baseUrl", "machineId"].some((key) => load()?.[key] !== binding[key]))) return;
34
+ loaded = true;
35
+ entry = null;
36
+ try { fs.unlinkSync(filePath); } catch { /* cache may not exist */ }
37
+ }
38
+
39
+ return {
40
+ get(binding) {
41
+ if (!validBinding(binding)) return null;
42
+ const value = load();
43
+ if (!value) return null;
44
+ if (value.userId !== binding.userId) {
45
+ clear();
46
+ return null;
47
+ }
48
+ return value.baseUrl === binding.baseUrl && value.machineId === binding.machineId ? value.token : null;
49
+ },
50
+ set(binding, token) {
51
+ if (!validBinding(binding) || typeof token !== "string" || !token) return false;
52
+ const value = { version: 1, userId: binding.userId, baseUrl: binding.baseUrl, machineId: binding.machineId, token };
53
+ if (JSON.stringify(load()) === JSON.stringify(value)) return true;
54
+ loaded = true;
55
+ entry = value;
56
+ const tmp = `${filePath}.tmp.${crypto.randomUUID()}`;
57
+ try {
58
+ fs.mkdirSync(path.dirname(filePath), { recursive: true });
59
+ fs.writeFileSync(tmp, JSON.stringify(value) + "\n", { encoding: "utf8", mode: 0o600, flag: "wx" });
60
+ fs.renameSync(tmp, filePath);
61
+ return true;
62
+ } catch {
63
+ try { fs.unlinkSync(tmp); } catch { /* no temporary file to remove */ }
64
+ return false;
65
+ }
66
+ },
67
+ invalidate(token) {
68
+ if (typeof token === "string" && token && load()?.token === token) clear();
69
+ },
70
+ clear,
71
+ };
72
+ }
73
+
74
+ module.exports = { createCloudDeviceTokenStore };
@@ -0,0 +1,14 @@
1
+ const fs = require("node:fs");
2
+ const path = require("node:path");
3
+
4
+ // The dashboard mirrors saved choices here. Missing or invalid preferences
5
+ // must never enable automatic uploads merely because credentials exist.
6
+ function readCloudSyncEnabled(trackerDir) {
7
+ try {
8
+ return JSON.parse(fs.readFileSync(path.join(trackerDir, "cloud-sync-pref.json"), "utf8"))?.enabled === true;
9
+ } catch {
10
+ return false;
11
+ }
12
+ }
13
+
14
+ module.exports = { readCloudSyncEnabled };