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.

test: validate model capability declarations

wyt0805ba5a2346
diff --git a/src/main/features/client_config.ts b/src/main/features/client_config.ts
index 290f894f..d5821937 100644
--- a/src/main/features/client_config.ts
+++ b/src/main/features/client_config.ts
@@ -653,6 +653,7 @@ function normalizeProviderModels(value: unknown): ProviderModelEntry[] | null {
const maxInputImages = normalizeNonNegativeInteger(r.maxInputImages);
const supportsVision = typeof r.supportsVision === 'boolean' ? r.supportsVision : undefined;
if (r.supportsVision !== undefined && supportsVision === undefined) return null;
+ if (r.maxInputImages !== undefined && maxInputImages === undefined) return null;
if (
(supportsVision === false && typeof maxInputImages === 'number' && maxInputImages > 0)
|| (supportsVision === true && maxInputImages === 0)
@@ -697,9 +698,8 @@ function normalizePositiveInteger(value: unknown): number | undefined {
}
function normalizeNonNegativeInteger(value: unknown): number | undefined {
- if (typeof value !== 'number' || !Number.isFinite(value)) return undefined;
- const n = Math.floor(value);
- return n >= 0 ? n : undefined;
+ if (typeof value !== 'number' || !Number.isInteger(value)) return undefined;
+ return value >= 0 ? value : undefined;
}
function normalizeImageGenCapability(value: unknown): ImageGenCapability | null {
diff --git a/test/main/model/provider_catalog.test.ts b/test/main/model/provider_catalog.test.ts
index 10f32cd3..9367028b 100644
--- a/test/main/model/provider_catalog.test.ts
+++ b/test/main/model/provider_catalog.test.ts
@@ -192,23 +192,90 @@ 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']);
+ it.each([
+ { input: ['text'] as const, configured: {}, expected: ['text'] },
+ { input: ['text', 'image'] as const, configured: {}, expected: ['text', 'image'] },
+ { input: ['text'] as const, configured: { supportsVision: true }, expected: ['text', 'image'] },
+ { input: ['text', 'image'] as const, configured: { supportsVision: false }, expected: ['text'] },
+ { input: ['text'] as const, configured: { maxInputImages: 12 }, expected: ['text', 'image'] },
+ { input: ['text', 'image'] as const, configured: { maxInputImages: 0 }, expected: ['text'] },
+ { input: ['text'] as const, configured: { supportsVision: true, maxInputImages: 12 }, expected: ['text', 'image'] },
+ { input: ['text', 'image'] as const, configured: { supportsVision: false, maxInputImages: 0 }, expected: ['text'] },
+ ])('applies configured vision capabilities: $configured', ({ input, configured, expected }) => {
+ expect(modelInputFromConfiguredCapabilities([...input], configured)).toEqual(expected);
+ });
+
+ it('uses the product image limit for a multimodal model without a provider limit', () => {
expect(modelInputImageLimit('unknown-provider', 'vision-next', {
id: 'vision-next',
input: ['text', 'image'],
} as any)).toBe(20);
});
+ it('accepts the capability-field matrix and rejects conflicts or invalid field types', async () => {
+ const users = await import('../../../src/main/features/users');
+ const paths = await import('../../../src/main/paths');
+ const storage = await import('../../../src/main/storage');
+ const uid = 'configuredcapabilitymatrix';
+ users.activateUser(uid);
+ const file = paths.userRemoteConfigFile(uid);
+ const cases: Array<{
+ id: string;
+ supportsVision?: unknown;
+ maxInputImages?: unknown;
+ accepted: boolean;
+ }> = [
+ { id: 'omitted-omitted', accepted: true },
+ { id: 'omitted-zero', maxInputImages: 0, accepted: true },
+ { id: 'omitted-positive', maxInputImages: 12, accepted: true },
+ { id: 'true-omitted', supportsVision: true, accepted: true },
+ { id: 'true-zero', supportsVision: true, maxInputImages: 0, accepted: false },
+ { id: 'true-positive', supportsVision: true, maxInputImages: 12, accepted: true },
+ { id: 'false-omitted', supportsVision: false, accepted: true },
+ { id: 'false-zero', supportsVision: false, maxInputImages: 0, accepted: true },
+ { id: 'false-positive', supportsVision: false, maxInputImages: 12, accepted: false },
+ { id: 'invalid-omitted', supportsVision: 'yes', accepted: false },
+ { id: 'invalid-zero', supportsVision: 'yes', maxInputImages: 0, accepted: false },
+ { id: 'invalid-positive', supportsVision: 'yes', maxInputImages: 12, accepted: false },
+ { id: 'invalid-invalid', supportsVision: 'yes', maxInputImages: '12', accepted: false },
+ { id: 'omitted-invalid', maxInputImages: '12', accepted: false },
+ { id: 'true-invalid', supportsVision: true, maxInputImages: '12', accepted: false },
+ { id: 'false-invalid', supportsVision: false, maxInputImages: '12', accepted: false },
+ { id: 'negative-limit', maxInputImages: -1, accepted: false },
+ { id: 'fractional-limit', maxInputImages: 1.5, accepted: false },
+ { id: 'boolean-limit', maxInputImages: true, accepted: false },
+ { id: 'null-limit', maxInputImages: null, accepted: false },
+ { id: 'object-limit', maxInputImages: { count: 12 }, accepted: false },
+ ];
+ const providers = Object.fromEntries(cases.map((entry) => [entry.id, [{
+ id: `${entry.id}-model`,
+ ...('supportsVision' in entry ? { supportsVision: entry.supportsVision } : {}),
+ ...('maxInputImages' in entry ? { maxInputImages: entry.maxInputImages } : {}),
+ }]]));
+ storage.writeJsonSync(file, {
+ version: 1,
+ active: { immediate: { model_catalog: { providers } } },
+ });
+ try {
+ for (const entry of cases) {
+ const models = curatedModelsFor(entry.id);
+ if (entry.accepted) {
+ expect(models, entry.id).toHaveLength(1);
+ } else {
+ expect(models, entry.id).toEqual([]);
+ }
+ }
+ expect(curatedModelsFor('false-zero')).toEqual([{
+ id: 'false-zero-model',
+ name: 'false-zero-model',
+ supportsVision: false,
+ maxInputImages: 0,
+ }]);
+ } finally {
+ fs.rmSync(path.dirname(file), { recursive: true, force: true });
+ }
+ });
+
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');