Files
magpie/docs/subsystems
yetone 1d016ee3f3 provider, gui: Token Plan 企业版 shows its usage on the Usage page, read with the account's SecretId and SecretKey (#1574, undirectlookable)
#1574 asks for Tencent Cloud Token Plan's usage on the Usage page through
TokenHub's cloud API (api/1823/132270). That API covers the enterprise
plan only (Token Plan 企业版; the previous commit added its regions). The
personal plan (api.lkeap.cloud.tencent.com/plan) has no usage API, only
the console, so it has no card. The API takes the account's API key, a
SecretId and SecretKey signed TC3-HMAC-SHA256, never the plan's sk- key.

provider (tencent_usage.go):
- A provider at /plan on tokenhub.tencentmaas.com (ap-guangzhou) or
  tokenhub-intl.tencentmaas.com (ap-singapore) with a SecretId and
  SecretKey gets a card per team plan in PlanQuotas
  (tencentPlanQuotas), each key and region asked once.
- It asks DescribeTokenPlanList, then DescribeTokenPlan per plan
  (version 2026-03-22), all at tokenhub.tencentcloudapi.com. Where a
  reply leaves a part out, the list's copy of it is kept.
- The window is TotalUsed of CycleQuota (else TotalQuota), in credits
  (专业套餐) or tokens (轻享套餐, enterprise-auto). It resets at
  TokenSummary.CycleEndTime. Without that, it counts months from
  StartTime and stops at ExpireTime.
- The docs don't say whether TotalUsed is the cycle's or the package's.
  This reads it as the cycle's.
- A plan that isn't enable shows its status beside the plan's name.
- An AuthFailure or UnauthorizedOperation reply says to check the key and
  its CAM rights. No plan visible to the key says so (a sub-user sees
  only the plans it made).
- The SecretId and SecretKey sit in the AccessKeyID and SecretAccessKey
  fields Volcengine's access key uses (#1427). They are stored, kept out
  of key-less backups and dropped from cached cards the same way.
  AccessKeyVendor tells the two vendors apart.

gui:
- The listing tells whose access key a provider or preset takes.
  presetAccessKey lists the regions that take one: Tencent Cloud's two
  Enterprise regions.
- The editor names the fields SecretId and SecretKey, with Tencent's
  hint, and shows them only at those regions (or at an endpoint none of
  the regions has).
- A SecretId with no SecretKey is refused only where the fields are
  shown. The new strings are in zh, zh-TW, ja and de.
- docs/subsystems/providers-accounts.md and the GUI tests README describe
  it.

Run:
- TestTC3SignMatchesDoc pins the signing doc's worked example (payload
  hash 35e9c5b0…, Signature 10b1a37a…).
- TestTencentPlanRegion, TestTencentPlanWindow and TestTencentPlanQuotas
  use the API docs' own response examples. The last is an httptest fake
  that rechecks each TC3 signature and the X-TC-* headers, and fails if
  the plan's key is ever sent.
- TestProviderListTellsTencentAccessKey covers the listing, alongside
  TestVolc* and TestPlanQuotas.
- Breaking the action's lowercasing in the signature, or dropping
  TokenSummary, turns them red.
- GUI: tencent-access-key.test.cjs (new) 12/12 in Chromium and WebKit at
  420px, en and zh. It goes red with the region hook or the vendor
  labels taken out. volc-access-key, tencent-cloud, i18n-keys, gui-ja
  and gui-de pass.
- gofmt; go vet on darwin, linux and windows; the full go test ./...

Not tried against the real API: we have no Tencent Cloud account. What
is read is what the docs show, and the reporter is asked to try it.
2026-10-11 13:06:28 +08:00
..

Subsystem design references

These pages describe current responsibilities, runtime paths, state, and contracts. Start with the subsystem relevant to your task, then follow its source links to verify the implementation you change.

Subsystem Reference
Built-in subscriptions moving to plugins Provider and plugin ownership
Plugins that run on the gateway's requests and replies Gateway middleware
Claude subscription turns across Claude Code runs Claude subscription bridge
How the gateway picks a provider, key or account, and falls back Gateway routing and fallback
Gateway Session Aggregation Gateway Session Aggregation
Connecting an agent's config to the gateway, drift, disconnect, WSL twins Agent wiring
Providers, keys, subscription accounts, refresh and allowance Providers and accounts
Instructions, MCP servers, skills and RTK written into agents Library
Tray, panel, window, magpie web and the page's JSON API GUI app shell

A subsystem can span several packages or repositories. Its reference describes the behavior those parts provide together; it does not need to list every function.

Maintain a reference

Update the owning reference in the same PR when a change alters a documented responsibility, interface, state transition, runtime path, compatibility rule, or failure behavior. An internal refactor that preserves these contracts does not require a prose change.

Keep each fact in one reference and link to it from agent instructions or other pages. Link to source files and named symbols rather than copying implementation details that change frequently. Explain field meanings and constraints that signatures alone do not express.

For a new reference, include the responsibilities and boundaries, source of truth, main runtime paths, state transitions, important constraints, and existing verification commands. Include failure and compatibility behavior where relevant. Document current behavior separately from proposed changes; the proposal belongs in its issue or PR.

Describe a PR's semantic changes

For each affected subsystem, explain the observable change with its trigger and before/after behavior. Include changes to interfaces, state, compatibility, and failure behavior when relevant. Link the affected reference, implementation, and verification evidence. State when a refactor preserves the documented behavior.

For example, a change to plugin adoption should explain which migration state and account condition trigger it, which implementation handles requests before and after adoption, and which test exercises that transition.

This is an author-provided explanation that a reviewer verifies against the diff and surrounding code. It is not an automatically proven compatibility verdict.

Review a change

  1. Identify the affected subsystem and the actual runtime path, including plugin or built-in ownership.
  2. Compare the claimed before/after behavior with the base and head implementation. Trace relevant callers and state transitions beyond the changed lines.
  3. Check that changed contracts appear in the owning reference and that source links still resolve.
  4. Check that the cited tests or runtime evidence exercise the claimed behavior. Report checks that were not run.

A documentation update alone does not prove the implementation. Existing tests and runtime evidence remain necessary for behavior changes.