@goodandready/dsh-subscriptions 0.7.37 → 0.7.38

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/adapter.js CHANGED
@@ -59,8 +59,15 @@ export class SubscriptionAdapter extends LlmAdapter {
59
59
  const builtin = modelCatalog(provider, cfg ? cfg.models : undefined)
60
60
  const targetAccount = accounts.find((a) => a.hasToken)
61
61
  let targetLive = null
62
+ const targetCached = targetAccount && typeof this.deps.getDynamicModels === 'function'
63
+ ? this.deps.getDynamicModels(targetAccount.ref)
64
+ : null
62
65
 
63
- if (targetAccount) {
66
+ // #27: resolution runs on every request. Do not hit live metadata when a
67
+ // last-known-good per-account snapshot already exists; background refresh
68
+ // updates it without turning a temporary metadata outage into a capability
69
+ // verdict.
70
+ if (targetAccount && !(Array.isArray(targetCached) && targetCached.length)) {
64
71
  const baseFetch = pickFetch(this.deps, targetAccount.ref)
65
72
  const listModelsFetch = (url, init, opts) =>
66
73
  fetchWithTimeout(baseFetch, url, init, { timeoutMs: 15000, ...(opts || {}) })
@@ -97,6 +97,11 @@ export function getModelReasoningCapabilities(provider, modelId, catalog = []) {
97
97
  if (id.includes('reasoning') || id === 'grok-3-mini') {
98
98
  return { supported: true, levels: ['low', 'medium', 'high'], defaultEffort: 'medium' }
99
99
  }
100
+ // #27: grok-4.x supports reasoning effort even when the best-effort CLI
101
+ // metadata endpoint is temporarily unreachable.
102
+ if (/^grok-4(?:[.-]|$)/i.test(id)) {
103
+ return { supported: true, levels: ['low', 'medium', 'high'], defaultEffort: 'high' }
104
+ }
100
105
  return { supported: false, levels: [] }
101
106
  }
102
107
 
@@ -43,18 +43,37 @@ async function cliCatalogCached(blob, cfg, fetchImpl) {
43
43
  const now = Date.now()
44
44
  const hit = catalogCache.get(key)
45
45
  if (hit && now - hit.at < CATALOG_TTL_MS) return hit.map
46
- if (hit) catalogCache.delete(key)
47
- const map = await cliCatalog(blob, cfg, fetchImpl)
48
- if (map.size > 0) {
49
- catalogCache.set(key, { at: now, map })
50
- pruneCatalogCache(now)
46
+ try {
47
+ const map = await cliCatalog(blob, cfg, fetchImpl)
48
+ if (map.size > 0) {
49
+ catalogCache.set(key, { at: now, map })
50
+ pruneCatalogCache(now)
51
+ return map
52
+ }
53
+ // An empty response must not erase the last-known-good metadata.
54
+ if (hit) return hit.map
55
+ return map
56
+ } catch (err) {
57
+ if (hit) return hit.map
58
+ throw err
59
+ }
60
+ }
61
+
62
+ function grokFallbackReasoning(modelId) {
63
+ if (!/^grok-4(?:[.-]|$)/i.test(String(modelId || ''))) return undefined
64
+ return {
65
+ efforts: [
66
+ { id: 'high', name: 'High' },
67
+ { id: 'medium', name: 'Medium' },
68
+ { id: 'low', name: 'Low' },
69
+ ],
70
+ defaultEffort: 'high',
51
71
  }
52
- return map
53
72
  }
54
73
 
55
74
  function grokReasoningBody(modelId, effort, catalogMap) {
56
75
  const entry = catalogMap && catalogMap.get(modelId)
57
- const reasoning = entry && entry.reasoning
76
+ const reasoning = (entry && entry.reasoning) || grokFallbackReasoning(modelId)
58
77
  if (!reasoning || !reasoning.efforts || !reasoning.efforts.length) return undefined
59
78
  const allowed = new Set(reasoning.efforts.map((row) => row.id))
60
79
  const pick = effort != null && effort !== '' ? String(effort) : ''
@@ -221,7 +240,7 @@ export async function listModels(blob, cfg, fetchImpl) {
221
240
  try {
222
241
  const [res, extra] = await Promise.all([
223
242
  impl(MODELS, { headers: { Authorization: `Bearer ${blob.accessToken}`, Accept: 'application/json' } }),
224
- cliCatalog(blob, cfg, impl).catch(() => new Map()),
243
+ cliCatalogCached(blob, cfg, impl).catch(() => new Map()),
225
244
  ])
226
245
  const json = await readJson(res)
227
246
  const rows = []
@@ -229,6 +248,7 @@ export async function listModels(blob, cfg, fetchImpl) {
229
248
  const modelId = entry && entry.id
230
249
  if (!modelId || !isChatModel(modelId)) continue
231
250
  const enrich = extra.get(modelId) || {}
251
+ const reasoning = enrich.reasoning || grokFallbackReasoning(modelId)
232
252
  const note = /multi-agent/i.test(modelId)
233
253
  ? 'Chat only in Harness until xAI grants multi-agent tool beta.'
234
254
  : ''
@@ -237,6 +257,7 @@ export async function listModels(blob, cfg, fetchImpl) {
237
257
  name: enrich.name || modelId,
238
258
  inputModalities: grokModalities(modelId),
239
259
  ...enrich,
260
+ ...(reasoning ? { reasoning } : {}),
240
261
  ...(note ? { description: enrich.description ? `${enrich.description} ${note}` : note } : {}),
241
262
  })
242
263
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@goodandready/dsh-subscriptions",
3
- "version": "0.7.37",
3
+ "version": "0.7.38",
4
4
  "description": "Use ChatGPT Codex, Claude, Grok, Antigravity, Kimi, GLM, Cursor, Kiro, Copilot, Qwen, ERNIE, Spark, JetBrains, Perplexity, Replit, and Cody subscriptions as DeepSeek Harness LLM providers via OAuth.",
5
5
  "license": "MIT",
6
6
  "type": "module",