@lks347/dsh-oauth 1.0.1 → 1.0.2

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.en.md CHANGED
@@ -43,11 +43,11 @@ Native OAuth uses the host authorization and credential services. Device codes,
43
43
  The panel can reuse supported entries from **Codex** and **OpenCode** at fixed local locations. Availability is discovered by the server; the browser does not receive the source token or an arbitrary filesystem path.
44
44
 
45
45
  - Codex: the supported ChatGPT token entry in `auth.json`, normally under `~/.codex/`, or the server's configured `CODEX_HOME`.
46
- - OpenCode: the legacy provider dictionary in `auth.json`, normally `~/.local/share/opencode/auth.json`, or the server's configured `XDG_DATA_HOME`. Supported OAuth and API-key entries retain their actual provider identity.
46
+ - OpenCode: the v1 provider dictionary in `auth.json`, or v2 saved credentials through the official CLI. OAuth renews in the source CLI.
47
47
 
48
48
  This saves a reference to an **externally managed** source. The source CLI continues to own refresh and renewal. The plugin rereads the selected source when authorization is needed; it does not copy a refresh token into a competing refresh chain or rewrite the source CLI's file. If the source is removed, expires, or is too close to expiry, renew it in that CLI and retry. Ambiguous entries are rejected rather than silently choosing an account. One provider connection is active at a time.
49
49
 
50
- This implementation does not read OpenCode's newer SQLite database or guess an export-array format. It does not import Hermes credentials. OpenCode and Hermes informed the design, but that research is distinct from an implemented local import source. A generic brand key is not reclassified as a Coding Plan key solely from its name.
50
+ OpenCode v2 lists credential metadata during discovery and exports the selected provider on demand. Set `DSH_OAUTH_OPENCODE_BIN` to the executable's absolute path if the DSH host cannot find it.
51
51
 
52
52
  ## Provider and evidence boundaries
53
53
 
@@ -56,13 +56,13 @@ This implementation does not read OpenCode's newer SQLite database or guess an e
56
56
  | Provider definition | Model source or limitation | Usage adapter and important scope |
57
57
  | --- | --- | --- |
58
58
  | ChatGPT / Codex | Account catalog; native OAuth or supported local source | Account usage windows; account ID retained when available |
59
- | Claude | Account catalog; host OAuth | OAuth usage windows; required profile permission still applies |
59
+ | Claude API | Account catalog via a Claude Console API key | Claude Code subscriptions and usage stay in the official client |
60
60
  | GitHub Copilot | Account picker/policy and declared capabilities | Account usage; request counters and AI credits remain distinct |
61
61
  | Kimi Code | Account catalog; host OAuth or plan key | Coding usage for the selected global/China endpoint |
62
62
  | MiniMax | Installed host catalog; entitlement unknown | Plan remains endpoint; provider counters and units retained |
63
63
  | Z.AI / GLM Coding Plan | Installed host catalog; entitlement unknown | Global/China quota; team queries require both organization and project IDs |
64
64
  | Alibaba Cloud Token Plan | Installed host catalog; entitlement unknown | Personal Console Token Plan usage; separate Console credential and selected region |
65
- | Google Antigravity | **Quota only**; no model protocol integration in the tested host | Remote Google quota summary from compatible OAuth authorization |
65
+ | Google Antigravity | View the model catalog from the official AGY CLI | View subscription usage with `/usage` in AGY |
66
66
  | Google Gemini CLI | **Quota only**; no model protocol integration in the tested host | Code Assist quota requires the authorized project and an eligible OAuth account |
67
67
  | xAI Grok | Account catalog; browser PKCE or device fallback | CLI billing allowance and credits are separate measures |
68
68
  | Nous Portal | Authenticated inference catalog; key connection | Portal OAuth account usage; an inference key alone is insufficient |
package/README.md CHANGED
@@ -52,14 +52,15 @@ dsh plugin --profile desktop add /absolute/path/to/lks347-dsh-oauth-1.0.1.tgz --
52
52
 
53
53
  | 来源 | 模型接入 | 用量与余量 |
54
54
  | --- | --- | --- |
55
- | ChatGPT / Codex、Claude、Copilot、Kimi、Grok | 原有 OAuth;部分支持套餐 Key 或本机复用 | 账号窗口、比例、重置及接口提供的额外余额 |
56
- | MiniMax、Z.AI、阿里 Token Plan | 套餐 Key、地区与已安装模型目录 | 套餐接口;阿里个人套餐需额外 Console 授权 |
55
+ | ChatGPT / Codex、Copilot、Kimi、Grok | 原有 OAuth;部分支持套餐 Key 或本机复用 | 账号窗口、比例、重置及接口提供的额外余额 |
56
+ | Claude API | Claude Console API Key 和在线账号目录 | Claude Code 套餐用量在官方客户端查询 |
57
+ | MiniMax、Z.AI、阿里 Token Plan | 套餐 Key、地区与可用目录 | 套餐接口;阿里个人套餐需额外 Console 授权 |
57
58
  | OpenRouter | OAuth/Key、当前 Key 过滤的模型目录 | Key 预算;账户余额另需 Management Key |
58
59
  | NanoGPT、ZenMux、OpenCode Go/Zen、Kilo、Poe、Synthetic、Chutes | 平台 Key、各自模型目录与调用通道 | 分平台读取窗口、积分、预算或余额;部分需要管理授权/工作区 |
59
60
  | Nous Portal | 推理 Key、组织模型目录 | Portal OAuth 查询授权与推理 Key 分开 |
60
61
  | DeepSeek API、New API 实例 | API Key;New API 显式配置 HTTPS API 根地址 | DeepSeek API 余额;New API 实例定义的 Key 配额单位 |
61
- | Google Antigravity / Gemini CLI | 本轮未增加宿主模型调用协议 | 已实现远程查询;需要匹配的有效授权、项目和服务资格 |
62
- | Qwen Code | 原有 OAuth 与模型导入 | 无本轮可确认的账号余量接口,显示不支持 |
62
+ | Google Antigravity / Gemini CLI | AGY 官方 CLI 目录可在面板查看 | 个人订阅用量在 AGY 的 `/usage` 查询 |
63
+ | Qwen Code | 保留历史 OAuth;新连接使用阿里云套餐入口 | 无本轮可确认的账号余量接口,显示不支持 |
63
64
 
64
65
  DeepSeek 官方网页登录账号仍沿用宿主集成,与新增的 **DeepSeek API 余额**入口分开。详细接口、凭据要求和边界见 [连接与支持清单](docs/CONNECTIONS.md)。
65
66
 
@@ -67,7 +68,7 @@ DeepSeek 官方网页登录账号仍沿用宿主集成,与新增的 **DeepSeek
67
68
 
68
69
  「持续启用」保存的是模型配置,不会延长上游账号或令牌的有效期。网页登录授权继续由宿主凭据服务及 pi-ai 续期;API Key、查询授权也交给宿主凭据服务保存,不放进浏览器存储或模型配置 JSON。
69
70
 
70
- 本机复用支持 Codex 的固定 `auth.json` 和 OpenCode 的传统 `auth.json` 来源。目录来自服务端配置的 `CODEX_HOME`、`XDG_DATA_HOME` 或系统默认值,浏览器不能提交任意文件路径。
71
+ 本机复用支持 Codex 的固定 `auth.json`、OpenCode v1 的传统 `auth.json` 及 OpenCode v2 官方 CLI 管理的授权。目录来自服务端配置的 `CODEX_HOME`、`XDG_DATA_HOME` 或系统默认值,浏览器不能提交任意文件路径。
71
72
 
72
73
  复用采用 **external-managed** 模式:每次使用时重读来源,**不复制刷新令牌,不与源 CLI 同时刷新**。源 CLI 退出或授权临期/过期时,需要在源 CLI 中续期;插件会阻止继续使用自己的旧镜像。本轮没有实现 Hermes 本机凭据导入或 OpenCode SQLite 凭据读取;Hermes 主要提供套餐查询、快照和能力导入的设计参考。
73
74
 
package/app.js CHANGED
@@ -190,6 +190,27 @@ function pullSummary(pulled, provider) {
190
190
  if (!pulled.length) return tr("尚未保存模型。连接后可获取模型与能力。", "No models saved. Fetch models and capabilities after connecting.");
191
191
  return tr(`已保存 ${pulled.length} 个模型:`, `Models saved: ${pulled.length} · `) + pulled.map((model) => escapeHtml(model.name || model.id)).join(locale === "en" ? ", " : "、");
192
192
  }
193
+ function providerConnectionHint(provider) {
194
+ if (provider.sourceStatus) return provider.sourceStatus === "source-reauth-required"
195
+ ? tr("本机授权已到期,请在源 CLI 中续期。", "Local authorization expired. Renew it in the source CLI.")
196
+ : tr("本机授权来源不可用,请重新选择或断开连接。", "Local authorization is unavailable. Select a source again or disconnect.");
197
+ if (provider.supportReason === "gemini-consumer-retired") return tr(
198
+ "Gemini CLI 个人订阅登录已停用。个人 Google 订阅请在 Antigravity CLI 中登录。",
199
+ "Gemini CLI consumer sign-in ended. Use Antigravity CLI for a personal Google subscription.",
200
+ );
201
+ if (provider.supportReason === "qwen-legacy-oauth") return tr(
202
+ "此入口保留已有的旧版 OAuth。新连接请使用阿里云 Token Plan。",
203
+ "This entry retains existing legacy OAuth connections. Use Alibaba Cloud Token Plan for new connections.",
204
+ );
205
+ if (provider.id === "anthropic") return tr(
206
+ "使用 Claude Console API Key 连接。Claude Code 订阅由其官方客户端管理。",
207
+ "Connect with a Claude Console API key. The official client manages Claude Code subscriptions.",
208
+ );
209
+ if (provider.keyConnect) return tr("可使用套餐密钥连接。调用与用量查询可能需要不同权限。", "Connect with a plan key. Model access and usage queries may require different permissions.");
210
+ return provider.pullable === false
211
+ ? tr("未连接。可用功能以此来源与宿主的支持范围为准。", "Not connected. Available features depend on this source and the host integration.")
212
+ : tr("未连接。登录后可获取模型与套餐信息。", "Not connected. Sign in to fetch models and plan information.");
213
+ }
193
214
  function shownProviders() { return remote === null ? PROVIDERS : remote; }
194
215
  function flowLabel(provider) {
195
216
  if (provider.authMethods?.length === 0) return tr("连接待支持", "Connection unavailable");
@@ -310,12 +331,12 @@ function renderList() {
310
331
  const connection = provider.connection || {};
311
332
  const context = [connection.label, connection.sourceLabel || provider.sourceLabel, connection.region, connection.organizationId, connection.workspaceId, connection.projectId].filter(Boolean);
312
333
  const detail = loggedIn ? `<span class="meta connection-summary">${escapeHtml(context.join(" · ") || tr("授权已保存", "Authorization saved"))}</span><span class="meta">${pullSummary(pulled, provider)}</span>`
313
- : `<span class="hint">${provider.keyConnect ? tr("可使用套餐密钥连接。调用与用量查询可能需要不同权限。", "Connect with a plan key. Model access and usage queries may require different permissions.") : (provider.pullable === false ? tr("未连接。可用功能以此来源与宿主的支持范围为准。", "Not connected. Available features depend on this source and the host integration.") : tr("未连接。登录后可获取模型与套餐信息。", "Not connected. Sign in to fetch models and plan information."))}</span>${provider.cli ? `<div class="cli"><code>${escapeHtml(provider.cli)}</code><button class="btn" type="button" data-copy="${id}">${tr("复制", "Copy")}</button></div>` : ""}`;
334
+ : `<span class="hint">${providerConnectionHint(provider)}</span>${provider.cli ? `<div class="cli"><code>${escapeHtml(provider.cli)}</code><button class="btn" type="button" data-copy="${id}">${tr("复制", "Copy")}</button></div>` : ""}`;
314
335
  const disabled = pendingId || apiMode === "checking" || apiMode === "unavailable";
315
336
  const action = loggedIn
316
337
  ? `${provider.pullable === false ? "" : `<button class="btn solid" type="button" data-pull="${id}" ${apiMode !== "live" || pendingId ? "disabled" : ""}>${tr("拉取模型", "Fetch models")}</button>`}${apiMode === "live" ? `<button class="btn" type="button" data-configure="${id}">${tr("连接配置", "Connection settings")}</button>${!usageOpen.has(provider.id) ? `<button class="btn" type="button" data-usage="${id}" ${usageBusy.has(provider.id) ? "disabled" : ""}>${tr("套餐与用量", "Plan & usage")}</button>` : ""}` : ""}<button class="btn" type="button" data-disconnect="${id}" ${disabled ? "disabled" : ""}>${apiMode === "preview" ? tr("移除示例", "Remove example") : tr("断开连接", "Disconnect")}</button>`
317
- : `${oauth ? `<button class="btn solid" type="button" data-login="${id}" ${disabled || !browserReady ? "disabled" : ""}>${pendingId === provider.id ? tr("登录中", "Signing in") : apiMode === "preview" ? tr("演示登录", "Demo sign-in") : provider.id === "xai" ? tr("浏览器登录", "Browser sign-in") : tr("登录", "Sign in")}</button>` : ""}${provider.keyConnect && apiMode === "live" ? `<button class="btn ${oauth ? "" : "solid"}" type="button" data-connect="${id}" ${disabled ? "disabled" : ""}>${tr("连接密钥", "Connect key")}</button>` : ""}${provider.id === "xai" && apiMode !== "preview" ? `<button class="btn" type="button" data-login="xai" data-login-method="device" ${disabled ? "disabled" : ""}>${tr("设备码备用", "Use device code")}</button>` : ""}${provider.authMethods?.includes("local") && apiMode === "live" ? `<button class="btn" type="button" data-local="${id}">${tr("复用本机授权", "Reuse local authorization")}</button>` : ""}${!oauth && !provider.keyConnect && !provider.authMethods?.includes("local") ? `<span class="hint">${tr("此来源尚未支持连接", "Connection not available for this source")}</span>` : ""}`;
318
- return `<div class="row" data-provider="${id}"><div class="identity">${shield(loggedIn)}<div><div class="name-line"><span class="name">${escapeHtml(provider.name)}</span>${badges}</div>${detail}${row.error ? `<span class="err">${escapeHtml(row.error)}</span>` : ""}${!browserReady && apiMode === "live" ? `<span class="hint">${tr("当前服务尚未加载浏览器登录,请重新启动 DSH 以启用新版路线。", "Restart DSH to load browser sign-in support.")}</span>` : ""}${loggedIn ? usageHtml(provider) : ""}</div></div><div class="actions">${provider.docs && safeAuthorizationUrl(provider.docs) ? `<a class="icon-btn" href="${escapeHtml(provider.docs)}" target="_blank" rel="noopener noreferrer" aria-label="${escapeHtml(tr(`打开 ${provider.name} 文档`, `Open ${provider.name} documentation`))}">↗</a>` : ""}${action}</div></div>`;
338
+ : `${oauth ? `<button class="btn solid" type="button" data-login="${id}" ${disabled || !browserReady ? "disabled" : ""}>${pendingId === provider.id ? tr("登录中", "Signing in") : apiMode === "preview" ? tr("演示登录", "Demo sign-in") : provider.id === "xai" ? tr("浏览器登录", "Browser sign-in") : tr("登录", "Sign in")}</button>` : ""}${provider.keyConnect && apiMode === "live" ? `<button class="btn ${oauth ? "" : "solid"}" type="button" data-connect="${id}" ${disabled ? "disabled" : ""}>${tr("连接密钥", "Connect key")}</button>` : ""}${provider.id === "xai" && apiMode !== "preview" ? `<button class="btn" type="button" data-login="xai" data-login-method="device" ${disabled ? "disabled" : ""}>${tr("设备码备用", "Use device code")}</button>` : ""}${provider.authMethods?.includes("local") && apiMode === "live" ? `<button class="btn" type="button" data-local="${id}">${tr("复用本机授权", "Reuse local authorization")}</button>` : ""}${!oauth && !provider.keyConnect && !provider.authMethods?.includes("local") && !provider.supportReason ? `<span class="hint">${tr("此来源尚未支持连接", "Connection not available for this source")}</span>` : ""}`;
339
+ return `<div class="row" data-provider="${id}"><div class="identity">${shield(loggedIn)}<div><div class="name-line"><span class="name">${escapeHtml(provider.name)}</span>${badges}</div>${detail}${row.error ? `<span class="err">${escapeHtml(row.error)}</span>` : ""}${!browserReady && apiMode === "live" ? `<span class="hint">${tr("当前服务尚未加载浏览器登录,请重新启动 DSH 以启用新版路线。", "Restart DSH to load browser sign-in support.")}</span>` : ""}${loggedIn ? usageHtml(provider) : ""}</div></div><div class="actions">${provider.docs && safeAuthorizationUrl(provider.docs) ? `<a class="icon-btn" href="${escapeHtml(provider.docs)}" target="_blank" rel="noopener noreferrer" aria-label="${escapeHtml(tr(`打开 ${provider.name} 文档`, `Open ${provider.name} documentation`))}">↗</a>` : ""}${action}${provider.cliCatalog && apiMode === "live" ? `<button class="btn" type="button" data-pull="${id}">${tr("查看 AGY CLI 模型", "View AGY CLI models")}</button>` : ""}${!loggedIn && provider.sourceStatus && provider.credentialConfigured ? `<button class="btn" type="button" data-disconnect="${id}">${tr("断开连接", "Disconnect")}</button>` : ""}</div></div>`;
319
340
  }).join("");
320
341
  }
321
342
  async function refreshUsage(id) {
@@ -666,6 +687,15 @@ function modelEvidence(model) {
666
687
  function renderPull(provider, models, error) {
667
688
  const root = document.querySelector("#modal");
668
689
  root.hidden = false;
690
+ if (provider.cliCatalog) {
691
+ root.innerHTML = `<div class="overlay" data-backdrop="1"><div class="dialog pull-dialog" role="dialog" aria-modal="true" aria-labelledby="pull-title">
692
+ <h2 id="pull-title">${tr("AGY CLI 模型目录", "AGY CLI model catalog")}</h2>
693
+ <p class="hint">${tr("目录由 AGY CLI 返回。通过 AGY 使用这些模型,在 CLI 中输入 /usage 查看套餐用量。", "Use these models with AGY CLI. Enter /usage there for plan quota.")}</p>
694
+ ${error ? `<p class="err" role="alert">${escapeHtml(error)}</p>` : `<ul class="choices">${models.map(model => `<li class="choice"><span>${escapeHtml(model.name)}</span><code>${escapeHtml(model.id)}</code></li>`).join("")}</ul>`}
695
+ <div class="row-actions"><button class="btn" type="button" id="cancel-pull">${tr("关闭", "Close")}</button></div></div></div>`;
696
+ focusDialog();
697
+ return;
698
+ }
669
699
  const chat = models.filter((model) => !model.role || model.role === "chat");
670
700
  const media = models.filter((model) => model.role === "image" || model.role === "video");
671
701
  const selected = new Set((provider.pulledModels || []).map((model) => model.id));
@@ -701,7 +731,7 @@ async function openPull(id) {
701
731
  root.innerHTML = `<div class="overlay"><div class="dialog" role="dialog" aria-modal="true" aria-labelledby="loading-title"><h2 id="loading-title">${escapeHtml(tr(`正在拉取 ${provider.name}`, `Fetching ${provider.name}`))}</h2><p class="hint">${tr("正在读取模型目录与能力信息。", "Reading the model catalog and capabilities.")}</p></div></div>`;
702
732
  focusDialog();
703
733
  let models = [], error = "";
704
- try { const body = await post("models", { provider: id }); models = Array.isArray(body.models) ? body.models : []; }
734
+ try { const body = await post("models", { provider: id, ...(provider.cliCatalog ? { source: "agy" } : {}) }); models = Array.isArray(body.models) ? body.models : []; }
705
735
  catch (cause) { error = cause.message; }
706
736
  if (serial !== modalSerial) return;
707
737
  pullModels = models; pullError = error;
@@ -811,11 +841,21 @@ async function openLocal(id) {
811
841
  } catch (error) { if (serial === modalSerial) localTarget.error = error.message; }
812
842
  if (serial === modalSerial) { localTarget.loading = false; renderLocal(); }
813
843
  }
844
+ function localSourceStatus(source, item) {
845
+ if (source.available && item.available) return tr("可复用", "Available");
846
+ if (item.reasonCode === "source-does-not-export-credentials") return tr(
847
+ "AGY 通过系统钥匙串管理登录,暂无法在此导入。请在 agy 中输入 /usage 查看套餐用量。",
848
+ "AGY manages sign-in in the system keyring. To view plan usage, enter /usage in agy.",
849
+ );
850
+ if (item.reasonCode === "ambiguous-source") return tr("源 CLI 有多个账号,请保留明确的授权来源。", "The source CLI has several accounts. Select a single authorization source.");
851
+ if (item.reasonCode === "unsupported-provider") return tr("此授权类型与该提供商的接入方式不兼容。", "This authorization type is unsupported for the provider.");
852
+ return tr("未找到可用授权,请先在源 CLI 登录", "No usable authorization; sign in in the source CLI first");
853
+ }
814
854
  function renderLocal() {
815
855
  const { provider, sources, loading, error } = localTarget;
816
856
  const choices = sources.flatMap((source) => (source.providers || []).filter((item) => item.provider === provider.id).map((item) => ({ source, item })));
817
857
  const root = document.querySelector("#modal"); root.hidden = false;
818
- root.innerHTML = `<div class="overlay" data-backdrop="1"><div class="dialog" role="dialog" aria-modal="true" aria-labelledby="local-title"><h2 id="local-title">${escapeHtml(tr(`复用 ${provider.name} 本机授权`, `Reuse local ${provider.name} authorization`))}</h2><p class="hint">${tr("使用固定位置的 CLI 授权。续期仍由源 CLI 管理,不复制刷新令牌;源 CLI 退出或授权过期后,需要在源 CLI 中重新登录。", "Use authorization from a known CLI location. The source CLI owns renewal; refresh tokens are not copied. Sign in again in that CLI if its authorization expires or is removed.")}</p><form id="local-form"><div class="choices">${loading ? `<p class="hint">${tr("正在检查本机来源…", "Checking local sources…")}</p>` : choices.length ? choices.map(({ source, item }) => `<label class="choice"><input type="radio" name="source" id="local-source-${escapeHtml(source.id)}" value="${escapeHtml(source.id)}" ${source.available && item.available ? "" : "disabled"} required /><span>${escapeHtml(source.label || source.id)}</span><span class="model-capabilities">${source.available && item.available ? tr("可复用", "Available") : tr("未找到可用授权,请先在源 CLI 登录", "No usable authorization; sign in in the source CLI first")}</span></label>`).join("") : `<p class="hint">${tr("没有找到此提供商支持的本机授权来源。", "No supported local authorization source was found for this provider.")}</p>`}</div><p class="err form-error" id="local-error" role="alert">${escapeHtml(error || "")}</p><div class="row-actions"><button class="btn" type="button" id="cancel-local">${tr("取消", "Cancel")}</button><button class="btn solid" id="save-local" type="submit" ${loading || localTarget.saving || !choices.some(({ source, item }) => source.available && item.available) ? "disabled" : ""}>${tr("确认复用此来源", "Use selected source")}</button></div></form></div></div>`;
858
+ root.innerHTML = `<div class="overlay" data-backdrop="1"><div class="dialog" role="dialog" aria-modal="true" aria-labelledby="local-title"><h2 id="local-title">${escapeHtml(tr(`复用 ${provider.name} 本机授权`, `Reuse local ${provider.name} authorization`))}</h2><p class="hint">${tr("可复用授权的续期由源 CLI 管理。授权过期时,请在对应 CLI 中续期。", "The source CLI manages renewal for reusable credentials. Renew expired authorization in that CLI.")}</p><form id="local-form"><div class="choices">${loading ? `<p class="hint">${tr("正在检查本机来源…", "Checking local sources…")}</p>` : choices.length ? choices.map(({ source, item }) => `<label class="choice"><input type="radio" name="source" id="local-source-${escapeHtml(source.id)}" value="${escapeHtml(source.id)}" ${source.available && item.available ? "" : "disabled"} required /><span>${escapeHtml(source.label || source.id)}</span><span class="model-capabilities">${escapeHtml(localSourceStatus(source, item))}</span></label>`).join("") : `<p class="hint">${tr("没有找到此提供商支持的本机授权来源。", "No supported local authorization source was found for this provider.")}</p>`}</div><p class="err form-error" id="local-error" role="alert">${escapeHtml(error || "")}</p><div class="row-actions"><button class="btn" type="button" id="cancel-local">${tr("取消", "Cancel")}</button><button class="btn solid" id="save-local" type="submit" ${loading || localTarget.saving || !choices.some(({ source, item }) => source.available && item.available) ? "disabled" : ""}>${tr("确认复用此来源", "Use selected source")}</button></div></form></div></div>`;
819
859
  focusDialog();
820
860
  }
821
861
  async function saveLocal(event) {
@@ -14,18 +14,18 @@ Key 连接保存在宿主 `dsh-oauth-connections/<provider>` 记录中,调用
14
14
 
15
15
  | 提供商 | 模型来源/接入 | 用量读取 | 额外要求与限制 |
16
16
  | --- | --- | --- | --- |
17
- | ChatGPT / Codex | 账号目录,宿主 OAuth / Codex 或 OpenCode 来源 | `GET chatgpt.com/backend-api/wham/usage` | 绑定 ChatGPT account;普通 OpenAI API Key 不替代订阅。按返回窗口解释,不硬编码套餐总 token |
18
- | Claude | Anthropic 账号目录与 OAuth | `GET api.anthropic.com/api/oauth/usage` | 需要订阅 OAuth 的相应权限;不是 Anthropic API 余额。额外付费与套餐窗口分开 |
17
+ | ChatGPT / Codex | 账号目录,宿主 OAuth / Codex 或 OpenCode 来源 | `GET chatgpt.com/backend-api/wham/usage` | 目录请求使用插件支持的客户端版本,或本机 Codex 缓存记录的更新版本。模型列表来自当前授权账号的在线响应,保留 Codex 模型选择器的可见范围 |
18
+ | Claude API | Claude Console API Key 的 Anthropic 目录 | Claude Code 套餐用量在官方客户端查看 | API Key 属于 Claude Platform 计费通道 |
19
19
  | Copilot | 账号 picker/policy 目录 | `GET api.github.com/copilot_internal/user` | 使用原始 GitHub 授权,不使用临时推理 token;只给已用积分而无上限时,不推算余量 |
20
20
  | Kimi Code | 账号目录、OAuth 或套餐 Key | `/coding/v1/usages` | 中国/国际区明确选择;比例 0–1 转百分比,钱包固定点金额单独换算。普通 Moonshot Key 不等于 Coding Plan |
21
- | MiniMax | 已安装目录、Anthropic 协议套餐通道 | `/v1/token_plan/remains` | 用返回比例核对新旧 counts 语义;`0/0` 不自动当无限。中国推理域名与查询域名可不同 |
22
- | Z.AI / GLM | 已安装目录、Coding 专用通道 | `/api/monitor/usage/quota/limit` | 组织/项目需成对;TOKENS_LIMIT 不擅自换算成原始 token;工具额度单列 |
23
- | 阿里 Token Plan | 地区对应的已安装目录和 Token Plan 通道 | 个人 Console gateway 读取 | 需要独立 Console token;推理 Key 不自动具有账单权限。本轮不实现团队 ACS3 签名全链路 |
21
+ | MiniMax | 已安装目录加用量响应中明确列出的对话模型,Anthropic 协议套餐通道 | `/v1/token_plan/remains` | 用返回比例核对新旧 counts 语义;`0/0` 不自动当无限。中国推理域名与查询域名可不同 |
22
+ | Z.AI / GLM | 优先查询 Coding 通道目录;服务未实现时使用已安装目录 | `/api/monitor/usage/quota/limit` | 组织/项目需成对;TOKENS_LIMIT 不擅自换算成原始 token;工具额度单列 |
23
+ | 阿里 Token Plan | 优先查询对应地区的 Token Plan 目录;服务未实现时使用已安装目录 | 个人 Console gateway 读取 | 需要独立 Console token;推理 Key 不自动具有账单权限。本轮不实现团队 ACS3 签名全链路 |
24
24
  | Grok / xAI | 原有 OAuth 账号目录 | `/v1/billing?format=credits` | 订阅窗口与预付金额分开;已使用本机真实授权通过读取与重启复查,其他套餐仍需分别确认 |
25
25
  | Nous Portal | 已授权组织推理目录 | `portal.nousresearch.com/api/oauth/account` | Key 连接另需 Portal OAuth;basis points 转百分比;推理 Key 不发送到 Portal 冒充 OAuth |
26
- | Antigravity | 本轮没有宿主模型协议 | `daily-cloudcode-pa.googleapis.com/v1internal:retrieveUserQuotaSummary` | 仅匹配的有效来源授权可查询,不自动开通项目;远端接口可能变化 |
27
- | Gemini CLI | 本轮没有宿主模型协议 | `cloudcode-pa.googleapis.com/v1internal:retrieveUserQuota` | 需要匹配项目和服务资格,不能用旧消费者登录路线保证当前可用性 |
28
- | Qwen Code | 原有 OAuth、账号目录 | 不支持主动余量查询 | 不把 CLI 本地累计 token 当账户剩余 |
26
+ | Antigravity | 官方 AGY CLI 目录浏览 | `daily-cloudcode-pa.googleapis.com/v1internal:retrieveUserQuotaSummary` | `agy` 通过系统钥匙串管理登入,插件无法从 CLI 直接导入。可在 `agy` 中输入 `/usage` 查看套餐用量。插件查询需要另有匹配的有效来源授权 |
27
+ | Gemini CLI | 本轮没有宿主模型协议 | `cloudcode-pa.googleapis.com/v1internal:retrieveUserQuota` | 需要匹配项目和服务资格,不能用已退役的消费者登录路线;个人用户转用 Antigravity |
28
+ | Qwen Code 旧 OAuth | 支持读取和移除已有授权 | 不支持主动余量查询 | 新连接使用阿里云套餐入口 |
29
29
  | DeepSeek API | API 模型目录与 API Key | `GET api.deepseek.com/user/balance` | 保留各币种小数余额,与 DSH 的 DeepSeek 官方网页登录账号分开 |
30
30
 
31
31
  ## 第三方平台
@@ -74,4 +74,4 @@ Key 连接保存在宿主 `dsh-oauth-connections/<provider>` 记录中,调用
74
74
 
75
75
  设计参考 [OpenCode](https://github.com/anomalyco/opencode) 的授权与模型接入、[Hermes Agent](https://github.com/NousResearch/hermes-agent) 的能力与套餐状态。字段优先核对供应商合同,包括 [OpenRouter credits](https://openrouter.ai/docs/api/api-reference/credits/get-remaining-credits)、[DeepSeek 余额](https://api-docs.deepseek.com/api/get-user-balance) 和 [Google 服务迁移说明](https://developers.google.com/gemini-code-assist/docs/deprecations/code-assist-individuals)。
76
76
 
77
- 尚未完成:Hermes 本机凭据、OpenCode SQLite 读取、Google 模型调用协议、阿里团队 ACS3 账单、New API 用户级订阅账单、LiteLLM 专用管理适配,以及其余供应商真实账号的逐家验收。Codex、OpenRouter、xAI 的真实只读验收已通过,见 [验收记录](LIVE-VALIDATION-1.0.1.md)。接口或服务资格变更仍需重新核对。
77
+ 尚未完成:Hermes 本机凭据、Google 模型调用协议、阿里团队 ACS3 账单、New API 用户级订阅账单、LiteLLM 专用管理适配,以及其余供应商真实账号的逐家验收。Codex、OpenRouter、xAI 的真实只读验收已通过,见 [验收记录](LIVE-VALIDATION-1.0.1.md)。接口或服务资格变更仍需重新核对。
@@ -21,18 +21,28 @@ OpenRouter 当前授权只能确认 Key 用量与预算,没有 Management Key
21
21
 
22
22
  ## 安装与发布状态
23
23
 
24
- 本地安装包名称为 `lks347-dsh-oauth-1.0.1.tgz`:
24
+ 已发布到 [npm:@lks347/dsh-oauth@1.0.1](https://www.npmjs.com/package/@lks347/dsh-oauth/v/1.0.1),`latest` 指向 `1.0.1`。注册表记录的发布时间为 **2026-11-16 22:25:15(新加坡时间)**;2026-11-17 00:01:45 下载核验通过。
25
+
26
+ 下载已发布安装包,再使用目标 DSH 安装附带的 CLI 添加到指定 profile:
25
27
 
26
28
  ```sh
29
+ npm pack @lks347/dsh-oauth@1.0.1
27
30
  dsh plugin --profile desktop add /absolute/path/to/lks347-dsh-oauth-1.0.1.tgz --offline
28
31
  ```
29
32
 
30
- 版本 `1.0.0` 曾被撤回,不可复用,因此采用 `1.0.1`。npm 对整包撤回规定了 24 小时重发等待期;依据 2026-11-16 的撤回确认时间,保守可再次发布时间为 **2026-11-17 12:27:26 UTC / 新加坡时间 20:27:26**。[npm 官方规则](https://docs.npmjs.com/policies/unpublish/)
33
+ 版本 `1.0.0` 曾被撤回,因此本次采用 `1.0.1`。从注册表下载的包与通过安装、宿主和持久化验收的本地包逐字节一致,共 65 个文件、191,964 字节;SHA-256 为:
34
+
35
+ ```text
36
+ 76438a3344f8bf045b9ab29d4eb2a067030c451982885f6375bffb9f740861da
37
+ ```
38
+
39
+ 发布代码提交为 `06f427716fef8bb4bb8381fcdba368ecbf3cc9a3`,对应 tag `v1.0.1`。发布后的文档状态更新单独提交,不移动 tag,不覆盖已发布的安装包。[注册表核验记录](evidence/release-1.0.1.json) 保留了版本、时间及完整性信息。
31
40
 
32
- Git 仓库、tag 或本地 tgz 的存在不代表 npm 已接收发布;注册表的实际状态可用以下命令确认:
41
+ 可用以下命令核对注册表中的版本、完整性及默认安装标签:
33
42
 
34
43
  ```sh
35
44
  npm view @lks347/dsh-oauth@1.0.1 version dist.integrity
45
+ npm view @lks347/dsh-oauth dist-tags
36
46
  ```
37
47
 
38
48
  升级不会自动给账号增加订阅权限。Google 模型协议、Hermes 本机导入、OpenCode SQLite、团队账单等未完成范围继续明确标注,没有宣称全市场套餐均已实测。
@@ -0,0 +1,8 @@
1
+ # @lks347/dsh-oauth 1.0.2
2
+
3
+ - Codex 使用更新的模型目录协议版本。OpenRouter 跟随同源分页,Copilot 保留标记缺失但策略明确启用的模型,Grok 保留目录中可导入的媒体变体。
4
+ - OpenCode v2 通过官方 CLI 读取可用凭证元数据,并按需获取选定提供商的授权。继续支持 v1 的 `auth.json`。授权失效时,面板会提示回到源 CLI 处理。
5
+ - Claude 面板支持 Console API Key。历史 Qwen OAuth 授权可继续使用,新连接使用阿里云套餐入口。Gemini CLI 个人用户可在 Antigravity CLI 登录,AGY 条目可通过官方 CLI 读取模型目录。
6
+ - 修复 Kimi OAuth 适配器只返回授权请求头时无法拉取目录的问题。阿里云 Token Plan 和 Z.AI 优先查询套餐端点的目录,MiniMax 补充用量端点明确列出的对话模型。服务未提供目录时展示已安装目录及其来源。
7
+
8
+ AGY 订阅登录由 CLI 的系统钥匙串管理,可在官方 CLI 中使用模型并通过 `/usage` 查看套餐用量。插件的 AGY 浏览页用于查看目录。OpenCode v2 如有多个账户且 CLI 响应无法明确标识所选账户,插件会提示选择可无歧义复用的授权。桌面宿主找不到 OpenCode 时,可为宿主设置 `DSH_OAUTH_OPENCODE_BIN`,值为 OpenCode 可执行文件的绝对路径。
@@ -0,0 +1,38 @@
1
+ {
2
+ "status": "published",
3
+ "checkedAt": "2026-11-16T16:01:45.833Z",
4
+ "package": "@lks347/dsh-oauth@1.0.1",
5
+ "commit": "06f427716fef8bb4bb8381fcdba368ecbf3cc9a3",
6
+ "remoteBranch": "main",
7
+ "tag": "v1.0.1",
8
+ "pushed": true,
9
+ "registryVersionVisible": true,
10
+ "tarball": {
11
+ "filename": "lks347-dsh-oauth-1.0.1.tgz",
12
+ "bytes": 191964,
13
+ "sha256": "76438a3344f8bf045b9ab29d4eb2a067030c451982885f6375bffb9f740861da",
14
+ "integrity": "sha512-eYB96MdRwUgYP0xy2WRzRCR2jwoz1uA4BSC7pFNvzVR7E150ZiNE7rmfZEoHQtoxjmmHjMCr2JmJ/5i2JKsYqA=="
15
+ },
16
+ "verification": {
17
+ "unitPassed": 292,
18
+ "liveProviders": [
19
+ "openai-codex",
20
+ "openrouter",
21
+ "xai"
22
+ ],
23
+ "independentLiveProcesses": 2,
24
+ "installedPackagePassed": true,
25
+ "olderHostPassed": true,
26
+ "subscriptionUiScenarios": 19,
27
+ "authorizationUiScenarios": 11
28
+ },
29
+ "registry": {
30
+ "publishedAt": "2026-11-16T14:25:15.655Z",
31
+ "latest": "1.0.1",
32
+ "downloaded": true,
33
+ "bytes": 191964,
34
+ "sha256": "76438a3344f8bf045b9ab29d4eb2a067030c451982885f6375bffb9f740861da",
35
+ "integrity": "sha512-eYB96MdRwUgYP0xy2WRzRCR2jwoz1uA4BSC7pFNvzVR7E150ZiNE7rmfZEoHQtoxjmmHjMCr2JmJ/5i2JKsYqA==",
36
+ "matchesTestedTarball": true
37
+ }
38
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lks347/dsh-oauth",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
4
4
  "publishConfig": { "access": "public", "registry": "https://registry.npmjs.org/" },
5
5
  "repository": { "type": "git", "url": "git+https://github.com/lakeofsky347/dsh-oauth.git" },
6
6
  "description": "Subscription connections, model capabilities and provider-reported usage for DeepSeek Harness.",
@@ -44,18 +44,10 @@ try {
44
44
  let commitDuringCancel = false;
45
45
  const deepseekCancels = [];
46
46
  let deepseekState = { status: "signed-out", attempt: null };
47
- let pauseQwenRecord;
48
- let pauseQwenReference;
49
47
  class MemoryCredentials extends CredentialProvider {
50
48
  async resolve(ref) { const value = references.get(ref); return value === undefined ? undefined : { value, source: "memory" }; }
51
49
  async describe(ref) { return { configured: references.has(ref), writable: true }; }
52
50
  async set(ref, value) {
53
- if (ref === "QWEN_OAUTH_ACCESS" && pauseQwenReference) {
54
- const pause = pauseQwenReference;
55
- pauseQwenReference = undefined;
56
- pause.enter();
57
- await pause.wait;
58
- }
59
51
  references.set(ref, value); this.notifyUpdated(ref);
60
52
  }
61
53
  async unset(ref) { references.delete(ref); this.notifyUpdated(ref); }
@@ -63,12 +55,6 @@ try {
63
55
  async describeRecord(key) { const value = records.get(key); return { configured: value !== undefined, writable: true, ...(value === undefined ? {} : { kind: value.kind }) }; }
64
56
  async listRecords() { return [...records].map(([key, record]) => ({ key, kind: record.kind })); }
65
57
  async modifyRecord(key, mutate) {
66
- if (key === credentialKey("dsh-oauth", "qwen") && pauseQwenRecord) {
67
- const pause = pauseQwenRecord;
68
- pauseQwenRecord = undefined;
69
- pause.enter();
70
- await pause.wait;
71
- }
72
58
  const next = await mutate(records.get(key));
73
59
  if (next !== undefined) { records.set(key, next); this.notifyRecordUpdated(key); }
74
60
  return records.get(key);
@@ -169,28 +155,14 @@ try {
169
155
  assert.deepEqual(deepseekCancels, ["deepseek-attempt-2", "deepseek-attempt-3"]);
170
156
  assert.ok(ctx.authorization instanceof authorizationModule.AuthorizationService);
171
157
  const key = credentialKey("dsh-oauth", "qwen");
172
- assert.ok(ctx.authorization.describe(key), "the Qwen flow is registered on the actual AuthorizationService");
173
- let networkCalls = 0;
174
- globalThis.fetch = async (url, options) => {
175
- networkCalls += 1;
176
- assert.equal(options.method, "POST");
177
- const path = String(url);
178
- if (path === "https://chat.qwen.ai/api/v1/oauth2/device/code") {
179
- assert.ok(options.body.get("code_challenge"));
180
- return new Response(JSON.stringify({ verification_uri_complete: "https://example.invalid/verify", device_code: "offline-device", user_code: "OFFLINE-CODE", expires_in: 30 }));
181
- }
182
- assert.equal(path, "https://chat.qwen.ai/api/v1/oauth2/token", "unexpected external request is refused");
183
- assert.equal(options.body.get("grant_type"), "urn:ietf:params:oauth:grant-type:device_code");
184
- return new Response(JSON.stringify({ access_token: "offline-access", refresh_token: "offline-refresh", expires_in: 3600, resource_url: "https://portal.qwen.ai" }));
185
- };
186
- const notices = [];
187
- const outcome = await ctx.authorization.begin({ key, interaction: { notify: (notice) => notices.push(notice), prompt: async () => { throw new Error("unexpected prompt"); } } });
188
- assert.deepEqual(outcome, { status: "authorized" });
189
- assert.equal(networkCalls, 2);
190
- assert.equal(records.get(key)?.payload.access, "offline-access");
191
- assert.equal(references.get("QWEN_OAUTH_ACCESS"), "offline-access");
192
- assert.equal(notices[0]?.url, "https://example.invalid/verify");
193
- assert.equal(notices[0]?.code, "OFFLINE-CODE");
158
+ assert.equal(ctx.authorization.describe(key), undefined, "new legacy Qwen login is retired");
159
+ globalThis.fetch = async () => assert.fail("retired Qwen login must not reach the provider");
160
+ const retired = await request("/oauth/api/login", { provider: "qwen" });
161
+ assert.equal(retired.status, 400);
162
+ assert.match(JSON.parse(retired.body).error, /Token Plan/);
163
+ records.set(key, { kind: "grant", payload: {
164
+ access: "offline-access", refresh: "offline-refresh", expires: Date.now() + 3600000, resourceUrl: "https://portal.qwen.ai",
165
+ } });
194
166
  globalThis.fetch = async (url, options) => {
195
167
  assert.equal(String(url), "https://portal.qwen.ai/v1/models");
196
168
  assert.equal(options.headers.authorization, "Bearer offline-access");
@@ -211,34 +183,6 @@ try {
211
183
  assert.equal(loggedOut.status, 200, loggedOut.body);
212
184
  assert.equal(userSettings.providers.qwen, undefined, "logout restores the previous settings through the adapter schema");
213
185
 
214
- for (const phase of ["record", "reference"]) {
215
- let enter;
216
- let release;
217
- const entered = new Promise((resolve) => { enter = resolve; });
218
- const wait = new Promise((resolve) => { release = resolve; });
219
- if (phase === "record") pauseQwenRecord = { enter, wait };
220
- else pauseQwenReference = { enter, wait };
221
- globalThis.fetch = async (url) => new Response(JSON.stringify(String(url).endsWith("/device/code")
222
- ? { verification_uri: "https://example.invalid/qwen", device_code: "offline-device", expires_in: 30 }
223
- : { access_token: `offline-delayed-${phase}`, refresh_token: "offline-refresh", expires_in: 3600 }));
224
- const pending = await request("/oauth/api/login", { provider: "qwen" });
225
- assert.equal(pending.status, 200, pending.body);
226
- await entered;
227
- const disconnecting = request("/oauth/api/logout", { provider: "qwen" });
228
- // Let the HTTP handler cancel the flow and queue cleanup behind its in-flight write.
229
- await new Promise((resolve) => setImmediate(resolve));
230
- release();
231
- const disconnected = await disconnecting;
232
- assert.equal(disconnected.status, 200, disconnected.body);
233
- assert.equal(records.has(key), false, `disconnect wins after a delayed Qwen ${phase} write`);
234
- assert.equal(references.has("QWEN_OAUTH_ACCESS"), false, `a delayed Qwen ${phase} write cannot recreate the access reference`);
235
- }
236
- const replacement = await ctx.authorization.begin({ key, interaction: { notify() {}, prompt: async () => { throw new Error("unexpected prompt"); } } });
237
- assert.equal(replacement.status, "authorized");
238
- assert.equal(records.get(key).payload.access, "offline-delayed-reference", "a subsequent legitimate Qwen login is preserved");
239
- assert.equal(references.get("QWEN_OAUTH_ACCESS"), "offline-delayed-reference");
240
- assert.equal((await request("/oauth/api/logout", { provider: "qwen" })).status, 200);
241
-
242
186
  const xaiKey = credentialKey("llm-pi-ai", "xai");
243
187
  const removeXaiFlow = ctx.authorization.registerFlow({
244
188
  key: xaiKey, label: "Offline xAI", methods: [{ id: "oauth", label: "Device" }],
@@ -425,7 +369,10 @@ try {
425
369
  assert.equal(references.has('DSH_OAUTH_OPENROUTER_KEY'), false);
426
370
  assert.equal(records.has(credentialKey('dsh-oauth-connections', 'openrouter')), false);
427
371
  for (const providerId of ['minimax', 'zai', 'aliyun-token-plan']) {
428
- globalThis.fetch = async () => { throw new Error('Installed catalog must not issue a model or inference request.'); };
372
+ globalThis.fetch = async (url) => {
373
+ assert.match(new URL(url).pathname, /(?:models|token_plan[/]remains)$/);
374
+ return new Response('', { status: 404 });
375
+ };
429
376
  assert.equal((await request('/oauth/api/connect', { provider: providerId, access: `offline-${providerId}`, region: 'cn' })).status, 200);
430
377
  const catalog = await request('/oauth/api/models', { provider: providerId });
431
378
  assert.equal(catalog.status, 200, catalog.body);
@@ -475,7 +422,7 @@ try {
475
422
  const sourceSha256 = {};
476
423
  const sourceFiles = ["package.json", "client.js", ...(await readdir(join(pluginRoot, "src"), { recursive: true })).filter((file) => file.endsWith(".js") && !file.endsWith(".test.js")).sort().map((file) => `src/${file}`)];
477
424
  for (const file of sourceFiles) sourceSha256[file] = createHash("sha256").update(await readFile(join(pluginRoot, file))).digest("hex");
478
- console.log(JSON.stringify({ ok: true, versions, sourceSha256, checks: ["host route", "provider listing", "DeepSeek callback metadata and attempt identity", "DeepSeek stale cancellation refusal", "DeepSeek commit before cancellation", "Qwen device notice and authorization commit", "Qwen standard verification URI fallback", "Qwen disconnect wins delayed record and access-reference writes", "subsequent legitimate Qwen login remains configured", "pull settings parsed by actual adapter schema", "pull persistence", "logout route restoration", "xAI defaults to loopback PKCE and preserves existing six scopes", "xAI production OIDC validation precedes the single canonical grant commit", "pending xAI login cannot silently switch methods", "explicit device fallback and cancellation preserve browser grant", "model catalog rejects future-valid token, refreshes once and retries with persisted grant", "permission denial preserves authorization without forced refresh", "public chat waterfalls persist a forced refresh before retrying", "second chat rejection in the same step does not refresh or retry again", "tool schemas", "settings slot", "unload", "subscription key and billing credential isolation", "account-filtered model capabilities and permanent settings", "quota cache without secrets", "account replacement clears old owned route and snapshot", "MiniMax/ZAI/Ali regional protocol profiles validated by real schema"], network: "mock xAI/provider fetch only, with actual loopback callback HTTP", persistentProfile: "temporary directory only" }, null, 2));
425
+ console.log(JSON.stringify({ ok: true, versions, sourceSha256, checks: ["host route", "provider listing", "DeepSeek callback metadata and attempt identity", "DeepSeek stale cancellation refusal", "DeepSeek commit before cancellation", "retired Qwen sign-in does not call upstream; existing grant can still pull and log out", "pull settings parsed by actual adapter schema", "pull persistence", "logout route restoration", "xAI defaults to loopback PKCE and preserves existing six scopes", "xAI production OIDC validation precedes the single canonical grant commit", "pending xAI login cannot silently switch methods", "explicit device fallback and cancellation preserve browser grant", "model catalog rejects future-valid token, refreshes once and retries with persisted grant", "permission denial preserves authorization without forced refresh", "public chat waterfalls persist a forced refresh before retrying", "second chat rejection in the same step does not refresh or retry again", "tool schemas", "settings slot", "unload", "subscription key and billing credential isolation", "account-filtered model capabilities and permanent settings", "quota cache without secrets", "account replacement clears old owned route and snapshot", "MiniMax/ZAI/Ali regional protocol profiles validated by real schema"], network: "mock xAI/provider fetch only, with actual loopback callback HTTP", persistentProfile: "temporary directory only" }, null, 2));
479
426
  } finally {
480
427
  globalThis.fetch = previousFetch;
481
428
  if (previousHome === undefined) delete process.env.DSH_HOME; else process.env.DSH_HOME = previousHome;
@@ -17,7 +17,7 @@ await mkdir(outDir, { recursive: true });
17
17
  const completed = [], pageErrors = [], blockedRequests = [], calls = [];
18
18
  let usageMode = 'fresh', lateUsage, releaseLate;
19
19
  const providers = [
20
- { id: 'google-antigravity', name: 'Google Antigravity', flow: 'pkce', authMethods: ['oauth'], usageSupported: true, loggedIn: true, pullable: false, supportReason: 'host-oauth-model-integration-unavailable', pulledModels: [] },
20
+ { id: 'google-antigravity', name: 'Google Antigravity', cliCatalog: true, flow: 'pkce', authMethods: ['oauth', 'local'], usageSupported: true, loggedIn: true, pullable: false, supportReason: 'host-oauth-model-integration-unavailable', pulledModels: [] },
21
21
  { id: 'qwen', name: 'Qwen CLI', flow: 'device_code', authMethods: ['oauth'], usageSupported: false, loggedIn: true, pullable: true, pulledModels: [] },
22
22
  { id: 'new-api', name: 'New API', flow: 'key', authMethods: ['key'], keyConnect: true, usageSupported: true, loggedIn: false, pulledModels: [] },
23
23
  { id: 'zenmux', name: 'ZenMux', flow: 'key', authMethods: ['key'], keyConnect: true, usageSupported: true, loggedIn: false, pulledModels: [] },
@@ -60,7 +60,11 @@ const server = createServer(async (req, res) => {
60
60
  if (['needs-permission', 'needs-configuration', 'rate-limited', 'reauth-required'].includes(usageMode)) return json({ status: usageMode, message: 'Management key required', lastAttemptAt: new Date().toISOString() });
61
61
  return json({ status: usageMode === 'partial' ? 'partial' : 'fresh', snapshot, lastAttemptAt: new Date().toISOString() });
62
62
  }
63
- if (pathname.endsWith('/import/sources')) return json({ sources: [{ id: 'codex', label: 'Codex CLI', available: true, providers: [{ provider: 'openai-codex', authType: 'oauth', available: true }] }, { id: 'opencode', label: 'OpenCode', available: false, providers: [{ provider: 'openai-codex', authType: 'oauth', available: false }] }] });
63
+ if (pathname.endsWith('/import/sources')) return json({ sources: [
64
+ { id: 'codex', label: 'Codex CLI', available: true, providers: [{ provider: 'openai-codex', authType: 'oauth', available: true }] },
65
+ { id: 'opencode', label: 'OpenCode', available: false, providers: [{ provider: 'openai-codex', authType: 'oauth', available: false }] },
66
+ { id: 'agy', label: 'Antigravity CLI (agy)', available: false, providers: [{ provider: 'google-antigravity', authType: 'oauth', available: false, reasonCode: 'source-does-not-export-credentials' }] },
67
+ ] });
64
68
  if (pathname.endsWith('/import')) return json({ ok: true });
65
69
  if (pathname.endsWith('/logout')) { providers.find((item) => item.id === body.provider).loggedIn = false; return json({ ok: true }); }
66
70
  if (pathname.endsWith('/login')) return json(auth);
@@ -96,6 +100,19 @@ try {
96
100
  completed.push('Original sidebar and rows retained; credentials hidden; no automatic quota calls');
97
101
  assert.equal(await row('google-antigravity').getByRole('button', { name: '拉取模型', exact: true }).count(), 0);
98
102
  await row('google-antigravity').getByText('可查询套餐用量;当前宿主尚未接入此来源的模型调用。', { exact: true }).waitFor();
103
+ await row('google-antigravity').getByRole('button', { name: '连接配置', exact: true }).click();
104
+ await page.getByRole('button', { name: '改用本机 CLI 管理的授权', exact: true }).click();
105
+ await page.getByText('AGY 通过系统钥匙串管理登录,暂无法在此导入。请在 agy 中输入 /usage 查看套餐用量。', { exact: true }).waitFor();
106
+ assert.equal(await page.locator('#local-source-agy').isDisabled(), true);
107
+ assert.equal(await page.getByRole('button', { name: '确认复用此来源', exact: true }).isDisabled(), true);
108
+ await page.getByRole('button', { name: '取消', exact: true }).click();
109
+ completed.push('AGY shows the system-keyring limitation and links the user to the CLI usage command');
110
+ await row('google-antigravity').getByRole('button', { name: '查看 AGY CLI 模型', exact: true }).click();
111
+ await page.getByRole('heading', { name: 'AGY CLI 模型目录' }).waitFor();
112
+ assert.ok(calls.some(item => item.pathname.endsWith('/models') && item.body.provider === 'google-antigravity' && item.body.source === 'agy'));
113
+ assert.equal(await page.locator('#confirm-pull').count(), 0);
114
+ await page.getByRole('button', { name: '关闭', exact: true }).click();
115
+
99
116
  await row('qwen').getByRole('button', { name: '套餐与用量', exact: true }).click();
100
117
  await row('qwen').getByText('此来源暂不提供用量', { exact: true }).waitFor();
101
118
  assert.equal(calls.filter((item) => item.pathname.endsWith('/usage')).length, 0);
package/src/catalog.js CHANGED
@@ -6,12 +6,12 @@ const bearerKey = Object.freeze({ header: 'Authorization', scheme: 'Bearer' });
6
6
  const definitions = [
7
7
  { id: 'openai-codex', name: 'ChatGPT / Codex', group: 'official', keyConnect: false,
8
8
  baseURL: 'https://chatgpt.com/backend-api/codex',
9
- modelsURL: 'https://chatgpt.com/backend-api/codex/models?client_version=0.156.1',
9
+ modelsURL: 'https://chatgpt.com/backend-api/codex/models',
10
10
  modelSource: 'account', entitlement: 'account', usageHosts: ['chatgpt.com'] },
11
- { id: 'anthropic', name: 'Claude', group: 'official', keyConnect: false,
11
+ { id: 'anthropic', name: 'Claude API', group: 'official', keyConnect: true, oauthConnect: false,
12
12
  baseURL: 'https://api.anthropic.com', modelsURL: 'https://api.anthropic.com/v1/models?limit=1000',
13
- modelHeaders: { 'anthropic-version': '2023-06-01', 'anthropic-beta': 'oauth-2025-04-20' },
14
- modelSource: 'account', entitlement: 'account', usageHosts: ['api.anthropic.com'] },
13
+ modelHeaders: { 'anthropic-version': '2023-06-01' }, docs: 'https://platform.claude.com/docs/en/api/models/list',
14
+ modelSource: 'account', entitlement: 'account', usageHosts: [] },
15
15
  { id: 'github-copilot', name: 'GitHub Copilot', group: 'official', keyConnect: false,
16
16
  baseURL: 'https://api.individual.githubcopilot.com', modelsURL: 'https://api.individual.githubcopilot.com/models',
17
17
  modelHeaders: { 'user-agent': 'GitHubCopilotChat/0.35.0', 'editor-version': 'vscode/1.107.0', 'editor-plugin-version': 'copilot-chat/0.35.0', 'copilot-integration-id': 'vscode-chat', 'x-github-api-version': '2026-06-01' },
@@ -43,9 +43,11 @@ const definitions = [
43
43
  global: { baseURL: 'https://token-plan.ap-southeast-1.maas.aliyuncs.com/compatible-mode/v1', catalogProvider: 'qwen-token-plan-individual', usageHosts: ['bailian-singapore-cs.alibabacloud.com'] },
44
44
  } },
45
45
  { id: 'google-antigravity', name: 'Google Antigravity', group: 'official', keyConnect: false,
46
- modelSource: 'account', entitlement: 'unknown', usageHosts: ['daily-cloudcode-pa.googleapis.com'], reason: 'host-oauth-model-integration-unavailable' },
46
+ modelSource: 'account', entitlement: 'unknown', usageHosts: ['daily-cloudcode-pa.googleapis.com'], reason: 'host-oauth-model-integration-unavailable',
47
+ docs: 'https://antigravity.google/docs/cli/commands/usage' },
47
48
  { id: 'google-gemini-cli', name: 'Google Gemini CLI', group: 'official', keyConnect: false,
48
- modelSource: 'account', entitlement: 'unknown', usageHosts: ['cloudcode-pa.googleapis.com'], reason: 'host-oauth-model-integration-unavailable' },
49
+ modelSource: 'account', entitlement: 'unknown', usageHosts: ['cloudcode-pa.googleapis.com'], reason: 'gemini-consumer-retired',
50
+ docs: 'https://developers.google.com/gemini-code-assist/docs/deprecations/code-assist-individuals' },
49
51
  { id: 'xai', name: 'xAI Grok', group: 'official', keyConnect: false,
50
52
  baseURL: 'https://cli-chat-proxy.grok.com/v1', modelsURL: 'https://cli-chat-proxy.grok.com/v1/models',
51
53
  modelHeaders: { 'x-xai-token-auth': 'xai-grok-cli' }, modelSource: 'account', entitlement: 'account', usageHosts: ['cli-chat-proxy.grok.com'] },
@@ -56,7 +58,8 @@ const definitions = [
56
58
  modelSource: 'account', entitlement: 'account', usageHosts: ['portal.nousresearch.com'], reason: 'usage-requires-portal-oauth' },
57
59
  { id: 'qwen', name: 'Qwen Code subscription', group: 'official', keyConnect: false,
58
60
  baseURL: 'https://api.qwen.ai/compatible-mode/v1', modelsURL: 'https://api.qwen.ai/compatible-mode/v1/models',
59
- modelSource: 'account', entitlement: 'account', usageHosts: [], reason: 'proactive-quota-api-unavailable' },
61
+ modelSource: 'account', entitlement: 'account', usageHosts: [], reason: 'qwen-legacy-oauth',
62
+ docs: 'https://help.aliyun.com/en/model-studio/qwen-code' },
60
63
  { id: 'deepseek', name: 'DeepSeek API', group: 'official', keyConnect: true,
61
64
  baseURL: 'https://api.deepseek.com', modelsURL: 'https://api.deepseek.com/models',
62
65
  modelSource: 'catalog', entitlement: 'unknown', usageHosts: ['api.deepseek.com'] },
@@ -54,7 +54,7 @@ test('unverified model listing and unsupported Google login are explicit', () =>
54
54
  const row = getProviderDefinition(id);
55
55
  assert.equal(row.keyConnect, false);
56
56
  assert.equal(row.modelsURL, undefined);
57
- assert.equal(row.reason, 'host-oauth-model-integration-unavailable');
57
+ assert.equal(row.reason, id === 'google-gemini-cli' ? 'gemini-consumer-retired' : 'host-oauth-model-integration-unavailable');
58
58
  }
59
59
  const internationalAli = getProviderDefinition('aliyun-token-plan');
60
60
  assert.equal(internationalAli.keyConnect, true);
@@ -56,6 +56,7 @@ export function createConnectionRuntime(credentials, nativeResolve, { localRead
56
56
  return { connection, rawGrant, grant: { ...rawGrant, ...connection.metadata } };
57
57
  }
58
58
  if (connection?.mode !== 'local') {
59
+ if (id === 'anthropic') throw new Error('Connect a Claude Console API key in this plugin. Claude Code subscription sign-in is managed by Claude Code.');
59
60
  const grant = await nativeResolve(id, options);
60
61
  const rawGrant = typeof nativeResolve.rawGrant === 'function' ? await nativeResolve.rawGrant(grant) : (await readRecord(nativeKey(id)))?.payload;
61
62
  await check(id, connection);
@@ -74,6 +75,7 @@ export function createConnectionRuntime(credentials, nativeResolve, { localRead
74
75
  throw Object.assign(new Error('The source CLI returned no usable credential.'), { code: 'source-unavailable' });
75
76
  }
76
77
  const rawGrant = { type: source.type, access: source.access };
78
+ if (id === 'anthropic' && rawGrant.type === 'oauth') throw new Error('Connect a Claude Console API key in this plugin.');
77
79
  for (const key of ['expires', 'accountId', 'scope']) if (source[key] !== undefined) rawGrant[key] = source[key];
78
80
  await check(id, connection, sequence);
79
81
  if (rawGrant.type === 'api_key') {
@@ -93,8 +95,9 @@ export function createConnectionRuntime(credentials, nativeResolve, { localRead
93
95
  const oauth = registry.getProvider(id)?.auth?.oauth;
94
96
  const auth = typeof oauth?.toAuth === 'function' ? await oauth.toAuth(rawGrant) : { apiKey: rawGrant.access };
95
97
  await check(id, connection, sequence);
96
- if (!auth?.apiKey) throw new Error('The source CLI credential cannot authorize this provider.');
97
- return { connection, rawGrant, grant: { ...rawGrant, access: auth.apiKey, ...(auth.headers ? { requestHeaders: auth.headers } : {}), ...(auth.baseUrl ? { apiBase: auth.baseUrl } : {}) } };
98
+ const access = auth?.apiKey ?? (id === 'kimi-coding' && auth?.headers ? rawGrant.access : undefined);
99
+ if (!access) throw new Error('The source CLI credential cannot authorize this provider.');
100
+ return { connection, rawGrant, grant: { ...rawGrant, access, ...(auth.headers ? { requestHeaders: auth.headers } : {}), ...(auth.baseUrl ? { apiBase: auth.baseUrl } : {}) } };
98
101
  }
99
102
 
100
103
  return {