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

Method CreateRole

agent/app/service/agents_agents.go:20–51  ·  view source on GitHub ↗
(req dto.AgentRoleCreateReq)

Source from the content-addressed store, hash-verified

18var agentMarkdownFileNames = []string{"AGENTS.md", "SOUL.md", "USER.md", "IDENTITY.md", "TOOLS.md", "HEARTBEAT.md", "BOOT.md", "BOOTSTRAP.md"}
19
20func (a AgentService) CreateRole(req dto.AgentRoleCreateReq) (*dto.AgentRoleCreateResp, error) {
21 _, install, err := a.loadAgentAndInstall(req.AgentID)
22 if err != nil {
23 return nil, err
24 }
25
26 args := []string{"openclaw", "agents", "add", req.Name}
27 workspace := "/home/node/.openclaw/workspace-agent_" + req.Name
28 agentDir := "/home/node/.openclaw/agents/" + req.Name
29 args = append(args, "--workspace", workspace)
30 if model := strings.TrimSpace(req.Model); model != "" {
31 args = append(args, "--model", model)
32 }
33 for _, binding := range req.Bindings {
34 channel := binding.Channel
35 if channel == "" {
36 continue
37 }
38 if accountID := binding.AccountID; accountID != "" {
39 channel = channel + ":" + accountID
40 }
41 args = append(args, "--bind", channel)
42 }
43 args = append(args, "--agent-dir", agentDir)
44 args = append(args, "--non-interactive", "--json")
45
46 output, err := cmd.RunDockerExecWithStdout(5*time.Minute, install.ContainerName, args...)
47 if err != nil {
48 return nil, err
49 }
50 return &dto.AgentRoleCreateResp{Output: strings.TrimSpace(output)}, nil
51}
52
53func (a AgentService) GetConfiguredAgents(req dto.AgentConfiguredAgentsReq) ([]dto.AgentConfiguredAgentItem, error) {
54 agent, _, conf, err := a.loadAgentConfig(req.AgentID)

Callers

nothing calls this directly

Calls 1

loadAgentAndInstallMethod · 0.95

Tested by

no test coverage detected