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
Daniel308c5ae7c9ec
diff --git a/app/src/assets/scss/business/_agentChat.scss b/app/src/assets/scss/business/_agentChat.scssindex e538cd686a..fa88e83f6e 100644--- a/app/src/assets/scss/business/_agentChat.scss+++ b/app/src/assets/scss/business/_agentChat.scss@@ -414,9 +414,9 @@line-height: 1.5;margin-bottom: 8px;padding: 8px 10px;- background: var(--b3-theme-surface-light);- border: 1px solid var(--b3-border-color);- border-radius: var(--b3-border-radius-b);+ background: transparent;+ border: none;+ border-radius: 0;}.agent-chat__thinking-chat--streaming {diff --git a/app/src/layout/dock/AgentChat.ts b/app/src/layout/dock/AgentChat.tsindex 513f29bc03..10a98744b2 100644--- a/app/src/layout/dock/AgentChat.ts+++ b/app/src/layout/dock/AgentChat.ts@@ -55,6 +55,7 @@ export class AgentChat extends Model {private currentThinkingSteps: Array<{reasoning: string; text: string; toolCalls: Array<{name: string; result?: string}>; reasoningContent: string; content?: string}> = [];private currentThinkingStepContent = "";private pendingConfirms: SessionEntry[] = [];+ private renderedToolNames: Record<string, boolean> = {};private modelSelect: HTMLSelectElement;constructor(app: App, tab: Tab) {@@ -610,6 +611,7 @@ export class AgentChat extends Model {this.sessionCompletionTokens = 0;this.sessionTotalDuration = 0;this.currentToolCalls = [];+ this.renderedToolNames = {};if (this.tokenDisplayEl) {this.tokenDisplayEl.classList.add("fn__none");}@@ -896,13 +898,22 @@ export class AgentChat extends Model {let detailLines = "";if (reasoning === "processing" && this.currentToolCalls.length > 0) {- const toolCallLabel = (L.agentToolCall || "Tool call") + "s:";- detailLines += `<div class="agent-chat__thinking-tools-line"><span class="agent-chat__thinking-summary">${toolCallLabel}</span>`;+ const newTools: Array<{name: string; result?: string}> = [];for (let i = 0; i < this.currentToolCalls.length; i++) {const tc = this.currentToolCalls[i];- detailLines += '<span class="agent-chat__thinking-tool">' + this.escapeHtml(tc.name) + "</span>";+ if (!this.renderedToolNames[tc.name]) {+ this.renderedToolNames[tc.name] = true;+ newTools.push(tc);+ }+ }+ if (newTools.length > 0) {+ const toolCallLabel = (L.agentToolCall || "Tool call") + "s:";+ detailLines += `<div class="agent-chat__thinking-tools-line"><span class="agent-chat__thinking-summary">${toolCallLabel}</span>`;+ for (let i = 0; i < newTools.length; i++) {+ detailLines += '<span class="agent-chat__thinking-tool">' + this.escapeHtml(newTools[i].name) + "</span>";+ }+ detailLines += '</div>';}- detailLines += '</div>';}if (reasoning === "processing" && this.currentAIElement) {@@ -1045,6 +1056,7 @@ export class AgentChat extends Model {this.currentContent = "";this.fullContent = "";this.currentToolCalls = [];+ this.renderedToolNames = {};this.currentThinkingSteps = [];this.currentThinkingStepContent = "";this.currentThinkingText = "";@@ -1109,6 +1121,7 @@ export class AgentChat extends Model {this.currentContent = "";this.fullContent = "";this.currentToolCalls = [];+ this.renderedToolNames = {};if (this.requestStartTime) {this.sessionTotalDuration += Date.now() - this.requestStartTime;this.requestStartTime = 0;@@ -1222,6 +1235,7 @@ export class AgentChat extends Model {this.currentContent = "";this.fullContent = "";this.currentToolCalls = [];+ this.renderedToolNames = {};if (this.requestStartTime) {this.sessionTotalDuration += Date.now() - this.requestStartTime;this.requestStartTime = 0;diff --git a/kernel/agent/agent.go b/kernel/agent/agent.goindex 7320b3a2ad..583d07d523 100644--- a/kernel/agent/agent.go+++ b/kernel/agent/agent.go@@ -85,6 +85,11 @@ const systemPrompt = `You are a SiYuan AI assistant. You help users manage their- Update the todo list whenever status changes — call todo_write with the updated list.- Skip todo_write for simple single-step requests. Only use it when there is meaningful multi-step work to track.+## Debugging+- When the user reports an error, problem, or unexpected behavior, first use the file tool to read the SiYuan log at "temp/siyuan.log" (relative to the workspace) to find error messages and context.+- The log file may contain stack traces, error codes, and timestamps that help pinpoint the issue.+- After reading the log, summarize the relevant errors before attempting any fixes.+## Safety- Confirm before deleting documents, blocks, or data.- Confirm before moving or renaming important items.@@ -516,7 +521,7 @@ func GenerateTitle(client *openai.Client, model string, msg string) string {var safeActions = map[string]bool{"get": true, "get_kramdown": true, "get_children": true, "breadcrumb": true,"tree_stat": true,- "list": true, "search_docs": true, "fulltext": true, "backlinks": true,+ "list": true, "read": true, "search_docs": true, "fulltext": true, "backlinks": true,"mentions": true, "labels": true, "status": true, "version": true,"current_time": true, "workspace": true, "md": true, "query": true,}