@lks347/dsh-oauth 0.0.0-stage → 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 +155 -0
- package/README.md +101 -2
- package/app.js +1045 -0
- package/auth.html +80 -0
- package/client.js +31 -0
- package/cordis.patch.yml +4 -0
- package/docs/CONNECTIONS.md +77 -0
- package/docs/LIVE-VALIDATION-1.0.1.md +100 -0
- package/docs/RELEASE-1.0.1.md +48 -0
- package/docs/RELEASE-1.0.2.md +8 -0
- package/docs/VALIDATION.md +59 -0
- package/docs/evidence/live-1.0.1.json +135 -0
- package/docs/evidence/release-1.0.1.json +38 -0
- package/index.html +43 -0
- package/package.json +64 -4
- package/providers.js +73 -0
- package/scripts/check-upstreams.mjs +27 -0
- package/scripts/link-peers.js +38 -0
- package/scripts/verify-browser.mjs +297 -0
- package/scripts/verify-host.mjs +431 -0
- package/scripts/verify-live.mjs +268 -0
- package/scripts/verify-package.mjs +168 -0
- package/scripts/verify-persistence.mjs +307 -0
- package/scripts/verify-subscriptions-ui.mjs +321 -0
- package/src/account.js +85 -0
- package/src/account.test.js +52 -0
- package/src/authorization.js +199 -0
- package/src/authorization.test.js +332 -0
- package/src/catalog.js +180 -0
- package/src/catalog.test.js +146 -0
- package/src/chat-recovery.js +110 -0
- package/src/chat-recovery.test.js +261 -0
- package/src/connection-runtime.js +129 -0
- package/src/connection-runtime.test.js +244 -0
- package/src/connections.js +70 -0
- package/src/grants.js +104 -0
- package/src/grants.test.js +340 -0
- package/src/index.js +676 -0
- package/src/local-imports.js +263 -0
- package/src/local-imports.test.js +201 -0
- package/src/media.js +152 -0
- package/src/models.js +610 -0
- package/src/models.test.js +503 -0
- package/src/profile-store.js +51 -0
- package/src/pulls.js +100 -0
- package/src/pulls.test.js +156 -0
- package/src/qwen.js +141 -0
- package/src/qwen.test.js +35 -0
- package/src/request-errors.js +50 -0
- package/src/request-errors.test.js +131 -0
- package/src/routes.js +47 -0
- package/src/routes.test.js +136 -0
- package/src/subscription-models.test.js +160 -0
- package/src/usage/aggregators.js +292 -0
- package/src/usage/aggregators.test.js +316 -0
- package/src/usage/core.js +68 -0
- package/src/usage/index.js +93 -0
- package/src/usage/official.js +339 -0
- package/src/usage/official.test.js +273 -0
- package/src/usage/service.test.js +89 -0
- package/src/xai-browser.js +272 -0
- package/src/xai-browser.test.js +256 -0
- package/src/xai-login.js +121 -0
- package/src/xai-login.test.js +259 -0
- package/styles.css +364 -0
- package/theme.js +118 -0
- package/upstreams.json +10 -0
package/README.en.md
ADDED
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
# dsh-oauth
|
|
2
|
+
|
|
3
|
+
[简体中文](README.md) · English
|
|
4
|
+
|
|
5
|
+
Connect subscription accounts and plan keys to DeepSeek Harness, keep model configuration across restarts, and inspect the plan usage that each provider actually reports.
|
|
6
|
+
|
|
7
|
+
The package is **`@lks347/dsh-oauth@1.0.1`**, updated on 2026-11-16. See the [release notes](docs/RELEASE-1.0.1.md) for npm publication status. The existing sidebar, provider rows, and visual style are preserved; connection settings, model capabilities, plan details, and Chinese/English switching are added within that structure.
|
|
8
|
+
|
|
9
|
+
The implementation contains **23 provider definitions and 22 usage adapters**. Those are implementation counts, not a claim that every plan, region, organization, or real account has passed live acceptance. Some connections provide only quota information, some expose a public or installed model catalog, and some require a separate billing credential. See [connection details](docs/CONNECTIONS.md) and [validation and limitations](docs/VALIDATION.md).
|
|
10
|
+
|
|
11
|
+
## Install locally
|
|
12
|
+
|
|
13
|
+
Add the repository to the profile you intend to use:
|
|
14
|
+
|
|
15
|
+
```sh
|
|
16
|
+
dsh plugin --profile oauth add /path/to/dsh-oauth
|
|
17
|
+
dsh --profile oauth --port 3081
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
Use the OAuth page in Settings, or open `http://127.0.0.1:3081/oauth/` for the server started by this command. The official desktop application uses the `desktop` profile. Add a locally built package through its plugin manager, or use the CLI bundled with that installation:
|
|
21
|
+
|
|
22
|
+
```sh
|
|
23
|
+
dsh plugin --profile desktop add /absolute/path/to/lks347-dsh-oauth-1.0.1.tgz --offline
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
On macOS, the bundled CLI is at `/Applications/DeepSeek Harness.app/Contents/Resources/runtime/cli/bin/dsh`. Reload or restart when the host requests it, and confirm that the plugin is enabled. Editing or packaging this repository does not automatically replace the copy already installed in the desktop application.
|
|
27
|
+
|
|
28
|
+
The declared host range is `>=0.2.0-rc.2 <0.3.0-0`. This iteration tested DSH **0.2.0-rc.2 with pi-ai 0.87.1** and DSH **0.2.2-rc.3 with pi-ai 1.5.2**. Other combinations inside the declared range have not all been individually accepted.
|
|
29
|
+
|
|
30
|
+
## Connect a subscription
|
|
31
|
+
|
|
32
|
+
1. Open the OAuth panel and select the appropriate provider. The available actions reflect the host and provider integration. Use browser sign-in where the host supplies it, or **Connect key** for a supported subscription/API key.
|
|
33
|
+
2. In **Connection settings**, supply any separate usage-query credential and required region, organization, workspace, or project. Region is independent of the interface language; the default is `global`, with `cn` available where the provider supports it. Changing an endpoint or account scope removes the previously installed route so that it can be fetched again for the new scope.
|
|
34
|
+
3. Use **Fetch models** to inspect model IDs, input/output modalities, tool support, context and output limits, and reasoning levels when the source declares them. Select at least one chat model and save. Image/video models, where supported, remain media tools within the current conversation.
|
|
35
|
+
4. Use **Plan & usage** to request the provider's read-only quota or balance data. Opening the panel does not start a usage query, and refreshing usage does not send an inference request.
|
|
36
|
+
|
|
37
|
+
Passwords are not echoed back into the form or kept in browser storage. A blank usage-query credential field retains an existing saved credential. Chinese and English are selectable in the page and dialogs; the browser remembers only the UI language preference. Switching languages preserves in-progress form input and authorization steps.
|
|
38
|
+
|
|
39
|
+
Native OAuth uses the host authorization and credential services. Device codes, manual authorization input, cancellation, and popup blocking remain visible in the panel. xAI defaults to its browser PKCE route and retains an explicit device-code fallback. The formal `/oauth/` panel never substitutes a simulated successful login when the service or authorization fails.
|
|
40
|
+
|
|
41
|
+
### Reuse a local CLI authorization
|
|
42
|
+
|
|
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
|
+
|
|
45
|
+
- Codex: the supported ChatGPT token entry in `auth.json`, normally under `~/.codex/`, or the server's configured `CODEX_HOME`.
|
|
46
|
+
- OpenCode: the v1 provider dictionary in `auth.json`, or v2 saved credentials through the official CLI. OAuth renews in the source CLI.
|
|
47
|
+
|
|
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
|
+
|
|
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
|
+
|
|
52
|
+
## Provider and evidence boundaries
|
|
53
|
+
|
|
54
|
+
“Account catalog” means an authenticated account endpoint returned the model. “Subscription catalog” means a subscription-specific endpoint returned it. Neither guarantees that a particular request will be permitted or funded. A public or installed catalog has **unknown plan entitlement**; the plugin does not spend tokens to test it.
|
|
55
|
+
|
|
56
|
+
| Provider definition | Model source or limitation | Usage adapter and important scope |
|
|
57
|
+
| --- | --- | --- |
|
|
58
|
+
| ChatGPT / Codex | Account catalog; native OAuth or supported local source | Account usage windows; account ID retained when available |
|
|
59
|
+
| Claude API | Account catalog via a Claude Console API key | Claude Code subscriptions and usage stay in the official client |
|
|
60
|
+
| GitHub Copilot | Account picker/policy and declared capabilities | Account usage; request counters and AI credits remain distinct |
|
|
61
|
+
| Kimi Code | Account catalog; host OAuth or plan key | Coding usage for the selected global/China endpoint |
|
|
62
|
+
| MiniMax | Installed host catalog; entitlement unknown | Plan remains endpoint; provider counters and units retained |
|
|
63
|
+
| Z.AI / GLM Coding Plan | Installed host catalog; entitlement unknown | Global/China quota; team queries require both organization and project IDs |
|
|
64
|
+
| Alibaba Cloud Token Plan | Installed host catalog; entitlement unknown | Personal Console Token Plan usage; separate Console credential and selected region |
|
|
65
|
+
| Google Antigravity | View the model catalog from the official AGY CLI | View subscription usage with `/usage` in AGY |
|
|
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
|
+
| xAI Grok | Account catalog; browser PKCE or device fallback | CLI billing allowance and credits are separate measures |
|
|
68
|
+
| Nous Portal | Authenticated inference catalog; key connection | Portal OAuth account usage; an inference key alone is insufficient |
|
|
69
|
+
| Qwen Code subscription | Account catalog and existing subscription authorization | **No verified proactive remote quota reader**; remaining quota is unknown |
|
|
70
|
+
| DeepSeek API | API catalog; entitlement unknown | API account balance, not a consumer chat subscription allowance |
|
|
71
|
+
| OpenRouter | Account model catalog | Key budgets and spend; account balance may need a separate management key |
|
|
72
|
+
| NanoGPT | Subscription-specific model endpoint and inference channel | Subscription allowance windows; cash wallet balance is not queried |
|
|
73
|
+
| ZenMux | Public catalog; entitlement unknown | Management key required; subscription and PAYG results stay separate |
|
|
74
|
+
| OpenCode Go | Go-specific catalog | Workspace/member allowance; select the intended workspace |
|
|
75
|
+
| OpenCode Console / Zen | Catalog; entitlement unknown | Workspace budgets; not a claim to expose the complete workspace wallet |
|
|
76
|
+
| Kilo Gateway / Pass | Catalog; entitlement unknown | Credit and Pass data; personal/organization scope matters |
|
|
77
|
+
| Poe | API catalog; entitlement unknown | Combined point balance; subscription/top-up split or reset may be unavailable |
|
|
78
|
+
| Synthetic | Catalog; entitlement unknown | Plan allowance; incremental recovery is not a full reset |
|
|
79
|
+
| Chutes | Catalog; entitlement unknown | Subscription allowance; PAYG-equivalent allowance is not a wallet balance |
|
|
80
|
+
| New API gateway | Catalog from an explicitly configured deployment; entitlement unknown | Deployment token quota in its original units, not an assumed USD balance |
|
|
81
|
+
|
|
82
|
+
For Google, a compatible OAuth entry already present in a supported legacy OpenCode file may be reused for quota queries. That does not add a Google login implementation or model transport to a host that lacks them. The plugin does not onboard a Google project or scan an IDE's local language server. A missing project, unsupported OAuth client, or insufficient permission is not interpreted as zero remaining quota.
|
|
83
|
+
|
|
84
|
+
Alibaba Cloud support here is the **personal Console Token Plan** query path. It does not claim team/RAM coverage, legacy Coding Plan equivalence, or PAYG fallback. The model key cannot replace the Console query credential. MiniMax, Z.AI, and Alibaba model choices come from the installed host catalog; the panel labels their plan entitlement as unconfirmed.
|
|
85
|
+
|
|
86
|
+
For Nous, configure the inference key for model access and a compatible **Portal OAuth access token** as the separate usage-query credential when required. This field does not establish a new Portal login or own its refresh lifecycle. Monthly, purchased, rollover, and total usable credits may overlap; do not add total usable credits to its components.
|
|
87
|
+
|
|
88
|
+
For New API, supply the trusted public HTTPS API root, including `/v1`. The explicit deployment receives the model key. The usage adapter preserves the deployment's quota units and does not invent a conversion to USD. A gateway with a different usage contract is reported as unavailable rather than estimated.
|
|
89
|
+
|
|
90
|
+
## Read usage accurately
|
|
91
|
+
|
|
92
|
+
The panel displays the provider's plan label, independent windows, balances, scope, source, observation time, and last query time. A snapshot is an observation at that time, not a continuously live balance.
|
|
93
|
+
|
|
94
|
+
- Windows keep their own units: percentages, requests, tokens, credits, points, currency, or deployment quota. They are not combined into a universal “tokens left” value.
|
|
95
|
+
- An unknown percentage stays unknown and has no fabricated zero-percent meter. A limit without a used/remaining value is still a limit, not proof of a full allowance.
|
|
96
|
+
- Subscription renewal, quota reset, and partial regeneration are different timestamps. The UI does not mark an incremental refill as a full reset.
|
|
97
|
+
- `partial` retains the fields that were actually returned. `stale` labels a previous successful snapshot after a transient refresh failure; its original observation time remains visible.
|
|
98
|
+
- Permission/configuration failures, required reauthorization, query rate limits, unsupported readers, and temporary unavailability remain separate from an exhausted allowance. A 429 response does not establish how much subscription quota is left.
|
|
99
|
+
- The service binds cached results to the credential and account scope. Disconnecting, replacing authorization, or changing scope cannot revive an older in-flight result for a different connection.
|
|
100
|
+
|
|
101
|
+
Model-access and billing permissions can differ. For example, a ZenMux management key or Alibaba Console token is separate from the model credential. An OpenRouter management balance can belong to its own account scope; it must not be assumed to describe another model key. These credentials are used for their designated endpoints, not sent to arbitrary model hosts.
|
|
102
|
+
|
|
103
|
+
## Keep model configuration across restarts
|
|
104
|
+
|
|
105
|
+
**Keep enabled** is the default. It saves `expiresAt: null` for the model configuration. You can still choose a future expiry, up to 366 days. Existing records with a deadline keep that deadline; upgrading does not silently make them permanent.
|
|
106
|
+
|
|
107
|
+
This setting controls model configuration, not OAuth lifetime. Closing the panel or restarting the plugin does not intentionally delete saved authorization. Tokens can still expire or be revoked, subscriptions can change, and some connections still require signing in again. There is no promise of permanent login.
|
|
108
|
+
|
|
109
|
+
Native OAuth and connected keys use the host credential service. A typical desktop installation uses `DSH_HOME/.credentials.yaml`, normally `~/.dsh/.credentials.yaml`. Profiles sharing the same `DSH_HOME` can share credentials, so **Disconnect** can affect another profile using that credential. Locally reused CLI authorization remains owned by the source CLI.
|
|
110
|
+
|
|
111
|
+
Model pull records and usage snapshots are profile-specific. They are stored under the profile directory as `dsh-oauth-pulls.json` and `dsh-oauth-usage.json`; these JSON records do not contain access or refresh tokens. Expiring a model configuration does not expire or delete the account authorization. Cleanup restores only configuration that still matches the plugin's installed values, preserving later manual edits.
|
|
112
|
+
|
|
113
|
+
The older `DSH_HOME/dsh-oauth-pulls.json` has no profile identity. It is not automatically migrated or used to clean another profile. Fetch models again in the intended profile when moving from that legacy layout. See [connection and persistence details](docs/CONNECTIONS.md).
|
|
114
|
+
|
|
115
|
+
## Develop and validate
|
|
116
|
+
|
|
117
|
+
Use the dependencies from the DSH installation being tested. `--from` points to the runtime installation containing `node_modules`; the linking script modifies only this repository's links and refuses to overwrite the real installation.
|
|
118
|
+
|
|
119
|
+
```sh
|
|
120
|
+
npm run link:peers -- --from /absolute/path/to/dsh-runtime
|
|
121
|
+
npm test
|
|
122
|
+
npm run verify:host -- --runtime /absolute/path/to/dsh-runtime
|
|
123
|
+
npm run verify:persistence -- --runtime /absolute/path/to/dsh-runtime
|
|
124
|
+
npm run verify:browser
|
|
125
|
+
npm run verify:subscriptions -- --out-dir artifacts/subscriptions-ui
|
|
126
|
+
npm run check:upstreams -- --out artifacts/upstream-check.json
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
The completed local validation for this iteration includes:
|
|
130
|
+
|
|
131
|
+
| Validation | Evidence scope |
|
|
132
|
+
| --- | --- |
|
|
133
|
+
| 292 unit tests | Parsing, scope, transport, credentials, authorization, models, and lifecycle behavior |
|
|
134
|
+
| Host integration on DSH 0.2.0-rc.2 / pi-ai 0.87.1 and DSH 0.2.2-rc.3 / pi-ai 1.5.2 | Real Cordis, authorization, tools, client slot, and model configuration schemas with mocked provider responses |
|
|
135
|
+
| Six independent persistence processes | Real `dsh-credentials-local` 0.2.2-rc.3 storage; credentials, permanent models/capabilities, quota snapshots, renewal, and expiry separation |
|
|
136
|
+
| 19 subscription UI scenarios and 11 existing OAuth scenarios | Real Chromium; local mock endpoints; Chinese/English, narrow screens, keyboard handling, connection settings, quota states, and existing authorization flows |
|
|
137
|
+
|
|
138
|
+
The offline checks were followed by live acceptance using existing Codex, OpenRouter, and xAI authorization. Their catalogs returned 6, 433, and 6 models respectively; two chat models per provider were imported. A second independent process restored identical saved capabilities and configuration, then successfully queried the real catalogs and usage services again. OpenRouter returned key usage and budgets; account-wide balance remained explicitly unavailable without Management permission. The local Codex and OpenCode source files were unchanged. No paid inference was sent, and the user's daily desktop profile was not restarted or modified. See [live acceptance](docs/LIVE-VALIDATION-1.0.1.md). This does not establish indefinite renewal or live acceptance of every other provider and plan.
|
|
139
|
+
|
|
140
|
+
`verify:browser` and `verify:subscriptions` require Playwright/Chromium; `DSH_PLAYWRIGHT_MODULE` can point to the Playwright module directory. `verify:persistence` uses temporary credential/profile directories. If the selected runtime lacks `dsh-credentials-local`, supply an independently prepared matching package with `--credentials-local /absolute/path/to/package`, as described in that script.
|
|
141
|
+
|
|
142
|
+
Opening `index.html` directly runs the explicitly labeled static example. It does not confirm real authorization. `DshOAuth.setLoginOpener()` and `onAuthorize()` are preview-only; the hosted `/oauth/` panel uses the server API.
|
|
143
|
+
|
|
144
|
+
## Implementation and references
|
|
145
|
+
|
|
146
|
+
The local implementation is split into [provider metadata](src/catalog.js), [fixed local sources](src/local-imports.js), [model capabilities](src/models.js), [connection storage](src/connections.js), and [usage readers/cache](src/usage/index.js). Provider-specific details are in [official readers](src/usage/official.js) and [aggregator readers](src/usage/aggregators.js).
|
|
147
|
+
|
|
148
|
+
The design was checked against official implementations and community readers, including these pinned sources:
|
|
149
|
+
|
|
150
|
+
- [OpenCode provider authentication and workspace handling](https://github.com/anomalyco/opencode/blob/26f2522e60a924b8bad95725ede56b55281fb46c/packages/core/src/plugin/provider/opencode.ts) and [usage limits](https://github.com/anomalyco/opencode/blob/26f2522e60a924b8bad95725ede56b55281fb46c/packages/core/src/usage-limits.ts).
|
|
151
|
+
- [Hermes account-aware usage caching](https://github.com/NousResearch/hermes-agent/blob/611f0ab757b307774c4a63c7b19f67d1f3aa6f6e/agent/account_usage_cache.py) and [Nous Portal account handling](https://github.com/NousResearch/hermes-agent/blob/f8acc26834bf1275c34d09ccc3e51250bcd1e26b/hermes_cli/nous_account.py).
|
|
152
|
+
- [CodexBar provider architecture](https://github.com/steipete/CodexBar/blob/1f6da9bec44455288ddee5ef6f3617a803d8eb2a/docs/provider.md) and [Antigravity source distinctions](https://github.com/steipete/CodexBar/blob/1f6da9bec44455288ddee5ef6f3617a803d8eb2a/docs/antigravity.md).
|
|
153
|
+
- [Official Gemini CLI quota request](https://github.com/google-gemini/gemini-cli/blob/4ed06ed0ddc523a6d356a4ad35ddfea331041888/packages/core/src/code_assist/server.ts), [MiniMax quota interpretation](https://github.com/MiniMax-AI/cli/blob/ae29aae57b05c2140c7ea6aba0a852763ffe7859/src/utils/quota.ts), and [Alibaba Token Plan usage command](https://github.com/modelstudioai/cli/blob/98ceadc00e00bd5043f266ba3781268e6b83b12f/packages/commands/src/commands/usage/token-plan.ts).
|
|
154
|
+
|
|
155
|
+
These references explain protocol and lifecycle decisions; their feature lists are not claims about functionality already implemented here. In particular, this worktree implements neither Hermes local credential import nor every alternative quota source offered by CodexBar.
|
package/README.md
CHANGED
|
@@ -1,3 +1,102 @@
|
|
|
1
|
-
#
|
|
1
|
+
# dsh-oauth
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[English](README.en.md)
|
|
4
|
+
|
|
5
|
+
为 DeepSeek Harness 接入订阅账号和第三方模型平台:保存授权,导入模型及能力,查询提供商返回的真实套餐用量、额度和余额。页面保留原来的侧栏、提供商列表和弹窗结构,支持中文与英文。
|
|
6
|
+
|
|
7
|
+
当前包名与版本为 **`@lks347/dsh-oauth@1.0.1`**。2026-11-16 已通过 DSH **0.2.0-rc.2 / pi-ai 0.87.1** 与 **0.2.2-rc.3 / pi-ai 1.5.2** 的离线宿主集成验证,并使用本机已有的 **Codex、OpenRouter、xAI 授权**通过真实模型导入、独立进程重启恢复和用量查询。其他平台仍以合同样例测试为主,不代表所有套餐和地区均已实测。
|
|
8
|
+
|
|
9
|
+
## 安装到目标 profile
|
|
10
|
+
|
|
11
|
+
使用目标 DSH 安装附带的 CLI:
|
|
12
|
+
|
|
13
|
+
```sh
|
|
14
|
+
dsh plugin --profile oauth add /absolute/path/to/dsh-oauth
|
|
15
|
+
dsh --profile oauth --port 3081
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
打开该实例的 `/oauth/`,或设置中的 OAuth 页面。官方桌面组合通常使用 `desktop` profile;可在插件管理器中加入本地包。修改仓库不会自动更新已经安装的插件,安装后按宿主提示重新加载。
|
|
19
|
+
|
|
20
|
+
如需生成本地安装包:
|
|
21
|
+
|
|
22
|
+
```sh
|
|
23
|
+
npm pack
|
|
24
|
+
dsh plugin --profile desktop add /absolute/path/to/lks347-dsh-oauth-1.0.1.tgz --offline
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
`npm pack` 生成本地安装包;npm 发布状态见 [1.0.1 发布说明](docs/RELEASE-1.0.1.md)。请使用作用域包名,非作用域的 `dsh-oauth` 不属于本仓库当前发布账号。
|
|
28
|
+
|
|
29
|
+
## 连接、导入与查询
|
|
30
|
+
|
|
31
|
+
1. 选择提供商,通过宿主支持的网页登录、套餐/API Key,或「复用本机授权」建立连接。地区、组织、项目和工作区需与授权实际所属范围一致,界面语言不会替你选择地区。
|
|
32
|
+
2. 打开「拉取模型」,检查目录来源和模型能力,选择至少一个对话模型后保存。默认**持续启用**;也可设置未来 366 天内的配置期限。
|
|
33
|
+
3. 打开「套餐与用量」。插件只请求相应的读取接口,不发送模型推理来试探余额,不把本地 token 计数当成套餐剩余量。
|
|
34
|
+
4. 若提示缺少权限,使用「连接配置」补充独立的查询授权或工作区信息。查询凭据不会进入模型调用路由。
|
|
35
|
+
|
|
36
|
+
新连接替换旧账号或改变地区、组织等路由范围时,需要重新导入模型。断开连接会移除本插件的凭据和当前 profile 中仍由插件拥有的路由修改;之后手工修改过的配置不会被强行覆盖。
|
|
37
|
+
|
|
38
|
+
## 模型能力与套餐权益
|
|
39
|
+
|
|
40
|
+
导入保存 ID、名称、输入/输出模态、工具支持、上下文长度、最大输出、推理档位,以及目录来源和权益证据。宿主支持的输入模态、上下文、输出上限、推理档位和协议兼容参数会写入真实模型路由;明确不支持工具调用的模型不会被当作工具模型使用。
|
|
41
|
+
|
|
42
|
+
- **账号目录**:例如 OpenRouter 的 `/models/user` 和 Copilot 的 picker/policy。反映接口当前允许列出的模型,仍受实际余额、配额和调用权限约束。
|
|
43
|
+
- **订阅通道目录**:例如 NanoGPT 使用订阅专用模型与调用地址,避免把按量付费目录当成套餐模型。
|
|
44
|
+
- **公共目录**:保存接口声明的能力,同时显示「套餐权益未确认」。
|
|
45
|
+
- **已安装目录**:MiniMax、Z.AI、阿里 Token Plan 使用 pi-ai 已安装目录及相应协议,没有声称它们来自当前账号的实时权益接口。
|
|
46
|
+
|
|
47
|
+
图片、视频模型可以保留能力信息,但本轮可执行的媒体工具仍以已实现的 xAI 路线为准。公共目录中的多模态条目不会自动变成已接通的生成接口。
|
|
48
|
+
|
|
49
|
+
## 支持范围
|
|
50
|
+
|
|
51
|
+
当前有 **23 个提供商定义、22 个用量读取适配器**。这些是代码覆盖数量,不等于 22 家全套餐实测。
|
|
52
|
+
|
|
53
|
+
| 来源 | 模型接入 | 用量与余量 |
|
|
54
|
+
| --- | --- | --- |
|
|
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 授权 |
|
|
58
|
+
| OpenRouter | OAuth/Key、当前 Key 过滤的模型目录 | Key 预算;账户余额另需 Management Key |
|
|
59
|
+
| NanoGPT、ZenMux、OpenCode Go/Zen、Kilo、Poe、Synthetic、Chutes | 平台 Key、各自模型目录与调用通道 | 分平台读取窗口、积分、预算或余额;部分需要管理授权/工作区 |
|
|
60
|
+
| Nous Portal | 推理 Key、组织模型目录 | Portal OAuth 查询授权与推理 Key 分开 |
|
|
61
|
+
| DeepSeek API、New API 实例 | API Key;New API 显式配置 HTTPS API 根地址 | DeepSeek API 余额;New API 实例定义的 Key 配额单位 |
|
|
62
|
+
| Google Antigravity / Gemini CLI | AGY 官方 CLI 目录可在面板查看 | 个人订阅用量在 AGY 的 `/usage` 查询 |
|
|
63
|
+
| Qwen Code | 保留历史 OAuth;新连接使用阿里云套餐入口 | 无本轮可确认的账号余量接口,显示不支持 |
|
|
64
|
+
|
|
65
|
+
DeepSeek 官方网页登录账号仍沿用宿主集成,与新增的 **DeepSeek API 余额**入口分开。详细接口、凭据要求和边界见 [连接与支持清单](docs/CONNECTIONS.md)。
|
|
66
|
+
|
|
67
|
+
## 长期保存与本机授权
|
|
68
|
+
|
|
69
|
+
「持续启用」保存的是模型配置,不会延长上游账号或令牌的有效期。网页登录授权继续由宿主凭据服务及 pi-ai 续期;API Key、查询授权也交给宿主凭据服务保存,不放进浏览器存储或模型配置 JSON。
|
|
70
|
+
|
|
71
|
+
本机复用支持 Codex 的固定 `auth.json`、OpenCode v1 的传统 `auth.json` 及 OpenCode v2 官方 CLI 管理的授权。目录来自服务端配置的 `CODEX_HOME`、`XDG_DATA_HOME` 或系统默认值,浏览器不能提交任意文件路径。
|
|
72
|
+
|
|
73
|
+
复用采用 **external-managed** 模式:每次使用时重读来源,**不复制刷新令牌,不与源 CLI 同时刷新**。源 CLI 退出或授权临期/过期时,需要在源 CLI 中续期;插件会阻止继续使用自己的旧镜像。本轮没有实现 Hermes 本机凭据导入或 OpenCode SQLite 凭据读取;Hermes 主要提供套餐查询、快照和能力导入的设计参考。
|
|
74
|
+
|
|
75
|
+
模型记录保存在当前 `profileContext.dir/dsh-oauth-pulls.json`;额度快照保存在同目录的 `dsh-oauth-usage.json`。两者不含访问令牌。写入采用受限文件权限、原子替换和跨进程锁;损坏文件会报错并保留原内容。旧的全局拉取文件不会被自动迁移,避免无法确定所属 profile 时改错路由。
|
|
76
|
+
|
|
77
|
+
凭据的物理位置和加密方式由宿主提供商决定;标准文件提供商通常使用 `DSH_HOME/.credentials.yaml`。多个 profile 若共用同一个凭据服务,也共享连接身份,断开连接会影响这些 profile 的授权。备份时应一并保留宿主凭据和目标 profile。
|
|
78
|
+
|
|
79
|
+
## 如何读用量
|
|
80
|
+
|
|
81
|
+
套餐窗口、Key 预算、组织共享额度和账户余额分别显示,不能直接相加。未知字段保持未知,不显示为 0 或无限;负余额、超额值不会被抹掉。Synthetic 的部分恢复时间与整段窗口重置分开。
|
|
82
|
+
|
|
83
|
+
每份快照保留来源和观察时间。普通请求在 60 秒内复用结果;手动刷新仍有 5 秒节流,供应商的 `Retry-After` 优先。临时网络失败可显示带「过期数据」标记的旧快照;换号、失去权限或授权无效时,不把旧账号的数据当作当前余额。查询成功但字段不全时显示「部分可用」。
|
|
84
|
+
|
|
85
|
+
OpenRouter 的管理余额标为管理凭据对应的独立账号范围;无法证明两把 Key 同属账号时,不合并成一个余额。阿里 Console、ZenMux Management、Nous Portal 等额外授权也应由用户确认对应的账号范围。
|
|
86
|
+
|
|
87
|
+
## 开发与验证
|
|
88
|
+
|
|
89
|
+
```sh
|
|
90
|
+
npm run link:peers -- --from /absolute/path/to/dsh-runtime
|
|
91
|
+
npm test
|
|
92
|
+
npm run verify:host -- --runtime /absolute/path/to/dsh-runtime
|
|
93
|
+
npm run verify:persistence -- --runtime /absolute/path/to/dsh-runtime
|
|
94
|
+
npm run verify:browser
|
|
95
|
+
npm run verify:subscriptions
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
`verify:host` 加载真实 Cordis、授权服务和模型路由 schema,供应商 HTTP 使用模拟响应。`verify:persistence` 使用真实文件凭据提供商与六个独立 Node 进程,验证 OAuth 续期轮换、失败保留、永久模型能力、查询授权和快照在重启后的状态。浏览器测试使用 Playwright;可通过 `DSH_PLAYWRIGHT_MODULE` 指定模块目录。
|
|
99
|
+
|
|
100
|
+
2026-11-16 验证结果:**292 项单元测试、两个宿主版本集成、六进程持久化、19 项订阅 UI 和 11 项原授权 UI 场景全部通过**。随后完成真实 Codex、OpenRouter、xAI 验收:目录分别返回 6、433、6 个模型,每家导入 2 个对话模型,独立进程重启后配置与能力一致,用量接口再次成功。OpenRouter 当前 Key 缺少 Management 权限,账户总余额保持未知,Key 用量与预算正常显示。
|
|
101
|
+
|
|
102
|
+
测试使用已有授权,未发出付费推理,也未重启或修改用户的日常桌面 profile。独立测试进程的恢复不能证明未来若干自然日内授权一直有效。详情见 [真实验收](docs/LIVE-VALIDATION-1.0.1.md) 与 [离线验证](docs/VALIDATION.md)。直接打开 `index.html` 仍是静态预览,不能证明账号已连接。
|