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
@@ -0,0 +1,128 @@
1
+ # 02 · 架构设计
2
+
3
+ ## 1. 路由与原生 provider
4
+
5
+ ```text
6
+ Harness route pi-ai provider 请求认证
7
+ ────────────────────────────────────────────────────────────
8
+ grok-build grok-build xAI access token + Grok CLI headers
9
+ codex-oauth openai-codex OAuth token → apiKey override
10
+ kimi-code-oauth kimi-coding OAuth token → Authorization: Bearer
11
+ claude-code-oauth anthropic sk-ant-oat token → Claude Code headers
12
+ agy dsh-agy external dsh-agy 自有账号池
13
+ ```
14
+
15
+ 外部 route 和 pi-ai 原生 id 由 `AliasLlmAdapter` 分隔。`PiAiAdapter` 始终看到原生 provider id,因此 Codex 工具调用、Claude compatibility 判断和 Kimi Anthropic transport 不因 route 改名而失效。
16
+
17
+ 模型发现里的“已认证”定义为存在可读、结构有效且可刷新的 OAuth credential;不会在每次打开选择器时向上游做在线探测。已被上游撤销但本地仍有效的 credential 会在 token refresh 或推理时被识别,避免目录加载产生额外网络请求。
18
+
19
+ ## 2. 主机数据流
20
+
21
+ ```text
22
+ Settings / CLI
23
+
24
+ ├─ GrokBuildWebAuth ── Grok custom PKCE/device
25
+ │ └─ .grok-build-auth.json
26
+
27
+ ├─ SubscriptionWebAuth ── pi-ai OAuth login/refresh
28
+ │ ├─ Codex ── .codex-oauth-auth.json
29
+ │ ├─ Kimi ── .kimi-code-oauth-auth.json
30
+ │ └─ Claude ── .claude-code-oauth-auth.json
31
+
32
+ └─ OAuthImportSession ── 白名单 CLI 只读发现
33
+ └─ 显式单向拉取(预览票据 → 目标 store)
34
+ 从不写入官方 CLI 文件
35
+
36
+ OAuthProviderSession.resolveAccessToken()
37
+ └─ Models.getAuth(native id) # refresh-under-lock
38
+ └─ OAuthCredentialFileStore # 0600 + atomic write + cross-process lock
39
+
40
+ CapabilitySettingsController(默认关闭,applies: live)
41
+ └─ CapabilityRuntimeState
42
+ ├─ Codex 搜索 / 用量 / gpt-image-2 图像
43
+ ├─ codex-oauth-fast(仅在最新 priority catalog 之后)
44
+ └─ Grok Imagine(api.x.ai + DSH 凭据 XAI_API_KEY)
45
+
46
+ ctx.llm route
47
+ └─ AliasLlmAdapter
48
+ └─ PiAiAdapter
49
+ └─ native pi-ai Provider.streamSimple()
50
+ ```
51
+
52
+ ## 3. 模块职责
53
+
54
+ - `store.ts`:一个文件只拥有一个 provider credential;保留旧 Grok store API;`invalidate()` 在上游 AUTH 拒绝后把 `expires` 回写到过去。
55
+ - `oauth-providers.ts`:Codex/Kimi/Claude 定义、route metadata、请求 token bridge。
56
+ - `oauth-session.ts`:登录、刷新、静态模型目录和模型选择缓存。
57
+ - `oauth-sources.ts`:白名单官方 Grok/Codex/Kimi/Claude CLI 发现;加固的 lstat/`O_NOFOLLOW`/属主/权限/普通文件/大小读取;一次性预览票据(五分钟、最多 32 张);从不写入官方 CLI 文件。
58
+ - `oauth-import-routes.ts`:同源拉取 HTTP API(发现 → 预览 → 提交/取消),写入发生在目标 store 锁内。
59
+ - `alias-adapter.ts`:转换 Harness route、不修改 pi-ai model.provider,并在 `listModels()` 前执行 credential gate;未认证或凭据读取失败返回空目录,provider group 名使用 `(OAuth)`。AUTH finish 时作废本地令牌,让 harness 重试先刷新。
60
+ - `adapter.ts`:组合 Grok 与三个 subscription profile;向 pi-ai 要求至少 60 秒剩余有效期,并注册包含 AUTH 与瞬时故障码的 retryPolicy。可选包装 `codex-oauth-fast`,显示为 **已请求 Fast**。
61
+ - `auth-routes.ts`:旧 Grok API + 新统一 `/plugins/dsh-grok-build/oauth/*`;JSON 写请求使用 64 KiB 有界读取器,无效/超限 body 分别返回 400/413。
62
+ - `capability-settings.ts`:默认关闭、立即生效的开关与限制(搜索 1–20、图像 1–4、产物 TTL 1 小时–7 天)。
63
+ - `capability-routes.ts`:无密钥的能力快照,以及可选的 Codex 用量和 Imagine 凭据状态路由。
64
+ - `capability-runtime.ts`:按 live 开关绑定/解绑搜索、工具,以及仅在最新 priority catalog 后发布 Fast 路由。
65
+ - `capability-tools.ts`:可选 Codex / Grok Imagine 工具定义;执行时重新读取开关。
66
+ - `codex-http.ts`:需打开的私有 `chatgpt.com/backend-api` 客户端(仅 HTTPS、仅第一方主机)。
67
+ - `codex-search.ts` / `codex-usage.ts` / `codex-images.ts`:可选搜索、配额,以及固定 `gpt-image-2` 生成/编辑(编辑要求当前会话顶层附件所有权)。
68
+ - `codex-model-capabilities.ts`:live Codex service-tier 缓存;Fast 资格失败关闭;注入 `service_tier: priority` 与路由提示。
69
+ - `grok-imagine.ts`:官方 `api.x.ai` Imagine 客户端(`grok-imagine-image-2.0` / `grok-imagine-video-1.5`);`XAI_API_KEY` 只通过 DSH 凭据;MIME/大小/超时/重定向/DNS 下载控制;冻结主机 `imgen.x.ai`、`videogen.x.ai`、`vidgen.x.ai`。
70
+ - `imagine-routes.ts`:生成图像与视频产物的同源 loopback GET 路由。
71
+ - `media-store.ts`:属主私有产物库(单件与唯一对象总量均硬限 256 MiB,最长七天)。
72
+ - `client/`:四个原生账号卡片、CLI 拉取、能力开关、网关控制,以及外部 Antigravity 状态卡片。
73
+ - `proxy.ts`:process-wide undici dispatcher,但只代理审核过的域名白名单。
74
+ - `gateway*.ts`:可选的隔离 loopback OpenAI/Anthropic 兼容 HTTP 服务(默认关;独立于 DSH web 端口)。
75
+
76
+ ## 4. Web API
77
+
78
+ 统一接口:
79
+
80
+ ```text
81
+ GET /plugins/dsh-grok-build/oauth/status
82
+ POST /plugins/dsh-grok-build/oauth/login
83
+ POST /plugins/dsh-grok-build/oauth/code
84
+ POST /plugins/dsh-grok-build/oauth/cancel
85
+ POST /plugins/dsh-grok-build/oauth/logout
86
+ POST /plugins/dsh-grok-build/oauth/models
87
+
88
+ GET /plugins/dsh-grok-build/oauth/sources
89
+ POST /plugins/dsh-grok-build/oauth/sources/preview
90
+ POST /plugins/dsh-grok-build/oauth/sources/commit
91
+ POST /plugins/dsh-grok-build/oauth/sources/cancel
92
+
93
+ GET /plugins/dsh-grok-build/capabilities
94
+ PATCH /plugins/dsh-grok-build/capabilities
95
+ PUT /plugins/dsh-grok-build/capabilities
96
+ GET /plugins/dsh-grok-build/codex/usage
97
+ GET /plugins/dsh-grok-build/imagine/credential-status
98
+ GET /plugins/dsh-grok-build/imagine/images/<id>
99
+ GET /plugins/dsh-grok-build/imagine/media/<id>
100
+ GET /plugins/dsh-grok-build/gateway
101
+ PATCH /plugins/dsh-grok-build/gateway
102
+ POST /plugins/dsh-grok-build/gateway/rotate
103
+ ```
104
+
105
+ 写接口请求体带 `provider: grok|codex|kimi|claude`。响应只包含状态、授权 URL、device user code、模型 id 和非敏感 expiry;绝不包含 access/refresh token。JSON 请求体在解析前限制为 64 KiB。
106
+
107
+ `/oauth/sources` 是只读发现。预览/提交是显式单向拉取(票据一次性、五分钟、最多 32 张)。能力写入位于 `coding-subscription-oauth` 设置区,是无密钥的 compare-and-swap 快照并立即生效。七项开关默认关闭;`searchResults` 为 1–20(默认 5),`imageCount` 为 1–4(默认 1),`videoArtifactTtlMs` 为 1 小时–7 天(默认 7 天;界面显示 1–168 小时);降低时立即改写/清理已有 expiry,提高只影响新产物。Imagine 下载路由是同源 loopback GET,从不返回上游签名 URL。
108
+
109
+ 旧 `/plugins/dsh-grok-build/auth/*` 继续注册并复用同一个 Grok 控制器。
110
+
111
+ ## 5. Antigravity
112
+
113
+ 本项目不复制 Google Antigravity 私有协议。profile 单独安装 `dsh-agy@0.1.2`,提供 `agy` route。由于该版本的 `/agy` dashboard 含无自身认证的 export API,trusted-host 部署应在 profile 最终 `cordis.patch.yml` 中禁用 `dsh-agy-web`(见 `INSTALL.md`),只保留 host adapter 和 CLI。profile 使用带 lockfile hash 的 pnpm patch:无 Google session 时 `listModels()` 返回空,认证后 provider group 名为 `Google Antigravity (OAuth)`。
114
+
115
+ ## 6. 兼容性
116
+
117
+ 正式包名与仓库名是 **`dsh-coding-subscription-oauth`**。旧 GitHub 地址仍指向同一条 `main`,因此旧的 `dsh plugin add github:lninghaha/dsh-grok-build` 仍会安装更名后的包。第一次公开 npm / GitHub Release 是 **`0.4.1`**。当前版本是 **`0.5.0`**(`dsh plugin --profile web add dsh-coding-subscription-oauth@0.5.0`)。GitHub 与本地 tarball 安装仍然有效。
118
+
119
+ 以下标识保持稳定(无迁移方案前不要改名):
120
+
121
+ - Cordis id:`llm-grok-build-oauth`
122
+ - 设置页 HTTP API:`/plugins/dsh-grok-build/oauth/*`、`/plugins/dsh-grok-build/capabilities`、`/plugins/dsh-grok-build/codex/usage`、`/plugins/dsh-grok-build/imagine/*`,以及旧的 `/plugins/dsh-grok-build/auth/*`
123
+ - 凭据文件:`$DSH_HOME/.grok-build-auth.json` 及其他 `*-oauth-auth.json`
124
+ - Imagine 凭据:DSH 凭据引用 `XAI_API_KEY`(不用 Grok OAuth,不回退进程环境变量)
125
+ - CLI:`dsh-coding-oauth`(主命令)与 `dsh-grok-build`(别名)
126
+ - LLM 路由:`grok-build`、`codex-oauth`、`kimi-code-oauth`、`claude-code-oauth`;可选 `codex-oauth-fast`(v0.4.0,仅在最新 live catalog 列出 `priority` 后发布)
127
+
128
+ 新 route 使用 `*-oauth` alias,不占用 `openai`、`xai`、`kimi-coding`。v0.3.0 将 `grok-build` fallback/default 更新为 `grok-4.6`,已有用户默认设置仍优先。
@@ -0,0 +1,24 @@
1
+ /** Coding-subscription adapter assembled from public dsh-llm-pi-ai extension points. */
2
+ import type { AttachmentStore } from "@deepseek-ai/dsh-attachment";
3
+ import type { RetryPolicyConfig } from "@deepseek-ai/dsh-llm";
4
+ import { type LlmAdapter } from "@deepseek-ai/dsh-llm";
5
+ import { PiAiAdapter } from "@deepseek-ai/dsh-llm-pi-ai";
6
+ import type { OAuthProviderSession } from "./oauth-session.js";
7
+ import type { GrokBuildSession } from "./session.js";
8
+ /** Prefer grok-4.6 when the current (live or baseline) list has it. */
9
+ export declare function preferredGrokBuildModel(models?: readonly {
10
+ id: string;
11
+ }[]): string;
12
+ /** Existing Grok-only constructor retained for public API compatibility. */
13
+ export declare function createGrokBuildAdapter(session: GrokBuildSession, resolveAttachments: () => AttachmentStore | undefined): PiAiAdapter;
14
+ /** Opt-in Codex Fast wiring; ordinary `codex-oauth` is unchanged when this is omitted. */
15
+ export interface CodingOAuthAdapterOptions {
16
+ retryPolicy?: RetryPolicyConfig;
17
+ codexFast?: {
18
+ isEligible(modelId: string): boolean;
19
+ };
20
+ }
21
+ /** Create the four-route OAuth adapter while preserving each pi-ai native id. */
22
+ export declare function createCodingOAuthAdapter(grok: GrokBuildSession, subscriptions: readonly OAuthProviderSession[], resolveAttachments: () => AttachmentStore | undefined, retryPolicy?: RetryPolicyConfig, options?: CodingOAuthAdapterOptions): LlmAdapter;
23
+ export declare function createCodingOAuthAdapter(grok: GrokBuildSession, subscriptions: readonly OAuthProviderSession[], resolveAttachments: () => AttachmentStore | undefined, options?: CodingOAuthAdapterOptions): LlmAdapter;
24
+ //# sourceMappingURL=adapter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../../src/adapter.ts"],"names":[],"mappings":"AAAA,wFAAwF;AAExF,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AACnE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAC9D,OAAO,EAAE,KAAK,UAAU,EAAgC,MAAM,sBAAsB,CAAC;AAErF,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAkBzD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAG/D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAErD,uEAAuE;AACvE,wBAAgB,uBAAuB,CAAC,MAAM,GAAE,SAAS;IAAE,EAAE,EAAE,MAAM,CAAA;CAAE,EAA8B,GAAG,MAAM,CAE7G;AAyDD,4EAA4E;AAC5E,wBAAgB,sBAAsB,CACrC,OAAO,EAAE,gBAAgB,EACzB,kBAAkB,EAAE,MAAM,eAAe,GAAG,SAAS,GACnD,WAAW,CAgBb;AAED,0FAA0F;AAC1F,MAAM,WAAW,yBAAyB;IACzC,WAAW,CAAC,EAAE,iBAAiB,CAAC;IAChC,SAAS,CAAC,EAAE;QAAE,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAA;KAAE,CAAC;CACrD;AAwBD,iFAAiF;AACjF,wBAAgB,wBAAwB,CACvC,IAAI,EAAE,gBAAgB,EACtB,aAAa,EAAE,SAAS,oBAAoB,EAAE,EAC9C,kBAAkB,EAAE,MAAM,eAAe,GAAG,SAAS,EACrD,WAAW,CAAC,EAAE,iBAAiB,EAC/B,OAAO,CAAC,EAAE,yBAAyB,GACjC,UAAU,CAAC;AACd,wBAAgB,wBAAwB,CACvC,IAAI,EAAE,gBAAgB,EACtB,aAAa,EAAE,SAAS,oBAAoB,EAAE,EAC9C,kBAAkB,EAAE,MAAM,eAAe,GAAG,SAAS,EACrD,OAAO,CAAC,EAAE,yBAAyB,GACjC,UAAU,CAAC"}
@@ -0,0 +1,43 @@
1
+ /**
2
+ * Harness route aliases over a native-id PiAiAdapter.
3
+ * @module dsh-coding-subscription-oauth/alias-adapter
4
+ */
5
+ import type { GenerateOptions, LlmModelInfo, LlmProviderInfo, LlmResolvedModelInfo, ResolvedRetryPolicy, StreamChunk } from "@deepseek-ai/dsh-llm";
6
+ import { LlmAdapter } from "@deepseek-ai/dsh-llm";
7
+ export interface AliasLlmRoutePolicy {
8
+ /** User-facing provider name shown above models in the model selector. */
9
+ displayName?: string;
10
+ /** Return false to hide every model for this route from discovery. */
11
+ isAuthenticated?: () => Promise<boolean>;
12
+ /**
13
+ * After authentication, keep only models this predicate accepts.
14
+ * Used by opt-in routes (e.g. Codex Fast) so ineligible ids stay hidden
15
+ * without hiding the whole authenticated catalog.
16
+ */
17
+ includeModel?: (modelId: string) => boolean;
18
+ /**
19
+ * Called once when a stream for this route finishes with an AUTH failure
20
+ * (upstream rejected a locally-valid token). Implementations backdate the
21
+ * stored credential's expiry so the retried step refreshes before reuse.
22
+ * Awaiting it here keeps invalidation ordered before the retry executor
23
+ * reruns the step; failures are swallowed so the original AUTH surfaces.
24
+ */
25
+ onAuthFailure?: () => Promise<void>;
26
+ }
27
+ /**
28
+ * Keeps pi-ai model.provider identities native while exposing collision-free
29
+ * Harness route names. Every public operation translates exactly once.
30
+ */
31
+ export declare class AliasLlmAdapter extends LlmAdapter {
32
+ private readonly inner;
33
+ private readonly aliases;
34
+ private readonly policies;
35
+ constructor(inner: LlmAdapter, aliases: ReadonlyMap<string, string>, policies?: ReadonlyMap<string, AliasLlmRoutePolicy>);
36
+ private nativeProvider;
37
+ providerInfo(provider: string): LlmProviderInfo;
38
+ providerRetryPolicy(provider: string): ResolvedRetryPolicy | undefined;
39
+ listModels(provider: string): Promise<readonly LlmModelInfo[]>;
40
+ resolveModel(provider: string, model: string, signal?: AbortSignal): Promise<LlmResolvedModelInfo>;
41
+ stream(options: GenerateOptions): AsyncIterable<StreamChunk>;
42
+ }
43
+ //# sourceMappingURL=alias-adapter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"alias-adapter.d.ts","sourceRoot":"","sources":["../../src/alias-adapter.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EACX,eAAe,EACf,YAAY,EACZ,eAAe,EACf,oBAAoB,EACpB,mBAAmB,EACnB,WAAW,EACX,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,UAAU,EAAY,MAAM,sBAAsB,CAAC;AAG5D,MAAM,WAAW,mBAAmB;IACnC,0EAA0E;IAC1E,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,sEAAsE;IACtE,eAAe,CAAC,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC,CAAC;IACzC;;;;OAIG;IACH,YAAY,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,OAAO,CAAC;IAC5C;;;;;;OAMG;IACH,aAAa,CAAC,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CACpC;AAwBD;;;GAGG;AACH,qBAAa,eAAgB,SAAQ,UAAU;IAE7C,OAAO,CAAC,QAAQ,CAAC,KAAK;IACtB,OAAO,CAAC,QAAQ,CAAC,OAAO;IACxB,OAAO,CAAC,QAAQ,CAAC,QAAQ;gBAFR,KAAK,EAAE,UAAU,EACjB,OAAO,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,EACpC,QAAQ,GAAE,WAAW,CAAC,MAAM,EAAE,mBAAmB,CAAa;IAKhF,OAAO,CAAC,cAAc;IAMtB,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,eAAe;IAO/C,mBAAmB,CAAC,QAAQ,EAAE,MAAM,GAAG,mBAAmB,GAAG,SAAS;IAIhE,UAAU,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,YAAY,EAAE,CAAC;IAiB9D,YAAY,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,oBAAoB,CAAC;IAKjG,MAAM,CAAC,OAAO,EAAE,eAAe,GAAG,aAAa,CAAC,WAAW,CAAC;CAwCnE"}
@@ -0,0 +1,155 @@
1
+ /** Same-origin Web settings routes for Grok Build OAuth. */
2
+ import type { Context } from "@deepseek-ai/cordis";
3
+ import type { CatalogSource } from "./catalog.js";
4
+ import { ANTIGRAVITY_ROUTE, type CodingOAuthProviderSlug } from "./ids.js";
5
+ import type { SubscriptionLoginMethod } from "./oauth-providers.js";
6
+ import type { OAuthProviderSession } from "./oauth-session.js";
7
+ import type { GrokBuildSession } from "./session.js";
8
+ export declare const GROK_BUILD_AUTH_STATUS_PATH = "/plugins/dsh-grok-build/auth/status";
9
+ export declare const GROK_BUILD_AUTH_LOGIN_PATH = "/plugins/dsh-grok-build/auth/login";
10
+ export declare const GROK_BUILD_AUTH_LOGIN_CODE_PATH = "/plugins/dsh-grok-build/auth/login/code";
11
+ export declare const GROK_BUILD_AUTH_LOGIN_CANCEL_PATH = "/plugins/dsh-grok-build/auth/login/cancel";
12
+ export declare const GROK_BUILD_AUTH_IMPORT_PATH = "/plugins/dsh-grok-build/auth/import";
13
+ export declare const GROK_BUILD_AUTH_LOGOUT_PATH = "/plugins/dsh-grok-build/auth/logout";
14
+ export declare const GROK_BUILD_AUTH_MODELS_PATH = "/plugins/dsh-grok-build/auth/models";
15
+ export declare const CODING_OAUTH_STATUS_PATH = "/plugins/dsh-grok-build/oauth/status";
16
+ export declare const CODING_OAUTH_LOGIN_PATH = "/plugins/dsh-grok-build/oauth/login";
17
+ export declare const CODING_OAUTH_LOGIN_CODE_PATH = "/plugins/dsh-grok-build/oauth/code";
18
+ export declare const CODING_OAUTH_LOGIN_CANCEL_PATH = "/plugins/dsh-grok-build/oauth/cancel";
19
+ export declare const CODING_OAUTH_LOGOUT_PATH = "/plugins/dsh-grok-build/oauth/logout";
20
+ export declare const CODING_OAUTH_MODELS_PATH = "/plugins/dsh-grok-build/oauth/models";
21
+ export type GrokBuildLoginMethod = "pkce" | "device";
22
+ export type GrokBuildWebAuthStatus = {
23
+ status: "signed-out";
24
+ grokImportAvailable: boolean;
25
+ } | {
26
+ status: "signing-in";
27
+ method: GrokBuildLoginMethod;
28
+ url?: string;
29
+ userCode?: string;
30
+ grokImportAvailable: boolean;
31
+ } | {
32
+ status: "signed-in";
33
+ models: string[];
34
+ available: string[];
35
+ selected: string[];
36
+ catalogSource: CatalogSource;
37
+ catalogError?: string;
38
+ grokImportAvailable: boolean;
39
+ } | {
40
+ status: "error";
41
+ message: string;
42
+ grokImportAvailable: boolean;
43
+ };
44
+ export interface LoginChallenge {
45
+ method: GrokBuildLoginMethod;
46
+ url: string;
47
+ userCode?: string;
48
+ }
49
+ /**
50
+ * One lifecycle owner for the pending login (PKCE or device), the published
51
+ * challenge, the pasted-code channel, and the public status.
52
+ */
53
+ export declare class GrokBuildWebAuth {
54
+ private readonly session;
55
+ private state;
56
+ private operation;
57
+ private cancellation;
58
+ private method;
59
+ private challenge;
60
+ private challengeWaiters;
61
+ private codeResolver;
62
+ constructor(session: GrokBuildSession);
63
+ status(): Promise<GrokBuildWebAuthStatus>;
64
+ /** Start (or join) a login. A different method aborts and restarts the flow. */
65
+ signIn(method: GrokBuildLoginMethod): Promise<LoginChallenge>;
66
+ /** Hand a pasted authorization code (or redirect URL) to a pending PKCE login. */
67
+ submitCode(code: string): Promise<void>;
68
+ /** Abort a pending login without touching any stored credential. */
69
+ cancel(): Promise<void>;
70
+ importGrok(): Promise<void>;
71
+ setModels(ids: readonly string[]): Promise<void>;
72
+ signOut(): Promise<void>;
73
+ dispose(): Promise<void>;
74
+ private start;
75
+ private runPkce;
76
+ private runDevice;
77
+ private onEvent;
78
+ private acceptChallenge;
79
+ private readStoredStatus;
80
+ private rejectChallenge;
81
+ }
82
+ export type SubscriptionWebAuthStatus = {
83
+ provider: Exclude<CodingOAuthProviderSlug, "grok">;
84
+ route: string;
85
+ displayName: string;
86
+ loginMethods: readonly SubscriptionLoginMethod[];
87
+ recommendedLoginMethod: SubscriptionLoginMethod;
88
+ models: string[];
89
+ available: string[];
90
+ selected: string[];
91
+ } & ({
92
+ status: "signed-out";
93
+ } | {
94
+ status: "signing-in";
95
+ method: SubscriptionLoginMethod;
96
+ url?: string;
97
+ userCode?: string;
98
+ } | {
99
+ status: "signed-in";
100
+ expiresAt?: number;
101
+ } | {
102
+ status: "error";
103
+ message: string;
104
+ });
105
+ export interface SubscriptionLoginChallenge {
106
+ method: SubscriptionLoginMethod;
107
+ url: string;
108
+ userCode?: string;
109
+ }
110
+ /** Web lifecycle for one pi-ai subscription OAuth provider. */
111
+ export declare class SubscriptionWebAuth {
112
+ readonly session: OAuthProviderSession;
113
+ private readonly challengeTimeoutMs;
114
+ private state;
115
+ private operation;
116
+ private cancellation;
117
+ private method;
118
+ private challenge;
119
+ private challengeWaiters;
120
+ private codeResolver;
121
+ constructor(session: OAuthProviderSession, challengeTimeoutMs?: number);
122
+ status(): Promise<SubscriptionWebAuthStatus>;
123
+ signIn(method: SubscriptionLoginMethod): Promise<SubscriptionLoginChallenge>;
124
+ submitCode(code: string): Promise<void>;
125
+ cancel(): Promise<void>;
126
+ setModels(ids: readonly string[]): Promise<void>;
127
+ signOut(): Promise<void>;
128
+ dispose(): Promise<void>;
129
+ private baseStatus;
130
+ private readStoredStatus;
131
+ private start;
132
+ private run;
133
+ private awaitCode;
134
+ private onEvent;
135
+ private acceptChallenge;
136
+ private rejectChallenge;
137
+ }
138
+ /** Register the plugin-owned OAuth routes when the Web server is composed. */
139
+ export declare function registerGrokBuildAuthRoutes(ctx: Context, session: GrokBuildSession, existingAuth?: GrokBuildWebAuth): void;
140
+ export interface CodingOAuthWebStatus {
141
+ providers: {
142
+ grok: GrokBuildWebAuthStatus;
143
+ codex: SubscriptionWebAuthStatus;
144
+ kimi: SubscriptionWebAuthStatus;
145
+ claude: SubscriptionWebAuthStatus;
146
+ };
147
+ antigravity: {
148
+ installed: boolean;
149
+ route: typeof ANTIGRAVITY_ROUTE;
150
+ management: "cli";
151
+ };
152
+ }
153
+ /** Register the unified Coding OAuth API plus the compatibility Grok routes. */
154
+ export declare function registerCodingOAuthRoutes(ctx: Context, grokSession: GrokBuildSession, subscriptionSessions: readonly OAuthProviderSession[]): void;
155
+ //# sourceMappingURL=auth-routes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auth-routes.d.ts","sourceRoot":"","sources":["../../src/auth-routes.ts"],"names":[],"mappings":"AAAA,4DAA4D;AAG5D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAKnD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAGlD,OAAO,EAAE,iBAAiB,EAAE,KAAK,uBAAuB,EAAmB,MAAM,UAAU,CAAC;AAE5F,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AACpE,OAAO,KAAK,EAAE,oBAA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ared by the plugin and standalone CLI.
3
+ * @module dsh-coding-subscription-oauth/auth
4
+ */
5
+ import type { AuthInteraction } from "@earendil-works/pi-ai";
6
+ import type { GrokBuildSession } from "./session.js";
7
+ import { GrokBuildCredentialStore } from "./store.js";
8
+ /** Non-secret login state shown by the launcher. */
9
+ export interface GrokBuildAuthStatus {
10
+ authenticated: boolean;
11
+ expiresAt?: Date;
12
+ }
13
+ /**
14
+ * Complete the xAI device-code OAuth flow and persist the credential.
15
+ * The Grok Build backend accepts the same auth.x.ai tokens (scope
16
+ * `grok-cli:access`); the PKCE authorization-code flow lands in a later
17
+ * milestone as the primary path.
18
+ */
19
+ export declare function loginGrokBuild(interaction: AuthInteraction, store?: GrokBuildCredentialStore): Promise<void>;
20
+ /** Copy ~/.grok/auth.json into the dsh store. Does not modify the Grok file. */
21
+ export declare function importGrokBuildFromGrok(store?: GrokBuildCredentialStore, filename?: string): Promise<void>;
22
+ /** Remove the stored Grok Build credential. */
23
+ export declare function logoutGrokBuild(store?: GrokBuildCredentialStore): Promise<void>;
24
+ /** Read non-secret login state without refreshing the token. */
25
+ export declare function grokBuildAuthStatus(store?: GrokBuildCredentialStore): Promise<GrokBuildAuthStatus>;
26
+ /** Login then refresh the account model list when a session is available. */
27
+ export declare function loginGrokBuildSession(interaction: AuthInteraction, session: GrokBuildSession): Promise<void>;
28
+ export declare function importGrokBuildSession(session: GrokBuildSession, filename?: string): Promise<void>;
29
+ //# sourceMappingURL=auth.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../src/auth.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAK7D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AACrD,OAAO,EAAE,wBAAwB,EAAE,MAAM,YAAY,CAAC;AAEtD,oDAAoD;AACpD,MAAM,WAAW,mBAAmB;IACnC,aAAa,EAAE,OAAO,CAAC;IACvB,SAAS,CAAC,EAAE,IAAI,CAAC;CACjB;AAED;;;;;GAKG;AACH,wBAAsB,cAAc,CACnC,WAAW,EAAE,eAAe,EAC5B,KAAK,GAAE,wBAAyD,GAC9D,OAAO,CAAC,IAAI,CAAC,CAIf;AAED,gFAAgF;AAChF,wBAAsB,uBAAuB,CAC5C,KAAK,GAAE,wBAAyD,EAChE,QAAQ,CAAC,EAAE,MAAM,GACf,OAAO,CAAC,IAAI,CAAC,CAEf;AAED,+CAA+C;AAC/C,wBAAsB,eAAe,CAAC,KAAK,GAAE,wBAAyD,GAAG,OAAO,CAAC,IAAI,CAAC,CAErH;AAED,gEAAgE;AAChE,wBAAsB,mBAAmB,CACxC,KAAK,GAAE,wBAAyD,GAC9D,OAAO,CAAC,mBAAmB,CAAC,CAK9B;AAED,6EAA6E;AAC7E,wBAAsB,qBAAqB,CAAC,WAAW,EAAE,eAAe,EAAE,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,IAAI,CAAC,CAGlH;AAED,wBAAsB,sBAAsB,CAAC,OAAO,EAAE,gBAAgB,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAGxG"}
package/lib/bin.d.ts ADDED
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env node
2
+ /** Standalone credential CLI for the coding-subscription bundle. */
3
+ export type CliAction = "login" | "logout" | "status" | "import";
4
+ export type CliProvider = "all" | "grok" | "codex" | "kimi" | "claude";
5
+ export declare function run(argv: readonly string[]): Promise<number>;
6
+ //# sourceMappingURL=bin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bin.d.ts","sourceRoot":"","sources":["../../src/bin.ts"],"names":[],"mappings":";AACA,oEAAoE;AAoBpE,MAAM,MAAM,SAAS,GAAG,OAAO,GAAG,QAAQ,GAAG,QAAQ,GAAG,QAAQ,CAAC;AACjE,MAAM,MAAM,WAAW,GAAG,KAAK,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,GAAG,QAAQ,CAAC;AAqPvE,wBAAsB,GAAG,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,CA8ElE"}