(req dto.AgentRoleMarkdownFilesUpdateReq)
| 210 | } |
| 211 | |
| 212 | func (a AgentService) UpdateRoleMarkdownFiles(req dto.AgentRoleMarkdownFilesUpdateReq) error { |
| 213 | agent, install, err := a.loadOpenclawAgentAndInstall(req.AgentID) |
| 214 | if err != nil { |
| 215 | return err |
| 216 | } |
| 217 | |
| 218 | baseDir := path.Join(global.Dir.AppInstallDir, agent.AgentType, agent.Name, "data") |
| 219 | dirPath, err := resolveMarkdownWorkspaceDir(baseDir, req.Workspace) |
| 220 | if err != nil { |
| 221 | return err |
| 222 | } |
| 223 | if err = os.MkdirAll(dirPath, 0755); err != nil { |
| 224 | return err |
| 225 | } |
| 226 | for _, item := range req.Files { |
| 227 | file := path.Join(dirPath, item.Name) |
| 228 | if err = os.WriteFile(file, []byte(item.Content), 0644); err != nil { |
| 229 | return err |
| 230 | } |
| 231 | } |
| 232 | if req.Restart { |
| 233 | return NewIAppInstalledService().Operate(request.AppInstalledOperate{ |
| 234 | InstallId: install.ID, |
| 235 | Operate: constant.Restart, |
| 236 | }) |
| 237 | } |
| 238 | return nil |
| 239 | } |
| 240 | |
| 241 | func extractConfiguredAgentItem(installDir string, record map[string]interface{}) dto.AgentConfiguredAgentItem { |
| 242 | item := dto.AgentConfiguredAgentItem{Bindings: []dto.AgentRoleBinding{}} |
nothing calls this directly
no test coverage detected