@myrialabs/clopen 0.4.46 → 0.4.47
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.
|
@@ -26,6 +26,31 @@ export interface ModelsDevProvider {
|
|
|
26
26
|
api: string | null;
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
+
/**
|
|
30
|
+
* OpenAI-compatible providers that models.dev doesn't list. They ride the same
|
|
31
|
+
* path as catalog providers with an `api` URL: stored with `api_url`, the
|
|
32
|
+
* account key becomes the bearer, and models are discovered from `/models`.
|
|
33
|
+
* A models.dev entry with the same id wins, so these retire themselves once
|
|
34
|
+
* upstream adds them.
|
|
35
|
+
*/
|
|
36
|
+
const CURATED_PROVIDERS: ModelsDevProvider[] = [
|
|
37
|
+
{
|
|
38
|
+
id: 'vikey',
|
|
39
|
+
name: 'Vikey',
|
|
40
|
+
npm: '@ai-sdk/openai-compatible',
|
|
41
|
+
env: ['VIKEY_API_KEY'],
|
|
42
|
+
api: 'https://api.vikey.ai/v1',
|
|
43
|
+
},
|
|
44
|
+
];
|
|
45
|
+
|
|
46
|
+
/** Merge curated providers into a models.dev catalog, keeping it name-sorted. */
|
|
47
|
+
export function withCuratedProviders(catalog: ModelsDevProvider[]): ModelsDevProvider[] {
|
|
48
|
+
const ids = new Set(catalog.map(c => c.id));
|
|
49
|
+
const extras = CURATED_PROVIDERS.filter(c => !ids.has(c.id));
|
|
50
|
+
if (extras.length === 0) return catalog;
|
|
51
|
+
return [...catalog, ...extras].sort((a, b) => a.name.localeCompare(b.name));
|
|
52
|
+
}
|
|
53
|
+
|
|
29
54
|
/**
|
|
30
55
|
* Fetch models.dev/api.json and cache a minimal provider catalog in the DB.
|
|
31
56
|
* Returns the parsed catalog.
|
|
@@ -68,7 +93,7 @@ export async function fetchAndCacheModelsDevCatalog(): Promise<ModelsDevProvider
|
|
|
68
93
|
settingsQueries.set(CACHE_TS_KEY, new Date().toISOString());
|
|
69
94
|
|
|
70
95
|
debug.log('engine', `Cached ${catalog.length} providers from models.dev`);
|
|
71
|
-
return catalog;
|
|
96
|
+
return withCuratedProviders(catalog);
|
|
72
97
|
}
|
|
73
98
|
|
|
74
99
|
/**
|
|
@@ -82,7 +107,7 @@ export function getCachedModelsDevCatalog(): { catalog: ModelsDevProvider[]; cac
|
|
|
82
107
|
|
|
83
108
|
try {
|
|
84
109
|
return {
|
|
85
|
-
catalog: JSON.parse(cached.value) as ModelsDevProvider[],
|
|
110
|
+
catalog: withCuratedProviders(JSON.parse(cached.value) as ModelsDevProvider[]),
|
|
86
111
|
cachedAt: cachedAt.value,
|
|
87
112
|
};
|
|
88
113
|
} catch {
|
|
@@ -551,9 +551,11 @@ async function buildProviderSection(): Promise<Record<string, unknown>> {
|
|
|
551
551
|
// malformed options — proceed to auto-discover
|
|
552
552
|
}
|
|
553
553
|
|
|
554
|
-
|
|
554
|
+
// `advertisedContext` comes from discovery: many OpenAI-compatible
|
|
555
|
+
// gateways report `context_window`/`context_length` on /models.
|
|
556
|
+
const addModel = (id: string, advertisedContext?: number) => {
|
|
555
557
|
const lim = modelLimits[id];
|
|
556
|
-
models[id] = { name: modelNames[id] || id, limit: { context: lim?.context || defaultContext, output: lim?.output || defaultOutput } };
|
|
558
|
+
models[id] = { name: modelNames[id] || id, limit: { context: lim?.context || advertisedContext || defaultContext, output: lim?.output || defaultOutput } };
|
|
557
559
|
};
|
|
558
560
|
|
|
559
561
|
for (const id of storedModels) {
|
|
@@ -569,9 +571,9 @@ async function buildProviderSection(): Promise<Record<string, unknown>> {
|
|
|
569
571
|
signal: AbortSignal.timeout(3000),
|
|
570
572
|
});
|
|
571
573
|
if (res.ok) {
|
|
572
|
-
const body = await res.json() as { data?: { id: string }[] };
|
|
574
|
+
const body = await res.json() as { data?: { id: string; context_window?: number; context_length?: number }[] };
|
|
573
575
|
for (const m of body.data ?? []) {
|
|
574
|
-
addModel(m.id);
|
|
576
|
+
addModel(m.id, m.context_window || m.context_length);
|
|
575
577
|
}
|
|
576
578
|
}
|
|
577
579
|
} catch {
|
|
@@ -10,6 +10,7 @@ import { engineQueries } from '../../../database/queries';
|
|
|
10
10
|
import {
|
|
11
11
|
fetchAndCacheModelsDevCatalog,
|
|
12
12
|
getCachedModelsDevCatalog,
|
|
13
|
+
withCuratedProviders,
|
|
13
14
|
} from '../../../engine/adapters/opencode/presets';
|
|
14
15
|
import { debug } from '$shared/utils/logger';
|
|
15
16
|
|
|
@@ -268,7 +269,7 @@ export const openCodeProviderHandler = createRouter()
|
|
|
268
269
|
return { catalog, cachedAt: new Date().toISOString() };
|
|
269
270
|
} catch (error) {
|
|
270
271
|
debug.error('engine', 'Failed to fetch models.dev catalog:', error);
|
|
271
|
-
return { catalog: [], cachedAt: null };
|
|
272
|
+
return { catalog: withCuratedProviders([]), cachedAt: null };
|
|
272
273
|
}
|
|
273
274
|
})
|
|
274
275
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@myrialabs/clopen",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.47",
|
|
4
4
|
"description": "All-in-one web workspace for AI coding agents — Claude Code, OpenCode, Codex, Copilot, Qwen Code, Pi, Cline, and Cursor — with chat, terminal, git, browser preview, database client, checkpoints, and real-time collaboration",
|
|
5
5
|
"author": "Myria Labs",
|
|
6
6
|
"license": "MIT",
|