dsh-keys-manager 0.3.2 → 0.3.3

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/index.d.ts CHANGED
@@ -1744,18 +1744,19 @@ export declare class KeysManagerService {
1744
1744
  private repairBinding;
1745
1745
  /**
1746
1746
  * Startup repair for an extra route installed before the capability index
1747
- * existed: its profile carries model rows with no `input` at all, so DSH
1748
- * treats an image model as text-only. Only the rows the pinned catalog marks
1749
- * image are filled, and only on a profile whose `models` still equal our own
1750
- * record — a list the user edited in Models is theirs. A second pass finds
1751
- * every row filled and writes nothing, and a refused write only warns: the
1747
+ * existed: its profile carries model rows with no `input` and no
1748
+ * `reasoningEfforts`, so DSH treats an image model as text-only and a
1749
+ * reasoning model as non-reasoning. Only the rows the pinned catalog describes
1750
+ * are filled, and only on a profile whose `models` still equal our own record —
1751
+ * a list the user edited in Models is theirs. A second pass finds every
1752
+ * indexed row filled and writes nothing, and a refused write only warns: the
1752
1753
  * route keeps working exactly as it did.
1753
1754
  *
1754
1755
  * A repair whose settings write landed but whose record never did (the store
1755
1756
  * flush was lost with the process) is healed from the profile itself: the
1756
- * live `models` equal exactly `repairImageModalities(record.models)`, so only
1757
- * the record is synced and the settings are left alone. Any other mismatch
1758
- * is a user list and stays untouched.
1757
+ * live `models` equal exactly the repaired rows, so only the record is synced
1758
+ * and the settings are left alone. Any other mismatch is a user list and stays
1759
+ * untouched.
1759
1760
  *
1760
1761
  * Every write below gates on {@link persistenceRefused}, not on `closing`
1761
1762
  * alone: `close()` raises `shutdownRequested` before it awaits the borrowed
package/lib/index.js CHANGED
@@ -17,7 +17,7 @@ import { AsyncLocalStorage } from 'node:async_hooks';
17
17
  import { createHash, randomBytes } from 'node:crypto';
18
18
  import { CURSOR_ROUTE, cursorCatalogModels } from 'dsh-llm-omp-transports';
19
19
  import * as transportModule from 'dsh-llm-omp-transports';
20
- import { mergeModelCapabilities, repairImageModalities } from './capabilities.js';
20
+ import { mergeModelCapabilities, repairModelCapabilities as repairModelRows, sanitizeReasoningEfforts } from './capabilities.js';
21
21
  import { KEY_LIMIT, TEST_SUCCESS_FINISH_KINDS, accountRef, applyFailureCooldown, bindingKey, classifyOAuthFailure, isSelectable, markKeySuccess, markKeyUsed, normalizeSettings, patchSettings, pickHealthyExcluding, pickRoundRobin, quotaRank, rankCandidates, shouldFailover, statusOfKey, statusOfProvider, validateKeyInput, validateKeyPatch, } from './core.js';
22
22
  import { signInCapable, signInProvider } from './oauth/providers.js';
23
23
  import { SignInCancelledError, runSignIn } from './oauth/signin.js';
@@ -344,9 +344,9 @@ function normalizeModel(model) {
344
344
  const modalities = input.filter((value) => value === 'text' || value === 'image');
345
345
  if (modalities.length > 0)
346
346
  next.input = [...new Set(modalities)];
347
- if (source.reasoningEfforts !== null && typeof source.reasoningEfforts === 'object') {
348
- next.reasoningEfforts = source.reasoningEfforts;
349
- }
347
+ const reasoningEfforts = sanitizeReasoningEfforts(source.reasoningEfforts);
348
+ if (reasoningEfforts !== undefined)
349
+ next.reasoningEfforts = reasoningEfforts;
350
350
  if (source.compat !== null && typeof source.compat === 'object') {
351
351
  next.compat = source.compat;
352
352
  }
@@ -7188,18 +7188,19 @@ export class KeysManagerService {
7188
7188
  }
7189
7189
  /**
7190
7190
  * Startup repair for an extra route installed before the capability index
7191
- * existed: its profile carries model rows with no `input` at all, so DSH
7192
- * treats an image model as text-only. Only the rows the pinned catalog marks
7193
- * image are filled, and only on a profile whose `models` still equal our own
7194
- * record — a list the user edited in Models is theirs. A second pass finds
7195
- * every row filled and writes nothing, and a refused write only warns: the
7191
+ * existed: its profile carries model rows with no `input` and no
7192
+ * `reasoningEfforts`, so DSH treats an image model as text-only and a
7193
+ * reasoning model as non-reasoning. Only the rows the pinned catalog describes
7194
+ * are filled, and only on a profile whose `models` still equal our own record —
7195
+ * a list the user edited in Models is theirs. A second pass finds every
7196
+ * indexed row filled and writes nothing, and a refused write only warns: the
7196
7197
  * route keeps working exactly as it did.
7197
7198
  *
7198
7199
  * A repair whose settings write landed but whose record never did (the store
7199
7200
  * flush was lost with the process) is healed from the profile itself: the
7200
- * live `models` equal exactly `repairImageModalities(record.models)`, so only
7201
- * the record is synced and the settings are left alone. Any other mismatch
7202
- * is a user list and stays untouched.
7201
+ * live `models` equal exactly the repaired rows, so only the record is synced
7202
+ * and the settings are left alone. Any other mismatch is a user list and stays
7203
+ * untouched.
7203
7204
  *
7204
7205
  * Every write below gates on {@link persistenceRefused}, not on `closing`
7205
7206
  * alone: `close()` raises `shutdownRequested` before it awaits the borrowed
@@ -7219,7 +7220,7 @@ export class KeysManagerService {
7219
7220
  const live = this.profileAt(record.settingsNs, record.settingsPath);
7220
7221
  if (live === undefined)
7221
7222
  continue;
7222
- const models = repairImageModalities(extraId, record.models);
7223
+ const models = repairModelRows(extraId, record.models);
7223
7224
  if (models === undefined)
7224
7225
  continue;
7225
7226
  if (JSON.stringify(live.models) !== JSON.stringify(record.models)) {
@@ -7252,7 +7253,7 @@ export class KeysManagerService {
7252
7253
  this.store.touch();
7253
7254
  }
7254
7255
  catch (error) {
7255
- this.pushWarning(`Did not store the catalog image capability on the ${record.provider} profile: ${error instanceof Error ? error.message : String(error)}`);
7256
+ this.pushWarning(`Did not store the catalog capabilities on the ${record.provider} profile: ${error instanceof Error ? error.message : String(error)}`);
7256
7257
  }
7257
7258
  }
7258
7259
  }
@@ -7721,7 +7722,7 @@ export class KeysManagerService {
7721
7722
  */
7722
7723
  async discoverModels(extra, value) {
7723
7724
  if (extra.headerEnv !== undefined)
7724
- return { models: normalizeModels(extra.models) };
7725
+ return { models: mergeModelCapabilities(extra.id, normalizeModels(extra.models)) };
7725
7726
  let discovered = [];
7726
7727
  let failure;
7727
7728
  try {
@@ -7733,7 +7734,9 @@ export class KeysManagerService {
7733
7734
  const models = discoveredModels(extra.id, discovered);
7734
7735
  if (models.length > 0)
7735
7736
  return { models, failure };
7736
- return { models: normalizeModels(extra.models), failure };
7737
+ // A seed-installed route must behave like a discovered one, so the same index
7738
+ // fills its modalities and thinking ladders before the profile is written.
7739
+ return { models: mergeModelCapabilities(extra.id, normalizeModels(extra.models)), failure };
7737
7740
  }
7738
7741
  /**
7739
7742
  * Remote: install and adopt one extra built-in provider.
@@ -7789,6 +7792,10 @@ export class KeysManagerService {
7789
7792
  extraId,
7790
7793
  api: existing.api ?? extra.api,
7791
7794
  baseURL: existing.baseURL ?? extra.baseURL,
7795
+ // No capability merge here: this branch writes only `apiKeyEnv`/`headers`
7796
+ // and adopts the profile's own rows, so a merged record would disagree
7797
+ // with the profile it adopted and the startup repair — which only acts on
7798
+ // a record that still matches its profile — could never heal it.
7792
7799
  models: normalizeModels(existing.models).length > 0 ? normalizeModels(existing.models) : normalizeModels(extra.models),
7793
7800
  adoptedAt: Date.now(),
7794
7801
  cursor: 0,
@@ -7834,7 +7841,7 @@ export class KeysManagerService {
7834
7841
  // mutation for its whole 20 s timeout before the row appears (F3).
7835
7842
  const found = importedFrom === null
7836
7843
  ? await this.discoverModels(extra, input.value)
7837
- : { models: normalizeModels(extra.models) };
7844
+ : { models: mergeModelCapabilities(extra.id, normalizeModels(extra.models)) };
7838
7845
  const { models, failure } = found;
7839
7846
  // The sign-in branch never probed the endpoint, so it cannot report a
7840
7847
  // discovery result.