opencode-plugin-litellm 1.8.0 → 1.8.1

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 CHANGED
@@ -590,6 +590,35 @@ the plugin logs a warning and you won't see LiteLLM-discovered models until
590
590
  the proxy is reachable again.
591
591
  </details>
592
592
 
593
+ <details>
594
+ <summary><b>Why does the first <code>opencode run</code> fail with <code>Model unavailable: litellm/…</code> on OpenCode 2?</b></summary>
595
+
596
+ This happens only on OpenCode 2, in a one-shot command (`opencode run`, CI jobs, scripts), when the plugin has no model cache yet. That covers the first run, a cleared or expired cache, and a changed config or credential. OpenCode registers the providers declared under `providers.*` only after plugin setup returns, so the plugin can't discover their models during setup. Discovery starts right after that, but a one-shot command has already resolved its model and fails before the models arrive. With `--standalone`, the process usually exits before discovery reaches the disk cache, so running it again fails the same way. Interactive sessions (TUI, web, desktop) and `opencode serve` aren't affected. This is how the OpenCode host orders startup ([anomalyco/opencode#57421](https://github.com/anomalyco/opencode/issues/57421)), not a plugin bug.
597
+
598
+ Workarounds:
599
+
600
+ - **Warm the cache once.** Open an interactive session or run `opencode serve` until the models appear, then stop it. One-shot runs use the cache until it expires (7 days) or the config or credential changes.
601
+ - **Pass the connection as plugin options** for CI and scripts. Plugin options are available during setup, so discovery finishes before the command resolves its model, even with a cold cache:
602
+
603
+ ```jsonc
604
+ {
605
+ "plugins": [
606
+ {
607
+ "package": "opencode-plugin-litellm@latest",
608
+ "options": {
609
+ "baseURL": "https://litellm.internal.example.com/v1",
610
+ "apiKey": "{env:LITELLM_API_KEY}"
611
+ }
612
+ }
613
+ ]
614
+ }
615
+ ```
616
+
617
+ One plugin entry describes one provider. To [split one proxy into several providers](#splitting-one-proxy-into-multiple-providers-includemodels--excludemodels) in a cold one-shot run, warm the cache first.
618
+
619
+ The OpenCode feature request for a readiness latch ([anomalyco/opencode#56119](https://github.com/anomalyco/opencode/issues/56119)) would remove the need for either workaround.
620
+ </details>
621
+
593
622
  <details>
594
623
  <summary><b>Will my hand-curated model entries be overwritten?</b></summary>
595
624
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/package.json",
3
3
  "name": "opencode-plugin-litellm",
4
- "version": "1.8.0",
4
+ "version": "1.8.1",
5
5
  "description": "OpenCode CLI (v1 and v2) and Desktop plugin for LiteLLM proxy support with auto-detection and dynamic model discovery",
6
6
  "type": "module",
7
7
  "main": "./src/index.ts",
@@ -11,6 +11,18 @@ function stripVersionSuffix(part: string): string {
11
11
  return part.replace(/@(default|\d{6,8})$/i, '')
12
12
  }
13
13
 
14
+ /**
15
+ * Like `looksLikeVersionComponent`, but tolerates a single leading
16
+ * version letter — only the letters seen in real version positions
17
+ * (`v3`, `k2`, `m2`), so quantization prefixes like `q4` never pair.
18
+ * Dotted ids like `deepseek-v3.2` or `kimi-k2.5` have their version
19
+ * split apart by the tokenizer, and the letter-prefixed half must
20
+ * still merge back with the digits after the dot.
21
+ */
22
+ function looksLikePrefixedVersionComponent(token: string): boolean {
23
+ return /^[vkm]?\d{1,2}$/i.test(token)
24
+ }
25
+
14
26
  /**
15
27
  * Heuristic: does this numeric token look like a real version component
16
28
  * (single or double digit) rather than a date stamp or build number?
@@ -31,6 +43,15 @@ function looksLikeVersionComponent(token: string): boolean {
31
43
  * version pair, but the formatter would otherwise render it as
32
44
  * "Claude Opus 4 5".
33
45
  *
46
+ * The left-hand token may also carry a single version letter (`v3`,
47
+ * `k2`, `m2`): ids like `deepseek-v3.2` or `kimi-k2.5` get their dot
48
+ * split apart by the tokenizer and must re-join as `v3.2` / `k2.5`,
49
+ * never render as "DeepSeek V3 2" / "Kimi K2 5".
50
+ * Quantization prefixes never pair (`q4_0` tokenises as `q4` + `0`,
51
+ * but `q` is not a version letter), so `mistral-7b-instruct-q4_0`
52
+ * renders "Mistral 7B Instruct Q4 0" while ids with a real version
53
+ * pair like `llama-3.1-8b-instruct-q4_0` keep merging `3.1`.
54
+ *
34
55
  * Conservative on purpose:
35
56
  * - Only the FIRST mergeable pair scanning from the right is collapsed:
36
57
  * `gpt-3-5-turbo-16k` merges `3-5` into `3.5` and stops there.
@@ -49,7 +70,7 @@ function joinTrailingVersionPair(tokens: string[]): string[] {
49
70
  for (let i = tokens.length - 1; i >= 1; i--) {
50
71
  const a = tokens[i - 1]
51
72
  const b = tokens[i]
52
- if (looksLikeVersionComponent(a) && looksLikeVersionComponent(b)) {
73
+ if (looksLikePrefixedVersionComponent(a) && looksLikeVersionComponent(b)) {
53
74
  const prev = tokens[i - 2]
54
75
  const next = tokens[i + 1]
55
76
  const prevIsShortNumeric = prev !== undefined && looksLikeVersionComponent(prev)
@@ -101,7 +122,11 @@ export function categorizeModel(model: LiteLLMModel): 'chat' | 'embedding' | 'im
101
122
  * - Collapse a trailing pair of bare numeric tokens into a single
102
123
  * dotted version. Anthropic uses dash-only ids — `claude-opus-4-7`
103
124
  * would otherwise render as "Claude Opus 4 7" instead of
104
- * "Claude Opus 4.7".
125
+ * "Claude Opus 4.7". The left-hand token may carry a version
126
+ * letter, so `deepseek-v3.2` renders "DeepSeek V3.2", not
127
+ * "Deepseek V3 2".
128
+ * - Keep the official casing of known brand names (GLM, DeepSeek,
129
+ * MiniMax) instead of generic title-case.
105
130
  *
106
131
  * Examples:
107
132
  * "openai/gpt-4o-mini" -> "GPT 4o Mini"
@@ -110,6 +135,10 @@ export function categorizeModel(model: LiteLLMModel): 'chat' | 'embedding' | 'im
110
135
  * "claude-sonnet-4-6@default" -> "Claude Sonnet 4.6"
111
136
  * "bedrock/amazon.nova-pro-v1" -> "Amazon Nova Pro V1"
112
137
  * "qwen/qwen3-30b-a3b" -> "Qwen3 30B A3B"
138
+ * "litellm/deepseek-v3.2" -> "DeepSeek V3.2"
139
+ * "litellm/glm-5.3" -> "GLM 5.3"
140
+ * "litellm/kimi-k2.5" -> "Kimi K2.5"
141
+ * "litellm/minimax-m2.5" -> "MiniMax M2.5"
113
142
  */
114
143
  export function formatModelName(model: LiteLLMModel): string {
115
144
  const { id } = model
@@ -124,10 +153,17 @@ export function formatModelName(model: LiteLLMModel): string {
124
153
  const modelPart = stripVersionSuffix(afterProvider)
125
154
 
126
155
  const acronyms = new Set([
127
- 'gpt', 'oss', 'api', 'gguf', 'ggml', 'nomic', 'vl', 'it', 'mlx',
156
+ 'gpt', 'glm', 'oss', 'api', 'gguf', 'ggml', 'nomic', 'vl', 'it', 'mlx',
128
157
  'llm', 'ai', 'sdk', 'aws', 'gcp', 'tts', 'stt', 'mm',
129
158
  ])
130
159
 
160
+ // Mixed-case brand names that generic title-case would mangle
161
+ // ("Deepseek", "Minimax").
162
+ const brandNames: Record<string, string> = {
163
+ deepseek: 'DeepSeek',
164
+ minimax: 'MiniMax',
165
+ }
166
+
131
167
  const rawTokens = modelPart
132
168
  .split(/[-_.]/) // split on -, _ and .
133
169
  .filter(Boolean)
@@ -138,6 +174,7 @@ export function formatModelName(model: LiteLLMModel): string {
138
174
  // when both sides are pure digits).
139
175
  const tokens = joinTrailingVersionPair(rawTokens).map((token) => {
140
176
  const lower = token.toLowerCase()
177
+ if (brandNames[lower]) return brandNames[lower]
141
178
  if (acronyms.has(lower)) return token.toUpperCase()
142
179
  // sizes (30b, 7b, 4k...)
143
180
  if (/^\d+[bkmg]$/i.test(token)) return token.toUpperCase()