dsh-plugin-subscription-oauth 0.16.2 → 0.17.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 (43) hide show
  1. package/README.dev.md +1 -1
  2. package/README.md +7 -6
  3. package/README.zh.dev.md +1 -1
  4. package/README.zh.md +7 -6
  5. package/lib/auth/workbuddy-flow.d.ts +1 -1
  6. package/lib/auth/workbuddy-flow.js +14 -9
  7. package/lib/client/index.js +10 -1
  8. package/lib/client.js +6 -1
  9. package/lib/client.js.map +1 -1
  10. package/lib/index.js +21 -0
  11. package/lib/providers/antigravity.d.ts +34 -4
  12. package/lib/providers/antigravity.js +100 -28
  13. package/lib/providers/ark-provider.d.ts +10 -0
  14. package/lib/providers/ark-provider.js +6 -0
  15. package/lib/providers/ark.d.ts +96 -10
  16. package/lib/providers/ark.js +176 -48
  17. package/lib/providers/catalog.d.ts +91 -0
  18. package/lib/providers/catalog.js +190 -0
  19. package/lib/providers/common.d.ts +14 -0
  20. package/lib/providers/common.js +23 -0
  21. package/lib/providers/glm-provider.d.ts +10 -0
  22. package/lib/providers/glm-provider.js +6 -0
  23. package/lib/providers/glm.d.ts +92 -16
  24. package/lib/providers/glm.js +172 -85
  25. package/lib/providers/grok.d.ts +106 -27
  26. package/lib/providers/grok.js +312 -128
  27. package/lib/providers/kimi-provider.d.ts +10 -0
  28. package/lib/providers/kimi-provider.js +8 -3
  29. package/lib/providers/kimi.d.ts +104 -32
  30. package/lib/providers/kimi.js +198 -129
  31. package/lib/providers/mimo-provider.d.ts +14 -1
  32. package/lib/providers/mimo-provider.js +17 -6
  33. package/lib/providers/mimo.d.ts +164 -19
  34. package/lib/providers/mimo.js +318 -19
  35. package/lib/providers/model-cache.d.ts +57 -0
  36. package/lib/providers/model-cache.js +105 -0
  37. package/lib/providers/responses-stream.d.ts +8 -0
  38. package/lib/providers/responses-stream.js +21 -5
  39. package/lib/providers/workbuddy-provider.d.ts +17 -0
  40. package/lib/providers/workbuddy-provider.js +14 -6
  41. package/lib/providers/workbuddy.d.ts +140 -13
  42. package/lib/providers/workbuddy.js +520 -55
  43. package/package.json +1 -1
@@ -32,14 +32,6 @@ export interface KimiSession extends SessionBase {
32
32
  * @returns the session, or undefined when required fields are missing.
33
33
  */
34
34
  export declare function parseKimiSession(value: unknown): KimiSession | undefined;
35
- /**
36
- * Kimi Code's live coding catalog.
37
- *
38
- * `kimi-for-coding` is the stable subscription alias Moonshot re-points at each
39
- * coding release; `k3` is the current flagship, with the `[1m]` suffix selecting
40
- * its 1M-token window.
41
- */
42
- export declare const KIMI_MODELS: readonly KimiModelEntry[];
43
35
  /** Constructor dependencies for {@link KimiAdapter}. */
44
36
  export interface KimiAdapterOptions {
45
37
  /** Resolved Kimi Code API base (`<base>/responses`). */
@@ -73,6 +65,14 @@ export interface KimiAdapterOptions {
73
65
  readUsage?: (account: string) => Promise<readonly UsageWindow[]>;
74
66
  /** Extra model ids from the plugin configuration, appended to the catalog. */
75
67
  extraModels?: readonly string[];
68
+ /**
69
+ * Model this route preselects, and therefore always offers.
70
+ *
71
+ * Configuration rather than a shipped fact: a subscription that re-points its
72
+ * alias at a new release follows the config instead of this build's release
73
+ * cadence. Defaults to {@link KIMI_DEFAULT_MODEL}.
74
+ */
75
+ defaultModel?: string;
76
76
  /**
77
77
  * The user's model rank for this route, most preferred first.
78
78
  *
@@ -96,36 +96,78 @@ export interface KimiAdapterOptions {
96
96
  * endpoint is the authority on what it serves, not this build.
97
97
  */
98
98
  userModels?: () => Promise<readonly string[]>;
99
+ /**
100
+ * The payload of the endpoint's last live listing, as the cache kept it.
101
+ *
102
+ * Read once per session, before the first catalog query, so the picker offers real
103
+ * models without asking the endpoint anything. A route that fetched once and cached
104
+ * the answer has no reason to fetch again on every refresh; the Settings "refresh
105
+ * models" action is what re-reads it.
106
+ */
107
+ cachedListing?: () => Promise<unknown>;
108
+ /** Record what a live listing just produced, replacing the cached table. */
109
+ saveListing?: (payload: unknown) => Promise<void>;
99
110
  }
100
111
  /** Kimi Code adapter serving the `kimi` provider route. */
101
112
  export declare class KimiAdapter extends LlmAdapter {
102
113
  private readonly options;
103
- /** Live catalog ids seen this session, used to accept renamed models. */
104
- private discovered;
105
- /** Image-generation model id, when discovery reported one. */
114
+ /**
115
+ * The catalog this route serves: entries derived from the endpoint's own listing,
116
+ * either the one just read or the one the cache kept from the last read.
117
+ *
118
+ * Undefined means neither source has produced a listing yet, so only the configured
119
+ * default model is offered until one does.
120
+ */
121
+ private live;
122
+ /** Whether the cached listing has been read; it is read at most once per session. */
123
+ private hydrated;
124
+ /** Image-generation model id, when the listing reported one. */
106
125
  private imageModel;
107
126
  /**
108
127
  * Fast-variant wire id per picker row, for the composer's quick-mode button.
109
128
  *
110
- * Seeded from the curated aliases — `kimi-for-coding-highspeed` is one — so the button
111
- * exists before any discovery run, and then updated from the live catalog, which is
112
- * the authority on what this account actually serves.
129
+ * Derived from the listing: `kimi-for-coding-highspeed` is a row of its own there,
130
+ * and pairs with `kimi-for-coding` because its name is that of a listed model plus
131
+ * the provider's own fast word.
113
132
  */
114
133
  private readonly fastVariants;
115
134
  /** Ids the user added by hand, cached so the sync catalog can name them. */
116
135
  private userAddedIds;
136
+ /**
137
+ * Model ids the endpoint renamed during this session, and what each became.
138
+ *
139
+ * Learned from the endpoint's own refusal (`Please set model id as \`k3\``), so a
140
+ * spelling retired after this build shipped is repaired without a plugin update. The
141
+ * first turn pays one refused request; every later turn goes straight to the current id.
142
+ */
143
+ private readonly renamed;
117
144
  /** Tools already reported as flattened, so each is stated once. */
118
145
  private readonly flattenedTools;
119
146
  constructor(options: KimiAdapterOptions);
120
147
  /**
121
- * Record the fast variants the curated catalog already names as aliases.
148
+ * Adopt the rows of one live listing as this route's catalog.
149
+ *
150
+ * Everything the picker shows is derived here from the endpoint's own answer: the
151
+ * rows that become picker entries, the fast variant that pairs with each row, and
152
+ * the image model that is called by an agent rather than chosen. Nothing about
153
+ * which models exist, or what each one is, is decided by this build.
154
+ *
155
+ * Fast variants ride with their base row instead of becoming rows of their own: they
156
+ * share the row's visibility switch and are reached by the composer's quick-mode
157
+ * button. A variant is recognized by its own name — the provider's fast word appended
158
+ * to a listed model's id — so no curated alias map is needed to pair them.
159
+ *
160
+ * @param rows - decoded rows of the endpoint's listing, in the endpoint's order.
161
+ * @returns the entries to publish, in picker order.
162
+ */
163
+ private adoptListing;
164
+ /**
165
+ * Read the cached listing, once, so the picker works without asking the endpoint.
122
166
  *
123
- * The alias is the recognition: `kimi-for-coding-highspeed` is stated as an accepted
124
- * id of `kimi-for-coding`, so the route can offer the quick-mode button without
125
- * waiting for a live list that may never name it. A row a live catalog already paired
126
- * keeps that pairing, so this only fills the gaps.
167
+ * Called before the first catalog query. A read failure is a cache miss, never a
168
+ * failure: the route simply has no listing until one is fetched.
127
169
  */
128
- private seedCuratedFastVariants;
170
+ hydrate(): Promise<void>;
129
171
  /** The fast pair one picker id belongs to, from either side. */
130
172
  fastPairOf(id: string): {
131
173
  baseId: string;
@@ -157,19 +199,27 @@ export declare class KimiAdapter extends LlmAdapter {
157
199
  */
158
200
  private catalog;
159
201
  /**
160
- * The catalog to present: the shipped entries in their curated order and with
161
- * their curated metadata, then any configured extra id, then any live id this
162
- * build does not know.
202
+ * The catalog to present: the models the endpoint's listing named, in its own order,
203
+ * each with the metadata that listing stated, then the configured extras.
163
204
  *
164
- * The live list never removes a shipped entry: the endpoint serves variants
165
- * such as `k3[1m]` that its own `/models` listing omits, so absence there is
166
- * not evidence of retirement.
205
+ * There is no shipped roster to fall back to. A listing is read once and cached (see
206
+ * {@link hydrate} and {@link fetchCatalog}), and that cached table is what the picker
207
+ * shows until the next read, so a model released, renamed or retired server-side is
208
+ * reflected without a plugin update or a request per refresh.
167
209
  */
168
210
  private shippedCatalog;
169
- /** Whether one shipped entry covers a live model id. */
170
- private entryMatches;
171
- /** Resolve a requested model id onto its catalog entry. */
211
+ /** Resolve a requested model id onto the entry the endpoint's listing described. */
172
212
  private entryFor;
213
+ /**
214
+ * The model one wire id names, when the endpoint has retired the spelling.
215
+ *
216
+ * Consulted only for an id the current listing does not serve, so an id the endpoint
217
+ * itself reports is always dispatched exactly as reported.
218
+ *
219
+ * @param model - the requested model id.
220
+ * @returns the current spelling, or undefined when the id is not a known retirement.
221
+ */
222
+ private repairModelId;
173
223
  /** Re-read the ids the user added by hand. */
174
224
  private syncUserModels;
175
225
  /**
@@ -179,9 +229,18 @@ export declare class KimiAdapter extends LlmAdapter {
179
229
  * the endpoint's own defaults are the honest description.
180
230
  */
181
231
  private addedEntries;
182
- /** Record the live catalog for the picker; failures keep the shipped list. */
232
+ /**
233
+ * Adopt the ids a caller reports as the served set, without a listing.
234
+ *
235
+ * {@link fetchCatalog} already derived the entries from the rows it read, and the
236
+ * controller reports those same ids back here; the entries it recorded are kept. A
237
+ * caller that only has ids (a test, another discovery path) gets conservative entries
238
+ * for them.
239
+ *
240
+ * @param ids - model ids the caller reports.
241
+ */
183
242
  discover(ids: readonly string[]): void;
184
- /** The curated catalog, for the Settings page's model list. */
243
+ /** The catalog, for the Settings page's model list. */
185
244
  catalogEntries(): readonly KimiModelEntry[];
186
245
  /** What this route itself serves, without the ids added by hand. */
187
246
  ownCatalogEntries(): readonly KimiModelEntry[];
@@ -191,6 +250,19 @@ export declare class KimiAdapter extends LlmAdapter {
191
250
  private identity;
192
251
  /** Resolve image blocks through the attachment service, when it is present. */
193
252
  private imageResolver;
194
- /** Read the live `/models` catalog, or undefined when unavailable. */
253
+ /**
254
+ * Read the endpoint's model listing and adopt it as this route's catalog.
255
+ *
256
+ * This is the one place a model table is produced, and it is the endpoint's own
257
+ * answer: what the listing names is what the picker offers, with the display name,
258
+ * context window, modalities and reasoning ladder the listing states. The rows are
259
+ * also handed to {@link KimiAdapterOptions.saveListing}, so the next session starts
260
+ * from this table instead of asking again — the Settings "refresh models" action is
261
+ * what re-reads it.
262
+ *
263
+ * @param accessToken - bearer for the account.
264
+ * @param signal - optional cancellation.
265
+ * @returns the model ids now served, or undefined when the listing is unavailable.
266
+ */
195
267
  fetchCatalog(accessToken: string, signal?: AbortSignal): Promise<readonly string[] | undefined>;
196
268
  }