flaggedToolDiff returns the tools whose definition (input schema or meta) differs from the default-flagged inventory when only the given flag is on, plus tools that exist only in the flag-on inventory. Results are sorted by tool name.
(t translations.TranslationHelperFunc, flag string, defaultTools map[string]inventory.ServerTool)
| 74 | // plus tools that exist only in the flag-on inventory. Results are sorted by |
| 75 | // tool name. |
| 76 | func flaggedToolDiff(t translations.TranslationHelperFunc, flag string, defaultTools map[string]inventory.ServerTool) []inventory.ServerTool { |
| 77 | flagTools := buildInventoryWithFlags(t, map[string]bool{flag: true}).ToolsForRegistration(context.Background()) |
| 78 | |
| 79 | out := make([]inventory.ServerTool, 0) |
| 80 | seen := make(map[string]struct{}, len(flagTools)) |
| 81 | |
| 82 | for _, tool := range flagTools { |
| 83 | if _, ok := seen[tool.Tool.Name]; ok { |
| 84 | continue |
| 85 | } |
| 86 | seen[tool.Tool.Name] = struct{}{} |
| 87 | |
| 88 | baseline, hadBaseline := defaultTools[tool.Tool.Name] |
| 89 | if hadBaseline && reflect.DeepEqual(tool.Tool.InputSchema, baseline.Tool.InputSchema) && reflect.DeepEqual(tool.Tool.Meta, baseline.Tool.Meta) { |
| 90 | continue |
| 91 | } |
| 92 | out = append(out, tool) |
| 93 | } |
| 94 | |
| 95 | sort.Slice(out, func(i, j int) bool { return out[i].Tool.Name < out[j].Tool.Name }) |
| 96 | return out |
| 97 | } |
| 98 | |
| 99 | // buildInventoryWithFlags constructs an inventory whose feature checker treats |
| 100 | // the given flags as enabled and every other flag as disabled. Passing nil |
no test coverage detected