From 431f78cfe01a2e365c180c304952b78d1bd9de7f Mon Sep 17 00:00:00 2001 From: Noel Moreno Lemus Date: Wed, 18 Feb 2026 18:55:07 -0500 Subject: [PATCH 1/5] feat: security, config, and docs improvements - Security: path traversal guards in files and artifacts routes; session_id validation in JSON store and API (SessionIdPath); Content-Disposition filename sanitization; doc notes for WebSocket API key, executor isolation, health endpoint - Config: single source (deps use config.get_settings); require_api_key and max_upload_mb; API version from package; Dockerfile version 0.8.4 - Upload: enforce DSAGENT_MAX_UPLOAD_MB in files upload - Tests: fix delete_session_not_found mock; API key fixture use config cache - Docs: README CLI/Docker; CLI serve & skills; configuration DSAGENT_*; HTTP API base /api, files/artifacts, full endpoint list; Docker PORT and env; quickstart/index version-agnostic Co-authored-by: Cursor --- Dockerfile | 7 +- README.md | 34 +++- docs/CLI.md | 132 ++++++++++++++-- docs/DOCKER.md | 38 +++-- docs/PLAN_MEJORAS_E_ISSUES.md | 135 ++++++++++++++++ docs/api/http-api.md | 162 +++++++++++++------ docs/diagrams/session-creation-flow.md | 205 +++++++++++++++++++++++++ docs/getting-started/configuration.md | 90 ++++++----- docs/getting-started/quickstart.md | 2 +- docs/guide/docker.md | 38 +++-- docs/index.md | 3 +- src/dsagent/config.py | 21 ++- src/dsagent/core/executor.py | 12 +- src/dsagent/server/app.py | 20 ++- src/dsagent/server/deps.py | 52 ++----- src/dsagent/server/routes/artifacts.py | 48 ++++-- src/dsagent/server/routes/chat.py | 9 +- src/dsagent/server/routes/files.py | 78 ++++++++-- src/dsagent/server/routes/health.py | 12 +- src/dsagent/server/routes/hitl.py | 9 +- src/dsagent/server/routes/kernel.py | 9 +- src/dsagent/server/routes/sessions.py | 19 ++- src/dsagent/server/validators.py | 19 +++ src/dsagent/server/websocket.py | 11 +- src/dsagent/session/manager.py | 4 +- src/dsagent/session/store.py | 28 +++- tests/test_server.py | 7 +- uv.lock | 112 +++++++++----- 28 files changed, 1039 insertions(+), 277 deletions(-) create mode 100644 docs/PLAN_MEJORAS_E_ISSUES.md create mode 100644 docs/diagrams/session-creation-flow.md create mode 100644 src/dsagent/server/validators.py diff --git a/Dockerfile b/Dockerfile index 7a1f40c..da95045 100644 --- a/Dockerfile +++ b/Dockerfile @@ -12,7 +12,7 @@ ARG INSTALL_LATEX=false # Labels LABEL maintainer="DSAgent Contributors" -LABEL version="0.7.0" +LABEL version="0.8.4" LABEL description="AI-powered autonomous agent for data science" # Set environment variables @@ -21,8 +21,7 @@ ENV PYTHONUNBUFFERED=1 \ PIP_NO_CACHE_DIR=1 \ PIP_DISABLE_PIP_VERSION_CHECK=1 \ DSAGENT_WORKSPACE=/workspace \ - DSAGENT_SESSIONS_DIR=/workspace \ - LLM_MODEL=gpt-4o + DSAGENT_SESSIONS_DIR=/workspace # Install system dependencies (base) RUN apt-get update && apt-get install -y --no-install-recommends \ @@ -72,4 +71,4 @@ EXPOSE 8000 # Default command: start API server # Can be overridden to run CLI: docker run -it dsagent dsagent chat -CMD ["dsagent", "serve", "--host", "0.0.0.0", "--port", "8000"] +CMD ["sh", "-c", "dsagent serve --host 0.0.0.0 --port ${PORT:-8000}"] diff --git a/README.md b/README.md index a2ec8ce..d45a1c9 100644 --- a/README.md +++ b/README.md @@ -50,20 +50,32 @@ uv sync --all-extras ### Docker +Configuration uses the same environment variables as the CLI and server (see [Configuration](docs/getting-started/configuration.md)). The container listens on `PORT` (default 8000). + ```bash -# Run API server -docker run -d -p 8000:8000 \ +# Run API server (default: port 8000) +docker run -d -p 8080:8080 \ + -e PORT=8080 \ + -e DSAGENT_DEFAULT_MODEL=gpt-4o \ -e OPENAI_API_KEY=sk-your-key \ nmlemus/dsagent:latest # Run interactive CLI docker run -it \ -e OPENAI_API_KEY=sk-your-key \ + -v "$(pwd)/workspace:/workspace" \ nmlemus/dsagent:latest \ dsagent chat + +# One-shot task +docker run --rm \ + -e OPENAI_API_KEY=sk-your-key \ + -v "$(pwd)/workspace:/workspace" \ + nmlemus/dsagent:latest \ + dsagent run "Analyze data/sales.csv" --data ./data/sales.csv ``` -For Docker deployment details, see [docs/DOCKER.md](docs/DOCKER.md). +For Docker deployment details, see [docs/DOCKER.md](docs/DOCKER.md) and [docs/guide/docker.md](docs/guide/docker.md). ## Quick Start @@ -85,7 +97,7 @@ This will: - Local → `ollama/llama3` - Optionally configure MCP tools (web search, etc.) -To use a different model, edit `~/.dsagent/.env` or use the `--model` flag: +To use a different model, set `DSAGENT_DEFAULT_MODEL` or `LLM_MODEL` in `~/.dsagent/.env`, or use the `--model` flag: ```bash dsagent --model gpt-4o-mini ``` @@ -118,11 +130,15 @@ dsagent run "Analyze sales trends" --data ./sales.csv | `dsagent` | Start interactive chat (default) | | `dsagent chat` | Same as above, with explicit options | | `dsagent run "task"` | Execute a one-shot task | +| `dsagent serve` | Run REST + WebSocket API server | | `dsagent init` | Setup wizard for configuration | | `dsagent skills list` | List installed skills | -| `dsagent skills install ` | Install a skill | +| `dsagent skills install ` | Install a skill from GitHub or path | +| `dsagent skills remove ` | Remove a skill | +| `dsagent skills info ` | Show skill details | | `dsagent mcp list` | List configured MCP servers | -| `dsagent mcp add