@magpie-community/opencode-trae-auth 0.1.14 → 0.1.15
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 +4 -2
- package/index.mjs +30 -13
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -80,10 +80,12 @@ TRAE agent list models `chat_v3` doesn't (deepseek-v4.1-flash is the TRAE
|
|
|
80
80
|
agent's, `solo_agent`). Left out are the IDE's helpers (`usage` other than
|
|
81
81
|
`chat_completion`: summary, fast_apply…), configs switched off and the
|
|
82
82
|
custom-model slots. Context is the list's `context_window_tokens.dev`,
|
|
83
|
-
output the `__dev` model's `max_tokens`. A
|
|
83
|
+
output the `__dev` model's `max_tokens`. A model with a `__max` model and
|
|
84
84
|
a bigger `context_window_tokens.max` is listed again as its Max,
|
|
85
85
|
`<id>-max` ("… (Max)"), with that window and the `__max` model's
|
|
86
|
-
`max_tokens`;
|
|
86
|
+
`max_tokens`; the two can come from different functions' lists (chat_v3
|
|
87
|
+
can name the `__max` model, a SOLO list the windows). It asks the
|
|
88
|
+
`__max` model through the function that names it, with `max_tokens` set
|
|
87
89
|
and `user_message_context.model_info.prompt_max_tokens` the window less
|
|
88
90
|
it, as Max mode does.
|
|
89
91
|
|
package/index.mjs
CHANGED
|
@@ -1133,14 +1133,21 @@ function chatModel(m) {
|
|
|
1133
1133
|
// devModel is the model an entry serves requests with: its __dev one
|
|
1134
1134
|
const devModel = (m) => (Array.isArray(m?.model_detail_list) ? m.model_detail_list : []).find((d) => /__dev$/.test(String(d?.model_name ?? "")))
|
|
1135
1135
|
|
|
1136
|
-
// maxModel is a
|
|
1137
|
-
//
|
|
1138
|
-
//
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1136
|
+
// maxModel is a model's Max mode, from the entries its lists give it (the
|
|
1137
|
+
// one it is asked through first): the first __max model one names, and the
|
|
1138
|
+
// window context_window_tokens.max gives it, when that is bigger than dev's.
|
|
1139
|
+
// The lists needn't agree: chat_v3 can name the __max model while the SOLO
|
|
1140
|
+
// list the model is asked through names only __dev, and the window can be
|
|
1141
|
+
// another entry's again. A model with no __max, or no bigger window, has no
|
|
1142
|
+
// Max.
|
|
1143
|
+
const maxModel = (...ms) => {
|
|
1144
|
+
const details = (m) => (Array.isArray(m?.model_detail_list) ? m.model_detail_list : [])
|
|
1145
|
+
const at = ms.find((m) => details(m).some((d) => /__max$/.test(String(d?.model_name ?? ""))))
|
|
1146
|
+
if (!at) return null
|
|
1147
|
+
const d = details(at).find((d) => /__max$/.test(String(d?.model_name ?? "")))
|
|
1148
|
+
const first = (k) => [at, ...ms].map((m) => Number(m?.context_window_tokens?.[k]) || 0).find((n) => n > 0) || 0
|
|
1149
|
+
const window = first("max")
|
|
1150
|
+
return window > first("dev") ? { name: String(d.model_name), most: Number(d.max_tokens) || 0, window, entry: at } : null
|
|
1144
1151
|
}
|
|
1145
1152
|
|
|
1146
1153
|
// MAX is the suffix of a model's Max: deepseek-v4.1-flash-max is
|
|
@@ -1186,6 +1193,8 @@ export const TraeCNAuthPlugin = async ({ client }) => {
|
|
|
1186
1193
|
// model it names there
|
|
1187
1194
|
const listedBy = new Map()
|
|
1188
1195
|
const modelNames = new Map()
|
|
1196
|
+
// the Max each model the list last read has (null: none)
|
|
1197
|
+
const maxes = new Map()
|
|
1189
1198
|
|
|
1190
1199
|
const save = async (auth) => {
|
|
1191
1200
|
try {
|
|
@@ -1402,10 +1411,18 @@ export const TraeCNAuthPlugin = async ({ client }) => {
|
|
|
1402
1411
|
const dev = devModel(m)
|
|
1403
1412
|
if (dev) modelNames.set(id, { fn, name: dev.model_name, most: Number(dev.max_tokens) || 0 })
|
|
1404
1413
|
else modelNames.delete(id)
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1414
|
+
if (out.has(id + MAX)) continue
|
|
1415
|
+
// its Max is asked through the function whose entry names the __max model
|
|
1416
|
+
const entries = [{ m, fn }, ...FUNCTIONS.flatMap((f) => (lists[f] ?? []).filter((o) => o !== m && chatModel(o) && String(o.config_name) === id).map((o) => ({ m: o, fn: f })))]
|
|
1417
|
+
const max = maxModel(...entries.map((e) => e.m))
|
|
1418
|
+
maxes.set(id, max)
|
|
1419
|
+
if (max) {
|
|
1420
|
+
const by = entries.find((e) => e.m === max.entry).fn
|
|
1421
|
+
listedBy.set(id + MAX, by)
|
|
1422
|
+
modelNames.set(id + MAX, { fn: by, name: max.name, most: max.most, max: { base: id, window: max.window } })
|
|
1423
|
+
} else {
|
|
1424
|
+
listedBy.delete(id + MAX)
|
|
1425
|
+
modelNames.delete(id + MAX)
|
|
1409
1426
|
}
|
|
1410
1427
|
}
|
|
1411
1428
|
return [...out.values()].map((x) => x.m)
|
|
@@ -1445,7 +1462,7 @@ export const TraeCNAuthPlugin = async ({ client }) => {
|
|
|
1445
1462
|
return Object.fromEntries(ms.flatMap((m) => {
|
|
1446
1463
|
const id = String(m.config_name)
|
|
1447
1464
|
const own = modelOf(provider, m)
|
|
1448
|
-
const max =
|
|
1465
|
+
const max = maxes.get(id)
|
|
1449
1466
|
if (!max || ids.has(id + MAX)) return [[id, own]]
|
|
1450
1467
|
// its Max, a model of its own: the window and output Max mode gives
|
|
1451
1468
|
const was = provider.models?.[id + MAX] ?? {}
|
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.15",
|
|
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",
|