SearchSessionTools searches only within the session/model-callable projection.
(c *gin.Context)
| 197 | |
| 198 | // SearchSessionTools searches only within the session/model-callable projection. |
| 199 | func (h *BaseHandlers) SearchSessionTools(c *gin.Context) { |
| 200 | req, ok := h.bindToolSearch(c) |
| 201 | if !ok { |
| 202 | return |
| 203 | } |
| 204 | if h.Tools == nil { |
| 205 | h.respondError(c, http.StatusServiceUnavailable, errors.New("tool registry is not configured")) |
| 206 | return |
| 207 | } |
| 208 | routeScope, routeSessionID, _, ok := h.routeSessionInWorkspace(c) |
| 209 | if !ok { |
| 210 | return |
| 211 | } |
| 212 | scope := h.sessionToolScope(c, routeScope.ID, routeSessionID) |
| 213 | if reqWorkspaceID := strings.TrimSpace( |
| 214 | req.WorkspaceID, |
| 215 | ); reqWorkspaceID != "" && |
| 216 | reqWorkspaceID != scope.WorkspaceID { |
| 217 | h.respondError(c, http.StatusBadRequest, errors.New("workspace_id does not match path")) |
| 218 | return |
| 219 | } |
| 220 | if reqSessionID := strings.TrimSpace(req.SessionID); reqSessionID != "" && reqSessionID != scope.SessionID { |
| 221 | h.respondError(c, http.StatusBadRequest, errors.New("session_id does not match path")) |
| 222 | return |
| 223 | } |
| 224 | scope.AgentName = firstNonEmpty(req.AgentName, scope.AgentName) |
| 225 | views, err := h.Tools.Search(c.Request.Context(), scope, toolspkg.SearchQuery{ |
| 226 | Query: req.Query, |
| 227 | Limit: req.Limit, |
| 228 | }) |
| 229 | if err != nil { |
| 230 | h.respondToolError(c, err) |
| 231 | return |
| 232 | } |
| 233 | c.JSON(http.StatusOK, contract.ToolsResponse{Tools: ToolPayloadsFromViews(views)}) |
| 234 | } |
| 235 | |
| 236 | // ListToolsets returns named toolsets with expansion diagnostics. |
| 237 | func (h *BaseHandlers) ListToolsets(c *gin.Context) { |
nothing calls this directly
no test coverage detected