Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/robusta/core/model/base_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,14 @@ class HolmesConversationParams(HolmesParams):
include_tool_call_results: bool = True


class HolmesValidateToolsetParams(HolmesParams):
"""
:var yaml_config: Raw YAML string containing the toolset configuration, including the 'holmes:' wrapper.
"""

yaml_config: str


class NamespacedResourcesParams(ActionParams):
"""
:var name: Resource name
Expand Down
25 changes: 25 additions & 0 deletions src/robusta/core/playbooks/internal/ai_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
HolmesChatParams,
HolmesConversationParams,
HolmesIssueChatParams,
HolmesValidateToolsetParams,
ResourceInfo,
)
from robusta.core.model.events import ExecutionBaseEvent
Expand All @@ -33,6 +34,8 @@
HolmesRequest,
HolmesResult,
HolmesResultsBlock,
HolmesValidateToolsetRequest,
HolmesValidateToolsetResponse,
)
from robusta.core.reporting.utils import convert_svg_to_png
from robusta.core.stream.utils import (
Expand Down Expand Up @@ -385,6 +388,28 @@ def holmes_chat(event: ExecutionBaseEvent, params: HolmesChatParams):
handle_holmes_error(e)


@action
def holmes_validate_toolset(event: ExecutionBaseEvent, params: HolmesValidateToolsetParams):
holmes_url = HolmesDiscovery.find_holmes_url(params.holmes_url)
if not holmes_url:
raise ActionException(
ErrorCodes.HOLMES_DISCOVERY_FAILED,
"Robusta couldn't connect to the Holmes client.",
)

try:
holmes_req = HolmesValidateToolsetRequest(yaml_config=params.yaml_config)
url = f"{holmes_url}/api/toolsets/validate"
result = requests.post(url, data=holmes_req.json())
result.raise_for_status()
holmes_response = HolmesValidateToolsetResponse(**json.loads(result.text))
event.ws(data=json.dumps(holmes_response.dict()))

except Exception as e:
logging.exception("Failed to validate toolset via Holmes", exc_info=True)
handle_holmes_error(e)


def stream_and_render_graphs(url, holmes_req, event):
with requests.post(
url,
Expand Down
17 changes: 17 additions & 0 deletions src/robusta/core/reporting/holmes.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,3 +93,20 @@ class HolmesChatResult(BaseModel):

class HolmesChatResultsBlock(BaseBlock):
holmes_result: Optional[HolmesChatResult]


class HolmesValidateToolsetRequest(BaseModel):
yaml_config: str = Field(
description="Raw YAML string containing the toolset configuration, including the 'holmes:' wrapper."
)


class HolmesValidateToolsetResult(BaseModel):
toolset_name: str
status: str = Field(description="Toolset status: 'enabled' or 'failed'")
error: Optional[str] = None
description: Optional[str] = None


class HolmesValidateToolsetResponse(BaseModel):
results: List[HolmesValidateToolsetResult]
Loading