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:
2025-12-14 22:12:36 +08:00
parent e97daaa0eb
commit c307cd3a7c
20 changed files with 339 additions and 594 deletions
-79
View File
@@ -76,16 +76,6 @@ interface PermissionManager {
setAskCallback(callback: (ctx: unknown) => Promise<{ allow: boolean; remember?: boolean }>): void;
}
/**
* Summary 配置接口
*/
export interface SummaryConfig {
provider: string;
apiKey: string;
model: string;
baseUrl?: string;
}
/**
* Core 模块接口
*/
@@ -94,7 +84,6 @@ interface CoreModule {
toolRegistry: ToolRegistry;
loadConfig: () => unknown;
saveConfig: (config: Record<string, unknown>) => void;
loadSummaryConfig: () => SummaryConfig | null;
getPermissionManager: (projectRoot?: string) => PermissionManager;
}
@@ -443,71 +432,3 @@ export async function compressContext(
}
}
// ============================================================================
// 摘要配置 API
// ============================================================================
/**
* 摘要配置(不含 API Key 明文)
*/
export interface SummaryConfigInfo {
provider?: string;
model?: string;
hasApiKey: boolean;
baseUrl?: string;
}
/**
* 获取摘要配置
*/
export function getSummaryConfig(): SummaryConfigInfo | null {
if (!coreModule) {
return null;
}
const config = coreModule.loadSummaryConfig();
if (!config) {
return {
hasApiKey: false,
};
}
return {
provider: config.provider,
model: config.model,
hasApiKey: !!config.apiKey,
baseUrl: config.baseUrl,
};
}
/**
* 更新摘要配置
*/
export function updateSummaryConfig(config: {
provider?: string;
model?: string;
apiKey?: string;
baseUrl?: string;
}): boolean {
if (!coreModule) {
return false;
}
// 构建要保存的配置
const saveData: Record<string, unknown> = {};
if (config.provider !== undefined) {
saveData.summaryProvider = config.provider;
}
if (config.model !== undefined) {
saveData.summaryModel = config.model;
}
if (config.apiKey !== undefined) {
saveData.summaryApiKey = config.apiKey;
}
if (config.baseUrl !== undefined) {
saveData.summaryBaseUrl = config.baseUrl;
}
coreModule.saveConfig(saveData);
return true;
}
-4
View File
@@ -15,12 +15,8 @@ export {
// 上下文压缩相关
getContextUsage,
compressContext,
getSummaryConfig,
updateSummaryConfig,
// 类型导出
type TokenUsage,
type CompressionResult,
type ContextUsageInfo,
type SummaryConfigInfo,
type SummaryConfig,
} from './adapter.js';