@kenz1117/dsh-ui-usage-billing 1.8.8 → 1.8.9

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/lib/index.js CHANGED
@@ -7697,27 +7697,40 @@ const pricingGate = createCooldownGate({
7697
7697
  cooldownMs: 6e4
7698
7698
  });
7699
7699
  /**
7700
- * USD → CNY 汇率源,按顺序尝试:国内可达的腾讯财经行情(免 key、`~` 分隔
7701
- * 第 4 个字段为价格)优先,国外 open.er-api.com 兜底。任一源失败自动落到
7702
- * 下一个;全部失败由调用方降级内置汇率。
7700
+ * 解析 `{ rates: { CNY: number } }` 结构的汇率 JSON(open.er-api.com 与 AllRatesToday 通用)。
7701
+ * @param text - 响应正文。
7702
+ * @returns CNY 汇率;结构不符或非正数时 undefined。
7703
7703
  */
7704
- const RATE_SOURCES = [{
7705
- url: "https://qt.gtimg.cn/q=whUSDCNY",
7706
- parse: (text) => {
7707
- const price = /"([^"]*)"/.exec(text)?.[1]?.split("~")[3];
7708
- return price !== void 0 && price !== "" ? Number(price) : void 0;
7704
+ function parseRatesJsonCny(text) {
7705
+ try {
7706
+ const cny = JSON.parse(text).rates?.CNY;
7707
+ return typeof cny === "number" && Number.isFinite(cny) && cny > 0 ? cny : void 0;
7708
+ } catch {
7709
+ return;
7709
7710
  }
7710
- }, {
7711
- url: "https://open.er-api.com/v6/latest/USD",
7712
- parse: (text) => {
7713
- try {
7714
- const cny = JSON.parse(text).rates?.CNY;
7715
- return typeof cny === "number" && Number.isFinite(cny) && cny > 0 ? cny : void 0;
7716
- } catch {
7717
- return;
7711
+ }
7712
+ /**
7713
+ * USD → CNY 汇率源,按顺序尝试:国内可达的腾讯财经行情(免 key、`~` 分隔
7714
+ * 第 4 个字段为价格)优先,国外 open.er-api.com 兜底,再退到 AllRatesToday
7715
+ * 免 key 端点(同结构)。任一源失败自动落到下一个;全部失败由调用方降级内置汇率。
7716
+ */
7717
+ const RATE_SOURCES = [
7718
+ {
7719
+ url: "https://qt.gtimg.cn/q=whUSDCNY",
7720
+ parse: (text) => {
7721
+ const price = /"([^"]*)"/.exec(text)?.[1]?.split("~")[3];
7722
+ return price !== void 0 && price !== "" ? Number(price) : void 0;
7718
7723
  }
7724
+ },
7725
+ {
7726
+ url: "https://open.er-api.com/v6/latest/USD",
7727
+ parse: parseRatesJsonCny
7728
+ },
7729
+ {
7730
+ url: "https://allratestoday.com/api/open/latest/USD",
7731
+ parse: parseRatesJsonCny
7719
7732
  }
7720
- }];
7733
+ ];
7721
7734
  /** OpenRouter's public model list: per-token USD prices, no key needed. */
7722
7735
  const ROUTER_URL = "https://openrouter.ai/api/v1/models";
7723
7736
  /** models.dev 公开目录:pi-ai 预制提供方的上游数据源(USD / 1M tokens)。
@@ -7822,25 +7835,25 @@ async function fetchJson(url) {
7822
7835
  /** Latest USD → CNY rate from the first working source, or undefined when none respond. */
7823
7836
  /**
7824
7837
  * EUR → CNY 汇率源。与 USD 同一套降级约定:腾讯行情优先(免 key、国内可达),
7825
- * open.er-api.com 兑底;全部失败由调用方降级内置汇率,不阻塞其他价格拉取。
7838
+ * open.er-api.com 兑底,AllRatesToday 再兜底;全部失败由调用方降级内置汇率,不阻塞其他价格拉取。
7826
7839
  */
7827
- const EUR_RATE_SOURCES = [{
7828
- url: "https://qt.gtimg.cn/q=whEURCNY",
7829
- parse: (text) => {
7830
- const price = /"([^"]*)"/.exec(text)?.[1]?.split("~")[3];
7831
- return price !== void 0 && price !== "" ? Number(price) : void 0;
7832
- }
7833
- }, {
7834
- url: "https://open.er-api.com/v6/latest/EUR",
7835
- parse: (text) => {
7836
- try {
7837
- const cny = JSON.parse(text).rates?.CNY;
7838
- return typeof cny === "number" && Number.isFinite(cny) && cny > 0 ? cny : void 0;
7839
- } catch {
7840
- return;
7840
+ const EUR_RATE_SOURCES = [
7841
+ {
7842
+ url: "https://qt.gtimg.cn/q=whEURCNY",
7843
+ parse: (text) => {
7844
+ const price = /"([^"]*)"/.exec(text)?.[1]?.split("~")[3];
7845
+ return price !== void 0 && price !== "" ? Number(price) : void 0;
7841
7846
  }
7847
+ },
7848
+ {
7849
+ url: "https://open.er-api.com/v6/latest/EUR",
7850
+ parse: parseRatesJsonCny
7851
+ },
7852
+ {
7853
+ url: "https://allratestoday.com/api/open/latest/EUR",
7854
+ parse: parseRatesJsonCny
7842
7855
  }
7843
- }];
7856
+ ];
7844
7857
  /**
7845
7858
  * 按顺序尝试汇率源,返回第一个合法正数。
7846
7859
  * @param sources - 待尝试的汇率源。
@@ -1,5 +1,5 @@
1
1
  /** Locale dictionaries for the usage billing surface. */
2
- export type UsageBillingKey = 'title' | 'cost' | 'todayCost' | 'monthCost' | 'yearCost' | 'monthProjected' | 'monthProjectedHint' | 'liveTurn' | 'liveSession' | 'liveSessionSub' | 'calls' | 'cacheHitRate' | 'tokens' | 'inputTokens' | 'outputTokens' | 'avgCost' | 'kpiRange' | 'avgRangeToday' | 'avgRange7d' | 'avgRangeWeek' | 'avgRangeMonth' | 'avgRangeAll' | 'avgRangeCustom' | 'customRangeStart' | 'customRangeEnd' | 'trend' | 'trend7d' | 'trend30d' | 'trendMetric' | 'trendMetricCost' | 'trendMetricTokens' | 'pricingSearch' | 'bandPinHint' | 'trendEmpty' | 'trendTotal' | 'roundsUnit' | 'healthModelsLive' | 'healthVendorsDown' | 'healthVendorsUnavailable' | 'budget' | 'budgetRemain' | 'budgetAmount' | 'budgetSummary' | 'sessions' | 'sessionTitle' | 'lastActive' | 'sessionOverflow' | 'budgetTierBody' | 'models' | 'providerBilling' | 'channelUnknown' | 'directTag' | 'relayTag' | 'unknownTag' | 'unknownChannelHint' | 'planCountUnit' | 'actual' | 'pricing' | 'input' | 'output' | 'cacheHit' | 'peak' | 'offPeak' | 'flat' | 'band' | 'close' | 'footer' | 'footerCredit' | 'lastUpdated' | 'noData' | 'todayRate' | 'rateLive' | 'rateBuiltin' | 'pricingSyncedAt' | 'pricingSyncNow' | 'pricingSyncing' | 'promoBadge' | 'promoUntil' | 'promoOpenEnded' | 'pricingTip' | 'pricingUnit' | 'pricingNotes' | 'ubPeak' | 'ubOff' | 'ubStd' | 'peakBand' | 'pricingSource' | 'noteCache' | 'noteBand' | 'noteSource' | 'balance' | 'recharge' | 'rechargeHint' | 'balanceUnconfigured' | 'balanceUnauthorized' | 'balanceUnreachable' | 'uncatalogued' | 'estimatedPricing' | 'balanceDays' | 'balanceLowBody' | 'reconcileDrift' | 'reconcileDismiss' | 'subscriptionNotConfigured' | 'subscriptionUnauthorized' | 'subscriptionUnavailable' | 'subscriptionInvalid' | 'subscriptionRateLimited' | 'subscriptionSession' | 'subscriptionWeekly' | 'subscriptionMonthly' | 'subscriptionBilling' | 'subscriptionRemaining' | 'subscriptionExhausted' | 'subscriptionReset' | 'subscriptionNoApi' | 'floatWindow' | 'floatModeCombined' | 'floatModeSubscription' | 'floatMode' | 'floatTargets' | 'floatWindowHint' | 'floatPrimaryToday' | 'floatPrimaryWeek' | 'floatPrimaryMonth' | 'floatNoTargets' | 'floatNoTargetsHint' | 'cardDisplay' | 'cardDisplayHint' | 'cardMode' | 'cardModeFull' | 'cardModeCompact' | 'cardModeHidden' | 'cardModeHiddenHint' | 'cardModeFallback' | 'nativeSettingsNav' | 'nativeSettingsIntro' | 'nativeSettingsHiddenHint' | 'cardMetric' | 'cardMetricMoney' | 'cardMetricTokens' | 'cardSpan' | 'cardSpanDay' | 'cardSpanWeek' | 'cardSpanMonth' | 'cardDeltaBadge' | 'cardDeltaShow' | 'cardDeltaHide' | 'triggerMonthTokens' | 'triggerTodayTokens' | 'triggerWeekTokens' | 'subscriptionsStale' | 'balanceStaleNotice' | 'staleLedgerNotice' | 'staleSnapshotNotice' | 'statsLoadFailed' | 'unreadableNotice' | 'unreadableFormatNotice' | 'unreadableNoLedgerNotice' | 'tokenCacheWrite' | 'toolRank' | 'toolName' | 'userPrices' | 'userPricesHint' | 'userPriceSave' | 'userPriceModel' | 'userPriceSource' | 'userPriceSourceHint' | 'userPriceOffPeak' | 'userPriceNormal' | 'userPriceCurrency' | 'userPriceAdd' | 'userPriceRemoveSelected' | 'userPriceSelect' | 'sessionStaleBadge' | 'sessionUntitled' | 'sessionSubCost' | 'sessionSubCalls' | 'sessionSubRow' | 'heatmapLess' | 'heatmapMore' | 'currency' | 'currencyCny' | 'currencyUsd' | 'currencyEur' | 'language' | 'heatmap' | 'rounds' | 'roundsHint' | 'anomaly' | 'model' | 'thModel' | 'thInputMiss' | 'thInputHit' | 'costAbbr' | 'tabOverview' | 'tabTrends' | 'tabProviders' | 'tabPricing' | 'tabSettings' | 'budgetHint' | 'peakAlertHint' | 'peakAlertDescPeak' | 'peakAlertDescOff' | 'peakAlertDescPeakZhipu' | 'peakAlertDescOffZhipu' | 'peakAlertQueuePeak' | 'peakAlertQueueOff' | 'export' | 'exportCsvDay' | 'exportCsvSession' | 'exportJson' | 'peakShare' | 'peakSharePerCall' | 'offPeakSavings' | 'perfMax' | 'weekCost' | 'roleCost' | 'roleUser' | 'roleAssistant' | 'roleTool' | 'roleHint' | 'tierPeak' | 'tierOff' | 'tierToPeak' | 'tierToOff' | 'tierAlertEnterPeak' | 'tierAlertEnterOff' | 'tierAlertEnterPeakZhipu' | 'tierAlertEnterOffZhipu' | 'peakAlertTitlePeak' | 'peakAlertTitleOff' | 'peakAlert' | 'peakAlertLeadMin' | 'peakAlertPos' | 'peakAlertMode' | 'peakAlertPosCorner' | 'peakAlertPosCenter' | 'peakAlertModePeak' | 'peakAlertModeOff' | 'peakAlertModeBoth' | 'peakAlertWebNotify' | 'peakAlertPreview' | 'planTypeCode' | 'planTypeToken' | 'subscriptionFeePerMonth' | 'triggerToday' | 'triggerMonth' | 'subscriptionTag' | 'cellEstimateHint' | 'free' | 'perfSamples' | 'perfTtft' | 'perfP50' | 'perfP90' | 'perfTps' | 'perfLatency' | 'perfEstimated' | 'perfEmpty' | 'perfTpsUnit' | 'perfTitle' | 'perfHint' | 'perfAll' | 'perfChartEmpty' | 'heatmapYear' | 'heatmapHalf' | 'heatmapMonth' | 'metricCost' | 'metricTokens' | 'heatmapTotal' | 'activeDays' | 'streakDays' | 'subscriptionAutoDetect' | 'pluginAuthor' | 'pluginRepository' | 'pluginNpm' | 'pluginLicense' | 'tabToken' | 'tokenExport' | 'tokenExportCsv' | 'tokenReasoningShare' | 'tokenReasoningShort' | 'tokenIo' | 'tokenPeak' | 'densityLabel' | 'densityHint' | 'densityCompact' | 'densityDefault' | 'densityComfortable' | 'motionLabel' | 'motionHint' | 'motionOff' | 'motionSubtle' | 'motionRich' | 'settingsNavDisplayPref' | 'settingsNavBudget' | 'settingsNavAlert' | 'settingsNavDisplay' | 'settingsNavAdvanced' | 'settingsNavAbout' | 'settingsSearchPlaceholder' | 'settingsSearchEmpty' | 'sessionsViewAll' | 'sessionsViewTop' | 'sessionViewerSearch' | 'modelBudgetTitle' | 'modelBudgetHint' | 'modelBudgetBody' | 'modelBudgetPlaceholder' | 'moreWorksTitle' | 'adEngramName' | 'adEngramDesc' | 'adRainbowName' | 'adRainbowDesc' | 'kpiDescCacheHit' | 'kpiDescTokens' | 'kpiDescAvgCost' | 'kpiDescCalls' | 'kpiDescReasoning' | 'kpiDescIo' | 'kpiDescPeak' | 'healthDotLive' | 'healthDotFailed' | 'healthDotUnknown' | 'settingsSectionDisplay' | 'emptyHint' | 'tokenDaily' | 'tokenByModel' | 'tokenMiss' | 'tokenHit' | 'tokenOutput' | 'tokenViewStructure' | 'tokenViewModel' | 'tokenHitShort' | 'tokenMissShort' | 'tokenTotal' | 'tokenShare' | 'usageStatsTool' | 'usageStatsToolHint' | 'balanceGranted' | 'balanceTopped' | 'balanceDaily' | 'balanceDaysLong' | 'balanceDaysUnit' | 'popTodayModel' | 'popNoConsumption' | 'popTitle' | 'popDirectLead' | 'popSubLead' | 'unpricedHint' | 'channelVisibility' | 'channelVisibilityHint' | 'channelVisibilityShowAll' | 'channelVisibilityHidden' | 'channelVisibilityEmpty' | 'unpricedMore' | 'unpricedFix' | 'searchEstimateHint' | 'siteListDisplay' | 'siteListDisplayHint' | 'liveCostBar' | 'liveCostBarHint' | 'liveCostBarPosition' | 'liveCostBarPosBelow' | 'liveCostBarPosAbove' | 'liveCostBarPosToolbar' | 'exportCsvSite' | 'panelRelayQuota' | 'relayBalance' | 'relayNoQuota' | 'relayWindowUsed' | 'relayKindNewApi' | 'relayKindSub2Api' | 'relayKindUnknown' | 'expandAll' | 'collapseAll' | 'todayOnly' | 'todayNoConsumption' | 'commandUsageLabel' | 'commandUsageDescription' | 'sessionOpen' | 'sessionOpenFailed' | 'sessionOpenUnavailable' | 'tabAgents' | 'tabQueue' | 'queueSubtitle' | 'queueUntilPeak' | 'queueUntilOffPeak' | 'queueUnsupportedTitle' | 'queueUnsupportedBody' | 'queueSafety' | 'queueSafetyIsolated' | 'queueSafetyReuse' | 'queueReusePlanned' | 'queueReuseDone' | 'queueFallbackReason' | 'queueReuseModelNote' | 'queueWorkspace' | 'queueModel' | 'queueNoOptions' | 'queuePromptLabel' | 'queuePromptPlaceholder' | 'queuePrivacy' | 'queueEnqueue' | 'queueImport' | 'queueImportHint' | 'queueImported' | 'queueImportFormat' | 'queueImportTooLarge' | 'queueActive' | 'queueClearFinished' | 'queueEmpty' | 'queueLoading' | 'queueOpenSession' | 'queueRemoveQueued' | 'queueRemoveHistory' | 'queueStatusQueued' | 'queueStatusStarting' | 'queueStatusRunning' | 'queueStatusCompleted' | 'queueStatusFailed' | 'quickQueueToggle' | 'quickQueueEntry' | 'quickQueueEntryHint' | 'quickQueueReuseEntry' | 'quickQueueReuseEntryHint' | 'quickQueueEnqueue' | 'quickQueueEnqueueing' | 'quickQueueWaiting' | 'quickQueueClear' | 'quickQueueEnqueued' | 'quickQueueEmpty' | 'quickQueueBusy' | 'quickQueueAttachments' | 'quickQueueContext' | 'quickQueueRoute' | 'quickQueueDraftChanged' | 'quickQueueUnsupported' | 'quickQueueFailed' | 'agentsSummary' | 'agentsCount' | 'agentsDelegations' | 'agentsRoots' | 'agentsMostExpensive' | 'agentsChainTotal' | 'agentsNoData' | 'agentsSubagent' | 'agentsRoot';
2
+ export type UsageBillingKey = 'title' | 'cost' | 'todayCost' | 'monthCost' | 'yearCost' | 'monthProjected' | 'monthProjectedHint' | 'liveTurn' | 'liveSession' | 'liveSessionSub' | 'calls' | 'cacheHitRate' | 'tokens' | 'inputTokens' | 'outputTokens' | 'avgCost' | 'kpiRange' | 'avgRangeToday' | 'avgRange7d' | 'avgRangeWeek' | 'avgRangeMonth' | 'avgRangeAll' | 'avgRangeCustom' | 'customRangeStart' | 'customRangeEnd' | 'trend' | 'trend7d' | 'trend30d' | 'trendMetric' | 'trendMetricCost' | 'trendMetricTokens' | 'pricingSearch' | 'bandPinHint' | 'trendEmpty' | 'trendTotal' | 'roundsUnit' | 'healthModelsLive' | 'healthVendorsDown' | 'healthVendorsUnavailable' | 'budget' | 'budgetRemain' | 'budgetAmount' | 'budgetSummary' | 'sessions' | 'sessionTitle' | 'lastActive' | 'sessionOverflow' | 'budgetTierBody' | 'models' | 'providerBilling' | 'channelUnknown' | 'directTag' | 'relayTag' | 'unknownTag' | 'unknownChannelHint' | 'planCountUnit' | 'actual' | 'pricing' | 'input' | 'output' | 'cacheHit' | 'peak' | 'offPeak' | 'flat' | 'band' | 'close' | 'footer' | 'footerCredit' | 'lastUpdated' | 'noData' | 'todayRate' | 'rateLive' | 'rateBuiltin' | 'pricingSyncedAt' | 'pricingSyncNow' | 'pricingSyncing' | 'promoBadge' | 'promoUntil' | 'promoOpenEnded' | 'pricingTip' | 'pricingUnit' | 'pricingNotes' | 'ubPeak' | 'ubOff' | 'ubStd' | 'peakBand' | 'pricingSource' | 'noteCache' | 'noteBand' | 'noteSource' | 'balance' | 'recharge' | 'rechargeHint' | 'balanceUnconfigured' | 'balanceUnauthorized' | 'balanceUnreachable' | 'uncatalogued' | 'estimatedPricing' | 'balanceDays' | 'balanceLowBody' | 'reconcileDrift' | 'reconcileDismiss' | 'subscriptionNotConfigured' | 'subscriptionUnauthorized' | 'subscriptionUnavailable' | 'subscriptionInvalid' | 'subscriptionRateLimited' | 'subscriptionSession' | 'subscriptionWeekly' | 'subscriptionMonthly' | 'subscriptionBilling' | 'subscriptionRemaining' | 'subscriptionExhausted' | 'subscriptionReset' | 'subscriptionNoApi' | 'floatWindow' | 'floatModeCombined' | 'floatModeSubscription' | 'floatMode' | 'floatTargets' | 'floatWindowHint' | 'floatPrimaryToday' | 'floatPrimaryWeek' | 'floatPrimaryMonth' | 'floatNoTargets' | 'floatNoTargetsHint' | 'cardDisplay' | 'cardDisplayHint' | 'cardMode' | 'cardModeFull' | 'cardModeCompact' | 'cardModeHidden' | 'cardModeHiddenHint' | 'cardModeFallback' | 'nativeSettingsNav' | 'nativeSettingsIntro' | 'nativeSettingsHiddenHint' | 'shortcutOpenDashboard' | 'cardMetric' | 'cardMetricMoney' | 'cardMetricTokens' | 'cardSpan' | 'cardSpanDay' | 'cardSpanWeek' | 'cardSpanMonth' | 'cardDeltaBadge' | 'cardDeltaShow' | 'cardDeltaHide' | 'triggerMonthTokens' | 'triggerTodayTokens' | 'triggerWeekTokens' | 'subscriptionsStale' | 'balanceStaleNotice' | 'staleLedgerNotice' | 'staleSnapshotNotice' | 'statsLoadFailed' | 'unreadableNotice' | 'unreadableFormatNotice' | 'unreadableNoLedgerNotice' | 'tokenCacheWrite' | 'toolRank' | 'toolName' | 'userPrices' | 'userPricesHint' | 'userPriceSave' | 'userPriceModel' | 'userPriceSource' | 'userPriceSourceHint' | 'userPriceOffPeak' | 'userPriceNormal' | 'userPriceCurrency' | 'userPriceAdd' | 'userPriceRemoveSelected' | 'userPriceSelect' | 'sessionStaleBadge' | 'sessionUntitled' | 'sessionSubCost' | 'sessionSubCalls' | 'sessionSubRow' | 'heatmapLess' | 'heatmapMore' | 'currency' | 'currencyCny' | 'currencyUsd' | 'currencyEur' | 'language' | 'heatmap' | 'rounds' | 'roundsHint' | 'anomaly' | 'model' | 'thModel' | 'thInputMiss' | 'thInputHit' | 'costAbbr' | 'tabOverview' | 'tabTrends' | 'tabProviders' | 'tabPricing' | 'tabSettings' | 'budgetHint' | 'peakAlertHint' | 'peakAlertDescPeak' | 'peakAlertDescOff' | 'peakAlertDescPeakZhipu' | 'peakAlertDescOffZhipu' | 'peakAlertQueuePeak' | 'peakAlertQueueOff' | 'export' | 'exportCsvDay' | 'exportCsvSession' | 'exportJson' | 'peakShare' | 'peakSharePerCall' | 'offPeakSavings' | 'perfMax' | 'weekCost' | 'roleCost' | 'roleUser' | 'roleAssistant' | 'roleTool' | 'roleHint' | 'tierPeak' | 'tierOff' | 'tierToPeak' | 'tierToOff' | 'tierAlertEnterPeak' | 'tierAlertEnterOff' | 'tierAlertEnterPeakZhipu' | 'tierAlertEnterOffZhipu' | 'peakAlertTitlePeak' | 'peakAlertTitleOff' | 'peakAlert' | 'peakAlertLeadMin' | 'peakAlertPos' | 'peakAlertMode' | 'peakAlertPosCorner' | 'peakAlertPosCenter' | 'peakAlertModePeak' | 'peakAlertModeOff' | 'peakAlertModeBoth' | 'peakAlertWebNotify' | 'peakAlertPreview' | 'planTypeCode' | 'planTypeToken' | 'subscriptionFeePerMonth' | 'triggerToday' | 'triggerMonth' | 'subscriptionTag' | 'cellEstimateHint' | 'free' | 'perfSamples' | 'perfTtft' | 'perfP50' | 'perfP90' | 'perfTps' | 'perfLatency' | 'perfEstimated' | 'perfEmpty' | 'perfTpsUnit' | 'perfTitle' | 'perfHint' | 'perfAll' | 'perfChartEmpty' | 'heatmapYear' | 'heatmapHalf' | 'heatmapMonth' | 'metricCost' | 'metricTokens' | 'heatmapTotal' | 'activeDays' | 'streakDays' | 'subscriptionAutoDetect' | 'pluginAuthor' | 'pluginRepository' | 'pluginNpm' | 'pluginLicense' | 'tabToken' | 'tokenExport' | 'tokenExportCsv' | 'tokenReasoningShare' | 'tokenReasoningShort' | 'tokenIo' | 'tokenPeak' | 'densityLabel' | 'densityHint' | 'densityCompact' | 'densityDefault' | 'densityComfortable' | 'motionLabel' | 'motionHint' | 'motionOff' | 'motionSubtle' | 'motionRich' | 'settingsNavDisplayPref' | 'settingsNavBudget' | 'settingsNavAlert' | 'settingsNavDisplay' | 'settingsNavAdvanced' | 'settingsNavAbout' | 'settingsSearchPlaceholder' | 'settingsSearchEmpty' | 'sessionsViewAll' | 'sessionsViewTop' | 'sessionViewerSearch' | 'modelBudgetTitle' | 'modelBudgetHint' | 'modelBudgetBody' | 'modelBudgetPlaceholder' | 'moreWorksTitle' | 'adEngramName' | 'adEngramDesc' | 'adRainbowName' | 'adRainbowDesc' | 'kpiDescCacheHit' | 'kpiDescTokens' | 'kpiDescAvgCost' | 'kpiDescCalls' | 'kpiDescReasoning' | 'kpiDescIo' | 'kpiDescPeak' | 'healthDotLive' | 'healthDotFailed' | 'healthDotUnknown' | 'settingsSectionDisplay' | 'emptyHint' | 'tokenDaily' | 'tokenByModel' | 'tokenMiss' | 'tokenHit' | 'tokenOutput' | 'tokenViewStructure' | 'tokenViewModel' | 'tokenHitShort' | 'tokenMissShort' | 'tokenTotal' | 'tokenShare' | 'usageStatsTool' | 'usageStatsToolHint' | 'balanceGranted' | 'balanceTopped' | 'balanceDaily' | 'balanceDaysLong' | 'balanceDaysUnit' | 'popTodayModel' | 'popNoConsumption' | 'popTitle' | 'popDirectLead' | 'popSubLead' | 'unpricedHint' | 'channelVisibility' | 'channelVisibilityHint' | 'channelVisibilityShowAll' | 'channelVisibilityHidden' | 'channelVisibilityEmpty' | 'unpricedMore' | 'unpricedFix' | 'searchEstimateHint' | 'siteListDisplay' | 'siteListDisplayHint' | 'liveCostBar' | 'liveCostBarHint' | 'liveCostBarPosition' | 'liveCostBarPosBelow' | 'liveCostBarPosAbove' | 'liveCostBarPosToolbar' | 'exportCsvSite' | 'panelRelayQuota' | 'relayBalance' | 'relayNoQuota' | 'relayWindowUsed' | 'relayKindNewApi' | 'relayKindSub2Api' | 'relayKindUnknown' | 'expandAll' | 'collapseAll' | 'todayOnly' | 'todayNoConsumption' | 'commandUsageLabel' | 'commandUsageDescription' | 'sessionOpen' | 'sessionOpenFailed' | 'sessionOpenUnavailable' | 'tabAgents' | 'tabQueue' | 'queueSubtitle' | 'queueUntilPeak' | 'queueUntilOffPeak' | 'queueUnsupportedTitle' | 'queueUnsupportedBody' | 'queueSafety' | 'queueSafetyIsolated' | 'queueSafetyReuse' | 'queueReusePlanned' | 'queueReuseDone' | 'queueFallbackReason' | 'queueReuseModelNote' | 'queueWorkspace' | 'queueModel' | 'queueNoOptions' | 'queuePromptLabel' | 'queuePromptPlaceholder' | 'queuePrivacy' | 'queueEnqueue' | 'queueImport' | 'queueImportHint' | 'queueImported' | 'queueImportFormat' | 'queueImportTooLarge' | 'queueActive' | 'queueClearFinished' | 'queueEmpty' | 'queueLoading' | 'queueOpenSession' | 'queueRemoveQueued' | 'queueRemoveHistory' | 'queueStatusQueued' | 'queueStatusStarting' | 'queueStatusRunning' | 'queueStatusCompleted' | 'queueStatusFailed' | 'quickQueueToggle' | 'quickQueueEntry' | 'quickQueueEntryHint' | 'quickQueueReuseEntry' | 'quickQueueReuseEntryHint' | 'quickQueueEnqueue' | 'quickQueueEnqueueing' | 'quickQueueWaiting' | 'quickQueueClear' | 'quickQueueEnqueued' | 'quickQueueEmpty' | 'quickQueueBusy' | 'quickQueueAttachments' | 'quickQueueContext' | 'quickQueueRoute' | 'quickQueueDraftChanged' | 'quickQueueUnsupported' | 'quickQueueFailed' | 'agentsSummary' | 'agentsCount' | 'agentsDelegations' | 'agentsRoots' | 'agentsMostExpensive' | 'agentsChainTotal' | 'agentsNoData' | 'agentsSubagent' | 'agentsRoot';
3
3
  export declare const NS = "usageBilling";
4
4
  export declare const zh: Record<UsageBillingKey, string>;
5
5
  export declare const en: Record<UsageBillingKey, string>;
@@ -10,9 +10,10 @@
10
10
  * - `label` / `description` 是**函数**:菜单每次打开都重新读取,切换语言立即生效,
11
11
  * 无需重新注册。
12
12
  *
13
- * 取服务走 `ctx.get('commandUi')`(cordis 免 inject 读取):老宿主没有该服务时
14
- * **不注册命令**,面板功能完全不受影响——这是「服务缺席即降级、不得因此收窄兼容
15
- * 矩阵」的落点(宿主自己的 ui-permission-presets 也是 `ctx.get('commandUi')`)。
13
+ * 取服务走 `ctx.inject(['commandUi'])` 而非 apply 期的 `ctx.get`:该服务是宿主的
14
+ * Service,要等 inputTriggers / remote.commands 就绪才构造,晚于本插件 apply。
15
+ * 老宿主没有这个服务时注入分支永不执行,**不注册命令**、面板功能完全不受影响——
16
+ * 这是「服务缺席即降级、不得因此收窄兼容矩阵」的落点。
16
17
  */
17
18
  import type { Context } from '@deepseek-ai/cordis';
18
19
  /** 命令名(斜杠后不带斜杠):与宿主命令目录合并的键。 */
@@ -29,9 +30,13 @@ export interface UsageCommandOptions {
29
30
  /**
30
31
  * 注册 `/usage` 命令。
31
32
  *
33
+ * commandUi 是宿主的 Service,构造前要等 inputTriggers / sessions / remote.commands
34
+ * 就绪——这些都晚于本插件 apply。因此在 apply 期用 `ctx.get` 一次性采样必然拿到
35
+ * undefined,命令永远注册不上;改为 `ctx.inject` 等它就位再注册。
36
+ *
32
37
  * @param ctx - 客户端根 context。
33
38
  * @param options - 打开回调与文案。
34
- * @returns 是否注册成功(宿主无 commandUi 服务时返回 false,属正常降级)。
39
+ * @returns 查询当前是否已注册的 getter(宿主无 commandUi 服务时恒为 false,属正常降级)。
35
40
  */
36
- export declare function registerUsageCommand(ctx: Context, options: UsageCommandOptions): boolean;
41
+ export declare function registerUsageCommand(ctx: Context, options: UsageCommandOptions): () => boolean;
37
42
  //# sourceMappingURL=usage-command.d.ts.map
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@kenz1117/dsh-ui-usage-billing",
3
3
  "description": "Usage billing dashboard for DeepSeek Harness: sidebar cost metrics plus a full dashboard modal, priced from a current multi-provider catalog with real usage aggregated from session logs.",
4
- "version": "1.8.8",
4
+ "version": "1.8.9",
5
5
  "keywords": [
6
6
  "deepseek-harness",
7
7
  "deepseek",
@@ -89,7 +89,9 @@
89
89
  "0.2.2-alpha.3": "compatible",
90
90
  "0.2.2-rc.1": "compatible",
91
91
  "0.2.2-rc.2": "compatible",
92
- "0.2.2-rc.3": "compatible"
92
+ "0.2.2-rc.3": "compatible",
93
+ "0.2.2-rc.4": "compatible",
94
+ "0.2.2-rc.5": "compatible"
93
95
  }
94
96
  }
95
97
  },
@@ -115,12 +117,12 @@
115
117
  "@deepseek-ai/dsh-atomic-write": "*",
116
118
  "@deepseek-ai/dsh-client-locale": "*",
117
119
  "@deepseek-ai/dsh-client-store": "*",
120
+ "@deepseek-ai/dsh-client-ui-commands": "*",
118
121
  "@deepseek-ai/dsh-client-ui-conversation": "*",
119
122
  "@deepseek-ai/dsh-client-ui-primitives": "*",
120
123
  "@deepseek-ai/dsh-client-ui-settings": "*",
121
124
  "@deepseek-ai/dsh-client-ui-sidebar": "*",
122
125
  "@deepseek-ai/dsh-client-ui-slots": "*",
123
- "@deepseek-ai/dsh-client-ui-commands": "*",
124
126
  "@deepseek-ai/dsh-client-ui-workspace": "*",
125
127
  "@deepseek-ai/dsh-credentials": "*",
126
128
  "@deepseek-ai/dsh-home-paths": "*",
@@ -142,64 +144,65 @@
142
144
  "@deepseek-ai/cordis-plugin-group": "1.1.0",
143
145
  "@deepseek-ai/cordis-plugin-include": "1.1.0",
144
146
  "@deepseek-ai/cordis-plugin-loader": "1.1.0",
145
- "@deepseek-ai/dsh-agent": "0.2.2-rc.3",
146
- "@deepseek-ai/dsh-agent-default-model": "0.2.2-rc.3",
147
- "@deepseek-ai/dsh-agent-preset-registry": "0.2.2-rc.3",
148
- "@deepseek-ai/dsh-api-gateway": "0.2.2-rc.3",
149
- "@deepseek-ai/dsh-api-remotes": "0.2.2-rc.3",
150
- "@deepseek-ai/dsh-api-session-controller": "0.2.2-rc.3",
151
- "@deepseek-ai/dsh-app-boot": "0.2.2-rc.3",
152
- "@deepseek-ai/dsh-atomic-write": "0.2.2-rc.3",
153
- "@deepseek-ai/dsh-attachment": "0.2.2-rc.3",
154
- "@deepseek-ai/dsh-client-connection": "0.2.2-rc.3",
155
- "@deepseek-ai/dsh-client-file-upload": "0.2.2-rc.3",
156
- "@deepseek-ai/dsh-client-locale": "0.2.2-rc.3",
157
- "@deepseek-ai/dsh-client-store": "0.2.2-rc.3",
158
- "@deepseek-ai/dsh-client-ui-commands": "0.2.2-rc.3",
159
- "@deepseek-ai/dsh-client-ui-conversation": "0.2.2-rc.3",
160
- "@deepseek-ai/dsh-client-ui-primitives": "0.2.2-rc.3",
161
- "@deepseek-ai/dsh-client-ui-renderer": "0.2.2-rc.3",
162
- "@deepseek-ai/dsh-client-ui-settings": "0.2.2-rc.3",
163
- "@deepseek-ai/dsh-client-ui-sidebar": "0.2.2-rc.3",
164
- "@deepseek-ai/dsh-client-ui-slots": "0.2.2-rc.3",
165
- "@deepseek-ai/dsh-client-ui-workspace": "0.2.2-rc.3",
166
- "@deepseek-ai/dsh-commands": "0.2.2-rc.3",
167
- "@deepseek-ai/dsh-compaction": "0.2.2-rc.3",
168
- "@deepseek-ai/dsh-credentials": "0.2.2-rc.3",
169
- "@deepseek-ai/dsh-error": "0.2.2-rc.3",
170
- "@deepseek-ai/dsh-file-reference": "0.2.2-rc.3",
171
- "@deepseek-ai/dsh-fs": "0.2.2-rc.3",
172
- "@deepseek-ai/dsh-home-paths": "0.2.2-rc.3",
173
- "@deepseek-ai/dsh-host-webserver": "0.2.2-rc.3",
147
+ "@deepseek-ai/dsh-agent": "0.2.2-rc.5",
148
+ "@deepseek-ai/dsh-agent-default-model": "0.2.2-rc.5",
149
+ "@deepseek-ai/dsh-agent-preset-registry": "0.2.2-rc.5",
150
+ "@deepseek-ai/dsh-api-gateway": "0.2.2-rc.5",
151
+ "@deepseek-ai/dsh-api-remotes": "0.2.2-rc.5",
152
+ "@deepseek-ai/dsh-api-session-controller": "0.2.2-rc.5",
153
+ "@deepseek-ai/dsh-app-boot": "0.2.2-rc.5",
154
+ "@deepseek-ai/dsh-atomic-write": "0.2.2-rc.5",
155
+ "@deepseek-ai/dsh-attachment": "0.2.2-rc.5",
156
+ "@deepseek-ai/dsh-client-connection": "0.2.2-rc.5",
157
+ "@deepseek-ai/dsh-client-file-upload": "0.2.2-rc.5",
158
+ "@deepseek-ai/dsh-client-locale": "0.2.2-rc.5",
159
+ "@deepseek-ai/dsh-client-shortcuts": "0.2.2-rc.5",
160
+ "@deepseek-ai/dsh-client-store": "0.2.2-rc.5",
161
+ "@deepseek-ai/dsh-client-ui-commands": "0.2.2-rc.5",
162
+ "@deepseek-ai/dsh-client-ui-conversation": "0.2.2-rc.5",
163
+ "@deepseek-ai/dsh-client-ui-primitives": "0.2.2-rc.5",
164
+ "@deepseek-ai/dsh-client-ui-renderer": "0.2.2-rc.5",
165
+ "@deepseek-ai/dsh-client-ui-settings": "0.2.2-rc.5",
166
+ "@deepseek-ai/dsh-client-ui-sidebar": "0.2.2-rc.5",
167
+ "@deepseek-ai/dsh-client-ui-slots": "0.2.2-rc.5",
168
+ "@deepseek-ai/dsh-client-ui-workspace": "0.2.2-rc.5",
169
+ "@deepseek-ai/dsh-commands": "0.2.2-rc.5",
170
+ "@deepseek-ai/dsh-compaction": "0.2.2-rc.5",
171
+ "@deepseek-ai/dsh-credentials": "0.2.2-rc.5",
172
+ "@deepseek-ai/dsh-error": "0.2.2-rc.5",
173
+ "@deepseek-ai/dsh-file-reference": "0.2.2-rc.5",
174
+ "@deepseek-ai/dsh-fs": "0.2.2-rc.5",
175
+ "@deepseek-ai/dsh-home-paths": "0.2.2-rc.5",
176
+ "@deepseek-ai/dsh-host-webserver": "0.2.2-rc.5",
174
177
  "@deepseek-ai/dsh-invariants": "0.2.0-rc.2",
175
- "@deepseek-ai/dsh-launch-environment": "0.2.2-rc.3",
176
- "@deepseek-ai/dsh-llm": "0.2.2-rc.3",
177
- "@deepseek-ai/dsh-native-command": "0.2.2-rc.3",
178
- "@deepseek-ai/dsh-ptc-runtime": "0.2.2-rc.3",
179
- "@deepseek-ai/dsh-sandbox": "0.2.2-rc.3",
180
- "@deepseek-ai/dsh-sandbox-policy": "0.2.2-rc.3",
181
- "@deepseek-ai/dsh-scope": "0.2.2-rc.3",
182
- "@deepseek-ai/dsh-session": "0.2.2-rc.3",
183
- "@deepseek-ai/dsh-session-persistence": "0.2.2-rc.3",
184
- "@deepseek-ai/dsh-session-projection": "0.2.2-rc.3",
185
- "@deepseek-ai/dsh-session-query": "0.2.2-rc.3",
186
- "@deepseek-ai/dsh-session-title": "0.2.2-rc.3",
187
- "@deepseek-ai/dsh-settings": "0.2.2-rc.3",
188
- "@deepseek-ai/dsh-skill": "0.2.2-rc.3",
189
- "@deepseek-ai/dsh-storage": "0.2.2-rc.3",
190
- "@deepseek-ai/dsh-storage-domain": "0.2.2-rc.3",
191
- "@deepseek-ai/dsh-subagent": "0.2.2-rc.3",
192
- "@deepseek-ai/dsh-system-prompt": "0.2.2-rc.3",
193
- "@deepseek-ai/dsh-tool-todo": "0.2.2-rc.3",
194
- "@deepseek-ai/dsh-tools": "0.2.2-rc.3",
195
- "@deepseek-ai/dsh-typert-protocol": "0.2.2-rc.3",
196
- "@deepseek-ai/dsh-typert-registry": "0.2.2-rc.3",
197
- "@deepseek-ai/dsh-user-approval": "0.2.2-rc.3",
198
- "@deepseek-ai/dsh-util-code-language": "0.2.2-rc.3",
199
- "@deepseek-ai/dsh-util-time": "0.2.2-rc.3",
200
- "@deepseek-ai/dsh-util-workspace-path": "0.2.2-rc.3",
201
- "@deepseek-ai/dsh-working-directory": "0.2.2-rc.3",
202
- "@deepseek-ai/dsh-workspace": "0.2.2-rc.3",
178
+ "@deepseek-ai/dsh-launch-environment": "0.2.2-rc.5",
179
+ "@deepseek-ai/dsh-llm": "0.2.2-rc.5",
180
+ "@deepseek-ai/dsh-native-command": "0.2.2-rc.5",
181
+ "@deepseek-ai/dsh-ptc-runtime": "0.2.2-rc.5",
182
+ "@deepseek-ai/dsh-sandbox": "0.2.2-rc.5",
183
+ "@deepseek-ai/dsh-sandbox-policy": "0.2.2-rc.5",
184
+ "@deepseek-ai/dsh-scope": "0.2.2-rc.5",
185
+ "@deepseek-ai/dsh-session": "0.2.2-rc.5",
186
+ "@deepseek-ai/dsh-session-persistence": "0.2.2-rc.5",
187
+ "@deepseek-ai/dsh-session-projection": "0.2.2-rc.5",
188
+ "@deepseek-ai/dsh-session-query": "0.2.2-rc.5",
189
+ "@deepseek-ai/dsh-session-title": "0.2.2-rc.5",
190
+ "@deepseek-ai/dsh-settings": "0.2.2-rc.5",
191
+ "@deepseek-ai/dsh-skill": "0.2.2-rc.5",
192
+ "@deepseek-ai/dsh-storage": "0.2.2-rc.5",
193
+ "@deepseek-ai/dsh-storage-domain": "0.2.2-rc.5",
194
+ "@deepseek-ai/dsh-subagent": "0.2.2-rc.5",
195
+ "@deepseek-ai/dsh-system-prompt": "0.2.2-rc.5",
196
+ "@deepseek-ai/dsh-tool-todo": "0.2.2-rc.5",
197
+ "@deepseek-ai/dsh-tools": "0.2.2-rc.5",
198
+ "@deepseek-ai/dsh-typert-protocol": "0.2.2-rc.5",
199
+ "@deepseek-ai/dsh-typert-registry": "0.2.2-rc.5",
200
+ "@deepseek-ai/dsh-user-approval": "0.2.2-rc.5",
201
+ "@deepseek-ai/dsh-util-code-language": "0.2.2-rc.5",
202
+ "@deepseek-ai/dsh-util-time": "0.2.2-rc.5",
203
+ "@deepseek-ai/dsh-util-workspace-path": "0.2.2-rc.5",
204
+ "@deepseek-ai/dsh-working-directory": "0.2.2-rc.5",
205
+ "@deepseek-ai/dsh-workspace": "0.2.2-rc.5",
203
206
  "@deepseek-ai/schemastery": "3.19.0",
204
207
  "@playwright/test": "^1.64.1",
205
208
  "@shikijs/langs": "^4.3.1",