MCPcopy Create free account
hub / github.com/astercloud/aster / agentDir

Method agentDir

pkg/store/json.go:52–62  ·  view source on GitHub ↗

agentDir 获取Agent的存储目录

(agentID string)

Source from the content-addressed store, hash-verified

50
51// agentDir 获取Agent的存储目录
52func (js *JSONStore) agentDir(agentID string) string {
53 // 优先使用原始 AgentID 目录(兼容旧数据,主要用于已有的 *nix 环境)
54 rawDir := filepath.Join(js.baseDir, agentID)
55 if fi, err := os.Stat(rawDir); err == nil && fi.IsDir() {
56 return rawDir
57 }
58
59 // 否则使用经过清洗后的目录名,避免 Windows 等平台上非法路径
60 safeID := sanitizeAgentIDForPath(agentID)
61 return filepath.Join(js.baseDir, safeID)
62}
63
64// ensureAgentDir 确保Agent目录存在
65func (js *JSONStore) ensureAgentDir(agentID string) error {

Callers 14

ensureAgentDirMethod · 0.95
SaveMessagesMethod · 0.95
LoadMessagesMethod · 0.95
TrimMessagesMethod · 0.95
SaveToolCallRecordsMethod · 0.95
LoadToolCallRecordsMethod · 0.95
SaveSnapshotMethod · 0.95
LoadSnapshotMethod · 0.95
ListSnapshotsMethod · 0.95
SaveInfoMethod · 0.95
LoadInfoMethod · 0.95
SaveTodosMethod · 0.95

Calls 3

sanitizeAgentIDForPathFunction · 0.85
StatMethod · 0.65
JoinMethod · 0.45

Tested by

no test coverage detected