@eddyskywalker/dsh-chatgpt-subscription 0.34.0 → 0.36.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 (189) hide show
  1. package/CHANGELOG.md +76 -110
  2. package/README.md +6 -6
  3. package/lib/client.js +2741 -2177
  4. package/lib/client.js.map +1 -1
  5. package/lib/index.js +3224 -9314
  6. package/lib/types/client/CodexSubscriptionSection.d.ts.map +1 -1
  7. package/lib/types/client/ProviderHubSection.d.ts.map +1 -1
  8. package/lib/types/client/antigravity/AntigravitySection.d.ts.map +1 -1
  9. package/lib/types/client/antigravity/locales.d.ts +2 -5
  10. package/lib/types/client/antigravity/locales.d.ts.map +1 -1
  11. package/lib/types/client/claude/ClaudeSection.d.ts.map +1 -1
  12. package/lib/types/client/claude/locales.d.ts +2 -5
  13. package/lib/types/client/claude/locales.d.ts.map +1 -1
  14. package/lib/types/client/claude/styles.d.ts +2 -2
  15. package/lib/types/client/claude/useClaudeSection.d.ts.map +1 -1
  16. package/lib/types/client/cline-pass/ClinePassSection.d.ts.map +1 -1
  17. package/lib/types/client/cline-pass/locales.d.ts +0 -6
  18. package/lib/types/client/cline-pass/locales.d.ts.map +1 -1
  19. package/lib/types/client/command-code/CommandCodeSection.d.ts.map +1 -1
  20. package/lib/types/client/command-code/locales.d.ts +2 -5
  21. package/lib/types/client/command-code/locales.d.ts.map +1 -1
  22. package/lib/types/client/common/AccountPoolSection.d.ts +3 -2
  23. package/lib/types/client/common/AccountPoolSection.d.ts.map +1 -1
  24. package/lib/types/client/common/account-pool-labels.d.ts +0 -2
  25. package/lib/types/client/common/account-pool-labels.d.ts.map +1 -1
  26. package/lib/types/client/common/format.d.ts +2 -2
  27. package/lib/types/client/common/line-locale.d.ts +21 -0
  28. package/lib/types/client/common/line-locale.d.ts.map +1 -0
  29. package/lib/types/client/common/styles.d.ts.map +1 -1
  30. package/lib/types/client/glm-coding-plan/GlmCodingPlanSection.d.ts +1 -1
  31. package/lib/types/client/glm-coding-plan/GlmCodingPlanSection.d.ts.map +1 -1
  32. package/lib/types/client/glm-coding-plan/locales.d.ts +2 -5
  33. package/lib/types/client/glm-coding-plan/locales.d.ts.map +1 -1
  34. package/lib/types/client/glm-coding-plan/styles.d.ts +3 -2
  35. package/lib/types/client/glm-coding-plan/styles.d.ts.map +1 -1
  36. package/lib/types/client/glm-coding-plan/useGlmCodingPlanSection.d.ts.map +1 -1
  37. package/lib/types/client/hub/UpdateCheck.d.ts +9 -0
  38. package/lib/types/client/hub/UpdateCheck.d.ts.map +1 -0
  39. package/lib/types/client/hub/brand-icons.d.ts +1 -1
  40. package/lib/types/client/hub/brand-icons.d.ts.map +1 -1
  41. package/lib/types/client/hub/brand-svg.d.ts +0 -4
  42. package/lib/types/client/hub/brand-svg.d.ts.map +1 -1
  43. package/lib/types/client/hub/hub-styles.d.ts.map +1 -1
  44. package/lib/types/client/hub/providers.d.ts.map +1 -1
  45. package/lib/types/client/index.d.ts +0 -2
  46. package/lib/types/client/index.d.ts.map +1 -1
  47. package/lib/types/client/kimi-code/KimiCodeSection.d.ts.map +1 -1
  48. package/lib/types/client/kimi-code/KimiModelCapabilities.d.ts.map +1 -1
  49. package/lib/types/client/kimi-code/locales.d.ts +2 -5
  50. package/lib/types/client/kimi-code/locales.d.ts.map +1 -1
  51. package/lib/types/client/locales-ru/account-pool.d.ts +11 -0
  52. package/lib/types/client/locales-ru/account-pool.d.ts.map +1 -0
  53. package/lib/types/client/locales-ru/antigravity.d.ts +10 -0
  54. package/lib/types/client/locales-ru/antigravity.d.ts.map +1 -0
  55. package/lib/types/client/locales-ru/claude.d.ts +3 -0
  56. package/lib/types/client/locales-ru/claude.d.ts.map +1 -0
  57. package/lib/types/client/locales-ru/cline-pass.d.ts +11 -0
  58. package/lib/types/client/locales-ru/cline-pass.d.ts.map +1 -0
  59. package/lib/types/client/locales-ru/command-code.d.ts +9 -0
  60. package/lib/types/client/locales-ru/command-code.d.ts.map +1 -0
  61. package/lib/types/client/locales-ru/glm-coding-plan.d.ts +10 -0
  62. package/lib/types/client/locales-ru/glm-coding-plan.d.ts.map +1 -0
  63. package/lib/types/client/locales-ru/hub.d.ts +3 -0
  64. package/lib/types/client/locales-ru/hub.d.ts.map +1 -0
  65. package/lib/types/client/locales-ru/index.d.ts +27 -0
  66. package/lib/types/client/locales-ru/index.d.ts.map +1 -0
  67. package/lib/types/client/locales-ru/kimi-code.d.ts +10 -0
  68. package/lib/types/client/locales-ru/kimi-code.d.ts.map +1 -0
  69. package/lib/types/client/locales-ru/minimax-code.d.ts +9 -0
  70. package/lib/types/client/locales-ru/minimax-code.d.ts.map +1 -0
  71. package/lib/types/client/locales-ru/ollama.d.ts +10 -0
  72. package/lib/types/client/locales-ru/ollama.d.ts.map +1 -0
  73. package/lib/types/client/locales-ru/opendesign.d.ts +10 -0
  74. package/lib/types/client/locales-ru/opendesign.d.ts.map +1 -0
  75. package/lib/types/client/locales-ru/progress-updates.d.ts +8 -0
  76. package/lib/types/client/locales-ru/progress-updates.d.ts.map +1 -0
  77. package/lib/types/client/locales-ru/qoder.d.ts +11 -0
  78. package/lib/types/client/locales-ru/qoder.d.ts.map +1 -0
  79. package/lib/types/client/locales-ru/step-code.d.ts +9 -0
  80. package/lib/types/client/locales-ru/step-code.d.ts.map +1 -0
  81. package/lib/types/client/locales.d.ts +39 -3
  82. package/lib/types/client/locales.d.ts.map +1 -1
  83. package/lib/types/client/minimax-code/locales.d.ts +2 -5
  84. package/lib/types/client/minimax-code/locales.d.ts.map +1 -1
  85. package/lib/types/client/minimax-code/useMinimaxCodeSection.d.ts +2 -2
  86. package/lib/types/client/minimax-code/useMinimaxCodeSection.d.ts.map +1 -1
  87. package/lib/types/client/ollama/OllamaSection.d.ts.map +1 -1
  88. package/lib/types/client/ollama/locales.d.ts +0 -6
  89. package/lib/types/client/ollama/locales.d.ts.map +1 -1
  90. package/lib/types/client/opendesign/OpenDesignSection.d.ts +4 -3
  91. package/lib/types/client/opendesign/OpenDesignSection.d.ts.map +1 -1
  92. package/lib/types/client/opendesign/locales.d.ts +108 -48
  93. package/lib/types/client/opendesign/locales.d.ts.map +1 -1
  94. package/lib/types/client/opendesign/styles.d.ts.map +1 -1
  95. package/lib/types/client/qoder/QoderSection.d.ts +3 -2
  96. package/lib/types/client/qoder/QoderSection.d.ts.map +1 -1
  97. package/lib/types/client/qoder/locales.d.ts +1 -3
  98. package/lib/types/client/qoder/locales.d.ts.map +1 -1
  99. package/lib/types/client/qoder/useQoderSection.d.ts.map +1 -1
  100. package/lib/types/client/step-code/StepCodeComposerQuota.d.ts +2 -2
  101. package/lib/types/client/step-code/StepCodeSection.d.ts +1 -1
  102. package/lib/types/client/step-code/StepCodeSection.d.ts.map +1 -1
  103. package/lib/types/client/step-code/locales.d.ts +2 -5
  104. package/lib/types/client/step-code/locales.d.ts.map +1 -1
  105. package/lib/types/client/step-code/styles.d.ts +1 -1
  106. package/lib/types/client/step-code/useStepCodeSection.d.ts.map +1 -1
  107. package/lib/types/host/claude/account-pool.d.ts +2 -2
  108. package/lib/types/host/claude/account-pool.d.ts.map +1 -1
  109. package/lib/types/host/claude/routes.d.ts +1 -1
  110. package/lib/types/host/common/capabilities.d.ts.map +1 -1
  111. package/lib/types/host/common/credential-read-cache.d.ts +2 -3
  112. package/lib/types/host/common/credential-read-cache.d.ts.map +1 -1
  113. package/lib/types/host/common/model-request-control.d.ts +1 -1
  114. package/lib/types/host/common/model-request-control.d.ts.map +1 -1
  115. package/lib/types/host/common/request-diagnostics.d.ts +2 -2
  116. package/lib/types/host/common/request-diagnostics.d.ts.map +1 -1
  117. package/lib/types/host/glm-coding-plan/mapper-openai.d.ts +1 -1
  118. package/lib/types/host/glm-coding-plan/model-catalog.d.ts +4 -4
  119. package/lib/types/host/minimax-code/account-pool.d.ts +6 -7
  120. package/lib/types/host/minimax-code/account-pool.d.ts.map +1 -1
  121. package/lib/types/host/minimax-code/checkin.d.ts +7 -8
  122. package/lib/types/host/minimax-code/checkin.d.ts.map +1 -1
  123. package/lib/types/host/minimax-code/routes.d.ts +1 -1
  124. package/lib/types/host/opendesign/client.d.ts +53 -0
  125. package/lib/types/host/opendesign/client.d.ts.map +1 -1
  126. package/lib/types/host/opendesign/routes.d.ts +4 -3
  127. package/lib/types/host/opendesign/routes.d.ts.map +1 -1
  128. package/lib/types/host/opendesign/types.d.ts +10 -0
  129. package/lib/types/host/opendesign/types.d.ts.map +1 -1
  130. package/lib/types/host/step-code/adapter.d.ts +1 -1
  131. package/lib/types/host/step-code/client.d.ts +1 -1
  132. package/lib/types/host/step-code/mapper.d.ts +3 -3
  133. package/lib/types/host/step-code/oauth.d.ts +1 -1
  134. package/lib/types/host/update-check.d.ts +118 -0
  135. package/lib/types/host/update-check.d.ts.map +1 -0
  136. package/lib/types/index.d.ts +0 -6
  137. package/lib/types/index.d.ts.map +1 -1
  138. package/lib/types/shared/account-pool-contracts.d.ts +0 -24
  139. package/lib/types/shared/account-pool-contracts.d.ts.map +1 -1
  140. package/lib/types/shared/hub-contracts.d.ts +1 -1
  141. package/lib/types/shared/hub-contracts.d.ts.map +1 -1
  142. package/lib/types/shared/minimax-code-contracts.d.ts +2 -2
  143. package/lib/types/shared/opendesign-contracts.d.ts +35 -2
  144. package/lib/types/shared/opendesign-contracts.d.ts.map +1 -1
  145. package/lib/types/shared/update-contracts.d.ts +124 -0
  146. package/lib/types/shared/update-contracts.d.ts.map +1 -0
  147. package/package.json +1 -1
  148. package/lib/types/client/workbuddy/WorkBuddyComposerQuota.d.ts +0 -22
  149. package/lib/types/client/workbuddy/WorkBuddyComposerQuota.d.ts.map +0 -1
  150. package/lib/types/client/workbuddy/WorkBuddySection.d.ts +0 -50
  151. package/lib/types/client/workbuddy/WorkBuddySection.d.ts.map +0 -1
  152. package/lib/types/client/workbuddy/locales.d.ts +0 -635
  153. package/lib/types/client/workbuddy/locales.d.ts.map +0 -1
  154. package/lib/types/client/workbuddy/styles.d.ts +0 -15
  155. package/lib/types/client/workbuddy/styles.d.ts.map +0 -1
  156. package/lib/types/client/workbuddy/useWorkBuddySection.d.ts +0 -149
  157. package/lib/types/client/workbuddy/useWorkBuddySection.d.ts.map +0 -1
  158. package/lib/types/host/workbuddy/account-pool.d.ts +0 -235
  159. package/lib/types/host/workbuddy/account-pool.d.ts.map +0 -1
  160. package/lib/types/host/workbuddy/adapter.d.ts +0 -129
  161. package/lib/types/host/workbuddy/adapter.d.ts.map +0 -1
  162. package/lib/types/host/workbuddy/atrest.d.ts +0 -98
  163. package/lib/types/host/workbuddy/atrest.d.ts.map +0 -1
  164. package/lib/types/host/workbuddy/checkin.d.ts +0 -150
  165. package/lib/types/host/workbuddy/checkin.d.ts.map +0 -1
  166. package/lib/types/host/workbuddy/client.d.ts +0 -169
  167. package/lib/types/host/workbuddy/client.d.ts.map +0 -1
  168. package/lib/types/host/workbuddy/dsml.d.ts +0 -55
  169. package/lib/types/host/workbuddy/dsml.d.ts.map +0 -1
  170. package/lib/types/host/workbuddy/guardrails.d.ts +0 -111
  171. package/lib/types/host/workbuddy/guardrails.d.ts.map +0 -1
  172. package/lib/types/host/workbuddy/identity.d.ts +0 -71
  173. package/lib/types/host/workbuddy/identity.d.ts.map +0 -1
  174. package/lib/types/host/workbuddy/mapper.d.ts +0 -131
  175. package/lib/types/host/workbuddy/mapper.d.ts.map +0 -1
  176. package/lib/types/host/workbuddy/model-catalog.d.ts +0 -217
  177. package/lib/types/host/workbuddy/model-catalog.d.ts.map +0 -1
  178. package/lib/types/host/workbuddy/oauth.d.ts +0 -47
  179. package/lib/types/host/workbuddy/oauth.d.ts.map +0 -1
  180. package/lib/types/host/workbuddy/outbound-identity.d.ts +0 -66
  181. package/lib/types/host/workbuddy/outbound-identity.d.ts.map +0 -1
  182. package/lib/types/host/workbuddy/routes.d.ts +0 -56
  183. package/lib/types/host/workbuddy/routes.d.ts.map +0 -1
  184. package/lib/types/host/workbuddy/token-store.d.ts +0 -360
  185. package/lib/types/host/workbuddy/token-store.d.ts.map +0 -1
  186. package/lib/types/host/workbuddy/types.d.ts +0 -161
  187. package/lib/types/host/workbuddy/types.d.ts.map +0 -1
  188. package/lib/types/shared/workbuddy-contracts.d.ts +0 -353
  189. package/lib/types/shared/workbuddy-contracts.d.ts.map +0 -1
@@ -1,360 +0,0 @@
1
- import type { WorkBuddyCheckinSettings, WorkBuddyReasoningEffort, WorkBuddyRegion } from '../../shared/workbuddy-contracts.ts';
2
- import { type ContextWindowOverridePatch } from '../common/context-window-overrides.ts';
3
- import { type WorkBuddyGuardrails } from './guardrails.ts';
4
- import { type WorkBuddyOutboundSetting } from './outbound-identity.ts';
5
- import type { CredentialStore } from '../token-store.ts';
6
- import { isIntlDomain } from './types.ts';
7
- export declare const WORKBUDDY_PREFERENCES_NAMESPACE = "dsh-workbuddy";
8
- export type { WorkBuddyReasoningEffort };
9
- /**
10
- * One WorkBuddy credential, parsed from a CodeBuddy desktop `*.info` file.
11
- *
12
- * These files are the IDE's own credential store, not this plugin's: the plugin
13
- * reads them so a user who is already signed in to the IDE needs no second
14
- * login. A refreshed token is written back so both clients stay valid instead of
15
- * racing each other with a rotating refresh token.
16
- */
17
- export interface WorkBuddyCredentials {
18
- /** Bearer token for the chat and billing APIs. Host-only. */
19
- accessToken: string;
20
- /** Rotating refresh token. Host-only. */
21
- refreshToken: string;
22
- /** Unix milliseconds the access token stops being valid. */
23
- expiresAt: number;
24
- /** Region the account belongs to; decides which backend serves it. */
25
- region: WorkBuddyRegion;
26
- /** Auth domain recorded in the file, e.g. `copilot.tencent.com`. */
27
- domain: string;
28
- /** Backend base URL derived from {@link domain}. */
29
- backend: string;
30
- uid?: string;
31
- nickname?: string;
32
- uin?: string;
33
- accountType?: string;
34
- enterpriseId?: string;
35
- /** Absolute path of the `*.info` file this credential came from. */
36
- sourceFile: string;
37
- /** File modification time when it was read, so a stale cache is detectable. */
38
- sourceMtimeMs: number;
39
- /** Which store owns the secret; only managed credentials may be deleted. */
40
- source: 'desktop' | 'managed';
41
- /**
42
- * Sealed token material, when the file holds `$wbEncrypted` envelopes.
43
- *
44
- * The desktop client stopped writing plaintext tokens on 2026-09-24, so a
45
- * credential read from such a file has no usable `accessToken` until the
46
- * at-rest key opens these. They are kept verbatim here — never logged, never
47
- * sent anywhere — and resolved by {@link unsealCredentials}.
48
- */
49
- sealed?: {
50
- accessToken?: unknown;
51
- refreshToken?: unknown;
52
- };
53
- }
54
- export interface WorkBuddyModelSettings {
55
- enabled?: boolean;
56
- enabledModelIds: string[];
57
- contextWindowOverrides: Record<string, number>;
58
- defaultReasoningEffort: WorkBuddyReasoningEffort | null;
59
- /** Stable account key selected by the user; null keeps automatic selection. */
60
- selectedAccountId: string | null;
61
- /** Desktop accounts hidden from this plugin without deleting CodeBuddy files. */
62
- hiddenAccountIds: string[];
63
- /** Daily check-in scheduler preferences. */
64
- checkin: WorkBuddyCheckinSettings;
65
- /**
66
- * Which outbound client identity requests present.
67
- *
68
- * `auto` assigns one product per account (stable for the account's life);
69
- * anything else pins it line-wide. The default is the identity this line has
70
- * always sent, so an untouched install behaves exactly as before.
71
- */
72
- outboundIdentity: WorkBuddyOutboundSetting;
73
- /** Local quota guardrails; all-off by default. */
74
- guardrails: WorkBuddyGuardrails;
75
- }
76
- export interface WorkBuddyPreferenceStore {
77
- /**
78
- * Resolve once the store has read whatever it was going to read.
79
- *
80
- * The file-backed store warms up asynchronously, so `status()` answers from
81
- * shipped defaults until that read settles. A caller that acts on a
82
- * preference at startup — the check-in scheduler signing in on boot — must
83
- * await this first, or it acts on the default instead of the user's choice.
84
- * A register-backed store reads synchronously and resolves immediately.
85
- */
86
- ready(): Promise<void>;
87
- status(): WorkBuddyModelSettings;
88
- update(patch: {
89
- enabled?: boolean;
90
- enabledModelIds?: string[];
91
- /** `null` deletes one override and falls back to the catalog default. */
92
- contextWindowOverrides?: ContextWindowOverridePatch;
93
- defaultReasoningEffort?: WorkBuddyReasoningEffort | null;
94
- selectedAccountId?: string | null;
95
- hiddenAccountIds?: string[];
96
- checkin?: Partial<WorkBuddyCheckinSettings>;
97
- outboundIdentity?: WorkBuddyOutboundSetting;
98
- guardrails?: Partial<WorkBuddyGuardrails>;
99
- }): Promise<WorkBuddyModelSettings>;
100
- }
101
- /** Shipped check-in default: on. */
102
- export declare const DEFAULT_CHECKIN_SETTINGS: WorkBuddyCheckinSettings;
103
- /**
104
- * Narrow an unknown stored/patched value into valid check-in settings.
105
- *
106
- * Documents written while the window was still configurable may carry
107
- * startHour/endHour; those keys are inert now and dropped on the next write.
108
- */
109
- export declare function normalizeCheckinSettings(value: unknown): WorkBuddyCheckinSettings;
110
- /**
111
- * Bind the model selection to the DSH settings document when the harness still
112
- * offers one, and to the JSON file beside it otherwise: a harness without the
113
- * register seam (0.1.7, and a headless test) reads that file back on boot.
114
- */
115
- export declare function registerWorkBuddyPreferenceStore(settings?: unknown, fallbackStore?: FileModelSettingsStore): WorkBuddyPreferenceStore;
116
- /**
117
- * Credential directory the CodeBuddy desktop client writes to.
118
- *
119
- * `CODEBUDDY_AUTH_DIR` overrides it, matching the environment variable the
120
- * official tooling honours, which is also what makes the scan testable without
121
- * touching a real profile.
122
- */
123
- export declare function codeBuddyAuthDir(): string;
124
- /** Plugin settings file, used when no settings service is present. */
125
- export declare function modelSettingsPath(): string;
126
- /** Encrypted account pool for credentials added through this plugin. */
127
- export declare function managedCredentialsPath(): string;
128
- /** Platform-encrypted storage for the pasted at-rest key (never plaintext on disk). */
129
- export declare function atRestKeyPath(): string;
130
- /**
131
- * Storage for the `$wbEncrypted` protector key.
132
- *
133
- * The key is the one secret that unlocks the desktop client's tokens, so it goes
134
- * through the same platform store the managed pool uses (DPAPI / Keychain /
135
- * Secret Service) and is installed into the process only after the client's own
136
- * keyblob accepts it. A pasted value that fails that check never displaces a
137
- * working key.
138
- */
139
- export declare class WorkBuddyAtRestKeyStore {
140
- private readonly filePath;
141
- private readonly backend;
142
- private cached;
143
- constructor(filePath?: string, backend?: CredentialStore<{
144
- version: 1;
145
- keyHex: string;
146
- }>);
147
- /** Human-readable storage description, mirroring the managed pool's. */
148
- path(): string;
149
- /**
150
- * Load the stored key into the process.
151
- *
152
- * Called once at startup: the credential readers consult the module-level
153
- * slot, so a key that is only on disk would otherwise leave every sealed
154
- * account unreadable until something else triggered a load.
155
- */
156
- load(): Promise<Buffer | null>;
157
- /** Validate and persist a pasted secret; returns the key id for display. */
158
- adopt(text: string): Promise<string>;
159
- /** Forget the key, both on disk and in this process. */
160
- clear(): Promise<void>;
161
- }
162
- /**
163
- * Parse one CodeBuddy `*.info` payload.
164
- *
165
- * Only the fields this plugin needs are read; the file also carries the IDE's
166
- * own account bookkeeping, which is deliberately left untouched. A file without
167
- * a usable access token is rejected rather than half-accepted, so the scanner
168
- * can move on to the next candidate.
169
- */
170
- export declare function parseCredentialFile(value: unknown, sourceFile: string, sourceMtimeMs?: number): WorkBuddyCredentials;
171
- /** Whether a credential is at or near expiry; refreshed a minute early. */
172
- export declare function isExpired(credentials: WorkBuddyCredentials, now?: number): boolean;
173
- /**
174
- * Stable public key for selecting an account without exposing a token or tying
175
- * the preference to a timestamped snapshot filename.
176
- *
177
- * The chain is uid → uin → nickname → domain, and the reason it is safe is
178
- * **ordering**: {@link withResolvedIdentity} settles a credential's uid from
179
- * its own token before any id is derived, so a real sign-in and the IDE's file
180
- * for the same account both reach the uid branch and agree. The nickname rung
181
- * is only reached by a token whose claims cannot be read at all, and keeping it
182
- * there is what stops two such accounts in one region from collapsing onto the
183
- * shared deployment key below it.
184
- *
185
- * A nickname must therefore never be the *first* rung: that is what split one
186
- * account into two pool rows, because the browser-login response states the
187
- * display name while the IDE's file states the uid. Likewise the uid must be
188
- * settled *before* the id is minted, which is why the heal runs inside the
189
- * credential parsers and the pool's own account creation.
190
- */
191
- export declare function workBuddyAccountId(credentials: Pick<WorkBuddyCredentials, 'region' | 'uid' | 'uin' | 'nickname' | 'domain'>): string;
192
- /**
193
- * Every key one credential may have been addressable under.
194
- *
195
- * A settings document written before the identity fix pinned and hid accounts
196
- * by the old chain (`uid → uin → nickname → domain`), so an account that only
197
- * had a nickname stored was addressed as `region:<nickname>`. The heal moves
198
- * that account to its uid, and without this alias the stored pointer would
199
- * silently stop matching — a pinned account would fall back to automatic
200
- * routing and a hidden one would reappear. Callers therefore accept either
201
- * spelling; only the current one is ever written.
202
- */
203
- export declare function workBuddyAccountIdAliases(credentials: Pick<WorkBuddyCredentials, 'region' | 'uid' | 'uin' | 'nickname' | 'domain'>): string[];
204
- /** Strict parser for credentials owned by the plugin's encrypted pool. */
205
- export declare function parseManagedCredentials(value: unknown): WorkBuddyCredentials[];
206
- /**
207
- * Candidate ordering for the scanned credential files.
208
- *
209
- * A user's auth directory accumulates timestamped snapshots beside the live
210
- * file, and the live one is not always the newest. Preference order is: the
211
- * plain `workbuddy-desktop.info` / `codebuddy-desktop.info` files first, then
212
- * the newest `expiresAt` among the timestamped snapshots. Picking purely by
213
- * mtime selected a stale snapshot during development, so the token's own
214
- * expiry is what decides.
215
- */
216
- /** What the last credential scan observed about sealed (`$wbEncrypted`) files. */
217
- export interface SealedCredentialDiagnostics {
218
- /** Sealed credential files the scan met. */
219
- sealedFiles: number;
220
- /** Of those, how many the held key opened. */
221
- opened: number;
222
- /** True when at least one sealed file was skipped because no key is held. */
223
- missingKey: boolean;
224
- /** Why the last sealed file refused to open, when it did. */
225
- lastError: string | null;
226
- }
227
- /** Snapshot of the last scan's sealed-credential observations. */
228
- export declare function sealedCredentialDiagnostics(): SealedCredentialDiagnostics;
229
- /**
230
- * Resolve a credential's sealed tokens into usable plaintext.
231
- *
232
- * Returns `null` when the credential is sealed and this process holds no key
233
- * that opens it: such a file is not an error the caller can act on per-file, it
234
- * is a missing key the settings card reports once.
235
- */
236
- export declare function unsealCredentials<T extends WorkBuddyCredentials>(credentials: T): T | null;
237
- /**
238
- * Scan the CodeBuddy auth directory for usable credentials.
239
- *
240
- * Every `*.info` file is considered; unreadable or malformed ones are skipped
241
- * rather than failing the whole scan, because the directory routinely holds
242
- * expired snapshots next to the live credential.
243
- */
244
- export declare function scanCredentials(dir?: string): Promise<WorkBuddyCredentials[]>;
245
- /** Encrypted credentials added through the WorkBuddy settings page. */
246
- export declare class ManagedCredentialStore {
247
- private readonly filePath;
248
- private readonly backend;
249
- constructor(filePath?: string, backend?: CredentialStore<{
250
- version: 1;
251
- accounts: WorkBuddyCredentials[];
252
- }>);
253
- path(): string;
254
- private serialize;
255
- list(): Promise<WorkBuddyCredentials[]>;
256
- add(credentials: WorkBuddyCredentials): Promise<void>;
257
- update(credentials: WorkBuddyCredentials): Promise<void>;
258
- delete(accountId: string): Promise<boolean>;
259
- }
260
- /**
261
- * Credential store backed by the CodeBuddy desktop client's own auth files.
262
- *
263
- * The plugin does not own these files, so there is nothing to encrypt here: the
264
- * secret is the IDE's, already on disk, and the only write this store performs
265
- * is an atomic write-back of a refreshed token so the IDE does not lose its
266
- * session. Tokens are never sent to a browser.
267
- */
268
- export declare class FileCredentialStore {
269
- private readonly dir;
270
- /** How long a scan result is reused before the directory is re-read. */
271
- private readonly cacheTtlMs;
272
- private readonly managed;
273
- private cached;
274
- private scannedAt;
275
- /** Serializes refresh/write-back per account; different accounts never share a token. */
276
- private readonly refreshInFlight;
277
- constructor(dir?: string,
278
- /** How long a scan result is reused before the directory is re-read. */
279
- cacheTtlMs?: number, managed?: ManagedCredentialStore);
280
- /** Directory this store scans. */
281
- directory(): string;
282
- /** Human-readable storage description for the settings card. */
283
- path(): string;
284
- managedPath(): string;
285
- /** Read the selected credential, or the best visible candidate in automatic mode. */
286
- read(options?: {
287
- force?: boolean;
288
- accountId?: string | null;
289
- hiddenAccountIds?: readonly string[];
290
- }): Promise<WorkBuddyCredentials | null>;
291
- /** Whether a cached credential's source file is unchanged on disk. */
292
- private isStillCurrent;
293
- /**
294
- * All distinct usable accounts, best credential first.
295
- *
296
- * The desktop directory keeps historical snapshots. They are credentials for
297
- * the same account, not additional account choices, so only the first (best)
298
- * candidate for each stable account id is exposed.
299
- */
300
- list(): Promise<WorkBuddyCredentials[]>;
301
- /**
302
- * Desktop credentials only, best first.
303
- *
304
- * The account pool adopts these so the IDE's own sign-ins take part in
305
- * scheduling. Unlike {@link list} this never mixes in managed accounts:
306
- * only the desktop set is re-adopted when the IDE changes its directory.
307
- */
308
- discoverDesktopCredentials(): Promise<WorkBuddyCredentials[]>;
309
- /**
310
- * Re-read one desktop credential file.
311
- *
312
- * A pooled desktop account must serve the IDE's current token rather than
313
- * the copy taken when it was adopted, because the IDE rotates that token on
314
- * its own schedule. Returns null when the file is gone or unreadable.
315
- */
316
- readDesktopFile(filePath: string): Promise<WorkBuddyCredentials | null>;
317
- addManaged(credentials: WorkBuddyCredentials): Promise<void>;
318
- deleteManaged(accountId: string): Promise<boolean>;
319
- /** Forget the cached scan; the next read re-reads the directory. */
320
- invalidate(): void;
321
- /**
322
- * Return a credential whose access token is valid, refreshing it first when
323
- * it is at or near expiry.
324
- *
325
- * Concurrent callers share one refresh: the refresh token rotates, so two
326
- * simultaneous refreshes would invalidate each other.
327
- */
328
- ensureFresh(credentials: WorkBuddyCredentials, refresh: (current: WorkBuddyCredentials) => Promise<WorkBuddyCredentials>): Promise<WorkBuddyCredentials>;
329
- /**
330
- * Persist a refreshed token back into the IDE's own credential file.
331
- *
332
- * Only the `auth` block is rewritten, and the write is atomic so a crash
333
- * cannot leave the IDE with a half-written file. A failure here is not fatal
334
- * to the in-flight request: the refreshed token still works for this process,
335
- * and the next scan simply finds the older token on disk.
336
- */
337
- writeBack(credentials: WorkBuddyCredentials): Promise<void>;
338
- }
339
- /** Plain-JSON model settings used when the settings service is unavailable. */
340
- export declare class FileModelSettingsStore {
341
- private readonly filePath;
342
- constructor(filePath?: string);
343
- path(): string;
344
- read(): Promise<WorkBuddyModelSettings>;
345
- write(settings: WorkBuddyModelSettings): Promise<void>;
346
- updateSettings(patch: {
347
- enabled?: boolean;
348
- enabledModelIds?: string[];
349
- /** `null` deletes one override and falls back to the catalog default. */
350
- contextWindowOverrides?: ContextWindowOverridePatch;
351
- defaultReasoningEffort?: WorkBuddyReasoningEffort | null;
352
- selectedAccountId?: string | null;
353
- hiddenAccountIds?: string[];
354
- checkin?: Partial<WorkBuddyCheckinSettings>;
355
- outboundIdentity?: WorkBuddyOutboundSetting;
356
- guardrails?: Partial<WorkBuddyGuardrails>;
357
- }): Promise<WorkBuddyModelSettings>;
358
- }
359
- export { isIntlDomain };
360
- //# sourceMappingURL=token-store.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"token-store.d.ts","sourceRoot":"","sources":["../../../../src/host/workbuddy/token-store.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,wBAAwB,EAAE,wBAAwB,EAAE,eAAe,EAAE,MAAM,qCAAqC,CAAA;AAI9H,OAAO,EAA+B,KAAK,0BAA0B,EAAE,MAAM,uCAAuC,CAAA;AAGpH,OAAO,EAGL,KAAK,mBAAmB,EACzB,MAAM,iBAAiB,CAAA;AACxB,OAAO,EAGL,KAAK,wBAAwB,EAC9B,MAAM,wBAAwB,CAAA;AAW/B,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AAIxD,OAAO,EAGL,YAAY,EAEb,MAAM,YAAY,CAAA;AAEnB,eAAO,MAAM,+BAA+B,kBAAkB,CAAA;AAE9D,YAAY,EAAE,wBAAwB,EAAE,CAAA;AAOxC;;;;;;;GAOG;AACH,MAAM,WAAW,oBAAoB;IACnC,6DAA6D;IAC7D,WAAW,EAAE,MAAM,CAAA;IACnB,yCAAyC;IACzC,YAAY,EAAE,MAAM,CAAA;IACpB,4DAA4D;IAC5D,SAAS,EAAE,MAAM,CAAA;IACjB,sEAAsE;IACtE,MAAM,EAAE,eAAe,CAAA;IACvB,oEAAoE;IACpE,MAAM,EAAE,MAAM,CAAA;IACd,oDAAoD;IACpD,OAAO,EAAE,MAAM,CAAA;IACf,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,WAAW,CAAC,EAAE,MAAM,CA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BAAgB,CAAC,EAAE,MAAM,EAAE,CAAA;QAC3B,OAAO,CAAC,EAAE,OAAO,CAAC,wBAAwB,CAAC,CAAA;QAC3C,gBAAgB,CAAC,EAAE,wBAAwB,CAAA;QAC3C,UAAU,CAAC,EAAE,OAAO,CAAC,mBAAmB,CAAC,CAAA;KAC1C,GAAG,OAAO,CAAC,sBAAsB,CAAC;CA+BpC;AAED,OAAO,EAAE,YAAY,EAAE,CAAA"}
@@ -1,161 +0,0 @@
1
- /**
2
- * Static facts about the WorkBuddy / CodeBuddy subscription backend.
3
- *
4
- * WorkBuddy is Tencent's CodeBuddy IDE subscription. Its model backend is a
5
- * plain OpenAI-compatible `/chat/completions` endpoint that the official IDE
6
- * calls directly; this plugin speaks the same wire instead of going through a
7
- * converter process.
8
- *
9
- * Everything asserted here was measured against a live subscription (see the
10
- * comments on each constant); the surprising constraints are that the endpoint
11
- * is **stream-only** and that the international region requires the first
12
- * message to be a system prompt.
13
- */
14
- import type { WorkBuddyRegion } from '../../shared/workbuddy-contracts.ts';
15
- export declare const PROVIDER_ID = "workbuddy-subscription";
16
- export declare const PROVIDER_NAME = "WorkBuddy\uFF08CodeBuddy \u8BA2\u9605\uFF09";
17
- /** Domestic backend. */
18
- export declare const CN_BACKEND = "https://copilot.tencent.com";
19
- /**
20
- * Domains whose accounts live on a region-specific backend.
21
- *
22
- * A credential's `auth.domain` decides both the backend host and the region:
23
- * `*.workbuddy.ai` / `*.codebuddy.ai` are international, anything else is the
24
- * domestic `copilot.tencent.com` deployment.
25
- */
26
- export declare const INTL_DOMAIN_SUFFIXES: readonly [".workbuddy.ai", ".codebuddy.ai"];
27
- /** Default auth domain when a credential does not record one. */
28
- export declare const DEFAULT_DOMAIN = "www.codebuddy.cn";
29
- /** Chat surface, appended to a region backend. */
30
- export declare const CHAT_PATH = "/v2/chat/completions";
31
- /**
32
- * Gateway configuration/catalog surface.
33
- *
34
- * This is where the real model list lives: the chat host answers 404 to
35
- * `/v1/models`, but `/v3/config` returns every model with its context window,
36
- * output cap, image support, and accepted reasoning ladder. The official CLI
37
- * reads it at startup.
38
- */
39
- export declare const CONFIG_PATH = "/v3/config";
40
- /** Token refresh surface; the official IDE posts the refresh token here. */
41
- export declare const REFRESH_PATH = "/v2/plugin/auth/token/refresh";
42
- /** Billing/allowance surface; answers the per-package credit picture. */
43
- export declare const BILLING_PATH = "/billing/meter/get-user-resource";
44
- /**
45
- * Current-account surface.
46
- *
47
- * The browser-authorization token response carries only the `auth` block, so
48
- * the signed-in account's uid / nickname / UIN come from here — the same
49
- * endpoint the official client reads its account from. Measured live on both
50
- * deployments: it answers with the full account record for a valid bearer.
51
- */
52
- export declare const ACCOUNT_PATH = "/v2/plugin/account";
53
- /** Browser authorization state and credential-poll surfaces used by the CLI. */
54
- export declare const LOGIN_STATE_PATH = "/v2/plugin/auth/state";
55
- export declare const LOGIN_TOKEN_PATH = "/v2/plugin/auth/token";
56
- export declare const LOGIN_PLATFORM = "cli";
57
- export declare const LOGIN_PENDING_CODE = 11217;
58
- export declare const LOGIN_POLL_INTERVAL_MS = 1500;
59
- export declare const LOGIN_TIMEOUT_MS: number;
60
- /**
61
- * User-Agent every request carries.
62
- *
63
- * Measured: `CodeBuddyIDE` is accepted by the chat endpoint but rejected by
64
- * `/v3/config` with 400 `code 12403` ("check ua, get coding copilot version
65
- * error"), and the international chat endpoint answers 401 to it outright. The
66
- * CLI identity is accepted by all three surfaces on both regions, so it is the
67
- * single identity this route uses rather than switching per endpoint.
68
- */
69
- export declare const CLIENT_USER_AGENT = "CLI/2.63.2 CodeBuddy/2.63.2";
70
- /** Client identity headers the gateway gates on. */
71
- export declare const HEADER_USER_ID = "x-user-id";
72
- export declare const HEADER_ENTERPRISE_ID = "x-enterprise-id";
73
- export declare const HEADER_TENANT_ID = "x-tenant-id";
74
- export declare const HEADER_DOMAIN = "x-domain";
75
- export declare const HEADER_PRODUCT = "x-product";
76
- export declare const HEADER_IDE_NAME = "x-ide-name";
77
- export declare const HEADER_REQUESTED_WITH = "x-requested-with";
78
- export declare const CLIENT_PRODUCT = "SaaS";
79
- /**
80
- * Conversation header group the international gateway gates on.
81
- *
82
- * Measured 2026-10 on `www.workbuddy.ai`: a request carrying the identity
83
- * headers alone answers 400 `code 11128` whatever its message shape, while
84
- * adding exactly these five answers 200 with a normal SSE body. The other
85
- * headers the official client sends (trace context, `X-Agent-Intent`,
86
- * `X-Agent-Purpose`, `x-codebuddy-request`, its own user agent) were added one
87
- * at a time and each left the outcome unchanged, so this group is the minimal
88
- * sufficient set rather than a copy of the whole client.
89
- */
90
- export declare const HEADER_CONVERSATION_ID = "x-conversation-id";
91
- export declare const HEADER_CONVERSATION_REQUEST_ID = "x-conversation-request-id";
92
- export declare const HEADER_CONVERSATION_MESSAGE_ID = "x-conversation-message-id";
93
- export declare const HEADER_REQUEST_ID = "x-request-id";
94
- export declare const HEADER_ACP_CONNECTION_ID = "acp-connection-id";
95
- /** Refresh-token header the token endpoint reads. */
96
- export declare const HEADER_REFRESH_TOKEN = "x-refresh-token";
97
- /** Refresh origin marker; `workbuddy` for the .ai domains, `plugin` otherwise. */
98
- export declare const HEADER_REFRESH_SOURCE = "x-auth-refresh-source";
99
- /** Timeouts and cache lifetimes. */
100
- export declare const DISCOVERY_TIMEOUT_MS = 20000;
101
- export declare const CHAT_TIMEOUT_MS = 300000;
102
- export declare const QUOTA_CACHE_TTL_MS: number;
103
- export declare const STREAM_IDLE_TIMEOUT_MS = 300000;
104
- export declare const STREAM_IDLE_TIMEOUT_CODE = "LLM_STREAM_IDLE_TIMEOUT";
105
- export declare const DEFAULT_MAX_TOKENS = 32768;
106
- export declare const DEFAULT_CONTEXT_WINDOW = 128000;
107
- /**
108
- * Output cap for the models the catalog does not pin individually.
109
- *
110
- * The subscription models are served by several upstream vendors whose own
111
- * published caps differ; this is the conservative ceiling the request builder
112
- * uses when nothing more specific is known.
113
- */
114
- export declare const FALLBACK_MAX_TOKENS = 32768;
115
- /** Subscription backend error codes, all measured. */
116
- export declare const ERROR_CODE: {
117
- /** Request parameters rejected (bad image payload, unsupported field). */
118
- readonly BAD_REQUEST: 11101;
119
- /** Model not served in this region — a wrong-region request. */
120
- readonly MODEL_UNAVAILABLE: 11102;
121
- /**
122
- * Gateway channel verification refused the request.
123
- *
124
- * The code is overloaded upstream, so the message — not the code — decides
125
- * what it means. Measured 2026-09: the international chat endpoint answers it
126
- * for a request that does not open with a system turn. Measured 2026-10: the
127
- * same code, with `msg: "conversation id missing"`, is the answer to *every*
128
- * request that omits the {@link HEADER_CONVERSATION_ID} group, whatever its
129
- * message shape. Read `msg` before concluding the history is at fault.
130
- */
131
- readonly SECURITY_BLOCKED: 11128;
132
- /** Provider rejected the parameters, e.g. an unsupported image for that model. */
133
- readonly PROVIDER_REJECTED: 11133;
134
- /** Upstream vendor error. */
135
- readonly UPSTREAM_ERROR: 11134;
136
- /** Image could not be decoded or is not an accepted format. */
137
- readonly INVALID_IMAGE: 11135;
138
- /** Unsupported reasoning effort value. */
139
- readonly INVALID_REASONING: 11150;
140
- /** Usage exceeds the frequency limit; the message carries the reset instant. */
141
- readonly RATE_LIMITED: 6004;
142
- /** Generic usage-limit signal seen alongside 429s. */
143
- readonly USAGE_LIMIT: 14003;
144
- };
145
- /** Whether an auth domain belongs to the international deployment. */
146
- export declare function isIntlDomain(domain: string): boolean;
147
- /** Region one credential belongs to, decided by its auth domain. */
148
- export declare function regionForDomain(domain: string): WorkBuddyRegion;
149
- /**
150
- * Backend base URL for an auth domain.
151
- *
152
- * International accounts are served from the same apex as their auth domain
153
- * (`www.workbuddy.ai`, `www.codebuddy.ai`); everything else uses the domestic
154
- * gateway.
155
- */
156
- export declare function backendForDomain(domain: string): string;
157
- /** Refresh-source marker the token endpoint expects for one domain. */
158
- export declare function refreshSourceForDomain(domain: string): string;
159
- /** `www.workbuddy.ai` / `www.codebuddy.ai` origin used for CORS headers. */
160
- export declare function originForDomain(domain: string): string;
161
- //# sourceMappingURL=types.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"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