opencode-magpie-plugin 0.3.0 → 0.3.2

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
@@ -55,7 +55,7 @@ OpenCode V2
55
55
 
56
56
  ```jsonc
57
57
  {
58
- "plugins": ["opencode-magpie-plugin@0.3.0"]
58
+ "plugins": ["opencode-magpie-plugin@0.3.2"]
59
59
  }
60
60
  ```
61
61
 
@@ -81,6 +81,8 @@ opencode service restart
81
81
 
82
82
  示例模型仅说明格式,实际列表取决于 Magpie 当前账号与配置。Magpie 自定义 provider ID 会原样映射为带 `magpie-` 前缀的 ID。
83
83
 
84
+ 网关中嵌套的远程来源按内层服务独立分组,例如 `remote-magpie/cursor/gpt-5.6-terra@272k` 显示在 **Cursor · Remote magpie** 下,WorkBuddy、Codex、Astra 等各自分组,不再由首条模型的标签决定整个 remote 的名称。该示例的 provider ID 为 `magpie-remote-magpie%2Fcursor`,模型 ID 为 `cursor/gpt-5.6-terra@272k`,请求仍发送完整的 `remote-magpie/cursor/gpt-5.6-terra@272k`。从旧版本升级后,原先选在合并 remote 分组中的模型需要重新选择。
85
+
84
86
  Routing group(例如 `group/auto`)会跨多个服务路由,因此不按 `owned_by` 或首个候选服务拆成 provider。没有插件 options 时,它们统一归到 **Magpie** 分组下。发送时仍保留网关原始 id(`group/auto`),价格只用 Magpie 给出的价格,不按成员猜测。
85
87
 
86
88
  ### 目录呈现
@@ -121,7 +123,7 @@ Routing group(例如 `group/auto`)会跨多个服务路由,因此不按 `o
121
123
 
122
124
  本机模式先检查网关根路径的 `name: "magpie"`,再请求 `/v1/models`。远程模式直接请求配置的 API baseURL 下的 `models`,不探测站点根路径,以兼容只暴露 API 的反向代理。请求携带 `X-Magpie-Prices: 1` 读取可用的网关价格扩展。
123
125
 
124
- 目录映射保留模型的上下文窗口、最大输出、输入输出模态和 reasoning 档位。仅发现聊天目录;重复的无 provider 前缀别名、图片生成或其他非聊天专用模型不会注册为聊天模型。
126
+ 目录映射保留模型的上下文窗口、最大输出、输入输出模态和 reasoning 档位。网关未提供有效上下文窗口时,默认使用 256K(256,000 tokens)。仅发现聊天目录;重复的无 provider 前缀别名、图片生成或其他非聊天专用模型不会注册为聊天模型。
125
127
 
126
128
  思考强度读取新版 `reasoning_levels`,并兼容已安装版本常见的 `supported_reasoning_levels`(`{ effort }` 对象或字符串列表)。只有网关实际声明的档位才会出现,可在 OpenCode 的模型变体控件中选择,或使用 `provider/model#high` 这样的引用。`default` 保留服务默认行为,不额外生成档位;网关未提供档位时不会凭模型名称猜测。
127
129
 
package/dist/index.mjs CHANGED
@@ -313,6 +313,23 @@ const providerName = (model) => {
313
313
  workbuddy: "WorkBuddy"
314
314
  }[model.owned_by] ?? model.owned_by;
315
315
  };
316
+ const nestedProvider = (row) => {
317
+ const prefix = `${row.owned_by}/`;
318
+ if (!row.id.startsWith(prefix)) return;
319
+ const remainder = row.id.slice(prefix.length);
320
+ const slash = remainder.indexOf("/");
321
+ if (slash <= 0 || slash === remainder.length - 1) return;
322
+ const source = remainder.slice(0, slash);
323
+ const label = providerName(row);
324
+ const sourceName = source === "auto" || source === "group" ? "routing group" : providerName({
325
+ id: source,
326
+ owned_by: source
327
+ });
328
+ return {
329
+ id: `${row.owned_by}/${source}`,
330
+ name: row.magpie_label?.split(" · ").length === 3 ? label : `${sourceName} · ${label}`
331
+ };
332
+ };
316
333
  /** Magpie writes context windows as `Claude Opus 5.5 @ 1m`. The picker shows `@1m`. */
317
334
  const displayName = (name) => name.replace(/@\s+(\d+(?:k|m))/gi, "@$1");
318
335
  const isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
@@ -399,7 +416,8 @@ const buildInventory = (rows, baseURL, options = {}) => {
399
416
  const groupKey = routingGroupKey(row.id);
400
417
  const group = groupKey !== void 0;
401
418
  const bucket = groupKey ? buckets.find((entry$1) => groupKey.length > entry$1.prefix.length && groupKey.startsWith(entry$1.prefix)) : void 0;
402
- const owner = group ? bucket?.id ?? ROUTING_GROUP : row.owned_by;
419
+ const nested = group ? void 0 : nestedProvider(row);
420
+ const owner = group ? bucket?.id ?? ROUTING_GROUP : nested?.id ?? row.owned_by;
403
421
  const providerID = `magpie-${encodeURIComponent(owner)}`;
404
422
  const modelID = bucket && groupKey ? groupKey.slice(bucket.prefix.length) : groupKey ?? row.id.slice(row.id.indexOf("/") + 1);
405
423
  const { cost } = modelCost(row, group, options.catalog);
@@ -408,7 +426,7 @@ const buildInventory = (rows, baseURL, options = {}) => {
408
426
  name: displayName(row.display_name ?? modelID),
409
427
  cost,
410
428
  limit: {
411
- context: row.context_window || 128e3,
429
+ context: row.context_window || 256e3,
412
430
  output: row.max_output_tokens || 32e3
413
431
  },
414
432
  modalities: row.modalities,
@@ -427,7 +445,7 @@ const buildInventory = (rows, baseURL, options = {}) => {
427
445
  const entry = providers.get(providerID) ?? {
428
446
  info: {
429
447
  id: providerID,
430
- name: bucket ? bucket.name : group ? "Magpie" : providerName(row),
448
+ name: bucket ? bucket.name : group ? "Magpie" : nested?.name ?? providerName(row),
431
449
  activation: "enabled",
432
450
  package: "@opencode/ai/providers/openai-compatible",
433
451
  settings: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-magpie-plugin",
3
- "version": "0.3.0",
3
+ "version": "0.3.2",
4
4
  "description": "Discover Magpie providers and models in OpenCode V2 with built-in pricing and automatic local gateway startup",
5
5
  "type": "module",
6
6
  "main": "./dist/index.mjs",