repo stringclasses 454
values | file_path stringlengths 5 201 | extension stringclasses 1
value | content stringlengths 8 509k | num_lines int64 3 16.9k | size_bytes int64 8 511k |
|---|---|---|---|---|---|
deepagents | examples/llm-wiki/models.py | .py | """Shared data models for LLM wiki workflows."""
from __future__ import annotations
import subprocess
import tempfile
from dataclasses import dataclass
from pathlib import Path
from typing import Literal
from collections.abc import Callable, Sequence
Mode = Literal["init", "ingest", "query", "lint"]
@dataclass(f... | 51 | 1,163 |
deepagents | examples/llm-wiki/runner.py | .py | """CLI entrypoint for the LLM wiki example."""
from __future__ import annotations
from collections.abc import Sequence
from helpers import WikiError, parse_config, run
def main(argv: Sequence[str] | None = None) -> int:
"""Run the LLM wiki CLI."""
try:
config = parse_config(argv)
run_result... | 28 | 664 |
deepagents | examples/llm-wiki/ingest.py | .py | """Ingest-specific workflow for the LLM wiki."""
from __future__ import annotations
from dataclasses import dataclass
from pathlib import Path
from collections.abc import Callable, Sequence
from models import CliDeps, RunnerConfig
import helpers
@dataclass(frozen=True)
class IngestResult:
"""Result from one ing... | 247 | 9,926 |
deepagents | examples/llm-wiki/lint.py | .py | """Lint-specific workflow for the LLM wiki."""
from __future__ import annotations
from pathlib import Path
from models import CliDeps, RunnerConfig
import helpers
def build_lint_prompt(topic: str, note: str | None) -> str:
"""Build the single-pass lint prompt for wiki health checks."""
note_text = note or ... | 63 | 3,085 |
deepagents | examples/llm-wiki/log.py | .py | """Log-specific helpers for append-only wiki interaction timelines."""
from __future__ import annotations
import re
from datetime import UTC, datetime
from pathlib import Path
from collections.abc import Callable
_LOG_HEADER_MAX_LEN = 220
_LOG_SUMMARY_MAX_LEN = 320
def _normalize_log_text(text: str) -> str:
"... | 99 | 2,883 |
deepagents | examples/llm-wiki/init.py | .py | """Init-specific workflow for the LLM wiki."""
from __future__ import annotations
import json
from urllib.parse import quote
from models import CliDeps, RunResult, RunnerConfig
import helpers
def resolve_internal_source_flag(deps: CliDeps) -> tuple[str, ...]:
"""Resolve an init flag set that enforces internal ... | 235 | 8,070 |
deepagents | examples/llm-wiki/query.py | .py | """Query-specific workflow for the LLM wiki."""
from __future__ import annotations
import re
from dataclasses import dataclass
from pathlib import Path
from models import CliDeps, RunnerConfig
import helpers
@dataclass(frozen=True)
class QueryResult:
"""Result from one query workspace pass."""
answer: str
... | 175 | 6,212 |
deepagents | examples/llm-wiki/helpers.py | .py | """Helper utilities for the LLM wiki example."""
from __future__ import annotations
import argparse
import errno
import json
import os
import shutil
import subprocess
import tempfile
from contextlib import contextmanager, suppress
from pathlib import Path
from typing import TYPE_CHECKING
from urllib.parse import urlp... | 830 | 28,159 |
deepagents | examples/llm-wiki/tests/unit_tests/test_helpers.py | .py | """Unit tests for LLM wiki setup and ingest helpers."""
from __future__ import annotations
import json
import re
import subprocess
import sys
import tempfile
from collections.abc import Callable
from pathlib import Path
import pytest
sys.path.insert(0, str(Path(__file__).resolve().parents[2]))
import lint as lint_h... | 1,497 | 50,625 |
deepagents | examples/deep_research/utils.py | .py | """Utility functions for displaying messages and prompts in Jupyter notebooks."""
import json
from rich.console import Console
from rich.panel import Panel
from rich.text import Text
console = Console()
def format_message_content(message):
"""Convert message content to displayable string."""
parts = []
... | 95 | 3,351 |
deepagents | examples/deep_research/agent.py | .py | """Research Agent - Standalone script for LangGraph deployment.
This module creates a deep research agent with custom tools and prompts
for conducting web research with strategic thinking and context management.
"""
from datetime import datetime
from langchain.chat_models import init_chat_model
from langchain_google... | 60 | 1,799 |
deepagents | examples/deep_research/research_agent/__init__.py | .py | """Deep Research Agent Example.
This module demonstrates building a research agent using the deepagents package
with custom tools for web search and strategic thinking.
"""
from research_agent.prompts import (
RESEARCHER_INSTRUCTIONS,
RESEARCH_WORKFLOW_INSTRUCTIONS,
SUBAGENT_DELEGATION_INSTRUCTIONS,
)
fro... | 21 | 539 |
deepagents | examples/deep_research/research_agent/tools.py | .py | """Research Tools.
This module provides search and content processing utilities for the research agent,
using Tavily for URL discovery and fetching full webpage content.
"""
import httpx
from langchain_core.tools import InjectedToolArg, tool
from markdownify import markdownify
from tavily import TavilyClient
from typ... | 117 | 3,658 |
deepagents | examples/deep_research/research_agent/prompts.py | .py | """Prompt templates and tool descriptions for the research deepagent."""
RESEARCH_WORKFLOW_INSTRUCTIONS = """# Research Workflow
Follow this workflow for all research requests:
1. **Plan**: Create a todo list with write_todos to break down the research into focused tasks
2. **Save the request**: Use write_file() to ... | 173 | 7,801 |
deepagents | examples/text-to-sql-agent/agent.py | .py | import argparse
import os
import sys
from deepagents import create_deep_agent
from deepagents.backends import FilesystemBackend
from dotenv import load_dotenv
from langchain_anthropic import ChatAnthropic
from langchain_community.agent_toolkits import SQLDatabaseToolkit
from langchain_community.utilities import SQLDat... | 111 | 3,320 |
deepagents | examples/content-builder-agent/content_writer.py | .py | #!/usr/bin/env python3
import warnings
warnings.filterwarnings("ignore", message="Core Pydantic V1 functionality")
"""
Content Builder Agent
A content writer agent configured entirely through files on disk:
- AGENTS.md defines brand voice and style guide
- skills/ provides specialized workflows (blog posts, social me... | 284 | 9,916 |
deepagents | examples/deploy-content-writer/test_user_memory.py | .py | """Test user memory persistence across threads."""
import asyncio
import os
from langgraph_sdk import get_client
DEPLOY_URL = "https://deepagents-deploy-content-w-6909480a63d7575eb597d5a1b3c6e61e.us.langgraph.app"
USER_ID = "test-user-sydney"
async def run_thread(client, assistant_id, message, user_id=None, label=... | 105 | 3,872 |
deepagents | examples/ralph_mode/ralph_mode.py | .py | """Ralph Mode - Autonomous looping for Deep Agents.
Ralph is an autonomous looping pattern created by Geoff Huntley
(https://ghuntley.com/ralph/). Each loop starts with fresh context.
The filesystem and git serve as the agent's memory across iterations.
Each iteration delegates to `run_non_interactive` from `deepagen... | 248 | 8,840 |
deepagents | examples/nvidia_deep_agent/src/tools.py | .py | """Research Tools.
This module provides search and content processing utilities for the research agent,
using Tavily for URL discovery and fetching full webpage content.
"""
import httpx
from langchain_core.tools import InjectedToolArg, tool
from markdownify import markdownify
from tavily import TavilyClient
from typ... | 86 | 2,278 |
deepagents | examples/nvidia_deep_agent/src/prompts.py | .py | """Prompt templates for the NVIDIA Deep Agent Skills example.
Adapted from NVIDIA's AIQ Blueprint (orchestrator.j2, researcher.j2) and
the LangChain deep_research example prompts.
"""
ORCHESTRATOR_INSTRUCTIONS = """You are a Deep Agent that handles research, data analysis, and optimization tasks. You produce thorough... | 145 | 7,569 |
deepagents | examples/nvidia_deep_agent/src/agent.py | .py | """NVIDIA Deep Agent Skills.
General-purpose deep agent showcasing multi-model architecture:
- Frontier model as orchestrator and data processor
- NVIDIA Nemotron Super for research
- NVIDIA GPU skills (cuDF analytics, cuML ML, data visualization, document processing)
- Modal GPU sandbox for code execution with Compos... | 100 | 3,265 |
deepagents | examples/nvidia_deep_agent/src/backend.py | .py | """Backend configuration: Modal sandbox with skills/memory uploaded on creation."""
from pathlib import Path
import modal
from langchain_modal import ModalSandbox
# --- Sandbox ---
# Modal sandbox with NVIDIA RAPIDS image.
# Authenticate first: `modal setup`
#
# Sandbox type (gpu/cpu) is controlled at runtime via co... | 105 | 3,494 |
deepagents | examples/better-harness/better_harness_plugin.py | .py | """Pytest plugin entrypoint for better-harness."""
from better_harness import patch_from_env
patch_from_env()
| 6 | 112 |
deepagents | examples/better-harness/better_harness/__init__.py | .py | """Public exports for better-harness."""
from better_harness.core import (
CaseOutcome,
EvalCase,
Experiment,
Proposal,
RunReport,
SplitResult,
Surface,
Variant,
load_experiment,
main,
run_experiment,
validate_experiment,
)
from better_harness.patching import (
build... | 47 | 933 |
deepagents | examples/better-harness/better_harness/patching.py | .py | """Surface patching helpers."""
from __future__ import annotations
import contextlib
import importlib
import os
from collections.abc import Iterator
from pathlib import Path
from better_harness.core import Experiment, Variant
VARIANT_ENV = "BETTER_HARNESS_VARIANT_FILE"
def build_baseline_variant(experiment: Exper... | 111 | 3,372 |
deepagents | examples/better-harness/better_harness/runners.py | .py | """Pytest and Harbor eval runners."""
from __future__ import annotations
import json
import os
import shlex
import subprocess
import xml.etree.ElementTree as ET
from pathlib import Path
from typing import Any
from better_harness.core import (
CaseOutcome,
EvalCase,
Experiment,
RunLayout,
SplitRes... | 500 | 18,970 |
deepagents | examples/better-harness/better_harness/agent.py | .py | """Outer-loop Deep Agent and proposer workspace helpers."""
from __future__ import annotations
import importlib
import json
import os
import shutil
import subprocess
import sys
import time
from collections.abc import Iterator
from contextlib import contextmanager
from dataclasses import dataclass
from pathlib import ... | 647 | 23,467 |
deepagents | examples/better-harness/better_harness/core.py | .py | """Core data model, config loading, run loop, history, and CLI."""
from __future__ import annotations
import argparse
import json
import os
import re
import sys
import tomllib
import urllib.error
import urllib.request
from dataclasses import asdict, dataclass
from datetime import UTC, datetime
from pathlib import Pat... | 1,132 | 39,165 |
deepagents | examples/better-harness/tests/test_better_harness.py | .py | from __future__ import annotations
import importlib
import json
from pathlib import Path
from textwrap import dedent
import pytest
from better_harness import (
CaseOutcome,
EvalCase,
Experiment,
SplitResult,
Surface,
load_experiment,
main,
run_experiment,
)
from better_harness.agent i... | 759 | 26,596 |
deepagents | examples/async-subagent-server/server.py | .py | """Async Subagent Server — Agent Protocol over FastAPI.
A minimal self-hosted Agent Protocol server that exposes a Deep Agents
researcher as an async subagent. Any Deep Agents supervisor can connect
to this server using the AsyncSubAgent configuration.
Implements the endpoints the Deep Agents async subagent middlewar... | 333 | 12,799 |
deepagents | examples/async-subagent-server/supervisor.py | .py | """Supervisor — Async Subagent Example.
An interactive REPL that demonstrates the five async subagent operations
against the FastAPI server in server.py.
The supervisor delegates research tasks to the server-hosted researcher
via Agent Protocol (through the LangGraph SDK). Tasks run in the
background — the supervisor... | 128 | 4,851 |
deepagents | examples/async-subagent-server/test_server.py | .py | """Minimal end-to-end tests for the async subagent server.
Tests the Agent Protocol HTTP contract without calling a real LLM.
The agent's ainvoke is patched to return a canned response.
"""
from __future__ import annotations
import asyncio
import json
from unittest.mock import AsyncMock, patch
import pytest
from fa... | 183 | 5,840 |
deepagents | libs/acp/deepagents_acp/server.py | .py | """ACP server implementation for Deep Agents."""
from __future__ import annotations
import json
from dataclasses import dataclass
from typing import TYPE_CHECKING, Any, TypeAlias, TypeGuard
from uuid import uuid4
from acp import (
Agent as ACPAgent,
InitializeResponse,
LoadSessionResponse,
NewSession... | 1,306 | 56,527 |
deepagents | libs/acp/deepagents_acp/utils.py | .py | """Utility functions for converting ACP content blocks to LangChain formats."""
from __future__ import annotations
import re
import shlex
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from acp.schema import (
AudioContentBlock,
EmbeddedResourceContentBlock,
ImageContentBlock,
... | 384 | 14,082 |
deepagents | libs/acp/deepagents_acp/_version.py | .py | """Version information for `deepagents-acp`."""
# Keep the `x-release-please-version` annotation — release-please uses it to
# bump `__version__` in sync with `pyproject.toml` on every release PR.
__version__ = "0.0.10" # x-release-please-version
| 6 | 251 |
deepagents | libs/acp/deepagents_acp/__main__.py | .py | """Entry point for running the ACP server as a module."""
import asyncio
from deepagents_acp.server import _serve_test_agent
def main() -> None:
"""Run the test ACP agent server."""
asyncio.run(_serve_test_agent())
if __name__ == "__main__":
main()
| 15 | 267 |
deepagents | libs/acp/tests/test_dangerous_patterns.py | .py | """Test dangerous shell pattern detection for auto-approve bypass prevention."""
import pytest
from deepagents_acp.utils import contains_dangerous_patterns, extract_command_types
class TestContainsDangerousPatterns:
"""Test the contains_dangerous_patterns function."""
def test_safe_commands(self):
... | 90 | 3,695 |
deepagents | libs/acp/tests/test_model_switching.py | .py | """Tests for model switching functionality in ACP adapter."""
from typing import Any
import pytest
from acp.schema import (
NewSessionResponse,
SessionConfigOptionSelect,
SetSessionConfigOptionResponse,
)
from deepagents import create_deep_agent
from deepagents.backends import FilesystemBackend
from langc... | 270 | 8,777 |
deepagents | libs/acp/tests/chat_model.py | .py | """Fake chat models for testing purposes."""
import re
from collections.abc import Callable, Iterator, Sequence
from typing import Any, cast
from langchain_core.callbacks import CallbackManagerForLLMRun
from langchain_core.language_models import LanguageModelInput
from langchain_core.language_models.chat_models impor... | 217 | 9,200 |
deepagents | libs/acp/tests/test_agent.py | .py | from __future__ import annotations
import asyncio
from dataclasses import dataclass
from typing import Any, Literal
import pytest
from acp import text_block, update_agent_message
from acp.exceptions import RequestError
from acp.interfaces import Client
from acp.schema import (
AgentMessageChunk,
AllowedOutcom... | 1,388 | 48,486 |
deepagents | libs/acp/tests/test_command_allowlist.py | .py | """Test command type allowlist functionality for execute tool."""
from deepagents import create_deep_agent
from langchain_core.messages import AIMessage
from langgraph.checkpoint.memory import MemorySaver
from deepagents_acp.server import AgentServerACP
from deepagents_acp.utils import extract_command_types
from test... | 319 | 15,474 |
deepagents | libs/acp/tests/test_main.py | .py | from __future__ import annotations
def test_import_main_module() -> None:
from deepagents_acp import __main__ # noqa: F401
| 6 | 130 |
deepagents | libs/acp/tests/test_utils.py | .py | from __future__ import annotations
from acp.schema import (
EmbeddedResourceContentBlock,
ImageContentBlock,
ResourceContentBlock,
TextContentBlock,
TextResourceContents,
)
from deepagents_acp.utils import (
convert_embedded_resource_block_to_content_blocks,
convert_image_block_to_content_... | 61 | 2,092 |
deepagents | libs/acp/examples/demo_agent.py | .py | """Demo coding agent using ACP."""
import asyncio
import os
from acp import (
run_agent as run_acp_agent,
)
from acp.schema import (
SessionMode,
SessionModeState,
)
from deepagents import create_deep_agent
from deepagents.backends import CompositeBackend, LocalShellBackend, StateBackend
from dotenv impor... | 130 | 4,492 |
deepagents | libs/acp/examples/local_context.py | .py | """Middleware for injecting local context into system prompt.
Detects git state, project structure, package managers, runtimes, and
directory layout by running a bash script via the backend. Because the
script executes inside the backend (local shell or remote sandbox), the
same detection logic works regardless of whe... | 540 | 17,920 |
deepagents | libs/code/hatch_build.py | .py | """Hatchling build hook that stamps the release commit into the package.
When `DEEPAGENTS_CODE_BUILD_COMMIT` is set (CI release builds), this writes
`deepagents_code/_build_info.py` so `dcode doctor` can report the exact commit
a wheel was built from. Editable and local builds leave the env var unset, so
no file is ge... | 68 | 2,685 |
deepagents | libs/code/deepagents_code/_constants.py | .py | """Lightweight shared constants for the app.
This module is intentionally dependency-free (no third-party imports, no
sibling-module imports) so any other module — including the startup-critical
`main.py` and the heavy `agent.py` — can import from it without triggering a
chain of expensive imports.
"""
from __future_... | 80 | 3,614 |
deepagents | libs/code/deepagents_code/reasoning_effort.py | .py | """Reasoning effort support for `/effort`.
Supported levels and defaults come from LangChain model profiles. Provider
integrations translate the standard `reasoning_effort` constructor parameter
into their native request shapes.
"""
from __future__ import annotations
import logging
from collections.abc import Mappin... | 333 | 11,747 |
deepagents | libs/code/deepagents_code/extras_info.py | .py | """Inspect optional-dependency install status for the running distribution.
Reads `Requires-Dist` metadata to report which packages declared under
`[project.optional-dependencies]` are installed, and renders that status
in either plain text (for stdout) or markdown (for rich UI contexts).
"""
from __future__ import a... | 1,580 | 59,787 |
deepagents | libs/code/deepagents_code/ask_user.py | .py | """Ask user middleware for interactive question-answering during agent execution."""
from __future__ import annotations
import logging
from collections.abc import Mapping
from typing import TYPE_CHECKING, Annotated, Any, cast
if TYPE_CHECKING:
from collections.abc import Awaitable, Callable
from langchain.agen... | 468 | 19,276 |
deepagents | libs/code/deepagents_code/auto_mode.py | .py | """Classifier-backed approval policy for the local interactive TUI."""
from __future__ import annotations
import asyncio
import contextlib
import inspect
import json
import logging
import math
import os
import re
import shlex
import stat
import tempfile
import time
from collections import OrderedDict
from collections... | 3,418 | 132,944 |
deepagents | libs/code/deepagents_code/_env_vars.py | .py | """Canonical registry of `DEEPAGENTS_CODE_*` environment variables.
Every env var the app reads whose name starts with `DEEPAGENTS_CODE_` must
be defined here as a module-level constant. A drift-detection test
(`tests/unit_tests/test_env_vars.py`) fails when a bare string literal
like `"DEEPAGENTS_CODE_FOO"` appears ... | 560 | 25,446 |
deepagents | libs/code/deepagents_code/notifications.py | .py | """Registry of pending actionable notifications.
Stores plain data for notices the user can act on from a dedicated
modal screen. The registry is deliberately UI-agnostic: UI routing
(toast click, keybinds) lives in the app layer.
"""
from __future__ import annotations
import logging
from dataclasses import dataclas... | 248 | 8,441 |
deepagents | libs/code/deepagents_code/offload.py | .py | """Storage paths for offloaded conversation history."""
from __future__ import annotations
import logging
import os
import stat
import tempfile
from dataclasses import dataclass
from pathlib import Path, PurePath
logger = logging.getLogger(__name__)
_FALLBACK_ARTIFACTS_ROOT = "/dcode-artifacts-fallback"
CONVERSATI... | 306 | 12,363 |
deepagents | libs/code/deepagents_code/terminal_escape.py | .py | """Best-effort writer for terminal escape/control sequences.
Centralizes the "fire and forget" pattern the app uses for cosmetic terminal
control (OSC 9;4 taskbar progress today; eventually OSC 52 clipboard and the
iTerm2 cursor guide). Writes prefer `/dev/tty` so output reaches the terminal
even when stdout/stderr ar... | 288 | 8,923 |
deepagents | libs/code/deepagents_code/project_utils.py | .py | """Utilities for project root detection and project-specific configuration."""
from __future__ import annotations
import os
from dataclasses import dataclass
from pathlib import Path
from typing import TYPE_CHECKING
from deepagents_code._env_vars import SERVER_ENV_PREFIX
from deepagents_code._git import find_git_roo... | 232 | 8,242 |
deepagents | libs/code/deepagents_code/_testing_models.py | .py | """Internal fake chat models for local integration tests.
The tool-binding base these build on (`_fake_models._ToolBindingFakeModel`) is
factored out into a use-neutral module so the `dcode tools list` enumeration
path can reuse it without importing this test-named module.
"""
from __future__ import annotations
from... | 347 | 13,532 |
deepagents | libs/code/deepagents_code/clipboard.py | .py | """Clipboard utilities."""
from __future__ import annotations
import base64
import logging
import os
import pathlib
from typing import TYPE_CHECKING, Literal
from textual.dom import NoScreen
from deepagents_code.config import get_glyphs
logger = logging.getLogger(__name__)
if TYPE_CHECKING:
from collections.a... | 226 | 7,476 |
deepagents | libs/code/deepagents_code/_dep_floor_check.py | .py | """Best-effort runtime dependency floor check for editable dev installs.
Editable installs resolve dependencies once at install time and nothing
re-checks them afterwards, so after `pyproject.toml` floors are bumped on
`main` a stale editable venv silently runs new source against old deps.
This module detects editable... | 588 | 21,843 |
deepagents | libs/code/deepagents_code/_textual_patches.py | .py | r"""Runtime patches over Textual internals, imported for side effect.
This module hosts five independent best-effort patches over private Textual
APIs. Each guards its own import/assignment and degrades to stock Textual
behavior (logging a warning) if the targeted internals move, so they have
separate lifecycles — do ... | 528 | 22,148 |
deepagents | libs/code/deepagents_code/main.py | .py | """Main entry point and loop."""
# ruff: noqa: E402
# Imports placed after warning filters to suppress deprecation warnings
# Suppress deprecation warnings from langchain_core (e.g., Pydantic V1 on Python 3.14+)
import warnings
warnings.filterwarnings("ignore", module="langchain_core._api.deprecation")
import argpa... | 5,308 | 212,438 |
deepagents | libs/code/deepagents_code/file_ops.py | .py | """Helpers for tracking file operations and computing diffs for display."""
from __future__ import annotations
import difflib
import logging
from dataclasses import dataclass, field
from pathlib import Path
from typing import TYPE_CHECKING, Any, Final, Literal
from deepagents_code._constants import FILE_NOT_FOUND
fr... | 1,063 | 47,392 |
deepagents | libs/code/deepagents_code/update_check.py | .py | """Update lifecycle for `deepagents-code`.
Handles version checking against PyPI (with caching), install-method detection,
auto-upgrade execution, config-driven opt-in/out, notification throttling, and
"what's new" tracking.
Most public entry points absorb errors and return sentinel values.
`set_auto_update` raises o... | 3,787 | 152,245 |
deepagents | libs/code/deepagents_code/subagents.py | .py | """Subagent loader for app.
Loads custom subagent definitions from the filesystem. Subagents are defined
as markdown files with YAML frontmatter in the agents/ directory.
Directory structure:
.deepagents/agents/{agent_name}/AGENTS.md
Example file (researcher/AGENTS.md):
---
name: researcher # optional; ... | 279 | 9,986 |
deepagents | libs/code/deepagents_code/editor.py | .py | """External editor support for composing prompts."""
from __future__ import annotations
import contextlib
import logging
import os
import shlex
import subprocess # noqa: S404
import sys
import tempfile
from pathlib import Path
logger = logging.getLogger(__name__)
GUI_WAIT_FLAG: dict[str, str] = {
"code": "--wa... | 206 | 6,296 |
deepagents | libs/code/deepagents_code/_markdown.py | .py | """Escaping for external text that reaches Rich/Textual markdown source."""
from __future__ import annotations
MARKDOWN_ESCAPES = str.maketrans({char: f"\\{char}" for char in "\\&`*_[]<>|~"})
"""Translation table backing `escape_markdown`.
Covers the inline constructs Rich's markdown parser acts on (emphasis, code
s... | 27 | 1,013 |
deepagents | libs/code/deepagents_code/auth_store.py | .py | """User-level credential storage for model providers.
Persists API keys (and, in the future, OAuth tokens) under
`~/.deepagents/.state/auth.json` (file mode 0600, parent 0700) so users can
enter credentials directly in the TUI rather than exporting environment
variables before launch.
Security notes:
- The stored va... | 546 | 21,141 |
deepagents | libs/code/deepagents_code/_tool_stream.py | .py | """Shared streaming tool-call buffering and hook-payload construction.
Both execution surfaces reassemble the same streamed tool-call state and fire
the same `tool.use` / `tool.result` / `tool.error` hook payloads:
- the interactive Textual TUI (`deepagents_code.tui.textual_adapter`), and
- the headless runner (`deep... | 702 | 30,946 |
deepagents | libs/code/deepagents_code/unicode_security.py | .py | """Unicode security helpers for deceptive text and URL checks.
This module is intentionally lightweight so it can be imported in display and
approval paths without affecting startup performance.
"""
from __future__ import annotations
import ipaddress
import unicodedata
from dataclasses import dataclass
from typing i... | 564 | 18,185 |
deepagents | libs/code/deepagents_code/_ask_user_types.py | .py | """Lightweight types and shared rendering for the ask-user interrupt protocol.
Extracted from `ask_user` so `textual_adapter` can import `AskUserRequest` at
module level — and `app` can reference the types at type-check time — without
pulling in the langchain middleware stack.
This is the shared wire format for the t... | 260 | 10,588 |
deepagents | libs/code/deepagents_code/mcp_config.py | .py | """Validation and environment-variable expansion for MCP server config.
Resolves `${VAR}` and `${VAR:-default}` references in the supported
configuration fields (`command`, `url`, `args`, `env`, `headers`) and
validates their types. A `${VAR:-default}` reference falls back to
`default` when `VAR` is unset *or* empty (... | 177 | 6,252 |
deepagents | libs/code/deepagents_code/output.py | .py | """Machine-readable JSON output helpers for CLI subcommands.
This module deliberately stays stdlib-only so it can be imported from CLI
startup paths without pulling in unnecessary dependency trees.
"""
from __future__ import annotations
import argparse
import json
import sys
from typing import Literal
OutputFormat ... | 70 | 2,044 |
deepagents | libs/code/deepagents_code/local_context.py | .py | """Middleware for injecting local context into system prompt.
Detects git state, project structure, package managers, runtimes, and
directory layout by running a bash script via the backend. Because the
script executes inside the backend (local shell or remote sandbox), the
same detection logic works regardless of whe... | 994 | 34,561 |
deepagents | libs/code/deepagents_code/model_config.py | .py | """Model configuration management.
Handles loading and saving model configuration from TOML files, providing a
structured way to define available models and providers.
"""
from __future__ import annotations
import contextlib
import hashlib
import importlib.util
import json
import logging
import os
import sys
import ... | 5,263 | 206,455 |
deepagents | libs/code/deepagents_code/managed_tools.py | .py | """Auto-install pinned upstream binaries for optional tools.
Today this only manages `ripgrep`. The SDK shells out to `rg` via `PATH`,
so installing into `~/.deepagents/bin/` and prepending that directory to
`os.environ["PATH"]` is sufficient — no SDK change required.
The pinned `RIPGREP_VERSION` and `RIPGREP_ASSETS`... | 643 | 23,288 |
deepagents | libs/code/deepagents_code/_version.py | .py | """Version information and lightweight constants for `deepagents-code`."""
# Keep the `x-release-please-version` annotation — release-please uses it to
# bump `__version__` in sync with `pyproject.toml` on every release PR.
__version__ = "0.1.56" # x-release-please-version
DOCS_URL = "https://docs.langchain.com/oss/... | 27 | 976 |
deepagents | libs/code/deepagents_code/__main__.py | .py | """Allow running the CLI as: `python -m deepagents_code`."""
from deepagents_code.main import cli_main
if __name__ == "__main__":
cli_main()
| 7 | 147 |
deepagents | libs/code/deepagents_code/__init__.py | .py | """Deep Agents Code - Interactive AI coding assistant."""
from __future__ import annotations
import logging
from typing import TYPE_CHECKING
from deepagents_code._debug import configure_debug_logging
from deepagents_code._debug_buffer import install_log_buffer
from deepagents_code._version import __version__
if TYP... | 43 | 1,446 |
deepagents | libs/code/deepagents_code/_repository_bounds.py | .py | """Shared path-safety and size limits for read-only repository inspection.
Both the goal-criteria agent's `_RepositoryToolBudgetMiddleware` and the rubric
grader's read-only tools let an LLM sub-agent inspect working-directory files.
They must apply identical guarantees: reads stay confined to the repository
root, sym... | 463 | 18,919 |
deepagents | libs/code/deepagents_code/_server_config.py | .py | """Typed configuration for the app-to-server subprocess communication channel.
The app spawns a `langgraph dev` subprocess and passes configuration via
environment variables prefixed with `DEEPAGENTS_CODE_SERVER_`. This module
provides a single
`ServerConfig` dataclass that both sides share so that the set of variable... | 723 | 29,740 |
deepagents | libs/code/deepagents_code/goal_state_notice.py | .py | """Canonical internal messages for goal state and work continuation."""
from __future__ import annotations
import hashlib
import html
import json
import uuid
from collections.abc import Mapping, Sequence
from typing import TYPE_CHECKING, Final, Literal, TypedDict, cast
from deepagents_code._constants import SYSTEM_M... | 443 | 15,853 |
deepagents | libs/code/deepagents_code/input.py | .py | """Input handling utilities including image/video tracking and file mention parsing."""
import logging
import re
import shlex
from dataclasses import dataclass, replace
from difflib import SequenceMatcher
from pathlib import Path
from typing import Literal
from urllib.parse import unquote, urlparse
from rich.markup i... | 1,110 | 37,752 |
deepagents | libs/code/deepagents_code/onboarding.py | .py | """First-run onboarding state for the interactive TUI."""
from __future__ import annotations
import json
import logging
import os
from typing import TYPE_CHECKING
from deepagents_code._env_vars import ONBOARDING, classify_env_bool
from deepagents_code.model_config import DEFAULT_STATE_DIR
if TYPE_CHECKING:
from... | 291 | 9,381 |
deepagents | libs/code/deepagents_code/sessions.py | .py | """Thread management using LangGraph's built-in checkpoint persistence."""
from __future__ import annotations
import asyncio
import contextlib
import logging
import sqlite3
from contextlib import asynccontextmanager
from datetime import datetime
from pathlib import Path
from typing import TYPE_CHECKING, Any, NamedTup... | 1,811 | 66,941 |
deepagents | libs/code/deepagents_code/diff_utils.py | .py | r"""Shared unified-diff helpers.
Every diff passing through this module is `"\n"`-joined from lines that came
from `splitlines()` or `split("\n")`, so no element can contain a line boundary.
That is what makes `split_diff_lines` the exact inverse and `splitlines()` wrong
here — see its docstring for what breaks. Check... | 223 | 8,634 |
deepagents | libs/code/deepagents_code/ui.py | .py | """Help screens and argparse utilities for the app.
This module is imported at app startup to wire `-h` actions into the
argparse tree. It must stay lightweight — no SDK or langchain imports.
"""
import argparse
from rich.markup import escape
from deepagents_code import theme
from deepagents_code._version import D... | 966 | 36,852 |
deepagents | libs/code/deepagents_code/iterm_cursor_guide.py | .py | """iTerm2 cursor guide workaround for Textual alternate-screen rendering."""
from __future__ import annotations
import os
from pathlib import Path
# iTerm2's cursor guide (highlight cursor line) causes visual artifacts when
# Textual takes over the terminal in alternate screen mode. We disable it at
# module load an... | 177 | 5,991 |
deepagents | libs/code/deepagents_code/_session_stats.py | .py | """Lightweight session statistics, token formatting, and usage-table rendering.
Holds `SessionStats`/`ModelStats`, the `format_token_count` formatter, and
`print_usage_table` (which imports `rich.table` lazily). The module is
intentionally kept free of heavy top-level dependencies (no pydantic, no
config, no widget im... | 1,005 | 38,494 |
deepagents | libs/code/deepagents_code/mcp_oauth_ui.py | .py | """UI-agnostic interaction interface for MCP OAuth login.
The OAuth login flow needs to ask the user a few things during the
handshake — open or display the authorize URL, accept a pasted callback
URL when the provider has no loopback redirect, show RFC 8628 device-code
instructions, and report success or failure. The... | 200 | 6,535 |
deepagents | libs/code/deepagents_code/goal_tools.py | .py | """Goal tools exposed to the agent for persisted TUI goals."""
from __future__ import annotations
from typing import (
TYPE_CHECKING,
Annotated,
Any,
Literal,
NotRequired,
TypedDict,
TypeVar,
cast,
)
from langchain.agents.middleware.types import (
AgentMiddleware,
AgentState,
... | 539 | 19,477 |
deepagents | libs/code/deepagents_code/resume_state.py | .py | """Schema and middleware for per-checkpoint state restored when resuming.
`ResumeState` declares several checkpointed, schema-private channels. They fall
into two groups with *different* write paths:
Written from inside the graph on successful model turns:
- `_context_tokens` — total context tokens from the latest
... | 274 | 11,256 |
deepagents | libs/code/deepagents_code/command_registry.py | .py | """Unified slash-command registry.
Every slash command is declared once as a `SlashCommand` entry in `COMMANDS`.
Bypass-tier frozensets and autocomplete entries are derived automatically — no
other file should hard-code command metadata.
"""
from __future__ import annotations
from dataclasses import dataclass
from e... | 564 | 19,922 |
deepagents | libs/code/deepagents_code/config_manifest.py | .py | """Canonical manifest and resolver for every user-tunable scalar config option.
This module is the single source of truth for the configuration *surface*: the
set of options, their types, typed defaults, env-var names, and `config.toml`
locations. The typed defaults for config-file-only options (notably the
`[interpre... | 1,891 | 72,954 |
deepagents | libs/code/deepagents_code/tool_display.py | .py | """Formatting utilities for tool call display in the app.
This module handles rendering tool calls and tool messages for the TUI.
Imported at module level by `textual_adapter` (itself deferred from the startup
path). Heavy SDK dependencies (e.g., `backends`) are deferred to function bodies.
"""
import json
from coll... | 368 | 14,259 |
deepagents | libs/code/deepagents_code/_cli_context.py | .py | """Lightweight runtime context types for the CLI agent graph.
Carries per-run overrides (model swap/params, approval mode) passed via
`context=`. Extracted from `configurable_model` so hot-path modules (`app`,
`textual_adapter`) can import `CLIContext` without pulling in the langchain
middleware stack.
"""
from __fut... | 165 | 6,224 |
deepagents | libs/code/deepagents_code/_git.py | .py | """Lightweight git metadata helpers for state detection."""
from __future__ import annotations
import logging
import os
import re
from pathlib import Path
from typing import NamedTuple
from urllib.parse import urlparse
logger = logging.getLogger(__name__)
_GIT_DIR_POINTER_PREFIX = "gitdir: "
"""Prefix used by workt... | 699 | 22,030 |
deepagents | libs/code/deepagents_code/mcp_tools.py | .py | """MCP (Model Context Protocol) tools loader.
This module provides async functions to load and manage MCP servers using
`langchain-mcp-adapters`, supporting Claude Desktop style JSON configs.
It also supports automatic discovery of `.mcp.json` files from user-level
and project-level locations.
"""
from __future__ imp... | 2,799 | 110,390 |
deepagents | libs/code/deepagents_code/configurable_model.py | .py | """Middleware for runtime model selection via LangGraph runtime context.
Allows switching the model per invocation by passing a `CLIContext` via
`context=` on `agent.astream()` / `agent.invoke()` without recompiling
the graph.
"""
from __future__ import annotations
import asyncio
import logging
from collections.abc ... | 672 | 26,915 |
deepagents | libs/code/deepagents_code/_glm_5p2_profile.py | .py | """GLM-5.2 harness profile for Deep Agents Code.
Bundles a concise execution-focused prompt suffix with one-shot recovery for the
measured Fireworks headless terminal-stall failure mode.
"""
from __future__ import annotations
import logging
from collections.abc import Mapping
from typing import TYPE_CHECKING
# Priv... | 310 | 13,773 |
deepagents | libs/code/deepagents_code/state_migration.py | .py | """One-time migration of legacy state files into `~/.deepagents/.state/`.
Earlier versions wrote internal state directly under `~/.deepagents/`,
mixing it with user-facing agent directories (so e.g. `mcp-tokens/`
showed up in `deepagents agents list`). State now lives in a dedicated
`.state/` subdirectory; this module... | 137 | 4,270 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.