dsh-cost-meter 1.9.47 → 1.9.49
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 +8 -8
- package/README.zh-CN.md +8 -8
- package/docs/billing-currency.md +21 -0
- package/docs/billing-review-2026-11-02.md +32 -0
- package/docs/display-settings.md +67 -61
- package/docs/native-search-billing.md +48 -0
- package/docs/plugin-compatibility-watch.md +4 -0
- package/docs/update-notes-1.9.48.md +26 -0
- package/docs/update-notes-1.9.49.md +30 -0
- package/docs/web-request-fees.md +52 -32
- package/lib/billing-storage-cli.js +8 -3
- package/lib/client.billing-storage.js +1 -1
- package/lib/client.codex.js +1 -1
- package/lib/client.community.js +1 -1
- package/lib/client.display.js +2 -2
- package/lib/client.js +8 -6
- package/lib/client.notices.js +1 -1
- package/lib/client.openrouter.js +2 -2
- package/lib/client.peak.js +3 -3
- package/lib/client.plan-settings.js +1 -1
- package/lib/client.pricing.js +2 -2
- package/lib/client.session-list.js +2 -2
- package/lib/client.settings-overview.js +1 -1
- package/lib/client.sidebar-order.js +3 -3
- package/lib/client.statistics.js +8 -8
- package/lib/ledger-persistence.js +1 -1
- package/lib/ledger-writer-worker.js +1 -1
- package/lib/native-search-billing.js +3 -1
- package/lib/native-search-fetch.js +48 -38
- package/lib/native-search-history.js +1 -0
- package/lib/native-search-manual.js +54 -0
- package/lib/store.js +3 -0
- package/lib/typert.host.js +1 -0
- package/package.json +7 -2
package/lib/client.notices.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
window.__ModuleLoader__.load({id:"dsh-cost-meter",chunk:"client.notices.js",factory(
|
|
1
|
+
;(function(e){const r=window.__ModuleLoader__,c=r[Symbol.for("@dsh-plugin/dsh-loader:load-wrap")];return(e.id==="dsh-cost-meter"&&r.load===c?.ours&&typeof c.original=="function"?c.original:r.load).call(r,e)})({id:"dsh-cost-meter",chunk:"client.notices.js",factory(E){const{createElement:e,useRef:r,useState:c,useEffect:y}=E("react"),g="dsh-cost-meter:display-onboarding-seen",h=["dsh-cost-meter:simple-guide-dismissed","dsh-cost-meter:balance-click-hint-seen","dsh-cost-meter:peak-progress-intro-v1","dsh-cost-meter:sidebar-summary-intro-v1"],C=["sidebarSimplePromptSeen","sidebarSummaryPromptSeen","peakProgressPromptSeen"],d=new Set;let l=!1;const P=()=>{if(l)return!0;try{return[g,...h].some(n=>window.localStorage.getItem(n)==="1")}catch{return!1}},_=n=>P()||C.some(o=>n[o]===!0)||n.quotaStrip?.promptSeen===!0||n.balance?.clickHintSeen===!0,m=()=>{const n=l?null:[...d].find(o=>o.ready);for(const o of d)o.update(o===n)},A=()=>{l=!0;for(const n of[g,...h])try{window.localStorage.setItem(n,"1")}catch{}m()};function F({FloatingCard:n,makeT:o,resolveLocale:O}){return function(q){const i=q.useCost?.(t=>t)?.state?.config,j=r(!1),S=r(null),[w,M]=c(!1),v=!!i&&!_(i);if(y(()=>{if(!v)return;const t={update:M,ready:!1},s=()=>{const f=document.querySelectorAll?.('dialog[open],[role="dialog"],[aria-modal="true"]')??[];t.ready=!document.hidden&&![...f].some(N=>!N.matches("[data-cm-onboarding]")&&N.getClientRects().length),m()},a=f=>{[g,...h].includes(f.key)&&f.newValue==="1"&&(l=!0,m())};d.add(t),s();let u=null;const G=()=>{u===null&&(u=window.requestAnimationFrame(()=>{u=null,s()}))},L=typeof MutationObserver=="function"?new MutationObserver(G):null;return document.body&&L?.observe(document.body,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["open","hidden","aria-modal","class","style"]}),document.addEventListener?.("visibilitychange",s),window.addEventListener?.("storage",a),()=>{L?.disconnect(),u!==null&&window.cancelAnimationFrame(u),document.removeEventListener?.("visibilitychange",s),d.delete(t),m(),window.removeEventListener?.("storage",a)}},[v]),y(()=>{w&&(S.current=document.activeElement)},[w]),!v||!w)return null;const k=o(O(i)),D=O(i)==="en",p=(t,s)=>D?s:t,b=()=>{if(j.current||l)return;j.current=!0;const t=document.activeElement?.closest?.("[data-cm-onboarding]");A(),t&&S.current?.isConnected&&S.current.focus?.({preventScroll:!0});const s=Object.fromEntries(C.filter(a=>Object.hasOwn(i,a)).map(a=>[a,!0]));Object.hasOwn(i.quotaStrip??{},"promptSeen")&&(s.quotaStrip={promptSeen:!0}),Object.hasOwn(i.balance??{},"clickHintSeen")&&(s.balance={clickHintSeen:!0}),Object.keys(s).length&&Promise.resolve().then(()=>q.api?.updateConfig(s)).catch(()=>{})};return e(n,{actions:{dismiss:b},className:"cm-qguide",role:"dialog","data-cm-onboarding":"","aria-label":p("按需设置费用显示","Set up your cost display"),onKeyDown:t=>{t.key==="Escape"&&(t.stopPropagation(),b())}},e("div",{className:"cm-bbox-head"},e("h4",null,p("按需设置费用显示","Set up your cost display")),e("button",{type:"button",className:"cm-btn small","aria-label":k("closeGuide"),"data-cm-action":"dismiss",onClick:b},"×")),e("p",null,p("在「设置 → 费用 → 显示」中统一选择侧栏样式、额度横条和峰谷进度,随时可改;现在无需设置。","Choose sidebar styles, the quota strip and pricing-period progress in Settings → Cost → Display. You can change them anytime; no setup is required now.")),e("p",null,k("balanceClickGuideBody")),e("p",null,p("关闭提示会保留当前显示、余额与计费设置。","Dismissing this guide keeps your display, balance and billing settings unchanged.")),e("div",{className:"cm-buttons"},e("button",{type:"button",className:"cm-btn small primary","data-cm-action":"dismiss",onClick:b},k("balanceClickGuideOk"))))}}return{mount:F}}});
|
package/lib/client.openrouter.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
window.__ModuleLoader__.load({id:"dsh-cost-meter",chunk:"client.openrouter.js",factory:
|
|
2
|
-
`)}function
|
|
1
|
+
;(function(x){const i=window.__ModuleLoader__,y=i[Symbol.for("@dsh-plugin/dsh-loader:load-wrap")];return(x.id==="dsh-cost-meter"&&i.load===y?.ours&&typeof y.original=="function"?y.original:i.load).call(i,x)})({id:"dsh-cost-meter",chunk:"client.openrouter.js",factory:W=>{const x=W("react"),{createElement:i,useState:y,useEffect:q,useRef:G}=x;function L(r){if(!r||typeof r.fetchedAt!="string"||typeof r.stale!="boolean"||typeof r.error!="string"||!Array.isArray(r.models))throw new Error("Invalid OpenRouter catalog");const o=a=>typeof a=="number"&&Number.isFinite(a)&&a>=0;for(const a of r.models)if(!a||typeof a.id!="string"||typeof a.name!="string"||!o(a.input)||!o(a.output)||!["cachedInput","cacheWrite"].every(s=>a[s]===null||o(a[s]))||!(a.contextLength===null||Number.isSafeInteger(a.contextLength)&&a.contextLength>=0))throw new Error("Invalid OpenRouter model price");return r}const U={parse:L},T={package:"dsh-cost-meter-openrouter",face:"host",descriptors:[{id:"dsh-cost-meter#costMeter/getOpenRouterCatalog",service:"costMeter",namespace:"costMeter",method:"getOpenRouterCatalog",invocation:{kind:"direct"},parameters:[],result:{mode:"strict",typeSymbol:"dsh-cost-meter#OpenRouterCatalog",schema:U,create:()=>U}}]},_=r=>"https://openrouter.ai/"+r.split("/").map(encodeURIComponent).join("/"),M=r=>r===null?"—":"$"+String(r),$=(r,o)=>{const a=new Map((r?.models??[]).map(s=>[s.id,s]));return new Set(o.models.filter(s=>a.has(s.id)&&["input","output","cachedInput","cacheWrite"].some(e=>a.get(s.id)[e]!==s[e])).map(s=>s.id))},P=new WeakMap,K=r=>(P.has(r)||P.set(r,{value:null,error:"",checkedAt:0,pending:null,changed:new Set,query:"",sort:"name",page:0}),P.get(r)),Q=(r,o)=>(o.pending||(o.pending=Promise.resolve().then(()=>r.getOpenRouterCatalog()).then(a=>{const s=L(a);return!s.stale&&s.fetchedAt!==o.value?.fetchedAt&&(o.changed=$(o.value,s)),o.value=s.error&&!s.models.length&&o.value?.models.length?{...o.value,stale:!0,error:s.error}:s,o.error=s.error,o.value}).catch(a=>{throw o.error=String(a?.message??a),a}).finally(()=>{o.checkedAt=Date.now(),o.pending=null})),o.pending);function j({api:r,state:o,resolveLocale:a}){const s=a(o.config)==="en",e=(n,u)=>s?u:n,t=K(r),[c,l]=y(()=>t.value),[d,g]=y(()=>t.error),[b,S]=y(!1),[w,E]=y(()=>t.query),[R,C]=y(()=>t.sort),[N,O]=y(()=>t.page),[D,p]=y(()=>t.changed),m=G(()=>{});q(()=>{let n=!0,u=!1;const A=async(J=!1)=>{if(!(!n||u||document.hidden)&&!(!J&&!t.pending&&t.value&&Date.now()-t.checkedAt<6e4)){u=!0,S(!0);try{const k=await Q(r,t);if(!n)return;p(t.changed),l(k),g(k.error)}catch(k){n&&g(String(k?.message??k))}finally{u=!1,n&&S(!1)}}},I=()=>A(!0);m.current=I,A();const H=setInterval(I,6e4);return document.addEventListener("visibilitychange",I),()=>{n=!1,clearInterval(H),document.removeEventListener("visibilitychange",I)}},[r]);const f=(c?.models??[]).filter(n=>(n.id+" "+n.name).toLowerCase().includes(w.trim().toLowerCase())).sort((n,u)=>(R==="name"?0:n[R]-u[R])||n.id.localeCompare(u.id)),h=Math.min(N,Math.max(0,Math.ceil(f.length/50)-1)),v=(n,u,A=!1)=>i("button",{type:"button",className:"cm-btn small",onClick:u,disabled:A},n);return i("section",{className:"cm-price-card","aria-label":e("OpenRouter 模型价格","OpenRouter model prices")},i("div",{className:"cm-price-head",style:{flexWrap:"wrap"}},i("h3",{className:"cm-h"},e("OpenRouter 模型价格","OpenRouter model prices")),v(b?e("刷新中…","Refreshing…"):e("刷新价格","Refresh prices"),()=>m.current(),b)),i("p",{className:"cm-note"},e("公开目录 · 美元 / 百万 tokens · 无需 API Key,不产生模型调用费用。优先显示上次价格,前台每分钟更新,也可手动刷新。","Public catalog · USD / million tokens · No API key or inference charges. Previous prices appear immediately; updates every minute while visible or on manual refresh.")),i("div",{className:"cm-buttons"},i("input",{className:"cm-input",type:"search",value:w,autoComplete:"off","aria-label":e("搜索 OpenRouter 模型","Search OpenRouter models"),placeholder:e("搜索模型,例如 flash","Search models, e.g. flash"),style:{flex:"1 1 180px",minWidth:0,maxWidth:"100%"},onChange:n=>{t.query=n.target.value,t.page=0,E(t.query),O(0)}}),i("select",{className:"cm-input",value:R,"aria-label":e("价格排序","Price order"),onChange:n=>{t.sort=n.target.value,t.page=0,C(t.sort),O(0)}},...[["name",e("按模型名称","Model name")],["input",e("输入价格从低到高","Input price: low to high")],["output",e("输出价格从低到高","Output price: low to high")]].map(([n,u])=>i("option",{key:n,value:n},u)))),i("p",{className:"cm-note",role:"status"},c?.fetchedAt?e("最近更新:","Last updated: ")+new Date(c.fetchedAt).toLocaleString(s?"en-US":"zh-CN"):e("尚未取得价格","Prices not loaded yet")),d?i("p",{className:"cm-msg err",role:"alert"},(c?.models.length?e("刷新失败,以下保留上次价格:","Refresh failed; previous prices are retained: "):e("价格查询失败:","Price lookup failed: "))+d):null,f.length?i("div",{className:"cm-scroll",tabIndex:0,"aria-label":e("OpenRouter 价格表","OpenRouter price table")},i("table",{className:"cm-table"},i("thead",null,i("tr",null,...[e("模型","Model"),e("输入","Input"),e("输出","Output"),e("缓存读取","Cache read"),e("缓存写入","Cache write"),e("上下文 tokens","Context tokens")].map((n,u)=>i("th",{key:n,scope:"col",className:u?"num":void 0},n)))),i("tbody",null,f.slice(h*50,h*50+50).map(n=>i("tr",{key:n.id},i("td",{style:{whiteSpace:"normal",minWidth:180,maxWidth:300,overflowWrap:"anywhere"}},i("a",{href:_(n.id),target:"_blank",rel:"noopener noreferrer",style:{color:"var(--dsw-alias-brand-primary)"}},n.name),i("div",{className:"cm-sess-id"},n.id),D.has(n.id)?i("span",{className:"cm-price-legacy"},e("价格已变动","Price changed")):null),...["input","output","cachedInput","cacheWrite"].map(u=>i("td",{key:u,className:"num"},M(n[u]))),i("td",{className:"num"},n.contextLength===null?"—":n.contextLength.toLocaleString())))))):i("p",{className:"cm-empty"},b&&!c?e("正在查询公开目录…","Loading public catalog…"):e("没有匹配的模型。","No matching models.")),i("div",{className:"cm-buttons"},i("span",{className:"cm-note"},f.length?`${h*50+1}–${Math.min((h+1)*50,f.length)} / ${f.length}`:"0"),v(e("上一页","Previous"),()=>{t.page=h-1,O(t.page)},h===0),v(e("下一页","Next"),()=>{t.page=h+1,O(t.page)},(h+1)*50>=f.length)),i("p",{className:"cm-note"},e("显示当前公开 token 参考价;— 表示目录未提供。具体路由、阶梯价格和图片、搜索等附加费用请点模型查看。优惠与实际结算以 OpenRouter 为准。","Current public token reference rates; — means unavailable. Open a model for routing, price tiers and extra image/search fees. Promotions and final charges are determined by OpenRouter.")))}function z(r,o){const a=r.querySelector('span[class$="_modelName"]')?.textContent,s=r.closest('section[role="group"][aria-labelledby]'),e=s&&document.getElementById(s.getAttribute("aria-labelledby"));if(!a||!e||!s.contains(e))return null;const t=o.filter(l=>l.name===e.textContent);if(t.length!==1||!["openrouter","llm-openrouter"].includes(t[0].id))return null;const c=t[0].models.filter(l=>l.name===a);return c.length===1?c[0]:null}function B(r,o,a,s=""){const e=a==="en",t=(d,g)=>e?g:d,c=o?.models.find(d=>d.id===r.id),l=[r.name,"OpenRouter · "+r.id];if(c){l.push(t("美元 / 百万 tokens","USD / million tokens"));for(const[d,g,b]of[["input","输入","Input"],["output","输出","Output"],["cachedInput","缓存读取","Cache read"],["cacheWrite","缓存写入","Cache write"]])l.push(t(g,b)+": "+M(c[d]));c.contextLength!==null&&l.push(t("上下文","Context")+": "+c.contextLength.toLocaleString()+" tokens")}else l.push(o?t("公开目录未提供此模型的 token 单价","Token price unavailable for this model in the public catalog"):s?t("价格查询失败","Price lookup failed"):t("正在查询公开价格…","Loading public prices…"));return o?.fetchedAt&&l.push(t("最近更新: ","Updated: ")+new Date(o.fetchedAt).toLocaleString(e?"en-US":"zh-CN")),(s||o?.stale)&&l.push(t("刷新失败,价格未更新","Refresh failed; prices have not been updated")),l.push(t("公开参考价;优惠与结算以 OpenRouter 为准","Public reference rates; promotions and billing follow OpenRouter")),l.join(`
|
|
2
|
+
`)}function F({api:r,getGroups:o,getLocale:a,subscribeGroups:s}){if(typeof MutationObserver!="function"||!document.body)return()=>{};const e='button[role="menuitemradio"]',t=new Map;let c=!0,l=!1,d=null,g="",b=-1/0;const S=(p,m)=>{p.getAttribute("title")===m.written&&(m.original===null?p.removeAttribute("title"):p.setAttribute("title",m.original)),t.delete(p)},w=(p=!0)=>{if(!c)return;const m=o(),f=new Map;for(const h of document.querySelectorAll(e)){const v=z(h,m);v&&f.set(h,v)}for(const[h,v]of t)f.has(h)||S(h,v);for(const[h,v]of f){let n=t.get(h);const u=h.getAttribute("title");(!n||u!==n.written)&&(n={original:u,written:null}),n.written=B(v,d,a(),g),t.set(h,n),u!==n.written&&h.setAttribute("title",n.written)}p&&f.size&&!document.hidden&&Date.now()-b>=15e3&&E()},E=async()=>{if(!(!c||l)){l=!0,b=Date.now();try{const p=await r.getOpenRouterCatalog();c&&(d=p,g=p.error)}catch(p){c&&(g=String(p?.message??p))}finally{l=!1,c&&w(!1)}}},R=new MutationObserver(p=>{p.some(m=>m.type==="attributes"?m.target.matches(e)&&m.target.getAttribute("title")!==t.get(m.target)?.written:m.type==="characterData"?m.target.parentElement?.closest(e):[...m.addedNodes,...m.removedNodes].some(f=>f.nodeType===1&&(f.matches(e)||f.querySelector(e))))&&w()});R.observe(document.body,{childList:!0,subtree:!0,characterData:!0,attributes:!0,attributeFilter:["title"]});const C=()=>{document.hidden||w()},N=p=>{p.target?.closest?.(e)&&w()};document.addEventListener("visibilitychange",C),document.addEventListener("pointerover",N),document.addEventListener("focusin",N);const O=setInterval(C,6e4),D=s?.(()=>w());return w(),()=>{c=!1,R.disconnect(),clearInterval(O),D?.(),document.removeEventListener("visibilitychange",C),document.removeEventListener("pointerover",N),document.removeEventListener("focusin",N);for(const[p,m]of t)S(p,m)}}async function V(r,o,a){const s=typeof o=="function"?o:()=>o&&a?a(o.getSnapshot().state?.config??{activeLocale:o.getSnapshot().locale}):r.get("locale")?.getSnapshot?.().active??"en",e=await r.get("remote").$mount(T);r.effect(()=>()=>e(),"cost-meter: OpenRouter catalog contribution");const t=document.createElement("style");t.textContent='@media (max-width:1023px){.cm-price-head{flex-wrap:wrap;gap:6px}.cm-scroll>.cm-table{min-width:520px}.cm-price-card{padding:10px 12px}}body[data-dsh-pocket-layout="mobile"] .cm-price-head{flex-wrap:wrap}',document.head.appendChild(t),r.effect(()=>()=>t.remove(),"cost-meter: OpenRouter responsive styles");const c=r.get("remote.costMeter"),l={getOpenRouterCatalog:async()=>{const d=await c.getOpenRouterCatalog();if(!d?.ok)throw new Error(d?.error?.message||"OpenRouter price lookup failed");return L(d.value)}};return typeof r.inject=="function"&&r.inject(["modelDirectories"],d=>{const g=d.get("modelDirectories")?.catalog?.store;g?.getSnapshot&&d.effect(()=>F({api:l,getGroups:()=>g.getSnapshot()?.value?.groups??[],getLocale:s,subscribeGroups:b=>g.subscribe?.(b)}),"cost-meter: model price tooltips")}),d=>i(j,{...d,api:l})}return{mount:V,PriceBrowser:j,CONTRIBUTION:T,parseCatalog:L,changedRates:$,priceText:M,modelUrl:_,pickerModel:z,priceTooltip:B,installPickerPrices:F}}});
|
package/lib/client.peak.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
window.__ModuleLoader__.load({id:"dsh-cost-meter",chunk:"client.peak.js",factory:
|
|
2
|
-
`,
|
|
3
|
-
`),l=
|
|
1
|
+
;(function(C){const e=window.__ModuleLoader__,y=e[Symbol.for("@dsh-plugin/dsh-loader:load-wrap")];return(C.id==="dsh-cost-meter"&&e.load===y?.ours&&typeof y.original=="function"?y.original:e.load).call(e,C)})({id:"dsh-cost-meter",chunk:"client.peak.js",factory:S=>{const C=S("react"),{createElement:e,useState:y,useEffect:I,Fragment:A}=C,L=`.cm-peak-progress{--peak-color:var(--dsw-alias-state-business-primary);min-width:0;padding:10px 2px 8px;display:flex;flex-direction:column;gap:7px;font-size:12px;line-height:1.35;font-variant-numeric:tabular-nums}.cm-peak-progress.peak{--peak-color:#ff9800}.cm-peak-progress-head,.cm-peak-progress-meta{display:flex;align-items:center;justify-content:space-between;gap:10px;min-width:0}.cm-peak-progress-phase{display:inline-flex;align-items:center;gap:6px;color:var(--peak-color);font-weight:600;white-space:nowrap}.cm-peak-progress-phase i{width:6px;height:6px;border-radius:50%;background:var(--peak-color);flex:none}.cm-peak-progress-time{font-size:11px;color:var(--dsw-alias-label-secondary);text-align:right;overflow-wrap:anywhere}.cm-peak-progress-track{height:6px;border-radius:99px;background:color-mix(in srgb,var(--peak-color) 12%,var(--dsw-alias-bg-layer-3));overflow:hidden;position:relative;width:100%}.cm-peak-progress-fill{height:100%;display:block;background:var(--peak-color);border-radius:inherit;position:relative}.cm-peak-progress-fill:after{content:"";position:absolute;right:2px;top:2px;width:2px;height:2px;background:#fff;border-radius:50%;opacity:.85}.cm-peak-progress-meta{font-size:10px;color:var(--dsw-alias-label-tertiary);gap:8px}.cm-peak-progress-meta span:last-child{text-align:right;color:var(--dsw-alias-label-secondary)}.cm-peak-progress.variant-simple{padding:2px 0;gap:3px;font-size:11px;line-height:14px}.cm-peak-progress.variant-simple .cm-peak-progress-time{font-size:10px;line-height:14px;white-space:nowrap}.cm-peak-progress.variant-simple .cm-peak-progress-track{height:4px}.cm-peak-progress.variant-simple .cm-peak-progress-meta{justify-content:flex-end;font-size:10px;line-height:12px}.cm-peak-progress.variant-simple .cm-peak-progress-phase{gap:5px}.cm-peak-progress.variant-compact{padding:2px 0;gap:7px;flex-direction:row;align-items:center;font-size:11px;line-height:16px;white-space:nowrap}.cm-peak-progress.variant-compact .cm-peak-progress-phase{gap:4px;flex:none}.cm-peak-progress.variant-compact .cm-peak-progress-phase i{width:5px;height:5px}.cm-peak-progress.variant-compact .cm-peak-progress-track{flex:1;min-width:20px;width:auto;height:4px}.cm-peak-progress.variant-compact .cm-peak-progress-time{flex:none;font-size:10px;line-height:16px;white-space:nowrap}.variant-simple .cm-peak-progress-fill:after,.variant-compact .cm-peak-progress-fill:after{top:1px;right:1px}.cm-footer-stack.simple>.cm-peak-progress{padding-left:10px;padding-right:10px;margin:0}.cm-peak-progress.rail{align-items:center;padding:4px 0;gap:4px}.cm-peak-progress.rail .cm-peak-progress-track{width:6px;height:42px;display:flex;align-items:flex-end}.cm-peak-progress.rail .cm-peak-progress-fill{width:100%}.cm-peak-progress-rail-label{font-size:10px;white-space:nowrap;color:var(--peak-color)}.cm-peak-progress.variant-summary{padding:0;border:0;border-radius:0;background:transparent;gap:2px;font-size:10px}.variant-summary .cm-peak-progress-head{gap:5px;align-items:baseline;flex-wrap:wrap}.cm-peak-summary-left{display:flex;gap:4px;align-items:center;flex-wrap:wrap;min-width:0}.cm-peak-summary-countdown,.variant-summary .cm-peak-progress-time{font-size:10px;white-space:nowrap;color:var(--dsw-alias-label-tertiary,#888)}.variant-summary .cm-peak-progress-track{height:3px}.variant-summary .cm-peak-progress-phase{font-weight:400}.cm-peak-progress.text-only:not(.rail){justify-content:space-between;flex-wrap:wrap;gap:2px 8px}.cm-peak-progress.text-only .cm-peak-progress-time{min-width:0;max-width:100%;white-space:normal}.cm-peak-progress.text-only .cm-peak-progress-phase i{display:none}
|
|
2
|
+
`,D="cm-peak-alert-preview";let O=0;function j(W){const{peakView:V,peakPhaseAt:H,peakPhaseForConfig:B=(r,c)=>H(c,r.peakWindows,r.peakHolidays),peakConfigForState:R=r=>r?.config,peakPeriodProgress:Z,usePeakClock:K,phaseLabelKeys:q,countdownText:z,resolveLocale:P,makeT:F,Tooltip:G,FloatingCard:J}=W;let N=document.getElementById("dsh-cost-meter-peak-style");N||(N=document.createElement("style"),N.id="dsh-cost-meter-peak-style",document.head.appendChild(N)),N.textContent=L;function Q(r,c){const a=V(r,c);if(!a)return null;const{start:o,progress:v}=Z(r,a,c),t=P(r)==="en"?"en":"zh-CN",i=n=>new Intl.DateTimeFormat(t,{timeZone:"Asia/Shanghai",hour:"2-digit",minute:"2-digit",hourCycle:"h23"}).format(n),u=n=>new Intl.DateTimeFormat("en-CA",{timeZone:"Asia/Shanghai",year:"numeric",month:"2-digit",day:"2-digit"}).format(n),w=n=>u(n)===u(c)?i(n):new Intl.DateTimeFormat(t,{timeZone:"Asia/Shanghai",...a.holiday||Math.abs(n-c)>=7*864e5?{month:"numeric",day:"numeric"}:{weekday:"short"}}).format(n)+" "+i(n);return{...a,start:o,progress:v,startText:w(o),switchTime:w(a.nextAtMs)}}function U({config:r,t:c,now:a,rail:o=!1}){const v=K(r,a),t=Q(r,v);if(!t)return null;const i=P(r)==="en",u=q(t),w=c(t.nextIntoPeak?"peakShort":"offPeakShort"),n=Math.max(1,Math.ceil((t.nextAtMs-v)/6e4)),g=Math.floor(n/1440),m=Math.floor(n%1440/60),d=n%60,x=g>0?i?g+"d "+m+"h"+(d?" "+d+"m":""):g+"天"+(m?m+"小时":"")+(d?d+"分":""):z(t,v,c),T=i?(g?g+"d ":"")+(m?m+"h ":"")+(d?d+"m":""):(g?g+"天":"")+(m?m+"时":"")+(d?d+"分":""),s=(i?"In ":"剩余 ")+x,p=t.switchTime+(i?" · ":" 转")+w,h=t.startText+" — "+t.switchTime,k=[c(u.notice),(i?"Beijing time · ":"北京时间 · ")+h,s+" · "+p,(i?"Elapsed ":"本时段已过 ")+t.progress.toFixed(1)+"%"].join(`
|
|
3
|
+
`),l=r.peakTimeDisplay??"both",f=r.sidebarTextOnly===!0,b=f?"compact":r.peakProgressVariant??(r.sidebarSimple?"simple":r.sidebarStyle==="compact"?"compact":"full"),Y=t.holiday?i?"Holiday · off-peak":"节假日 · 全天谷价":t.weekend?i?"Weekend · off-peak":"周末 · 全天谷价":c(u.short),M=t.holiday?i?"Holiday":"假日":t.weekend?i?"Weekend":"周末":c(u.short),_=ae=>e("span",{className:"cm-peak-progress-phase"},e("i",{"aria-hidden":!0}),ae),E=f?null:e("div",{className:"cm-peak-progress-track",role:"progressbar","aria-label":i?"Current pricing period elapsed":"当前计价时段已过进度","aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":Math.round(t.progress*10)/10,"aria-valuetext":k},e("span",{className:"cm-peak-progress-fill",style:{[o?"height":"width"]:t.progress+"%"}})),$=l==="countdown"?T:l==="switch"?t.switchTime+" → "+w:t.switchTime+" · "+T,ee=o?e(A,null,E,e("span",{className:"cm-peak-progress-rail-label"},M)):b==="summary"?e(A,null,e("div",{className:"cm-peak-progress-head"},e("span",{className:"cm-peak-summary-left"},_(M),l!=="switch"?e("span",{className:"cm-peak-summary-countdown"},(i?"In ":"剩余 ")+T):null),l!=="countdown"?e("span",{className:"cm-peak-progress-time"},p):null),E):b==="compact"?e(A,null,_(M),E,e("span",{className:"cm-peak-progress-time"},$)):b==="simple"?e(A,null,e("div",{className:"cm-peak-progress-head"},_(t.holiday||t.weekend?M+(i?" · off-peak":"谷价"):M),e("span",{className:"cm-peak-progress-time"},l==="switch"?p:s)),E,l==="both"?e("div",{className:"cm-peak-progress-meta"},e("span",null,p)):null):e(A,null,e("div",{className:"cm-peak-progress-head"},_(Y),e("span",{className:"cm-peak-progress-time"},l==="switch"?p:s)),E,l==="both"?e("div",{className:"cm-peak-progress-meta"},e("span",null,t.startText+(i?" start":" 开始")),e("span",null,p)):null);return e(G,{portal:!0,label:k,side:"right",delayMs:300},e("div",{"data-cm-display":"peak",title:k,className:"cm-peak-progress "+(t.inPeak?"peak":"off")+(o?" rail":" variant-"+b)+(f?" text-only":""),"data-variant":b,"data-progress":t.progress,"data-switch-at":t.nextAtMs},ee))}function X(r){const c=r.useCost?r.useCost(s=>s):void 0,a=R(c?.state),[o,v]=y(Date.now()),[t,i]=y(null),[u,w]=y(null);if(I(()=>{const s=window.setInterval(()=>v(Date.now()),1e4);return()=>window.clearInterval(s)},[]),I(()=>{const s=p=>{const h=p.detail?.kind==="offpeak"?"offpeak":"peak";w(h);const k=c?.state?.config;if(k?.peakAlertWebNotify===!0&&window.Notification&&Notification.permission==="granted"){const l=F(P(k));try{new Notification(l(h==="peak"?"peakAlertTitlePeak":"peakAlertTitleOffPeak")+l("peakAlertPreviewTag"),{body:l("peakAlertBody",{time:l("countdownMinute",{m:2}),phase:l(h==="peak"?"peakAlertPhasePeak":"peakAlertPhaseOffPeak")})})}catch{}}};return window.addEventListener(D,s),window.__cmPeakAlertLive=!0,()=>{window.removeEventListener(D,s),window.__cmPeakAlertLive=!1}},[]),I(()=>{if(!a||a.peakAlertEnabled!==!0||a.peakEnabled!==!0||a.peakAlertWebNotify!==!0||!window.Notification||Notification.permission!=="granted")return;const s=B(a,o);if(s===null)return;const p=a.peakAlertTarget==="peak"||a.peakAlertTarget==="offpeak"?a.peakAlertTarget:"both",h=s.nextIntoPeak===!0;if(p!=="both"&&p!==(h?"peak":"offpeak"))return;const k=Number(a.peakAlertAhead),l=(Number.isFinite(k)&&k>=1?k:2)*6e4;if(o<s.nextAtMs-l||o>=s.nextAtMs||O===s.nextAtMs)return;const f=F(P(a));O=s.nextAtMs;try{new Notification(f(h?"peakAlertTitlePeak":"peakAlertTitleOffPeak"),{body:f("peakAlertBody",{time:z(s,o,f),phase:f(h?"peakAlertPhasePeak":"peakAlertPhaseOffPeak")})})}catch{}},[o]),!a||a.peakEnabled!==!0)return null;let n=null;if(a.peakAlertEnabled===!0){const s=Date.parse(a.peakEffectiveAt||"");if(!(Number.isFinite(s)&&o<s)){const p=B(a,o);if(p!==null){const h=a.peakAlertTarget==="peak"||a.peakAlertTarget==="offpeak"?a.peakAlertTarget:"both",k=Number(a.peakAlertAhead),l=(Number.isFinite(k)&&k>=1?k:2)*6e4;(h==="both"||h===(p.nextIntoPeak?"peak":"offpeak"))&&o>=p.nextAtMs-l&&o<p.nextAtMs&&t!==p.nextAtMs&&(n=p)}}}let g=null,m=!1,d=null;if(n!==null)g=n,m=n.nextIntoPeak===!0,d=()=>i(n.nextAtMs);else if(u!==null)g={nextAtMs:o+2*6e4,nextIntoPeak:u==="peak"},m=u==="peak",d=()=>w(null);else return null;const x=F(P(a)),T=a.peakAlertPosition==="center"?"cm-peak-alert-center":"cm-peak-alert-corner";return e(J,{actions:{dismiss:d},className:"cm-peak-alert "+T+" "+(m?"cm-peak-alert-peak":"cm-peak-alert-offpeak"),role:"alert"},e("div",{className:"cm-peak-alert-badge"},x(m?"peakAlertBadgePeak":"peakAlertBadgeOffPeak")),e("div",{className:"cm-peak-alert-title"},x(m?"peakAlertTitlePeak":"peakAlertTitleOffPeak")),e("div",{className:"cm-peak-alert-body"},x("peakAlertBody",{time:z(g,o,x),phase:x(m?"peakAlertPhasePeak":"peakAlertPhaseOffPeak")})),e("div",{className:"cm-peak-alert-actions"},e("button",{type:"button",className:"cm-btn","data-cm-action":"dismiss",onClick:d},x("peakAlertBtn"))))}return r=>e(r.view==="alert"?X:U,r)}return{mount:j}}});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
window.__ModuleLoader__.load({id:"dsh-cost-meter",chunk:"client.plan-settings.js",factory:j=>{const{createElement:e,useState:S,Fragment:A}=j("react"),W={kimi:{checkedAt:"2026-10-28",sourceUrl:"https://www.kimi.com/code/docs/kimi-code/membership.html",tiers:["Go","Plus","Pro","Max","Ultra"],legacyTiers:["Andante","Moderato","Allegretto","Vivace"],models:["k3.1-pro","k3.1-pro-highspeed","k3","k3-256k","kimi-for-coding","kimi-for-coding-highspeed"],zh:"新套餐:Go、Plus、Pro、Max、Ultra。Plus 起提供 Kimi Code,Pro 起提供高速版和 1M 上下文。新套餐使用 5 小时窗口及月总额度;老套餐保留周窗口。",en:"Current tiers: Go, Plus, Pro, Max and Ultra. Kimi Code starts at Plus; Pro adds Highspeed and 1M context. New plans use a 5-hour window and monthly total; legacy plans retain weekly limits."},minimax:{checkedAt:"2026-10-28",sourceUrl:"https://platform.minimax.io/docs/m-plan/intro",tiers:["Go","Explore","Build"],legacyTiers:["Plus","Max","Ultra"],models:["MiniMax-M3.1-Flash"],zh:"M Plan:Go、Explore、Build,均包含 M3.1 Flash;Explore、Build 另含 H3 视频。原 Token Plan 的 Plus、Max、Ultra 保留。使用现有 MiniMax 查询凭据。",en:"M Plan: Go, Explore and Build, all including M3.1 Flash. Explore and Build also include H3 video. Legacy Token Plan Plus, Max and Ultra remain. Uses the existing MiniMax quota credential."},go:{checkedAt:"2026-10-28",sourceUrl:"https://opencode.ai/v2/docs/console/go/",tiers:["Go","Go Plus"],models:["kimi-k3.1-pro","minimax-m3.1-flash","step-5-preview","gemini-4-argon","beam-free","iceman-contributor-free"],zh:"Go 为 $10/月,Go Plus 为 $40/月。新增 Kimi K3.1 Pro、MiniMax M3.1 Flash 等模型,各模型使用独立的月度额度标准。",en:"Go costs $10/month; Go Plus costs $40/month. Includes Kimi K3.1 Pro, MiniMax M3.1 Flash and other additions, with model-specific monthly allowances."},"tencent-token":{checkedAt:"2026-10-28",sourceUrl:"https://cloud.tencent.com/document/product/1823/130060",tiers:["Lite","Standard","Pro","Max"],products:["Token Plan","Hy Token Plan"],zh:"腾讯通用 Token Plan 与 Hy Token Plan 共用 API Key 和请求地址,按模型从对应套餐扣减积分。当前支持套餐归属统计。",en:"Tencent Token Plan and Hy Token Plan share an API key and endpoints; credits are deducted from the applicable plan for each model. Plan classification is supported."}};return{mount(V){const{useQuotaRefresh:Y,miniMaxWindowsOf:L,MiniMaxPlanCard:z,barDirectionOf:G,quotaWindowRow:$,codingPlanWindowLabel:X,codingPlanWindowEntries:J,numInput:Z,CredentialField:ee,QuotaCard:ae,resolveLocale:C,formatMoneyUsd:H,quotaPlacementValue:ne,quotaPlacementPatch:te,quotaPlacementOptions:le}=V;function I(b){const{state:u,draft:f,setDraft:n,target:l,api:h}=b,t=(d,v)=>C(u.config)==="en"?v:d,p=l.replace(/\.(ak|sk)$/,""),g=(f??u.config).queryAccounts??{},m=g[p]??{selected:"default",accounts:[]},s=u.config.queryAccounts?.[p]?.selected??"default",[c,q]=S(""),[o,r]=S(!1),[k,P]=S(""),w=s!==m.selected||f===null||o,M=d=>n({...f,queryAccounts:{...g,[p]:d}}),y=()=>{const d=c.trim();if(!d||m.accounts.length>=10||w)return;const v=crypto.randomUUID();M({selected:v,accounts:[...m.accounts,{id:v,label:d}]}),q(""),P("")},T=async()=>{if(!(w||m.selected==="default")){r(!0),P("");try{const d=p==="codingPlans.volcengine"?[p+".ak",p+".sk"]:[p];for(const v of d)await h.clearCredential(v+"@"+m.selected);M({selected:"default",accounts:m.accounts.filter(v=>v.id!==m.selected)})}catch(d){P(String(d?.message??d))}finally{r(!1)}}};return e("div",{"data-query-account":l},l.endsWith(".sk")?null:e("div",{className:"cm-field"},e("label",null,t("查询并显示的账号","Account to query and display"),e("select",{className:"cm-input","aria-label":t("查询并显示的账号","Account to query and display"),value:m.selected,disabled:o||f===null,onChange:d=>M({...m,selected:d.target.value})},e("option",{value:"default"},t("默认账号(现有配置)","Default account (existing configuration)")),...m.accounts.map(d=>e("option",{key:d.id,value:d.id},d.label)))),e("div",{className:"cm-buttons"},e("input",{className:"cm-input",type:"text",value:c,maxLength:64,autoComplete:"off","aria-label":t("新账号名称","New account name"),placeholder:t("如:工作账号","e.g. Work account"),disabled:w,onChange:d=>q(d.target.value),style:{minWidth:0,flex:1}}),e("button",{className:"cm-btn small",type:"button",disabled:w||!c.trim()||m.accounts.length>=10,onClick:y},t("添加账号","Add account")),m.selected!=="default"?e("button",{className:"cm-btn small",type:"button",disabled:w,onClick:T},t("移除账号","Remove account")):null),e("p",{className:"cm-note"},t("每个账号单独保存凭据,仅查询所选账号。默认账号沿用现有自动识别;新增账号不会回退到其他账号。区域、工作区等查询设置由同一来源共用。","Each account has its own credential; only the selected account is queried. Default keeps existing discovery. Added accounts never fall back to another account. Region and workspace settings are shared by this source.")),k?e("p",{role:"alert",className:"cm-msg err"},k):null),e(ee,{...b,key:l+"@"+m.selected,target:l+"@"+m.selected,disabled:b.disabled||w,configured:!w&&b.configured}))}function oe({live:b,config:u,setPlan:f,state:n}){const l=(o,r)=>C(n.config)==="en"?r:o,h=b.workbuddy,t=h?.accounts??[],p=u.accountScope??"current",g=new Set(u.accountIds??[]),m=t.filter(o=>p==="all"||(p==="current"?o.current:g.has(o.id))),s=o=>typeof o=="number"&&Number.isFinite(o)?o.toLocaleString(void 0,{maximumFractionDigits:4}):"—",c=o=>m.length&&m.every(r=>typeof r[o]=="number")?m.reduce((r,k)=>r+k[o],0):null,q=o=>Object.entries(o?.byProviderModel??{}).reduce((r,[k,P])=>/^(workbuddy|workbuddy-ai|workbuddy-global|workbuddy-subscription|xdpool|xdpool-global):/.test(k)?r+(P.cost??0):r,0);return e("section",{className:"cm-workbuddy-accounts",style:{minWidth:0}},e("div",{className:"cm-field"},e("label",null,l("积分来源","Credit source")),e("select",{className:"cm-input","aria-label":l("积分来源","Credit source"),value:u.accountSource??"auto",onChange:o=>f("accountSource",o.target.value)},...[["auto",l("自动识别","Automatic")],["connect",l("WorkBuddy 连接插件","WorkBuddy connectors")],["xdpool","dsh-xdpool"]].map(([o,r])=>e("option",{value:o,key:o},r))),e("p",{className:"cm-note"},l("自动识别优先读取连接插件的账号列表,其次读取 XD Pool。两者同时使用时可指定来源。","Automatic uses connector accounts first, then XD Pool. Select a source when using both."))),e("div",{className:"cm-field"},e("label",null,l("统计账号","Accounts to include")),e("select",{className:"cm-input","aria-label":l("统计账号","Accounts to include"),value:p,onChange:o=>f("accountScope",o.target.value)},...[["current",l("当前账号(各区域)","Current account per region")],["all",l("全部账号","All accounts")],["selected",l("勾选账号","Select accounts")]].map(([o,r])=>e("option",{value:o,key:o},r)))),h?.incomplete?e("p",{className:"cm-note",role:"status"},l("部分区域查询失败,当前汇总不完整。","Some regions could not be queried; totals are incomplete.")):null,h?.historyUnavailable?e("p",{className:"cm-note",role:"status"},l("历史统计暂时无法读取,原记录已保留;余额仍可查看。","History is unavailable and has been preserved; balances are still available.")):null,t.length?e("div",{style:{maxHeight:260,overflow:"auto",border:"1px solid var(--dsw-alias-border-l1)",borderRadius:8}},...t.map((o,r)=>e("label",{key:o.id,style:{display:"flex",alignItems:"center",gap:8,padding:"8px 10px",minWidth:0}},e("input",{type:"checkbox",checked:p==="all"||(p==="current"?o.current:g.has(o.id)),disabled:p!=="selected","aria-label":o.name||l("账号 ","Account ")+(r+1),onChange:k=>{const P=new Set(g);k.target.checked?P.add(o.id):P.delete(o.id),f("accountIds",[...P])}}),e("span",{style:{flex:1,minWidth:0,overflowWrap:"anywhere"}},o.name||l("账号 ","Account ")+(r+1),e("small",{style:{display:"block",opacity:.65}},o.region==="cn"?l("国内","CN"):l("国际","Global"))),e("span",{style:{textAlign:"right",flexShrink:0}},s(o.remaining),e("small",{style:{display:"block",opacity:.65}},l("今日减少 ","Decrease today ")+s(o.observedToday)))))):e("p",{className:"cm-note"},l("刷新后显示账号。旧连接插件未提供账号列表时,仍可查看当前账号积分。","Refresh to load accounts. Older connectors can still show current credits without an account list.")),e("div",{style:{display:"grid",gridTemplateColumns:"repeat(2,minmax(0,1fr))",gap:8,marginTop:10}},...[["remaining",l("剩余积分","Credits remaining")],["observedToday",l("今日观测减少","Observed decrease today")],["observedWeek",l("近 7 天观测减少","Observed decrease, 7 days")],["observedTotal",l("启用以来观测减少","Observed decrease since enabled")]].map(([o,r])=>e("div",{key:o,style:{padding:8,borderRadius:6,background:"var(--dsw-alias-bg-layer-1)",minWidth:0,overflowWrap:"anywhere"}},e("small",null,r),e("strong",{style:{display:"block"}},s(h?.incomplete?null:c(o)))))),e("p",{className:"cm-note"},l("从首次成功查询开始记录;充值或赠送不计为减少,积分过期可能计入减少。不是官方扣费账单,积分不折算成人民币。","Recorded from the first successful query. Grants are not decreases; expiry may be. This is not an official charge statement and credits are not converted to currency.")),e("p",{className:"cm-note"},l("全部 WorkBuddy 调用 API 等值:今日 ","API-equivalent value of all WorkBuddy calls: today ")+H(q(n.today),n.config)+l(";累计 ","; total ")+H(q(n.total),n.config)+l("。调用记录没有账号标识,此项不随账号筛选。",". Call records have no account identifiers; this value is not filtered by account.")))}function se(b){const{state:u,api:f,t:n,draft:l,setDraft:h,planId:t,labelKey:p}=b,g=u.config,m=u.codingPlans??{},s=l?.codingPlans?.[t]??g.codingPlans?.[t]??{},c=m[t]??{status:"off",message:"",fetchedAt:0,windows:{}},q=s.enabled===!0,[o,r]=S(b.targeted===!0),k=t==="qwen"&&g.codingPlans?.qwen?.quotaSource==="bailian"&&s.quotaSource==="bailian"&&c.quotaSource==="bailian"&&c.loginRequired===!0,[P,w,M]=Y(n,()=>k?f.loginCodingPlan(t):f.refreshCodingPlan(t)),y=(a,i)=>{if(l===null)return;const N=l.codingPlans??g.codingPlans??{};h({...l,codingPlans:{...N,[t]:{...N[t]??{},[a]:i}}})},[T,d]=S(""),[v,D]=S({}),F=a=>a?.rates!==null&&typeof a?.rates=="object"&&!Array.isArray(a.rates)?a.rates:{},K=["input","cachedInput","output"],U=a=>v[a]??F(s)[a]??{},Q=a=>K.every(i=>Number.isFinite(Number(a[i]))&&Number(a[i])>0),ce=(a,i,N)=>{if(l===null)return;const x={...U(a),[i]:String(N)};D(O=>({...O,[a]:x}));const E=K.every(O=>String(x[O]??"").trim()==="");if(!E&&!Q(x))return;const _=l.codingPlans??g.codingPlans??{},B={...(_.qwen??{}).rates??{}};E?delete B[a]:B[a]=Object.fromEntries(K.map(O=>[O,Number(x[O])])),h({...l,codingPlans:{..._,qwen:{..._.qwen??{},rates:B}}})},ie=a=>{l!==null&&D(i=>({...i,[a]:i[a]??F(s)[a]??{}}))},re=a=>{if(l===null)return;D(x=>{const E={...x};return delete E[a],E});const i=l.codingPlans??g.codingPlans??{},N={...(i.qwen??{}).rates??{}};delete N[a],h({...l,codingPlans:{...i,qwen:{...i.qwen??{},rates:N}}})},R=c.windows!==null&&typeof c.windows=="object"?c.windows:{},de=q===!1?e("p",{className:"cm-note"},C(u.config)==="en"?"Disabled. Enable it to query this vendor's coding plan quota on the refresh interval and show it here.":"未启用。开启后将按刷新间隔查询该厂商的 coding plan 额度并显示在这里。"):c.status==="ok"?e("div",{className:"cm-go-list"},c.message?e("p",{className:"cm-note"},c.message):null,Object.keys(R).length>0?t==="minimax"&&(L(R).five!=null||L(R).seven!=null)?e(z,{five:L(R).five,seven:L(R).seven,fetchedAt:c.fetchedAt,t:n,wide:!0,direction:G(g,"plan")}):J(R,t).map(([a,i])=>$(n,X(a,n),i,G(g,"plan"),!1,a)):e("div",{className:"cm-bal-line"},n("codingPlanNotQueried")),e("div",{className:"cm-go-time"},n("goQuotaFetchedAt",{time:c.fetchedAt>0?new Date(c.fetchedAt).toLocaleTimeString():"—"}))):c.status==="error"?e("div",{className:"cm-bal-line err"},c.message||n("unknownError")):c.status==="off"&&c.message?e("p",{className:"cm-note"},c.message):e("div",{className:"cm-bal-line"},n("codingPlanNotQueried")),ue=e(A,null,W[t]?e("p",{className:"cm-note","data-cm-plan-catalog":t},W[t][C(u.config)==="en"?"en":"zh"]," ",e("a",{href:W[t].sourceUrl,target:"_blank",rel:"noopener noreferrer",style:{whiteSpace:"nowrap"}},C(u.config)==="en"?"Plan details":"套餐详情")):null,t==="opendesign"?e("div",{className:"cm-field"},e("label",null,n("opendesignWorkspace")),e("input",{className:"cm-input","aria-label":n("opendesignWorkspace"),value:s.workspaceId??"",onChange:a=>y("workspaceId",a.target.value)}),e("p",{className:"cm-note"},n("opendesignNote"))):null,t==="factory"?e(A,null,e("div",{className:"cm-field"},e("label",null,n("factoryPool")),e("select",{className:"cm-input","aria-label":n("factoryPool"),value:s.factoryPool??"standard",onChange:a=>y("factoryPool",a.target.value)},e("option",{value:"standard"},"Standard"),e("option",{value:"core"},"Droid Core"),e("option",{value:"both"},n("factoryPoolBoth")))),e("div",{className:"cm-field"},e("label",null,n("factoryOrg")),e("input",{className:"cm-input","aria-label":n("factoryOrg"),value:s.orgId??"",onChange:a=>y("orgId",a.target.value)}))):null,t==="minimax"?e("div",{className:"cm-field"},e("label",null,n("minimaxOrigin")),e("input",{className:"cm-input",type:"url",value:s.baseUrl??"",placeholder:"https://www.minimax.cn","aria-label":n("minimaxOrigin"),onChange:a=>y("baseUrl",a.target.value)}),e("p",{className:"cm-note"},n("minimaxOriginNote"))):null,t==="qwen"?e("div",{className:"cm-field"},e("label",null,n("qwenSource")),e("select",{className:"cm-input",value:s.quotaSource??"local",onChange:a=>y("quotaSource",a.target.value)},e("option",{value:"local"},n("qwenSourceLocal")),e("option",{value:"cli"},n("qwenSourceCli")),e("option",{value:"bailian"},n("qwenSourceBailian"))),e("p",{className:"cm-note"},n(s.quotaSource==="bailian"?"qwenBailianNote":"qwenCliNote"))):null,e("div",{className:"cm-field"},e("label",null,n("codingPlanDisplayLabel")),e("select",{className:"cm-input","aria-label":n("codingPlanDisplayLabel"),value:ne(s,(l??g).quotaStrip,"plans"),onChange:a=>{if(l===null)return;const i=l.codingPlans??g.codingPlans??{};h({...l,codingPlans:{...i,[t]:{...s,...te(a.target.value)}}})}},...le(n)),e("span",{className:"cm-hint"},C(u.config)==="en"?"Choose the sidebar, settings, the area above the input box, or a combination. Individual placement overrides strip defaults.":"可单独选择侧栏、设置页或输入框上方,也可同时显示。单家位置优先于横条默认设置。")),t!=="scnet"&&(t!=="qwen"||(s.quotaSource??"local")!=="local")?e("div",{className:"cm-field"},e("label",null,n("codingPlanRefreshIntervalLabel")),Z({value:typeof s.refreshMinutes=="number"&&Number.isFinite(s.refreshMinutes)&&s.refreshMinutes>0?s.refreshMinutes:15},a=>{y("refreshMinutes",Math.min(1440,Math.max(1,Math.floor(a))))})):null,t==="scnet"||t==="qwen"&&(s.quotaSource??"local")==="local"?e(A,null,e("div",{className:"cm-field"},e("label",null,n(t==="qwen"?"qwenPlanCreditsLabel":"scnetPlanCreditsLabel")),e("input",{className:"cm-input",type:"number",min:"1",step:"1000",value:typeof s.planCredits=="number"&&Number.isFinite(s.planCredits)&&s.planCredits>0?s.planCredits:t==="qwen"?5e5:24e4,onChange:a=>{const i=Number(a.target.value);Number.isFinite(i)&&i>0&&y("planCredits",Math.floor(i))}})),e("div",{className:"cm-field"},e("label",null,n(t==="qwen"?"qwenPlanStartLabel":"scnetPlanStartLabel")),e("input",{className:"cm-input",type:"date",value:typeof s.planStart=="string"?s.planStart:"",onChange:a=>y("planStart",a.target.value)})),t==="qwen"?e(A,null,e("div",{className:"cm-field"},e("label",null,n("qwenRatesLabel"))),[...new Set([...Object.keys(F(s)),...Object.keys(v)])].sort().map(a=>e("div",{key:a,className:"cm-match-row"},e("span",{style:{minWidth:"120px"}},a),K.map(i=>e("input",{key:i,className:"cm-input narrow",type:"number",min:"0",step:"0.1",value:U(a)[i]??"",placeholder:n("qwenRate_"+i),"aria-label":a+" · "+n("qwenRate_"+i),onChange:N=>{const x=N.target.value;ce(a,i,x)}})),e("button",{className:"cm-btn small",onClick:()=>re(a)},n("overrideRemove")),a in v&&!Q(U(a))?e("span",{className:"cm-note"},n("qwenRateDraftNote")):null)),e("div",{className:"cm-buttons"},e("input",{className:"cm-input narrow",type:"text",placeholder:n("qwenRatesModelPlaceholder"),value:T,onChange:a=>d(a.target.value)}),e("button",{className:"cm-btn small",onClick:()=>{const a=T.trim();a.length!==0&&(ie(a),d(""))},disabled:T.trim().length===0},n("qwenRatesAdd")))):null,e("p",{className:"cm-note"},n(t==="qwen"?"qwenLocalNote":"scnetLocalNote"))):t==="qwen"?null:t==="volcengine"?e(A,null,e("div",{className:"cm-field"},e("label",null,n("volcengineAccessKeyIdLabel"))),e(I,{state:u,draft:l,setDraft:h,target:"codingPlans.volcengine.ak",configured:c.keyConfigured===!0,source:c.keySource,t:n,api:f,placeholder:n("volcengineAccessKeyPlaceholder")}),e("div",{className:"cm-field"},e("label",null,n("volcengineSecretAccessKeyLabel"))),e(I,{state:u,draft:l,setDraft:h,target:"codingPlans.volcengine.sk",configured:c.keyConfigured===!0,source:c.keySource,t:n,api:f,placeholder:n("volcengineSecretPlaceholder")}),e("p",{className:"cm-note"},C(u.config)==="en"?"Volcano Ark needs AK/SK, ArkReadOnlyAccess and BillingCenterReadOnlyAccess. Enter credentials or export VOLC_ACCESSKEY/VOLC_SECRETKEY. Only open.volcengineapi.com is contacted.":"火山方舟需 AK/SK、ArkReadOnlyAccess 和 BillingCenterReadOnlyAccess;可填凭据或导出 VOLC_ACCESSKEY/VOLC_SECRETKEY。只连接 open.volcengineapi.com。")):t==="workbuddy"?e(A,null,e("p",{className:"cm-note"},n("wbH")),e(oe,{live:c,config:s,setPlan:y,state:u})):e(A,null,e("div",{className:"cm-field"},e("label",null,t==="baidu-coding"?"Cookie (console.bce.baidu.com)":t==="mimo"?"Cookie (platform.xiaomimimo.com)":t==="factory"?"Factory Token":t==="opendesign"?"OpenDesign Cookie / Control Key":n("codingPlanKeyLabel"))),e(I,{state:u,draft:l,setDraft:h,target:"codingPlans."+t,configured:c.keyConfigured===!0,source:c.keySource,t:n,api:f,placeholder:t==="baidu-coding"?"BAIDU_QIANFAN_COOKIE":t==="mimo"?"api-platform_serviceToken=…; userId=…":t==="factory"?"FACTORY_API_KEY":t==="opendesign"?"Cookie: name=value; … / vela_ctrl_…":"sk-…"}),t==="baidu-coding"?e("p",{className:"cm-note"},C(u.config)==="en"?"Sign in at console.bce.baidu.com, open Token Plan → browser Network → tokenPlanPersonal/resource, and copy the full Cookie request header. Supports Personal credits and Tokens; excludes add-on packs. API keys cannot query quotas.":"登录 console.bce.baidu.com,打开 Token Plan 页面,在浏览器网络面板找到 tokenPlanPersonal/resource,复制完整 Cookie 请求头。支持个人版积分制与 Token 制套餐,不含加油包;API Key 不用于额度查询。"):null));return e(ae,{planId:t,targeted:b.targeted,name:n(p),enabled:q,saved:g.codingPlans?.[t],busy:P,open:o,errorMsg:w?.text===c.message?null:w,statusNode:de,configNode:ue,onToggle:a=>y("enabled",a),onRefresh:M,onLogin:M,loginRequired:k,onToggleOpen:()=>r(a=>!a),t:n})}return b=>b.mode==="credential"?e(I,b):e(se,b)}}}});
|
|
1
|
+
;(function(e){const k=window.__ModuleLoader__,P=k[Symbol.for("@dsh-plugin/dsh-loader:load-wrap")];return(e.id==="dsh-cost-meter"&&k.load===P?.ours&&typeof P.original=="function"?P.original:k.load).call(k,e)})({id:"dsh-cost-meter",chunk:"client.plan-settings.js",factory:G=>{const{createElement:e,useState:k,Fragment:P}=G("react"),L={kimi:{checkedAt:"2026-10-28",sourceUrl:"https://www.kimi.com/code/docs/kimi-code/membership.html",tiers:["Go","Plus","Pro","Max","Ultra"],legacyTiers:["Andante","Moderato","Allegretto","Vivace"],models:["k3.1-pro","k3.1-pro-highspeed","k3","k3-256k","kimi-for-coding","kimi-for-coding-highspeed"],zh:"新套餐:Go、Plus、Pro、Max、Ultra。Plus 起提供 Kimi Code,Pro 起提供高速版和 1M 上下文。新套餐使用 5 小时窗口及月总额度;老套餐保留周窗口。",en:"Current tiers: Go, Plus, Pro, Max and Ultra. Kimi Code starts at Plus; Pro adds Highspeed and 1M context. New plans use a 5-hour window and monthly total; legacy plans retain weekly limits."},minimax:{checkedAt:"2026-10-28",sourceUrl:"https://platform.minimax.io/docs/m-plan/intro",tiers:["Go","Explore","Build"],legacyTiers:["Plus","Max","Ultra"],models:["MiniMax-M3.1-Flash"],zh:"M Plan:Go、Explore、Build,均包含 M3.1 Flash;Explore、Build 另含 H3 视频。原 Token Plan 的 Plus、Max、Ultra 保留。使用现有 MiniMax 查询凭据。",en:"M Plan: Go, Explore and Build, all including M3.1 Flash. Explore and Build also include H3 video. Legacy Token Plan Plus, Max and Ultra remain. Uses the existing MiniMax quota credential."},go:{checkedAt:"2026-10-28",sourceUrl:"https://opencode.ai/v2/docs/console/go/",tiers:["Go","Go Plus"],models:["kimi-k3.1-pro","minimax-m3.1-flash","step-5-preview","gemini-4-argon","beam-free","iceman-contributor-free"],zh:"Go 为 $10/月,Go Plus 为 $40/月。新增 Kimi K3.1 Pro、MiniMax M3.1 Flash 等模型,各模型使用独立的月度额度标准。",en:"Go costs $10/month; Go Plus costs $40/month. Includes Kimi K3.1 Pro, MiniMax M3.1 Flash and other additions, with model-specific monthly allowances."},"tencent-token":{checkedAt:"2026-10-28",sourceUrl:"https://cloud.tencent.com/document/product/1823/130060",tiers:["Lite","Standard","Pro","Max"],products:["Token Plan","Hy Token Plan"],zh:"腾讯通用 Token Plan 与 Hy Token Plan 共用 API Key 和请求地址,按模型从对应套餐扣减积分。当前支持套餐归属统计。",en:"Tencent Token Plan and Hy Token Plan share an API key and endpoints; credits are deducted from the applicable plan for each model. Plan classification is supported."}};return{mount(V){const{useQuotaRefresh:Y,miniMaxWindowsOf:I,MiniMaxPlanCard:z,barDirectionOf:H,quotaWindowRow:$,codingPlanWindowLabel:X,codingPlanWindowEntries:J,numInput:Z,CredentialField:ee,QuotaCard:ae,resolveLocale:x,formatMoneyUsd:Q,quotaPlacementValue:ne,quotaPlacementPatch:te,quotaPlacementOptions:le}=V;function K(b){const{state:u,draft:f,setDraft:n,target:l,api:h}=b,t=(d,v)=>x(u.config)==="en"?v:d,p=l.replace(/\.(ak|sk)$/,""),g=(f??u.config).queryAccounts??{},m=g[p]??{selected:"default",accounts:[]},s=u.config.queryAccounts?.[p]?.selected??"default",[c,A]=k(""),[o,r]=k(!1),[w,N]=k(""),C=s!==m.selected||f===null||o,M=d=>n({...f,queryAccounts:{...g,[p]:d}}),y=()=>{const d=c.trim();if(!d||m.accounts.length>=10||C)return;const v=crypto.randomUUID();M({selected:v,accounts:[...m.accounts,{id:v,label:d}]}),A(""),N("")},T=async()=>{if(!(C||m.selected==="default")){r(!0),N("");try{const d=p==="codingPlans.volcengine"?[p+".ak",p+".sk"]:[p];for(const v of d)await h.clearCredential(v+"@"+m.selected);M({selected:"default",accounts:m.accounts.filter(v=>v.id!==m.selected)})}catch(d){N(String(d?.message??d))}finally{r(!1)}}};return e("div",{"data-query-account":l},l.endsWith(".sk")?null:e("div",{className:"cm-field"},e("label",null,t("查询并显示的账号","Account to query and display"),e("select",{className:"cm-input","aria-label":t("查询并显示的账号","Account to query and display"),value:m.selected,disabled:o||f===null,onChange:d=>M({...m,selected:d.target.value})},e("option",{value:"default"},t("默认账号(现有配置)","Default account (existing configuration)")),...m.accounts.map(d=>e("option",{key:d.id,value:d.id},d.label)))),e("div",{className:"cm-buttons"},e("input",{className:"cm-input",type:"text",value:c,maxLength:64,autoComplete:"off","aria-label":t("新账号名称","New account name"),placeholder:t("如:工作账号","e.g. Work account"),disabled:C,onChange:d=>A(d.target.value),style:{minWidth:0,flex:1}}),e("button",{className:"cm-btn small",type:"button",disabled:C||!c.trim()||m.accounts.length>=10,onClick:y},t("添加账号","Add account")),m.selected!=="default"?e("button",{className:"cm-btn small",type:"button",disabled:C,onClick:T},t("移除账号","Remove account")):null),e("p",{className:"cm-note"},t("每个账号单独保存凭据,仅查询所选账号。默认账号沿用现有自动识别;新增账号不会回退到其他账号。区域、工作区等查询设置由同一来源共用。","Each account has its own credential; only the selected account is queried. Default keeps existing discovery. Added accounts never fall back to another account. Region and workspace settings are shared by this source.")),w?e("p",{role:"alert",className:"cm-msg err"},w):null),e(ee,{...b,key:l+"@"+m.selected,target:l+"@"+m.selected,disabled:b.disabled||C,configured:!C&&b.configured}))}function oe({live:b,config:u,setPlan:f,state:n}){const l=(o,r)=>x(n.config)==="en"?r:o,h=b.workbuddy,t=h?.accounts??[],p=u.accountScope??"current",g=new Set(u.accountIds??[]),m=t.filter(o=>p==="all"||(p==="current"?o.current:g.has(o.id))),s=o=>typeof o=="number"&&Number.isFinite(o)?o.toLocaleString(void 0,{maximumFractionDigits:4}):"—",c=o=>m.length&&m.every(r=>typeof r[o]=="number")?m.reduce((r,w)=>r+w[o],0):null,A=o=>Object.entries(o?.byProviderModel??{}).reduce((r,[w,N])=>/^(workbuddy|workbuddy-ai|workbuddy-global|workbuddy-subscription|xdpool|xdpool-global):/.test(w)?r+(N.cost??0):r,0);return e("section",{className:"cm-workbuddy-accounts",style:{minWidth:0}},e("div",{className:"cm-field"},e("label",null,l("积分来源","Credit source")),e("select",{className:"cm-input","aria-label":l("积分来源","Credit source"),value:u.accountSource??"auto",onChange:o=>f("accountSource",o.target.value)},...[["auto",l("自动识别","Automatic")],["connect",l("WorkBuddy 连接插件","WorkBuddy connectors")],["xdpool","dsh-xdpool"]].map(([o,r])=>e("option",{value:o,key:o},r))),e("p",{className:"cm-note"},l("自动识别优先读取连接插件的账号列表,其次读取 XD Pool。两者同时使用时可指定来源。","Automatic uses connector accounts first, then XD Pool. Select a source when using both."))),e("div",{className:"cm-field"},e("label",null,l("统计账号","Accounts to include")),e("select",{className:"cm-input","aria-label":l("统计账号","Accounts to include"),value:p,onChange:o=>f("accountScope",o.target.value)},...[["current",l("当前账号(各区域)","Current account per region")],["all",l("全部账号","All accounts")],["selected",l("勾选账号","Select accounts")]].map(([o,r])=>e("option",{value:o,key:o},r)))),h?.incomplete?e("p",{className:"cm-note",role:"status"},l("部分区域查询失败,当前汇总不完整。","Some regions could not be queried; totals are incomplete.")):null,h?.historyUnavailable?e("p",{className:"cm-note",role:"status"},l("历史统计暂时无法读取,原记录已保留;余额仍可查看。","History is unavailable and has been preserved; balances are still available.")):null,t.length?e("div",{style:{maxHeight:260,overflow:"auto",border:"1px solid var(--dsw-alias-border-l1)",borderRadius:8}},...t.map((o,r)=>e("label",{key:o.id,style:{display:"flex",alignItems:"center",gap:8,padding:"8px 10px",minWidth:0}},e("input",{type:"checkbox",checked:p==="all"||(p==="current"?o.current:g.has(o.id)),disabled:p!=="selected","aria-label":o.name||l("账号 ","Account ")+(r+1),onChange:w=>{const N=new Set(g);w.target.checked?N.add(o.id):N.delete(o.id),f("accountIds",[...N])}}),e("span",{style:{flex:1,minWidth:0,overflowWrap:"anywhere"}},o.name||l("账号 ","Account ")+(r+1),e("small",{style:{display:"block",opacity:.65}},o.region==="cn"?l("国内","CN"):l("国际","Global"))),e("span",{style:{textAlign:"right",flexShrink:0}},s(o.remaining),e("small",{style:{display:"block",opacity:.65}},l("今日减少 ","Decrease today ")+s(o.observedToday)))))):e("p",{className:"cm-note"},l("刷新后显示账号。旧连接插件未提供账号列表时,仍可查看当前账号积分。","Refresh to load accounts. Older connectors can still show current credits without an account list.")),e("div",{style:{display:"grid",gridTemplateColumns:"repeat(2,minmax(0,1fr))",gap:8,marginTop:10}},...[["remaining",l("剩余积分","Credits remaining")],["observedToday",l("今日观测减少","Observed decrease today")],["observedWeek",l("近 7 天观测减少","Observed decrease, 7 days")],["observedTotal",l("启用以来观测减少","Observed decrease since enabled")]].map(([o,r])=>e("div",{key:o,style:{padding:8,borderRadius:6,background:"var(--dsw-alias-bg-layer-1)",minWidth:0,overflowWrap:"anywhere"}},e("small",null,r),e("strong",{style:{display:"block"}},s(h?.incomplete?null:c(o)))))),e("p",{className:"cm-note"},l("从首次成功查询开始记录;充值或赠送不计为减少,积分过期可能计入减少。不是官方扣费账单,积分不折算成人民币。","Recorded from the first successful query. Grants are not decreases; expiry may be. This is not an official charge statement and credits are not converted to currency.")),e("p",{className:"cm-note"},l("全部 WorkBuddy 调用 API 等值:今日 ","API-equivalent value of all WorkBuddy calls: today ")+Q(A(n.today),n.config)+l(";累计 ","; total ")+Q(A(n.total),n.config)+l("。调用记录没有账号标识,此项不随账号筛选。",". Call records have no account identifiers; this value is not filtered by account.")))}function se(b){const{state:u,api:f,t:n,draft:l,setDraft:h,planId:t,labelKey:p}=b,g=u.config,m=u.codingPlans??{},s=l?.codingPlans?.[t]??g.codingPlans?.[t]??{},c=m[t]??{status:"off",message:"",fetchedAt:0,windows:{}},A=s.enabled===!0,[o,r]=k(b.targeted===!0),w=t==="qwen"&&g.codingPlans?.qwen?.quotaSource==="bailian"&&s.quotaSource==="bailian"&&c.quotaSource==="bailian"&&c.loginRequired===!0,[N,C,M]=Y(n,()=>w?f.loginCodingPlan(t):f.refreshCodingPlan(t)),y=(a,i)=>{if(l===null)return;const q=l.codingPlans??g.codingPlans??{};h({...l,codingPlans:{...q,[t]:{...q[t]??{},[a]:i}}})},[T,d]=k(""),[v,D]=k({}),F=a=>a?.rates!==null&&typeof a?.rates=="object"&&!Array.isArray(a.rates)?a.rates:{},W=["input","cachedInput","output"],U=a=>v[a]??F(s)[a]??{},j=a=>W.every(i=>Number.isFinite(Number(a[i]))&&Number(a[i])>0),ce=(a,i,q)=>{if(l===null)return;const S={...U(a),[i]:String(q)};D(O=>({...O,[a]:S}));const E=W.every(O=>String(S[O]??"").trim()==="");if(!E&&!j(S))return;const _=l.codingPlans??g.codingPlans??{},B={...(_.qwen??{}).rates??{}};E?delete B[a]:B[a]=Object.fromEntries(W.map(O=>[O,Number(S[O])])),h({...l,codingPlans:{..._,qwen:{..._.qwen??{},rates:B}}})},ie=a=>{l!==null&&D(i=>({...i,[a]:i[a]??F(s)[a]??{}}))},re=a=>{if(l===null)return;D(S=>{const E={...S};return delete E[a],E});const i=l.codingPlans??g.codingPlans??{},q={...(i.qwen??{}).rates??{}};delete q[a],h({...l,codingPlans:{...i,qwen:{...i.qwen??{},rates:q}}})},R=c.windows!==null&&typeof c.windows=="object"?c.windows:{},de=A===!1?e("p",{className:"cm-note"},x(u.config)==="en"?"Disabled. Enable it to query this vendor's coding plan quota on the refresh interval and show it here.":"未启用。开启后将按刷新间隔查询该厂商的 coding plan 额度并显示在这里。"):c.status==="ok"?e("div",{className:"cm-go-list"},c.message?e("p",{className:"cm-note"},c.message):null,Object.keys(R).length>0?t==="minimax"&&(I(R).five!=null||I(R).seven!=null)?e(z,{five:I(R).five,seven:I(R).seven,fetchedAt:c.fetchedAt,t:n,wide:!0,direction:H(g,"plan")}):J(R,t).map(([a,i])=>$(n,X(a,n),i,H(g,"plan"),!1,a)):e("div",{className:"cm-bal-line"},n("codingPlanNotQueried")),e("div",{className:"cm-go-time"},n("goQuotaFetchedAt",{time:c.fetchedAt>0?new Date(c.fetchedAt).toLocaleTimeString():"—"}))):c.status==="error"?e("div",{className:"cm-bal-line err"},c.message||n("unknownError")):c.status==="off"&&c.message?e("p",{className:"cm-note"},c.message):e("div",{className:"cm-bal-line"},n("codingPlanNotQueried")),ue=e(P,null,L[t]?e("p",{className:"cm-note","data-cm-plan-catalog":t},L[t][x(u.config)==="en"?"en":"zh"]," ",e("a",{href:L[t].sourceUrl,target:"_blank",rel:"noopener noreferrer",style:{whiteSpace:"nowrap"}},x(u.config)==="en"?"Plan details":"套餐详情")):null,t==="opendesign"?e("div",{className:"cm-field"},e("label",null,n("opendesignWorkspace")),e("input",{className:"cm-input","aria-label":n("opendesignWorkspace"),value:s.workspaceId??"",onChange:a=>y("workspaceId",a.target.value)}),e("p",{className:"cm-note"},n("opendesignNote"))):null,t==="factory"?e(P,null,e("div",{className:"cm-field"},e("label",null,n("factoryPool")),e("select",{className:"cm-input","aria-label":n("factoryPool"),value:s.factoryPool??"standard",onChange:a=>y("factoryPool",a.target.value)},e("option",{value:"standard"},"Standard"),e("option",{value:"core"},"Droid Core"),e("option",{value:"both"},n("factoryPoolBoth")))),e("div",{className:"cm-field"},e("label",null,n("factoryOrg")),e("input",{className:"cm-input","aria-label":n("factoryOrg"),value:s.orgId??"",onChange:a=>y("orgId",a.target.value)}))):null,t==="minimax"?e("div",{className:"cm-field"},e("label",null,n("minimaxOrigin")),e("input",{className:"cm-input",type:"url",value:s.baseUrl??"",placeholder:"https://www.minimax.cn","aria-label":n("minimaxOrigin"),onChange:a=>y("baseUrl",a.target.value)}),e("p",{className:"cm-note"},n("minimaxOriginNote"))):null,t==="qwen"?e("div",{className:"cm-field"},e("label",null,n("qwenSource")),e("select",{className:"cm-input",value:s.quotaSource??"local",onChange:a=>y("quotaSource",a.target.value)},e("option",{value:"local"},n("qwenSourceLocal")),e("option",{value:"cli"},n("qwenSourceCli")),e("option",{value:"bailian"},n("qwenSourceBailian"))),e("p",{className:"cm-note"},n(s.quotaSource==="bailian"?"qwenBailianNote":"qwenCliNote"))):null,e("div",{className:"cm-field"},e("label",null,n("codingPlanDisplayLabel")),e("select",{className:"cm-input","aria-label":n("codingPlanDisplayLabel"),value:ne(s,(l??g).quotaStrip,"plans"),onChange:a=>{if(l===null)return;const i=l.codingPlans??g.codingPlans??{};h({...l,codingPlans:{...i,[t]:{...s,...te(a.target.value)}}})}},...le(n)),e("span",{className:"cm-hint"},x(u.config)==="en"?"Choose the sidebar, settings, the area above the input box, or a combination. Individual placement overrides strip defaults.":"可单独选择侧栏、设置页或输入框上方,也可同时显示。单家位置优先于横条默认设置。")),t!=="scnet"&&(t!=="qwen"||(s.quotaSource??"local")!=="local")?e("div",{className:"cm-field"},e("label",null,n("codingPlanRefreshIntervalLabel")),Z({value:typeof s.refreshMinutes=="number"&&Number.isFinite(s.refreshMinutes)&&s.refreshMinutes>0?s.refreshMinutes:15},a=>{y("refreshMinutes",Math.min(1440,Math.max(1,Math.floor(a))))})):null,t==="scnet"||t==="qwen"&&(s.quotaSource??"local")==="local"?e(P,null,e("div",{className:"cm-field"},e("label",null,n(t==="qwen"?"qwenPlanCreditsLabel":"scnetPlanCreditsLabel")),e("input",{className:"cm-input",type:"number",min:"1",step:"1000",value:typeof s.planCredits=="number"&&Number.isFinite(s.planCredits)&&s.planCredits>0?s.planCredits:t==="qwen"?5e5:24e4,onChange:a=>{const i=Number(a.target.value);Number.isFinite(i)&&i>0&&y("planCredits",Math.floor(i))}})),e("div",{className:"cm-field"},e("label",null,n(t==="qwen"?"qwenPlanStartLabel":"scnetPlanStartLabel")),e("input",{className:"cm-input",type:"date",value:typeof s.planStart=="string"?s.planStart:"",onChange:a=>y("planStart",a.target.value)})),t==="qwen"?e(P,null,e("div",{className:"cm-field"},e("label",null,n("qwenRatesLabel"))),[...new Set([...Object.keys(F(s)),...Object.keys(v)])].sort().map(a=>e("div",{key:a,className:"cm-match-row"},e("span",{style:{minWidth:"120px"}},a),W.map(i=>e("input",{key:i,className:"cm-input narrow",type:"number",min:"0",step:"0.1",value:U(a)[i]??"",placeholder:n("qwenRate_"+i),"aria-label":a+" · "+n("qwenRate_"+i),onChange:q=>{const S=q.target.value;ce(a,i,S)}})),e("button",{className:"cm-btn small",onClick:()=>re(a)},n("overrideRemove")),a in v&&!j(U(a))?e("span",{className:"cm-note"},n("qwenRateDraftNote")):null)),e("div",{className:"cm-buttons"},e("input",{className:"cm-input narrow",type:"text",placeholder:n("qwenRatesModelPlaceholder"),value:T,onChange:a=>d(a.target.value)}),e("button",{className:"cm-btn small",onClick:()=>{const a=T.trim();a.length!==0&&(ie(a),d(""))},disabled:T.trim().length===0},n("qwenRatesAdd")))):null,e("p",{className:"cm-note"},n(t==="qwen"?"qwenLocalNote":"scnetLocalNote"))):t==="qwen"?null:t==="volcengine"?e(P,null,e("div",{className:"cm-field"},e("label",null,n("volcengineAccessKeyIdLabel"))),e(K,{state:u,draft:l,setDraft:h,target:"codingPlans.volcengine.ak",configured:c.keyConfigured===!0,source:c.keySource,t:n,api:f,placeholder:n("volcengineAccessKeyPlaceholder")}),e("div",{className:"cm-field"},e("label",null,n("volcengineSecretAccessKeyLabel"))),e(K,{state:u,draft:l,setDraft:h,target:"codingPlans.volcengine.sk",configured:c.keyConfigured===!0,source:c.keySource,t:n,api:f,placeholder:n("volcengineSecretPlaceholder")}),e("p",{className:"cm-note"},x(u.config)==="en"?"Volcano Ark needs AK/SK, ArkReadOnlyAccess and BillingCenterReadOnlyAccess. Enter credentials or export VOLC_ACCESSKEY/VOLC_SECRETKEY. Only open.volcengineapi.com is contacted.":"火山方舟需 AK/SK、ArkReadOnlyAccess 和 BillingCenterReadOnlyAccess;可填凭据或导出 VOLC_ACCESSKEY/VOLC_SECRETKEY。只连接 open.volcengineapi.com。")):t==="workbuddy"?e(P,null,e("p",{className:"cm-note"},n("wbH")),e(oe,{live:c,config:s,setPlan:y,state:u})):e(P,null,e("div",{className:"cm-field"},e("label",null,t==="baidu-coding"?"Cookie (console.bce.baidu.com)":t==="mimo"?"Cookie (platform.xiaomimimo.com)":t==="factory"?"Factory Token":t==="opendesign"?"OpenDesign Cookie / Control Key":n("codingPlanKeyLabel"))),e(K,{state:u,draft:l,setDraft:h,target:"codingPlans."+t,configured:c.keyConfigured===!0,source:c.keySource,t:n,api:f,placeholder:t==="baidu-coding"?"BAIDU_QIANFAN_COOKIE":t==="mimo"?"api-platform_serviceToken=…; userId=…":t==="factory"?"FACTORY_API_KEY":t==="opendesign"?"Cookie: name=value; … / vela_ctrl_…":"sk-…"}),t==="baidu-coding"?e("p",{className:"cm-note"},x(u.config)==="en"?"Sign in at console.bce.baidu.com, open Token Plan → browser Network → tokenPlanPersonal/resource, and copy the full Cookie request header. Supports Personal credits and Tokens; excludes add-on packs. API keys cannot query quotas.":"登录 console.bce.baidu.com,打开 Token Plan 页面,在浏览器网络面板找到 tokenPlanPersonal/resource,复制完整 Cookie 请求头。支持个人版积分制与 Token 制套餐,不含加油包;API Key 不用于额度查询。"):null));return e(ae,{planId:t,targeted:b.targeted,name:n(p),enabled:A,saved:g.codingPlans?.[t],busy:N,open:o,errorMsg:C?.text===c.message?null:C,statusNode:de,configNode:ue,onToggle:a=>y("enabled",a),onRefresh:M,onLogin:M,loginRequired:w,onToggleOpen:()=>r(a=>!a),t:n})}return b=>b.mode==="credential"?e(K,b):e(se,b)}}}});
|