MCPcopy Create free account
hub / github.com/1Panel-dev/1Panel / GetRoleMarkdownFiles

Method GetRoleMarkdownFiles

agent/app/service/agents_agents.go:184–210  ·  view source on GitHub ↗
(req dto.AgentRoleMarkdownFilesReq)

Source from the content-addressed store, hash-verified

182}
183
184func (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
212func (a AgentService) UpdateRoleMarkdownFiles(req dto.AgentRoleMarkdownFilesUpdateReq) error {
213 agent, install, err := a.loadOpenclawAgentAndInstall(req.AgentID)

Callers

nothing calls this directly

Calls 2

loadOpenclawAgentByIDFunction · 0.85

Tested by

no test coverage detected