feat: add CLI backend fallback
This commit is contained in:
@@ -28,6 +28,15 @@ export function normalizeProviderId(provider: string): string {
|
||||
return normalized;
|
||||
}
|
||||
|
||||
export function isCliProvider(provider: string, cfg?: ClawdbotConfig): boolean {
|
||||
const normalized = normalizeProviderId(provider);
|
||||
if (normalized === "claude-cli") return true;
|
||||
const backends = cfg?.agents?.defaults?.cliBackends ?? {};
|
||||
return Object.keys(backends).some(
|
||||
(key) => normalizeProviderId(key) === normalized,
|
||||
);
|
||||
}
|
||||
|
||||
function normalizeAnthropicModelId(model: string): string {
|
||||
const trimmed = model.trim();
|
||||
if (!trimmed) return trimmed;
|
||||
@@ -173,7 +182,9 @@ export function buildAllowedModelSet(params: {
|
||||
const parsed = parseModelRef(String(raw), params.defaultProvider);
|
||||
if (!parsed) continue;
|
||||
const key = modelKey(parsed.provider, parsed.model);
|
||||
if (catalogKeys.has(key)) {
|
||||
if (isCliProvider(parsed.provider, params.cfg)) {
|
||||
allowedKeys.add(key);
|
||||
} else if (catalogKeys.has(key)) {
|
||||
allowedKeys.add(key);
|
||||
}
|
||||
}
|
||||
@@ -186,7 +197,7 @@ export function buildAllowedModelSet(params: {
|
||||
allowedKeys.has(modelKey(entry.provider, entry.id)),
|
||||
);
|
||||
|
||||
if (allowedCatalog.length === 0) {
|
||||
if (allowedCatalog.length === 0 && allowedKeys.size === 0) {
|
||||
if (defaultKey) catalogKeys.add(defaultKey);
|
||||
return {
|
||||
allowAny: true,
|
||||
|
||||
Reference in New Issue
Block a user