@eddyskywalker/dsh-chatgpt-subscription 0.21.0 → 0.23.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 (85) hide show
  1. package/CHANGELOG.md +46 -0
  2. package/README.md +56 -3
  3. package/lib/client.js +2719 -491
  4. package/lib/client.js.map +1 -1
  5. package/lib/index.js +8041 -3092
  6. package/lib/types/client/glm-coding-plan/GlmCodingPlanSection.d.ts.map +1 -1
  7. package/lib/types/client/glm-coding-plan/locales.d.ts +17 -26
  8. package/lib/types/client/glm-coding-plan/locales.d.ts.map +1 -1
  9. package/lib/types/client/glm-coding-plan/styles.d.ts +2 -2
  10. package/lib/types/client/glm-coding-plan/styles.d.ts.map +1 -1
  11. package/lib/types/client/hub/brand-icons.d.ts +2 -2
  12. package/lib/types/client/hub/brand-icons.d.ts.map +1 -1
  13. package/lib/types/client/hub/providers.d.ts.map +1 -1
  14. package/lib/types/client/index.d.ts +2 -0
  15. package/lib/types/client/index.d.ts.map +1 -1
  16. package/lib/types/client/ollama/OllamaSection.d.ts.map +1 -1
  17. package/lib/types/client/ollama/api.d.ts +13 -0
  18. package/lib/types/client/ollama/api.d.ts.map +1 -1
  19. package/lib/types/client/ollama/locales.d.ts +24 -0
  20. package/lib/types/client/ollama/locales.d.ts.map +1 -1
  21. package/lib/types/client/step-code/StepCodeComposerQuota.d.ts +52 -0
  22. package/lib/types/client/step-code/StepCodeComposerQuota.d.ts.map +1 -0
  23. package/lib/types/client/step-code/StepCodeSection.d.ts +28 -0
  24. package/lib/types/client/step-code/StepCodeSection.d.ts.map +1 -0
  25. package/lib/types/client/step-code/api.d.ts +4 -0
  26. package/lib/types/client/step-code/api.d.ts.map +1 -0
  27. package/lib/types/client/step-code/locales.d.ts +648 -0
  28. package/lib/types/client/step-code/locales.d.ts.map +1 -0
  29. package/lib/types/client/step-code/styles.d.ts +28 -0
  30. package/lib/types/client/step-code/styles.d.ts.map +1 -0
  31. package/lib/types/client/step-code/useStepCodeSection.d.ts +122 -0
  32. package/lib/types/client/step-code/useStepCodeSection.d.ts.map +1 -0
  33. package/lib/types/host/antigravity/account-pool.d.ts.map +1 -1
  34. package/lib/types/host/common/account-pool.d.ts +38 -3
  35. package/lib/types/host/common/account-pool.d.ts.map +1 -1
  36. package/lib/types/host/common/model-request-control.d.ts +1 -1
  37. package/lib/types/host/common/model-request-control.d.ts.map +1 -1
  38. package/lib/types/host/common/request-diagnostics.d.ts +1 -1
  39. package/lib/types/host/common/request-diagnostics.d.ts.map +1 -1
  40. package/lib/types/host/glm-coding-plan/account-pool.d.ts.map +1 -1
  41. package/lib/types/host/glm-coding-plan/adapter.d.ts +1 -14
  42. package/lib/types/host/glm-coding-plan/adapter.d.ts.map +1 -1
  43. package/lib/types/host/glm-coding-plan/client.d.ts.map +1 -1
  44. package/lib/types/host/glm-coding-plan/types.d.ts +0 -10
  45. package/lib/types/host/glm-coding-plan/types.d.ts.map +1 -1
  46. package/lib/types/host/ollama/adapter.d.ts +26 -2
  47. package/lib/types/host/ollama/adapter.d.ts.map +1 -1
  48. package/lib/types/host/ollama/client.d.ts +16 -1
  49. package/lib/types/host/ollama/client.d.ts.map +1 -1
  50. package/lib/types/host/ollama/routes.d.ts +1 -1
  51. package/lib/types/host/ollama/routes.d.ts.map +1 -1
  52. package/lib/types/host/ollama/types.d.ts +74 -8
  53. package/lib/types/host/ollama/types.d.ts.map +1 -1
  54. package/lib/types/host/step-code/account-pool.d.ts +187 -0
  55. package/lib/types/host/step-code/account-pool.d.ts.map +1 -0
  56. package/lib/types/host/step-code/adapter.d.ts +142 -0
  57. package/lib/types/host/step-code/adapter.d.ts.map +1 -0
  58. package/lib/types/host/step-code/adopt.d.ts +201 -0
  59. package/lib/types/host/step-code/adopt.d.ts.map +1 -0
  60. package/lib/types/host/step-code/cache-stats.d.ts +181 -0
  61. package/lib/types/host/step-code/cache-stats.d.ts.map +1 -0
  62. package/lib/types/host/step-code/client.d.ts +331 -0
  63. package/lib/types/host/step-code/client.d.ts.map +1 -0
  64. package/lib/types/host/step-code/mapper.d.ts +301 -0
  65. package/lib/types/host/step-code/mapper.d.ts.map +1 -0
  66. package/lib/types/host/step-code/model-catalog.d.ts +230 -0
  67. package/lib/types/host/step-code/model-catalog.d.ts.map +1 -0
  68. package/lib/types/host/step-code/oauth.d.ts +265 -0
  69. package/lib/types/host/step-code/oauth.d.ts.map +1 -0
  70. package/lib/types/host/step-code/routes.d.ts +126 -0
  71. package/lib/types/host/step-code/routes.d.ts.map +1 -0
  72. package/lib/types/host/step-code/token-store.d.ts +325 -0
  73. package/lib/types/host/step-code/token-store.d.ts.map +1 -0
  74. package/lib/types/host/step-code/types.d.ts +488 -0
  75. package/lib/types/host/step-code/types.d.ts.map +1 -0
  76. package/lib/types/host/workbuddy/adapter.d.ts.map +1 -1
  77. package/lib/types/index.d.ts +5 -1
  78. package/lib/types/index.d.ts.map +1 -1
  79. package/lib/types/shared/ollama-contracts.d.ts +30 -0
  80. package/lib/types/shared/ollama-contracts.d.ts.map +1 -1
  81. package/lib/types/shared/step-code-contracts.d.ts +438 -0
  82. package/lib/types/shared/step-code-contracts.d.ts.map +1 -0
  83. package/package.json +1 -1
  84. package/lib/types/host/glm-coding-plan/signing.d.ts +0 -323
  85. package/lib/types/host/glm-coding-plan/signing.d.ts.map +0 -1
@@ -35,6 +35,8 @@ export declare const CLOUD_BASE_URL = "https://ollama.com";
35
35
  /** Native surface. */
36
36
  export declare const NATIVE_CHAT_PATH = "/api/chat";
37
37
  export declare const NATIVE_TAGS_PATH = "/api/tags";
38
+ /** Per-model metadata: the one surface where a model states its own thinking levels. */
39
+ export declare const NATIVE_SHOW_PATH = "/api/show";
38
40
  /** OpenAI-compatible surface. */
39
41
  export declare const OPENAI_BASE_URL = "https://ollama.com/v1";
40
42
  export declare const OPENAI_CHAT_PATH = "/chat/completions";
@@ -84,10 +86,11 @@ export declare const FORCED_THINKING_FLOOR_TOKENS = 512;
84
86
  *
85
87
  * @param modelId - the routed model id.
86
88
  * @param requested - the caller's cap, undefined when it stated none.
89
+ * @param declared - the model's own thinking metadata, when it was read.
87
90
  * @returns the cap to request, raised only when that is the difference between an
88
91
  * empty truncated answer and a usable one.
89
92
  */
90
- export declare function floorForcedThinkingTokens(modelId: string, requested: number | undefined): number | undefined;
93
+ export declare function floorForcedThinkingTokens(modelId: string, requested: number | undefined, declared?: OllamaThinkingCapability): number | undefined;
91
94
  /** How long a catalog sync may take before the cached list is used instead. */
92
95
  export declare const CATALOG_TIMEOUT_MS = 15000;
93
96
  /**
@@ -151,21 +154,84 @@ export declare function ollamaHeaders(apiKey: string): Record<string, string>;
151
154
  */
152
155
  export declare function ollamaModelSupportsImage(modelId: string): boolean;
153
156
  export type OllamaThinkingMode = 'levels' | 'boolean' | 'none';
157
+ /**
158
+ * What one model says about its own thinking, as `POST /api/show` reports it.
159
+ *
160
+ * `values` is the complete set the wire accepts: a boolean, meaning on/off, or
161
+ * a level name that model defines itself (gpt-oss declares low/medium/high and
162
+ * cannot be switched off). `[false]` means the model has no thinking to control,
163
+ * and an absent `thinking` means the service states nothing about it. `default`
164
+ * is the value the service uses when a request sends no `think` at all.
165
+ *
166
+ * Source: https://github.com/ollama/ollama/blob/main/docs/capabilities/thinking.mdx
167
+ */
168
+ export interface OllamaThinkingCapability {
169
+ values: readonly (boolean | string)[];
170
+ default?: boolean | string;
171
+ }
172
+ /** One selectable effort, as the picker renders it. */
173
+ export interface OllamaReasoningEffort {
174
+ /** Sent as the caller's `reasoningEffort` and mapped onto the wire from it. */
175
+ id: string;
176
+ name: string;
177
+ }
154
178
  /**
155
179
  * Resolve model-specific thinking support in Ollama.
180
+ *
181
+ * The service's own metadata outranks the prefix list: `/api/show` is where a
182
+ * model states the levels it accepts, and it is the only source there is for a
183
+ * family this file has never heard of. The prefix list stays as the fallback for
184
+ * a model whose metadata could not be read, and that fallback is unchanged.
185
+ *
156
186
  * Source: official https://github.com/ollama/ollama/blob/main/docs/capabilities/thinking.mdx
157
- * - 'levels': gpt-oss family (values low, medium, high; cannot disable thinking)
158
- * - 'boolean': deepseek-r1, qwq, qwen3 families (values true, false)
159
- * - 'none': all other / unknown models (omit thinking control entirely)
187
+ * - 'levels': named levels (gpt-oss: low, medium, high; cannot disable thinking)
188
+ * - 'boolean': booleans (deepseek-r1, qwq, qwen3: true, false)
189
+ * - 'none': declared [false], declared nothing, or unknown
190
+ */
191
+ export declare function thinkingModeForModel(modelId: string, declared?: OllamaThinkingCapability): OllamaThinkingMode;
192
+ /**
193
+ * The efforts one model can actually be sent, in display order.
194
+ *
195
+ * This set is the whole contract with the harness: a level outside it is
196
+ * rejected before a request is built (see `resolveCallWithInfo`), so it must be
197
+ * exactly what the wire accepts and no more - which is why, when the model has
198
+ * declared its own values, this returns that table row for row instead of
199
+ * choosing from a fixed menu. A model that declares `[false]` is the one case
200
+ * with a declared value and no ladder at all: `[false]` is the service saying
201
+ * there is no thinking here to turn on or off.
202
+ *
203
+ * Without metadata the families this file knows answer instead, unchanged:
204
+ * gpt-oss takes the three levels, and a boolean family takes the on/off pair.
205
+ */
206
+ export declare function reasoningEffortsForModel(modelId: string, declared?: OllamaThinkingCapability): OllamaReasoningEffort[];
207
+ /**
208
+ * The effort this model's ladder should start on.
209
+ *
210
+ * A stored default is a per-route preference, not a per-model promise: the
211
+ * settings card offers one ladder for the whole line, so a level chosen for one
212
+ * model can be one this model cannot express - and DSH rejects a level that is
213
+ * not on the ladder before a request is built. So the order is: the configured
214
+ * level when this model has it, then the level the model itself defaults to,
215
+ * then the ladder's own first entry.
216
+ *
217
+ * The last step skips a "thinking off" position. A user who picked a thinking
218
+ * model and was handed that position would silently get a model that never
219
+ * thinks, which is a worse wrong answer than the mildest level that does think.
160
220
  */
161
- export declare function thinkingModeForModel(modelId: string): OllamaThinkingMode;
221
+ export declare function resolveOllamaDefaultEffort(modelId: string, declared: OllamaThinkingCapability | undefined, configured: string | null | undefined): string | undefined;
162
222
  /**
163
223
  * Map reasoning effort to wire think parameter for the target model.
164
224
  * Per Ollama docs:
165
- * - gpt-oss: only 'low' | 'medium' | 'high' are valid. gpt-oss cannot disable thinking, so 'none'
166
- * as well as 'xhigh'/'max'/garbage MUST be omitted (undefined).
225
+ * - a model that has declared its own values: the effort reverses to the one
226
+ * value that model declared for it, and nothing else is sent. A level the
227
+ * model never declared is omitted rather than coerced - a model that declares
228
+ * `[true]` is never asked for `false`, and one that declares ['low','high'] is
229
+ * never handed 'medium'. Omitting is the service's own default, which is a
230
+ * weaker turn and never a failed one.
231
+ * - gpt-oss with no metadata: only 'low' | 'medium' | 'high' are valid. gpt-oss cannot disable
232
+ * thinking, so 'none' as well as 'xhigh'/'max'/garbage MUST be omitted (undefined).
167
233
  * - boolean models: 'none' -> false; 'low'|'medium'|'high'|'auto'|'true' -> true; garbage -> undefined.
168
234
  * - all other models: omit (undefined).
169
235
  */
170
- export declare function thinkForModel(modelId: string, reasoningEffort: unknown): boolean | string | undefined;
236
+ export declare function thinkForModel(modelId: string, reasoningEffort: unknown, declared?: OllamaThinkingCapability): boolean | string | undefined;
171
237
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/host/ollama/types.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAEH,eAAO,MAAM,WAAW,WAAW,CAAA;AACnC,eAAO,MAAM,aAAa,WAAW,CAAA;AAErC,sDAAsD;AACtD,eAAO,MAAM,cAAc,uBAAuB,CAAA;AAElD,sBAAsB;AACtB,eAAO,MAAM,gBAAgB,cAAc,CAAA;AAC3C,eAAO,MAAM,gBAAgB,cAAc,CAAA;AAE3C,iCAAiC;AACjC,eAAO,MAAM,eAAe,0BAA0B,CAAA;AACtD,eAAO,MAAM,gBAAgB,sBAAsB,CAAA;AACnD,eAAO,MAAM,kBAAkB,YAAY,CAAA;AAE3C;;;;;;GAMG;AACH,eAAO,MAAM,sBAAsB,SAAU,CAAA;AAE7C;;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BAAqB,EAAE,CAStH;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,0BAA0B,CACxC,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,wBAAwB,GAAG,SAAS,EAC9C,UAAU,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GACpC,MAAM,GAAG,SAAS,CAepB;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,MAAM,EAAE,eAAe,EAAE,OAAO,EAAE,QAAQ,CAAC,EAAE,wBAAwB,GAAG,OAAO,GAAG,MAAM,GAAG,SAAS,CA4B1I"}
@@ -0,0 +1,187 @@
1
+ /**
2
+ * Step Code 线路的号池:共享 `AccountPoolCore` 之上的薄封装。
3
+ *
4
+ * 存储、序列化、可用性、轮转、429 冷却都由 `src/host/common/account-pool.ts` 管;
5
+ * 本文件只回答「Step 这条线的凭据长什么样、谁能被刷新、身份怎么算、卡片怎么装配」。
6
+ *
7
+ * 四个与兄弟线路不同的地方,各有理由:
8
+ *
9
+ * 1. **两区可以同时在池里。** 区域是凭据的属性(计划 §1),一区铸造的 Key 被另一区拒绝,
10
+ * 所以去重键里必须带区域:否则同一个账号名在两个部署上会被合并成一行,
11
+ * 然后那一行的凭据被拿去打另一个区的主机——一次不会被任何本地检查发现的串区。
12
+ * 2. **凭据永不过期、永不刷新。** `needsRefresh` 恒为 false,`refresh` **一定抛错**;
13
+ * `expiresAt` 恒为 `STATIC_EXPIRES_AT`(Number.MAX_SAFE_INTEGER)且刻意**不**实现
14
+ * `expiresAt` 钩子——把一个「永不过期」写成卡片上的 expiresAt 会让人以为它会过期。
15
+ * 适配器收到 401 时 markAuthFailed,那才是上游自己说的失效。
16
+ * 3. **adopt 快照可删。** 与 codex/claude/glm 不同:本插件只读 `~/.stepcode/auth.json`,
17
+ * 从不写它;删掉池里的一行只是删掉本插件自己的加密记录,用户的 stepcode 会话不动。
18
+ * 所以这里没有 glm 那条「adopt 账号不可删」的规则。
19
+ * 4. **额度装配复用共享的 `quotaWindow()` / `poolQuota()`**,不另写第三份。
20
+ * 窗口长度取 types.ts 的 QUOTA_WINDOW_MINUTES(共享窗口 DTO 里没有窗口 key,
21
+ * 那是线路自己的桥),`label` 传空串(窗口名的规范在客户端字典里),
22
+ * `usedPercent` 为 null 的窗口由 `quotaWindow()` 丢弃(null 不是 0%,是「未说明」)。
23
+ */
24
+ import { AccountPoolCore, type PoolAccountShape, type PoolData } from '../common/account-pool.ts';
25
+ import type { CredentialStore } from '../token-store.ts';
26
+ import type { AccountRotationStrategy, PoolAccountQuotaDto } from '../../shared/account-pool-contracts.ts';
27
+ import { type StepCodeAccountSummaryDto, type StepCodeProfile, type StepCodeQuotaSnapshotDto, type StepCodeRegion, type StepCodeStatusDto } from '../../shared/step-code-contracts.ts';
28
+ import { type StepCodeStoredCredential } from './oauth.ts';
29
+ /**
30
+ * 号池里存的一份凭据。
31
+ *
32
+ * 它是 `oauth.ts` 的 `StepCodeStoredCredential` 加两个**来源**标记:
33
+ *
34
+ * - `adopted`:这一份是本机 stepcode 登录态的拷贝(卡片的来源标记)。
35
+ * - `sourcePath`:读到它的确切文件,卡片可以显示给用户。
36
+ *
37
+ * 凭据本身(access / refresh / expires / profile / uid)与 OAuth 模块装配的完全一致,
38
+ * 因为它们**就是**同一个东西:Step 的 api_key 不分来源,池里也不该分。
39
+ */
40
+ export interface StepCodeCredentials extends StepCodeStoredCredential {
41
+ adopted?: true;
42
+ sourcePath?: string;
43
+ }
44
+ /** 一个池内账号行。凭据整个随行存放;其余是卡片渲染用的非机密事实。 */
45
+ export interface StepCodePoolAccount extends PoolAccountShape<StepCodeCredentials> {
46
+ /** 账号所属区域;由凭据的 profile 决定,这里是给它做索引用。 */
47
+ region: StepCodeRegion;
48
+ /** 这份凭据的来源(浏览器授权 / 手动粘贴 / adopt),供卡片显示。 */
49
+ source: StepCodeCredentialSource;
50
+ /** 控制台侧的账号显示名(非机密)。 */
51
+ accountName?: string;
52
+ }
53
+ /** 凭据来源,逐字取自 types.ts 的 PROFILE_HOSTS[].credentialSource 之外的用户动作。 */
54
+ export type StepCodeCredentialSource = 'browser' | 'apiKey' | 'adopt';
55
+ /** 号池切片:共享摘要 + 本线路的 profile 与区域。 */
56
+ export type StepCodeAccountSummary = StepCodeAccountSummaryDto;
57
+ /** 本线路自己的加密号池文件。与凭据文件分开:池可以有多行,凭据文件只有主账号一份。 */
58
+ export declare function stepCodePoolPath(): string;
59
+ /** keychain / Secret Service 的服务名。与其它线路各用各的,互不相干。 */
60
+ export declare const STEP_CODE_POOL_KEYCHAIN_SERVICE = "dsh-step-code-pool";
61
+ /**
62
+ * 身份:两个凭据什么时候是同一个上游账号。
63
+ *
64
+ * 组成是「区域 + uid」,两段都非机密,也都不随重新登录而变(Step 的 api_key 每次登录
65
+ * 都可能换一把新的,拿 api_key 当键会让同一个账号每次登录都长成新账号,号池无限增长)。
66
+ *
67
+ * 没有 uid 时退回「区域 + api_key 的 SHA-256 前 16 字节」:那是**指纹**,不是身份,
68
+ * 但它至少保证同一把 Key 落到同一行;两段全空才返回 undefined,那时核心自己生成
69
+ * `acc_<random>`,把这一行**新增**而不是与某个无关凭据合并。
70
+ */
71
+ export declare function stepCodePoolIdentity(credentials: StepCodeCredentials): string | undefined;
72
+ /**
73
+ * 校验并归一化一份凭据。
74
+ *
75
+ * 规则刻意收得比 OAuth 模块更紧(`access` 必须非空、`expires` 必须等于静态值),
76
+ * 因为池里的一行是**要被直接发去上游**的:一份半截的凭据会让号池把一个必然 401 的请求
77
+ * 当成可路由的账号打出去。
78
+ */
79
+ export declare function parseStepCodeCredentials(value: unknown): StepCodeCredentials;
80
+ /**
81
+ * 校验并归一化整份号池文档。
82
+ *
83
+ * 凭据重新过一遍 `parseStepCodeCredentials`,所以一行不可能装着一份 store 会拒绝写回的形状。
84
+ * `region` / `source` 必须显式恢复:行上的这两个字段是索引,丢了会让卡片把国区账号画成国际区。
85
+ * 一行凭据读不通就**丢弃这一行**而不是整体报错——`read()` 会吞掉一次加载失败并回落,
86
+ * 抛错等于让一行坏数据带走整个池。
87
+ */
88
+ export declare function parseStepCodePoolData(value: unknown): PoolData<StepCodePoolAccount>;
89
+ /**
90
+ * 额度快照 → 号池卡片渲染的形状。
91
+ *
92
+ * 每个窗口**按长度**而不是按一个字符串来标注:窗口名的规范在客户端字典里,host 没有
93
+ * 资格下发展示文案,而知道自己长度的窗口可以让共享卡片直接从长度推出名字。
94
+ * `usedPercent` 为 null 的窗口由 `quotaWindow()` 丢掉——null 不是 0%,是「未说明」,
95
+ * 画成一条进度条等于谎报用量。
96
+ */
97
+ export declare function stepCodePoolQuota(snapshot: StepCodeQuotaSnapshotDto | null | undefined): PoolAccountQuotaDto | undefined;
98
+ /** 本线路号池的构造选项。全部可选:生产按池文件路径构造平台后端。 */
99
+ export interface StepCodeAccountPoolOptions {
100
+ /** 测试缝;生产按池文件路径构造平台后端(DPAPI / Keychain / SecretService)。 */
101
+ backend?: CredentialStore<PoolData<StepCodePoolAccount>>;
102
+ /** 本池接受的账号数上限。 */
103
+ maxAccounts?: number;
104
+ /** 用户在设置里钉住的账号;钉住的账号冷却时自动让位给轮转(核心自己处理)。 */
105
+ preferAccountId?: () => string | null;
106
+ }
107
+ /**
108
+ * 对一份凭据提出的刷新。
109
+ *
110
+ * 它**永远不会成功**,而**必须**是一个显式错误而不是一次静默的空操作:核心的刷新路径
111
+ * 会把这个错误报给用户,而静默返回旧凭据会让一次注定失败的请求看起来像成功了。
112
+ * 逐字照抄官方 refreshStepOAuth(index.ts:316-321)的拒绝语义。
113
+ */
114
+ export declare class StepCodeCredentialRefreshError extends Error {
115
+ constructor();
116
+ }
117
+ /** 本线路的号池。凭据类型是本线路自己的,静态凭据不刷新。 */
118
+ export declare class StepCodeAccountPool extends AccountPoolCore<StepCodeCredentials, StepCodePoolAccount, StepCodeAccountSummary> {
119
+ constructor(options?: StepCodeAccountPoolOptions);
120
+ /**
121
+ * 把一份 adopt 快照收进号池。
122
+ *
123
+ * 快照已经跑过 `adopt.ts` 的解析(形状、占位符、profile 都已确认),这里只补来源标记;
124
+ * 账号仍以 `stepCodePoolIdentity` 的身份落进池,重复 adopt 同一次登录只会更新同一行。
125
+ */
126
+ addAdoptedCredential(adopted: {
127
+ readonly credentials: StepCodeStoredCredential;
128
+ readonly sourcePath?: string;
129
+ }, alias?: string): Promise<StepCodePoolAccount>;
130
+ /**
131
+ * 手动粘贴 Platform API Key 的入口(形状与登录完全一致,见 `stepCodeCredentialFromApiKey`)。
132
+ */
133
+ addApiKeyCredential(credentials: StepCodeStoredCredential, alias?: string): Promise<StepCodePoolAccount>;
134
+ /**
135
+ * 适配器取下一个账号用的入口。
136
+ *
137
+ * 核心在这里做轮转、冷却、可用性判断与(被拒绝的)刷新;本方法只多给适配器一件事:
138
+ * 一次请求内换过账号时,把试过的账号排除掉。
139
+ */
140
+ getEffectiveCredential(excludeIds?: ReadonlySet<string>, fetchFn?: typeof fetch): Promise<{
141
+ account: StepCodePoolAccount;
142
+ credentials: StepCodeCredentials;
143
+ }>;
144
+ /**
145
+ * 一次额度读属于哪个账号,连同读它用的凭据。
146
+ *
147
+ * 写在这里而不是路由里,是因为它是线路形状的:路由需要的是凭据**和**这次读所属的账号,
148
+ * 这样快照才能记在它描述的那一行上,不会被一次轮转画到另一行名下。
149
+ * 选谁读是核心自己对「没有指名账号的调用方」的规则,这里照抄那三行,
150
+ * 因为核心只通过 `getFreshCredential` 暴露凭据本身。
151
+ */
152
+ getQuotaReadTarget(fetchFn?: typeof fetch): Promise<{
153
+ accountId: string;
154
+ profile: StepCodeProfile;
155
+ region: StepCodeRegion;
156
+ credentials: StepCodeCredentials;
157
+ }>;
158
+ }
159
+ /** 状态应答里的号池切片。 */
160
+ export interface StepCodePoolStatus {
161
+ accounts: StepCodeAccountSummary[];
162
+ activeAccountId?: string;
163
+ rotationStrategy: AccountRotationStrategy;
164
+ /** 本进程是否装上了号池。 */
165
+ poolInstalled: boolean;
166
+ }
167
+ /**
168
+ * 读状态应答的号池切片。
169
+ *
170
+ * 读不出来的号池不能带倒整张卡:连接那一半仍然值得渲染,只是账号列表是空的。
171
+ */
172
+ export declare function stepCodePoolStatus(pool: StepCodeAccountPool | undefined): Promise<StepCodePoolStatus>;
173
+ /**
174
+ * 把池状态装配成 `StepCodeStatusDto` 的号池切片。
175
+ *
176
+ * 这是**唯一**装配号池切片的地方(照抄 glm 的 `glmCodingPlanPoolStatus` + 同族先例):
177
+ * 一旦卡片、hub 汇总与适配器各装配一次,三处就会在「activeAccountId 缺失时给不给"
178
+ * activeAccountId: undefined"」这种细节上漂移。
179
+ *
180
+ * 两个刻意的省略:
181
+ *
182
+ * - `activeAccountId` 只在**真的读到**时下发(共享 DTO 的 enabledModelIds 语义同源:
183
+ * 缺省 = 没有钉住,而不是「钉住了 undefined」)。
184
+ * - 读不出来的池给空列表而不是抛错:连接那一半仍然值得渲染。
185
+ */
186
+ export declare function stepCodePoolStatusSlice(pool: StepCodeAccountPool | undefined): Promise<Pick<StepCodeStatusDto, 'accounts' | 'rotationStrategy' | 'activeAccountId'>>;
187
+ //# sourceMappingURL=account-pool.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"account-pool.d.ts","sourceRoot":"","sources":["../../../../src/host/step-code/account-pool.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAIH,OAAO,EACL,eAAe,EAGf,KAAK,gBAAgB,EACrB,KAAK,QAAQ,EACd,MAAM,2BAA2B,CAAA;AAGlC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AACxD,OAAO,KAAK,EACV,uBAAuB,EACvB,mBAAmB,EACpB,MAAM,wCAAwC,CAAA;AAC/C,OAAO,EAEL,KAAK,yBAAyB,EAC9B,KAAK,eAAe,EACpB,KAAK,wBAAwB,EAC7B,KAAK,cAAc,EACnB,KAAK,iBAAiB,EACvB,MAAM,qCAAqC,CAAA;AAY5C,OAAO,EAEL,KAAK,wBAAwB,EAC9B,MAAM,YAAY,CAAA;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ACH,wBAAsB,kBAAkB,CACtC,IAAI,EAAE,mBAAmB,GAAG,SAAS,GACpC,OAAO,CAAC,kBAAkB,CAAC,CAY7B;AAED;;;;;;;;;;;;GAYG;AACH,wBAAsB,uBAAuB,CAC3C,IAAI,EAAE,mBAAmB,GAAG,SAAS,GACpC,OAAO,CAAC,IAAI,CAAC,iBAAiB,EAAE,UAAU,GAAG,kBAAkB,GAAG,iBAAiB,CAAC,CAAC,CAOvF"}
@@ -0,0 +1,142 @@
1
+ /**
2
+ * Step Code(Step Plan 订阅)线路的 DSH 适配器。
3
+ *
4
+ * 形状与 GLM / WorkBuddy 同构(`extends LlmAdapter`:`listModels` / `resolveModel` /
5
+ * `prepareCall` / `stream` / `catalog` / `credentialFor`),但它**不碰任何协议细节**:
6
+ *
7
+ * - 请求体、流解析、用量与错误分类全部来自 `./mapper.ts`;
8
+ * - URL 全部来自 `./client.ts`(`stepChatCompletionsUrl` / `stepModelCatalogUrl`);
9
+ * - 目录的归一化全部来自 `./model-catalog.ts`。
10
+ *
11
+ * 也就是说本文件只回答三件事:**这一行请求用哪个目录行**、**用哪把凭据**、
12
+ * **失败之后换不换账号**。任何一份 URL 拼接或 JSON 解析在这里出现第二遍,
13
+ * 就等于给线路造了第二条会漂移的真相。
14
+ *
15
+ * 三处刻意如此:
16
+ *
17
+ * 1. **凭据只在 `credentialFor()` 一处取。** 有号池时轮转,没有池时读单凭据存储
18
+ * (无头 host 与测试的形态)。两条路径都**不刷新**:Step 的 api_key 永不过期,
19
+ * 号池的 refresh 钩子恒抛 `StepCodeCredentialRefreshError`,所以这里没有「捕获后重登」
20
+ * 这种分支——上游撤销一把 Key 的唯一诚实的处置是 401 时的 `markAuthFailed`。
21
+ * 2. **请求路径不联网。** 目录只读 `client.ts` 的进程内缓存,随包目录兜底;
22
+ * 实时目录是 `/catalog/refresh` 与登录/adopt 的产物。
23
+ * 3. **缓存用量在本进程累计。** 累计器住在本文件(流的末端是唯一知道用量帧的地方),
24
+ * `/status` 由 `readStepCodeCacheStats()` 读它;路由不另算第二套口径。
25
+ */
26
+ import { LlmAdapter, type GenerateOptions, type LlmModelInfo, type LlmProviderInfo, type LlmResolvedModelInfo, type PreparedAdapterCall, type ResolvedRetryPolicy, type StreamChunk } from '@deepseek-ai/dsh-llm';
27
+ import type { AttachmentImageReader } from '../common/request-images.ts';
28
+ import { type StepCodeCacheUsage } from './cache-stats.ts';
29
+ import { type StepCodeCatalogEntry, type StepCodeUpstreamCredential } from './client.ts';
30
+ import { type StepCodeModelEntry } from './model-catalog.ts';
31
+ import { StepCodeCredentialStore, StepCodeModelSettingsStore, type StepCodePreferenceStore } from './token-store.ts';
32
+ import type { StepCodeAccountPool } from './account-pool.ts';
33
+ import { PROVIDER_ID, PROVIDER_NAME } from './types.ts';
34
+ import type { StepCodeCacheStatsDto, StepCodeProfile } from '../../shared/step-code-contracts.ts';
35
+ /**
36
+ * 这条路由的瞬时故障重试策略,与兄弟线路逐字一致。
37
+ *
38
+ * 刻意不在集合里:AUTH(被拒的 Key 每次都一样,而它只能重新授权)、
39
+ * PROVIDER_ERROR(400 或套餐拒绝)、ABORTED(调用方自己取消)。
40
+ */
41
+ export declare const STEP_CODE_RETRY_POLICY_CONFIG: {
42
+ mode: 'normal';
43
+ maxRetries: number;
44
+ retryableCodes: string[];
45
+ backoff: {
46
+ initialDelayMs: number;
47
+ maxDelayMs: number;
48
+ jitterRatio: number;
49
+ };
50
+ };
51
+ /** 上游没有给 `Retry-After` 时,一次 429 按 5 分钟冷却。 */
52
+ export declare const STEP_CODE_POOL_COOLDOWN_MS: number;
53
+ /**
54
+ * 目录缓存 → 能力行。
55
+ *
56
+ * `client.ts` 的缓存装的是 `StepCodeCatalogEntry`(**只含端点真的报了的字段**),
57
+ * 而请求面与设置面要的是 `model-catalog.ts` 的 `StepCodeModelEntry`。
58
+ * 这里把前者还原成上游载荷再交给 {@link parseStepCodeModelListing},而不是自己映射一遍:
59
+ * 档位表、`model_type` 过滤、上下文窗口兜底与 hint 生成都因此只有**一份**实现。
60
+ *
61
+ * 还原是等价的:缓存条目里每个字段都对应上游记录里的同名键,
62
+ * 而 `model_type` 的过滤在 `client.ts` 已经按同一条规则做过一次,
63
+ * 再跑一遍得到同一份集合(缓存里要么全带 `model_type` 要么全不带)。
64
+ */
65
+ export declare function stepCodeModelCatalogFrom(entries: readonly StepCodeCatalogEntry[]): StepCodeModelEntry[];
66
+ /**
67
+ * 这个部署能调的模型:**进程内缓存优先、随包目录兜底,请求路径上绝不联网**。
68
+ *
69
+ * 实时目录只由 `/catalog/refresh` 与登录/adopt 产生(见 `routes.ts`),
70
+ * 卡片打开时就能把它同步好;让每一次模型解析都去打上游只会把设置页变成一条压测。
71
+ */
72
+ export declare function cachedStepCodeModelCatalog(profile?: StepCodeProfile): readonly StepCodeModelEntry[];
73
+ /** 设置卡片渲染的模型总数(hub 概览与状态共用同一份读数)。 */
74
+ export declare function stepCodeCatalogSize(): number;
75
+ /**
76
+ * 记下一次请求的用量(流读到终止帧之后调用)。
77
+ *
78
+ * 口径全部借自 `cache-stats.ts` 的 {@link promptTokensOf}——它是本线路对
79
+ * 「聚合 prompt = 未命中 + 缓存读入 + 缓存写入」的唯一写法,这里不再复述一遍。
80
+ */
81
+ export declare function rememberStepCodeCacheUsage(usage: StepCodeCacheUsage): void;
82
+ /**
83
+ * 卡片要的那份切片;**尚无样本时返回 undefined**。
84
+ *
85
+ * 「还没有样本」与「样本全都没命中」必须能被区分:契约里 `cacheStats` 是可选的,
86
+ * 客户端把缺失渲染成占位符、把 0 渲染成真实的 0%,所以这里绝不下发一个全 0 的对象。
87
+ */
88
+ export declare function readStepCodeCacheStats(): StepCodeCacheStatsDto | undefined;
89
+ /** 一行请求要用的凭据:发请求只需要 `client.ts` 认得的那三件事。 */
90
+ export interface StepCodePickedCredential {
91
+ /** 号池里的账号 id;无池(单凭据路径)时为 null。 */
92
+ accountId: string | null;
93
+ credentials: StepCodeUpstreamCredential;
94
+ }
95
+ export interface StepCodeAdapterOptions {
96
+ fetchFn?: typeof fetch;
97
+ attachments?: AttachmentImageReader;
98
+ /** 多账号号池;缺省走单凭据路径(无头 host 与测试)。 */
99
+ accountPool?: StepCodeAccountPool;
100
+ }
101
+ /**
102
+ * Step Code(Step Plan 订阅)线路的 LlmAdapter 实现。
103
+ *
104
+ * 请求面只有一个:四条 profile 全部走 OpenAI Chat Completions(官方
105
+ * `STEP_MODEL_API = "openai-completions"` 对所有模型一视同仁),所以本文件里
106
+ * **没有**协议面判定——而 region 也不在这里拼,URL 由 `client.ts` 从凭据的 profile 得出。
107
+ */
108
+ export declare class StepCodeAdapter extends LlmAdapter {
109
+ private readonly store;
110
+ private readonly modelSettings;
111
+ private readonly preferences;
112
+ private readonly accountPool;
113
+ private readonly options;
114
+ constructor(store?: StepCodeCredentialStore, modelSettings?: StepCodeModelSettingsStore, preferences?: StepCodePreferenceStore, options?: StepCodeAdapterOptions);
115
+ providerInfo(provider: string): LlmProviderInfo;
116
+ providerRetryPolicy(): ResolvedRetryPolicy;
117
+ imageRequestPricing(): undefined;
118
+ private settings;
119
+ /** 这个部署的目录行(缓存优先,请求路径不联网)。 */
120
+ private catalog;
121
+ /**
122
+ * 这一行请求用哪份凭据。
123
+ *
124
+ * 有池时轮转;没有池时读单凭据存储(无头 host 与测试的形态)。
125
+ * 两条路径都**不刷新**:Step 的 api_key 永不过期,号池的 refresh 钩子恒抛
126
+ * `StepCodeCredentialRefreshError`,所以这里不存在「刷新失败后再试一次」的分支。
127
+ */
128
+ private credentialFor;
129
+ listModels(provider?: string): Promise<readonly LlmModelInfo[]>;
130
+ resolveModel(provider: string, model: string, signal?: AbortSignal): Promise<LlmResolvedModelInfo>;
131
+ prepareCall(provider: string, model: string, signal?: AbortSignal): Promise<PreparedAdapterCall>;
132
+ stream(options: GenerateOptions): AsyncIterable<StreamChunk>;
133
+ /**
134
+ * 一次请求的完整往返:选账号 → 定目录行 → 发 → 解析流。
135
+ *
136
+ * 账号轮转的循环只有一处:一次 429 或一次 AUTH 会把那个账号移出本次请求,
137
+ * 由另一个账号来发**同一份**请求体。没有池时这个循环只跑一次。
138
+ */
139
+ private requestStream;
140
+ }
141
+ export { PROVIDER_ID, PROVIDER_NAME };
142
+ //# sourceMappingURL=adapter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../../../../src/host/step-code/adapter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,OAAO,EACL,UAAU,EAIV,KAAK,eAAe,EACpB,KAAK,YAAY,EACjB,KAAK,eAAe,EACpB,KAAK,oBAAoB,EACzB,KAAK,mBAAmB,EACxB,KAAK,mBAAmB,EACxB,KAAK,WAAW,EACjB,MAAM,sBAAsB,CAAA;AAc7B,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,6BAA6B,CAAA;AAExE,OAAO,EAAkB,KAAK,kBAAkB,EAAE,MAAM,kBAAkB,CAAA;AAC1E,OAAO,EAIL,KAAK,oBAAoB,EACzB,KAAK,0BAA0B,EAChC,MAAM,aAAa,CAAA;AACpB,OAAO,EAOL,KAAK,kBAAkB,EACxB,MAAM,oBAAoB,CAAA;AAY3B,OAAO,EACL,uBAAuB,EACvB,0BAA0B,EAE1B,KAAK,uBAAuB,EAC7B,MAAM,kBAAkB,CAAA;AACzB,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAA;AAC5D,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AACvD,OAAO,KAAK,EACV,qBAAqB,EACrB,eAAe,EAChB,MAAM,qCAAqC,CAAA;AAE5C;;;;;GAKG;AACH,eAAO,MAAM,6BAA6B,EAAE;IAC1C,IAAI,EAAE,QAAQ,CAAA;IACd,UAAU,EAAE,MAAM,CAAA;IAClB,cAAc,EAAE,MAAM,EAAE,CAAA;IACxB,OAAO,EAAE;QAAE,cAAc,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,MAAM,CA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