Skip to content

Your lightweight open-source personal agent.

Merge origin/main into feat/best_skill_and_hook (resolve 4 conflicts)

Xubin Rena8707ca8f61e
diff --cc Dockerfile
index 594a9e7a7,90f0e36a5..141a6f9b3
--- a/Dockerfile
+++ b/Dockerfile
@@@ -2,7 -2,7 +2,7 @@@ FROM ghcr.io/astral-sh/uv:python3.12-bo
# Install Node.js 20 for the WhatsApp bridge
RUN apt-get update && \
- apt-get install -y --no-install-recommends curl ca-certificates gnupg git bubblewrap && \
- apt-get install -y --no-install-recommends curl ca-certificates gnupg git openssh-client && \
++ apt-get install -y --no-install-recommends curl ca-certificates gnupg git bubblewrap openssh-client && \
mkdir -p /etc/apt/keyrings && \
curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg && \
echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_20.x nodistro main" > /etc/apt/sources.list.d/nodesource.list && \
@@@ -27,16 -27,13 +27,18 @@@ RUN uv pip install --system --no-cache
# Build the WhatsApp bridge
WORKDIR /app/bridge
- RUN npm install && npm run build
+ RUN git config --global --add url."https://github.com/".insteadOf ssh://[email protected]/ && \
+ git config --global --add url."https://github.com/".insteadOf [email protected]: && \
+ npm install && npm run build
WORKDIR /app
-# Create config directory
-RUN mkdir -p /root/.nanobot
+# Create non-root user and config directory
+RUN useradd -m -u 1000 -s /bin/bash nanobot && \
+ mkdir -p /home/nanobot/.nanobot && \
+ chown -R nanobot:nanobot /home/nanobot /app
+
+USER nanobot
+ENV HOME=/home/nanobot
# Gateway default port
EXPOSE 18790
diff --cc nanobot/agent/loop.py
index 1333a89e1,25a81b62b..93dcaabec
--- a/nanobot/agent/loop.py
+++ b/nanobot/agent/loop.py
@@@ -120,15 -267,18 +267,19 @@@ class AgentLoop
self.tools.register(ReadFileTool(workspace=self.workspace, allowed_dir=allowed_dir, extra_allowed_dirs=extra_read))
for cls in (WriteFileTool, EditFileTool, ListDirTool):
self.tools.register(cls(workspace=self.workspace, allowed_dir=allowed_dir))
- self.tools.register(ExecTool(
- working_dir=str(self.workspace),
- timeout=self.exec_config.timeout,
- restrict_to_workspace=self.restrict_to_workspace,
- sandbox=self.exec_config.sandbox,
- path_append=self.exec_config.path_append,
- ))
- self.tools.register(WebSearchTool(config=self.web_search_config, proxy=self.web_proxy))
- self.tools.register(WebFetchTool(proxy=self.web_proxy))
+ for cls in (GlobTool, GrepTool):
+ self.tools.register(cls(workspace=self.workspace, allowed_dir=allowed_dir))
+ if self.exec_config.enable:
+ self.tools.register(ExecTool(
+ working_dir=str(self.workspace),
+ timeout=self.exec_config.timeout,
+ restrict_to_workspace=self.restrict_to_workspace,
++ sandbox=self.exec_config.sandbox,
+ path_append=self.exec_config.path_append,
+ ))
+ if self.web_config.enable:
+ self.tools.register(WebSearchTool(config=self.web_config.search, proxy=self.web_config.proxy))
+ self.tools.register(WebFetchTool(proxy=self.web_config.proxy))
self.tools.register(MessageTool(send_callback=self.bus.publish_outbound))
self.tools.register(SpawnTool(manager=self.subagents))
if self.cron_service:
diff --cc nanobot/agent/subagent.py
index 1960bd82c,8ea4b6c06..585139972
--- a/nanobot/agent/subagent.py
+++ b/nanobot/agent/subagent.py
@@@ -98,16 -117,18 +117,19 @@@ class SubagentManager
tools.register(WriteFileTool(workspace=self.workspace, allowed_dir=allowed_dir))
tools.register(EditFileTool(workspace=self.workspace, allowed_dir=allowed_dir))
tools.register(ListDirTool(workspace=self.workspace, allowed_dir=allowed_dir))
- tools.register(ExecTool(
- working_dir=str(self.workspace),
- timeout=self.exec_config.timeout,
- restrict_to_workspace=self.restrict_to_workspace,
- sandbox=self.exec_config.sandbox,
- path_append=self.exec_config.path_append,
- ))
- tools.register(WebSearchTool(config=self.web_search_config, proxy=self.web_proxy))
- tools.register(WebFetchTool(proxy=self.web_proxy))
-
+ tools.register(GlobTool(workspace=self.workspace, allowed_dir=allowed_dir))
+ tools.register(GrepTool(workspace=self.workspace, allowed_dir=allowed_dir))
+ if self.exec_config.enable:
+ tools.register(ExecTool(
+ working_dir=str(self.workspace),
+ timeout=self.exec_config.timeout,
+ restrict_to_workspace=self.restrict_to_workspace,
++ sandbox=self.exec_config.sandbox,
+ path_append=self.exec_config.path_append,
+ ))
+ if self.web_config.enable:
+ tools.register(WebSearchTool(config=self.web_config.search, proxy=self.web_config.proxy))
+ tools.register(WebFetchTool(proxy=self.web_config.proxy))
system_prompt = self._build_subagent_prompt()
messages: list[dict[str, Any]] = [
{"role": "system", "content": system_prompt},
diff --cc nanobot/agent/tools/shell.py
index 4bdeda6ec,c8876827c..ec2f1a775
--- a/nanobot/agent/tools/shell.py
+++ b/nanobot/agent/tools/shell.py
@@@ -6,10 -7,29 +7,30 @@@ import sy
from pathlib import Path
from typing import Any
- from nanobot.agent.tools.base import Tool
- from nanobot.agent.tools.sandbox import wrap_command
-
+ from loguru import logger
+ from nanobot.agent.tools.base import Tool, tool_parameters
++from nanobot.agent.tools.sandbox import wrap_command
+ from nanobot.agent.tools.schema import IntegerSchema, StringSchema, tool_parameters_schema
+ from nanobot.config.paths import get_media_dir
+
+
+ @tool_parameters(
+ tool_parameters_schema(
+ command=StringSchema("The shell command to execute"),
+ working_dir=StringSchema("Optional working directory for the command"),
+ timeout=IntegerSchema(
+ 60,
+ description=(
+ "Timeout in seconds. Increase for long-running commands "
+ "like compilation or installation (default 60, max 600)."
+ ),
+ minimum=1,
+ maximum=600,
+ ),
+ required=["command"],
+ )
+ )
class ExecTool(Tool):
"""Tool to execute shell commands."""
diff --cc nanobot/config/schema.py
index dee8c5f34,47e35070c..dfb91c528
--- a/nanobot/config/schema.py
+++ b/nanobot/config/schema.py
@@@ -126,11 -171,10 +171,11 @@@ class WebToolsConfig(Base)
class ExecToolConfig(Base):
"""Shell exec tool configuration."""
+ enable: bool = True
timeout: int = 60
path_append: str = ""
+ sandbox: str = "" # sandbox backend: "" (none) or "bwrap"
-
class MCPServerConfig(Base):
"""MCP server connection configuration (stdio or HTTP)."""
@@@ -148,8 -192,9 +193,9 @@@ class ToolsConfig(Base)
web: WebToolsConfig = Field(default_factory=WebToolsConfig)
exec: ExecToolConfig = Field(default_factory=ExecToolConfig)
- restrict_to_workspace: bool = False # If true, restrict all tool access to workspace directory
+ restrict_to_workspace: bool = False # restrict all tool access to workspace directory
mcp_servers: dict[str, MCPServerConfig] = Field(default_factory=dict)
+ ssrf_whitelist: list[str] = Field(default_factory=list) # CIDR ranges to exempt from SSRF blocking (e.g. ["100.64.0.0/10"] for Tailscale)
class Config(BaseSettings):