Skip to content
Navigation

Interactive REPL console for Orbiter CLI. Provides a read-eval-print loop for chatting with agents, with slash-command support, streaming output, and Rich formatting.

python
from orbiter_cli.console import InteractiveConsole, format_agents_table, parse_command

parse_command

python
def parse_command(text: str) -> tuple[str, str]

Parse a slash command from text.

NameTypeDefaultDescription
textstr(required)Raw input text

Returns: (command, argument) tuple. command is the slash-command name (lowercase, without /) and argument is the rest of the line. For non-command input, returns ("", text).

Example

python
from orbiter_cli import parse_command

cmd, arg = parse_command("/switch helper")
# cmd = "switch", arg = "helper"

cmd, arg = parse_command("Hello world")
# cmd = "", arg = "Hello world"

cmd, arg = parse_command("/help")
# cmd = "help", arg = ""

format_agents_table

python
def format_agents_table(agents: dict[str, Any]) -> Table

Build a Rich Table listing available agents with columns: Name, Model, and Description.

NameTypeDefaultDescription
agentsdict[str, Any](required)Mapping of agent name to agent instance

Returns: rich.table.Table — Formatted table ready for printing.

Example

python
from orbiter_cli import format_agents_table
from rich.console import Console

table = format_agents_table({"helper": agent, "coder": code_agent})
Console().print(table)

InteractiveConsole

python
class InteractiveConsole(
    *,
    agents: dict[str, Any],
    run_fn: RunFn,
    stream_fn: StreamFn | None = None,
    console: RichConsole | None = None,
    streaming: bool = False,
)

Interactive REPL for chatting with Orbiter agents. Supports slash commands for switching agents, listing agents, clearing the screen, and getting agent info.

Constructor parameters

NameTypeDefaultDescription
agentsdict[str, Any](required)Mapping of agent name to agent instance (at least one required)
run_fnRunFn(required)Async callable run(agent, input, **kw) -> result
stream_fnStreamFn | NoneNoneOptional async-iterator factory for streaming responses
consoleRichConsole | NoneNoneRich console (default: stderr for clean piping)
streamingboolFalseEnable streaming mode (requires stream_fn)

Raises: ValueError — If agents is empty.

Type aliases

python
RunFn = Callable[..., Coroutine[Any, Any, Any]]
StreamFn = Callable[..., AsyncIterator[StreamEvent]]

Properties

PropertyTypeDescription
current_agent_namestrName of the currently selected agent
current_agentAnyThe currently selected agent instance
agentsdict[str, Any]Copy of the agents registry

Methods

start

python
async def start(self) -> None

Run the interactive REPL until exit. Reads lines from stdin, dispatches slash commands, and sends other input to the current agent.

Slash commands

CommandDescription
/helpShow help message
/exit, /quitExit the console
/agentsList available agents
/switch <name>Switch to a different agent
/clearClear the screen
/infoShow current agent info

Example

python
from orbiter_cli import InteractiveConsole
from orbiter.runner import run

console = InteractiveConsole(
    agents={"helper": my_agent, "coder": code_agent},
    run_fn=run,
    streaming=False,
)
await console.start()