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
@@ -48,11 +48,14 @@ export declare const GROK_DEFAULT_MAX_TOKENS = 32000;
48
48
  /** Refresh when the access token has less than this much life left. */
49
49
  export declare const GROK_PREEMPT_MS: number;
50
50
  /**
51
- * Curated catalog entries.
51
+ * The cold-start seed: what this build knows about xAI's models before either of the
52
+ * account's own listings has been read.
52
53
  *
53
- * Seeds only what the provider's own documentation names; everything else the
54
- * account is entitled to arrives through live discovery, so a new model does not
55
- * need a plugin release.
54
+ * A seed, never a roster. It decides which ids exist only until a listing has been read
55
+ * — the cached one at startup, or a fresh one on "refresh models" — and afterwards it
56
+ * describes only the fields those listings left silent. A fact the endpoint states,
57
+ * a context window included, always wins over anything here, so a model released,
58
+ * renamed or retired server-side reaches the picker without a plugin release.
56
59
  */
57
60
  export declare const GROK_MODELS: readonly CatalogEntry[];
58
61
  /** A stored Grok (X Premium) login. */
@@ -106,12 +109,6 @@ export declare function refreshGrokToken(input: {
106
109
  tokenEndpoint: string;
107
110
  refreshToken: string;
108
111
  }): Promise<GrokTokens>;
109
- /** One CLI-catalog entry's capability metadata. */
110
- interface GrokCliMetadata {
111
- contextWindow?: number;
112
- reasoningEfforts?: readonly string[];
113
- defaultEffort?: string;
114
- }
115
112
  /** True when a model id names an image-generation model. */
116
113
  export declare function isImageModel(id: string): boolean;
117
114
  /** True when a model id names a fast/lightspeed variant of a base model. */
@@ -224,21 +221,66 @@ export interface GrokAdapterOptions {
224
221
  onCredentialRejected?: (account: string) => void;
225
222
  /** Read one account's metered windows, so the streamer can steer away from a spent one. */
226
223
  readUsage?: ((account: string) => Promise<readonly UsageWindow[]>) | undefined;
224
+ /**
225
+ * The endpoint's last live payload, from this plugin's cache.
226
+ *
227
+ * Read once per session, before the first catalog query, so the picker offers real
228
+ * models without asking the endpoint anything. The Settings "refresh models" action is
229
+ * what re-reads it; a picker query never does.
230
+ */
231
+ cachedListing?: () => Promise<unknown>;
232
+ /** Record what a live listing just produced, replacing the cached table. */
233
+ saveListing?: (payload: unknown) => Promise<void>;
227
234
  }
228
235
  /** Grok wire adapter: one instance serves the `grok` provider route. */
229
236
  export declare class GrokAdapter extends LlmAdapter {
230
237
  private readonly options;
231
- /** Live model ids seen this session. */
232
- private discovered;
238
+ /**
239
+ * The catalog this route serves: entries derived from the endpoint's own two
240
+ * listings, either the pair just read or the pair the cache kept from the last read.
241
+ *
242
+ * Undefined means neither source has produced a listing yet, so the cold-start seed
243
+ * is all this build can honestly offer.
244
+ */
245
+ private live;
246
+ /** Whether the cached listing has been read; it is read at most once per session. */
247
+ private hydrated;
233
248
  /** Capability metadata from the CLI catalog, keyed by model id. */
234
249
  private readonly metadata;
235
250
  /** Fast-variant wire id per base model, for the picker's quick-mode button. */
236
251
  private readonly fastVariants;
237
- /** Image-generation model id, when discovery reported one. */
252
+ /** The context variant one base row dispatches to, so `@500k` is never typed by hand. */
253
+ private readonly defaultContext;
254
+ /** Image-generation model id, when the listing reported one. */
238
255
  private imageModel;
239
256
  /** Ids the user added by hand, cached so the sync catalog can name them. */
240
257
  private userAddedIds;
241
258
  constructor(options: GrokAdapterOptions);
259
+ /**
260
+ * Adopt the two listings of one live read as this route's catalog.
261
+ *
262
+ * Everything the picker shows is derived here from the endpoint's own answers: the
263
+ * public `/models` rows decide membership and state each model's display name, window
264
+ * and modalities, and the account's CLI catalog states the reasoning ladder and names
265
+ * the fast variants — the one thing the public list omits.
266
+ *
267
+ * A fast variant or an `@Nk` context variant rides with its base row instead of becoming
268
+ * a row of its own: the variant is a wire id the composer dispatches, never a picker
269
+ * row, so the user always has a way back to the standard model.
270
+ *
271
+ * @param payload - the cached or freshly assembled `{ public, cli }` payload.
272
+ * @returns the entries to publish, in the endpoint's own order; undefined when the
273
+ * payload names no model at all, so the caller keeps whatever it already had.
274
+ */
275
+ private adoptListing;
276
+ /**
277
+ * Read the cached listing, once, so the picker works without asking the endpoint.
278
+ *
279
+ * Called before the first catalog query, and fired at construction by the route's
280
+ * factory because the Settings page reads the catalog synchronously. A read failure is
281
+ * a cache miss, never a failure: the route simply has no listing until one is fetched.
282
+ */
283
+ hydrate(): Promise<void>;
242
284
  providerInfo(provider: string): LlmProviderInfo;
243
285
  providerRetryPolicy(): undefined;
244
286
  listModels(_provider: string): Promise<readonly LlmModelInfo[]>;
@@ -252,9 +294,17 @@ export declare class GrokAdapter extends LlmAdapter {
252
294
  */
253
295
  private catalog;
254
296
  /**
255
- * The catalog to present: curated seeds with their shipped metadata, then any
256
- * live id this build does not know, enriched from the CLI catalog when it
257
- * disclosed that model's context window or reasoning ladder.
297
+ * The catalog to present: the models both of the endpoint's listings named, in the
298
+ * public list's own order, each with the metadata the listings stated.
299
+ *
300
+ * There is no shipped roster to fall back to. The listings are read once and cached
301
+ * (see {@link hydrate} and {@link fetchCatalog}), and that cached table is what the
302
+ * picker shows until the next read, so a model released, renamed or retired
303
+ * server-side is reflected without a plugin update or a request per refresh.
304
+ *
305
+ * {@link GROK_MODELS} is only the cold-start seed: it decides membership while neither
306
+ * listing has been read, and afterwards describes the fields the listings left silent.
307
+ * A live fact, a context window included, always wins over it.
258
308
  */
259
309
  private shippedCatalog;
260
310
  /** Re-read the ids the user added by hand. */
@@ -266,8 +316,18 @@ export declare class GrokAdapter extends LlmAdapter {
266
316
  * the endpoint's own defaults are the honest description.
267
317
  */
268
318
  private addedEntries;
269
- /** Record the live catalog for the picker. */
270
- discover(ids: readonly string[], metadata?: ReadonlyMap<string, GrokCliMetadata>): void;
319
+ /**
320
+ * Adopt the ids a caller reports as the served set, without a listing.
321
+ *
322
+ * {@link fetchCatalog} already derived the entries from the rows it read, and the
323
+ * controller reports the union of every account's ids back here; the entries it
324
+ * recorded are kept, and an id no entry describes gets a conservative row described by
325
+ * the cold-start seed. An id the caller does not report is dropped: the reported set is
326
+ * the endpoint's whole answer.
327
+ *
328
+ * @param ids - model ids the caller reports.
329
+ */
330
+ discover(ids: readonly string[]): void;
271
331
  /** The fast/lightspeed variant wire id for a base model, when discovery reported one. */
272
332
  fastVariant(baseId: string): string | undefined;
273
333
  /** The fast pair one picker id belongs to, from either side. */
@@ -282,8 +342,6 @@ export declare class GrokAdapter extends LlmAdapter {
282
342
  /** What this route itself serves, without the ids added by hand. */
283
343
  ownCatalogEntries(): readonly CatalogEntry[];
284
344
  /** Build and send one request for one model. */
285
- /** The default context variant per base model, set during discovery. */
286
- private defaultContext;
287
345
  /** Resolve a model id to the wire id the endpoint accepts (largest context). */
288
346
  resolveModelId(model: string): string;
289
347
  /** Record one default-context mapping. */
@@ -292,9 +350,18 @@ export declare class GrokAdapter extends LlmAdapter {
292
350
  /** Resolve image blocks through the attachment service, when it is present. */
293
351
  private imageResolver;
294
352
  /**
295
- * Read the live model list, and the CLI catalog's capability metadata.
296
- * @param accessToken - bearer for the account's models.
297
- * @returns the model ids, or undefined when discovery is off or unavailable.
353
+ * Read both of the endpoint's listings and adopt them as this route's catalog.
354
+ *
355
+ * This is the one place a model table is produced, and it is the endpoint's own answer:
356
+ * what the public list names is what the picker offers, and the account's CLI catalog
357
+ * states the capabilities and names the fast variants that list omits. The rows are also
358
+ * handed to {@link GrokAdapterOptions.saveListing}, so the next session starts from this
359
+ * table instead of asking again — the Settings "refresh models" action is what re-reads
360
+ * it, and a picker query never does.
361
+ *
362
+ * @param accessToken - bearer for the account.
363
+ * @param signal - optional cancellation.
364
+ * @returns the model ids now served, or undefined when the listing is unavailable.
298
365
  */
299
366
  fetchCatalog(accessToken: string, signal?: AbortSignal): Promise<readonly string[] | undefined>;
300
367
  /**
@@ -304,16 +371,18 @@ export declare class GrokAdapter extends LlmAdapter {
304
371
  */
305
372
  private noteWireVariants;
306
373
  /**
307
- * Read per-model capabilities from the CLI catalog; failures are silent.
374
+ * Read the account's CLI catalog; a failure is an empty listing, not an error.
308
375
  *
309
376
  * The catalog answers only for the signed-in account's own bearer — an anonymous
310
- * request is refused — and it, unlike the public `/models` list, names the account's
311
- * fast variant.
377
+ * request is refused — and it, unlike the public `/models` list, states per-model
378
+ * context windows and reasoning ladders and names the account's fast variant. The rows
379
+ * are returned verbatim so both the fresh catalog and the cached payload are derived
380
+ * from the same parse.
312
381
  *
313
382
  * @param fetchFn - fetch implementation.
314
383
  * @param signal - caller cancellation.
315
384
  * @param accessToken - the account's bearer.
316
- * @returns the capability metadata and every id the catalog named.
385
+ * @returns the decoded rows, or an empty list when the catalog is unavailable.
317
386
  */
318
387
  private readCliCatalog;
319
388
  }
@@ -338,6 +407,16 @@ export interface GrokProviderOptions {
338
407
  fetchFn?: FetchFn;
339
408
  /** Discovery fetch override, for tests. */
340
409
  discoveryFetchFn?: FetchFn;
410
+ /**
411
+ * The endpoint's last live payload, from this plugin's cache.
412
+ *
413
+ * The cached table is what the picker shows before any request: the endpoint's own
414
+ * answer from the last read, so a release does not need a plugin update and a refresh
415
+ * does not need a request.
416
+ */
417
+ cachedListing?: () => Promise<unknown>;
418
+ /** Record what a live listing just produced, replacing the cached table. */
419
+ saveListing?: (payload: unknown) => Promise<void>;
341
420
  }
342
421
  /**
343
422
  * Build the `grok` route: its adapter and its login/lifecycle controller.