@vibedev-si/dsh-vibedev 0.8.1 → 0.10.0
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 +30 -0
- package/THIRD-PARTY-NOTICES.txt +1 -1
- package/client/client.account-center.js +237 -7
- package/client/client.js +18 -0
- package/lib/account/promotions.d.ts +33 -0
- package/lib/index.js +366 -63
- package/lib/llm/adapter.d.ts +19 -1
- package/lib/llm/catalog.d.ts +5 -0
- package/lib/llm/index.d.ts +6 -0
- package/lib/llm/promotions.d.ts +124 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -10,6 +10,21 @@
|
|
|
10
10
|
|
|
11
11
|
本插件由 `dsh-media` 改名而来,见下面的「从 dsh-media 升级」。
|
|
12
12
|
|
|
13
|
+
## 0.10.0 用户可见更新
|
|
14
|
+
|
|
15
|
+
支持家族分组的 VibeDev 宿主现在会按网关目录将普通和中转模型分组。配置中的 `preferredModels` 提供常用模型的初始顺序。模型目录缺少家族信息时,模型仍可正常选择。
|
|
16
|
+
|
|
17
|
+
## 0.9.0 用户可见更新
|
|
18
|
+
|
|
19
|
+
模型限时特惠接进来了:
|
|
20
|
+
|
|
21
|
+
- **模型选择器**:网关正在做的活动,其覆盖的模型旁边会显示「限时特惠」徽标。只有当前报价分组在活动范围内时才显示;读不到活动信息时静默不显示,模型列表照常可用。
|
|
22
|
+
- **模型价格页**:带徽标的模型卡片里有完整说明:活动描述、档位(前一天全模型实付满多少、次日几折)、每天可享优惠的额度、活动起止时间和每天 00:10 的更新时间。起止时间取自网关返回,活动结束后徽标自动消失。
|
|
23
|
+
- **使用记录**:享受过优惠的记录显示「限时特惠 −¥x(原价 ¥y)」。优惠金额直接用网关返回的 `promotion_discount`,实付金额用 `actual_cost`。插件不自己折算折扣,也不用「原价 − 实付」倒推——那个差额里可能还有分组倍率或其他优惠。
|
|
24
|
+
- **仪表盘**:今日和累计 Token 卡片增加缓存命中率,算法与用量图表一致:缓存读取 ÷(输入 + 缓存读取 + 缓存创建)。
|
|
25
|
+
|
|
26
|
+
折扣由网关发放,只对 VibeDev 托管密钥生效;公开 API Key 即使在同一分组也不享受。插件只负责显示,不参与计算。
|
|
27
|
+
|
|
13
28
|
## 0.8.1 用户可见更新
|
|
14
29
|
|
|
15
30
|
回复输出到一半时,网关到上游模型服务的连接断开、超时或上游临时出错(5xx、限流),现在和输出开始之前一样按退避自动重试,不再停下来显示「回复暂时中断,已收到的内容已保留。请确认后继续。」(0.6.0 到 0.8.0 会这样)。重试会把这一步从头重新生成:已经显示的半截会清掉,对话里出现一行重试提示和失败原因;这一轮里之前已经完成的步骤和工具结果都保留。所有重试都失败时,对话里显示真实的失败原因。
|
|
@@ -368,6 +383,21 @@ npm run build
|
|
|
368
383
|
|
|
369
384
|
## English
|
|
370
385
|
|
|
386
|
+
### What changes in 0.10.0
|
|
387
|
+
|
|
388
|
+
VibeDev hosts with family grouping show regular and relay models under the families advertised by the gateway catalog. The `preferredModels` setting supplies the initial order of favorites. Models without family metadata remain available in the picker.
|
|
389
|
+
|
|
390
|
+
### What changes in 0.9.0
|
|
391
|
+
|
|
392
|
+
Model promotions are now visible:
|
|
393
|
+
|
|
394
|
+
- **Model selector**: a 「限时特惠」 badge appears beside each model the gateway currently promotes. It shows only when the account's price group is in the promotion's scope, and hides silently when the promotion cannot be read, so the model list keeps working.
|
|
395
|
+
- **Model prices page**: a promoted card carries the activity description, its spending tiers, the daily discounted amount, the activity window and the daily 00:10 refresh note. The window is whatever the gateway returned, so the badge disappears by itself when the activity ends.
|
|
396
|
+
- **Usage records**: a discounted row shows 「限时特惠 −¥x(原价 ¥y)」. The amount is the gateway's own `promotion_discount`, shown beside `actual_cost`. The plugin never computes a discount and never subtracts the two costs, because that difference can also carry a group multiplier or another discount.
|
|
397
|
+
- **Dashboard**: the today and lifetime token cards carry a cache-hit rate, computed the way the usage charts compute it: cache reads over reads, writes and fresh input.
|
|
398
|
+
|
|
399
|
+
The gateway grants the discount to its managed keys only; a public API key gets none even in the same group. The plugin only displays it.
|
|
400
|
+
|
|
371
401
|
### What changes in 0.8.1
|
|
372
402
|
|
|
373
403
|
When the connection from the gateway to the upstream model service breaks, times out, or the upstream fails temporarily (5xx, rate limit) after a reply has started, the request is now retried with backoff, as it is before any output, instead of stopping with 「回复暂时中断,已收到的内容已保留。请确认后继续。」 as releases 0.6.0 to 0.8.0 did. A retry generates that step again from its beginning: the partial reply on screen is cleared and the conversation shows a retry row with the failure reason; earlier steps of the turn and their tool results stay. When every retry fails, the conversation shows the real failure reason.
|
package/THIRD-PARTY-NOTICES.txt
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
THIRD-PARTY NOTICES · @vibedev-si/dsh-vibedev 0.
|
|
1
|
+
THIRD-PARTY NOTICES · @vibedev-si/dsh-vibedev 0.10.0
|
|
2
2
|
|
|
3
3
|
This package bundles code from the projects below. Each is used under the licence that
|
|
4
4
|
follows its name; the licence texts are reproduced as the projects ship them.
|
|
@@ -322,6 +322,13 @@ window.__ModuleLoader__.load({
|
|
|
322
322
|
const priceFactFields = Object.keys(factText);
|
|
323
323
|
const facts = (index) => Object.fromEntries(Object.entries(factText).map(([key, values]) => [`priceFact_${key}`, values[index]]));
|
|
324
324
|
const priceZh = {
|
|
325
|
+
pricePromoBadge: "限时特惠",
|
|
326
|
+
pricePromoTitle: "限时特惠",
|
|
327
|
+
pricePromoTier: "{min} 及以上 → {rate}",
|
|
328
|
+
pricePromoRate: "{percent} 折",
|
|
329
|
+
pricePromoCap: "每天前 ¥{amount} 的 {model} 消费享受折扣",
|
|
330
|
+
pricePromoUpdated: "北京时间每天 00:10 更新",
|
|
331
|
+
pricePromoWindow: "活动时间 {from} – {to}",
|
|
325
332
|
...facts(0),
|
|
326
333
|
priceTitle: "模型价格",
|
|
327
334
|
priceIntro: "当前已发布目录与分组售价。仅供阅读,不是报价单或账单;最终扣费以实际用量与计费结果为准。",
|
|
@@ -458,6 +465,13 @@ window.__ModuleLoader__.load({
|
|
|
458
465
|
priceNoteImageEstimate: "约:按官方输出 Token 示例推导,仅含图片输出,不含提示词、参考图、文字/思考和工具费用。"
|
|
459
466
|
};
|
|
460
467
|
const priceEn = {
|
|
468
|
+
pricePromoBadge: "Limited-time offer",
|
|
469
|
+
pricePromoTitle: "Limited-time offer",
|
|
470
|
+
pricePromoTier: "{min} and above → {rate}",
|
|
471
|
+
pricePromoRate: "{percent}% off",
|
|
472
|
+
pricePromoCap: "The first ¥{amount} of {model} spend each day is discounted",
|
|
473
|
+
pricePromoUpdated: "Refreshed daily at 00:10 Beijing time",
|
|
474
|
+
pricePromoWindow: "Activity window {from} – {to}",
|
|
461
475
|
...facts(1),
|
|
462
476
|
priceTitle: "Model prices",
|
|
463
477
|
priceIntro: "Current published catalog and group retail prices. Not a quote or ledger; final charges follow actual usage and billing results.",
|
|
@@ -1516,6 +1530,8 @@ window.__ModuleLoader__.load({
|
|
|
1516
1530
|
//#endregion
|
|
1517
1531
|
//#region src/client/AccountCenter/center-locales.ts
|
|
1518
1532
|
const centerZh = {
|
|
1533
|
+
centerUsagePromo: "限时特惠 −{discount}(原价 {total})",
|
|
1534
|
+
centerCacheHitRate: "缓存命中率",
|
|
1519
1535
|
...commerceZh,
|
|
1520
1536
|
...memberZh,
|
|
1521
1537
|
...businessZh,
|
|
@@ -1662,6 +1678,8 @@ window.__ModuleLoader__.load({
|
|
|
1662
1678
|
centerBooleanNo: "否"
|
|
1663
1679
|
};
|
|
1664
1680
|
const centerEn = {
|
|
1681
|
+
centerUsagePromo: "Limited-time offer −{discount} (standard {total})",
|
|
1682
|
+
centerCacheHitRate: "Cache hit rate",
|
|
1665
1683
|
...commerceEn,
|
|
1666
1684
|
...memberEn,
|
|
1667
1685
|
...businessEn,
|
|
@@ -2441,6 +2459,22 @@ window.__ModuleLoader__.load({
|
|
|
2441
2459
|
return "—";
|
|
2442
2460
|
}
|
|
2443
2461
|
}
|
|
2462
|
+
/**
|
|
2463
|
+
* One usage row's promotion line, from the gateway's own discount.
|
|
2464
|
+
*
|
|
2465
|
+
* `actual_cost` is what was charged and `total_cost` the list price, but their
|
|
2466
|
+
* difference also carries group multipliers and other discounts, so it is never
|
|
2467
|
+
* used to infer this amount: `promotion_discount` is the only source.
|
|
2468
|
+
* @param row - one usage row.
|
|
2469
|
+
* @param t - the page's translate function.
|
|
2470
|
+
* @returns the sentence, or undefined when the row received no promotion.
|
|
2471
|
+
*/
|
|
2472
|
+
function promotionText(row, t) {
|
|
2473
|
+
const discount = numeric(row.promotion_discount);
|
|
2474
|
+
if (discount === void 0 || discount <= 0) return void 0;
|
|
2475
|
+
const currency = typeof row.currency === "string" && /^[A-Z]{3}$/.test(row.currency) ? row.currency : "CNY";
|
|
2476
|
+
return t("centerUsagePromo").replace("{discount}", money(discount, currency)).replace("{total}", money(row.total_cost, currency));
|
|
2477
|
+
}
|
|
2444
2478
|
function dateTime(value, t) {
|
|
2445
2479
|
if (typeof value !== "string" || !Number.isFinite(Date.parse(value))) return "—";
|
|
2446
2480
|
return new Date(value).toLocaleString(t?.("localeTag") === "en" ? "en-US" : t === void 0 ? void 0 : "zh-CN", {
|
|
@@ -3290,6 +3324,15 @@ window.__ModuleLoader__.load({
|
|
|
3290
3324
|
}
|
|
3291
3325
|
function DashboardMetrics({ stats, view, t }) {
|
|
3292
3326
|
const currency = stats.currency ?? "CNY";
|
|
3327
|
+
/**
|
|
3328
|
+
* The share of prompt tokens the provider served from its cache, using the same
|
|
3329
|
+
* arithmetic the usage charts use: reads over reads, writes and fresh input.
|
|
3330
|
+
*/
|
|
3331
|
+
const cacheRate = (prefix) => {
|
|
3332
|
+
const input = numeric(stats[`${prefix}input_tokens`]), read = numeric(stats[`${prefix}cache_read_tokens`]), created = numeric(stats[`${prefix}cache_creation_tokens`]);
|
|
3333
|
+
if (input === void 0 || read === void 0 || created === void 0 || input + read + created <= 0) return "—";
|
|
3334
|
+
return `${new Intl.NumberFormat(void 0, { maximumFractionDigits: 1 }).format(read / (input + read + created) * 100)}%`;
|
|
3335
|
+
};
|
|
3293
3336
|
const tokenRows = (prefix) => [
|
|
3294
3337
|
[t("centerInputTokens"), count(stats[`${prefix}input_tokens`])],
|
|
3295
3338
|
[t("centerOutputTokens"), count(stats[`${prefix}output_tokens`])],
|
|
@@ -3324,12 +3367,12 @@ window.__ModuleLoader__.load({
|
|
|
3324
3367
|
{
|
|
3325
3368
|
title: t("centerTodayTokens"),
|
|
3326
3369
|
value: count(stats.today_tokens),
|
|
3327
|
-
rows: tokenRows("today_").slice(0, 2)
|
|
3370
|
+
rows: [...tokenRows("today_").slice(0, 2), [t("centerCacheHitRate"), cacheRate("today_")]]
|
|
3328
3371
|
},
|
|
3329
3372
|
{
|
|
3330
3373
|
title: t("centerTotalTokens"),
|
|
3331
3374
|
value: count(stats.total_tokens),
|
|
3332
|
-
rows: tokenRows("total_").slice(0, 2)
|
|
3375
|
+
rows: [...tokenRows("total_").slice(0, 2), [t("centerCacheHitRate"), cacheRate("total_")]]
|
|
3333
3376
|
},
|
|
3334
3377
|
{
|
|
3335
3378
|
title: t("centerPerformance"),
|
|
@@ -4278,7 +4321,10 @@ window.__ModuleLoader__.load({
|
|
|
4278
4321
|
})
|
|
4279
4322
|
] })]
|
|
4280
4323
|
})] });
|
|
4281
|
-
case "cost": return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(FactList, { facts: [[t("centerActual"), amount(row.actual_cost)], [t("centerStandard"), amount(row.total_cost)]] })
|
|
4324
|
+
case "cost": return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(FactList, { facts: [[t("centerActual"), amount(row.actual_cost)], [t("centerStandard"), amount(row.total_cost)]] }), promotionText(row, t) && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
4325
|
+
className: "center-usage-promo",
|
|
4326
|
+
children: promotionText(row, t)
|
|
4327
|
+
})] });
|
|
4282
4328
|
case "latency": return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(FactList, { facts: [
|
|
4283
4329
|
[t("centerDuration"), duration(row.duration_ms)],
|
|
4284
4330
|
[t("centerFirstToken"), duration(row.first_token_ms)],
|
|
@@ -4895,6 +4941,10 @@ window.__ModuleLoader__.load({
|
|
|
4895
4941
|
[t("centerCacheWriteCost"), amount(row.cache_creation_cost)]
|
|
4896
4942
|
]
|
|
4897
4943
|
}),
|
|
4944
|
+
promotionText(row, t) && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
4945
|
+
className: "center-usage-promo",
|
|
4946
|
+
children: promotionText(row, t)
|
|
4947
|
+
}),
|
|
4898
4948
|
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("details", {
|
|
4899
4949
|
className: "center-detail-unit-prices",
|
|
4900
4950
|
children: [
|
|
@@ -5990,6 +6040,126 @@ window.__ModuleLoader__.load({
|
|
|
5990
6040
|
return `model-plaza?${params}`;
|
|
5991
6041
|
}
|
|
5992
6042
|
//#endregion
|
|
6043
|
+
//#region src/client/AccountCenter/promotion-api.ts
|
|
6044
|
+
/**
|
|
6045
|
+
* The 「限时特惠」 list the model page labels prices with, read from this plugin's
|
|
6046
|
+
* own Host route so the renderer never calls the gateway.
|
|
6047
|
+
*
|
|
6048
|
+
* The Host has already narrowed the list to the account's price group and to the
|
|
6049
|
+
* activity window the gateway stated; this module only re-validates the wire
|
|
6050
|
+
* shape, because the answer is network data the page did not construct.
|
|
6051
|
+
*
|
|
6052
|
+
* A promotion is decoration: every failure answers "no promotion", which is what
|
|
6053
|
+
* keeps prices reachable when the gateway cannot describe one.
|
|
6054
|
+
*
|
|
6055
|
+
* @module dsh-vibedev/account-center/promotion-api
|
|
6056
|
+
*/
|
|
6057
|
+
/** Where the Host serves the list. */
|
|
6058
|
+
const PROMOTIONS_ROUTE = "/api/dsh-vibedev/promotions";
|
|
6059
|
+
/** No promotions apply; shared so an unlabelled page allocates nothing. */
|
|
6060
|
+
const NO_PROMOTIONS = { items: [] };
|
|
6061
|
+
/** How long one answer stays usable in the page, matching the Host's own cache. */
|
|
6062
|
+
const CACHE_MS = 3e5;
|
|
6063
|
+
/**
|
|
6064
|
+
* The last answer, with the account it was read for: switching accounts must not
|
|
6065
|
+
* show the previous account's group labels for five minutes.
|
|
6066
|
+
*/
|
|
6067
|
+
let cached;
|
|
6068
|
+
let inflight;
|
|
6069
|
+
const record = (value) => typeof value === "object" && value !== null && !Array.isArray(value) ? value : void 0;
|
|
6070
|
+
const string = (value) => typeof value === "string" && value.trim() !== "" ? value : void 0;
|
|
6071
|
+
const amount = (value) => typeof value === "number" && Number.isFinite(value) && value >= 0 ? value : void 0;
|
|
6072
|
+
const identifier = (value) => {
|
|
6073
|
+
const parsed = amount(value);
|
|
6074
|
+
return parsed !== void 0 && Number.isInteger(parsed) && parsed > 0 ? parsed : void 0;
|
|
6075
|
+
};
|
|
6076
|
+
/**
|
|
6077
|
+
* One promotion, or undefined when it cannot be rendered safely.
|
|
6078
|
+
* @param value - one `items[]` entry.
|
|
6079
|
+
* @returns the promotion, or undefined.
|
|
6080
|
+
*/
|
|
6081
|
+
function parsePromotion(value) {
|
|
6082
|
+
const source = record(value);
|
|
6083
|
+
if (source === void 0) return void 0;
|
|
6084
|
+
const model = string(source.model);
|
|
6085
|
+
const startsAt = string(source.starts_at);
|
|
6086
|
+
const endsAt = string(source.ends_at);
|
|
6087
|
+
if (model === void 0 || startsAt === void 0 || endsAt === void 0) return void 0;
|
|
6088
|
+
if (!Number.isFinite(Date.parse(startsAt)) || !Number.isFinite(Date.parse(endsAt))) return void 0;
|
|
6089
|
+
const dailyCap = amount(source.daily_cap);
|
|
6090
|
+
const tiers = Array.isArray(source.tiers) ? source.tiers.flatMap((item) => {
|
|
6091
|
+
const tier = record(item);
|
|
6092
|
+
const prevSpendMin = tier === void 0 ? void 0 : amount(tier.prev_spend_min);
|
|
6093
|
+
const discountRate = tier === void 0 ? void 0 : amount(tier.discount_rate);
|
|
6094
|
+
return prevSpendMin === void 0 || discountRate === void 0 || discountRate <= 0 ? [] : [{
|
|
6095
|
+
prevSpendMin,
|
|
6096
|
+
discountRate
|
|
6097
|
+
}];
|
|
6098
|
+
}) : [];
|
|
6099
|
+
return {
|
|
6100
|
+
model,
|
|
6101
|
+
badge: string(source.badge) ?? "限时特惠",
|
|
6102
|
+
description: string(source.description) ?? "",
|
|
6103
|
+
...dailyCap === void 0 || dailyCap === 0 ? {} : { dailyCap },
|
|
6104
|
+
startsAt,
|
|
6105
|
+
endsAt,
|
|
6106
|
+
tiers: tiers.sort((left, right) => left.prevSpendMin - right.prevSpendMin)
|
|
6107
|
+
};
|
|
6108
|
+
}
|
|
6109
|
+
/**
|
|
6110
|
+
* The whole answer, or none when it is not shaped like one.
|
|
6111
|
+
* @param value - the response body of the Host route.
|
|
6112
|
+
* @returns the listing, or undefined.
|
|
6113
|
+
*/
|
|
6114
|
+
function parsePromotionListing(value) {
|
|
6115
|
+
const body = record(value);
|
|
6116
|
+
const data = record(body?.data);
|
|
6117
|
+
const items = data?.items;
|
|
6118
|
+
if (!Array.isArray(items)) return void 0;
|
|
6119
|
+
const groupId = identifier(data?.group_id);
|
|
6120
|
+
return {
|
|
6121
|
+
...groupId === void 0 ? {} : { groupId },
|
|
6122
|
+
items: items.flatMap((item) => {
|
|
6123
|
+
const parsed = parsePromotion(item);
|
|
6124
|
+
return parsed === void 0 ? [] : [parsed];
|
|
6125
|
+
})
|
|
6126
|
+
};
|
|
6127
|
+
}
|
|
6128
|
+
/**
|
|
6129
|
+
* Read the promotions, from a five-minute cache when one is fresh for this account.
|
|
6130
|
+
* @param options - fetch implementation, clock and the account the page shows, for tests.
|
|
6131
|
+
* @returns the listing, or none when the read fails.
|
|
6132
|
+
*/
|
|
6133
|
+
async function readPromotions(options = {}) {
|
|
6134
|
+
const now = options.now ?? Date.now;
|
|
6135
|
+
const identity = options.identity ?? "";
|
|
6136
|
+
if (cached !== void 0 && cached.identity === identity && now() - cached.at < CACHE_MS) return cached.value;
|
|
6137
|
+
if (inflight !== void 0 && inflight.identity === identity) return inflight.read;
|
|
6138
|
+
const read = (async () => {
|
|
6139
|
+
try {
|
|
6140
|
+
const response = await (options.fetch ?? fetch)(PROMOTIONS_ROUTE, { headers: { accept: "application/json" } });
|
|
6141
|
+
if (!response.ok) return NO_PROMOTIONS;
|
|
6142
|
+
return parsePromotionListing(await response.json()) ?? NO_PROMOTIONS;
|
|
6143
|
+
} catch {
|
|
6144
|
+
return NO_PROMOTIONS;
|
|
6145
|
+
}
|
|
6146
|
+
})().then((value) => {
|
|
6147
|
+
cached = {
|
|
6148
|
+
at: now(),
|
|
6149
|
+
identity,
|
|
6150
|
+
value
|
|
6151
|
+
};
|
|
6152
|
+
return value;
|
|
6153
|
+
}).finally(() => {
|
|
6154
|
+
if (inflight?.identity === identity) inflight = void 0;
|
|
6155
|
+
});
|
|
6156
|
+
inflight = {
|
|
6157
|
+
identity,
|
|
6158
|
+
read
|
|
6159
|
+
};
|
|
6160
|
+
return read;
|
|
6161
|
+
}
|
|
6162
|
+
//#endregion
|
|
5993
6163
|
//#region src/client/AccountCenter/ModelPrices.tsx
|
|
5994
6164
|
const p = (t, key) => t(key);
|
|
5995
6165
|
const message = (value, t) => {
|
|
@@ -6469,7 +6639,48 @@ window.__ModuleLoader__.load({
|
|
|
6469
6639
|
})]
|
|
6470
6640
|
});
|
|
6471
6641
|
}
|
|
6472
|
-
|
|
6642
|
+
/**
|
|
6643
|
+
* The label a card may carry: only the promotion whose model id matches exactly,
|
|
6644
|
+
* and only while the page shows the group the account's promotions were read for.
|
|
6645
|
+
* Browsing another group's prices never carries this group's label along.
|
|
6646
|
+
*/
|
|
6647
|
+
function promotionOf(model, response, promotions) {
|
|
6648
|
+
if (promotions === void 0 || promotions.groupId === void 0) return void 0;
|
|
6649
|
+
if (Number(response.price_context.group_id) !== promotions.groupId) return void 0;
|
|
6650
|
+
return promotions.items.find((item) => item.model === model.id);
|
|
6651
|
+
}
|
|
6652
|
+
/** What the activity gives, stated as the gateway stated it: description, tiers, daily cap, window. */
|
|
6653
|
+
function PromotionDetails({ promotion, model, t }) {
|
|
6654
|
+
const english = t("localeTag") === "en";
|
|
6655
|
+
const rate = (value) => p(t, "pricePromoRate").replace("{percent}", String(english ? Math.round((1 - value) * 1e3) / 10 : Math.round(value * 100) / 10));
|
|
6656
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("section", {
|
|
6657
|
+
className: "center-price-detail-block center-price-promotion",
|
|
6658
|
+
children: [
|
|
6659
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("h4", { children: p(t, "pricePromoTitle") }),
|
|
6660
|
+
promotion.description !== "" && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
6661
|
+
className: "center-price-description",
|
|
6662
|
+
children: promotion.description
|
|
6663
|
+
}),
|
|
6664
|
+
promotion.tiers.length > 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("ul", {
|
|
6665
|
+
className: "center-price-promo-tiers",
|
|
6666
|
+
children: promotion.tiers.map((tier) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("li", { children: p(t, "pricePromoTier").replace("{min}", `¥${priceAmount(tier.prevSpendMin)}`).replace("{rate}", rate(tier.discountRate)) }, tier.prevSpendMin))
|
|
6667
|
+
}),
|
|
6668
|
+
promotion.dailyCap !== void 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
6669
|
+
className: "center-muted",
|
|
6670
|
+
children: p(t, "pricePromoCap").replace("{amount}", priceAmount(promotion.dailyCap)).replace("{model}", model.name || model.id)
|
|
6671
|
+
}),
|
|
6672
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
6673
|
+
className: "center-muted",
|
|
6674
|
+
children: p(t, "pricePromoWindow").replace("{from}", dateTime(promotion.startsAt, t)).replace("{to}", dateTime(promotion.endsAt, t))
|
|
6675
|
+
}),
|
|
6676
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
6677
|
+
className: "center-muted",
|
|
6678
|
+
children: p(t, "pricePromoUpdated")
|
|
6679
|
+
})
|
|
6680
|
+
]
|
|
6681
|
+
});
|
|
6682
|
+
}
|
|
6683
|
+
function ModelPriceCard({ model, context, promotion, t }) {
|
|
6473
6684
|
const [scenario, setScenario] = (0, react.useState)(() => ({
|
|
6474
6685
|
...defaultScenario(),
|
|
6475
6686
|
resolution: (model.kind === "image" ? model.capabilities.image_sizes?.[0] : model.capabilities.video?.resolutions?.[0]) ?? defaultScenario().resolution,
|
|
@@ -6492,7 +6703,10 @@ window.__ModuleLoader__.load({
|
|
|
6492
6703
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
6493
6704
|
className: "center-price-model",
|
|
6494
6705
|
children: [
|
|
6495
|
-
/* @__PURE__ */ (0, react_jsx_runtime.
|
|
6706
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("h3", { children: [model.name || model.id, promotion && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
6707
|
+
className: "center-price-tag center-price-promo-badge",
|
|
6708
|
+
children: promotion.badge || p(t, "pricePromoBadge")
|
|
6709
|
+
})] }),
|
|
6496
6710
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("code", { children: model.id }),
|
|
6497
6711
|
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
6498
6712
|
className: "center-price-tags",
|
|
@@ -6584,6 +6798,11 @@ window.__ModuleLoader__.load({
|
|
|
6584
6798
|
})
|
|
6585
6799
|
]
|
|
6586
6800
|
}),
|
|
6801
|
+
promotion && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(PromotionDetails, {
|
|
6802
|
+
promotion,
|
|
6803
|
+
model,
|
|
6804
|
+
t
|
|
6805
|
+
}),
|
|
6587
6806
|
model.description && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("section", {
|
|
6588
6807
|
className: "center-price-detail-block",
|
|
6589
6808
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("h4", { children: p(t, "priceModelDescription") }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
@@ -6601,7 +6820,7 @@ window.__ModuleLoader__.load({
|
|
|
6601
6820
|
]
|
|
6602
6821
|
});
|
|
6603
6822
|
}
|
|
6604
|
-
function PriceCatalog({ response, filters, onChange, t }) {
|
|
6823
|
+
function PriceCatalog({ response, filters, promotions, onChange, t }) {
|
|
6605
6824
|
const pagination = response?.pagination, pages = pagination ? Math.max(1, Math.ceil(pagination.total / Math.max(1, pagination.page_size))) : 1;
|
|
6606
6825
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
6607
6826
|
className: "center-price-catalog",
|
|
@@ -6699,6 +6918,7 @@ window.__ModuleLoader__.load({
|
|
|
6699
6918
|
children: [response.models.map((model) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ModelPriceCard, {
|
|
6700
6919
|
model,
|
|
6701
6920
|
context: response.reference_context,
|
|
6921
|
+
promotion: promotionOf(model, response, promotions),
|
|
6702
6922
|
t
|
|
6703
6923
|
}, `${response.price_context.group_id}:${model.id}`)), response.models.length === 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
6704
6924
|
className: "center-muted center-price-empty",
|
|
@@ -6747,7 +6967,16 @@ window.__ModuleLoader__.load({
|
|
|
6747
6967
|
search: ""
|
|
6748
6968
|
};
|
|
6749
6969
|
function ModelPrices({ identity, refresh, t }) {
|
|
6750
|
-
const [filters, setFilters] = (0, react.useState)(initialFilters), [search, setSearch] = (0, react.useState)("");
|
|
6970
|
+
const [filters, setFilters] = (0, react.useState)(initialFilters), [search, setSearch] = (0, react.useState)(""), [promotions, setPromotions] = (0, react.useState)(void 0);
|
|
6971
|
+
(0, react.useEffect)(() => {
|
|
6972
|
+
let live = true;
|
|
6973
|
+
readPromotions({ identity }).then((value) => {
|
|
6974
|
+
if (live) setPromotions(value);
|
|
6975
|
+
});
|
|
6976
|
+
return () => {
|
|
6977
|
+
live = false;
|
|
6978
|
+
};
|
|
6979
|
+
}, [identity]);
|
|
6751
6980
|
(0, react.useEffect)(() => {
|
|
6752
6981
|
const timer = setTimeout(() => setSearch(filters.search), 250);
|
|
6753
6982
|
return () => clearTimeout(timer);
|
|
@@ -6777,6 +7006,7 @@ window.__ModuleLoader__.load({
|
|
|
6777
7006
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(PriceCatalog, {
|
|
6778
7007
|
response: data,
|
|
6779
7008
|
filters,
|
|
7009
|
+
promotions,
|
|
6780
7010
|
onChange: (patch) => setFilters((current) => ({
|
|
6781
7011
|
...current,
|
|
6782
7012
|
...patch
|
package/client/client.js
CHANGED
|
@@ -1220,6 +1220,13 @@ window.__ModuleLoader__.load({ id: "@vibedev-si/dsh-vibedev", factory: (require)
|
|
|
1220
1220
|
Object.keys(factText);
|
|
1221
1221
|
const facts = (index) => Object.fromEntries(Object.entries(factText).map(([key, values]) => [`priceFact_${key}`, values[index]]));
|
|
1222
1222
|
const priceZh = {
|
|
1223
|
+
pricePromoBadge: "限时特惠",
|
|
1224
|
+
pricePromoTitle: "限时特惠",
|
|
1225
|
+
pricePromoTier: "{min} 及以上 → {rate}",
|
|
1226
|
+
pricePromoRate: "{percent} 折",
|
|
1227
|
+
pricePromoCap: "每天前 ¥{amount} 的 {model} 消费享受折扣",
|
|
1228
|
+
pricePromoUpdated: "北京时间每天 00:10 更新",
|
|
1229
|
+
pricePromoWindow: "活动时间 {from} – {to}",
|
|
1223
1230
|
...facts(0),
|
|
1224
1231
|
priceTitle: "模型价格",
|
|
1225
1232
|
priceIntro: "当前已发布目录与分组售价。仅供阅读,不是报价单或账单;最终扣费以实际用量与计费结果为准。",
|
|
@@ -1356,6 +1363,13 @@ window.__ModuleLoader__.load({ id: "@vibedev-si/dsh-vibedev", factory: (require)
|
|
|
1356
1363
|
priceNoteImageEstimate: "约:按官方输出 Token 示例推导,仅含图片输出,不含提示词、参考图、文字/思考和工具费用。"
|
|
1357
1364
|
};
|
|
1358
1365
|
const priceEn = {
|
|
1366
|
+
pricePromoBadge: "Limited-time offer",
|
|
1367
|
+
pricePromoTitle: "Limited-time offer",
|
|
1368
|
+
pricePromoTier: "{min} and above → {rate}",
|
|
1369
|
+
pricePromoRate: "{percent}% off",
|
|
1370
|
+
pricePromoCap: "The first ¥{amount} of {model} spend each day is discounted",
|
|
1371
|
+
pricePromoUpdated: "Refreshed daily at 00:10 Beijing time",
|
|
1372
|
+
pricePromoWindow: "Activity window {from} – {to}",
|
|
1359
1373
|
...facts(1),
|
|
1360
1374
|
priceTitle: "Model prices",
|
|
1361
1375
|
priceIntro: "Current published catalog and group retail prices. Not a quote or ledger; final charges follow actual usage and billing results.",
|
|
@@ -2400,6 +2414,8 @@ window.__ModuleLoader__.load({ id: "@vibedev-si/dsh-vibedev", factory: (require)
|
|
|
2400
2414
|
//#endregion
|
|
2401
2415
|
//#region src/client/AccountCenter/center-locales.ts
|
|
2402
2416
|
const centerZh = {
|
|
2417
|
+
centerUsagePromo: "限时特惠 −{discount}(原价 {total})",
|
|
2418
|
+
centerCacheHitRate: "缓存命中率",
|
|
2403
2419
|
...commerceZh,
|
|
2404
2420
|
...memberZh,
|
|
2405
2421
|
...businessZh,
|
|
@@ -2546,6 +2562,8 @@ window.__ModuleLoader__.load({ id: "@vibedev-si/dsh-vibedev", factory: (require)
|
|
|
2546
2562
|
centerBooleanNo: "否"
|
|
2547
2563
|
};
|
|
2548
2564
|
const centerEn = {
|
|
2565
|
+
centerUsagePromo: "Limited-time offer −{discount} (standard {total})",
|
|
2566
|
+
centerCacheHitRate: "Cache hit rate",
|
|
2549
2567
|
...commerceEn,
|
|
2550
2568
|
...memberEn,
|
|
2551
2569
|
...businessEn,
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The model page's 「限时特惠」 labels, read from the gateway by the Host so the
|
|
3
|
+
* renderer never talks to the gateway itself.
|
|
4
|
+
*
|
|
5
|
+
* - `GET /api/dsh-vibedev/promotions` — the promotions the account's own price
|
|
6
|
+
* group runs right now, already narrowed by the group and by the activity
|
|
7
|
+
* window the gateway stated. The page additionally keeps only the entries that
|
|
8
|
+
* name the group it is showing, so browsing another group's prices never
|
|
9
|
+
* carries this group's label along.
|
|
10
|
+
*
|
|
11
|
+
* The answer is always `200`: a promotion is decoration, and a gateway that
|
|
12
|
+
* cannot describe one must not stop a page from showing prices. It is never
|
|
13
|
+
* cached, because the page reads it once per open and the five-minute cache
|
|
14
|
+
* lives in {@link PromotionService}.
|
|
15
|
+
*
|
|
16
|
+
* @module dsh-vibedev/account/promotions
|
|
17
|
+
*/
|
|
18
|
+
import type { ConnectionFetchRoute } from '@deepseek-ai/dsh-client-connection';
|
|
19
|
+
import type { ActivePromotion, PromotionService } from '../llm/promotions.js';
|
|
20
|
+
/** The Host route the model page reads. */
|
|
21
|
+
export declare const PROMOTIONS_ROUTE = "/api/dsh-vibedev/promotions";
|
|
22
|
+
/** One answer of the route. */
|
|
23
|
+
export interface PromotionListing {
|
|
24
|
+
/** The account's price group, so a page can keep the labels on that group's prices only. */
|
|
25
|
+
readonly group_id?: number;
|
|
26
|
+
readonly items: readonly ActivePromotion[];
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* The Host routes that serve promotion labels to the account pages.
|
|
30
|
+
* @param promotions - the shared service the model list labels from too.
|
|
31
|
+
* @returns the routes to register on the connection.
|
|
32
|
+
*/
|
|
33
|
+
export declare function promotionRoutes(promotions: PromotionService): ConnectionFetchRoute[];
|