diff --git a/README.md b/README.md
index 25fb97a..12389df 100644
--- a/README.md
+++ b/README.md
@@ -185,6 +185,7 @@ These add a page to magpie's window, in the app and in `magpie web`, under Plugi
| [nowledge-mem](packages/nowledge-mem) | Connection settings, recall and capture switches, a real connection test, and the scope of what is sent | None |
| [agent-office](packages/agent-office) | What are my agents doing: a real WebGL 3D office with six scenes, an isometric/2D office, grouped workbench, Today usage and recent conversations | no `magpie.read`; its host part reads local session files of Claude Code, Codex, Copilot CLI, Kimi Code, dsh, Gemini CLI, Qwen Code, Pi, omp, Qoder, WorkBuddy, CodeBuddy and Grok Build, including prompts, replies and tool commands (`text:false` keeps statuses and tool names only) |
| [page-usage-tree](packages/page-usage-tree) | Account usage: usage as provider -> account -> model, each level expandable, with per-account calls, errors and cost; adds the account layer Usage glance's `usage:summary` does not contain | none (its local service calls Magpie's local usage API) |
+| [page-usage-board](packages/page-usage-board) | Full usage board: quota cards with expiry tiers, daily/per-provider charts, 24h cache-hit and token curves, optional remote attribution and account detail | none (the page reads nothing through the bridge; its local service reads your usage.jsonl, magpie's usage/quota API, and — for optional remote attribution — your magpie config's provider key to query the configured remote magpie) |
| [fingerprint](packages/fingerprint) | Numeric response fingerprints to investigate suspected model substitution across providers, with shared challenges, candidate rankings, local evidence and JSON export | none (its local service calls magpie’s gateway; sampling uses provider quota) |
| [chat](packages/chat) | Chat with magpie's models, your MCP servers, instructions and skills, by Magic_zero ([Magiczerowxy](https://github.com/Magiczerowxy)). Has a host part: a local service the page goes to | none (its service calls magpie's gateway) |
| [window-warmup](packages/window-warmup) | Window warmup: send one fixed short message ("hi", max_tokens 16) to a provider, account and model you pick, right after its quota window resets, daily at set times or every few hours, so the next subscription window opens early, by [YangHonghang](https://github.com/YangHonghang). Has a host part: a local service on 127.0.0.1 the page goes to | none; its service calls magpie's gateway and reads magpie's providers.json (keys only as sha256 fingerprints, plus key names and account models) and model cache. Each send uses the chosen account's quota |
diff --git a/packages/page-usage-board/.env.example b/packages/page-usage-board/.env.example
new file mode 100644
index 0000000..a8c1464
--- /dev/null
+++ b/packages/page-usage-board/.env.example
@@ -0,0 +1,61 @@
+# Copy to .env and edit as needed; run the board with `npm start` (or `node server.mjs`).
+# Every variable is optional — commented-out lines show the built-in defaults.
+
+# Listen port. Default 3455; 0 = let the OS pick. When the port is held the service
+# retries for ~8s, then reuses a live instance of the same build, or fails with a clear
+# error when a different build / a foreign process holds it. It never scans upward.
+#PORT=3455
+
+# Bind address. Keep the loopback default: the board page answers loopback binds and
+# loopback Host names only — a non-loopback bind never serves the page (403).
+#HOST=127.0.0.1
+
+# Token for scripts that call the API (send it as the "x-dash-key" request header).
+# Optional: when unset, every start generates a random token — not persisted, not logged,
+# not in any URL. Set it EMPTY explicitly (PAGE_KEY=) to serve the API without a token.
+# Never commit a real key: .env is git-ignored.
+#PAGE_KEY=
+
+# Extra Host names the API may be reached by behind a reverse proxy (comma-separated).
+# The board page stays loopback-only regardless.
+#ALLOWED_HOSTS=
+
+# magpie's local gateway API and its bearer key (live quotas / KPIs).
+# Resolution order: manifest options.gateway → GATEWAY → MAGPIE_GATEWAY →
+# MAGPIE_ADDR (set by magpie's plugin host) → the 3425 default.
+#GATEWAY=http://127.0.0.1:3425
+#MAGPIE_KEY=
+
+# magpie's config directory — explicit override only (magpie itself has no such
+# env; the service follows the host's cwd, then XDG_CONFIG_HOME/magpie, then
+# ~/.config/magpie, so portable installs need nothing here).
+# usage.jsonl, plugin-providers.json and providers.json live there.
+#MAGPIE_CONFIG_DIR=
+
+# magpie's usage log — the only data source (no prompts or message bodies are read).
+#USAGE_JSONL=
+
+# Brand logos: the only source is magpie's own plugin-providers.json (data-URI icons,
+# no downloads, no directory scanning). Default: the file next to usage.jsonl.
+#MAGPIE_PROVIDERS_FILE=
+
+# ---- Remote attribution: OPT-IN, OFF by default -------------------------------
+# ATTRIBUTION=local (default) keeps all attribution on this machine's usage.jsonl.
+# ATTRIBUTION=remote makes the service read this machine's magpie providers.json (or
+# REMOTE_BASE/REMOTE_KEY below) and send that provider's key to the remote magpie's
+# /v1/magpie/usage/requests — the key leaves this machine only toward that remote
+# magpie. The equivalent manifest option is options.attribution: "remote".
+#ATTRIBUTION=local
+
+# Remote provider credentials (read only when ATTRIBUTION=remote). Default source: the
+# preset remote-magpie / magpie-direct / magpie-cf provider in MAGPIE_PROVIDERS.
+#MAGPIE_PROVIDERS=~/.config/magpie/providers.json
+#REMOTE_BASE=
+#REMOTE_KEY=
+
+# Caller names kept for the remote charts. No default: empty means no filtering.
+#REMOTE_CALLERS=
+
+# Provider aliases counted as "remote" in the 24-hour split. Default: magpie's own three
+# route names; override via manifest options.remoteProviders.
+#REMOTE_PROVIDERS=magpie-direct,magpie-cf,remote-magpie
diff --git a/packages/page-usage-board/LICENSE b/packages/page-usage-board/LICENSE
new file mode 100644
index 0000000..3e630d7
--- /dev/null
+++ b/packages/page-usage-board/LICENSE
@@ -0,0 +1,21 @@
+MIT License
+
+Copyright (c) 2026 magpie-usage-board contributors
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
diff --git a/packages/page-usage-board/LICENSES/Apache-2.0.txt b/packages/page-usage-board/LICENSES/Apache-2.0.txt
new file mode 100644
index 0000000..d645695
--- /dev/null
+++ b/packages/page-usage-board/LICENSES/Apache-2.0.txt
@@ -0,0 +1,202 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
diff --git a/packages/page-usage-board/NOTICE b/packages/page-usage-board/NOTICE
new file mode 100644
index 0000000..14f63e1
--- /dev/null
+++ b/packages/page-usage-board/NOTICE
@@ -0,0 +1,24 @@
+magpie usage board
+Copyright 2026 magpie-usage-board contributors
+
+This product includes third-party software and assets:
+
+* Apache ECharts (static/echarts.min.js)
+ Copyright 2018-2026 Apache Software Foundation.
+ Licensed under the Apache License, Version 2.0 (the "License"); you may
+ not use this file except in compliance with the License. The full license
+ text ships with this distribution at LICENSES/Apache-2.0.txt and is also
+ available at https://www.apache.org/licenses/LICENSE-2.0
+ Provenance: custom build from the npm `echarts@5.5.1` package via
+ `build/echarts-entry.mjs` (see that file for the included components).
+ The bundle is byte-for-byte reproducible with `npm run build:echarts`
+ (scripts/build-echarts.mjs).
+
+* Brand logos
+ Provider logos are not bundled with this package: at service startup the
+ server reads magpie's own `plugin-providers.json` (the registry magpie
+ maintains next to its usage.jsonl) and keeps only the data-URI icons it
+ already contains. No network downloads and no plugin-directory scanning
+ are involved. Product and company names and logos are trademarks or
+ registered trademarks of their respective owners, used solely to identify
+ the corresponding providers; they do not imply endorsement.
diff --git a/packages/page-usage-board/README.md b/packages/page-usage-board/README.md
new file mode 100644
index 0000000..944abff
--- /dev/null
+++ b/packages/page-usage-board/README.md
@@ -0,0 +1,193 @@
+# magpie usage board
+
+A usage dashboard page inside [magpie](https://usemagpie.ai)'s window, served by the plugin's
+own zero-dependency local service.
+
+**Most of this board repeats magpie's own Usage page** — the allowance cards, the
+per-provider and per-model totals and the request list are all there already. Install this
+page for the five things Usage does not show:
+
+1. **Remote attribution by caller key** — traffic routed through a remote magpie, split by
+ which caller key caused it (opt-in; see *Remote attribution*).
+2. **TTFT p50/p90 per provider** — latency quality next to the volume.
+3. **A 7×24 heatmap** — when the calls actually happen, by weekday and hour.
+4. **Direct-vs-remote split of the last 24 hours** — how much went out through a remote
+ magpie versus straight out of this machine.
+5. **Expiry tiers on the quota cards** — how soon each allowance lapses, not just how much
+ is left.
+
+Everything else is convenience around those: daily and per-provider charts, 24-hour
+cache-hit and token curves, per-account detail for the remote side.
+
+Where [`@magpie-community/page-usage`](https://github.com/magpie-community/plugins/tree/main/packages/usage)
+is a bridge-only glance at magpie's summary totals, this page is the full board. Where
+[`page-usage-tree`](https://github.com/magpie-community/plugins/tree/main/packages/page-usage-tree)
+drills provider → account → model, this one puts quotas, costs and quality on one screen.
+
+## What it answers
+
+1. **Which providers were used** — local direct traffic plus traffic that landed on a remote
+ magpie (opt-in), merged under real provider names (daily chart, provider pies).
+2. **How much** — calls, tokens, daily trend; the quota wall shows what is left and when it
+ lapses.
+3. **How good** — TTFT P50/P90, per-account detail and error counts for the remote side.
+
+The two accounting views (KPI ledger vs. provider charts) and the exit-alias rules are
+documented in [`docs/data-semantics.md`](docs/data-semantics.md).
+
+## How it works
+
+Two layers, the same shape the community uses for host-part pages:
+
+1. `index.mjs` is an OpenCode v1 plugin loaded by magpie's Bun host. When magpie calls its
+ `server()` entry it starts `server.mjs`, a zero-dependency Node 22+/Bun HTTP service on
+ `127.0.0.1:3455`.
+2. `page/index.html` + `page/boot.js` is the hosted page. It asks the bridge for
+ `magpie.service` first: when `magpie web` runs on another machine it proxies the local
+ service under magpie's own origin, so **magpie's own key/auth is the outer gate** and the
+ page never leaves that origin. A desktop window has no service, so it falls back to
+ `http://127.0.0.1:3455/` — the port it read from `magpie.options.get()`, the same value
+ the service was started with. An 8-second `` is the fallback if the boot
+ script is blocked.
+
+The 8-second `` is deliberate: an earlier all-script page could be declared dead
+by the host after 10 seconds when the bridge handshake raced; the meta fallback still
+navigates if `boot.js` never runs, and the window is wide enough for slow bridge handshakes
+that `boot.js` resolves first.
+
+### Why a local service (and its token)
+
+magpie's bridge exposes a small set of reads — the bridge-only `usage` page uses just
+`usage:summary`. This board needs quotas, per-provider/per-day totals, a 7×24 heatmap,
+recent requests, TTFT and account detail; those are not in that summary. Like
+[`page-usage-tree`](https://github.com/magpie-community/plugins/tree/main/packages/page-usage-tree),
+it therefore runs a small local service that reads `usage.jsonl`.
+
+That service is a separate origin on `127.0.0.1`, outside magpie's auth. The gate is the same
+model the community [`page-usage-tree`](https://github.com/magpie-community/plugins/tree/main/packages/page-usage-tree)
+uses: the board page is served only on a loopback bind **and** a loopback `Host` — any
+non-loopback bind answers 403 for the page — and the service injects its token into the
+served HTML (`window.__KEY__`), so nobody types it. `/api/*` (except the two anonymous
+liveness routes below) checks the same token from the `x-dash-key` request header. There is
+no `?key=` query authentication and no token cookie: a key must never reach a URL, where
+proxy and browser-history logs would record it.
+
+The token comes from the `PAGE_KEY` environment variable when you set one (for scripts that
+call the API); otherwise every start generates a fresh random token that is never written to
+disk and never appears in a log line or URL. When `magpie web` is remote, the page goes
+through `magpie.service` and stays under magpie's origin, so magpie's key remains the outer
+gate.
+
+## Install
+
+Requires Node 22+. Inside magpie (once the package is merged into the community registry):
+
+```sh
+magpie plugin add @magpie-community/page-usage-board
+```
+
+Standalone, from a checkout or the npm package:
+
+```sh
+npm start # or: node server.mjs
+# [magpie-usage] listening on http://127.0.0.1:3455/
+```
+
+The board is local-only: the page answers loopback binds and loopback `Host` names, and a
+non-loopback bind never serves it (403) — there is no remote-visitor auth channel. Scripts
+that want the API set `PAGE_KEY` and send it as the `x-dash-key` request header. The service
+reads `~/.config/magpie/usage.jsonl`.
+
+## Configuration
+
+| Variable | Default | Meaning |
+|---|---|---|
+| `PORT` | `3455` | Listen port; `0` = let the OS pick. When the port is held, the service retries for ~8s, then reuses a live instance of the **same build** (recognised anonymously via the build id on `/api/ping`) or fails with a clear error when a different build or a foreign process holds it. It never scans upward. |
+| `HOST` | `127.0.0.1` | Bind address. Keep loopback: the board page answers loopback binds and loopback `Host` names only, and other local users of this machine can reach a loopback-bound board. |
+| `PAGE_KEY` | generated | Optional token for scripts that call the API (sent as the `x-dash-key` header). When unset, every start generates a random token — not persisted, not logged, not in any URL. Set it **empty explicitly** (`PAGE_KEY=`) to serve the API without a token. |
+| `ALLOWED_HOSTS` | empty | Comma-separated extra `Host` names the **API** may be reached by (e.g. behind a reverse proxy). The page stays loopback-only regardless. |
+| `GATEWAY` | `http://127.0.0.1:3425` | magpie's local gateway API. Resolved in this order: manifest `options.gateway` → `GATEWAY` → `MAGPIE_GATEWAY` → **`MAGPIE_ADDR`** (set by magpie's plugin host; a `0.0.0.0:`/`[::]:` prefix is normalised to loopback) → the `3425` default. |
+| `MAGPIE_KEY` | empty | Bearer key for the gateway, when the gateway requires one. |
+| `USAGE_JSONL` | `~/.config/magpie/usage.jsonl` | magpie's usage log. |
+| `MAGPIE_CONFIG_DIR` | `~/.config/magpie` | Explicit override for magpie's config directory (magpie itself has no such env — this is for tests and unusual layouts). The service resolves the dir the way magpie does: the **host's cwd** when it carries magpie markers (`usage.jsonl` / `plugins.json` / `providers.json` — the plugin host starts the service with the data dir as cwd, which covers portable installs) → `XDG_CONFIG_HOME/magpie` → `~/.config/magpie`. `usage.jsonl`, `plugin-providers.json` and `providers.json` default to files inside it. |
+| `MAGPIE_PROVIDERS_FILE` | `/plugin-providers.json` | Where brand logos are read from (magpie's own provider registry — see *Brand logos*). |
+| `ATTRIBUTION` | `local` | Remote attribution is **opt-in**: the default `local` keeps attribution on this machine's log; `ATTRIBUTION=remote` (or manifest `options.attribution: "remote"`) makes the service query the configured remote magpie — the provider key is sent to that remote magpie. |
+| `MAGPIE_PROVIDERS` | `~/.config/magpie/providers.json` | Where the remote URL and key are read from (used only with `ATTRIBUTION=remote`). |
+| `REMOTE_BASE` / `REMOTE_KEY` | empty | Explicit remote override (both required) instead of `providers.json`. |
+| `REMOTE_CALLERS` | empty | Caller names kept for the remote charts. **No default** — empty means no caller filtering. |
+| `REMOTE_PROVIDERS` | `magpie-direct,magpie-cf,remote-magpie` | Provider aliases counted as "remote" in the 24-hour split. The default is exactly magpie's own three route names; override via manifest `options.remoteProviders`. |
+
+## Manifest options
+
+The magpie manifest (`magpie.options` in package.json) carries the same knobs. Options take
+precedence over environment variables, and the built-in default applies when neither is set:
+
+| Option | Default | Meaning |
+|---|---|---|
+| `port` | `3455` | Service port. `magpie.page.service.option: "port"` tells magpie to inject the user's chosen port into `server(input, options)`; `index.mjs` forwards it to `startServer`. |
+| `attribution` | `"local"` | Keep `"local"` to hold attribution on this machine (the default — remote is never enabled implicitly). `"remote"` is the explicit opt-in that queries the configured remote magpie and sends the provider key to it. |
+| `remoteCallers` | `""` | Caller filter for the remote charts; empty means no filtering. |
+| `remoteProviders` | `"magpie-direct,magpie-cf,remote-magpie"` | Provider aliases counted as "remote" in the 24-hour split. |
+
+## Languages
+
+The interface ships in Chinese and English. `?lang=zh` or `?lang=en` forces one; otherwise
+the page follows `navigator.language` automatically.
+
+## Brand logos
+
+The quota wall shows provider brand icons. Their only source is magpie's own
+`plugin-providers.json` — the registry magpie maintains next to `usage.jsonl`
+(`MAGPIE_PROVIDERS_FILE` overrides the path). At startup the service reads that file once,
+keeps only `data:image/...` URIs (each capped at 2 MB, at most 4 MB injected in total) and
+injects them into the served HTML. There is no plugin-directory scanning, no download, no
+disk cache and no `/logos` route: `https://` icons are deliberately not fetched, so the
+board never contacts a third-party CDN on your behalf — providers without a data-URI icon
+fall back to a colored first-letter block.
+
+## Data and privacy
+
+- Reads this machine's `usage.jsonl` and magpie's local gateway API. The board itself sends
+ no telemetry; its Content-Security-Policy allows no third-party host at all.
+- **Remote attribution is opt-in and off by default.** Only `ATTRIBUTION=remote` (or manifest
+ `options.attribution: "remote"`) enables it: the service then makes read-only requests to
+ the configured remote magpie's own `/v1/magpie/usage/requests`, using the provider key
+ already configured in this machine's `providers.json` — that key is sent to that remote
+ magpie and nowhere else. Rows are filtered by `REMOTE_CALLERS` (no default filter) and
+ aggregated locally; no prompts or message bodies are involved. There is no second service
+ and no separate page key.
+- The page and its assets are served from `127.0.0.1`. The trust boundary is the local
+ machine: other local users can reach a loopback-bound board, and remote attribution reads
+ every caller's rows on the shared remote magpie (filtered for display, disclosed in the
+ Pages table).
+- The anonymous surface is exactly two routes: `GET /api/ping` (an identity fingerprint +
+ build id, used to recognise a live instance of the same build) and `GET /api/health`
+ (liveness). Every other `/api/*` route requires the token via the `x-dash-key` header,
+ every route checks `Host` to block DNS rebinding, and the board page itself is never
+ served on a non-loopback bind or a public `Host` name.
+- No prompts or message bodies are read — the service aggregates model, provider, tokens,
+ cost, timing and error counts.
+
+## Develop
+
+These commands run from a git checkout — the npm package (`npm pack`) ships the runtime,
+docs and notices; `test/` stays in the checkout.
+
+```sh
+node --test # auth/host/page gate, caller filtering, package metadata
+npm run build:echarts # rebuild static/echarts.min.js byte-for-byte (verify: git diff --exit-code static/echarts.min.js)
+```
+
+- `static/index.html` is the page source; at request time the service injects
+ `window.__DATA__`, `window.QLOGOS` (brand logos) and, on a loopback bind, `window.__KEY__`
+ into the served HTML.
+- `npm test` / `npm pack` run the same checks; `prepack` refuses to package a stray
+ `remote.js` or a literal page key.
+- Remote attribution defaults to off and must be opted into (see *Configuration*).
+
+## License
+
+MIT. `static/echarts.min.js` is a custom Apache-2.0 build of Apache ECharts, reproducible
+byte-for-byte with `npm run build:echarts` (see `NOTICE`). Provider logos are collected at
+runtime from magpie's `plugin-providers.json` and are the trademarks of their owners, used
+only to identify providers (see `NOTICE`).
diff --git a/packages/page-usage-board/build/echarts-entry.mjs b/packages/page-usage-board/build/echarts-entry.mjs
new file mode 100644
index 0000000..0d2ddf1
--- /dev/null
+++ b/packages/page-usage-board/build/echarts-entry.mjs
@@ -0,0 +1,24 @@
+// 定制构建入口:只包含看板用到的图表与组件(见第四轮瘦身分析)。
+// 重建命令:npx esbuild build/echarts-entry.mjs --bundle --minify --global-name=echarts
+// --outfile=static/echarts.min.js
+// 页面通过全局 echarts.init(...) 使用;新增图表类型时在此补 import 并重建。
+import * as echarts from 'echarts/core';
+import { BarChart, LineChart, PieChart, HeatmapChart } from 'echarts/charts';
+import {
+ TooltipComponent, LegendComponent, GridComponent, DataZoomComponent,
+ DataZoomInsideComponent, DataZoomSliderComponent, VisualMapComponent,
+ AxisPointerComponent,
+} from 'echarts/components';
+import { CanvasRenderer } from 'echarts/renderers';
+
+echarts.use([
+ BarChart, LineChart, PieChart, HeatmapChart,
+ TooltipComponent, LegendComponent, GridComponent, DataZoomComponent,
+ DataZoomInsideComponent, DataZoomSliderComponent, VisualMapComponent,
+ AxisPointerComponent, CanvasRenderer,
+]);
+
+// 页面通过全局 echarts.init(...) 使用;--global-name 的 iife 会把 default export
+// 嵌套进 .default,这里直接赋值保证 window.echarts 就是完整命名空间
+if (typeof window !== 'undefined') window.echarts = echarts;
+export default echarts;
diff --git a/packages/page-usage-board/docs/community-submission.md b/packages/page-usage-board/docs/community-submission.md
new file mode 100644
index 0000000..a16eda9
--- /dev/null
+++ b/packages/page-usage-board/docs/community-submission.md
@@ -0,0 +1,82 @@
+# Community submission
+
+The community publishes packages by merging a pull request into
+[`magpie-community/plugins`](https://github.com/magpie-community/plugins). Submitting is just
+that PR — no dashboard form, and no manual `npm publish`: merging to the registry's main
+branch bumps the version and **trusted publishing puts the package on npm automatically**,
+so `package.json`'s `version` must be release-ready when the PR lands. One PR adds three
+things:
+
+1. `packages/page-usage-board/` — this package (all files from `npm pack`, plus `LICENSE`,
+ `README.md`, `docs/` and the development files — see the layout trap below).
+2. One entry in `registry.json`.
+3. One row in the README's **Pages** table.
+
+## registry.json entry
+
+```json
+{
+ "package": "@magpie-community/page-usage-board",
+ "name": "Usage Board",
+ "kind": "page",
+ "community": true,
+ "summary": {
+ "en": "A quota card wall with expiry tiers, daily/per-provider charts, 24h cache-hit and token curves, optional remote attribution and account detail. Runs its own zero-dependency local service reading this machine's Magpie usage data; optional remote attribution queries the configured remote magpie.",
+ "zh": "额度到期卡片墙 + 每日与 provider 用量图表 + 24 小时缓存命中与 token 曲线,可选远端归因与账号明细。自带零依赖本机服务,读本机 Magpie 用量数据;远端归因会查询所配置的远端 magpie。"
+ }
+}
+```
+
+The `summary` above must stay **verbatim-identical** to `magpie.summary` in package.json —
+copy it into the PR description together with the difference declaration (the registry
+requires all three texts to match).
+
+## README Pages row
+
+```md
+| [page-usage-board](packages/page-usage-board) | Full usage board: quota cards with expiry tiers, daily and per-provider charts, 24-hour cache-hit and token curves, optional remote attribution and account detail | none (the page reads nothing through the bridge; its local service reads your usage.jsonl, magpie's usage/quota API, and — for optional remote attribution — your magpie config's provider key to query the configured remote magpie) |
+```
+
+## The packaging layout
+
+`npm pack` ships what the `files` field in package.json lists — the runtime (`index.mjs`,
+`server.mjs`, `page/`, `static/`), the vendored echarts bundle (`build/echarts-entry.mjs` +
+`static/echarts.min.js`), `docs/`, `scripts/` (`prepack.mjs`, `build-echarts.mjs`) and
+`NOTICE`. The `prepack` hook asserts that the echarts entry and its build script exist and
+are covered by `files`, and validates every relative link in README.md and `docs/*.md`.
+
+Correct layout for `packages/page-usage-board/`: the `npm pack` output, plus `LICENSE`,
+`.env.example` and `test/` (development files the README references — they do not need to
+be in `files`).
+
+Check before opening the PR:
+
+- `docs/` and `.env.example` are in the staged tree.
+- Every relative link in README.md and `docs/*.md` resolves inside
+ `packages/page-usage-board/` — click through them in the GitHub PR preview.
+
+## Checks before opening the PR
+
+- `npm test` passes (auth, `Host`, page gate, traversal, lead-page, package metadata).
+- `npm pack --dry-run` contains no `remote.js`, no page key, and includes `LICENSE`.
+- The host part guards every route with a token **and checks `Host`** (community requirement
+ for pages that navigate to a local service). The board page itself is served only on a
+ loopback bind with a loopback `Host` name — the token is injected into the served HTML
+ rather than typed, and a non-loopback bind or a proxied public `Host` never receives the
+ page. Deliberate anonymous routes, filed here for review: `GET /api/ping` (returns
+ `{service,ok,build,version}` — an identity fingerprint + build id, used to recognise a
+ live instance of the same build) and `GET /api/health` (returns `{ok,jsonl}` — liveness).
+ Both carry no key and no usage data; every other `/api/*` route requires the token via
+ the `x-dash-key` header (no `?key=` query auth, no cookie channel), and `/static/*` holds
+ only the chart library and page assets (no data).
+- Remote attribution defaults to **off** (`magpie.options.attribution: "local"`); the user
+ must explicitly opt in (`ATTRIBUTION=remote` or `options.attribution: "remote"`), which
+ sends the configured provider key to the remote magpie and nowhere else.
+- The hosted page uses `window.magpie.service` when present, so a remote `magpie web`
+ deployment keeps the frame under magpie's own origin and key.
+- The lead page has no inline scripts (its only sources are magpie's `_magpie/bridge.js`
+ and the plugin's `boot.js`) and fetches nothing; the board itself only calls its own
+ service on `127.0.0.1`. Its Content-Security-Policy allows no third-party host, and brand
+ logos come from magpie's `plugin-providers.json` as data URIs — the page never contacts a
+ third-party CDN.
+- `magpie.permissions` is `[]`: the page reads nothing through the bridge.
\ No newline at end of file
diff --git a/packages/page-usage-board/docs/data-semantics.md b/packages/page-usage-board/docs/data-semantics.md
new file mode 100644
index 0000000..480d88a
--- /dev/null
+++ b/packages/page-usage-board/docs/data-semantics.md
@@ -0,0 +1,66 @@
+# Data semantics
+
+Read this before changing the page or the aggregations. Two different totals are shown on
+purpose; they answer different questions and must not be silently reconciled.
+
+## The four exit aliases are two routes
+
+magpie renamed its outbound providers over time:
+
+| Route | Names in `usage.jsonl` | Remote `caller` |
+|---|---|---|
+| direct | `magpie-direct`, `remote-magpie` | `cloud` |
+| Cloudflare | `magpie-cf`, `magpie-2` | `Magpie` |
+
+The page keeps all four in one `REMOTE_ENTRY` set. Never hand-write a single name.
+
+## Charts use real providers
+
+- Local, non-exit providers are taken from the detail log as-is.
+- Remote attribution adds per-provider totals under the same provider names.
+- When attribution is available, the exit aliases do **not** enter the charts; their traffic
+ is already attributed.
+- When attribution is unavailable, the four exit aliases collapse into one series labelled
+ "remote (unattributed)", so nothing disappears silently.
+- The daily chart stacks providers; the provider pie merges aliases.
+
+## Where the remote side comes from
+
+The local service reads the remote magpie's own `/v1/magpie/usage/requests` (provider key
+already in `providers.json`) and keeps rows whose `callerKeyName` is in `REMOTE_CALLERS`
+(default `cloud`, `Magpie`). The caller breakdown still lists every caller on that instance
+(e.g. `hermes`), but provider/account/day/hourly numbers are this machine's only. The 24-hour
+remote curve is caller-filtered too; older builds that read the remote log without that filter
+over-counted other callers.
+
+The standalone `/usage2` service is retired: it was only a way to run that filter on the
+remote log when the magpie API could not give per-caller rows.
+
+## KPI cards use the local gateway ledger
+
+Cost on the KPI cards is magpie's own pricing (subscription quota converted to money), not
+money actually spent. It is intentionally different from the chart totals, which follow real
+providers. Label both clearly; do not "fix" one to match the other.
+
+## Quota cards deduplicate by subscription
+
+The same subscription can be read through two routes (direct / proxy) and two instances
+(local / remote). The quota wall groups by (normalized subscription + account) and shows one
+card per group; the `· Magpie direct/proxy` suffix is stripped from the name. Different
+accounts (different phone numbers or keys) are different quotas and stay as separate cards.
+
+## Remote cards have three states
+
+- No remote data source (remote attribution is opt-in and defaults to local): hide the TTFT and account cards.
+- Source configured but the fetch fails (45 s client timeout, 10 s per remote page server-side): show a red error card explaining it.
+- Success: show the data.
+
+A dead source must never make the card vanish without a trace — silence looks like "zero
+usage" and is the one failure mode that misleads.
+
+## What is read
+
+`usage.jsonl` lines are aggregated into daily × provider totals, a 7×24 heatmap, 24-hour
+token/cache curves, recent requests and per-account attribution. Probe lines
+(`kind: "model_list"`, `source: "probe"`) are filtered out. Prompts, messages and tool output
+are never read or displayed.
\ No newline at end of file
diff --git a/packages/page-usage-board/index.mjs b/packages/page-usage-board/index.mjs
new file mode 100644
index 0000000..6b2c813
--- /dev/null
+++ b/packages/page-usage-board/index.mjs
@@ -0,0 +1,57 @@
+// magpie 窗口里的「用量看板」页面。
+//
+// 两层结构(同 Magiczerowxy/magpie-chat、magpie-community/page-usage-tree 的做法):
+// 1. 本文件作为 OpenCode v1 插件被 magpie 的 Bun 宿主加载。模块导入必须零副作用
+// (社区 scripts_check.mjs 会直接 import 做静态检查,导入即监听会占端口、写配置);
+// 服务只在 magpie 调用 server(input, options) 时启动,且 await 到真正监听后才返回。
+// 2. page/index.html + page/boot.js 是 magpie 托管的「带路页」:优先跳
+// window.magpie.service(magpie web 在自己域名下的转发路径,页面留在 magpie
+// origin、由 magpie 自己的 key 保护),桌面回退 http://127.0.0.1:3455/。
+// 服务端把口令注入返回的看板(window.__KEY__),只有 API 路由校验它。
+//
+// 服务已在本机跑着(另一个插件实例 / 手动 node)时端口占用,server.mjs 会静默复用。
+import { fileURLToPath, pathToFileURL } from "node:url";
+import path from "node:path";
+
+const here = path.dirname(fileURLToPath(import.meta.url));
+let starting = null;
+
+const plugin = {
+ id: "magpie-usage-board",
+ server: async (_input, options) => {
+ if (!starting) {
+ // manifest options(page.service.option = "port" 时 options.port 由 magpie 注入)
+ // → startServer() 内部再回退到环境变量/默认值。port 的 0/非法值归成 undefined:
+ // 服务回落到默认口,页面从同一 options 读到的也走同一回落,两边永远一致。
+ const n = Number(options?.port);
+ const port = Number.isInteger(n) && n > 0 && n < 65536 ? n : undefined;
+ starting = import(pathToFileURL(path.join(here, "server.mjs")).href)
+ .then((m) => m.startServer({
+ port,
+ attribution: options?.attribution,
+ remoteCallers: options?.remoteCallers,
+ remoteProviders: options?.remoteProviders,
+ gateway: options?.gateway,
+ }))
+ .then((port) => ({ ok: true, port }))
+ .catch((err) => {
+ starting = null; // 允许 magpie 下次调用重试
+ console.error("[magpie-usage-board] server not started:", err?.message || err);
+ throw err;
+ });
+ }
+ await starting;
+ // 返回 { ok, port }:magpie 只要 await 成功即可,多出的字段便于测试与排障
+ return await starting;
+ },
+};
+
+export default plugin;
+
+// 手动启动入口:node index.mjs(与 server.mjs 直跑等价,走同一生命周期契约)
+if (process.argv[1] && path.resolve(process.argv[1]) === fileURLToPath(import.meta.url)) {
+ plugin.server().catch((e) => {
+ console.error(`[magpie-usage-board] not started: ${e?.message || e}`);
+ process.exit(1);
+ });
+}
diff --git a/packages/page-usage-board/package-lock.json b/packages/page-usage-board/package-lock.json
new file mode 100644
index 0000000..0ab57e4
--- /dev/null
+++ b/packages/page-usage-board/package-lock.json
@@ -0,0 +1,533 @@
+{
+ "name": "@magpie-community/page-usage-board",
+ "version": "0.1.0",
+ "lockfileVersion": 3,
+ "requires": true,
+ "packages": {
+ "": {
+ "name": "@magpie-community/page-usage-board",
+ "version": "0.1.0",
+ "license": "MIT",
+ "devDependencies": {
+ "echarts": "5.5.1",
+ "esbuild": "0.28.2"
+ },
+ "engines": {
+ "magpie": ">=0.1.1340",
+ "node": ">=22"
+ }
+ },
+ "node_modules/@esbuild/aix-ppc64": {
+ "version": "0.28.2",
+ "resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.28.2.tgz",
+ "integrity": "sha512-XExcO+dvLKvVtNTibSTBej1NCAbaGhWn9Ww1ZPx80qsahhPFe/8jgWP0IchNe0F3HwkU7n8ejhH8bjonqht8mQ==",
+ "cpu": [
+ "ppc64"
+ ],
+ "dev": true,
+ "license": "MIT",
+ "optional": true,
+ "os": [
+ "aix"
+ ],
+ "engines": {
+ "node": ">=18"
+ }
+ },
+ "node_modules/@esbuild/android-arm": {
+ "version": "0.28.2",
+ "resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.28.2.tgz",
+ "integrity": "sha512-kXXoiPVVGQcnIYGOeaovwOURpniDBpSq4A03qkQ+BMQqtGG6HYap3xne9C1O1yo4TR3qxlCX5IqqmX6fFo2Lqg==",
+ "cpu": [
+ "arm"
+ ],
+ "dev": true,
+ "license": "MIT",
+ "optional": true,
+ "os": [
+ "android"
+ ],
+ "engines": {
+ "node": ">=18"
+ }
+ },
+ "node_modules/@esbuild/android-arm64": {
+ "version": "0.28.2",
+ "resolved": "https://registry.npmjs.org/@esbuild/android-arm64/-/android-arm64-0.28.2.tgz",
+ "integrity": "sha512-5YfKeeI8qWfBZIX+u2xZC3Zlb3Os/gLS2sbEKM+I4ZOcsWmHS2WLysCcQZDAFRslDUU5Oiq44gf6PYN1vGwG5A==",
+ "cpu": [
+ "arm64"
+ ],
+ "dev": true,
+ "license": "MIT",
+ "optional": true,
+ "os": [
+ "android"
+ ],
+ "engines": {
+ "node": ">=18"
+ }
+ },
+ "node_modules/@esbuild/android-x64": {
+ "version": "0.28.2",
+ "resolved": "https://registry.npmjs.org/@esbuild/android-x64/-/android-x64-0.28.2.tgz",
+ "integrity": "sha512-O387ite7SzUyCcy3JQX4P4bLtEA7bLLkx+esve5JHnyYfNTxcVpXZo9jhdB0lTKN44gztELTdU7nS8Nr16Fs1Q==",
+ "cpu": [
+ "x64"
+ ],
+ "dev": true,
+ "license": "MIT",
+ "optional": true,
+ "os": [
+ "android"
+ ],
+ "engines": {
+ "node": ">=18"
+ }
+ },
+ "node_modules/@esbuild/darwin-arm64": {
+ "version": "0.28.2",
+ "resolved": "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.28.2.tgz",
+ "integrity": "sha512-n4KqkOQrraxHJcgjM1RvwbigfQKIKJVpM7xp+KsxiyUSrRdIXnt73VhrPAx0fV44hgfmIVKjxMN9J1t5jySVkw==",
+ "cpu": [
+ "arm64"
+ ],
+ "dev": true,
+ "license": "MIT",
+ "optional": true,
+ "os": [
+ "darwin"
+ ],
+ "engines": {
+ "node": ">=18"
+ }
+ },
+ "node_modules/@esbuild/darwin-x64": {
+ "version": "0.28.2",
+ "resolved": "https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-0.28.2.tgz",
+ "integrity": "sha512-uq6suIWYP37qzGddBKPw5QEQPi6HiLGsO7UmkpfyaYNQ3D+rN6w6WfwH+nuqcGXWvawGwxOEroO4YGnFh95azw==",
+ "cpu": [
+ "x64"
+ ],
+ "dev": true,
+ "license": "MIT",
+ "optional": true,
+ "os": [
+ "darwin"
+ ],
+ "engines": {
+ "node": ">=18"
+ }
+ },
+ "node_modules/@esbuild/freebsd-arm64": {
+ "version": "0.28.2",
+ "resolved": "https://registry.npmjs.org/@esbuild/freebsd-arm64/-/freebsd-arm64-0.28.2.tgz",
+ "integrity": "sha512-n+I0BTSRIoy+d6RPKnEVwql5UwBJolytvY4mAOIEJorKlqgPII8ix6slVVrfZ5Tnj7glIZvloylbB/EJPMWEXw==",
+ "cpu": [
+ "arm64"
+ ],
+ "dev": true,
+ "license": "MIT",
+ "optional": true,
+ "os": [
+ "freebsd"
+ ],
+ "engines": {
+ "node": ">=18"
+ }
+ },
+ "node_modules/@esbuild/freebsd-x64": {
+ "version": "0.28.2",
+ "resolved": "https://registry.npmjs.org/@esbuild/freebsd-x64/-/freebsd-x64-0.28.2.tgz",
+ "integrity": "sha512-78XJTJkvPs0kz2w61301PJjXl4g7q3JqiYMZ/M/yVI73EHBrCRTgkhu9oqG7vPqq+a/yadEW8aD+agKlk5xrmg==",
+ "cpu": [
+ "x64"
+ ],
+ "dev": true,
+ "license": "MIT",
+ "optional": true,
+ "os": [
+ "freebsd"
+ ],
+ "engines": {
+ "node": ">=18"
+ }
+ },
+ "node_modules/@esbuild/linux-arm": {
+ "version": "0.28.2",
+ "resolved": "https://registry.npmjs.org/@esbuild/linux-arm/-/linux-arm-0.28.2.tgz",
+ "integrity": "sha512-XlDnu2q5yoqems+xay6wSAcg9DDD7K9RLKZEBOMZm3ckNpJBvOX20tSfby8KfrrhINDyv9V2YVZKY/SpoGJI8w==",
+ "cpu": [
+ "arm"
+ ],
+ "dev": true,
+ "license": "MIT",
+ "optional": true,
+ "os": [
+ "linux"
+ ],
+ "engines": {
+ "node": ">=18"
+ }
+ },
+ "node_modules/@esbuild/linux-arm64": {
+ "version": "0.28.2",
+ "resolved": "https://registry.npmjs.org/@esbuild/linux-arm64/-/linux-arm64-0.28.2.tgz",
+ "integrity": "sha512-pW4AC0P3it8c7do9MVM4p51FzHzdM/TZrerurgRcHJ2WTa1VQ1CIq18xncfpBJw4ojkiZZrKW2yIBWBP92j6Ug==",
+ "cpu": [
+ "arm64"
+ ],
+ "dev": true,
+ "license": "MIT",
+ "optional": true,
+ "os": [
+ "linux"
+ ],
+ "engines": {
+ "node": ">=18"
+ }
+ },
+ "node_modules/@esbuild/linux-ia32": {
+ "version": "0.28.2",
+ "resolved": "https://registry.npmjs.org/@esbuild/linux-ia32/-/linux-ia32-0.28.2.tgz",
+ "integrity": "sha512-CYbnj78HsIeA+DhgUKgFCfvNsTHFhMMrinUrMZpDXJXKN8T3XViTZ/+wtHeVxEWY8ewSzTFN+nRmSwO2tZaLUQ==",
+ "cpu": [
+ "ia32"
+ ],
+ "dev": true,
+ "license": "MIT",
+ "optional": true,
+ "os": [
+ "linux"
+ ],
+ "engines": {
+ "node": ">=18"
+ }
+ },
+ "node_modules/@esbuild/linux-loong64": {
+ "version": "0.28.2",
+ "resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.28.2.tgz",
+ "integrity": "sha512-buwkd8nsph4R+ajRvw0qM5Hja/TXQow3ptzWO2EbG/cqcIkHloRrdlBtQlshyYGTNFvfkfJ5tpPLVkY4DtsPfQ==",
+ "cpu": [
+ "loong64"
+ ],
+ "dev": true,
+ "license": "MIT",
+ "optional": true,
+ "os": [
+ "linux"
+ ],
+ "engines": {
+ "node": ">=18"
+ }
+ },
+ "node_modules/@esbuild/linux-mips64el": {
+ "version": "0.28.2",
+ "resolved": "https://registry.npmjs.org/@esbuild/linux-mips64el/-/linux-mips64el-0.28.2.tgz",
+ "integrity": "sha512-ZVykbDyk7519VwiNb9Lcj9m8XM6v5V9uKPvrEMkkEedVewf+0itkhahp4HDpgERXhwLRpWFypsGbG/J8s0QjJA==",
+ "cpu": [
+ "mips64el"
+ ],
+ "dev": true,
+ "license": "MIT",
+ "optional": true,
+ "os": [
+ "linux"
+ ],
+ "engines": {
+ "node": ">=18"
+ }
+ },
+ "node_modules/@esbuild/linux-ppc64": {
+ "version": "0.28.2",
+ "resolved": "https://registry.npmjs.org/@esbuild/linux-ppc64/-/linux-ppc64-0.28.2.tgz",
+ "integrity": "sha512-CAXl+Dtd9UUuJd8pKKdwh6MLm3MUMiqMPmhZ3tTSXPqfyQ3vDl6R5hZdZ/kYojK4ofXtdfSv1tFq8XzWx3heNQ==",
+ "cpu": [
+ "ppc64"
+ ],
+ "dev": true,
+ "license": "MIT",
+ "optional": true,
+ "os": [
+ "linux"
+ ],
+ "engines": {
+ "node": ">=18"
+ }
+ },
+ "node_modules/@esbuild/linux-riscv64": {
+ "version": "0.28.2",
+ "resolved": "https://registry.npmjs.org/@esbuild/linux-riscv64/-/linux-riscv64-0.28.2.tgz",
+ "integrity": "sha512-GeXCej4IQtU1B+QlDV8W/RRvbzI3O/Stss+/bCXv4lZls5WGRtu2a+3JkA3i4qIUlMXpcHebWpF8AkJhATowuA==",
+ "cpu": [
+ "riscv64"
+ ],
+ "dev": true,
+ "license": "MIT",
+ "optional": true,
+ "os": [
+ "linux"
+ ],
+ "engines": {
+ "node": ">=18"
+ }
+ },
+ "node_modules/@esbuild/linux-s390x": {
+ "version": "0.28.2",
+ "resolved": "https://registry.npmjs.org/@esbuild/linux-s390x/-/linux-s390x-0.28.2.tgz",
+ "integrity": "sha512-3H1weTYZPxt/WOhByszQZybS9w5lKzUn1FDMsgEChbHWQwHYQQRfBxgCcZvPhjHfKyJjIievvMmEUawJrdY9Dg==",
+ "cpu": [
+ "s390x"
+ ],
+ "dev": true,
+ "license": "MIT",
+ "optional": true,
+ "os": [
+ "linux"
+ ],
+ "engines": {
+ "node": ">=18"
+ }
+ },
+ "node_modules/@esbuild/linux-x64": {
+ "version": "0.28.2",
+ "resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.28.2.tgz",
+ "integrity": "sha512-4xTZr1FUmSoQW4XIWmit3tzQrUTZM+N3P0XV8xROKYF50XfI7xeO90+1bZvNwxIufQ9hDQVRJH5YhgPVF8A/HQ==",
+ "cpu": [
+ "x64"
+ ],
+ "dev": true,
+ "license": "MIT",
+ "optional": true,
+ "os": [
+ "linux"
+ ],
+ "engines": {
+ "node": ">=18"
+ }
+ },
+ "node_modules/@esbuild/netbsd-arm64": {
+ "version": "0.28.2",
+ "resolved": "https://registry.npmjs.org/@esbuild/netbsd-arm64/-/netbsd-arm64-0.28.2.tgz",
+ "integrity": "sha512-sSATRjPeDBg3pdgHoQfoYBob11Kk1FGa9lui5RIHZCoCkJa9QKlvl3/vKz2usCmYYjs7ymJR/2Nnsqe+Hjt5nw==",
+ "cpu": [
+ "arm64"
+ ],
+ "dev": true,
+ "license": "MIT",
+ "optional": true,
+ "os": [
+ "netbsd"
+ ],
+ "engines": {
+ "node": ">=18"
+ }
+ },
+ "node_modules/@esbuild/netbsd-x64": {
+ "version": "0.28.2",
+ "resolved": "https://registry.npmjs.org/@esbuild/netbsd-x64/-/netbsd-x64-0.28.2.tgz",
+ "integrity": "sha512-lqnzCV+mM0gIADaKihiCg6ifgfU2L3h5E33rNQBN1Y4MaVGnzryzmvvf7UHxprpQdE8hpqLolJ9Rl+SkIRDpyw==",
+ "cpu": [
+ "x64"
+ ],
+ "dev": true,
+ "license": "MIT",
+ "optional": true,
+ "os": [
+ "netbsd"
+ ],
+ "engines": {
+ "node": ">=18"
+ }
+ },
+ "node_modules/@esbuild/openbsd-arm64": {
+ "version": "0.28.2",
+ "resolved": "https://registry.npmjs.org/@esbuild/openbsd-arm64/-/openbsd-arm64-0.28.2.tgz",
+ "integrity": "sha512-AL2qJILH7lNjrDmCQDvdxMfAUIv8KMNZOvrwAQ8i8//ntL9FflhOyMJ8OZSMBb8/AWXe3/5v5S20y3zCoZWKoQ==",
+ "cpu": [
+ "arm64"
+ ],
+ "dev": true,
+ "license": "MIT",
+ "optional": true,
+ "os": [
+ "openbsd"
+ ],
+ "engines": {
+ "node": ">=18"
+ }
+ },
+ "node_modules/@esbuild/openbsd-x64": {
+ "version": "0.28.2",
+ "resolved": "https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.28.2.tgz",
+ "integrity": "sha512-QtiuPytchRyC4rwUKhexJdQKvDuZ6hWloi3igqPQNUJCS1/v9EiO3UTOXR6A3FoMo4fnAKbWJdqaIwhOzh8qEw==",
+ "cpu": [
+ "x64"
+ ],
+ "dev": true,
+ "license": "MIT",
+ "optional": true,
+ "os": [
+ "openbsd"
+ ],
+ "engines": {
+ "node": ">=18"
+ }
+ },
+ "node_modules/@esbuild/openharmony-arm64": {
+ "version": "0.28.2",
+ "resolved": "https://registry.npmjs.org/@esbuild/openharmony-arm64/-/openharmony-arm64-0.28.2.tgz",
+ "integrity": "sha512-WkhYDmpTjLvGlScA1rwjRUmhl4k8oXR3cIbtqWmELgU/dFeHHlEllxDvdWcNJV9rbzCexB5vz8gtNewWLgCT7Q==",
+ "cpu": [
+ "arm64"
+ ],
+ "dev": true,
+ "license": "MIT",
+ "optional": true,
+ "os": [
+ "openharmony"
+ ],
+ "engines": {
+ "node": ">=18"
+ }
+ },
+ "node_modules/@esbuild/sunos-x64": {
+ "version": "0.28.2",
+ "resolved": "https://registry.npmjs.org/@esbuild/sunos-x64/-/sunos-x64-0.28.2.tgz",
+ "integrity": "sha512-GPMSkTOtMnv2U2F8gxe4Io6qmVs+YKyp832Etqqxr0hFngmXQ3rzwytelm3GIn7T4VviRUlf3sOgBOiTdvaf7g==",
+ "cpu": [
+ "x64"
+ ],
+ "dev": true,
+ "license": "MIT",
+ "optional": true,
+ "os": [
+ "sunos"
+ ],
+ "engines": {
+ "node": ">=18"
+ }
+ },
+ "node_modules/@esbuild/win32-arm64": {
+ "version": "0.28.2",
+ "resolved": "https://registry.npmjs.org/@esbuild/win32-arm64/-/win32-arm64-0.28.2.tgz",
+ "integrity": "sha512-PIhhEkE9uPBleRBrQEJpUn7MBnibZzbGzYWPmY3x+YoVg/95zbjB4CxPPOQ8l5tYYM4mMaCthF8/1DIfBQQyWQ==",
+ "cpu": [
+ "arm64"
+ ],
+ "dev": true,
+ "license": "MIT",
+ "optional": true,
+ "os": [
+ "win32"
+ ],
+ "engines": {
+ "node": ">=18"
+ }
+ },
+ "node_modules/@esbuild/win32-ia32": {
+ "version": "0.28.2",
+ "resolved": "https://registry.npmjs.org/@esbuild/win32-ia32/-/win32-ia32-0.28.2.tgz",
+ "integrity": "sha512-YmJbfTlvU7Sdn9BB+4PRES4oB6pxgS37MAONj+hBr/cpXS1aBPKXxNnDbu+QCWPj0o9dgyxeq79g6c5P8KeuYA==",
+ "cpu": [
+ "ia32"
+ ],
+ "dev": true,
+ "license": "MIT",
+ "optional": true,
+ "os": [
+ "win32"
+ ],
+ "engines": {
+ "node": ">=18"
+ }
+ },
+ "node_modules/@esbuild/win32-x64": {
+ "version": "0.28.2",
+ "resolved": "https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.28.2.tgz",
+ "integrity": "sha512-5ebpxr3nWMzrL/rnUI755Jkuee0bHL/Gq0WTF9lvcpv73wAp5eu8MfBUgWK9bhWvZjj7yX8etf/8tI8Ney695g==",
+ "cpu": [
+ "x64"
+ ],
+ "dev": true,
+ "license": "MIT",
+ "optional": true,
+ "os": [
+ "win32"
+ ],
+ "engines": {
+ "node": ">=18"
+ }
+ },
+ "node_modules/echarts": {
+ "version": "5.5.1",
+ "resolved": "https://registry.npmjs.org/echarts/-/echarts-5.5.1.tgz",
+ "integrity": "sha512-Fce8upazaAXUVUVsjgV6mBnGuqgO+JNDlcgF79Dksy4+wgGpQB2lmYoO4TSweFg/mZITdpGHomw/cNBJZj1icA==",
+ "dev": true,
+ "license": "Apache-2.0",
+ "dependencies": {
+ "tslib": "2.3.0",
+ "zrender": "5.6.0"
+ }
+ },
+ "node_modules/esbuild": {
+ "version": "0.28.2",
+ "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.28.2.tgz",
+ "integrity": "sha512-HKVLS8dvII+xoKW9kmqxbRKrnWEXfJJr/FZhhJmiqIB0e053QNYFqOBouTMO/k5sID4MvCiUCvv8b9M4h32wIA==",
+ "dev": true,
+ "hasInstallScript": true,
+ "license": "MIT",
+ "bin": {
+ "esbuild": "bin/esbuild"
+ },
+ "engines": {
+ "node": ">=18"
+ },
+ "optionalDependencies": {
+ "@esbuild/aix-ppc64": "0.28.2",
+ "@esbuild/android-arm": "0.28.2",
+ "@esbuild/android-arm64": "0.28.2",
+ "@esbuild/android-x64": "0.28.2",
+ "@esbuild/darwin-arm64": "0.28.2",
+ "@esbuild/darwin-x64": "0.28.2",
+ "@esbuild/freebsd-arm64": "0.28.2",
+ "@esbuild/freebsd-x64": "0.28.2",
+ "@esbuild/linux-arm": "0.28.2",
+ "@esbuild/linux-arm64": "0.28.2",
+ "@esbuild/linux-ia32": "0.28.2",
+ "@esbuild/linux-loong64": "0.28.2",
+ "@esbuild/linux-mips64el": "0.28.2",
+ "@esbuild/linux-ppc64": "0.28.2",
+ "@esbuild/linux-riscv64": "0.28.2",
+ "@esbuild/linux-s390x": "0.28.2",
+ "@esbuild/linux-x64": "0.28.2",
+ "@esbuild/netbsd-arm64": "0.28.2",
+ "@esbuild/netbsd-x64": "0.28.2",
+ "@esbuild/openbsd-arm64": "0.28.2",
+ "@esbuild/openbsd-x64": "0.28.2",
+ "@esbuild/openharmony-arm64": "0.28.2",
+ "@esbuild/sunos-x64": "0.28.2",
+ "@esbuild/win32-arm64": "0.28.2",
+ "@esbuild/win32-ia32": "0.28.2",
+ "@esbuild/win32-x64": "0.28.2"
+ }
+ },
+ "node_modules/tslib": {
+ "version": "2.3.0",
+ "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.3.0.tgz",
+ "integrity": "sha512-N82ooyxVNm6h1riLCoyS9e3fuJ3AMG2zIZs2Gd1ATcSFjSA23Q0fzjjZeh0jbJvWVDZ0cJT8yaNNaaXHzueNjg==",
+ "dev": true,
+ "license": "0BSD"
+ },
+ "node_modules/zrender": {
+ "version": "5.6.0",
+ "resolved": "https://registry.npmjs.org/zrender/-/zrender-5.6.0.tgz",
+ "integrity": "sha512-uzgraf4njmmHAbEUxMJ8Oxg+P3fT04O+9p7gY+wJRVxo8Ge+KmYv0WJev945EH4wFuc4OY2NLXz46FZrWS9xJg==",
+ "dev": true,
+ "license": "BSD-3-Clause",
+ "dependencies": {
+ "tslib": "2.3.0"
+ }
+ }
+ }
+}
diff --git a/packages/page-usage-board/package.json b/packages/page-usage-board/package.json
new file mode 100644
index 0000000..2ad8c28
--- /dev/null
+++ b/packages/page-usage-board/package.json
@@ -0,0 +1,82 @@
+{
+ "name": "@magpie-community/page-usage-board",
+ "version": "0.1.0",
+ "description": "在 magpie 窗口里查看用量:额度到期卡片墙 + 每日/模型/provider 用量图表 + 可选远端归因,由插件自带的本机服务供数。A usage dashboard page in magpie's window: quota cards with expiry tiers, daily and per-provider charts, optional remote attribution, served by the plugin's own local service.",
+ "type": "module",
+ "main": "./index.mjs",
+ "files": [
+ "index.mjs",
+ "server.mjs",
+ "page",
+ "static",
+ "build",
+ "LICENSE",
+ "README.md",
+ "scripts",
+ "NOTICE",
+ "docs",
+ "LICENSES"
+ ],
+ "scripts": {
+ "start": "node server.mjs",
+ "test": "node --test",
+ "build:echarts": "node scripts/build-echarts.mjs",
+ "prepack": "node scripts/prepack.mjs"
+ },
+ "engines": {
+ "node": ">=22",
+ "magpie": ">=0.1.1340"
+ },
+ "keywords": [
+ "magpie",
+ "magpie-page",
+ "magpie-plugin",
+ "usage",
+ "dashboard",
+ "quota",
+ "charts",
+ "token"
+ ],
+ "license": "MIT",
+ "repository": {
+ "type": "git",
+ "url": "git+https://github.com/magpie-community/plugins.git",
+ "directory": "packages/page-usage-board"
+ },
+ "homepage": "https://github.com/magpie-community/plugins/tree/main/packages/page-usage-board",
+ "bugs": {
+ "url": "https://github.com/magpie-community/plugins/issues"
+ },
+ "magpie": {
+ "name": "Usage Board",
+ "summary": {
+ "en": "A quota card wall with expiry tiers, daily/per-provider charts, 24h cache-hit and token curves, optional remote attribution and account detail. Runs its own zero-dependency local service reading this machine's Magpie usage data; optional remote attribution queries the configured remote magpie.",
+ "zh": "额度到期卡片墙 + 每日与 provider 用量图表 + 24 小时缓存命中与 token 曲线,可选远端归因与账号明细。自带零依赖本机服务,读本机 Magpie 用量数据;远端归因会查询所配置的远端 magpie。"
+ },
+ "page": {
+ "title": "Usage Board",
+ "titles": {
+ "en": "Usage Board",
+ "zh": "用量看板"
+ },
+ "file": "page/index.html",
+ "icon": "page/icon.svg",
+ "service": {
+ "port": 3455,
+ "option": "port"
+ }
+ },
+ "permissions": [],
+ "options": {
+ "port": 3455,
+ "attribution": "local",
+ "remoteCallers": "",
+ "remoteProviders": "magpie-direct,magpie-cf,remote-magpie"
+ },
+ "icon": "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAxMDAgMTAwIj4KICA8IS0tIFVzYWdlIGJvYXJkOiBkYXJrIHJvdW5kZWQgcGxhdGUsIGJsdWUgdXNhZ2UgbGluZSwgb25lIGFtYmVyIGJhciAtLT4KICA8cmVjdCB4PSI0IiB5PSI0IiB3aWR0aD0iOTIiIGhlaWdodD0iOTIiIHJ4PSIyMCIgZmlsbD0iIzFlMjQzMCIvPgogIDwhLS0gYW1iZXIgYmFyIChxdW90YSB0b2RheSkgLS0+CiAgPHJlY3QgeD0iMjQiIHk9IjU2IiB3aWR0aD0iMTAiIGhlaWdodD0iMjQiIHJ4PSIzIiBmaWxsPSIjZjVhNjIzIi8+CiAgPCEtLSBibHVlIHVzYWdlIGxpbmUgb3ZlciB0aGUgbGFzdCBob3VycyAtLT4KICA8cG9seWxpbmUgcG9pbnRzPSIyMiw2NiAzNiw1MiA1MCw1OCA2NCwzOCA3OCwzMCIKICAgIGZpbGw9Im5vbmUiIHN0cm9rZT0iIzRjOWZmZSIgc3Ryb2tlLXdpZHRoPSI3IgogICAgc3Ryb2tlLWxpbmVjYXA9InJvdW5kIiBzdHJva2UtbGluZWpvaW49InJvdW5kIi8+CiAgPCEtLSBlbmRwb2ludCBkb3QgLS0+CiAgPGNpcmNsZSBjeD0iNzgiIGN5PSIzMCIgcj0iNS41IiBmaWxsPSIjNGM5ZmZlIi8+Cjwvc3ZnPgo="
+ },
+ "devDependencies": {
+ "echarts": "5.5.1",
+ "esbuild": "0.28.2"
+ }
+}
diff --git a/packages/page-usage-board/page/boot.js b/packages/page-usage-board/page/boot.js
new file mode 100644
index 0000000..0fcaa46
--- /dev/null
+++ b/packages/page-usage-board/page/boot.js
@@ -0,0 +1,114 @@
+// Navigate magpie's frame to the board service.
+//
+// Prefer window.magpie.service: magpie web proxies the service on its own address, so the
+// page stays under magpie's origin and magpie's own key/auth is the gate. A desktop window
+// has no service; fall back to loopback on the port from the manifest options — the same
+// value the service itself was started with, so they can never disagree.
+//
+// Do not probe the service: the page's CSP is connect-src 'none', so fetch/XHR is refused.
+// The progress bar here is therefore driven by two real signals only — the bridge handshake
+// (window.magpie.ready) and elapsed time. The meta refresh in index.html (8 s) is the last
+// fallback if this script never runs.
+(async () => {
+ const DEFAULT_PORT = 3455;
+ const words = {
+ en: {
+ title: "Usage Board",
+ bridging: "Connecting to the host bridge…",
+ slow: "Bridge is slow — opening the local board…",
+ err: (m) => `Bridge did not respond: ${m} — opening the local board…`,
+ nobridge: "No host bridge detected — opening the local board…",
+ ready: "Board located, navigating…",
+ readyLocal: "Ready — opening the local board…",
+ },
+ zh: {
+ title: "用量看板",
+ bridging: "正在连接宿主桥接…",
+ slow: "桥接响应慢,即将直接打开本机看板…",
+ err: (m) => `桥接未响应:${m} —— 将直接打开本机看板…`,
+ nobridge: "未检测到宿主桥接,直接打开本机看板…",
+ ready: "已定位看板服务,正在跳转…",
+ readyLocal: "已就绪,正在打开本机看板…",
+ },
+ };
+ let lang = String(navigator.language || "en").toLowerCase().startsWith("zh") ? "zh" : "en";
+ let port = DEFAULT_PORT;
+ let theme = ""; // magpie 自己的深浅色;空 = 看板回落 prefers-color-scheme
+ const bar = document.getElementById("bar");
+ const msg = document.getElementById("msg");
+ const say = (t, bad) => {
+ if (!msg) return;
+ msg.textContent = t;
+ msg.classList.toggle("bad", !!bad);
+ };
+ const setBar = (pct, bad) => {
+ if (!bar) return;
+ bar.style.width = pct + "%";
+ if (bar.parentElement) bar.parentElement.classList.toggle("bad", !!bad);
+ };
+ setBar(18);
+ // 桥接慢时进度条缓慢爬行,6 秒后预告回退(meta refresh 8 秒兜底)
+ const creep = setInterval(() => setBar(Math.min(38, (parseFloat(bar?.style.width) || 18) + 2.5)), 350);
+ let service = "";
+ let bridgeErr = "";
+ const hasBridge = !!window.magpie;
+ try {
+ const current = await window.magpie?.ready;
+ if (current) {
+ if (typeof current.lang === "string" && current.lang) {
+ lang = current.lang.toLowerCase().startsWith("zh") ? "zh" : "en";
+ }
+ if (typeof current.dark === "boolean") theme = current.dark ? "dark" : "light";
+ }
+ } catch (e) {
+ bridgeErr = (e && e.message) || "bridge handshake failed";
+ }
+ try {
+ const options = await window.magpie?.options?.get?.();
+ const n = Number(options?.port);
+ if (Number.isInteger(n) && n > 0 && n < 65536) port = n;
+ } catch {
+ // Use the declared default.
+ }
+ try {
+ const s = window.magpie?.service;
+ if (typeof s === "string" && /^https?:\/\//.test(s)) service = s;
+ } catch {
+ // Desktop windows navigate directly to loopback.
+ }
+ clearInterval(creep);
+ const w = words[lang];
+ document.title = w.title;
+ const head = document.querySelector(".box b");
+ if (head) head.textContent = w.title;
+ if (bridgeErr) {
+ // 桥接报错:如实展示原因,仍回退打开本机看板
+ setBar(30, true);
+ say(w.err(bridgeErr), true);
+ } else if (!hasBridge) {
+ setBar(72);
+ say(w.nobridge);
+ } else {
+ setBar(72);
+ say(service ? w.ready : w.readyLocal);
+ }
+ let target = service || `http://127.0.0.1:${port}/`;
+ // lang/theme 都通过 URL 带给看板(走 service 代理路径时同样要带——用 URL 拼接避免丢已有参数)
+ try {
+ const u = new URL(target, location.href);
+ u.searchParams.set("lang", lang);
+ if (theme) u.searchParams.set("theme", theme);
+ target = u.href;
+ } catch {
+ target += (target.includes("?") ? "&" : "?") + "lang=" + lang + (theme ? "&theme=" + theme : "");
+ }
+ const go = document.getElementById("go");
+ if (go) go.setAttribute("content", "0;url=" + target);
+ setTimeout(() => {
+ try {
+ location.replace(target);
+ } catch {
+ // The meta refresh above still navigates.
+ }
+ }, 350); // 让用户看清最终状态再跳
+})();
diff --git a/packages/page-usage-board/page/icon.svg b/packages/page-usage-board/page/icon.svg
new file mode 100644
index 0000000..b7e2f0d
--- /dev/null
+++ b/packages/page-usage-board/page/icon.svg
@@ -0,0 +1,12 @@
+
diff --git a/packages/page-usage-board/page/index.html b/packages/page-usage-board/page/index.html
new file mode 100644
index 0000000..d700d55
--- /dev/null
+++ b/packages/page-usage-board/page/index.html
@@ -0,0 +1,48 @@
+
+
+
+
+
+用量看板
+
+
+
+
+
+