@ran-sh/dsh-crew 0.3.6 → 0.3.7
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/.claude-plugin/plugin.json +8 -8
- package/.mcp.json +8 -8
- package/LICENSE +21 -21
- package/README.de.md +359 -359
- package/README.es.md +359 -359
- package/README.fr.md +359 -359
- package/README.hi.md +359 -359
- package/README.id.md +359 -359
- package/README.ja.md +359 -359
- package/README.ko.md +359 -359
- package/README.md +125 -180
- package/README.pt.md +359 -359
- package/README.ru.md +359 -359
- package/README.th.md +359 -359
- package/README.tr.md +359 -359
- package/README.vi.md +359 -359
- package/README.zh-TW.md +359 -359
- package/README.zh.md +125 -180
- package/agents/ds-flash.md +26 -26
- package/agents/ds-pro.md +32 -32
- package/agents/ds-reviewer.md +23 -23
- package/agents/ds-worker.md +22 -22
- package/codex/agents/ds-flash.toml +30 -30
- package/codex/agents/ds-pro.toml +31 -31
- package/codex/agents/ds-reviewer.toml +28 -28
- package/codex/agents/ds-worker.toml +28 -28
- package/codex/prompts/dsh-config.md +3 -3
- package/codex/prompts/dsh-status.md +1 -1
- package/commands/config.md +11 -11
- package/commands/off.md +5 -5
- package/commands/on.md +5 -5
- package/commands/status.md +5 -5
- package/cordis.patch.yml +4 -4
- package/lib/client.js +3446 -2765
- package/package.json +131 -131
- package/scripts/build-client.mjs +28 -28
- package/scripts/live-crew-smoke.mjs +39 -39
- package/scripts/live-policy-matrix.mjs +177 -177
- package/scripts/policy-probe.mjs +101 -101
- package/scripts/setup.mjs +284 -284
- package/scripts/smoke-real.mjs +110 -110
- package/scripts/smoke.mjs +78 -78
- package/scripts/verify-installer-fix.mjs +26 -26
- package/src/adaptive-routing.mjs +260 -260
- package/src/client/activation-summary.tsx +64 -64
- package/src/client/collapsible-sections.mjs +55 -0
- package/src/client/entry.tsx +236 -236
- package/src/client/index.tsx +1213 -1120
- package/src/config-readiness.mjs +59 -59
- package/src/delivery.mjs +205 -205
- package/src/dsh-cli-runtime.mjs +239 -239
- package/src/failure-classification.mjs +172 -172
- package/src/hub/entry.mjs +98 -98
- package/src/hub-client.mjs +132 -132
- package/src/hub-compatibility.mjs +49 -49
- package/src/i18n.mjs +19 -19
- package/src/install/cli.mjs +28 -28
- package/src/install/install-legacy.mjs +462 -462
- package/src/install/install.mjs +451 -451
- package/src/install/npx-lifecycle.mjs +1055 -1055
- package/src/mcp-runtime.mjs +257 -257
- package/src/model-catalog.mjs +173 -173
- package/src/model-routing.mjs +391 -391
- package/src/policy.mjs +197 -197
- package/src/readiness-matrix.mjs +169 -169
- package/src/runtime-controls.mjs +90 -90
- package/src/runtime-identity.mjs +108 -108
- package/src/server.mjs +477 -477
- package/src/status-shard.mjs +52 -52
- package/src/structured-error-code.mjs +38 -38
- package/src/vision-route.mjs +138 -138
- package/src/workflow-runtime.mjs +573 -573
- package/src/workflow.mjs +160 -160
- package/src/workspace-audit.mjs +231 -231
- package/src/workspace-isolation.mjs +365 -365
- package/statusline/statusline.sh +14 -14
- package/statusline/worker-segment.sh +35 -35
- package/worker.cordis.yml +77 -77
package/src/model-catalog.mjs
CHANGED
|
@@ -1,173 +1,173 @@
|
|
|
1
|
-
// Read-only adapter from the DSH LLM registry to a credential-free Settings
|
|
2
|
-
// payload. Provider/model discovery stays owned by Harness; Crew only reads
|
|
3
|
-
// its registered routes and advertised catalog.
|
|
4
|
-
|
|
5
|
-
export const MODEL_CATALOG_UNAVAILABLE = 'MODEL_CATALOG_UNAVAILABLE';
|
|
6
|
-
|
|
7
|
-
export const CATALOG_HEALTH_CODES = Object.freeze({
|
|
8
|
-
EMPTY_CATALOG: 'EMPTY_CATALOG',
|
|
9
|
-
EMPTY_PROVIDER_MODELS: 'EMPTY_PROVIDER_MODELS',
|
|
10
|
-
PROVIDER_MODEL_LIST_FAILED: 'PROVIDER_MODEL_LIST_FAILED',
|
|
11
|
-
HARNESS_DEFAULT_PROVIDER_MISSING: 'HARNESS_DEFAULT_PROVIDER_MISSING',
|
|
12
|
-
HARNESS_DEFAULT_MODEL_UNADVERTISED: 'HARNESS_DEFAULT_MODEL_UNADVERTISED',
|
|
13
|
-
CATALOG_CONSTRAINED: 'CATALOG_CONSTRAINED',
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
function catalogError() {
|
|
17
|
-
return Object.assign(new Error('Unable to read Harness model catalog.'), { code: MODEL_CATALOG_UNAVAILABLE });
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
function normalizeProvider(raw) {
|
|
21
|
-
if (!raw || typeof raw.id !== 'string' || raw.id.trim() === '') return null;
|
|
22
|
-
const id = raw.id.trim();
|
|
23
|
-
return { id, name: typeof raw.name === 'string' && raw.name.trim() ? raw.name.trim() : id };
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
function normalizeModels(raw, provider) {
|
|
27
|
-
if (!Array.isArray(raw)) return [];
|
|
28
|
-
const seen = new Set();
|
|
29
|
-
const result = [];
|
|
30
|
-
for (const item of raw) {
|
|
31
|
-
if (!item || typeof item.id !== 'string' || item.id.trim() === '') continue;
|
|
32
|
-
const id = item.id.trim();
|
|
33
|
-
if (seen.has(id)) continue;
|
|
34
|
-
seen.add(id);
|
|
35
|
-
result.push({
|
|
36
|
-
id,
|
|
37
|
-
name: typeof item.name === 'string' && item.name.trim() ? item.name.trim() : id,
|
|
38
|
-
...(typeof item.description === 'string' && item.description.trim() ? { description: item.description.trim() } : {}),
|
|
39
|
-
...(Array.isArray(item.inputModalities) ? { inputModalities: item.inputModalities.filter((v) => v === 'text' || v === 'image') } : {}),
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
|
-
return result;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
function safeDefault(getCurrentSelection) {
|
|
46
|
-
try {
|
|
47
|
-
const raw = typeof getCurrentSelection === 'function' ? getCurrentSelection() : undefined;
|
|
48
|
-
if (!raw || typeof raw.provider !== 'string' || typeof raw.model !== 'string') return null;
|
|
49
|
-
return {
|
|
50
|
-
provider: raw.provider,
|
|
51
|
-
model: raw.model,
|
|
52
|
-
...(typeof raw.reasoningEffort === 'string' ? { reasoningEffort: raw.reasoningEffort } : {}),
|
|
53
|
-
};
|
|
54
|
-
} catch {
|
|
55
|
-
return null;
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
function healthHint(code, level, { provider, model, signal } = {}) {
|
|
60
|
-
return {
|
|
61
|
-
code,
|
|
62
|
-
level,
|
|
63
|
-
...(typeof provider === 'string' && provider ? { provider } : {}),
|
|
64
|
-
...(typeof model === 'string' && model ? { model } : {}),
|
|
65
|
-
...(typeof signal === 'string' && signal ? { signal } : {}),
|
|
66
|
-
};
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
/**
|
|
70
|
-
* Analyze only the effective, already-sanitized Harness catalog.
|
|
71
|
-
*
|
|
72
|
-
* This intentionally does not know an "expected" third-party catalog. A
|
|
73
|
-
* narrow advertised list is therefore informational only: it can point a user
|
|
74
|
-
* toward upstream/provider configuration, but it is never proof of a bad
|
|
75
|
-
* override and never changes routing eligibility.
|
|
76
|
-
*/
|
|
77
|
-
export function analyzeCatalogHealth({ providers = [], harnessDefault = null } = {}) {
|
|
78
|
-
const safeProviders = Array.isArray(providers) ? providers : [];
|
|
79
|
-
const hints = [];
|
|
80
|
-
|
|
81
|
-
if (safeProviders.length === 0) {
|
|
82
|
-
hints.push(healthHint(CATALOG_HEALTH_CODES.EMPTY_CATALOG, 'warning'));
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
for (const provider of safeProviders) {
|
|
86
|
-
const providerId = typeof provider?.id === 'string' ? provider.id : null;
|
|
87
|
-
const models = Array.isArray(provider?.models) ? provider.models : [];
|
|
88
|
-
if (provider?.error === 'MODEL_LIST_FAILED') {
|
|
89
|
-
hints.push(healthHint(CATALOG_HEALTH_CODES.PROVIDER_MODEL_LIST_FAILED, 'warning', { provider: providerId }));
|
|
90
|
-
continue;
|
|
91
|
-
}
|
|
92
|
-
if (models.length === 0) {
|
|
93
|
-
// Some providers intentionally accept exact model ids without advertising
|
|
94
|
-
// them. Keep this informational rather than turning it into a failure.
|
|
95
|
-
hints.push(healthHint(CATALOG_HEALTH_CODES.EMPTY_PROVIDER_MODELS, 'info', { provider: providerId }));
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
if (harnessDefault && typeof harnessDefault.provider === 'string' && typeof harnessDefault.model === 'string') {
|
|
100
|
-
const defaultProvider = safeProviders.find((provider) => provider?.id === harnessDefault.provider);
|
|
101
|
-
if (!defaultProvider) {
|
|
102
|
-
hints.push(healthHint(CATALOG_HEALTH_CODES.HARNESS_DEFAULT_PROVIDER_MISSING, 'warning', {
|
|
103
|
-
provider: harnessDefault.provider,
|
|
104
|
-
model: harnessDefault.model,
|
|
105
|
-
}));
|
|
106
|
-
} else if (defaultProvider.error !== 'MODEL_LIST_FAILED' && Array.isArray(defaultProvider.models) && defaultProvider.models.length > 0) {
|
|
107
|
-
const advertised = defaultProvider.models.some((model) => model?.id === harnessDefault.model);
|
|
108
|
-
if (!advertised) {
|
|
109
|
-
hints.push(healthHint(CATALOG_HEALTH_CODES.HARNESS_DEFAULT_MODEL_UNADVERTISED, 'info', {
|
|
110
|
-
provider: harnessDefault.provider,
|
|
111
|
-
model: harnessDefault.model,
|
|
112
|
-
}));
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
// A single provider advertising only one or two explicit models is a useful
|
|
118
|
-
// signal because local/provider overrides can produce this shape. It is only
|
|
119
|
-
// an INFO heuristic: legitimate providers can also have intentionally small
|
|
120
|
-
// catalogs, so Crew must not claim an override or route around it.
|
|
121
|
-
const healthyProviders = safeProviders.filter((provider) => provider?.error !== 'MODEL_LIST_FAILED');
|
|
122
|
-
const totalAdvertised = healthyProviders.reduce(
|
|
123
|
-
(sum, provider) => sum + (Array.isArray(provider?.models) ? provider.models.length : 0),
|
|
124
|
-
0,
|
|
125
|
-
);
|
|
126
|
-
if (healthyProviders.length === 1 && totalAdvertised > 0 && totalAdvertised <= 2) {
|
|
127
|
-
hints.push(healthHint(CATALOG_HEALTH_CODES.CATALOG_CONSTRAINED, 'info', {
|
|
128
|
-
provider: healthyProviders[0].id,
|
|
129
|
-
signal: 'single-provider-small-explicit-catalog',
|
|
130
|
-
}));
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
const warningCount = hints.filter((hint) => hint.level === 'warning').length;
|
|
134
|
-
const infoCount = hints.filter((hint) => hint.level === 'info').length;
|
|
135
|
-
return {
|
|
136
|
-
schema_version: 1,
|
|
137
|
-
warning_count: warningCount,
|
|
138
|
-
info_count: infoCount,
|
|
139
|
-
attention: warningCount > 0,
|
|
140
|
-
hints,
|
|
141
|
-
};
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
export async function readHarnessModelCatalog({ llm, getCurrentSelection, now = () => new Date().toISOString() } = {}) {
|
|
145
|
-
if (!llm || typeof llm.listProviders !== 'function' || typeof llm.listModels !== 'function') throw catalogError();
|
|
146
|
-
let rawProviders;
|
|
147
|
-
try {
|
|
148
|
-
rawProviders = llm.listProviders();
|
|
149
|
-
} catch {
|
|
150
|
-
throw catalogError();
|
|
151
|
-
}
|
|
152
|
-
if (!Array.isArray(rawProviders)) throw catalogError();
|
|
153
|
-
const providers = rawProviders.map(normalizeProvider).filter(Boolean);
|
|
154
|
-
let failed = 0;
|
|
155
|
-
const hydrated = await Promise.all(providers.map(async (provider) => {
|
|
156
|
-
try {
|
|
157
|
-
return { ...provider, models: normalizeModels(await llm.listModels(provider.id), provider.id) };
|
|
158
|
-
} catch {
|
|
159
|
-
failed += 1;
|
|
160
|
-
return { ...provider, models: [], error: 'MODEL_LIST_FAILED' };
|
|
161
|
-
}
|
|
162
|
-
}));
|
|
163
|
-
const harnessDefault = safeDefault(getCurrentSelection);
|
|
164
|
-
return {
|
|
165
|
-
providers: hydrated,
|
|
166
|
-
provider_count: hydrated.length,
|
|
167
|
-
model_count: hydrated.reduce((sum, provider) => sum + provider.models.length, 0),
|
|
168
|
-
harness_default: harnessDefault,
|
|
169
|
-
refreshed_at: now(),
|
|
170
|
-
partial: failed > 0,
|
|
171
|
-
health: analyzeCatalogHealth({ providers: hydrated, harnessDefault }),
|
|
172
|
-
};
|
|
173
|
-
}
|
|
1
|
+
// Read-only adapter from the DSH LLM registry to a credential-free Settings
|
|
2
|
+
// payload. Provider/model discovery stays owned by Harness; Crew only reads
|
|
3
|
+
// its registered routes and advertised catalog.
|
|
4
|
+
|
|
5
|
+
export const MODEL_CATALOG_UNAVAILABLE = 'MODEL_CATALOG_UNAVAILABLE';
|
|
6
|
+
|
|
7
|
+
export const CATALOG_HEALTH_CODES = Object.freeze({
|
|
8
|
+
EMPTY_CATALOG: 'EMPTY_CATALOG',
|
|
9
|
+
EMPTY_PROVIDER_MODELS: 'EMPTY_PROVIDER_MODELS',
|
|
10
|
+
PROVIDER_MODEL_LIST_FAILED: 'PROVIDER_MODEL_LIST_FAILED',
|
|
11
|
+
HARNESS_DEFAULT_PROVIDER_MISSING: 'HARNESS_DEFAULT_PROVIDER_MISSING',
|
|
12
|
+
HARNESS_DEFAULT_MODEL_UNADVERTISED: 'HARNESS_DEFAULT_MODEL_UNADVERTISED',
|
|
13
|
+
CATALOG_CONSTRAINED: 'CATALOG_CONSTRAINED',
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
function catalogError() {
|
|
17
|
+
return Object.assign(new Error('Unable to read Harness model catalog.'), { code: MODEL_CATALOG_UNAVAILABLE });
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function normalizeProvider(raw) {
|
|
21
|
+
if (!raw || typeof raw.id !== 'string' || raw.id.trim() === '') return null;
|
|
22
|
+
const id = raw.id.trim();
|
|
23
|
+
return { id, name: typeof raw.name === 'string' && raw.name.trim() ? raw.name.trim() : id };
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function normalizeModels(raw, provider) {
|
|
27
|
+
if (!Array.isArray(raw)) return [];
|
|
28
|
+
const seen = new Set();
|
|
29
|
+
const result = [];
|
|
30
|
+
for (const item of raw) {
|
|
31
|
+
if (!item || typeof item.id !== 'string' || item.id.trim() === '') continue;
|
|
32
|
+
const id = item.id.trim();
|
|
33
|
+
if (seen.has(id)) continue;
|
|
34
|
+
seen.add(id);
|
|
35
|
+
result.push({
|
|
36
|
+
id,
|
|
37
|
+
name: typeof item.name === 'string' && item.name.trim() ? item.name.trim() : id,
|
|
38
|
+
...(typeof item.description === 'string' && item.description.trim() ? { description: item.description.trim() } : {}),
|
|
39
|
+
...(Array.isArray(item.inputModalities) ? { inputModalities: item.inputModalities.filter((v) => v === 'text' || v === 'image') } : {}),
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
return result;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function safeDefault(getCurrentSelection) {
|
|
46
|
+
try {
|
|
47
|
+
const raw = typeof getCurrentSelection === 'function' ? getCurrentSelection() : undefined;
|
|
48
|
+
if (!raw || typeof raw.provider !== 'string' || typeof raw.model !== 'string') return null;
|
|
49
|
+
return {
|
|
50
|
+
provider: raw.provider,
|
|
51
|
+
model: raw.model,
|
|
52
|
+
...(typeof raw.reasoningEffort === 'string' ? { reasoningEffort: raw.reasoningEffort } : {}),
|
|
53
|
+
};
|
|
54
|
+
} catch {
|
|
55
|
+
return null;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function healthHint(code, level, { provider, model, signal } = {}) {
|
|
60
|
+
return {
|
|
61
|
+
code,
|
|
62
|
+
level,
|
|
63
|
+
...(typeof provider === 'string' && provider ? { provider } : {}),
|
|
64
|
+
...(typeof model === 'string' && model ? { model } : {}),
|
|
65
|
+
...(typeof signal === 'string' && signal ? { signal } : {}),
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Analyze only the effective, already-sanitized Harness catalog.
|
|
71
|
+
*
|
|
72
|
+
* This intentionally does not know an "expected" third-party catalog. A
|
|
73
|
+
* narrow advertised list is therefore informational only: it can point a user
|
|
74
|
+
* toward upstream/provider configuration, but it is never proof of a bad
|
|
75
|
+
* override and never changes routing eligibility.
|
|
76
|
+
*/
|
|
77
|
+
export function analyzeCatalogHealth({ providers = [], harnessDefault = null } = {}) {
|
|
78
|
+
const safeProviders = Array.isArray(providers) ? providers : [];
|
|
79
|
+
const hints = [];
|
|
80
|
+
|
|
81
|
+
if (safeProviders.length === 0) {
|
|
82
|
+
hints.push(healthHint(CATALOG_HEALTH_CODES.EMPTY_CATALOG, 'warning'));
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
for (const provider of safeProviders) {
|
|
86
|
+
const providerId = typeof provider?.id === 'string' ? provider.id : null;
|
|
87
|
+
const models = Array.isArray(provider?.models) ? provider.models : [];
|
|
88
|
+
if (provider?.error === 'MODEL_LIST_FAILED') {
|
|
89
|
+
hints.push(healthHint(CATALOG_HEALTH_CODES.PROVIDER_MODEL_LIST_FAILED, 'warning', { provider: providerId }));
|
|
90
|
+
continue;
|
|
91
|
+
}
|
|
92
|
+
if (models.length === 0) {
|
|
93
|
+
// Some providers intentionally accept exact model ids without advertising
|
|
94
|
+
// them. Keep this informational rather than turning it into a failure.
|
|
95
|
+
hints.push(healthHint(CATALOG_HEALTH_CODES.EMPTY_PROVIDER_MODELS, 'info', { provider: providerId }));
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
if (harnessDefault && typeof harnessDefault.provider === 'string' && typeof harnessDefault.model === 'string') {
|
|
100
|
+
const defaultProvider = safeProviders.find((provider) => provider?.id === harnessDefault.provider);
|
|
101
|
+
if (!defaultProvider) {
|
|
102
|
+
hints.push(healthHint(CATALOG_HEALTH_CODES.HARNESS_DEFAULT_PROVIDER_MISSING, 'warning', {
|
|
103
|
+
provider: harnessDefault.provider,
|
|
104
|
+
model: harnessDefault.model,
|
|
105
|
+
}));
|
|
106
|
+
} else if (defaultProvider.error !== 'MODEL_LIST_FAILED' && Array.isArray(defaultProvider.models) && defaultProvider.models.length > 0) {
|
|
107
|
+
const advertised = defaultProvider.models.some((model) => model?.id === harnessDefault.model);
|
|
108
|
+
if (!advertised) {
|
|
109
|
+
hints.push(healthHint(CATALOG_HEALTH_CODES.HARNESS_DEFAULT_MODEL_UNADVERTISED, 'info', {
|
|
110
|
+
provider: harnessDefault.provider,
|
|
111
|
+
model: harnessDefault.model,
|
|
112
|
+
}));
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
// A single provider advertising only one or two explicit models is a useful
|
|
118
|
+
// signal because local/provider overrides can produce this shape. It is only
|
|
119
|
+
// an INFO heuristic: legitimate providers can also have intentionally small
|
|
120
|
+
// catalogs, so Crew must not claim an override or route around it.
|
|
121
|
+
const healthyProviders = safeProviders.filter((provider) => provider?.error !== 'MODEL_LIST_FAILED');
|
|
122
|
+
const totalAdvertised = healthyProviders.reduce(
|
|
123
|
+
(sum, provider) => sum + (Array.isArray(provider?.models) ? provider.models.length : 0),
|
|
124
|
+
0,
|
|
125
|
+
);
|
|
126
|
+
if (healthyProviders.length === 1 && totalAdvertised > 0 && totalAdvertised <= 2) {
|
|
127
|
+
hints.push(healthHint(CATALOG_HEALTH_CODES.CATALOG_CONSTRAINED, 'info', {
|
|
128
|
+
provider: healthyProviders[0].id,
|
|
129
|
+
signal: 'single-provider-small-explicit-catalog',
|
|
130
|
+
}));
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
const warningCount = hints.filter((hint) => hint.level === 'warning').length;
|
|
134
|
+
const infoCount = hints.filter((hint) => hint.level === 'info').length;
|
|
135
|
+
return {
|
|
136
|
+
schema_version: 1,
|
|
137
|
+
warning_count: warningCount,
|
|
138
|
+
info_count: infoCount,
|
|
139
|
+
attention: warningCount > 0,
|
|
140
|
+
hints,
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
export async function readHarnessModelCatalog({ llm, getCurrentSelection, now = () => new Date().toISOString() } = {}) {
|
|
145
|
+
if (!llm || typeof llm.listProviders !== 'function' || typeof llm.listModels !== 'function') throw catalogError();
|
|
146
|
+
let rawProviders;
|
|
147
|
+
try {
|
|
148
|
+
rawProviders = llm.listProviders();
|
|
149
|
+
} catch {
|
|
150
|
+
throw catalogError();
|
|
151
|
+
}
|
|
152
|
+
if (!Array.isArray(rawProviders)) throw catalogError();
|
|
153
|
+
const providers = rawProviders.map(normalizeProvider).filter(Boolean);
|
|
154
|
+
let failed = 0;
|
|
155
|
+
const hydrated = await Promise.all(providers.map(async (provider) => {
|
|
156
|
+
try {
|
|
157
|
+
return { ...provider, models: normalizeModels(await llm.listModels(provider.id), provider.id) };
|
|
158
|
+
} catch {
|
|
159
|
+
failed += 1;
|
|
160
|
+
return { ...provider, models: [], error: 'MODEL_LIST_FAILED' };
|
|
161
|
+
}
|
|
162
|
+
}));
|
|
163
|
+
const harnessDefault = safeDefault(getCurrentSelection);
|
|
164
|
+
return {
|
|
165
|
+
providers: hydrated,
|
|
166
|
+
provider_count: hydrated.length,
|
|
167
|
+
model_count: hydrated.reduce((sum, provider) => sum + provider.models.length, 0),
|
|
168
|
+
harness_default: harnessDefault,
|
|
169
|
+
refreshed_at: now(),
|
|
170
|
+
partial: failed > 0,
|
|
171
|
+
health: analyzeCatalogHealth({ providers: hydrated, harnessDefault }),
|
|
172
|
+
};
|
|
173
|
+
}
|