feat: v3.0 Tool Calling — AI 本地文件操作系统
新增文件: - src/main/tool-security.ts: 路径白名单/黑名单、命令安全检查 - src/main/tool-handlers.ts: 7个工具实现(read/write/list/search/create/delete/run) - src/renderer/services/tool-registry.ts: 工具注册调度中心 - src/renderer/services/agent-engine.ts: Agent Loop 流式多轮工具调用引擎 - src/renderer/components/tool-confirm-modal.ts: 高风险操作确认对话框 修改文件: - types.d.ts: 新增 ToolCall/ToolResult/ToolCallRecord 等类型 - ollama.ts: chatStream 支持 tools 参数 - ipc.ts: 新增 tool:execute/getConfig/setAllowedDirs IPC - preload.ts: 暴露 tool API - chat-area.ts: 渲染工具调用卡片 - input-area.ts: 集成 Agent Loop 引擎 - settings-modal.ts: 工具调用开关设置 - index.html: 工具调用设置面板 + 确认对话框 HTML - style.css: 工具调用卡片、确认对话框样式 - main.ts: 初始化工具调用配置
This commit is contained in:
@@ -5,7 +5,7 @@
|
||||
import type {
|
||||
OllamaChatParams, OllamaStreamChunk, OllamaModelsResponse,
|
||||
OllamaPsResponse, OllamaVersionResponse, OllamaModelDetail,
|
||||
OllamaEmbedResponse
|
||||
OllamaEmbedResponse, ToolDefinition
|
||||
} from '../types.js';
|
||||
|
||||
export class OllamaAPI {
|
||||
@@ -65,7 +65,7 @@ export class OllamaAPI {
|
||||
}
|
||||
|
||||
async chatStream(
|
||||
params: OllamaChatParams,
|
||||
params: OllamaChatParams & { tools?: ToolDefinition[] },
|
||||
onChunk: (chunk: OllamaStreamChunk) => void,
|
||||
abortController?: AbortController
|
||||
): Promise<void> {
|
||||
@@ -78,6 +78,7 @@ export class OllamaAPI {
|
||||
if (params.system) body.system = params.system;
|
||||
if (params.keep_alive !== undefined) body.keep_alive = params.keep_alive;
|
||||
if (params.options) body.options = params.options;
|
||||
if (params.tools?.length) body.tools = params.tools;
|
||||
|
||||
const fetchOptions: RequestInit = {
|
||||
method: 'POST',
|
||||
|
||||
Reference in New Issue
Block a user