feat: 开发对话功能

This commit is contained in:
2026-04-11 16:54:09 +08:00
parent 5151379726
commit 8c2ea4488b
8 changed files with 466 additions and 167 deletions

View File

@@ -199,6 +199,18 @@ function registerIpcHandlers() {
return res.json();
});
ipcMain.handle('opencode:session:prompt-async', async (_e, sessionId, text) => {
if (!opencodePort) throw new Error('OpenCode 服务未启动');
const res = await fetch(`http://127.0.0.1:${opencodePort}/session/${sessionId}/prompt_async`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ parts: [{ type: 'text', text }] }),
});
if (!res.ok) throw new Error(`发送消息失败: ${res.status}`);
// 204 No Content无需解析响应体
return true;
});
// Bonjour
ipcMain.handle('bonjour:get-services', () => getDiscoveredServices());