The previous commit incorrectly deleted all workflows. Only restart-gateway should be removed (replaced by direct shell trigger). Other workflows (solve-issue, extract-knowledge, develop-sense, develop-workflow) are CLI-triggered and independent of sense coupling.
27 lines
979 B
TypeScript
27 lines
979 B
TypeScript
import type { LlmProvider } from "@uncaged/nerve-workflow-utils";
|
|
import { spawnSafe } from "@uncaged/nerve-workflow-utils";
|
|
|
|
export async function cfgGet(nerveRoot: string, key: string): Promise<string | null> {
|
|
const result = await spawnSafe("cfg", ["get", key], {
|
|
cwd: nerveRoot,
|
|
env: null,
|
|
timeoutMs: 10_000,
|
|
abortSignal: null,
|
|
});
|
|
if (!result.ok) {
|
|
return null;
|
|
}
|
|
const value = result.value.stdout.trim();
|
|
return value.length > 0 ? value : null;
|
|
}
|
|
|
|
export async function resolveDashScopeProvider(nerveRoot: string): Promise<LlmProvider | null> {
|
|
const apiKey = process.env.DASHSCOPE_API_KEY ?? (await cfgGet(nerveRoot, "DASHSCOPE_API_KEY"));
|
|
const baseUrl = process.env.DASHSCOPE_BASE_URL ?? (await cfgGet(nerveRoot, "DASHSCOPE_BASE_URL"));
|
|
const model = process.env.DASHSCOPE_MODEL ?? (await cfgGet(nerveRoot, "DASHSCOPE_MODEL")) ?? "qwen-plus";
|
|
if (!apiKey || !baseUrl) {
|
|
return null;
|
|
}
|
|
return { apiKey, baseUrl, model };
|
|
}
|