dsh-opendesign-corouter 0.1.9 → 0.1.10

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
@@ -32,7 +32,7 @@ dsh plugin --profile web add dsh-opendesign-corouter
32
32
  也可打开 [Actions → CI](https://github.com/KouzakiUmi/dsh-opendesign-corouter/actions/workflows/ci.yml),从成功构建下载 **`dsh-opendesign-corouter-build`** artifact。登录 GitHub 后解压 ZIP,取得 `.tgz` 与 `.sha256`,再安装本地包:
33
33
 
34
34
  ```console
35
- dsh plugin --profile web add /absolute/path/to/dsh-opendesign-corouter-0.1.9.tgz
35
+ dsh plugin --profile web add /absolute/path/to/dsh-opendesign-corouter-0.1.10.tgz
36
36
  ```
37
37
 
38
38
  `web` 只是示例,请替换为目标 Profile。Desktop 使用桌面安装器提供的 `dsh` 入口;独立公共 CLI 不能代管保留的 `desktop` Profile。安装后的启用与重载按目标 DSH 的管理流程进行。
package/lib/client.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import * as React from 'react';
2
2
  import openDesignCoRouterRemote, { type CoRouterRemote } from './generated/typert.remote-client.js';
3
3
  import type { TypertClientRemote } from '@deepseek-ai/dsh-typert-protocol';
4
- import { type LoginState, type Status, type StatusModel } from './remote.js';
4
+ import { type LoginState, type Status, type StatusModel, type PriceCatalog } from './remote.js';
5
5
  import type { QuotaSnapshot, QuotaWindow } from './quota.js';
6
6
  import { type ApiProtocol } from './protocol-options.js';
7
7
  import type { ModelSettings, ModelSettingsMap } from './model-settings.js';
@@ -82,16 +82,29 @@ interface Notice {
82
82
  }
83
83
  export declare function formatUsd(value: number | undefined): string;
84
84
  export declare function formatTime(value: string | undefined): string;
85
+ /** Relative time uses the actual scheduled instant, not the refresh interval. */
86
+ export declare function formatRelativeDeadline(value: string | undefined, now: number, dueText: string): string;
87
+ export declare function formatRefreshCountdown(value: string | undefined, now: number): string;
85
88
  /** Token capacities use the same zh-CN grouping as amounts so large windows stay readable. */
86
89
  export declare function formatTokens(value: number | undefined): string;
90
+ /** Compact credits for the summary; exact figures remain available to assistive technology. */
91
+ export declare function formatWindowCredits(value: number): string;
92
+ type QuotaTone = 'neutral' | 'good' | 'warn' | 'critical';
93
+ export declare function quotaStatusView(quota: QuotaSnapshot, now: number): {
94
+ title: string;
95
+ tone: QuotaTone;
96
+ icon: string;
97
+ window?: QuotaWindow;
98
+ };
87
99
  export interface QuotaViewProps {
88
100
  quota: QuotaSnapshot | undefined;
89
101
  nextAutoRefreshAt?: string | undefined;
90
102
  refreshIntervalSeconds?: number | undefined;
103
+ busy?: boolean | undefined;
91
104
  }
92
105
  /** Earliest still-future window reset; quota recovery comes only from `windows[].resetsAt`. */
93
106
  export declare function nextWindowResetAt(windows: readonly QuotaWindow[], now: number): string | undefined;
94
- export declare function QuotaView({ quota, nextAutoRefreshAt, refreshIntervalSeconds }: QuotaViewProps): React.DetailedReactHTMLElement<{
107
+ export declare function QuotaView({ quota, nextAutoRefreshAt, refreshIntervalSeconds, busy }: QuotaViewProps): React.DetailedReactHTMLElement<{
95
108
  className: string;
96
109
  role: "status";
97
110
  }, HTMLElement> | React.FunctionComponentElement<{
@@ -157,9 +170,11 @@ export interface ModelRowProps {
157
170
  authoritative: boolean;
158
171
  writable: boolean;
159
172
  pending: boolean;
173
+ price?: PriceCatalog['models'][number] | undefined;
174
+ priceKnown?: boolean | undefined;
160
175
  onCommit: (next: ModelSettings | undefined) => Promise<boolean>;
161
176
  }
162
- export declare function ModelRow({ model, settings, authoritative, writable, pending, onCommit }: ModelRowProps): React.DetailedReactHTMLElement<{
177
+ export declare function ModelRow({ model, settings, authoritative, writable, pending, price, priceKnown, onCommit }: ModelRowProps): React.DetailedReactHTMLElement<{
163
178
  className: string;
164
179
  }, HTMLElement>;
165
180
  export interface ModelsProps {
@@ -170,8 +185,11 @@ export interface ModelsProps {
170
185
  onRefreshModels: () => void;
171
186
  refreshingModels: boolean;
172
187
  notice: Notice | null;
188
+ prices?: PriceCatalog | undefined;
189
+ refreshingPrices?: boolean | undefined;
190
+ onRefreshPrices?: (() => void) | undefined;
173
191
  }
174
- export declare function Models({ status, formSnapshot, setFormField, pendingField, onRefreshModels, refreshingModels, notice }: ModelsProps): React.FunctionComponentElement<{
192
+ export declare function Models({ status, formSnapshot, setFormField, pendingField, onRefreshModels, refreshingModels, notice, prices, refreshingPrices, onRefreshPrices }: ModelsProps): React.FunctionComponentElement<{
175
193
  children?: React.ReactNode | undefined;
176
194
  }>;
177
195
  export interface AdvancedProps {
package/lib/client.js CHANGED
@@ -39,9 +39,12 @@ __export(client_exports, {
39
39
  QuotaView: () => QuotaView,
40
40
  SettingsPage: () => SettingsPage,
41
41
  apply: () => apply,
42
+ formatRefreshCountdown: () => formatRefreshCountdown,
43
+ formatRelativeDeadline: () => formatRelativeDeadline,
42
44
  formatTime: () => formatTime,
43
45
  formatTokens: () => formatTokens,
44
46
  formatUsd: () => formatUsd,
47
+ formatWindowCredits: () => formatWindowCredits,
45
48
  inject: () => inject,
46
49
  modelEnabled: () => modelEnabled,
47
50
  modelSettingsEntry: () => modelSettingsEntry,
@@ -51,6 +54,7 @@ __export(client_exports, {
51
54
  parseNumberInput: () => parseNumberInput,
52
55
  protocolEndpoint: () => protocolEndpoint,
53
56
  quotaAutoRefresh: () => quotaAutoRefresh,
57
+ quotaStatusView: () => quotaStatusView,
54
58
  tabAfter: () => tabAfter,
55
59
  writeModelSettings: () => writeModelSettings
56
60
  });
@@ -20068,6 +20072,40 @@ function member(value, allowed, label) {
20068
20072
  if (hit === void 0) throw new Error(`${label} \u4E0D\u5728\u5141\u8BB8\u7684\u53D6\u503C\u5185`);
20069
20073
  return hit;
20070
20074
  }
20075
+ function parsePriceCatalog(value) {
20076
+ if (!record2(value) || !Array.isArray(value.models) || value.models.length > MAX_MODELS) throw new Error("\u4EF7\u683C\u76EE\u5F55\u683C\u5F0F\u65E0\u6548");
20077
+ const state = member(value.state, ["ok", "partial", "error"], "\u4EF7\u683C\u76EE\u5F55\u72B6\u6001");
20078
+ const stale = flag(value.stale, "\u4EF7\u683C\u7F13\u5B58\u72B6\u6001");
20079
+ const fetchedAt = value.fetchedAt === void 0 ? void 0 : isoTime(value.fetchedAt, "\u4EF7\u683C\u66F4\u65B0\u65F6\u95F4");
20080
+ if (stale && fetchedAt === void 0) throw new Error("\u8FC7\u671F\u4EF7\u683C\u5FC5\u987B\u6807\u6CE8\u66F4\u65B0\u65F6\u95F4");
20081
+ const ids = /* @__PURE__ */ new Set();
20082
+ const nullableAmount = (item) => {
20083
+ if (item === null) return null;
20084
+ const result = amount(item, "\u4EF7\u683C");
20085
+ if (result > 1e6) throw new Error("\u4EF7\u683C\u8D85\u51FA\u8303\u56F4");
20086
+ return result;
20087
+ };
20088
+ const models = value.models.map((model) => {
20089
+ if (!record2(model) || !Array.isArray(model.tiers) || model.tiers.length === 0 || model.tiers.length > 8) throw new Error("\u6A21\u578B\u4EF7\u683C\u683C\u5F0F\u65E0\u6548");
20090
+ const id = text(model.id, "\u6A21\u578B id", 128);
20091
+ if (!MODEL_ID.test(id) || ids.has(id)) throw new Error("\u6A21\u578B\u4EF7\u683C id \u65E0\u6548\u6216\u91CD\u590D");
20092
+ ids.add(id);
20093
+ const tiers = model.tiers.map((tier) => {
20094
+ if (!record2(tier)) throw new Error("\u4EF7\u683C\u6863\u4F4D\u683C\u5F0F\u65E0\u6548");
20095
+ return {
20096
+ label: text(tier.label, "\u4EF7\u683C\u6863\u4F4D", 128),
20097
+ currency: tier.currency === null ? null : member(tier.currency, ["USD"], "\u4EF7\u683C\u5E01\u79CD"),
20098
+ unit: tier.unit === null ? null : member(tier.unit, ["per_1m_tokens", "per_1k_tokens"], "\u4EF7\u683C\u5355\u4F4D"),
20099
+ input: nullableAmount(tier.input),
20100
+ output: nullableAmount(tier.output),
20101
+ cacheRead: nullableAmount(tier.cacheRead),
20102
+ cacheWrite: nullableAmount(tier.cacheWrite)
20103
+ };
20104
+ });
20105
+ return { id, tiers };
20106
+ });
20107
+ return { state, stale, ...fetchedAt === void 0 ? {} : { fetchedAt }, models };
20108
+ }
20071
20109
  function parseQuotaWindow(value) {
20072
20110
  if (!record2(value)) throw new Error("\u989D\u5EA6\u7A97\u53E3\u5FC5\u987B\u662F\u5BF9\u8C61");
20073
20111
  const durationSeconds = amount(value.durationSeconds, "\u989D\u5EA6\u7A97\u53E3\u65F6\u957F");
@@ -20215,6 +20253,7 @@ function parseActivationOpenState(value) {
20215
20253
 
20216
20254
  // src/generated/typert.remote-client.ts
20217
20255
  var StatusCodec = { mode: "strict", typeSymbol: "dsh-opendesign-corouter#Status", create: () => external_exports.unknown().transform((value) => parseStatus(value)) };
20256
+ var PriceCatalogCodec = { mode: "strict", typeSymbol: "dsh-opendesign-corouter#PriceCatalog", create: () => external_exports.unknown().transform((value) => parsePriceCatalog(value)) };
20218
20257
  var QuotaSnapshotCodec = { mode: "strict", typeSymbol: "dsh-opendesign-corouter#QuotaSnapshot", create: () => external_exports.unknown().transform((value) => parseQuotaSnapshot(value)) };
20219
20258
  var LoginStateCodec = { mode: "strict", typeSymbol: "dsh-opendesign-corouter#LoginState", create: () => external_exports.unknown().transform((value) => parseLoginState(value)) };
20220
20259
  var StartLoginRequestCodec = { mode: "strict", typeSymbol: "dsh-opendesign-corouter#StartLoginRequest", create: () => external_exports.unknown().transform((value) => parseStartLoginRequest(value)) };
@@ -20224,6 +20263,7 @@ var SaveApiKeyRequestCodec = { mode: "strict", typeSymbol: "dsh-opendesign-corou
20224
20263
  var TYPERT_REMOTE = createTypertRemoteInfo({ package: "dsh-opendesign-corouter", methods: {
20225
20264
  "openDesignCoRouter/status": { service: "openDesignCoRouter", invocation: { kind: "direct" }, parameters: [], result: StatusCodec },
20226
20265
  "openDesignCoRouter/refreshModels": { service: "openDesignCoRouter", invocation: { kind: "direct" }, parameters: [], result: StatusCodec },
20266
+ "openDesignCoRouter/refreshPrices": { service: "openDesignCoRouter", invocation: { kind: "direct" }, parameters: [], result: PriceCatalogCodec },
20227
20267
  "openDesignCoRouter/refreshQuota": { service: "openDesignCoRouter", invocation: { kind: "direct" }, parameters: [], result: QuotaSnapshotCodec },
20228
20268
  "openDesignCoRouter/refreshQuotaNow": { service: "openDesignCoRouter", invocation: { kind: "direct" }, parameters: [], result: QuotaSnapshotCodec },
20229
20269
  "openDesignCoRouter/startLogin": { service: "openDesignCoRouter", invocation: { kind: "direct" }, parameters: [{ name: "input", source: "json", codec: StartLoginRequestCodec, strictCodec: StartLoginRequestCodec }], result: LoginStateCodec },
@@ -20305,14 +20345,26 @@ function installStyles() {
20305
20345
  .odc-model-details{margin-top:8px}.odc-model-details>summary{cursor:pointer;color:var(--dsw-alias-label-secondary,inherit);font-size:11px;line-height:1.7}.odc-model-editor{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:2px 10px;margin-top:8px}
20306
20346
  .odc-field{display:grid;gap:6px;margin-top:14px}.odc-field-compact{margin-top:8px}.odc-field label,.odc-switch-text{font-size:12px;font-weight:550}.odc-input{width:100%;min-width:0;min-height:34px;padding:7px 9px;border:1px solid var(--dsw-alias-border-l3,transparent);border-radius:8px;background:var(--dsw-alias-bg-layer-2,transparent);color:var(--dsw-alias-label-primary,inherit);font:inherit;font-size:12px}.odc-field-compact .odc-input{min-height:30px;padding:5px 8px;font-size:11px}.odc-input::placeholder{color:var(--dsw-alias-label-secondary,inherit);opacity:1}.odc-input:disabled{opacity:.55}
20307
20347
  .odc-input option{background:var(--dsw-alias-bg-layer-2,Canvas);color:var(--dsw-alias-label-primary,CanvasText)}
20308
- .odc-input,.odc-button:not(.odc-button-primary),.odc-tab[aria-selected=true]{border-color:var(--dsw-alias-border-l3,CanvasText);border-color:color-mix(in srgb,var(--dsw-alias-label-primary,CanvasText) 45%,var(--dsw-alias-bg-layer-2,Canvas))}
20348
+ .odc-input,.odc-button:not(.odc-button-primary),.odc-tab[aria-selected=true]{border-color:var(--dsw-alias-border-l3,CanvasText);border-color:color-mix(in srgb,var(--dsw-alias-label-primary,CanvasText) 55%,var(--dsw-alias-bg-layer-2,Canvas))}
20309
20349
  .odc-switch{display:flex;align-items:center;gap:12px;min-height:44px;padding:6px 2px;cursor:pointer}.odc-switch input{appearance:auto;width:20px;height:20px;flex:none;margin:0;cursor:inherit;accent-color:var(--dsw-alias-brand-primary,Highlight)}.odc-switch>span{display:grid;gap:4px;min-width:0}.odc-switch:has(input:disabled){cursor:not-allowed;opacity:.6}.odc-divider{height:1px;border:0;background:var(--dsw-alias-border-l4,transparent);margin:2px 0}.odc-link{color:var(--dsw-alias-brand-primary,inherit);text-underline-offset:3px}
20310
20350
  .odc-readonly{display:grid;gap:10px;margin-top:14px;padding:10px 12px;border-radius:8px;background:var(--dsw-alias-bg-layer-2,transparent)}.odc-code{display:block;min-width:0;color:var(--dsw-alias-label-primary,inherit);font-family:ui-monospace,'Cascadia Mono',Consolas,monospace;font-size:11px;line-height:1.6;overflow-wrap:anywhere}
20311
20351
  .odc-timing{padding:12px 0;border-top:1px solid var(--dsw-alias-border-l4,transparent)}.odc-timing .odc-metric{min-height:0}.odc-settings>.odc-notice{margin-bottom:14px}.odc-model-details>summary{min-height:32px;padding:6px 0}
20312
20352
  .odc-field-error{color:var(--dsw-alias-state-error-primary,inherit);color:color-mix(in srgb,var(--dsw-alias-state-error-primary,CanvasText) 85%,var(--dsw-alias-label-primary,CanvasText))}
20313
20353
  .odc-model-groups{align-items:start}.odc-label,.odc-hint,.odc-meta,.odc-window dt,.odc-quota-footer dt,.odc-quota-footer dd,.odc-window-details>summary,.odc-model-details>summary,.odc-model-item code,.odc-model-meta,.odc-model-count,.odc-code{font-size:12px}.odc-field-compact .odc-input,.odc-button-small{font-size:12px}.odc-button-small{min-height:32px}.odc-chip{font-size:11px}
20354
+ .odc-settings{--odc-accent:var(--dsw-alias-brand-primary-new-colorprimary-new-color,#4176e6);max-width:720px;padding:16px;line-height:1.6}
20355
+ .odc-settings h2{font-size:16px;letter-spacing:0}.odc-intro{margin:4px 0 12px!important}.odc-tabs{flex-wrap:wrap;overflow:visible;gap:4px;padding:0;border:0;margin-bottom:14px}
20356
+ .odc-tab{border:1px solid transparent;border-radius:999px;padding:6px 12px;font-size:12px}.odc-tab[aria-selected=true]{border-color:transparent;background:color-mix(in srgb,var(--odc-accent) 16%,transparent);font-weight:600}
20357
+ .odc-card{border-radius:10px;background:transparent;padding:14px}.odc-panel{gap:12px}.odc-card-head{margin-bottom:10px}.odc-button-primary{background:color-mix(in srgb,var(--odc-accent) 12%,transparent);border-color:color-mix(in srgb,var(--odc-accent) 65%,transparent);color:var(--dsw-alias-label-primary,CanvasText)}.odc-button-primary:hover:not(:disabled){background:color-mix(in srgb,var(--odc-accent) 18%,transparent)}
20358
+ .odc-quota-panel{display:grid;gap:8px;min-width:0}.odc-quota-panel>.odc-card-head{margin:0}.odc-quota-status{--odc-state:var(--odc-accent);display:flex;align-items:center;gap:10px;padding:10px 12px;border:1px solid color-mix(in srgb,var(--odc-state) 28%,transparent);border-radius:10px;background:color-mix(in srgb,var(--odc-state) 10%,transparent);font-size:13px;font-weight:600}.odc-quota-status[data-tone=good]{--odc-state:var(--dsw-alias-state-success-primary,Highlight)}.odc-quota-status[data-tone=warn]{--odc-state:var(--dsw-alias-state-warn-primary,Highlight)}.odc-quota-status[data-tone=critical]{--odc-state:var(--dsw-alias-state-error-primary,Highlight)}.odc-state-mark{display:grid;place-items:center;width:28px;height:28px;border:1px solid color-mix(in srgb,var(--odc-state) 65%,transparent);border-radius:8px;flex:none;font-size:15px;font-weight:700}.odc-state-copy{display:grid;gap:1px;min-width:0}.odc-state-copy .odc-hint{font-weight:400}
20359
+ .odc-window{--odc-window-color:var(--dsw-alias-label-secondary,CanvasText);gap:5px;margin:0;padding:10px 12px;border:0;border-radius:8px;background:color-mix(in srgb,var(--dsw-alias-label-primary,CanvasText) 5%,transparent)}.odc-window[data-tone=good]{--odc-window-color:color-mix(in srgb,var(--dsw-alias-state-success-primary,Highlight) 70%,var(--dsw-alias-label-primary,CanvasText))}.odc-window[data-tone=warn]{--odc-window-color:color-mix(in srgb,var(--dsw-alias-state-warn-primary,Highlight) 70%,var(--dsw-alias-label-primary,CanvasText))}.odc-window[data-tone=critical]{--odc-window-color:var(--dsw-alias-state-error-primary,Highlight)}.odc-window-remaining strong{font-size:18px}.odc-window progress{appearance:none;height:7px;border:0;border-radius:999px;overflow:hidden;background:color-mix(in srgb,var(--dsw-alias-label-primary,CanvasText) 18%,transparent);accent-color:var(--odc-window-color)}.odc-window progress::-webkit-progress-bar{background:color-mix(in srgb,var(--dsw-alias-label-primary,CanvasText) 18%,transparent);border-radius:999px}.odc-window progress::-webkit-progress-value{background:var(--odc-window-color);border-radius:999px}
20360
+ .odc-window-usage{display:block;margin:0;color:var(--dsw-alias-label-secondary,inherit);font-size:12px;overflow-wrap:anywhere}.odc-window-bottom{display:flex;align-items:baseline;justify-content:space-between;gap:4px 12px;flex-wrap:wrap}.odc-window-reset{display:flex;align-items:baseline;justify-content:flex-start;flex-wrap:wrap;gap:4px 6px;padding:0;border:0}.odc-window-details>summary{min-height:28px;padding:4px 0}.odc-window-details[open]{flex-basis:100%}.odc-window-details dl>div{display:flex;justify-content:space-between;gap:12px}
20361
+ @media(forced-colors:active){.odc-window progress{appearance:auto;accent-color:Highlight;forced-color-adjust:auto}.odc-window progress::-webkit-progress-value{background:Highlight}}
20362
+ .odc-balance-list,.odc-timing{display:grid;gap:0;margin:0}.odc-balance-row,.odc-timing-row{display:flex;justify-content:space-between;align-items:baseline;gap:12px;min-width:0;min-height:0;padding:6px 0;border-top:1px solid var(--dsw-alias-border-l4,transparent)}.odc-balance-row:first-child,.odc-timing-row:first-child{border-top:0}.odc-balance-row>div,.odc-timing-row>div{min-width:0}.odc-balance-row dt,.odc-timing-row dt{font-size:12px;font-weight:600}.odc-balance-row dd,.odc-timing-row dd{margin:0;min-width:0;text-align:right}.odc-balance-row .odc-metric-value{font-size:13px}.odc-timing-row .odc-metric-text{font-size:13px;white-space:nowrap}.odc-timing-row .odc-hint{display:block}.odc-timing{padding:4px 14px}
20363
+ .odc-model-item{background:transparent;border:1px solid var(--dsw-alias-border-l4,transparent)}.odc-model-item:has(details[open]){border-color:color-mix(in srgb,var(--odc-accent) 55%,transparent);background:color-mix(in srgb,var(--odc-accent) 5%,transparent)}
20364
+ .odc-price-summary{margin:5px 0 0!important;font-size:12px;color:var(--dsw-alias-label-secondary,inherit);overflow-wrap:anywhere}.odc-pricing-head{display:flex;justify-content:space-between;align-items:center;gap:10px;flex-wrap:wrap}.odc-price-tier{padding:8px 0;border-top:1px solid var(--dsw-alias-border-l4,transparent)}.odc-price-tier dl{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:6px 12px;margin:6px 0 0}.odc-price-tier dl>div{display:flex;justify-content:space-between;gap:8px}.odc-price-tier dt{color:var(--dsw-alias-label-secondary,inherit)}.odc-price-tier dd{margin:0;font-variant-numeric:tabular-nums}
20314
20365
  .odc-settings :focus-visible{outline:2px solid var(--dsw-alias-brand-primary,Highlight);outline-offset:3px}@media(max-width:680px){.odc-quota-grid{grid-template-columns:repeat(2,minmax(0,1fr))}.odc-model-groups{grid-template-columns:1fr}.odc-model-editor{grid-template-columns:1fr}}@media(max-width:380px){.odc-quota-grid{grid-template-columns:1fr}.odc-card{padding:12px}}
20315
20366
  @container(max-width:680px){.odc-quota-grid{grid-template-columns:repeat(2,minmax(0,1fr))}.odc-model-groups,.odc-model-editor{grid-template-columns:1fr}}@container(max-width:380px){.odc-quota-grid{grid-template-columns:1fr}.odc-card{padding:12px}}
20367
+ @container(max-width:480px){.odc-timing-row{align-items:flex-start}.odc-timing-row>div{flex:1 1 0}.odc-timing-row dd{flex:0 0 auto;max-width:50%;overflow-wrap:anywhere}.odc-timing-row .odc-metric-text{white-space:normal}}
20316
20368
  `;
20317
20369
  document.head.append(style);
20318
20370
  return () => style.remove();
@@ -20410,6 +20462,37 @@ function formatTime(value) {
20410
20462
  const date5 = new Date(value);
20411
20463
  return Number.isFinite(date5.getTime()) ? date5.toLocaleString("zh-CN", { hour12: false }) : "\u2014";
20412
20464
  }
20465
+ function formatRelativeDeadline(value, now, dueText) {
20466
+ const at = value === void 0 ? Number.NaN : Date.parse(value);
20467
+ if (!Number.isFinite(at) || !Number.isFinite(now)) return "\u2014";
20468
+ const seconds = Math.ceil((at - now) / 1e3);
20469
+ if (seconds <= 0) return dueText;
20470
+ if (seconds >= 86400) return `${Math.floor(seconds / 86400)}\u5929${Math.floor(seconds % 86400 / 3600)}\u5C0F\u65F6\u540E`;
20471
+ if (seconds >= 3600) return `${Math.floor(seconds / 3600)}\u5C0F\u65F6${Math.floor(seconds % 3600 / 60)}\u5206\u949F\u540E`;
20472
+ if (seconds >= 60) return `${Math.floor(seconds / 60)}\u5206${seconds % 60}\u79D2\u540E`;
20473
+ return `${seconds}\u79D2\u540E`;
20474
+ }
20475
+ function formatRefreshCountdown(value, now) {
20476
+ return formatRelativeDeadline(value, now, "\u5373\u5C06\u5237\u65B0");
20477
+ }
20478
+ function RelativeDeadline({ at, busy = false, dueText, titleLabel, futureSuffix = "" }) {
20479
+ const [now, setNow] = React.useState(() => Date.now());
20480
+ React.useEffect(() => {
20481
+ if (at === void 0 || !Number.isFinite(Date.parse(at))) return;
20482
+ const update = () => setNow(Date.now());
20483
+ update();
20484
+ const timer = setInterval(update, 1e3);
20485
+ document.addEventListener("visibilitychange", update);
20486
+ return () => {
20487
+ clearInterval(timer);
20488
+ document.removeEventListener("visibilitychange", update);
20489
+ };
20490
+ }, [at]);
20491
+ if (busy) return h("span", null, "\u5237\u65B0\u4E2D\u2026");
20492
+ if (at === void 0 || !Number.isFinite(Date.parse(at))) return h("span", null, "\u2014");
20493
+ const relative = formatRelativeDeadline(at, now, dueText) + (Date.parse(at) > now ? futureSuffix : "");
20494
+ return h("time", { dateTime: at, title: `${titleLabel}\uFF1A${formatTime(at)}`, "aria-label": `${relative}\uFF0C${titleLabel}\uFF1A${formatTime(at)}` }, relative);
20495
+ }
20413
20496
  function formatTokens(value) {
20414
20497
  if (value === void 0 || !Number.isFinite(value)) return "\u2014";
20415
20498
  return new Intl.NumberFormat("zh-CN").format(value);
@@ -20420,6 +20503,34 @@ function windowLabel(seconds) {
20420
20503
  if (seconds % 60 === 0) return `${seconds / 60} \u5206\u949F\u8D60\u9001\u7A97\u53E3`;
20421
20504
  return `${seconds} \u79D2\u8D60\u9001\u7A97\u53E3`;
20422
20505
  }
20506
+ function formatWindowCredits(value) {
20507
+ if (value >= 1e9) return `${(value / 1e9).toFixed(2)}B`;
20508
+ if (value >= 1e6) return `${(value / 1e6).toFixed(2)}M`;
20509
+ if (value >= 1e3) return `${(value / 1e3).toFixed(1)}K`;
20510
+ return String(value);
20511
+ }
20512
+ function windowTone(window) {
20513
+ return window.percent >= 100 ? "critical" : window.percent >= 71 ? "warn" : "good";
20514
+ }
20515
+ function windowDue(window, now) {
20516
+ if (window.resetsAt === void 0) return false;
20517
+ const at = Date.parse(window.resetsAt);
20518
+ return Number.isFinite(at) && at <= now;
20519
+ }
20520
+ function quotaStatusView(quota, now) {
20521
+ if (quota.state === "error") return { title: QUOTA_LABELS.error, tone: "critical", icon: "!" };
20522
+ if (quota.state === "need-login") return { title: QUOTA_LABELS["need-login"], tone: "neutral", icon: "i" };
20523
+ if (quota.stale) return { title: "\u663E\u793A\u4E0A\u6B21\u6210\u529F\u8BFB\u6570", tone: "warn", icon: "?" };
20524
+ if (quota.state === "partial") return { title: QUOTA_LABELS.partial, tone: "warn", icon: "?" };
20525
+ if (quota.eligible === false) return { title: "\u672A\u5F00\u901A Design Plan", tone: "neutral", icon: "i" };
20526
+ const windows = quota.windows.filter((window2) => Number.isFinite(window2.percent));
20527
+ if (!windows.length) return { title: "\u6682\u65E0\u8D60\u9001\u7A97\u53E3\u6570\u636E", tone: "neutral", icon: "i" };
20528
+ if (windows.some((window2) => windowDue(window2, now))) return { title: "\u7B49\u5F85\u66F4\u65B0\u7A97\u53E3\u989D\u5EA6", tone: "neutral", icon: "\u2026" };
20529
+ const window = windows.reduce((worst, next) => next.percent > worst.percent ? next : worst);
20530
+ const tone = windowTone(window);
20531
+ const title = tone === "critical" ? "\u8D60\u9001\u7A97\u53E3\u989D\u5EA6\u5DF2\u7528\u5C3D" : window.percent >= 91 ? "\u8D60\u9001\u7A97\u53E3\u989D\u5EA6\u5373\u5C06\u7528\u5C3D" : tone === "warn" ? "\u8D60\u9001\u7A97\u53E3\u989D\u5EA6\u504F\u5C11" : "\u8D60\u9001\u7A97\u53E3\u989D\u5EA6\u5145\u8DB3";
20532
+ return { title, tone, icon: tone === "good" ? "\u2713" : tone === "warn" ? "!" : "\xD7", window };
20533
+ }
20423
20534
  function nextWindowResetAt(windows, now) {
20424
20535
  let earliest;
20425
20536
  let earliestMs = Number.POSITIVE_INFINITY;
@@ -20441,7 +20552,21 @@ var RESET_MODE_LABELS = {
20441
20552
  activity_triggered: "\u6309\u4F7F\u7528\u89E6\u53D1",
20442
20553
  anchored_recurring: "\u56FA\u5B9A\u5468\u671F"
20443
20554
  };
20444
- function QuotaView({ quota, nextAutoRefreshAt, refreshIntervalSeconds }) {
20555
+ function QuotaView({ quota, nextAutoRefreshAt, refreshIntervalSeconds, busy = false }) {
20556
+ const [now, setNow] = React.useState(() => Date.now());
20557
+ React.useEffect(() => {
20558
+ setNow(Date.now());
20559
+ }, [quota?.windows]);
20560
+ React.useEffect(() => {
20561
+ const future = (quota?.windows ?? []).map((window) => Date.parse(window.resetsAt ?? "")).filter((at) => Number.isFinite(at) && at > now);
20562
+ const update = () => setNow(Date.now());
20563
+ const timer = future.length ? setTimeout(update, Math.min(2147483647, Math.max(1, Math.min(...future) - now + 10))) : void 0;
20564
+ document.addEventListener("visibilitychange", update);
20565
+ return () => {
20566
+ if (timer !== void 0) clearTimeout(timer);
20567
+ document.removeEventListener("visibilitychange", update);
20568
+ };
20569
+ }, [quota?.windows, now]);
20445
20570
  if (quota === void 0) return h("p", { className: "odc-hint", role: "status" }, "\u6B63\u5728\u8BFB\u53D6\u989D\u5EA6\u2026");
20446
20571
  const metrics = [
20447
20572
  { label: "\u5957\u9910\u4F59\u989D", value: formatUsd(quota.balances.subscriptionUsd), hint: "\u8BA2\u9605\u5269\u4F59\u53EF\u7528\u91D1\u989D" },
@@ -20451,17 +20576,17 @@ function QuotaView({ quota, nextAutoRefreshAt, refreshIntervalSeconds }) {
20451
20576
  const timing = [
20452
20577
  {
20453
20578
  label: "\u8BA2\u9605\u8D26\u671F\u7ED3\u675F",
20454
- value: formatTime(quota.subscriptionPeriodEnd),
20579
+ value: h(RelativeDeadline, { at: quota.subscriptionPeriodEnd, dueText: "\u5DF2\u5230\u7ED3\u675F\u65F6\u95F4", titleLabel: "\u8D26\u671F\u7ED3\u675F\u65F6\u95F4" }),
20455
20580
  hint: `\u8D26\u671F\u5F00\u59CB\uFF1A${formatTime(quota.subscriptionPeriodStart)}`
20456
20581
  },
20457
20582
  {
20458
20583
  label: "\u4E0B\u6B21\u989D\u5EA6\u6062\u590D",
20459
- value: formatTime(nextWindowResetAt(quota.windows, Date.now())),
20584
+ value: h(RelativeDeadline, { at: nextWindowResetAt(quota.windows, Date.now()), dueText: "\u7B49\u5F85\u66F4\u65B0", titleLabel: "\u989D\u5EA6\u6062\u590D\u65F6\u95F4" }),
20460
20585
  hint: "\u6700\u65E9\u6062\u590D\u7684\u8D60\u9001\u7A97\u53E3\uFF1B\u4E0D\u4EE3\u8868\u94B1\u5305\u5230\u8D26\u65F6\u95F4"
20461
20586
  },
20462
20587
  {
20463
20588
  label: "\u4E0B\u6B21\u81EA\u52A8\u5237\u65B0",
20464
- value: formatTime(quota.state === "need-login" || quota.autoRefreshPaused ? void 0 : nextAutoRefreshAt),
20589
+ value: h(RelativeDeadline, { at: quota.state === "need-login" || quota.autoRefreshPaused ? void 0 : nextAutoRefreshAt, busy: busy && quota.state !== "need-login" && !quota.autoRefreshPaused, dueText: "\u5373\u5C06\u5237\u65B0", titleLabel: "\u8BA1\u5212\u5237\u65B0\u65F6\u95F4" }),
20465
20590
  hint: quota.state === "need-login" ? "\u767B\u5F55\u540E\u81EA\u52A8\u5237\u65B0" : quota.autoRefreshPaused ? "\u8FDE\u7EED\u5931\u8D25\uFF0C\u81EA\u52A8\u91CD\u8BD5\u5DF2\u6682\u505C\uFF1B\u70B9\u51FB\u5237\u65B0\u989D\u5EA6\u91CD\u8BD5" : refreshIntervalSeconds === void 0 ? "\u672A\u542F\u7528\u81EA\u52A8\u5237\u65B0" : quota.refreshFailures ? `\u5237\u65B0\u5931\u8D25 ${quota.refreshFailures} \u6B21\uFF0C\u6B63\u5728\u5EF6\u8FDF\u91CD\u8BD5` : `\u6BCF ${refreshIntervalSeconds} \u79D2\u81EA\u52A8\u5237\u65B0`
20466
20591
  }
20467
20592
  ];
@@ -20469,12 +20594,13 @@ function QuotaView({ quota, nextAutoRefreshAt, refreshIntervalSeconds }) {
20469
20594
  quota.tier === void 0 ? void 0 : `\u5F53\u524D\u5957\u9910\uFF1A${quota.tier}`,
20470
20595
  quota.eligible === void 0 ? void 0 : `\u5957\u9910\u8D44\u683C\uFF1A${quota.eligible ? "\u5DF2\u5F00\u901A" : "\u672A\u5F00\u901A"}`
20471
20596
  ].filter((value) => value !== void 0).join(" \xB7 ");
20597
+ const quotaStatus = quotaStatusView(quota, now);
20472
20598
  return h(
20473
20599
  React.Fragment,
20474
20600
  null,
20475
20601
  h(
20476
20602
  "div",
20477
- { className: "odc-card" },
20603
+ { className: "odc-quota-panel" },
20478
20604
  h(
20479
20605
  "div",
20480
20606
  { className: "odc-card-head" },
@@ -20484,11 +20610,22 @@ function QuotaView({ quota, nextAutoRefreshAt, refreshIntervalSeconds }) {
20484
20610
  h("h3", null, "\u5957\u9910\u8D60\u9001\u7A97\u53E3"),
20485
20611
  tierLine === "" ? null : h("p", { className: "odc-hint" }, tierLine)
20486
20612
  ),
20613
+ quota.stale ? h("span", { className: "odc-chip" }, "\u4E0A\u6B21\u6210\u529F\u8BFB\u6570") : null
20614
+ ),
20615
+ h(
20616
+ "div",
20617
+ { className: "odc-quota-status", "data-state": quota.state, "data-tone": quotaStatus.tone },
20618
+ h("span", { className: "odc-state-mark", "aria-hidden": true }, quotaStatus.icon),
20487
20619
  h(
20488
20620
  "div",
20489
- { className: "odc-actions" },
20490
- h("span", { className: "odc-label" }, QUOTA_LABELS[quota.state]),
20491
- quota.stale ? h("span", { className: "odc-chip" }, "\u4E0A\u6B21\u6210\u529F\u8BFB\u6570") : null
20621
+ { className: "odc-state-copy" },
20622
+ h("strong", null, quotaStatus.title),
20623
+ quotaStatus.window === void 0 ? null : h(
20624
+ "span",
20625
+ { className: "odc-hint" },
20626
+ `${windowLabel(quotaStatus.window.durationSeconds).replace("\u8D60\u9001\u7A97\u53E3", "")} \xB7 \u5269\u4F59 ${Math.max(0, Math.min(100, 100 - quotaStatus.window.percent)).toFixed(1)}%`,
20627
+ quotaStatus.window.resetsAt === void 0 ? null : h(React.Fragment, null, " \xB7 ", h(RelativeDeadline, { at: quotaStatus.window.resetsAt, dueText: "\u7B49\u5F85\u66F4\u65B0", titleLabel: "\u9884\u8BA1\u6062\u590D\u65F6\u95F4", futureSuffix: "\u6062\u590D" }))
20628
+ )
20492
20629
  )
20493
20630
  ),
20494
20631
  quota.windows.length === 0 ? quota.eligible === false ? h("p", { className: "odc-hint", role: "status" }, "\u5F53\u524D\u8D26\u53F7\u672A\u5F00\u901A Design Plan\uFF0C\u6CA1\u6709\u8D60\u9001\u989D\u5EA6\u7A97\u53E3\u3002") : h(
@@ -20499,9 +20636,10 @@ function QuotaView({ quota, nextAutoRefreshAt, refreshIntervalSeconds }) {
20499
20636
  ) : quota.windows.map((window, index) => {
20500
20637
  const label = windowLabel(window.durationSeconds);
20501
20638
  const remainingPercent = Math.max(0, Math.min(100, 100 - window.percent));
20639
+ const tone = quota.state === "ok" && !quota.stale && !windowDue(window, now) ? windowTone(window) : "neutral";
20502
20640
  return h(
20503
20641
  "section",
20504
- { className: "odc-window", key: `${window.durationSeconds}-${index}`, "aria-label": label },
20642
+ { className: "odc-window", key: `${window.durationSeconds}-${index}`, "aria-label": label, "data-tone": tone },
20505
20643
  h(
20506
20644
  "div",
20507
20645
  { className: "odc-window-head" },
@@ -20510,48 +20648,52 @@ function QuotaView({ quota, nextAutoRefreshAt, refreshIntervalSeconds }) {
20510
20648
  "div",
20511
20649
  { className: "odc-window-remaining" },
20512
20650
  h("strong", null, `${remainingPercent.toFixed(1)}%`),
20513
- h("span", { className: "odc-label" }, "\u5269\u4F59")
20651
+ h("span", { className: "odc-label" }, "\u5269\u4F59\u6BD4\u4F8B")
20514
20652
  )
20515
20653
  ),
20516
20654
  h("progress", { max: 100, value: remainingPercent, "aria-label": `${label}\u5269\u4F59\u989D\u5EA6` }),
20517
- h(
20518
- "dl",
20519
- { className: "odc-window-usage", "aria-label": "\u7A97\u53E3\u7528\u91CF\u660E\u7EC6" },
20520
- [{ label: "\u5DF2\u7528", value: window.used }, { label: "\u4E0A\u9650", value: window.limit }, { label: "\u5269\u4F59", value: window.remaining ?? "\u2014" }].map((item) => h("div", { key: item.label }, h("dt", null, item.label), h("dd", null, item.value)))
20521
- ),
20655
+ h("p", { className: "odc-window-usage", title: `\u5DF2\u7528 ${window.used} / \u603B\u8BA1 ${window.limit} \u79EF\u5206`, "aria-label": `\u7A97\u53E3\u79EF\u5206\uFF1A\u5DF2\u7528 ${window.used}\uFF0C\u603B\u8BA1 ${window.limit}` }, `\u5DF2\u7528 ${formatWindowCredits(window.used)} / \u603B\u8BA1 ${formatWindowCredits(window.limit)} \u79EF\u5206`),
20522
20656
  h(
20523
20657
  "div",
20524
- { className: "odc-window-reset" },
20525
- h("span", { className: "odc-label" }, "\u4E0B\u6B21\u6062\u590D"),
20526
- window.resetsAt === void 0 ? h("span", null, "\u2014") : h("time", { dateTime: window.resetsAt }, formatTime(window.resetsAt))
20527
- ),
20528
- window.windowStart === void 0 && window.resetMode === void 0 ? null : h(
20529
- "details",
20530
- { className: "odc-window-details" },
20531
- h("summary", null, "\u7A97\u53E3\u8BE6\u60C5"),
20658
+ { className: "odc-window-bottom" },
20532
20659
  h(
20533
- "dl",
20534
- null,
20535
- window.windowStart === void 0 ? null : h("div", null, h("dt", null, "\u7A97\u53E3\u5F00\u59CB"), h("dd", null, h("time", { dateTime: window.windowStart }, formatTime(window.windowStart)))),
20536
- window.resetMode === void 0 ? null : h("div", null, h("dt", null, "\u91CD\u7F6E\u65B9\u5F0F"), h("dd", null, RESET_MODE_LABELS[window.resetMode] ?? window.resetMode))
20660
+ "div",
20661
+ { className: "odc-window-reset" },
20662
+ h("span", { className: "odc-label" }, "\u4E0B\u6B21\u6062\u590D"),
20663
+ h(RelativeDeadline, { at: window.resetsAt, dueText: "\u5DF2\u5230\u6062\u590D\u65F6\u95F4\uFF0C\u7B49\u5F85\u66F4\u65B0", titleLabel: "\u9884\u8BA1\u6062\u590D\u65F6\u95F4" })
20664
+ ),
20665
+ h(
20666
+ "details",
20667
+ { className: "odc-window-details" },
20668
+ h("summary", null, "\u7A97\u53E3\u8BE6\u60C5"),
20669
+ h(
20670
+ "dl",
20671
+ null,
20672
+ h("div", null, h("dt", null, "\u63A5\u53E3\u5269\u4F59\u79EF\u5206"), h("dd", null, window.remaining === void 0 ? "\u2014" : window.remaining)),
20673
+ window.windowStart === void 0 ? null : h("div", null, h("dt", null, "\u7A97\u53E3\u5F00\u59CB"), h("dd", null, h("time", { dateTime: window.windowStart }, formatTime(window.windowStart)))),
20674
+ window.resetMode === void 0 ? null : h("div", null, h("dt", null, "\u91CD\u7F6E\u65B9\u5F0F"), h("dd", null, RESET_MODE_LABELS[window.resetMode] ?? window.resetMode))
20675
+ )
20537
20676
  )
20538
20677
  )
20539
20678
  );
20540
20679
  })
20541
20680
  ),
20542
- h("div", { className: "odc-quota-grid" }, metrics.map((metric) => h(
20543
- "div",
20544
- { className: "odc-card odc-metric", key: metric.label },
20545
- h("span", { className: "odc-label" }, metric.label),
20546
- h("strong", { className: "odc-metric-value" }, metric.value),
20547
- h("span", { className: "odc-hint" }, metric.hint)
20548
- ))),
20549
- h("div", { className: "odc-quota-grid odc-timing", "aria-label": "\u989D\u5EA6\u65F6\u95F4\u5B89\u6392" }, timing.map((metric) => h(
20681
+ h(
20682
+ "section",
20683
+ { className: "odc-card", "aria-label": "\u94B1\u5305\u4F59\u989D" },
20684
+ h("h3", null, "\u94B1\u5305\u4F59\u989D"),
20685
+ h("dl", { className: "odc-balance-list" }, metrics.map((metric) => h(
20686
+ "div",
20687
+ { className: "odc-balance-row odc-metric", key: metric.label },
20688
+ h("div", null, h("dt", { title: metric.hint }, metric.label)),
20689
+ h("dd", null, h("strong", { className: "odc-metric-value" }, metric.value))
20690
+ )))
20691
+ ),
20692
+ h("dl", { className: "odc-card odc-timing", "aria-label": "\u989D\u5EA6\u65F6\u95F4\u5B89\u6392" }, timing.map((metric) => h(
20550
20693
  "div",
20551
- { className: "odc-metric", key: metric.label },
20552
- h("span", { className: "odc-label" }, metric.label),
20553
- h("strong", { className: "odc-metric-value odc-metric-text" }, metric.value),
20554
- h("span", { className: "odc-hint" }, metric.hint)
20694
+ { className: "odc-timing-row odc-metric", key: metric.label },
20695
+ h("div", null, h("dt", null, metric.label), h("span", { className: "odc-hint" }, metric.hint)),
20696
+ h("dd", null, h("strong", { className: "odc-metric-value odc-metric-text" }, metric.value))
20555
20697
  ))),
20556
20698
  h(
20557
20699
  "dl",
@@ -20647,7 +20789,7 @@ function Overview({ status, busy, onRefresh, nextAutoRefreshAt, refreshIntervalS
20647
20789
  h("div", null, h("h3", null, "\u989D\u5EA6\u6982\u89C8"), h("p", { className: "odc-hint" }, "\u67E5\u770B\u5957\u9910\u7528\u91CF\u3001\u8BA2\u9605\u4F59\u989D\u548C\u5145\u503C\u4F59\u989D\u3002")),
20648
20790
  h("button", { className: "odc-button", type: "button", disabled: busy, onClick: onRefresh }, busy ? "\u5237\u65B0\u4E2D\u2026" : "\u5237\u65B0\u989D\u5EA6")
20649
20791
  ),
20650
- h(QuotaView, { quota: status?.quota, nextAutoRefreshAt, refreshIntervalSeconds })
20792
+ h(QuotaView, { quota: status?.quota, nextAutoRefreshAt, refreshIntervalSeconds, busy })
20651
20793
  );
20652
20794
  }
20653
20795
  var NUMERIC_FIELDS = {
@@ -20755,7 +20897,23 @@ function EffortField({ id, model, value, disabled, onChange }) {
20755
20897
  }, error62 ?? (invalidDefault ? "\u5DF2\u4FDD\u5B58\u7684\u6863\u4F4D\u4E0D\u9002\u7528\u4E8E\u5F53\u524D\u6A21\u578B\u6216\u534F\u8BAE\uFF0C\u8BF7\u9009\u62E9\u5176\u4ED6\u6863\u4F4D\u6216\u7EE7\u627F\u9ED8\u8BA4\u3002" : unavailable ? "\u5F53\u524D\u6A21\u578B\u6216\u534F\u8BAE\u672A\u63D0\u4F9B\u53EF\u8C03\u6574\u7684\u601D\u8003\u6863\u4F4D\u3002" : "\u7559\u7A7A\u4F7F\u7528\u670D\u52A1\u7AEF\u9ED8\u8BA4\u6863\u4F4D\u3002"))
20756
20898
  );
20757
20899
  }
20758
- function ModelRow({ model, settings, authoritative, writable, pending, onCommit }) {
20900
+ var PRICE_SITE = "https://corouter.open-design.ai/zh/models/";
20901
+ function priceUnit(tier) {
20902
+ return tier.unit === "per_1m_tokens" ? "\u6BCF\u767E\u4E07 Token" : tier.unit === "per_1k_tokens" ? "\u6BCF\u5343 Token" : "\u8BA1\u4EF7\u5355\u4F4D\u672A\u6807\u660E";
20903
+ }
20904
+ function priceAmount(amount2, currency) {
20905
+ if (amount2 === null) return "\u672A\u5217\u51FA";
20906
+ return currency === "USD" ? `$${amount2}` : `${amount2}\uFF08\u5E01\u79CD\u672A\u6807\u660E\uFF09`;
20907
+ }
20908
+ function PriceDetails({ tiers }) {
20909
+ return h("div", { className: "odc-price-details", "aria-label": "\u5B98\u7F51\u4EF7\u683C\u8BE6\u60C5" }, tiers.map((tier, index) => h(
20910
+ "section",
20911
+ { className: "odc-price-tier", key: `${index}-${tier.label}` },
20912
+ h("strong", null, `${tier.label} \xB7 ${priceUnit(tier)}`),
20913
+ h("dl", null, [["\u8F93\u5165", tier.input], ["\u8F93\u51FA", tier.output], ["\u7F13\u5B58\u8BFB\u53D6", tier.cacheRead], ["\u7F13\u5B58\u5199\u5165", tier.cacheWrite]].map(([label, value]) => h("div", { key: label }, h("dt", null, label), h("dd", null, priceAmount(value, tier.currency)))))
20914
+ )));
20915
+ }
20916
+ function ModelRow({ model, settings, authoritative, writable, pending, price, priceKnown = false, onCommit }) {
20759
20917
  const id = React.useId();
20760
20918
  const mounted = useMounted();
20761
20919
  const [error62, setError] = React.useState(void 0);
@@ -20818,11 +20976,13 @@ function ModelRow({ model, settings, authoritative, writable, pending, onCommit
20818
20976
  } }, "\u91CD\u7F6E")
20819
20977
  )
20820
20978
  ),
20979
+ price !== void 0 ? h("p", { className: "odc-price-summary" }, `\u5B98\u7F51\u53C2\u8003 \xB7 ${price.tiers[0].label} \xB7 \u8F93\u5165 ${priceAmount(price.tiers[0].input, price.tiers[0].currency)} / \u8F93\u51FA ${priceAmount(price.tiers[0].output, price.tiers[0].currency)} \xB7 ${priceUnit(price.tiers[0])}${price.tiers.length > 1 ? ` \xB7 \u5171 ${price.tiers.length} \u6863` : ""}`) : priceKnown ? h("p", { className: "odc-price-summary" }, "\u5B98\u7F51\u6682\u672A\u5217\u51FA\u6B64\u6A21\u578B\u4EF7\u683C") : null,
20821
20980
  h(
20822
20981
  "details",
20823
20982
  { className: "odc-model-details" },
20824
- h("summary", { "aria-label": `${model.name} \u53C2\u6570\u8BBE\u7F6E` }, hasOverrides ? "\u53C2\u6570\u8BBE\u7F6E \xB7 \u5DF2\u81EA\u5B9A\u4E49" : "\u53C2\u6570\u8BBE\u7F6E \xB7 \u4F7F\u7528\u9ED8\u8BA4\u503C"),
20983
+ h("summary", { "aria-label": `${model.name} \u53C2\u6570\u8BBE\u7F6E${price === void 0 ? "" : "\u4E0E\u4EF7\u683C"}` }, `${price === void 0 ? "\u53C2\u6570\u8BBE\u7F6E" : "\u53C2\u6570\u4E0E\u4EF7\u683C"} \xB7 ${hasOverrides ? "\u5DF2\u81EA\u5B9A\u4E49" : "\u4F7F\u7528\u9ED8\u8BA4\u503C"}`),
20825
20984
  h("p", { className: "odc-model-meta" }, facts),
20985
+ price === void 0 ? null : h(PriceDetails, { tiers: price.tiers }),
20826
20986
  h("p", { className: "odc-hint" }, "\u6570\u503C\u79BB\u5F00\u8F93\u5165\u6846\u540E\u4FDD\u5B58\uFF0C\u7559\u7A7A\u7EE7\u627F\u9ED8\u8BA4\u3002"),
20827
20987
  h(
20828
20988
  "div",
@@ -20854,7 +21014,7 @@ function ModelRow({ model, settings, authoritative, writable, pending, onCommit
20854
21014
  error62 !== void 0 ? h("p", { className: "odc-hint odc-field-error", role: "alert" }, error62) : null
20855
21015
  );
20856
21016
  }
20857
- function ModelGroup({ title, group, models, settingsMap, authoritative, writable, pending, onCommit }) {
21017
+ function ModelGroup({ title, group, models, settingsMap, authoritative, writable, pending, onCommit, prices }) {
20858
21018
  const [query, setQuery] = React.useState("");
20859
21019
  const [expanded, setExpanded] = React.useState(false);
20860
21020
  const id = React.useId();
@@ -20888,6 +21048,8 @@ function ModelGroup({ title, group, models, settingsMap, authoritative, writable
20888
21048
  authoritative,
20889
21049
  writable,
20890
21050
  pending,
21051
+ price: prices?.models.find((entry) => entry.id === model.id),
21052
+ priceKnown: prices !== void 0 && (prices.state !== "error" || prices.stale),
20891
21053
  onCommit: (next) => onCommit(model.id, next)
20892
21054
  }))),
20893
21055
  normalized === "" && filtered.length > 6 ? h("button", {
@@ -20900,7 +21062,7 @@ function ModelGroup({ title, group, models, settingsMap, authoritative, writable
20900
21062
  }, expanded ? "\u6536\u8D77\u6A21\u578B\u5217\u8868" : `\u663E\u793A\u5168\u90E8 ${filtered.length} \u4E2A\u6A21\u578B`) : null
20901
21063
  );
20902
21064
  }
20903
- function Models({ status, formSnapshot, setFormField, pendingField, onRefreshModels, refreshingModels, notice }) {
21065
+ function Models({ status, formSnapshot, setFormField, pendingField, onRefreshModels, refreshingModels, notice, prices, refreshingPrices = false, onRefreshPrices }) {
20904
21066
  const formReady = formSnapshot.status === "ready" && formSnapshot.value !== void 0;
20905
21067
  const settingsMap = formReady ? formSnapshot.value?.modelSettings ?? {} : status?.config.modelSettings ?? {};
20906
21068
  const authoritative = formReady || status?.config.modelSettings !== void 0;
@@ -20955,11 +21117,23 @@ function Models({ status, formSnapshot, setFormField, pendingField, onRefreshMod
20955
21117
  status?.apiKeyConfigured === false ? h("p", { className: "odc-hint" }, "\u5237\u65B0\u6A21\u578B\u9700\u8981\u53EF\u7528\u7684 API Key\uFF1B\u4FDD\u5B58 Key \u540E\u91CD\u8BD5\u3002") : null,
20956
21118
  status?.modelsError !== void 0 ? h("p", { className: "odc-notice", "data-kind": "error", role: "alert" }, status.modelsError) : null,
20957
21119
  h(NoticeView, { notice }),
21120
+ h(
21121
+ "section",
21122
+ { className: "odc-card", "aria-label": "\u5B98\u7F51\u6A21\u578B\u4EF7\u683C" },
21123
+ h(
21124
+ "div",
21125
+ { className: "odc-pricing-head" },
21126
+ h("h3", null, "\u5B98\u7F51\u53C2\u8003\u4EF7\u683C"),
21127
+ h("button", { className: "odc-button", type: "button", disabled: refreshingPrices || onRefreshPrices === void 0, onClick: onRefreshPrices }, refreshingPrices ? "\u6B63\u5728\u66F4\u65B0\u4EF7\u683C\u2026" : "\u66F4\u65B0\u4EF7\u683C")
21128
+ ),
21129
+ h("p", { className: "odc-hint", role: "status" }, refreshingPrices ? "\u6B63\u5728\u8BFB\u53D6\u5B98\u7F51\u4EF7\u683C\u2026" : prices === void 0 ? "\u7B49\u5F85\u8BFB\u53D6\u5B98\u7F51\u4EF7\u683C\u3002" : prices.state === "error" ? prices.stale ? `\u8BFB\u53D6\u5931\u8D25\uFF0C\u663E\u793A\u4E0A\u6B21\u4EF7\u683C\uFF08${formatTime(prices.fetchedAt)}\uFF09\u3002` : "\u5B98\u7F51\u4EF7\u683C\u6682\u4E0D\u53EF\u7528\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5\u3002" : `\u5DF2\u66F4\u65B0\uFF1A${formatTime(prices.fetchedAt)}${prices.state === "partial" ? "\uFF1B\u90E8\u5206\u4EF7\u683C\u672A\u80FD\u8BFB\u53D6" : ""}`),
21130
+ h("p", { className: "odc-hint" }, "\u5B98\u7F51\u5206\u6863\u4EF7\u683C\u4EC5\u4F9B\u53C2\u8003\uFF1B\u5B9E\u9645\u8D39\u7528\u4EE5\u8D26\u6237\u8D26\u5355\u4E3A\u51C6\u3002", " ", h("a", { className: "odc-link", href: PRICE_SITE, target: "_blank", rel: "noreferrer noopener" }, "\u67E5\u770B\u5B98\u7F51\u4EF7\u683C"))
21131
+ ),
20958
21132
  models.length === 0 ? h("p", { className: "odc-hint", role: "status" }, "\u6682\u65E0\u53EF\u7528\u6A21\u578B\uFF1B\u53EF\u5237\u65B0\u6A21\u578B\u5217\u8868\u540E\u91CD\u8BD5\u3002") : h(
20959
21133
  "div",
20960
21134
  { className: "odc-model-groups" },
20961
- h(ModelGroup, { title: "\u5957\u9910\u8D60\u9001\u6A21\u578B", group: "plan", models, settingsMap, authoritative, writable, pending, onCommit: commit }),
20962
- h(ModelGroup, { title: "\u4ED8\u8D39\u6A21\u578B", group: "paid", models, settingsMap, authoritative, writable, pending, onCommit: commit })
21135
+ h(ModelGroup, { title: "\u5957\u9910\u8D60\u9001\u6A21\u578B", group: "plan", models, settingsMap, authoritative, writable, pending, onCommit: commit, prices }),
21136
+ h(ModelGroup, { title: "\u4ED8\u8D39\u6A21\u578B", group: "paid", models, settingsMap, authoritative, writable, pending, onCommit: commit, prices })
20963
21137
  )
20964
21138
  );
20965
21139
  }
@@ -21455,6 +21629,10 @@ function SettingsPage({ caller, form }) {
21455
21629
  const [loading, setLoading] = React.useState(true);
21456
21630
  const [refreshing, setRefreshing] = React.useState(false);
21457
21631
  const [refreshingModels, setRefreshingModels] = React.useState(false);
21632
+ const [prices, setPrices] = React.useState();
21633
+ const [refreshingPrices, setRefreshingPrices] = React.useState(false);
21634
+ const pricesBusy = React.useRef(false);
21635
+ const pricesRequested = React.useRef(false);
21458
21636
  const [modelsNotice, setModelsNotice] = React.useState(null);
21459
21637
  const [pendingField, setPendingField] = React.useState([]);
21460
21638
  const writeTail = React.useRef(Promise.resolve());
@@ -21600,6 +21778,25 @@ function SettingsPage({ caller, form }) {
21600
21778
  }
21601
21779
  }
21602
21780
  }, [caller, mounted]);
21781
+ const refreshPrices = React.useCallback(async () => {
21782
+ if (pricesBusy.current) return;
21783
+ pricesBusy.current = true;
21784
+ setRefreshingPrices(true);
21785
+ try {
21786
+ const next = await caller("refreshPrices");
21787
+ if (mounted.current) setPrices(next);
21788
+ } catch {
21789
+ if (mounted.current) setPrices((previous) => previous?.fetchedAt === void 0 ? { state: "error", stale: false, models: [] } : { ...previous, state: "error", stale: true });
21790
+ } finally {
21791
+ pricesBusy.current = false;
21792
+ if (mounted.current) setRefreshingPrices(false);
21793
+ }
21794
+ }, [caller, mounted]);
21795
+ React.useEffect(() => {
21796
+ if (tab !== "models" || pricesRequested.current) return;
21797
+ pricesRequested.current = true;
21798
+ void refreshPrices();
21799
+ }, [tab, refreshPrices]);
21603
21800
  const loginState = status?.login.state;
21604
21801
  const loginActive = loginState !== void 0 && loginInFlight(loginState);
21605
21802
  React.useEffect(() => {
@@ -21672,7 +21869,12 @@ function SettingsPage({ caller, form }) {
21672
21869
  void refreshModels();
21673
21870
  },
21674
21871
  refreshingModels,
21675
- notice: modelsNotice
21872
+ notice: modelsNotice,
21873
+ prices,
21874
+ refreshingPrices,
21875
+ onRefreshPrices: () => {
21876
+ void refreshPrices();
21877
+ }
21676
21878
  });
21677
21879
  } else if (tab === "connection") {
21678
21880
  content = h(Connection, { status, formSnapshot, setFormField, pendingField, caller, onLoginStatus: acceptLoginStatus, onStatus: acceptStatus });
@@ -3,7 +3,7 @@ export interface DeviceTokens {
3
3
  runtimeKey: string;
4
4
  }
5
5
  export declare const DEVICE_AUTH_ENDPOINT = "https://amr-api.open-design.ai/api/v1/cli/device-authorizations";
6
- export declare const DEVICE_AUTH_PLUGIN_VERSION = "0.1.9";
6
+ export declare const DEVICE_AUTH_PLUGIN_VERSION = "0.1.10";
7
7
  export declare const DEVICE_REQUEST_TIMEOUT_MS = 20000;
8
8
  /** One bounded launch step of the temporary activation window. */
9
9
  export declare const DEVICE_OPEN_TIMEOUT_MS = 30000;