opencode-magpie-plugin 0.1.3 → 0.1.4
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 +6 -5
- package/dist/index.mjs +4 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -14,7 +14,7 @@ Magpie 管理多个服务的账号、模型、协议转换和路由;这个插
|
|
|
14
14
|
|
|
15
15
|
```text
|
|
16
16
|
OpenCode V2
|
|
17
|
-
├─ /models:Cursor、WorkBuddy
|
|
17
|
+
├─ /models:Cursor、WorkBuddy、Magpie(路由分组)
|
|
18
18
|
├─ 模型能力、上下文限制、reasoning 档位和价格
|
|
19
19
|
└─ 原生 Chat / Responses / Anthropic 请求
|
|
20
20
|
↓
|
|
@@ -25,7 +25,7 @@ OpenCode V2
|
|
|
25
25
|
|
|
26
26
|
- `opencode.jsonc` 只加载插件,不维护 `providers.models`。
|
|
27
27
|
- 启动时发现目录,每 30 秒刷新;服务新增、模型下线都能反映到 OpenCode。
|
|
28
|
-
- Provider 显示 Magpie 中的分组名称,而不是统一挤在一个 “Magpie”
|
|
28
|
+
- Provider 显示 Magpie 中的分组名称,而不是统一挤在一个 “Magpie” 下;路由分组统一归入 Magpie。
|
|
29
29
|
- 内置独立价格表和模型名归一化逻辑,支持输入、输出、缓存读取与写入价格。
|
|
30
30
|
- Magpie 已安装但未运行时自动执行 `magpie serve`;未安装时给出安装链接。
|
|
31
31
|
- 登录和服务凭据由 Magpie 管理,插件不需要复制上游 token。
|
|
@@ -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.4"]
|
|
59
59
|
}
|
|
60
60
|
```
|
|
61
61
|
|
|
@@ -77,10 +77,11 @@ opencode service restart
|
|
|
77
77
|
| --- | --- | --- | --- |
|
|
78
78
|
| Cursor | `magpie-cursor` | `magpie-cursor/gpt-5.5` | `cursor/gpt-5.5` |
|
|
79
79
|
| WorkBuddy | `magpie-workbuddy` | `magpie-workbuddy/claude-opus-4-6` | `workbuddy/claude-opus-4-6` |
|
|
80
|
+
| Magpie | `magpie-magpie` | `magpie-magpie/auto` | `group/auto` |
|
|
80
81
|
|
|
81
82
|
示例模型仅说明格式,实际列表取决于 Magpie 当前账号与配置。Magpie 自定义 provider ID 会原样映射为带 `magpie-` 前缀的 ID。
|
|
82
83
|
|
|
83
|
-
|
|
84
|
+
Routing group(例如 `group/auto`)会跨多个服务路由,因此不按 `owned_by` 或首个候选服务拆成 provider,而是统一归到 **Magpie** 分组下。发送时仍保留 `group/auto`,价格只用 Magpie 给出的价格,不按成员猜测。
|
|
84
85
|
|
|
85
86
|
## 自动发现与请求行为
|
|
86
87
|
|
|
@@ -139,7 +140,7 @@ MAGPIE_ADDR=127.0.0.1:3426 opencode --standalone
|
|
|
139
140
|
2. 内置表未覆盖时,使用 Magpie 返回的 `magpie_price`。
|
|
140
141
|
3. 两边均没有价格时,不启用该模型,避免把未知价格显示为免费。
|
|
141
142
|
|
|
142
|
-
Cursor 使用 `cursor` 覆盖,WorkBuddy 使用 `codebuddy` 覆盖;其他已识别服务按表中对应 provider 处理。Routing group
|
|
143
|
+
Cursor 使用 `cursor` 覆盖,WorkBuddy 使用 `codebuddy` 覆盖;其他已识别服务按表中对应 provider 处理。Routing group 只用 Magpie 提供的价格,不按成员猜测。明确记录的零价格仍视为有效价格。
|
|
143
144
|
|
|
144
145
|
所有价格单位都是 **美元 / 百万 token**。OpenCode 用这些单价计算请求费用。普通计费的概念公式为:
|
|
145
146
|
|
package/dist/index.mjs
CHANGED
|
@@ -58,6 +58,8 @@ const toClassicModelInfo = (providerID, catalogID, entry) => ({
|
|
|
58
58
|
|
|
59
59
|
//#endregion
|
|
60
60
|
//#region src/catalog.ts
|
|
61
|
+
/** Routing groups route across providers, so they belong to Magpie itself rather than to a vendor. */
|
|
62
|
+
const ROUTING_GROUP = "magpie";
|
|
61
63
|
const reasoningVariants = (row, anthropic) => {
|
|
62
64
|
if (row.reasoning === false) return [];
|
|
63
65
|
const levels = row.reasoning_levels ?? row.supported_reasoning_levels?.map((level) => typeof level === "string" ? level : level.effort) ?? [];
|
|
@@ -93,7 +95,7 @@ const buildInventory = (rows, baseURL) => {
|
|
|
93
95
|
const providers = /* @__PURE__ */ new Map();
|
|
94
96
|
rows.filter((row) => !row.kind && row.id.includes("/")).forEach((row) => {
|
|
95
97
|
const group = row.id.startsWith("group/");
|
|
96
|
-
const owner = group ?
|
|
98
|
+
const owner = group ? ROUTING_GROUP : row.owned_by;
|
|
97
99
|
const providerID = `magpie-${encodeURIComponent(owner)}`;
|
|
98
100
|
const modelID = row.id.slice(row.id.indexOf("/") + 1);
|
|
99
101
|
const pricingID = modelID.replace(/@\d+(?:k|m)$/i, "");
|
|
@@ -123,7 +125,7 @@ const buildInventory = (rows, baseURL) => {
|
|
|
123
125
|
const entry = providers.get(providerID) ?? {
|
|
124
126
|
info: {
|
|
125
127
|
id: providerID,
|
|
126
|
-
name: group ?
|
|
128
|
+
name: group ? "Magpie" : providerName(row),
|
|
127
129
|
activation: "enabled",
|
|
128
130
|
package: "@opencode/ai/providers/openai-compatible",
|
|
129
131
|
settings: {
|
package/package.json
CHANGED