Skip to content

Commit 48dee34

Browse files
authored
Merge pull request #88 from usnavy13/skills-bash-batch-improvements
feat: Auth, sandbox egress, file handling, and bash batch execution
2 parents 70fbae3 + d9199ad commit 48dee34

57 files changed

Lines changed: 4701 additions & 376 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.env.example

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,28 @@
66
API_KEY=your-secure-api-key-here-change-this-in-production
77
# API_KEYS=key1,key2,key3 # Additional API keys (comma-separated)
88
# MASTER_API_KEY=your-secure-master-key # Required for admin dashboard CLI
9+
#
10+
# AUTH_ENABLED=true # Set to false to disable x-api-key/Basic auth checks
11+
# # on user endpoints. Use only when running behind a
12+
# # trusted network boundary. /api/v1/admin/* still
13+
# # requires MASTER_API_KEY regardless.
14+
#
15+
# Three ways clients can authenticate when AUTH_ENABLED=true:
16+
# 1. x-api-key: <key> (recommended for proxies)
17+
# 2. Authorization: Basic base64("<key>:") (LibreChat URL credentials)
18+
# e.g. LIBRECHAT_CODE_BASEURL=https://<key>@your-api/v1
19+
# 3. (none, when AUTH_ENABLED=false)
20+
21+
# ── Sandbox network access (skill installs) ───────────────────
22+
# When ENABLE_SANDBOX_NETWORK=true, sandboxes can reach the internet but only
23+
# through an inline allowlist proxy that permits PyPI, npm, Go modules, and
24+
# crates.io. Required for skills that pip/npm/go install dependencies at
25+
# runtime. Off by default (sandboxes are isolated).
26+
#
27+
# ENABLE_SANDBOX_NETWORK=false
28+
# SANDBOX_EGRESS_PORT=18443 # local-only, sandbox -> proxy
29+
# SANDBOX_EGRESS_ALLOWLIST= # comma-separated extra hosts
30+
# SKILL_DEPS_PATH=/opt/skill-deps # backing volume mount
931

1032
# ── Redis ───────────────────────────────────────────────────────
1133
REDIS_HOST=localhost

Dockerfile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
2626
flex bison \
2727
curl wget ca-certificates gnupg software-properties-common \
2828
libssl-dev libffi-dev libxml2-dev libxslt-dev zlib1g-dev \
29+
jq iptables \
2930
&& rm -rf /var/lib/apt/lists/*
3031

3132
RUN git clone https://github.com/google/nsjail.git /tmp/nsjail && \
@@ -51,6 +52,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
5152
portaudio19-dev flac ffmpeg \
5253
libpulse-dev libsdl2-dev libsdl2-mixer-dev libsdl2-image-dev libsdl2-ttf-dev \
5354
antiword unrtf \
55+
libreoffice-impress libreoffice-writer libreoffice-calc libreoffice-common \
5456
&& rm -rf /var/lib/apt/lists/*
5557

5658
COPY docker/requirements/python-core.txt /tmp/python-core.txt
@@ -276,8 +278,9 @@ WORKDIR /app
276278
# Keep the application layer thin so app-only changes do not invalidate runtime stages.
277279
COPY docker/repl_server.py /opt/repl_server.py
278280
COPY docker/ptc_server.py /opt/ptc_server.py
281+
COPY docker/ptc_bash_server.py /opt/ptc_bash_server.py
279282
COPY docker/entrypoint.sh /opt/entrypoint.sh
280-
RUN chmod +x /opt/repl_server.py /opt/ptc_server.py /opt/entrypoint.sh
283+
RUN chmod +x /opt/repl_server.py /opt/ptc_server.py /opt/ptc_bash_server.py /opt/entrypoint.sh
281284

282285
COPY requirements.txt /tmp/requirements.txt
283286
RUN --mount=type=cache,target=/root/.cache/pip \

docker-compose.local-test.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
services:
2+
api:
3+
image: code-interpreter:nsjail-librechat-compat
4+
pull_policy: never

docker-compose.prod.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ services:
77
init: true
88
cap_add:
99
- SYS_ADMIN
10+
# NET_ADMIN required to install iptables egress rules for sandbox uid
11+
# when ENABLE_SANDBOX_NETWORK=true. Restricts sandbox traffic to the
12+
# inline allowlist proxy and prevents SSRF to Redis/MinIO/etc.
13+
- NET_ADMIN
1014
security_opt:
1115
- apparmor:unconfined
1216
ports:
@@ -18,6 +22,10 @@ services:
1822
- MINIO_ENDPOINT=minio:9000
1923
volumes:
2024
- sandbox-data:/var/lib/code-interpreter/sandboxes
25+
# Persistent skill-deps cache: pip/npm/go/cargo install here when
26+
# ENABLE_SANDBOX_NETWORK=true so future executions reuse the install.
27+
# Survives container restarts; purge with POST /api/v1/admin/skill-deps/purge.
28+
- skill-deps:/opt/skill-deps
2129
# SSL_CERTS_PATH is a host path; SSL_CERT_FILE and SSL_KEY_FILE must point
2230
# to the mounted files inside the container under /app/ssl.
2331
- ${SSL_CERTS_PATH:-./ssl}:/app/ssl:ro
@@ -92,5 +100,6 @@ services:
92100

93101
volumes:
94102
sandbox-data:
103+
skill-deps:
95104
redis-data:
96105
minio-data:

docker-compose.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ services:
1313
# nsjail requires these capabilities to create namespaces and cgroups
1414
cap_add:
1515
- SYS_ADMIN
16+
- NET_ADMIN
1617
security_opt:
1718
- apparmor:unconfined
1819
ports:

0 commit comments

Comments
 (0)