Skip to content

armgit / Orkas

Public Imported from GitHub
0

Orkas is an open-source (MIT), local-first AI team for your desktop: a Commander turns your goal into to-dos and coordinates 16 built-in specialist agents plus Claude Code, Codex, OpenCode, OpenClaw and Hermes, with projects, scheduled automations and connectors. Free app for macOS & Windows; built-in models or your own keys.

fix: align configured model capabilities

wyt1d56e65843ec
diff --git a/src/main/features/auth.ts b/src/main/features/auth.ts
index 91c77cb1..cbca1696 100644
--- a/src/main/features/auth.ts
+++ b/src/main/features/auth.ts
@@ -76,7 +76,6 @@ import {
curatedModelsFor,
isSelectableModel,
resolveConfiguredPiModel,
- pickLatestGenerations,
providerLabel,
providerLabelKey,
providerDocsUrl,
@@ -560,7 +559,52 @@ function isEntryAllowed(store: ProfilesFile, entry: Entry): boolean {
return !!prof
&& isModelProviderAllowed(entry.provider, entry.model)
&& !isStoredProfileBlocked(prof)
- && (!providerUsesCustomOpenAIConfig(entry.provider) || !!customRuntimeConfigFromProfile(prof));
+ && (!providerUsesCustomOpenAIConfig(entry.provider) || !!customRuntimeConfigFromProfile(prof))
+ && isSelectableModel(entry.provider, entry.model);
+}
+
+function modelNotAvailableError(): Error & { code: string } {
+ return Object.assign(new Error(t('errors.model_not_available')), {
+ code: 'MODEL_NOT_AVAILABLE',
+ });
+}
+
+/** A configured SDK-backed model is usable only when pi-ai knows the exact id
+ * or the public/configured catalog names an explicit template to clone.
+ * Direct adapters build their own Model objects and remain independently
+ * resolvable. */
+function isRuntimeModelResolvable(
+ catalog: CoreAgentModule,
+ providerId: string,
+ modelId: string,
+): boolean {
+ if (!isSelectableModel(providerId, modelId)) return false;
+ if (EXTERNAL_API_PROVIDERS.includes(providerId)) return true;
+ return resolveConfiguredPiModel(catalog, providerId, modelId) !== null;
+}
+
+async function assertRuntimeSelectableModel(providerId: string, modelId: string): Promise<void> {
+ if (!isSelectableModel(providerId, modelId)) throw modelNotAvailableError();
+ if (EXTERNAL_API_PROVIDERS.includes(providerId)) return;
+ if (isRuntimeModelResolvable(await ca(), providerId, modelId)) return;
+ throw modelNotAvailableError();
+}
+
+type RuntimeModelResolver = (providerId: string, modelId: string) => boolean;
+
+async function buildRuntimeModelResolver(
+ entries: readonly Pick<Entry, 'provider' | 'model'>[],
+): Promise<RuntimeModelResolver> {
+ const needsPiCatalog = entries.some((entry) => (
+ isSelectableModel(entry.provider, entry.model)
+ && !EXTERNAL_API_PROVIDERS.includes(entry.provider)
+ ));
+ const catalog = needsPiCatalog ? await ca() : null;
+ return (providerId, modelId) => (
+ isSelectableModel(providerId, modelId)
+ && (EXTERNAL_API_PROVIDERS.includes(providerId)
+ || (!!catalog && isRuntimeModelResolvable(catalog, providerId, modelId)))
+ );
}
function makeProfileId(provider: string, label: string): string {
@@ -727,7 +771,10 @@ export async function getConfig(): Promise<AuthConfig> {
// list. Credentials + model selection share one source of truth
// (auth-profiles.json); there's no longer a fallback config.json.
const store = loadProfiles();
- const first = store.entries.find((e) => isEntryAllowed(store, e));
+ const runtimeResolvable = await buildRuntimeModelResolver(store.entries);
+ const first = store.entries.find((entry) => (
+ isEntryAllowed(store, entry) && runtimeResolvable(entry.provider, entry.model)
+ ));
if (first) return { provider: first.provider, model: first.model };
return { provider: '', model: '' };
}
@@ -900,28 +947,25 @@ export async function listProviders(): Promise<{ providers: ProviderEntry[] }> {
/**
* Model list for a provider.
*
- * Source priority:
- * 1. Hand-curated list in `provider_catalog.ts::CURATED_MODELS`
- * (the sole file to edit when adding/removing models).
- * 2. Fallback: `pickLatestGenerations()` derives the last 2 (major,
- * minor) version bands from pi-ai's raw list. Only used for
- * uncurated providers.
+ * The visible list is explicitly curated. SDK-backed rows are returned only
+ * when the bundled runtime knows the id or can clone an explicit template;
+ * direct adapters resolve their own model metadata.
*/
export async function listModels(providerId: string): Promise<{ models: { id: string; name: string }[] }> {
const id = String(providerId || '').trim();
if (!id) return { models: [] };
- if (!isModelProviderAllowed(id)) return { models: [] };
+ if (!isVisibleProvider(id) || !isModelProviderAllowed(id)) return { models: [] };
const allowed = (models: { id: string; name: string }[]) =>
models.filter((m) => isModelProviderAllowed(id, m.id));
const curated = curatedModelsFor(id);
- if (curated.length) return { models: allowed(curated) };
- try {
- const mod = await ca();
- const raw = mod.listPiModels(id) || [];
- return { models: allowed(pickLatestGenerations(raw as any[], 2)) };
- } catch {
- return { models: [] };
+ const policyAllowed = allowed(curated);
+ if (EXTERNAL_API_PROVIDERS.includes(id) || policyAllowed.length === 0) {
+ return { models: policyAllowed };
}
+ const catalog = await ca();
+ return {
+ models: policyAllowed.filter((model) => isRuntimeModelResolvable(catalog, id, model.id)),
+ };
}
// ── Credential writes ────────────────────────────────────────────────────
@@ -939,7 +983,6 @@ export async function addApiKey(
if (providerUsesCustomOpenAIConfig(id)) {
throw customConfigError('CUSTOM_CONFIG_REQUIRED', 'Use the custom model configuration flow');
}
-
const store = loadProfiles();
const chosenLabel = label ? sanitizeLabel(label) : autoLabel(store, id);
const profileId = makeProfileId(id, chosenLabel);
@@ -979,6 +1022,7 @@ export async function addApiKeyEntry(
if (providerUsesCustomOpenAIConfig(id)) {
throw customConfigError('CUSTOM_CONFIG_REQUIRED', 'Use the custom model configuration flow');
}
+ await assertRuntimeSelectableModel(id, model);
const store = loadProfiles();
const chosenLabel = label ? sanitizeLabel(label) : autoLabel(store, id);
@@ -1176,7 +1220,12 @@ export interface EntryView {
lastUsed: number;
}
-function entryToView(e: Entry, store: ProfilesFile, modelNameLookup: (p: string, m: string) => string): EntryView {
+function entryToView(
+ e: Entry,
+ store: ProfilesFile,
+ modelNameLookup: (p: string, m: string) => string,
+ runtimeResolvable = true,
+): EntryView {
const prof = store.profiles[e.profileId];
const base = {
entryId: e.entryId,
@@ -1186,7 +1235,7 @@ function entryToView(e: Entry, store: ProfilesFile, modelNameLookup: (p: string,
model: e.model,
modelName: modelNameLookup(e.provider, e.model),
modelEditable: !providerUsesCustomOpenAIConfig(e.provider),
- modelAvailable: isSelectableModel(e.provider, e.model),
+ modelAvailable: isSelectableModel(e.provider, e.model) && runtimeResolvable,
profileId: e.profileId,
profileAvailable: !!prof,
profileLabel: prof?.label || e.profileId.split(':').slice(1).join(':') || '(missing)',
@@ -1226,11 +1275,20 @@ export async function listEntries(
opts: { includeUnavailable?: boolean } = {},
): Promise<{ entries: EntryView[] }> {
const store = loadProfiles();
+ const runtimeResolvable = await buildRuntimeModelResolver(store.entries);
const lookup = await buildModelNameLookup();
return {
entries: store.entries
- .filter((e) => opts.includeUnavailable === true || isEntryAllowed(store, e))
- .map((e) => entryToView(e, store, lookup)),
+ .filter((entry) => (
+ opts.includeUnavailable === true
+ || (isEntryAllowed(store, entry) && runtimeResolvable(entry.provider, entry.model))
+ ))
+ .map((entry) => entryToView(
+ entry,
+ store,
+ lookup,
+ runtimeResolvable(entry.provider, entry.model),
+ )),
};
}
@@ -1244,6 +1302,7 @@ export async function addEntry({
const pid = String(profileId || '').trim();
if (!p || !m || !pid) throw new Error('provider / model / profileId required');
assertModelProviderAllowed(p, m);
+ await assertRuntimeSelectableModel(p, m);
const store = loadProfiles();
if (!store.profiles[pid]) throw new Error('profile not found');
if (store.profiles[pid].provider !== p) throw new Error('profile does not belong to provider');
@@ -1277,6 +1336,7 @@ export async function updateEntryModel(entryId: string, model: string): Promise<
const target = store.entries.find((e) => e.entryId === id);
if (!target) throw new Error('entry not found');
assertModelProviderAllowed(target.provider, m);
+ await assertRuntimeSelectableModel(target.provider, m);
// Deduplicate: if another entry with the same (provider, model, profileId)
// already exists, removing the target makes the priority list cleaner.
const collision = store.entries.find(
@@ -1304,6 +1364,7 @@ export async function removeEntry(entryId: string): Promise<{ removed: boolean }
export async function reorderEntries(orderedIds: string[]): Promise<{ entries: EntryView[] }> {
if (!Array.isArray(orderedIds)) throw new Error('orderedIds must be an array');
const store = loadProfiles();
+ const runtimeResolvable = await buildRuntimeModelResolver(store.entries);
const byId = new Map(store.entries.map((e) => [e.entryId, e]));
const reordered: Entry[] = [];
for (const id of orderedIds) {
@@ -1320,8 +1381,10 @@ export async function reorderEntries(orderedIds: string[]): Promise<{ entries: E
const lookup = await buildModelNameLookup();
return {
entries: store.entries
- .filter((e) => isEntryAllowed(store, e))
- .map((e) => entryToView(e, store, lookup)),
+ .filter((entry) => (
+ isEntryAllowed(store, entry) && runtimeResolvable(entry.provider, entry.model)
+ ))
+ .map((entry) => entryToView(entry, store, lookup, true)),
};
}
@@ -1336,7 +1399,10 @@ export async function selectEntry(
const requestedModel = String(model || '').trim();
if (requestedModel) await updateEntryModel(id, requestedModel);
const store = loadProfiles();
- if (!store.entries.some((entry) => entry.entryId === id)) throw new Error('entry not found');
+ const selected = store.entries.find((entry) => entry.entryId === id);
+ if (!selected) throw new Error('entry not found');
+ if (!isEntryAllowed(store, selected)) throw modelNotAvailableError();
+ await assertRuntimeSelectableModel(selected.provider, selected.model);
return reorderEntries([id]);
}
@@ -1745,6 +1811,7 @@ export function bumpEntryLastUsed(entryId: string): void {
export async function pickChatEntryGroup(): Promise<ChatEntryChoice[]> {
const store = loadProfiles();
if (store.entries.length === 0) return [];
+ const runtimeResolvable = await buildRuntimeModelResolver(store.entries);
// Flatten: preserve entries[] order across groups, but within a
// consecutive same-(provider, model) run, sort oldest lastUsed first.
@@ -1761,6 +1828,10 @@ export async function pickChatEntryGroup(): Promise<ChatEntryChoice[]> {
log.info(`skipping disabled provider/model ${entry.provider}/${entry.model}`);
continue;
}
+ if (!runtimeResolvable(entry.provider, entry.model)) {
+ log.info(`skipping unresolved provider/model ${entry.provider}/${entry.model}`);
+ continue;
+ }
if (isCooledDown(entry.profileId)) {
log.info(`skipping cooled-down profile ${entry.profileId}`);
continue;
@@ -1907,10 +1978,20 @@ export async function testConnection(
): Promise<TestConnectionResult> {
const pid = String(providerId || '').trim();
if (!pid) return { ok: false, error: 'provider required' };
- if (!isModelProviderAllowed(pid, modelId)) {
+ const selectedModel = String(modelId || '').trim() || curatedModelsFor(pid)[0]?.id || '';
+ if (!isModelProviderAllowed(pid, selectedModel || undefined)) {
return { ok: false, error: 'DeepSeek is disabled in this build' };
}
+ if (!selectedModel || !isSelectableModel(pid, selectedModel)) {
+ return { ok: false, error: t('errors.model_not_available') };
+ }
const mod = await ca();
+ const resolvedModel = EXTERNAL_API_PROVIDERS.includes(pid)
+ ? null
+ : resolveConfiguredPiModel(mod, pid, selectedModel);
+ if (!EXTERNAL_API_PROVIDERS.includes(pid) && !resolvedModel) {
+ return { ok: false, error: t('errors.model_not_available') };
+ }
let chosenProfileId: string | undefined = profileId;
let apiKey: string | undefined;
@@ -1942,22 +2023,17 @@ export async function testConnection(
// to their factory so we don't hit the "provider has no models registered"
// guard below (which relies on pi-ai's listPiModels).
if (EXTERNAL_API_PROVIDERS.includes(pid)) {
- const modelForTest = String(modelId || '').trim();
+ const modelForTest = selectedModel;
const t0 = Date.now();
try {
const ext = await import('../model/core-agent/external-providers');
let provider;
let probeModel = modelForTest;
if (pid === 'moonshot') {
- probeModel = probeModel || 'kimi-k2.5';
provider = await ext.createMoonshotProvider({ apiKey, modelId: probeModel });
} else if (pid === 'deepseek') {
- // Default probe = V4 Flash (cheaper than Pro; fine for a 1-token ping).
- probeModel = probeModel || 'deepseek-v4-flash';
provider = await ext.createDeepSeekProvider({ apiKey, modelId: probeModel });
} else if (pid === 'doubao') {
- // Default probe = Seed 2.0 Lite (cheaper than Pro).
- probeModel = probeModel || 'doubao-seed-2-0-lite-260215';
provider = await ext.createDoubaoProvider({ apiKey, modelId: probeModel });
} else if (pid === CUSTOM_MODEL_PROVIDER && customConfig) {
provider = await ext.createCustomOpenAICompatibleProvider({
@@ -1997,9 +2073,7 @@ export async function testConnection(
// IDs, which trips an NPE inside core-agent's `resolveModel`. Guard here
// so we surface a clean "model not found" instead of "Cannot read
// properties of undefined".
- const requestedModel = modelId ? String(modelId).trim() : '';
- let effectiveModel = requestedModel;
- const resolvedModel = requestedModel ? resolveConfiguredPiModel(mod, pid, requestedModel) : null;
+ const requestedModel = selectedModel;
if (resolvedModel?.isConfiguredFallback) {
log.info('using configured model fallback for connection test', {
provider: pid,
@@ -2008,29 +2082,17 @@ export async function testConnection(
templateModel: resolvedModel.templateModelId,
});
}
- try {
- const knownIds: string[] = ((mod as any).listPiModels(pid) || [])
- .map((m: any) => m && m.id)
- .filter((id: unknown): id is string => typeof id === 'string');
- if (requestedModel && !resolvedModel && !knownIds.includes(requestedModel)) {
- if (!knownIds.length) {
- return { ok: false, error: `provider "${pid}" has no models registered`, profileId: chosenProfileId };
- }
- effectiveModel = knownIds[0];
- }
- } catch { /* fall through — let pi-ai surface whatever it wants */ }
-
const t0 = Date.now();
try {
const provider = mod.createPiProvider({
provider: pid,
...(resolvedModel?.needsCustomModel
? { customModel: resolvedModel.model }
- : { model: effectiveModel || undefined }),
+ : { model: requestedModel }),
apiKey,
});
const msg = await provider.complete({
- model: resolvedModel?.needsCustomModel ? requestedModel : effectiveModel,
+ model: requestedModel,
// ChatGPT Codex's `responses` API rejects requests without
// `instructions` (= system prompt). Plain providers ignore it.
systemPrompt: 'You are a connectivity probe; reply with a single word.',
diff --git a/src/main/features/client_config.ts b/src/main/features/client_config.ts
index 47d28ced..290f894f 100644
--- a/src/main/features/client_config.ts
+++ b/src/main/features/client_config.ts
@@ -651,6 +651,12 @@ function normalizeProviderModels(value: unknown): ProviderModelEntry[] | null {
const contextWindow = normalizePositiveInteger(r.contextWindow);
const maxTokens = normalizePositiveInteger(r.maxTokens);
const maxInputImages = normalizeNonNegativeInteger(r.maxInputImages);
+ const supportsVision = typeof r.supportsVision === 'boolean' ? r.supportsVision : undefined;
+ if (r.supportsVision !== undefined && supportsVision === undefined) return null;
+ if (
+ (supportsVision === false && typeof maxInputImages === 'number' && maxInputImages > 0)
+ || (supportsVision === true && maxInputImages === 0)
+ ) return null;
const includedModels = normalizeIncludedModels(r.includedModels);
if (r.includedModels !== undefined && includedModels === null) return null;
out.push({
@@ -662,6 +668,7 @@ function normalizeProviderModels(value: unknown): ProviderModelEntry[] | null {
...(template ? { template } : {}),
...(contextWindow ? { contextWindow } : {}),
...(maxTokens ? { maxTokens } : {}),
+ ...(supportsVision !== undefined ? { supportsVision } : {}),
...(maxInputImages !== undefined ? { maxInputImages } : {}),
});
}
diff --git a/src/main/model/core-agent/external-providers.ts b/src/main/model/core-agent/external-providers.ts
index f79174d6..2f458f51 100644
--- a/src/main/model/core-agent/external-providers.ts
+++ b/src/main/model/core-agent/external-providers.ts
@@ -41,6 +41,7 @@ import type { Model } from '@earendil-works/pi-ai';
import { isBearerTokenHeaderSafe } from '../../util/http-authorization';
import {
curatedModelsFor,
+ modelInputFromConfiguredCapabilities,
type CustomOpenAICompatibleRuntimeConfig,
} from '../provider_catalog';
import { repairOpenAIToolMessageOrder } from './openai-payload';
@@ -86,6 +87,15 @@ function openAICompatibleModelSupportsImages(
return declared ?? unknownDefault;
}
+function configuredModelVisionDeclaration(model: {
+ supportsVision?: boolean;
+ maxInputImages?: number;
+} | undefined): boolean | undefined {
+ if (typeof model?.supportsVision === 'boolean') return model.supportsVision;
+ if (typeof model?.maxInputImages === 'number') return model.maxInputImages > 0;
+ return undefined;
+}
+
export function repairOpenAICompatiblePayload(params: unknown): unknown {
return repairOpenAIToolMessageOrder(params);
}
@@ -174,7 +184,10 @@ export function buildMoonshotModel(modelId: string): Model<'openai-completions'>
baseUrl: MOONSHOT_BASE_URL,
reasoning: protocol?.reasoning ?? false,
...(protocol?.thinkingLevelMap ? { thinkingLevelMap: { ...protocol.thinkingLevelMap } } : {}),
- input: protocol ? [...protocol.input] : ['text', 'image'],
+ input: modelInputFromConfiguredCapabilities(
+ protocol ? [...protocol.input] : ['text', 'image'],
+ curated,
+ ),
// The Moonshot open platform bills per token, but pi-ai's `cost`
// field is only used for local cost-statistics display and does not
// affect the actual request. Filling 0 means "not accounted for here";
@@ -246,9 +259,7 @@ function deepseekMaxOutputTokens(modelId: string): number {
export function buildDeepSeekModel(modelId: string): Model<'openai-completions'> {
const curated = curatedModelsFor('deepseek').find((m) => m.id === modelId);
- const configuredVision = typeof curated?.maxInputImages === 'number'
- ? curated.maxInputImages > 0
- : undefined;
+ const configuredVision = configuredModelVisionDeclaration(curated);
return {
id: modelId,
name: curated?.name || modelId,
@@ -266,9 +277,10 @@ export function buildDeepSeekModel(modelId: string): Model<'openai-completions'>
// true, paired with `defaultReasoning: 'low'` below so the request
// always carries the effort field.
reasoning: /^deepseek-v4-/.test(modelId),
- // Official Pro/Flash aliases remain text-only. Flash Vision Exp opts into
- // image input through its public catalog capability metadata.
- input: openAICompatibleModelSupportsImages(modelId, configuredVision, false)
+ // Official Pro/Flash aliases remain text-only. Flash Vision and remotely
+ // configured models can declare supportsVision explicitly; an omitted
+ // declaration defaults to visual for parity with user-defined endpoints.
+ input: openAICompatibleModelSupportsImages(modelId, configuredVision, true)
? ['text', 'image']
: ['text'],
cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 },
@@ -387,7 +399,7 @@ export function buildDoubaoModel(modelId: string): Model<'openai-completions'> {
// developer role for unknown providers, which Ark rejects with a
// 400. Disable it explicitly.
compat: { supportsDeveloperRole: false },
- input: ['text', 'image'],
+ input: modelInputFromConfiguredCapabilities(['text', 'image'], curated),
cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 },
contextWindow: configuredPositiveInteger(curated?.contextWindow, doubaoContextWindow(modelId)),
maxTokens: configuredPositiveInteger(curated?.maxTokens, doubaoMaxOutputTokens(modelId)),
diff --git a/src/main/model/provider_catalog.ts b/src/main/model/provider_catalog.ts
index 46029cc6..f28e555b 100644
--- a/src/main/model/provider_catalog.ts
+++ b/src/main/model/provider_catalog.ts
@@ -142,15 +142,15 @@ export function curatedModelsFor(providerId: string): ProviderModelEntry[] {
* storage may keep more files over the life of a conversation, but a single
* composer turn currently accepts at most 20 attachments. */
export const MAX_MODEL_INPUT_IMAGES = 20;
-export const DEFAULT_MODEL_INPUT_IMAGE_LIMIT = 5;
+export const DEFAULT_MODEL_INPUT_IMAGE_LIMIT = MAX_MODEL_INPUT_IMAGES;
/**
* Resolve the image count for one concrete provider/model candidate.
*
* Model protocol metadata is authoritative for whether images are supported
* at all. The remotely configurable catalog may then declare the provider's
- * exact per-request count. Unknown multimodal models retain the old,
- * conservative five-image behavior instead of risking an upstream 400.
+ * exact per-request count. Multimodal models without a declared provider
+ * limit use the Orkas product boundary of 20 images per request.
*/
export function modelInputImageLimit(
providerId: string,
@@ -348,7 +348,10 @@ function cloneModelWithId(
template: Model<Api>,
id: string,
name: string,
- overrides?: Pick<ProviderModelEntry, 'contextWindow' | 'maxTokens'>,
+ overrides?: Pick<
+ ProviderModelEntry,
+ 'contextWindow' | 'maxTokens' | 'supportsVision' | 'maxInputImages'
+ >,
): Model<Api> {
const cloned = {
...template,
@@ -364,16 +367,48 @@ function cloneModelWithId(
function hasConfiguredModelOverrides(configured: ProviderModelEntry | undefined): boolean {
return !!configured
- && (typeof configured.contextWindow === 'number' || typeof configured.maxTokens === 'number');
+ && (
+ typeof configured.contextWindow === 'number'
+ || typeof configured.maxTokens === 'number'
+ || typeof configured.supportsVision === 'boolean'
+ || typeof configured.maxInputImages === 'number'
+ );
+}
+
+/**
+ * Apply only an explicitly configured image capability. An omitted declaration
+ * preserves pi-ai/provider protocol metadata byte-for-byte, which keeps older
+ * Server catalogs backward compatible. `maxInputImages` remains a legacy
+ * capability declaration: zero means text-only, any positive value means the
+ * model accepts images (the actual product limit is resolved separately).
+ */
+export function modelInputFromConfiguredCapabilities(
+ input: Model<Api>['input'],
+ overrides?: Pick<ProviderModelEntry, 'supportsVision' | 'maxInputImages'>,
+): Model<Api>['input'] {
+ const declared = typeof overrides?.supportsVision === 'boolean'
+ ? overrides.supportsVision
+ : typeof overrides?.maxInputImages === 'number'
+ ? overrides.maxInputImages > 0
+ : undefined;
+ if (declared === undefined) return input;
+ if (!declared) return ['text'];
+ const withText: Model<Api>['input'] = input.includes('text') ? input : ['text', ...input];
+ return withText.includes('image') ? withText : [...withText, 'image'];
}
function applyConfiguredModelOverrides(
model: Model<Api>,
- overrides?: Pick<ProviderModelEntry, 'contextWindow' | 'maxTokens'>,
+ overrides?: Pick<
+ ProviderModelEntry,
+ 'contextWindow' | 'maxTokens' | 'supportsVision' | 'maxInputImages'
+ >,
): Model<Api> {
if (!overrides) return model;
+ const input = modelInputFromConfiguredCapabilities(model.input, overrides);
return {
...model,
+ ...(input !== model.input ? { input } : {}),
...(typeof overrides.contextWindow === 'number' && overrides.contextWindow > 0
? { contextWindow: overrides.contextWindow }
: {}),
diff --git a/src/main/model/public_model_catalog.ts b/src/main/model/public_model_catalog.ts
index 345a2515..79d11b75 100644
--- a/src/main/model/public_model_catalog.ts
+++ b/src/main/model/public_model_catalog.ts
@@ -22,9 +22,14 @@ export interface ProviderModelEntry {
template?: string;
contextWindow?: number;
maxTokens?: number;
- /** Maximum image inputs Orkas may send in one model request. Zero disables
- * visual input. Omit when the provider/model limit is unknown; the runtime
- * then uses a conservative fallback. Text-only capability always wins. */
+ /** Explicit visual capability for any Server-configured model. Omit to
+ * preserve a built-in/template model's protocol metadata; declarative
+ * OpenAI-compatible models default unknown ids to visual input. */
+ supportsVision?: boolean;
+ /** Maximum image inputs Orkas may send in one model request. This is a
+ * quantity limit, not the primary capability flag. Zero remains a legacy
+ * text-only declaration. Omit when the provider/model limit is unknown; the
+ * runtime then uses the Orkas product limit. */
maxInputImages?: number;
}
@@ -79,9 +84,9 @@ export const PUBLIC_PROVIDER_MODELS: Readonly<Record<string, readonly ProviderMo
{ id: 'MiniMax-M2.7', name: 'MiniMax 2.7' },
],
deepseek: [
- { id: 'deepseek-v4-pro', name: 'DeepSeek V4 Pro', contextWindow: 1_048_576, maxTokens: 384_000 },
- { id: 'deepseek-v4-flash-vision-exp', name: 'DeepSeek V4 Flash Vision', contextWindow: 1_048_576, maxTokens: 384_000, maxInputImages: 600 },
- { id: 'deepseek-v4-flash', name: 'DeepSeek V4 Flash', contextWindow: 1_048_576, maxTokens: 384_000 },
+ { id: 'deepseek-v4-pro', name: 'DeepSeek V4 Pro', contextWindow: 1_048_576, maxTokens: 384_000, supportsVision: false },
+ { id: 'deepseek-v4-flash-vision-exp', name: 'DeepSeek V4 Flash Vision', contextWindow: 1_048_576, maxTokens: 384_000, supportsVision: true, maxInputImages: 600 },
+ { id: 'deepseek-v4-flash', name: 'DeepSeek V4 Flash', contextWindow: 1_048_576, maxTokens: 384_000, supportsVision: false },
],
doubao: [
{ id: 'doubao-seed-2-0-pro-260215', name: 'Doubao Seed 2.0 Pro' },
diff --git a/test/main/features/auth.test.ts b/test/main/features/auth.test.ts
index 89129ed4..56655657 100644
--- a/test/main/features/auth.test.ts
+++ b/test/main/features/auth.test.ts
@@ -950,6 +950,50 @@ describe('auth › listModels', () => {
'gpt-5.4',
]);
});
+
+ it('exposes and saves only configured models resolvable by this runtime', async () => {
+ const { clientConfig } = await import('../../../src/main/features/client_config');
+ const a = await import('../../../src/main/features/auth');
+ const exact = { id: 'claude-opus-4-8', name: 'Claude Opus 4.8' };
+ const templated = {
+ id: 'claude-open-future-999',
+ name: 'Claude Future',
+ template: 'claude-opus-4-8',
+ supportsVision: true,
+ };
+ const unresolved = { id: 'brand-new-open-999', name: 'Brand New' };
+ clientConfig.applyServerPayload({
+ immediate: {
+ model_catalog: {
+ providers: { anthropic: [exact, templated, unresolved] },
+ },
+ },
+ restart: {},
+ config_hash: 'sha256:runtime-model-resolution',
+ }, '"runtime-model-resolution"');
+
+ expect((await a.listModels('anthropic')).models.map((model) => model.id)).toEqual([
+ exact.id,
+ templated.id,
+ ]);
+ await expect(a.addApiKeyEntry(
+ 'anthropic',
+ unresolved.id,
+ 'sk-unresolved-must-not-save-xxxxxxxx',
+ )).rejects.toMatchObject({ code: 'MODEL_NOT_AVAILABLE' });
+ expect((await a.listProviders()).providers
+ .find((provider) => provider.id === 'anthropic')?.profiles).toEqual([]);
+
+ const added = await a.addApiKeyEntry(
+ 'anthropic',
+ templated.id,
+ 'sk-templated-model-xxxxxxxx',
+ );
+ expect((await a.pickChatEntryGroup())[0]).toMatchObject({
+ entryId: added.entryId,
+ model: templated.id,
+ });
+ });
});
describe('auth › DeepSeek policy gate', () => {
diff --git a/test/main/model/core-agent/external-providers.test.ts b/test/main/model/core-agent/external-providers.test.ts
index a618b98f..f2f4dcfe 100644
--- a/test/main/model/core-agent/external-providers.test.ts
+++ b/test/main/model/core-agent/external-providers.test.ts
@@ -81,6 +81,11 @@ describe('external-providers › DeepSeek model capabilities', () => {
});
expect(modelInputImageLimit('deepseek', 'deepseek-v4-flash-vision-exp', model)).toBe(20);
});
+
+ it('defaults unknown direct DeepSeek models to vision while known aliases remain text-only', () => {
+ expect(buildDeepSeekModel('deepseek-next').input).toEqual(['text', 'image']);
+ expect(buildDeepSeekModel('deepseek-v4-flash').input).toEqual(['text']);
+ });
});
describe('external-providers › buildMoonshotModel', () => {
diff --git a/test/main/model/provider_catalog.test.ts b/test/main/model/provider_catalog.test.ts
index 196383ec..10f32cd3 100644
--- a/test/main/model/provider_catalog.test.ts
+++ b/test/main/model/provider_catalog.test.ts
@@ -16,6 +16,8 @@ import {
providerSubscriptionNote,
sortProviderIds,
curatedModelsFor,
+ modelInputFromConfiguredCapabilities,
+ modelInputImageLimit,
resolveConfiguredPiModel,
pickLatestGenerations,
} from '../../../src/main/model/provider_catalog';
@@ -190,6 +192,23 @@ describe('provider_catalog › CURATED_MODELS', () => {
expect(curatedModelsFor('no-such-provider-id')).toEqual([]);
});
+ it('applies explicit vision declarations and uses the product image limit by default', () => {
+ expect(modelInputFromConfiguredCapabilities(['text', 'image'], {})).toEqual(['text', 'image']);
+ expect(modelInputFromConfiguredCapabilities(['text', 'image'], {
+ supportsVision: false,
+ })).toEqual(['text']);
+ expect(modelInputFromConfiguredCapabilities(['text'], {
+ supportsVision: true,
+ })).toEqual(['text', 'image']);
+ expect(modelInputFromConfiguredCapabilities(['text', 'image'], {
+ maxInputImages: 0,
+ })).toEqual(['text']);
+ expect(modelInputImageLimit('unknown-provider', 'vision-next', {
+ id: 'vision-next',
+ input: ['text', 'image'],
+ } as any)).toBe(20);
+ });
+
it('curatedModelsFor can be overridden by Server remote-config cache', async () => {
const users = await import('../../../src/main/features/users');
const paths = await import('../../../src/main/paths');
diff --git a/test/main/model/public_model_catalog.test.ts b/test/main/model/public_model_catalog.test.ts
index 6b187b79..6fea6641 100644
--- a/test/main/model/public_model_catalog.test.ts
+++ b/test/main/model/public_model_catalog.test.ts
@@ -54,10 +54,14 @@ describe('public model catalog', () => {
'deepseek-v4-flash',
]);
expect(PUBLIC_PROVIDER_MODELS.deepseek?.[1]).toMatchObject({
+ name: 'DeepSeek V4 Flash Vision',
contextWindow: 1_048_576,
maxTokens: 384_000,
+ supportsVision: true,
maxInputImages: 600,
});
+ expect(PUBLIC_PROVIDER_MODELS.deepseek?.[0]).toMatchObject({ supportsVision: false });
+ expect(PUBLIC_PROVIDER_MODELS.deepseek?.[2]).toMatchObject({ supportsVision: false });
});
it('keeps the explicitly curated OpenRouter shortcut set', () => {