@fish-under-sea/opencode-meoo-auth 0.0.0-stage → 1.0.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/LICENSE ADDED
@@ -0,0 +1,26 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Fish-under-sea and Chensy (elysia395)
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
22
+
23
+ ---
24
+
25
+ Third-party components included or derived in this package are distributed
26
+ under their own MIT licenses; see THIRD_PARTY_NOTICES.md.
package/README.md CHANGED
@@ -1,3 +1,137 @@
1
- # Temporary Holding Version
1
+ # opencode-meoo-auth
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ OpenCode & Magpie provider plugin for **Meoo 秒悟**(`meoo.com`)。npm 包名 `@fish-under-sea/opencode-meoo-auth`。
4
+
5
+ 在 Magpie 的插件/供应商列表里,外层显示名是 **Meoo**;点进插件详情,看到的是完整包名 `@fish-under-sea/opencode-meoo-auth`——外层短名由插件的 `provider.name` 给出,完整包名由宿主读到的插件 spec 给出,与官方插件(`@magpie-community/opencode-*-auth`)的呈现方式一致。
6
+
7
+ 作者:[@Fish-under-sea](https://github.com/Fish-under-sea)、[Chensy(elysia395)](https://github.com/elysia395)。本包由 [FISH-DOCK-Plugins PR #35](https://github.com/Fish-under-sea/FISH-DOCK-Plugins/pull/35) 的 Magpie 供应商插件落成独立 npm 包;代码源头是 [dsh-meoo-connect](https://github.com/2239058652/dsh-meoo-connect)(DeepSeek Harness 的 dsh 插件):同一套 Meoo 官方「AI 服务」链路(OAuth 登录 → 项目服务 AK → OpenAI 兼容网关),换到 Magpie / OpenCode 的 provider 插件平面上。装好并登录后,Meoo 的模型会出现在 Magpie 的模型选择器里,也作为 OpenCode 的一个 provider。
8
+
9
+ ```
10
+ Qwen3.8-Flash · Qwen3.8-Max · Qwen3.7-Max · Qwen3.7-Plus
11
+ DeepSeek V4.1 Flash · DeepSeek V4 Pro · DeepSeek V4 Flash
12
+ GLM-5.2 · GLM-5.2-Fast
13
+ ```
14
+
15
+ ## 思考强度
16
+
17
+ 模型默认带三档思考强度,对应会话 UI 里的 **快速 / 适中 / 极致**(`reasoning_effort: low / medium / high`)。网关实测该参数真实生效(low 档思考 tokens 约为 high 档的 60%~70%,`enable_thinking:false` 可完全关闭,但为避免不可控行为未暴露「关闭」档)。不选档位时走上游默认思考。
18
+
19
+ ## 它是怎么做的
20
+
21
+ 不自己做 LLM 适配器、不加会掉流式的中间代理——插件只准备「凭证 + 模型目录」,
22
+ 真正的转发交给宿主的 `@ai-sdk/openai-compatible` SDK 直连 Meoo 网关:
23
+
24
+ ```
25
+ opencode-meoo-auth
26
+ ├─ OAuth(PKCE) 登录 meoo → access/refresh token 存宿主账号记录
27
+ ├─ /open/v1/cli-compat/... → 身份、项目列表、项目服务 AK(自动开通云服务)
28
+ ├─ GET {gateway}/models → 当前可用模型目录(10 分钟缓存)
29
+ └─ loader → baseURL + apiKey(项目服务 AK) 交给宿主 SDK
30
+ ↓
31
+ Magpie 的模型选择器 / OpenCode 的 provider 列表
32
+ ```
33
+
34
+ ## 登录方式(三选一)
35
+
36
+ | 方式 | 适合谁 | 要人工做什么 |
37
+ | --- | --- | --- |
38
+ | **浏览器授权**(PKCE,本机 loopback 自动收回调) | 大多数人 | 浏览器里点一次「授权」;身份、项目、云服务 AK 之后全自动 |
39
+ | **复用本机登录态** | 已在用 dsh-meoo-connect 或 meoo-proxy 的人 | 无——只读 `$DSH_HOME/meoo/state.json` 或 `~/.meoo-proxy/config.json`,不会写这两个文件 |
40
+ | **手填项目服务 AK** | 不想走 OAuth / 账号下多项目想精确指定的人 | 在 meoo.com 打开项目 → 云服务,复制 `meoo_project_service_v1.` 开头的 AK 粘贴;保存前会用网关 `/models` 校验一次 |
41
+
42
+ 自动链路的细节:
43
+
44
+ - access token 过期前 5 分钟自动单飞续期(并发共享一次刷新请求),续期结果写回宿主的账号记录。
45
+ - 项目没开通「云服务」时,授权登录会自动开通一次再取 AK;仍失败会提示在 meoo.com 项目的对话框里让 AI 开启(平台的设计是会话触发自动开通,没有手动按钮)。
46
+ - 账号下一个项目都没有时,授权登录会**自动创建一个项目**(默认名「AI 服务」,可在 meoo.com 改名),再继续取 AK。
47
+ - 账号下有多个项目且没设默认时,浏览器登录会拒绝并**列出可选项**(项目间计费归属不同,不替你做主);想精确指定就用「手填 AK」方式。
48
+ - 手填了 `meoo_ak_` 开头的用户 Key 会被明确拒绝——那是用户 Key,不是项目服务 AK。
49
+
50
+ ## 安装
51
+
52
+ ### Magpie
53
+
54
+ Magpie 的插件清单在数据目录的 `plugins.json`。直接用 npm spec(首次加载时按 spec 装,`@latest` 跟着版本走):
55
+
56
+ ```json
57
+ {
58
+ "plugins": [
59
+ { "spec": "@fish-under-sea/opencode-meoo-auth@latest" }
60
+ ]
61
+ }
62
+ ```
63
+
64
+ 也可以把包解开后指向本地目录:
65
+
66
+ ```json
67
+ {
68
+ "plugins": [
69
+ { "spec": "C:\\<magpie 数据目录>\\plugins\\opencode-meoo-auth" }
70
+ ]
71
+ }
72
+ ```
73
+
74
+ 改完重启 magpie:模型来源/插件列表里会出现 **Meoo**,点进去显示 `@fish-under-sea/opencode-meoo-auth`,选一种方式登录即可。
75
+
76
+ ### OpenCode
77
+
78
+ ```bash
79
+ # 包在 npm 上,OpenCode 按包名加载
80
+ # opencode.json 的 plugin 里写 "plugin": ["@fish-under-sea/opencode-meoo-auth@latest"]
81
+ opencode auth login # 选 Meoo
82
+ ```
83
+
84
+ 也可以把本目录放进 `~/.config/opencode/plugin/`,或在 `opencode.json` 里写本目录的绝对路径。
85
+
86
+ ## 配置(可选)
87
+
88
+ 环境变量(Magpie 的插件进程只透传白名单变量,这两个主要用于 OpenCode/裸跑调试):
89
+
90
+ | 变量 | 默认 | 说明 |
91
+ | --- | --- | --- |
92
+ | `MEOO_MAIN_SITE_URL` | `https://meoo.com` | OAuth/控制面站点(测试环境可换) |
93
+ | `MEOO_GATEWAY_BASE_URL` | `https://api.meoo.host/meoo-ai/compatible-mode/v1` | OpenAI 兼容网关 |
94
+ | `MEOO_PROXY_HOME` | `~/.meoo-proxy` | meoo-proxy 登录态目录(复用方式) |
95
+
96
+ ## 排错
97
+
98
+ | 现象 | 处理 |
99
+ | --- | --- |
100
+ | 授权页 404 / unsupported_response_type | 用插件生成的授权链接,别手拼;redirect_uri 必须是本机 loopback |
101
+ | `账号下有多个项目…` | 浏览器登录要求账号有默认项目;或改用「手填 AK」方式指定项目 |
102
+ | `项目 xxx 还没开通 Meoo AI 服务` | 云服务/AK 没有手动按钮:在 meoo.com 打开该项目,**对话框里发「帮我开启云服务」**(或让 AI 加个带后端/AI 的功能),平台自动开通并签发 AK 后重试;若带 `QUOTA_EXCEEDED(实例数已达上限)`,先释放不用的全栈项目/实例(Free 可部署 1 个全栈项目),或升级套餐 |
103
+ | `AK 被网关拒绝 (401/403)` | 填的是用户 Key 或项目没开云服务;确认是 `meoo_project_service_v1.` 开头 |
104
+ | `401(登录态已失效)` | refresh token 失效,重新登录一次 |
105
+ | 模型列表是兜底清单 | 网关 `/models` 暂时拉不到(断网/AK 失效),恢复后会自动同步 |
106
+
107
+ ## 状态与凭证
108
+
109
+ - 凭证(token、AK)只存在宿主的账号记录里:Magpie 的 `plugin-auth.json`、OpenCode 的 `auth.json`。本插件自己不落地任何文件。
110
+ - 「复用本机登录态」是严格只读的,不会写 dsh-meoo-connect / meoo-proxy 的文件,也不消耗它们的 refresh token 之外的东西(续期结果只写回 Magpie 自己的记录)。
111
+ - 调用消耗 Meoo 账号自身额度,插件不绕过任何计费;与 Meoo 官方无关联,是第三方集成。
112
+
113
+ ## 开发
114
+
115
+ ```bash
116
+ node --check index.mjs && node --check opencode.mjs
117
+ node --test test/offline.test.mjs # 19 项:假 fetch + 假 client,含浏览器 PKCE loopback 全流程
118
+ ```
119
+
120
+ Windows 沙箱里跑测试要关掉测试隔离(沙箱禁命名管道,`spawn EPERM`):
121
+
122
+ ```powershell
123
+ node --test --test-isolation=none test/offline.test.mjs
124
+ ```
125
+
126
+ ## 作者
127
+
128
+ - [Fish-under-sea](https://github.com/Fish-under-sea):独立 npm 包化、仓库与发版维护,外层显示名(Meoo)与包名呈现。
129
+ - [Chensy(elysia395)](https://github.com/elysia395):Magpie 供应商插件形态的设计与实现,见 [FISH-DOCK-Plugins PR #35](https://github.com/Fish-under-sea/FISH-DOCK-Plugins/pull/35)。
130
+
131
+ ## 派生声明
132
+
133
+ 本项目是 [2239058652/dsh-meoo-connect](https://github.com/2239058652/dsh-meoo-connect)(MIT,基线 [sangonomiya249/dsh-meoo](https://github.com/sangonomiya249/dsh-meoo) `cf77e92` 衍生)向 Magpie/OpenCode 插件平面的迁移移植,插件形态与代码出自 [FISH-DOCK-Plugins PR #35](https://github.com/Fish-under-sea/FISH-DOCK-Plugins/pull/35);`opencode2.mjs` 适配层整份取自 [magpie-community/plugins](https://github.com/magpie-community/plugins) 的同名字节(MIT)。详见 `THIRD_PARTY_NOTICES.md`。
134
+
135
+ ## License
136
+
137
+ MIT
@@ -0,0 +1,27 @@
1
+ # 第三方声明(THIRD_PARTY_NOTICES)
2
+
3
+ 本包包含或衍生自下列第三方代码,均按其原始 MIT 许可证分发。
4
+
5
+ 本包由 [FISH-DOCK-Plugins PR #35](https://github.com/Fish-under-sea/FISH-DOCK-Plugins/pull/35)(作者:Chensy / elysia395)的 Magpie 供应商插件落成独立 npm 包(维护:Fish-under-sea);插件代码与结构出自该 PR。
6
+
7
+ ## 1. dsh-meoo-connect
8
+
9
+ - 来源:https://github.com/2239058652/dsh-meoo-connect
10
+ - 上游基线:sangonomiya249/dsh-meoo `cf77e92`(独立维护衍生版)
11
+ - 许可证:MIT(原始版权归 sangonomiya249 及 dsh-meoo-connect 作者所有)
12
+ - 使用方式:`index.mjs` 中的 Meoo OAuth(PKCE) 流程、控制面
13
+ (身份/项目/云服务 AK)、网关模型目录解析、兜底模型清单、CLI 请求头
14
+ 等逻辑由该项目的 `index.js` 移植而来,并适配 Magpie/OpenCode 的
15
+ provider 插件契约(auth.loader / provider.models / methods)。
16
+
17
+ ## 2. magpie-community/plugins 的 opencode2.mjs 适配层
18
+
19
+ - 来源:https://github.com/magpie-community/plugins
20
+ (`opencode-raccoon-auth` 包内同名字节)
21
+ - 许可证:MIT
22
+ - 使用方式:`opencode2.mjs` 为 OpenCode 2.x 适配层,按该仓库声明
23
+ 「每个包携带同一份字节」的约定整份复制,未做修改。该文件原样声明:
24
+ 它把 1.x 插件(auth.methods / config / provider.models / auth.loader)
25
+ 适配成 OpenCode 2.x 的 {id, setup(ctx)} 形态。
26
+
27
+ MIT 许可证全文见本包 LICENSE 与上述两个上游仓库。