uniqueNames drops empty entries and de-duplicates names. By default it keeps the first-seen order (meaningful for declaration/priority order); when sorted is true it orders the result case-insensitively instead.
(names []string, sorted bool)
| 965 | // the first-seen order (meaningful for declaration/priority order); when sorted |
| 966 | // is true it orders the result case-insensitively instead. |
| 967 | func uniqueNames(names []string, sorted bool) []string { |
| 968 | seen := make(map[string]struct{}, len(names)) |
| 969 | out := make([]string, 0, len(names)) |
| 970 | for _, name := range names { |
| 971 | if name == "" { |
| 972 | continue |
| 973 | } |
| 974 | if _, dup := seen[name]; dup { |
| 975 | continue |
| 976 | } |
| 977 | seen[name] = struct{}{} |
| 978 | out = append(out, name) |
| 979 | } |
| 980 | if sorted { |
| 981 | slices.SortFunc(out, func(a, b string) int { |
| 982 | return strings.Compare(strings.ToLower(a), strings.ToLower(b)) |
| 983 | }) |
| 984 | } |
| 985 | return out |
| 986 | } |
| 987 | |
| 988 | // CurrentAgentToolsetStatuses returns one ToolsetStatus per toolset of the |
| 989 | // active agent. The list is in declaration order. Toolsets that wrap |
no outgoing calls