This commit is contained in:
@@ -38,6 +38,60 @@ export function buildWorkerEntry({ connectionType, endpoint, model, apiKey }) {
|
||||
return entry;
|
||||
}
|
||||
|
||||
// Build the single worker entry in **camelCase v2 shape** that
|
||||
// ConfigManager.updateConfig expects (it snake-cases on save). The CLI writes
|
||||
// raw YAML via buildWorkerEntry (snake_case); the browser wizard instead PUTs a
|
||||
// JSON config object through updateConfig, which requires camelCase keys.
|
||||
// Passing buildWorkerEntry's snake_case output to updateConfig double-converts
|
||||
// and corrupts keys (Codex review P1 #1) — so the wizard MUST use this builder.
|
||||
export function buildLlmWorkerCamel({ connectionType, endpoint, model, apiKey }) {
|
||||
const entry = {
|
||||
id: connectionType === 'aao_gateway' ? 'gateway' : 'local-llm',
|
||||
connectionType,
|
||||
endpoint,
|
||||
model,
|
||||
roles: [...ALL_ROLES],
|
||||
maxConcurrency: 1,
|
||||
enabled: true,
|
||||
vlm: false,
|
||||
};
|
||||
if (connectionType === 'aao_gateway') entry.apiKey = apiKey;
|
||||
return entry;
|
||||
}
|
||||
|
||||
// Detect whether the runtime has a usable LLM connection. Operate on the
|
||||
// RESOLVED worker list (provider.workers from ConfigManager.getConfig(), after
|
||||
// loadConfig has applied OLLAMA_* env overrides). A fresh install's synthetic
|
||||
// default worker carries an endpoint but an EMPTY model (config-normalize.ts
|
||||
// EMPTY_MODEL=''), so requiring a non-empty model naturally excludes it.
|
||||
// An env override (OLLAMA_MODEL) fills the model, so it counts as configured.
|
||||
// (Codex review P1 #2.)
|
||||
// Execution roles a worker must cover for normal task running. A worker that
|
||||
// only serves e.g. 'title' or 'reflection' can't run user tasks, so the wizard
|
||||
// must NOT consider the install configured (Codex P2 #6). Empty/missing roles
|
||||
// mean "all roles" at runtime (src/worker.ts defaults to auto/fast/quality), so
|
||||
// they count as covering execution.
|
||||
const EXECUTION_ROLES = ['auto', 'fast', 'quality'];
|
||||
function workerCoversExecution(w) {
|
||||
const roles = w.roles;
|
||||
if (!Array.isArray(roles) || roles.length === 0) return true;
|
||||
return roles.some((r) => EXECUTION_ROLES.includes(r));
|
||||
}
|
||||
|
||||
export function isLlmConfigured(workers) {
|
||||
const list = Array.isArray(workers) ? workers : [];
|
||||
return list.some(
|
||||
(w) =>
|
||||
w &&
|
||||
w.enabled !== false &&
|
||||
typeof w.endpoint === 'string' &&
|
||||
w.endpoint.trim() !== '' &&
|
||||
typeof w.model === 'string' &&
|
||||
w.model.trim() !== '' &&
|
||||
workerCoversExecution(w),
|
||||
);
|
||||
}
|
||||
|
||||
// Quote a scalar when a YAML plain scalar would be ambiguous or invalid.
|
||||
function yamlScalar(v) {
|
||||
if (typeof v === 'boolean' || typeof v === 'number') return String(v);
|
||||
|
||||
Reference in New Issue
Block a user