@dan-ai-studio/dshopencodego 0.1.53 → 0.1.54

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.
package/lib/client.js CHANGED
@@ -27,6 +27,7 @@ __export(index_exports, {
27
27
  module.exports = __toCommonJS(index_exports);
28
28
 
29
29
  // src/catalog/constants.ts
30
+ var BACKGROUND_RETRY_BACKOFF_MS = 5 * 6e4;
30
31
  var MODEL_LISTING_MAX_BYTES = 1024 * 1024;
31
32
  var MODEL_METADATA_MAX_BYTES = 16 * 1024 * 1024;
32
33
  var UNKNOWN_MODEL_PROBE_COOLDOWN_MS = 5 * 6e4;
package/lib/index.js CHANGED
@@ -42530,6 +42530,7 @@ var MODEL_METADATA_PROVIDER = "opencode-go";
42530
42530
  var METADATA_FETCH_TIMEOUT_MS = 1e4;
42531
42531
  var MODEL_METADATA_TIMEOUT_MS = 3e4;
42532
42532
  var METADATA_RETRY_DELAY_MS = 1500;
42533
+ var BACKGROUND_RETRY_BACKOFF_MS = 5 * 6e4;
42533
42534
  var MODEL_LISTING_MAX_BYTES = 1024 * 1024;
42534
42535
  var MODEL_METADATA_MAX_BYTES = 16 * 1024 * 1024;
42535
42536
  var UNKNOWN_MODEL_PROBE_COOLDOWN_MS = 5 * 6e4;
@@ -43285,6 +43286,8 @@ var OpencodeGoCatalog = class {
43285
43286
  probedAt = /* @__PURE__ */ new Map();
43286
43287
  /** The background refresh, kept so a caller can wait for it to be over. */
43287
43288
  backgroundRefresh;
43289
+ /** When the last background refresh was started, for the back-off. */
43290
+ lastRefreshAttemptAt = 0;
43288
43291
  constructor(options) {
43289
43292
  this.options = options;
43290
43293
  const cached = readFactsCache(options.cacheDir);
@@ -43348,7 +43351,9 @@ var OpencodeGoCatalog = class {
43348
43351
  */
43349
43352
  refreshInBackground() {
43350
43353
  if (this.pending !== void 0) return;
43351
- const refresh = this.build().then((snapshot2) => {
43354
+ if (Date.now() - this.lastRefreshAttemptAt < BACKGROUND_RETRY_BACKOFF_MS) return;
43355
+ this.lastRefreshAttemptAt = Date.now();
43356
+ const refresh = this.build(void 0, false).then((snapshot2) => {
43352
43357
  this.served = snapshot2;
43353
43358
  return snapshot2;
43354
43359
  }).finally(() => {
@@ -43440,13 +43445,17 @@ var OpencodeGoCatalog = class {
43440
43445
  /**
43441
43446
  * Revalidate every source, reusing the metadata document when it is unchanged.
43442
43447
  * @param signal - caller cancellation, forwarded to the documentation read.
43448
+ * @param retry - whether a failed metadata read is tried again. A caller
43449
+ * that is waiting for the answer wants it tried again; a refresh nobody
43450
+ * is waiting for does not, because the answer it wants is the one it
43451
+ * already has.
43443
43452
  */
43444
- async build(signal) {
43453
+ async build(signal, retry = true) {
43445
43454
  const builtin = builtinModels(this.options.baseURL);
43446
43455
  const readDocument = this.options.readDocument ?? ((signal2) => fetchGoDocument(signal2, { cacheDir: this.options.cacheDir }));
43447
43456
  const [listing, metadata, documentation] = await Promise.allSettled([
43448
43457
  fetchModelIds(this.options.baseURL),
43449
- this.refreshMetadata(builtin),
43458
+ this.refreshMetadata(builtin, retry),
43450
43459
  readDocument(signal)
43451
43460
  ]);
43452
43461
  const degradations = [];
@@ -43668,10 +43677,11 @@ var OpencodeGoCatalog = class {
43668
43677
  * @param builtin - the installed catalog, for the parse.
43669
43678
  * @returns the parsed metadata.
43670
43679
  */
43671
- async refreshMetadata(builtin) {
43680
+ async refreshMetadata(builtin, retry) {
43672
43681
  try {
43673
43682
  return await this.readMetadataDocument(builtin);
43674
43683
  } catch (first) {
43684
+ if (!retry) throw first;
43675
43685
  await new Promise((resolve3) => {
43676
43686
  setTimeout(resolve3, METADATA_RETRY_DELAY_MS);
43677
43687
  });
@@ -46198,7 +46208,7 @@ function createUpdateChecker(deps) {
46198
46208
  }
46199
46209
 
46200
46210
  // src/update/version.ts
46201
- var PLUGIN_VERSION = true ? "0.1.53" : "0.0.0-dev";
46211
+ var PLUGIN_VERSION = true ? "0.1.54" : "0.0.0-dev";
46202
46212
 
46203
46213
  // src/update/service.ts
46204
46214
  import { TypertRemoteService as TypertRemoteService2 } from "@deepseek-ai/dsh-typert-protocol";
@@ -33,6 +33,18 @@ export declare const MODEL_METADATA_TIMEOUT_MS = 30000;
33
33
  * document still fails inside the catalog build.
34
34
  */
35
35
  export declare const METADATA_RETRY_DELAY_MS = 1500;
36
+ /**
37
+ * How long a failed background refresh waits before it is tried again.
38
+ *
39
+ * A refresh that fails leaves the catalog's age where it was, so every call
40
+ * sees it as past its TTL and starts another. Without a back-off, a service
41
+ * that is down turns every model request into a full download attempt.
42
+ *
43
+ * Five minutes is short enough that a service that comes back is picked up
44
+ * soon, and long enough that a service that stays down is asked once, not
45
+ * once per request.
46
+ */
47
+ export declare const BACKGROUND_RETRY_BACKOFF_MS: number;
36
48
  /** Response caps: the listing is tiny, the metadata document is not. */
37
49
  export declare const MODEL_LISTING_MAX_BYTES: number;
38
50
  export declare const MODEL_METADATA_MAX_BYTES: number;
@@ -160,6 +160,8 @@ export declare class OpencodeGoCatalog {
160
160
  private readonly probedAt;
161
161
  /** The background refresh, kept so a caller can wait for it to be over. */
162
162
  private backgroundRefresh;
163
+ /** When the last background refresh was started, for the back-off. */
164
+ private lastRefreshAttemptAt;
163
165
  constructor(options: CatalogOptions);
164
166
  /**
165
167
  * The cached snapshot, refreshed when it is older than the configured TTL.
@@ -237,6 +239,10 @@ export declare class OpencodeGoCatalog {
237
239
  /**
238
240
  * Revalidate every source, reusing the metadata document when it is unchanged.
239
241
  * @param signal - caller cancellation, forwarded to the documentation read.
242
+ * @param retry - whether a failed metadata read is tried again. A caller
243
+ * that is waiting for the answer wants it tried again; a refresh nobody
244
+ * is waiting for does not, because the answer it wants is the one it
245
+ * already has.
240
246
  */
241
247
  private build;
242
248
  /** Merge the listing with the metadata document and the installed entries. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dan-ai-studio/dshopencodego",
3
- "version": "0.1.53",
3
+ "version": "0.1.54",
4
4
  "description": "OpenCode Go provider for DeepSeek Harness: live gateway catalog, per-conversation session header, usage",
5
5
  "type": "module",
6
6
  "license": "MIT",