@goodandready/dsh-messenger-gateway 0.4.4 → 0.4.5
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/adapters/telegram.js +597 -596
- package/lib/client.js +11 -6
- package/lib/forum-mirror.js +105 -105
- package/lib/gateway-callbacks.js +188 -187
- package/lib/gateway-commands.js +587 -584
- package/lib/gateway.js +7 -1
- package/lib/http.js +16 -3
- package/lib/index.js +544 -540
- package/lib/models.js +29 -2
- package/package.json +1 -1
package/lib/models.js
CHANGED
|
@@ -1,13 +1,33 @@
|
|
|
1
1
|
export const MODEL_PAGE_SIZE = 10
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
let catalogCache = new WeakMap()
|
|
4
|
+
|
|
5
|
+
export function clearModelCatalogCache() {
|
|
6
|
+
catalogCache = new WeakMap()
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export async function listModelCatalog(ctx, fallback = {}, options = {}) {
|
|
10
|
+
const llm = ctx?.get?.('llm') || ctx?.llm
|
|
11
|
+
const ttlMs = typeof options.ttlMs === 'number' ? options.ttlMs : 60_000
|
|
12
|
+
const bypass = Boolean(options.bypassCache)
|
|
13
|
+
const now = Date.now()
|
|
14
|
+
|
|
15
|
+
if (llm && typeof llm === 'object' && !bypass) {
|
|
16
|
+
const cached = catalogCache.get(llm)
|
|
17
|
+
if (cached && (now - cached.timestamp < ttlMs)) {
|
|
18
|
+
return {
|
|
19
|
+
providers: [...cached.providers],
|
|
20
|
+
modelsByProvider: new Map(cached.modelsByProvider),
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
4
25
|
const result = {
|
|
5
26
|
providers: [],
|
|
6
27
|
modelsByProvider: new Map(),
|
|
7
28
|
}
|
|
8
29
|
|
|
9
30
|
// 1. Try ctx.llm if available
|
|
10
|
-
const llm = ctx?.get?.('llm') || ctx?.llm
|
|
11
31
|
if (llm?.listProviders) {
|
|
12
32
|
try {
|
|
13
33
|
const providers = await llm.listProviders()
|
|
@@ -25,6 +45,13 @@ export async function listModelCatalog(ctx, fallback = {}) {
|
|
|
25
45
|
result.modelsByProvider.set(pId, [])
|
|
26
46
|
}
|
|
27
47
|
}
|
|
48
|
+
if (llm && typeof llm === 'object' && result.providers.length > 0) {
|
|
49
|
+
catalogCache.set(llm, {
|
|
50
|
+
timestamp: now,
|
|
51
|
+
providers: result.providers,
|
|
52
|
+
modelsByProvider: new Map(result.modelsByProvider),
|
|
53
|
+
})
|
|
54
|
+
}
|
|
28
55
|
} catch (err) {
|
|
29
56
|
/* safe fallback when ctx.llm.listProviders is unavailable or throws */
|
|
30
57
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@goodandready/dsh-messenger-gateway",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.5",
|
|
4
4
|
"description": "Telegram messenger bridge for DeepSeek Harness: sessions, steer, homes, inline asks, notify bridge, and optional TTS voice notes.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|