Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 19 additions & 19 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ categories = ["network-programming", "web-programming::http-server"]

# 二进制走 CalVer,crate 走 SemVer —— 两者是两回事,卖给不同的人。
# 这里是 crate 的版本。
version = "0.69.0"
version = "0.70.0"

[workspace.dependencies]
# ── 内部 crate ───────────────────────────────────────────
Expand Down
26 changes: 26 additions & 0 deletions release-notes/0.70.0.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
This release reads each upstream's balance: the money left on a key, the quota of a relay key and its time windows, a key's limit and spend on OpenRouter, or the usage and limits a ThinkWatch Enterprise gateway reports for a key. It also records which upstreams were written by signing in to a Z.ai or BigModel account.

**Upgrade notes**

- The control-plane protocol version (`CONTROL_API_VERSION`) goes from 45 to 46. ThinkWatch Lite connects only to a core with the same protocol version: ThinkWatch Lite 2026.10.13 includes 0.69.0 (protocol 45) and does not connect to 0.70.0. A server used with it stays on 0.69.0 until the app is updated to a release that includes 0.70.0; `sudo twcore upgrade --version 0.69.0 --restart` switches a server back.
- The request store's schema is unchanged; nothing is cleared.
- Configuration: an upstream takes two new optional keys, `balance:` and `signed_in:`. Existing configurations load unchanged and read balances where the address is recognized.
- New message codes: `control.balance_none`, `gw.balance.rejected`, `gw.balance.status`, `gw.balance.unrecognized`, `gw.balance.timeout`, `gw.balance.connect`, `gw.balance.request_failed`.
- Changed in the protocol:
- `ProviderView` gains `balance` (the latest reading), `balance_setting` (what the configuration says) and `signed_in`; `ProviderInput` gains `balance`; `ProviderTestResult` gains `balance`.
- New types `Balance`, `BalanceQuota`, `BalanceWindow`, `BalanceScope`, `Spent`, `SpentPeriod`, `BalanceSetting`.
- New event `balance_updated` and endpoint `POST /providers/{name}/balance/refresh`: `404 control.balance_none` for an upstream with no balance to read, `502` with the reason when the source could not be determined because a request failed.

**Balances.** An upstream's `balance:` says where its balance is read from, with the upstream's own key and proxy: `openrouter`, `deepseek`, `moonshot`, `sub2api`, `newapi` (New API and One API) or `thinkwatch` (a ThinkWatch Enterprise gateway); `off` reads nothing. The default, `auto`, recognizes OpenRouter, DeepSeek and Moonshot by their address; any other address, except Anthropic's, OpenAI's and Gemini's own, is asked once whether it is a Sub2API relay, a New API relay or a ThinkWatch Enterprise gateway, and the answer is kept in memory only. ChatGPT and Z.ai accounts and Bedrock upstreams have no balance; their quota windows are reported as before.

A reading is one or more of: money left on the key (a wallet, in its own currency), a total quota with what has been used of it, time windows with their limits, use and reset time, and the money already spent. Per source:

- OpenRouter: the key's own limit, if it has one, and what the key spent this month (or in total), with the key's expiry. The account's credits need a management key and are not read.
- DeepSeek and Moonshot: the account balance, in its currency.
- Sub2API: the key's quota and its 5-hour, daily and weekly windows, or its subscription's windows, or the wallet balance; what was spent today is the amount actually charged.
- New API and One API: the key's quota and use, in the unit the site displays (US dollars, yuan or tokens, read from the site's public status); a site that does not say is marked as an unknown unit rather than dollars.
- ThinkWatch Enterprise: the key's limits and usage when the key has limits of its own, otherwise the account's limits and its total over all of its keys, each limit saying which.

Balances are read at start, at most once a minute after requests through that upstream end, every ten minutes otherwise, and on request; **Check connection** also reads the balance and runs the recognition for `auto`, waiting at most five seconds for it. A failed read keeps the previous reading and says why; reading a balance never affects forwarding. Requests go only to the upstream's own address, through its proxy, and redirects are not followed.

**Z.ai and BigModel sign-in.** An upstream written by signing in to a Z.ai or BigModel account now carries `signed_in: zai` or `signed_in: bigmodel`, and `ProviderView.signed_in` says so, so an app can show it as an account sign-in. Signing in again sets it on upstreams written before this release. Saving the upstream with the same key keeps it; replacing or removing the key clears it.
Loading