opencode-magpie-plugin 0.2.0 → 0.2.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 +3 -1
- package/dist/index.mjs +8 -4
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -85,6 +85,8 @@ Routing group(例如 `group/auto`)会跨多个服务路由,因此不按 `o
|
|
|
85
85
|
|
|
86
86
|
### 目录呈现
|
|
87
87
|
|
|
88
|
+
新版 Auto Group 的 `auto/<model>` 也按路由组处理,默认放在 `magpie-magpie`,选择器 ID 为 `auto-<model>`,请求仍发送原始 `auto/<model>`。它按 `auto-<model>` 匹配下述 `groups.prefix`,因此可用 `auto-` 单独分桶;模型名中的点号保持原样。旧的 `group/` 格式继续支持,普通厂商模型不会被自动组覆盖。自动组及其 Fast 变体仅采用 Magpie 报价。
|
|
89
|
+
|
|
88
90
|
路由组的成员由 Magpie 维护;这个插件只决定 OpenCode 选择器里怎么摆。分组、显示名和排序写在 `opencode.jsonc` 的插件 `options` 里,升级插件包之后仍在,不用再改 `dist`。空 options(或仍用字符串引用插件)和不声明时完全一样:所有 `group/` 行都在 `magpie-magpie`。
|
|
89
91
|
|
|
90
92
|
```jsonc
|
|
@@ -109,7 +111,7 @@ Routing group(例如 `group/auto`)会跨多个服务路由,因此不按 `o
|
|
|
109
111
|
|
|
110
112
|
上面只是写法示例,不是插件默认值。语义:
|
|
111
113
|
|
|
112
|
-
- 只对 id 以 `group/` 开头的行分桶。`groups` 按 `prefix` 最长优先匹配。命中后 provider 是 `magpie-<id>`,显示名是 `name`,选择器里的模型 id 去掉这段 prefix(`group/adams-deepseek-v4.1-flash` → `magpie-adams/deepseek-v4.1-flash`)。发给 Magpie 的仍是原始 id。没匹配到的组保持今天的行为:`magpie-magpie`,显示名 Magpie,id 不去前缀。厂商模型(`cursor/`、`workbuddy/`)不受 `groups` 影响。
|
|
114
|
+
- 只对 id 以 `group/` 或 `auto/` 开头的行分桶。`groups` 按 `prefix` 最长优先匹配。命中后 provider 是 `magpie-<id>`,显示名是 `name`,选择器里的模型 id 去掉这段 prefix(`group/adams-deepseek-v4.1-flash` → `magpie-adams/deepseek-v4.1-flash`)。发给 Magpie 的仍是原始 id。没匹配到的组保持今天的行为:`magpie-magpie`,显示名 Magpie,id 不去前缀。厂商模型(`cursor/`、`workbuddy/`)不受 `groups` 影响。
|
|
113
115
|
- OpenCode 同 provider 内按 `time.released` 倒序排。`order` 的 key 是最终 provider id,值是最终模型 id(已去前缀),越靠前越靠前。名单里没有的保持 0,退化为字母序。`-fast` 克隆继承父模型的权重并紧跟在后面;不要给它单独写一条,除非那个 `-fast` id 自己出现在 `order` 里。provider 之间的顺序控制不了。
|
|
114
116
|
- 插件不隐藏模型。网关列出的都会出现,没标价的也一样。不想在 OpenCode 里看到某个组,在 Magpie 里处理:不用了就 `magpie group rm <id>`,只对 OpenCode 收窄就用 `magpie visible opencode …`。组的成员是厂商模型时,删掉一个组不会影响把同一批模型当成员的其他组。
|
|
115
117
|
|
package/dist/index.mjs
CHANGED
|
@@ -267,6 +267,10 @@ const priceInProvider = (catalog, maker, id) => {
|
|
|
267
267
|
const hasUnpricedModel = (inventory) => inventory.some((entry) => entry.models.some((model) => model.cost.length === 0));
|
|
268
268
|
/** Routing groups route across providers, so they belong to Magpie itself rather than to a vendor. */
|
|
269
269
|
const ROUTING_GROUP = "magpie";
|
|
270
|
+
const routingGroupKey = (id) => {
|
|
271
|
+
if (id.startsWith("group/")) return id.slice(6);
|
|
272
|
+
if (id.startsWith("auto/")) return `auto-${id.slice(5)}`;
|
|
273
|
+
};
|
|
270
274
|
const reasoningVariants = (row, anthropic) => {
|
|
271
275
|
if (row.reasoning === false) return [];
|
|
272
276
|
const levels = row.reasoning_levels ?? row.supported_reasoning_levels?.map((level) => typeof level === "string" ? level : level.effort) ?? [];
|
|
@@ -378,12 +382,12 @@ const buildInventory = (rows, baseURL, options = {}) => {
|
|
|
378
382
|
const buckets = [...presentation.groups].sort((left, right) => right.prefix.length - left.prefix.length);
|
|
379
383
|
for (const row of rows) if (row.service_tiers?.some((tier) => (typeof tier === "string" ? tier : tier.id) === "priority")) fastModelIDs.add(row.id);
|
|
380
384
|
rows.filter((row) => !row.kind && row.id.includes("/")).forEach((row) => {
|
|
381
|
-
const
|
|
382
|
-
const
|
|
385
|
+
const groupKey = routingGroupKey(row.id);
|
|
386
|
+
const group = groupKey !== void 0;
|
|
383
387
|
const bucket = groupKey ? buckets.find((entry$1) => groupKey.length > entry$1.prefix.length && groupKey.startsWith(entry$1.prefix)) : void 0;
|
|
384
388
|
const owner = group ? bucket?.id ?? ROUTING_GROUP : row.owned_by;
|
|
385
389
|
const providerID = `magpie-${encodeURIComponent(owner)}`;
|
|
386
|
-
const modelID = bucket && groupKey ? groupKey.slice(bucket.prefix.length) : row.id.slice(row.id.indexOf("/") + 1);
|
|
390
|
+
const modelID = bucket && groupKey ? groupKey.slice(bucket.prefix.length) : groupKey ?? row.id.slice(row.id.indexOf("/") + 1);
|
|
387
391
|
const { cost } = modelCost(row, group, options.catalog);
|
|
388
392
|
const model = toClassicModelInfo(providerID, modelID, {
|
|
389
393
|
id: row.id,
|
|
@@ -435,7 +439,7 @@ const buildInventory = (rows, baseURL, options = {}) => {
|
|
|
435
439
|
if (!fastModelIDs.has(model.modelID) || /-fast(?:@\d+[km])?$/i.test(model.id) || ids.has(`${model.id}-fast`)) return [model];
|
|
436
440
|
const row = rows.find((row$1) => row$1.id === model.modelID);
|
|
437
441
|
const fastKey = `${model.id.replace(/@\d+(?:k|m)$/i, "")}-fast`;
|
|
438
|
-
const fastPrice = row &&
|
|
442
|
+
const fastPrice = row && routingGroupKey(row.id) === void 0 && resolveModelPricingKey(fastKey)?.endsWith("-fast") ? getModelPricing(fastKey, pricingProvider(row.owned_by)) : void 0;
|
|
439
443
|
return [model, {
|
|
440
444
|
...model,
|
|
441
445
|
id: `${model.id}-fast`,
|
package/package.json
CHANGED