mirror of
https://github.com/YspCoder/clawgo.git
synced 2026-04-29 05:47:37 +08:00
feat: add subagent profiles, memory namespaces, and webui management
This commit is contained in:
38
pkg/tools/memory_namespace.go
Normal file
38
pkg/tools/memory_namespace.go
Normal file
@@ -0,0 +1,38 @@
|
||||
package tools
|
||||
|
||||
import (
|
||||
"path/filepath"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func normalizeMemoryNamespace(in string) string {
|
||||
v := normalizeSubagentIdentifier(in)
|
||||
if v == "" {
|
||||
return "main"
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
func memoryNamespaceBaseDir(workspace, namespace string) string {
|
||||
ns := normalizeMemoryNamespace(namespace)
|
||||
if ns == "main" {
|
||||
return workspace
|
||||
}
|
||||
return filepath.Join(workspace, "agents", ns)
|
||||
}
|
||||
|
||||
func parseMemoryNamespaceArg(args map[string]interface{}) string {
|
||||
if args == nil {
|
||||
return "main"
|
||||
}
|
||||
raw, _ := args["namespace"].(string)
|
||||
return normalizeMemoryNamespace(raw)
|
||||
}
|
||||
|
||||
func isPathUnder(parent, child string) bool {
|
||||
rel, err := filepath.Rel(parent, child)
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
return !strings.HasPrefix(rel, "..")
|
||||
}
|
||||
Reference in New Issue
Block a user