(context.Context)
| 144 | } |
| 145 | |
| 146 | func (t *ToolSet) Tools(context.Context) ([]tools.Tool, error) { |
| 147 | inputSchema, err := tools.SchemaToMap(map[string]any{ |
| 148 | "type": "object", |
| 149 | "properties": t.config.Args, |
| 150 | "required": t.config.Required, |
| 151 | }) |
| 152 | if err != nil { |
| 153 | return nil, fmt.Errorf("invalid schema: %w", err) |
| 154 | } |
| 155 | |
| 156 | parsedURL, err := url.Parse(t.config.Endpoint) |
| 157 | if err != nil { |
| 158 | return nil, fmt.Errorf("invalid URL: %w", err) |
| 159 | } |
| 160 | |
| 161 | if parsedURL.Scheme == "" || parsedURL.Host == "" { |
| 162 | return nil, errors.New("invalid URL: missing scheme or host") |
| 163 | } |
| 164 | |
| 165 | if parsedURL.Scheme != "http" && parsedURL.Scheme != "https" { |
| 166 | return nil, errors.New("only HTTP and HTTPS URLs are supported") |
| 167 | } |
| 168 | |
| 169 | outputSchema := tools.MustSchemaFor[string]() |
| 170 | if t.config.OutputSchema != nil { |
| 171 | var err error |
| 172 | outputSchema, err = tools.SchemaToMap(t.config.OutputSchema) |
| 173 | if err != nil { |
| 174 | return nil, fmt.Errorf("invalid output_schema: %w", err) |
| 175 | } |
| 176 | } |
| 177 | |
| 178 | return []tools.Tool{ |
| 179 | { |
| 180 | Name: t.config.Name, |
| 181 | Category: "api", |
| 182 | Description: t.config.Instruction, |
| 183 | Parameters: inputSchema, |
| 184 | OutputSchema: outputSchema, |
| 185 | Handler: t.callTool, |
| 186 | Annotations: tools.ToolAnnotations{ |
| 187 | ReadOnlyHint: true, |
| 188 | Title: cmp.Or(t.config.Name, "Query API"), |
| 189 | }, |
| 190 | }, |
| 191 | }, nil |
| 192 | } |
| 193 | |
| 194 | func setHeaders(req *http.Request, headers map[string]string) { |
| 195 | useragent.SetIdentity(req) |
nothing calls this directly
no test coverage detected