@magpie-community/opencode-trae-auth 0.2.6 → 0.2.7

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.
Files changed (3) hide show
  1. package/README.md +9 -1
  2. package/index.mjs +28 -9
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -138,7 +138,15 @@ a bigger `context_window_tokens.max` is listed again as its Max,
138
138
  can name the `__max` model, a SOLO list the windows). It asks the
139
139
  `__max` model through the function that names it, with `max_tokens` set
140
140
  and `user_message_context.model_info.prompt_max_tokens` the window less
141
- it, as Max mode does.
141
+ it, as Max mode does. The lists needn't agree on a model's *name*: chat_v3
142
+ calls deepseek-v4.1-flash "DeepSeek-V4-Flash 正式版", as it once called
143
+ DeepSeek-V4-Flash-Official, where the SOLO lists call it
144
+ "DeepSeek-V4.1-Flash" (yetone/magpie#681). Trae's usage page books a
145
+ request under the name of the list it was served through, so the plugin
146
+ takes the name most of a model's lists give — the one Trae's own client is
147
+ served under — and asks that model, and its Max, through a list carrying
148
+ it. Trae renamed its official entries on 2026-10-09, leaving the name its
149
+ lists mostly agree on the only thing that tells a misnamed entry apart.
142
150
 
143
151
  Reasoning: the models reason, but Trae's request takes no effort or
144
152
  thinking level, so the plugin lists no variants and a level an agent
package/index.mjs CHANGED
@@ -2042,24 +2042,40 @@ const makePlugin = (site) => async ({ client }) => {
2042
2042
  // deepseek-v4.1-flash "DeepSeek-V4-Flash 正式版", as it does
2043
2043
  // DeepSeek-V4-Flash-Official, where SOLO's lists call it
2044
2044
  // DeepSeek-V4.1-Flash (yetone/magpie#681) — Trae's usage page then books
2045
- // it under that name too. Such an entry is misnamed: its name is another
2046
- // model's in the same list, and other lists name it otherwise.
2045
+ // a request under the name of the list it was served through. Such an
2046
+ // entry is misnamed: its name is another model's in the same list, and
2047
+ // other lists name it otherwise.
2047
2048
  const nameOf = (m) => String(m.display_config?.display_name || m.display_name || m.display_model_name || m.config_name)
2048
- const names = new Map() // id → the names its lists give it
2049
+ const names = new Map() // id → the names its lists give it, and how many give each
2049
2050
  for (const fn of site.functions) {
2050
2051
  for (const m of lists[fn] ?? []) {
2051
2052
  if (!chatModel(m, site)) continue
2052
- const id = String(m.config_name)
2053
- names.set(id, (names.get(id) ?? new Set()).add(nameOf(m)))
2053
+ const id = String(m.config_name), name = nameOf(m)
2054
+ const by = names.get(id) ?? new Map()
2055
+ by.set(name, (by.get(name) ?? 0) + 1)
2056
+ names.set(id, by)
2054
2057
  }
2055
2058
  }
2059
+ // the name most of a model's lists give it: the one Trae's own client is
2060
+ // served under, and so the one its usage page books it as. Trae renames
2061
+ // entries when it likes, and its 2026-10-09 rename of
2062
+ // DeepSeek-V4-Flash-Official left chat_v3 the only list still calling
2063
+ // deepseek-v4.1-flash by another's name — which neither signal above
2064
+ // catches. A tie leaves the name to its entry.
2065
+ const agreed = new Map() // id → that name, "" when the lists tie
2066
+ for (const [id, by] of names) {
2067
+ const top = Math.max(...by.values())
2068
+ const most = [...by].filter(([, n]) => n === top)
2069
+ agreed.set(id, most.length === 1 ? most[0][0] : "")
2070
+ }
2056
2071
  const misnamed = (fn, m) => {
2057
2072
  const id = String(m.config_name), name = nameOf(m)
2058
2073
  return names.get(id).size > 1 && (lists[fn] ?? []).some((o) => chatModel(o, site) && String(o.config_name) !== id && nameOf(o) === name)
2059
2074
  }
2060
2075
  // a function's entry is worth more when it names a __dev model, then
2061
- // when it isn't misnamed; the first of the best is taken
2062
- const worth = (fn, m) => (devModel(m) ? 2 : 0) + (misnamed(fn, m) ? 0 : 1)
2076
+ // when it isn't misnamed, then when it carries the name its lists agree
2077
+ // on; the first of the best is taken
2078
+ const worth = (fn, m) => (devModel(m) ? 2 : 0) + (misnamed(fn, m) ? 0 : 1) + (nameOf(m) === agreed.get(String(m.config_name)) ? 1 : 0)
2063
2079
  const out = new Map()
2064
2080
  for (const fn of site.functions) {
2065
2081
  for (const m of lists[fn] ?? []) {
@@ -2075,8 +2091,11 @@ const makePlugin = (site) => async ({ client }) => {
2075
2091
  if (dev) modelNames.set(id, { fn, name: dev.model_name, most: Number(dev.max_tokens) || 0 })
2076
2092
  else modelNames.delete(id)
2077
2093
  if (out.has(id + MAX)) continue
2078
- // its Max is asked through the function whose entry names the __max model
2079
- const entries = [{ m, fn }, ...site.functions.flatMap((f) => (lists[f] ?? []).filter((o) => o !== m && chatModel(o, site) && String(o.config_name) === id).map((o) => ({ m: o, fn: f })))]
2094
+ // its Max is asked through the function whose entry names the __max
2095
+ // model, the entries carrying the agreed name first: Trae books the
2096
+ // Max under that name too
2097
+ const plain = (e) => (nameOf(e.m) === agreed.get(id) ? 0 : 1)
2098
+ const entries = [{ m, fn }, ...site.functions.flatMap((f) => (lists[f] ?? []).filter((o) => o !== m && chatModel(o, site) && String(o.config_name) === id).map((o) => ({ m: o, fn: f })))].sort((a, b) => plain(a) - plain(b))
2080
2099
  const max = maxModel(...entries.map((e) => e.m))
2081
2100
  maxes.set(id, max)
2082
2101
  if (max) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@magpie-community/opencode-trae-auth",
3
- "version": "0.2.6",
3
+ "version": "0.2.7",
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",