Textual UI application for deepagents-cli.
URL for deepagents-cli documentation.
Tool names recognized as shell/command-execution tools.
Only 'execute' is registered by the SDK and CLI backends in practice.
'bash' and 'shell' are legacy names carried over and kept as
backwards-compatible aliases.
Copy selected text from app widgets to clipboard.
This queries all widgets for their text_selection and copies any selected text to the system clipboard.
Build a full LangSmith thread URL if tracing is configured.
Combines get_langsmith_project_name and fetch_langsmith_project_url
into a single convenience helper.
Create a chat model.
Uses init_chat_model for standard providers, or imports a custom
BaseChatModel subclass when the provider has a class_path in config.
Supports provider:model format (e.g., 'anthropic:claude-sonnet-4-5')
for explicit provider selection, or bare model names for auto-detection.
Auto-detect provider from model name.
Intentionally duplicates a subset of LangChain's
_attempt_infer_model_provider because we need to resolve the provider
before calling init_chat_model in order to:
init_chat_model.Check if a shell command is in the allow-list.
The allow-list matches against the first token of the command (the executable name). This allows read-only commands like ls, cat, grep, etc. to be auto-approved.
When allow_list is the SHELL_ALLOW_ALL sentinel, all non-empty commands
are approved unconditionally — dangerous pattern checks are skipped.
SECURITY: For regular allow-lists, this function rejects commands containing dangerous shell patterns (command substitution, redirects, process substitution, etc.) BEFORE parsing, to prevent injection attacks that could bypass the allow-list.
Return the platform-native label for the newline keyboard shortcut.
macOS labels the modifier "Option" while other platforms use Ctrl+J as the most reliable cross-terminal shortcut.
Fire matching hook commands with payload serialized as JSON on stdin.
The event name is automatically injected into the payload under the
"event" key so callers don't need to duplicate it.
The blocking subprocess work is offloaded to a thread so the caller's event loop is never stalled. Matching hooks run concurrently, each with a 5-second timeout. Errors are logged and never propagated.
Update the recently used model in config file.
Writes to [models].recent instead of [models].default, so that /model
switches do not overwrite the user's intentional default.
Execute a task with output directed to Textual UI.
This is the Textual-compatible version of execute_task() that uses the TextualUIAdapter for all UI operations.
Format a token count into a human-readable short string.
Run the Textual application.
Character set mode for TUI display.
A model specification in provider:model format.
Stats accumulated over a single agent turn (or full session).
Adapter for rendering agent output to Textual widgets.
This adapter provides an abstraction layer between the agent execution and the Textual UI, allowing streaming output to be rendered as widgets.
Approval menu using standard Textual patterns.
Key design decisions (following mistral-vibe reference):
Interactive widget for asking the user questions.
Supports text input and multiple choice questions. Multiple choice questions always include an "Other" option for free-form input.
Chat input widget with prompt, multi-line text, autocomplete, and history.
Features:
config.newline_shortcut)Animated loading indicator with status text and elapsed time.
Displays:
In-memory message data for virtualization.
This dataclass holds all information needed to recreate a message widget. It is designed to be lightweight so that thousands of messages can be stored without meaningful memory overhead.
Manages message data and widget window for virtualization.
This class stores all messages as data and manages a sliding window of widgets that are actually mounted in the DOM.
Types of messages in the chat.
Status of a tool call.
Widget displaying an app message.
Widget displaying an assistant message with markdown support.
Uses MarkdownStream for smoother streaming instead of re-rendering the full content on each update.
Widget displaying an error message.
Widget displaying a queued (pending) user message in grey.
This is an ephemeral widget that gets removed when the message is dequeued.
Widget displaying a tool call with collapsible output.
Tool outputs are shown as a 3-line preview by default. Press Ctrl+E to expand/collapse the full output. Shows an animated "Running..." indicator while the tool is executing.
Widget displaying a user message.
Full-screen modal for model selection.
Displays available models grouped by provider with keyboard navigation and search filtering. Current model is highlighted.
Returns (model_spec, provider) tuple on selection, or None on cancel.
Status bar showing mode, auto-approve, cwd, git branch, tokens, and model.
Confirmation modal shown before deleting a thread.
Modal dialog for browsing and resuming threads.
Displays recent threads with keyboard navigation, fuzzy search, configurable columns, and delete support.
Returns a thread_id string on selection, or None on cancel.
Welcome banner displayed at startup.
A question to ask the user.
Metadata for a connected MCP server and its tools.
Represents a queued user message awaiting processing.
Token tracker that updates the status bar.
Session state for the Textual app.
Main Textual application for deepagents-cli.
Result from running the Textual application.