refactor(core): 统一配置系统,移除 config.json

- 移除 config.json,所有配置统一从 agents.json 和 providers.json 读取
- config-loader.ts 从全局目录 ~/.ai-terminal-assistant/ 加载配置
- loadConfig() 从 agentRegistry.getGlobalConfig() 获取 defaults.model
- 添加 loadVisionConfig() 支持 Vision 模型配置
- Tavily API Key 仅从环境变量读取
- UI AgentDefaultsEditor 添加 Vision 模型配置界面
- 更新相关测试
This commit is contained in:
2025-12-16 00:33:29 +08:00
parent 76b1ae1573
commit 9376887995
14 changed files with 414 additions and 643 deletions
+6 -5
View File
@@ -5,6 +5,7 @@
*/
import { Hono } from 'hono';
import { getConfig } from './config.js';
// Types from core - dynamically import to avoid build dependency
interface ProviderListItem {
@@ -246,7 +247,7 @@ providersRouter.post('/', async (c) => {
const registry = core.getProviderRegistry();
registry.registerCustom(body);
await registry.saveConfig();
await registry.saveConfig(getConfig().workdir);
return c.json({
success: true,
@@ -284,7 +285,7 @@ providersRouter.put('/:id', async (c) => {
}
registry.setConfig(id, { ...body, id });
await registry.saveConfig();
await registry.saveConfig(getConfig().workdir);
return c.json({
success: true,
@@ -320,7 +321,7 @@ providersRouter.delete('/:id', async (c) => {
return c.json({ success: false, error: `Provider not found: ${id}` }, 404);
}
await registry.saveConfig();
await registry.saveConfig(getConfig().workdir);
return c.json({
success: true,
@@ -364,7 +365,7 @@ providersRouter.post('/:id/models', async (c) => {
const registry = core.getProviderRegistry();
registry.addCustomModel(providerId, body);
await registry.saveConfig();
await registry.saveConfig(getConfig().workdir);
return c.json({
success: true,
@@ -407,7 +408,7 @@ providersRouter.delete('/:id/models/:modelId', async (c) => {
);
}
await registry.saveConfig();
await registry.saveConfig(getConfig().workdir);
return c.json({
success: true,