(a, b string)
| 979 | Name: "tool_search", |
| 980 | Description: "Search for and load tools that are not in the default tool list. Use this when you need a specific tool that isn't available.\n\nQuery syntax:\n \"select:Name1,Name2\" — directly load specific tools by exact name\n \"+prefix keyword\" — filter tools whose name starts with prefix, ranked by keyword relevance\n \"keyword1 keyword2\" — search all deferred tools by name and description\n\nAfter loading with select:, the tool becomes available for immediate use.", |
| 981 | InputPrototype: ToolSearchInput{}, |
| 982 | Aliases: []string{"search_tools"}, |
| 983 | ReadOnly: BoolPtr(true), |
| 984 | ConcurrencySafe: BoolPtr(true), |
| 985 | Destructive: BoolPtr(false), |
| 986 | }}} |
| 987 | } |
| 988 | |
| 989 | func (t *ToolSearchTool) Execute(_ context.Context, execCtx ExecutionContext, input any) (string, error) { |
| 990 | in := deref[ToolSearchInput](input) |
| 991 | registry, _ := execCtx["_registry"].(*ToolRegistry) |
| 992 | if registry == nil { |
| 993 | return "<tool_use_error>\nTool registry not available in context.\n</tool_use_error>", nil |
| 994 | } |
| 995 | query := strings.TrimSpace(in.Query) |
| 996 | if strings.HasPrefix(query, "select:") { |
| 997 | return handleToolSearchSelect(query, registry), nil |
| 998 | } |
| 999 | return handleToolSearchQuery(query, registry), nil |
| 1000 | } |
| 1001 | |
| 1002 | func handleToolSearchSelect(query string, registry *ToolRegistry) string { |
| 1003 | rawNames := strings.Split(query[7:], ",") |
| 1004 | var names []string |
| 1005 | for _, name := range rawNames { |
| 1006 | if trimmed := strings.TrimSpace(name); trimmed != "" { |
| 1007 | names = append(names, trimmed) |
| 1008 | } |
| 1009 | } |
| 1010 | if len(names) == 0 { |
| 1011 | return "No tool names specified. Use 'select:Name1,Name2' to load specific tools." |
| 1012 | } |
| 1013 | var lines, activated, notFound, alreadyActive []string |
no outgoing calls
no test coverage detected