TextualAgent
See also
- This agent subclass builds on top of the default agent, make sure to read that first.
- This class powers the
minicommand 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
39 40 41 42 43 | |
app
instance-attribute
app = app
add_message
add_message(role: str, content: str)
Source code in src/minisweagent/agents/interactive_textual.py
45 46 47 48 | |
query
query() -> dict
Source code in src/minisweagent/agents/interactive_textual.py
50 51 52 53 54 55 56 57 58 | |
run
run(task: str) -> tuple[str, str]
Source code in src/minisweagent/agents/interactive_textual.py
60 61 62 63 64 65 66 67 68 69 70 71 | |
execute_action
execute_action(action: dict) -> dict
Source code in src/minisweagent/agents/interactive_textual.py
73 74 75 76 77 78 79 80 81 82 83 84 | |
has_finished
has_finished(output: dict[str, str])
Source code in src/minisweagent/agents/interactive_textual.py
86 87 88 89 90 91 92 93 94 95 96 | |
minisweagent.agents.interactive_textual.AgentApp
AgentApp(model, env, task: str, **kwargs)
Bases: App
Source code in src/minisweagent/agents/interactive_textual.py
254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 | |
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"),
Binding("u", "human", "Switch to Human Mode"),
]
agent_state
instance-attribute
agent_state = 'UNINITIALIZED'
agent_task
instance-attribute
agent_task = task
n_steps
instance-attribute
n_steps = 1
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
287 288 289 290 291 292 293 294 | |
on_mount
on_mount() -> None
Source code in src/minisweagent/agents/interactive_textual.py
296 297 298 299 300 | |
on_message_added
on_message_added() -> None
Source code in src/minisweagent/agents/interactive_textual.py
304 305 306 307 308 309 | |
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
311 312 313 314 | |
on_unmount
on_unmount() -> None
Clean up the log handler when the app shuts down.
Source code in src/minisweagent/agents/interactive_textual.py
316 317 318 319 | |
on_agent_finished
on_agent_finished(exit_status: str, result: str)
Source code in src/minisweagent/agents/interactive_textual.py
321 322 323 324 325 326 | |
update_content
update_content() -> None
Source code in src/minisweagent/agents/interactive_textual.py
330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 | |
action_yolo
action_yolo()
Source code in src/minisweagent/agents/interactive_textual.py
373 374 375 376 377 | |
action_human
action_human()
Source code in src/minisweagent/agents/interactive_textual.py
379 380 381 382 383 | |
action_confirm
action_confirm()
Source code in src/minisweagent/agents/interactive_textual.py
385 386 387 388 389 | |
action_next_step
action_next_step() -> None
Source code in src/minisweagent/agents/interactive_textual.py
391 392 | |
action_previous_step
action_previous_step() -> None
Source code in src/minisweagent/agents/interactive_textual.py
394 395 | |
action_first_step
action_first_step() -> None
Source code in src/minisweagent/agents/interactive_textual.py
397 398 | |
action_last_step
action_last_step() -> None
Source code in src/minisweagent/agents/interactive_textual.py
400 401 | |
action_scroll_down
action_scroll_down() -> None
Source code in src/minisweagent/agents/interactive_textual.py
403 404 | |
action_scroll_up
action_scroll_up() -> None
Source code in src/minisweagent/agents/interactive_textual.py
406 407 | |
minisweagent.agents.interactive_textual.SmartInputContainer
SmartInputContainer(app: AgentApp)
Bases: Container
Smart input container supporting single-line and multi-line input modes.
Source code in src/minisweagent/agents/interactive_textual.py
124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 | |
can_focus
instance-attribute
can_focus = True
display
instance-attribute
display = False
pending_prompt
instance-attribute
pending_prompt: str | None = None
compose
compose() -> ComposeResult
Source code in src/minisweagent/agents/interactive_textual.py
148 149 | |
on_mount
on_mount() -> None
Initialize the widget state.
Source code in src/minisweagent/agents/interactive_textual.py
151 152 153 154 | |
on_focus
on_focus() -> None
Called when the container gains focus.
Source code in src/minisweagent/agents/interactive_textual.py
156 157 158 159 160 161 | |
request_input
request_input(prompt: str) -> str
Request input from user. Returns input text (empty string if confirmed without reason).
Source code in src/minisweagent/agents/interactive_textual.py
163 164 165 166 167 168 169 170 171 172 | |
action_toggle_mode
action_toggle_mode() -> None
Switch from single-line to multi-line mode (one-way only).
Source code in src/minisweagent/agents/interactive_textual.py
190 191 192 193 194 195 196 197 | |
on_input_submitted
on_input_submitted(event: Submitted) -> None
Handle single-line input submission.
Source code in src/minisweagent/agents/interactive_textual.py
215 216 217 218 219 | |
on_key
on_key(event: Key) -> None
Handle key events.
Source code in src/minisweagent/agents/interactive_textual.py
221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 | |
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
100 101 102 103 | |
callback
instance-attribute
callback = callback
emit
emit(record: LogRecord)
Source code in src/minisweagent/agents/interactive_textual.py
105 106 | |