sync: update from private repo (2ef0fa6)
CI / build-and-test (push) Has been cancelled

This commit is contained in:
oss-sync
2026-06-17 05:23:28 +00:00
parent 517142c61d
commit 1602d52510
42 changed files with 3387 additions and 64 deletions
+62 -1
View File
@@ -1,7 +1,68 @@
import { describe, it, expect } from 'vitest';
import { parseEndpoint, buildWorkerEntry, ALL_ROLES, renderConfigYaml, renderDotenv, parseAnswersFromEnv, probeModels } from './setup-lib.mjs';
import { parseEndpoint, buildWorkerEntry, buildLlmWorkerCamel, isLlmConfigured, ALL_ROLES, renderConfigYaml, renderDotenv, parseAnswersFromEnv, probeModels } from './setup-lib.mjs';
import { parse as parseYaml } from 'yaml';
describe('buildLlmWorkerCamel', () => {
it('returns camelCase v2 keys for a direct worker (no apiKey)', () => {
const w = buildLlmWorkerCamel({ connectionType: 'direct', endpoint: 'http://localhost:11434/v1', model: 'llama3' });
expect(w).toEqual({
id: 'local-llm',
connectionType: 'direct',
endpoint: 'http://localhost:11434/v1',
model: 'llama3',
roles: [...ALL_ROLES],
maxConcurrency: 1,
enabled: true,
vlm: false,
});
// Must NOT carry snake_case keys that would double-convert in updateConfig (P1 #1).
expect(w).not.toHaveProperty('connection_type');
expect(w).not.toHaveProperty('max_concurrency');
});
it('adds apiKey (camelCase) for aao_gateway', () => {
const w = buildLlmWorkerCamel({ connectionType: 'aao_gateway', endpoint: 'http://gw:9876/v1', model: 'm', apiKey: 'sk-aao-x' });
expect(w.id).toBe('gateway');
expect(w.apiKey).toBe('sk-aao-x');
expect(w).not.toHaveProperty('api_key');
});
});
describe('isLlmConfigured', () => {
it('false for empty / non-array', () => {
expect(isLlmConfigured([])).toBe(false);
expect(isLlmConfigured(undefined)).toBe(false);
});
it('false for the synthetic default (endpoint set, empty model)', () => {
expect(isLlmConfigured([{ id: 'default', endpoint: 'http://localhost:11434/v1', model: '', enabled: true }])).toBe(false);
});
it('false when the only usable worker is disabled', () => {
expect(isLlmConfigured([{ endpoint: 'http://h/v1', model: 'm', enabled: false }])).toBe(false);
});
it('true when a usable worker has endpoint + model', () => {
expect(isLlmConfigured([{ endpoint: 'http://h/v1', model: 'm' }])).toBe(true);
});
it('true if any one worker is usable (mixed)', () => {
expect(isLlmConfigured([
{ endpoint: 'http://a/v1', model: '', enabled: true },
{ endpoint: 'http://b/v1', model: 'good', enabled: true },
])).toBe(true);
});
it('treats whitespace-only model/endpoint as empty', () => {
expect(isLlmConfigured([{ endpoint: ' ', model: 'm' }])).toBe(false);
expect(isLlmConfigured([{ endpoint: 'http://h/v1', model: ' ' }])).toBe(false);
});
it('requires execution-role coverage — a title/reflection-only worker does not count', () => {
expect(isLlmConfigured([{ endpoint: 'http://h/v1', model: 'm', roles: ['title'] }])).toBe(false);
expect(isLlmConfigured([{ endpoint: 'http://h/v1', model: 'm', roles: ['title', 'reflection'] }])).toBe(false);
expect(isLlmConfigured([{ endpoint: 'http://h/v1', model: 'm', roles: ['auto'] }])).toBe(true);
expect(isLlmConfigured([{ endpoint: 'http://h/v1', model: 'm', roles: ['quality', 'title'] }])).toBe(true);
});
it('treats empty/missing roles as covering execution (runtime default auto/fast/quality)', () => {
expect(isLlmConfigured([{ endpoint: 'http://h/v1', model: 'm', roles: [] }])).toBe(true);
expect(isLlmConfigured([{ endpoint: 'http://h/v1', model: 'm' }])).toBe(true);
});
});
describe('parseEndpoint', () => {
it('keeps a full http URL and derives the /v1-stripped base', () => {
expect(parseEndpoint('http://localhost:11434/v1')).toEqual({