Interactive Spring Shell-based command-line interface for the Embabel Agent platform, providing terminal interaction, chat sessions, and agent management commands.
The ShellCommands class is the main entry point for the interactive shell interface, providing comprehensive commands for agent management, task execution, and system operations.
import com.embabel.agent.shell.ShellCommands@ShellComponent
class ShellCommands(
private val autonomy: Autonomy,
private val modelProvider: ModelProvider,
private val terminalServices: TerminalServices,
private val environment: ConfigurableEnvironment,
private val objectMapper: ObjectMapper,
private val colorPalette: ColorPalette,
loggingPersonality: LoggingPersonality,
private val toolsStats: ToolsStats,
private val context: ConfigurableApplicationContext,
private val shellProperties: ShellProperties = ShellProperties(),
@param:Autowired(required = false)
private val chatbot: Chatbot? = null
)The class is automatically instantiated by Spring when included in your application's component scan.
Optional Dependencies: The chatbot parameter is marked with @Autowired(required = false), meaning the chatbot dependency is optional. If no Chatbot bean is available in the Spring context, chatbot will be null and the shell will function without chat capabilities. When a Chatbot bean is provided, the chat command becomes available.
List all available agents in the platform with detailed information.
@ShellMethod("List agents")
fun agents(): StringReturns: Formatted string with agent details including name, description, goals, actions, and conditions.
Usage:
embabel> agentsList all available actions with detailed information.
@ShellMethod("List actions")
fun actions(): StringReturns: Formatted string with action details including name and description.
Usage:
embabel> actionsList all available goals with detailed information.
@ShellMethod("List goals")
fun goals(): StringReturns: Formatted string with goal details including name and description.
Usage:
embabel> goalsList all available conditions with detailed information.
@ShellMethod("List conditions")
fun conditions(): StringReturns: Formatted string with condition details including name and description.
Usage:
embabel> conditionsTry to choose a goal for a given intent, showing all goal rankings.
@ShellMethod("Try to choose a goal for a given intent. Show all goal rankings")
fun chooseGoal(
@ShellOption(help = "what the agent system should do") intent: String
): StringParameters:
intent: String describing what the agent system should doReturns: Goal rankings and chosen agent information, or error message if goal not found/approved
Usage:
embabel> chooseGoal "Find news about technology"Execute a task with a given natural language intent.
@ShellMethod(
"Execute a task. Put the task in double quotes. For example:\n\tx \"Lynda is a scorpio. Find news for her\" -p",
key = ["execute", "x"]
)
fun execute(
@ShellOption(help = "what the agent system should do") intent: String,
@ShellOption(
value = ["-o", "--open"],
help = "run in open mode, choosing a goal and using all actions that can help achieve it"
) open: Boolean = false,
@ShellOption(value = ["-p", "--showPrompts"], help = "show prompts to LLMs") showPrompts: Boolean,
@ShellOption(value = ["-r", "--showResponses"], help = "show LLM responses") showLlmResponses: Boolean = false,
@ShellOption(value = ["-d", "--debug"], help = "show debug info") debug: Boolean = false,
@ShellOption(value = ["-s", "--state"], help = "Use existing blackboard") state: Boolean = false,
@ShellOption(value = ["-td", "--toolDelay"], help = "Tool delay") toolDelay: Boolean = false,
@ShellOption(value = ["-od", "--operationDelay"], help = "Operation delay") operationDelay: Boolean = false,
@ShellOption(
value = ["-P", "--showPlanning"],
help = "show detailed planning info",
defaultValue = "true"
) showPlanning: Boolean = true
): StringParameters:
intent: Natural language description of what to doopen: Run in open mode (choose goal and use all helpful actions)showPrompts: Display prompts sent to LLMsshowLlmResponses: Display LLM responsesdebug: Show debug informationstate: Use existing blackboard statetoolDelay: Add delay between tool callsoperationDelay: Add delay between operationsshowPlanning: Show detailed planning information (default: true)Returns: Formatted execution result with agent process information, output, cost info, and tool statistics
Aliases: execute, x
Usage:
embabel> x "Find news about technology" -p
embabel> execute "Summarize this article" -d --showPromptsStart an interactive chat session with an agent.
@ShellMethod("Chat")
fun chat(): StringReturns: "Conversation finished" when chat session ends
Behavior:
redirectLogToFile is enabled, logs are redirected to file during chatUsage:
embabel> chatDisplay current execution options.
@ShellMethod("Show options")
fun showOptions(): StringReturns: JSON-formatted string of current process options (excluding blackboard content)
Usage:
embabel> showOptionsConfigure execution options for subsequent commands.
@ShellMethod("Set options")
fun setOptions(
@ShellOption(
value = ["-o", "--open"],
help = "run in open mode, choosing a goal and using all actions that can help achieve it"
) open: Boolean = false,
@ShellOption(value = ["-t", "--test"], help = "run in help mode") test: Boolean = false,
@ShellOption(value = ["-p", "--showPrompts"], help = "show prompts to LLMs") showPrompts: Boolean,
@ShellOption(value = ["-r", "--showResponses"], help = "show LLM responses") showLlmResponses: Boolean = false,
@ShellOption(value = ["-d", "--debug"], help = "show debug info") debug: Boolean = false,
@ShellOption(value = ["-s", "--state"], help = "Use existing blackboard") state: Boolean = false,
@ShellOption(value = ["-td", "--toolDelay"], help = "Tool delay") toolDelay: Boolean = false,
@ShellOption(value = ["-od", "--operationDelay"], help = "Operation delay") operationDelay: Boolean = false,
@ShellOption(
value = ["-s", "--showPlanning"],
help = "show detailed planning info",
defaultValue = "true"
) showPlanning: Boolean = true
): StringParameters: Same as execute command
Returns: Confirmation message with updated options
Usage:
embabel> setOptions -p -dShow AgentPlatform information.
@ShellMethod("Information about the AgentPlatform")
fun platform(): StringReturns: Platform name
Usage:
embabel> platformShow the last blackboard state from a previous operation.
@ShellMethod(
"Show last blackboard: The final state of a previous operation",
key = ["blackboard", "bb"]
)
fun blackboard(): StringReturns: Blackboard contents in verbose format, or message if no blackboard available
Aliases: blackboard, bb
Usage:
embabel> bb
embabel> blackboardClear the current blackboard state.
@ShellMethod(value = "Clear blackboard")
fun clear(): StringReturns: "Blackboard cleared"
Usage:
embabel> clearShow recent agent process runs with actual execution history.
@ShellMethod(value = "Show recent agent process runs. This is what actually happened, not just what was planned.")
fun runs(): StringReturns: List of recent runs with goal names, usage/cost information, and execution history
Usage:
embabel> runsList available tool groups.
@ShellMethod("List available tool groups")
fun tools(): StringReturns: Formatted list of available tool groups with metadata
Usage:
embabel> toolsDisplay tool usage statistics.
@ShellMethod("Show tool stats")
fun toolStats(): StringReturns: Tool usage statistics in verbose format
Usage:
embabel> toolStatsList available LLM models.
@ShellMethod("List available models")
fun models(): StringReturns: Formatted list of available models with details
Usage:
embabel> modelsList all active Spring profiles.
@ShellMethod(value = "List all active Spring profiles")
fun profiles(): StringReturns: Comma-separated list of active profile names
Usage:
embabel> profilesExit the shell application gracefully.
@ShellMethod(value = "Exit the application", key = ["exit", "quit", "bye"])
fun exit(): StringReturns: "Goodbye!" message
Aliases: exit, quit, bye
Behavior:
Usage:
embabel> exit
embabel> quit
embabel> byeThe shell commands handle several exception types:
import com.embabel.agent.core.NoGoalFound
import com.embabel.agent.core.GoalNotApproved
import com.embabel.agent.core.NoAgentFound
import com.embabel.agent.core.ProcessExecutionStuckException
import com.embabel.agent.core.ProcessExecutionTerminatedException
import com.embabel.agent.core.ProcessWaitingExceptionNoGoalFound: When no suitable goal can be found for the intentGoalNotApproved: When the chosen goal is not approvedNoAgentFound: When no suitable agent can be foundProcessExecutionStuckException: When the process cannot proceedProcessExecutionTerminatedException: When the process is terminatedProcessWaitingException: When the process is waiting for user input (forms, confirmations)These exceptions are caught and formatted into user-friendly error messages.
-s Short FlagThe setOptions method has a bug where both the state and showPlanning parameters use the same -s short flag:
state parameter: -s / --stateshowPlanning parameter: -s / --showPlanningThis prevents both flags from being used simultaneously via the short form. When using -s, only one of these options can be specified. To work around this issue, use the long form flags (--state and --showPlanning) if you need to specify both options.
This same issue also affects the execute command, which shares the same parameter definitions.
tessl i tessl/maven-com-embabel-agent--embabel-agent-shell@0.3.0