Skip to content

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

:art: Remove AI/LLM isolation for encrypted notebooks, unlocked means plaintext-readable by all callers https://github.com/siyuan-note/siyuan/issues/18034

Danieleb65dfff89a1
diff --git a/app/src/layout/dock/agent/AgentChat.ts b/app/src/layout/dock/agent/AgentChat.ts
index 9d56e5ea75..64d49c56d4 100644
--- a/app/src/layout/dock/agent/AgentChat.ts
+++ b/app/src/layout/dock/agent/AgentChat.ts
@@ -16,7 +16,6 @@ import {setPanelFocus} from "../../util";
import {escapeAriaLabel, escapeHtml} from "../../../util/escape";
import {setPosition} from "../../../util/setPosition";
import {fetchPost, fetchSyncPost} from "../../../util/fetch";
-import {isEncryptedBox} from "../../../util/pathName";
import {Constants} from "../../../constants";
import {confirmDialog} from "../../../dialog/confirmDialog";
import {showMessage} from "../../../dialog/message";
@@ -1525,8 +1524,6 @@ export class AgentChat extends Model {
const focusedBlockID = p.block?.id;
const activeDocTitle = p.title?.editElement?.textContent?.trim() || undefined;
const notebookID = p.notebookId || undefined;
- // AI/LLM 不得感知加密笔记本:当前文档位于加密 box 时,不下发 notebookID 与文档标题等元数据
- const encryptedCtx = isEncryptedBox(notebookID);
const selectedBlockIDs: string[] = [];
p.wysiwyg?.element?.querySelectorAll("[data-node-id].protyle-wysiwyg--select")
@@ -1572,10 +1569,10 @@ export class AgentChat extends Model {
if (activeDocID) {
ctx.activeDocID = activeDocID;
}
- if (activeDocTitle && !encryptedCtx) {
+ if (activeDocTitle) {
ctx.activeDocTitle = activeDocTitle;
}
- if (notebookID && !encryptedCtx) {
+ if (notebookID) {
ctx.notebookID = notebookID;
}
if (focusedBlockID && focusedBlockID !== activeDocID) {
diff --git a/kernel/mcp/tools/document.go b/kernel/mcp/tools/document.go
index 8b768b469d..a92f15e20b 100644
--- a/kernel/mcp/tools/document.go
+++ b/kernel/mcp/tools/document.go
@@ -151,10 +151,6 @@ func documentList(args map[string]interface{}) (CallToolResult, error) {
if notebook == "" {
return CallToolResult{Content: []ContentItem{{Type: "text", Text: "notebook is required"}}, IsError: true}, nil
}
- // AI/LLM 不得进入加密笔记本,拒绝列出其文档(防止文档标题等元数据泄漏)
- if model.IsEncryptedBox(notebook) {
- return CallToolResult{Content: []ContentItem{{Type: "text", Text: "access denied: encrypted notebook is not accessible to AI"}}, IsError: true}, nil
- }
hPath, _ := args["path"].(string)
if hPath == "" {
hPath = "/"
diff --git a/kernel/mcp/tools/file.go b/kernel/mcp/tools/file.go
index 45e951b617..e52aeab95b 100644
--- a/kernel/mcp/tools/file.go
+++ b/kernel/mcp/tools/file.go
@@ -24,7 +24,6 @@ import (
"strings"
"github.com/88250/gulu"
- "github.com/siyuan-note/siyuan/kernel/model"
"github.com/siyuan-note/siyuan/kernel/util"
)
@@ -157,10 +156,6 @@ func fileRead(args map[string]interface{}) (CallToolResult, error) {
if err != nil {
return CallToolResult{Content: []ContentItem{{Type: "text", Text: err.Error()}}, IsError: true}, nil
}
- // 加密笔记本的文件不可通过 AI/MCP 读取
- if model.IsEncryptedAssetPath(abs) {
- return CallToolResult{Content: []ContentItem{{Type: "text", Text: "access denied: encrypted notebook files are not accessible to AI"}}, IsError: true}, nil
- }
data, err := os.ReadFile(abs)
if err != nil {
return CallToolResult{Content: []ContentItem{{Type: "text", Text: "read file failed: " + err.Error()}}, IsError: true}, nil
diff --git a/kernel/mcp/tools/notebook.go b/kernel/mcp/tools/notebook.go
index 23583c8f32..13b48b22c6 100644
--- a/kernel/mcp/tools/notebook.go
+++ b/kernel/mcp/tools/notebook.go
@@ -78,18 +78,9 @@ func notebookList(args map[string]interface{}) (CallToolResult, error) {
return CallToolResult{Content: []ContentItem{{Type: "text", Text: "list notebooks failed: " + err.Error()}}, IsError: true}, nil
}
- // AI/LLM 不得感知加密笔记本的存在,过滤掉加密 box(含其 ID/名称/图标)
- var visible []*model.Box
- for _, nb := range notebooks {
- if model.IsEncryptedBox(nb.ID) {
- continue
- }
- visible = append(visible, nb)
- }
-
var sb strings.Builder
- sb.WriteString(fmt.Sprintf("Notebooks (%d):\n\n", len(visible)))
- for _, nb := range visible {
+ sb.WriteString(fmt.Sprintf("Notebooks (%d):\n\n", len(notebooks)))
+ for _, nb := range notebooks {
sb.WriteString(fmt.Sprintf("- %s (id: %s, icon: %s, closed: %v)\n", nb.Name, nb.ID, nb.Icon, nb.Closed))
}
return CallToolResult{Content: []ContentItem{{Type: "text", Text: sb.String()}}}, nil