An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
:sparkles: AI Agent https://github.com/siyuan-note/siyuan/issues/17797
Daniel1e5f4c32f5f6
diff --git a/app/src/layout/dock/AgentChat.ts b/app/src/layout/dock/AgentChat.tsindex 4f7e6d93c6..394607ef39 100644--- a/app/src/layout/dock/AgentChat.ts+++ b/app/src/layout/dock/AgentChat.ts@@ -522,7 +522,6 @@ export class AgentChat extends Model {this.messages.push({role: "user", content: text});this.appendUserMessage(text);if (this.composer) { this.composer.pushHistory(text); }- this.saveSession().catch(function (e) { console.error(e); });this.requestStartTime = Date.now();@@ -697,6 +696,15 @@ export class AgentChat extends Model {}private appendThinking(reasoning: string) {+ if (this.currentThinkingText) {+ const tc = this.currentToolCalls.map(function (t) { return {name: t.name, result: t.result}; });+ this.thinkingSteps.push({+ reasoning: this.currentThinkingReasoning,+ text: this.currentThinkingText,+ toolCalls: tc,+ reasoningContent: this.currentThinkingReasoningContent,+ });+ }this.finishActiveThinking();this.currentThinkingText = "";this.currentThinkingReasoning = reasoning;@@ -872,15 +880,6 @@ export class AgentChat extends Model {this.currentAIElement = null;this.currentContent = "";this.fullContent = "";- if (this.currentThinkingText) {- const tc = this.currentToolCalls.map(function (t) { return {name: t.name, result: t.result}; });- this.thinkingSteps.push({- reasoning: this.currentThinkingReasoning,- text: this.currentThinkingText,- toolCalls: tc,- reasoningContent: this.currentThinkingReasoningContent,- });- }this.currentToolCalls = [];if (this.requestStartTime) {this.sessionTotalDuration += Date.now() - this.requestStartTime;diff --git a/kernel/mcp/handler.go b/kernel/mcp/handler.goindex 4329d86cbd..994493b84f 100644--- a/kernel/mcp/handler.go+++ b/kernel/mcp/handler.go@@ -133,8 +133,8 @@ func handleToolsCall(req *JsonRpcRequest) any {}}- t, exists := tools.Registry[toolName]- if !exists {+ t := tools.LookupTool(toolName)+ if t == nil {return &JsonRpcResponse{JsonRpc: "2.0",Result: tools.CallToolResult{diff --git a/kernel/mcp/tools/register.go b/kernel/mcp/tools/register.goindex a40c7c80f5..22ffc0a730 100644--- a/kernel/mcp/tools/register.go+++ b/kernel/mcp/tools/register.go@@ -16,15 +16,45 @@package tools-import "sync"+import (+ "strings"+ "sync"+)var registryMu sync.RWMutexvar Registry = map[string]*Tool{}func GetTool(name string) *Tool {+ return LookupTool(name)+}++func LookupTool(name string) *Tool {registryMu.RLock()defer registryMu.RUnlock()- return Registry[name]++ name = strings.TrimSpace(name)++ if t := Registry[name]; t != nil {+ return t+ }++ lower := strings.ToLower(name)+ for k, v := range Registry {+ if strings.ToLower(k) == lower {+ return v+ }+ }++ if prefix := "siyuan_"; strings.HasPrefix(lower, prefix) {+ base := strings.TrimPrefix(lower, prefix)+ for k, v := range Registry {+ if strings.ToLower(k) == base {+ return v+ }+ }+ }++ return nil}func GetAllTools() []*Tool {