waygate-open 1.6.15 → 1.6.16

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 CHANGED
@@ -8,7 +8,7 @@
8
8
  [![NestJS](https://img.shields.io/badge/NestJS-12-E0234E?style=flat-square)](https://nestjs.com)
9
9
  [![SQLite](https://img.shields.io/badge/SQLite-better--sqlite3-003B57?style=flat-square)](https://github.com/WiseLibs/better-sqlite3)
10
10
  [![Node](https://img.shields.io/badge/Node-%E2%89%A522.9-3C873A?style=flat-square)](https://nodejs.org)
11
- [![version](https://img.shields.io/badge/version-1.6.15-4A38C0?style=flat-square)](https://github.com/zhanghaojie513/waygate-open/releases)
11
+ [![version](https://img.shields.io/badge/version-1.6.16-4A38C0?style=flat-square)](https://github.com/zhanghaojie513/waygate-open/releases)
12
12
  [![tests](https://img.shields.io/badge/tests-741%20passed-0A7247?style=flat-square)](./server)
13
13
 
14
14
  ![途关 · Waygate](docs/img/intro.png)
@@ -391,4 +391,4 @@ tools/ 仓库级工具(lint 门禁、token 合并、截图
391
391
 
392
392
  ---
393
393
 
394
- 版本约定:`1.0.0` 起 API 契约稳定(当前 `1.6.15`,见 `server/src/version.ts`;历史版本见 [Releases](https://github.com/zhanghaojie513/waygate-open/releases))。
394
+ 版本约定:`1.0.0` 起 API 契约稳定(当前 `1.6.16`,见 `server/src/version.ts`;历史版本见 [Releases](https://github.com/zhanghaojie513/waygate-open/releases))。
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "waygate-open",
3
- "version": "1.6.15",
3
+ "version": "1.6.16",
4
4
  "description": "途关 Waygate · 本地启动 —— 把 WorkBuddy / MiniMax Code / Qoder CN 的客户端订阅转成 OpenAI / Anthropic 兼容 base_url(自带控制台,一条命令起服务并自动打开浏览器)",
5
5
  "license": "MIT",
6
6
  "bin": {
@@ -71,19 +71,24 @@ function aggregateAccounts(accounts, nowMs) {
71
71
  continue;
72
72
  const acc = item;
73
73
  const expireMs = parseCnTime(acc['ExpiredTime']);
74
- if (expireMs !== null && expireMs <= nowMs)
75
- continue; // 已过期:作废不计入
74
+ /* [2026-10-17 口径修正] 过期包**不再整包跳过**,只按字段分流:
75
+ · remain(剩余)只累计**未过期**包 —— 过期包的余额确实不可用;
76
+ · total(累计发放)/ used(已消耗)**含过期包** —— 发放和消耗是历史事实,
77
+ 包过期不该让它们从账上消失(实测:WB 的 6300 已消耗藏在 7 个过期包里,
78
+ 整包跳过导致「已消耗 96.95」小得反常)。 */
79
+ const expired = expireMs !== null && expireMs <= nowMs;
76
80
  const r = pickAccountNumber(acc, 'CapacityRemainPrecise', 'CapacityRemain');
77
81
  const s = pickAccountNumber(acc, 'CapacitySizePrecise', 'CapacitySize');
78
82
  if (r === null && s === null)
79
83
  continue; // 两数都没有:跳过该包,不猜
80
- remain += r ?? 0;
84
+ if (!expired)
85
+ remain += r ?? 0;
81
86
  total += s ?? 0;
82
87
  const used = pickAccountNumber(acc, 'CapacityUsedPrecise', 'CapacityUsed');
83
88
  usedSum = usedSum === null ? (used !== null ? used : null) : used !== null ? usedSum + used : usedSum || null;
84
89
  packages.push({
85
90
  name: typeof acc['PackageName'] === 'string' ? acc['PackageName'] : '',
86
- remain: r ?? 0,
91
+ remain: expired ? 0 : r ?? 0,
87
92
  size: s ?? 0,
88
93
  used,
89
94
  expireAt: expireMs,
@@ -12,4 +12,4 @@ exports.VERSION = void 0;
12
12
  * `version` 一致,不一致直接 fail build —— 两处版本永远不会悄悄分叉。
13
13
  * 升版本 = 同时改 package.json 与这里(构建会逼你对齐)。
14
14
  */
15
- exports.VERSION = '1.6.15';
15
+ exports.VERSION = '1.6.16';
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "waygate-server",
3
- "version": "1.6.15",
3
+ "version": "1.6.16",
4
4
  "private": true,
5
5
  "description": "驿站 · Relay — OpenAI 兼容反向代理与控制台(后端)",
6
6
  "engines": {
@@ -1,4 +1,4 @@
1
- import{D as e,J as t,K as n,S as r,_ as i,a,g as o,h as s,it as c,n as l,t as u,tt as d,z as f}from"./vendor-befEYGHM.js";import{A as p,D as m,M as h,a as g,c as _,g as v,j as y,m as b,r as x,v as S,y as C}from"./index-BJtz6Ses.js";import{a as w,c as T,l as E,n as D,o as O,r as k,s as A,t as j}from"./Select-HrLgXSri.js";import{t as M}from"./Modal-B-rIrvXS.js";import{n as N}from"./PageSkeleton-DG-Dj4_9.js";var P=c(),F=d(),I={live:`live`,off:`off`,exp:`exp`};function L({rows:e,clientByKey:t,pendingId:n,onToggle:r,onEdit:i,onDelete:c}){return(0,F.jsx)(`div`,{className:`tbl-scroll`,children:(0,F.jsxs)(`table`,{className:`tbl`,children:[(0,F.jsxs)(`caption`,{className:`sr-only`,children:[`API Key 列表,共 `,e.length,` 把密钥`]}),(0,F.jsx)(`thead`,{children:(0,F.jsxs)(`tr`,{children:[(0,F.jsx)(`th`,{scope:`col`,children:`名称 / 密钥`}),(0,F.jsx)(`th`,{scope:`col`,children:`绑定提供商`}),(0,F.jsx)(`th`,{scope:`col`,children:`权限范围`}),(0,F.jsx)(`th`,{scope:`col`,className:`r`,children:`近24h请求`}),(0,F.jsx)(`th`,{scope:`col`,className:`r`,children:`最后使用`}),(0,F.jsx)(`th`,{scope:`col`,children:`状态 / 到期`}),(0,F.jsx)(`th`,{scope:`col`,className:`r`,style:{width:184},children:`操作`})]})}),(0,F.jsx)(`tbody`,{children:e.map(e=>{let u=p(e.enabled,e.expiresAt),d=n===e.id,f=t?.get(e.id),h=e.clients??[];return(0,F.jsxs)(`tr`,{children:[(0,F.jsxs)(`td`,{children:[(0,F.jsx)(`div`,{className:`td-strong`,children:e.name}),(0,F.jsx)(`div`,{className:`td-sub td-mono`,children:e.hint})]}),(0,F.jsx)(`td`,{children:h.length>0?(0,F.jsx)(g,{content:`绑定提供商(路由优先级从高到低):\n${h.join(`
1
+ import{D as e,J as t,K as n,S as r,_ as i,a,g as o,h as s,it as c,n as l,t as u,tt as d,z as f}from"./vendor-befEYGHM.js";import{A as p,D as m,M as h,a as g,c as _,g as v,j as y,m as b,r as x,v as S,y as C}from"./index-nQeRK3kW.js";import{a as w,c as T,l as E,n as D,o as O,r as k,s as A,t as j}from"./Select-G6AhT0TA.js";import{t as M}from"./Modal-B-rIrvXS.js";import{n as N}from"./PageSkeleton-DG-Dj4_9.js";var P=c(),F=d(),I={live:`live`,off:`off`,exp:`exp`};function L({rows:e,clientByKey:t,pendingId:n,onToggle:r,onEdit:i,onDelete:c}){return(0,F.jsx)(`div`,{className:`tbl-scroll`,children:(0,F.jsxs)(`table`,{className:`tbl`,children:[(0,F.jsxs)(`caption`,{className:`sr-only`,children:[`API Key 列表,共 `,e.length,` 把密钥`]}),(0,F.jsx)(`thead`,{children:(0,F.jsxs)(`tr`,{children:[(0,F.jsx)(`th`,{scope:`col`,children:`名称 / 密钥`}),(0,F.jsx)(`th`,{scope:`col`,children:`绑定提供商`}),(0,F.jsx)(`th`,{scope:`col`,children:`权限范围`}),(0,F.jsx)(`th`,{scope:`col`,className:`r`,children:`近24h请求`}),(0,F.jsx)(`th`,{scope:`col`,className:`r`,children:`最后使用`}),(0,F.jsx)(`th`,{scope:`col`,children:`状态 / 到期`}),(0,F.jsx)(`th`,{scope:`col`,className:`r`,style:{width:184},children:`操作`})]})}),(0,F.jsx)(`tbody`,{children:e.map(e=>{let u=p(e.enabled,e.expiresAt),d=n===e.id,f=t?.get(e.id),h=e.clients??[];return(0,F.jsxs)(`tr`,{children:[(0,F.jsxs)(`td`,{children:[(0,F.jsx)(`div`,{className:`td-strong`,children:e.name}),(0,F.jsx)(`div`,{className:`td-sub td-mono`,children:e.hint})]}),(0,F.jsx)(`td`,{children:h.length>0?(0,F.jsx)(g,{content:`绑定提供商(路由优先级从高到低):\n${h.join(`
2
2
  `)}`,children:(0,F.jsx)(`span`,{className:`key-bindings`,children:(()=>{let e=h[0],t=f?.name===e?f:void 0;return(0,F.jsxs)(F.Fragment,{children:[t?(0,F.jsx)(`a`,{href:`#/clients?clientId=${encodeURIComponent(t.clientId)}`,children:e}):e,h.length>1?(0,F.jsx)(`i`,{className:`kb-rank`,children:`优先`}):null]})})()})}):f?(0,F.jsx)(`a`,{href:`#/clients?clientId=${encodeURIComponent(f.clientId)}`,children:f.name}):(0,F.jsx)(`span`,{className:`td-sub`,children:`未绑定`})}),(0,F.jsx)(`td`,{children:C(e.scope)}),(0,F.jsx)(`td`,{className:`r td-mono`,children:v(e.requests24h)}),(0,F.jsx)(`td`,{className:`r td-mono`,children:S(e.lastSeenAt)}),(0,F.jsxs)(`td`,{children:[(0,F.jsxs)(`span`,{style:{display:`inline-flex`,alignItems:`center`,gap:8,whiteSpace:`nowrap`},children:[(0,F.jsx)(E,{tone:I[u],children:m[u]}),(0,F.jsx)(`span`,{className:`td-sub td-mono`,children:e.expiresAt?`至 ${b(e.expiresAt)}`:`永不过期`})]}),e.maxIps!==null||e.tokenQuota!==null?(0,F.jsxs)(`div`,{className:`td-sub td-mono`,style:{marginTop:2},children:[e.maxIps===null?null:`IP ${e.usedIps??0}/${e.maxIps}`,e.maxIps!==null&&e.tokenQuota!==null?` · `:null,e.tokenQuota===null?null:`${v(e.usedTokens??0)}/${v(e.tokenQuota)} tok`,e.ipWhitelist&&e.ipWhitelist.length>0?` · 白名单 ${e.ipWhitelist.length} 条`:null]}):null]}),(0,F.jsx)(`td`,{className:`r`,children:(0,F.jsxs)(`span`,{style:{display:`inline-flex`,gap:8,justifyContent:`flex-start`},children:[(0,F.jsx)(g,{content:`改名 / 改绑定 / 访问控制(不动权限范围,密钥与哈希不受影响)`,children:d?(0,F.jsx)(`span`,{tabIndex:0,children:(0,F.jsxs)(`button`,{type:`button`,className:`mini-pill`,disabled:d,onClick:()=>i(e),children:[(0,F.jsx)(l,{size:12}),`修改`]})}):(0,F.jsxs)(`button`,{type:`button`,className:`mini-pill`,onClick:()=>i(e),children:[(0,F.jsx)(l,{size:12}),`修改`]})}),(0,F.jsx)(g,{content:u===`exp`?`已过期,需重新创建`:e.enabled?`停用后立即失效`:`重新启用`,children:d||u===`exp`?(0,F.jsx)(`span`,{tabIndex:0,children:(0,F.jsxs)(`button`,{type:`button`,className:`mini-pill`,disabled:!0,onClick:()=>r(e),children:[e.enabled?(0,F.jsx)(o,{size:12}):(0,F.jsx)(s,{size:12}),e.enabled?`停用`:`启用`]})}):(0,F.jsxs)(`button`,{type:`button`,className:`mini-pill`,onClick:()=>r(e),children:[e.enabled?(0,F.jsx)(o,{size:12}):(0,F.jsx)(s,{size:12}),e.enabled?`停用`:`启用`]})}),(0,F.jsxs)(`button`,{type:`button`,className:`mini-pill danger`,disabled:d,onClick:()=>c(e),children:[(0,F.jsx)(a,{size:12}),`删除`]})]})})]},e.id)})})]})})}var R={ipText:``,maxIps:``,tokenQuota:``};function z(e){return{ipText:e.ipWhitelist.join(`
3
3
  `),maxIps:e.maxIps===null?``:String(e.maxIps),tokenQuota:e.tokenQuota===null?``:String(e.tokenQuota)}}function B(e){return e.ipText.trim()!==``||e.maxIps.trim()!==``||e.tokenQuota.trim()!==``}function V(e){let t=e.trim();if(!t)return null;let n=t.indexOf(`/`);if(n>0){let e=t.slice(0,n),r=t.slice(n+1);return!/^\d{1,2}$/.test(r)||Number(r)>32?`「${t}」的掩码位数只能是 0-32`:H(e)?null:`「${t}」CIDR 只支持 IPv4 网段`}return H(t)||t.includes(`:`)&&/^[0-9a-fA-F:]+$/.test(t)?null:`「${t}」不是合法的 IP 地址(支持 IPv4、IPv6、IPv4 CIDR)`}function H(e){let t=e.split(`.`);return t.length===4&&t.every(e=>/^\d{1,3}$/.test(e)&&Number(e)<=255)}function U(e){let t=e.ipText.split(/[\n,]+/).map(e=>e.trim()).filter(e=>e!==``);for(let e of t){let t=V(e);if(t)return{error:`IP 白名单:${t}`}}let n=null;if(e.maxIps.trim()!==``&&(n=Number(e.maxIps),!Number.isInteger(n)||n<1))return{error:`最大 IP 数必须是正整数(留空 = 不限)。`};let r=null;return e.tokenQuota.trim()!==``&&(r=Number(e.tokenQuota),!Number.isInteger(r)||r<1)?{error:`Token 配额必须是正整数(留空 = 不限)。`}:{ipWhitelist:t,maxIps:n,tokenQuota:r}}function W(e){let t=[],n=e.ipText.split(/[\n,]+/).map(e=>e.trim()).filter(e=>e!==``).length;return n>0&&t.push(`白名单 ${n} 条`),e.maxIps.trim()!==``&&t.push(`最大 ${e.maxIps.trim()} IP`),e.tokenQuota.trim()!==``&&t.push(`配额 ${Number(e.tokenQuota).toLocaleString()} tok`),t.length>0?t.join(` · `):`未限制`}function G({draft:e,onChange:t,defaultOpen:r=!1}){let[i,a]=(0,P.useState)(r||B(e));return(0,F.jsxs)(`div`,{className:`ov-field`,children:[(0,F.jsxs)(`button`,{type:`button`,className:`policy-toggle`,"aria-expanded":i,onClick:()=>a(e=>!e),children:[(0,F.jsx)(n,{size:14,"aria-hidden":!0}),(0,F.jsxs)(`span`,{children:[`访问控制`,i?``:`(可选,留空 = 不限)`]}),i?null:(0,F.jsx)(`span`,{className:`policy-sum`,children:W(e)})]}),i?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(`textarea`,{className:`field-input text`,style:{width:`100%`,minHeight:48,resize:`vertical`,fontFamily:`var(--font-mono)`,marginTop:8},value:e.ipText,placeholder:`IP 白名单,每行一个:
4
4
  203.0.113.7
@@ -1 +1 @@
1
- import{tt as e}from"./vendor-befEYGHM.js";import{_ as t,d as n,g as r,p as i,x as a}from"./index-BJtz6Ses.js";var o=e();function s({metrics:e}){return(0,o.jsxs)(`div`,{className:`credit-banner`,children:[(0,o.jsxs)(`div`,{className:`cb-left`,children:[(0,o.jsx)(`div`,{className:`cb-label`,children:`本窗口总 tokens`}),(0,o.jsx)(`div`,{children:(0,o.jsx)(`span`,{className:`cb-num`,children:a(e.totalTokens)})}),(0,o.jsx)(`div`,{className:`cb-why`,children:(0,o.jsxs)(`span`,{children:[`输入 `,a(e.promptTokens),` · 输出 `,a(e.completionTokens)]})})]}),(0,o.jsxs)(`div`,{className:`cb-mid`,children:[(0,o.jsx)(`div`,{className:`row`,children:(0,o.jsxs)(`span`,{className:`t`,children:[`经本服务转发已用 `,i(e.creditsUsed),` 积分`]})}),(0,o.jsxs)(`div`,{className:`cb-note`,children:[`仅统计经本服务转发的请求(取上游实扣 usage.credit;上游未回报的行积分未知,不计入合计`,e.creditsUnknownCount>0?`,本窗口 ${r(e.creditsUnknownCount)} 条`:``,`)。 官方客户端直连的消耗不计入 —— 账户总消耗与余额以官方客户端为准。`]})]}),(0,o.jsxs)(`div`,{className:`cb-right`,children:[(0,o.jsx)(`div`,{className:`cb-label`,children:`缓存命中率`}),(0,o.jsx)(`div`,{className:`cb-num`,style:{fontSize:22},children:n(e.cacheHitRate)}),(0,o.jsxs)(`div`,{className:`cb-note`,children:[a(e.cachedTokens),` / `,a(e.promptTokens),` 输入 tokens`]})]})]})}function c({row:e}){let n=e.models??[],s=Math.max(0,(e.modelCount??n.length)-n.length),c=Math.max(0,e.tokens??0),l=e.client??`未归属`;return(0,o.jsxs)(`div`,{className:`client-model-tip`,children:[(0,o.jsxs)(`div`,{className:`client-model-tip-head`,children:[(0,o.jsxs)(`div`,{className:`client-model-tip-title`,children:[(0,o.jsx)(`strong`,{children:l}),(0,o.jsx)(`span`,{children:`模型消耗明细`})]}),(0,o.jsx)(`span`,{className:`client-model-tip-tag`,children:`按模型`})]}),(0,o.jsxs)(`div`,{className:`client-model-tip-summary`,children:[(0,o.jsxs)(`div`,{children:[(0,o.jsx)(`span`,{children:`总 tokens`}),(0,o.jsx)(`b`,{children:a(c)})]}),(0,o.jsxs)(`div`,{children:[(0,o.jsx)(`span`,{children:`总积分`}),(0,o.jsx)(`b`,{children:i(e.credits)})]})]}),n.length>0?(0,o.jsx)(`div`,{className:`client-model-tip-list`,children:n.map((e,n)=>{let s=c>0?e.tokens/c:0,l=e.displayName??e.model,u=!!(e.displayName&&e.displayName!==e.model);return(0,o.jsxs)(`div`,{className:`client-model-tip-row`,children:[(0,o.jsxs)(`div`,{className:`client-model-tip-row-head`,children:[(0,o.jsx)(`span`,{className:`client-model-tip-rank`,children:String(n+1).padStart(2,`0`)}),(0,o.jsxs)(`div`,{className:`client-model-tip-name`,children:[(0,o.jsx)(`strong`,{children:l}),u?(0,o.jsx)(`span`,{children:e.model}):null]}),(0,o.jsxs)(`b`,{children:[a(e.tokens),` `,(0,o.jsx)(`em`,{children:`tokens`})]})]}),(0,o.jsxs)(`div`,{className:`client-model-tip-row-meta`,children:[(0,o.jsx)(`span`,{className:`client-model-tip-track`,children:(0,o.jsx)(`i`,{style:{width:`${Math.max(0,Math.min(100,s*100))}%`}})}),(0,o.jsx)(`span`,{children:t(s)}),(0,o.jsxs)(`span`,{children:[r(e.requests),` 次`]}),(0,o.jsxs)(`span`,{children:[i(e.credits),` 积分`]})]})]},e.model)})}):(0,o.jsx)(`div`,{className:`client-model-tip-empty`,children:`当前窗口没有可拆分的模型记录。`}),s>0?(0,o.jsxs)(`div`,{className:`client-model-tip-note`,children:[`另有 `,s,` 个模型未展开,完整明细见「按模型消耗明细」。`]}):null]})}var l={credits:`消耗积分`,tokens:`Token 消耗`,requests:`请求次数`};function u(e,t){return e[t]??0}function d(e,t){return t===`credits`?i(e):t===`tokens`?a(e):r(e)}function f(e){return e===`credits`?`积分`:e===`tokens`?`tokens`:`次`}function p({rows:e,metric:n,windowLabel:r,total:i,totalCount:a}){let s=e.slice(0,6),c=Math.max(0,a-s.length),p=Math.max(0,i);return(0,o.jsxs)(`div`,{className:`client-metric-tip`,children:[(0,o.jsxs)(`div`,{className:`client-metric-tip-head`,children:[(0,o.jsxs)(`div`,{children:[(0,o.jsx)(`strong`,{children:`客户端拆分`}),(0,o.jsxs)(`span`,{children:[r,` · `,l[n]]})]}),(0,o.jsxs)(`span`,{className:`client-metric-tip-tag`,children:[`TOP `,s.length]})]}),(0,o.jsxs)(`div`,{className:`client-metric-tip-total`,children:[(0,o.jsx)(`span`,{children:`窗口合计`}),(0,o.jsxs)(`b`,{children:[d(p,n),` `,(0,o.jsx)(`em`,{children:f(n)})]})]}),(0,o.jsx)(`div`,{className:`client-metric-tip-list`,children:s.map((e,r)=>{let i=u(e,n),a=p>0?i/p:0;return(0,o.jsxs)(`div`,{className:`client-metric-tip-row`,children:[(0,o.jsxs)(`div`,{className:`client-metric-tip-row-top`,children:[(0,o.jsx)(`span`,{className:`client-metric-tip-rank`,children:String(r+1).padStart(2,`0`)}),(0,o.jsx)(`span`,{className:`client-metric-tip-name`,children:e.client??`未归属`}),(0,o.jsxs)(`b`,{children:[d(i,n),` `,(0,o.jsx)(`em`,{children:f(n)})]})]}),(0,o.jsxs)(`div`,{className:`client-metric-tip-row-bottom`,children:[(0,o.jsx)(`span`,{className:`client-metric-tip-track`,children:(0,o.jsx)(`i`,{style:{width:`${Math.max(0,Math.min(100,a*100))}%`}})}),(0,o.jsx)(`span`,{children:t(a)})]})]},e.clientId??e.client??r)})}),c>0?(0,o.jsxs)(`div`,{className:`client-metric-tip-note`,children:[`另有 `,c,` 个客户端未展开,完整明细见按客户端列表。`]}):null]})}export{c as n,s as r,p as t};
1
+ import{tt as e}from"./vendor-befEYGHM.js";import{_ as t,d as n,g as r,p as i,x as a}from"./index-nQeRK3kW.js";var o=e();function s({metrics:e}){return(0,o.jsxs)(`div`,{className:`credit-banner`,children:[(0,o.jsxs)(`div`,{className:`cb-left`,children:[(0,o.jsx)(`div`,{className:`cb-label`,children:`本窗口总 tokens`}),(0,o.jsx)(`div`,{children:(0,o.jsx)(`span`,{className:`cb-num`,children:a(e.totalTokens)})}),(0,o.jsx)(`div`,{className:`cb-why`,children:(0,o.jsxs)(`span`,{children:[`输入 `,a(e.promptTokens),` · 输出 `,a(e.completionTokens)]})})]}),(0,o.jsxs)(`div`,{className:`cb-mid`,children:[(0,o.jsx)(`div`,{className:`row`,children:(0,o.jsxs)(`span`,{className:`t`,children:[`经本服务转发已用 `,i(e.creditsUsed),` 积分`]})}),(0,o.jsxs)(`div`,{className:`cb-note`,children:[`仅统计经本服务转发的请求(取上游实扣 usage.credit;上游未回报的行积分未知,不计入合计`,e.creditsUnknownCount>0?`,本窗口 ${r(e.creditsUnknownCount)} 条`:``,`)。 官方客户端直连的消耗不计入 —— 账户总消耗与余额以官方客户端为准。`]})]}),(0,o.jsxs)(`div`,{className:`cb-right`,children:[(0,o.jsx)(`div`,{className:`cb-label`,children:`缓存命中率`}),(0,o.jsx)(`div`,{className:`cb-num`,style:{fontSize:22},children:n(e.cacheHitRate)}),(0,o.jsxs)(`div`,{className:`cb-note`,children:[a(e.cachedTokens),` / `,a(e.promptTokens),` 输入 tokens`]})]})]})}function c({row:e}){let n=e.models??[],s=Math.max(0,(e.modelCount??n.length)-n.length),c=Math.max(0,e.tokens??0),l=e.client??`未归属`;return(0,o.jsxs)(`div`,{className:`client-model-tip`,children:[(0,o.jsxs)(`div`,{className:`client-model-tip-head`,children:[(0,o.jsxs)(`div`,{className:`client-model-tip-title`,children:[(0,o.jsx)(`strong`,{children:l}),(0,o.jsx)(`span`,{children:`模型消耗明细`})]}),(0,o.jsx)(`span`,{className:`client-model-tip-tag`,children:`按模型`})]}),(0,o.jsxs)(`div`,{className:`client-model-tip-summary`,children:[(0,o.jsxs)(`div`,{children:[(0,o.jsx)(`span`,{children:`总 tokens`}),(0,o.jsx)(`b`,{children:a(c)})]}),(0,o.jsxs)(`div`,{children:[(0,o.jsx)(`span`,{children:`总积分`}),(0,o.jsx)(`b`,{children:i(e.credits)})]})]}),n.length>0?(0,o.jsx)(`div`,{className:`client-model-tip-list`,children:n.map((e,n)=>{let s=c>0?e.tokens/c:0,l=e.displayName??e.model,u=!!(e.displayName&&e.displayName!==e.model);return(0,o.jsxs)(`div`,{className:`client-model-tip-row`,children:[(0,o.jsxs)(`div`,{className:`client-model-tip-row-head`,children:[(0,o.jsx)(`span`,{className:`client-model-tip-rank`,children:String(n+1).padStart(2,`0`)}),(0,o.jsxs)(`div`,{className:`client-model-tip-name`,children:[(0,o.jsx)(`strong`,{children:l}),u?(0,o.jsx)(`span`,{children:e.model}):null]}),(0,o.jsxs)(`b`,{children:[a(e.tokens),` `,(0,o.jsx)(`em`,{children:`tokens`})]})]}),(0,o.jsxs)(`div`,{className:`client-model-tip-row-meta`,children:[(0,o.jsx)(`span`,{className:`client-model-tip-track`,children:(0,o.jsx)(`i`,{style:{width:`${Math.max(0,Math.min(100,s*100))}%`}})}),(0,o.jsx)(`span`,{children:t(s)}),(0,o.jsxs)(`span`,{children:[r(e.requests),` 次`]}),(0,o.jsxs)(`span`,{children:[i(e.credits),` 积分`]})]})]},e.model)})}):(0,o.jsx)(`div`,{className:`client-model-tip-empty`,children:`当前窗口没有可拆分的模型记录。`}),s>0?(0,o.jsxs)(`div`,{className:`client-model-tip-note`,children:[`另有 `,s,` 个模型未展开,完整明细见「按模型消耗明细」。`]}):null]})}var l={credits:`消耗积分`,tokens:`Token 消耗`,requests:`请求次数`};function u(e,t){return e[t]??0}function d(e,t){return t===`credits`?i(e):t===`tokens`?a(e):r(e)}function f(e){return e===`credits`?`积分`:e===`tokens`?`tokens`:`次`}function p({rows:e,metric:n,windowLabel:r,total:i,totalCount:a}){let s=e.slice(0,6),c=Math.max(0,a-s.length),p=Math.max(0,i);return(0,o.jsxs)(`div`,{className:`client-metric-tip`,children:[(0,o.jsxs)(`div`,{className:`client-metric-tip-head`,children:[(0,o.jsxs)(`div`,{children:[(0,o.jsx)(`strong`,{children:`客户端拆分`}),(0,o.jsxs)(`span`,{children:[r,` · `,l[n]]})]}),(0,o.jsxs)(`span`,{className:`client-metric-tip-tag`,children:[`TOP `,s.length]})]}),(0,o.jsxs)(`div`,{className:`client-metric-tip-total`,children:[(0,o.jsx)(`span`,{children:`窗口合计`}),(0,o.jsxs)(`b`,{children:[d(p,n),` `,(0,o.jsx)(`em`,{children:f(n)})]})]}),(0,o.jsx)(`div`,{className:`client-metric-tip-list`,children:s.map((e,r)=>{let i=u(e,n),a=p>0?i/p:0;return(0,o.jsxs)(`div`,{className:`client-metric-tip-row`,children:[(0,o.jsxs)(`div`,{className:`client-metric-tip-row-top`,children:[(0,o.jsx)(`span`,{className:`client-metric-tip-rank`,children:String(r+1).padStart(2,`0`)}),(0,o.jsx)(`span`,{className:`client-metric-tip-name`,children:e.client??`未归属`}),(0,o.jsxs)(`b`,{children:[d(i,n),` `,(0,o.jsx)(`em`,{children:f(n)})]})]}),(0,o.jsxs)(`div`,{className:`client-metric-tip-row-bottom`,children:[(0,o.jsx)(`span`,{className:`client-metric-tip-track`,children:(0,o.jsx)(`i`,{style:{width:`${Math.max(0,Math.min(100,a*100))}%`}})}),(0,o.jsx)(`span`,{children:t(a)})]})]},e.clientId??e.client??r)})}),c>0?(0,o.jsxs)(`div`,{className:`client-metric-tip-note`,children:[`另有 `,c,` 个客户端未展开,完整明细见按客户端列表。`]}):null]})}export{c as n,s as r,p as t};
@@ -0,0 +1 @@
1
+ import{H as e,I as t,J as n,L as r,Q as i,S as a,U as o,a as s,it as c,m as l,n as u,tt as d,z as f}from"./vendor-befEYGHM.js";import{M as p,a as m,c as h,g,j as _,k as v,p as y,r as b,t as x,v as S}from"./index-nQeRK3kW.js";import{a as C,c as w,n as T,r as E,s as D,t as O}from"./Select-G6AhT0TA.js";import{t as k}from"./Modal-B-rIrvXS.js";import{t as A}from"./PageSkeleton-DG-Dj4_9.js";import{n as j,t as M}from"./sharedWindow-FDfq75PI.js";import{t as N}from"./Drawer-CleQGhRU.js";import{t as P}from"./Switch-0KA1AbiV.js";var F=c(),I=d();function L({rows:e,byProvider:t,busyId:n,onEdit:r,onModels:a,onSignin:o,onGrowthRun:c,onOauthImport:d,onActivate:f,onDeactivate:p,onDelete:h}){let _=()=>new Intl.DateTimeFormat(`en-CA`,{timeZone:`Asia/Shanghai`,year:`numeric`,month:`2-digit`,day:`2-digit`}).format(new Date),v=new Map((t??[]).map(e=>[e.providerId??``,e]));return(0,I.jsx)(`div`,{className:`tbl-scroll`,children:(0,I.jsxs)(`table`,{className:`tbl`,children:[(0,I.jsxs)(`caption`,{className:`sr-only`,children:[`提供商列表,共 `,e.length,` 家提供商`]}),(0,I.jsx)(`thead`,{children:(0,I.jsxs)(`tr`,{children:[(0,I.jsx)(`th`,{scope:`col`,children:`提供商`}),(0,I.jsx)(`th`,{scope:`col`,children:`密钥`}),(0,I.jsx)(`th`,{scope:`col`,className:`r`,children:`请求次数`}),(0,I.jsx)(`th`,{scope:`col`,className:`r`,children:`消耗积分`}),(0,I.jsx)(`th`,{scope:`col`,className:`r`,children:`最后活跃`}),(0,I.jsx)(`th`,{scope:`col`,className:`r`,children:`操作`})]})}),(0,I.jsx)(`tbody`,{children:e.map(t=>{let b=n===t.id;return(0,I.jsxs)(`tr`,{className:`prov-row`,children:[(0,I.jsxs)(`td`,{className:`td-strong`,children:[t.name,t.active?(0,I.jsx)(w,{tone:`live`,children:`已启用`}):(0,I.jsx)(w,{tone:`ghost`,children:`未启用`}),t.protocol===`anthropic`?(0,I.jsx)(m,{content:`Anthropic Messages 方言(mavis 网关):模型目录用内置清单,凭证为 refresh token 自动换新`,children:(0,I.jsx)(`span`,{className:`pill pill-ghost`,children:`Anthropic`})}):t.protocol===`qoder`?(0,I.jsx)(m,{content:`Qoder CN 网关(COSY 协议):免费档 billable:false 实扣 0;目录从网关 /model/list 拉取;凭证为客户端身份 JSON(不自动刷新)`,children:(0,I.jsx)(`span`,{className:`pill pill-ghost`,children:`Qoder`})}):null,(0,I.jsx)(`div`,{className:`td-sub td-mono`,children:(0,I.jsx)(m,{content:(0,I.jsx)(I.Fragment,{children:(0,I.jsxs)(`div`,{className:`client-model-tip`,children:[(0,I.jsxs)(`div`,{className:`client-model-tip-head`,children:[(0,I.jsxs)(`div`,{className:`client-model-tip-title`,children:[(0,I.jsx)(`strong`,{children:t.name}),(0,I.jsx)(`span`,{children:t.baseUrl})]}),(0,I.jsx)(`span`,{className:`client-model-tip-tag`,children:t.active?`已启用`:`未启用`})]}),(0,I.jsxs)(`div`,{className:`client-model-tip-summary`,children:[(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`span`,{children:`模型总数`}),(0,I.jsx)(`b`,{children:g(t.modelCount??0)})]}),(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`span`,{children:`已启用`}),(0,I.jsx)(`b`,{children:g(t.modelEnabled??0)})]})]}),(()=>{let e=t.credits?.available?{remaining:t.credits.remaining,consumed:t.credits.consumed}:t.wbCredits?{remaining:t.wbCredits.remaining,consumed:t.wbCredits.consumed}:t.qoderCredits?{remaining:t.qoderCredits.remaining,consumed:t.qoderCredits.consumed}:null;return e&&(e.remaining!==null||e.consumed!==null)?(0,I.jsxs)(`div`,{className:`client-metric-tip-total`,children:[(0,I.jsx)(`span`,{children:`剩余积分`}),(0,I.jsxs)(`b`,{children:[y(e.remaining??0),` `,(0,I.jsxs)(`em`,{children:[`已用 `,y(e.consumed??0)]})]})]}):null})(),t.credits?.stale||t.qoderCredits?.stale?(0,I.jsx)(`div`,{className:`client-model-tip-note`,children:`⚠ 积分数据偏旧(账本快照超时)`}):null]})}),children:(0,I.jsxs)(`span`,{className:`prov-model-count`,children:[g(t.modelCount??0),` 个模型`]})})})]}),(0,I.jsxs)(`td`,{className:`td-cred`,children:[(0,I.jsx)(m,{content:`供应商访问密钥(掩码显示;全量只存在服务器上)`,children:(0,I.jsx)(`span`,{className:`cred-mask`,children:t.credentialMask})}),(0,I.jsx)(`span`,{className:`up-badge${t.configured?``:` warn`}`,children:t.configured?`有效`:`未配置`})]}),(0,I.jsx)(`td`,{className:`r td-mono`,children:t.active?g(v.get(t.id)?.requests??0):`—`}),(0,I.jsx)(`td`,{className:`r td-mono`,children:t.active?y(v.get(t.id)?.credits??0):`—`}),(0,I.jsx)(`td`,{className:`r td-mono`,children:t.active?S(v.get(t.id)?.lastSeenAt??null):`—`}),(0,I.jsx)(`td`,{className:`r`,children:(0,I.jsxs)(`span`,{className:`prov-row-actions`,children:[(0,I.jsx)(m,{content:`改名称与上游地址;凭证可在抽屉内「重新导入授权」`,children:(0,I.jsxs)(`button`,{type:`button`,className:`mini-pill`,disabled:b,onClick:()=>r(t),children:[(0,I.jsx)(u,{size:12}),`配置`]})}),(0,I.jsx)(m,{content:`查看这家自己的模型清单(启停只作用于该提供商分区)`,children:(0,I.jsxs)(`button`,{type:`button`,className:`mini-pill`,"aria-disabled":b||!t.active,onClick:()=>{!b&&t.active&&a(t)},children:[(0,I.jsx)(l,{size:12}),`模型列表`]})}),t.credKind===`oauth_minimax`||t.protocol===`qoder`?(0,I.jsx)(m,{content:(()=>{let e=t.protocol===`qoder`?`10:05`:`08:05`,n=t.signin?.checkedOn?`最近签到 ${t.signin.checkedOn}${t.signin.lastPoints?` · +${t.signin.lastPoints} 积分`:``}(relay 每天 ${e} 自动签)`:`今天还没签到 —— 点一下立即签(relay 每天 ${e} 也会自动签)`;return t.protocol===`qoder`?(0,I.jsxs)(I.Fragment,{children:[n,(0,I.jsx)(`br`,{}),`Qoder 官方标注:每日 10:00(UTC+8)刷新,领取后 30 天有效。`]}):n})(),children:(0,I.jsxs)(`button`,{type:`button`,className:`mini-pill`,"aria-disabled":b||t.signin?.checkedOn===_(),onClick:()=>{b||t.signin?.checkedOn===_()||o(t)},children:[(0,I.jsx)(i,{size:12}),t.signin?.checkedOn===_()?`已签到`:`签到`]})}):null,t.protocol===`openai`?t.wbOAuth?.configured?(0,I.jsx)(m,{content:t.wbSignin?.checkedOn===_()?`今天已签到过(明天 08:05 自动跑;任务面板在设置 → 提供商健康)`:`立即签到 + 顺带跑一轮成长任务与连登兑换(每天 08:05 也会自动跑)。转发不受影响。`,children:(0,I.jsxs)(`button`,{type:`button`,className:`mini-pill`,"aria-disabled":b||t.wbSignin?.checkedOn===_(),onClick:()=>{!b&&t.wbSignin?.checkedOn!==_()&&c(t)},children:[(0,I.jsx)(i,{size:12}),t.wbSignin?.checkedOn===_()?`已签到`:`签到`]})}):(0,I.jsx)(m,{content:`导入桌面端 OAuth 凭证后可代领签到/任务(上游不允许 API 密钥代领)。粘贴 tools/wb-oauth-export.mjs 的输出;转发仍走 API 密钥。`,children:(0,I.jsxs)(`button`,{type:`button`,className:`mini-pill`,"aria-disabled":b,onClick:()=>{b||d(t)},children:[(0,I.jsx)(i,{size:12}),`导入OAuth`]})}):null,t.active?(0,I.jsx)(m,{content:`退出出站路由(目录与凭证保留,可再启用)`,children:(0,I.jsx)(`button`,{type:`button`,className:`mini-pill`,"aria-disabled":b,onClick:()=>{b||p(t)},children:`停用`})}):(0,I.jsx)(`button`,{type:`button`,className:`mini-pill`,disabled:b,onClick:()=>f(t),children:`启用`}),(0,I.jsx)(m,{content:t.active?`不能删除已启用的提供商 —— 先停用它`:e.length<=1?`至少保留一个提供商`:`删除这个提供商(凭证文件一并删除)`,children:(0,I.jsxs)(`button`,{type:`button`,className:`mini-pill danger`,"aria-disabled":b||t.active||e.length<=1,onClick:()=>{!b&&!t.active&&e.length>1&&h(t)},children:[(0,I.jsx)(s,{size:12}),`删除`]})})]})})]},t.id)})})]})})}function R({command:e}){let[t,r]=(0,F.useState)(!1);if(!e)return null;let i=async()=>{try{await navigator.clipboard.writeText(e),r(!0),setTimeout(()=>r(!1),2e3)}catch{r(!1)}};return(0,I.jsxs)(`div`,{className:`cred-guide-cmd`,children:[(0,I.jsx)(`code`,{children:e}),(0,I.jsxs)(`button`,{type:`button`,className:`copy`,"aria-label":t?`已复制命令`:`复制命令`,onClick:()=>void i(),children:[t?(0,I.jsx)(n,{size:13}):(0,I.jsx)(f,{size:13}),t?`已复制`:`复制`]})]})}var z=[{protocol:`openai`,label:`WorkBuddy`,desc:`OpenAI 方言`,needsAuth:!0},{protocol:`anthropic`,label:`MiniMax Code`,desc:`Anthropic 方言`,needsAuth:!0},{protocol:`qoder`,label:`Qoder CN`,desc:`COSY 协议`,needsAuth:!0}],B={openai:`https://copilot.tencent.com`,anthropic:`https://agent.minimax.cn`,qoder:`https://gateway.qoder.com.cn`},V=2500,H=3e5;function U({provider:e,onClose:n,onImported:r}){let i=x(),[o,s]=(0,F.useState)(e?`confirm`:`pick`),[c,l]=(0,F.useState)(e?.protocol??`anthropic`),[u,d]=(0,F.useState)(e?.name??``),[f,m]=(0,F.useState)(``),[g,_]=(0,F.useState)(``),[v,y]=(0,F.useState)(!1),[S,C]=(0,F.useState)(null),w=(0,F.useRef)(e?.id??null),T=(0,F.useRef)(!1),D=(0,F.useRef)(!1),O=z.find(e=>e.protocol===c);(0,F.useEffect)(()=>()=>{D.current=!0;let e=w.current;e&&h.providerImportDeviceCancel(e).catch(()=>void 0)},[]);let A=(0,F.useCallback)(async()=>{y(!0),C(null);try{let e=w.current;e||(e=(await h.createProvider({name:u.trim()||O.label,baseUrl:B[c]??B.openai,credential:``,protocol:c})).item.id,w.current=e,T.current=!0);let t=await h.providerImportDeviceStart(e);if(!t.ok||!t.authUrl){C(new p(t.message??`申请授权失败`,0,0)),s(`confirm`),y(!1);return}m(t.authUrl),_(t.userCode??``),window.open(t.authUrl,`_blank`,`noopener`),s(`waiting`),y(!1);let n=Date.now()+H;for(;!D.current&&Date.now()<n;){if(await new Promise(e=>setTimeout(e,V)),D.current)return;let t=await h.providerImportDevicePoll(e);if(D.current)return;if(t.status===`done`){s(`done`),i.push({tone:`success`,message:`${u.trim()||O.label} 授权已导入。`}),r();return}if(t.status===`error`){C(new p(t.message??`授权失败`,0,0)),s(`confirm`);return}}D.current||(C(new p(`授权超时(5 分钟)—— 请重新发起导入。`,0,0)),s(`confirm`))}catch(e){C(e instanceof p?e:new p(String(e),0,0)),s(`confirm`),y(!1)}},[O.label,u,r,c,i]);if(o===`done`)return(0,I.jsxs)(k,{title:`授权已导入`,onClose:n,footer:(0,I.jsx)(`button`,{type:`button`,className:`btn btn-primary btn-sm`,onClick:n,children:`完成`}),children:[(0,I.jsx)(b,{tone:`success`,children:(0,I.jsxs)(`span`,{children:[u.trim()||O.label,` 的授权已通过官方通道导入。`]})}),e?null:(0,I.jsxs)(`p`,{className:`ov-sub`,style:{marginTop:12},children:[`回到列表点`,(0,I.jsx)(`b`,{children:`试通`}),`确认可用,再按需启用(启用后它才参与出站路由)。`]})]});if(o===`waiting`)return(0,I.jsx)(k,{title:`等待你完成授权`,onClose:n,children:(0,I.jsxs)(`div`,{className:`cred-guide`,children:[(0,I.jsxs)(`div`,{className:`cred-guide-note`,children:[`已为你打开 `,(0,I.jsx)(`b`,{children:O.label}),` 的授权页 —— `,(0,I.jsx)(`b`,{children:`请在浏览器里完成授权`}),`, 本窗口会自动检测结果,无需回到终端。`]}),g?(0,I.jsxs)(`div`,{className:`cred-guide-note`,children:[`若页面要求输入短码:`,(0,I.jsx)(`span`,{className:`code-chip`,children:g})]}):null,(0,I.jsx)(R,{command:f}),(0,I.jsxs)(`div`,{className:`cred-guide-note`,style:{display:`flex`,alignItems:`center`,gap:8},children:[(0,I.jsx)(a,{size:14}),`正在等待授权完成…(最多 5 分钟;没弹出浏览器就点上面的链接)`]}),S?(0,I.jsx)(b,{tone:`error`,children:E(S)}):null]})});let j=o===`confirm`;return(0,I.jsx)(k,{title:e?`重新导入授权 · ${e.name}`:`导入客户端`,onClose:n,footer:(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`button`,{type:`button`,className:`btn btn-quiet btn-sm`,onClick:n,children:`取消`}),(0,I.jsxs)(`button`,{type:`button`,className:`btn btn-primary btn-sm`,disabled:v,onClick:()=>{if(!j){s(`confirm`);return}A()},children:[v?(0,I.jsx)(a,{size:14}):(0,I.jsx)(t,{size:14}),v?`正在申请授权…`:j?`确定,前往授权页`:`导入`]})]}),children:j?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(b,{tone:`warn`,children:(0,I.jsxs)(`span`,{children:[`即将跳转至 `,(0,I.jsx)(`b`,{children:O.label}),` 的授权页面(`,(0,I.jsx)(`b`,{children:`新标签页`}),`)。 请在页面里登录并完成授权,授权完成后本窗口会自动检测。`]})}),(0,I.jsxs)(`div`,{className:`cred-guide-note`,style:{marginTop:12},children:[`授权只用于取本工具的凭证;令牌保存在`,(0,I.jsx)(`b`,{children:`本机服务端`}),`(0600),不会回传到浏览器。`]}),c===`anthropic`?(0,I.jsxs)(`div`,{className:`cred-guide-note`,style:{marginTop:8},children:[`⚠️ MiniMax 的凭证是`,(0,I.jsx)(`b`,{children:`同账号单会话`}),`:请用`,(0,I.jsx)(`b`,{children:`专用账号`}),`, 否则会与日常客户端互相顶下线。`]}):null,S?(0,I.jsx)(b,{tone:`error`,children:E(S)}):null]}):(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`p`,{className:`ov-sub`,children:[`选一个客户端,用它的`,(0,I.jsx)(`b`,{children:`官方授权`}),`拿到凭证(凭证在客户端登录态里,用户拿不到、无需手填)。`]}),(0,I.jsxs)(`div`,{className:`ov-field`,children:[(0,I.jsx)(`label`,{children:`客户端类型`}),(0,I.jsx)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:6},children:z.map(e=>(0,I.jsxs)(`label`,{style:{display:`flex`,alignItems:`center`,gap:8,cursor:`pointer`},children:[(0,I.jsx)(`input`,{type:`radio`,name:`import-client`,checked:c===e.protocol,onChange:()=>l(e.protocol)}),(0,I.jsxs)(`span`,{children:[(0,I.jsx)(`b`,{children:e.label}),(0,I.jsx)(`span`,{className:`ov-hint`,style:{marginLeft:8},children:e.desc})]})]},e.protocol))})]}),(0,I.jsxs)(`div`,{className:`ov-field`,children:[(0,I.jsx)(`label`,{htmlFor:`imp-name`,children:`名称(可留空)`}),(0,I.jsx)(`input`,{id:`imp-name`,className:`field-input text`,style:{width:`100%`},value:u,placeholder:O.label,onChange:e=>d(e.target.value)})]})]})})}var W={upstream:`上游`,seed:`种子`,manual:`手工`},G={upstream:`从上游模型目录拉取到的`,seed:`来自本地种子清单(上游拉取失败时的回落)`,manual:`人工添加的`};function K({catalog:t,catalogLoading:n,catalogMsg:r,catalogError:i,onCatalogRefresh:s,onCatalogReload:c,onModelToggled:u}){let[d,f]=(0,F.useState)(null),p=async e=>{f(e.id);try{await u(e.id,!e.enabled)}finally{f(null)}};return(0,I.jsxs)(`div`,{className:`up-col`,children:[(0,I.jsxs)(`div`,{className:`up-models-head`,children:[(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`b`,{children:`可用模型`}),(0,I.jsx)(`span`,{children:t?`${t.models.length} 个 · ${t.models.filter(e=>e.enabled).length} 个已启用`:`尚未获取`})]}),(0,I.jsx)(`div`,{className:`up-models-actions`,children:n?(0,I.jsxs)(`button`,{type:`button`,className:`btn btn-quiet btn-sm`,disabled:!0,children:[(0,I.jsx)(a,{size:14,className:`spin`,style:{animation:`spin 1s linear infinite`}}),`正在实测模型…`]}):(0,I.jsxs)(`button`,{type:`button`,className:`btn btn-quiet btn-sm`,onClick:s,children:[(0,I.jsx)(l,{size:14}),`获取模型`]})})]}),n?(0,I.jsxs)(`div`,{className:`up-progress`,role:`status`,children:[(0,I.jsx)(a,{size:14,className:`spin`,style:{animation:`spin 1s linear infinite`},"aria-hidden":!0}),(0,I.jsxs)(`span`,{children:[`正在逐个实测模型(每个 1 token)…这一步会真打上游,`,(0,I.jsx)(`b`,{children:`可能要几十秒`}),`,请不要关掉页面; 完成后结果会出现在这里,模型清单也会自动刷新。`]})]}):null,r?(0,I.jsx)(b,{tone:r.kind===`error`?`error`:r.kind===`partial`?`warn`:`success`,children:r.text}):null,i?(0,I.jsx)(T,{kind:`error`,title:`模型清单没拉到`,detail:E(i),onRetry:c}):n&&!t?(0,I.jsx)(T,{kind:`loading`,title:`正在向上游获取模型…`}):!t||t.models.length===0?(0,I.jsx)(T,{kind:`empty`,title:`还没有模型清单`,detail:`启用提供商后会自动同步一次它自己的模型清单;这里也可以手动点「获取模型」逐项实测是否真的能调通。`}):(0,I.jsx)(`div`,{className:`up-models`,children:t.models.map(t=>(0,I.jsxs)(`div`,{className:`up-model${t.enabled?``:` off`}`,children:[(0,I.jsxs)(`div`,{className:`um-info`,children:[(0,I.jsxs)(`b`,{children:[(0,I.jsx)(`span`,{className:`um-k`,children:`模型名:`}),t.displayName,(0,I.jsx)(m,{content:G[t.source],children:(0,I.jsx)(`span`,{className:`um-src src-${t.source}`,children:W[t.source]})}),t.tag?(0,I.jsx)(m,{content:`上游计价标签,随目录同步更新`,children:(0,I.jsx)(`span`,{className:`mu-tag`,children:t.tag})}):null]}),(0,I.jsxs)(`i`,{className:`code-chip`,children:[(0,I.jsx)(`span`,{className:`um-k`,children:`模型ID:`}),t.id]})]}),(0,I.jsxs)(`div`,{className:`um-meta`,children:[t.verified?(0,I.jsx)(m,{content:`实测可调通`,children:(0,I.jsxs)(`span`,{className:`um-ok`,children:[(0,I.jsx)(o,{size:12}),`可用`]})}):(0,I.jsx)(m,{content:`实测未通过(可能未订阅)`,children:(0,I.jsxs)(`span`,{className:`um-bad`,children:[(0,I.jsx)(e,{size:12}),`未通过`]})}),t.multiplier==null?(0,I.jsx)(m,{content:`接口与本地快照都没有该模型的倍率 —— 不编造`,children:(0,I.jsx)(`span`,{className:`um-mult unknown`,children:`倍率未知`})}):(0,I.jsx)(m,{content:t.source===`upstream`?`倍率取自上游 /v3/config 接口实时值,随目录刷新与每日同步更新。`:`接口未覆盖该模型,倍率为内置快照,可能随官方调价过期。`,children:(0,I.jsxs)(`span`,{className:`um-mult`,children:[`×`,t.multiplier]})}),(0,I.jsx)(P,{checked:t.enabled,disabled:d===t.id,label:`${t.enabled?`停用`:`启用`} ${t.displayName}`,onChange:()=>void p(t)})]})]},t.id))}),(0,I.jsxs)(`div`,{className:`up-foot`,children:[`实测会真打上游、消耗少量积分(每模型 1 token)。上游不接受的模型会标「未通过」, 但`,(0,I.jsx)(`b`,{children:`不删除`}),` —— 订阅以后可能又开,随时可以再拉一次。 倍率以 /v3/config 接口实时值为准(目录刷新与每日自动同步都会更新), 接口未覆盖的模型回落内置快照。`,(0,I.jsx)(`br`,{}),`启用提供商时会同步这家自己的清单;已有提供商的目录互不覆盖,启用/停用选择也分别保留。`]})]})}function q({window:e}){let t=_(()=>h.providers(),[],{cacheKey:`providers`}),[n,i]=(0,F.useState)(null),o=_(()=>h.catalog(n?.id),[n?.id],{cacheKey:n?.id?`catalog:${n.id}`:`catalog`}),s=_(()=>h.clients(e),[e],{cacheKey:`clients:${e}`}),[c,l]=(0,F.useState)(!1),[u,d]=(0,F.useState)(null),[f,g]=(0,F.useState)(null),[v,y]=(0,F.useState)(null),[S,D]=(0,F.useState)(null),[O,j]=(0,F.useState)(null),[M,P]=(0,F.useState)(null),[R,z]=(0,F.useState)(!1),B=x(),V=t.data?.items??[],H=s.data?.byProvider??[],W=()=>{t.reload(),o.reload(),s.reload()},G=async e=>{g(e.id),j(null);try{await h.activateProvider(e.id),P(null),W()}catch(e){j(e instanceof p?e:new p(String(e),0,0))}finally{g(null)}},q=async e=>{g(e.id),j(null);try{await h.deactivateProvider(e.id),W()}catch(e){j(e instanceof p?e:new p(String(e),0,0))}finally{g(null)}},Y=async e=>{g(e.id),j(null);try{let n=await h.providerSigninNow(e.id);P({kind:n.ok?`ok`:`error`,text:n.message}),n.ok?B.push(n.outcome===`none`?{tone:`info`,message:`${e.name}:${n.message}`}:{tone:`success`,message:`${e.name} 签到成功${n.points?` · +${n.points} 积分`:``}。`}):B.push({tone:`error`,message:`${e.name} 签到失败:${n.message}`}),t.reload()}catch(t){let n=t instanceof p?t:new p(String(t),0,0);j(n),B.push({tone:`error`,message:`${e.name} 签到失败:${n.message||`请求未完成`}`})}finally{g(null)}},X=async e=>{g(e.id),j(null);try{let n=await h.providerGrowthRun(e.id),r=n.tasks?.filter(e=>e.outcome===`claimed`).length??0,i=n.tasks?.filter(e=>e.outcome===`already`).length??0,a=n.tasks?.filter(e=>e.outcome===`skipped`).length??0,o=n.ok?`领取完成:签到 ${n.signin?.points??0} 积分;任务新领 ${r}、已领过 ${i}、待完成 ${a};本轮合计 +${n.creditsGained??0}。`:n.message??`领取失败。`;P({kind:n.ok?`ok`:`error`,text:o}),B.push(n.ok?{tone:`success`,message:`${e.name}:${o}`}:{tone:`error`,message:`${e.name} 领取失败:${n.message??`未知原因`}`}),t.reload()}catch(t){let n=t instanceof p?t:new p(String(t),0,0);j(n),B.push({tone:`error`,message:`${e.name} 领取失败:${n.message||`请求未完成`}`})}finally{g(null)}},Z=async e=>{let n=globalThis.prompt?.(`粘贴 WorkBuddy OAuth 凭证 JSON(tools/wb-oauth-export.mjs 的输出):`,``)??null;if(!n)return;let r;try{r=JSON.parse(n)}catch{P({kind:`error`,text:`不是合法 JSON —— 请完整复制导出文件内容。`});return}g(e.id),j(null);try{let n=await h.providerOauthImport(e.id,r);P({kind:n.ok?`ok`:`error`,text:n.message}),t.reload()}catch(e){j(e instanceof p?e:new p(String(e),0,0))}finally{g(null)}},Q=async()=>{if(!S||f)return;let e=S;g(e.id),j(null);try{await h.deleteProvider(e.id),D(null),W()}catch(e){j(e instanceof p?e:new p(String(e),0,0)),D(null)}finally{g(null)}},ee=async()=>{if(!R){z(!0),P(null),j(null);try{let e=await h.refreshCatalog(),r=e.configPulled===!1?` 倍率未从接口取到,沿用本地快照。`:e.multipliersUpdated?` 倍率已按接口同步(${e.multipliersUpdated} 项有更新)。`:``,i=e.perProvider?.find(e=>e.id===n?.id),a=i?.checked??e.checked,s=i?.ok??e.ok,c=i?.failed.length??e.failed.length;P(c>0?{kind:`partial`,text:`已实测 ${a} 个模型:${s} 个可用、${c} 个未通过(可能未订阅)。未通过的不会删除,订阅后可再拉一次。${r}`}:{kind:`ok`,text:`已实测 ${a} 个模型,全部可用。${r}`}),o.reload(),t.reload()}catch(e){let t=e instanceof p?e:new p(String(e),0,0);P({kind:`error`,text:`获取模型失败:${E(t)}`})}finally{z(!1)}}},te=async(e,t)=>{j(null);try{await h.setModelEnabled(e,t,n?.id),o.reload()}catch(e){j(e instanceof p?e:new p(String(e),0,0))}},$=V.filter(e=>e.active).length;return(0,I.jsxs)(I.Fragment,{children:[O?(0,I.jsx)(b,{tone:`error`,children:E(O)}):null,s.error?(0,I.jsxs)(b,{tone:`error`,actions:(0,I.jsx)(`button`,{type:`button`,className:`btn btn-quiet btn-sm`,onClick:s.reload,children:`重试`}),children:[`提供商用量没取到:`,E(s.error)]}):null,(0,I.jsxs)(C,{title:`提供商`,aside:(0,I.jsxs)(`span`,{className:`panel-aside-row`,children:[$>0?(0,I.jsxs)(w,{tone:`live`,dot:!0,children:[`已启用 `,$,` 家`]}):null,(0,I.jsx)(m,{content:`选一个客户端(WorkBuddy / MiniMax Code / Qoder CN),用它的官方授权导入凭证`,children:(0,I.jsxs)(`button`,{type:`button`,className:`btn btn-primary btn-sm`,onClick:()=>l(!0),children:[(0,I.jsx)(r,{size:14}),`导入客户端`]})})]}),padded:!1,children:[t.initial&&t.loading?(0,I.jsx)(`div`,{style:{padding:`0 20px 18px`},children:(0,I.jsx)(A,{})}):t.error?(0,I.jsx)(`div`,{style:{padding:`0 20px 18px`},children:(0,I.jsx)(T,{kind:`error`,title:`提供商列表没取到`,detail:E(t.error),onRetry:t.reload})}):V.length===0?(0,I.jsx)(`div`,{style:{padding:`0 20px 18px`},children:(0,I.jsx)(T,{kind:`empty`,title:`还没有任何提供商`,detail:`先登记一个上游,再按需启用它的出站路由。`})}):(0,I.jsx)(L,{rows:V,byProvider:H,busyId:f,onEdit:y,onSignin:e=>void Y(e),onGrowthRun:e=>void X(e),onOauthImport:e=>void Z(e),onModels:e=>{P(null),i(e)},onActivate:e=>void G(e),onDeactivate:e=>void q(e),onDelete:D}),(0,I.jsxs)(`div`,{className:`footer-note`,style:{padding:`0 20px 18px`},children:[`启用提供商会让它加入出站路由,并同步它自己的模型清单;已启用的提供商可以并行生效,模型按各自目录路由。 三家凭证都来自各客户端的`,(0,I.jsx)(`b`,{children:`官方授权`}),`(用户无需也无法手填)——点「重新导入授权」即可换账号或刷新令牌; 令牌只存在服务端,任何接口都读不回完整值。`,(0,I.jsx)(`br`,{}),`行内三列用量按`,(0,I.jsx)(`b`,{children:`提供商`}),`归属:由「模型 id → 生效目录的提供商」解析(请求记录本身没有 provider 维度)。模型不属于任何生效目录的行归到「未归属」,不冒充某一家。`]})]}),c?(0,I.jsx)(U,{onClose:()=>{l(!1),W()},onImported:()=>W()}):null,u?(0,I.jsx)(U,{provider:{id:u.id,name:u.name,protocol:u.protocol},onClose:()=>{d(null),W()},onImported:()=>W()}):null,v?(0,I.jsx)(J,{provider:v,onClose:()=>y(null),onSaved:()=>{y(null),W()},onReimport:()=>{let e=v;y(null),e&&d(e)}}):null,n?(0,I.jsx)(N,{title:`模型列表 · ${n.name}`,subtitle:n.baseUrl,onClose:()=>i(null),children:(0,I.jsx)(`div`,{className:`drawer-body`,children:(0,I.jsx)(K,{catalog:o.data,catalogLoading:R,catalogMsg:M,catalogError:o.error,onCatalogRefresh:()=>void ee(),onCatalogReload:o.reload,onModelToggled:te})})}):null,S?(0,I.jsx)(k,{title:`删除这个提供商?`,onClose:()=>{f||D(null)},footer:(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`button`,{type:`button`,className:`btn btn-primary btn-sm`,disabled:!!f,onClick:()=>D(null),children:`取消(保留)`}),(0,I.jsxs)(`button`,{type:`button`,className:`btn btn-danger btn-sm`,disabled:!!f,onClick:()=>void Q(),children:[f?(0,I.jsx)(a,{size:14,className:`spin`}):null,f?`删除中…`:`确认删除`]})]}),children:(0,I.jsxs)(`div`,{className:`ov-lose`,children:[(0,I.jsx)(`b`,{children:`会失去什么:`}),`提供商「`,S.name,`」(`,S.baseUrl,`)的登记与它的凭证文件一并删除, 需要重新登记并填一次 ck_ 密钥。此操作不可撤销。`]})}):null]})}function J({provider:e,onClose:t,onSaved:i,onReimport:o}){let[s,c]=(0,F.useState)(e.name),[l,u]=(0,F.useState)(e.baseUrl),[d,f]=(0,F.useState)(!1),[g,_]=(0,F.useState)(!1),[v,y]=(0,F.useState)(null),[x,S]=(0,F.useState)(null),[C,w]=(0,F.useState)(!1),[T,D]=(0,F.useState)(null),O=async()=>{if(!C){w(!0),D(null),y(null);try{let t=await h.providerImportLocal(e.id);if(t.ok)D({kind:`ok`,text:t.message+(t.detail?`\n${t.detail}`:``)}),i();else if(t.outcome===`unavailable`){let t=e.protocol===`qoder`?`qoder`:`minimax`;D({kind:`unavailable`,text:`本服务所在机器上读不到客户端登录态(远程部署的正常情形)。`,command:`node tools/import-credential-push.mjs ${location.origin} ${t} --provider ${e.id}`})}else D({kind:`error`,text:t.message+(t.detail?`\n${t.detail}`:``)})}catch(e){y(e instanceof p?e:new p(String(e),0,0))}finally{w(!1)}}},k=async t=>{if(t.preventDefault(),!d){f(!0),y(null);try{let t={};s.trim()!==e.name&&(t.name=s.trim()),l.trim()!==e.baseUrl&&(t.baseUrl=l.trim()),Object.keys(t).length>0&&await h.patchProvider(e.id,t),i()}catch(e){y(e instanceof p?e:new p(String(e),0,0))}finally{f(!1)}}},A=async()=>{if(!g){_(!0),y(null),S(null);try{S(await h.testProvider(e.id,void 0))}catch(e){y(e instanceof p?e:new p(String(e),0,0))}finally{_(!1)}}};return(0,I.jsx)(N,{title:`配置提供商 · ${e.name}`,subtitle:e.baseUrl,onClose:t,children:(0,I.jsxs)(`div`,{className:`drawer-body`,children:[v?(0,I.jsx)(b,{tone:`error`,children:E(v)}):null,(0,I.jsxs)(`form`,{onSubmit:e=>void k(e),className:`prov-edit`,style:{marginTop:6},children:[(0,I.jsxs)(`div`,{className:`up-row`,children:[(0,I.jsx)(`div`,{className:`up-lab`,children:`名称`}),(0,I.jsx)(`input`,{className:`field-input text`,style:{width:`100%`},value:s,onChange:e=>c(e.target.value),"aria-label":`提供商名称`})]}),(0,I.jsxs)(`div`,{className:`up-row`,children:[(0,I.jsx)(`div`,{className:`up-lab`,children:`地址`}),(0,I.jsx)(`input`,{className:`field-input text`,style:{width:`100%`},value:l,placeholder:`https://api.example.com`,onChange:e=>u(e.target.value),"aria-label":`提供商地址`})]}),(0,I.jsxs)(`div`,{className:`up-row`,children:[(0,I.jsx)(`div`,{className:`up-lab`,children:`凭证`}),(0,I.jsxs)(`div`,{className:`cred-guide`,children:[(0,I.jsx)(`div`,{className:`cred-guide-note`,children:e.protocol===`openai`?(0,I.jsxs)(I.Fragment,{children:[`凭证来自 WorkBuddy `,(0,I.jsx)(`b`,{children:`官方 OAuth 授权`}),`(桌面端 / 插件同一条通道),无需手填。`]}):e.protocol===`anthropic`?(0,I.jsxs)(I.Fragment,{children:[`凭证是客户端登录态里的 `,(0,I.jsx)(`span`,{className:`code-chip`,children:`mmort_…`}),` refresh token。 请用`,(0,I.jsx)(`b`,{children:`专用账号`}),`(与桌面端共用会互相顶下线)。`]}):(0,I.jsxs)(I.Fragment,{children:[`凭证来自 Qoder 客户端登录态(一段`,(0,I.jsx)(`b`,{children:`身份 JSON`}),`)。桌面客户端与它`,(0,I.jsx)(`b`,{children:`互不影响`}),`。`]})}),(0,I.jsxs)(`div`,{className:`cred-guide-actions`,children:[(0,I.jsxs)(`button`,{type:`button`,className:`btn btn-primary btn-sm`,disabled:d,onClick:()=>o(),children:[(0,I.jsx)(r,{size:14}),`重新导入授权`]}),(0,I.jsxs)(`button`,{type:`button`,className:`btn btn-quiet btn-sm`,disabled:C,onClick:()=>void O(),children:[C?(0,I.jsx)(a,{size:14}):(0,I.jsx)(r,{size:14}),`从本机客户端读取`]})]}),T?(0,I.jsx)(b,{tone:T.kind===`ok`?`success`:T.kind===`unavailable`?`warn`:`error`,children:(0,I.jsxs)(`span`,{children:[T.text,T.command?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`br`,{}),`在`,(0,I.jsx)(`b`,{children:`装了客户端的那台机器`}),`的仓库目录下跑:`,(0,I.jsx)(R,{command:T.command})]}):null]})}):null,e.protocol===`qoder`?(0,I.jsxs)(`div`,{className:`cred-guide-note`,children:[`本服务`,(0,I.jsx)(`b`,{children:`不自动刷新`}),` Qoder 令牌;过期后重跑一次导入即可。`]}):null]})]}),(0,I.jsxs)(`div`,{className:`up-actions`,children:[(0,I.jsxs)(`button`,{type:`submit`,className:`btn btn-primary btn-sm`,disabled:d,children:[d?(0,I.jsx)(a,{size:14}):(0,I.jsx)(n,{size:14}),`保存`]}),(0,I.jsx)(m,{content:`用已导入的授权测这家上游是否还通`,children:(0,I.jsxs)(`button`,{type:`button`,className:`btn btn-quiet btn-sm`,disabled:g,onClick:()=>void A(),children:[g?(0,I.jsx)(a,{size:14}):null,`测试`]})})]})]}),x?(0,I.jsx)(b,{tone:x.ok?`success`:`warn`,children:(0,I.jsx)(`span`,{children:x.ok?(0,I.jsxs)(I.Fragment,{children:[`通了:`,e.name,` 接受了这次 1 token 探测(`,x.elapsedMs,`ms)。`]}):x.httpStatus===null?(0,I.jsxs)(I.Fragment,{children:[`没连上(网络层):`,x.reason??`未知原因`,`。先查地址与出网,再看凭证。`]}):(0,I.jsxs)(I.Fragment,{children:[`连上了但被拒(HTTP `,x.httpStatus,x.upstreamCode===null?``:` · 业务码 ${x.upstreamCode}`,`)。`,x.upstreamCode===11102?`业务码 11102 = 账号没订阅这个模型。key 可能是好的,换个模型再测或直接切换。`:`通常是凭证问题;换一把再测。`]})})}):null,(0,I.jsx)(`div`,{className:`up-note`,style:{marginTop:18},children:(0,I.jsxs)(`span`,{children:[`凭证只存在`,(0,I.jsx)(`b`,{children:`服务端`}),`:界面只显示账号摘要或掩码,任何接口都读不回完整值。`]})})]})})}function Y(){let[e,t]=(0,F.useState)(()=>M()??`today`);return(0,I.jsxs)(`div`,{className:`view on`,children:[(0,I.jsx)(D,{title:`提供商管理`,actions:(0,I.jsx)(O,{value:e,options:v,onChange:e=>{j(e),t(e)},width:148})}),(0,I.jsx)(`div`,{className:`view-body stack`,children:(0,I.jsx)(q,{window:e})})]})}export{Y as ClientsPage};
@@ -1,4 +1,4 @@
1
- import{b as e,it as t,t as n,tt as r}from"./vendor-befEYGHM.js";import{c as i,i as a,n as o,o as s,s as c,x as l}from"./index-BJtz6Ses.js";import{t as u}from"./accessUrl-DbL5DLDz.js";var d=t(),f=`1.6.15`,p={totalTokens:193e4,cacheHitRate:62.4,requestsToday:1284,successRate:99.7};function m(e,t=0){let n=e.toFixed(t).split(`.`);return n[0]=n[0].replace(/\B(?=(\d{3})+(?!\d))/g,`,`),n.join(`.`)}function h(e,t=1){return e==null?`—`:`${e.toFixed(t)}%`}function g(e){if(e&&typeof e==`object`){let t=e;return{ok:t.ok!==!1,version:typeof t.version==`string`?t.version:void 0}}return{ok:!0}}function _(){let e=c(),[t,n]=(0,d.useState)(!0),[r,a]=(0,d.useState)(f),[o,s]=(0,d.useState)(p),[l,u]=(0,d.useState)(!1);return(0,d.useEffect)(()=>{let e=!0,t=async()=>{try{let t=await fetch(`/healthz`,{headers:{Accept:`application/json`}});if(!t.ok)throw Error(`healthz ${t.status}`);let r=g(await t.json());if(!e)return;n(r.ok),r.version&&a(r.version)}catch{e&&n(!1)}};t();let r=window.setInterval(()=>void t(),3e4);return()=>{e=!1,window.clearInterval(r)}},[]),(0,d.useEffect)(()=>{if(e.status!==`authed`){u(!1),s(p);return}let t=!0;return i.overview(`24h`).then(e=>{t&&(s({totalTokens:e.metrics.totalTokens,cacheHitRate:e.metrics.cacheHitRate*100,requestsToday:e.metrics.requests,successRate:e.metrics.successRate*100}),u(!0))}).catch(()=>{t&&(u(!1),s(p))}),()=>{t=!1}},[e.status]),{online:t,version:r,real:l,numbers:o}}function v(){var e=window.matchMedia(`(prefers-reduced-motion: reduce)`).matches,t=!0,n=[],r=[],i={totalTokens:`本窗口 tokens`,cacheHitRate:`缓存命中率`,requestsToday:`今日请求`,successRate:`今日成功率`};function a(){var e=window.RelayDemo;if(e&&e.summary){var t=[];[].forEach.call(document.querySelectorAll(`[data-demo]`),function(n){var r=n.getAttribute(`data-demo`),a=e.summary[r];if(typeof a==`number`){var o=parseInt(n.getAttribute(`data-dec`)||`0`,10),s=n.textContent.trim().replace(/,/g,``);s!==``&&Math.abs(parseFloat(s)-a)>10**-o/2&&t.push((i[r]||r)+`:页面上写的 `+s+`,数据层是 `+a),n.setAttribute(`data-count`,a),n.textContent=p(a,o)}}),t.length&&window.console&&console.warn(`[page] 首页演示数字与 demo-data 不一致(已按数据层显示):
1
+ import{b as e,it as t,t as n,tt as r}from"./vendor-befEYGHM.js";import{c as i,i as a,n as o,o as s,s as c,x as l}from"./index-nQeRK3kW.js";import{t as u}from"./accessUrl-DbL5DLDz.js";var d=t(),f=`1.6.16`,p={totalTokens:193e4,cacheHitRate:62.4,requestsToday:1284,successRate:99.7};function m(e,t=0){let n=e.toFixed(t).split(`.`);return n[0]=n[0].replace(/\B(?=(\d{3})+(?!\d))/g,`,`),n.join(`.`)}function h(e,t=1){return e==null?`—`:`${e.toFixed(t)}%`}function g(e){if(e&&typeof e==`object`){let t=e;return{ok:t.ok!==!1,version:typeof t.version==`string`?t.version:void 0}}return{ok:!0}}function _(){let e=c(),[t,n]=(0,d.useState)(!0),[r,a]=(0,d.useState)(f),[o,s]=(0,d.useState)(p),[l,u]=(0,d.useState)(!1);return(0,d.useEffect)(()=>{let e=!0,t=async()=>{try{let t=await fetch(`/healthz`,{headers:{Accept:`application/json`}});if(!t.ok)throw Error(`healthz ${t.status}`);let r=g(await t.json());if(!e)return;n(r.ok),r.version&&a(r.version)}catch{e&&n(!1)}};t();let r=window.setInterval(()=>void t(),3e4);return()=>{e=!1,window.clearInterval(r)}},[]),(0,d.useEffect)(()=>{if(e.status!==`authed`){u(!1),s(p);return}let t=!0;return i.overview(`24h`).then(e=>{t&&(s({totalTokens:e.metrics.totalTokens,cacheHitRate:e.metrics.cacheHitRate*100,requestsToday:e.metrics.requests,successRate:e.metrics.successRate*100}),u(!0))}).catch(()=>{t&&(u(!1),s(p))}),()=>{t=!1}},[e.status]),{online:t,version:r,real:l,numbers:o}}function v(){var e=window.matchMedia(`(prefers-reduced-motion: reduce)`).matches,t=!0,n=[],r=[],i={totalTokens:`本窗口 tokens`,cacheHitRate:`缓存命中率`,requestsToday:`今日请求`,successRate:`今日成功率`};function a(){var e=window.RelayDemo;if(e&&e.summary){var t=[];[].forEach.call(document.querySelectorAll(`[data-demo]`),function(n){var r=n.getAttribute(`data-demo`),a=e.summary[r];if(typeof a==`number`){var o=parseInt(n.getAttribute(`data-dec`)||`0`,10),s=n.textContent.trim().replace(/,/g,``);s!==``&&Math.abs(parseFloat(s)-a)>10**-o/2&&t.push((i[r]||r)+`:页面上写的 `+s+`,数据层是 `+a),n.setAttribute(`data-count`,a),n.textContent=p(a,o)}}),t.length&&window.console&&console.warn(`[page] 首页演示数字与 demo-data 不一致(已按数据层显示):
2
2
  · `+t.join(`
3
3
  · `))}}function o(e){var t=!1;return function(){t||(t=!0,requestAnimationFrame(function(){t=!1,e()}))}}function s(){var e=[].slice.call(document.querySelectorAll(`.reveal`));if(e.length){if(!(`IntersectionObserver`in window)){e.forEach(function(e){e.classList.add(`in`)});return}var t=new IntersectionObserver(function(e){e.forEach(function(e){e.isIntersecting&&(e.target.classList.add(`in`),t.unobserve(e.target))})},{rootMargin:`0px 0px -10% 0px`,threshold:.1});r.push(t),e.forEach(function(e){t.observe(e)})}}var c=document.querySelector(`.nav`);function l(){c&&c.classList.toggle(`stuck`,window.pageYOffset>28)}var u=[].slice.call(document.querySelectorAll(`.rail a`)),d=u.map(function(e){return document.querySelector(e.getAttribute(`href`))});function f(){if(u.length){for(var e=window.pageYOffset+window.innerHeight*.42,t=0,n=0;n<d.length;n+=1){var r=d[n];r&&r.offsetTop<=e&&(t=n)}for(var i=0;i<u.length;i+=1)u[i].classList.toggle(`on`,i===t)}}function p(e,t){var n=e.toFixed(t).split(`.`);return n[0]=n[0].replace(/\B(?=(\d{3})+(?!\d))/g,`,`),n.join(`.`)}function m(e){var n=parseFloat(e.getAttribute(`data-count`));if(isNaN(n))return;var r=parseInt(e.getAttribute(`data-dec`)||`0`,10),i=1500,a=0;function o(s){if(t){a||=s;var c=Math.min(1,(s-a)/i);e.textContent=p(n*(c===1?1:1-2**(-10*c)),r),c<1?requestAnimationFrame(o):e.textContent=p(n,r)}}requestAnimationFrame(o)}function h(){var t=[].slice.call(document.querySelectorAll(`[data-count]`));if(t.length){if(e||!(`IntersectionObserver`in window)){t.forEach(function(e){var t=parseFloat(e.getAttribute(`data-count`)),n=parseInt(e.getAttribute(`data-dec`)||`0`,10);isNaN(t)||(e.textContent=p(t,n))});return}var n=new IntersectionObserver(function(e){e.forEach(function(e){e.isIntersecting&&(m(e.target),n.unobserve(e.target))})},{threshold:.6});r.push(n),t.forEach(function(e){n.observe(e)})}}function g(){var i=[].slice.call(document.querySelectorAll(`[data-type]`));if(i.length&&!e&&`IntersectionObserver`in window){var a=new IntersectionObserver(function(e){e.forEach(function(e){if(e.isIntersecting){var r=e.target;a.unobserve(r);var i=r.getAttribute(`data-type`),o=0;r.textContent=``,r.classList.add(`typing`),(function e(){if(t){if(o>i.length){r.classList.remove(`typing`);return}r.textContent=i.slice(0,o),o+=1,n.push(window.setTimeout(e,34))}})()}})},{threshold:.8});r.push(a),i.forEach(function(e){a.observe(e)})}}var _=o(function(){l(),f()}),v=o(function(){f()}),y=function(){l(),f()};return a(),s(),h(),g(),l(),f(),window.addEventListener(`scroll`,_,{passive:!0}),window.addEventListener(`resize`,v),window.addEventListener(`load`,y),function(){t=!1,window.removeEventListener(`scroll`,_),window.removeEventListener(`resize`,v),window.removeEventListener(`load`,y),r.forEach(function(e){e.disconnect()}),n.forEach(function(e){clearTimeout(e)}),r=[],n=[]}}var y=r(),b=[{href:`#top`,label:`概览`},{href:`#ways`,label:`运行方式`},{href:`#quickstart`,label:`快速开始`},{href:`#clients`,label:`客户端配置`},{href:`#status`,label:`运行状态`},{href:`#cta`,label:`开始使用`}];function x(){return(0,y.jsx)(`nav`,{className:`rail`,"aria-label":`章节`,children:b.map(e=>(0,y.jsxs)(`a`,{href:e.href,children:[(0,y.jsx)(`i`,{}),(0,y.jsx)(`b`,{children:e.label})]},e.href))})}function S({version:t}){let[r,i]=(0,d.useState)(!1),o=()=>i(!1);return(0,y.jsxs)(`nav`,{className:`nav${r?` menu-open`:``}`,children:[(0,y.jsxs)(`a`,{className:`brand`,href:`#top`,onClick:o,children:[(0,y.jsx)(s,{size:28,id:`relay-mark-nav`}),(0,y.jsx)(`b`,{children:`途关`}),(0,y.jsx)(`span`,{children:`Waygate`})]}),(0,y.jsxs)(`div`,{className:`nav-links`,children:[(0,y.jsx)(`a`,{href:`#ways`,onClick:o,children:`运行方式`}),(0,y.jsx)(`a`,{href:`#quickstart`,onClick:o,children:`快速开始`}),(0,y.jsx)(`a`,{href:`#clients`,onClick:o,children:`客户端配置`}),(0,y.jsx)(`a`,{href:`#status`,onClick:o,children:`运行状态`})]}),(0,y.jsxs)(`div`,{className:`nav-right`,style:{display:`flex`,alignItems:`center`,gap:14,marginLeft:`auto`},children:[(0,y.jsxs)(`span`,{className:`pill pill-brand`,children:[`v`,t]}),(0,y.jsx)(`a`,{className:`btn btn-primary btn-sm`,href:a(),children:`打开控制台`}),(0,y.jsx)(`button`,{type:`button`,className:`nav-menu-toggle`,"aria-label":r?`关闭导航菜单`:`打开导航菜单`,"aria-controls":`landing-mobile-nav`,"aria-expanded":r,onClick:()=>i(e=>!e),children:r?(0,y.jsx)(n,{size:18,"aria-hidden":`true`}):(0,y.jsx)(e,{size:18,"aria-hidden":`true`})})]}),(0,y.jsxs)(`div`,{id:`landing-mobile-nav`,className:`mobile-nav`,"aria-hidden":!r,children:[(0,y.jsx)(`a`,{href:`#ways`,onClick:o,children:`运行方式`}),(0,y.jsx)(`a`,{href:`#quickstart`,onClick:o,children:`快速开始`}),(0,y.jsx)(`a`,{href:`#clients`,onClick:o,children:`客户端配置`}),(0,y.jsx)(`a`,{href:`#status`,onClick:o,children:`运行状态`})]})]})}function C(e,t=0,n){if(e==null)return{children:`—`};let r={"data-count":e,children:m(e,t)};return t&&(r[`data-dec`]=t),n&&(r[`data-demo`]=n),r}var w={live:`var(--signal-live)`,offline:`var(--warn-amber)`};function T(e=window.location.hostname){return/^\d{1,3}(\.\d{1,3}){3}$/.test(e)||e.includes(`:`)}function E(e){return T(e)?`自签证书`:`公共 CA`}var D=e=>e;function O({text:e,className:t,label:n,idle:r=`复制`,done:i=`已复制`}){let[a,o]=(0,d.useState)(!1),s=(0,d.useRef)(null);(0,d.useEffect)(()=>()=>{s.current&&window.clearTimeout(s.current)},[]);let c=(0,d.useCallback)(()=>{let t=navigator.clipboard;t&&typeof t.writeText==`function`&&t.writeText(e).then(()=>{o(!0),s.current&&window.clearTimeout(s.current),s.current=window.setTimeout(()=>o(!1),1200)},()=>void 0)},[e]);return(0,y.jsx)(`button`,{className:t,type:`button`,"aria-label":n,onClick:c,children:a?i:r})}var k=`{"x":0,"y":0,"z":0,"rx":0,"ry":0,"rz":0,"fog":0.16,"dim":0.90}`,A=[`# 克隆并构建`,`git clone <仓库地址> && cd relay-station`,`npm ci --prefix server && npm run build --prefix server`,`npm ci --prefix web && npm run build --prefix web`,``,`# 启动 systemd 服务(TLS 由 nginx 终止)`,`sudo systemctl start relay`].join(`
4
4
  `);function j({status:e}){let{online:t,real:n,numbers:r}=e,i=u(),a=r.totalTokens==null?`—`:l(r.totalTokens),o=t?void 0:D({color:`var(--warn-amber)`,background:`color-mix(in srgb, var(--warn-amber) 7%, transparent)`,borderColor:`var(--warn-amber-line)`});return(0,y.jsxs)(`header`,{className:`hero`,id:`top`,"data-cam":k,children:[(0,y.jsxs)(`div`,{className:`wrap`,children:[(0,y.jsxs)(`div`,{className:`hero-grid`,children:[(0,y.jsxs)(`div`,{className:`hero-inner`,children:[(0,y.jsxs)(`div`,{className:`hero-badge reveal`,style:o,children:[(0,y.jsx)(`i`,{className:t?`dot dot-live`:`dot`,style:{color:t?w.live:w.offline}}),t?`服务运行中`:`服务离线`,` · 本窗口 tokens`,` `,(0,y.jsx)(`span`,{className:`n`,children:a}),n?null:`(示例)`]}),(0,y.jsxs)(`div`,{className:`hero-title reveal`,children:[(0,y.jsxs)(`h1`,{className:`hero-h1 display-1`,children:[(0,y.jsx)(`span`,{className:`rv-line`,children:(0,y.jsx)(`span`,{style:D({"--i":0}),children:`把自己的订阅积分`})}),(0,y.jsx)(`span`,{className:`rv-line`,children:(0,y.jsxs)(`span`,{style:D({"--i":1}),children:[`变成一个 `,(0,y.jsx)(`span`,{className:`mk grad-text`,children:`base_url`})]})})]}),(0,y.jsx)(`div`,{className:`hero-flip`,"aria-hidden":`true`,children:(0,y.jsxs)(`h1`,{className:`hero-h1 display-1`,children:[`把自己的订阅积分`,(0,y.jsx)(`br`,{}),`变成一个 `,(0,y.jsx)(`span`,{className:`mk grad-text`,children:`base_url`})]})})]}),(0,y.jsx)(`p`,{className:`hero-sub reveal`,style:D({"--i":3}),children:`部署在你自己机器上,把你的 AI 订阅积分(WorkBuddy / MiniMax / Qoder)暴露成 OpenAI 兼容接口。 IDE、聊天客户端、手机、脚本共用同一个 Key,积分消耗实时可见。`}),(0,y.jsxs)(`div`,{className:`hero-acts reveal`,style:D({"--i":4}),children:[(0,y.jsx)(O,{className:`btn btn-primary`,text:A,label:`复制部署命令`,idle:`复制部署命令`}),(0,y.jsx)(`a`,{className:`btn btn-ghost`,href:`#clients`,children:`查看客户端配置`})]}),(0,y.jsxs)(`div`,{className:`trust reveal`,style:D({"--i":5}),children:[(0,y.jsx)(`span`,{children:`只监听本机回环`}),(0,y.jsx)(`span`,{children:`外发直连上游,无中转`}),(0,y.jsx)(`span`,{children:`请求日志保存在本地`})]})]}),(0,y.jsx)(`aside`,{className:`hero-side reveal`,style:D({"--i":2}),children:(0,y.jsxs)(`div`,{className:`glass access`,children:[(0,y.jsxs)(`div`,{className:`access-h`,children:[(0,y.jsx)(`span`,{className:`eyebrow`,style:D({"--c":`var(--text-ghost)`}),children:`接入地址`}),(0,y.jsxs)(`span`,{className:t?`pill pill-live`:`pill pill-amber`,children:[(0,y.jsx)(`i`,{className:t?`dot dot-live`:`dot`}),t?`可用`:`离线`]})]}),(0,y.jsxs)(`div`,{className:`access-url`,children:[(0,y.jsx)(`code`,{children:i}),(0,y.jsx)(O,{className:`copy`,text:i,label:`复制接入地址`})]}),(0,y.jsx)(`div`,{className:`access-note`,children:`把它填进任何支持 OpenAI 兼容协议的工具`}),(0,y.jsxs)(`dl`,{className:`kv`,children:[(0,y.jsxs)(`div`,{children:[(0,y.jsx)(`dt`,{children:`协议`}),(0,y.jsx)(`dd`,{children:`OpenAI v1 · Anthropic`})]}),(0,y.jsxs)(`div`,{children:[(0,y.jsx)(`dt`,{children:`日志保留`}),(0,y.jsx)(`dd`,{children:`默认 30 天`})]}),(0,y.jsxs)(`div`,{children:[(0,y.jsx)(`dt`,{children:`TLS`}),(0,y.jsx)(`dd`,{children:E()})]}),(0,y.jsxs)(`div`,{children:[(0,y.jsx)(`dt`,{children:`部署形态`}),(0,y.jsx)(`dd`,{children:`systemd + nginx`})]})]})]})})]}),(0,y.jsxs)(`div`,{className:`panel-wrap glass reveal`,style:D({"--i":6}),children:[(0,y.jsxs)(`div`,{className:`panel-left`,children:[(0,y.jsxs)(`div`,{className:`winbar`,children:[(0,y.jsx)(`i`,{style:{background:`var(--danger-red)`}}),(0,y.jsx)(`i`,{style:{background:`var(--warn-amber)`}}),(0,y.jsx)(`i`,{style:{background:`var(--signal-live)`}}),(0,y.jsx)(`span`,{className:`fname`,children:`deploy.sh`}),(0,y.jsx)(`span`,{className:`wtag`,children:`SHELL`}),(0,y.jsx)(`span`,{className:`wsp`}),(0,y.jsx)(O,{className:`wbtn`,text:A})]}),(0,y.jsxs)(`div`,{className:`panel-code`,children:[(0,y.jsxs)(`div`,{className:`cl`,children:[(0,y.jsx)(`i`,{children:`1`}),(0,y.jsx)(`span`,{children:(0,y.jsx)(`span`,{className:`c`,children:`# Ubuntu + systemd(TLS 由 nginx 终止)`})})]}),(0,y.jsxs)(`div`,{className:`cl`,children:[(0,y.jsx)(`i`,{children:`2`}),(0,y.jsx)(`span`,{children:(0,y.jsx)(`span`,{className:`fn`,children:`$ sudo systemctl start relay`})})]}),(0,y.jsxs)(`div`,{className:`cl`,children:[(0,y.jsx)(`i`,{children:`3`}),(0,y.jsx)(`span`,{children:(0,y.jsx)(`span`,{className:`fn`,children:`$ sudo systemctl status relay`})})]}),(0,y.jsxs)(`div`,{className:`cl`,children:[(0,y.jsx)(`i`,{children:`4`}),(0,y.jsx)(`span`,{children:(0,y.jsx)(`span`,{className:`fn`,children:`$ sudo systemctl restart relay`})})]}),(0,y.jsxs)(`div`,{className:`cl hl`,children:[(0,y.jsx)(`i`,{children:`5`}),(0,y.jsx)(`span`,{children:(0,y.jsx)(`span`,{className:`c`,children:`# 首次启动打印管理口令(仅此一次)`})})]}),(0,y.jsxs)(`div`,{className:`cl`,children:[(0,y.jsx)(`i`,{children:`6`}),(0,y.jsx)(`span`,{children:(0,y.jsx)(`span`,{className:`c`,children:`# API Key 在控制台「客户端与密钥」页新建`})})]})]})]}),(0,y.jsxs)(`div`,{className:`panel-right`,children:[(0,y.jsxs)(`div`,{className:`pr-head`,children:[(0,y.jsx)(`h4`,{children:`连接状态`}),(0,y.jsx)(`span`,{className:`pr-count`,children:t?`示例 · 3 个客户端`:`服务离线`})]}),(0,y.jsxs)(`div`,{className:`conn`,children:[(0,y.jsx)(`i`,{className:`dot dot-live`,style:{color:w.live}}),(0,y.jsx)(`span`,{className:`cname`,children:`Claude Code`}),(0,y.jsx)(`span`,{className:`dev`,children:`本机`}),(0,y.jsx)(`span`,{className:`lat`,children:`12ms`}),(0,y.jsx)(`span`,{className:`pill pill-live`,children:`在线`})]}),(0,y.jsxs)(`div`,{className:`conn`,children:[(0,y.jsx)(`i`,{className:`dot dot-live`,style:{color:w.live}}),(0,y.jsx)(`span`,{className:`cname`,children:`Cherry Studio`}),(0,y.jsx)(`span`,{className:`dev`,children:`桌面`}),(0,y.jsx)(`span`,{className:`lat`,children:`48ms`}),(0,y.jsx)(`span`,{className:`pill pill-live`,children:`在线`})]}),(0,y.jsxs)(`div`,{className:`conn`,children:[(0,y.jsx)(`i`,{className:`dot`,style:{color:w.offline}}),(0,y.jsx)(`span`,{className:`cname`,children:`Cursor`}),(0,y.jsx)(`span`,{className:`dev`,children:`笔记本`}),(0,y.jsx)(`span`,{className:`lat`,children:`—`}),(0,y.jsx)(`span`,{className:`pill pill-amber`,children:`待机`})]}),(0,y.jsxs)(`div`,{className:`panel-metrics`,children:[(0,y.jsxs)(`div`,{children:[(0,y.jsx)(`div`,{className:`k`,children:`本窗口 tokens`}),(0,y.jsx)(`div`,{className:`v num live`,style:{color:w.live},children:a})]}),(0,y.jsxs)(`div`,{children:[(0,y.jsx)(`div`,{className:`k`,children:`缓存命中率`}),(0,y.jsx)(`div`,{className:`v num`,children:h(r.cacheHitRate)})]}),(0,y.jsxs)(`div`,{children:[(0,y.jsx)(`div`,{className:`k`,children:`今日请求`}),(0,y.jsx)(`div`,{className:`v num`,children:r.requestsToday==null?`—`:m(r.requestsToday)})]})]})]})]})]}),(0,y.jsxs)(`div`,{className:`scroll-cue`,children:[(0,y.jsx)(`span`,{className:`tick`}),`SCROLL`]})]})}var M=`{"x":-26,"y":-16,"z":-150,"rx":2.5,"ry":3,"rz":0,"fog":0.30,"dim":0.44}`;function N(){return(0,y.jsx)(`section`,{className:`strip`,"data-cam":M,children:(0,y.jsxs)(`div`,{className:`wrap reveal`,children:[(0,y.jsxs)(`div`,{className:`cap`,children:[`任何支持 `,(0,y.jsx)(`b`,{children:`OpenAI 兼容协议`}),` 的工具,填上地址就能用`]}),(0,y.jsxs)(`div`,{className:`logos`,children:[(0,y.jsx)(`span`,{children:`Claude Code`}),(0,y.jsx)(`span`,{children:`Cursor`}),(0,y.jsx)(`span`,{children:`Cherry Studio`}),(0,y.jsx)(`span`,{children:`ChatBox`}),(0,y.jsx)(`span`,{children:`LobeChat`}),(0,y.jsx)(`span`,{children:`Continue`}),(0,y.jsx)(`span`,{className:`cn`,children:`你的脚本`})]})]})})}var P=`{"x":-118,"y":-38,"z":-310,"rx":5,"ry":7,"rz":-1.5,"fog":0.44,"dim":0.40}`,F={color:`var(--accent-cyan)`},I={fill:`none`,stroke:`currentColor`,strokeWidth:1.6};function L(){return(0,y.jsx)(`section`,{className:`section`,id:`ways`,"data-cam":P,children:(0,y.jsx)(`div`,{className:`wrap`,children:(0,y.jsxs)(`div`,{className:`split`,children:[(0,y.jsxs)(`div`,{className:`split-l reveal`,children:[(0,y.jsxs)(`div`,{className:`eyebrow`,children:[(0,y.jsx)(`span`,{className:`idx`,children:`02`}),`运行方式`]}),(0,y.jsxs)(`h2`,{className:`display-2`,children:[`一个进程,`,(0,y.jsx)(`br`,{}),`管住所有客户端的积分`]}),(0,y.jsx)(`p`,{children:`不用为每个客户端单独登录、单独算积分。服务跑在你自己的机器上,所有请求走同一个出口。`})]}),(0,y.jsxs)(`ul`,{className:`linelist`,children:[(0,y.jsxs)(`li`,{className:`reveal`,children:[(0,y.jsx)(`span`,{className:`ll-ico`,children:(0,y.jsxs)(`svg`,{width:`20`,height:`20`,viewBox:`0 0 20 20`,"aria-hidden":`true`,style:F,...I,children:[(0,y.jsx)(`circle`,{cx:`6.5`,cy:`10`,r:`3.5`}),(0,y.jsx)(`path`,{d:`M10 10h8M15 10v3M17.5 10v3`,strokeLinecap:`round`})]})}),(0,y.jsxs)(`span`,{className:`ll-tx`,children:[(0,y.jsx)(`b`,{children:`一个 Key,多端共用`}),(0,y.jsx)(`i`,{children:`桌面客户端、IDE、手机、脚本共用同一个密钥,控制台按客户端拆开看用量。`})]})]}),(0,y.jsxs)(`li`,{className:`reveal`,style:D({"--i":1}),children:[(0,y.jsx)(`span`,{className:`ll-ico`,children:(0,y.jsxs)(`svg`,{width:`20`,height:`20`,viewBox:`0 0 20 20`,"aria-hidden":`true`,style:F,...I,children:[(0,y.jsx)(`path`,{d:`M4 10h4M12 10h4`,strokeLinecap:`round`}),(0,y.jsx)(`circle`,{cx:`10`,cy:`10`,r:`2`}),(0,y.jsx)(`path`,{d:`M12 10V5.5M12 10v4.5`,strokeLinecap:`round`})]})}),(0,y.jsxs)(`span`,{className:`ll-tx`,children:[(0,y.jsx)(`b`,{children:`请求只在你自己的机器上流转`}),(0,y.jsx)(`i`,{children:`应用默认只监听本机回环,对外由你自己的 nginx 暴露,没有第三方中转。`})]})]}),(0,y.jsxs)(`li`,{className:`reveal`,style:D({"--i":2}),children:[(0,y.jsx)(`span`,{className:`ll-ico`,children:(0,y.jsxs)(`svg`,{width:`20`,height:`20`,viewBox:`0 0 20 20`,"aria-hidden":`true`,style:F,...I,children:[(0,y.jsx)(`rect`,{x:`2`,y:`4.5`,width:`16`,height:`11`,rx:`2.5`}),(0,y.jsx)(`path`,{d:`M2 8.5h16`}),(0,y.jsx)(`path`,{d:`M4.5 13h4`,strokeLinecap:`round`})]})}),(0,y.jsxs)(`span`,{className:`ll-tx`,children:[(0,y.jsx)(`b`,{children:`用量与消耗实时同步`}),(0,y.jsx)(`i`,{children:`本窗口总 tokens、缓存命中率、每条请求消耗多少积分,控制台里一眼看清。`})]})]}),(0,y.jsxs)(`li`,{className:`reveal`,style:D({"--i":3}),children:[(0,y.jsx)(`span`,{className:`ll-ico`,children:(0,y.jsx)(`svg`,{width:`20`,height:`20`,viewBox:`0 0 20 20`,"aria-hidden":`true`,style:F,...I,children:(0,y.jsx)(`path`,{d:`M10 2.5 16.5 5v5c0 4-2.8 6.4-6.5 7.5C6.3 16.4 3.5 14 3.5 10V5L10 2.5Z`,strokeLinejoin:`round`})})}),(0,y.jsxs)(`span`,{className:`ll-tx`,children:[(0,y.jsx)(`b`,{children:`请求日志与超限保护`}),(0,y.jsx)(`i`,{children:`每条请求都落库、可回溯;超过并发上限时直接回 429,失败不会被静默吞掉。`})]})]})]})]})})})}var R=`{"x":58,"y":-70,"z":-480,"rx":10,"ry":-5,"rz":1.5,"fog":0.52,"dim":0.36}`;function z({version:e}){return(0,y.jsx)(`section`,{className:`section`,id:`quickstart`,"data-cam":R,children:(0,y.jsxs)(`div`,{className:`wrap`,children:[(0,y.jsxs)(`div`,{className:`sec-head reveal`,children:[(0,y.jsxs)(`div`,{children:[(0,y.jsxs)(`div`,{className:`eyebrow`,children:[(0,y.jsx)(`span`,{className:`idx`,children:`03`}),`快速开始`]}),(0,y.jsx)(`h2`,{className:`display-2`,style:{marginTop:20},children:`三步,十分钟内跑起来`})]}),(0,y.jsx)(`p`,{className:`lead`,children:`自己的一台机器就够。首次启动打印管理口令(只显示一次),客户端的 Key 在控制台新建。`})]}),(0,y.jsxs)(`ol`,{className:`steps`,children:[(0,y.jsxs)(`li`,{className:`reveal`,children:[(0,y.jsx)(`div`,{className:`st-n`,children:`01`}),(0,y.jsx)(`h3`,{children:`部署服务`}),(0,y.jsx)(`p`,{children:`克隆仓库,构建前后端,装成 systemd 服务(nginx 在外层终止 TLS)。首次启动即打印管理口令。`}),(0,y.jsx)(`div`,{className:`cmd`,style:{marginTop:8},children:`git clone … → npm ci → npm run build → systemctl start`})]}),(0,y.jsxs)(`li`,{className:`reveal`,style:D({"--i":1}),children:[(0,y.jsx)(`div`,{className:`st-n`,children:`02`}),(0,y.jsx)(`h3`,{children:`生成密钥`}),(0,y.jsx)(`p`,{children:`在控制台「客户端与密钥」页新建密钥,按客户端命名,可以随时停用或删除。`}),(0,y.jsx)(`div`,{className:`cmd`,children:`控制台 → 客户端与密钥 → 新建密钥`})]}),(0,y.jsxs)(`li`,{className:`reveal`,style:D({"--i":2}),children:[(0,y.jsx)(`div`,{className:`st-n`,children:`03`}),(0,y.jsx)(`h3`,{children:`填进客户端`}),(0,y.jsx)(`p`,{children:`把 base_url 填成控制台的同源地址,模型名照抄,其余代码不用改。`})]})]}),(0,y.jsxs)(`div`,{className:`term reveal`,children:[(0,y.jsxs)(`div`,{className:`term-bar`,children:[(0,y.jsx)(`i`,{className:`dot dot-live`,style:{color:`var(--signal-live)`}}),(0,y.jsx)(`span`,{children:`首次启动输出`}),(0,y.jsxs)(`span`,{className:`term-tag`,children:[`relay · v`,e]})]}),(0,y.jsxs)(`div`,{className:`term-body`,children:[(0,y.jsxs)(`div`,{className:`tl`,children:[(0,y.jsx)(`span`,{className:`pr`,children:`$`}),` sudo systemctl start relay`]}),(0,y.jsx)(`div`,{className:`tl out`,children:`Waygate · 首次启动,已生成管理口令(此口令只显示这一次)`}),(0,y.jsxs)(`div`,{className:`tl out`,children:[`口令:`,(0,y.jsx)(`span`,{className:`hl`,children:`••••••••••••••••`})]}),(0,y.jsx)(`div`,{className:`tl out`,children:`请立即复制保存。忘记口令时:控制台「设置 → 管理口令」重置。`}),(0,y.jsx)(`div`,{className:`tl ok`,children:`Waygate 已在 http://127.0.0.1:8787 就绪(默认仅回环,不对公网直接暴露)`})]})]})]})})}var B=`{"x":148,"y":-94,"z":-630,"rx":6,"ry":-11,"rz":-2.5,"fog":0.60,"dim":0.34}`,V=`sk-waygate-4f9c2a7e1b83d04f391c7a2e`,H=u(),U=u().replace(/\/v1$/,``),W=[{k:`兼容协议`,v:`OpenAI v1 · Anthropic`},{k:`接入方式`,v:`HTTPS · ${E()}`},{k:`统计口径`,v:`本机日志聚合`},{k:`日志存储`,v:`本地`}];function G(){return(0,y.jsx)(`section`,{className:`section`,id:`clients`,"data-cam":B,children:(0,y.jsxs)(`div`,{className:`wrap`,children:[(0,y.jsxs)(`div`,{className:`sec-head reveal`,children:[(0,y.jsxs)(`div`,{children:[(0,y.jsxs)(`div`,{className:`eyebrow`,children:[(0,y.jsx)(`span`,{className:`idx`,children:`04`}),`客户端配置`]}),(0,y.jsx)(`h2`,{className:`display-2`,style:{marginTop:20},children:`四处填好,立刻能用`})]}),(0,y.jsx)(`p`,{className:`lead`,children:`所有客户端都只需要一个地址加一个密钥。下面是最常见的四种接法。`})]}),(0,y.jsxs)(`div`,{className:`grid-2`,children:[(0,y.jsxs)(`div`,{className:`glass glass-soft cfg reveal`,children:[(0,y.jsx)(`h3`,{children:`编程工具 / IDE`}),(0,y.jsx)(`div`,{className:`sub`,children:`Continue · Cline · 任意 OpenAI 兼容插件`}),(0,y.jsxs)(`div`,{className:`code`,children:[`OPENAI_BASE_URL=`,(0,y.jsx)(`span`,{className:`s`,children:H}),`
@@ -0,0 +1 @@
1
+ import{B as e,N as t,_ as n,i as r,it as i,r as a,tt as o}from"./vendor-befEYGHM.js";import{O as s,_ as c,a as l,c as u,g as d,j as f,k as p,p as m,r as h,v as g,x as _}from"./index-nQeRK3kW.js";import{a as v,c as y,i as b,n as x,r as S,s as C,t as w}from"./Select-G6AhT0TA.js";import{r as T}from"./PageSkeleton-DG-Dj4_9.js";import{n as E,t as D}from"./sharedWindow-FDfq75PI.js";import{t as O}from"./useFx-xcrp_LHB.js";import{n as k,r as A,t as j}from"./ClientMetricTip-C2VuiT4-.js";var M=i(),N=o();function P({navigate:i}){let[o,P]=(0,M.useState)(()=>D()??`today`),F=f(()=>u.overview(o),[o],{cacheKey:`overview:${o}`});O(`overview-${o}-${F.data?`ready`:`pending`}`);let I=F.data,L={today:(()=>{let e=new Date;return e.getHours()*60+e.getMinutes()||1})(),"1h":60,"24h":1440,"7d":10080,"30d":43200},R=I?L[I.window]:null,z=I&&R?I.metrics.requests/R:null,B=I&&R?I.metrics.totalTokens/R:null,V=e=>{if(!I||I.byClient.length===0)return;let t=[...I.byClient].sort((t,n)=>(n[e]??0)-(t[e]??0));return(0,N.jsx)(j,{rows:t,metric:e,windowLabel:s[I.window],total:e===`credits`?I.metrics.creditsUsed:I.metrics.requests,totalCount:t.length})};return(0,N.jsxs)(`div`,{className:`view on`,children:[(0,N.jsx)(C,{title:`概览`,status:I?(0,N.jsxs)(y,{tone:`live`,dot:!0,children:[`本机日志聚合 · `,g(I.generatedAt)]}):null,actions:(0,N.jsxs)(N.Fragment,{children:[(0,N.jsx)(w,{value:o,options:p,onChange:e=>{E(e),P(e)},width:148}),(0,N.jsxs)(`button`,{type:`button`,className:`btn btn-primary btn-sm`,onClick:()=>i(`keys`),children:[(0,N.jsx)(n,{size:14}),`新建密钥`]})]})}),(0,N.jsx)(`div`,{className:`view-body stack`,children:F.initial&&F.loading?(0,N.jsx)(T,{}):F.error?(0,N.jsx)(v,{children:(0,N.jsx)(x,{kind:`error`,title:`概览数据没取到`,detail:S(F.error),onRetry:F.reload})}):I?(0,N.jsxs)(N.Fragment,{children:[I.alerts.channelReject.count>=I.alerts.channelReject.threshold?(0,N.jsxs)(h,{tone:`warn`,children:[(0,N.jsx)(a,{size:14,"aria-hidden":!0}),`最近 1 小时出现 `,(0,N.jsxs)(`b`,{children:[I.alerts.channelReject.count,` 次`]}),`上游渠道校验拒绝(11128): 请求的 system 提示命中了上游的第三方客户端指纹。本服务会自动改写模板行、被拒时降级重试, 连续失败说明出现了新的指纹变体。请到「请求日志」筛 note 含 upstream_11128 的行排查。`]}):null,I.alerts.credentialInvalid?.count!=null&&I.alerts.credentialInvalid.count>=I.alerts.credentialInvalid.threshold?(0,N.jsxs)(h,{tone:`error`,actions:(0,N.jsx)(`a`,{href:`#/clients`,className:`btn btn-quiet btn-sm`,children:`去提供商管理`}),children:[(0,N.jsx)(a,{size:14,"aria-hidden":!0}),`最近 1 小时出现 `,(0,N.jsxs)(`b`,{children:[I.alerts.credentialInvalid.count,` 次`]}),`上游访问密钥失效: 所有请求将以 502 失败,直到换新为止。`]}):null,(0,N.jsx)(A,{metrics:I.metrics}),(0,N.jsxs)(`div`,{className:`metric-row`,children:[(0,N.jsx)(b,{label:`已消耗积分`,value:m(I.metrics.creditsUsed),detail:I.metrics.creditsUnknownCount>0?`上游实扣 · 另 ${d(I.metrics.creditsUnknownCount)} 条上游未回报,未计入`:`上游实扣 · 全部请求均已回报`,tone:`amber`,icon:(0,N.jsx)(e,{size:14}),tip:V(`credits`),tipPos:`down`}),(0,N.jsx)(b,{label:`平均 RPM`,value:z===null?`—`:d(Math.round(z)),detail:`每分钟请求 · ${s[I.window]}`,tone:`violet`,icon:(0,N.jsx)(t,{size:14}),tip:V(`requests`),tipPos:`down`}),(0,N.jsx)(b,{label:`平均 TPM`,value:B===null?`—`:_(Math.round(B)),detail:`每分钟 tokens · ${s[I.window]}`,tone:`green`,icon:(0,N.jsx)(r,{size:14}),tip:V(`tokens`),tipPos:`down`})]}),(0,N.jsx)(v,{title:`提供商用量摘要`,aside:(0,N.jsxs)(y,{children:[I.byClient.length,` 个提供商 · 按 Token 排序`]}),children:I.byClient.length>0?(0,N.jsx)(`div`,{className:`tbl-scroll`,children:(0,N.jsxs)(`table`,{className:`tbl`,children:[(0,N.jsxs)(`caption`,{className:`sr-only`,children:[`提供商用量摘要,共 `,I.byClient.length,` 个提供商`]}),(0,N.jsx)(`thead`,{children:(0,N.jsxs)(`tr`,{children:[(0,N.jsx)(`th`,{scope:`col`,children:`提供商`}),(0,N.jsx)(`th`,{scope:`col`,className:`r`,children:`请求次数`}),(0,N.jsx)(`th`,{scope:`col`,className:`r`,children:`Token 消耗`}),(0,N.jsx)(`th`,{scope:`col`,className:`r`,children:`消耗积分`}),(0,N.jsx)(`th`,{scope:`col`,className:`r`,children:`Token 占比`}),(0,N.jsx)(`th`,{scope:`col`,children:`分布`})]})}),(0,N.jsx)(`tbody`,{children:[...I.byClient].sort((e,t)=>(t.tokens??0)-(e.tokens??0)).slice(0,6).map(e=>(0,N.jsxs)(`tr`,{children:[(0,N.jsx)(`td`,{className:`td-strong`,children:(0,N.jsx)(l,{content:(0,N.jsx)(k,{row:e}),children:(0,N.jsx)(`span`,{children:e.client??`未归属`})})}),(0,N.jsx)(`td`,{className:`r td-mono`,children:d(e.requests)}),(0,N.jsx)(`td`,{className:`r td-mono`,children:_(e.tokens??0)}),(0,N.jsx)(`td`,{className:`r td-mono`,children:m(e.credits)}),(0,N.jsx)(`td`,{className:`r td-mono`,children:c(e.share)}),(0,N.jsx)(`td`,{children:(0,N.jsx)(`div`,{className:`ov-bar-track`,children:(0,N.jsx)(`div`,{className:`ov-bar-fill`,style:{width:`${Math.max(2,Math.round((e.share??0)*100))}%`}})})})]},e.clientId??e.client??`unknown`))})]})}):(0,N.jsxs)(`div`,{className:`empty-note`,style:{padding:`24px 0`},children:[s[I.window],`没有提供商消耗记录。`]})}),(0,N.jsxs)(v,{title:`模型用量摘要`,aside:(0,N.jsxs)(y,{children:[I.byModel.length,` 个模型 · 按 Token 排序`]}),children:[I.byModel.length>0?(0,N.jsx)(`div`,{className:`tbl-scroll`,children:(0,N.jsxs)(`table`,{className:`tbl`,children:[(0,N.jsxs)(`caption`,{className:`sr-only`,children:[`模型用量摘要,共 `,I.byModel.length,` 个模型`]}),(0,N.jsx)(`thead`,{children:(0,N.jsxs)(`tr`,{children:[(0,N.jsx)(`th`,{scope:`col`,children:`模型`}),(0,N.jsx)(`th`,{scope:`col`,className:`r`,children:`请求次数`}),(0,N.jsx)(`th`,{scope:`col`,className:`r`,children:`Token 消耗`}),(0,N.jsx)(`th`,{scope:`col`,className:`r`,children:`消耗积分`}),(0,N.jsx)(`th`,{scope:`col`,className:`r`,children:`Token 占比`}),(0,N.jsx)(`th`,{scope:`col`,children:`分布`})]})}),(0,N.jsx)(`tbody`,{children:[...I.byModel].sort((e,t)=>(t.tokens??0)-(e.tokens??0)).slice(0,8).map(e=>{let t=e.displayName??e.model??`未知`;return(0,N.jsxs)(`tr`,{children:[(0,N.jsx)(`td`,{className:`td-strong`,children:t}),(0,N.jsx)(`td`,{className:`r td-mono`,children:d(e.requests)}),(0,N.jsx)(`td`,{className:`r td-mono`,children:_(e.tokens??0)}),(0,N.jsx)(`td`,{className:`r td-mono`,children:m(e.credits)}),(0,N.jsx)(`td`,{className:`r td-mono`,children:c(e.share)}),(0,N.jsx)(`td`,{children:(0,N.jsx)(`div`,{className:`ov-bar-track`,children:(0,N.jsx)(`div`,{className:`ov-bar-fill`,style:{width:`${Math.max(2,Math.round((e.share??0)*100))}%`}})})})]},e.model??t)})})]})}):(0,N.jsxs)(`div`,{className:`empty-note`,style:{padding:`24px 0`},children:[s[I.window],`没有模型消耗记录。`]}),(0,N.jsx)(`div`,{className:`footer-note`,children:`这一页只留结论。详细构成去「积分与用量」,逐条请求去「请求日志」。`})]}),(0,N.jsx)(`div`,{className:`footer-note`,style:{marginTop:0},children:I.provenance.note})]}):null})]})}export{P as OverviewPage};
@@ -1,4 +1,4 @@
1
- import{B as e,C as t,D as n,G as r,K as i,M as a,N as o,R as s,V as c,W as l,X as u,Z as d,et as f,it as p,j as m,o as h,q as g,tt as _,u as ee}from"./vendor-befEYGHM.js";import{C as v,E as y,M as te,S as b,T as x,_ as ne,a as S,b as C,c as w,f as T,g as E,h as D,j as O,l as k,m as A,p as j,r as re,w as M}from"./index-BJtz6Ses.js";import{a as N,c as P,n as F,o as ie,r as I,s as ae,t as L}from"./Select-HrLgXSri.js";import{i as oe}from"./PageSkeleton-DG-Dj4_9.js";import{t as se}from"./Drawer-CleQGhRU.js";import{t as ce}from"./useFx-xcrp_LHB.js";var R=p();function le(e,t=320){let[n,r]=(0,R.useState)(e);return(0,R.useEffect)(()=>{let n=window.setTimeout(()=>r(e),t);return()=>window.clearTimeout(n)},[e,t]),n}var z=_(),B=[20,50,100];function ue({page:e,limit:t,total:n,onPage:a,onLimit:o}){let s=Math.max(1,Math.ceil(n/t)),c=[],l=e=>{c[c.length-1]!==e&&c.push(e)},u=[1,e-1,e,e+1,s].filter(e=>e>=1&&e<=s).sort((e,t)=>e-t),d=0;return u.forEach(e=>{e-d>1&&l(`…`),l(e),d=e}),(0,z.jsxs)(`div`,{className:`pager`,children:[(0,z.jsxs)(`span`,{className:`txt`,children:[`第 `,e,` / `,s,` 页 · 每页 `,t,` 条,共 `,E(n),` 条`]}),(0,z.jsxs)(`span`,{className:`btns`,children:[(0,z.jsx)(L,{value:String(t),options:B.map(e=>({value:String(e),label:`${e} / 页`})),onChange:e=>o(Number(e)),size:`sm`,width:92,ariaLabel:`每页条数`}),(0,z.jsx)(`button`,{type:`button`,className:`pg`,disabled:e<=1,onClick:()=>a(e-1),"aria-label":`上一页`,children:(0,z.jsx)(r,{size:13})}),c.map((t,n)=>t===`…`?(0,z.jsx)(`span`,{className:`pg`,style:{cursor:`default`,background:`transparent`,border:`none`},children:`…`},`gap-${n}`):(0,z.jsx)(`button`,{type:`button`,className:`pg${t===e?` on`:``}`,onClick:()=>a(t),children:t},t)),(0,z.jsx)(`button`,{type:`button`,className:`pg`,disabled:e>=s,onClick:()=>a(e+1),"aria-label":`下一页`,children:(0,z.jsx)(i,{size:13})})]})]})}function V(e){let t=e.toLowerCase();return t.includes(`python`)||t.includes(`httpx`)||t.includes(`aiohttp`)?`python`:t.includes(`node`)||t.includes(`deno`)||t.includes(`bun`)||t.includes(`axios`)||t.includes(`undici`)?`node`:t.includes(`curl`)||t.includes(`wget`)||t.includes(`http`)?`terminal`:t.includes(`sdk`)?`sdk`:`cli`}var H=`M11.9 0C8.7 0 8.4 1.7 8.4 1.7v2.4h3.6v.7H5.3S2.4 4.5 2.4 8.4c0 3.8 2.5 3.7 2.5 3.7h1.5v-2.2s-.1-2.5 2.6-2.5h3.6s2.6 0 2.6-2.5V2.1S15.4 0 11.9 0zM9.3 1.5a.9.9 0 1 1 0 1.7.9.9 0 0 1 0-1.7zm6.3 3.4v2.3s.1 2.6-2.6 2.6H9.4s-2.5 0-2.5 2.5v4.4s-.2 2.7 4.8 2.7 4.7-2.3 4.7-2.3v-2.1h-3.6v-.7h6.7s3.2.3 3.2-3.7c0-4-2.8-3.8-2.8-3.8h-1.6v2.3s.1 2.6-2.6 2.6h-3.5s-2.4 0-2.4 2.4v4.1s-.4 2.4 4.4 2.4 4.5-2.1 4.5-2.1v-2h-3.4v-.7h6.6s3.4.4 3.4-3.9c0-4.3-2.9-4.1-2.9-4.1zM14.6 21.9a.9.9 0 1 1 0 1.8.9.9 0 0 1 0-1.8z`,U=`M12 1.5c-.3 0-.6.1-.9.3L3.4 6.4c-.5.3-.9.9-.9 1.5v8.2c0 .6.4 1.2.9 1.5l2 1.2c1 .5 1.8.1 1.8-1v-9c0-.7.5-1.2 1.2-1.2h7c.7 0 1.2.5 1.2 1.2v9c0 1.1.8 1.5 1.8 1l2-1.2c.5-.3.9-.9.9-1.5V7.9c0-.6-.4-1.2-.9-1.5L12.9 1.8c-.3-.2-.6-.3-.9-.3zm5.1 6c-.6 0-1.1.5-1.1 1.1v6.8c0 .6.5 1.1 1.1 1.1h5.2l-1.9 3.3 2.7-1.6c.5-.3.9-.9.9-1.5V7.9c0-.6-.4-1.2-.9-1.5l-7.7-4.6`,W=`M5 7l5 5-5 5m7 0h7`,G=`M14.7 6.3a5 5 0 0 0-6.9 6l-6.1 6.1a2 2 0 1 0 2.8 2.8l6.1-6.1a5 5 0 0 0 6-6.9l-3.2 3.2-2.8-2.8 3.1-3.1z`,K=`M8 6l-6 6 6 6m8-12l6 6-6 6`;function q({tool:e,size:t=14,style:n}){let r=e?V(e):`none`;if(r===`none`)return(0,z.jsxs)(`svg`,{width:t,height:t,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`,className:`ua-ico ${r}`,style:n,"aria-hidden":`true`,children:[(0,z.jsx)(`circle`,{cx:`12`,cy:`12`,r:`10`}),(0,z.jsx)(`path`,{d:`M2 12h20`}),(0,z.jsx)(`path`,{d:`M12 2a15.3 15.3 0 0 1 4 10 15.3 15.3 0 0 1-4 10 15.3 15.3 0 0 1-4-10 15.3 15.3 0 0 1 4-10z`})]});if(r===`python`||r===`node`){let e=r===`python`?H:U;return(0,z.jsx)(`svg`,{width:t,height:t,viewBox:`0 0 24 24`,fill:`currentColor`,className:`ua-ico ${r}`,style:n,"aria-hidden":`true`,children:(0,z.jsx)(`path`,{d:e})})}let i=r===`terminal`?W:r===`sdk`?G:K;return(0,z.jsx)(`svg`,{width:t,height:t,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`,className:`ua-ico ${r}`,style:n,"aria-hidden":`true`,children:(0,z.jsx)(`path`,{d:i})})}var J={live:`var(--text-tertiary)`,warn:`var(--warn-amber)`,fatal:`var(--danger-red)`,muted:`var(--text-faint)`},Y={live:`var(--signal-live)`,warn:`var(--warn-amber)`,fatal:`var(--danger-red)`,muted:`var(--text-faint)`};function X(e,t){if(!e)return!1;let n=e=>e.toLowerCase().replace(/[^a-z0-9]/g,``),r=n(e.trim().split(/[\s/]/)[0]??``);return r?t.split(/[\s.\-_/]+/).map(n).filter(e=>e.length>=3).some(e=>r.includes(e)):!1}function Z(e){let t=new Date(e);return Number.isNaN(t.getTime())?`--`:t.toLocaleDateString(`zh-CN`)}function de({rows:t,activeId:r,onOpen:l,resolveClientName:u,modelTagOf:d,providerOfModel:p}){return(0,z.jsx)(`div`,{className:`tbl-scroll`,children:(0,z.jsxs)(`table`,{className:`tbl`,children:[(0,z.jsxs)(`caption`,{className:`sr-only`,children:[`请求日志,共 `,t.length,` 条当前筛选结果`]}),(0,z.jsx)(`thead`,{children:(0,z.jsxs)(`tr`,{children:[(0,z.jsx)(`th`,{"aria-hidden":`true`}),(0,z.jsxs)(`th`,{scope:`col`,children:[(0,z.jsx)(c,{size:12}),`请求时间`]}),(0,z.jsxs)(`th`,{scope:`col`,children:[(0,z.jsx)(n,{size:12}),`令牌`]}),(0,z.jsxs)(`th`,{scope:`col`,children:[(0,z.jsx)(s,{size:12}),`模型 / 提供商`]}),(0,z.jsxs)(`th`,{scope:`col`,children:[(0,z.jsx)(m,{size:12}),`User Agent`]}),(0,z.jsxs)(`th`,{scope:`col`,className:`r`,children:[(0,z.jsx)(f,{size:12}),`状态`]}),(0,z.jsxs)(`th`,{scope:`col`,className:`r`,children:[(0,z.jsx)(h,{size:12}),`耗时`]}),(0,z.jsxs)(`th`,{scope:`col`,className:`r`,children:[(0,z.jsx)(o,{size:12}),`输出速度`]}),(0,z.jsxs)(`th`,{scope:`col`,className:`r`,children:[(0,z.jsx)(e,{size:12}),`Tokens`]}),(0,z.jsxs)(`th`,{scope:`col`,className:`r`,children:[(0,z.jsx)(a,{size:12}),`积分`]})]})}),(0,z.jsx)(`tbody`,{children:t.map(e=>{let t=x(e.status,e.note),n=v(e.note),a=e.modelDisplay||e.model;return(0,z.jsxs)(`tr`,{onClick:()=>l(e),className:r===e.id?`row-on`:void 0,style:{cursor:`pointer`,background:r===e.id?`var(--brand-tint)`:t===`fatal`?`color-mix(in srgb, var(--danger-red) 5%, transparent)`:void 0},children:[(0,z.jsx)(`td`,{className:`row-x-td`,children:(0,z.jsx)(`button`,{type:`button`,className:`row-open`,"aria-label":`打开 ${Z(e.ts)} ${T(e.ts)} 的请求详情`,onClick:t=>{t.stopPropagation(),l(e)},children:(0,z.jsx)(i,{size:14,className:`row-x`,"aria-hidden":`true`})})}),(0,z.jsxs)(`td`,{children:[(0,z.jsx)(`div`,{className:`cell-date`,children:Z(e.ts)}),(0,z.jsx)(`div`,{className:`td-mono`,style:{color:`var(--text-ghost)`},children:T(e.ts)})]}),(0,z.jsx)(`td`,{className:`td-mono`,style:{color:`var(--text-tertiary)`},children:(0,z.jsx)(S,{content:`密钥 ${e.keyHint}`,placement:`below`,children:(0,z.jsx)(`span`,{children:e.keyHint})})}),(0,z.jsxs)(`td`,{children:[(0,z.jsx)(`div`,{className:`td-strong`,children:a}),(0,z.jsxs)(`div`,{className:`model-meta`,children:[(0,z.jsx)(S,{content:`提供商:${p(e.model)??u(e)}(按模型目录归属解析)`,children:(0,z.jsx)(`span`,{className:`prov-pill`,children:p(e.model)??u(e)})}),d(e.model)?(0,z.jsx)(`span`,{className:`mu-tag`,children:d(e.model)}):null]})]}),(0,z.jsx)(`td`,{className:`td-ua`,children:e.ua?(0,z.jsx)(S,{content:e.ua,children:(0,z.jsxs)(`span`,{style:{display:`block`},children:[(0,z.jsxs)(`span`,{className:`ua-raw`,children:[(0,z.jsx)(q,{tool:e.tool,size:14,style:{marginRight:5,verticalAlign:-2}}),e.ua]}),e.tool&&!X(e.ua,e.tool)?(0,z.jsx)(`div`,{className:`ua-tool`,children:e.tool}):e.tool?null:(0,z.jsx)(`div`,{className:`ua-tool`,children:(0,z.jsx)(`span`,{style:{color:`var(--text-ghost)`},children:`未识别`})})]})}):(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`span`,{className:`ua-raw`,style:{color:`var(--text-ghost)`},children:`未采集`}),e.tool?(0,z.jsx)(`div`,{className:`ua-tool`,children:e.tool}):(0,z.jsx)(`div`,{className:`ua-tool`,children:(0,z.jsx)(`span`,{style:{color:`var(--text-ghost)`},children:`未识别`})})]})}),(0,z.jsx)(`td`,{className:`r td-mono`,style:{color:J[t]},children:n.length>0?(0,z.jsx)(S,{content:n.join(` · `),children:(0,z.jsxs)(`span`,{children:[(0,z.jsx)(`span`,{className:`dotc`,style:{background:Y[t]},"aria-hidden":`true`}),e.status]})}):(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`span`,{className:`dotc`,style:{background:Y[t]},"aria-hidden":`true`}),e.status]})}),(0,z.jsxs)(`td`,{className:`r td-mono`,children:[(0,z.jsx)(`div`,{children:(0,z.jsx)(S,{content:`首字耗时 —— 从发出请求到收到第一个内容块的等待
1
+ import{B as e,C as t,D as n,G as r,K as i,M as a,N as o,R as s,V as c,W as l,X as u,Z as d,et as f,it as p,j as m,o as h,q as g,tt as _,u as ee}from"./vendor-befEYGHM.js";import{C as v,E as y,M as te,S as b,T as x,_ as ne,a as S,b as C,c as w,f as T,g as E,h as D,j as O,l as k,m as A,p as j,r as re,w as M}from"./index-nQeRK3kW.js";import{a as N,c as P,n as F,o as ie,r as I,s as ae,t as L}from"./Select-G6AhT0TA.js";import{i as oe}from"./PageSkeleton-DG-Dj4_9.js";import{t as se}from"./Drawer-CleQGhRU.js";import{t as ce}from"./useFx-xcrp_LHB.js";var R=p();function le(e,t=320){let[n,r]=(0,R.useState)(e);return(0,R.useEffect)(()=>{let n=window.setTimeout(()=>r(e),t);return()=>window.clearTimeout(n)},[e,t]),n}var z=_(),B=[20,50,100];function ue({page:e,limit:t,total:n,onPage:a,onLimit:o}){let s=Math.max(1,Math.ceil(n/t)),c=[],l=e=>{c[c.length-1]!==e&&c.push(e)},u=[1,e-1,e,e+1,s].filter(e=>e>=1&&e<=s).sort((e,t)=>e-t),d=0;return u.forEach(e=>{e-d>1&&l(`…`),l(e),d=e}),(0,z.jsxs)(`div`,{className:`pager`,children:[(0,z.jsxs)(`span`,{className:`txt`,children:[`第 `,e,` / `,s,` 页 · 每页 `,t,` 条,共 `,E(n),` 条`]}),(0,z.jsxs)(`span`,{className:`btns`,children:[(0,z.jsx)(L,{value:String(t),options:B.map(e=>({value:String(e),label:`${e} / 页`})),onChange:e=>o(Number(e)),size:`sm`,width:92,ariaLabel:`每页条数`}),(0,z.jsx)(`button`,{type:`button`,className:`pg`,disabled:e<=1,onClick:()=>a(e-1),"aria-label":`上一页`,children:(0,z.jsx)(r,{size:13})}),c.map((t,n)=>t===`…`?(0,z.jsx)(`span`,{className:`pg`,style:{cursor:`default`,background:`transparent`,border:`none`},children:`…`},`gap-${n}`):(0,z.jsx)(`button`,{type:`button`,className:`pg${t===e?` on`:``}`,onClick:()=>a(t),children:t},t)),(0,z.jsx)(`button`,{type:`button`,className:`pg`,disabled:e>=s,onClick:()=>a(e+1),"aria-label":`下一页`,children:(0,z.jsx)(i,{size:13})})]})]})}function V(e){let t=e.toLowerCase();return t.includes(`python`)||t.includes(`httpx`)||t.includes(`aiohttp`)?`python`:t.includes(`node`)||t.includes(`deno`)||t.includes(`bun`)||t.includes(`axios`)||t.includes(`undici`)?`node`:t.includes(`curl`)||t.includes(`wget`)||t.includes(`http`)?`terminal`:t.includes(`sdk`)?`sdk`:`cli`}var H=`M11.9 0C8.7 0 8.4 1.7 8.4 1.7v2.4h3.6v.7H5.3S2.4 4.5 2.4 8.4c0 3.8 2.5 3.7 2.5 3.7h1.5v-2.2s-.1-2.5 2.6-2.5h3.6s2.6 0 2.6-2.5V2.1S15.4 0 11.9 0zM9.3 1.5a.9.9 0 1 1 0 1.7.9.9 0 0 1 0-1.7zm6.3 3.4v2.3s.1 2.6-2.6 2.6H9.4s-2.5 0-2.5 2.5v4.4s-.2 2.7 4.8 2.7 4.7-2.3 4.7-2.3v-2.1h-3.6v-.7h6.7s3.2.3 3.2-3.7c0-4-2.8-3.8-2.8-3.8h-1.6v2.3s.1 2.6-2.6 2.6h-3.5s-2.4 0-2.4 2.4v4.1s-.4 2.4 4.4 2.4 4.5-2.1 4.5-2.1v-2h-3.4v-.7h6.6s3.4.4 3.4-3.9c0-4.3-2.9-4.1-2.9-4.1zM14.6 21.9a.9.9 0 1 1 0 1.8.9.9 0 0 1 0-1.8z`,U=`M12 1.5c-.3 0-.6.1-.9.3L3.4 6.4c-.5.3-.9.9-.9 1.5v8.2c0 .6.4 1.2.9 1.5l2 1.2c1 .5 1.8.1 1.8-1v-9c0-.7.5-1.2 1.2-1.2h7c.7 0 1.2.5 1.2 1.2v9c0 1.1.8 1.5 1.8 1l2-1.2c.5-.3.9-.9.9-1.5V7.9c0-.6-.4-1.2-.9-1.5L12.9 1.8c-.3-.2-.6-.3-.9-.3zm5.1 6c-.6 0-1.1.5-1.1 1.1v6.8c0 .6.5 1.1 1.1 1.1h5.2l-1.9 3.3 2.7-1.6c.5-.3.9-.9.9-1.5V7.9c0-.6-.4-1.2-.9-1.5l-7.7-4.6`,W=`M5 7l5 5-5 5m7 0h7`,G=`M14.7 6.3a5 5 0 0 0-6.9 6l-6.1 6.1a2 2 0 1 0 2.8 2.8l6.1-6.1a5 5 0 0 0 6-6.9l-3.2 3.2-2.8-2.8 3.1-3.1z`,K=`M8 6l-6 6 6 6m8-12l6 6-6 6`;function q({tool:e,size:t=14,style:n}){let r=e?V(e):`none`;if(r===`none`)return(0,z.jsxs)(`svg`,{width:t,height:t,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`,className:`ua-ico ${r}`,style:n,"aria-hidden":`true`,children:[(0,z.jsx)(`circle`,{cx:`12`,cy:`12`,r:`10`}),(0,z.jsx)(`path`,{d:`M2 12h20`}),(0,z.jsx)(`path`,{d:`M12 2a15.3 15.3 0 0 1 4 10 15.3 15.3 0 0 1-4 10 15.3 15.3 0 0 1-4-10 15.3 15.3 0 0 1 4-10z`})]});if(r===`python`||r===`node`){let e=r===`python`?H:U;return(0,z.jsx)(`svg`,{width:t,height:t,viewBox:`0 0 24 24`,fill:`currentColor`,className:`ua-ico ${r}`,style:n,"aria-hidden":`true`,children:(0,z.jsx)(`path`,{d:e})})}let i=r===`terminal`?W:r===`sdk`?G:K;return(0,z.jsx)(`svg`,{width:t,height:t,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`,className:`ua-ico ${r}`,style:n,"aria-hidden":`true`,children:(0,z.jsx)(`path`,{d:i})})}var J={live:`var(--text-tertiary)`,warn:`var(--warn-amber)`,fatal:`var(--danger-red)`,muted:`var(--text-faint)`},Y={live:`var(--signal-live)`,warn:`var(--warn-amber)`,fatal:`var(--danger-red)`,muted:`var(--text-faint)`};function X(e,t){if(!e)return!1;let n=e=>e.toLowerCase().replace(/[^a-z0-9]/g,``),r=n(e.trim().split(/[\s/]/)[0]??``);return r?t.split(/[\s.\-_/]+/).map(n).filter(e=>e.length>=3).some(e=>r.includes(e)):!1}function Z(e){let t=new Date(e);return Number.isNaN(t.getTime())?`--`:t.toLocaleDateString(`zh-CN`)}function de({rows:t,activeId:r,onOpen:l,resolveClientName:u,modelTagOf:d,providerOfModel:p}){return(0,z.jsx)(`div`,{className:`tbl-scroll`,children:(0,z.jsxs)(`table`,{className:`tbl`,children:[(0,z.jsxs)(`caption`,{className:`sr-only`,children:[`请求日志,共 `,t.length,` 条当前筛选结果`]}),(0,z.jsx)(`thead`,{children:(0,z.jsxs)(`tr`,{children:[(0,z.jsx)(`th`,{"aria-hidden":`true`}),(0,z.jsxs)(`th`,{scope:`col`,children:[(0,z.jsx)(c,{size:12}),`请求时间`]}),(0,z.jsxs)(`th`,{scope:`col`,children:[(0,z.jsx)(n,{size:12}),`令牌`]}),(0,z.jsxs)(`th`,{scope:`col`,children:[(0,z.jsx)(s,{size:12}),`模型 / 提供商`]}),(0,z.jsxs)(`th`,{scope:`col`,children:[(0,z.jsx)(m,{size:12}),`User Agent`]}),(0,z.jsxs)(`th`,{scope:`col`,className:`r`,children:[(0,z.jsx)(f,{size:12}),`状态`]}),(0,z.jsxs)(`th`,{scope:`col`,className:`r`,children:[(0,z.jsx)(h,{size:12}),`耗时`]}),(0,z.jsxs)(`th`,{scope:`col`,className:`r`,children:[(0,z.jsx)(o,{size:12}),`输出速度`]}),(0,z.jsxs)(`th`,{scope:`col`,className:`r`,children:[(0,z.jsx)(e,{size:12}),`Tokens`]}),(0,z.jsxs)(`th`,{scope:`col`,className:`r`,children:[(0,z.jsx)(a,{size:12}),`积分`]})]})}),(0,z.jsx)(`tbody`,{children:t.map(e=>{let t=x(e.status,e.note),n=v(e.note),a=e.modelDisplay||e.model;return(0,z.jsxs)(`tr`,{onClick:()=>l(e),className:r===e.id?`row-on`:void 0,style:{cursor:`pointer`,background:r===e.id?`var(--brand-tint)`:t===`fatal`?`color-mix(in srgb, var(--danger-red) 5%, transparent)`:void 0},children:[(0,z.jsx)(`td`,{className:`row-x-td`,children:(0,z.jsx)(`button`,{type:`button`,className:`row-open`,"aria-label":`打开 ${Z(e.ts)} ${T(e.ts)} 的请求详情`,onClick:t=>{t.stopPropagation(),l(e)},children:(0,z.jsx)(i,{size:14,className:`row-x`,"aria-hidden":`true`})})}),(0,z.jsxs)(`td`,{children:[(0,z.jsx)(`div`,{className:`cell-date`,children:Z(e.ts)}),(0,z.jsx)(`div`,{className:`td-mono`,style:{color:`var(--text-ghost)`},children:T(e.ts)})]}),(0,z.jsx)(`td`,{className:`td-mono`,style:{color:`var(--text-tertiary)`},children:(0,z.jsx)(S,{content:`密钥 ${e.keyHint}`,placement:`below`,children:(0,z.jsx)(`span`,{children:e.keyHint})})}),(0,z.jsxs)(`td`,{children:[(0,z.jsx)(`div`,{className:`td-strong`,children:a}),(0,z.jsxs)(`div`,{className:`model-meta`,children:[(0,z.jsx)(S,{content:`提供商:${p(e.model)??u(e)}(按模型目录归属解析)`,children:(0,z.jsx)(`span`,{className:`prov-pill`,children:p(e.model)??u(e)})}),d(e.model)?(0,z.jsx)(`span`,{className:`mu-tag`,children:d(e.model)}):null]})]}),(0,z.jsx)(`td`,{className:`td-ua`,children:e.ua?(0,z.jsx)(S,{content:e.ua,children:(0,z.jsxs)(`span`,{style:{display:`block`},children:[(0,z.jsxs)(`span`,{className:`ua-raw`,children:[(0,z.jsx)(q,{tool:e.tool,size:14,style:{marginRight:5,verticalAlign:-2}}),e.ua]}),e.tool&&!X(e.ua,e.tool)?(0,z.jsx)(`div`,{className:`ua-tool`,children:e.tool}):e.tool?null:(0,z.jsx)(`div`,{className:`ua-tool`,children:(0,z.jsx)(`span`,{style:{color:`var(--text-ghost)`},children:`未识别`})})]})}):(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`span`,{className:`ua-raw`,style:{color:`var(--text-ghost)`},children:`未采集`}),e.tool?(0,z.jsx)(`div`,{className:`ua-tool`,children:e.tool}):(0,z.jsx)(`div`,{className:`ua-tool`,children:(0,z.jsx)(`span`,{style:{color:`var(--text-ghost)`},children:`未识别`})})]})}),(0,z.jsx)(`td`,{className:`r td-mono`,style:{color:J[t]},children:n.length>0?(0,z.jsx)(S,{content:n.join(` · `),children:(0,z.jsxs)(`span`,{children:[(0,z.jsx)(`span`,{className:`dotc`,style:{background:Y[t]},"aria-hidden":`true`}),e.status]})}):(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`span`,{className:`dotc`,style:{background:Y[t]},"aria-hidden":`true`}),e.status]})}),(0,z.jsxs)(`td`,{className:`r td-mono`,children:[(0,z.jsx)(`div`,{children:(0,z.jsx)(S,{content:`首字耗时 —— 从发出请求到收到第一个内容块的等待
2
2
  (含上游排队与思考时间;失败行没有首字)`,children:(0,z.jsx)(`span`,{className:`cell-sub`,children:e.firstByteMs===null?`无首字`:`首字 ${D(e.firstByteMs)}`})})}),(0,z.jsx)(`div`,{children:(0,z.jsx)(S,{content:`总耗时 —— 从发出请求到流结束`,children:(0,z.jsxs)(`span`,{children:[`耗时 `,D(e.ms)]})})})]}),(0,z.jsx)(`td`,{className:`r td-mono`,children:(0,z.jsx)(S,{content:`输出速度 = 输出 tokens ÷ 生成时长(总耗时 − 首字)
3
3
  上游不回报生成时长,此值由本服务按两端观测推算;
4
4
  失败行或首字即结束的请求没有生成过程,显示 --`,children:(0,z.jsx)(`span`,{children:C(M(e.completionTokens,e.ms,e.firstByteMs))})})}),(0,z.jsxs)(`td`,{className:`r td-mono`,children:[(0,z.jsx)(`div`,{children:(0,z.jsx)(S,{content:`输入 ${E(e.promptTokens)} tokens / 输出 ${E(e.completionTokens)} tokens`,children:(0,z.jsxs)(`span`,{children:[E(e.promptTokens),`/`,E(e.completionTokens)]})})}),e.cachedTokens>0?(0,z.jsx)(`div`,{children:(0,z.jsx)(S,{content:`输入中命中缓存 ${E(e.cachedTokens)} tokens\n上游按缓存价计费(已体现在积分里)`,children:(0,z.jsxs)(`span`,{className:`cell-cached`,children:[`+`,E(e.cachedTokens)]})})}):null]}),(0,z.jsx)(`td`,{className:`r td-mono`,children:e.credits===null?(0,z.jsx)(S,{content:`上游未回报该次费用(未知)
@@ -1 +1 @@
1
- import{J as e,S as t,it as n,k as r,m as i,q as a,r as o,rt as s,tt as c}from"./vendor-befEYGHM.js";import{a as l}from"./index-BJtz6Ses.js";var u=c();function d({tone:e=`ghost`,dot:t=!1,children:n}){return(0,u.jsxs)(`span`,{className:`pill pill-${e}`,children:[t?(0,u.jsx)(`span`,{className:`dot dot-live`}):null,n]})}function f({tone:e=`off`,children:t}){return(0,u.jsx)(`span`,{className:`tag tag-${e}`,children:t})}function p({title:e,status:t,actions:n}){return(0,u.jsxs)(`div`,{className:`topbar`,children:[(0,u.jsxs)(`div`,{className:`topbar-left`,children:[(0,u.jsx)(`h1`,{children:e}),t]}),n?(0,u.jsx)(`div`,{className:`topbar-right`,children:n}):null]})}function m({title:e,aside:t,children:n,className:r=``,padded:i=!0}){return(0,u.jsxs)(`div`,{className:`card${i?` panel`:``} ${r}`.trim(),children:[e?(0,u.jsxs)(`div`,{className:`panel-head`,style:i?void 0:{padding:`18px 20px 0`,marginBottom:12},children:[(0,u.jsx)(`h3`,{children:e}),t]}):null,n]})}function h({items:e}){return(0,u.jsx)(`div`,{className:`statbar`,"data-count":e.length,children:e.map(e=>(0,u.jsxs)(`div`,{children:[(0,u.jsxs)(`div`,{className:`sb-top`,children:[(0,u.jsx)(`span`,{className:`lb`,children:e.label}),e.detail?(0,u.jsx)(`span`,{className:`sdl`,children:e.detail}):null]}),e.tip?(0,u.jsx)(l,{content:e.tip,placement:e.tipPos===`down`?`below`:`auto`,className:`tooltip-value-anchor`,children:(0,u.jsx)(`div`,{className:`vl`,style:e.tone===`live`?{color:`var(--signal-live)`}:e.tone===`amber`?{color:`var(--warn-amber)`}:void 0,children:e.value})}):(0,u.jsx)(`div`,{className:`vl`,style:e.tone===`live`?{color:`var(--signal-live)`}:e.tone===`amber`?{color:`var(--warn-amber)`}:void 0,children:e.value})]},e.label))})}function g({label:e,value:t,detail:n,tone:r,icon:i,tip:a,tipPos:o}){let s=r===`cyan`||r===`violet`||r===`green`||r===`amber`||r===`blue`||r===`rose`?` m-${r}`:``;return(0,u.jsxs)(`div`,{className:`card metric`,children:[(0,u.jsxs)(`div`,{className:`m-top`,children:[i?(0,u.jsx)(`span`,{className:`m-ico${s}`,"aria-hidden":`true`,children:i}):null,(0,u.jsx)(`span`,{className:`lb`,children:e})]}),a?(0,u.jsx)(l,{content:a,placement:o===`down`?`below`:`auto`,className:`tooltip-value-anchor`,children:(0,u.jsx)(`div`,{className:`vl`,children:t})}):(0,u.jsx)(`div`,{className:`vl`,children:t}),n?(0,u.jsx)(`div`,{className:`dl${r===`up`?` up`:r===`warn`?` warn`:``}`,children:n}):null]})}function _({kind:e,title:n,detail:a,onRetry:s,children:c}){return e===`loading`?(0,u.jsxs)(`div`,{className:`state-block`,role:`status`,"aria-live":`polite`,"aria-busy":`true`,children:[(0,u.jsx)(t,{size:22,className:`spin`,style:{animation:`spin 1s linear infinite`}}),(0,u.jsx)(`div`,{className:`t`,children:n??`加载中…`})]}):e===`empty`?(0,u.jsxs)(`div`,{className:`state-block`,role:`status`,"aria-live":`polite`,children:[(0,u.jsx)(r,{size:26}),(0,u.jsx)(`div`,{className:`t`,children:n??`暂无数据`}),a?(0,u.jsx)(`div`,{className:`d`,children:a}):null,c]}):(0,u.jsxs)(`div`,{className:`state-block`,role:`alert`,"aria-live":`assertive`,children:[(0,u.jsx)(o,{size:26}),(0,u.jsx)(`div`,{className:`t`,children:n??`加载失败`}),a?(0,u.jsx)(`div`,{className:`d`,children:a}):null,s?(0,u.jsxs)(`button`,{type:`button`,className:`btn btn-quiet btn-sm`,onClick:s,children:[(0,u.jsx)(i,{size:14}),`重试`]}):null]})}function v(e){if(!e)return``;let t={40001:`有字段没通过校验,回退一步检查刚填的内容。`,40002:`确认文字不匹配 —— 这是刻意设计的门槛。`,40101:`管理口令不正确,注意区分大小写。`,40102:`会话已过期,登录后继续。`,40290:`登录失败次数过多,请 ${e.retryAfterSeconds?Math.ceil(e.retryAfterSeconds/60):10} 分钟后重试。`,40301:`请求来源校验失败(CSRF 防护),刷新页面重试。`,40401:`这条记录已不存在,可能刚被删掉了。`,40901:`同名密钥已存在,换一个名字。`,50001:`服务端未分类异常,可稍后重试或查看服务日志。`,50301:`数据库暂时不可用,确认后端进程是否在运行。`};return(e.code===40001||e.code===50001)&&/[\u4e00-\u9fa5]/.test(e.message)?e.message:t[e.code]?t[e.code]:e.status===0?e.message:e.message||`请求失败(HTTP ${e.status})`}var y=n(),b=s();function x({value:t,options:n,onChange:r,width:i,disabled:o,size:s=`md`,ariaLabel:c}){let[l,d]=(0,y.useState)(!1),[f,p]=(0,y.useState)(0),[m,h]=(0,y.useState)(null),[g,_]=(0,y.useState)(!1),v=(0,y.useRef)(null),x=(0,y.useRef)(null),S=(0,y.useRef)({buf:``,at:0}),C=(0,y.useId)(),w=`${C}list`,T=e=>`${C}opt${e}`,E=Math.max(0,n.findIndex(e=>e.value===t)),D=(0,y.useCallback)(()=>{let e=v.current;if(!e)return;let t=e.getBoundingClientRect();h({left:t.left,top:t.top,bottom:t.bottom,width:t.width})},[]),O=(0,y.useCallback)(()=>{o||n.length===0||(S.current={buf:``,at:0},p(E),D(),d(!0))},[o,D,n.length,E]),k=(0,y.useCallback)(e=>{let t=n[e];t&&r(t.value),d(!1),v.current?.focus()},[r,n]);(0,y.useLayoutEffect)(()=>{l&&x.current?.focus()},[l]),(0,y.useLayoutEffect)(()=>{if(!l||!m)return;let e=x.current;if(!e)return;let t=window.innerHeight-m.bottom;_(t<e.offsetHeight+12&&m.top>t)},[l,m,n.length]),(0,y.useEffect)(()=>{l&&x.current?.querySelector(`[data-opt="${f}"]`)?.scrollIntoView({block:`nearest`})},[f,l]),(0,y.useEffect)(()=>{if(!l)return;let e=()=>D(),t=e=>{let t=e.target;t&&(v.current?.contains(t)||x.current?.contains(t))||d(!1)};return window.addEventListener(`scroll`,e,!0),window.addEventListener(`resize`,e),document.addEventListener(`pointerdown`,t,!0),()=>{window.removeEventListener(`scroll`,e,!0),window.removeEventListener(`resize`,e),document.removeEventListener(`pointerdown`,t,!0)}},[l,D]);let A=(0,y.useCallback)((e,t)=>{let r=Date.now(),i=(r-S.current.at>700?``:S.current.buf)+e;S.current={buf:i,at:r};let a=i.toLowerCase(),o=n.length,s=i.length===1?(t+1)%o:0;for(let e=0;e<o;e+=1){let t=(s+e)%o;if(n[t].label.toLowerCase().startsWith(a)){p(t);return}}},[n]),j=e=>e.key.length===1&&!e.ctrlKey&&!e.metaKey&&!e.altKey&&/\S/.test(e.key),M=e=>{if(!(o||l)){if(e.key===`ArrowDown`||e.key===`ArrowUp`||e.key===`Enter`||e.key===` `){e.preventDefault(),O();return}j(e)&&(e.preventDefault(),O(),A(e.key,E))}},N=e=>{let t=n.length;switch(e.key){case`ArrowDown`:e.preventDefault(),p(e=>(e+1)%t);break;case`ArrowUp`:e.preventDefault(),p(e=>(e-1+t)%t);break;case`Home`:e.preventDefault(),p(0);break;case`End`:e.preventDefault(),p(t-1);break;case`Enter`:case` `:e.preventDefault(),k(f);break;case`Escape`:e.preventDefault(),e.stopPropagation(),d(!1),v.current?.focus();break;case`Tab`:d(!1),v.current?.focus();break;default:j(e)&&A(e.key,f)}},P=n[E]?.label??``;return(0,u.jsxs)(`div`,{className:`sel-field`,style:i?{width:i}:void 0,children:[(0,u.jsxs)(`button`,{type:`button`,ref:v,className:s===`sm`?`sel sm`:`sel`,"aria-haspopup":`listbox`,"aria-expanded":l,"aria-controls":l?w:void 0,"aria-label":c,"data-value":t,disabled:o,onClick:()=>l?d(!1):O(),onKeyDown:M,children:[(0,u.jsx)(`span`,{className:`sel-val`,children:P}),(0,u.jsx)(a,{size:s===`sm`?12:13,className:`ic caret-glyph`,"aria-hidden":!0})]}),l&&m?(0,b.createPortal)((0,u.jsx)(`div`,{ref:x,id:w,role:`listbox`,tabIndex:-1,"aria-activedescendant":n.length?T(f):void 0,className:s===`sm`?`sel-pop sm`:`sel-pop`,onKeyDown:N,style:{left:Math.max(8,Math.min(m.left,window.innerWidth-Math.max(m.width,168)-8)),top:g?void 0:m.bottom+6,bottom:g?window.innerHeight-m.top+6:void 0,minWidth:m.width},children:n.map((n,r)=>(0,u.jsxs)(`div`,{id:T(r),"data-opt":r,"data-value":n.value,role:`option`,"aria-selected":n.value===t,className:`sel-opt${r===f?` on`:``}${n.value===t?` picked`:``}`,onMouseEnter:()=>p(r),onPointerDown:e=>e.preventDefault(),onClick:()=>k(r),children:[(0,u.jsx)(`span`,{className:`sel-opt-lb`,children:n.label}),n.value===t?(0,u.jsx)(e,{size:13,className:`ic`,"aria-hidden":!0}):null]},n.value))}),document.body):null]})}export{m as a,d as c,g as i,f as l,_ as n,h as o,v as r,p as s,x as t};
1
+ import{J as e,S as t,it as n,k as r,m as i,q as a,r as o,rt as s,tt as c}from"./vendor-befEYGHM.js";import{a as l}from"./index-nQeRK3kW.js";var u=c();function d({tone:e=`ghost`,dot:t=!1,children:n}){return(0,u.jsxs)(`span`,{className:`pill pill-${e}`,children:[t?(0,u.jsx)(`span`,{className:`dot dot-live`}):null,n]})}function f({tone:e=`off`,children:t}){return(0,u.jsx)(`span`,{className:`tag tag-${e}`,children:t})}function p({title:e,status:t,actions:n}){return(0,u.jsxs)(`div`,{className:`topbar`,children:[(0,u.jsxs)(`div`,{className:`topbar-left`,children:[(0,u.jsx)(`h1`,{children:e}),t]}),n?(0,u.jsx)(`div`,{className:`topbar-right`,children:n}):null]})}function m({title:e,aside:t,children:n,className:r=``,padded:i=!0}){return(0,u.jsxs)(`div`,{className:`card${i?` panel`:``} ${r}`.trim(),children:[e?(0,u.jsxs)(`div`,{className:`panel-head`,style:i?void 0:{padding:`18px 20px 0`,marginBottom:12},children:[(0,u.jsx)(`h3`,{children:e}),t]}):null,n]})}function h({items:e}){return(0,u.jsx)(`div`,{className:`statbar`,"data-count":e.length,children:e.map(e=>(0,u.jsxs)(`div`,{children:[(0,u.jsxs)(`div`,{className:`sb-top`,children:[(0,u.jsx)(`span`,{className:`lb`,children:e.label}),e.detail?(0,u.jsx)(`span`,{className:`sdl`,children:e.detail}):null]}),e.tip?(0,u.jsx)(l,{content:e.tip,placement:e.tipPos===`down`?`below`:`auto`,className:`tooltip-value-anchor`,children:(0,u.jsx)(`div`,{className:`vl`,style:e.tone===`live`?{color:`var(--signal-live)`}:e.tone===`amber`?{color:`var(--warn-amber)`}:void 0,children:e.value})}):(0,u.jsx)(`div`,{className:`vl`,style:e.tone===`live`?{color:`var(--signal-live)`}:e.tone===`amber`?{color:`var(--warn-amber)`}:void 0,children:e.value})]},e.label))})}function g({label:e,value:t,detail:n,tone:r,icon:i,tip:a,tipPos:o}){let s=r===`cyan`||r===`violet`||r===`green`||r===`amber`||r===`blue`||r===`rose`?` m-${r}`:``;return(0,u.jsxs)(`div`,{className:`card metric`,children:[(0,u.jsxs)(`div`,{className:`m-top`,children:[i?(0,u.jsx)(`span`,{className:`m-ico${s}`,"aria-hidden":`true`,children:i}):null,(0,u.jsx)(`span`,{className:`lb`,children:e})]}),a?(0,u.jsx)(l,{content:a,placement:o===`down`?`below`:`auto`,className:`tooltip-value-anchor`,children:(0,u.jsx)(`div`,{className:`vl`,children:t})}):(0,u.jsx)(`div`,{className:`vl`,children:t}),n?(0,u.jsx)(`div`,{className:`dl${r===`up`?` up`:r===`warn`?` warn`:``}`,children:n}):null]})}function _({kind:e,title:n,detail:a,onRetry:s,children:c}){return e===`loading`?(0,u.jsxs)(`div`,{className:`state-block`,role:`status`,"aria-live":`polite`,"aria-busy":`true`,children:[(0,u.jsx)(t,{size:22,className:`spin`,style:{animation:`spin 1s linear infinite`}}),(0,u.jsx)(`div`,{className:`t`,children:n??`加载中…`})]}):e===`empty`?(0,u.jsxs)(`div`,{className:`state-block`,role:`status`,"aria-live":`polite`,children:[(0,u.jsx)(r,{size:26}),(0,u.jsx)(`div`,{className:`t`,children:n??`暂无数据`}),a?(0,u.jsx)(`div`,{className:`d`,children:a}):null,c]}):(0,u.jsxs)(`div`,{className:`state-block`,role:`alert`,"aria-live":`assertive`,children:[(0,u.jsx)(o,{size:26}),(0,u.jsx)(`div`,{className:`t`,children:n??`加载失败`}),a?(0,u.jsx)(`div`,{className:`d`,children:a}):null,s?(0,u.jsxs)(`button`,{type:`button`,className:`btn btn-quiet btn-sm`,onClick:s,children:[(0,u.jsx)(i,{size:14}),`重试`]}):null]})}function v(e){if(!e)return``;let t={40001:`有字段没通过校验,回退一步检查刚填的内容。`,40002:`确认文字不匹配 —— 这是刻意设计的门槛。`,40101:`管理口令不正确,注意区分大小写。`,40102:`会话已过期,登录后继续。`,40290:`登录失败次数过多,请 ${e.retryAfterSeconds?Math.ceil(e.retryAfterSeconds/60):10} 分钟后重试。`,40301:`请求来源校验失败(CSRF 防护),刷新页面重试。`,40401:`这条记录已不存在,可能刚被删掉了。`,40901:`同名密钥已存在,换一个名字。`,50001:`服务端未分类异常,可稍后重试或查看服务日志。`,50301:`数据库暂时不可用,确认后端进程是否在运行。`};return(e.code===40001||e.code===50001)&&/[\u4e00-\u9fa5]/.test(e.message)?e.message:t[e.code]?t[e.code]:e.status===0?e.message:e.message||`请求失败(HTTP ${e.status})`}var y=n(),b=s();function x({value:t,options:n,onChange:r,width:i,disabled:o,size:s=`md`,ariaLabel:c}){let[l,d]=(0,y.useState)(!1),[f,p]=(0,y.useState)(0),[m,h]=(0,y.useState)(null),[g,_]=(0,y.useState)(!1),v=(0,y.useRef)(null),x=(0,y.useRef)(null),S=(0,y.useRef)({buf:``,at:0}),C=(0,y.useId)(),w=`${C}list`,T=e=>`${C}opt${e}`,E=Math.max(0,n.findIndex(e=>e.value===t)),D=(0,y.useCallback)(()=>{let e=v.current;if(!e)return;let t=e.getBoundingClientRect();h({left:t.left,top:t.top,bottom:t.bottom,width:t.width})},[]),O=(0,y.useCallback)(()=>{o||n.length===0||(S.current={buf:``,at:0},p(E),D(),d(!0))},[o,D,n.length,E]),k=(0,y.useCallback)(e=>{let t=n[e];t&&r(t.value),d(!1),v.current?.focus()},[r,n]);(0,y.useLayoutEffect)(()=>{l&&x.current?.focus()},[l]),(0,y.useLayoutEffect)(()=>{if(!l||!m)return;let e=x.current;if(!e)return;let t=window.innerHeight-m.bottom;_(t<e.offsetHeight+12&&m.top>t)},[l,m,n.length]),(0,y.useEffect)(()=>{l&&x.current?.querySelector(`[data-opt="${f}"]`)?.scrollIntoView({block:`nearest`})},[f,l]),(0,y.useEffect)(()=>{if(!l)return;let e=()=>D(),t=e=>{let t=e.target;t&&(v.current?.contains(t)||x.current?.contains(t))||d(!1)};return window.addEventListener(`scroll`,e,!0),window.addEventListener(`resize`,e),document.addEventListener(`pointerdown`,t,!0),()=>{window.removeEventListener(`scroll`,e,!0),window.removeEventListener(`resize`,e),document.removeEventListener(`pointerdown`,t,!0)}},[l,D]);let A=(0,y.useCallback)((e,t)=>{let r=Date.now(),i=(r-S.current.at>700?``:S.current.buf)+e;S.current={buf:i,at:r};let a=i.toLowerCase(),o=n.length,s=i.length===1?(t+1)%o:0;for(let e=0;e<o;e+=1){let t=(s+e)%o;if(n[t].label.toLowerCase().startsWith(a)){p(t);return}}},[n]),j=e=>e.key.length===1&&!e.ctrlKey&&!e.metaKey&&!e.altKey&&/\S/.test(e.key),M=e=>{if(!(o||l)){if(e.key===`ArrowDown`||e.key===`ArrowUp`||e.key===`Enter`||e.key===` `){e.preventDefault(),O();return}j(e)&&(e.preventDefault(),O(),A(e.key,E))}},N=e=>{let t=n.length;switch(e.key){case`ArrowDown`:e.preventDefault(),p(e=>(e+1)%t);break;case`ArrowUp`:e.preventDefault(),p(e=>(e-1+t)%t);break;case`Home`:e.preventDefault(),p(0);break;case`End`:e.preventDefault(),p(t-1);break;case`Enter`:case` `:e.preventDefault(),k(f);break;case`Escape`:e.preventDefault(),e.stopPropagation(),d(!1),v.current?.focus();break;case`Tab`:d(!1),v.current?.focus();break;default:j(e)&&A(e.key,f)}},P=n[E]?.label??``;return(0,u.jsxs)(`div`,{className:`sel-field`,style:i?{width:i}:void 0,children:[(0,u.jsxs)(`button`,{type:`button`,ref:v,className:s===`sm`?`sel sm`:`sel`,"aria-haspopup":`listbox`,"aria-expanded":l,"aria-controls":l?w:void 0,"aria-label":c,"data-value":t,disabled:o,onClick:()=>l?d(!1):O(),onKeyDown:M,children:[(0,u.jsx)(`span`,{className:`sel-val`,children:P}),(0,u.jsx)(a,{size:s===`sm`?12:13,className:`ic caret-glyph`,"aria-hidden":!0})]}),l&&m?(0,b.createPortal)((0,u.jsx)(`div`,{ref:x,id:w,role:`listbox`,tabIndex:-1,"aria-activedescendant":n.length?T(f):void 0,className:s===`sm`?`sel-pop sm`:`sel-pop`,onKeyDown:N,style:{left:Math.max(8,Math.min(m.left,window.innerWidth-Math.max(m.width,168)-8)),top:g?void 0:m.bottom+6,bottom:g?window.innerHeight-m.top+6:void 0,minWidth:m.width},children:n.map((n,r)=>(0,u.jsxs)(`div`,{id:T(r),"data-opt":r,"data-value":n.value,role:`option`,"aria-selected":n.value===t,className:`sel-opt${r===f?` on`:``}${n.value===t?` picked`:``}`,onMouseEnter:()=>p(r),onPointerDown:e=>e.preventDefault(),onClick:()=>k(r),children:[(0,u.jsx)(`span`,{className:`sel-opt-lb`,children:n.label}),n.value===t?(0,u.jsx)(e,{size:13,className:`ic`,"aria-hidden":!0}):null]},n.value))}),document.body):null]})}export{m as a,d as c,g as i,f as l,_ as n,h as o,v as r,p as s,x as t};
@@ -1,3 +1,5 @@
1
- import{D as e,J as t,S as n,f as r,it as i,l as a,p as o,tt as s,w as c,z as l}from"./vendor-befEYGHM.js";import{M as u,a as d,c as f,g as p,j as m,p as h,r as g}from"./index-BJtz6Ses.js";import{t as _}from"./accessUrl-DbL5DLDz.js";import{a as v,c as y,l as b,n as x,r as S,s as C,t as w}from"./Select-HrLgXSri.js";import{t as T}from"./Modal-B-rIrvXS.js";import{t as E}from"./Drawer-CleQGhRU.js";import{t as D}from"./Switch-0KA1AbiV.js";var O=i(),k=s();function A({item:e,value:t,disabled:n,onChange:r}){if(e.type===`switch`)return(0,k.jsx)(D,{checked:!!t,disabled:n||e.readonly,label:e.label,onChange:e=>r(e)});if(e.type===`badge`)return(0,k.jsx)(b,{tone:`live`,children:String(t)});if(e.type===`select`){let i=(e.options??[]).map(e=>({value:e.value,label:e.label}));return(0,k.jsx)(w,{value:String(t),options:i,disabled:n||e.readonly,onChange:e=>r(e),width:188})}return e.type===`number`?(0,k.jsx)(`input`,{className:`field-input num`,type:`number`,value:t==null?``:String(t),disabled:n||e.readonly,onChange:e=>r(e.target.value===``?``:Number(e.target.value)),"aria-label":e.label}):e.type===`mapping`?null:(0,k.jsx)(`input`,{className:`field-input text`,value:t==null?``:String(t),disabled:n||e.readonly,onChange:e=>r(e.target.value),"aria-label":e.label})}function j(){let e=_(),[n,r]=(0,O.useState)(!1),i=async()=>{try{await navigator.clipboard.writeText(e),r(!0),window.setTimeout(()=>r(!1),1200)}catch{}};return(0,k.jsxs)(`div`,{className:`card access-card`,children:[(0,k.jsxs)(`div`,{className:`access-head`,children:[(0,k.jsxs)(`span`,{className:`access-title`,children:[(0,k.jsx)(c,{size:13,"aria-hidden":!0}),`接入地址`]}),(0,k.jsx)(`span`,{className:`access-sub`,children:`客户端与 API 同源 —— 这就是你当前访问控制台的地址`})]}),(0,k.jsxs)(`div`,{className:`key-plain access-url`,children:[(0,k.jsx)(`code`,{children:e}),(0,k.jsxs)(`button`,{type:`button`,className:`copy`,"aria-label":n?`已复制接入地址`:`复制接入地址`,onClick:()=>void i(),children:[n?(0,k.jsx)(t,{size:13}):(0,k.jsx)(l,{size:13}),n?`已复制`:`复制`]})]}),(0,k.jsxs)(`p`,{className:`chain-note`,children:[`客户端里要填两组值:`,(0,k.jsx)(`b`,{children:`base_url`}),` 就是上面这串;`,(0,k.jsx)(`b`,{children:`API Key`}),` 用你在本页`,(0,k.jsx)(`b`,{children:`新建的那把`}),(0,k.jsx)(`span`,{className:`code-chip`,children:`sk-waygate-…`}),`(明文只在创建时显示一次,丢了只能删掉重建)。`]}),(0,k.jsxs)(`div`,{className:`cred-note access-cert`,children:[(0,k.jsx)(a,{size:14,"aria-hidden":!0}),(0,k.jsxs)(`span`,{children:[`本服务的 TLS 是`,(0,k.jsx)(`b`,{children:`自签证书`}),`:客户端得先信任它的根证书,否则会以「证书错误」失败 —— 那`,(0,k.jsx)(`b`,{children:`不是`}),`地址填错。把根证书装进系统信任库,或让客户端通过`,(0,k.jsx)(`span`,{className:`code-chip`,children:`NODE_EXTRA_CA_CERTS`}),` /`,(0,k.jsx)(`span`,{className:`code-chip`,children:`SSL_CERT_FILE`}),`指向随部署产出的`,(0,k.jsx)(`span`,{className:`code-chip`,children:`relay-ca.crt`}),`。`]})]})]})}var M=8,N=128;function P({onClose:r,onDone:i}){let[o,s]=(0,O.useState)(`reset`),[c,d]=(0,O.useState)(`warn`),[p,m]=(0,O.useState)(``),[h,_]=(0,O.useState)(!1),[v,y]=(0,O.useState)(null),[b,x]=(0,O.useState)(null),[C,w]=(0,O.useState)(!1),[E,D]=(0,O.useState)(``),[A,j]=(0,O.useState)(``),[P,I]=(0,O.useState)(null),L=p===`确认`,R=async()=>{if(L&&!h){_(!0),y(null);try{let e=await f.resetAdminPassword();x(e),d(`result`)}catch(e){y(e instanceof u?S(e):String(e))}finally{_(!1)}}},z=async()=>{if(b)try{await navigator.clipboard.writeText(b.password),w(!0),window.setTimeout(()=>w(!1),2e3)}catch{y(`浏览器拒绝了剪贴板访问,请手动选中口令复制。`)}},B=()=>{x(null),D(``),j(``),i?.(),r()},V=async()=>{if(h)return;let e=E.trim();if(e.length===0){y(`管理口令不能为空或纯空白。`);return}if(e.length<M){y(`管理口令至少 ${M} 个字符,当前 ${e.length} 个。`);return}if(E.length>N){y(`管理口令最多 ${N} 个字符,当前 ${E.length} 个。`);return}if(E!==A){y(`两次输入不一致,请重新确认。`);return}_(!0),y(null);try{let e=await f.setAdminPassword(E);D(``),j(``),I(e.persisted?`已生效,下次登录用新口令。当前会话不受影响。`:`已生效(仅内存),下次登录用新口令 —— 但服务端数据库不可写,重启后会回到上一个口令。`)}catch(e){y(e instanceof u?S(e):String(e))}finally{_(!1)}};if(o===`manual`&&P)return(0,k.jsxs)(T,{title:`管理口令已更新`,onClose:B,footer:(0,k.jsx)(`button`,{type:`button`,className:`btn btn-primary btn-sm`,onClick:B,children:`知道了`}),children:[(0,k.jsx)(`div`,{className:`pw-note`,children:P}),(0,k.jsxs)(`p`,{className:`ov-sub`,style:{marginTop:12},children:[`服务端只存了口令的 scrypt 哈希,`,(0,k.jsx)(`b`,{children:`回不出明文`}),`。请确保你已经记住了刚才输入的口令。`]})]});if(o===`manual`){let t=E.trim().length>0&&E.trim().length<M,i=A.length>0&&E!==A;return(0,k.jsxs)(T,{title:`手动设定管理口令`,onClose:r,footer:(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(`button`,{type:`button`,className:`btn btn-quiet btn-sm`,onClick:r,children:`取消`}),(0,k.jsxs)(`button`,{type:`button`,className:`btn btn-primary btn-sm`,disabled:h||t||i||E.trim().length===0,onClick:()=>void V(),children:[h?(0,k.jsx)(n,{size:14}):(0,k.jsx)(e,{size:14}),h?`保存中…`:`保存并生效`]})]}),children:[(0,k.jsxs)(`p`,{className:`ov-sub`,children:[`设定一个你自己方便记忆的管理口令(至少 `,M,` 个字符)。 保存后`,(0,k.jsx)(`b`,{children:`立即生效、无需重启`}),`,当前会话不会被打断。`]}),(0,k.jsxs)(`div`,{className:`ov-field`,children:[(0,k.jsx)(`label`,{htmlFor:`pw-new`,children:`新管理口令`}),(0,k.jsx)(`input`,{id:`pw-new`,type:`password`,className:`field-input text`,style:{width:`100%`},value:E,autoFocus:!0,autoComplete:`new-password`,placeholder:`至少 ${M} 个字符`,onChange:e=>{D(e.target.value),y(null)}}),t?(0,k.jsxs)(`div`,{className:`ov-hint`,style:{color:`var(--warn-amber)`},children:[`至少 `,M,` 个字符,当前 `,E.trim().length,` 个。`]}):null]}),(0,k.jsxs)(`div`,{className:`ov-field`,children:[(0,k.jsx)(`label`,{htmlFor:`pw-new-confirm`,children:`再次输入`}),(0,k.jsx)(`input`,{id:`pw-new-confirm`,type:`password`,className:`field-input text`,style:{width:`100%`},value:A,autoComplete:`new-password`,placeholder:`重复上面输入的口令`,onChange:e=>{j(e.target.value),y(null)}}),i?(0,k.jsx)(`div`,{className:`ov-hint`,style:{color:`var(--warn-amber)`},children:`两次输入不一致。`}):null]}),(0,k.jsxs)(`div`,{className:`ov-lose`,children:[(0,k.jsx)(`b`,{children:`请记住它:`}),`设定后旧口令立即失效,且本产品没有「忘记口令」的找回通道。 口令明文不会保存在浏览器任何位置,也不会被回显。`]}),v?(0,k.jsx)(g,{tone:`error`,children:(0,k.jsx)(`span`,{style:{display:`block`,marginTop:14},children:v})}):null]})}return c===`result`&&b?(0,k.jsxs)(T,{title:`新管理口令`,onClose:B,footer:(0,k.jsx)(`button`,{type:`button`,className:`btn btn-primary btn-sm`,onClick:B,children:`我已保存,关闭`}),children:[(0,k.jsxs)(`div`,{className:`pw-once`,children:[(0,k.jsxs)(`div`,{className:`pw-once-head`,children:[(0,k.jsx)(a,{size:16}),(0,k.jsx)(`b`,{children:`这是唯一一次显示`})]}),(0,k.jsx)(`div`,{className:`pw-once-body`,children:`关闭这个窗口后,服务端也回不出这份明文 —— 库里只存了它的 scrypt 哈希。 请现在就复制并保存到你的密码管理器里。`})]}),(0,k.jsxs)(`div`,{className:`pw-plain`,children:[(0,k.jsx)(`code`,{children:b.password}),(0,k.jsxs)(`button`,{type:`button`,className:`btn btn-quiet btn-sm`,onClick:()=>void z(),children:[C?(0,k.jsx)(t,{size:14}):(0,k.jsx)(l,{size:14}),C?`已复制`:`复制`]})]}),b.persisted?(0,k.jsxs)(`div`,{className:`pw-note`,children:[`已写入服务端数据库,`,(0,k.jsx)(`b`,{children:`立即生效、无需重启`}),`,并会随每日备份一起保存。 下次登录请使用新口令。`]}):(0,k.jsx)(g,{tone:`warn`,children:(0,k.jsxs)(`span`,{style:{display:`block`,marginTop:14},children:[`服务端数据库不可写,新口令`,(0,k.jsx)(`b`,{children:`仅本次运行有效`}),`:重启后会回到旧口令。 请先修好数据目录权限,再重置一次。`]})}),v?(0,k.jsx)(g,{tone:`error`,children:(0,k.jsx)(`span`,{style:{display:`block`,marginTop:14},children:v})}):null]}):c===`confirm`?(0,k.jsxs)(T,{title:`确认重置管理口令?`,onClose:r,footer:(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(`button`,{type:`button`,className:`btn btn-primary btn-sm`,onClick:r,children:`取消(保持现状)`}),(0,k.jsxs)(`button`,{type:`button`,className:`btn btn-danger btn-sm`,disabled:!L||h,onClick:()=>void R(),children:[h?(0,k.jsx)(n,{size:14}):null,h?`重置中…`:`确认重置`]})]}),children:[(0,k.jsxs)(`p`,{className:`ov-sub`,children:[`重置后,`,(0,k.jsx)(`b`,{children:`当前口令立即失效`}),`。你正在使用的这个会话不会被打断,但下次登录必须用新口令。`]}),(0,k.jsxs)(`div`,{className:`ov-lose`,children:[(0,k.jsx)(`b`,{children:`会失去什么:`}),`旧口令的所有副本(笔记、密码管理器里的旧条目)都会变成无效值。本产品没有「忘记口令」的找回通道。`]}),(0,k.jsxs)(`div`,{className:`ov-field`,children:[(0,k.jsxs)(`label`,{htmlFor:`pw-confirm`,children:[`输入 `,(0,k.jsx)(`b`,{style:{color:`var(--text-secondary)`,fontWeight:500},children:`确认`}),` 以继续`]}),(0,k.jsx)(`input`,{id:`pw-confirm`,className:`field-input text`,style:{width:`100%`,fontFamily:`var(--font-mono)`},value:p,autoFocus:!0,placeholder:`确认`,onChange:e=>m(e.target.value)}),(0,k.jsx)(`div`,{className:`ov-hint`,children:`打错一个字就没法继续。重置入口凭证值得这一步。`})]}),v?(0,k.jsx)(g,{tone:`error`,children:v}):null]}):(0,k.jsxs)(T,{title:`重置管理口令`,onClose:r,footer:(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(`button`,{type:`button`,className:`btn btn-quiet btn-sm`,onClick:r,children:`取消`}),(0,k.jsxs)(`button`,{type:`button`,className:`btn btn-danger btn-sm`,onClick:()=>d(`confirm`),children:[(0,k.jsx)(e,{size:14}),`我明白,继续`]})]}),children:[(0,k.jsx)(F,{mode:o,onChange:e=>{s(e),y(null)}}),(0,k.jsxs)(`p`,{className:`ov-sub`,children:[`服务端会生成一个新的 16 位随机口令。`,(0,k.jsx)(`b`,{children:`新口令只显示一次`}),`,请准备好记录工具。`]}),(0,k.jsxs)(`div`,{className:`pw-warn-list`,children:[(0,k.jsxs)(`div`,{children:[(0,k.jsx)(`span`,{className:`pw-dot`}),(0,k.jsxs)(`span`,{children:[(0,k.jsx)(`b`,{children:`当前口令立即失效`}),` —— 但已登录的会话`,(0,k.jsx)(`b`,{children:`不受影响`}),`:会话由独立密钥 (RELAY_SECRET)签名,与口令本身无关。包括其它浏览器标签页在内的登录态, 都会保持有效直到各自过期。本版本未提供「改密强制所有会话下线」。`]})]}),(0,k.jsxs)(`div`,{children:[(0,k.jsx)(`span`,{className:`pw-dot`}),(0,k.jsxs)(`span`,{children:[(0,k.jsx)(`b`,{children:`没有找回通道`}),` —— 忘记新口令后,只能上服务器删除数据结构后重新引导。`]})]}),(0,k.jsxs)(`div`,{children:[(0,k.jsx)(`span`,{className:`pw-dot`}),(0,k.jsxs)(`span`,{children:[(0,k.jsx)(`b`,{children:`立即生效、无需重启`}),` —— 哈希写进数据库后立刻对后续登录起作用。`]})]})]}),(0,k.jsx)(`div`,{className:`ov-hint`,style:{marginTop:12},children:`想用自己的口令?切到上方「手动设定」—— 随机口令更安全,手动口令更好记,按需选择。`})]})}function F({mode:e,onChange:t}){return(0,k.jsxs)(`span`,{className:`seg-tabs`,role:`group`,"aria-label":`口令变更方式`,style:{marginBottom:14},children:[(0,k.jsx)(`button`,{type:`button`,className:e===`reset`?`on`:``,"aria-pressed":e===`reset`,onClick:()=>t(`reset`),children:`随机重置`}),(0,k.jsx)(`button`,{type:`button`,className:e===`manual`?`on`:``,"aria-pressed":e===`manual`,onClick:()=>t(`manual`),children:`手动设定`})]})}function I({spec:e,onClose:t,onDone:r}){let[i,a]=(0,O.useState)(``),[o,s]=(0,O.useState)(!1),[c,l]=(0,O.useState)(null),d=i===`确认`,p=async()=>{if(d&&!o){s(!0),l(null);try{r(await f.danger(e.action,i))}catch(e){l(e instanceof u?e:new u(String(e),0,0)),s(!1)}}};return(0,k.jsxs)(T,{title:e.title,onClose:t,footer:(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(`button`,{type:`button`,className:`btn btn-primary btn-sm`,onClick:t,children:`取消(保持现状)`}),(0,k.jsxs)(`button`,{type:`button`,className:`btn btn-danger btn-sm`,disabled:!d||o,onClick:()=>void p(),children:[o?(0,k.jsx)(n,{size:14}):null,o?`执行中…`:e.ok]})]}),children:[(0,k.jsx)(`p`,{className:`ov-sub`,children:e.body}),(0,k.jsxs)(`div`,{className:`ov-lose`,children:[(0,k.jsx)(`b`,{children:`会失去什么:`}),e.lose]}),(0,k.jsxs)(`div`,{className:`ov-field`,children:[(0,k.jsxs)(`label`,{htmlFor:`danger-confirm`,children:[`输入 `,(0,k.jsx)(`b`,{style:{color:`var(--text-secondary)`,fontWeight:500},children:`确认`}),` 以继续`]}),(0,k.jsx)(`input`,{id:`danger-confirm`,className:`field-input text`,style:{width:`100%`,fontFamily:`var(--font-mono)`},value:i,autoFocus:!0,placeholder:`确认`,onChange:e=>a(e.target.value)}),(0,k.jsx)(`div`,{className:`ov-hint`,children:`打错一个字就没法继续。破坏性操作值得这一步。`})]}),c?(0,k.jsx)(g,{tone:`error`,children:S(c)}):null]})}var L={"danger.clearLogs":{action:`clearLogs`,title:`清空全部日志?`,body:`删除后「按模型 / 按客户端」明细会一并归零。剩余积分不受影响,服务也不中断。`,lose:`将删除本机全部请求日志,覆盖保留天数内的所有记录,没有备份入口。`,ok:`确认清空`},"danger.resetKeys":{action:`resetKeys`,title:`重置全部密钥?`,body:`所有密钥会立即失效,每个客户端都要重新填一次。已消耗的积分不受影响。`,lose:`将失效全部 sk-waygate- 密钥,正在使用它们的客户端会立刻收到 401。`,ok:`确认重置`},"danger.restoreDefaults":{action:`restoreDefaults`,title:`恢复默认配置?`,body:`会用默认值覆盖 ~/.relay/config.yml。你改过的端口、并发、日志保留天数都会回到出厂值。`,lose:`将覆盖所有自定义配置,服务重启后生效。`,ok:`确认恢复`}},R={openai:`OpenAI 方言`,anthropic:`Anthropic 方言`,qoder:`COSY 协议`};function z(){let e=m(()=>f.providers(),[],{cacheKey:`providers`}),t=e.data?.items??[],[n,r]=(0,O.useState)(null),i=m(()=>f.providerGrowthPanel(n.id),[n?.id],{enabled:n!==null});return(0,k.jsxs)(v,{title:`提供商健康`,aside:(0,k.jsxs)(y,{children:[t.length,` 家 · 只读总览`]}),children:[e.initial&&e.loading?(0,k.jsx)(`div`,{className:`empty-note`,style:{padding:`8px 0`},children:`正在读取提供商…`}):e.error?(0,k.jsx)(`div`,{className:`empty-note`,style:{padding:`8px 0`},children:`提供商列表没取到,稍后重试。`}):t.length===0?(0,k.jsx)(`div`,{className:`empty-note`,style:{padding:`8px 0`},children:`还没有登记任何提供商 —— 到「提供商管理 → 提供商」新增。`}):(0,k.jsx)(`div`,{className:`tbl-scroll`,children:(0,k.jsxs)(`table`,{className:`tbl`,children:[(0,k.jsx)(`caption`,{className:`sr-only`,children:`各提供商的健康状态`}),(0,k.jsx)(`thead`,{children:(0,k.jsxs)(`tr`,{children:[(0,k.jsx)(`th`,{scope:`col`,children:`提供商`}),(0,k.jsx)(`th`,{scope:`col`,children:`协议`}),(0,k.jsx)(`th`,{scope:`col`,children:`凭证`}),(0,k.jsx)(`th`,{scope:`col`,children:`状态`}),(0,k.jsx)(`th`,{scope:`col`,className:`r`,children:`模型数`}),(0,k.jsx)(`th`,{scope:`col`,children:`积分 / 签到`})]})}),(0,k.jsx)(`tbody`,{children:t.map(e=>(0,k.jsxs)(`tr`,{children:[(0,k.jsx)(`td`,{className:`td-strong`,children:e.name}),(0,k.jsx)(`td`,{className:`td-sub`,children:R[e.protocol]??e.protocol}),(0,k.jsx)(`td`,{children:(0,k.jsx)(`span`,{className:`up-badge${e.configured?``:` warn`}`,children:e.configured?`有效`:`未配置`})}),(0,k.jsx)(`td`,{children:e.active?(0,k.jsx)(y,{tone:`live`,children:`已启用`}):(0,k.jsx)(y,{tone:`ghost`,children:`未启用`})}),(0,k.jsx)(`td`,{className:`r td-mono`,children:p(e.modelCount??0)}),(0,k.jsx)(`td`,{className:`td-sub td-mono`,children:e.credits?.available?(0,k.jsxs)(k.Fragment,{children:[`剩余 `,h(e.credits.remaining??0),e.credits.stale?`(偏旧)`:``]}):e.qoderCredits?(0,k.jsxs)(k.Fragment,{children:[e.qoderCredits.remaining===null?`余额未知`:`剩余 ${h(e.qoderCredits.remaining)}`,e.qoderCredits.lifetimeConsumed!==null&&e.qoderCredits.lifetimeConsumed!==void 0?(0,k.jsxs)(k.Fragment,{children:[` `,(0,k.jsx)(d,{content:`累计消耗 —— 这个账号近一年在该平台消耗掉的 credits 总量(账号级)。
1
+ import{D as e,J as t,S as n,f as r,it as i,l as a,p as o,tt as s,w as c,z as l}from"./vendor-befEYGHM.js";import{M as u,a as d,c as f,g as p,j as m,p as h,r as g}from"./index-nQeRK3kW.js";import{t as _}from"./accessUrl-DbL5DLDz.js";import{a as v,c as y,l as b,n as x,r as S,s as C,t as w}from"./Select-G6AhT0TA.js";import{t as T}from"./Modal-B-rIrvXS.js";import{t as E}from"./Drawer-CleQGhRU.js";import{t as D}from"./Switch-0KA1AbiV.js";var O=i(),k=s();function A({item:e,value:t,disabled:n,onChange:r}){if(e.type===`switch`)return(0,k.jsx)(D,{checked:!!t,disabled:n||e.readonly,label:e.label,onChange:e=>r(e)});if(e.type===`badge`)return(0,k.jsx)(b,{tone:`live`,children:String(t)});if(e.type===`select`){let i=(e.options??[]).map(e=>({value:e.value,label:e.label}));return(0,k.jsx)(w,{value:String(t),options:i,disabled:n||e.readonly,onChange:e=>r(e),width:188})}return e.type===`number`?(0,k.jsx)(`input`,{className:`field-input num`,type:`number`,value:t==null?``:String(t),disabled:n||e.readonly,onChange:e=>r(e.target.value===``?``:Number(e.target.value)),"aria-label":e.label}):e.type===`mapping`?null:(0,k.jsx)(`input`,{className:`field-input text`,value:t==null?``:String(t),disabled:n||e.readonly,onChange:e=>r(e.target.value),"aria-label":e.label})}function j(){let e=_(),[n,r]=(0,O.useState)(!1),i=async()=>{try{await navigator.clipboard.writeText(e),r(!0),window.setTimeout(()=>r(!1),1200)}catch{}};return(0,k.jsxs)(`div`,{className:`card access-card`,children:[(0,k.jsxs)(`div`,{className:`access-head`,children:[(0,k.jsxs)(`span`,{className:`access-title`,children:[(0,k.jsx)(c,{size:13,"aria-hidden":!0}),`接入地址`]}),(0,k.jsx)(`span`,{className:`access-sub`,children:`客户端与 API 同源 —— 这就是你当前访问控制台的地址`})]}),(0,k.jsxs)(`div`,{className:`key-plain access-url`,children:[(0,k.jsx)(`code`,{children:e}),(0,k.jsxs)(`button`,{type:`button`,className:`copy`,"aria-label":n?`已复制接入地址`:`复制接入地址`,onClick:()=>void i(),children:[n?(0,k.jsx)(t,{size:13}):(0,k.jsx)(l,{size:13}),n?`已复制`:`复制`]})]}),(0,k.jsxs)(`p`,{className:`chain-note`,children:[`客户端里要填两组值:`,(0,k.jsx)(`b`,{children:`base_url`}),` 就是上面这串;`,(0,k.jsx)(`b`,{children:`API Key`}),` 用你在本页`,(0,k.jsx)(`b`,{children:`新建的那把`}),(0,k.jsx)(`span`,{className:`code-chip`,children:`sk-waygate-…`}),`(明文只在创建时显示一次,丢了只能删掉重建)。`]}),(0,k.jsxs)(`div`,{className:`cred-note access-cert`,children:[(0,k.jsx)(a,{size:14,"aria-hidden":!0}),(0,k.jsxs)(`span`,{children:[`本服务的 TLS 是`,(0,k.jsx)(`b`,{children:`自签证书`}),`:客户端得先信任它的根证书,否则会以「证书错误」失败 —— 那`,(0,k.jsx)(`b`,{children:`不是`}),`地址填错。把根证书装进系统信任库,或让客户端通过`,(0,k.jsx)(`span`,{className:`code-chip`,children:`NODE_EXTRA_CA_CERTS`}),` /`,(0,k.jsx)(`span`,{className:`code-chip`,children:`SSL_CERT_FILE`}),`指向随部署产出的`,(0,k.jsx)(`span`,{className:`code-chip`,children:`relay-ca.crt`}),`。`]})]})]})}var M=8,N=128;function P({onClose:r,onDone:i}){let[o,s]=(0,O.useState)(`reset`),[c,d]=(0,O.useState)(`warn`),[p,m]=(0,O.useState)(``),[h,_]=(0,O.useState)(!1),[v,y]=(0,O.useState)(null),[b,x]=(0,O.useState)(null),[C,w]=(0,O.useState)(!1),[E,D]=(0,O.useState)(``),[A,j]=(0,O.useState)(``),[P,I]=(0,O.useState)(null),L=p===`确认`,R=async()=>{if(L&&!h){_(!0),y(null);try{let e=await f.resetAdminPassword();x(e),d(`result`)}catch(e){y(e instanceof u?S(e):String(e))}finally{_(!1)}}},z=async()=>{if(b)try{await navigator.clipboard.writeText(b.password),w(!0),window.setTimeout(()=>w(!1),2e3)}catch{y(`浏览器拒绝了剪贴板访问,请手动选中口令复制。`)}},B=()=>{x(null),D(``),j(``),i?.(),r()},V=async()=>{if(h)return;let e=E.trim();if(e.length===0){y(`管理口令不能为空或纯空白。`);return}if(e.length<M){y(`管理口令至少 ${M} 个字符,当前 ${e.length} 个。`);return}if(E.length>N){y(`管理口令最多 ${N} 个字符,当前 ${E.length} 个。`);return}if(E!==A){y(`两次输入不一致,请重新确认。`);return}_(!0),y(null);try{let e=await f.setAdminPassword(E);D(``),j(``),I(e.persisted?`已生效,下次登录用新口令。当前会话不受影响。`:`已生效(仅内存),下次登录用新口令 —— 但服务端数据库不可写,重启后会回到上一个口令。`)}catch(e){y(e instanceof u?S(e):String(e))}finally{_(!1)}};if(o===`manual`&&P)return(0,k.jsxs)(T,{title:`管理口令已更新`,onClose:B,footer:(0,k.jsx)(`button`,{type:`button`,className:`btn btn-primary btn-sm`,onClick:B,children:`知道了`}),children:[(0,k.jsx)(`div`,{className:`pw-note`,children:P}),(0,k.jsxs)(`p`,{className:`ov-sub`,style:{marginTop:12},children:[`服务端只存了口令的 scrypt 哈希,`,(0,k.jsx)(`b`,{children:`回不出明文`}),`。请确保你已经记住了刚才输入的口令。`]})]});if(o===`manual`){let t=E.trim().length>0&&E.trim().length<M,i=A.length>0&&E!==A;return(0,k.jsxs)(T,{title:`手动设定管理口令`,onClose:r,footer:(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(`button`,{type:`button`,className:`btn btn-quiet btn-sm`,onClick:r,children:`取消`}),(0,k.jsxs)(`button`,{type:`button`,className:`btn btn-primary btn-sm`,disabled:h||t||i||E.trim().length===0,onClick:()=>void V(),children:[h?(0,k.jsx)(n,{size:14}):(0,k.jsx)(e,{size:14}),h?`保存中…`:`保存并生效`]})]}),children:[(0,k.jsxs)(`p`,{className:`ov-sub`,children:[`设定一个你自己方便记忆的管理口令(至少 `,M,` 个字符)。 保存后`,(0,k.jsx)(`b`,{children:`立即生效、无需重启`}),`,当前会话不会被打断。`]}),(0,k.jsxs)(`div`,{className:`ov-field`,children:[(0,k.jsx)(`label`,{htmlFor:`pw-new`,children:`新管理口令`}),(0,k.jsx)(`input`,{id:`pw-new`,type:`password`,className:`field-input text`,style:{width:`100%`},value:E,autoFocus:!0,autoComplete:`new-password`,placeholder:`至少 ${M} 个字符`,onChange:e=>{D(e.target.value),y(null)}}),t?(0,k.jsxs)(`div`,{className:`ov-hint`,style:{color:`var(--warn-amber)`},children:[`至少 `,M,` 个字符,当前 `,E.trim().length,` 个。`]}):null]}),(0,k.jsxs)(`div`,{className:`ov-field`,children:[(0,k.jsx)(`label`,{htmlFor:`pw-new-confirm`,children:`再次输入`}),(0,k.jsx)(`input`,{id:`pw-new-confirm`,type:`password`,className:`field-input text`,style:{width:`100%`},value:A,autoComplete:`new-password`,placeholder:`重复上面输入的口令`,onChange:e=>{j(e.target.value),y(null)}}),i?(0,k.jsx)(`div`,{className:`ov-hint`,style:{color:`var(--warn-amber)`},children:`两次输入不一致。`}):null]}),(0,k.jsxs)(`div`,{className:`ov-lose`,children:[(0,k.jsx)(`b`,{children:`请记住它:`}),`设定后旧口令立即失效,且本产品没有「忘记口令」的找回通道。 口令明文不会保存在浏览器任何位置,也不会被回显。`]}),v?(0,k.jsx)(g,{tone:`error`,children:(0,k.jsx)(`span`,{style:{display:`block`,marginTop:14},children:v})}):null]})}return c===`result`&&b?(0,k.jsxs)(T,{title:`新管理口令`,onClose:B,footer:(0,k.jsx)(`button`,{type:`button`,className:`btn btn-primary btn-sm`,onClick:B,children:`我已保存,关闭`}),children:[(0,k.jsxs)(`div`,{className:`pw-once`,children:[(0,k.jsxs)(`div`,{className:`pw-once-head`,children:[(0,k.jsx)(a,{size:16}),(0,k.jsx)(`b`,{children:`这是唯一一次显示`})]}),(0,k.jsx)(`div`,{className:`pw-once-body`,children:`关闭这个窗口后,服务端也回不出这份明文 —— 库里只存了它的 scrypt 哈希。 请现在就复制并保存到你的密码管理器里。`})]}),(0,k.jsxs)(`div`,{className:`pw-plain`,children:[(0,k.jsx)(`code`,{children:b.password}),(0,k.jsxs)(`button`,{type:`button`,className:`btn btn-quiet btn-sm`,onClick:()=>void z(),children:[C?(0,k.jsx)(t,{size:14}):(0,k.jsx)(l,{size:14}),C?`已复制`:`复制`]})]}),b.persisted?(0,k.jsxs)(`div`,{className:`pw-note`,children:[`已写入服务端数据库,`,(0,k.jsx)(`b`,{children:`立即生效、无需重启`}),`,并会随每日备份一起保存。 下次登录请使用新口令。`]}):(0,k.jsx)(g,{tone:`warn`,children:(0,k.jsxs)(`span`,{style:{display:`block`,marginTop:14},children:[`服务端数据库不可写,新口令`,(0,k.jsx)(`b`,{children:`仅本次运行有效`}),`:重启后会回到旧口令。 请先修好数据目录权限,再重置一次。`]})}),v?(0,k.jsx)(g,{tone:`error`,children:(0,k.jsx)(`span`,{style:{display:`block`,marginTop:14},children:v})}):null]}):c===`confirm`?(0,k.jsxs)(T,{title:`确认重置管理口令?`,onClose:r,footer:(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(`button`,{type:`button`,className:`btn btn-primary btn-sm`,onClick:r,children:`取消(保持现状)`}),(0,k.jsxs)(`button`,{type:`button`,className:`btn btn-danger btn-sm`,disabled:!L||h,onClick:()=>void R(),children:[h?(0,k.jsx)(n,{size:14}):null,h?`重置中…`:`确认重置`]})]}),children:[(0,k.jsxs)(`p`,{className:`ov-sub`,children:[`重置后,`,(0,k.jsx)(`b`,{children:`当前口令立即失效`}),`。你正在使用的这个会话不会被打断,但下次登录必须用新口令。`]}),(0,k.jsxs)(`div`,{className:`ov-lose`,children:[(0,k.jsx)(`b`,{children:`会失去什么:`}),`旧口令的所有副本(笔记、密码管理器里的旧条目)都会变成无效值。本产品没有「忘记口令」的找回通道。`]}),(0,k.jsxs)(`div`,{className:`ov-field`,children:[(0,k.jsxs)(`label`,{htmlFor:`pw-confirm`,children:[`输入 `,(0,k.jsx)(`b`,{style:{color:`var(--text-secondary)`,fontWeight:500},children:`确认`}),` 以继续`]}),(0,k.jsx)(`input`,{id:`pw-confirm`,className:`field-input text`,style:{width:`100%`,fontFamily:`var(--font-mono)`},value:p,autoFocus:!0,placeholder:`确认`,onChange:e=>m(e.target.value)}),(0,k.jsx)(`div`,{className:`ov-hint`,children:`打错一个字就没法继续。重置入口凭证值得这一步。`})]}),v?(0,k.jsx)(g,{tone:`error`,children:v}):null]}):(0,k.jsxs)(T,{title:`重置管理口令`,onClose:r,footer:(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(`button`,{type:`button`,className:`btn btn-quiet btn-sm`,onClick:r,children:`取消`}),(0,k.jsxs)(`button`,{type:`button`,className:`btn btn-danger btn-sm`,onClick:()=>d(`confirm`),children:[(0,k.jsx)(e,{size:14}),`我明白,继续`]})]}),children:[(0,k.jsx)(F,{mode:o,onChange:e=>{s(e),y(null)}}),(0,k.jsxs)(`p`,{className:`ov-sub`,children:[`服务端会生成一个新的 16 位随机口令。`,(0,k.jsx)(`b`,{children:`新口令只显示一次`}),`,请准备好记录工具。`]}),(0,k.jsxs)(`div`,{className:`pw-warn-list`,children:[(0,k.jsxs)(`div`,{children:[(0,k.jsx)(`span`,{className:`pw-dot`}),(0,k.jsxs)(`span`,{children:[(0,k.jsx)(`b`,{children:`当前口令立即失效`}),` —— 但已登录的会话`,(0,k.jsx)(`b`,{children:`不受影响`}),`:会话由独立密钥 (RELAY_SECRET)签名,与口令本身无关。包括其它浏览器标签页在内的登录态, 都会保持有效直到各自过期。本版本未提供「改密强制所有会话下线」。`]})]}),(0,k.jsxs)(`div`,{children:[(0,k.jsx)(`span`,{className:`pw-dot`}),(0,k.jsxs)(`span`,{children:[(0,k.jsx)(`b`,{children:`没有找回通道`}),` —— 忘记新口令后,只能上服务器删除数据结构后重新引导。`]})]}),(0,k.jsxs)(`div`,{children:[(0,k.jsx)(`span`,{className:`pw-dot`}),(0,k.jsxs)(`span`,{children:[(0,k.jsx)(`b`,{children:`立即生效、无需重启`}),` —— 哈希写进数据库后立刻对后续登录起作用。`]})]})]}),(0,k.jsx)(`div`,{className:`ov-hint`,style:{marginTop:12},children:`想用自己的口令?切到上方「手动设定」—— 随机口令更安全,手动口令更好记,按需选择。`})]})}function F({mode:e,onChange:t}){return(0,k.jsxs)(`span`,{className:`seg-tabs`,role:`group`,"aria-label":`口令变更方式`,style:{marginBottom:14},children:[(0,k.jsx)(`button`,{type:`button`,className:e===`reset`?`on`:``,"aria-pressed":e===`reset`,onClick:()=>t(`reset`),children:`随机重置`}),(0,k.jsx)(`button`,{type:`button`,className:e===`manual`?`on`:``,"aria-pressed":e===`manual`,onClick:()=>t(`manual`),children:`手动设定`})]})}function I({spec:e,onClose:t,onDone:r}){let[i,a]=(0,O.useState)(``),[o,s]=(0,O.useState)(!1),[c,l]=(0,O.useState)(null),d=i===`确认`,p=async()=>{if(d&&!o){s(!0),l(null);try{r(await f.danger(e.action,i))}catch(e){l(e instanceof u?e:new u(String(e),0,0)),s(!1)}}};return(0,k.jsxs)(T,{title:e.title,onClose:t,footer:(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(`button`,{type:`button`,className:`btn btn-primary btn-sm`,onClick:t,children:`取消(保持现状)`}),(0,k.jsxs)(`button`,{type:`button`,className:`btn btn-danger btn-sm`,disabled:!d||o,onClick:()=>void p(),children:[o?(0,k.jsx)(n,{size:14}):null,o?`执行中…`:e.ok]})]}),children:[(0,k.jsx)(`p`,{className:`ov-sub`,children:e.body}),(0,k.jsxs)(`div`,{className:`ov-lose`,children:[(0,k.jsx)(`b`,{children:`会失去什么:`}),e.lose]}),(0,k.jsxs)(`div`,{className:`ov-field`,children:[(0,k.jsxs)(`label`,{htmlFor:`danger-confirm`,children:[`输入 `,(0,k.jsx)(`b`,{style:{color:`var(--text-secondary)`,fontWeight:500},children:`确认`}),` 以继续`]}),(0,k.jsx)(`input`,{id:`danger-confirm`,className:`field-input text`,style:{width:`100%`,fontFamily:`var(--font-mono)`},value:i,autoFocus:!0,placeholder:`确认`,onChange:e=>a(e.target.value)}),(0,k.jsx)(`div`,{className:`ov-hint`,children:`打错一个字就没法继续。破坏性操作值得这一步。`})]}),c?(0,k.jsx)(g,{tone:`error`,children:S(c)}):null]})}var L={"danger.clearLogs":{action:`clearLogs`,title:`清空全部日志?`,body:`删除后「按模型 / 按客户端」明细会一并归零。剩余积分不受影响,服务也不中断。`,lose:`将删除本机全部请求日志,覆盖保留天数内的所有记录,没有备份入口。`,ok:`确认清空`},"danger.resetKeys":{action:`resetKeys`,title:`重置全部密钥?`,body:`所有密钥会立即失效,每个客户端都要重新填一次。已消耗的积分不受影响。`,lose:`将失效全部 sk-waygate- 密钥,正在使用它们的客户端会立刻收到 401。`,ok:`确认重置`},"danger.restoreDefaults":{action:`restoreDefaults`,title:`恢复默认配置?`,body:`会用默认值覆盖 ~/.relay/config.yml。你改过的端口、并发、日志保留天数都会回到出厂值。`,lose:`将覆盖所有自定义配置,服务重启后生效。`,ok:`确认恢复`}},R={openai:`OpenAI 方言`,anthropic:`Anthropic 方言`,qoder:`COSY 协议`};function z(){let e=m(()=>f.providers(),[],{cacheKey:`providers`}),t=e.data?.items??[],[n,r]=(0,O.useState)(null),i=m(()=>f.providerGrowthPanel(n.id),[n?.id],{enabled:n!==null});return(0,k.jsxs)(v,{title:`提供商健康`,aside:(0,k.jsxs)(y,{children:[t.length,` 家 · 只读总览`]}),children:[e.initial&&e.loading?(0,k.jsx)(`div`,{className:`empty-note`,style:{padding:`8px 0`},children:`正在读取提供商…`}):e.error?(0,k.jsx)(`div`,{className:`empty-note`,style:{padding:`8px 0`},children:`提供商列表没取到,稍后重试。`}):t.length===0?(0,k.jsx)(`div`,{className:`empty-note`,style:{padding:`8px 0`},children:`还没有登记任何提供商 —— 到「提供商管理 → 提供商」新增。`}):(0,k.jsx)(`div`,{className:`tbl-scroll`,children:(0,k.jsxs)(`table`,{className:`tbl`,children:[(0,k.jsx)(`caption`,{className:`sr-only`,children:`各提供商的健康状态`}),(0,k.jsx)(`thead`,{children:(0,k.jsxs)(`tr`,{children:[(0,k.jsx)(`th`,{scope:`col`,children:`提供商`}),(0,k.jsx)(`th`,{scope:`col`,children:`协议`}),(0,k.jsx)(`th`,{scope:`col`,children:`凭证`}),(0,k.jsx)(`th`,{scope:`col`,children:`状态`}),(0,k.jsx)(`th`,{scope:`col`,className:`r`,children:`模型数`}),(0,k.jsx)(`th`,{scope:`col`,children:`积分 / 签到`})]})}),(0,k.jsx)(`tbody`,{children:t.map(e=>(0,k.jsxs)(`tr`,{children:[(0,k.jsx)(`td`,{className:`td-strong`,children:e.name}),(0,k.jsx)(`td`,{className:`td-sub`,children:R[e.protocol]??e.protocol}),(0,k.jsx)(`td`,{children:(0,k.jsx)(`span`,{className:`up-badge${e.configured?``:` warn`}`,children:e.configured?`有效`:`未配置`})}),(0,k.jsx)(`td`,{children:e.active?(0,k.jsx)(y,{tone:`live`,children:`已启用`}):(0,k.jsx)(y,{tone:`ghost`,children:`未启用`})}),(0,k.jsx)(`td`,{className:`r td-mono`,children:p(e.modelCount??0)}),(0,k.jsx)(`td`,{className:`td-sub td-mono`,children:e.credits?.available?(0,k.jsxs)(k.Fragment,{children:[`剩余 `,h(e.credits.remaining??0),e.credits.consumed===null?null:(0,k.jsxs)(k.Fragment,{children:[` `,(0,k.jsx)(d,{content:`已消耗 / 累计发放 —— 账户级全部历史(含官方客户端直连的用量)。
2
+ 不是本服务转发的那部分,与剩余不是同一种量。`,children:(0,k.jsxs)(`span`,{className:`credit-aside`,children:[`已消耗 `,h(e.credits.consumed),e.credits.granted===null?``:` / 发放 ${h(e.credits.granted)}`]})})]}),e.credits.stale?`(偏旧)`:``]}):e.qoderCredits?(0,k.jsxs)(k.Fragment,{children:[e.qoderCredits.remaining===null?`余额未知`:`剩余 ${h(e.qoderCredits.remaining)}`,e.qoderCredits.lifetimeConsumed!==null&&e.qoderCredits.lifetimeConsumed!==void 0?(0,k.jsxs)(k.Fragment,{children:[` `,(0,k.jsx)(d,{content:`累计消耗 —— 这个账号近一年在该平台消耗掉的 credits 总量(账号级)。
2
3
  它不是当前余额,也不是本服务转发的那部分:含官方客户端直连的用量。
3
- 数值等于每日消耗热力图近 371 天之和。`,children:(0,k.jsxs)(`span`,{className:`credit-aside`,children:[`累计消耗 `,h(e.qoderCredits.lifetimeConsumed)]})})]}):null,e.qoderCredits.stale?`(偏旧)`:``,e.signin?.streak?`(连续活跃 ${p(e.signin.streak)} 天)`:``]}):e.wbCredits?(0,k.jsxs)(k.Fragment,{children:[`剩余 `,h(e.wbCredits.remaining??0),e.wbSignin?.streak?`(连签 ${p(e.wbSignin.streak)} 天)`:``]}):e.signin?.checkedOn?(0,k.jsxs)(k.Fragment,{children:[`今日已签到`,e.signin.lastPoints?` +${p(e.signin.lastPoints)}`:``]}):e.wbSignin?.checkedOn?(0,k.jsxs)(k.Fragment,{children:[`今日已签到`,e.wbSignin.lastPoints?` +${p(e.wbSignin.lastPoints)}`:``]}):`—`}),(0,k.jsx)(`td`,{children:e.protocol===`openai`&&e.wbOAuth?.configured?(0,k.jsx)(d,{content:`查看成长任务的完成情况(进度/奖励/状态,只读)`,children:(0,k.jsx)(`button`,{type:`button`,className:`mini-pill`,onClick:()=>r(e),children:`任务`})}):(0,k.jsx)(`span`,{className:`td-sub`,children:`—`})})]},e.id))})]})}),(0,k.jsxs)(`ul`,{className:`ph-notes`,children:[(0,k.jsxs)(`li`,{children:[(0,k.jsx)(`b`,{children:`积分口径(三家各不同)`}),`:本表「积分」列都取`,(0,k.jsx)(`b`,{children:`上游真实余额`}),`,非本地推算。 MiniMax Code 来自 `,(0,k.jsx)(`span`,{className:`code-chip`,children:`credit/details`}),`(余额/已用/累计发放齐全,精确到 0.01); WorkBuddy 来自资源包聚合 `,(0,k.jsx)(`span`,{className:`code-chip`,children:`get-user-resource`}),`(剩余/发放为包级真实数); Qoder CN 来自 `,(0,k.jsx)(`span`,{className:`code-chip`,children:`v2/me/usage`}),`(套餐内 + 资源包合计 —— 签到赠送的 Credits 进资源包,故签完此处会上涨)。`,(0,k.jsx)(`b`,{children:`到期时刻仅 Qoder 不提供`}),`(上游无此字段), 概览「积分账本」对应列显示 `,(0,k.jsx)(`span`,{className:`code-chip`,children:`—`}),`。 另一种「累计消耗」是`,(0,k.jsx)(`b`,{children:`账号级近一年消耗总量`}),`(含官方客户端直连),与余额不是一回事, 两者不混算。`]}),(0,k.jsxs)(`li`,{children:[(0,k.jsx)(`b`,{children:`每日签到`}),`:MiniMax Code 由本服务每天 08:05 后自动代签(OAuth 链)。WorkBuddy 分两档: 已导入桌面端 OAuth 凭证的(提供商管理 → 提供商 → 导入OAuth)每天 08:05 `,(0,k.jsx)(`b`,{children:`自动代领`}),`签到 + 成长任务 + 连登兑换;未导入的只做状态同步(上游不允许 API 密钥代领,403 实证)。 OAuth 与转发用的 API 密钥互不影响(实验实证多会话共存,桌面端不受干扰)。成长任务的 完成情况点本表「任务」查看(未完成的需在官方客户端真实使用后才能领)。`]}),(0,k.jsxs)(`li`,{children:[(0,k.jsx)(`b`,{children:`凭证口径(两家不同)`}),`:`,(0,k.jsx)(`b`,{children:`MiniMax Code 是真互斥`}),` —— refresh token 一次性,且「同一账号同时只有一个有效会话」, 桌面客户端登录会把本服务顶下线,反之亦然;`,(0,k.jsx)(`b`,{children:`建议给本服务用专用账号`}),`。`,(0,k.jsx)(`b`,{children:`Qoder CN 不互斥`}),` —— 支持多会话并存,本服务与桌面客户端可同时用同一账号(实测 2026-10-16),`,(0,k.jsx)(`b`,{children:`无需`}),`专用账号。任一凭证失效时到「提供商管理 → 提供商」重新导入。`]}),(0,k.jsxs)(`li`,{children:[(0,k.jsx)(`b`,{children:`Qoder 零内容断流自动重试`}),`:Qoder 网关在大上下文时偶发「返回 200 但零字节即断开」, 本服务会自动重发一次(最多 1 次,对客户端无感 —— 重试发生在响应提交之前)。 请求日志里记 `,(0,k.jsx)(`span`,{className:`code-chip`,children:`retry_count`}),` 与 `,(0,k.jsx)(`span`,{className:`code-chip`,children:`retried`}),`。`]}),(0,k.jsxs)(`li`,{children:[(0,k.jsx)(`b`,{children:`提供商归属的已知限制`}),`:请求表不记录「这条走的是哪家」,提供商归属按`,(0,k.jsx)(`b`,{children:`模型 id → 目录`}),`推断。因此同名的模型 id 分属两家时归属可能不准; 请求日志的「提供商」列也是用同一推断口径。`]})]}),n?(0,k.jsx)(E,{title:`成长任务 · ${n.name}`,subtitle:`完成态与奖励(上游实时只读;未完成的需在官方客户端真实使用后才能领)`,onClose:()=>r(null),children:(0,k.jsxs)(`div`,{className:`drawer-body`,children:[i.initial&&i.loading?(0,k.jsx)(`div`,{className:`empty-note`,children:`正在读取任务面板…`}):i.error||!i.data?.ok?(0,k.jsx)(`div`,{className:`empty-note`,children:i.error?.message??i.data?.message??`任务面板没取到,稍后重试。`}):(0,k.jsx)(`div`,{style:{maxHeight:`min(68vh, 640px)`,overflow:`auto`},children:(0,k.jsxs)(`table`,{className:`tbl`,style:{minWidth:480},children:[(0,k.jsx)(`caption`,{className:`sr-only`,children:`成长任务完成情况`}),(0,k.jsx)(`thead`,{children:(0,k.jsxs)(`tr`,{children:[(0,k.jsx)(`th`,{scope:`col`,children:`任务`}),(0,k.jsx)(`th`,{scope:`col`,style:{width:56},children:`进度`}),(0,k.jsx)(`th`,{scope:`col`,className:`r`,style:{width:84},children:`奖励`}),(0,k.jsx)(`th`,{scope:`col`,style:{width:72},children:`状态`})]})}),(0,k.jsx)(`tbody`,{children:i.data.tasks.map(e=>(0,k.jsxs)(`tr`,{children:[(0,k.jsx)(`td`,{style:{maxWidth:104},children:(0,k.jsx)(d,{content:e.desc?`${e.title??e.code} —— ${e.desc}`:e.title??e.code,children:(0,k.jsx)(`span`,{className:`td-strong`,style:{display:`inline-block`,maxWidth:`100%`,whiteSpace:`nowrap`,overflow:`hidden`,textOverflow:`ellipsis`,verticalAlign:`bottom`},children:e.title??e.code})})}),(0,k.jsx)(`td`,{className:`td-mono`,children:e.progress?`${e.progress.current}/${e.progress.target}`:`—`}),(0,k.jsx)(`td`,{className:`r td-mono`,children:e.rewardCredit?`${e.rewardCredit} 积分`:`—`}),(0,k.jsx)(`td`,{children:e.status===`claimed`?(0,k.jsx)(y,{tone:`live`,children:`已领取`}):e.status===`in_progress`?(0,k.jsx)(y,{tone:`amber`,children:`进行中`}):e.locked?(0,k.jsx)(y,{tone:`ghost`,children:`未解锁`}):(0,k.jsx)(y,{tone:`ghost`,children:`待完成`})})]},e.code))})]})}),(0,k.jsx)(`div`,{className:`footer-note`,children:`每天 08:05 自动代领一轮(签到 + 已完成的任务 + 连登兑换);这里的数据来自上游任务面板,实时只读。`})]})}):null]})}var B=new Set([`credential.source`,`credential.status`]),V={service:`ghost`,credential:`cyan`,quota:`amber`,limits:`rose`,logs:`ghost`,password:`amber`,danger:`amber`,mapping:`cyan`};function H(){let t=m(()=>f.settings(),[],{cacheKey:`settings`}),[n,i]=(0,O.useState)({}),[a,s]=(0,O.useState)(!1),[c,l]=(0,O.useState)(null),[d,p]=(0,O.useState)(null),[h,_]=(0,O.useState)(null),[b,w]=(0,O.useState)(null),[T,E]=(0,O.useState)(!1),[D,A]=(0,O.useState)(null),[M,N]=(0,O.useState)(`access`),F=t.data?.groups??[],R=(0,O.useMemo)(()=>{let e=[{id:`access`,label:`接入地址`,tone:`cyan`}];for(let t of F)t.id!==`mapping`&&e.push({id:t.id,label:t.label,tone:V[t.id]??`ghost`});return e.push({id:`password`,label:`管理口令`,tone:`amber`}),e.push({id:`mapping`,label:`键位映射`,tone:`cyan`}),e},[F]),H=(0,O.useMemo)(()=>{let e={};for(let t of F){let r=0;for(let e of t.items)B.has(e.key)||e.readonly||e.type===`action`||e.type===`mapping`||e.key in n&&n[e.key]!==e.value&&(r+=1);r>0&&(e[t.id]=r)}return e},[F,n]),W=(e,t)=>e in n?n[e]:t,G=(0,O.useMemo)(()=>{if(!t.data)return[];let e=[];return t.data.groups.forEach(t=>t.items.forEach(t=>{B.has(t.key)||t.readonly||t.type===`action`||t.type===`mapping`||t.key in n&&n[t.key]!==t.value&&e.push({key:t.key,value:n[t.key]})})),e},[t.data,n]),K=async()=>{if(!(G.length===0||a)){s(!0),l(null),p(null);try{let e=await f.putSettings(G);i({}),p(e.requiresRestart?`已应用 ${e.applied} 项,配置版本 → v${e.version}。其中含需重启才生效的项。`:`已应用 ${e.applied} 项,配置版本 → v${e.version}。`),setTimeout(()=>p(null),4e3),t.reload()}catch(e){l(e instanceof u?e:new u(String(e),0,0))}finally{s(!1)}}},q=e=>{let n=e.affected.logs??e.affected.keys??0;w(`操作已完成,影响 ${n} 条记录。`),setTimeout(()=>w(null),4e3),_(null),t.reload()},J=F.find(e=>e.id===`mapping`)?.items[0],Y=F.find(e=>e.id===M),X=F.find(e=>e.id===`danger`)?.items??[];return(0,k.jsxs)(`div`,{className:`view on`,children:[(0,k.jsx)(C,{title:`设置`,status:t.data?(0,k.jsx)(y,{tone:G.length?`amber`:`ghost`,dot:G.length>0,children:G.length?`${G.length} 项待保存`:`配置版本 v${t.data.version}`}):null,actions:(0,k.jsxs)(k.Fragment,{children:[G.length?(0,k.jsxs)(`button`,{type:`button`,className:`btn btn-quiet btn-sm`,onClick:()=>i({}),children:[(0,k.jsx)(o,{size:14}),`放弃改动`]}):null,(0,k.jsxs)(`button`,{type:`button`,className:`btn btn-primary btn-sm`,disabled:G.length===0||a,onClick:()=>void K(),children:[(0,k.jsx)(r,{size:14}),a?`保存中…`:`保存`]})]})}),(0,k.jsxs)(`div`,{className:`view-body stack`,children:[c?(0,k.jsx)(g,{tone:`error`,children:S(c)}):null,d?(0,k.jsx)(g,{tone:`success`,children:d}):null,b?(0,k.jsx)(g,{tone:`success`,children:b}):null,D?(0,k.jsx)(g,{tone:`success`,children:D}):null,(0,k.jsxs)(`div`,{className:`settings-split`,children:[(0,k.jsx)(`nav`,{className:`settings-nav`,"aria-label":`设置分组`,children:R.map(e=>{let t=H[e.id]??0;return(0,k.jsxs)(`button`,{type:`button`,className:`settings-nav-i${M===e.id?` on`:``}`,"aria-current":M===e.id?`page`:void 0,onClick:()=>N(e.id),children:[(0,k.jsx)(`span`,{className:`settings-nav-label`,children:e.label}),t>0?(0,k.jsx)(`span`,{className:`settings-nav-dirty`,children:t}):null]},e.id)})}),(0,k.jsx)(`div`,{className:`settings-content`,children:t.initial&&t.loading?(0,k.jsx)(v,{children:(0,k.jsx)(x,{kind:`loading`,title:`正在读取配置…`})}):t.error?(0,k.jsx)(v,{children:(0,k.jsx)(x,{kind:`error`,title:`配置没取到`,detail:S(t.error),onRetry:t.reload})}):(0,k.jsxs)(k.Fragment,{children:[M===`access`?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(j,{}),(0,k.jsx)(z,{})]}):null,M===`password`?(0,k.jsxs)(`div`,{className:`card`,children:[(0,k.jsxs)(`div`,{className:`group-head`,children:[(0,k.jsxs)(`h3`,{children:[(0,k.jsx)(e,{size:14,style:{verticalAlign:-2,marginRight:6}}),`管理口令`]}),(0,k.jsx)(`p`,{children:`控制台的唯一入口凭证`})]}),(0,k.jsxs)(`div`,{className:`set-row`,children:[(0,k.jsxs)(`div`,{className:`info`,children:[(0,k.jsx)(`b`,{children:`管理口令`}),(0,k.jsxs)(`span`,{children:[`两种改法:`,(0,k.jsx)(`b`,{children:`随机重置`}),`由服务端生成 16 位新口令(更强,但需当场保存);`,(0,k.jsx)(`b`,{children:`手动设定`}),`由你输入一个方便记忆的口令(至少 8 个字符)。 两种都立即生效、无需重启;新口令不回显、不落浏览器任何位置。`]})]}),(0,k.jsx)(`div`,{className:`ctl`,children:(0,k.jsxs)(`button`,{type:`button`,className:`btn btn-quiet btn-sm`,disabled:a,onClick:()=>E(!0),children:[(0,k.jsx)(e,{size:13}),`修改`]})})]})]}):null,M===`danger`?(0,k.jsxs)(`div`,{className:`card danger-zone`,children:[(0,k.jsxs)(`div`,{className:`group-head`,children:[(0,k.jsx)(`h3`,{style:{color:`var(--warn-amber)`},children:`危险操作`}),(0,k.jsx)(`p`,{children:`不可撤销,需二次确认`})]}),X.map(e=>(0,k.jsxs)(`div`,{className:`set-row`,children:[(0,k.jsxs)(`div`,{className:`info`,children:[(0,k.jsx)(`b`,{children:e.label}),(0,k.jsx)(`span`,{children:e.why})]}),(0,k.jsx)(`div`,{className:`ctl`,children:(0,k.jsx)(`button`,{type:`button`,className:`mini-pill danger`,disabled:a,onClick:()=>_(L[e.key]??null),children:e.label})})]},e.key))]}):null,M===`mapping`&&J?.type===`mapping`?(0,k.jsxs)(v,{title:J.label,aside:(0,k.jsx)(y,{children:`config.yml`}),children:[(0,k.jsx)(`div`,{className:`code`,style:{fontSize:12},children:Object.entries(J.value??{}).map(([e,t])=>(0,k.jsxs)(`div`,{children:[(0,k.jsx)(`span`,{className:`k`,children:e}),` → `,(0,k.jsx)(`span`,{className:`st`,children:t})]},e))}),(0,k.jsx)(`div`,{className:`footer-note`,children:J.why})]}):null,Y&&Y.id!==`danger`&&Y.id!==`mapping`?(0,k.jsx)(U,{group:Y,saving:a,valueOf:W,onChange:(e,t)=>i(n=>({...n,[e]:t}))}):null]})})]})]}),h?(0,k.jsx)(I,{spec:h,onClose:()=>_(null),onDone:q}):null,T?(0,k.jsx)(P,{onClose:()=>E(!1),onDone:()=>{A(`管理口令已更新并立即生效。下次登录请使用新口令。`),setTimeout(()=>A(null),4e3),t.reload()}}):null]})}function U({group:e,saving:t,valueOf:n,onChange:r}){let i=e.items.filter(e=>!B.has(e.key));if(i.length===0)return null;let a=i.filter(e=>!e.noop),o=i.filter(e=>e.noop);return(0,k.jsxs)(`div`,{className:`card`,children:[(0,k.jsxs)(`div`,{className:`group-head`,children:[(0,k.jsx)(`h3`,{children:e.label}),(0,k.jsx)(`p`,{children:W(e.id)})]}),a.map(e=>(0,k.jsx)(G,{item:e,value:n(e.key,e.value),saving:t,onChange:t=>r(e.key,t)},e.key)),o.length>0?(0,k.jsxs)(`details`,{className:`dormant`,children:[(0,k.jsxs)(`summary`,{children:[o.length,` 项暂未生效`,(0,k.jsx)(`span`,{children:`改了不会有任何变化 —— 依赖的功能未实现或上游未供货`})]}),o.map(e=>(0,k.jsx)(G,{item:e,value:n(e.key,e.value),saving:t,onChange:t=>r(e.key,t)},e.key))]}):null]})}function W(e){return{service:`进程监听与启动方式`,credential:`跨提供商的全局策略(部分项仅对 WorkBuddy 生效)`,quota:`积分口径与额度轮询(仅 WorkBuddy;MiniMax 走独立账本,Qoder 无端点)`,signin:`每日 08:05 自动签到(WorkBuddy 可关;MiniMax 恒开,Qoder 无签到)`,limits:`自用场景的保护,而非配额限制`,logs:`留在本机,不参与同步`}[e]??``}function G({item:e,value:t,saving:n,onChange:r}){return(0,k.jsxs)(`div`,{className:`set-row`,children:[(0,k.jsxs)(`div`,{className:`info`,children:[(0,k.jsxs)(`b`,{children:[e.label,e.requiresRestart?(0,k.jsx)(`span`,{style:{marginLeft:8,fontSize:10.5,color:`var(--warn-amber)`},children:`需重启`}):null]}),(0,k.jsx)(`span`,{children:e.why})]}),(0,k.jsx)(`div`,{className:`ctl`,children:(0,k.jsx)(A,{item:e,value:t,disabled:n,onChange:r})})]})}export{H as SettingsPage};
4
+ 数值等于每日消耗热力图近 371 天之和。`,children:(0,k.jsxs)(`span`,{className:`credit-aside`,children:[`累计消耗 `,h(e.qoderCredits.lifetimeConsumed),e.qoderCredits.granted===null?``:` / 发放 ${h(e.qoderCredits.granted)}`]})})]}):null,e.qoderCredits.stale?`(偏旧)`:``,e.signin?.streak?`(连续活跃 ${p(e.signin.streak)} 天)`:``]}):e.wbCredits?(0,k.jsxs)(k.Fragment,{children:[`剩余 `,h(e.wbCredits.remaining??0),e.wbCredits.consumed===null?null:(0,k.jsxs)(k.Fragment,{children:[` `,(0,k.jsx)(d,{content:`已消耗 / 累计发放 —— 账户全部资源包的历史合计(含已过期包、
5
+ 含官方客户端直连的用量)。剩余只统计未过期包,两者口径不同。`,children:(0,k.jsxs)(`span`,{className:`credit-aside`,children:[`已消耗 `,h(e.wbCredits.consumed),e.wbCredits.granted===null?``:` / 发放 ${h(e.wbCredits.granted)}`]})})]}),e.wbSignin?.streak?`(连签 ${p(e.wbSignin.streak)} 天)`:``]}):e.signin?.checkedOn?(0,k.jsxs)(k.Fragment,{children:[`今日已签到`,e.signin.lastPoints?` +${p(e.signin.lastPoints)}`:``]}):e.wbSignin?.checkedOn?(0,k.jsxs)(k.Fragment,{children:[`今日已签到`,e.wbSignin.lastPoints?` +${p(e.wbSignin.lastPoints)}`:``]}):`—`}),(0,k.jsx)(`td`,{children:e.protocol===`openai`&&e.wbOAuth?.configured?(0,k.jsx)(d,{content:`查看成长任务的完成情况(进度/奖励/状态,只读)`,children:(0,k.jsx)(`button`,{type:`button`,className:`mini-pill`,onClick:()=>r(e),children:`任务`})}):(0,k.jsx)(`span`,{className:`td-sub`,children:`—`})})]},e.id))})]})}),(0,k.jsxs)(`ul`,{className:`ph-notes`,children:[(0,k.jsxs)(`li`,{children:[(0,k.jsx)(`b`,{children:`积分口径(三家各不同)`}),`:本表「积分」列都取`,(0,k.jsx)(`b`,{children:`上游真实余额`}),`,非本地推算。 MiniMax Code 来自 `,(0,k.jsx)(`span`,{className:`code-chip`,children:`credit/details`}),`(余额/已用/累计发放齐全,精确到 0.01); WorkBuddy 来自资源包聚合 `,(0,k.jsx)(`span`,{className:`code-chip`,children:`get-user-resource`}),`(剩余/发放为包级真实数); Qoder CN 来自 `,(0,k.jsx)(`span`,{className:`code-chip`,children:`v2/me/usage`}),`(套餐内 + 资源包合计 —— 签到赠送的 Credits 进资源包,故签完此处会上涨)。`,(0,k.jsx)(`b`,{children:`到期时刻仅 Qoder 不提供`}),`(上游无此字段), 概览「积分账本」对应列显示 `,(0,k.jsx)(`span`,{className:`code-chip`,children:`—`}),`。 另一种「累计消耗」是`,(0,k.jsx)(`b`,{children:`账号级近一年消耗总量`}),`(含官方客户端直连),与余额不是一回事, 两者不混算。`]}),(0,k.jsxs)(`li`,{children:[(0,k.jsx)(`b`,{children:`每日签到`}),`:MiniMax Code 由本服务每天 08:05 后自动代签(OAuth 链)。WorkBuddy 分两档: 已导入桌面端 OAuth 凭证的(提供商管理 → 提供商 → 导入OAuth)每天 08:05 `,(0,k.jsx)(`b`,{children:`自动代领`}),`签到 + 成长任务 + 连登兑换;未导入的只做状态同步(上游不允许 API 密钥代领,403 实证)。 OAuth 与转发用的 API 密钥互不影响(实验实证多会话共存,桌面端不受干扰)。成长任务的 完成情况点本表「任务」查看(未完成的需在官方客户端真实使用后才能领)。`]}),(0,k.jsxs)(`li`,{children:[(0,k.jsx)(`b`,{children:`凭证口径(两家不同)`}),`:`,(0,k.jsx)(`b`,{children:`MiniMax Code 是真互斥`}),` —— refresh token 一次性,且「同一账号同时只有一个有效会话」, 桌面客户端登录会把本服务顶下线,反之亦然;`,(0,k.jsx)(`b`,{children:`建议给本服务用专用账号`}),`。`,(0,k.jsx)(`b`,{children:`Qoder CN 不互斥`}),` —— 支持多会话并存,本服务与桌面客户端可同时用同一账号(实测 2026-10-16),`,(0,k.jsx)(`b`,{children:`无需`}),`专用账号。任一凭证失效时到「提供商管理 → 提供商」重新导入。`]}),(0,k.jsxs)(`li`,{children:[(0,k.jsx)(`b`,{children:`Qoder 零内容断流自动重试`}),`:Qoder 网关在大上下文时偶发「返回 200 但零字节即断开」, 本服务会自动重发一次(最多 1 次,对客户端无感 —— 重试发生在响应提交之前)。 请求日志里记 `,(0,k.jsx)(`span`,{className:`code-chip`,children:`retry_count`}),` 与 `,(0,k.jsx)(`span`,{className:`code-chip`,children:`retried`}),`。`]}),(0,k.jsxs)(`li`,{children:[(0,k.jsx)(`b`,{children:`提供商归属的已知限制`}),`:请求表不记录「这条走的是哪家」,提供商归属按`,(0,k.jsx)(`b`,{children:`模型 id → 目录`}),`推断。因此同名的模型 id 分属两家时归属可能不准; 请求日志的「提供商」列也是用同一推断口径。`]})]}),n?(0,k.jsx)(E,{title:`成长任务 · ${n.name}`,subtitle:`完成态与奖励(上游实时只读;未完成的需在官方客户端真实使用后才能领)`,onClose:()=>r(null),children:(0,k.jsxs)(`div`,{className:`drawer-body`,children:[i.initial&&i.loading?(0,k.jsx)(`div`,{className:`empty-note`,children:`正在读取任务面板…`}):i.error||!i.data?.ok?(0,k.jsx)(`div`,{className:`empty-note`,children:i.error?.message??i.data?.message??`任务面板没取到,稍后重试。`}):(0,k.jsx)(`div`,{style:{maxHeight:`min(68vh, 640px)`,overflow:`auto`},children:(0,k.jsxs)(`table`,{className:`tbl`,style:{minWidth:480},children:[(0,k.jsx)(`caption`,{className:`sr-only`,children:`成长任务完成情况`}),(0,k.jsx)(`thead`,{children:(0,k.jsxs)(`tr`,{children:[(0,k.jsx)(`th`,{scope:`col`,children:`任务`}),(0,k.jsx)(`th`,{scope:`col`,style:{width:56},children:`进度`}),(0,k.jsx)(`th`,{scope:`col`,className:`r`,style:{width:84},children:`奖励`}),(0,k.jsx)(`th`,{scope:`col`,style:{width:72},children:`状态`})]})}),(0,k.jsx)(`tbody`,{children:i.data.tasks.map(e=>(0,k.jsxs)(`tr`,{children:[(0,k.jsx)(`td`,{style:{maxWidth:104},children:(0,k.jsx)(d,{content:e.desc?`${e.title??e.code} —— ${e.desc}`:e.title??e.code,children:(0,k.jsx)(`span`,{className:`td-strong`,style:{display:`inline-block`,maxWidth:`100%`,whiteSpace:`nowrap`,overflow:`hidden`,textOverflow:`ellipsis`,verticalAlign:`bottom`},children:e.title??e.code})})}),(0,k.jsx)(`td`,{className:`td-mono`,children:e.progress?`${e.progress.current}/${e.progress.target}`:`—`}),(0,k.jsx)(`td`,{className:`r td-mono`,children:e.rewardCredit?`${e.rewardCredit} 积分`:`—`}),(0,k.jsx)(`td`,{children:e.status===`claimed`?(0,k.jsx)(y,{tone:`live`,children:`已领取`}):e.status===`in_progress`?(0,k.jsx)(y,{tone:`amber`,children:`进行中`}):e.locked?(0,k.jsx)(y,{tone:`ghost`,children:`未解锁`}):(0,k.jsx)(y,{tone:`ghost`,children:`待完成`})})]},e.code))})]})}),(0,k.jsx)(`div`,{className:`footer-note`,children:`每天 08:05 自动代领一轮(签到 + 已完成的任务 + 连登兑换);这里的数据来自上游任务面板,实时只读。`})]})}):null]})}var B=new Set([`credential.source`,`credential.status`]),V={service:`ghost`,credential:`cyan`,quota:`amber`,limits:`rose`,logs:`ghost`,password:`amber`,danger:`amber`,mapping:`cyan`};function H(){let t=m(()=>f.settings(),[],{cacheKey:`settings`}),[n,i]=(0,O.useState)({}),[a,s]=(0,O.useState)(!1),[c,l]=(0,O.useState)(null),[d,p]=(0,O.useState)(null),[h,_]=(0,O.useState)(null),[b,w]=(0,O.useState)(null),[T,E]=(0,O.useState)(!1),[D,A]=(0,O.useState)(null),[M,N]=(0,O.useState)(`access`),F=t.data?.groups??[],R=(0,O.useMemo)(()=>{let e=[{id:`access`,label:`接入地址`,tone:`cyan`}];for(let t of F)t.id!==`mapping`&&e.push({id:t.id,label:t.label,tone:V[t.id]??`ghost`});return e.push({id:`password`,label:`管理口令`,tone:`amber`}),e.push({id:`mapping`,label:`键位映射`,tone:`cyan`}),e},[F]),H=(0,O.useMemo)(()=>{let e={};for(let t of F){let r=0;for(let e of t.items)B.has(e.key)||e.readonly||e.type===`action`||e.type===`mapping`||e.key in n&&n[e.key]!==e.value&&(r+=1);r>0&&(e[t.id]=r)}return e},[F,n]),W=(e,t)=>e in n?n[e]:t,G=(0,O.useMemo)(()=>{if(!t.data)return[];let e=[];return t.data.groups.forEach(t=>t.items.forEach(t=>{B.has(t.key)||t.readonly||t.type===`action`||t.type===`mapping`||t.key in n&&n[t.key]!==t.value&&e.push({key:t.key,value:n[t.key]})})),e},[t.data,n]),K=async()=>{if(!(G.length===0||a)){s(!0),l(null),p(null);try{let e=await f.putSettings(G);i({}),p(e.requiresRestart?`已应用 ${e.applied} 项,配置版本 → v${e.version}。其中含需重启才生效的项。`:`已应用 ${e.applied} 项,配置版本 → v${e.version}。`),setTimeout(()=>p(null),4e3),t.reload()}catch(e){l(e instanceof u?e:new u(String(e),0,0))}finally{s(!1)}}},q=e=>{let n=e.affected.logs??e.affected.keys??0;w(`操作已完成,影响 ${n} 条记录。`),setTimeout(()=>w(null),4e3),_(null),t.reload()},J=F.find(e=>e.id===`mapping`)?.items[0],Y=F.find(e=>e.id===M),X=F.find(e=>e.id===`danger`)?.items??[];return(0,k.jsxs)(`div`,{className:`view on`,children:[(0,k.jsx)(C,{title:`设置`,status:t.data?(0,k.jsx)(y,{tone:G.length?`amber`:`ghost`,dot:G.length>0,children:G.length?`${G.length} 项待保存`:`配置版本 v${t.data.version}`}):null,actions:(0,k.jsxs)(k.Fragment,{children:[G.length?(0,k.jsxs)(`button`,{type:`button`,className:`btn btn-quiet btn-sm`,onClick:()=>i({}),children:[(0,k.jsx)(o,{size:14}),`放弃改动`]}):null,(0,k.jsxs)(`button`,{type:`button`,className:`btn btn-primary btn-sm`,disabled:G.length===0||a,onClick:()=>void K(),children:[(0,k.jsx)(r,{size:14}),a?`保存中…`:`保存`]})]})}),(0,k.jsxs)(`div`,{className:`view-body stack`,children:[c?(0,k.jsx)(g,{tone:`error`,children:S(c)}):null,d?(0,k.jsx)(g,{tone:`success`,children:d}):null,b?(0,k.jsx)(g,{tone:`success`,children:b}):null,D?(0,k.jsx)(g,{tone:`success`,children:D}):null,(0,k.jsxs)(`div`,{className:`settings-split`,children:[(0,k.jsx)(`nav`,{className:`settings-nav`,"aria-label":`设置分组`,children:R.map(e=>{let t=H[e.id]??0;return(0,k.jsxs)(`button`,{type:`button`,className:`settings-nav-i${M===e.id?` on`:``}`,"aria-current":M===e.id?`page`:void 0,onClick:()=>N(e.id),children:[(0,k.jsx)(`span`,{className:`settings-nav-label`,children:e.label}),t>0?(0,k.jsx)(`span`,{className:`settings-nav-dirty`,children:t}):null]},e.id)})}),(0,k.jsx)(`div`,{className:`settings-content`,children:t.initial&&t.loading?(0,k.jsx)(v,{children:(0,k.jsx)(x,{kind:`loading`,title:`正在读取配置…`})}):t.error?(0,k.jsx)(v,{children:(0,k.jsx)(x,{kind:`error`,title:`配置没取到`,detail:S(t.error),onRetry:t.reload})}):(0,k.jsxs)(k.Fragment,{children:[M===`access`?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(j,{}),(0,k.jsx)(z,{})]}):null,M===`password`?(0,k.jsxs)(`div`,{className:`card`,children:[(0,k.jsxs)(`div`,{className:`group-head`,children:[(0,k.jsxs)(`h3`,{children:[(0,k.jsx)(e,{size:14,style:{verticalAlign:-2,marginRight:6}}),`管理口令`]}),(0,k.jsx)(`p`,{children:`控制台的唯一入口凭证`})]}),(0,k.jsxs)(`div`,{className:`set-row`,children:[(0,k.jsxs)(`div`,{className:`info`,children:[(0,k.jsx)(`b`,{children:`管理口令`}),(0,k.jsxs)(`span`,{children:[`两种改法:`,(0,k.jsx)(`b`,{children:`随机重置`}),`由服务端生成 16 位新口令(更强,但需当场保存);`,(0,k.jsx)(`b`,{children:`手动设定`}),`由你输入一个方便记忆的口令(至少 8 个字符)。 两种都立即生效、无需重启;新口令不回显、不落浏览器任何位置。`]})]}),(0,k.jsx)(`div`,{className:`ctl`,children:(0,k.jsxs)(`button`,{type:`button`,className:`btn btn-quiet btn-sm`,disabled:a,onClick:()=>E(!0),children:[(0,k.jsx)(e,{size:13}),`修改`]})})]})]}):null,M===`danger`?(0,k.jsxs)(`div`,{className:`card danger-zone`,children:[(0,k.jsxs)(`div`,{className:`group-head`,children:[(0,k.jsx)(`h3`,{style:{color:`var(--warn-amber)`},children:`危险操作`}),(0,k.jsx)(`p`,{children:`不可撤销,需二次确认`})]}),X.map(e=>(0,k.jsxs)(`div`,{className:`set-row`,children:[(0,k.jsxs)(`div`,{className:`info`,children:[(0,k.jsx)(`b`,{children:e.label}),(0,k.jsx)(`span`,{children:e.why})]}),(0,k.jsx)(`div`,{className:`ctl`,children:(0,k.jsx)(`button`,{type:`button`,className:`mini-pill danger`,disabled:a,onClick:()=>_(L[e.key]??null),children:e.label})})]},e.key))]}):null,M===`mapping`&&J?.type===`mapping`?(0,k.jsxs)(v,{title:J.label,aside:(0,k.jsx)(y,{children:`config.yml`}),children:[(0,k.jsx)(`div`,{className:`code`,style:{fontSize:12},children:Object.entries(J.value??{}).map(([e,t])=>(0,k.jsxs)(`div`,{children:[(0,k.jsx)(`span`,{className:`k`,children:e}),` → `,(0,k.jsx)(`span`,{className:`st`,children:t})]},e))}),(0,k.jsx)(`div`,{className:`footer-note`,children:J.why})]}):null,Y&&Y.id!==`danger`&&Y.id!==`mapping`?(0,k.jsx)(U,{group:Y,saving:a,valueOf:W,onChange:(e,t)=>i(n=>({...n,[e]:t}))}):null]})})]})]}),h?(0,k.jsx)(I,{spec:h,onClose:()=>_(null),onDone:q}):null,T?(0,k.jsx)(P,{onClose:()=>E(!1),onDone:()=>{A(`管理口令已更新并立即生效。下次登录请使用新口令。`),setTimeout(()=>A(null),4e3),t.reload()}}):null]})}function U({group:e,saving:t,valueOf:n,onChange:r}){let i=e.items.filter(e=>!B.has(e.key));if(i.length===0)return null;let a=i.filter(e=>!e.noop),o=i.filter(e=>e.noop);return(0,k.jsxs)(`div`,{className:`card`,children:[(0,k.jsxs)(`div`,{className:`group-head`,children:[(0,k.jsx)(`h3`,{children:e.label}),(0,k.jsx)(`p`,{children:W(e.id)})]}),a.map(e=>(0,k.jsx)(G,{item:e,value:n(e.key,e.value),saving:t,onChange:t=>r(e.key,t)},e.key)),o.length>0?(0,k.jsxs)(`details`,{className:`dormant`,children:[(0,k.jsxs)(`summary`,{children:[o.length,` 项暂未生效`,(0,k.jsx)(`span`,{children:`改了不会有任何变化 —— 依赖的功能未实现或上游未供货`})]}),o.map(e=>(0,k.jsx)(G,{item:e,value:n(e.key,e.value),saving:t,onChange:t=>r(e.key,t)},e.key))]}):null]})}function W(e){return{service:`进程监听与启动方式`,credential:`跨提供商的全局策略(部分项仅对 WorkBuddy 生效)`,quota:`积分口径与额度轮询(仅 WorkBuddy;MiniMax 走独立账本,Qoder 无端点)`,signin:`每日 08:05 自动签到(WorkBuddy 可关;MiniMax 恒开,Qoder 无签到)`,limits:`自用场景的保护,而非配额限制`,logs:`留在本机,不参与同步`}[e]??``}function G({item:e,value:t,saving:n,onChange:r}){return(0,k.jsxs)(`div`,{className:`set-row`,children:[(0,k.jsxs)(`div`,{className:`info`,children:[(0,k.jsxs)(`b`,{children:[e.label,e.requiresRestart?(0,k.jsx)(`span`,{style:{marginLeft:8,fontSize:10.5,color:`var(--warn-amber)`},children:`需重启`}):null]}),(0,k.jsx)(`span`,{children:e.why})]}),(0,k.jsx)(`div`,{className:`ctl`,children:(0,k.jsx)(A,{item:e,value:t,disabled:n,onChange:r})})]})}export{H as SettingsPage};
@@ -1 +1 @@
1
- import{A as e,E as t,it as n,r,tt as i}from"./vendor-befEYGHM.js";import{O as a,_ as o,a as s,c,g as l,j as u,k as d,p as f,u as p,v as m,x as h}from"./index-BJtz6Ses.js";import{a as g,c as _,n as v,o as y,r as b,s as x,t as S}from"./Select-HrLgXSri.js";import{a as C}from"./PageSkeleton-DG-Dj4_9.js";import{n as w,t as T}from"./sharedWindow-FDfq75PI.js";import{t as E}from"./useFx-xcrp_LHB.js";import{n as D,r as O,t as k}from"./ClientMetricTip-DIe3I7w4.js";var A=n(),j=i(),M={tokens:`消耗 tokens`,requests:`请求次数`};function N({points:e,metric:t,avg:n}){let[r,i]=(0,A.useState)(null),[a,o]=(0,A.useState)(null),s=(0,A.useRef)(null),c=(0,A.useRef)(null),[u,d]=(0,A.useState)(null);(0,A.useLayoutEffect)(()=>{let t=c.current,n=s.current;if(!t||!n||r===null||e.length===0){d(null);return}let i=()=>{let i=(r+.5)/e.length*n.clientWidth,a=n.getBoundingClientRect(),o=t.getBoundingClientRect(),s=i-(o.left-a.left);d(Math.max(12,Math.min(s,o.width-12)))};return i(),window.addEventListener(`resize`,i),()=>window.removeEventListener(`resize`,i)},[r,t,e.length]);let f=(0,A.useMemo)(()=>e.map((n,r)=>{let i=r>0?e[r-1]:null,a=i?t===`tokens`?n.tokens-i.tokens:n.requests-i.requests:null,o=/T\d{2}$/.test(n.bucket),s=(n.models??[]).slice(0,5).map(e=>`${e.model} ${h(e.tokens)} tokens`).join(`、`),c=a===null?``:` · 较${o?`上一小时`:`昨日`} ${a>0?`增加`:a<0?`减少`:`持平`}${a===0?``:` ${l(Math.abs(a))}`}`;return`${p(n.bucket)} · ${l(n.requests)} 次请求 · ${h(n.tokens)} tokens`+(n.errors>0?` · ${l(n.errors)} 次失败`:``)+(s?` · 模型:${s}`:``)+c}),[e,t]);if(e.length===0)return(0,j.jsx)(`div`,{className:`empty-note`,style:{padding:`24px 0`},children:`该窗口内没有请求记录。`});let m=e.map(e=>t===`tokens`?e.tokens:e.requests),g=Math.max(1,...m),_=l,v=n===null?null:Math.round(Math.min(1,Math.max(0,n/g))*1e4)/1e4,y=Math.ceil(e.length/5),b=a??e.length-1,x=t=>{let n=e.length-1,r;if(t.key===`ArrowRight`)r=Math.min(n,b+1);else if(t.key===`ArrowLeft`)r=Math.max(0,b-1);else if(t.key===`Home`)r=0;else if(t.key===`End`)r=n;else return;t.preventDefault(),o(r),i(r),(s.current?.querySelector(`[data-idx="${r}"]`)??void 0)?.focus()},S=r===null?null:e[r],C=S?/T\d{2}$/.test(S.bucket):!1,w=S&&r!==null&&r>0?e[r-1]:null,T=S&&w?t===`tokens`?S.tokens-w.tokens:S.requests-w.requests:null;return(0,j.jsxs)(j.Fragment,{children:[(0,j.jsxs)(`div`,{className:`avgline`,style:{"--avg":v??0},children:[v===null?null:(0,j.jsxs)(`span`,{className:`avg-row`,children:[(0,j.jsxs)(`span`,{className:`avg-tag`,children:[`日均 `,_(n)]}),(0,j.jsx)(`i`,{className:`avg-rule`})]}),(0,j.jsxs)(`div`,{className:`bars30 js-grow`,ref:s,onKeyDown:x,onMouseLeave:()=>i(null),children:[(0,j.jsxs)(`span`,{className:`grid`,"aria-hidden":`true`,children:[(0,j.jsx)(`i`,{className:`base`}),(0,j.jsx)(`i`,{className:`mid`}),(0,j.jsx)(`i`,{className:`q1`})]}),e.map((n,a)=>{let o=t===`tokens`?n.tokens:n.requests,s=a===e.length-1?`today`:o>=g?`peak`:``,c=n.errors>0,l=f[a];return(0,j.jsx)(`div`,{"data-idx":a,className:`bcol${a===r?` on`:``}`,role:`img`,"aria-label":l,tabIndex:a===b?0:-1,onMouseEnter:()=>i(a),onFocus:()=>i(a),onBlur:()=>i(e=>e===a?null:e),children:(0,j.jsx)(`div`,{className:`b ${s}`.trim()+(c?` err`:``),style:{height:`${Math.max(2,Math.round(o/g*100))}%`},children:c?(0,j.jsx)(`span`,{className:`err-dot`,"aria-hidden":`true`}):null})},n.bucket)}),S?(()=>{let n=r!==null&&e.length>0?(r+.5)/e.length*100:50;return(0,j.jsxs)(`div`,{ref:c,className:`bar-tip${n<12?` tip-left`:n>88?` tip-right`:``}`,style:{"--tip-x":`${n}%`,"--tip-arrow":u===null?void 0:`${u}px`},"aria-hidden":`true`,children:[(0,j.jsxs)(`div`,{className:`bt-head`,children:[(0,j.jsx)(`b`,{children:p(S.bucket)}),r===e.length-1?(0,j.jsx)(`span`,{className:`bt-tag`,children:`最新`}):null]}),(0,j.jsxs)(`div`,{className:`bt-row${t===`tokens`?` hot`:``}`,children:[(0,j.jsx)(`span`,{children:`消耗 tokens`}),(0,j.jsx)(`i`,{children:h(S.tokens)})]}),(S.models??[]).length>0?(0,j.jsx)(`div`,{className:`bt-models`,children:(S.models??[]).map(e=>(0,j.jsxs)(`div`,{className:`bt-model`,children:[(0,j.jsx)(`span`,{className:`bt-model-name`,children:e.model}),(0,j.jsxs)(`i`,{children:[h(e.tokens),(0,j.jsx)(`em`,{children:` · ${S.tokens>0?Math.round(e.tokens/S.tokens*100):0}%`})]})]},e.model))}):null,(0,j.jsxs)(`div`,{className:`bt-row${t===`requests`?` hot`:``}`,children:[(0,j.jsx)(`span`,{children:`请求次数`}),(0,j.jsx)(`i`,{children:l(S.requests)})]}),S.errors>0?(0,j.jsxs)(`div`,{className:`bt-row bt-err`,children:[(0,j.jsx)(`span`,{children:`失败`}),(0,j.jsxs)(`i`,{children:[l(S.errors),(0,j.jsxs)(`em`,{children:[` `,`(`,l(S.requests)===`--`||S.requests===0?`—`:`${(S.errors/S.requests*100).toFixed(1)}%`,`)`]})]})]}):null,T===null?null:(0,j.jsxs)(`div`,{className:`bt-delta${T>0?` up`:T<0?` down`:` flat`}`,children:[`较`,C?`上一小时`:`昨日`,T>0?` ▲`:T<0?` ▼`:` — `,T>0||T<0?l(Math.abs(T)):`持平`]})]})})():null]})]}),(0,j.jsx)(`div`,{className:`axis`,children:e.map((t,n)=>(0,j.jsx)(`span`,{children:n%y===0||n===e.length-1?p(t.bucket):``},t.bucket))})]})}function P({items:e,windowLabel:t}){if(e.length===0)return(0,j.jsxs)(`div`,{className:`empty-note`,children:[t,`没有可拆分的请求。`]});let n=Math.max(1,...e.map(e=>e.value)),r=e=>e?void 0:{fontFamily:`var(--font-body)`};return(0,j.jsx)(`div`,{className:`dist js-stagger js-grow`,children:e.map(e=>(0,j.jsxs)(`div`,{className:`d-row`,children:[e.tip?(0,j.jsx)(s,{content:e.tip,children:(0,j.jsx)(`span`,{className:`d-name`,style:r(e.mono),children:e.label})}):(0,j.jsx)(`span`,{className:`d-name`,style:r(e.mono),children:e.label}),(0,j.jsxs)(`span`,{className:`d-val`,children:[e.format===`credits`?f(e.value):l(e.value),` · `,e.trailing]}),(0,j.jsx)(`span`,{className:`d-track`,children:(0,j.jsx)(`i`,{style:{width:`${Math.max(2,Math.round(e.value/n*100))}%`}})})]},e.key))})}function F({items:e,windowLabel:t}){return e.length===0?(0,j.jsxs)(`div`,{className:`empty-note`,style:{padding:`8px 0`},children:[t,`没有按模型的消耗记录。`]}):(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(`div`,{className:`tbl-scroll`,children:(0,j.jsxs)(`table`,{className:`tbl`,children:[(0,j.jsxs)(`caption`,{className:`sr-only`,children:[`按模型的 token 消耗明细,共 `,e.length,` 个模型`]}),(0,j.jsx)(`thead`,{children:(0,j.jsxs)(`tr`,{children:[(0,j.jsx)(`th`,{scope:`col`,children:`模型`}),(0,j.jsx)(`th`,{scope:`col`,className:`r`,children:`请求次数`}),(0,j.jsx)(`th`,{scope:`col`,className:`r`,children:`Token 消耗`}),(0,j.jsx)(`th`,{scope:`col`,className:`r`,children:`Token 占比`}),(0,j.jsx)(`th`,{scope:`col`,className:`r`,children:`消耗积分`}),(0,j.jsx)(`th`,{scope:`col`,className:`r`,children:`平均单次 Token`})]})}),(0,j.jsx)(`tbody`,{children:e.map(e=>{let t=e.displayName??e.model??`未知模型`;return(0,j.jsxs)(`tr`,{children:[(0,j.jsxs)(`td`,{className:`td-strong`,children:[t,e.tag?(0,j.jsx)(`span`,{className:`mu-tag`,children:e.tag}):null,e.multiplier==null?(0,j.jsx)(s,{content:`接口与本地快照都缺此模型倍率 —— 该行积分按中性倍率估算,不是上游真实计费`,children:(0,j.jsx)(`span`,{className:`mu-unknown`,children:`倍率未知`})}):null]}),(0,j.jsx)(`td`,{className:`r td-mono`,children:l(e.requests)}),(0,j.jsx)(`td`,{className:`r td-mono`,children:h(e.tokens??0)}),(0,j.jsx)(`td`,{className:`r td-mono`,children:o(e.share)}),(0,j.jsx)(`td`,{className:`r td-mono`,children:e.credits===null?(0,j.jsx)(s,{content:e.creditsUnknownCount?`本窗口 ${l(e.creditsUnknownCount)} 条请求上游均未回报单次费用(该上游只在账本给累计值)。真实消耗见上方「积分账本」。`:`上游未回报单次费用。真实消耗见上方「积分账本」。`,children:(0,j.jsx)(`span`,{className:`cred-unknown`,children:`--`})}):f(e.credits)}),(0,j.jsx)(`td`,{className:`r td-mono`,children:e.requests>0?h(Math.round((e.tokens??0)/e.requests)):`--`})]},e.model??t)})})]})}),(0,j.jsxs)(`div`,{className:`footer-note`,children:[`平均单次 = Token 消耗 ÷ 请求次数。接口不提供按模型的耗时,「较昨日」与「本计费周期」也无对应字段 —— 这三样一律留空而不是补一个看着合理的数。`,(0,j.jsx)(`br`,{}),`标着`,(0,j.jsx)(`b`,{children:`「倍率未知」`}),`的行,是 /v3/config 接口与本地快照都没有的模型:`,(0,j.jsx)(`b`,{children:`该行积分是按中性倍率估算的,不是上游真实计费`}),`。`]})]})}var I={ok:`额度接口正常`,quota_endpoint_not_configured:`未配置额度端点`,quota_endpoint_error:`额度端点拉取失败`};function L({quota:n,provenance:i,windowLabel:a}){let o=n.available&&n.remain!==null;return(0,j.jsxs)(g,{title:`配额数据来源`,aside:(0,j.jsx)(_,{tone:n.available?`live`:`amber`,dot:!0,children:I[n.reason]}),children:[(0,j.jsxs)(`div`,{className:`src-grid`,children:[(0,j.jsxs)(`div`,{className:`src-col`,children:[(0,j.jsxs)(`div`,{className:`src-head`,children:[(0,j.jsx)(t,{size:13,"aria-hidden":!0}),`来自上游额度接口`,(0,j.jsx)(`span`,{className:`tag tag-live`,children:`官方口径`})]}),(0,j.jsxs)(`ul`,{children:[(0,j.jsxs)(`li`,{children:[(0,j.jsx)(`b`,{children:`剩余积分`}),(0,j.jsx)(`i`,{children:`quota.remain`})]}),(0,j.jsxs)(`li`,{children:[(0,j.jsx)(`b`,{children:`总量`}),(0,j.jsx)(`i`,{children:`quota.total`})]}),(0,j.jsxs)(`li`,{children:[(0,j.jsx)(`b`,{children:`重置时间`}),(0,j.jsx)(`i`,{children:`quota.resetAt`})]})]}),(0,j.jsx)(`div`,{className:`src-state`,children:o?n.stale?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(r,{size:13,"aria-hidden":!0}),`上次拉取失败,当前显示的是上一次成功值(不会清空)。`]}):`已接入,随配额端点轮询刷新。`:(0,j.jsxs)(j.Fragment,{children:[`未接入 —— 上面三项显示 `,(0,j.jsx)(`i`,{children:`--`}),`。服务端不做估算,前端更不会替它编一个。`]})})]}),(0,j.jsxs)(`div`,{className:`src-col`,children:[(0,j.jsxs)(`div`,{className:`src-head`,children:[(0,j.jsx)(e,{size:13,"aria-hidden":!0}),`本机按请求累计`,(0,j.jsx)(`span`,{className:`tag tag-off`,children:`非官方口径`})]}),(0,j.jsxs)(`ul`,{children:[(0,j.jsxs)(`li`,{children:[(0,j.jsx)(`b`,{children:`已消耗积分`}),(0,j.jsx)(`i`,{children:`仅统计经本服务转发的请求,按上游实扣累加(官方客户端直连不计入)`})]}),(0,j.jsxs)(`li`,{children:[(0,j.jsxs)(`b`,{children:[a,`趋势`]}),(0,j.jsx)(`i`,{children:`本机日志按天聚合`})]}),(0,j.jsxs)(`li`,{children:[(0,j.jsx)(`b`,{children:`按模型 / 按提供商消耗`}),(0,j.jsx)(`i`,{children:`同一次聚合的一体两面`})]})]}),(0,j.jsx)(`div`,{className:`src-state`,children:`这些数即时产生,不等额度接口 —— 也正是它和「剩余积分」会对不齐的原因。`})]})]}),n.message?(0,j.jsx)(`div`,{className:`footer-note`,children:n.message}):null,(0,j.jsx)(`div`,{className:`footer-note`,children:i.note}),(0,j.jsxs)(`div`,{className:`footer-note`,children:[`官方额度接口按 `,(0,j.jsx)(`span`,{className:`code-chip`,children:`quota.pollSeconds`}),`(默认 `,(0,j.jsx)(`b`,{children:`30 秒`}),`)轮询, 所以「剩余积分」最多滞后 30 秒;本机累计的消耗是即时的。 两者最多相差 `,(0,j.jsx)(`b`,{children:`30 秒内的消耗量`}),` —— 这是取样时刻不同,不是账对不上。 来源标记:已消耗积分 `,(0,j.jsx)(`span`,{className:`code-chip`,children:i.creditsUsed}),` · `,`剩余积分 `,(0,j.jsx)(`span`,{className:`code-chip`,children:i.quotaRemain}),`。`]})]})}var R=`today`,z={today:null,"1h":null,"24h":null,"7d":7,"30d":30};function B(){let[e,t]=(0,A.useState)(()=>T()??R),n=u(()=>c.overview(e),[e],{cacheKey:`overview:${e}`});E(`usage-${e}-${n.data?`ready`:`pending`}`);let[r,i]=(0,A.useState)(`tokens`),s=n.data,p=z[e],I=s&&p?s.metrics.creditsUsed/p:null,B=s&&p?s.metrics.requests/p:null,V=s&&p?s.metrics.totalTokens/p:null,H=s?[...s.byModel].sort((e,t)=>(t.tokens??0)-(e.tokens??0)):[],U=s?[...s.byClient].sort((e,t)=>(t.tokens??0)-(e.tokens??0)):[],W=s&&s.quota.available&&s.quota.remain!==null&&I!==null&&I>0?Math.floor(s.quota.remain/I):null,G=s?s.quota.available?I===null||I<=0?`${a[s.window]}无消耗记录`:`按日均 ${f(I)} 积分估算`:`需要额度接口`:void 0,K=e=>{if(!s||s.byClient.length===0)return;let t=[...s.byClient].sort((t,n)=>(n[e]??0)-(t[e]??0));return(0,j.jsx)(k,{rows:t,metric:e,windowLabel:a[s.window],total:e===`credits`?s.metrics.creditsUsed:e===`tokens`?s.metrics.totalTokens:s.metrics.requests,totalCount:t.length})};return(0,j.jsxs)(`div`,{className:`view on`,children:[(0,j.jsx)(x,{title:`积分与用量`,status:s?(0,j.jsxs)(_,{tone:`live`,dot:!0,children:[a[s.window],` · `,m(s.generatedAt)]}):null,actions:(0,j.jsx)(S,{value:e,options:d,onChange:e=>{w(e),t(e)},width:148})}),(0,j.jsx)(`div`,{className:`view-body stack`,children:n.initial&&n.loading?(0,j.jsx)(C,{}):n.error?(0,j.jsx)(g,{children:(0,j.jsx)(v,{kind:`error`,title:`用量数据没取到`,detail:b(n.error),onRetry:n.reload})}):s?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(O,{metrics:s.metrics}),(0,j.jsx)(y,{items:[{label:`${a[s.window]}消耗`,value:f(s.metrics.creditsUsed),detail:`经本服务转发 · 上游实扣累计`,tip:K(`credits`),tipPos:`down`},{label:`${a[s.window]}请求`,value:l(s.metrics.requests),detail:`${l(s.metrics.activeClients)} 个密钥活跃`,tip:K(`requests`),tipPos:`down`},...I===null?[{label:`本窗口总 tokens`,value:h(s.metrics.totalTokens),detail:`输入 ${h(s.metrics.promptTokens)} · 输出 ${h(s.metrics.completionTokens)}`,tip:K(`tokens`),tipPos:`down`}]:[{label:`日均消耗`,value:f(I),detail:`${a[s.window]}消耗 ÷ ${p} 天`,tip:K(`credits`),tipPos:`down`},{label:`按当前速度可用天数`,value:W===null?`—`:l(W),detail:G,tone:s.quota.available?void 0:`amber`}]]}),(0,j.jsx)(g,{title:`${a[s.window]}趋势`,aside:(0,j.jsxs)(`span`,{className:`panel-aside-row`,children:[(0,j.jsx)(`span`,{className:`seg-tabs`,role:`group`,"aria-label":`趋势口径`,children:[`tokens`,`requests`].map(e=>(0,j.jsx)(`button`,{type:`button`,className:r===e?`on`:``,"aria-pressed":r===e,onClick:()=>i(e),children:e===`tokens`?`Token`:`请求数`},e))}),(0,j.jsxs)(_,{children:[`单位:`,M[r],` `,e===`1h`||e===`24h`||e===`today`?`/ 小时`:`/ 天`]})]}),padded:!1,children:(0,j.jsx)(`div`,{style:{padding:`0 20px 18px`},children:(0,j.jsx)(N,{points:s.trend,metric:r,avg:r===`tokens`?V:B})})}),(0,j.jsx)(g,{title:`按模型消耗明细`,aside:(0,j.jsx)(_,{children:`按 Token 排序`}),padded:!1,children:(0,j.jsx)(`div`,{style:{padding:`0 20px 18px`},children:(0,j.jsx)(F,{items:H,windowLabel:a[s.window]})})}),(0,j.jsxs)(g,{title:`按提供商消耗`,aside:(0,j.jsx)(_,{children:`按 Token 排序`}),children:[(0,j.jsx)(P,{windowLabel:a[s.window],items:U.map(e=>({key:e.clientId??`—`,label:e.client??`未识别`,value:e.tokens??0,format:`int`,trailing:`${o(e.share)} · ${f(e.credits)} 积分 · ${l(e.requests)} 次`,tip:(0,j.jsx)(D,{row:e})}))}),(0,j.jsx)(`div`,{className:`footer-note`,children:`「未识别」是正常的识别分支,不是错误 —— 没绑定密钥又没匹配到特征时归到这里。`})]}),(0,j.jsx)(L,{quota:s.quota,provenance:s.provenance,windowLabel:a[s.window]})]}):null})]})}export{B as UsagePage};
1
+ import{A as e,E as t,it as n,r,tt as i}from"./vendor-befEYGHM.js";import{O as a,_ as o,a as s,c,g as l,j as u,k as d,p as f,u as p,v as m,x as h}from"./index-nQeRK3kW.js";import{a as g,c as _,n as v,o as y,r as b,s as x,t as S}from"./Select-G6AhT0TA.js";import{a as C}from"./PageSkeleton-DG-Dj4_9.js";import{n as w,t as T}from"./sharedWindow-FDfq75PI.js";import{t as E}from"./useFx-xcrp_LHB.js";import{n as D,r as O,t as k}from"./ClientMetricTip-C2VuiT4-.js";var A=n(),j=i(),M={tokens:`消耗 tokens`,requests:`请求次数`};function N({points:e,metric:t,avg:n}){let[r,i]=(0,A.useState)(null),[a,o]=(0,A.useState)(null),s=(0,A.useRef)(null),c=(0,A.useRef)(null),[u,d]=(0,A.useState)(null);(0,A.useLayoutEffect)(()=>{let t=c.current,n=s.current;if(!t||!n||r===null||e.length===0){d(null);return}let i=()=>{let i=(r+.5)/e.length*n.clientWidth,a=n.getBoundingClientRect(),o=t.getBoundingClientRect(),s=i-(o.left-a.left);d(Math.max(12,Math.min(s,o.width-12)))};return i(),window.addEventListener(`resize`,i),()=>window.removeEventListener(`resize`,i)},[r,t,e.length]);let f=(0,A.useMemo)(()=>e.map((n,r)=>{let i=r>0?e[r-1]:null,a=i?t===`tokens`?n.tokens-i.tokens:n.requests-i.requests:null,o=/T\d{2}$/.test(n.bucket),s=(n.models??[]).slice(0,5).map(e=>`${e.model} ${h(e.tokens)} tokens`).join(`、`),c=a===null?``:` · 较${o?`上一小时`:`昨日`} ${a>0?`增加`:a<0?`减少`:`持平`}${a===0?``:` ${l(Math.abs(a))}`}`;return`${p(n.bucket)} · ${l(n.requests)} 次请求 · ${h(n.tokens)} tokens`+(n.errors>0?` · ${l(n.errors)} 次失败`:``)+(s?` · 模型:${s}`:``)+c}),[e,t]);if(e.length===0)return(0,j.jsx)(`div`,{className:`empty-note`,style:{padding:`24px 0`},children:`该窗口内没有请求记录。`});let m=e.map(e=>t===`tokens`?e.tokens:e.requests),g=Math.max(1,...m),_=l,v=n===null?null:Math.round(Math.min(1,Math.max(0,n/g))*1e4)/1e4,y=Math.ceil(e.length/5),b=a??e.length-1,x=t=>{let n=e.length-1,r;if(t.key===`ArrowRight`)r=Math.min(n,b+1);else if(t.key===`ArrowLeft`)r=Math.max(0,b-1);else if(t.key===`Home`)r=0;else if(t.key===`End`)r=n;else return;t.preventDefault(),o(r),i(r),(s.current?.querySelector(`[data-idx="${r}"]`)??void 0)?.focus()},S=r===null?null:e[r],C=S?/T\d{2}$/.test(S.bucket):!1,w=S&&r!==null&&r>0?e[r-1]:null,T=S&&w?t===`tokens`?S.tokens-w.tokens:S.requests-w.requests:null;return(0,j.jsxs)(j.Fragment,{children:[(0,j.jsxs)(`div`,{className:`avgline`,style:{"--avg":v??0},children:[v===null?null:(0,j.jsxs)(`span`,{className:`avg-row`,children:[(0,j.jsxs)(`span`,{className:`avg-tag`,children:[`日均 `,_(n)]}),(0,j.jsx)(`i`,{className:`avg-rule`})]}),(0,j.jsxs)(`div`,{className:`bars30 js-grow`,ref:s,onKeyDown:x,onMouseLeave:()=>i(null),children:[(0,j.jsxs)(`span`,{className:`grid`,"aria-hidden":`true`,children:[(0,j.jsx)(`i`,{className:`base`}),(0,j.jsx)(`i`,{className:`mid`}),(0,j.jsx)(`i`,{className:`q1`})]}),e.map((n,a)=>{let o=t===`tokens`?n.tokens:n.requests,s=a===e.length-1?`today`:o>=g?`peak`:``,c=n.errors>0,l=f[a];return(0,j.jsx)(`div`,{"data-idx":a,className:`bcol${a===r?` on`:``}`,role:`img`,"aria-label":l,tabIndex:a===b?0:-1,onMouseEnter:()=>i(a),onFocus:()=>i(a),onBlur:()=>i(e=>e===a?null:e),children:(0,j.jsx)(`div`,{className:`b ${s}`.trim()+(c?` err`:``),style:{height:`${Math.max(2,Math.round(o/g*100))}%`},children:c?(0,j.jsx)(`span`,{className:`err-dot`,"aria-hidden":`true`}):null})},n.bucket)}),S?(()=>{let n=r!==null&&e.length>0?(r+.5)/e.length*100:50;return(0,j.jsxs)(`div`,{ref:c,className:`bar-tip${n<12?` tip-left`:n>88?` tip-right`:``}`,style:{"--tip-x":`${n}%`,"--tip-arrow":u===null?void 0:`${u}px`},"aria-hidden":`true`,children:[(0,j.jsxs)(`div`,{className:`bt-head`,children:[(0,j.jsx)(`b`,{children:p(S.bucket)}),r===e.length-1?(0,j.jsx)(`span`,{className:`bt-tag`,children:`最新`}):null]}),(0,j.jsxs)(`div`,{className:`bt-row${t===`tokens`?` hot`:``}`,children:[(0,j.jsx)(`span`,{children:`消耗 tokens`}),(0,j.jsx)(`i`,{children:h(S.tokens)})]}),(S.models??[]).length>0?(0,j.jsx)(`div`,{className:`bt-models`,children:(S.models??[]).map(e=>(0,j.jsxs)(`div`,{className:`bt-model`,children:[(0,j.jsx)(`span`,{className:`bt-model-name`,children:e.model}),(0,j.jsxs)(`i`,{children:[h(e.tokens),(0,j.jsx)(`em`,{children:` · ${S.tokens>0?Math.round(e.tokens/S.tokens*100):0}%`})]})]},e.model))}):null,(0,j.jsxs)(`div`,{className:`bt-row${t===`requests`?` hot`:``}`,children:[(0,j.jsx)(`span`,{children:`请求次数`}),(0,j.jsx)(`i`,{children:l(S.requests)})]}),S.errors>0?(0,j.jsxs)(`div`,{className:`bt-row bt-err`,children:[(0,j.jsx)(`span`,{children:`失败`}),(0,j.jsxs)(`i`,{children:[l(S.errors),(0,j.jsxs)(`em`,{children:[` `,`(`,l(S.requests)===`--`||S.requests===0?`—`:`${(S.errors/S.requests*100).toFixed(1)}%`,`)`]})]})]}):null,T===null?null:(0,j.jsxs)(`div`,{className:`bt-delta${T>0?` up`:T<0?` down`:` flat`}`,children:[`较`,C?`上一小时`:`昨日`,T>0?` ▲`:T<0?` ▼`:` — `,T>0||T<0?l(Math.abs(T)):`持平`]})]})})():null]})]}),(0,j.jsx)(`div`,{className:`axis`,children:e.map((t,n)=>(0,j.jsx)(`span`,{children:n%y===0||n===e.length-1?p(t.bucket):``},t.bucket))})]})}function P({items:e,windowLabel:t}){if(e.length===0)return(0,j.jsxs)(`div`,{className:`empty-note`,children:[t,`没有可拆分的请求。`]});let n=Math.max(1,...e.map(e=>e.value)),r=e=>e?void 0:{fontFamily:`var(--font-body)`};return(0,j.jsx)(`div`,{className:`dist js-stagger js-grow`,children:e.map(e=>(0,j.jsxs)(`div`,{className:`d-row`,children:[e.tip?(0,j.jsx)(s,{content:e.tip,children:(0,j.jsx)(`span`,{className:`d-name`,style:r(e.mono),children:e.label})}):(0,j.jsx)(`span`,{className:`d-name`,style:r(e.mono),children:e.label}),(0,j.jsxs)(`span`,{className:`d-val`,children:[e.format===`credits`?f(e.value):l(e.value),` · `,e.trailing]}),(0,j.jsx)(`span`,{className:`d-track`,children:(0,j.jsx)(`i`,{style:{width:`${Math.max(2,Math.round(e.value/n*100))}%`}})})]},e.key))})}function F({items:e,windowLabel:t}){return e.length===0?(0,j.jsxs)(`div`,{className:`empty-note`,style:{padding:`8px 0`},children:[t,`没有按模型的消耗记录。`]}):(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(`div`,{className:`tbl-scroll`,children:(0,j.jsxs)(`table`,{className:`tbl`,children:[(0,j.jsxs)(`caption`,{className:`sr-only`,children:[`按模型的 token 消耗明细,共 `,e.length,` 个模型`]}),(0,j.jsx)(`thead`,{children:(0,j.jsxs)(`tr`,{children:[(0,j.jsx)(`th`,{scope:`col`,children:`模型`}),(0,j.jsx)(`th`,{scope:`col`,className:`r`,children:`请求次数`}),(0,j.jsx)(`th`,{scope:`col`,className:`r`,children:`Token 消耗`}),(0,j.jsx)(`th`,{scope:`col`,className:`r`,children:`Token 占比`}),(0,j.jsx)(`th`,{scope:`col`,className:`r`,children:`消耗积分`}),(0,j.jsx)(`th`,{scope:`col`,className:`r`,children:`平均单次 Token`})]})}),(0,j.jsx)(`tbody`,{children:e.map(e=>{let t=e.displayName??e.model??`未知模型`;return(0,j.jsxs)(`tr`,{children:[(0,j.jsxs)(`td`,{className:`td-strong`,children:[t,e.tag?(0,j.jsx)(`span`,{className:`mu-tag`,children:e.tag}):null,e.multiplier==null?(0,j.jsx)(s,{content:`接口与本地快照都缺此模型倍率 —— 该行积分按中性倍率估算,不是上游真实计费`,children:(0,j.jsx)(`span`,{className:`mu-unknown`,children:`倍率未知`})}):null]}),(0,j.jsx)(`td`,{className:`r td-mono`,children:l(e.requests)}),(0,j.jsx)(`td`,{className:`r td-mono`,children:h(e.tokens??0)}),(0,j.jsx)(`td`,{className:`r td-mono`,children:o(e.share)}),(0,j.jsx)(`td`,{className:`r td-mono`,children:e.credits===null?(0,j.jsx)(s,{content:e.creditsUnknownCount?`本窗口 ${l(e.creditsUnknownCount)} 条请求上游均未回报单次费用(该上游只在账本给累计值)。真实消耗见上方「积分账本」。`:`上游未回报单次费用。真实消耗见上方「积分账本」。`,children:(0,j.jsx)(`span`,{className:`cred-unknown`,children:`--`})}):f(e.credits)}),(0,j.jsx)(`td`,{className:`r td-mono`,children:e.requests>0?h(Math.round((e.tokens??0)/e.requests)):`--`})]},e.model??t)})})]})}),(0,j.jsxs)(`div`,{className:`footer-note`,children:[`平均单次 = Token 消耗 ÷ 请求次数。接口不提供按模型的耗时,「较昨日」与「本计费周期」也无对应字段 —— 这三样一律留空而不是补一个看着合理的数。`,(0,j.jsx)(`br`,{}),`标着`,(0,j.jsx)(`b`,{children:`「倍率未知」`}),`的行,是 /v3/config 接口与本地快照都没有的模型:`,(0,j.jsx)(`b`,{children:`该行积分是按中性倍率估算的,不是上游真实计费`}),`。`]})]})}var I={ok:`额度接口正常`,quota_endpoint_not_configured:`未配置额度端点`,quota_endpoint_error:`额度端点拉取失败`};function L({quota:n,provenance:i,windowLabel:a}){let o=n.available&&n.remain!==null;return(0,j.jsxs)(g,{title:`配额数据来源`,aside:(0,j.jsx)(_,{tone:n.available?`live`:`amber`,dot:!0,children:I[n.reason]}),children:[(0,j.jsxs)(`div`,{className:`src-grid`,children:[(0,j.jsxs)(`div`,{className:`src-col`,children:[(0,j.jsxs)(`div`,{className:`src-head`,children:[(0,j.jsx)(t,{size:13,"aria-hidden":!0}),`来自上游额度接口`,(0,j.jsx)(`span`,{className:`tag tag-live`,children:`官方口径`})]}),(0,j.jsxs)(`ul`,{children:[(0,j.jsxs)(`li`,{children:[(0,j.jsx)(`b`,{children:`剩余积分`}),(0,j.jsx)(`i`,{children:`quota.remain`})]}),(0,j.jsxs)(`li`,{children:[(0,j.jsx)(`b`,{children:`总量`}),(0,j.jsx)(`i`,{children:`quota.total`})]}),(0,j.jsxs)(`li`,{children:[(0,j.jsx)(`b`,{children:`重置时间`}),(0,j.jsx)(`i`,{children:`quota.resetAt`})]})]}),(0,j.jsx)(`div`,{className:`src-state`,children:o?n.stale?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(r,{size:13,"aria-hidden":!0}),`上次拉取失败,当前显示的是上一次成功值(不会清空)。`]}):`已接入,随配额端点轮询刷新。`:(0,j.jsxs)(j.Fragment,{children:[`未接入 —— 上面三项显示 `,(0,j.jsx)(`i`,{children:`--`}),`。服务端不做估算,前端更不会替它编一个。`]})})]}),(0,j.jsxs)(`div`,{className:`src-col`,children:[(0,j.jsxs)(`div`,{className:`src-head`,children:[(0,j.jsx)(e,{size:13,"aria-hidden":!0}),`本机按请求累计`,(0,j.jsx)(`span`,{className:`tag tag-off`,children:`非官方口径`})]}),(0,j.jsxs)(`ul`,{children:[(0,j.jsxs)(`li`,{children:[(0,j.jsx)(`b`,{children:`已消耗积分`}),(0,j.jsx)(`i`,{children:`仅统计经本服务转发的请求,按上游实扣累加(官方客户端直连不计入)`})]}),(0,j.jsxs)(`li`,{children:[(0,j.jsxs)(`b`,{children:[a,`趋势`]}),(0,j.jsx)(`i`,{children:`本机日志按天聚合`})]}),(0,j.jsxs)(`li`,{children:[(0,j.jsx)(`b`,{children:`按模型 / 按提供商消耗`}),(0,j.jsx)(`i`,{children:`同一次聚合的一体两面`})]})]}),(0,j.jsx)(`div`,{className:`src-state`,children:`这些数即时产生,不等额度接口 —— 也正是它和「剩余积分」会对不齐的原因。`})]})]}),n.message?(0,j.jsx)(`div`,{className:`footer-note`,children:n.message}):null,(0,j.jsx)(`div`,{className:`footer-note`,children:i.note}),(0,j.jsxs)(`div`,{className:`footer-note`,children:[`官方额度接口按 `,(0,j.jsx)(`span`,{className:`code-chip`,children:`quota.pollSeconds`}),`(默认 `,(0,j.jsx)(`b`,{children:`30 秒`}),`)轮询, 所以「剩余积分」最多滞后 30 秒;本机累计的消耗是即时的。 两者最多相差 `,(0,j.jsx)(`b`,{children:`30 秒内的消耗量`}),` —— 这是取样时刻不同,不是账对不上。 来源标记:已消耗积分 `,(0,j.jsx)(`span`,{className:`code-chip`,children:i.creditsUsed}),` · `,`剩余积分 `,(0,j.jsx)(`span`,{className:`code-chip`,children:i.quotaRemain}),`。`]})]})}var R=`today`,z={today:null,"1h":null,"24h":null,"7d":7,"30d":30};function B(){let[e,t]=(0,A.useState)(()=>T()??R),n=u(()=>c.overview(e),[e],{cacheKey:`overview:${e}`});E(`usage-${e}-${n.data?`ready`:`pending`}`);let[r,i]=(0,A.useState)(`tokens`),s=n.data,p=z[e],I=s&&p?s.metrics.creditsUsed/p:null,B=s&&p?s.metrics.requests/p:null,V=s&&p?s.metrics.totalTokens/p:null,H=s?[...s.byModel].sort((e,t)=>(t.tokens??0)-(e.tokens??0)):[],U=s?[...s.byClient].sort((e,t)=>(t.tokens??0)-(e.tokens??0)):[],W=s&&s.quota.available&&s.quota.remain!==null&&I!==null&&I>0?Math.floor(s.quota.remain/I):null,G=s?s.quota.available?I===null||I<=0?`${a[s.window]}无消耗记录`:`按日均 ${f(I)} 积分估算`:`需要额度接口`:void 0,K=e=>{if(!s||s.byClient.length===0)return;let t=[...s.byClient].sort((t,n)=>(n[e]??0)-(t[e]??0));return(0,j.jsx)(k,{rows:t,metric:e,windowLabel:a[s.window],total:e===`credits`?s.metrics.creditsUsed:e===`tokens`?s.metrics.totalTokens:s.metrics.requests,totalCount:t.length})};return(0,j.jsxs)(`div`,{className:`view on`,children:[(0,j.jsx)(x,{title:`积分与用量`,status:s?(0,j.jsxs)(_,{tone:`live`,dot:!0,children:[a[s.window],` · `,m(s.generatedAt)]}):null,actions:(0,j.jsx)(S,{value:e,options:d,onChange:e=>{w(e),t(e)},width:148})}),(0,j.jsx)(`div`,{className:`view-body stack`,children:n.initial&&n.loading?(0,j.jsx)(C,{}):n.error?(0,j.jsx)(g,{children:(0,j.jsx)(v,{kind:`error`,title:`用量数据没取到`,detail:b(n.error),onRetry:n.reload})}):s?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(O,{metrics:s.metrics}),(0,j.jsx)(y,{items:[{label:`${a[s.window]}消耗`,value:f(s.metrics.creditsUsed),detail:`经本服务转发 · 上游实扣累计`,tip:K(`credits`),tipPos:`down`},{label:`${a[s.window]}请求`,value:l(s.metrics.requests),detail:`${l(s.metrics.activeClients)} 个密钥活跃`,tip:K(`requests`),tipPos:`down`},...I===null?[{label:`本窗口总 tokens`,value:h(s.metrics.totalTokens),detail:`输入 ${h(s.metrics.promptTokens)} · 输出 ${h(s.metrics.completionTokens)}`,tip:K(`tokens`),tipPos:`down`}]:[{label:`日均消耗`,value:f(I),detail:`${a[s.window]}消耗 ÷ ${p} 天`,tip:K(`credits`),tipPos:`down`},{label:`按当前速度可用天数`,value:W===null?`—`:l(W),detail:G,tone:s.quota.available?void 0:`amber`}]]}),(0,j.jsx)(g,{title:`${a[s.window]}趋势`,aside:(0,j.jsxs)(`span`,{className:`panel-aside-row`,children:[(0,j.jsx)(`span`,{className:`seg-tabs`,role:`group`,"aria-label":`趋势口径`,children:[`tokens`,`requests`].map(e=>(0,j.jsx)(`button`,{type:`button`,className:r===e?`on`:``,"aria-pressed":r===e,onClick:()=>i(e),children:e===`tokens`?`Token`:`请求数`},e))}),(0,j.jsxs)(_,{children:[`单位:`,M[r],` `,e===`1h`||e===`24h`||e===`today`?`/ 小时`:`/ 天`]})]}),padded:!1,children:(0,j.jsx)(`div`,{style:{padding:`0 20px 18px`},children:(0,j.jsx)(N,{points:s.trend,metric:r,avg:r===`tokens`?V:B})})}),(0,j.jsx)(g,{title:`按模型消耗明细`,aside:(0,j.jsx)(_,{children:`按 Token 排序`}),padded:!1,children:(0,j.jsx)(`div`,{style:{padding:`0 20px 18px`},children:(0,j.jsx)(F,{items:H,windowLabel:a[s.window]})})}),(0,j.jsxs)(g,{title:`按提供商消耗`,aside:(0,j.jsx)(_,{children:`按 Token 排序`}),children:[(0,j.jsx)(P,{windowLabel:a[s.window],items:U.map(e=>({key:e.clientId??`—`,label:e.client??`未识别`,value:e.tokens??0,format:`int`,trailing:`${o(e.share)} · ${f(e.credits)} 积分 · ${l(e.requests)} 次`,tip:(0,j.jsx)(D,{row:e})}))}),(0,j.jsx)(`div`,{className:`footer-note`,children:`「未识别」是正常的识别分支,不是错误 —— 没绑定密钥又没匹配到特征时归到这里。`})]}),(0,j.jsx)(L,{quota:s.quota,provenance:s.provenance,windowLabel:a[s.window]})]}):null})]})}export{B as UsagePage};
@@ -1,2 +1,2 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./LandingPage-Cwbtdh2I.js","./vendor-befEYGHM.js","./accessUrl-DbL5DLDz.js","./LandingPage-B2hMgbmZ.css","./OverviewPage-AeWM2Lg5.js","./Select-HrLgXSri.js","./PageSkeleton-DG-Dj4_9.js","./sharedWindow-FDfq75PI.js","./useFx-xcrp_LHB.js","./ClientMetricTip-DIe3I7w4.js","./UsagePage-oe_p1Aiz.js","./ClientsPage-D5F7-rin.js","./Modal-B-rIrvXS.js","./useFocusTrap-Cj84bnpH.js","./Drawer-CleQGhRU.js","./Switch-0KA1AbiV.js","./ApiKeysPage-CdguoLCa.js","./RequestsPage-ivdKipjv.js","./SettingsPage-PX7wr7r_.js"])))=>i.map(i=>d[i]);
2
- import{$ as e,D as t,F as n,O as r,P as i,S as a,T as o,U as s,Y as c,b as l,c as u,d,it as f,nt as p,r as m,rt as h,s as g,tt as _,v,x as y,y as b}from"./vendor-befEYGHM.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),t.credentials=e.crossOrigin===`use-credentials`?`include`:e.crossOrigin===`anonymous`?`omit`:`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var x=f(),S=p();function C(e=window.location.pathname){let t=e.replace(/\/+$/,``)||`/`;return t===`/console`||t.startsWith(`/console/`)?`console`:`landing`}function w(e=!1){let{pathname:t,hash:n}=window.location;if(C(t)===`console`||!n.startsWith(`#/`))return;let r=`/console${n}`;e?window.location.replace(r):window.history.replaceState(null,``,r)}function T(){window.addEventListener(`hashchange`,()=>w(!0))}var E=`relay.theme`,D=`system`;function O(){try{return window.matchMedia?.(`(prefers-color-scheme: light)`).matches?`light`:`dark`}catch{return`dark`}}function k(e,t=window.location.pathname,n=window.location.hash){return e===`system`?O():e}function A(){try{let e=window.localStorage.getItem(E);return e===`light`||e===`dark`||e===`system`?e:D}catch{return D}}function ee(e){document.documentElement.dataset.theme=e}var j=null,M=new Set;function N(){if(j===null){let e=document.documentElement.dataset.theme,t=A();j={theme:e===`light`||e===`dark`?e:k(t),preference:t}}return j}function P(e){return M.add(e),()=>M.delete(e)}function te(e){try{window.localStorage.setItem(E,e)}catch{}F()}function F(){let e=A(),t=k(e);ee(t),j={theme:t,preference:e},M.forEach(e=>e())}typeof window<`u`&&(window.matchMedia?.(`(prefers-color-scheme: light)`).addEventListener?.(`change`,()=>{A()===`system`&&F()}),window.addEventListener(`storage`,e=>{(e.key===null||e.key===E)&&F()}));var I=[`overview`,`usage`,`clients`,`keys`,`requests`,`settings`];function L(e){let t=e.replace(/^#\/?/,``).split(`?`)[0];return I.includes(t)?t:`overview`}function ne(){let[e,t]=(0,x.useState)(()=>L(window.location.hash));return(0,x.useEffect)(()=>{let e=()=>t(L(window.location.hash));return window.addEventListener(`hashchange`,e),()=>window.removeEventListener(`hashchange`,e)},[]),{route:e,navigate:e=>{window.location.hash=`#/${e}`}}}var R=class extends Error{code;status;retryAfterSeconds;constructor(e,t,n,r){super(e),this.name=`ApiError`,this.code=t,this.status=n,this.retryAfterSeconds=r}get isSessionExpired(){return this.code===40102}},z=new Set;function re(e){return z.add(e),()=>z.delete(e)}function ie(e){z.forEach(t=>t(e))}async function ae(e){let t=await e.text(),n=null;try{n=t?JSON.parse(t):null}catch{throw new R(`服务端返回了非 JSON 响应(HTTP ${e.status})`,0,e.status)}if(!n||typeof n.code!=`number`)throw new R(`响应缺少统一信封(HTTP ${e.status})`,0,e.status);if(n.code===0)return n.data;let r=n.data?.retryAfterSeconds;throw new R(n.message||`请求失败(code ${n.code})`,n.code,e.status,r)}var B=2e4;function oe(e,t){let n=new AbortController,r=!1,i=()=>n.abort(e?.reason);e&&(e.aborted?n.abort(e.reason):e.addEventListener(`abort`,i,{once:!0}));let a=t===null?void 0:setTimeout(()=>{r=!0,n.abort()},t);return{signal:n.signal,isTimedOut:()=>r,dispose:()=>{a!==void 0&&clearTimeout(a),e?.removeEventListener(`abort`,i)}}}function se(e){return e instanceof DOMException&&e.name===`AbortError`}async function V(e,t){let n=(t?.method??`GET`).toUpperCase(),r=oe(t?.signal,n===`GET`?B:null),i=new Headers(t?.headers);i.has(`accept`)||i.set(`Accept`,`application/json`),t?.body&&!i.has(`content-type`)&&i.set(`Content-Type`,`application/json`);let a;try{a=await fetch(e,{...t,signal:r.signal,credentials:`same-origin`,headers:i})}catch(e){throw r.dispose(),r.isTimedOut()?new R(`请求超时(${B/1e3}s 无响应),稍后重试。`,0,0):se(e)?e:new R(`连不上本机服务。确认后端已在 127.0.0.1:8787 启动。`,0,0)}try{let e=await ae(a);if(!a.ok)throw new R(`请求失败(HTTP ${a.status})`,0,a.status);return e}catch(e){throw r.isTimedOut()?new R(`请求超时(${B/1e3}s 无响应),稍后重试。`,0,0):e}finally{r.dispose()}}async function H(e,t){try{return await V(e,t)}catch(e){throw e instanceof R&&e.isSessionExpired&&ie(e),e}}function U(e){let t=new URLSearchParams;Object.entries(e).forEach(([e,n])=>{n!=null&&n!==``&&t.set(e,String(n))});let n=t.toString();return n?`?${n}`:``}var W=new Map,G=new Map;function ce(){W.clear(),G.clear()}function le(e,t){W.has(e)&&W.set(e,t(W.get(e)))}function ue(e,t,n){let r=G.get(e);if(r&&!n)return r;let i=t().then(t=>(G.get(e)===i&&W.set(e,t),t));return G.set(e,i),i.finally(()=>{G.get(e)===i&&G.delete(e)}).catch(()=>{}),i}function de(e,t,n={}){let r=n.enabled??!0,i=n.cacheKey,a=r&&i!==void 0&&W.has(i),[o,s]=(0,x.useState)(()=>a?W.get(i):null),[c,l]=(0,x.useState)(null),[u,d]=(0,x.useState)(r),[f,p]=(0,x.useState)(!a),m=(0,x.useRef)(0),h=(0,x.useRef)(e);h.current=e;let g=(0,x.useRef)(i);g.current=i;let _=(0,x.useCallback)(e=>{let t=++m.current,n=g.current;d(!0),(n===void 0?h.current():ue(n,()=>h.current(),e)).then(e=>{t===m.current&&(s(e),l(null),d(!1),p(!1))},e=>{t!==m.current||se(e)||(l(e instanceof R?e:new R(String(e),0,0)),d(!1),p(!1))})},[]);return(0,x.useEffect)(()=>{if(!r){m.current+=1,s(null),l(null),d(!1),p(!0);return}i!==void 0&&W.has(i)&&(s(W.get(i)),l(null),p(!1)),_(!1)},[r,i,...t]),{data:o,error:c,loading:u,initial:f,reload:(0,x.useCallback)(()=>_(!0),[_])}}var fe={today:`今日`,"1h":`最近 1 小时`,"24h":`最近 24 小时`,"7d":`最近 7 天`,"30d":`最近 30 天`},pe=Object.keys(fe).map(e=>({value:e,label:fe[e]}));function me(e,t){return t&&new Date(t).getTime()<Date.now()?`exp`:e?`live`:`off`}var he={live:`启用`,off:`已停用`,exp:`已过期`},ge=new Intl.NumberFormat(`zh-CN`),_e=new Intl.NumberFormat(`zh-CN`,{minimumFractionDigits:2,maximumFractionDigits:2});function ve(e){return e==null||Number.isNaN(e)?`--`:ge.format(Math.round(e))}function ye(e){return e==null||Number.isNaN(e)?`--`:_e.format(e)}function be(e,t=1){return e==null||Number.isNaN(e)?`--`:`${(e*100).toFixed(t)}%`}function xe(e,t=1){return`${((Number.isFinite(e)?Math.max(0,Math.min(1,e)):0)*100).toFixed(t)}%`}var Se=[{limit:0x38d7ea4c68000,div:0x38d7ea4c68000,digits:2,suffix:`Q`},{limit:0xe8d4a51000,div:0xe8d4a51000,digits:2,suffix:`T`},{limit:1e9,div:1e9,digits:2,suffix:`B`},{limit:1e6,div:1e6,digits:2,suffix:`M`},{limit:1e3,div:1e3,digits:1,suffix:`K`}];function Ce(e){if(e==null||Number.isNaN(e))return`--`;let t=Math.round(e),n=Se.find(e=>Math.abs(t)>=e.limit);return n?`${(t/n.div).toFixed(n.digits)}${n.suffix}`:String(t)}function we(e){return e==null||Number.isNaN(e)?`--`:e<1e3?`${Math.round(e)}ms`:e<6e4?`${(e/1e3).toFixed(1)}s`:`${Math.floor(e/6e4)}m${Math.round(e%6e4/1e3)}s`}function Te(e,t,n){let r=e??0;if(r<=0||t==null||t<=0)return null;let i=n==null?t:t-n;return i<=0?null:r/(i/1e3)}function Ee(e){return e==null||Number.isNaN(e)?`--`:`${e.toFixed(1)} t/s`}function De(e){if(!e)return`--`;let t=new Date(e);return Number.isNaN(t.getTime())?`--`:t.toLocaleTimeString(`zh-CN`,{hour12:!1})}function Oe(e){if(!e)return`--`;let t=new Date(e);return Number.isNaN(t.getTime())?`--`:`${t.toLocaleDateString(`zh-CN`)} ${t.toLocaleTimeString(`zh-CN`,{hour12:!1})}`}function ke(e){if(!e)return`--`;let t=new Date(e).getTime();if(Number.isNaN(t))return`--`;let n=Date.now()-t;if(n<0){let e=-n;return e<6e4?`马上`:e<36e5?`${Math.floor(e/6e4)} 分钟后`:e<864e5?`${Math.floor(e/36e5)} 小时后`:`${Math.floor(e/864e5)} 天后`}let r=Math.floor(n/6e4);if(r<1)return`刚刚`;if(r<60)return`${r} 分钟前`;let i=Math.floor(r/60);if(i<24)return`${i} 小时前`;let a=Math.floor(i/24);return a<30?`${a} 天前`:`${Math.floor(a/30)} 个月前`}function Ae(e){let t=e.match(/^(\d{4})-(\d{2})-(\d{2})(?:T(\d{2}))?/);if(!t)return e.slice(5,10);let n=`${Number(t[2])}/${Number(t[3])}`;return t[4]===void 0?n:`${n} ${Number(t[4])}时`}function je(e){switch(e.type){case`all`:return`全部模型`;case`family`:return`仅 ${e.value} 系`;case`tag`:return`仅 ${e.value}`;case`models`:return`指定 ${e.value.length} 个模型`;default:return`未知范围`}}var Me=`upstream_credential_invalid`;function Ne(e,t=Me){return e.split(`,`).includes(t)}function Pe(e,t=``){return Ne(t)||e===401?`fatal`:e>=400?`warn`:`live`}var Fe={[Me]:`上游访问密钥失效`,"upstream unreachable":`上游不可达`,"upstream empty body":`上游返回空响应`,upstream_error:`上游错误`,"bad request body":`请求体不合法`,"model not permitted":`模型未授权`,"model not found":`模型不存在`,"concurrency limit":`本机并发上限`,"rate limited":`命中上游限流`,rate_limited:`命中上游限流`,"upstream timeout":`上游超时`,model_not_available:`账号未开通此模型`,invalid_max_tokens:`max_tokens 不合法`,context_length_exceeded:`上下文超限`,upstream_11101:`上游要求强制流式`,upstream_11128:`上游渠道校验拒绝(提示指纹)`,retried:`已自动重试`,"cache hit":`命中缓存`,system_injected:`已补 system`,developer_role_normalized:`已规范 developer 角色`,stream_options_stripped:`已移除 stream_options`,sysprompt_degraded_retry:`命中渠道校验,已降级重试`,stream_aborted:`流式中断`,client_detached:`客户端已断开`,usage_missing:`上游未返回用量`,"minimax tokens unavailable":`MiniMax token 不可用`,"token refresh failed":`上游 token 刷新失败`,"missing credential":`缺少上游访问凭证`,"wb oauth unavailable":`WorkBuddy 授权服务不可用`,"missing wb oauth credential":`WorkBuddy 未导入授权`,"wb token refresh failed":`WorkBuddy 授权刷新失败`,"qoder credential invalid":`Qoder 凭证无效`,"multiplier-unknown":`倍率未知(历史:积分按中性估算)`,cache_discounted:`缓存命中已按折扣计(历史)`,credits_from_upstream:`上游实扣积分`,credits_unknown:`上游未回报积分`,credits_recalibrated:`历史积分已重算`,estimate_voided:`历史估算已作废(上游未回报)`};function Ie(e){if(!e)return`-`;let t=e.split(`,`)[0];return Fe[t]??t}function Le(e){return e?e.split(`,`).map(e=>e.trim()).filter(Boolean).map(e=>Fe[e]??e):[]}function Re(e){return e.upstreamCode===11102?`11102:当前账号未开通该模型。该项已在模型表标为未验证,不会自动删除——订阅变动后可能再开。`:e.upstreamCode===11128?`11128:上游返回业务码 11128(上游原文「Illegal API invocation from an unapproved channel」):本次请求的 system 提示命中了上游对第三方客户端模板的指纹校验。本服务已在转发前改写模板行,并在被拒时自动降级为中性提示重试一次,均未通过;请检查「客户端与密钥 → 提供商 → system 提示改写」是否被关闭,或把该请求的特征反馈给维护者。`:e.upstreamCode===11101?`11101:上游拒绝了非流式请求。本服务已强制改写为流式,出现此码说明上游协议变更。`:e.upstreamCode===11133?`11133:max_tokens 过小。已提升到下限后重试一次。`:Ne(e.note)?`上游访问密钥失效是这套方案唯一会让服务停摆的状态:所有客户端共用同一把上游访问密钥,它一失效即整体不可用。去「客户端与密钥 → 提供商」的「修改」里换新。`:null}var ze=[{displayName:`Hy4 preview`,id:`hy4-preview`,tag:`限时免费`,multiplier:0},{displayName:`Hy3`,id:`hy3`,tag:`限时免费`,multiplier:0},{displayName:`Space-Bunny`,id:`space-bunny`,tag:`限时折扣`,multiplier:.03},{displayName:`Deepseek-V4.1-Flash`,id:`deepseek-v4.1-flash`,tag:null,multiplier:.11},{displayName:`Deepseek-V4-Pro`,id:`deepseek-v4-pro`,tag:null,multiplier:.51},{displayName:`GLM-5.3`,id:`glm-5.3`,tag:`订阅优先`,multiplier:.79},{displayName:`GLM-5.3-Flash`,id:`glm-5.3-flash`,tag:`订阅优先`,multiplier:.06},{displayName:`GLM-5.3-FlashX`,id:`glm-5.3-flashx`,tag:`订阅优先`,multiplier:.14},{displayName:`GLM-5.2`,id:`glm-5.2`,tag:null,multiplier:.79},{displayName:`GLM-5.1`,id:`glm-5.1`,tag:null,multiplier:.79},{displayName:`GLM-5v-Turbo`,id:`glm-5v-turbo`,tag:null,multiplier:.71},{displayName:`MiniMax-M3`,id:`minimax-m3`,tag:null,multiplier:.25},{displayName:`Kimi-K3`,id:`kimi-k3`,tag:`订阅优先`,multiplier:1.62},{displayName:`Kimi-K2.8-Preview`,id:`kimi-k2.8-preview`,tag:`订阅优先`,multiplier:.77},{displayName:`Kimi-K2.7-Code`,id:`kimi-k2.7`,tag:null,multiplier:.57},{displayName:`Kimi-K2.6`,id:`kimi-k2.6`,tag:null,multiplier:.52},{displayName:`Step-5-Preview`,id:`step-5-preview`,tag:`订阅优先`,multiplier:.43},{displayName:`Kimi-K3-1`,id:`kimi-k3-1`,tag:`订阅优先`,multiplier:null}],Be=new Set([`kimi-k3-1`]),Ve=new Set([`step-5-preview`]);function He(e){return Be.has(e)?`upstream`:Ve.has(e)?`manual`:`seed`}var Ue={source:`seed`,fetchedAt:new Date(Date.now()-72e5).toISOString(),upstreamReachable:!0,models:ze.map(e=>({...e,family:e.id.split(`-`)[0],source:He(e.id),provider:e.id.startsWith(`MiniMax-`)||e.id.startsWith(`minimax-`)?`MiniMax Code`:`WorkBuddy`,verified:e.id===`glm-5.1`||e.id===`hy3`?0:1,enabled:!0,lastVerifiedAt:new Date(Date.now()-72e5).toISOString()}))},We=[{id:`k_8f21`,name:`Claude Code`},{id:`k_1b83`,name:`Cherry Studio`},{id:`k_9d02`,name:`Cursor`},{id:`k_c3a5`,name:`Cron Job`},{id:`k_77c1`,name:`手机端(临时)`},{id:`unidentified`,name:`未识别客户端`}];function Ge(){let e=Date.now(),t={ipWhitelist:[],maxIps:null,tokenQuota:null,usedIps:0,usedTokens:0};return[{...t,id:`k_8f21`,name:`Claude Code · 本机`,hint:`sk-waygate-4f9c…7a2e`,scope:{type:`all`},client:`Claude Code`,clients:[`Claude Code`],enabled:!0,expiresAt:null,createdAt:new Date(e-11232e5).toISOString(),lastSeenAt:new Date(e-4e4).toISOString(),requests24h:760},{...t,maxIps:3,tokenQuota:2e6,usedIps:2,usedTokens:1234567,id:`k_1b83`,name:`Cherry Studio`,hint:`sk-waygate-1b83…c40f`,scope:{type:`all`},client:`Cherry Studio`,clients:[`Cherry Studio`],enabled:!0,expiresAt:null,createdAt:new Date(e-9504e5).toISOString(),lastSeenAt:new Date(e-9e4).toISOString(),requests24h:324},{...t,id:`k_9d02`,name:`Cursor · 笔记本`,hint:`sk-waygate-9d02…3ee1`,scope:{type:`family`,value:`kimi`},client:`Cursor`,clients:[`Cursor`,`Claude Code`],enabled:!0,expiresAt:null,createdAt:new Date(e-7776e5).toISOString(),lastSeenAt:new Date(e-108e5).toISOString(),requests24h:154},{...t,id:`k_c3a5`,name:`Cron Job · 定时任务`,hint:`sk-waygate-c3a5…91d7`,scope:{type:`family`,value:`deepseek`},client:`Cron Job`,clients:[`Cron Job`],enabled:!0,expiresAt:null,createdAt:new Date(e-6912e5).toISOString(),lastSeenAt:new Date(e-3e5).toISOString(),requests24h:78},{...t,ipWhitelist:[`192.168.1.0/24`],id:`k_77c1`,name:`手机端(临时)`,hint:`sk-waygate-77c1…b8f0`,scope:{type:`all`},client:`手机端(临时)`,clients:[`手机端(临时)`],enabled:!1,expiresAt:null,createdAt:new Date(e-2592e6).toISOString(),lastSeenAt:new Date(e-2592e5).toISOString(),requests24h:0},{...t,id:`k_2e6b`,name:`测试脚本 · 本地`,hint:`sk-waygate-2e6b…0a13`,scope:{type:`tag`,value:`夜间折扣`},client:null,clients:[],enabled:!0,expiresAt:new Date(e-1728e5).toISOString(),createdAt:new Date(e-3456e6).toISOString(),lastSeenAt:new Date(e-10368e5).toISOString(),requests24h:0},{...t,id:`k_5d7f`,name:`家人共享 · 只读`,hint:`sk-waygate-5d7f…22c8`,scope:{type:`models`,value:[`glm-5.3`,`kimi-k2.7`]},client:null,clients:[],enabled:!1,expiresAt:null,createdAt:new Date(e-1728e6).toISOString(),lastSeenAt:new Date(e-432e6).toISOString(),requests24h:0}]}We.filter(e=>e.id!==`unidentified`).map(e=>e.name),Ge(),new Date().toISOString(),Date.now()+1728e6,Date.now()+22464e5,new Date().toISOString().slice(0,10),new Date(Date.now()-18e5).toISOString(),new Date(Date.now()-216e5).toISOString(),new Date(Date.now()+19008e5).toISOString(),new Date(Date.now()-24e5).toISOString(),Ue.models.map(e=>({...e}));function K(e){return{method:`POST`,body:JSON.stringify(e)}}var q={session(){return V(`/api/auth/session`)},login(e){return V(`/api/auth/login`,K({password:e}))},logout(){return V(`/api/auth/logout`,{method:`POST`})},overview(e){return H(`/api/overview${U({window:e})}`)},clients(e){return H(`/api/clients${U({window:e})}`)},requests(e){return H(`/api/requests${U({...e})}`)},requestDetail(e){return H(`/api/requests/${e}`)},keys(){return H(`/api/keys`).then(e=>e.items)},createKey(e){return H(`/api/keys`,K(e))},patchKey(e,t){return H(`/api/keys/${e}`,{method:`PATCH`,body:JSON.stringify(t)})},deleteKey(e){return H(`/api/keys/${e}`,{method:`DELETE`})},settings(){return H(`/api/settings`)},putSettings(e){return H(`/api/settings`,{method:`PUT`,body:JSON.stringify({settings:e})}).then(t=>(le(`settings`,n=>({...n,version:t.version,groups:n.groups.map(t=>({...t,items:t.items.map(t=>{let n=e.find(e=>e.key===t.key);return n?{...t,value:n.value}:t})}))})),t))},danger(e,t){return H(`/api/settings/danger`,K({action:e,confirm:t}))},putCredential(e){return H(`/api/settings/credential`,{method:`PUT`,body:JSON.stringify({key:e})})},resetAdminPassword(){return H(`/api/auth/password/reset`,{method:`POST`})},setAdminPassword(e){return H(`/api/auth/password`,{method:`PUT`,body:JSON.stringify({password:e})})},catalog(e){return H(`/api/models/catalog${e?`?provider=${encodeURIComponent(e)}`:``}`)},refreshCatalog(){return H(`/api/models/catalog`,{method:`POST`})},testCredential(e){return H(`/api/settings/credential/test`,K({key:e}))},setModelEnabled(e,t,n){return H(`/api/models/catalog/${encodeURIComponent(e)}${n?`?provider=${encodeURIComponent(n)}`:``}`,{method:`PATCH`,body:JSON.stringify({enabled:t})})},providerSignin(e){return H(`/api/providers/${encodeURIComponent(e)}/signin`)},providerOauthImport(e,t){return H(`/api/providers/${encodeURIComponent(e)}/oauth-import`,{method:`POST`,body:JSON.stringify(t)})},providerImportLocal(e){return H(`/api/providers/${encodeURIComponent(e)}/import-local`,{method:`POST`,body:`{}`})},providerImportDeviceStart(e){return H(`/api/providers/${encodeURIComponent(e)}/import-device/start`,{method:`POST`,body:`{}`})},providerImportDevicePoll(e){return H(`/api/providers/${encodeURIComponent(e)}/import-device/poll`,{method:`POST`,body:`{}`})},providerImportDeviceCancel(e){return H(`/api/providers/${encodeURIComponent(e)}/import-device/cancel`,{method:`POST`,body:`{}`})},providerGrowthRun(e){return H(`/api/providers/${encodeURIComponent(e)}/growth/run`,{method:`POST`})},providerGrowthPanel(e){return H(`/api/providers/${encodeURIComponent(e)}/growth`)},providerSigninNow(e){return H(`/api/providers/${encodeURIComponent(e)}/signin`,{method:`POST`})},providers(){return H(`/api/providers`)},createProvider(e){return H(`/api/providers`,{method:`POST`,body:JSON.stringify(e)})},patchProvider(e,t){return H(`/api/providers/${encodeURIComponent(e)}`,{method:`PATCH`,body:JSON.stringify(t)})},deactivateProvider(e){return H(`/api/providers/${encodeURIComponent(e)}/deactivate`,{method:`PUT`})},activateProvider(e){return H(`/api/providers/${encodeURIComponent(e)}/activate`,{method:`PUT`})},testProvider(e,t){return H(`/api/providers/${encodeURIComponent(e)}/test`,{method:`POST`,body:JSON.stringify(t?{credential:t}:{})})},deleteProvider(e){return H(`/api/providers/${encodeURIComponent(e)}`,{method:`DELETE`})}};function Ke(){let[e,t]=(0,x.useState)(`loading`),[n,r]=(0,x.useState)(null);(0,x.useEffect)(()=>{let e=!0;return q.session().then(n=>{e&&(t(n.authenticated?`authed`:`anon`),r(n.expiresAt))}).catch(()=>{e&&t(`anon`)}),()=>{e=!1}},[]);let i=(0,x.useRef)(!1);return(0,x.useEffect)(()=>re(()=>{i.current||(ce(),t(`anon`))}),[]),{status:e,expiresAt:n,login:(0,x.useCallback)(async e=>{let n=await q.login(e);ce(),t(`authed`),r(n.expiresAt)},[]),logout:(0,x.useCallback)(async()=>{i.current=!0;try{await q.logout()}catch(e){if(!(e instanceof R))throw i.current=!1,e}t(`anon`),r(null),window.location.assign(`/`)},[])}}var J=_();function Y({size:e=26}){return(0,J.jsxs)(`svg`,{width:e,height:e,viewBox:`0 0 160 160`,fill:`none`,role:`img`,"aria-label":`Waygate`,children:[(0,J.jsx)(`polygon`,{points:`80,8 148,48 128,125 50,151 12,78`,fill:`var(--brand-500)`,opacity:`.12`}),(0,J.jsx)(`polygon`,{points:`80,8 80,94 12,78`,fill:`var(--brand-400)`}),(0,J.jsx)(`polygon`,{points:`80,8 148,48 80,94`,fill:`var(--brand-500)`}),(0,J.jsx)(`polygon`,{points:`148,48 128,125 80,94`,fill:`var(--accent-blue)`}),(0,J.jsx)(`polygon`,{points:`12,78 80,94 50,151`,fill:`var(--brand-450)`,opacity:`.85`}),(0,J.jsx)(`polygon`,{points:`80,94 128,125 50,151`,fill:`var(--brand-450)`})]})}function qe(){return{...(0,x.useSyncExternalStore)(P,N,()=>({theme:`dark`,preference:`system`})),setPreference:te}}var Je=h(),X=12,Z=8,Ye=300;function Xe(e,t){typeof e==`function`?e(t):e&&(e.current=t)}function Ze({content:e,children:t,placement:n=`auto`,className:r}){let i=(0,x.useId)(),a=(0,x.useRef)(null),o=(0,x.useRef)(null),[s,c]=(0,x.useState)(!1),[l,u]=(0,x.useState)(null),d=t.props,f=d.disabled===!0,p=d.ref,m=typeof d[`aria-describedby`]==`string`?d[`aria-describedby`]:void 0,h=[m,s?i:void 0].filter(Boolean).join(` `)||void 0,g=typeof d.tabIndex==`number`?d.tabIndex:f?void 0:0,_=(0,x.useCallback)(()=>{let e=a.current,t=o.current;if(!e||!t)return;let r=e.getBoundingClientRect(),i=window.innerWidth,s=window.innerHeight,c=Math.min(Ye,Math.max(0,i-24)),l=Math.min(c,t.offsetWidth||c),d=t.offsetHeight;if(r.bottom<X||r.top>s-X){u(null);return}let f=r.top-X,p=s-r.bottom-X,m=f>=d+Z,h=p>=d+Z,g=n===`above`?m||!h?`above`:`below`:n===`below`?h||!m?`below`:`above`:m||!h?`above`:`below`,_=r.left+r.width/2,v=Math.max(X,Math.min(_-l/2,i-l-X)),y=Math.max(12,Math.min(_-v,l-12)),b=g===`above`?Math.max(X,r.top-d-Z):Math.max(X,Math.min(s-d-X,r.bottom+Z));u({left:v,top:b,placement:g,maxWidth:c,arrowLeft:y})},[n]),v=(0,x.useCallback)(()=>c(!0),[]),y=(0,x.useCallback)(()=>c(!1),[]);(0,x.useLayoutEffect)(()=>{if(!s){u(null);return}_()},[e,_,s]),(0,x.useLayoutEffect)(()=>{if(!s)return;let e=()=>_(),t=e=>{e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),y())},n=e=>{let t=e.target;t&&(a.current?.contains(t)||o.current?.contains(t))||y()};return window.addEventListener(`scroll`,e,!0),window.addEventListener(`resize`,e),window.visualViewport?.addEventListener(`resize`,e),window.visualViewport?.addEventListener(`scroll`,e),document.addEventListener(`keydown`,t,!0),document.addEventListener(`pointerdown`,n,!0),()=>{window.removeEventListener(`scroll`,e,!0),window.removeEventListener(`resize`,e),window.visualViewport?.removeEventListener(`resize`,e),window.visualViewport?.removeEventListener(`scroll`,e),document.removeEventListener(`keydown`,t,!0),document.removeEventListener(`pointerdown`,n,!0)}},[y,_,s]);let b=(0,x.useCallback)(e=>{a.current=e,Xe(p,e)},[p]),S=(0,x.useCallback)(e=>{Xe(p,e)},[p]),C=(0,x.useCallback)(e=>{a.current=e},[]),w=d.onBlur,T=(e,t)=>{let n=e.relatedTarget;n instanceof Node&&e.currentTarget.contains(n)||(t&&w?.(e),y())},E=typeof d.className==`string`&&r?`${d.className} ${r}`:r??d.className,D=(0,x.cloneElement)(t,{...E?{className:E}:{},ref:f?S:b,"aria-describedby":f?m:h,"data-tooltip-trigger":f?void 0:`true`,tabIndex:g,onMouseEnter:e=>{d.onMouseEnter?.(e),v()},onMouseLeave:e=>{d.onMouseLeave?.(e),y()},onFocus:e=>{d.onFocus?.(e),v()},onBlur:e=>T(e,!f)}),O=s&&typeof document<`u`?(0,Je.createPortal)((0,J.jsx)(`div`,{ref:o,id:i,role:`tooltip`,className:`tooltip-surface tooltip-${l?.placement??`measuring`}`,style:l?{left:l.left,top:l.top,maxWidth:l.maxWidth,"--tooltip-arrow-left":`${l.arrowLeft}px`}:{visibility:`hidden`,maxWidth:Math.min(Ye,Math.max(0,window.innerWidth-24))},children:e}),document.body):null;if(!f)return(0,J.jsxs)(J.Fragment,{children:[D,O]});let k=[m,s?i:void 0].filter(Boolean).join(` `)||void 0;return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`span`,{ref:C,className:`tooltip-anchor${r?` ${r}`:``}`,"data-tooltip-trigger":`true`,tabIndex:0,"aria-describedby":k,"aria-disabled":`true`,onMouseEnter:v,onMouseLeave:y,onFocus:v,onBlur:e=>T(e,!1),children:D}),O]})}var Q=[{value:`system`,label:`跟随系统`,Icon:b},{value:`light`,label:`浅色`,Icon:g},{value:`dark`,label:`深色`,Icon:v}];function Qe(){let{preference:e,setPreference:t}=qe();return(0,J.jsx)(`div`,{className:`theme-seg`,role:`radiogroup`,"aria-label":`外观`,onKeyDown:n=>{if(n.key!==`ArrowLeft`&&n.key!==`ArrowRight`)return;n.preventDefault();let r=Q.findIndex(t=>t.value===e),i=n.key===`ArrowRight`?(r+1)%Q.length:(r-1+Q.length)%Q.length;t(Q[i].value)},children:Q.map(({value:n,label:r,Icon:i})=>{let a=e===n;return(0,J.jsx)(Ze,{content:r,children:(0,J.jsx)(`button`,{type:`button`,role:`radio`,"aria-checked":a,tabIndex:a?0:-1,className:`theme-seg-i${a?` on`:``}`,"aria-label":r,onClick:()=>t(n),children:(0,J.jsx)(i,{size:14})})},n)})})}var $e=`relay.console.route`;function et(e){try{window.sessionStorage.setItem($e,e)}catch{}}function tt(){try{let e=window.sessionStorage.getItem($e);if(e&&I.includes(e))return e}catch{}return`overview`}function nt(e){return`/console#/${e??tt()}`}var rt=[{route:`overview`,label:`概览`,icon:(0,J.jsx)(o,{size:18})},{route:`usage`,label:`积分与用量`,icon:(0,J.jsx)(c,{size:18})},{route:`clients`,label:`提供商管理`,icon:(0,J.jsx)(e,{size:18})},{route:`keys`,label:`API 密钥`,icon:(0,J.jsx)(t,{size:18})},{route:`requests`,label:`请求日志`,icon:(0,J.jsx)(d,{size:18})},{route:`settings`,label:`设置`,icon:(0,J.jsx)(u,{size:18})}];function it({route:e,navigate:t,expiresAt:n,onLogout:r,children:i}){(0,x.useEffect)(()=>{et(e)},[e]);let[a,o]=(0,x.useState)(null);(0,x.useEffect)(()=>{let e=!0;return(async()=>{try{let t=await fetch(`/healthz`,{headers:{Accept:`application/json`}});if(!t.ok)return;let n=await t.json();e&&typeof n.version==`string`&&n.version&&o(n.version)}catch{}})(),()=>{e=!1}},[]);let[s,c]=(0,x.useState)(!1),u=(0,x.useRef)(null),d=(0,x.useRef)(null),f=(0,x.useRef)(null);(0,x.useEffect)(()=>{if(s){f.current=document.activeElement instanceof HTMLElement?document.activeElement:null,(d.current?.querySelector(`a[href], button:not([disabled])`))?.focus({preventScroll:!0});return}f.current?.isConnected&&f.current.focus({preventScroll:!0}),f.current=null},[s]),(0,x.useEffect)(()=>{if(!s)return;let e=e=>{if(e.key===`Escape`){e.preventDefault(),c(!1);return}if(e.key!==`Tab`)return;let t=d.current?Array.from(d.current.querySelectorAll(`a[href], button:not([disabled])`)):[];if(t.length===0)return;let n=t[0],r=t[t.length-1];e.shiftKey&&document.activeElement===n?(e.preventDefault(),r.focus()):!e.shiftKey&&document.activeElement===r&&(e.preventDefault(),n.focus())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[s]),(0,x.useEffect)(()=>{let e=()=>{window.innerWidth>720&&c(!1)};return window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[]);let p=e=>{c(!1),t(e)};return(0,J.jsxs)(`div`,{className:`app`,"data-view":e,"data-nav-open":s?`true`:`false`,children:[(0,J.jsxs)(`div`,{className:`scene`,"aria-hidden":`true`,children:[(0,J.jsxs)(`div`,{className:`lights`,children:[(0,J.jsx)(`div`,{className:`bloom l1`}),(0,J.jsx)(`div`,{className:`bloom l2`}),(0,J.jsx)(`div`,{className:`bloom l3`})]}),(0,J.jsx)(`div`,{className:`dimmer`}),(0,J.jsx)(`div`,{className:`noise`})]}),(0,J.jsx)(`button`,{ref:u,type:`button`,className:`nav-toggle`,"aria-label":`打开导航菜单`,"aria-controls":`console-sidebar`,"aria-expanded":s,onClick:()=>c(e=>!e),children:(0,J.jsx)(l,{size:20})}),(0,J.jsxs)(`aside`,{ref:d,className:`sidebar`,id:`console-sidebar`,"aria-label":`控制台导航`,children:[(0,J.jsxs)(`a`,{className:`sb-brand`,href:`/`,children:[(0,J.jsx)(Y,{size:26}),(0,J.jsx)(`span`,{children:`途关`}),(0,J.jsx)(`span`,{className:`brand-en`,children:`Waygate`}),(0,J.jsxs)(`span`,{className:`brand-ver`,children:[`v`,a??`1.6.15`]})]}),(0,J.jsx)(`div`,{className:`sb-group`,children:`工作台`}),rt.filter(e=>I.includes(e.route)).map(t=>(0,J.jsxs)(`button`,{type:`button`,className:`sb-item${e===t.route?` active`:``}`,onClick:()=>p(t.route),"aria-current":e===t.route?`page`:void 0,children:[t.icon,t.label]},t.route)),(0,J.jsx)(`div`,{className:`sb-spacer`}),(0,J.jsxs)(`div`,{className:`sb-tools`,children:[(0,J.jsx)(`span`,{className:`sb-tools-lb`,children:`外观`}),(0,J.jsx)(Qe,{})]}),(0,J.jsxs)(`div`,{className:`sb-account`,children:[(0,J.jsx)(`div`,{className:`avatar`,children:`管`}),(0,J.jsxs)(`div`,{className:`meta`,children:[(0,J.jsx)(`b`,{children:`管理员`}),(0,J.jsx)(`i`,{children:n?`会话有效 · ${ke(n)}到期`:`本机管理员`})]}),(0,J.jsx)(Ze,{content:`退出登录`,children:(0,J.jsx)(`button`,{type:`button`,className:`sb-logout`,onClick:r,"aria-label":`退出登录`,children:(0,J.jsx)(y,{size:16})})})]})]}),(0,J.jsx)(`div`,{className:`nav-backdrop`,"aria-hidden":`true`,onClick:()=>c(!1)}),(0,J.jsx)(`main`,{className:`main`,children:i})]})}var at={error:{icon:m},success:{icon:s},info:{icon:r},warn:{icon:m}};function ot({tone:e,children:t,actions:n}){let r=at[e].icon;return(0,J.jsxs)(`div`,{className:`banner banner-${e}`,role:e===`error`||e===`warn`?`alert`:`status`,children:[(0,J.jsx)(r,{className:`banner-ico`,size:15,"aria-hidden":`true`}),(0,J.jsx)(`div`,{className:`banner-body`,children:t}),n?(0,J.jsx)(`div`,{className:`banner-actions`,children:n}):null]})}function st(e){var t=e&&typeof e.querySelectorAll==`function`?e:document,n=document.documentElement,r={};function i(e,t){r[e]!==t&&(r[e]=t,n.style.setProperty(e,t))}var a=window.matchMedia(`(prefers-reduced-motion: reduce)`).matches,o=!0,s=[`x`,`y`,`z`,`rx`,`ry`,`rz`,`fog`,`dim`],c={x:0,y:0,z:0,rx:0,ry:0,rz:0,fog:.18,dim:1},l={x:`px`,y:`px`,z:`px`,rx:`deg`,ry:`deg`,rz:`deg`},u={x:`--cam-x`,y:`--cam-y`,z:`--cam-z`,rx:`--cam-rx`,ry:`--cam-ry`,rz:`--cam-rz`,fog:`--fog`,dim:`--scene-dim`};function d(e){return function(){e|=0,e=e+1831565813|0;var t=Math.imul(e^e>>>15,1|e);return t=t+Math.imul(t^t>>>7,61|t)^t,((t^t>>>14)>>>0)/4294967296}}var f=[{sel:`.dust.d3`,count:14,min:.9,max:1.5,seed:20261004},{sel:`.dust.d2`,count:10,min:1.3,max:2,seed:77110203},{sel:`.dust.d1`,count:6,min:1.8,max:2.8,seed:31415926}];function p(){f.forEach(function(e){for(var n=t.querySelectorAll(e.sel),r=0;r<n.length;r+=1){n[r].innerHTML=``;for(var i=d(e.seed),a=document.createDocumentFragment(),o=0;o<e.count;o+=1){var s=document.createElement(`i`),c=e.min+i()*(e.max-e.min);s.style.left=(i()*100).toFixed(2)+`%`,s.style.top=(i()*100).toFixed(2)+`%`,s.style.width=c.toFixed(2)+`px`,s.style.height=c.toFixed(2)+`px`,s.style.animationDelay=(i()*3200).toFixed(0)+`ms`,a.appendChild(s)}n[r].appendChild(a)}})}var m=[];function h(e){var t=e.getBoundingClientRect();return t.top+window.pageYOffset+t.height/2}function g(){m=[].slice.call(t.querySelectorAll(`[data-cam]`)).map(function(e){var t={},n=e.getAttribute(`data-cam`);if(n)try{t=JSON.parse(n)}catch{console.warn(`[scene] data-cam 不是合法 JSON,已忽略:`,e,n),t={}}return{at:h(e),cam:t}}),m.sort(function(e,t){return e.at-t.at})}function _(e){return e<.5?2*e*e:1-(-2*e+2)**2/2}function v(e){if(!m.length)return Object.assign({},c);for(var t=0;t<m.length-1&&e>m[t+1].at;)t+=1;var n=m[t],r=m[t+1],i=r?e<=n.at?0:(e-n.at)/(r.at-n.at):1;i=Math.max(0,Math.min(1,i));for(var a=_(i),o={},l=0;l<s.length;l+=1){var u=s[l],d=n.cam[u]===void 0?c[u]:n.cam[u];o[u]=d+((r&&r.cam[u]!==void 0?r.cam[u]:d)-d)*a}return o}var y=.16,b=null,x=null,S=0,C=0;function w(e){for(var t=0;t<s.length;t+=1){var n=s[t],r=l[n]||``;i(u[n],e[n].toFixed(3)+r)}}function T(e){var t=S?Math.min((e-S)/1e3,.12):.016;S=e,b||=Object.assign({},x);for(var n=a?1:1-Math.exp(-t/y),r=!0,i=0;i<s.length;i+=1){var o=s[i],c=x[o]-b[o];b[o]+=c*n;var l=Math.max(.0015,Math.abs(x[o])*.0012);Math.abs(c)>l&&(r=!1)}if(w(b),r){b=Object.assign({},x),w(x),C=0,S=0;return}C=requestAnimationFrame(T)}function E(){C||=(S=0,requestAnimationFrame(T))}function D(){if(o){var e=document.documentElement,t=Math.max(1,e.scrollHeight-window.innerHeight);i(`--scroll-p`,(window.pageYOffset/t).toFixed(4)),x=v(window.pageYOffset+window.innerHeight/2),E()}}var O={tx:0,ty:0,x:0,y:0},k=0,A=0,ee=window.matchMedia(`(hover: hover) and (pointer: fine)`).matches;function j(){i(`--look-x`,O.x.toFixed(4)),i(`--look-y`,O.y.toFixed(4))}function M(e){var t=A?Math.min((e-A)/1e3,.12):.016;A=e;var n=1-Math.exp(-t/y);O.x+=(O.tx-O.x)*n,O.y+=(O.ty-O.y)*n,j(),Math.abs(O.tx-O.x)>8e-4||Math.abs(O.ty-O.y)>8e-4?k=requestAnimationFrame(M):(O.x=O.tx,O.y=O.ty,j(),k=0,A=0)}function N(e){document.hidden||(O.tx=(e.clientX/window.innerWidth-.5)*2,O.ty=(e.clientY/window.innerHeight-.5)*2,k||=(A=0,requestAnimationFrame(M)))}function P(){O.tx=0,O.ty=0,k||=(A=0,requestAnimationFrame(M))}function te(){!a&&ee&&(window.addEventListener(`pointermove`,N,{passive:!0}),document.addEventListener(`pointerleave`,P))}var F=null,I=null,L=null;function ne(){if(p(),g(),!m.length){n.setAttribute(`data-scene-ready`,`static`);return}D(),te();var e=!1;F=function(){e||(e=!0,requestAnimationFrame(function(){e=!1,D()}))},I=function(){o&&(g(),D())},L=function(){o&&(g(),D())},window.addEventListener(`scroll`,F,{passive:!0}),window.addEventListener(`resize`,I),window.addEventListener(`load`,L),document.fonts&&document.fonts.ready&&document.fonts.ready.then(function(){o&&(g(),D())}),n.setAttribute(`data-scene-ready`,`1`)}function R(){o=!1,F&&window.removeEventListener(`scroll`,F),I&&window.removeEventListener(`resize`,I),L&&window.removeEventListener(`load`,L),window.removeEventListener(`pointermove`,N),document.removeEventListener(`pointerleave`,P),C&&cancelAnimationFrame(C),k&&cancelAnimationFrame(k),C=0,k=0,[].slice.call(t.querySelectorAll(`.dust`)).forEach(function(e){e.innerHTML=``}),Object.keys(u).forEach(function(e){n.style.removeProperty(u[e])}),n.style.removeProperty(`--scroll-p`),n.style.removeProperty(`--look-x`),n.style.removeProperty(`--look-y`),r={},n.removeAttribute(`data-scene-ready`)}return ne(),R}var ct=e=>e,lt=[{tint:`var(--iris)`,a:`0deg`,r:`430px`,y:`-40px`,w:`300px`,h:`520px`,z:`-18deg`,x:`16deg`,o:`.95`,e:`.70`,hot:`.26`,dof:`0px`,dur:`15s`,delay:`0s`},{tint:`var(--accent-cyan)`,a:`72deg`,r:`448px`,y:`10px`,w:`255px`,h:`470px`,z:`12deg`,x:`-22deg`,o:`.82`,e:`.18`,hot:`.05`,dof:`0px`,dur:`19s`,delay:`3s`},{tint:`var(--brand-500)`,a:`144deg`,r:`424px`,y:`-60px`,w:`325px`,h:`560px`,z:`-24deg`,x:`19deg`,o:`.90`,e:`.52`,hot:`.18`,dof:`0px`,dur:`17s`,delay:`6.5s`},{tint:`var(--brand-400)`,a:`216deg`,r:`456px`,y:`20px`,w:`270px`,h:`490px`,z:`16deg`,x:`-14deg`,o:`.76`,e:`.14`,hot:`.04`,dof:`0px`,dur:`21s`,delay:`10s`},{tint:`var(--accent-blue)`,a:`288deg`,r:`436px`,y:`-30px`,w:`310px`,h:`535px`,z:`-14deg`,x:`24deg`,o:`.88`,e:`.30`,hot:`.12`,dof:`0px`,dur:`18s`,delay:`13.5s`},{tint:`var(--brand-500)`,a:`36deg`,r:`860px`,y:`40px`,w:`400px`,h:`560px`,z:`-22deg`,x:`26deg`,o:`.62`,e:`.20`,hot:`.06`,dof:`2.6px`,dur:`26s`,delay:`2s`,soft:!0},{tint:`var(--accent-cyan)`,a:`126deg`,r:`900px`,y:`-20px`,w:`360px`,h:`520px`,z:`18deg`,x:`-28deg`,o:`.52`,e:`.10`,hot:`.03`,dof:`2.6px`,dur:`30s`,delay:`9s`,soft:!0},{tint:`var(--iris)`,a:`216deg`,r:`840px`,y:`60px`,w:`440px`,h:`620px`,z:`-28deg`,x:`20deg`,o:`.58`,e:`.30`,hot:`.09`,dof:`2.6px`,dur:`24s`,delay:`15s`,soft:!0},{tint:`var(--brand-400)`,a:`306deg`,r:`890px`,y:`-10px`,w:`380px`,h:`540px`,z:`14deg`,x:`-24deg`,o:`.48`,e:`.08`,hot:`.03`,dof:`2.6px`,dur:`33s`,delay:`19s`,soft:!0}];function ut(){return(0,J.jsxs)(`div`,{className:`scene`,"aria-hidden":`true`,children:[(0,J.jsxs)(`div`,{className:`rig`,children:[(0,J.jsx)(`div`,{className:`tilt`,children:(0,J.jsx)(`div`,{className:`stage`,children:lt.map((e,t)=>(0,J.jsx)(`i`,{className:e.soft?`pl soft`:`pl`,style:ct({"--tint":e.tint,"--a":e.a,"--r":e.r,"--y":e.y,"--w":e.w,"--h":e.h,"--z":e.z,"--x":e.x,"--o":e.o,"--e":e.e,"--hot":e.hot,"--dof":e.dof,"--sheen-dur":e.dur,"--sheen-delay":e.delay})},t))})}),(0,J.jsx)(`div`,{className:`dust d3`}),(0,J.jsx)(`div`,{className:`dust d2`}),(0,J.jsx)(`div`,{className:`dust d1`})]}),(0,J.jsx)(`div`,{className:`core`}),(0,J.jsx)(`div`,{className:`nucleus`}),(0,J.jsx)(`div`,{className:`beam b1`}),(0,J.jsx)(`div`,{className:`beam b2`}),(0,J.jsx)(`div`,{className:`fog`}),(0,J.jsx)(`div`,{className:`dimmer`}),(0,J.jsx)(`div`,{className:`vignette`}),(0,J.jsx)(`div`,{className:`noise`})]})}function dt(){return(0,x.useEffect)(()=>st(document),[]),(0,J.jsx)(ut,{})}function ft({session:e,mockHint:r}){let[o,s]=(0,x.useState)(``),[c,l]=(0,x.useState)(!1),[u,d]=(0,x.useState)(!1),[f,p]=(0,x.useState)(null),m=(0,x.useRef)(null);return(0,x.useEffect)(()=>{let e=m.current;if(!e||!window.matchMedia(`(hover: hover) and (pointer: fine)`).matches)return;let t=t=>{let n=e.getBoundingClientRect();e.style.setProperty(`--mx`,`${t.clientX-n.left}px`),e.style.setProperty(`--my`,`${t.clientY-n.top}px`)};return e.addEventListener(`pointermove`,t),()=>e.removeEventListener(`pointermove`,t)},[]),(0,J.jsxs)(`div`,{className:`login-wrap landing`,children:[(0,J.jsx)(dt,{}),(0,J.jsxs)(`div`,{className:`login-card`,ref:m,children:[(0,J.jsx)(`span`,{className:`login-glow`,"aria-hidden":`true`}),(0,J.jsxs)(`div`,{className:`login-brand`,children:[(0,J.jsx)(Y,{size:30}),(0,J.jsx)(`span`,{className:`b-name`,children:`途关`}),(0,J.jsx)(`span`,{className:`b-en`,children:`Waygate`})]}),(0,J.jsx)(`h1`,{children:`登录控制台`}),(0,J.jsx)(`p`,{className:`sub`,children:`这是自用工具,只有一个管理口令。口令校验在服务端完成,前端不保存明文。`}),(0,J.jsxs)(`form`,{className:`login-form`,onSubmit:async t=>{if(t.preventDefault(),!u){d(!0),p(null);try{await e.login(o)}catch(e){p(e instanceof R?e:new R(String(e),0,0)),d(!1)}}},children:[(0,J.jsxs)(`div`,{className:`login-field`,children:[(0,J.jsx)(`label`,{htmlFor:`pw`,children:`管理口令`}),(0,J.jsxs)(`div`,{className:`login-input`,children:[(0,J.jsx)(t,{size:15,color:`var(--text-faint)`,"aria-hidden":!0}),(0,J.jsx)(`input`,{id:`pw`,type:c?`text`:`password`,value:o,autoFocus:!0,autoComplete:`current-password`,placeholder:`输入管理口令`,onChange:e=>s(e.target.value)}),(0,J.jsx)(`button`,{type:`button`,className:`login-eye`,"aria-label":c?`隐藏口令`:`显示口令`,onClick:()=>l(e=>!e),children:c?(0,J.jsx)(n,{size:15}):(0,J.jsx)(i,{size:15})})]})]}),f?(0,J.jsx)(ot,{tone:`error`,children:f.message}):null,(0,J.jsxs)(`button`,{type:`submit`,className:`btn btn-primary login-submit`,disabled:u||!o,children:[u?(0,J.jsx)(a,{size:16}):null,u?`正在验证…`:`进入控制台`]})]}),(0,J.jsx)(`p`,{className:`login-hint`,children:r?`当前为 Mock 模式(npm run dev:mock),口令固定为 ${r}。`:`口令首次启动时若未配置 RELAY_ADMIN_PASSWORD_HASH,会打印到服务端 stdout 一次。`})]})]})}function pt(){return(0,J.jsx)(`div`,{className:`login-wrap`,children:(0,J.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,alignItems:`center`,gap:16},children:[(0,J.jsx)(Y,{size:40}),(0,J.jsx)(`div`,{style:{fontSize:12.5,color:`var(--text-ghost)`},children:`正在确认会话…`})]})})}var mt=`modulepreload`,ht=function(e,t){return new URL(e,t).href},gt={},_t=function(e){return e.pathname.endsWith(`.css`)},$=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e,i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}function s(e){return import.meta.resolve?new URL(import.meta.resolve(e)):new URL(e,import.meta.url)}r=o(t.map(t=>{t=ht(t,n);let r=s(t);if(r.href in gt)return;gt[r.href]=!0;let i=_t(r);if(e===void 0){e={all:new Set,styles:new Set};let t=document.getElementsByTagName(`link`);for(let n=t.length-1;n>=0;n--){let r=t[n];e.all.add(r.href),r.rel===`stylesheet`&&e.styles.add(r.href)}}if((i?e.styles:e.all).has(r.href))return;let o=document.createElement(`link`);if(o.rel=i?`stylesheet`:mt,i||(o.as=`script`),o.crossOrigin=``,o.href=r.href,a&&o.setAttribute(`nonce`,a),document.head.appendChild(o),i)return new Promise((e,t)=>{o.addEventListener(`load`,e),o.addEventListener(`error`,()=>t(Error(`Unable to preload CSS for ${r}`)))})}).filter(e=>e!==void 0))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})},vt=(0,x.lazy)(()=>$(()=>import(`./LandingPage-Cwbtdh2I.js`).then(e=>({default:e.LandingPage})),__vite__mapDeps([0,1,2,3]),import.meta.url)),yt=(0,x.lazy)(()=>$(()=>import(`./OverviewPage-AeWM2Lg5.js`).then(e=>({default:e.OverviewPage})),__vite__mapDeps([4,1,5,6,7,8,9]),import.meta.url)),bt=(0,x.lazy)(()=>$(()=>import(`./UsagePage-oe_p1Aiz.js`).then(e=>({default:e.UsagePage})),__vite__mapDeps([10,1,5,6,7,8,9]),import.meta.url)),xt=(0,x.lazy)(()=>$(()=>import(`./ClientsPage-D5F7-rin.js`).then(e=>({default:e.ClientsPage})),__vite__mapDeps([11,1,5,12,13,6,7,14,15]),import.meta.url)),St=(0,x.lazy)(()=>$(()=>import(`./ApiKeysPage-CdguoLCa.js`).then(e=>({default:e.ApiKeysPage})),__vite__mapDeps([16,1,5,12,13,6]),import.meta.url)),Ct=(0,x.lazy)(()=>$(()=>import(`./RequestsPage-ivdKipjv.js`).then(e=>({default:e.RequestsPage})),__vite__mapDeps([17,1,5,6,14,13,8]),import.meta.url)),wt=(0,x.lazy)(()=>$(()=>import(`./SettingsPage-PX7wr7r_.js`).then(e=>({default:e.SettingsPage})),__vite__mapDeps([18,1,2,5,12,13,14,15]),import.meta.url));function Tt(){let[e,t]=(0,x.useState)(()=>window.location.pathname);return(0,x.useEffect)(()=>{let e=()=>t(window.location.pathname);return window.addEventListener(`popstate`,e),()=>window.removeEventListener(`popstate`,e)},[]),e}var Et=`Waygate — 控制台`;function Dt(){return(0,J.jsx)(`div`,{style:{display:`flex`,alignItems:`center`,justifyContent:`center`,minHeight:`50vh`,fontSize:12.5,color:`var(--text-ghost)`},children:`加载中…`})}function Ot(){let{route:e,navigate:t}=ne(),n=Ke();return(0,x.useEffect)(()=>{document.title=Et},[]),(0,x.useEffect)(()=>{window.location.hash||(window.location.hash=`#/overview`)},[]),n.status===`loading`?(0,J.jsx)(pt,{}):n.status===`anon`?(0,J.jsx)(ft,{session:n,mockHint:null}):(0,J.jsx)(it,{route:e,navigate:t,expiresAt:n.expiresAt,onLogout:()=>void n.logout(),children:(0,J.jsxs)(x.Suspense,{fallback:(0,J.jsx)(Dt,{}),children:[e===`overview`?(0,J.jsx)(yt,{navigate:t}):null,e===`usage`?(0,J.jsx)(bt,{}):null,e===`clients`?(0,J.jsx)(xt,{}):null,e===`keys`?(0,J.jsx)(St,{}):null,e===`requests`?(0,J.jsx)(Ct,{}):null,e===`settings`?(0,J.jsx)(wt,{}):null]})})}function kt(){let e=Tt(),t=C(e)===`console`;return(0,x.useEffect)(()=>{F()},[e]),t?(0,J.jsx)(Ot,{}):(0,J.jsx)(x.Suspense,{fallback:null,children:(0,J.jsx)(vt,{})})}var At=(0,x.createContext)(null),jt={error:{icon:m,defaultMs:8e3},warn:{icon:m,defaultMs:8e3},success:{icon:s,defaultMs:5e3},info:{icon:r,defaultMs:5e3}};function Mt({children:e}){let[t,n]=(0,x.useState)([]),r=(0,x.useRef)(1),i=(0,x.useCallback)(e=>{n(t=>t.filter(t=>t.id!==e))},[]),a=(0,x.useCallback)(e=>{let t=r.current++;return n(n=>[...n,{...e,id:t}].slice(-4)),t},[]),o=(0,x.useMemo)(()=>({push:a,dismiss:i}),[a,i]);return(0,J.jsxs)(At.Provider,{value:o,children:[e,typeof document<`u`?(0,Je.createPortal)((0,J.jsx)(`div`,{className:`toast-stack`,"aria-live":`polite`,"aria-atomic":`false`,children:t.map(e=>(0,J.jsx)(Nt,{item:e,onDismiss:i},e.id))}),document.body):null]})}function Nt({item:e,onDismiss:t}){let{icon:n,defaultMs:r}=jt[e.tone],i=e.durationMs??r,[a,o]=(0,x.useState)(!1),[s,c]=(0,x.useState)(i);return(0,x.useEffect)(()=>{if(a)return;let n=Date.now(),r=window.setInterval(()=>{let a=i-(Date.now()-n);a<=0?(window.clearInterval(r),t(e.id)):c(a)},100);return()=>window.clearInterval(r)},[a,i,e.id,t]),(0,J.jsxs)(`div`,{className:`toast toast-${e.tone}`,role:e.tone===`error`||e.tone===`warn`?`alert`:`status`,onMouseEnter:()=>o(!0),onMouseLeave:()=>o(!1),onFocus:()=>o(!0),onBlur:()=>o(!1),children:[(0,J.jsx)(n,{className:`toast-ico`,size:15,"aria-hidden":`true`}),(0,J.jsx)(`div`,{className:`toast-body`,children:e.message}),(0,J.jsx)(`button`,{type:`button`,className:`toast-close`,"aria-label":`关闭提示`,onClick:()=>t(e.id),children:`×`}),(0,J.jsx)(`span`,{className:`toast-progress${a?` paused`:``}`,style:{animationDuration:`${i}ms`},"aria-hidden":`true`})]})}function Pt(){return(0,x.useContext)(At)??{push:()=>0,dismiss:()=>{}}}w(),T(),F();for(let e of[`icon`,`apple-touch-icon`]){let t=document.createElement(`link`);t.rel=e,t.type=`image/svg+xml`,t.href=`/icon.svg?v=2`,document.head.appendChild(t)}var Ft=document.getElementById(`root`);if(!Ft)throw Error(`#root 未找到 —— index.html 被改坏了`);(0,S.createRoot)(Ft).render((0,J.jsx)(x.StrictMode,{children:(0,J.jsx)(Mt,{children:(0,J.jsx)(kt,{})})}));export{me as A,Le as C,he as D,Re as E,R as M,fe as O,Ie as S,Pe as T,be as _,Ze as a,Ee as b,q as c,xe as d,De as f,ve as g,we as h,nt as i,de as j,pe as k,Me as l,Oe as m,dt as n,Y as o,ye as p,ot as r,Ke as s,Pt as t,Ae as u,ke as v,Te as w,Ce as x,je as y};
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./LandingPage-P2QNDFaP.js","./vendor-befEYGHM.js","./accessUrl-DbL5DLDz.js","./LandingPage-B2hMgbmZ.css","./OverviewPage-BgBo_XhF.js","./Select-G6AhT0TA.js","./PageSkeleton-DG-Dj4_9.js","./sharedWindow-FDfq75PI.js","./useFx-xcrp_LHB.js","./ClientMetricTip-C2VuiT4-.js","./UsagePage-cxZ-GnpO.js","./ClientsPage-Dy68uQDl.js","./Modal-B-rIrvXS.js","./useFocusTrap-Cj84bnpH.js","./Drawer-CleQGhRU.js","./Switch-0KA1AbiV.js","./ApiKeysPage-Ck0Gry6E.js","./RequestsPage-CVB0wpCH.js","./SettingsPage-B4Mew-7b.js"])))=>i.map(i=>d[i]);
2
+ import{$ as e,D as t,F as n,O as r,P as i,S as a,T as o,U as s,Y as c,b as l,c as u,d,it as f,nt as p,r as m,rt as h,s as g,tt as _,v,x as y,y as b}from"./vendor-befEYGHM.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),t.credentials=e.crossOrigin===`use-credentials`?`include`:e.crossOrigin===`anonymous`?`omit`:`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var x=f(),S=p();function C(e=window.location.pathname){let t=e.replace(/\/+$/,``)||`/`;return t===`/console`||t.startsWith(`/console/`)?`console`:`landing`}function w(e=!1){let{pathname:t,hash:n}=window.location;if(C(t)===`console`||!n.startsWith(`#/`))return;let r=`/console${n}`;e?window.location.replace(r):window.history.replaceState(null,``,r)}function T(){window.addEventListener(`hashchange`,()=>w(!0))}var E=`relay.theme`,D=`system`;function O(){try{return window.matchMedia?.(`(prefers-color-scheme: light)`).matches?`light`:`dark`}catch{return`dark`}}function k(e,t=window.location.pathname,n=window.location.hash){return e===`system`?O():e}function A(){try{let e=window.localStorage.getItem(E);return e===`light`||e===`dark`||e===`system`?e:D}catch{return D}}function ee(e){document.documentElement.dataset.theme=e}var j=null,M=new Set;function N(){if(j===null){let e=document.documentElement.dataset.theme,t=A();j={theme:e===`light`||e===`dark`?e:k(t),preference:t}}return j}function P(e){return M.add(e),()=>M.delete(e)}function te(e){try{window.localStorage.setItem(E,e)}catch{}F()}function F(){let e=A(),t=k(e);ee(t),j={theme:t,preference:e},M.forEach(e=>e())}typeof window<`u`&&(window.matchMedia?.(`(prefers-color-scheme: light)`).addEventListener?.(`change`,()=>{A()===`system`&&F()}),window.addEventListener(`storage`,e=>{(e.key===null||e.key===E)&&F()}));var I=[`overview`,`usage`,`clients`,`keys`,`requests`,`settings`];function L(e){let t=e.replace(/^#\/?/,``).split(`?`)[0];return I.includes(t)?t:`overview`}function ne(){let[e,t]=(0,x.useState)(()=>L(window.location.hash));return(0,x.useEffect)(()=>{let e=()=>t(L(window.location.hash));return window.addEventListener(`hashchange`,e),()=>window.removeEventListener(`hashchange`,e)},[]),{route:e,navigate:e=>{window.location.hash=`#/${e}`}}}var R=class extends Error{code;status;retryAfterSeconds;constructor(e,t,n,r){super(e),this.name=`ApiError`,this.code=t,this.status=n,this.retryAfterSeconds=r}get isSessionExpired(){return this.code===40102}},z=new Set;function re(e){return z.add(e),()=>z.delete(e)}function ie(e){z.forEach(t=>t(e))}async function ae(e){let t=await e.text(),n=null;try{n=t?JSON.parse(t):null}catch{throw new R(`服务端返回了非 JSON 响应(HTTP ${e.status})`,0,e.status)}if(!n||typeof n.code!=`number`)throw new R(`响应缺少统一信封(HTTP ${e.status})`,0,e.status);if(n.code===0)return n.data;let r=n.data?.retryAfterSeconds;throw new R(n.message||`请求失败(code ${n.code})`,n.code,e.status,r)}var B=2e4;function oe(e,t){let n=new AbortController,r=!1,i=()=>n.abort(e?.reason);e&&(e.aborted?n.abort(e.reason):e.addEventListener(`abort`,i,{once:!0}));let a=t===null?void 0:setTimeout(()=>{r=!0,n.abort()},t);return{signal:n.signal,isTimedOut:()=>r,dispose:()=>{a!==void 0&&clearTimeout(a),e?.removeEventListener(`abort`,i)}}}function se(e){return e instanceof DOMException&&e.name===`AbortError`}async function V(e,t){let n=(t?.method??`GET`).toUpperCase(),r=oe(t?.signal,n===`GET`?B:null),i=new Headers(t?.headers);i.has(`accept`)||i.set(`Accept`,`application/json`),t?.body&&!i.has(`content-type`)&&i.set(`Content-Type`,`application/json`);let a;try{a=await fetch(e,{...t,signal:r.signal,credentials:`same-origin`,headers:i})}catch(e){throw r.dispose(),r.isTimedOut()?new R(`请求超时(${B/1e3}s 无响应),稍后重试。`,0,0):se(e)?e:new R(`连不上本机服务。确认后端已在 127.0.0.1:8787 启动。`,0,0)}try{let e=await ae(a);if(!a.ok)throw new R(`请求失败(HTTP ${a.status})`,0,a.status);return e}catch(e){throw r.isTimedOut()?new R(`请求超时(${B/1e3}s 无响应),稍后重试。`,0,0):e}finally{r.dispose()}}async function H(e,t){try{return await V(e,t)}catch(e){throw e instanceof R&&e.isSessionExpired&&ie(e),e}}function U(e){let t=new URLSearchParams;Object.entries(e).forEach(([e,n])=>{n!=null&&n!==``&&t.set(e,String(n))});let n=t.toString();return n?`?${n}`:``}var W=new Map,G=new Map;function ce(){W.clear(),G.clear()}function le(e,t){W.has(e)&&W.set(e,t(W.get(e)))}function ue(e,t,n){let r=G.get(e);if(r&&!n)return r;let i=t().then(t=>(G.get(e)===i&&W.set(e,t),t));return G.set(e,i),i.finally(()=>{G.get(e)===i&&G.delete(e)}).catch(()=>{}),i}function de(e,t,n={}){let r=n.enabled??!0,i=n.cacheKey,a=r&&i!==void 0&&W.has(i),[o,s]=(0,x.useState)(()=>a?W.get(i):null),[c,l]=(0,x.useState)(null),[u,d]=(0,x.useState)(r),[f,p]=(0,x.useState)(!a),m=(0,x.useRef)(0),h=(0,x.useRef)(e);h.current=e;let g=(0,x.useRef)(i);g.current=i;let _=(0,x.useCallback)(e=>{let t=++m.current,n=g.current;d(!0),(n===void 0?h.current():ue(n,()=>h.current(),e)).then(e=>{t===m.current&&(s(e),l(null),d(!1),p(!1))},e=>{t!==m.current||se(e)||(l(e instanceof R?e:new R(String(e),0,0)),d(!1),p(!1))})},[]);return(0,x.useEffect)(()=>{if(!r){m.current+=1,s(null),l(null),d(!1),p(!0);return}i!==void 0&&W.has(i)&&(s(W.get(i)),l(null),p(!1)),_(!1)},[r,i,...t]),{data:o,error:c,loading:u,initial:f,reload:(0,x.useCallback)(()=>_(!0),[_])}}var fe={today:`今日`,"1h":`最近 1 小时`,"24h":`最近 24 小时`,"7d":`最近 7 天`,"30d":`最近 30 天`},pe=Object.keys(fe).map(e=>({value:e,label:fe[e]}));function me(e,t){return t&&new Date(t).getTime()<Date.now()?`exp`:e?`live`:`off`}var he={live:`启用`,off:`已停用`,exp:`已过期`},ge=new Intl.NumberFormat(`zh-CN`),_e=new Intl.NumberFormat(`zh-CN`,{minimumFractionDigits:2,maximumFractionDigits:2});function ve(e){return e==null||Number.isNaN(e)?`--`:ge.format(Math.round(e))}function ye(e){return e==null||Number.isNaN(e)?`--`:_e.format(e)}function be(e,t=1){return e==null||Number.isNaN(e)?`--`:`${(e*100).toFixed(t)}%`}function xe(e,t=1){return`${((Number.isFinite(e)?Math.max(0,Math.min(1,e)):0)*100).toFixed(t)}%`}var Se=[{limit:0x38d7ea4c68000,div:0x38d7ea4c68000,digits:2,suffix:`Q`},{limit:0xe8d4a51000,div:0xe8d4a51000,digits:2,suffix:`T`},{limit:1e9,div:1e9,digits:2,suffix:`B`},{limit:1e6,div:1e6,digits:2,suffix:`M`},{limit:1e3,div:1e3,digits:1,suffix:`K`}];function Ce(e){if(e==null||Number.isNaN(e))return`--`;let t=Math.round(e),n=Se.find(e=>Math.abs(t)>=e.limit);return n?`${(t/n.div).toFixed(n.digits)}${n.suffix}`:String(t)}function we(e){return e==null||Number.isNaN(e)?`--`:e<1e3?`${Math.round(e)}ms`:e<6e4?`${(e/1e3).toFixed(1)}s`:`${Math.floor(e/6e4)}m${Math.round(e%6e4/1e3)}s`}function Te(e,t,n){let r=e??0;if(r<=0||t==null||t<=0)return null;let i=n==null?t:t-n;return i<=0?null:r/(i/1e3)}function Ee(e){return e==null||Number.isNaN(e)?`--`:`${e.toFixed(1)} t/s`}function De(e){if(!e)return`--`;let t=new Date(e);return Number.isNaN(t.getTime())?`--`:t.toLocaleTimeString(`zh-CN`,{hour12:!1})}function Oe(e){if(!e)return`--`;let t=new Date(e);return Number.isNaN(t.getTime())?`--`:`${t.toLocaleDateString(`zh-CN`)} ${t.toLocaleTimeString(`zh-CN`,{hour12:!1})}`}function ke(e){if(!e)return`--`;let t=new Date(e).getTime();if(Number.isNaN(t))return`--`;let n=Date.now()-t;if(n<0){let e=-n;return e<6e4?`马上`:e<36e5?`${Math.floor(e/6e4)} 分钟后`:e<864e5?`${Math.floor(e/36e5)} 小时后`:`${Math.floor(e/864e5)} 天后`}let r=Math.floor(n/6e4);if(r<1)return`刚刚`;if(r<60)return`${r} 分钟前`;let i=Math.floor(r/60);if(i<24)return`${i} 小时前`;let a=Math.floor(i/24);return a<30?`${a} 天前`:`${Math.floor(a/30)} 个月前`}function Ae(e){let t=e.match(/^(\d{4})-(\d{2})-(\d{2})(?:T(\d{2}))?/);if(!t)return e.slice(5,10);let n=`${Number(t[2])}/${Number(t[3])}`;return t[4]===void 0?n:`${n} ${Number(t[4])}时`}function je(e){switch(e.type){case`all`:return`全部模型`;case`family`:return`仅 ${e.value} 系`;case`tag`:return`仅 ${e.value}`;case`models`:return`指定 ${e.value.length} 个模型`;default:return`未知范围`}}var Me=`upstream_credential_invalid`;function Ne(e,t=Me){return e.split(`,`).includes(t)}function Pe(e,t=``){return Ne(t)||e===401?`fatal`:e>=400?`warn`:`live`}var Fe={[Me]:`上游访问密钥失效`,"upstream unreachable":`上游不可达`,"upstream empty body":`上游返回空响应`,upstream_error:`上游错误`,"bad request body":`请求体不合法`,"model not permitted":`模型未授权`,"model not found":`模型不存在`,"concurrency limit":`本机并发上限`,"rate limited":`命中上游限流`,rate_limited:`命中上游限流`,"upstream timeout":`上游超时`,model_not_available:`账号未开通此模型`,invalid_max_tokens:`max_tokens 不合法`,context_length_exceeded:`上下文超限`,upstream_11101:`上游要求强制流式`,upstream_11128:`上游渠道校验拒绝(提示指纹)`,retried:`已自动重试`,"cache hit":`命中缓存`,system_injected:`已补 system`,developer_role_normalized:`已规范 developer 角色`,stream_options_stripped:`已移除 stream_options`,sysprompt_degraded_retry:`命中渠道校验,已降级重试`,stream_aborted:`流式中断`,client_detached:`客户端已断开`,usage_missing:`上游未返回用量`,"minimax tokens unavailable":`MiniMax token 不可用`,"token refresh failed":`上游 token 刷新失败`,"missing credential":`缺少上游访问凭证`,"wb oauth unavailable":`WorkBuddy 授权服务不可用`,"missing wb oauth credential":`WorkBuddy 未导入授权`,"wb token refresh failed":`WorkBuddy 授权刷新失败`,"qoder credential invalid":`Qoder 凭证无效`,"multiplier-unknown":`倍率未知(历史:积分按中性估算)`,cache_discounted:`缓存命中已按折扣计(历史)`,credits_from_upstream:`上游实扣积分`,credits_unknown:`上游未回报积分`,credits_recalibrated:`历史积分已重算`,estimate_voided:`历史估算已作废(上游未回报)`};function Ie(e){if(!e)return`-`;let t=e.split(`,`)[0];return Fe[t]??t}function Le(e){return e?e.split(`,`).map(e=>e.trim()).filter(Boolean).map(e=>Fe[e]??e):[]}function Re(e){return e.upstreamCode===11102?`11102:当前账号未开通该模型。该项已在模型表标为未验证,不会自动删除——订阅变动后可能再开。`:e.upstreamCode===11128?`11128:上游返回业务码 11128(上游原文「Illegal API invocation from an unapproved channel」):本次请求的 system 提示命中了上游对第三方客户端模板的指纹校验。本服务已在转发前改写模板行,并在被拒时自动降级为中性提示重试一次,均未通过;请检查「客户端与密钥 → 提供商 → system 提示改写」是否被关闭,或把该请求的特征反馈给维护者。`:e.upstreamCode===11101?`11101:上游拒绝了非流式请求。本服务已强制改写为流式,出现此码说明上游协议变更。`:e.upstreamCode===11133?`11133:max_tokens 过小。已提升到下限后重试一次。`:Ne(e.note)?`上游访问密钥失效是这套方案唯一会让服务停摆的状态:所有客户端共用同一把上游访问密钥,它一失效即整体不可用。去「客户端与密钥 → 提供商」的「修改」里换新。`:null}var ze=[{displayName:`Hy4 preview`,id:`hy4-preview`,tag:`限时免费`,multiplier:0},{displayName:`Hy3`,id:`hy3`,tag:`限时免费`,multiplier:0},{displayName:`Space-Bunny`,id:`space-bunny`,tag:`限时折扣`,multiplier:.03},{displayName:`Deepseek-V4.1-Flash`,id:`deepseek-v4.1-flash`,tag:null,multiplier:.11},{displayName:`Deepseek-V4-Pro`,id:`deepseek-v4-pro`,tag:null,multiplier:.51},{displayName:`GLM-5.3`,id:`glm-5.3`,tag:`订阅优先`,multiplier:.79},{displayName:`GLM-5.3-Flash`,id:`glm-5.3-flash`,tag:`订阅优先`,multiplier:.06},{displayName:`GLM-5.3-FlashX`,id:`glm-5.3-flashx`,tag:`订阅优先`,multiplier:.14},{displayName:`GLM-5.2`,id:`glm-5.2`,tag:null,multiplier:.79},{displayName:`GLM-5.1`,id:`glm-5.1`,tag:null,multiplier:.79},{displayName:`GLM-5v-Turbo`,id:`glm-5v-turbo`,tag:null,multiplier:.71},{displayName:`MiniMax-M3`,id:`minimax-m3`,tag:null,multiplier:.25},{displayName:`Kimi-K3`,id:`kimi-k3`,tag:`订阅优先`,multiplier:1.62},{displayName:`Kimi-K2.8-Preview`,id:`kimi-k2.8-preview`,tag:`订阅优先`,multiplier:.77},{displayName:`Kimi-K2.7-Code`,id:`kimi-k2.7`,tag:null,multiplier:.57},{displayName:`Kimi-K2.6`,id:`kimi-k2.6`,tag:null,multiplier:.52},{displayName:`Step-5-Preview`,id:`step-5-preview`,tag:`订阅优先`,multiplier:.43},{displayName:`Kimi-K3-1`,id:`kimi-k3-1`,tag:`订阅优先`,multiplier:null}],Be=new Set([`kimi-k3-1`]),Ve=new Set([`step-5-preview`]);function He(e){return Be.has(e)?`upstream`:Ve.has(e)?`manual`:`seed`}var Ue={source:`seed`,fetchedAt:new Date(Date.now()-72e5).toISOString(),upstreamReachable:!0,models:ze.map(e=>({...e,family:e.id.split(`-`)[0],source:He(e.id),provider:e.id.startsWith(`MiniMax-`)||e.id.startsWith(`minimax-`)?`MiniMax Code`:`WorkBuddy`,verified:e.id===`glm-5.1`||e.id===`hy3`?0:1,enabled:!0,lastVerifiedAt:new Date(Date.now()-72e5).toISOString()}))},We=[{id:`k_8f21`,name:`Claude Code`},{id:`k_1b83`,name:`Cherry Studio`},{id:`k_9d02`,name:`Cursor`},{id:`k_c3a5`,name:`Cron Job`},{id:`k_77c1`,name:`手机端(临时)`},{id:`unidentified`,name:`未识别客户端`}];function Ge(){let e=Date.now(),t={ipWhitelist:[],maxIps:null,tokenQuota:null,usedIps:0,usedTokens:0};return[{...t,id:`k_8f21`,name:`Claude Code · 本机`,hint:`sk-waygate-4f9c…7a2e`,scope:{type:`all`},client:`Claude Code`,clients:[`Claude Code`],enabled:!0,expiresAt:null,createdAt:new Date(e-11232e5).toISOString(),lastSeenAt:new Date(e-4e4).toISOString(),requests24h:760},{...t,maxIps:3,tokenQuota:2e6,usedIps:2,usedTokens:1234567,id:`k_1b83`,name:`Cherry Studio`,hint:`sk-waygate-1b83…c40f`,scope:{type:`all`},client:`Cherry Studio`,clients:[`Cherry Studio`],enabled:!0,expiresAt:null,createdAt:new Date(e-9504e5).toISOString(),lastSeenAt:new Date(e-9e4).toISOString(),requests24h:324},{...t,id:`k_9d02`,name:`Cursor · 笔记本`,hint:`sk-waygate-9d02…3ee1`,scope:{type:`family`,value:`kimi`},client:`Cursor`,clients:[`Cursor`,`Claude Code`],enabled:!0,expiresAt:null,createdAt:new Date(e-7776e5).toISOString(),lastSeenAt:new Date(e-108e5).toISOString(),requests24h:154},{...t,id:`k_c3a5`,name:`Cron Job · 定时任务`,hint:`sk-waygate-c3a5…91d7`,scope:{type:`family`,value:`deepseek`},client:`Cron Job`,clients:[`Cron Job`],enabled:!0,expiresAt:null,createdAt:new Date(e-6912e5).toISOString(),lastSeenAt:new Date(e-3e5).toISOString(),requests24h:78},{...t,ipWhitelist:[`192.168.1.0/24`],id:`k_77c1`,name:`手机端(临时)`,hint:`sk-waygate-77c1…b8f0`,scope:{type:`all`},client:`手机端(临时)`,clients:[`手机端(临时)`],enabled:!1,expiresAt:null,createdAt:new Date(e-2592e6).toISOString(),lastSeenAt:new Date(e-2592e5).toISOString(),requests24h:0},{...t,id:`k_2e6b`,name:`测试脚本 · 本地`,hint:`sk-waygate-2e6b…0a13`,scope:{type:`tag`,value:`夜间折扣`},client:null,clients:[],enabled:!0,expiresAt:new Date(e-1728e5).toISOString(),createdAt:new Date(e-3456e6).toISOString(),lastSeenAt:new Date(e-10368e5).toISOString(),requests24h:0},{...t,id:`k_5d7f`,name:`家人共享 · 只读`,hint:`sk-waygate-5d7f…22c8`,scope:{type:`models`,value:[`glm-5.3`,`kimi-k2.7`]},client:null,clients:[],enabled:!1,expiresAt:null,createdAt:new Date(e-1728e6).toISOString(),lastSeenAt:new Date(e-432e6).toISOString(),requests24h:0}]}We.filter(e=>e.id!==`unidentified`).map(e=>e.name),Ge(),new Date().toISOString(),Date.now()+1728e6,Date.now()+22464e5,new Date().toISOString().slice(0,10),new Date(Date.now()-18e5).toISOString(),new Date(Date.now()-216e5).toISOString(),new Date(Date.now()+19008e5).toISOString(),new Date(Date.now()-24e5).toISOString(),Ue.models.map(e=>({...e}));function K(e){return{method:`POST`,body:JSON.stringify(e)}}var q={session(){return V(`/api/auth/session`)},login(e){return V(`/api/auth/login`,K({password:e}))},logout(){return V(`/api/auth/logout`,{method:`POST`})},overview(e){return H(`/api/overview${U({window:e})}`)},clients(e){return H(`/api/clients${U({window:e})}`)},requests(e){return H(`/api/requests${U({...e})}`)},requestDetail(e){return H(`/api/requests/${e}`)},keys(){return H(`/api/keys`).then(e=>e.items)},createKey(e){return H(`/api/keys`,K(e))},patchKey(e,t){return H(`/api/keys/${e}`,{method:`PATCH`,body:JSON.stringify(t)})},deleteKey(e){return H(`/api/keys/${e}`,{method:`DELETE`})},settings(){return H(`/api/settings`)},putSettings(e){return H(`/api/settings`,{method:`PUT`,body:JSON.stringify({settings:e})}).then(t=>(le(`settings`,n=>({...n,version:t.version,groups:n.groups.map(t=>({...t,items:t.items.map(t=>{let n=e.find(e=>e.key===t.key);return n?{...t,value:n.value}:t})}))})),t))},danger(e,t){return H(`/api/settings/danger`,K({action:e,confirm:t}))},putCredential(e){return H(`/api/settings/credential`,{method:`PUT`,body:JSON.stringify({key:e})})},resetAdminPassword(){return H(`/api/auth/password/reset`,{method:`POST`})},setAdminPassword(e){return H(`/api/auth/password`,{method:`PUT`,body:JSON.stringify({password:e})})},catalog(e){return H(`/api/models/catalog${e?`?provider=${encodeURIComponent(e)}`:``}`)},refreshCatalog(){return H(`/api/models/catalog`,{method:`POST`})},testCredential(e){return H(`/api/settings/credential/test`,K({key:e}))},setModelEnabled(e,t,n){return H(`/api/models/catalog/${encodeURIComponent(e)}${n?`?provider=${encodeURIComponent(n)}`:``}`,{method:`PATCH`,body:JSON.stringify({enabled:t})})},providerSignin(e){return H(`/api/providers/${encodeURIComponent(e)}/signin`)},providerOauthImport(e,t){return H(`/api/providers/${encodeURIComponent(e)}/oauth-import`,{method:`POST`,body:JSON.stringify(t)})},providerImportLocal(e){return H(`/api/providers/${encodeURIComponent(e)}/import-local`,{method:`POST`,body:`{}`})},providerImportDeviceStart(e){return H(`/api/providers/${encodeURIComponent(e)}/import-device/start`,{method:`POST`,body:`{}`})},providerImportDevicePoll(e){return H(`/api/providers/${encodeURIComponent(e)}/import-device/poll`,{method:`POST`,body:`{}`})},providerImportDeviceCancel(e){return H(`/api/providers/${encodeURIComponent(e)}/import-device/cancel`,{method:`POST`,body:`{}`})},providerGrowthRun(e){return H(`/api/providers/${encodeURIComponent(e)}/growth/run`,{method:`POST`})},providerGrowthPanel(e){return H(`/api/providers/${encodeURIComponent(e)}/growth`)},providerSigninNow(e){return H(`/api/providers/${encodeURIComponent(e)}/signin`,{method:`POST`})},providers(){return H(`/api/providers`)},createProvider(e){return H(`/api/providers`,{method:`POST`,body:JSON.stringify(e)})},patchProvider(e,t){return H(`/api/providers/${encodeURIComponent(e)}`,{method:`PATCH`,body:JSON.stringify(t)})},deactivateProvider(e){return H(`/api/providers/${encodeURIComponent(e)}/deactivate`,{method:`PUT`})},activateProvider(e){return H(`/api/providers/${encodeURIComponent(e)}/activate`,{method:`PUT`})},testProvider(e,t){return H(`/api/providers/${encodeURIComponent(e)}/test`,{method:`POST`,body:JSON.stringify(t?{credential:t}:{})})},deleteProvider(e){return H(`/api/providers/${encodeURIComponent(e)}`,{method:`DELETE`})}};function Ke(){let[e,t]=(0,x.useState)(`loading`),[n,r]=(0,x.useState)(null);(0,x.useEffect)(()=>{let e=!0;return q.session().then(n=>{e&&(t(n.authenticated?`authed`:`anon`),r(n.expiresAt))}).catch(()=>{e&&t(`anon`)}),()=>{e=!1}},[]);let i=(0,x.useRef)(!1);return(0,x.useEffect)(()=>re(()=>{i.current||(ce(),t(`anon`))}),[]),{status:e,expiresAt:n,login:(0,x.useCallback)(async e=>{let n=await q.login(e);ce(),t(`authed`),r(n.expiresAt)},[]),logout:(0,x.useCallback)(async()=>{i.current=!0;try{await q.logout()}catch(e){if(!(e instanceof R))throw i.current=!1,e}t(`anon`),r(null),window.location.assign(`/`)},[])}}var J=_();function Y({size:e=26}){return(0,J.jsxs)(`svg`,{width:e,height:e,viewBox:`0 0 160 160`,fill:`none`,role:`img`,"aria-label":`Waygate`,children:[(0,J.jsx)(`polygon`,{points:`80,8 148,48 128,125 50,151 12,78`,fill:`var(--brand-500)`,opacity:`.12`}),(0,J.jsx)(`polygon`,{points:`80,8 80,94 12,78`,fill:`var(--brand-400)`}),(0,J.jsx)(`polygon`,{points:`80,8 148,48 80,94`,fill:`var(--brand-500)`}),(0,J.jsx)(`polygon`,{points:`148,48 128,125 80,94`,fill:`var(--accent-blue)`}),(0,J.jsx)(`polygon`,{points:`12,78 80,94 50,151`,fill:`var(--brand-450)`,opacity:`.85`}),(0,J.jsx)(`polygon`,{points:`80,94 128,125 50,151`,fill:`var(--brand-450)`})]})}function qe(){return{...(0,x.useSyncExternalStore)(P,N,()=>({theme:`dark`,preference:`system`})),setPreference:te}}var Je=h(),X=12,Z=8,Ye=300;function Xe(e,t){typeof e==`function`?e(t):e&&(e.current=t)}function Ze({content:e,children:t,placement:n=`auto`,className:r}){let i=(0,x.useId)(),a=(0,x.useRef)(null),o=(0,x.useRef)(null),[s,c]=(0,x.useState)(!1),[l,u]=(0,x.useState)(null),d=t.props,f=d.disabled===!0,p=d.ref,m=typeof d[`aria-describedby`]==`string`?d[`aria-describedby`]:void 0,h=[m,s?i:void 0].filter(Boolean).join(` `)||void 0,g=typeof d.tabIndex==`number`?d.tabIndex:f?void 0:0,_=(0,x.useCallback)(()=>{let e=a.current,t=o.current;if(!e||!t)return;let r=e.getBoundingClientRect(),i=window.innerWidth,s=window.innerHeight,c=Math.min(Ye,Math.max(0,i-24)),l=Math.min(c,t.offsetWidth||c),d=t.offsetHeight;if(r.bottom<X||r.top>s-X){u(null);return}let f=r.top-X,p=s-r.bottom-X,m=f>=d+Z,h=p>=d+Z,g=n===`above`?m||!h?`above`:`below`:n===`below`?h||!m?`below`:`above`:m||!h?`above`:`below`,_=r.left+r.width/2,v=Math.max(X,Math.min(_-l/2,i-l-X)),y=Math.max(12,Math.min(_-v,l-12)),b=g===`above`?Math.max(X,r.top-d-Z):Math.max(X,Math.min(s-d-X,r.bottom+Z));u({left:v,top:b,placement:g,maxWidth:c,arrowLeft:y})},[n]),v=(0,x.useCallback)(()=>c(!0),[]),y=(0,x.useCallback)(()=>c(!1),[]);(0,x.useLayoutEffect)(()=>{if(!s){u(null);return}_()},[e,_,s]),(0,x.useLayoutEffect)(()=>{if(!s)return;let e=()=>_(),t=e=>{e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),y())},n=e=>{let t=e.target;t&&(a.current?.contains(t)||o.current?.contains(t))||y()};return window.addEventListener(`scroll`,e,!0),window.addEventListener(`resize`,e),window.visualViewport?.addEventListener(`resize`,e),window.visualViewport?.addEventListener(`scroll`,e),document.addEventListener(`keydown`,t,!0),document.addEventListener(`pointerdown`,n,!0),()=>{window.removeEventListener(`scroll`,e,!0),window.removeEventListener(`resize`,e),window.visualViewport?.removeEventListener(`resize`,e),window.visualViewport?.removeEventListener(`scroll`,e),document.removeEventListener(`keydown`,t,!0),document.removeEventListener(`pointerdown`,n,!0)}},[y,_,s]);let b=(0,x.useCallback)(e=>{a.current=e,Xe(p,e)},[p]),S=(0,x.useCallback)(e=>{Xe(p,e)},[p]),C=(0,x.useCallback)(e=>{a.current=e},[]),w=d.onBlur,T=(e,t)=>{let n=e.relatedTarget;n instanceof Node&&e.currentTarget.contains(n)||(t&&w?.(e),y())},E=typeof d.className==`string`&&r?`${d.className} ${r}`:r??d.className,D=(0,x.cloneElement)(t,{...E?{className:E}:{},ref:f?S:b,"aria-describedby":f?m:h,"data-tooltip-trigger":f?void 0:`true`,tabIndex:g,onMouseEnter:e=>{d.onMouseEnter?.(e),v()},onMouseLeave:e=>{d.onMouseLeave?.(e),y()},onFocus:e=>{d.onFocus?.(e),v()},onBlur:e=>T(e,!f)}),O=s&&typeof document<`u`?(0,Je.createPortal)((0,J.jsx)(`div`,{ref:o,id:i,role:`tooltip`,className:`tooltip-surface tooltip-${l?.placement??`measuring`}`,style:l?{left:l.left,top:l.top,maxWidth:l.maxWidth,"--tooltip-arrow-left":`${l.arrowLeft}px`}:{visibility:`hidden`,maxWidth:Math.min(Ye,Math.max(0,window.innerWidth-24))},children:e}),document.body):null;if(!f)return(0,J.jsxs)(J.Fragment,{children:[D,O]});let k=[m,s?i:void 0].filter(Boolean).join(` `)||void 0;return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`span`,{ref:C,className:`tooltip-anchor${r?` ${r}`:``}`,"data-tooltip-trigger":`true`,tabIndex:0,"aria-describedby":k,"aria-disabled":`true`,onMouseEnter:v,onMouseLeave:y,onFocus:v,onBlur:e=>T(e,!1),children:D}),O]})}var Q=[{value:`system`,label:`跟随系统`,Icon:b},{value:`light`,label:`浅色`,Icon:g},{value:`dark`,label:`深色`,Icon:v}];function Qe(){let{preference:e,setPreference:t}=qe();return(0,J.jsx)(`div`,{className:`theme-seg`,role:`radiogroup`,"aria-label":`外观`,onKeyDown:n=>{if(n.key!==`ArrowLeft`&&n.key!==`ArrowRight`)return;n.preventDefault();let r=Q.findIndex(t=>t.value===e),i=n.key===`ArrowRight`?(r+1)%Q.length:(r-1+Q.length)%Q.length;t(Q[i].value)},children:Q.map(({value:n,label:r,Icon:i})=>{let a=e===n;return(0,J.jsx)(Ze,{content:r,children:(0,J.jsx)(`button`,{type:`button`,role:`radio`,"aria-checked":a,tabIndex:a?0:-1,className:`theme-seg-i${a?` on`:``}`,"aria-label":r,onClick:()=>t(n),children:(0,J.jsx)(i,{size:14})})},n)})})}var $e=`relay.console.route`;function et(e){try{window.sessionStorage.setItem($e,e)}catch{}}function tt(){try{let e=window.sessionStorage.getItem($e);if(e&&I.includes(e))return e}catch{}return`overview`}function nt(e){return`/console#/${e??tt()}`}var rt=[{route:`overview`,label:`概览`,icon:(0,J.jsx)(o,{size:18})},{route:`usage`,label:`积分与用量`,icon:(0,J.jsx)(c,{size:18})},{route:`clients`,label:`提供商管理`,icon:(0,J.jsx)(e,{size:18})},{route:`keys`,label:`API 密钥`,icon:(0,J.jsx)(t,{size:18})},{route:`requests`,label:`请求日志`,icon:(0,J.jsx)(d,{size:18})},{route:`settings`,label:`设置`,icon:(0,J.jsx)(u,{size:18})}];function it({route:e,navigate:t,expiresAt:n,onLogout:r,children:i}){(0,x.useEffect)(()=>{et(e)},[e]);let[a,o]=(0,x.useState)(null);(0,x.useEffect)(()=>{let e=!0;return(async()=>{try{let t=await fetch(`/healthz`,{headers:{Accept:`application/json`}});if(!t.ok)return;let n=await t.json();e&&typeof n.version==`string`&&n.version&&o(n.version)}catch{}})(),()=>{e=!1}},[]);let[s,c]=(0,x.useState)(!1),u=(0,x.useRef)(null),d=(0,x.useRef)(null),f=(0,x.useRef)(null);(0,x.useEffect)(()=>{if(s){f.current=document.activeElement instanceof HTMLElement?document.activeElement:null,(d.current?.querySelector(`a[href], button:not([disabled])`))?.focus({preventScroll:!0});return}f.current?.isConnected&&f.current.focus({preventScroll:!0}),f.current=null},[s]),(0,x.useEffect)(()=>{if(!s)return;let e=e=>{if(e.key===`Escape`){e.preventDefault(),c(!1);return}if(e.key!==`Tab`)return;let t=d.current?Array.from(d.current.querySelectorAll(`a[href], button:not([disabled])`)):[];if(t.length===0)return;let n=t[0],r=t[t.length-1];e.shiftKey&&document.activeElement===n?(e.preventDefault(),r.focus()):!e.shiftKey&&document.activeElement===r&&(e.preventDefault(),n.focus())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[s]),(0,x.useEffect)(()=>{let e=()=>{window.innerWidth>720&&c(!1)};return window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[]);let p=e=>{c(!1),t(e)};return(0,J.jsxs)(`div`,{className:`app`,"data-view":e,"data-nav-open":s?`true`:`false`,children:[(0,J.jsxs)(`div`,{className:`scene`,"aria-hidden":`true`,children:[(0,J.jsxs)(`div`,{className:`lights`,children:[(0,J.jsx)(`div`,{className:`bloom l1`}),(0,J.jsx)(`div`,{className:`bloom l2`}),(0,J.jsx)(`div`,{className:`bloom l3`})]}),(0,J.jsx)(`div`,{className:`dimmer`}),(0,J.jsx)(`div`,{className:`noise`})]}),(0,J.jsx)(`button`,{ref:u,type:`button`,className:`nav-toggle`,"aria-label":`打开导航菜单`,"aria-controls":`console-sidebar`,"aria-expanded":s,onClick:()=>c(e=>!e),children:(0,J.jsx)(l,{size:20})}),(0,J.jsxs)(`aside`,{ref:d,className:`sidebar`,id:`console-sidebar`,"aria-label":`控制台导航`,children:[(0,J.jsxs)(`a`,{className:`sb-brand`,href:`/`,children:[(0,J.jsx)(Y,{size:26}),(0,J.jsx)(`span`,{children:`途关`}),(0,J.jsx)(`span`,{className:`brand-en`,children:`Waygate`}),(0,J.jsxs)(`span`,{className:`brand-ver`,children:[`v`,a??`1.6.16`]})]}),(0,J.jsx)(`div`,{className:`sb-group`,children:`工作台`}),rt.filter(e=>I.includes(e.route)).map(t=>(0,J.jsxs)(`button`,{type:`button`,className:`sb-item${e===t.route?` active`:``}`,onClick:()=>p(t.route),"aria-current":e===t.route?`page`:void 0,children:[t.icon,t.label]},t.route)),(0,J.jsx)(`div`,{className:`sb-spacer`}),(0,J.jsxs)(`div`,{className:`sb-tools`,children:[(0,J.jsx)(`span`,{className:`sb-tools-lb`,children:`外观`}),(0,J.jsx)(Qe,{})]}),(0,J.jsxs)(`div`,{className:`sb-account`,children:[(0,J.jsx)(`div`,{className:`avatar`,children:`管`}),(0,J.jsxs)(`div`,{className:`meta`,children:[(0,J.jsx)(`b`,{children:`管理员`}),(0,J.jsx)(`i`,{children:n?`会话有效 · ${ke(n)}到期`:`本机管理员`})]}),(0,J.jsx)(Ze,{content:`退出登录`,children:(0,J.jsx)(`button`,{type:`button`,className:`sb-logout`,onClick:r,"aria-label":`退出登录`,children:(0,J.jsx)(y,{size:16})})})]})]}),(0,J.jsx)(`div`,{className:`nav-backdrop`,"aria-hidden":`true`,onClick:()=>c(!1)}),(0,J.jsx)(`main`,{className:`main`,children:i})]})}var at={error:{icon:m},success:{icon:s},info:{icon:r},warn:{icon:m}};function ot({tone:e,children:t,actions:n}){let r=at[e].icon;return(0,J.jsxs)(`div`,{className:`banner banner-${e}`,role:e===`error`||e===`warn`?`alert`:`status`,children:[(0,J.jsx)(r,{className:`banner-ico`,size:15,"aria-hidden":`true`}),(0,J.jsx)(`div`,{className:`banner-body`,children:t}),n?(0,J.jsx)(`div`,{className:`banner-actions`,children:n}):null]})}function st(e){var t=e&&typeof e.querySelectorAll==`function`?e:document,n=document.documentElement,r={};function i(e,t){r[e]!==t&&(r[e]=t,n.style.setProperty(e,t))}var a=window.matchMedia(`(prefers-reduced-motion: reduce)`).matches,o=!0,s=[`x`,`y`,`z`,`rx`,`ry`,`rz`,`fog`,`dim`],c={x:0,y:0,z:0,rx:0,ry:0,rz:0,fog:.18,dim:1},l={x:`px`,y:`px`,z:`px`,rx:`deg`,ry:`deg`,rz:`deg`},u={x:`--cam-x`,y:`--cam-y`,z:`--cam-z`,rx:`--cam-rx`,ry:`--cam-ry`,rz:`--cam-rz`,fog:`--fog`,dim:`--scene-dim`};function d(e){return function(){e|=0,e=e+1831565813|0;var t=Math.imul(e^e>>>15,1|e);return t=t+Math.imul(t^t>>>7,61|t)^t,((t^t>>>14)>>>0)/4294967296}}var f=[{sel:`.dust.d3`,count:14,min:.9,max:1.5,seed:20261004},{sel:`.dust.d2`,count:10,min:1.3,max:2,seed:77110203},{sel:`.dust.d1`,count:6,min:1.8,max:2.8,seed:31415926}];function p(){f.forEach(function(e){for(var n=t.querySelectorAll(e.sel),r=0;r<n.length;r+=1){n[r].innerHTML=``;for(var i=d(e.seed),a=document.createDocumentFragment(),o=0;o<e.count;o+=1){var s=document.createElement(`i`),c=e.min+i()*(e.max-e.min);s.style.left=(i()*100).toFixed(2)+`%`,s.style.top=(i()*100).toFixed(2)+`%`,s.style.width=c.toFixed(2)+`px`,s.style.height=c.toFixed(2)+`px`,s.style.animationDelay=(i()*3200).toFixed(0)+`ms`,a.appendChild(s)}n[r].appendChild(a)}})}var m=[];function h(e){var t=e.getBoundingClientRect();return t.top+window.pageYOffset+t.height/2}function g(){m=[].slice.call(t.querySelectorAll(`[data-cam]`)).map(function(e){var t={},n=e.getAttribute(`data-cam`);if(n)try{t=JSON.parse(n)}catch{console.warn(`[scene] data-cam 不是合法 JSON,已忽略:`,e,n),t={}}return{at:h(e),cam:t}}),m.sort(function(e,t){return e.at-t.at})}function _(e){return e<.5?2*e*e:1-(-2*e+2)**2/2}function v(e){if(!m.length)return Object.assign({},c);for(var t=0;t<m.length-1&&e>m[t+1].at;)t+=1;var n=m[t],r=m[t+1],i=r?e<=n.at?0:(e-n.at)/(r.at-n.at):1;i=Math.max(0,Math.min(1,i));for(var a=_(i),o={},l=0;l<s.length;l+=1){var u=s[l],d=n.cam[u]===void 0?c[u]:n.cam[u];o[u]=d+((r&&r.cam[u]!==void 0?r.cam[u]:d)-d)*a}return o}var y=.16,b=null,x=null,S=0,C=0;function w(e){for(var t=0;t<s.length;t+=1){var n=s[t],r=l[n]||``;i(u[n],e[n].toFixed(3)+r)}}function T(e){var t=S?Math.min((e-S)/1e3,.12):.016;S=e,b||=Object.assign({},x);for(var n=a?1:1-Math.exp(-t/y),r=!0,i=0;i<s.length;i+=1){var o=s[i],c=x[o]-b[o];b[o]+=c*n;var l=Math.max(.0015,Math.abs(x[o])*.0012);Math.abs(c)>l&&(r=!1)}if(w(b),r){b=Object.assign({},x),w(x),C=0,S=0;return}C=requestAnimationFrame(T)}function E(){C||=(S=0,requestAnimationFrame(T))}function D(){if(o){var e=document.documentElement,t=Math.max(1,e.scrollHeight-window.innerHeight);i(`--scroll-p`,(window.pageYOffset/t).toFixed(4)),x=v(window.pageYOffset+window.innerHeight/2),E()}}var O={tx:0,ty:0,x:0,y:0},k=0,A=0,ee=window.matchMedia(`(hover: hover) and (pointer: fine)`).matches;function j(){i(`--look-x`,O.x.toFixed(4)),i(`--look-y`,O.y.toFixed(4))}function M(e){var t=A?Math.min((e-A)/1e3,.12):.016;A=e;var n=1-Math.exp(-t/y);O.x+=(O.tx-O.x)*n,O.y+=(O.ty-O.y)*n,j(),Math.abs(O.tx-O.x)>8e-4||Math.abs(O.ty-O.y)>8e-4?k=requestAnimationFrame(M):(O.x=O.tx,O.y=O.ty,j(),k=0,A=0)}function N(e){document.hidden||(O.tx=(e.clientX/window.innerWidth-.5)*2,O.ty=(e.clientY/window.innerHeight-.5)*2,k||=(A=0,requestAnimationFrame(M)))}function P(){O.tx=0,O.ty=0,k||=(A=0,requestAnimationFrame(M))}function te(){!a&&ee&&(window.addEventListener(`pointermove`,N,{passive:!0}),document.addEventListener(`pointerleave`,P))}var F=null,I=null,L=null;function ne(){if(p(),g(),!m.length){n.setAttribute(`data-scene-ready`,`static`);return}D(),te();var e=!1;F=function(){e||(e=!0,requestAnimationFrame(function(){e=!1,D()}))},I=function(){o&&(g(),D())},L=function(){o&&(g(),D())},window.addEventListener(`scroll`,F,{passive:!0}),window.addEventListener(`resize`,I),window.addEventListener(`load`,L),document.fonts&&document.fonts.ready&&document.fonts.ready.then(function(){o&&(g(),D())}),n.setAttribute(`data-scene-ready`,`1`)}function R(){o=!1,F&&window.removeEventListener(`scroll`,F),I&&window.removeEventListener(`resize`,I),L&&window.removeEventListener(`load`,L),window.removeEventListener(`pointermove`,N),document.removeEventListener(`pointerleave`,P),C&&cancelAnimationFrame(C),k&&cancelAnimationFrame(k),C=0,k=0,[].slice.call(t.querySelectorAll(`.dust`)).forEach(function(e){e.innerHTML=``}),Object.keys(u).forEach(function(e){n.style.removeProperty(u[e])}),n.style.removeProperty(`--scroll-p`),n.style.removeProperty(`--look-x`),n.style.removeProperty(`--look-y`),r={},n.removeAttribute(`data-scene-ready`)}return ne(),R}var ct=e=>e,lt=[{tint:`var(--iris)`,a:`0deg`,r:`430px`,y:`-40px`,w:`300px`,h:`520px`,z:`-18deg`,x:`16deg`,o:`.95`,e:`.70`,hot:`.26`,dof:`0px`,dur:`15s`,delay:`0s`},{tint:`var(--accent-cyan)`,a:`72deg`,r:`448px`,y:`10px`,w:`255px`,h:`470px`,z:`12deg`,x:`-22deg`,o:`.82`,e:`.18`,hot:`.05`,dof:`0px`,dur:`19s`,delay:`3s`},{tint:`var(--brand-500)`,a:`144deg`,r:`424px`,y:`-60px`,w:`325px`,h:`560px`,z:`-24deg`,x:`19deg`,o:`.90`,e:`.52`,hot:`.18`,dof:`0px`,dur:`17s`,delay:`6.5s`},{tint:`var(--brand-400)`,a:`216deg`,r:`456px`,y:`20px`,w:`270px`,h:`490px`,z:`16deg`,x:`-14deg`,o:`.76`,e:`.14`,hot:`.04`,dof:`0px`,dur:`21s`,delay:`10s`},{tint:`var(--accent-blue)`,a:`288deg`,r:`436px`,y:`-30px`,w:`310px`,h:`535px`,z:`-14deg`,x:`24deg`,o:`.88`,e:`.30`,hot:`.12`,dof:`0px`,dur:`18s`,delay:`13.5s`},{tint:`var(--brand-500)`,a:`36deg`,r:`860px`,y:`40px`,w:`400px`,h:`560px`,z:`-22deg`,x:`26deg`,o:`.62`,e:`.20`,hot:`.06`,dof:`2.6px`,dur:`26s`,delay:`2s`,soft:!0},{tint:`var(--accent-cyan)`,a:`126deg`,r:`900px`,y:`-20px`,w:`360px`,h:`520px`,z:`18deg`,x:`-28deg`,o:`.52`,e:`.10`,hot:`.03`,dof:`2.6px`,dur:`30s`,delay:`9s`,soft:!0},{tint:`var(--iris)`,a:`216deg`,r:`840px`,y:`60px`,w:`440px`,h:`620px`,z:`-28deg`,x:`20deg`,o:`.58`,e:`.30`,hot:`.09`,dof:`2.6px`,dur:`24s`,delay:`15s`,soft:!0},{tint:`var(--brand-400)`,a:`306deg`,r:`890px`,y:`-10px`,w:`380px`,h:`540px`,z:`14deg`,x:`-24deg`,o:`.48`,e:`.08`,hot:`.03`,dof:`2.6px`,dur:`33s`,delay:`19s`,soft:!0}];function ut(){return(0,J.jsxs)(`div`,{className:`scene`,"aria-hidden":`true`,children:[(0,J.jsxs)(`div`,{className:`rig`,children:[(0,J.jsx)(`div`,{className:`tilt`,children:(0,J.jsx)(`div`,{className:`stage`,children:lt.map((e,t)=>(0,J.jsx)(`i`,{className:e.soft?`pl soft`:`pl`,style:ct({"--tint":e.tint,"--a":e.a,"--r":e.r,"--y":e.y,"--w":e.w,"--h":e.h,"--z":e.z,"--x":e.x,"--o":e.o,"--e":e.e,"--hot":e.hot,"--dof":e.dof,"--sheen-dur":e.dur,"--sheen-delay":e.delay})},t))})}),(0,J.jsx)(`div`,{className:`dust d3`}),(0,J.jsx)(`div`,{className:`dust d2`}),(0,J.jsx)(`div`,{className:`dust d1`})]}),(0,J.jsx)(`div`,{className:`core`}),(0,J.jsx)(`div`,{className:`nucleus`}),(0,J.jsx)(`div`,{className:`beam b1`}),(0,J.jsx)(`div`,{className:`beam b2`}),(0,J.jsx)(`div`,{className:`fog`}),(0,J.jsx)(`div`,{className:`dimmer`}),(0,J.jsx)(`div`,{className:`vignette`}),(0,J.jsx)(`div`,{className:`noise`})]})}function dt(){return(0,x.useEffect)(()=>st(document),[]),(0,J.jsx)(ut,{})}function ft({session:e,mockHint:r}){let[o,s]=(0,x.useState)(``),[c,l]=(0,x.useState)(!1),[u,d]=(0,x.useState)(!1),[f,p]=(0,x.useState)(null),m=(0,x.useRef)(null);return(0,x.useEffect)(()=>{let e=m.current;if(!e||!window.matchMedia(`(hover: hover) and (pointer: fine)`).matches)return;let t=t=>{let n=e.getBoundingClientRect();e.style.setProperty(`--mx`,`${t.clientX-n.left}px`),e.style.setProperty(`--my`,`${t.clientY-n.top}px`)};return e.addEventListener(`pointermove`,t),()=>e.removeEventListener(`pointermove`,t)},[]),(0,J.jsxs)(`div`,{className:`login-wrap landing`,children:[(0,J.jsx)(dt,{}),(0,J.jsxs)(`div`,{className:`login-card`,ref:m,children:[(0,J.jsx)(`span`,{className:`login-glow`,"aria-hidden":`true`}),(0,J.jsxs)(`div`,{className:`login-brand`,children:[(0,J.jsx)(Y,{size:30}),(0,J.jsx)(`span`,{className:`b-name`,children:`途关`}),(0,J.jsx)(`span`,{className:`b-en`,children:`Waygate`})]}),(0,J.jsx)(`h1`,{children:`登录控制台`}),(0,J.jsx)(`p`,{className:`sub`,children:`这是自用工具,只有一个管理口令。口令校验在服务端完成,前端不保存明文。`}),(0,J.jsxs)(`form`,{className:`login-form`,onSubmit:async t=>{if(t.preventDefault(),!u){d(!0),p(null);try{await e.login(o)}catch(e){p(e instanceof R?e:new R(String(e),0,0)),d(!1)}}},children:[(0,J.jsxs)(`div`,{className:`login-field`,children:[(0,J.jsx)(`label`,{htmlFor:`pw`,children:`管理口令`}),(0,J.jsxs)(`div`,{className:`login-input`,children:[(0,J.jsx)(t,{size:15,color:`var(--text-faint)`,"aria-hidden":!0}),(0,J.jsx)(`input`,{id:`pw`,type:c?`text`:`password`,value:o,autoFocus:!0,autoComplete:`current-password`,placeholder:`输入管理口令`,onChange:e=>s(e.target.value)}),(0,J.jsx)(`button`,{type:`button`,className:`login-eye`,"aria-label":c?`隐藏口令`:`显示口令`,onClick:()=>l(e=>!e),children:c?(0,J.jsx)(n,{size:15}):(0,J.jsx)(i,{size:15})})]})]}),f?(0,J.jsx)(ot,{tone:`error`,children:f.message}):null,(0,J.jsxs)(`button`,{type:`submit`,className:`btn btn-primary login-submit`,disabled:u||!o,children:[u?(0,J.jsx)(a,{size:16}):null,u?`正在验证…`:`进入控制台`]})]}),(0,J.jsx)(`p`,{className:`login-hint`,children:r?`当前为 Mock 模式(npm run dev:mock),口令固定为 ${r}。`:`口令首次启动时若未配置 RELAY_ADMIN_PASSWORD_HASH,会打印到服务端 stdout 一次。`})]})]})}function pt(){return(0,J.jsx)(`div`,{className:`login-wrap`,children:(0,J.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,alignItems:`center`,gap:16},children:[(0,J.jsx)(Y,{size:40}),(0,J.jsx)(`div`,{style:{fontSize:12.5,color:`var(--text-ghost)`},children:`正在确认会话…`})]})})}var mt=`modulepreload`,ht=function(e,t){return new URL(e,t).href},gt={},_t=function(e){return e.pathname.endsWith(`.css`)},$=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e,i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}function s(e){return import.meta.resolve?new URL(import.meta.resolve(e)):new URL(e,import.meta.url)}r=o(t.map(t=>{t=ht(t,n);let r=s(t);if(r.href in gt)return;gt[r.href]=!0;let i=_t(r);if(e===void 0){e={all:new Set,styles:new Set};let t=document.getElementsByTagName(`link`);for(let n=t.length-1;n>=0;n--){let r=t[n];e.all.add(r.href),r.rel===`stylesheet`&&e.styles.add(r.href)}}if((i?e.styles:e.all).has(r.href))return;let o=document.createElement(`link`);if(o.rel=i?`stylesheet`:mt,i||(o.as=`script`),o.crossOrigin=``,o.href=r.href,a&&o.setAttribute(`nonce`,a),document.head.appendChild(o),i)return new Promise((e,t)=>{o.addEventListener(`load`,e),o.addEventListener(`error`,()=>t(Error(`Unable to preload CSS for ${r}`)))})}).filter(e=>e!==void 0))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})},vt=(0,x.lazy)(()=>$(()=>import(`./LandingPage-P2QNDFaP.js`).then(e=>({default:e.LandingPage})),__vite__mapDeps([0,1,2,3]),import.meta.url)),yt=(0,x.lazy)(()=>$(()=>import(`./OverviewPage-BgBo_XhF.js`).then(e=>({default:e.OverviewPage})),__vite__mapDeps([4,1,5,6,7,8,9]),import.meta.url)),bt=(0,x.lazy)(()=>$(()=>import(`./UsagePage-cxZ-GnpO.js`).then(e=>({default:e.UsagePage})),__vite__mapDeps([10,1,5,6,7,8,9]),import.meta.url)),xt=(0,x.lazy)(()=>$(()=>import(`./ClientsPage-Dy68uQDl.js`).then(e=>({default:e.ClientsPage})),__vite__mapDeps([11,1,5,12,13,6,7,14,15]),import.meta.url)),St=(0,x.lazy)(()=>$(()=>import(`./ApiKeysPage-Ck0Gry6E.js`).then(e=>({default:e.ApiKeysPage})),__vite__mapDeps([16,1,5,12,13,6]),import.meta.url)),Ct=(0,x.lazy)(()=>$(()=>import(`./RequestsPage-CVB0wpCH.js`).then(e=>({default:e.RequestsPage})),__vite__mapDeps([17,1,5,6,14,13,8]),import.meta.url)),wt=(0,x.lazy)(()=>$(()=>import(`./SettingsPage-B4Mew-7b.js`).then(e=>({default:e.SettingsPage})),__vite__mapDeps([18,1,2,5,12,13,14,15]),import.meta.url));function Tt(){let[e,t]=(0,x.useState)(()=>window.location.pathname);return(0,x.useEffect)(()=>{let e=()=>t(window.location.pathname);return window.addEventListener(`popstate`,e),()=>window.removeEventListener(`popstate`,e)},[]),e}var Et=`Waygate — 控制台`;function Dt(){return(0,J.jsx)(`div`,{style:{display:`flex`,alignItems:`center`,justifyContent:`center`,minHeight:`50vh`,fontSize:12.5,color:`var(--text-ghost)`},children:`加载中…`})}function Ot(){let{route:e,navigate:t}=ne(),n=Ke();return(0,x.useEffect)(()=>{document.title=Et},[]),(0,x.useEffect)(()=>{window.location.hash||(window.location.hash=`#/overview`)},[]),n.status===`loading`?(0,J.jsx)(pt,{}):n.status===`anon`?(0,J.jsx)(ft,{session:n,mockHint:null}):(0,J.jsx)(it,{route:e,navigate:t,expiresAt:n.expiresAt,onLogout:()=>void n.logout(),children:(0,J.jsxs)(x.Suspense,{fallback:(0,J.jsx)(Dt,{}),children:[e===`overview`?(0,J.jsx)(yt,{navigate:t}):null,e===`usage`?(0,J.jsx)(bt,{}):null,e===`clients`?(0,J.jsx)(xt,{}):null,e===`keys`?(0,J.jsx)(St,{}):null,e===`requests`?(0,J.jsx)(Ct,{}):null,e===`settings`?(0,J.jsx)(wt,{}):null]})})}function kt(){let e=Tt(),t=C(e)===`console`;return(0,x.useEffect)(()=>{F()},[e]),t?(0,J.jsx)(Ot,{}):(0,J.jsx)(x.Suspense,{fallback:null,children:(0,J.jsx)(vt,{})})}var At=(0,x.createContext)(null),jt={error:{icon:m,defaultMs:8e3},warn:{icon:m,defaultMs:8e3},success:{icon:s,defaultMs:5e3},info:{icon:r,defaultMs:5e3}};function Mt({children:e}){let[t,n]=(0,x.useState)([]),r=(0,x.useRef)(1),i=(0,x.useCallback)(e=>{n(t=>t.filter(t=>t.id!==e))},[]),a=(0,x.useCallback)(e=>{let t=r.current++;return n(n=>[...n,{...e,id:t}].slice(-4)),t},[]),o=(0,x.useMemo)(()=>({push:a,dismiss:i}),[a,i]);return(0,J.jsxs)(At.Provider,{value:o,children:[e,typeof document<`u`?(0,Je.createPortal)((0,J.jsx)(`div`,{className:`toast-stack`,"aria-live":`polite`,"aria-atomic":`false`,children:t.map(e=>(0,J.jsx)(Nt,{item:e,onDismiss:i},e.id))}),document.body):null]})}function Nt({item:e,onDismiss:t}){let{icon:n,defaultMs:r}=jt[e.tone],i=e.durationMs??r,[a,o]=(0,x.useState)(!1),[s,c]=(0,x.useState)(i);return(0,x.useEffect)(()=>{if(a)return;let n=Date.now(),r=window.setInterval(()=>{let a=i-(Date.now()-n);a<=0?(window.clearInterval(r),t(e.id)):c(a)},100);return()=>window.clearInterval(r)},[a,i,e.id,t]),(0,J.jsxs)(`div`,{className:`toast toast-${e.tone}`,role:e.tone===`error`||e.tone===`warn`?`alert`:`status`,onMouseEnter:()=>o(!0),onMouseLeave:()=>o(!1),onFocus:()=>o(!0),onBlur:()=>o(!1),children:[(0,J.jsx)(n,{className:`toast-ico`,size:15,"aria-hidden":`true`}),(0,J.jsx)(`div`,{className:`toast-body`,children:e.message}),(0,J.jsx)(`button`,{type:`button`,className:`toast-close`,"aria-label":`关闭提示`,onClick:()=>t(e.id),children:`×`}),(0,J.jsx)(`span`,{className:`toast-progress${a?` paused`:``}`,style:{animationDuration:`${i}ms`},"aria-hidden":`true`})]})}function Pt(){return(0,x.useContext)(At)??{push:()=>0,dismiss:()=>{}}}w(),T(),F();for(let e of[`icon`,`apple-touch-icon`]){let t=document.createElement(`link`);t.rel=e,t.type=`image/svg+xml`,t.href=`/icon.svg?v=2`,document.head.appendChild(t)}var Ft=document.getElementById(`root`);if(!Ft)throw Error(`#root 未找到 —— index.html 被改坏了`);(0,S.createRoot)(Ft).render((0,J.jsx)(x.StrictMode,{children:(0,J.jsx)(Mt,{children:(0,J.jsx)(kt,{})})}));export{me as A,Le as C,he as D,Re as E,R as M,fe as O,Ie as S,Pe as T,be as _,Ze as a,Ee as b,q as c,xe as d,De as f,ve as g,we as h,nt as i,de as j,pe as k,Me as l,Oe as m,dt as n,Y as o,ye as p,ot as r,Ke as s,Pt as t,Ae as u,ke as v,Te as w,Ce as x,je as y};
@@ -56,7 +56,7 @@
56
56
  }
57
57
  })();
58
58
  </script>
59
- <script type="module" crossorigin src="./assets/index-BJtz6Ses.js"></script>
59
+ <script type="module" crossorigin src="./assets/index-nQeRK3kW.js"></script>
60
60
  <link rel="modulepreload" crossorigin href="./assets/vendor-befEYGHM.js">
61
61
  <link rel="stylesheet" crossorigin href="./assets/index-CEoe20BF.css">
62
62
  </head>
@@ -1 +0,0 @@
1
- import{H as e,I as t,J as n,L as r,Q as i,S as a,U as o,a as s,it as c,m as l,n as u,tt as d,z as f}from"./vendor-befEYGHM.js";import{M as p,a as m,c as h,g,j as _,k as v,p as y,r as b,t as x,v as S}from"./index-BJtz6Ses.js";import{a as C,c as w,n as T,r as E,s as D,t as O}from"./Select-HrLgXSri.js";import{t as k}from"./Modal-B-rIrvXS.js";import{t as A}from"./PageSkeleton-DG-Dj4_9.js";import{n as j,t as M}from"./sharedWindow-FDfq75PI.js";import{t as N}from"./Drawer-CleQGhRU.js";import{t as P}from"./Switch-0KA1AbiV.js";var F=c(),I=d();function L({rows:e,byProvider:t,busyId:n,onEdit:r,onModels:a,onSignin:o,onGrowthRun:c,onOauthImport:d,onActivate:f,onDeactivate:p,onDelete:h}){let _=()=>new Intl.DateTimeFormat(`en-CA`,{timeZone:`Asia/Shanghai`,year:`numeric`,month:`2-digit`,day:`2-digit`}).format(new Date),v=new Map((t??[]).map(e=>[e.providerId??``,e]));return(0,I.jsx)(`div`,{className:`tbl-scroll`,children:(0,I.jsxs)(`table`,{className:`tbl`,children:[(0,I.jsxs)(`caption`,{className:`sr-only`,children:[`提供商列表,共 `,e.length,` 家提供商`]}),(0,I.jsx)(`thead`,{children:(0,I.jsxs)(`tr`,{children:[(0,I.jsx)(`th`,{scope:`col`,children:`提供商`}),(0,I.jsx)(`th`,{scope:`col`,children:`密钥`}),(0,I.jsx)(`th`,{scope:`col`,className:`r`,children:`请求次数`}),(0,I.jsx)(`th`,{scope:`col`,className:`r`,children:`消耗积分`}),(0,I.jsx)(`th`,{scope:`col`,className:`r`,children:`最后活跃`}),(0,I.jsx)(`th`,{scope:`col`,className:`r`,children:`操作`})]})}),(0,I.jsx)(`tbody`,{children:e.map(t=>{let b=n===t.id;return(0,I.jsxs)(`tr`,{className:`prov-row`,children:[(0,I.jsxs)(`td`,{className:`td-strong`,children:[t.name,t.active?(0,I.jsx)(w,{tone:`live`,children:`已启用`}):(0,I.jsx)(w,{tone:`ghost`,children:`未启用`}),t.protocol===`anthropic`?(0,I.jsx)(m,{content:`Anthropic Messages 方言(mavis 网关):模型目录用内置清单,凭证为 refresh token 自动换新`,children:(0,I.jsx)(`span`,{className:`pill pill-ghost`,children:`Anthropic`})}):t.protocol===`qoder`?(0,I.jsx)(m,{content:`Qoder CN 网关(COSY 协议):免费档 billable:false 实扣 0;目录从网关 /model/list 拉取;凭证为客户端身份 JSON(不自动刷新)`,children:(0,I.jsx)(`span`,{className:`pill pill-ghost`,children:`Qoder`})}):null,(0,I.jsx)(`div`,{className:`td-sub td-mono`,children:(0,I.jsx)(m,{content:(0,I.jsx)(I.Fragment,{children:(0,I.jsxs)(`div`,{className:`client-model-tip`,children:[(0,I.jsxs)(`div`,{className:`client-model-tip-head`,children:[(0,I.jsxs)(`div`,{className:`client-model-tip-title`,children:[(0,I.jsx)(`strong`,{children:t.name}),(0,I.jsx)(`span`,{children:t.baseUrl})]}),(0,I.jsx)(`span`,{className:`client-model-tip-tag`,children:t.active?`已启用`:`未启用`})]}),(0,I.jsxs)(`div`,{className:`client-model-tip-summary`,children:[(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`span`,{children:`模型总数`}),(0,I.jsx)(`b`,{children:g(t.modelCount??0)})]}),(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`span`,{children:`已启用`}),(0,I.jsx)(`b`,{children:g(t.modelEnabled??0)})]})]}),t.credits?.available?(0,I.jsxs)(`div`,{className:`client-metric-tip-total`,children:[(0,I.jsx)(`span`,{children:`剩余积分`}),(0,I.jsxs)(`b`,{children:[y(t.credits.remaining??0),` `,(0,I.jsxs)(`em`,{children:[`已用 `,y(t.credits.consumed??0)]})]})]}):null,t.credits?.stale?(0,I.jsx)(`div`,{className:`client-model-tip-note`,children:`⚠ 积分数据偏旧(账本快照超时)`}):null]})}),children:(0,I.jsxs)(`span`,{className:`prov-model-count`,children:[g(t.modelCount??0),` 个模型`]})})})]}),(0,I.jsxs)(`td`,{className:`td-cred`,children:[(0,I.jsx)(m,{content:`供应商访问密钥(掩码显示;全量只存在服务器上)`,children:(0,I.jsx)(`span`,{className:`cred-mask`,children:t.credentialMask})}),(0,I.jsx)(`span`,{className:`up-badge${t.configured?``:` warn`}`,children:t.configured?`有效`:`未配置`})]}),(0,I.jsx)(`td`,{className:`r td-mono`,children:t.active?g(v.get(t.id)?.requests??0):`—`}),(0,I.jsx)(`td`,{className:`r td-mono`,children:t.active?y(v.get(t.id)?.credits??0):`—`}),(0,I.jsx)(`td`,{className:`r td-mono`,children:t.active?S(v.get(t.id)?.lastSeenAt??null):`—`}),(0,I.jsx)(`td`,{className:`r`,children:(0,I.jsxs)(`span`,{className:`prov-row-actions`,children:[(0,I.jsx)(m,{content:`改名称与上游地址;凭证可在抽屉内「重新导入授权」`,children:(0,I.jsxs)(`button`,{type:`button`,className:`mini-pill`,disabled:b,onClick:()=>r(t),children:[(0,I.jsx)(u,{size:12}),`配置`]})}),(0,I.jsx)(m,{content:`查看这家自己的模型清单(启停只作用于该提供商分区)`,children:(0,I.jsxs)(`button`,{type:`button`,className:`mini-pill`,"aria-disabled":b||!t.active,onClick:()=>{!b&&t.active&&a(t)},children:[(0,I.jsx)(l,{size:12}),`模型列表`]})}),t.credKind===`oauth_minimax`||t.protocol===`qoder`?(0,I.jsx)(m,{content:(()=>{let e=t.protocol===`qoder`?`10:05`:`08:05`,n=t.signin?.checkedOn?`最近签到 ${t.signin.checkedOn}${t.signin.lastPoints?` · +${t.signin.lastPoints} 积分`:``}(relay 每天 ${e} 自动签)`:`今天还没签到 —— 点一下立即签(relay 每天 ${e} 也会自动签)`;return t.protocol===`qoder`?(0,I.jsxs)(I.Fragment,{children:[n,(0,I.jsx)(`br`,{}),`Qoder 官方标注:每日 10:00(UTC+8)刷新,领取后 30 天有效。`]}):n})(),children:(0,I.jsxs)(`button`,{type:`button`,className:`mini-pill`,"aria-disabled":b||t.signin?.checkedOn===_(),onClick:()=>{b||t.signin?.checkedOn===_()||o(t)},children:[(0,I.jsx)(i,{size:12}),t.signin?.checkedOn===_()?`已签到`:`签到`]})}):null,t.protocol===`openai`?t.wbOAuth?.configured?(0,I.jsx)(m,{content:t.wbSignin?.checkedOn===_()?`今天已签到过(明天 08:05 自动跑;任务面板在设置 → 提供商健康)`:`立即签到 + 顺带跑一轮成长任务与连登兑换(每天 08:05 也会自动跑)。转发不受影响。`,children:(0,I.jsxs)(`button`,{type:`button`,className:`mini-pill`,"aria-disabled":b||t.wbSignin?.checkedOn===_(),onClick:()=>{!b&&t.wbSignin?.checkedOn!==_()&&c(t)},children:[(0,I.jsx)(i,{size:12}),t.wbSignin?.checkedOn===_()?`已签到`:`签到`]})}):(0,I.jsx)(m,{content:`导入桌面端 OAuth 凭证后可代领签到/任务(上游不允许 API 密钥代领)。粘贴 tools/wb-oauth-export.mjs 的输出;转发仍走 API 密钥。`,children:(0,I.jsxs)(`button`,{type:`button`,className:`mini-pill`,"aria-disabled":b,onClick:()=>{b||d(t)},children:[(0,I.jsx)(i,{size:12}),`导入OAuth`]})}):null,t.active?(0,I.jsx)(m,{content:`退出出站路由(目录与凭证保留,可再启用)`,children:(0,I.jsx)(`button`,{type:`button`,className:`mini-pill`,"aria-disabled":b,onClick:()=>{b||p(t)},children:`停用`})}):(0,I.jsx)(`button`,{type:`button`,className:`mini-pill`,disabled:b,onClick:()=>f(t),children:`启用`}),(0,I.jsx)(m,{content:t.active?`不能删除已启用的提供商 —— 先停用它`:e.length<=1?`至少保留一个提供商`:`删除这个提供商(凭证文件一并删除)`,children:(0,I.jsxs)(`button`,{type:`button`,className:`mini-pill danger`,"aria-disabled":b||t.active||e.length<=1,onClick:()=>{!b&&!t.active&&e.length>1&&h(t)},children:[(0,I.jsx)(s,{size:12}),`删除`]})})]})})]},t.id)})})]})})}function R({command:e}){let[t,r]=(0,F.useState)(!1);if(!e)return null;let i=async()=>{try{await navigator.clipboard.writeText(e),r(!0),setTimeout(()=>r(!1),2e3)}catch{r(!1)}};return(0,I.jsxs)(`div`,{className:`cred-guide-cmd`,children:[(0,I.jsx)(`code`,{children:e}),(0,I.jsxs)(`button`,{type:`button`,className:`copy`,"aria-label":t?`已复制命令`:`复制命令`,onClick:()=>void i(),children:[t?(0,I.jsx)(n,{size:13}):(0,I.jsx)(f,{size:13}),t?`已复制`:`复制`]})]})}var z=[{protocol:`openai`,label:`WorkBuddy`,desc:`OpenAI 方言`,needsAuth:!0},{protocol:`anthropic`,label:`MiniMax Code`,desc:`Anthropic 方言`,needsAuth:!0},{protocol:`qoder`,label:`Qoder CN`,desc:`COSY 协议`,needsAuth:!0}],B={openai:`https://copilot.tencent.com`,anthropic:`https://agent.minimax.cn`,qoder:`https://gateway.qoder.com.cn`},V=2500,H=3e5;function U({provider:e,onClose:n,onImported:r}){let i=x(),[o,s]=(0,F.useState)(e?`confirm`:`pick`),[c,l]=(0,F.useState)(e?.protocol??`anthropic`),[u,d]=(0,F.useState)(e?.name??``),[f,m]=(0,F.useState)(``),[g,_]=(0,F.useState)(``),[v,y]=(0,F.useState)(!1),[S,C]=(0,F.useState)(null),w=(0,F.useRef)(e?.id??null),T=(0,F.useRef)(!1),D=(0,F.useRef)(!1),O=z.find(e=>e.protocol===c);(0,F.useEffect)(()=>()=>{D.current=!0;let e=w.current;e&&h.providerImportDeviceCancel(e).catch(()=>void 0)},[]);let A=(0,F.useCallback)(async()=>{y(!0),C(null);try{let e=w.current;e||(e=(await h.createProvider({name:u.trim()||O.label,baseUrl:B[c]??B.openai,credential:``,protocol:c})).item.id,w.current=e,T.current=!0);let t=await h.providerImportDeviceStart(e);if(!t.ok||!t.authUrl){C(new p(t.message??`申请授权失败`,0,0)),s(`confirm`),y(!1);return}m(t.authUrl),_(t.userCode??``),window.open(t.authUrl,`_blank`,`noopener`),s(`waiting`),y(!1);let n=Date.now()+H;for(;!D.current&&Date.now()<n;){if(await new Promise(e=>setTimeout(e,V)),D.current)return;let t=await h.providerImportDevicePoll(e);if(D.current)return;if(t.status===`done`){s(`done`),i.push({tone:`success`,message:`${u.trim()||O.label} 授权已导入。`}),r();return}if(t.status===`error`){C(new p(t.message??`授权失败`,0,0)),s(`confirm`);return}}D.current||(C(new p(`授权超时(5 分钟)—— 请重新发起导入。`,0,0)),s(`confirm`))}catch(e){C(e instanceof p?e:new p(String(e),0,0)),s(`confirm`),y(!1)}},[O.label,u,r,c,i]);if(o===`done`)return(0,I.jsxs)(k,{title:`授权已导入`,onClose:n,footer:(0,I.jsx)(`button`,{type:`button`,className:`btn btn-primary btn-sm`,onClick:n,children:`完成`}),children:[(0,I.jsx)(b,{tone:`success`,children:(0,I.jsxs)(`span`,{children:[u.trim()||O.label,` 的授权已通过官方通道导入。`]})}),e?null:(0,I.jsxs)(`p`,{className:`ov-sub`,style:{marginTop:12},children:[`回到列表点`,(0,I.jsx)(`b`,{children:`试通`}),`确认可用,再按需启用(启用后它才参与出站路由)。`]})]});if(o===`waiting`)return(0,I.jsx)(k,{title:`等待你完成授权`,onClose:n,children:(0,I.jsxs)(`div`,{className:`cred-guide`,children:[(0,I.jsxs)(`div`,{className:`cred-guide-note`,children:[`已为你打开 `,(0,I.jsx)(`b`,{children:O.label}),` 的授权页 —— `,(0,I.jsx)(`b`,{children:`请在浏览器里完成授权`}),`, 本窗口会自动检测结果,无需回到终端。`]}),g?(0,I.jsxs)(`div`,{className:`cred-guide-note`,children:[`若页面要求输入短码:`,(0,I.jsx)(`span`,{className:`code-chip`,children:g})]}):null,(0,I.jsx)(R,{command:f}),(0,I.jsxs)(`div`,{className:`cred-guide-note`,style:{display:`flex`,alignItems:`center`,gap:8},children:[(0,I.jsx)(a,{size:14}),`正在等待授权完成…(最多 5 分钟;没弹出浏览器就点上面的链接)`]}),S?(0,I.jsx)(b,{tone:`error`,children:E(S)}):null]})});let j=o===`confirm`;return(0,I.jsx)(k,{title:e?`重新导入授权 · ${e.name}`:`导入客户端`,onClose:n,footer:(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`button`,{type:`button`,className:`btn btn-quiet btn-sm`,onClick:n,children:`取消`}),(0,I.jsxs)(`button`,{type:`button`,className:`btn btn-primary btn-sm`,disabled:v,onClick:()=>{if(!j){s(`confirm`);return}A()},children:[v?(0,I.jsx)(a,{size:14}):(0,I.jsx)(t,{size:14}),v?`正在申请授权…`:j?`确定,前往授权页`:`导入`]})]}),children:j?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(b,{tone:`warn`,children:(0,I.jsxs)(`span`,{children:[`即将跳转至 `,(0,I.jsx)(`b`,{children:O.label}),` 的授权页面(`,(0,I.jsx)(`b`,{children:`新标签页`}),`)。 请在页面里登录并完成授权,授权完成后本窗口会自动检测。`]})}),(0,I.jsxs)(`div`,{className:`cred-guide-note`,style:{marginTop:12},children:[`授权只用于取本工具的凭证;令牌保存在`,(0,I.jsx)(`b`,{children:`本机服务端`}),`(0600),不会回传到浏览器。`]}),c===`anthropic`?(0,I.jsxs)(`div`,{className:`cred-guide-note`,style:{marginTop:8},children:[`⚠️ MiniMax 的凭证是`,(0,I.jsx)(`b`,{children:`同账号单会话`}),`:请用`,(0,I.jsx)(`b`,{children:`专用账号`}),`, 否则会与日常客户端互相顶下线。`]}):null,S?(0,I.jsx)(b,{tone:`error`,children:E(S)}):null]}):(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`p`,{className:`ov-sub`,children:[`选一个客户端,用它的`,(0,I.jsx)(`b`,{children:`官方授权`}),`拿到凭证(凭证在客户端登录态里,用户拿不到、无需手填)。`]}),(0,I.jsxs)(`div`,{className:`ov-field`,children:[(0,I.jsx)(`label`,{children:`客户端类型`}),(0,I.jsx)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:6},children:z.map(e=>(0,I.jsxs)(`label`,{style:{display:`flex`,alignItems:`center`,gap:8,cursor:`pointer`},children:[(0,I.jsx)(`input`,{type:`radio`,name:`import-client`,checked:c===e.protocol,onChange:()=>l(e.protocol)}),(0,I.jsxs)(`span`,{children:[(0,I.jsx)(`b`,{children:e.label}),(0,I.jsx)(`span`,{className:`ov-hint`,style:{marginLeft:8},children:e.desc})]})]},e.protocol))})]}),(0,I.jsxs)(`div`,{className:`ov-field`,children:[(0,I.jsx)(`label`,{htmlFor:`imp-name`,children:`名称(可留空)`}),(0,I.jsx)(`input`,{id:`imp-name`,className:`field-input text`,style:{width:`100%`},value:u,placeholder:O.label,onChange:e=>d(e.target.value)})]})]})})}var W={upstream:`上游`,seed:`种子`,manual:`手工`},G={upstream:`从上游模型目录拉取到的`,seed:`来自本地种子清单(上游拉取失败时的回落)`,manual:`人工添加的`};function K({catalog:t,catalogLoading:n,catalogMsg:r,catalogError:i,onCatalogRefresh:s,onCatalogReload:c,onModelToggled:u}){let[d,f]=(0,F.useState)(null),p=async e=>{f(e.id);try{await u(e.id,!e.enabled)}finally{f(null)}};return(0,I.jsxs)(`div`,{className:`up-col`,children:[(0,I.jsxs)(`div`,{className:`up-models-head`,children:[(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`b`,{children:`可用模型`}),(0,I.jsx)(`span`,{children:t?`${t.models.length} 个 · ${t.models.filter(e=>e.enabled).length} 个已启用`:`尚未获取`})]}),(0,I.jsx)(`div`,{className:`up-models-actions`,children:n?(0,I.jsxs)(`button`,{type:`button`,className:`btn btn-quiet btn-sm`,disabled:!0,children:[(0,I.jsx)(a,{size:14,className:`spin`,style:{animation:`spin 1s linear infinite`}}),`正在实测模型…`]}):(0,I.jsxs)(`button`,{type:`button`,className:`btn btn-quiet btn-sm`,onClick:s,children:[(0,I.jsx)(l,{size:14}),`获取模型`]})})]}),n?(0,I.jsxs)(`div`,{className:`up-progress`,role:`status`,children:[(0,I.jsx)(a,{size:14,className:`spin`,style:{animation:`spin 1s linear infinite`},"aria-hidden":!0}),(0,I.jsxs)(`span`,{children:[`正在逐个实测模型(每个 1 token)…这一步会真打上游,`,(0,I.jsx)(`b`,{children:`可能要几十秒`}),`,请不要关掉页面; 完成后结果会出现在这里,模型清单也会自动刷新。`]})]}):null,r?(0,I.jsx)(b,{tone:r.kind===`error`?`error`:r.kind===`partial`?`warn`:`success`,children:r.text}):null,i?(0,I.jsx)(T,{kind:`error`,title:`模型清单没拉到`,detail:E(i),onRetry:c}):n&&!t?(0,I.jsx)(T,{kind:`loading`,title:`正在向上游获取模型…`}):!t||t.models.length===0?(0,I.jsx)(T,{kind:`empty`,title:`还没有模型清单`,detail:`启用提供商后会自动同步一次它自己的模型清单;这里也可以手动点「获取模型」逐项实测是否真的能调通。`}):(0,I.jsx)(`div`,{className:`up-models`,children:t.models.map(t=>(0,I.jsxs)(`div`,{className:`up-model${t.enabled?``:` off`}`,children:[(0,I.jsxs)(`div`,{className:`um-info`,children:[(0,I.jsxs)(`b`,{children:[(0,I.jsx)(`span`,{className:`um-k`,children:`模型名:`}),t.displayName,(0,I.jsx)(m,{content:G[t.source],children:(0,I.jsx)(`span`,{className:`um-src src-${t.source}`,children:W[t.source]})}),t.tag?(0,I.jsx)(m,{content:`上游计价标签,随目录同步更新`,children:(0,I.jsx)(`span`,{className:`mu-tag`,children:t.tag})}):null]}),(0,I.jsxs)(`i`,{className:`code-chip`,children:[(0,I.jsx)(`span`,{className:`um-k`,children:`模型ID:`}),t.id]})]}),(0,I.jsxs)(`div`,{className:`um-meta`,children:[t.verified?(0,I.jsx)(m,{content:`实测可调通`,children:(0,I.jsxs)(`span`,{className:`um-ok`,children:[(0,I.jsx)(o,{size:12}),`可用`]})}):(0,I.jsx)(m,{content:`实测未通过(可能未订阅)`,children:(0,I.jsxs)(`span`,{className:`um-bad`,children:[(0,I.jsx)(e,{size:12}),`未通过`]})}),t.multiplier==null?(0,I.jsx)(m,{content:`接口与本地快照都没有该模型的倍率 —— 不编造`,children:(0,I.jsx)(`span`,{className:`um-mult unknown`,children:`倍率未知`})}):(0,I.jsx)(m,{content:t.source===`upstream`?`倍率取自上游 /v3/config 接口实时值,随目录刷新与每日同步更新。`:`接口未覆盖该模型,倍率为内置快照,可能随官方调价过期。`,children:(0,I.jsxs)(`span`,{className:`um-mult`,children:[`×`,t.multiplier]})}),(0,I.jsx)(P,{checked:t.enabled,disabled:d===t.id,label:`${t.enabled?`停用`:`启用`} ${t.displayName}`,onChange:()=>void p(t)})]})]},t.id))}),(0,I.jsxs)(`div`,{className:`up-foot`,children:[`实测会真打上游、消耗少量积分(每模型 1 token)。上游不接受的模型会标「未通过」, 但`,(0,I.jsx)(`b`,{children:`不删除`}),` —— 订阅以后可能又开,随时可以再拉一次。 倍率以 /v3/config 接口实时值为准(目录刷新与每日自动同步都会更新), 接口未覆盖的模型回落内置快照。`,(0,I.jsx)(`br`,{}),`启用提供商时会同步这家自己的清单;已有提供商的目录互不覆盖,启用/停用选择也分别保留。`]})]})}function q({window:e}){let t=_(()=>h.providers(),[],{cacheKey:`providers`}),[n,i]=(0,F.useState)(null),o=_(()=>h.catalog(n?.id),[n?.id],{cacheKey:n?.id?`catalog:${n.id}`:`catalog`}),s=_(()=>h.clients(e),[e],{cacheKey:`clients:${e}`}),[c,l]=(0,F.useState)(!1),[u,d]=(0,F.useState)(null),[f,g]=(0,F.useState)(null),[v,y]=(0,F.useState)(null),[S,D]=(0,F.useState)(null),[O,j]=(0,F.useState)(null),[M,P]=(0,F.useState)(null),[R,z]=(0,F.useState)(!1),B=x(),V=t.data?.items??[],H=s.data?.byProvider??[],W=()=>{t.reload(),o.reload(),s.reload()},G=async e=>{g(e.id),j(null);try{await h.activateProvider(e.id),P(null),W()}catch(e){j(e instanceof p?e:new p(String(e),0,0))}finally{g(null)}},q=async e=>{g(e.id),j(null);try{await h.deactivateProvider(e.id),W()}catch(e){j(e instanceof p?e:new p(String(e),0,0))}finally{g(null)}},Y=async e=>{g(e.id),j(null);try{let n=await h.providerSigninNow(e.id);P({kind:n.ok?`ok`:`error`,text:n.message}),n.ok?B.push(n.outcome===`none`?{tone:`info`,message:`${e.name}:${n.message}`}:{tone:`success`,message:`${e.name} 签到成功${n.points?` · +${n.points} 积分`:``}。`}):B.push({tone:`error`,message:`${e.name} 签到失败:${n.message}`}),t.reload()}catch(t){let n=t instanceof p?t:new p(String(t),0,0);j(n),B.push({tone:`error`,message:`${e.name} 签到失败:${n.message||`请求未完成`}`})}finally{g(null)}},X=async e=>{g(e.id),j(null);try{let n=await h.providerGrowthRun(e.id),r=n.tasks?.filter(e=>e.outcome===`claimed`).length??0,i=n.tasks?.filter(e=>e.outcome===`already`).length??0,a=n.tasks?.filter(e=>e.outcome===`skipped`).length??0,o=n.ok?`领取完成:签到 ${n.signin?.points??0} 积分;任务新领 ${r}、已领过 ${i}、待完成 ${a};本轮合计 +${n.creditsGained??0}。`:n.message??`领取失败。`;P({kind:n.ok?`ok`:`error`,text:o}),B.push(n.ok?{tone:`success`,message:`${e.name}:${o}`}:{tone:`error`,message:`${e.name} 领取失败:${n.message??`未知原因`}`}),t.reload()}catch(t){let n=t instanceof p?t:new p(String(t),0,0);j(n),B.push({tone:`error`,message:`${e.name} 领取失败:${n.message||`请求未完成`}`})}finally{g(null)}},Z=async e=>{let n=globalThis.prompt?.(`粘贴 WorkBuddy OAuth 凭证 JSON(tools/wb-oauth-export.mjs 的输出):`,``)??null;if(!n)return;let r;try{r=JSON.parse(n)}catch{P({kind:`error`,text:`不是合法 JSON —— 请完整复制导出文件内容。`});return}g(e.id),j(null);try{let n=await h.providerOauthImport(e.id,r);P({kind:n.ok?`ok`:`error`,text:n.message}),t.reload()}catch(e){j(e instanceof p?e:new p(String(e),0,0))}finally{g(null)}},Q=async()=>{if(!S||f)return;let e=S;g(e.id),j(null);try{await h.deleteProvider(e.id),D(null),W()}catch(e){j(e instanceof p?e:new p(String(e),0,0)),D(null)}finally{g(null)}},ee=async()=>{if(!R){z(!0),P(null),j(null);try{let e=await h.refreshCatalog(),r=e.configPulled===!1?` 倍率未从接口取到,沿用本地快照。`:e.multipliersUpdated?` 倍率已按接口同步(${e.multipliersUpdated} 项有更新)。`:``,i=e.perProvider?.find(e=>e.id===n?.id),a=i?.checked??e.checked,s=i?.ok??e.ok,c=i?.failed.length??e.failed.length;P(c>0?{kind:`partial`,text:`已实测 ${a} 个模型:${s} 个可用、${c} 个未通过(可能未订阅)。未通过的不会删除,订阅后可再拉一次。${r}`}:{kind:`ok`,text:`已实测 ${a} 个模型,全部可用。${r}`}),o.reload(),t.reload()}catch(e){let t=e instanceof p?e:new p(String(e),0,0);P({kind:`error`,text:`获取模型失败:${E(t)}`})}finally{z(!1)}}},te=async(e,t)=>{j(null);try{await h.setModelEnabled(e,t,n?.id),o.reload()}catch(e){j(e instanceof p?e:new p(String(e),0,0))}},$=V.filter(e=>e.active).length;return(0,I.jsxs)(I.Fragment,{children:[O?(0,I.jsx)(b,{tone:`error`,children:E(O)}):null,s.error?(0,I.jsxs)(b,{tone:`error`,actions:(0,I.jsx)(`button`,{type:`button`,className:`btn btn-quiet btn-sm`,onClick:s.reload,children:`重试`}),children:[`提供商用量没取到:`,E(s.error)]}):null,(0,I.jsxs)(C,{title:`提供商`,aside:(0,I.jsxs)(`span`,{className:`panel-aside-row`,children:[$>0?(0,I.jsxs)(w,{tone:`live`,dot:!0,children:[`已启用 `,$,` 家`]}):null,(0,I.jsx)(m,{content:`选一个客户端(WorkBuddy / MiniMax Code / Qoder CN),用它的官方授权导入凭证`,children:(0,I.jsxs)(`button`,{type:`button`,className:`btn btn-primary btn-sm`,onClick:()=>l(!0),children:[(0,I.jsx)(r,{size:14}),`导入客户端`]})})]}),padded:!1,children:[t.initial&&t.loading?(0,I.jsx)(`div`,{style:{padding:`0 20px 18px`},children:(0,I.jsx)(A,{})}):t.error?(0,I.jsx)(`div`,{style:{padding:`0 20px 18px`},children:(0,I.jsx)(T,{kind:`error`,title:`提供商列表没取到`,detail:E(t.error),onRetry:t.reload})}):V.length===0?(0,I.jsx)(`div`,{style:{padding:`0 20px 18px`},children:(0,I.jsx)(T,{kind:`empty`,title:`还没有任何提供商`,detail:`先登记一个上游,再按需启用它的出站路由。`})}):(0,I.jsx)(L,{rows:V,byProvider:H,busyId:f,onEdit:y,onSignin:e=>void Y(e),onGrowthRun:e=>void X(e),onOauthImport:e=>void Z(e),onModels:e=>{P(null),i(e)},onActivate:e=>void G(e),onDeactivate:e=>void q(e),onDelete:D}),(0,I.jsxs)(`div`,{className:`footer-note`,style:{padding:`0 20px 18px`},children:[`启用提供商会让它加入出站路由,并同步它自己的模型清单;已启用的提供商可以并行生效,模型按各自目录路由。 三家凭证都来自各客户端的`,(0,I.jsx)(`b`,{children:`官方授权`}),`(用户无需也无法手填)——点「重新导入授权」即可换账号或刷新令牌; 令牌只存在服务端,任何接口都读不回完整值。`,(0,I.jsx)(`br`,{}),`行内三列用量按`,(0,I.jsx)(`b`,{children:`提供商`}),`归属:由「模型 id → 生效目录的提供商」解析(请求记录本身没有 provider 维度)。模型不属于任何生效目录的行归到「未归属」,不冒充某一家。`]})]}),c?(0,I.jsx)(U,{onClose:()=>{l(!1),W()},onImported:()=>W()}):null,u?(0,I.jsx)(U,{provider:{id:u.id,name:u.name,protocol:u.protocol},onClose:()=>{d(null),W()},onImported:()=>W()}):null,v?(0,I.jsx)(J,{provider:v,onClose:()=>y(null),onSaved:()=>{y(null),W()},onReimport:()=>{let e=v;y(null),e&&d(e)}}):null,n?(0,I.jsx)(N,{title:`模型列表 · ${n.name}`,subtitle:n.baseUrl,onClose:()=>i(null),children:(0,I.jsx)(`div`,{className:`drawer-body`,children:(0,I.jsx)(K,{catalog:o.data,catalogLoading:R,catalogMsg:M,catalogError:o.error,onCatalogRefresh:()=>void ee(),onCatalogReload:o.reload,onModelToggled:te})})}):null,S?(0,I.jsx)(k,{title:`删除这个提供商?`,onClose:()=>{f||D(null)},footer:(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`button`,{type:`button`,className:`btn btn-primary btn-sm`,disabled:!!f,onClick:()=>D(null),children:`取消(保留)`}),(0,I.jsxs)(`button`,{type:`button`,className:`btn btn-danger btn-sm`,disabled:!!f,onClick:()=>void Q(),children:[f?(0,I.jsx)(a,{size:14,className:`spin`}):null,f?`删除中…`:`确认删除`]})]}),children:(0,I.jsxs)(`div`,{className:`ov-lose`,children:[(0,I.jsx)(`b`,{children:`会失去什么:`}),`提供商「`,S.name,`」(`,S.baseUrl,`)的登记与它的凭证文件一并删除, 需要重新登记并填一次 ck_ 密钥。此操作不可撤销。`]})}):null]})}function J({provider:e,onClose:t,onSaved:i,onReimport:o}){let[s,c]=(0,F.useState)(e.name),[l,u]=(0,F.useState)(e.baseUrl),[d,f]=(0,F.useState)(!1),[g,_]=(0,F.useState)(!1),[v,y]=(0,F.useState)(null),[x,S]=(0,F.useState)(null),[C,w]=(0,F.useState)(!1),[T,D]=(0,F.useState)(null),O=async()=>{if(!C){w(!0),D(null),y(null);try{let t=await h.providerImportLocal(e.id);if(t.ok)D({kind:`ok`,text:t.message+(t.detail?`\n${t.detail}`:``)}),i();else if(t.outcome===`unavailable`){let t=e.protocol===`qoder`?`qoder`:`minimax`;D({kind:`unavailable`,text:`本服务所在机器上读不到客户端登录态(远程部署的正常情形)。`,command:`node tools/import-credential-push.mjs ${location.origin} ${t} --provider ${e.id}`})}else D({kind:`error`,text:t.message+(t.detail?`\n${t.detail}`:``)})}catch(e){y(e instanceof p?e:new p(String(e),0,0))}finally{w(!1)}}},k=async t=>{if(t.preventDefault(),!d){f(!0),y(null);try{let t={};s.trim()!==e.name&&(t.name=s.trim()),l.trim()!==e.baseUrl&&(t.baseUrl=l.trim()),Object.keys(t).length>0&&await h.patchProvider(e.id,t),i()}catch(e){y(e instanceof p?e:new p(String(e),0,0))}finally{f(!1)}}},A=async()=>{if(!g){_(!0),y(null),S(null);try{S(await h.testProvider(e.id,void 0))}catch(e){y(e instanceof p?e:new p(String(e),0,0))}finally{_(!1)}}};return(0,I.jsx)(N,{title:`配置提供商 · ${e.name}`,subtitle:e.baseUrl,onClose:t,children:(0,I.jsxs)(`div`,{className:`drawer-body`,children:[v?(0,I.jsx)(b,{tone:`error`,children:E(v)}):null,(0,I.jsxs)(`form`,{onSubmit:e=>void k(e),className:`prov-edit`,style:{marginTop:6},children:[(0,I.jsxs)(`div`,{className:`up-row`,children:[(0,I.jsx)(`div`,{className:`up-lab`,children:`名称`}),(0,I.jsx)(`input`,{className:`field-input text`,style:{width:`100%`},value:s,onChange:e=>c(e.target.value),"aria-label":`提供商名称`})]}),(0,I.jsxs)(`div`,{className:`up-row`,children:[(0,I.jsx)(`div`,{className:`up-lab`,children:`地址`}),(0,I.jsx)(`input`,{className:`field-input text`,style:{width:`100%`},value:l,placeholder:`https://api.example.com`,onChange:e=>u(e.target.value),"aria-label":`提供商地址`})]}),(0,I.jsxs)(`div`,{className:`up-row`,children:[(0,I.jsx)(`div`,{className:`up-lab`,children:`凭证`}),(0,I.jsxs)(`div`,{className:`cred-guide`,children:[(0,I.jsx)(`div`,{className:`cred-guide-note`,children:e.protocol===`openai`?(0,I.jsxs)(I.Fragment,{children:[`凭证来自 WorkBuddy `,(0,I.jsx)(`b`,{children:`官方 OAuth 授权`}),`(桌面端 / 插件同一条通道),无需手填。`]}):e.protocol===`anthropic`?(0,I.jsxs)(I.Fragment,{children:[`凭证是客户端登录态里的 `,(0,I.jsx)(`span`,{className:`code-chip`,children:`mmort_…`}),` refresh token。 请用`,(0,I.jsx)(`b`,{children:`专用账号`}),`(与桌面端共用会互相顶下线)。`]}):(0,I.jsxs)(I.Fragment,{children:[`凭证来自 Qoder 客户端登录态(一段`,(0,I.jsx)(`b`,{children:`身份 JSON`}),`)。桌面客户端与它`,(0,I.jsx)(`b`,{children:`互不影响`}),`。`]})}),(0,I.jsxs)(`div`,{className:`cred-guide-actions`,children:[(0,I.jsxs)(`button`,{type:`button`,className:`btn btn-primary btn-sm`,disabled:d,onClick:()=>o(),children:[(0,I.jsx)(r,{size:14}),`重新导入授权`]}),(0,I.jsxs)(`button`,{type:`button`,className:`btn btn-quiet btn-sm`,disabled:C,onClick:()=>void O(),children:[C?(0,I.jsx)(a,{size:14}):(0,I.jsx)(r,{size:14}),`从本机客户端读取`]})]}),T?(0,I.jsx)(b,{tone:T.kind===`ok`?`success`:T.kind===`unavailable`?`warn`:`error`,children:(0,I.jsxs)(`span`,{children:[T.text,T.command?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`br`,{}),`在`,(0,I.jsx)(`b`,{children:`装了客户端的那台机器`}),`的仓库目录下跑:`,(0,I.jsx)(R,{command:T.command})]}):null]})}):null,e.protocol===`qoder`?(0,I.jsxs)(`div`,{className:`cred-guide-note`,children:[`本服务`,(0,I.jsx)(`b`,{children:`不自动刷新`}),` Qoder 令牌;过期后重跑一次导入即可。`]}):null]})]}),(0,I.jsxs)(`div`,{className:`up-actions`,children:[(0,I.jsxs)(`button`,{type:`submit`,className:`btn btn-primary btn-sm`,disabled:d,children:[d?(0,I.jsx)(a,{size:14}):(0,I.jsx)(n,{size:14}),`保存`]}),(0,I.jsx)(m,{content:`用已导入的授权测这家上游是否还通`,children:(0,I.jsxs)(`button`,{type:`button`,className:`btn btn-quiet btn-sm`,disabled:g,onClick:()=>void A(),children:[g?(0,I.jsx)(a,{size:14}):null,`测试`]})})]})]}),x?(0,I.jsx)(b,{tone:x.ok?`success`:`warn`,children:(0,I.jsx)(`span`,{children:x.ok?(0,I.jsxs)(I.Fragment,{children:[`通了:`,e.name,` 接受了这次 1 token 探测(`,x.elapsedMs,`ms)。`]}):x.httpStatus===null?(0,I.jsxs)(I.Fragment,{children:[`没连上(网络层):`,x.reason??`未知原因`,`。先查地址与出网,再看凭证。`]}):(0,I.jsxs)(I.Fragment,{children:[`连上了但被拒(HTTP `,x.httpStatus,x.upstreamCode===null?``:` · 业务码 ${x.upstreamCode}`,`)。`,x.upstreamCode===11102?`业务码 11102 = 账号没订阅这个模型。key 可能是好的,换个模型再测或直接切换。`:`通常是凭证问题;换一把再测。`]})})}):null,(0,I.jsx)(`div`,{className:`up-note`,style:{marginTop:18},children:(0,I.jsxs)(`span`,{children:[`凭证只存在`,(0,I.jsx)(`b`,{children:`服务端`}),`:界面只显示账号摘要或掩码,任何接口都读不回完整值。`]})})]})})}function Y(){let[e,t]=(0,F.useState)(()=>M()??`today`);return(0,I.jsxs)(`div`,{className:`view on`,children:[(0,I.jsx)(D,{title:`提供商管理`,actions:(0,I.jsx)(O,{value:e,options:v,onChange:e=>{j(e),t(e)},width:148})}),(0,I.jsx)(`div`,{className:`view-body stack`,children:(0,I.jsx)(q,{window:e})})]})}export{Y as ClientsPage};
@@ -1 +0,0 @@
1
- import{B as e,N as t,_ as n,i as r,it as i,r as a,tt as o}from"./vendor-befEYGHM.js";import{O as s,_ as c,a as l,c as u,g as d,j as f,k as p,m,p as h,r as g,v as _,x as v}from"./index-BJtz6Ses.js";import{a as y,c as b,i as x,n as S,r as C,s as w,t as T}from"./Select-HrLgXSri.js";import{r as E}from"./PageSkeleton-DG-Dj4_9.js";import{n as D,t as O}from"./sharedWindow-FDfq75PI.js";import{t as k}from"./useFx-xcrp_LHB.js";import{n as A,r as j,t as M}from"./ClientMetricTip-DIe3I7w4.js";var N=i(),P=o();function F({navigate:i}){let[o,F]=(0,N.useState)(()=>O()??`today`),I=f(()=>u.overview(o),[o],{cacheKey:`overview:${o}`});k(`overview-${o}-${I.data?`ready`:`pending`}`);let L=I.data,R={today:(()=>{let e=new Date;return e.getHours()*60+e.getMinutes()||1})(),"1h":60,"24h":1440,"7d":10080,"30d":43200},z=L?R[L.window]:null,B=L&&z?L.metrics.requests/z:null,V=L&&z?L.metrics.totalTokens/z:null,H=e=>{if(!L||L.byClient.length===0)return;let t=[...L.byClient].sort((t,n)=>(n[e]??0)-(t[e]??0));return(0,P.jsx)(M,{rows:t,metric:e,windowLabel:s[L.window],total:e===`credits`?L.metrics.creditsUsed:L.metrics.requests,totalCount:t.length})};return(0,P.jsxs)(`div`,{className:`view on`,children:[(0,P.jsx)(w,{title:`概览`,status:L?(0,P.jsxs)(b,{tone:`live`,dot:!0,children:[`本机日志聚合 · `,_(L.generatedAt)]}):null,actions:(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(T,{value:o,options:p,onChange:e=>{D(e),F(e)},width:148}),(0,P.jsxs)(`button`,{type:`button`,className:`btn btn-primary btn-sm`,onClick:()=>i(`keys`),children:[(0,P.jsx)(n,{size:14}),`新建密钥`]})]})}),(0,P.jsx)(`div`,{className:`view-body stack`,children:I.initial&&I.loading?(0,P.jsx)(E,{}):I.error?(0,P.jsx)(y,{children:(0,P.jsx)(S,{kind:`error`,title:`概览数据没取到`,detail:C(I.error),onRetry:I.reload})}):L?(0,P.jsxs)(P.Fragment,{children:[L.alerts.channelReject.count>=L.alerts.channelReject.threshold?(0,P.jsxs)(g,{tone:`warn`,children:[(0,P.jsx)(a,{size:14,"aria-hidden":!0}),`最近 1 小时出现 `,(0,P.jsxs)(`b`,{children:[L.alerts.channelReject.count,` 次`]}),`上游渠道校验拒绝(11128): 请求的 system 提示命中了上游的第三方客户端指纹。本服务会自动改写模板行、被拒时降级重试, 连续失败说明出现了新的指纹变体。请到「请求日志」筛 note 含 upstream_11128 的行排查。`]}):null,L.alerts.credentialInvalid?.count!=null&&L.alerts.credentialInvalid.count>=L.alerts.credentialInvalid.threshold?(0,P.jsxs)(g,{tone:`error`,actions:(0,P.jsx)(`a`,{href:`#/clients`,className:`btn btn-quiet btn-sm`,children:`去提供商管理`}),children:[(0,P.jsx)(a,{size:14,"aria-hidden":!0}),`最近 1 小时出现 `,(0,P.jsxs)(`b`,{children:[L.alerts.credentialInvalid.count,` 次`]}),`上游访问密钥失效: 所有请求将以 502 失败,直到换新为止。`]}):null,(0,P.jsx)(j,{metrics:L.metrics}),(0,P.jsxs)(`div`,{className:`metric-row`,children:[(0,P.jsx)(x,{label:`已消耗积分`,value:h(L.metrics.creditsUsed),detail:L.metrics.creditsUnknownCount>0?`上游实扣 · 另 ${d(L.metrics.creditsUnknownCount)} 条上游未回报,未计入`:`上游实扣 · 全部请求均已回报`,tone:`amber`,icon:(0,P.jsx)(e,{size:14}),tip:H(`credits`),tipPos:`down`}),(0,P.jsx)(x,{label:`平均 RPM`,value:B===null?`—`:d(Math.round(B)),detail:`每分钟请求 · ${s[L.window]}`,tone:`violet`,icon:(0,P.jsx)(t,{size:14}),tip:H(`requests`),tipPos:`down`}),(0,P.jsx)(x,{label:`平均 TPM`,value:V===null?`—`:v(Math.round(V)),detail:`每分钟 tokens · ${s[L.window]}`,tone:`green`,icon:(0,P.jsx)(r,{size:14}),tip:H(`tokens`),tipPos:`down`})]}),L.creditLedgers.length>0?(0,P.jsxs)(y,{title:`积分账本`,aside:(0,P.jsx)(b,{children:`上游账户账本(全部历史,含非本服务消耗)`}),children:[(0,P.jsx)(`div`,{className:`tbl-scroll`,children:(0,P.jsxs)(`table`,{className:`tbl`,children:[(0,P.jsx)(`thead`,{children:(0,P.jsxs)(`tr`,{children:[(0,P.jsx)(`th`,{scope:`col`,children:`提供商`}),(0,P.jsx)(`th`,{scope:`col`,className:`r`,children:`剩余积分`}),(0,P.jsx)(`th`,{scope:`col`,className:`r`,children:`已消耗`}),(0,P.jsx)(`th`,{scope:`col`,className:`r`,children:`累计发放`}),(0,P.jsx)(`th`,{scope:`col`,children:`最近过期`})]})}),(0,P.jsx)(`tbody`,{children:L.creditLedgers.map(e=>(0,P.jsxs)(`tr`,{children:[(0,P.jsxs)(`td`,{className:`td-strong`,children:[e.providerName,e.stale?(0,P.jsx)(b,{tone:`ghost`,children:`数据偏旧`}):null]}),(0,P.jsx)(`td`,{className:`r td-mono`,children:e.remaining===null?`—`:h(e.remaining)}),(0,P.jsx)(`td`,{className:`r td-mono`,children:e.consumed===null?`—`:h(e.consumed)}),(0,P.jsx)(`td`,{className:`r td-mono`,children:e.granted===null?`—`:h(e.granted)}),(0,P.jsx)(`td`,{className:`td-sub td-mono`,children:e.nextExpireAt?m(e.nextExpireAt):`—`})]},e.providerId))})]})}),(0,P.jsxs)(`details`,{className:`footer-note ledger-caveat`,children:[(0,P.jsx)(`summary`,{children:`各家账本口径不同(含官方直连消耗,比逐条统计更全)`}),(0,P.jsx)(`b`,{children:`MiniMax`}),` 来自 credit/details(余额/已用/发放齐全,精确到 0.01);`,(0,P.jsx)(`b`,{children:`WorkBuddy`}),` 来自资源包聚合(get-user-resource,剩余/发放为包级真实数);`,(0,P.jsx)(`b`,{children:`Qoder`}),` 来自 me/usage(套餐内 + 资源包合计,签到赠送进资源包)。 到期时刻上游不提供,该列显示「—」。`]})]}):null,(0,P.jsx)(y,{title:`提供商用量摘要`,aside:(0,P.jsxs)(b,{children:[L.byClient.length,` 个提供商 · 按 Token 排序`]}),children:L.byClient.length>0?(0,P.jsx)(`div`,{className:`tbl-scroll`,children:(0,P.jsxs)(`table`,{className:`tbl`,children:[(0,P.jsxs)(`caption`,{className:`sr-only`,children:[`提供商用量摘要,共 `,L.byClient.length,` 个提供商`]}),(0,P.jsx)(`thead`,{children:(0,P.jsxs)(`tr`,{children:[(0,P.jsx)(`th`,{scope:`col`,children:`提供商`}),(0,P.jsx)(`th`,{scope:`col`,className:`r`,children:`请求次数`}),(0,P.jsx)(`th`,{scope:`col`,className:`r`,children:`Token 消耗`}),(0,P.jsx)(`th`,{scope:`col`,className:`r`,children:`消耗积分`}),(0,P.jsx)(`th`,{scope:`col`,className:`r`,children:`Token 占比`}),(0,P.jsx)(`th`,{scope:`col`,children:`分布`})]})}),(0,P.jsx)(`tbody`,{children:[...L.byClient].sort((e,t)=>(t.tokens??0)-(e.tokens??0)).slice(0,6).map(e=>(0,P.jsxs)(`tr`,{children:[(0,P.jsx)(`td`,{className:`td-strong`,children:(0,P.jsx)(l,{content:(0,P.jsx)(A,{row:e}),children:(0,P.jsx)(`span`,{children:e.client??`未归属`})})}),(0,P.jsx)(`td`,{className:`r td-mono`,children:d(e.requests)}),(0,P.jsx)(`td`,{className:`r td-mono`,children:v(e.tokens??0)}),(0,P.jsx)(`td`,{className:`r td-mono`,children:h(e.credits)}),(0,P.jsx)(`td`,{className:`r td-mono`,children:c(e.share)}),(0,P.jsx)(`td`,{children:(0,P.jsx)(`div`,{className:`ov-bar-track`,children:(0,P.jsx)(`div`,{className:`ov-bar-fill`,style:{width:`${Math.max(2,Math.round((e.share??0)*100))}%`}})})})]},e.clientId??e.client??`unknown`))})]})}):(0,P.jsxs)(`div`,{className:`empty-note`,style:{padding:`24px 0`},children:[s[L.window],`没有提供商消耗记录。`]})}),(0,P.jsxs)(y,{title:`模型用量摘要`,aside:(0,P.jsxs)(b,{children:[L.byModel.length,` 个模型 · 按 Token 排序`]}),children:[L.byModel.length>0?(0,P.jsx)(`div`,{className:`tbl-scroll`,children:(0,P.jsxs)(`table`,{className:`tbl`,children:[(0,P.jsxs)(`caption`,{className:`sr-only`,children:[`模型用量摘要,共 `,L.byModel.length,` 个模型`]}),(0,P.jsx)(`thead`,{children:(0,P.jsxs)(`tr`,{children:[(0,P.jsx)(`th`,{scope:`col`,children:`模型`}),(0,P.jsx)(`th`,{scope:`col`,className:`r`,children:`请求次数`}),(0,P.jsx)(`th`,{scope:`col`,className:`r`,children:`Token 消耗`}),(0,P.jsx)(`th`,{scope:`col`,className:`r`,children:`消耗积分`}),(0,P.jsx)(`th`,{scope:`col`,className:`r`,children:`Token 占比`}),(0,P.jsx)(`th`,{scope:`col`,children:`分布`})]})}),(0,P.jsx)(`tbody`,{children:[...L.byModel].sort((e,t)=>(t.tokens??0)-(e.tokens??0)).slice(0,8).map(e=>{let t=e.displayName??e.model??`未知`;return(0,P.jsxs)(`tr`,{children:[(0,P.jsx)(`td`,{className:`td-strong`,children:t}),(0,P.jsx)(`td`,{className:`r td-mono`,children:d(e.requests)}),(0,P.jsx)(`td`,{className:`r td-mono`,children:v(e.tokens??0)}),(0,P.jsx)(`td`,{className:`r td-mono`,children:h(e.credits)}),(0,P.jsx)(`td`,{className:`r td-mono`,children:c(e.share)}),(0,P.jsx)(`td`,{children:(0,P.jsx)(`div`,{className:`ov-bar-track`,children:(0,P.jsx)(`div`,{className:`ov-bar-fill`,style:{width:`${Math.max(2,Math.round((e.share??0)*100))}%`}})})})]},e.model??t)})})]})}):(0,P.jsxs)(`div`,{className:`empty-note`,style:{padding:`24px 0`},children:[s[L.window],`没有模型消耗记录。`]}),(0,P.jsx)(`div`,{className:`footer-note`,children:`这一页只留结论。详细构成去「积分与用量」,逐条请求去「请求日志」。`})]}),(0,P.jsx)(`div`,{className:`footer-note`,style:{marginTop:0},children:L.provenance.note})]}):null})]})}export{F as OverviewPage};