Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:sparkles: AI Agent https://github.com/siyuan-note/siyuan/issues/17797

Daniel916bd2cf1066
diff --git a/app/electron/main.js b/app/electron/main.js
index 306b6948c6..93e5b041fa 100644
--- a/app/electron/main.js
+++ b/app/electron/main.js
@@ -76,6 +76,7 @@ app.commandLine.appendSwitch("auto-detect", "false");
app.commandLine.appendSwitch("no-proxy-server");
app.commandLine.appendSwitch("enable-features", "PlatformHEVCDecoderSupport");
app.commandLine.appendSwitch("xdg-portal-required-version", "4");
+app.commandLine.appendSwitch("max-connections-per-host", "256");
// Support set Chromium command line arguments on the desktop https://github.com/siyuan-note/siyuan/issues/9696
writeLog("app is packaged [" + app.isPackaged + "], command line args [" + process.argv.join(", ") + "]");
diff --git a/app/src/assets/scss/business/_agentChat.scss b/app/src/assets/scss/business/_agentChat.scss
index eeb221b6d0..6f1af446ed 100644
--- a/app/src/assets/scss/business/_agentChat.scss
+++ b/app/src/assets/scss/business/_agentChat.scss
@@ -554,16 +554,8 @@
.agent-session-popup {
position: fixed;
- top: 40px;
- right: 8px;
width: 280px;
max-height: 300px;
-
- .b3-menu__label {
- overflow: hidden;
- text-overflow: ellipsis;
- white-space: nowrap;
- }
}
.agent-session-popup__actions {
diff --git a/app/src/layout/dock/AgentChat.ts b/app/src/layout/dock/AgentChat.ts
index 7a1e4b9bea..0fea2aba1a 100644
--- a/app/src/layout/dock/AgentChat.ts
+++ b/app/src/layout/dock/AgentChat.ts
@@ -6,6 +6,7 @@ import {mountComposer} from "./AgentComposer";
import {AgentSession, SessionStore} from "./SessionStore";
import {getDockByType} from "../tabUtil";
import {updateHotkeyAfterTip} from "../../protyle/util/compatibility";
+import {setPosition} from "../../util/setPosition";
interface IAgentMessage {
role: "user" | "assistant";
@@ -287,6 +288,9 @@ export class AgentChat extends Model {
this.parent.panelElement.appendChild(this.sessionPopup);
+ const btnRect = this.sessionMenuBtn.getBoundingClientRect();
+ setPosition(this.sessionPopup, btnRect.right - 280, btnRect.bottom, btnRect.height, btnRect.width);
+
const self2 = this;
this.sessionPopup.addEventListener("click", function (e: MouseEvent) {
e.stopPropagation();
@@ -853,9 +857,10 @@ export class AgentChat extends Model {
}
}
// Remove all AI/tool/thinking/error DOM after last user message
- const msgs = this.messagesContainer.querySelectorAll(".agent-chat__msg--ai, .agent-chat__msg--tool, .agent-chat__msg--thinking, .agent-chat__msg--error, .agent-chat__msg--confirm, .agent-chat__msg--question");
- for (let i = msgs.length - 1; i >= 0; i--) {
- msgs[i].remove();
+ const all = this.messagesContainer.querySelectorAll(".agent-chat__msg");
+ for (let i = all.length - 1; i >= 0; i--) {
+ if (all[i].classList.contains("agent-chat__msg--user")) { break; }
+ all[i].remove();
}
this.currentAIElement = null;
this.currentContent = "";
diff --git a/kernel/api/router.go b/kernel/api/router.go
index f9f6b770d2..0961c97d8d 100644
--- a/kernel/api/router.go
+++ b/kernel/api/router.go
@@ -524,9 +524,9 @@ func ServeAPI(ginServer *gin.Engine) {
ginServer.Handle("POST", "/api/ai/chatGPT", model.CheckAuth, model.CheckAdminRole, chatGPT)
ginServer.Handle("POST", "/api/ai/chatGPTWithAction", model.CheckAuth, model.CheckAdminRole, chatGPTWithAction)
- ginServer.Handle("POST", "/api/ai/agent/chat", model.CheckAuth, model.CheckAdminRole, agentChat)
- ginServer.Handle("POST", "/api/ai/agent/confirm", model.CheckAuth, model.CheckAdminRole, agentChatConfirm)
- ginServer.Handle("POST", "/api/ai/agent/question", model.CheckAuth, model.CheckAdminRole, agentChatQuestion)
+ ginServer.Handle("POST", "/api/ai/agent/chat", model.CheckAuth, model.CheckAdminRole, model.CheckReadonly, agentChat)
+ ginServer.Handle("POST", "/api/ai/agent/confirm", model.CheckAuth, model.CheckAdminRole, model.CheckReadonly, agentChatConfirm)
+ ginServer.Handle("POST", "/api/ai/agent/question", model.CheckAuth, model.CheckAdminRole, model.CheckReadonly, agentChatQuestion)
ginServer.Handle("POST", "/api/ai/agent/title", model.CheckAuth, model.CheckAdminRole, agentChatTitle)
ginServer.Handle("POST", "/api/petal/loadPetals", model.CheckAuth, loadPetals)
diff --git a/kernel/model/session.go b/kernel/model/session.go
index dfa778bee1..5c6992ab5e 100644
--- a/kernel/model/session.go
+++ b/kernel/model/session.go
@@ -477,6 +477,7 @@ func ControlConcurrency(c *gin.Context) {
strings.HasPrefix(reqPath, "/api/search/") ||
strings.HasPrefix(reqPath, "/api/network/") ||
strings.HasPrefix(reqPath, "/api/broadcast/") ||
+ strings.HasPrefix(reqPath, "/api/ai/") ||
strings.HasPrefix(reqPath, "/es/") ||
strings.HasPrefix(reqPath, "/mcp") {
c.Next()