MCPcopy Create free account
hub / github.com/53AI/53AIHub / buildSkillFilesForSandbox

Function buildSkillFilesForSandbox

api/service/tools/executor.go:714–753  ·  view source on GitHub ↗
(ctx context.Context)

Source from the content-addressed store, hash-verified

712}
713
714func buildSkillFilesForSandbox(ctx context.Context) (map[string]string, error) {
715 files := make(map[string]string)
716
717 if runtime := loadRuntimeSeedFilesFromContext(ctx); len(runtime) > 0 {
718 for k, v := range runtime {
719 files[k] = v
720 }
721 }
722
723 skillRootPath, ok := ctx.Value(SkillRootPathKey).(string)
724 if !ok || strings.TrimSpace(skillRootPath) == "" {
725 if len(files) == 0 {
726 return nil, nil
727 }
728 return files, nil
729 }
730
731 var resources []string
732 if raw := ctx.Value(SkillResourcesKey); raw != nil {
733 if list, ok := raw.([]string); ok {
734 resources = list
735 }
736 }
737
738 skillFiles, err := loadSkillFilesForSandbox(ctx, skillRootPath, resources)
739 if err != nil {
740 return nil, err
741 }
742 for k, v := range skillFiles {
743 // Runtime seed files have higher priority than static skill resources.
744 if _, exists := files[k]; !exists {
745 files[k] = v
746 }
747 }
748
749 if len(files) == 0 {
750 return nil, nil
751 }
752 return files, nil
753}
754
755func loadRuntimeSeedFilesFromContext(ctx context.Context) map[string]string {
756 raw := ctx.Value(RuntimeSeedFilesKey)

Callers 7

executeRunShellFunction · 0.85
executeReadFileFunction · 0.85
executeEditFileFunction · 0.85
executeListFilesFunction · 0.85
buildSandboxRequestFunction · 0.85

Calls 2

loadSkillFilesForSandboxFunction · 0.85

Tested by

no test coverage detected