Textual UI application for deepagents-cli.
URL for the full changelog.
URL for deepagents-cli documentation.
Valid DeferredAction.kind values for type-checked deduplication.
Format a token count into a human-readable short string.
Check whether the terminal is in ASCII charset mode.
Convenience wrapper so widgets can branch on charset without importing
both _detect_charset_mode and CharsetMode.
Persist theme preference to ~/.deepagents/config.toml.
Run the Textual application.
When server_kwargs is provided (and agent is None), the app starts
immediately with a "Connecting..." banner and launches the server in the
background. Server cleanup is handled automatically after the app exits.
Runtime context passed via context= to the LangGraph graph.
Carries per-invocation overrides that ConfigurableModelMiddleware
reads from request.runtime.context.
Stats accumulated over a single agent turn (or full session).
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 skill invocation with collapsible body.
Shows skill name, source badge, description, and user args as a compact
header. The full SKILL.md body (frontmatter stripped) is hidden behind a
preview/expand toggle (click or Ctrl+O). The expanded view renders
markdown via Rich's Markdown inside a single Static widget.
Visibility is driven by a CSS class (-expanded) toggled via a Textual
reactive var. Click handlers are scoped to the header and hint widgets
(_SkillToggle) so clicks on the rendered markdown body do not trigger
expansion toggles (preserving text selection, for instance).
Widget displaying a tool call with collapsible output.
Tool outputs are shown as a 3-line preview by default. Press Ctrl+O to expand/collapse the full output. Shows an animated "Running..." indicator while the tool is executing.
Widget displaying a user message.
Status bar showing mode, auto-approve, cwd, git branch, tokens, and model.
Welcome banner displayed at startup.
A question to ask the user.
Metadata for a connected MCP server and its tools.
Client that talks to a LangGraph server over HTTP+SSE.
Wraps langgraph.pregel.remote.RemoteGraph which handles SSE parsing,
stream-mode negotiation (messages-tuple), namespace extraction, and
interrupt detection. This class adds only message-object conversion for the
Textual adapter and thread-ID normalization.
Manages a langgraph dev server subprocess.
Focuses on subprocess lifecycle (start, stop, restart) and health checking.
Env-var management for restarts (e.g. configuration changes requiring a full
restart) is handled by _scoped_env_overrides, keeping this class focused
on process management.
Extended skill metadata for CLI display, adds source tracking.
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.
Represents a queued user message awaiting processing.
An action deferred until the current busy state resolves.
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.
Valid spinner display states, or None to hide.
Discriminated union for the ask_user widget Future result.
LangChain brand colors and semantic constants for the CLI.
Single source of truth for color values used in Python code (Rich markup,
Content.styled, Content.from_markup). CSS-side styling should reference
Textual CSS variables: built-in variables
($primary, $background, $text-muted, $error-muted, etc.) are set via
register_theme() in DeepAgentsApp.__init__, while the few app-specific
variables ($mode-bash, $mode-command, $skill, $skill-hover, $tool,
$tool-hover) are backed by these constants via App.get_theme_variable_defaults().
Code that needs custom CSS variable values should call
get_css_variable_defaults(dark=...). For the full semantic color palette, look
up the ThemeColors instance via ThemeEntry.REGISTRY.
Users can define custom themes in ~/.deepagents/config.toml under
[themes.<name>] sections. Each new theme section must include label (str);
dark (bool) defaults to False if omitted (set to True for dark themes).
Color fields are optional and fall back to the built-in dark/light palette based
on the dark flag. Sections whose name matches a built-in theme override its
colors without replacing it. See _load_user_themes() for details.