(ctx context.Context)
| 712 | } |
| 713 | |
| 714 | func 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 | |
| 755 | func loadRuntimeSeedFilesFromContext(ctx context.Context) map[string]string { |
| 756 | raw := ctx.Value(RuntimeSeedFilesKey) |
no test coverage detected