TextualAgent
See also
- This agent subclass builds on top of the default agent, make sure to read that first.
- This class powers the
mini
command line tool, see usage for more details.
minisweagent.agents.interactive_textual.TextualAgent
TextualAgent(app: AgentApp, *args, **kwargs)
Bases: DefaultAgent
Connects the DefaultAgent to the TextualApp.
Source code in src/minisweagent/agents/interactive_textual.py
36 37 38 39 |
|
app
instance-attribute
app = app
add_message
add_message(role: str, content: str)
Source code in src/minisweagent/agents/interactive_textual.py
41 42 43 44 |
|
run
run(task: str) -> tuple[str, str]
Source code in src/minisweagent/agents/interactive_textual.py
46 47 48 49 50 51 52 53 54 55 |
|
execute_action
execute_action(action: dict) -> dict
Source code in src/minisweagent/agents/interactive_textual.py
57 58 59 60 61 62 63 |
|
minisweagent.agents.interactive_textual.AgentApp
AgentApp(model, env, task: str, **kwargs)
Bases: App
Source code in src/minisweagent/agents/interactive_textual.py
176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 |
|
BINDINGS
class-attribute
instance-attribute
BINDINGS = [
Binding("right,l", "next_step", "Step++"),
Binding("left,h", "previous_step", "Step--"),
Binding("0", "first_step", "Step=0"),
Binding("$", "last_step", "Step=-1"),
Binding("j,down", "scroll_down", "Scroll down"),
Binding("k,up", "scroll_up", "Scroll up"),
Binding("q", "quit", "Quit"),
Binding("y", "yolo", "Switch to YOLO Mode"),
Binding("c", "confirm", "Switch to Confirm Mode"),
]
agent_state
instance-attribute
agent_state = 'UNINITIALIZED'
agent_task
instance-attribute
agent_task = task
n_steps
instance-attribute
n_steps = 1
confirmation_container
instance-attribute
confirmation_container = ConfirmationPromptContainer(self)
log_handler
instance-attribute
log_handler = AddLogEmitCallback(
lambda record: call_from_thread(
on_log_message_emitted, record
)
)
exit_status
instance-attribute
exit_status: str | None = None
result
instance-attribute
result: str | None = None
i_step
property
writable
i_step: int
Current step index.
compose
compose() -> ComposeResult
Source code in src/minisweagent/agents/interactive_textual.py
207 208 209 210 211 212 213 |
|
on_mount
on_mount() -> None
Source code in src/minisweagent/agents/interactive_textual.py
215 216 217 218 219 |
|
on_message_added
on_message_added() -> None
Source code in src/minisweagent/agents/interactive_textual.py
223 224 225 226 227 228 229 |
|
on_log_message_emitted
on_log_message_emitted(record: LogRecord) -> None
Handle log messages of warning level or higher by showing them as notifications.
Source code in src/minisweagent/agents/interactive_textual.py
231 232 233 234 |
|
on_unmount
on_unmount() -> None
Clean up the log handler when the app shuts down.
Source code in src/minisweagent/agents/interactive_textual.py
236 237 238 239 |
|
on_agent_finished
on_agent_finished(exit_status: str, result: str)
Source code in src/minisweagent/agents/interactive_textual.py
241 242 243 244 245 246 |
|
update_content
update_content() -> None
Source code in src/minisweagent/agents/interactive_textual.py
250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 |
|
action_yolo
action_yolo()
Source code in src/minisweagent/agents/interactive_textual.py
295 296 297 298 |
|
action_confirm
action_confirm()
Source code in src/minisweagent/agents/interactive_textual.py
300 301 302 |
|
action_next_step
action_next_step() -> None
Source code in src/minisweagent/agents/interactive_textual.py
304 305 |
|
action_previous_step
action_previous_step() -> None
Source code in src/minisweagent/agents/interactive_textual.py
307 308 |
|
action_first_step
action_first_step() -> None
Source code in src/minisweagent/agents/interactive_textual.py
310 311 |
|
action_last_step
action_last_step() -> None
Source code in src/minisweagent/agents/interactive_textual.py
313 314 |
|
action_scroll_down
action_scroll_down() -> None
Source code in src/minisweagent/agents/interactive_textual.py
316 317 318 |
|
action_scroll_up
action_scroll_up() -> None
Source code in src/minisweagent/agents/interactive_textual.py
320 321 322 |
|
minisweagent.agents.interactive_textual.ConfirmationPromptContainer
ConfirmationPromptContainer(app: AgentApp)
Bases: Container
This class is responsible for handling the action execution confirmation.
Source code in src/minisweagent/agents/interactive_textual.py
91 92 93 94 95 96 97 98 99 100 101 |
|
rejecting
instance-attribute
rejecting = False
can_focus
instance-attribute
can_focus = True
display
instance-attribute
display = False
compose
compose() -> ComposeResult
Source code in src/minisweagent/agents/interactive_textual.py
103 104 105 106 107 108 109 110 111 112 113 114 115 |
|
request_confirmation
request_confirmation(action: str) -> str | None
Request confirmation for an action. Returns rejection message or None.
Source code in src/minisweagent/agents/interactive_textual.py
117 118 119 120 121 122 123 124 |
|
on_key
on_key(event: Key) -> None
Source code in src/minisweagent/agents/interactive_textual.py
143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 |
|
minisweagent.agents.interactive_textual.AddLogEmitCallback
AddLogEmitCallback(callback)
Bases: Handler
Custom log handler that forwards messages via callback.
Source code in src/minisweagent/agents/interactive_textual.py
67 68 69 70 |
|
callback
instance-attribute
callback = callback
emit
emit(record: LogRecord)
Source code in src/minisweagent/agents/interactive_textual.py
72 73 |
|