An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
:art: Add a kernel API `/api/system/getWorkspaceInfo` https://github.com/siyuan-note/siyuan/issues/13300
Daniel691290a7be30
diff --git a/kernel/api/router.go b/kernel/api/router.goindex c3cc9457e5..ec2d5dbd0c 100644--- a/kernel/api/router.go+++ b/kernel/api/router.go@@ -65,6 +65,7 @@ func ServeAPI(ginServer *gin.Engine) {ginServer.Handle("POST", "/api/system/getNetwork", model.CheckAuth, model.CheckAdminRole, getNetwork)ginServer.Handle("POST", "/api/system/exportConf", model.CheckAuth, model.CheckAdminRole, exportConf)ginServer.Handle("POST", "/api/system/importConf", model.CheckAuth, model.CheckAdminRole, model.CheckReadonly, importConf)+ ginServer.Handle("POST", "/api/system/getWorkspaceInfo", model.CheckAuth, model.CheckAdminRole, model.CheckReadonly, getWorkspaceInfo)ginServer.Handle("POST", "/api/storage/setLocalStorage", model.CheckAuth, model.CheckAdminRole, model.CheckReadonly, setLocalStorage)ginServer.Handle("POST", "/api/storage/getLocalStorage", model.CheckAuth, getLocalStorage)diff --git a/kernel/api/system.go b/kernel/api/system.goindex 5f1e66a342..c4eb5cd467 100644--- a/kernel/api/system.go+++ b/kernel/api/system.go@@ -35,6 +35,15 @@ import ("github.com/siyuan-note/siyuan/kernel/util")+func getWorkspaceInfo(c *gin.Context) {+ ret := gulu.Ret.NewResult()+ defer c.JSON(http.StatusOK, ret)++ ret.Data = map[string]any{+ "workspaceDir": util.WorkspaceDir,+ }+}+func getNetwork(c *gin.Context) {ret := gulu.Ret.NewResult()defer c.JSON(http.StatusOK, ret)diff --git a/kernel/model/session.go b/kernel/model/session.goindex f51f82a76f..a5ff1f1210 100644--- a/kernel/model/session.go+++ b/kernel/model/session.go@@ -232,7 +232,7 @@ func CheckAuth(c *gin.Context) {c.Next()return}- if strings.HasPrefix(c.Request.RequestURI, "/api/system/getNetwork") {+ if strings.HasPrefix(c.Request.RequestURI, "/api/system/getNetwork") || strings.HasPrefix(c.Request.RequestURI, "/api/system/getWorkspaceInfo") {c.Set(RoleContextKey, RoleAdministrator)c.Next()return