@goodandready/dsh-moa 0.2.8 → 0.2.9

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/pricing.js CHANGED
@@ -30,6 +30,14 @@ export const FALLBACK_RATES = { input: 0.50, output: 1.50, cacheHit: 0.15 }
30
30
  let memoryCatalog = null
31
31
  let lastFetchedAt = 0
32
32
 
33
+ /**
34
+ * Reset in-memory catalog cache (useful for tests and forced reload).
35
+ */
36
+ export function resetMemoryCatalog() {
37
+ memoryCatalog = null
38
+ lastFetchedAt = 0
39
+ }
40
+
33
41
  /**
34
42
  * Load cached catalog from disk into memory.
35
43
  */
@@ -58,10 +66,11 @@ export function loadCachedCatalog(cachePath = CACHE_FILE) {
58
66
  export async function fetchCatalog({
59
67
  url = CATALOG_URL,
60
68
  cachePath = CACHE_FILE,
61
- signal = AbortSignal.timeout(5000),
69
+ signal = null,
62
70
  } = {}) {
63
71
  try {
64
- const res = await fetch(url, { signal })
72
+ const fetchSignal = signal || (typeof AbortSignal?.timeout === 'function' ? AbortSignal.timeout(5000) : undefined)
73
+ const res = await fetch(url, { signal: fetchSignal })
65
74
  if (!res.ok) return loadCachedCatalog(cachePath)
66
75
  const json = await res.json()
67
76
  if (!json || !Array.isArray(json.data)) return loadCachedCatalog(cachePath)
@@ -109,7 +118,11 @@ export function refreshCatalogInBackground(cachePath = CACHE_FILE) {
109
118
  const catalog = loadCachedCatalog(cachePath)
110
119
  const isStale = !lastFetchedAt || Date.now() - lastFetchedAt > REFRESH_INTERVAL_MS
111
120
  if (isStale) {
112
- fetchCatalog({ cachePath }).catch(() => {})
121
+ try {
122
+ fetchCatalog({ cachePath }).catch(() => {})
123
+ } catch {
124
+ // safe fallback
125
+ }
113
126
  }
114
127
  return catalog
115
128
  }
@@ -192,3 +205,4 @@ export function estimateTokenCost(slot = {}, usage = {}, customPrices = {}, cach
192
205
  rates,
193
206
  }
194
207
  }
208
+
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@goodandready/dsh-moa",
3
- "version": "0.2.8",
3
+ "version": "0.2.9",
4
4
  "description": "Mixture of Agents (MoA) plugin for DeepSeek Harness with /moa slash command",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",