@magpie-community/opencode-trae-auth 0.2.25 → 0.2.26
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +13 -3
- package/index.mjs +18 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -113,7 +113,11 @@ agent's `POST https://trae-api-cn.mchost.guru/api/agent/v3/llm_utils_chat`:
|
|
|
113
113
|
What `token_usage` says the prompt cache read and wrote
|
|
114
114
|
(`cache_read_input_tokens`, `cache_creation_input_tokens`) goes on under
|
|
115
115
|
those names, and `reasoning_tokens` as
|
|
116
|
-
`completion_tokens_details.reasoning_tokens`.
|
|
116
|
+
`completion_tokens_details.reasoning_tokens`. DeepSeek's
|
|
117
|
+
`prompt_cache_hit_tokens` and `cached_tokens` are read as cache reads
|
|
118
|
+
too. A `token_usage` that names no cache count at all goes on with
|
|
119
|
+
`magpie_cache_unknown: true`, so magpie shows the cache as unknown,
|
|
120
|
+
not as a 0% miss (0.2.26).
|
|
117
121
|
`done`'s `finish_reason` `length`/`max_tokens` is OpenAI's `length`.
|
|
118
122
|
- Queue events are ignored.
|
|
119
123
|
- A `{"reasoning_content": …}` object written into the text is reasoning,
|
|
@@ -458,8 +462,14 @@ answered it 9074 even with the client's headers.
|
|
|
458
462
|
machine whose two profiles (`Trae CN`, `TRAE SOLO CN`) were both the
|
|
459
463
|
first account's; it checked in and the second got 9074, which took
|
|
460
464
|
running `clientDevice` by hand to explain. A profile started with its
|
|
461
|
-
own `--user-data-dir` is
|
|
462
|
-
|
|
465
|
+
own `--user-data-dir` is not read, and there is no reason to: on
|
|
466
|
+
2026-10-29 TRAE CN 3.4.4 (Windows 11) kept a second account's sign-in
|
|
467
|
+
apart in such a folder but gave it the same device id as the default
|
|
468
|
+
folder, and the client itself said 「本设备今日已签到」 for that
|
|
469
|
+
account. The check-in is counted per device, so on one machine only the
|
|
470
|
+
first account to check in gets the day's credits; the others' usage,
|
|
471
|
+
models and requests are unaffected (plugins#436, closed as not
|
|
472
|
+
planned).
|
|
463
473
|
- **A claim's code 0 is not the answer (0.2.22):** Trae answers a
|
|
464
474
|
claim code 0 for one that registered nothing, so the status is read back
|
|
465
475
|
after every claim and only a day that is in is reported as `claimed`.
|
package/index.mjs
CHANGED
|
@@ -1479,6 +1479,22 @@ const eventName = (s) =>
|
|
|
1479
1479
|
// Claude (whether prompt_tokens counts them too is judged there, by
|
|
1480
1480
|
// whether it is at least as big); without them every request read as no
|
|
1481
1481
|
// cache hit (01huadalang on magpie's Discord: K3, 53 calls, all 0)
|
|
1482
|
+
//
|
|
1483
|
+
// A count that names no cache at all — Trae's token_usage as
|
|
1484
|
+
// {"prompt_tokens":1717,"completion_tokens":2,"total_tokens":1719}, a shape
|
|
1485
|
+
// plugins#455 captured from Trae — says magpie_cache_unknown, as the Kiro
|
|
1486
|
+
// plugin does: Trae didn't say what its cache read, so magpie shows no hit
|
|
1487
|
+
// rate rather than a 0% Trae never gave. Before, it and a count of 0 both
|
|
1488
|
+
// went on with no cache field, which magpie can only read as a miss, so
|
|
1489
|
+
// since 10-28 every chat showed 0 (yetone/magpie#3979, #3991; plugins#434
|
|
1490
|
+
// says Trae stopped sending cache_read_input_tokens then). A count naming
|
|
1491
|
+
// the cache, a 0 included, is Trae's own word and goes as before.
|
|
1492
|
+
// DeepSeek's prompt_cache_hit_tokens, a bare cached_tokens and the
|
|
1493
|
+
// Responses-style input_tokens_details are read too, the largest of them,
|
|
1494
|
+
// should Trae pass a model's own usage on.
|
|
1495
|
+
const CACHE_NAMED = ["cache_read_input_tokens", "cacheReadInputTokens", "cache_creation_input_tokens", "cacheCreationInputTokens", "prompt_cache_hit_tokens", "cached_tokens"]
|
|
1496
|
+
const namesCache = (u) =>
|
|
1497
|
+
CACHE_NAMED.some((k) => u[k] != null) || u.prompt_tokens_details?.cached_tokens != null || u.input_tokens_details?.cached_tokens != null
|
|
1482
1498
|
function tokensOf(u) {
|
|
1483
1499
|
if (!u || typeof u !== "object") return null
|
|
1484
1500
|
const n = (...v) => Number(v.find((x) => x != null) ?? 0) || 0
|
|
@@ -1486,9 +1502,10 @@ function tokensOf(u) {
|
|
|
1486
1502
|
const c = n(u.completion_tokens, u.output_tokens, u.completionTokens, u.outputTokens)
|
|
1487
1503
|
if (!p && !c) return null
|
|
1488
1504
|
const out = { prompt_tokens: p, completion_tokens: c, total_tokens: n(u.total_tokens, u.totalTokens) || p + c }
|
|
1489
|
-
const read =
|
|
1505
|
+
const read = Math.max(...[u.prompt_tokens_details?.cached_tokens, u.input_tokens_details?.cached_tokens, u.prompt_cache_hit_tokens, u.cached_tokens].map((x) => Number(x) || 0))
|
|
1490
1506
|
const write = n(u.prompt_tokens_details?.cache_write_tokens)
|
|
1491
1507
|
if (read || write) out.prompt_tokens_details = { cached_tokens: read, ...(write ? { cache_write_tokens: write } : {}) }
|
|
1508
|
+
else if (!namesCache(u)) out.magpie_cache_unknown = true
|
|
1492
1509
|
else {
|
|
1493
1510
|
const r = n(u.cache_read_input_tokens, u.cacheReadInputTokens)
|
|
1494
1511
|
const w = n(u.cache_creation_input_tokens, u.cacheCreationInputTokens)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@magpie-community/opencode-trae-auth",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.26",
|
|
4
4
|
"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",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./index.mjs",
|