refactor(agent): 将 Summary Model 改造为内置 Sub Agent
- 扩展 AgentMode 类型添加 'internal' 模式 - 新增 summary agent preset (claude-3-5-haiku) - AgentRegistry 添加 getInternal/listInternalAgents 方法 - CompressionManager 添加 setSummaryModelFromAgentConfig - Agent 构造函数改用 Registry 配置初始化 Summary 模型 - 清理旧的 SummaryConfig 配置系统 - UI AgentsPanel 分离显示 System/Preset/Custom agents - UI AgentEditor 为 internal agent 显示简化编辑界面
This commit is contained in:
@@ -5,11 +5,6 @@
|
||||
*/
|
||||
|
||||
import { Hono } from 'hono';
|
||||
import {
|
||||
getSummaryConfig,
|
||||
updateSummaryConfig,
|
||||
type SummaryConfigInfo,
|
||||
} from '../agent/adapter.js';
|
||||
|
||||
export const configRouter = new Hono();
|
||||
|
||||
@@ -102,70 +97,3 @@ export function getConfig(): ServerConfig {
|
||||
export function setConfig(config: Partial<ServerConfig>): void {
|
||||
serverConfig = { ...serverConfig, ...config };
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
// 摘要配置 API
|
||||
// ============================================================================
|
||||
|
||||
/**
|
||||
* GET /config/summary - 获取摘要模型配置
|
||||
*/
|
||||
configRouter.get('/summary', (c) => {
|
||||
const config = getSummaryConfig();
|
||||
|
||||
if (!config) {
|
||||
// Core 模块不可用
|
||||
return c.json({
|
||||
success: true,
|
||||
data: {
|
||||
hasApiKey: false,
|
||||
} as SummaryConfigInfo,
|
||||
});
|
||||
}
|
||||
|
||||
return c.json({
|
||||
success: true,
|
||||
data: config,
|
||||
});
|
||||
});
|
||||
|
||||
/**
|
||||
* PUT /config/summary - 更新摘要模型配置
|
||||
*/
|
||||
configRouter.put('/summary', async (c) => {
|
||||
try {
|
||||
const body = await c.req.json();
|
||||
|
||||
const success = updateSummaryConfig({
|
||||
provider: body.provider,
|
||||
model: body.model,
|
||||
apiKey: body.apiKey,
|
||||
baseUrl: body.baseUrl,
|
||||
});
|
||||
|
||||
if (!success) {
|
||||
return c.json(
|
||||
{
|
||||
success: false,
|
||||
error: 'Core module not available',
|
||||
},
|
||||
500
|
||||
);
|
||||
}
|
||||
|
||||
// 返回更新后的配置(不含 API Key)
|
||||
const config = getSummaryConfig();
|
||||
return c.json({
|
||||
success: true,
|
||||
data: config,
|
||||
});
|
||||
} catch (error) {
|
||||
return c.json(
|
||||
{
|
||||
success: false,
|
||||
error: error instanceof Error ? error.message : 'Invalid input',
|
||||
},
|
||||
400
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user