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

Method UpdateRoleMarkdownFiles

agent/app/service/agents_agents.go:212–239  ·  view source on GitHub ↗
(req dto.AgentRoleMarkdownFilesUpdateReq)

Source from the content-addressed store, hash-verified

210}
211
212func (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
241func extractConfiguredAgentItem(installDir string, record map[string]interface{}) dto.AgentConfiguredAgentItem {
242 item := dto.AgentConfiguredAgentItem{Bindings: []dto.AgentRoleBinding{}}

Callers

nothing calls this directly

Calls 6

NewIAppInstalledServiceFunction · 0.85
MkdirAllMethod · 0.80
WriteFileMethod · 0.80
OperateMethod · 0.65

Tested by

no test coverage detected