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

Function resolveMarkdownWorkspaceDir

agent/app/service/agents_agents.go:505–527  ·  view source on GitHub ↗
(installDir, workspace string)

Source from the content-addressed store, hash-verified

503}
504
505func resolveMarkdownWorkspaceDir(installDir, workspace string) (string, error) {
506 if workspace == "" {
507 return "", buserr.New("ErrRecordNotFound")
508 }
509
510 confDir := path.Join(installDir, "conf")
511 allowedOpenclawPrefixes := []string{
512 "/home/node/.openclaw/workspace/",
513 "/home/node/.openclaw/workspace-agent_",
514 }
515 for _, prefix := range allowedOpenclawPrefixes {
516 if strings.HasPrefix(workspace, prefix) {
517 return resolveRoleDir(installDir, workspace), nil
518 }
519 }
520
521 cleanWorkspace := path.Clean(workspace)
522 cleanConfDir := path.Clean(confDir)
523 if cleanWorkspace == cleanConfDir || strings.HasPrefix(cleanWorkspace, cleanConfDir+"/") {
524 return cleanWorkspace, nil
525 }
526 return "", buserr.New("ErrRecordNotFound")
527}

Callers 2

GetRoleMarkdownFilesMethod · 0.85

Calls 2

resolveRoleDirFunction · 0.85
CleanMethod · 0.65

Tested by

no test coverage detected