Interactive Spring Shell-based command-line interface for the Embabel Agent platform, providing terminal interaction, chat sessions, and agent management commands.
The shell module provides Spring Boot configuration classes and properties for customizing shell behavior.
import com.embabel.agent.shell.config.ShellConfiguration
import com.embabel.agent.shell.config.ShellPropertiesSpring configuration class for shell-specific components.
@Configuration
@EnableConfigurationProperties(ShellProperties::class)
class ShellConfigurationProvides a fallback prompt provider if no custom provider is configured.
@Bean
@ConditionalOnMissingBean(PromptProvider::class)
fun defaultPromptProvider(): PromptProviderReturns: DefaultPromptProvider instance
Conditions: Only creates this bean if no other PromptProvider bean is found
Usage: This bean is automatically configured by Spring. If you want to use a custom prompt provider, define your own PromptProvider bean:
import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration
import org.springframework.shell.jline.PromptProvider
import org.jline.utils.AttributedString
import org.jline.utils.AttributedStyle
@Configuration
class MyConfiguration {
@Bean
fun customPromptProvider(): PromptProvider {
return PromptProvider {
AttributedString(
"my-app> ",
AttributedStyle.DEFAULT.foreground(AttributedStyle.CYAN)
)
}
}
}Configuration properties class with prefix "embabel.agent.shell".
@ConfigurationProperties(prefix = "embabel.agent.shell")
class ShellProperties {
var lineLength: Int = 140
var redirectLogToFile: Boolean = false
}Maximum line length for text wrapping in terminal output.
Type: Int
Default: 140
Property Key: embabel.agent.shell.lineLength
Usage:
embabel:
agent:
shell:
lineLength: 120Or in application.properties:
embabel.agent.shell.lineLength=120Whether to redirect log output to a file during chat sessions.
Type: Boolean
Default: false
Property Key: embabel.agent.shell.redirectLogToFile
Behavior:
Usage:
embabel:
agent:
shell:
redirectLogToFile: trueOr in application.properties:
embabel.agent.shell.redirectLogToFile=trueHere's a complete application.yaml configuration example:
embabel:
agent:
shell:
# Maximum line length for text wrapping
lineLength: 140
# Redirect logs to file during chat
redirectLogToFile: false
logging:
# Choose personality theme for prompt
# Options: starwars, severance, hitchhiker, colossus, montypython
personality: starwars
spring:
application:
name: my-agent-app
# Spring Shell configuration
shell:
interactive:
enabled: true
noninteractive:
enabled: falseYou can inject ShellProperties to access configuration values:
import com.embabel.agent.shell.config.ShellProperties
import org.springframework.stereotype.Component
@Component
class MyComponent(
private val shellProperties: ShellProperties
) {
fun processText(text: String) {
val maxLength = shellProperties.lineLength
val shouldRedirect = shellProperties.redirectLogToFile
// Use configuration values
}
}The ShellConfiguration class enables configuration properties processing through the @EnableConfigurationProperties(ShellProperties::class) annotation. This ensures that ShellProperties is registered as a Spring bean and properties are bound from application configuration sources.
The ShellConfiguration uses Spring's conditional bean registration:
@ConditionalOnMissingBean(PromptProvider::class): Only creates the default prompt provider if no other PromptProvider bean exists@ConditionalOnProperty to activate based on configurationThis configuration integrates with Spring Shell framework:
org.springframework.shell.jlinetessl i tessl/maven-com-embabel-agent--embabel-agent-shell@0.3.0