diff --git a/.rogue/user_config.json b/.rogue/user_config.json index ade3c8b8..292fb459 100644 --- a/.rogue/user_config.json +++ b/.rogue/user_config.json @@ -1,4 +1,6 @@ { + "protocol": "mcp", + "transport": "streamable_http", "evaluated_agent_url": "http://localhost:10001/", "evaluated_agent_auth_type": "no_auth", "evaluated_agent_credentials": "", diff --git a/rogue/ui/app.py b/rogue/ui/app.py index f4014234..c7971d44 100644 --- a/rogue/ui/app.py +++ b/rogue/ui/app.py @@ -1,7 +1,7 @@ import json from pathlib import Path -from rogue_sdk.types import AuthType +from rogue_sdk.types import AuthType, Protocol, Transport from ..common.workdir_utils import load_config from .components.config_screen import create_config_screen @@ -35,6 +35,8 @@ def get_app(workdir: Path, rogue_server_url: str): with gr.TabItem("1. Config", id="config"): ( agent_url, + protocol, + transport, interview_mode, auth_type, auth_credentials, @@ -115,11 +117,27 @@ def load_and_update_ui(): "evaluated_agent_auth_type", AuthType.NO_AUTH.value, ) + # Safe enum parsing with sensible fallbacks + raw_protocol = config.get("protocol", Protocol.A2A.value) + raw_transport = config.get("transport", Transport.HTTP.value) + try: + protocol_val = Protocol(raw_protocol) + except (ValueError, KeyError): + protocol_val = Protocol.A2A + try: + transport_val = Transport(raw_transport) + except (ValueError, KeyError): + transport_val = Transport.HTTP + + if not transport_val.is_valid_for_protocol(protocol_val): + transport_val = protocol_val.get_default_transport() return { shared_state: state, agent_url: gr.update( value=config.get("evaluated_agent_url", "http://localhost:10001"), ), + protocol: gr.update(value=protocol_val.value), + transport: gr.update(value=transport_val.value), interview_mode: gr.update(value=config.get("interview_mode", True)), deep_test_mode: gr.update(value=config.get("deep_test_mode", False)), parallel_runs: gr.update(value=config.get("parallel_runs", 1)), @@ -144,6 +162,8 @@ def load_and_update_ui(): outputs=[ shared_state, agent_url, + protocol, + transport, interview_mode, auth_type, auth_credentials, diff --git a/rogue/ui/components/config_screen.py b/rogue/ui/components/config_screen.py index e7ff48ca..1d84df88 100644 --- a/rogue/ui/components/config_screen.py +++ b/rogue/ui/components/config_screen.py @@ -2,7 +2,7 @@ from loguru import logger from pydantic import ValidationError -from rogue_sdk.types import AgentConfig, AuthType +from rogue_sdk.types import PROTOCOL_TO_TRANSPORTS, AgentConfig, AuthType, Protocol from ...common.workdir_utils import dump_config @@ -33,6 +33,37 @@ def create_config_screen( ) agent_url_error = gr.Markdown(visible=False, elem_classes=["error-label"]) + gr.Markdown("**Protocol**") + protocol = gr.Dropdown( + label="Protocol", + choices=[p.value for p in Protocol], + value=config_data.get( + "protocol", + Protocol.A2A.value, + ), + ) + + # Get initial transport choices based on current protocol + initial_protocol = Protocol( + config_data.get("protocol", Protocol.A2A.value), + ) + initial_transport_choices = [ + t.value for t in PROTOCOL_TO_TRANSPORTS[initial_protocol] + ] + initial_transport_value = config_data.get( + "transport", + initial_protocol.get_default_transport().value, + ) + if initial_transport_value not in initial_transport_choices: + initial_transport_value = initial_protocol.get_default_transport().value + + gr.Markdown("**Transport**") + transport = gr.Dropdown( + label="Transport", + choices=initial_transport_choices, + value=initial_transport_value, + ) + gr.Markdown("**Interview Mode**") interview_mode = gr.Checkbox( label="Enable AI-powered business context interview", @@ -153,6 +184,8 @@ def update_state(state, key, value): for component, key in [ (agent_url, "agent_url"), + (protocol, "protocol"), + (transport, "transport"), (interview_mode, "interview_mode"), (auth_type, "auth_type"), (auth_credentials, "auth_credentials"), @@ -179,9 +212,24 @@ def toggle_auth_credentials(auth_t): outputs=[auth_credentials], ) + def update_transport_choices(protocol_val): + """Update transport choices based on selected protocol.""" + selected_protocol = Protocol(protocol_val) + transport_choices = [t.value for t in PROTOCOL_TO_TRANSPORTS[selected_protocol]] + default_transport = selected_protocol.get_default_transport().value + return gr.update(choices=transport_choices, value=default_transport) + + protocol.change( + fn=update_transport_choices, + inputs=[protocol], + outputs=[transport], + ) + def save_config( state, url, + protocol_val, + transport_val, interview_mode_val, deep_test_mode_val, parallel_runs_val, @@ -207,6 +255,8 @@ def save_config( judge_llm=llm, judge_llm_api_key=llm_key, deep_test_mode=deep_test_mode_val, + protocol=protocol_val, + transport=transport_val, interview_mode=interview_mode_val, parallel_runs=parallel_runs_val, business_context="", @@ -252,6 +302,8 @@ def save_config( inputs=[ shared_state, agent_url, + protocol, + transport, interview_mode, deep_test_mode, parallel_runs, @@ -272,6 +324,8 @@ def save_config( return ( agent_url, + protocol, + transport, interview_mode, auth_type, auth_credentials,