MCPcopy Create free account
hub / github.com/RightNow-AI/rightnow-cli / handle_command

Function handle_command

rightnow_cli/cli_minimal.py:240–409  ·  view source on GitHub ↗

Handle slash commands (simplified to essential commands only). Returns: True to continue, False to exit

(orchestrator: AgentOrchestrator, cmd: str)

Source from the content-addressed store, hash-verified

238
239
240def handle_command(orchestrator: AgentOrchestrator, cmd: str) -> bool:
241 """
242 Handle slash commands (simplified to essential commands only).
243
244 Returns:
245 True to continue, False to exit
246 """
247 parts = cmd[1:].split()
248 if not parts:
249 return True
250
251 command = parts[0].lower()
252
253 # Essential Commands Only
254
255 # Model selection
256 if command == "models":
257 if len(parts) < 2:
258 # Show models if no argument provided
259 try:
260 current_agent = orchestrator.get_current_agent()
261 show_models(current_agent.model, OpenRouterClientV2.MODEL_CATALOG)
262 except Exception as e:
263 # Handle any error in showing models
264 import re
265 error_msg = str(e)[:200]
266 # Remove all rich markup tags
267 error_msg = re.sub(r'\[.*?\]', '', error_msg)
268 show_error(f"Failed to display models: {error_msg}")
269 console.print("[dim]Try /setkey to update your API key[/dim]\n")
270 else:
271 choice = parts[1]
272 selected = select_model(choice, OpenRouterClientV2.MODEL_CATALOG, OpenRouterClientV2.DEFAULT_MODEL)
273
274 if selected:
275 # Check if model is free or premium
276 is_free_model = selected.endswith(":free")
277
278 # Check if we need an API key (all models require one)
279 current_api_key = orchestrator.cache_manager.get_api_key()
280
281 if not current_api_key or current_api_key == "sk-temp-placeholder":
282 # Need to get API key from user
283 console.print("\n[nvidia]API Key Required[/nvidia]")
284 console.print("All models (including free ones) require an OpenRouter API key.\n")
285 console.print("[dim]Get your FREE API key from: https://openrouter.ai[/dim]")
286 console.print("[dim](Sign up with Google/GitHub for instant access)[/dim]\n")
287
288 from rich.prompt import Prompt
289 try:
290 api_key = Prompt.ask("[nvidia]Paste your API key[/nvidia]", password=True)
291
292 if api_key and api_key.strip():
293 # Save the API key
294 orchestrator.cache_manager.save_api_key(api_key.strip())
295 orchestrator.api_key = api_key.strip()
296 orchestrator.needs_api_key = False
297

Callers 1

interactive_modeFunction · 0.85

Calls 14

show_modelsFunction · 0.85
show_errorFunction · 0.85
select_modelFunction · 0.85
show_successFunction · 0.85
show_warningFunction · 0.85
show_gpu_statusFunction · 0.85
run_setup_wizardFunction · 0.85
show_compiler_statusFunction · 0.85
show_minimal_bannerFunction · 0.85
get_current_agentMethod · 0.80
get_api_keyMethod · 0.80
askMethod · 0.80

Tested by

no test coverage detected