dsh-cost-meter 1.9.39 → 1.9.41
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +588 -588
- package/README.zh-CN.md +592 -592
- package/docs/billion-context-billing.md +4 -4
- package/docs/display-settings.md +1 -1
- package/docs/ledger-lock-recovery.md +12 -0
- package/docs/update-notes-1.9.31.md +1 -1
- package/docs/update-notes-1.9.40.md +25 -0
- package/docs/update-notes-1.9.41.md +29 -0
- package/lib/balance-retry.js +23 -0
- package/lib/client.display.js +3 -3
- package/lib/client.js +6 -6
- package/lib/client.settings-overview.js +1 -1
- package/lib/client.statistics.js +8 -8
- package/lib/custom-balance.js +2 -1
- package/lib/external-usage.js +119 -119
- package/lib/index.js +12 -8
- package/lib/ledger-persistence.js +43 -7
- package/lib/ledger-totals.js +57 -57
- package/lib/ledger-writer-worker.js +1 -1
- package/lib/store.js +27 -2
- package/package.json +4 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
window.__ModuleLoader__.load({id:"dsh-cost-meter",chunk:"client.settings-overview.js",factory:B=>{const{createElement:
|
|
1
|
+
window.__ModuleLoader__.load({id:"dsh-cost-meter",chunk:"client.settings-overview.js",factory:B=>{const{createElement:o,Fragment:Q}=B("react");function C({state:i,snapshot:m,helpers:s,resolveLocale:P,formatMoneyUsd:T,formatTokens:N}){const t=i?.config??{activeLocale:m?.locale},b=P(t),l=s.makeT(b),g=(e,c)=>b==="en"?c:e,v=s.useCodexQuota(t.codexQuotaEnabled===!0,t.codexQuotaSource);if(!i)return o("div",{className:"cm-section",role:m?.error?"alert":"status"},m?.error||l(m?.status==="loading"?"readingLedger":"ledgerUnavailable"));const f=(e,c,n)=>o("section",{key:e,className:"cm-budget","data-overview-source":e},o("h3",{className:"cm-h"},c),n),d=e=>o("p",{className:"cm-note"},e),W=e=>e?.fetchedAt>0?d(l("goQuotaFetchedAt",{time:new Date(e.fetchedAt).toLocaleString(b==="en"?"en-US":"zh-CN")})):null,w=(e,c)=>o(Q,null,["ok","partial"].includes(e?.status)?c:o("p",{className:e?.status==="error"?"cm-err":"cm-note",role:e?.status==="error"?"alert":void 0},e?.message||l("codingPlanNotQueried")),["ok","partial"].includes(e?.status)&&e.message?d(e.message):null,W(e)),p=(e,c)=>{const n=(s.codingPlanWindowEntries?s.codingPlanWindowEntries(e,c):Object.entries(e??{})).filter(([,a])=>a!=null);return n.length?o("div",{className:"cm-go-list"},n.map(([a,u])=>s.quotaWindowRow(l,(u.label||s.codingPlanWindowLabel(a==="five"?"5h":a,l))+(typeof u.percent=="number"?g(" · 剩余"," · remaining"):""),u,"remaining",!1,a))):d(l("codingPlanNotQueried"))},r=[];if(t.balance?.display!=="off"&&t.hideOfficialBalance!==!0){const e=i.balance;r.push(f("balance",l("accountBalance"),w(e,o("div",{className:"cm-card-value cm-num"},e?.totalBalance==null?"—":s.formatBalanceMoney(e.totalBalance,t,e.currency)))))}if(t.goQuota?.enabled!==!1&&t.goQuota?.display!=="off"){const e=i.goQuota;r.push(f("go",l("goQuotaTitle"),w(e,p({[l("goWindowRolling")]:e?.rolling,[l("goWindowWeekly")]:e?.weekly,[l("goWindowMonthly")]:e?.monthly}))))}t.codexQuotaEnabled===!0&&r.push(f("codex",l("codexQuotaTitle"),w(v,p(v.windows))));for(const{id:e,labelKey:c}of s.CODING_PLAN_ROWS){const n=t.codingPlans?.[e],a=i.codingPlans?.[e];n?.enabled===!0&&n.display!=="off"&&r.push(f(e,l(c),w(a,p(a?.windows,e))))}(t.customBalances?.length?t.customBalances:t.customBalance?[t.customBalance]:[]).forEach((e,c)=>{if(!e.enabled||e.display==="off")return;const n=i.customBalances?.find(a=>a.index===c)??(c===0&&!i.customBalances?.length?i.customBalance:null);r.push(f("custom-"+c,b==="en"&&e.labelEn||e.label||l("customBalanceTitle"),w(n,o("div",{className:"cm-card-value cm-num"},n?.remaining==null?"—":s.formatCustomBalanceMoney(n.remaining,t,n,e)))))});for(const e of t.gatewayQuotas?.sources??[]){if(!e.enabled||e.display==="off")continue;const c=i.gatewayQuotas?.find(a=>a.id===e.id),n=(a,u)=>a?o("p",{key:u,className:"cm-note cm-num"},(a.label||a.unit||"Credits")+" · "+g("剩余 ","Remaining ")+(a.remaining??"—")+" / "+(a.limit??"—")):null;r.push(f("gateway-"+e.id,e.label||e.id,w(c,c?.accounts?.length?c.accounts.map((a,u)=>o("div",{key:a.id||u},o("h4",{className:"cm-h"},a.label||a.provider),a.message?d(a.message):null,p(Object.fromEntries((a.windows??[]).map((h,y)=>[h.id||y,h]))),n(a.credits),(a.credits?.packages??[]).map((h,y)=>n(h,h.id||y)))):d(l("gatewaySourceNoAccounts")))))}return o("div",{className:"cm-section","data-settings-overview":!0},d(g("费用和额度随当前数据更新。调整配置请前往「插件 → 费用计量」。","Costs and quotas update with the current data. Configure them in Plugins → Cost meter.")),m?.error?o("p",{className:"cm-err",role:"alert"},l("ledgerReadFailed",{message:m.error})):null,o("div",{className:"cm-overview-grid"},o("div",{className:"cm-cards",style:{"--cm-overview-count":t.hideTodayCost===!0?2:3}},[["today","cardToday"],["month","cardMonth"],["total","cardTotal"]].filter(([e])=>e!=="today"||t.hideTodayCost!==!0).map(([e,c])=>{const n=i[e];return o(s.Card,{key:e,title:l(c),value:T(s.displayCostOf(n,t),t),sub:l("callsTokens",{calls:n.calls,input:N(n.input),cache:N(n.cacheRead+n.cacheWrite),output:N(n.output)})})}))),d(l("cardsFootnote")),o(s.BillingAccuracyNote,{state:i}),d(l("cardsTogglePlanTotal")+": "+g(t.showTotalWithPlan?"已开启":"已关闭",t.showTotalWithPlan?"On":"Off")),t.budget?.enabled&&t.hideBudget!==!0?o(s.BudgetBoxContent,{state:i,wide:!0}):null,o("h3",{className:"cm-h"},g("余额与额度","Balances and quotas")),r.length?o("div",{className:"cm-quota-list"},r):d(g("尚未启用余额或额度来源。","No balance or quota sources enabled.")),o(s.UsagePanel,{state:i,t:l,locale:b}),o("h3",{className:"cm-h"},l("todaySessions")),o(s.TodaySessions,{state:i}))}return{mount:()=>C}}});
|