fix(v2): 服务端入口通过 V2 校验 + 余额自动复用 auth.json 凭据 - #38
Merged
Merged
Conversation
- src/server.ts: 默认导出补充空 setup,避免 V2 服务端因缺少 setup/effect 而通过不了 PluginModule 校验,导致 cli.json 中的插件未激活、面板不显示 - src/v2/commands.ts: readOpenAIOAuthToken 泛化为 readAuthCredential, 同时支持 oauth(access) 与 api(key);V2 的 Provider.Info 不含凭据, provider list 拿不到 key 时回退读取 auth.json,修复 DeepSeek 等 提供商在 V2 下显示「API Key not set」的问题
Owner
|
感谢你的修复,代码合并后,我会尽快发布新版本,感谢你的支持 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
背景
修复 opencode 2.x(V2)下的两个问题,关联 #37。
改动
src/server.ts:默认导出补充空setup(保留 V1 的server字段),使模块通过 V2 的PluginModule校验。本插件没有服务端能力,空setup无副作用;否则 V2 服务端解析./server时会报Plugin must export a default definition with an id and an effect or setup function,插件不激活,TUI 面板不显示。src/v2/commands.ts:readOpenAIOAuthToken()泛化为readAuthCredential(providerID),支持oauth → access与api → key;findOpencodeKeyV2()在 provider list 拿不到凭据时回退读取auth.json。V2 的Provider.Info不包含 key 字段,这一步让 DeepSeek 等 API key 提供商也能自动复用 OpenCode 已认证的凭据(此前仅 OpenAI 特判)。验证
npm run typecheck、npm run build均通过(Node 25)。failed to load plugin,侧边栏面板正常渲染。https://api.deepseek.com/user/balance(api.key)与 OpenAI Codexhttps://chatgpt.com/backend-api/wham/usage(oauth.access)均能取到数据并在余额区展示。Fixes #37
补充说明:#33(未合并)曾尝试整体迁移 V2 并删除
src/server.ts;本 PR 保留现有双入口架构,只补setup,不破坏 V1 的server字段检测。#31 仅调整了 oc2 发布脚本的 server 入口,未解决 1.7.x 主线包在 V2 服务端的 schema 校验问题。