tokensOf kept only prompt_tokens, completion_tokens and total_tokens of Trae's token_usage, so every request reached magpie with no cache count and Usage/Routing showed 0 hits. Trae's event carries more: TRAE SOLO CN 3.5.20's ai-agent (libai_agent.dylib, the serde field list of infrastructure/adapter/llm/event.rs's TokenUsageEvent, read from the binary's __DATA_CONST) is name, prompt_tokens, completion_tokens, total_tokens, reasoning_tokens, cache_creation_input_tokens, cache_read_input_tokens, prompt_tokens_total, completion_tokens_total. cache_read_input_tokens and cache_creation_input_tokens now go on in the OpenAI usage under those names; magpie's gateway (chat.go cUsage) reads them beside prompt_tokens as it reads a relay's in front of Claude, and judges there whether prompt_tokens counts them too. An OpenAI prompt_tokens_details.cached_tokens, if Trae sends one, is kept as it came, and reasoning_tokens goes as completion_tokens_details. No cache count adds no field. cache.test.mjs (stream and single answer with the TokenUsageEvent's fields, OpenAI's details, none) fails 3 of 4 on 0.2.11 and passes; bun test (113 pass) and bun scripts/check.mjs trae under a temp HOME pass. Not tried with a real Trae account (none here): that Trae fills the cache fields for K3 in particular is not known.
13 lines
592 B
JSON
13 lines
592 B
JSON
{
|
|
"name": "@magpie-community/opencode-trae-auth",
|
|
"version": "0.2.12",
|
|
"description": "OpenCode provider plugins for Trae: Trae CN (trae.cn) and Trae Global (trae.ai), free tier included, with Trae's own browser sign-in",
|
|
"type": "module",
|
|
"main": "./index.mjs",
|
|
"exports": "./index.mjs",
|
|
"files": ["index.mjs", "README.md"],
|
|
"keywords": ["opencode", "opencode-plugin", "magpie", "trae", "trae-cn", "trae-global", "bytedance"],
|
|
"license": "MIT",
|
|
"repository": { "type": "git", "url": "git+https://github.com/magpie-community/plugins.git", "directory": "packages/trae" }
|
|
}
|