feat: 开发对话功能
This commit is contained in:
@@ -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());
|
||||
|
||||
|
||||
Reference in New Issue
Block a user