(req dto.AgentRoleMarkdownFilesReq)
| 182 | } |
| 183 | |
| 184 | func (a AgentService) GetRoleMarkdownFiles(req dto.AgentRoleMarkdownFilesReq) ([]dto.AgentRoleMarkdownFileItem, error) { |
| 185 | agent, err := loadOpenclawAgentByID(req.AgentID) |
| 186 | if err != nil { |
| 187 | return nil, err |
| 188 | } |
| 189 | |
| 190 | baseDir := path.Join(global.Dir.AppInstallDir, agent.AgentType, agent.Name, "data") |
| 191 | workspaceDir, err := resolveMarkdownWorkspaceDir(baseDir, req.Workspace) |
| 192 | if err != nil { |
| 193 | return nil, err |
| 194 | } |
| 195 | |
| 196 | items := make([]dto.AgentRoleMarkdownFileItem, 0, len(agentMarkdownFileNames)) |
| 197 | for _, name := range agentMarkdownFileNames { |
| 198 | item := dto.AgentRoleMarkdownFileItem{ |
| 199 | Name: name, |
| 200 | } |
| 201 | content, readErr := os.ReadFile(path.Join(workspaceDir, name)) |
| 202 | if readErr == nil { |
| 203 | item.Content = string(content) |
| 204 | } else if !os.IsNotExist(readErr) { |
| 205 | return nil, readErr |
| 206 | } |
| 207 | items = append(items, item) |
| 208 | } |
| 209 | return items, nil |
| 210 | } |
| 211 | |
| 212 | func (a AgentService) UpdateRoleMarkdownFiles(req dto.AgentRoleMarkdownFilesUpdateReq) error { |
| 213 | agent, install, err := a.loadOpenclawAgentAndInstall(req.AgentID) |
nothing calls this directly
no test coverage detected