magpie-multi-usage 0.1.2 → 0.3.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 +3 -1
- package/README.zh-CN.md +3 -1
- package/package.json +1 -1
- package/src/aggregator.mjs +271 -2
- package/src/github-store.mjs +1 -1
- package/src/http-server.mjs +21 -1
- package/src/sync-engine.mjs +26 -5
- package/src/ui/app.css +54 -4
- package/src/ui/app.js +277 -43
- package/src/ui/dashboard-state.mjs +131 -0
- package/src/ui/icons/azure-color.svg +1 -0
- package/src/ui/icons/bedrock-color.svg +1 -0
- package/src/ui/icons/claude-color.svg +1 -0
- package/src/ui/icons/deepseek-color.svg +1 -0
- package/src/ui/icons/gemini-color.svg +1 -0
- package/src/ui/icons/groq.svg +1 -0
- package/src/ui/icons/kimi.svg +1 -0
- package/src/ui/icons/mimocode.svg +1 -0
- package/src/ui/icons/minimax-color.svg +1 -0
- package/src/ui/icons/mistral-color.svg +1 -0
- package/src/ui/icons/openai.svg +1 -0
- package/src/ui/icons/openrouter.svg +1 -0
- package/src/ui/icons/qwen-color.svg +1 -0
- package/src/ui/icons/stepfun.svg +1 -0
- package/src/ui/icons/xai.svg +1 -0
- package/src/ui/icons/zhipu-color.svg +1 -0
- package/src/ui/index.html +2 -1
- package/src/ui/view-model.mjs +247 -3
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg height="1em" style="flex:none;line-height:1" viewBox="0 0 24 24" width="1em" xmlns="http://www.w3.org/2000/svg"><title>Minimax</title><defs><linearGradient id="lobe-icons-minimax-_R_0_" x1="0%" x2="100.182%" y1="50.057%" y2="50.057%"><stop offset="0%" stop-color="#E2167E"></stop><stop offset="100%" stop-color="#FE603C"></stop></linearGradient></defs><path d="M16.278 2c1.156 0 2.093.927 2.093 2.07v12.501a.74.74 0 00.744.709.74.74 0 00.743-.709V9.099a2.06 2.06 0 012.071-2.049A2.06 2.06 0 0124 9.1v6.561a.649.649 0 01-.652.645.649.649 0 01-.653-.645V9.1a.762.762 0 00-.766-.758.762.762 0 00-.766.758v7.472a2.037 2.037 0 01-2.048 2.026 2.037 2.037 0 01-2.048-2.026v-12.5a.785.785 0 00-.788-.753.785.785 0 00-.789.752l-.001 15.904A2.037 2.037 0 0113.441 22a2.037 2.037 0 01-2.048-2.026V18.04c0-.356.292-.645.652-.645.36 0 .652.289.652.645v1.934c0 .263.142.506.372.638.23.131.514.131.744 0a.734.734 0 00.372-.638V4.07c0-1.143.937-2.07 2.093-2.07zm-5.674 0c1.156 0 2.093.927 2.093 2.07v11.523a.648.648 0 01-.652.645.648.648 0 01-.652-.645V4.07a.785.785 0 00-.789-.78.785.785 0 00-.789.78v14.013a2.06 2.06 0 01-2.07 2.048 2.06 2.06 0 01-2.071-2.048V9.1a.762.762 0 00-.766-.758.762.762 0 00-.766.758v3.8a2.06 2.06 0 01-2.071 2.049A2.06 2.06 0 010 12.9v-1.378c0-.357.292-.646.652-.646.36 0 .653.29.653.646V12.9c0 .418.343.757.766.757s.766-.339.766-.757V9.099a2.06 2.06 0 012.07-2.048 2.06 2.06 0 012.071 2.048v8.984c0 .419.343.758.767.758.423 0 .766-.339.766-.758V4.07c0-1.143.937-2.07 2.093-2.07z" fill="url(#lobe-icons-minimax-_R_0_)" fill-rule="nonzero"></path></svg>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg height="1em" style="flex:none;line-height:1" viewBox="0 0 24 24" width="1em" xmlns="http://www.w3.org/2000/svg"><title>Mistral</title><path d="M3.428 3.4h3.429v3.428H3.428V3.4zm13.714 0h3.43v3.428h-3.43V3.4z" fill="gold"></path><path d="M3.428 6.828h6.857v3.429H3.429V6.828zm10.286 0h6.857v3.429h-6.857V6.828z" fill="#FFAF00"></path><path d="M3.428 10.258h17.144v3.428H3.428v-3.428z" fill="#FF8205"></path><path d="M3.428 13.686h3.429v3.428H3.428v-3.428zm6.858 0h3.429v3.428h-3.429v-3.428zm6.856 0h3.43v3.428h-3.43v-3.428z" fill="#FA500F"></path><path d="M0 17.114h10.286v3.429H0v-3.429zm13.714 0H24v3.429H13.714v-3.429z" fill="#E10500"></path></svg>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg fill="currentColor" fill-rule="evenodd" height="1em" style="flex:none;line-height:1" viewBox="0 0 24 24" width="1em" xmlns="http://www.w3.org/2000/svg"><title>OpenAI</title><path d="M9.205 8.658v-2.26c0-.19.072-.333.238-.428l4.543-2.616c.619-.357 1.356-.523 2.117-.523 2.854 0 4.662 2.212 4.662 4.566 0 .167 0 .357-.024.547l-4.71-2.759a.797.797 0 00-.856 0l-5.97 3.473zm10.609 8.8V12.06c0-.333-.143-.57-.429-.737l-5.97-3.473 1.95-1.118a.433.433 0 01.476 0l4.543 2.617c1.309.76 2.189 2.378 2.189 3.948 0 1.808-1.07 3.473-2.76 4.163zM7.802 12.703l-1.95-1.142c-.167-.095-.239-.238-.239-.428V5.899c0-2.545 1.95-4.472 4.591-4.472 1 0 1.927.333 2.712.928L8.23 5.067c-.285.166-.428.404-.428.737v6.898zM12 15.128l-2.795-1.57v-3.33L12 8.658l2.795 1.57v3.33L12 15.128zm1.796 7.23c-1 0-1.927-.332-2.712-.927l4.686-2.712c.285-.166.428-.404.428-.737v-6.898l1.974 1.142c.167.095.238.238.238.428v5.233c0 2.545-1.974 4.472-4.614 4.472zm-5.637-5.303l-4.544-2.617c-1.308-.761-2.188-2.378-2.188-3.948A4.482 4.482 0 014.21 6.327v5.423c0 .333.143.571.428.738l5.947 3.449-1.95 1.118a.432.432 0 01-.476 0zm-.262 3.9c-2.688 0-4.662-2.021-4.662-4.519 0-.19.024-.38.047-.57l4.686 2.71c.286.167.571.167.856 0l5.97-3.448v2.26c0 .19-.07.333-.237.428l-4.543 2.616c-.619.357-1.356.523-2.117.523zm5.899 2.83a5.947 5.947 0 005.827-4.756C22.287 18.339 24 15.84 24 13.296c0-1.665-.713-3.282-1.998-4.448.119-.5.19-.999.19-1.498 0-3.401-2.759-5.947-5.946-5.947-.642 0-1.26.095-1.88.31A5.962 5.962 0 0010.205 0a5.947 5.947 0 00-5.827 4.757C1.713 5.447 0 7.945 0 10.49c0 1.666.713 3.283 1.998 4.448-.119.5-.19 1-.19 1.499 0 3.401 2.759 5.946 5.946 5.946.642 0 1.26-.095 1.88-.309a5.96 5.96 0 004.162 1.713z"></path></svg>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg fill="currentColor" fill-rule="evenodd" height="1em" style="flex:none;line-height:1" viewBox="0 0 24 24" width="1em" xmlns="http://www.w3.org/2000/svg"><title>OpenRouter</title><path d="M18.654 3.87a5.087 5.087 0 110 10.174L23.7 19.09c.64.641.187 1.737-.72 1.737H8.48a8.479 8.479 0 010-16.958h10.175zM8.479 7.26a5.087 5.087 0 100 10.176 5.087 5.087 0 000-10.175z"></path></svg>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg height="1em" style="flex:none;line-height:1" viewBox="0 0 24 24" width="1em" xmlns="http://www.w3.org/2000/svg"><title>Qwen</title><path d="M12.604 1.34c.393.69.784 1.382 1.174 2.075a.18.18 0 00.157.091h5.552c.174 0 .322.11.446.327l1.454 2.57c.19.337.24.478.024.837-.26.43-.513.864-.76 1.3l-.367.658c-.106.196-.223.28-.04.512l2.652 4.637c.172.301.111.494-.043.77-.437.785-.882 1.564-1.335 2.34-.159.272-.352.375-.68.37-.777-.016-1.552-.01-2.327.016a.099.099 0 00-.081.05 575.097 575.097 0 01-2.705 4.74c-.169.293-.38.363-.725.364-.997.003-2.002.004-3.017.002a.537.537 0 01-.465-.271l-1.335-2.323a.09.09 0 00-.083-.049H4.982c-.285.03-.553-.001-.805-.092l-1.603-2.77a.543.543 0 01-.002-.54l1.207-2.12a.198.198 0 000-.197 550.951 550.951 0 01-1.875-3.272l-.79-1.395c-.16-.31-.173-.496.095-.965.465-.813.927-1.625 1.387-2.436.132-.234.304-.334.584-.335a338.3 338.3 0 012.589-.001.124.124 0 00.107-.063l2.806-4.895a.488.488 0 01.422-.246c.524-.001 1.053 0 1.583-.006L11.704 1c.341-.003.724.032.9.34zm-3.432.403a.06.06 0 00-.052.03L6.254 6.788a.157.157 0 01-.135.078H3.253c-.056 0-.07.025-.041.074l5.81 10.156c.025.042.013.062-.034.063l-2.795.015a.218.218 0 00-.2.116l-1.32 2.31c-.044.078-.021.118.068.118l5.716.008c.046 0 .08.02.104.061l1.403 2.454c.046.081.092.082.139 0l5.006-8.76.783-1.382a.055.055 0 01.096 0l1.424 2.53a.122.122 0 00.107.062l2.763-.02a.04.04 0 00.035-.02.041.041 0 000-.04l-2.9-5.086a.108.108 0 010-.113l.293-.507 1.12-1.977c.024-.041.012-.062-.035-.062H9.2c-.059 0-.073-.026-.043-.077l1.434-2.505a.107.107 0 000-.114L9.225 1.774a.06.06 0 00-.053-.031zm6.29 8.02c.046 0 .058.02.034.06l-.832 1.465-2.613 4.585a.056.056 0 01-.05.029.058.058 0 01-.05-.029L8.498 9.841c-.02-.034-.01-.052.028-.054l.216-.012 6.722-.012z" fill="url(#lobe-icons-qwen-_R_0_)" fill-rule="nonzero"></path><defs><linearGradient id="lobe-icons-qwen-_R_0_" x1="0%" x2="100%" y1="0%" y2="0%"><stop offset="0%" stop-color="#6336E7" stop-opacity=".84"></stop><stop offset="100%" stop-color="#6F69F7" stop-opacity=".84"></stop></linearGradient></defs></svg>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg fill="currentColor" fill-rule="evenodd" height="1em" style="flex:none;line-height:1" viewBox="0 0 24 24" width="1em" xmlns="http://www.w3.org/2000/svg"><title>StepFun</title><path d="M12 0C5.372 0 0 5.372 0 12s5.372 12 12 12 12-5.372 12-12S18.628 0 12 0zM8.762 19.614H4.376v-4.386h4.386v4.386zm5.423 0H9.798v-4.386h4.387v4.386zm0-5.42H9.798V9.81h4.387v4.386zm0-5.418H9.798V4.39h4.387v4.386zm5.422-.004h-4.386V4.386h4.386v4.386z"></path></svg>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg fill="currentColor" fill-rule="evenodd" height="1em" style="flex:none;line-height:1" viewBox="0 0 24 24" width="1em" xmlns="http://www.w3.org/2000/svg"><title>Grok</title><path d="M6.469 8.776L16.512 23h-4.464L2.005 8.776H6.47zm-.004 7.9l2.233 3.164L6.467 23H2l4.465-6.324zM22 2.582V23h-3.659V7.764L22 2.582zM22 1l-9.952 14.095-2.233-3.163L17.533 1H22z"></path></svg>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg height="1em" style="flex:none;line-height:1" viewBox="0 0 24 24" width="1em" xmlns="http://www.w3.org/2000/svg"><title>Zhipu</title><path d="M11.991 23.503a.24.24 0 00-.244.248.24.24 0 00.244.249.24.24 0 00.245-.249.24.24 0 00-.22-.247l-.025-.001zM9.671 5.365a1.697 1.697 0 011.099 2.132l-.071.172-.016.04-.018.054c-.07.16-.104.32-.104.498-.035.71.47 1.279 1.186 1.314h.366c1.309.053 2.338 1.173 2.286 2.523-.052 1.332-1.152 2.38-2.478 2.327h-.174c-.715.018-1.274.64-1.239 1.368 0 .124.018.23.053.337.209.373.54.658.96.8.75.23 1.517-.125 1.9-.782l.018-.035c.402-.64 1.17-.96 1.92-.711.854.284 1.378 1.226 1.099 2.167a1.661 1.661 0 01-2.077 1.102 1.711 1.711 0 01-.907-.711l-.017-.035c-.2-.323-.463-.58-.851-.711l-.056-.018a1.646 1.646 0 00-1.954.746 1.66 1.66 0 01-1.065.764 1.677 1.677 0 01-1.989-1.279c-.209-.906.332-1.83 1.257-2.043a1.51 1.51 0 01.296-.035h.018c.68-.071 1.151-.622 1.116-1.333a1.307 1.307 0 00-.227-.693 2.515 2.515 0 01-.366-1.403 2.39 2.39 0 01.366-1.208c.14-.195.21-.444.227-.693.018-.71-.506-1.261-1.186-1.332l-.07-.018a1.43 1.43 0 01-.299-.07l-.05-.019a1.7 1.7 0 01-1.047-2.114 1.68 1.68 0 012.094-1.101zm-5.575 10.11c.26-.264.639-.367.994-.27.355.096.633.379.728.74.095.362-.007.748-.267 1.013-.402.41-1.053.41-1.455 0a1.062 1.062 0 010-1.482zm14.845-.294c.359-.09.738.024.992.297.254.274.344.665.237 1.025-.107.36-.396.634-.756.718-.551.128-1.1-.22-1.23-.781a1.05 1.05 0 01.757-1.26zm-.064-4.39c.314.32.49.753.49 1.206 0 .452-.176.886-.49 1.206-.315.32-.74.5-1.185.5-.444 0-.87-.18-1.184-.5a1.727 1.727 0 010-2.412 1.654 1.654 0 012.369 0zm-11.243.163c.364.484.447 1.128.218 1.691a1.665 1.665 0 01-2.188.923c-.855-.36-1.26-1.358-.907-2.228a1.68 1.68 0 011.33-1.038c.593-.08 1.183.169 1.547.652zm11.545-4.221c.368 0 .708.2.892.524.184.324.184.724 0 1.048a1.026 1.026 0 01-.892.524c-.568 0-1.03-.47-1.03-1.048 0-.579.462-1.048 1.03-1.048zm-14.358 0c.368 0 .707.2.891.524.184.324.184.724 0 1.048a1.026 1.026 0 01-.891.524c-.569 0-1.03-.47-1.03-1.048 0-.579.461-1.048 1.03-1.048zm10.031-1.475c.925 0 1.675.764 1.675 1.706s-.75 1.705-1.675 1.705-1.674-.763-1.674-1.705c0-.942.75-1.706 1.674-1.706zm-2.626-.684c.362-.082.653-.356.761-.718a1.062 1.062 0 00-.238-1.028 1.017 1.017 0 00-.996-.294c-.547.14-.881.7-.752 1.257.13.558.675.907 1.225.783zm0 16.876c.359-.087.644-.36.75-.72a1.062 1.062 0 00-.237-1.019 1.018 1.018 0 00-.985-.301 1.037 1.037 0 00-.762.717c-.108.361-.017.754.239 1.028.245.263.606.377.953.305l.043-.01zM17.19 3.5a.631.631 0 00.628-.64c0-.355-.279-.64-.628-.64a.631.631 0 00-.628.64c0 .355.28.64.628.64zm-10.38 0a.631.631 0 00.628-.64c0-.355-.28-.64-.628-.64a.631.631 0 00-.628.64c0 .355.279.64.628.64zm-5.182 7.852a.631.631 0 00-.628.64c0 .354.28.639.628.639a.63.63 0 00.627-.606l.001-.034a.62.62 0 00-.628-.64zm5.182 9.13a.631.631 0 00-.628.64c0 .355.279.64.628.64a.631.631 0 00.628-.64c0-.355-.28-.64-.628-.64zm10.38.018a.631.631 0 00-.628.64c0 .355.28.64.628.64a.631.631 0 00.628-.64c0-.355-.279-.64-.628-.64zm5.182-9.148a.631.631 0 00-.628.64c0 .354.279.639.628.639a.631.631 0 00.628-.64c0-.355-.28-.64-.628-.64zm-.384-4.992a.24.24 0 00.244-.249.24.24 0 00-.244-.249.24.24 0 00-.244.249c0 .142.122.249.244.249zM11.991.497a.24.24 0 00.245-.248A.24.24 0 0011.99 0a.24.24 0 00-.244.249c0 .133.108.236.223.247l.021.001zM2.011 6.36a.24.24 0 00.245-.249.24.24 0 00-.244-.249.24.24 0 00-.244.249.24.24 0 00.244.249zm0 11.263a.24.24 0 00-.243.248.24.24 0 00.244.249.24.24 0 00.244-.249.252.252 0 00-.244-.248zm19.995-.018a.24.24 0 00-.245.248.24.24 0 00.245.25.24.24 0 00.244-.25.252.252 0 00-.244-.248z" fill="#3859FF" fill-rule="nonzero"></path></svg>
|
package/src/ui/index.html
CHANGED
|
@@ -36,11 +36,12 @@
|
|
|
36
36
|
|
|
37
37
|
<section id="kpi-strip" class="stats" aria-label="Usage overview"></section>
|
|
38
38
|
|
|
39
|
-
<section class="chart" aria-label="
|
|
39
|
+
<section id="trend-section" class="chart" aria-label="Token activity">
|
|
40
40
|
<div class="chart-top">
|
|
41
41
|
<span id="trend-readout" class="chart-readout"></span>
|
|
42
42
|
<span id="trend-peak" class="peak"></span>
|
|
43
43
|
</div>
|
|
44
|
+
<span id="trend-keyboard-hint" class="sr-only"></span>
|
|
44
45
|
<div id="trend-container"></div>
|
|
45
46
|
</section>
|
|
46
47
|
|
package/src/ui/view-model.mjs
CHANGED
|
@@ -56,9 +56,19 @@ export const MESSAGES = Object.freeze({
|
|
|
56
56
|
statusStale: "Cached",
|
|
57
57
|
statusError: "Error",
|
|
58
58
|
statusEmpty: "No data",
|
|
59
|
-
trendHeading: "
|
|
59
|
+
trendHeading: "Token activity",
|
|
60
60
|
trendHint: "Hover a bar for details · light prompt/cache, solid output",
|
|
61
61
|
trendEmpty: "No usage recorded in the selected range.",
|
|
62
|
+
trendUnavailable: "Chart unavailable: no verified data for this selection.",
|
|
63
|
+
trendNoHourly: "Hourly detail is unavailable for the selected devices; showing the daily total.",
|
|
64
|
+
trendPartial: "Some sources are cached or unavailable; bars show verified values only.",
|
|
65
|
+
trendStale: "Showing the last successful data for this selection.",
|
|
66
|
+
trendDailyOnly: "Daily total without hourly detail",
|
|
67
|
+
trendNoVerifiedPoint: "No verified usage recorded in this bucket",
|
|
68
|
+
tokensUnit: "tokens",
|
|
69
|
+
summaryUnavailable: "Summary unavailable for this selection.",
|
|
70
|
+
trendLoading: "Loading usage…",
|
|
71
|
+
trendKeyboardHint: "Use the arrow keys, Home, or End to move between time buckets; press Tab to leave the chart.",
|
|
62
72
|
legendInput: "Input",
|
|
63
73
|
legendOutput: "Output",
|
|
64
74
|
legendCacheRead: "Cache read",
|
|
@@ -158,9 +168,19 @@ export const MESSAGES = Object.freeze({
|
|
|
158
168
|
statusStale: "缓存",
|
|
159
169
|
statusError: "异常",
|
|
160
170
|
statusEmpty: "无数据",
|
|
161
|
-
trendHeading: "
|
|
162
|
-
trendHint: "
|
|
171
|
+
trendHeading: "Token 趋势",
|
|
172
|
+
trendHint: "悬停柱体查看明细 · 浅色为输入/缓存,深色为输出",
|
|
163
173
|
trendEmpty: "所选范围内暂无用量数据。",
|
|
174
|
+
trendUnavailable: "图表不可用:当前选择没有已校验的数据。",
|
|
175
|
+
trendNoHourly: "所选设备没有小时级明细,以下显示当日总量。",
|
|
176
|
+
trendPartial: "部分数据来源为缓存或不可用,图表仅展示已校验的数据。",
|
|
177
|
+
trendStale: "当前显示该选择上次成功获取的数据。",
|
|
178
|
+
trendDailyOnly: "无小时明细的当日合计",
|
|
179
|
+
trendNoVerifiedPoint: "该时间段没有已校验的用量",
|
|
180
|
+
tokensUnit: "Token",
|
|
181
|
+
summaryUnavailable: "当前选择的汇总数据不可用。",
|
|
182
|
+
trendLoading: "正在加载用量…",
|
|
183
|
+
trendKeyboardHint: "使用方向键、Home 或 End 在各时间桶之间移动;按 Tab 离开图表。",
|
|
164
184
|
legendInput: "输入",
|
|
165
185
|
legendOutput: "输出",
|
|
166
186
|
legendCacheRead: "缓存读取",
|
|
@@ -220,6 +240,88 @@ export function t(lang, key) {
|
|
|
220
240
|
return dict[key] ?? MESSAGES.en[key] ?? key;
|
|
221
241
|
}
|
|
222
242
|
|
|
243
|
+
// Bundled vendor logos under src/ui/icons. Model families match by id prefix;
|
|
244
|
+
// provider names match exactly. Anything unlisted has no logo.
|
|
245
|
+
const MODEL_ICON_FAMILIES = Object.freeze([
|
|
246
|
+
["claude", "claude-color"],
|
|
247
|
+
["gpt", "openai"],
|
|
248
|
+
["o1", "openai"],
|
|
249
|
+
["o3", "openai"],
|
|
250
|
+
["o4", "openai"],
|
|
251
|
+
["codex", "openai"],
|
|
252
|
+
["gemini", "gemini-color"],
|
|
253
|
+
["gemma", "gemini-color"],
|
|
254
|
+
["deepseek", "deepseek-color"],
|
|
255
|
+
["grok", "xai"],
|
|
256
|
+
["kimi", "kimi"],
|
|
257
|
+
["moonshot", "kimi"],
|
|
258
|
+
["glm", "zhipu-color"],
|
|
259
|
+
["qwen", "qwen-color"],
|
|
260
|
+
["qwq", "qwen-color"],
|
|
261
|
+
["mistral", "mistral-color"],
|
|
262
|
+
["codestral", "mistral-color"],
|
|
263
|
+
["devstral", "mistral-color"],
|
|
264
|
+
["magistral", "mistral-color"],
|
|
265
|
+
["minimax", "minimax-color"],
|
|
266
|
+
["mimo", "mimocode"],
|
|
267
|
+
["xiaomi", "mimocode"],
|
|
268
|
+
["step", "stepfun"],
|
|
269
|
+
]);
|
|
270
|
+
|
|
271
|
+
const PROVIDER_ICON_NAMES = Object.freeze({
|
|
272
|
+
anthropic: "claude-color",
|
|
273
|
+
openai: "openai",
|
|
274
|
+
google: "gemini-color",
|
|
275
|
+
deepseek: "deepseek-color",
|
|
276
|
+
xai: "xai",
|
|
277
|
+
kimi: "kimi",
|
|
278
|
+
moonshot: "kimi",
|
|
279
|
+
zhipu: "zhipu-color",
|
|
280
|
+
zai: "zhipu-color",
|
|
281
|
+
qwen: "qwen-color",
|
|
282
|
+
alibaba: "qwen-color",
|
|
283
|
+
mistral: "mistral-color",
|
|
284
|
+
minimax: "minimax-color",
|
|
285
|
+
xiaomi: "mimocode",
|
|
286
|
+
stepfun: "stepfun",
|
|
287
|
+
groq: "groq",
|
|
288
|
+
openrouter: "openrouter",
|
|
289
|
+
azure: "azure-color",
|
|
290
|
+
bedrock: "bedrock-color",
|
|
291
|
+
});
|
|
292
|
+
|
|
293
|
+
/**
|
|
294
|
+
* Resolve a bundled vendor logo key for a model id or name. Relay-style
|
|
295
|
+
* "vendor/model" ids match by the model part only; unknown -> "".
|
|
296
|
+
*/
|
|
297
|
+
export function vendorIconForModel(modelId) {
|
|
298
|
+
if (typeof modelId !== "string") {
|
|
299
|
+
return "";
|
|
300
|
+
}
|
|
301
|
+
let id = modelId.toLowerCase();
|
|
302
|
+
const relaySeparator = id.lastIndexOf("/");
|
|
303
|
+
if (relaySeparator !== -1) {
|
|
304
|
+
id = id.slice(relaySeparator + 1);
|
|
305
|
+
}
|
|
306
|
+
for (const [prefix, icon] of MODEL_ICON_FAMILIES) {
|
|
307
|
+
if (id.startsWith(prefix)) {
|
|
308
|
+
return icon;
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
return "";
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
/** Resolve a bundled vendor logo key for a provider name; unknown -> "". */
|
|
315
|
+
export function vendorIconForProvider(providerName) {
|
|
316
|
+
if (typeof providerName !== "string") {
|
|
317
|
+
return "";
|
|
318
|
+
}
|
|
319
|
+
const key = providerName.toLowerCase();
|
|
320
|
+
return Object.prototype.hasOwnProperty.call(PROVIDER_ICON_NAMES, key)
|
|
321
|
+
? PROVIDER_ICON_NAMES[key]
|
|
322
|
+
: "";
|
|
323
|
+
}
|
|
324
|
+
|
|
223
325
|
export function formatCompactTokens(value) {
|
|
224
326
|
const n = Number(value) || 0;
|
|
225
327
|
const abs = Math.abs(n);
|
|
@@ -408,3 +510,145 @@ export function buildDailyChartModel(daily = [], { width = 880, height = 224 } =
|
|
|
408
510
|
bars,
|
|
409
511
|
};
|
|
410
512
|
}
|
|
513
|
+
|
|
514
|
+
/**
|
|
515
|
+
* Format a trend point's compact axis label. Hour buckets use 24-hour labels;
|
|
516
|
+
* day buckets use the backend-provided MM-DD label or the day suffix.
|
|
517
|
+
*/
|
|
518
|
+
export function formatTrendPointLabel(point) {
|
|
519
|
+
if (!point || typeof point !== "object") {
|
|
520
|
+
return "";
|
|
521
|
+
}
|
|
522
|
+
if (Number.isInteger(point.hour) && point.hour >= 0 && point.hour <= 23) {
|
|
523
|
+
return `${String(point.hour).padStart(2, "0")}:00`;
|
|
524
|
+
}
|
|
525
|
+
if (typeof point.label === "string" && point.label) {
|
|
526
|
+
return point.label;
|
|
527
|
+
}
|
|
528
|
+
const day = typeof point.day === "string" ? point.day : "";
|
|
529
|
+
return day.length === 10 ? day.slice(5) : day;
|
|
530
|
+
}
|
|
531
|
+
|
|
532
|
+
/**
|
|
533
|
+
* Format a trend point's full hover title. Hour buckets include the calendar
|
|
534
|
+
* day so repeated daily hours can never be confused.
|
|
535
|
+
*/
|
|
536
|
+
export function formatTrendPointTitle(point) {
|
|
537
|
+
if (!point || typeof point !== "object") {
|
|
538
|
+
return "";
|
|
539
|
+
}
|
|
540
|
+
const day = typeof point.day === "string" ? point.day : "";
|
|
541
|
+
if (Number.isInteger(point.hour) && point.hour >= 0 && point.hour <= 23) {
|
|
542
|
+
return `${day} ${formatTrendPointLabel(point)}`.trim();
|
|
543
|
+
}
|
|
544
|
+
return day;
|
|
545
|
+
}
|
|
546
|
+
|
|
547
|
+
/**
|
|
548
|
+
* Choose a sparse axis-label interval that keeps dense 24/30-slot charts legible.
|
|
549
|
+
*/
|
|
550
|
+
export function trendLabelEvery(count) {
|
|
551
|
+
const n = Number(count) || 0;
|
|
552
|
+
if (n <= 8) {
|
|
553
|
+
return 1;
|
|
554
|
+
}
|
|
555
|
+
return n <= 31 ? Math.ceil(n / 6) : Math.ceil(n / 5);
|
|
556
|
+
}
|
|
557
|
+
|
|
558
|
+
/**
|
|
559
|
+
* Decide whether a sparse axis tick should render. The terminal tick is always
|
|
560
|
+
* kept, but a penultimate regular tick is dropped when it would crowd the last
|
|
561
|
+
* label at narrow widths. With a one-slot interval every label remains visible.
|
|
562
|
+
*/
|
|
563
|
+
export function trendShowLabel(index, count, every) {
|
|
564
|
+
const n = Math.max(0, Math.floor(Number(count) || 0));
|
|
565
|
+
const step = Math.max(1, Math.floor(Number(every) || 1));
|
|
566
|
+
if (!Number.isInteger(index) || index < 0 || index >= n) {
|
|
567
|
+
return false;
|
|
568
|
+
}
|
|
569
|
+
if (index === 0 || index === n - 1) {
|
|
570
|
+
return true;
|
|
571
|
+
}
|
|
572
|
+
if (index % step !== 0) {
|
|
573
|
+
return false;
|
|
574
|
+
}
|
|
575
|
+
return n - 1 - index >= step;
|
|
576
|
+
}
|
|
577
|
+
|
|
578
|
+
/**
|
|
579
|
+
* Build the visual axis plan for a trend chart. Today keeps all hourly bars but
|
|
580
|
+
* labels only the 12 even hours (00, 02, … 22), while date buckets keep the
|
|
581
|
+
* existing sparse terminal-tick policy. Hover/keyboard detail is unaffected.
|
|
582
|
+
*/
|
|
583
|
+
export function buildTrendAxisModel(points = [], { bucket = "day", every = 1 } = {}) {
|
|
584
|
+
const n = points.length;
|
|
585
|
+
return points.map((point, index) => {
|
|
586
|
+
if (bucket === "hour") {
|
|
587
|
+
const hour = point?.hour;
|
|
588
|
+
const show = Number.isInteger(hour) && hour >= 0 && hour < 24 && hour % 2 === 0;
|
|
589
|
+
const compactLabel = show ? String(hour).padStart(2, "0") : "";
|
|
590
|
+
return {
|
|
591
|
+
index,
|
|
592
|
+
show,
|
|
593
|
+
fullLabel: show ? `${compactLabel}:00` : "",
|
|
594
|
+
compactLabel,
|
|
595
|
+
};
|
|
596
|
+
}
|
|
597
|
+
const show = trendShowLabel(index, n, every);
|
|
598
|
+
const label = show ? formatTrendPointLabel(point) : "";
|
|
599
|
+
return {
|
|
600
|
+
index,
|
|
601
|
+
show,
|
|
602
|
+
fullLabel: label,
|
|
603
|
+
compactLabel: label,
|
|
604
|
+
};
|
|
605
|
+
});
|
|
606
|
+
}
|
|
607
|
+
|
|
608
|
+
/**
|
|
609
|
+
* Resolve a roving-tab-stop target for chart keyboard navigation. Returns null
|
|
610
|
+
* for keys the chart does not handle so Tab and other shortcuts keep working.
|
|
611
|
+
*/
|
|
612
|
+
export function trendFocusTarget(currentIndex, key, count) {
|
|
613
|
+
const n = Math.max(0, Math.floor(Number(count) || 0));
|
|
614
|
+
if (n === 0) {
|
|
615
|
+
return null;
|
|
616
|
+
}
|
|
617
|
+
const current = Number.isInteger(currentIndex) && currentIndex >= 0 && currentIndex < n
|
|
618
|
+
? currentIndex
|
|
619
|
+
: 0;
|
|
620
|
+
switch (key) {
|
|
621
|
+
case "ArrowRight":
|
|
622
|
+
case "ArrowDown":
|
|
623
|
+
return Math.min(n - 1, current + 1);
|
|
624
|
+
case "ArrowLeft":
|
|
625
|
+
case "ArrowUp":
|
|
626
|
+
return Math.max(0, current - 1);
|
|
627
|
+
case "Home":
|
|
628
|
+
return 0;
|
|
629
|
+
case "End":
|
|
630
|
+
return n - 1;
|
|
631
|
+
default:
|
|
632
|
+
return null;
|
|
633
|
+
}
|
|
634
|
+
}
|
|
635
|
+
|
|
636
|
+
/**
|
|
637
|
+
* Stable key for a range/device selection so last-good data can be reused only
|
|
638
|
+
* for the exact selection that produced it.
|
|
639
|
+
*/
|
|
640
|
+
export function summarySelectionKey(range, device) {
|
|
641
|
+
return `${range}|${device}`;
|
|
642
|
+
}
|
|
643
|
+
|
|
644
|
+
/**
|
|
645
|
+
* True only for a partial chart's completely empty bucket. A bucket with calls
|
|
646
|
+
* or cost but no tokens is verified activity and must keep its real tooltip.
|
|
647
|
+
*/
|
|
648
|
+
export function isUnverifiedEmptyTrendPoint(point, availability = "ok") {
|
|
649
|
+
if (availability !== "partial" || !point || typeof point !== "object") {
|
|
650
|
+
return false;
|
|
651
|
+
}
|
|
652
|
+
return ["totalTokens", "calls", "errors", "cost", "input", "output", "cacheRead", "cacheWrite"]
|
|
653
|
+
.every((key) => !Number(point[key]));
|
|
654
|
+
}
|