feat: 升级至 v0.2.2 — 工作空间路径注入、Provider 切换修复、编码与样式优化
功能增强: - System Prompt 注入当前工作空间路径到动态区(LLM 可使用绝对路径调用工具) - ContextBuilder.buildSystemPrompt 新增 workspacePath 参数 Provider 切换修复: - reloadAdapter 返回 boolean,失败时 sendMessage 中止发送 - 切换 Provider 时自动清空 apiKey(不同 Provider key 不通用) - apiKey 为空时显示警告提示 - Provider 切换事件加 sessionId 字段 编码修复: - run_command 使用 encoding: 'buffer' 获取原始字节 - 新增 decodeBuffer 智能解码:UTF-8 严格 → GBK → UTF-8 宽松 - 修复不响应 chcp 的 Windows 命令中文乱码问题 样式优化: - 代码块底色改用主题变量(灰底主题色文字,双主题适配) - 表格标题 th/td 底色和文字色改用主题变量 - CodeBlock 组件 pre 背景从 secondary.main 改为 background.default - 设置面板已自动执行工具行 opacity 0.8→0.15(淡绿底,文字清晰) 版本号 0.2.1 → 0.2.2
This commit is contained in:
@@ -44,7 +44,7 @@ export function registerAllIPCHandlers(
|
||||
sessionRecorder: SessionRecorder,
|
||||
memoryManager: MemoryManager,
|
||||
mcpManager: MCPManager,
|
||||
reloadAdapter: () => void,
|
||||
reloadAdapter: () => boolean,
|
||||
promptInjectionDefender: PromptInjectionDefender,
|
||||
outputValidator: OutputValidator,
|
||||
confirmationHook: ConfirmationHook,
|
||||
@@ -56,8 +56,29 @@ export function registerAllIPCHandlers(
|
||||
ipcMain.handle('agent:sendMessage', async (_event, userMessage: MetonaMessage, sessionId: string) => {
|
||||
log.info('[AGENT] sendMessage:', sessionId, userMessage.content.slice(0, 80));
|
||||
|
||||
// 发送消息前确保 Adapter 使用最新配置(防止 config:set 中间状态导致 reload 失败)
|
||||
reloadAdapter();
|
||||
// 发送消息前确保 Adapter 使用最新配置(失败则中止,防止用旧 Provider 的 adapter 发送)
|
||||
if (!reloadAdapter()) {
|
||||
const errorMsg = 'Adapter 加载失败,请检查 LLM 配置(Provider、API Key、Base URL、Model 是否完整)';
|
||||
log.error('[AGENT]', errorMsg);
|
||||
if (!mainWindow.isDestroyed()) {
|
||||
const errorEvent: MetonaStreamEvent = {
|
||||
type: MetonaStreamEventType.ERROR,
|
||||
requestId: '',
|
||||
sessionId,
|
||||
iteration: 0,
|
||||
seq: 0,
|
||||
timestamp: Date.now(),
|
||||
error: { code: MetonaErrorCode.UNKNOWN, message: errorMsg, retryable: false },
|
||||
};
|
||||
mainWindow.webContents.send('agent:streamEvent', errorEvent);
|
||||
mainWindow.webContents.send('agent:streamEvent', {
|
||||
...errorEvent,
|
||||
type: MetonaStreamEventType.DONE,
|
||||
});
|
||||
}
|
||||
sessionRecorder.stopRecording({ totalIterations: 0, totalTokens: 0, durationMs: 0, terminationReason: 'error' });
|
||||
return { success: false, error: errorMsg };
|
||||
}
|
||||
|
||||
// TRACE 层:开始录制
|
||||
sessionRecorder.startRecording(sessionId);
|
||||
@@ -88,9 +109,9 @@ export function registerAllIPCHandlers(
|
||||
timestamp: m.timestamp,
|
||||
}));
|
||||
|
||||
// 从工作空间文件构建 System Prompt
|
||||
// 从工作空间文件构建 System Prompt(注入当前工作空间路径,便于 LLM 在需要绝对路径时使用)
|
||||
const workspaceFiles = workspaceService.getFiles();
|
||||
const systemPrompt = contextBuilder.buildSystemPrompt(workspaceFiles);
|
||||
const systemPrompt = contextBuilder.buildSystemPrompt(workspaceFiles, workspaceService.getPath());
|
||||
|
||||
// 检索与用户消息相关的记忆,注入到 System Prompt 动态区
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user