@magpie-community/opencode-trae-auth 0.1.4 → 0.1.6
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 +3 -2
- package/index.mjs +30 -4
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -105,8 +105,9 @@ magpie's usage card shows the account's credits:
|
|
|
105
105
|
- **Source:** `api.trae.cn/trae/api/v2/pay/ide_user_ent_usage`.
|
|
106
106
|
- **What it adds up:** each entitlement pack's `credits_limit` (-1 means
|
|
107
107
|
unlimited) and what the pack has used.
|
|
108
|
-
- **What it shows:**
|
|
109
|
-
|
|
108
|
+
- **What it shows:** one Credits window: the credits used of the packs'
|
|
109
|
+
total, with the share, which magpie shows as used or left like
|
|
110
|
+
WorkBuddy's.
|
|
110
111
|
|
|
111
112
|
## Daily check-in
|
|
112
113
|
|
package/index.mjs
CHANGED
|
@@ -881,8 +881,11 @@ export const TraeCNAuthPlugin = async ({ client }) => {
|
|
|
881
881
|
const out = { plan: r.v.is_credits_billing ? "Credits" : "Free", user: a.name || a.uid, signIn }
|
|
882
882
|
if (c.unlimited) out.balance = "unlimited"
|
|
883
883
|
else if (c.limit > 0) {
|
|
884
|
-
|
|
885
|
-
|
|
884
|
+
// the count rides on the window (amount of limit, in credits), as
|
|
885
|
+
// WorkBuddy's does, so magpie says it in the window's row, used or
|
|
886
|
+
// left, in its own words and number format, rather than as an
|
|
887
|
+
// English balance line beside it (yetone/magpie#694)
|
|
888
|
+
const w = { name: "Credits", used: Math.max(0, Math.min(100, (c.used / c.limit) * 100)), amount: round(c.used), limit: round(c.limit), unit: "credits" }
|
|
886
889
|
if (c.until) w.resetsAt = new Date(c.until).toISOString()
|
|
887
890
|
out.windows = [w]
|
|
888
891
|
}
|
|
@@ -930,7 +933,8 @@ export const TraeCNAuthPlugin = async ({ client }) => {
|
|
|
930
933
|
// The lists come from batch_get_detail_param, as TRAE SOLO CN asks them;
|
|
931
934
|
// when that gives none, from get_detail_param, one function at a time.
|
|
932
935
|
// A model several functions list is asked through the first whose entry
|
|
933
|
-
// names a __dev model (one Trae serves), else the
|
|
936
|
+
// names a __dev model (one Trae serves) and isn't misnamed, else the
|
|
937
|
+
// first that names one, else the first.
|
|
934
938
|
const liveModels = async (a) => {
|
|
935
939
|
let lists = null
|
|
936
940
|
try {
|
|
@@ -948,13 +952,35 @@ export const TraeCNAuthPlugin = async ({ client }) => {
|
|
|
948
952
|
if (g.status === "fulfilled") lists[FUNCTIONS[i]] = g.value
|
|
949
953
|
})
|
|
950
954
|
}
|
|
955
|
+
// a function can give a model another's name: chat_v3 calls
|
|
956
|
+
// deepseek-v4.1-flash "DeepSeek-V4-Flash 正式版", as it does
|
|
957
|
+
// DeepSeek-V4-Flash-Official, where SOLO's lists call it
|
|
958
|
+
// DeepSeek-V4.1-Flash (yetone/magpie#681) — Trae's usage page then books
|
|
959
|
+
// it under that name too. Such an entry is misnamed: its name is another
|
|
960
|
+
// model's in the same list, and other lists name it otherwise.
|
|
961
|
+
const nameOf = (m) => String(m.display_config?.display_name || m.display_name || m.display_model_name || m.config_name)
|
|
962
|
+
const names = new Map() // id → the names its lists give it
|
|
963
|
+
for (const fn of FUNCTIONS) {
|
|
964
|
+
for (const m of lists[fn] ?? []) {
|
|
965
|
+
if (!chatModel(m)) continue
|
|
966
|
+
const id = String(m.config_name)
|
|
967
|
+
names.set(id, (names.get(id) ?? new Set()).add(nameOf(m)))
|
|
968
|
+
}
|
|
969
|
+
}
|
|
970
|
+
const misnamed = (fn, m) => {
|
|
971
|
+
const id = String(m.config_name), name = nameOf(m)
|
|
972
|
+
return names.get(id).size > 1 && (lists[fn] ?? []).some((o) => chatModel(o) && String(o.config_name) !== id && nameOf(o) === name)
|
|
973
|
+
}
|
|
974
|
+
// a function's entry is worth more when it names a __dev model, then
|
|
975
|
+
// when it isn't misnamed; the first of the best is taken
|
|
976
|
+
const worth = (fn, m) => (devModel(m) ? 2 : 0) + (misnamed(fn, m) ? 0 : 1)
|
|
951
977
|
const out = new Map()
|
|
952
978
|
for (const fn of FUNCTIONS) {
|
|
953
979
|
for (const m of lists[fn] ?? []) {
|
|
954
980
|
if (!chatModel(m)) continue
|
|
955
981
|
const id = String(m.config_name)
|
|
956
982
|
const was = out.get(id)
|
|
957
|
-
if (!was || (
|
|
983
|
+
if (!was || worth(fn, m) > was.worth) out.set(id, { m, fn, worth: worth(fn, m) })
|
|
958
984
|
}
|
|
959
985
|
}
|
|
960
986
|
for (const [id, { m, fn }] of out) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@magpie-community/opencode-trae-auth",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.6",
|
|
4
4
|
"description": "OpenCode provider plugin for Trae CN (trae.cn): your Trae CN account's models, free tier included, with Trae's own browser sign-in",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./index.mjs",
|