Class: Rubino::Commands::Handlers::AgentSwitch
- Inherits:
-
Object
- Object
- Rubino::Commands::Handlers::AgentSwitch
- Defined in:
- lib/rubino/commands/handlers/agent_switch.rb
Overview
The PRIMARY-agent switcher (#320), distinct from Handlers::Agents (which drills into the background ‘task` subagents). Resolves the `/agent` picker and the dynamic `/<agent-name>` commands against the live Rubino.agent_registry, returning the dispatcher’s signal vocabulary:
{select_agent: name} pin a primary agent for the session (sticky)
{prompt:, agent:} route THIS turn to an agent (one-shot)
:handled listing / usage hint, no turn and no switch
The REPL applies select_agent: to the live runner + Rubino::ActiveAgent and threads agent: through run_turn — the same channel a custom command’s ‘agent:` frontmatter already used.
Instance Method Summary collapse
-
#handle_command(name, arguments) ⇒ Object
Resolves a dynamic ‘/<agent-name>` command.
-
#handle_picker(arguments) ⇒ Object
‘/agent` → list switchable primaries + invokable subagents `/agent <name>` → pin a primary (returns a select_agent: signal).
-
#initialize(ui:) ⇒ AgentSwitch
constructor
A new instance of AgentSwitch.
Constructor Details
#initialize(ui:) ⇒ AgentSwitch
Returns a new instance of AgentSwitch.
19 20 21 |
# File 'lib/rubino/commands/handlers/agent_switch.rb', line 19 def initialize(ui:) @ui = ui end |
Instance Method Details
#handle_command(name, arguments) ⇒ Object
Resolves a dynamic ‘/<agent-name>` command. Returns nil when name is not a visible agent (so the dispatcher falls through to custom commands), a select_agent: sticky switch for a bare primary, a agent: one-shot route when a message follows, or :handled with a usage hint for a bare subagent name.
47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/rubino/commands/handlers/agent_switch.rb', line 47 def handle_command(name, arguments) agent = registry.find(name) return nil unless agent && !agent.hidden? = arguments.to_s.strip return (name, agent) if .empty? # One-shot route: this turn runs under <agent>'s definition. @ui.status("Routing this turn to agent: /#{name}") { prompt: , agent: agent.name } end |
#handle_picker(arguments) ⇒ Object
‘/agent` → list switchable primaries + invokable subagents `/agent <name>` → pin a primary (returns a select_agent: signal)
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/rubino/commands/handlers/agent_switch.rb', line 25 def handle_picker(arguments) name = arguments.to_s.strip.split(/\s+/).first if name.nil? || name.empty? || name == "list" show_roster return :handled end agent = registry.find(name) unless agent&.primary? reject_non_primary(name, agent) return :handled end { select_agent: agent.name } end |