Skip to content

page-token-receipt 0.1.0: your usage printed by a paper-receipt printer (page) - #1167

Open
maxlee wants to merge 1 commit into
magpie-community:mainfrom
maxlee:add-token-receipt
Open

maxlee wants to merge 1 commit into
magpie-community:mainfrom
maxlee:add-token-receipt

Conversation

@maxlee

@maxlee maxlee commented Nov 14, 2026

Copy link
Copy Markdown

Adds @magpie-community/page-token-receipt, a page that prints your AI usage as a receipt
fed by a paper printer.

What it does

  • Periods: day, calendar week, calendar month, last 7 / 30 / 90 days, all time.
  • One row per model (merged across agents and providers), by tokens; a day prints 4
    rows, a week 6, a month or longer 8, the rest folded into "+N more models".
  • Input / output / cache read / cache write as token counts, the cost, requests, errors,
    the agents with their logos (redrawn in one ink), a bill number.
  • USD, CNY (magpie's own rate) or JPY (a fixed, dated reference rate).
  • Save PNG and Copy image through magpie.image, painted at 3x.
  • English, 简体中文, 繁體中文, 日本語; light and dark; period and currency kept in options.

It is a port of my own dsh-token-receipt (MIT)
to magpie's page API.

Permissions and network

  • Reads only usage:day (magpie.permissions: ["usage:day"]).
  • No network: fonts, the magpie mark and the paper textures are data the page carries.
  • No main, no exports, no runtime dependencies, no inline scripts.
  • Needs magpie >= 0.1.3427 (usage:day with from spans, and magpie.image), like Day card.

How it differs from Day card

Day card also prints usage as a receipt from usage:day, so I'd like to be upfront about
the overlap. What this page does that Day card doesn't: the printer and its stepped paper
feed instead of a card on a backdrop; the calendar week and month (Day card's are the
last 7 and 30 days); last 90 days; USD / CNY / JPY switching; models merged by name with a
row budget per period; agents' logos in one ink; 繁體中文. What Day card does that this
doesn't: streak, the day against your average day, backdrops. The package README has the
table. If you'd rather these live in Day card, I'm happy to talk about that instead.

Files

  • packages/token-receipt/: the package, with its test (token-receipt.test.mjs).
  • README.md: a row in the Pages table.
  • registry.json: the entry (kind: "page", community: true).

Checks run

  • HOME=$(mktemp -d) bun test packages/token-receipt: 38 pass. The page tests check that
    the scripts read only what permissions declares and reach no network, that
    index.html loads every script as a file with no inline script, and that the fonts'
    licenses and the NOTICE ship with the package.
  • HOME=$(mktemp -d) bun test on the whole repo: 8898 pass, 9 skip, 0 fail.
  • bun scripts/check.mjs token-receipt: passes.
  • scripts/try.sh token-receipt: magpie 0.1.4095 loads it as a page.
  • Used in magpie 0.1.4095 on macOS (magpie web); the desktop app's WebKit window is
    not covered by these checks.

After merge

First npm publish (and its Trusted Publisher) is for an org owner; until then magpie
installs from dist, as usual.

A page that prints a day, calendar week or month, the last 7/30/90 days or all
of your usage as a receipt: cost per model, tokens and the agents behind them,
in USD, CNY or JPY, saved as a PNG or copied as a picture. Reads only usage:day.
@yetone

yetone commented Nov 14, 2026

Copy link
Copy Markdown
Contributor

Thanks for this. Holding it for the maintainer before a line-by-line review: it ships an embedded font bundle (page/fonts.js), and bundled binaries need the maintainer's look first. It's also a new package, whose first npm publish the maintainer does. I'll review and run it once they've looked.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants