Vendored deer-flow upstream (bytedance/deer-flow) plus prompt-injection hardening: - New deerflow.security package: content_delimiter, html_cleaner, sanitizer (8 layers — invisible chars, control chars, symbols, NFC, PUA, tag chars, horizontal whitespace collapse with newline/tab preservation, length cap) - New deerflow.community.searx package: web_search, web_fetch, image_search backed by a private SearX instance, every external string sanitized and wrapped in <<<EXTERNAL_UNTRUSTED_CONTENT>>> delimiters - All native community web providers (ddg_search, tavily, exa, firecrawl, jina_ai, infoquest, image_search) replaced with hard-fail stubs that raise NativeWebToolDisabledError at import time, so a misconfigured tool.use path fails loud rather than silently falling back to unsanitized output - Native client back-doors (jina_client.py, infoquest_client.py) stubbed too - Native-tool tests quarantined under tests/_disabled_native/ (collect_ignore_glob via local conftest.py) - Sanitizer Layer 7 fix: only collapse horizontal whitespace, preserve newlines and tabs so list/table structure survives - Hardened runtime config.yaml references only the searx-backed tools - Factory overlay (backend/) kept in sync with deer-flow tree as a reference / source See HARDENING.md for the full audit trail and verification steps.
47 lines
1.7 KiB
Python
47 lines
1.7 KiB
Python
"""Configuration for LangGraph checkpointer."""
|
|
|
|
from typing import Literal
|
|
|
|
from pydantic import BaseModel, Field
|
|
|
|
CheckpointerType = Literal["memory", "sqlite", "postgres"]
|
|
|
|
|
|
class CheckpointerConfig(BaseModel):
|
|
"""Configuration for LangGraph state persistence checkpointer."""
|
|
|
|
type: CheckpointerType = Field(
|
|
description="Checkpointer backend type. "
|
|
"'memory' is in-process only (lost on restart). "
|
|
"'sqlite' persists to a local file (requires langgraph-checkpoint-sqlite). "
|
|
"'postgres' persists to PostgreSQL (requires langgraph-checkpoint-postgres)."
|
|
)
|
|
connection_string: str | None = Field(
|
|
default=None,
|
|
description="Connection string for sqlite (file path) or postgres (DSN). "
|
|
"Required for sqlite and postgres types. "
|
|
"For sqlite, use a file path like '.deer-flow/checkpoints.db' or ':memory:' for in-memory. "
|
|
"For postgres, use a DSN like 'postgresql://user:pass@localhost:5432/db'.",
|
|
)
|
|
|
|
|
|
# Global configuration instance — None means no checkpointer is configured.
|
|
_checkpointer_config: CheckpointerConfig | None = None
|
|
|
|
|
|
def get_checkpointer_config() -> CheckpointerConfig | None:
|
|
"""Get the current checkpointer configuration, or None if not configured."""
|
|
return _checkpointer_config
|
|
|
|
|
|
def set_checkpointer_config(config: CheckpointerConfig | None) -> None:
|
|
"""Set the checkpointer configuration."""
|
|
global _checkpointer_config
|
|
_checkpointer_config = config
|
|
|
|
|
|
def load_checkpointer_config_from_dict(config_dict: dict) -> None:
|
|
"""Load checkpointer configuration from a dictionary."""
|
|
global _checkpointer_config
|
|
_checkpointer_config = CheckpointerConfig(**config_dict)
|