Configuration, constants, and model creation for the CLI.
URL for deepagents-cli documentation.
App color scheme.
Maps each non-normal mode to its trigger character.
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.
Get the glyph set for the current charset mode.
Reset the glyphs cache (for testing).
Get the appropriate banner for the current charset mode.
Parse shell allow-list from string.
Check if a command contains dangerous shell patterns.
These patterns can be used to bypass allow-list validation by embedding
arbitrary commands within seemingly safe commands. The check includes
both literal substring patterns (redirects, substitution operators, etc.)
and regex patterns for bare variable expansion ($VAR) and the background
operator (&).
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.
SECURITY: 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.
Resolve the LangSmith project name if tracing is configured.
Checks for the required API key and tracing environment variables.
When both are present, resolves the project name with priority:
settings.deepagents_langchain_project (from
DEEPAGENTS_LANGSMITH_PROJECT), then LANGSMITH_PROJECT from the
environment (note: this may already have been overridden at import
time to match DEEPAGENTS_LANGSMITH_PROJECT), then 'default'.
Fetch the LangSmith project URL via the LangSmith client.
Results are cached at module level so repeated calls do not make additional network requests. Failed lookups are also cached to avoid retries.
This is a blocking network call on the first invocation. In async
contexts, run it in a thread (e.g. via asyncio.to_thread).
Returns None (with a debug log) on any expected failure: missing
langsmith package, network errors, invalid project names, or client
initialization issues.
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.
Reset the LangSmith URL cache (for testing).
Get the default coding agent instructions.
These are the immutable base instructions that cannot be modified by the agent. Long-term memory (AGENTS.md) is handled separately by the middleware.
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.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.
Validate that the model has required capabilities for deepagents.
Checks the model's profile (if available) to ensure it supports tool calling, which is required for agent functionality. Issues warnings for models without profiles or with limited context windows.
Parsed model configuration from config.toml.
Instances are immutable once constructed. The providers mapping is
wrapped in MappingProxyType to prevent accidental mutation of the
globally cached singleton returned by load().
Raised when model configuration or creation fails.
A model specification in provider:model format.
Character set mode for TUI display.
Character glyphs for TUI display.
Global settings and environment detection for deepagents-cli.
This class is initialized once at startup and provides access to:
Mutable session state shared across the app, adapter, and agent.
Tracks runtime flags like auto-approve that can be toggled during a session via keybindings or the HITL approval menu's "Auto-approve all" option.
The auto_approve flag controls whether tool calls (shell execution, file
writes/edits, web search, URL fetch) require user confirmation before running.
Result of creating a chat model, bundling the model with its metadata.
This separates model creation from settings mutation so callers can decide when to commit the metadata to global settings.