opencode-magpie-plugin 0.1.0 → 0.1.3
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 +7 -2
- package/dist/index.mjs +14 -5
- package/package.json +10 -12
package/README.md
CHANGED
|
@@ -55,7 +55,7 @@ OpenCode V2
|
|
|
55
55
|
|
|
56
56
|
```jsonc
|
|
57
57
|
{
|
|
58
|
-
"plugins": ["opencode-magpie-plugin@0.1.
|
|
58
|
+
"plugins": ["opencode-magpie-plugin@0.1.3"]
|
|
59
59
|
}
|
|
60
60
|
```
|
|
61
61
|
|
|
@@ -88,6 +88,8 @@ Magpie 的 routing group(例如 `group/fast`)单独成为一个分组,内
|
|
|
88
88
|
|
|
89
89
|
目录映射保留模型的上下文窗口、最大输出、输入输出模态和 reasoning 档位。仅发现聊天目录;重复的无 provider 前缀别名、图片生成或其他非聊天专用模型不会注册为聊天模型。
|
|
90
90
|
|
|
91
|
+
思考强度读取新版 `reasoning_levels`,并兼容已安装版本常见的 `supported_reasoning_levels`(`{ effort }` 对象或字符串列表)。只有网关实际声明的档位才会出现,可在 OpenCode 的模型变体控件中选择,或使用 `provider/model#high` 这样的引用。`default` 保留服务默认行为,不额外生成档位;网关未提供档位时不会凭模型名称猜测。
|
|
92
|
+
|
|
91
93
|
根据 `native_endpoints` 选择 OpenCode 内置 runtime:
|
|
92
94
|
|
|
93
95
|
| Magpie 元数据 | OpenCode runtime |
|
|
@@ -98,6 +100,8 @@ Magpie 的 routing group(例如 `group/fast`)单独成为一个分组,内
|
|
|
98
100
|
|
|
99
101
|
消息、工具调用和工具结果由 OpenCode 原生 runtime 编码,再由 Magpie 转接。插件传递 `X-Magpie-Session` 保持会话标识,并指定 HTTP 传输。模型上游支持的完整能力仍取决于 Magpie 和相应服务。
|
|
100
102
|
|
|
103
|
+
思考档位按所选协议编码:Chat 使用 `reasoning_effort`,Responses 使用 `reasoning.effort`,Anthropic 使用 `thinking.type=adaptive` 配合 `output_config.effort`;Anthropic 的 `none` 关闭 thinking。
|
|
104
|
+
|
|
101
105
|
刷新成功时替换完整目录;刷新失败保留最近一次成功的目录。首次发现失败会报告初始化错误,不生成虚假的可用模型。
|
|
102
106
|
|
|
103
107
|
## 网关地址与启动
|
|
@@ -218,9 +222,10 @@ curl -H 'Authorization: Bearer magpie' -H 'X-Magpie-Prices: 1' \
|
|
|
218
222
|
```sh
|
|
219
223
|
pnpm check
|
|
220
224
|
pnpm pack
|
|
221
|
-
pnpm publish --access public --registry=https://registry.npmjs.org/
|
|
222
225
|
```
|
|
223
226
|
|
|
227
|
+
维护者发布采用 tag 驱动:推送与 `package.json.version` 一致的 `v<version>` tag 后,GitHub Actions 自动检查、发布公网 npm 并创建 GitHub Release。正式版使用 `latest`,预发布版使用 `next`。完整步骤、认证要求与失败恢复见 [发布指南](docs/releasing.md)。
|
|
228
|
+
|
|
224
229
|
测试覆盖目录分组与替换、wire model ID、协议元数据、价格归一化与覆盖、未知价格、会话头、网关身份检查、自动启动与并发去重、未安装提示、刷新失败和清理。测试不消耗真实服务额度。
|
|
225
230
|
|
|
226
231
|
只发布 `dist`、README 和许可证,**没有 runtime dependencies**。价格表变更时应更新相应测试,并在 release 说明价格来源与变化。
|
package/dist/index.mjs
CHANGED
|
@@ -58,6 +58,17 @@ const toClassicModelInfo = (providerID, catalogID, entry) => ({
|
|
|
58
58
|
|
|
59
59
|
//#endregion
|
|
60
60
|
//#region src/catalog.ts
|
|
61
|
+
const reasoningVariants = (row, anthropic) => {
|
|
62
|
+
if (row.reasoning === false) return [];
|
|
63
|
+
const levels = row.reasoning_levels ?? row.supported_reasoning_levels?.map((level) => typeof level === "string" ? level : level.effort) ?? [];
|
|
64
|
+
return [...new Set(levels)].filter((effort) => effort && effort !== "default").map((effort) => ({
|
|
65
|
+
id: effort,
|
|
66
|
+
settings: anthropic ? effort === "none" ? { thinking: { type: "disabled" } } : {
|
|
67
|
+
thinking: { type: "adaptive" },
|
|
68
|
+
effort
|
|
69
|
+
} : { reasoningEffort: effort }
|
|
70
|
+
}));
|
|
71
|
+
};
|
|
61
72
|
const pricingProvider = (owner) => {
|
|
62
73
|
const id = owner.toLowerCase();
|
|
63
74
|
if (id === "workbuddy") return "codebuddy";
|
|
@@ -85,7 +96,8 @@ const buildInventory = (rows, baseURL) => {
|
|
|
85
96
|
const owner = group ? row.id : row.owned_by;
|
|
86
97
|
const providerID = `magpie-${encodeURIComponent(owner)}`;
|
|
87
98
|
const modelID = row.id.slice(row.id.indexOf("/") + 1);
|
|
88
|
-
const
|
|
99
|
+
const pricingID = modelID.replace(/@\d+(?:k|m)$/i, "");
|
|
100
|
+
const cost = (!group ? getModelPricing(pricingID, pricingProvider(owner)) : void 0) ?? row.magpie_price;
|
|
89
101
|
const model = toClassicModelInfo(providerID, modelID, {
|
|
90
102
|
id: row.id,
|
|
91
103
|
name: row.display_name ?? modelID,
|
|
@@ -107,10 +119,7 @@ const buildInventory = (rows, baseURL) => {
|
|
|
107
119
|
apiKey: "magpie",
|
|
108
120
|
transport: "http"
|
|
109
121
|
};
|
|
110
|
-
model.variants = (row
|
|
111
|
-
id: effort,
|
|
112
|
-
settings: { reasoningEffort: effort }
|
|
113
|
-
}));
|
|
122
|
+
model.variants = reasoningVariants(row, !!anthropic);
|
|
114
123
|
const entry = providers.get(providerID) ?? {
|
|
115
124
|
info: {
|
|
116
125
|
id: providerID,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "opencode-magpie-plugin",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
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",
|
|
@@ -30,15 +30,6 @@
|
|
|
30
30
|
"engines": {
|
|
31
31
|
"node": ">=22"
|
|
32
32
|
},
|
|
33
|
-
"packageManager": "pnpm@9.15.0",
|
|
34
|
-
"scripts": {
|
|
35
|
-
"build": "tsdown",
|
|
36
|
-
"type-check": "tsc --noEmit",
|
|
37
|
-
"test": "vitest run",
|
|
38
|
-
"lint": "biome check src tests tsdown.config.ts package.json",
|
|
39
|
-
"check": "pnpm type-check && pnpm lint && pnpm test && pnpm build",
|
|
40
|
-
"prepublishOnly": "pnpm check"
|
|
41
|
-
},
|
|
42
33
|
"devDependencies": {
|
|
43
34
|
"@biomejs/biome": "2.5.1",
|
|
44
35
|
"@types/node": "^22.0.0",
|
|
@@ -68,5 +59,12 @@
|
|
|
68
59
|
"llm",
|
|
69
60
|
"gateway"
|
|
70
61
|
],
|
|
71
|
-
"license": "MIT"
|
|
72
|
-
|
|
62
|
+
"license": "MIT",
|
|
63
|
+
"scripts": {
|
|
64
|
+
"build": "tsdown",
|
|
65
|
+
"type-check": "tsc --noEmit",
|
|
66
|
+
"test": "vitest run",
|
|
67
|
+
"lint": "biome check src tests scripts tsdown.config.ts package.json",
|
|
68
|
+
"check": "pnpm type-check && pnpm lint && pnpm test && pnpm build"
|
|
69
|
+
}
|
|
70
|
+
}
|