dsh-coding-subscription-oauth 0.5.0

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.
Files changed (178) hide show
  1. package/CHANGELOG.md +136 -0
  2. package/CONTRIBUTING.md +109 -0
  3. package/INSTALL.md +220 -0
  4. package/LICENSE +19 -0
  5. package/NOTICE +11 -0
  6. package/README.de.md +254 -0
  7. package/README.es.md +254 -0
  8. package/README.fr.md +254 -0
  9. package/README.ja.md +254 -0
  10. package/README.ko.md +254 -0
  11. package/README.md +286 -0
  12. package/README.pt-BR.md +254 -0
  13. package/README.ru.md +254 -0
  14. package/README.zh-CN.md +271 -0
  15. package/cordis.patch.yml +13 -0
  16. package/docs/00-project-rules.md +195 -0
  17. package/docs/02-architecture.md +132 -0
  18. package/docs/02-architecture.zh-CN.md +128 -0
  19. package/lib/adapter.d.ts +24 -0
  20. package/lib/adapter.d.ts.map +1 -0
  21. package/lib/alias-adapter.d.ts +43 -0
  22. package/lib/alias-adapter.d.ts.map +1 -0
  23. package/lib/auth-routes.d.ts +155 -0
  24. package/lib/auth-routes.d.ts.map +1 -0
  25. package/lib/auth.d.ts +29 -0
  26. package/lib/auth.d.ts.map +1 -0
  27. package/lib/bin.d.ts +6 -0
  28. package/lib/bin.d.ts.map +1 -0
  29. package/lib/bin.js +27591 -0
  30. package/lib/bin.js.map +7 -0
  31. package/lib/capability-routes.d.ts +43 -0
  32. package/lib/capability-routes.d.ts.map +1 -0
  33. package/lib/capability-runtime.d.ts +56 -0
  34. package/lib/capability-runtime.d.ts.map +1 -0
  35. package/lib/capability-settings.d.ts +263 -0
  36. package/lib/capability-settings.d.ts.map +1 -0
  37. package/lib/capability-tools.d.ts +50 -0
  38. package/lib/capability-tools.d.ts.map +1 -0
  39. package/lib/catalog.d.ts +53 -0
  40. package/lib/catalog.d.ts.map +1 -0
  41. package/lib/client.js +3 -0
  42. package/lib/client.js.map +7 -0
  43. package/lib/codex-http.d.ts +77 -0
  44. package/lib/codex-http.d.ts.map +1 -0
  45. package/lib/codex-images.d.ts +109 -0
  46. package/lib/codex-images.d.ts.map +1 -0
  47. package/lib/codex-model-capabilities.d.ts +112 -0
  48. package/lib/codex-model-capabilities.d.ts.map +1 -0
  49. package/lib/codex-search.d.ts +96 -0
  50. package/lib/codex-search.d.ts.map +1 -0
  51. package/lib/codex-usage.d.ts +79 -0
  52. package/lib/codex-usage.d.ts.map +1 -0
  53. package/lib/gateway-anthropic-messages.d.ts +8 -0
  54. package/lib/gateway-anthropic-messages.d.ts.map +1 -0
  55. package/lib/gateway-auth.d.ts +22 -0
  56. package/lib/gateway-auth.d.ts.map +1 -0
  57. package/lib/gateway-backend.d.ts +62 -0
  58. package/lib/gateway-backend.d.ts.map +1 -0
  59. package/lib/gateway-body.d.ts +9 -0
  60. package/lib/gateway-body.d.ts.map +1 -0
  61. package/lib/gateway-config.d.ts +24 -0
  62. package/lib/gateway-config.d.ts.map +1 -0
  63. package/lib/gateway-http.d.ts +16 -0
  64. package/lib/gateway-http.d.ts.map +1 -0
  65. package/lib/gateway-openai-chat.d.ts +8 -0
  66. package/lib/gateway-openai-chat.d.ts.map +1 -0
  67. package/lib/gateway-openai-responses.d.ts +8 -0
  68. package/lib/gateway-openai-responses.d.ts.map +1 -0
  69. package/lib/gateway-parse.d.ts +10 -0
  70. package/lib/gateway-parse.d.ts.map +1 -0
  71. package/lib/gateway-protocol.d.ts +47 -0
  72. package/lib/gateway-protocol.d.ts.map +1 -0
  73. package/lib/gateway-routes.d.ts +21 -0
  74. package/lib/gateway-routes.d.ts.map +1 -0
  75. package/lib/gateway.d.ts +48 -0
  76. package/lib/gateway.d.ts.map +1 -0
  77. package/lib/grok-imagine.d.ts +271 -0
  78. package/lib/grok-imagine.d.ts.map +1 -0
  79. package/lib/grok-import.d.ts +21 -0
  80. package/lib/grok-import.d.ts.map +1 -0
  81. package/lib/http-json.d.ts +10 -0
  82. package/lib/http-json.d.ts.map +1 -0
  83. package/lib/ids.d.ts +33 -0
  84. package/lib/ids.d.ts.map +1 -0
  85. package/lib/imagine-routes.d.ts +59 -0
  86. package/lib/imagine-routes.d.ts.map +1 -0
  87. package/lib/index.d.ts +69 -0
  88. package/lib/index.d.ts.map +1 -0
  89. package/lib/index.js +35355 -0
  90. package/lib/index.js.map +7 -0
  91. package/lib/invariant.d.ts +9 -0
  92. package/lib/invariant.d.ts.map +1 -0
  93. package/lib/invariant.js +14 -0
  94. package/lib/invariant.js.map +7 -0
  95. package/lib/kimi-errors.d.ts +13 -0
  96. package/lib/kimi-errors.d.ts.map +1 -0
  97. package/lib/media-store.d.ts +130 -0
  98. package/lib/media-store.d.ts.map +1 -0
  99. package/lib/oauth-import-routes.d.ts +52 -0
  100. package/lib/oauth-import-routes.d.ts.map +1 -0
  101. package/lib/oauth-providers.d.ts +26 -0
  102. package/lib/oauth-providers.d.ts.map +1 -0
  103. package/lib/oauth-session.d.ts +40 -0
  104. package/lib/oauth-session.d.ts.map +1 -0
  105. package/lib/oauth-sources.d.ts +205 -0
  106. package/lib/oauth-sources.d.ts.map +1 -0
  107. package/lib/oauth.d.ts +79 -0
  108. package/lib/oauth.d.ts.map +1 -0
  109. package/lib/provider.d.ts +38 -0
  110. package/lib/provider.d.ts.map +1 -0
  111. package/lib/proxy.d.ts +17 -0
  112. package/lib/proxy.d.ts.map +1 -0
  113. package/lib/redact.d.ts +5 -0
  114. package/lib/redact.d.ts.map +1 -0
  115. package/lib/session.d.ts +40 -0
  116. package/lib/session.d.ts.map +1 -0
  117. package/lib/store.d.ts +46 -0
  118. package/lib/store.d.ts.map +1 -0
  119. package/lib/web-origin.d.ts +10 -0
  120. package/lib/web-origin.d.ts.map +1 -0
  121. package/lib/web-routes.d.ts +20 -0
  122. package/lib/web-routes.d.ts.map +1 -0
  123. package/package.json +185 -0
  124. package/patches/dsh-agy@0.1.2.patch +25 -0
  125. package/scripts/release.mjs +166 -0
  126. package/scripts/smoke-deployed-routes.mjs +146 -0
  127. package/scripts/verify-deployed-catalog.mjs +87 -0
  128. package/src/adapter.ts +282 -0
  129. package/src/alias-adapter.ts +152 -0
  130. package/src/auth-routes.ts +871 -0
  131. package/src/auth.ts +67 -0
  132. package/src/bin.ts +350 -0
  133. package/src/capability-routes.ts +275 -0
  134. package/src/capability-runtime.ts +313 -0
  135. package/src/capability-settings.ts +657 -0
  136. package/src/capability-tools.ts +666 -0
  137. package/src/catalog.ts +271 -0
  138. package/src/client/GrokBuildSettings.tsx +2221 -0
  139. package/src/client/index.tsx +37 -0
  140. package/src/client/locales.ts +421 -0
  141. package/src/codex-http.ts +447 -0
  142. package/src/codex-images.ts +485 -0
  143. package/src/codex-model-capabilities.ts +320 -0
  144. package/src/codex-search.ts +245 -0
  145. package/src/codex-usage.ts +263 -0
  146. package/src/gateway-anthropic-messages.ts +84 -0
  147. package/src/gateway-auth.ts +100 -0
  148. package/src/gateway-backend.ts +274 -0
  149. package/src/gateway-body.ts +49 -0
  150. package/src/gateway-config.ts +76 -0
  151. package/src/gateway-http.ts +104 -0
  152. package/src/gateway-openai-chat.ts +124 -0
  153. package/src/gateway-openai-responses.ts +53 -0
  154. package/src/gateway-parse.ts +224 -0
  155. package/src/gateway-protocol.ts +52 -0
  156. package/src/gateway-routes.ts +152 -0
  157. package/src/gateway.ts +242 -0
  158. package/src/grok-imagine.ts +1627 -0
  159. package/src/grok-import.ts +151 -0
  160. package/src/http-json.ts +82 -0
  161. package/src/ids.ts +45 -0
  162. package/src/imagine-routes.ts +461 -0
  163. package/src/index.ts +598 -0
  164. package/src/invariant.ts +17 -0
  165. package/src/kimi-errors.ts +26 -0
  166. package/src/media-store.ts +927 -0
  167. package/src/oauth-import-routes.ts +314 -0
  168. package/src/oauth-providers.ts +152 -0
  169. package/src/oauth-session.ts +183 -0
  170. package/src/oauth-sources.ts +1104 -0
  171. package/src/oauth.ts +620 -0
  172. package/src/provider.ts +128 -0
  173. package/src/proxy.ts +99 -0
  174. package/src/redact.ts +72 -0
  175. package/src/session.ts +218 -0
  176. package/src/store.ts +217 -0
  177. package/src/web-origin.ts +60 -0
  178. package/src/web-routes.ts +75 -0
package/README.de.md ADDED
@@ -0,0 +1,254 @@
1
+
2
+ <!-- banner -->
3
+ <div align="center">
4
+
5
+ # 🔐 dsh-coding-subscription-oauth
6
+
7
+ **v0.5.0** · früher `dsh-grok-build`
8
+
9
+ **OAuth-Plugin für Coding-Abonnements für [DeepSeek Harness](https://github.com/deepseek-ai/dsh).** Melden Sie sich einmal mit den Abonnements an, die Sie bereits bezahlen, und nutzen Sie die Modelle aus den Einstellungen oder der CLI von dsh. **Keine Tokens in den Chat einfügen.**
10
+
11
+ [![License](https://img.shields.io/badge/license-Apache--2.0-green.svg)](LICENSE)
12
+ [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](CONTRIBUTING.md)
13
+
14
+ *[English](README.md) · [中文版](README.zh-CN.md) · [日本語](README.ja.md) · [한국어](README.ko.md) · [Português (BR)](README.pt-BR.md) · [Español](README.es.md) · [Français](README.fr.md) · [Deutsch](README.de.md) · [Русский](README.ru.md)*
15
+
16
+ </div>
17
+
18
+ ---
19
+
20
+ ## Namensänderung
21
+
22
+ Zuerst **`dsh-grok-build`** (nur Grok Build). Jetzt SuperGrok / Codex / Kimi / Claude / Antigravity.
23
+
24
+ | | Das verwenden | Funktioniert weiter |
25
+ |---|---|---|
26
+ | GitHub / `dsh plugin add` | [`dsh-coding-subscription-oauth`](https://github.com/lninghaha/dsh-coding-subscription-oauth) | `github:lninghaha/dsh-grok-build` (derselbe `main`) |
27
+ | npm | Noch nicht veröffentlicht; von GitHub installieren | Es gab kein altes npm-Paket |
28
+ | CLI | `dsh-coding-oauth` | `dsh-grok-build` |
29
+ | Cordis-Plugin-id | `llm-grok-build-oauth` | unverändert |
30
+ | Settings-HTTP-API | `/plugins/dsh-grok-build/*` | unverändert |
31
+ | Zugangsdateien | `$DSH_HOME/.grok-build-auth.json` und die anderen `*-oauth-auth.json` | unverändert |
32
+
33
+ ## ✨ Funktionen
34
+
35
+ - 🧾 **Eigenes Abonnement mitbringen** — nutzen Sie die vorhandenen Coding-Pläne, die Sie bereits bezahlen, statt separater API-Keys.
36
+ - 🔑 **Lokales OAuth, ohne Key einzufügen** — in den Einstellungen oder der CLI autorisieren; Tokens gelangen nie in den Chat.
37
+ - 🧩 **Ein Plugin, fünf Anbieter** — Grok Build, Codex, Kimi, Claude und Google Antigravity.
38
+ - 🛡️ **Sicherheit by Design** — Zugangsdateien nur-eigentümer `0600`, atomares Schreiben, dateiübergreifende Prozesssperre.
39
+ - ⚙️ **Dynamischer Katalog** — der Modellwähler listet genau die Anbieter, die Sie authentifiziert haben.
40
+ - 🌐 **Proxy-bewusst** — nur geprüfte, vertrauenswürdige Abonnement-Domänen werden über den Proxy geleitet.
41
+
42
+ ## Integrationsprobleme, die dieses Plugin löst
43
+
44
+ Diese Suchbegriffe und DSH-Fehler führen meist hierher.
45
+
46
+ | Gesucht / gesehen | Was kaputt war | Was das Plugin tut |
47
+ |---|---|---|
48
+ | SuperGrok / X Premium in DSH, Grok Build vs `api.x.ai` | Die eingebaute Route `xai` ist die Pay-as-you-go-API. Das Coding-Abo geht über `cli-chat-proxy.grok.com` | Route `grok-build` + CLI-Fingerabdruck-Header (`X-XAI-Token-Auth` usw.), damit kein stilles 403 entsteht |
49
+ | `API key is invalid` / `AUTH` | Die GUI mappt **jedes** AUTH auf diesen Text. Oft ist nur das kurze OAuth-Access-Token abgelaufen | Refresh **5 Min.** vor Ablauf; bei 401 Token invalidieren und den Step **wiederholen** |
50
+ | `INVALID_REPLAY_STATE` im 2. Codex/Kimi-Turn | Replay trug noch die native pi-ai-Provider-ID | Harness-Route-ID behalten und altes Replay heilen |
51
+ | grok-4.6 ohne **xhigh** | `/v1/models-v2` liefert bereits `reasoning_efforts`; das 4.5-Template versteckt xhigh | Live-Efforts einlesen. 4.6 hat xhigh; 4.5 bleibt low/medium/high |
52
+ | Kimi Code als Anthropic-`x-api-key` | OAuth-Token als Anthropic-Key gesendet | Nur `Authorization: Bearer` |
53
+ | Nicht angemeldete Modelle bleiben im Wähler | Alle registrierten Routen wurden gelistet | Nicht authentifizierte Routen sind leer; angemeldete Namen tragen `(OAuth)` |
54
+ | PKCE auf remote / headless DSH | Kein Weg zurück zu `localhost` | Device-Code für Grok/Codex/Kimi; Claude akzeptiert die eingefügte Redirect-URL |
55
+ | Proxy lässt Grok durch und legt Kimi in China lahm | Ein globales `HTTPS_PROXY` | Nur Allowlist; Kimi bleibt **direkt**, außer `proxyKimi: true` |
56
+
57
+ ## Unterstützte Anbieter
58
+
59
+ | Anbieter | Route | Authentifizierung | Koexistiert mit |
60
+ |---|---|---|---|
61
+ | **xAI Grok Build** | `grok-build` | SuperGrok / X Premium OAuth | `xai` |
62
+ | **OpenAI Codex** | `codex-oauth` | ChatGPT Plus/Pro OAuth | `openai` |
63
+ | **Kimi Code** | `kimi-code-oauth` | Kimi Code OAuth | `kimi-coding` |
64
+ | **Claude Code** | `claude-code-oauth` | Claude Pro/Max OAuth | — |
65
+ | **Google Antigravity** | `agy` | `dsh-agy` Google OAuth | — |
66
+
67
+ > Der Geräte-Login von Grok Build, der dynamische `/v1/models-v2`-Katalog und das Responses-Streaming sind auf echten Deployments verifiziert. Codex/Kimi/Claude nutzen das native OAuth/Refresh von `@earendil-works/pi-ai`, anstatt die Anbieter-Flows neu zu implementieren.
68
+
69
+ ## 🚀 Schnellstart
70
+
71
+ ```bash
72
+ # 1. Plugin in das Web-Profil installieren
73
+ dsh plugin --profile web add github:lninghaha/dsh-coding-subscription-oauth
74
+
75
+ # 2. optional — Google Antigravity (gepinnte, geprüfte Version)
76
+ dsh plugin --profile web add dsh-agy@0.1.2
77
+
78
+ # 3. den residenten dsh-web-Dienst neu starten
79
+ systemctl --user restart dsh-web.service
80
+ ```
81
+
82
+ Danach **Settings → Coding OAuth** öffnen und bei einem beliebigen Anbieter anmelden. Fertig — wählen Sie Ihr authentifiziertes Modell im Wähler.
83
+
84
+ ## 📚 Inhaltsverzeichnis
85
+
86
+ - [Namensänderung](#namensänderung)
87
+ - [Integrationsprobleme, die dieses Plugin löst](#integrationsprobleme-die-dieses-plugin-löst)
88
+ - [Installation](#installation)
89
+ - [Einstellungsseite](#einstellungsseite)
90
+ - [CLI](#cli)
91
+ - [Kimi in China](#kimi-in-china)
92
+ - [Netzwerk-Proxy](#netzwerk-proxy)
93
+ - [Ausfallsicherheit](#ausfallsicherheit)
94
+ - [Zugangsdaten](#zugangsdaten)
95
+ - [Architektur](#architektur)
96
+ - [Technische Hinweise](#technische-hinweise)
97
+ - [Compliance](#compliance)
98
+ - [Dokumentation](#dokumentation)
99
+ - [Mitwirken](#mitwirken)
100
+ - [Lizenz](#lizenz)
101
+
102
+ ## Installation
103
+
104
+ Erfordert DeepSeek Harness `0.1.0-rc.6+` und Node.js 22.19+. Vollständige Details in den [Installationshinweisen](INSTALL.md).
105
+
106
+ ```bash
107
+ # von GitHub
108
+ dsh plugin --profile web add github:lninghaha/dsh-coding-subscription-oauth
109
+
110
+ # oder ein lokales Entwicklungs-Checkout
111
+ dsh plugin --profile web add ./dsh-coding-subscription-oauth
112
+ ```
113
+
114
+ Nach der Installation `dsh web` neu starten. Verifikation gegen ein Live-Deployment:
115
+
116
+ ```bash
117
+ pnpm run verify:deployed # prüft echtes /api/llm.models + OAuth-Status
118
+ DSH_EXPECT_AGY_AUTH=signed-in pnpm run verify:deployed # falls Google angemeldet ist
119
+
120
+ DSH_RESTORE_PROVIDER=openai \
121
+ DSH_RESTORE_MODEL=gpt-5.6-sol \
122
+ DSH_RESTORE_REASONING=max \
123
+ pnpm run smoke:deployed # echte Codex/Kimi-Tool-Calls + Replay des zweiten Turns
124
+ ```
125
+
126
+ > `smoke:deployed` erstellt eine temporäre Sitzung, validiert Codex- und Kimi-Tool-Calls sowie einen zweiten Benutzer-Turn (Regression für `INVALID_REPLAY_STATE`), stellt das deklarierte Standardmodell wieder her und archiviert die Sitzung.
127
+
128
+ ## Einstellungsseite
129
+
130
+ **Settings → Coding OAuth** öffnen:
131
+
132
+ | Anbieter | Methoden |
133
+ |---|---|
134
+ | Grok | Autorisierungscode · Gerätecode · Grok-CLI-Import · Modellauswahl |
135
+ | Codex | Gerätecode (empfohlen auf Remote-DSH) · Browser-PKCE |
136
+ | Kimi | Gerätecode |
137
+ | Claude | Browser-PKCE (ein Remote-Browser kann die vollständige localhost-Redirect-URL einfügen) |
138
+ | Antigravity | `dsh-agy`-Installationsstatus + profil-lokale CLI-Befehle |
139
+
140
+ Der Wähler listet nur Routen, die die Authentifizierung abgeschlossen haben; nicht authentifizierte Anbieter liefern eine leere Liste. Anbieternamen tragen `(OAuth)`, und der Katalog wird nach An-/Abmeldung über `llm/adapters-updated` aktualisiert.
141
+
142
+ ## Optionale Funktionen
143
+
144
+ Die sieben Schalter `codexSearch`, `codexImages`, `codexImageEdits`, `codexUsage`, `codexFast`, `grokImagineImage` und `grokImagineVideo` sind standardmäßig aus und werden ohne Neustart live angewendet. Die Grenzwerte sind `searchResults` (1–20, Standard 5), `imageCount` (1–4, Standard 1) und `videoArtifactTtlMs` (1 Stunde–7 Tage, Standard 7 Tage; die Oberfläche zeigt 1–168 Stunden). Eine kürzere Aufbewahrung verkürzt und bereinigt vorhandene Artefakte sofort; eine Erhöhung gilt nur für neue Artefakte.
145
+
146
+ ## CLI
147
+
148
+ ```bash
149
+ # `dsh-grok-build` bleibt ein Befehlsalias
150
+ dsh-coding-oauth login [--pkce] | import | status | logout
151
+
152
+ # neuere Anbieter
153
+ dsh-coding-oauth login codex --device-auth | codex --browser | kimi | claude
154
+ dsh-coding-oauth status all
155
+ dsh-coding-oauth logout codex
156
+
157
+ # Antigravity (zuerst ins Web-Profil installieren)
158
+ dsh plugin --profile web exec dsh-agy login --headless
159
+ ```
160
+
161
+ > Die `dsh-agy`-CLI ändert den Kontopool außerhalb des DSH-Prozesses und kann daher kein Katalogereignis im Prozess auslösen — nach An-/Abmeldung den Modellwähler schließen und wieder öffnen.
162
+
163
+ ## Kimi in China
164
+
165
+ Das Kimi-Code-Abonnement-OAuth nutzt `https://auth.kimi.com`; das Inferencing nutzt `https://api.kimi.com/coding`. `https://api.moonshot.cn/v1` ist der Pay-as-you-go-API-Key-Kanal des **Moonshot Open Platform** — es gibt keinen umschaltbaren „China-OAuth-Endpunkt“. Dieses Plugin nutzt eine separate Route `kimi-code-oauth` und hat keinen Einfluss auf eine bestehende `kimi-coding`-API-Key-Konfiguration.
166
+
167
+ ## Netzwerk-Proxy
168
+
169
+ Priorität: `config.proxy` → `CODING_OAUTH_PROXY` → `GROK_BUILD_PROXY` → `HTTPS_PROXY`/`HTTP_PROXY`.
170
+
171
+ ```yaml
172
+ - id: llm-grok-build-oauth
173
+ config:
174
+ proxy: http://127.0.0.1:7890
175
+ proxyKimi: false
176
+ ```
177
+
178
+ Nur geprüfte Abonnement-Domänen werden proxied (xAI/Grok, OpenAI Codex, Claude/Anthropic, Google Antigravity); aller übriger DSH-Traffic behält seinen ursprünglichen Dispatcher. Kimi bleibt standardmäßig direkt und nutzt den Proxy nur bei `proxyKimi: true`.
179
+
180
+ ## Ausfallsicherheit
181
+
182
+ OAuth-Zugriffstoken werden **fünf Minuten** vor dem gespeicherten Ablauf erneuert (pi-ai 0.84+). Lehnt der Upstream ein lokal noch gültiges Token mit 401/403 ab, setzt das Plugin das gespeicherte `expires` in die Vergangenheit; der wiederholte Step refresht zuerst und sendet dann erneut.
183
+
184
+ Wiederholungen folgen der Harness-Retry-Policy: transiente Fehler (`RATE_LIMIT`/`SERVER`/`TIMEOUT`/`TRANSPORT`/`EMPTY_RESPONSE`) **und `AUTH`** werden mit exponentiellem Backoff wiederholt (2 Versuche, 500 ms → 10 s, 10 % Jitter). Quota-Erschöpfung und ein totes Refresh-Token werden **nicht** wiederholt. Überschreiben pro Deployment:
185
+
186
+ ```yaml
187
+ - id: llm-grok-build-oauth
188
+ config:
189
+ retryPolicy:
190
+ mode: normal
191
+ maxRetries: 2
192
+ retryableCodes: [EMPTY_RESPONSE, RATE_LIMIT, SERVER, TIMEOUT, TRANSPORT, AUTH]
193
+ backoff: { initialDelayMs: 500, maxDelayMs: 10000, jitterRatio: 0.1 }
194
+ ```
195
+
196
+ ## Zugangsdaten
197
+
198
+ Nur-Eigentümer `0600`, atomares Schreiben, dateiübergreifende Prozesssperre:
199
+
200
+ - `$DSH_HOME/.grok-build-auth.json`
201
+ - `$DSH_HOME/.codex-oauth-auth.json`
202
+ - `$DSH_HOME/.kimi-code-oauth-auth.json`
203
+ - `$DSH_HOME/.claude-code-oauth-auth.json`
204
+
205
+ Auswahl-Caches liegen in den entsprechenden `*-models.json`-Dateien. **Kein HTTP-Status, kein Log und keine Oberfläche darf ein Token zurückgeben.**
206
+
207
+ ## Architektur
208
+
209
+ ```mermaid
210
+ flowchart LR
211
+ subgraph DSH["DSH Harness"]
212
+ UI[Einstellungen / Web · Coding OAuth] --> LLM[llm route]
213
+ LLM --> ALIA[Routen-Alias-Adapter]
214
+ end
215
+ ALIA --> PI[nativer pi-ai-Anbieter<br/>OAuth · Refresh · Stream]
216
+ PI --> GROK[Grok Build]
217
+ PI --> COD[Codex]
218
+ PI --> KIMI[Kimi]
219
+ PI --> CLAU[Claude]
220
+ AGY[dsh-agy-Plugin] --> GAL[Google Antigravity]
221
+ ```
222
+
223
+ ## Technische Hinweise
224
+
225
+ - **Grok Build**: eigener Responses-Anbieter auf `cli-chat-proxy.grok.com/v1`, CLI-Fingerprint-Header, dynamischer Modellkatalog.
226
+ - **Codex/Kimi/Claude**: native pi-ai-Anbieter übernehmen OAuth und Refresh; der Routen-Alias-Adapter mappt sie auf native ids, während die Modellidentität unverändert bleibt.
227
+ - Der Kimi-Zugangstoken wird explizit in `Authorization: Bearer` umgewandelt — niemals versehentlich als Anthropic-`x-api-key` gesendet.
228
+ - Google Antigravity wird hier **nicht** reverse-engineered; es nutzt ein versions-gepinntes dediziertes DSH-Plugin.
229
+
230
+ ## Compliance
231
+
232
+ Coding-Abonnements über einen Drittanbieter-Harness zu nutzen, kann in einer Grauzone der Bedingungen jedes Anbieters liegen und Quoten-, Regional- oder Kontoriskokontrollen auslösen. **Nutzen Sie nur eigene Konten**; dieses Projekt unterstützt keine Massenkonten, Quotenverkauf, Remote-Relay, Paywall-Umgehung oder Client-Identitätsvortäuschung. Für kommerzielle Nutzung bevorzugen Sie die offiziellen API-Key-Kanäle der Anbieter.
233
+
234
+ ## Dokumentation
235
+
236
+ | Dokument | Zweck |
237
+ |---|---|
238
+ | [`INSTALL.md`](INSTALL.md) | Installations- und Nutzungsdetails |
239
+ | [`CHANGELOG.md`](CHANGELOG.md) | Release-Historie |
240
+ | [`docs/00-project-rules.md`](docs/00-project-rules.md) | Versionierung, Release-Loop, Trennung öffentlich/privat |
241
+ | [`docs/02-architecture.md`](docs/02-architecture.md) | Interne Architektur (Routen, Datenfluss, Module, API) · [中文](docs/02-architecture.zh-CN.md) |
242
+ | [`CONTRIBUTING.md`](CONTRIBUTING.md) | Beitragsleitfaden |
243
+
244
+ ## Verwandt
245
+
246
+ - [`dsh-agy`](https://www.npmjs.com/package/dsh-agy) — separates, versions-gepinntes Plugin für Google Antigravity.
247
+
248
+ ## Mitwirken
249
+
250
+ Alle Arten von Beiträgen sind willkommen — Funktionen, Dokumentation, Übersetzungen, Bug-Reports. Siehe **[CONTRIBUTING](CONTRIBUTING.md)** für den Ablauf, Commit-Konventionen und den Release-Loop. Wenn Ihre Sprache nicht aufgeführt ist, senden Sie einen PR mit einer README-Übersetzung, und wir fügen sie der Tabelle oben hinzu.
251
+
252
+ ## Lizenz
253
+
254
+ [Apache-2.0](LICENSE) · siehe [NOTICE](NOTICE). Teile stammen vom Projekt [dsh-xai](https://github.com/MirDie/dsh-xai) (Apache-2.0).
package/README.es.md ADDED
@@ -0,0 +1,254 @@
1
+
2
+ <!-- banner -->
3
+ <div align="center">
4
+
5
+ # 🔐 dsh-coding-subscription-oauth
6
+
7
+ **v0.5.0** · antes `dsh-grok-build`
8
+
9
+ **Plugin OAuth de suscripciones de codificación para [DeepSeek Harness](https://github.com/deepseek-ai/dsh).** Inicia sesión una vez con las suscripciones que ya pagas y luego usa sus modelos desde la página de configuración o la CLI de dsh. **Sin pegar tokens en el chat.**
10
+
11
+ [![License](https://img.shields.io/badge/license-Apache--2.0-green.svg)](LICENSE)
12
+ [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](CONTRIBUTING.md)
13
+
14
+ *[English](README.md) · [中文版](README.zh-CN.md) · [日本語](README.ja.md) · [한국어](README.ko.md) · [Português (BR)](README.pt-BR.md) · [Español](README.es.md) · [Français](README.fr.md) · [Deutsch](README.de.md) · [Русский](README.ru.md)*
15
+
16
+ </div>
17
+
18
+ ---
19
+
20
+ ## Cambio de nombre
21
+
22
+ Empezó como **`dsh-grok-build`** (solo Grok Build). Ahora cubre SuperGrok / Codex / Kimi / Claude / Antigravity.
23
+
24
+ | | Usa esto | Sigue funcionando |
25
+ |---|---|---|
26
+ | GitHub / `dsh plugin add` | [`dsh-coding-subscription-oauth`](https://github.com/lninghaha/dsh-coding-subscription-oauth) | `github:lninghaha/dsh-grok-build` (el mismo `main`) |
27
+ | npm | Aún no publicado; instala desde GitHub | No se publicó un paquete npm legado |
28
+ | CLI | `dsh-coding-oauth` | `dsh-grok-build` |
29
+ | Cordis plugin id | `llm-grok-build-oauth` | sin cambios |
30
+ | API HTTP de ajustes | `/plugins/dsh-grok-build/*` | sin cambios |
31
+ | Archivos de credenciales | `$DSH_HOME/.grok-build-auth.json` y los demás `*-oauth-auth.json` | sin cambios |
32
+
33
+ ## ✨ Funciones
34
+
35
+ - 🧾 **Trae tu propia suscripción** — usa los planes de codificación que ya pagas en lugar de claves de API aparte.
36
+ - 🔑 **OAuth local, sin pegar claves** — autoriza en la página de configuración o la CLI; los tokens nunca entran en el chat.
37
+ - 🧩 **Un plugin, cinco proveedores** — Grok Build, Codex, Kimi, Claude y Google Antigravity.
38
+ - 🛡️ **Seguro por diseño** — archivos de credenciales solo-propietario `0600`, escritura atómica, bloqueo de archivo entre procesos.
39
+ - ⚙️ **Catálogo dinámico** — el selector de modelos lista exactamente los proveedores que autenticaste.
40
+ - 🌐 **Consciente de proxy** — solo hace proxy de dominios de suscripción revisados y confiables.
41
+
42
+ ## Problemas de integración que resuelve este plugin
43
+
44
+ Estas búsquedas y errores de DSH suelen traer a la gente hasta aquí.
45
+
46
+ | Buscaste / viste | Qué estaba roto | Qué hace el plugin |
47
+ |---|---|---|
48
+ | SuperGrok / X Premium en DSH, Grok Build vs `api.x.ai` | La ruta `xai` es la API de pago por uso. La suscripción de coding va a `cli-chat-proxy.grok.com` | Ruta `grok-build` + cabeceras fingerprint de la CLI (`X-XAI-Token-Auth`, etc.) para evitar un 403 silencioso |
49
+ | `API key is invalid` / `AUTH` | La GUI traduce **todo** AUTH a ese texto. A menudo el access token OAuth caducó | Refresh **5 min** antes del expiry; ante 401 invalida el token y **reintenta el step** |
50
+ | `INVALID_REPLAY_STATE` en el 2.º turno Codex/Kimi | El replay seguía con el provider id nativo de pi-ai | Conserva el id de ruta del Harness y repara replay antiguo |
51
+ | grok-4.6 sin **xhigh** | `/v1/models-v2` ya trae `reasoning_efforts`; clonar la plantilla 4.5 oculta xhigh | Lee los efforts en vivo. 4.6 tiene xhigh; 4.5 queda low/medium/high |
52
+ | Kimi Code como `x-api-key` de Anthropic | El token OAuth se envió como clave Anthropic | Solo `Authorization: Bearer` |
53
+ | Modelos sin iniciar sesión aún en el selector | Se listaban todas las rutas registradas | Las rutas sin auth quedan vacías; los nombres autenticados llevan `(OAuth)` |
54
+ | PKCE en un DSH remoto / headless | No se puede volver a `localhost` | Device-code para Grok/Codex/Kimi; Claude acepta la URL de redirect pegada |
55
+ | El proxy deja pasar Grok y tumba Kimi en China | Un `HTTPS_PROXY` global | Proxy solo en la allowlist; Kimi queda **directo** salvo `proxyKimi: true` |
56
+
57
+ ## Proveedores soportados
58
+
59
+ | Proveedor | Ruta | Autenticación | Coexiste con |
60
+ |---|---|---|---|
61
+ | **xAI Grok Build** | `grok-build` | SuperGrok / X Premium OAuth | `xai` |
62
+ | **OpenAI Codex** | `codex-oauth` | ChatGPT Plus/Pro OAuth | `openai` |
63
+ | **Kimi Code** | `kimi-code-oauth` | Kimi Code OAuth | `kimi-coding` |
64
+ | **Claude Code** | `claude-code-oauth` | Claude Pro/Max OAuth | — |
65
+ | **Google Antigravity** | `agy` | `dsh-agy` Google OAuth | — |
66
+
67
+ > El inicio de sesión por dispositivo de Grok Build, el catálogo dinámico `/v1/models-v2` y la inferencia en streaming vía Responses están verificados en despliegues reales. Codex/Kimi/Claude reutilizan el OAuth/refresh nativo del proveedor de `@earendil-works/pi-ai` en lugar de reimplementar los flujos de cada proveedor.
68
+
69
+ ## 🚀 Inicio rápido
70
+
71
+ ```bash
72
+ # 1. instala el plugin en el perfil web
73
+ dsh plugin --profile web add github:lninghaha/dsh-coding-subscription-oauth
74
+
75
+ # 2. opcional — Google Antigravity (versión fija revisada)
76
+ dsh plugin --profile web add dsh-agy@0.1.2
77
+
78
+ # 3. reinicia el servicio dsh web residente
79
+ systemctl --user restart dsh-web.service
80
+ ```
81
+
82
+ Luego abre **Settings → Coding OAuth** e inicia sesión en cualquier proveedor. Listo — elige tu modelo autenticado en el selector.
83
+
84
+ ## 📚 Índice
85
+
86
+ - [Cambio de nombre](#cambio-de-nombre)
87
+ - [Problemas de integración que resuelve este plugin](#problemas-de-integración-que-resuelve-este-plugin)
88
+ - [Instalación](#instalación)
89
+ - [Página de configuración](#página-de-configuración)
90
+ - [CLI](#cli)
91
+ - [Kimi en China](#kimi-en-china)
92
+ - [Proxy de red](#proxy-de-red)
93
+ - [Resiliencia](#resiliencia)
94
+ - [Credenciales](#credenciales)
95
+ - [Arquitectura](#arquitectura)
96
+ - [Notas técnicas](#notas-técnicas)
97
+ - [Cumplimiento](#cumplimiento)
98
+ - [Documentación](#documentación)
99
+ - [Contribución](#contribución)
100
+ - [Licencia](#licencia)
101
+
102
+ ## Instalación
103
+
104
+ Requiere DeepSeek Harness `0.1.0-rc.6+` y Node.js 22.19+. Detalles completos en las [notas de instalación](INSTALL.md).
105
+
106
+ ```bash
107
+ # desde GitHub
108
+ dsh plugin --profile web add github:lninghaha/dsh-coding-subscription-oauth
109
+
110
+ # o un checkout local de desarrollo
111
+ dsh plugin --profile web add ./dsh-coding-subscription-oauth
112
+ ```
113
+
114
+ Reinicia `dsh web` tras instalar. Verificación contra un despliegue en vivo:
115
+
116
+ ```bash
117
+ pnpm run verify:deployed # comprueba /api/llm.models real + estado OAuth
118
+ DSH_EXPECT_AGY_AUTH=signed-in pnpm run verify:deployed # si Google está autenticado
119
+
120
+ DSH_RESTORE_PROVIDER=openai \
121
+ DSH_RESTORE_MODEL=gpt-5.6-sol \
122
+ DSH_RESTORE_REASONING=max \
123
+ pnpm run smoke:deployed # llamadas reales Codex/Kimi + replay del segundo turn
124
+ ```
125
+
126
+ > `smoke:deployed` crea una sesión temporal, valida llamadas de herramientas de Codex y Kimi y un segundo turno del usuario (regresión de `INVALID_REPLAY_STATE`), restaura el modelo predeterminado declarado y luego archiva la sesión.
127
+
128
+ ## Página de configuración
129
+
130
+ Abre **Settings → Coding OAuth**:
131
+
132
+ | Proveedor | Métodos |
133
+ |---|---|
134
+ | Grok | código de autorización · código de dispositivo · importación CLI de Grok · selección de modelos |
135
+ | Codex | código de dispositivo (recomendado en DSH remoto) · PKCE en navegador |
136
+ | Kimi | código de dispositivo |
137
+ | Claude | PKCE en navegador (un navegador remoto puede pegar la URL completa de redirect localhost) |
138
+ | Antigravity | estado de instalación de `dsh-agy` + comandos CLI locales al perfil |
139
+
140
+ El selector solo lista rutas que completaron la autenticación; los proveedores no autenticados devuelven lista vacía. Los nombres de proveedor llevan `(OAuth)` y el catálogo se actualiza vía `llm/adapters-updated` tras iniciar/cerrar sesión.
141
+
142
+ ## Capacidades opcionales
143
+
144
+ Los siete controles `codexSearch`, `codexImages`, `codexImageEdits`, `codexUsage`, `codexFast`, `grokImagineImage` y `grokImagineVideo` empiezan desactivados y se aplican en vivo, sin reinicio. Los límites son `searchResults` (1–20, predeterminado 5), `imageCount` (1–4, predeterminado 1) y `videoArtifactTtlMs` (1 hora–7 días, predeterminado 7 días; la interfaz muestra 1–168 horas). Reducir la retención acorta y limpia los artefactos existentes de inmediato; aumentarla solo afecta a los nuevos.
145
+
146
+ ## CLI
147
+
148
+ ```bash
149
+ # `dsh-grok-build` sigue siendo un alias
150
+ dsh-coding-oauth login [--pkce] | import | status | logout
151
+
152
+ # proveedores más nuevos
153
+ dsh-coding-oauth login codex --device-auth | codex --browser | kimi | claude
154
+ dsh-coding-oauth status all
155
+ dsh-coding-oauth logout codex
156
+
157
+ # Antigravity (instala en el perfil web primero)
158
+ dsh plugin --profile web exec dsh-agy login --headless
159
+ ```
160
+
161
+ > La CLI de `dsh-agy` modifica el grupo de cuentas fuera del proceso DSH, por lo que no puede emitir un evento de catálogo en el proceso — cierra y vuelve a abrir el selector de modelos tras iniciar/cerrar sesión.
162
+
163
+ ## Kimi en China
164
+
165
+ El OAuth de la suscripción de Kimi Code usa `https://auth.kimi.com`; la inferencia usa `https://api.kimi.com/coding`. `https://api.moonshot.cn/v1` es el canal de clave API de pago por uso del **Moonshot Open Platform** — no existe un "endpoint OAuth de China" conmutable. Este plugin usa una ruta separada `kimi-code-oauth` y no afecta una configuración `kimi-coding` por clave API existente.
166
+
167
+ ## Proxy de red
168
+
169
+ Prioridad: `config.proxy` → `CODING_OAUTH_PROXY` → `GROK_BUILD_PROXY` → `HTTPS_PROXY`/`HTTP_PROXY`.
170
+
171
+ ```yaml
172
+ - id: llm-grok-build-oauth
173
+ config:
174
+ proxy: http://127.0.0.1:7890
175
+ proxyKimi: false
176
+ ```
177
+
178
+ Solo se usan vía proxy los dominios de suscripción revisados (xAI/Grok, OpenAI Codex, Claude/Anthropic, Google Antigravity); el resto del tráfico DSH mantiene su dispatcher original. Kimi permanece directo por defecto y solo usa el proxy cuando `proxyKimi: true`.
179
+
180
+ ## Resiliencia
181
+
182
+ Los tokens de acceso OAuth se renuevan **cinco minutos** antes del vencimiento almacenado (pi-ai 0.84+). Si el origen aún rechaza un token localmente válido con 401/403, el plugin retrocede el `expires` guardado y el step reintentado renueva el token antes de reenviar.
183
+
184
+ Los reintentos siguen la política del harness: fallos transitorios (`RATE_LIMIT`/`SERVER`/`TIMEOUT`/`TRANSPORT`/`EMPTY_RESPONSE`) **y `AUTH`** se reintentan con backoff exponencial (2 reintentos, 500 ms → 10 s, 10% de jitter). El agotamiento de cuota y un refresh token muerto **no** se reintentan. Anulación por despliegue:
185
+
186
+ ```yaml
187
+ - id: llm-grok-build-oauth
188
+ config:
189
+ retryPolicy:
190
+ mode: normal
191
+ maxRetries: 2
192
+ retryableCodes: [EMPTY_RESPONSE, RATE_LIMIT, SERVER, TIMEOUT, TRANSPORT, AUTH]
193
+ backoff: { initialDelayMs: 500, maxDelayMs: 10000, jitterRatio: 0.1 }
194
+ ```
195
+
196
+ ## Credenciales
197
+
198
+ Solo-propietario `0600`, escritura atómica, bloqueo de archivo entre procesos:
199
+
200
+ - `$DSH_HOME/.grok-build-auth.json`
201
+ - `$DSH_HOME/.codex-oauth-auth.json`
202
+ - `$DSH_HOME/.kimi-code-oauth-auth.json`
203
+ - `$DSH_HOME/.claude-code-oauth-auth.json`
204
+
205
+ Los cachés de selección viven en los archivos `*-models.json` correspondientes. **Ningún estado HTTP, log o interfaz puede devolver un token.**
206
+
207
+ ## Arquitectura
208
+
209
+ ```mermaid
210
+ flowchart LR
211
+ subgraph DSH["DSH Harness"]
212
+ UI[Configuración / Web · Coding OAuth] --> LLM[llm route]
213
+ LLM --> ALIA[Adaptador de alias de ruta]
214
+ end
215
+ ALIA --> PI[proveedor nativo pi-ai<br/>OAuth · refresh · stream]
216
+ PI --> GROK[Grok Build]
217
+ PI --> COD[Codex]
218
+ PI --> KIMI[Kimi]
219
+ PI --> CLAU[Claude]
220
+ AGY[plugin dsh-agy] --> GAL[Google Antigravity]
221
+ ```
222
+
223
+ ## Notas técnicas
224
+
225
+ - **Grok Build**: proveedor Responses personalizado en `cli-chat-proxy.grok.com/v1`, encabezados de huella del CLI, catálogo dinámico de modelos.
226
+ - **Codex/Kimi/Claude**: los proveedores nativos de pi-ai manejan OAuth y refresh; el adaptador de alias de ruta los mapea a los ids nativos mientras la identidad del modelo permanece igual.
227
+ - El access token de Kimi se convierte explícitamente a `Authorization: Bearer` — nunca se envía por error como `x-api-key` de Anthropic.
228
+ - Google Antigravity **no** tiene ingeniería inversa aquí; usa un plugin DSH dedicado con versión fija.
229
+
230
+ ## Cumplimiento
231
+
232
+ Usar suscripciones de codificación a través de un harness de terceros puede estar en una zona gris de los términos de cada proveedor y puede desencadenar controles de cuota, regionales o de riesgo de cuenta. **Usa solo tus propias cuentas**; este proyecto no admite cuentas masivas, reventa de cuota, relay remoto, evasión de paywall ni suplantación de cliente. Para uso comercial, prefiere los canales oficiales de clave API de los proveedores.
233
+
234
+ ## Documentación
235
+
236
+ | Documento | Propósito |
237
+ |---|---|
238
+ | [`INSTALL.md`](INSTALL.md) | Detalles de instalación y uso |
239
+ | [`CHANGELOG.md`](CHANGELOG.md) | Historial de versiones |
240
+ | [`docs/00-project-rules.md`](docs/00-project-rules.md) | Versionado, bucle de release, división público/privado |
241
+ | [`docs/02-architecture.md`](docs/02-architecture.md) | Arquitectura interna (rutas, flujo de datos, módulos, API) · [中文](docs/02-architecture.zh-CN.md) |
242
+ | [`CONTRIBUTING.md`](CONTRIBUTING.md) | Guía de contribución |
243
+
244
+ ## Relacionados
245
+
246
+ - [`dsh-agy`](https://www.npmjs.com/package/dsh-agy) — plugin separado fijo para Google Antigravity.
247
+
248
+ ## Contribución
249
+
250
+ Contribuciones de todo tipo son bienvenidas — funciones, documentación, traducciones, informes de errores. Consulta **[CONTRIBUTING](CONTRIBUTING.md)** para el flujo, convenciones de commits y el bucle de release. Si tu idioma no aparece en la lista, envía un PR con la traducción del README y lo añadiremos a la tabla anterior.
251
+
252
+ ## Licencia
253
+
254
+ [Apache-2.0](LICENSE) · consulta [NOTICE](NOTICE). Partes derivadas del proyecto [dsh-xai](https://github.com/MirDie/dsh-xai) (Apache-2.0).