Files
yetone 3d0a546aa3 usage 0.1.1: the tab is named in the window's language, and the tiles fill four across or two by two
magpie.page.titles names the page in zh, zh-TW, ja and de; a magpie that
doesn't know titles still reads title. The tiles were auto-fill, which left
a hole in their row at most widths; now four across, two by two under 640px.

Run: bun test in packages/usage (6 pass). Tried in the magpie sandbox app's
dev UI with the real usage.jsonl, WebKit, dark and light, zh and en, at
900 and 560px.
2026-10-16 18:13:05 +08:00

1.7 KiB
Raw Permalink Blame History

@magpie-community/page-usage

A page in magpie's window with your usage at a glance. It shows calls, errors, tokens and cost for today, 7 days or 30 days, and the models that took them.

Install it from magpie's Plugins › Discover, or with magpie plugin add @magpie-community/page-usage. It then has a tab, Usage glance (titled in the window's language: 用量速览, 用量速覽, 使用量の概要, Nutzung im Überblick), under Plugins in the sidebar, in the app and in magpie web.

What it reads

Only usage:summary, the one permission its package.json declares (magpie.permissions). That is magpie's totals for a period, and the top models in it. magpie refuses any other read the page asks for.

Like every plugin page, it runs in a sandboxed frame. It has no network (connect-src 'none'), no inline scripts, and no access to magpie's API except through _magpie/bridge.js.

Options

{ "period": "today", "sort": "tokens" }

The page saves the period (today, 7d, 30d) and the model sort (tokens, calls, cost) you last picked, so it opens the same next time.

Files

  • page/index.html, page/style.css: the page. It takes magpie's theme from the --magpie-* variables, light or dark.
  • page/view.js: what the numbers and rows say, in English and Chinese, with no DOM. The test loads it.
  • page/app.js: reads through the bridge, draws, and refreshes every minute.

Test

bun test packages/usage

中文:在 magpie 窗口里加一个「用量速览」页面,一眼看到今天、7 天或 30 天的调用、错误、token 和费用,以及用到的模型。它只读取声明过的 usage:summary,运行在无网络的沙盒 frame 里。