diff --git a/README.md b/README.md index 71e11f6e2..614ae6ed1 100644 --- a/README.md +++ b/README.md @@ -35,279 +35,166 @@ # nanobot -🐈 **nanobot** is an ultra-lightweight, open-source, self-hosted personal AI agent framework written in Python. Use it in a browser, terminal, or chat app to work with files, remember preferences, and schedule tasks. Connect a supported model provider or local model server to supply the AI. - -## Start Here - -| You want to... | Go to | -|---|---| -| Install nanobot with no terminal/config background | [Start Without Technical Background](./docs/start-without-technical-background.md) | -| Install quickly and get your first reply | [Install](#-install) and [Quick Start](#-quick-start) | -| Open the bundled browser UI | [WebUI](#-webui) | -| Connect Telegram, Discord, WeChat, Slack, Email, Mattermost, Linear, or another channel | [Chat app guide](./docs/guides/chat-app-ai-agent.md) | -| Configure providers, fallback models, Langfuse, MCP, web tools, or security | [Docs](./docs/README.md) and [Configuration](./docs/configuration.md) | -| Develop the browser UI | [Install current source](#-install), then [WebUI development](./webui/README.md) and [Contributing](./CONTRIBUTING.md) | -| Integrate from Python | [Python SDK](./docs/python-sdk.md) | -| Understand or extend the internals | [Architecture](./docs/architecture.md), [Contributing](./CONTRIBUTING.md), and [Provider extensions](./docs/development.md) | -| Deploy to the cloud or keep nanobot running as a service | [Deployment](./docs/deployment.md) | - -## What can nanobot do? - -nanobot can: - -- run in a browser WebUI or terminal -- connect to Telegram, Discord, Slack, WeChat, Email, Mattermost, Linear, and other channels -- read images, PDF, Word (`.docx`), Excel (`.xlsx`), and PowerPoint (`.pptx`) files with built-in file tools -- use shell, web search/fetch, MCP integrations, cron, image generation, and multi-agent delegation -- keep session history and use [Dream](./docs/memory.md#save-and-check-a-preference) to consolidate long-term memory -- run [long-horizon goals](./docs/guides/long-running-ai-agent.md) and [scheduled automations](./docs/automations.md) -- embed the agent with the Python SDK -- deploy as a long-running local or server-side agent gateway +🐈 **nanobot** is a lightweight, open-source, self-hosted personal AI agent written in Python. Chat with it from your browser, terminal, or favorite chat app to work with files, remember preferences, use tools, and run scheduled tasks—powered by any supported cloud or local AI model. ## 💡 Why nanobot -- **Persistent workflows**: keep saved conversations, long-term memory, and task results for later work. -- **Chat-native reach**: WebUI, Telegram, Feishu, Slack, Discord, Teams, email, Mattermost, and Linear. -- **Model freedom**: OpenAI-compatible APIs, local LLMs, image generation, search, and fallbacks. -- **Small core**: readable internals with MCP, memory, deployment, and automation built in. -- **Own your stack**: inspect, customize, self-host, and extend without a giant platform. +- **Lightweight & low footprint:** Small Python core with fast startup and low memory usage—runs comfortably on a personal laptop or a modest VPS without heavyweight infrastructure. +- **Polished WebUI & native TUI out of the box:** Includes a clean, responsive browser workbench (multi-pane topics, live tool activity, inline file diffs, context usage, themes, and custom backgrounds) plus a matching terminal UI—no separate frontend build needed. +- **Works where you already chat:** Connect seamlessly to 15+ chat apps including Telegram, Discord, Slack, Feishu, WeChat, WhatsApp, Email, Mattermost, and Linear. +- **Real tools, memory & automations:** Reads images, PDFs, and Office files (`.docx`, `.xlsx`, `.pptx`), edits files, connects to MCP servers and plugins, builds long-term memory with [Dream](./docs/memory.md), and runs [scheduled tasks, local triggers, and sustained goals](./docs/automations.md). +- **Model freedom & full control:** Use any cloud API (OpenRouter, Anthropic, OpenAI, Gemini, DeepSeek), OAuth subscription (OpenAI Codex, GitHub Copilot, xAI Grok), or local server (Ollama, vLLM, LM Studio)—self-hosted on your own machine. + +## Start Here + +| What you want to do | Where to go | +|---|---| +| Install nanobot with no terminal or config experience | [Start Without Technical Background](./docs/start-without-technical-background.md) | +| Install quickly and get your first reply | [Install](#-install) → [Quick Start](#-quick-start) | +| Explore the browser workbench | [WebUI](#-webui) | +| Connect Telegram, Discord, Slack, Feishu, WeChat, Email, Linear, or others | [Chat Apps Guide](./docs/guides/chat-app-ai-agent.md) | +| Configure models, MCP tools, memory, or security | [Documentation](./docs/README.md) · [Configuration](./docs/configuration.md) | +| Run nanobot continuously or on a server | [Deploy](#-deploy) · [Deployment Guide](./docs/deployment.md) | +| Embed nanobot in Python | [Python SDK](./docs/python-sdk.md) | +| Contribute or extend nanobot | [Architecture](./docs/architecture.md) · [Contributing](./CONTRIBUTING.md) | ## 📦 Install -You need **Python 3.11 or newer** and access to a [supported model provider or local model server](./docs/providers.md). Model fees or local hardware requirements depend on the service you choose; nanobot does not supply a model account. +Requires **Python 3.11 or newer** and an account on a [supported AI provider or local model server](./docs/providers.md). Packaged installs include both the WebUI and terminal UI—no frontend build tools required. -Choose the **stable release** for everyday use or **current source** for development and the latest features. This README describes current source; [published documentation](https://nanobot.wiki/docs/latest/getting-started/nanobot-overview) covers the released version. +> [!NOTE] +> This README tracks the latest development branch; the installer below installs the latest stable release. For published release docs, visit [nanobot.wiki](https://nanobot.wiki/docs/latest/getting-started/nanobot-overview). -New to terminals or model credentials? Follow [Start Without Technical Background](./docs/start-without-technical-background.md). Updating an existing instance? Follow [updates and recovery](./docs/updating.md) for your installation method, backup steps and restart checks. +**Recommended: one-command installer** (installs into an isolated environment and opens the WebUI automatically on desktop) -| Track | Install with | Update with | What runs | -|---|---|---|---| -| Stable | installer, `uv`, or pip | [WebUI when supported](./docs/updating.md#update-from-the-webui), otherwise the original package tool | one released Python/WebUI/TUI version | -| Current source | editable Git checkout | `git pull --ff-only` + editable dependency sync | Python, WebUI, and TUI from that checkout | - -**Stable release: automatic setup (recommended)** - -The installer chooses an isolated Python environment and opens setup for you. The two commands below are the same installation method for different operating systems; run only the one for your system. - -
-macOS / Linux +**macOS / Linux** ```bash curl -fsSL https://raw.githubusercontent.com/HKUDS/nanobot/main/scripts/install.sh | sh ``` -
- -
-Windows PowerShell +**Windows PowerShell** ```powershell irm https://raw.githubusercontent.com/HKUDS/nanobot/main/scripts/install.ps1 | iex ``` -
-
-Installer details, preview, and script review +Preview the installer or inspect the scripts first -The default command installs or upgrades the stable PyPI release. Fresh installations use a dedicated environment under `~/.nanobot/venv`. On a fresh local desktop it opens the WebUI for model setup. That gateway keeps running after the browser or terminal closes; use the printed `gateway stop` command to stop it. SSH, headless, existing-config and older-release installs use terminal setup when an interactive terminal is available; otherwise the installer prints the command to run later. - -The installer uses the detected installation method when safe, or stops for manual review. Check existing extras and constraints with the original package manager. An active venv remains an explicit target, not an installer-managed environment. The installer avoids system-wide pip and prints the command to reuse if `nanobot` is not on `PATH`. - -To preview the plan without changing your environment, pass `--dry-run`. +Preview what the installer will do without changing anything: ```bash +# macOS / Linux curl -fsSL https://raw.githubusercontent.com/HKUDS/nanobot/main/scripts/install.sh | sh -s -- --dry-run ``` ```powershell +# Windows PowerShell & ([scriptblock]::Create((irm https://raw.githubusercontent.com/HKUDS/nanobot/main/scripts/install.ps1))) --dry-run ``` -If you prefer to inspect the script first, open [`scripts/install.sh`](./scripts/install.sh) or [`scripts/install.ps1`](./scripts/install.ps1). +Or read [`scripts/install.sh`](./scripts/install.sh) and [`scripts/install.ps1`](./scripts/install.ps1) directly.
-Already use uv or pip? Install the stable package yourself +Other install methods: uv, pip, or from source -Use this instead of the recommended installer when you already manage your own Python environment. These commands install the same stable `nanobot-ai` package; they do not launch setup. - -**uv: isolated CLI installation** +**uv** ```bash uv tool install nanobot-ai +nanobot webui ``` -**pip: activate your virtual environment first** +**pip (inside a virtual environment)** ```bash python -m pip install nanobot-ai +nanobot webui ``` -Then run `nanobot webui` for browser setup, or `nanobot onboard --wizard` for terminal-only setup. For the [Python SDK](./docs/python-sdk.md), install `nanobot-ai` in your application's virtual environment so the application can import it; a separate `uv tool` environment does not make the SDK importable there. - -If pip reports `externally-managed-environment`, use the recommended installer, `uv tool install nanobot-ai`, `pipx install nanobot-ai`, or an activated virtual environment. Upgrade with the same method; for uv use `uv tool upgrade nanobot-ai`, and for pip use `python -m pip install -U nanobot-ai`. - -
- -**Current source: development checkout** - -
-Install current source with Git and Bun - -Clone the repository and install it in editable mode. A source install requires Git and [Bun](https://bun.sh/); Bun runs the matching TUI directly from the checkout instead of downloading an older release binary. +**From source (latest `main`, requires Git)** ```bash git clone https://github.com/HKUDS/nanobot.git cd nanobot python3 -m venv .venv -``` - -On Windows, use `py -3 -m venv .venv` instead of `python3`. Activate it with `source .venv/bin/activate` on macOS/Linux or `.venv\Scripts\Activate.ps1` in Windows PowerShell, then run: - -```bash +source .venv/bin/activate # Windows PowerShell: .venv\Scripts\Activate.ps1 python -m pip install -e . +nanobot webui ``` -After that, the normal commands are identical to a stable install. `nanobot` runs the TUI from this checkout, and `nanobot webui` prompts to rebuild stale frontend assets, or warns in non-interactive sessions; `--yes` builds automatically. After stopping the old instance, `git pull --ff-only` updates the Python, TUI, and WebUI source together; rerun `python -m pip install -e .` when Python dependencies change, then restart the instance. Contributors should also read [`CONTRIBUTING.md`](./CONTRIBUTING.md). +For full install options, troubleshooting `nanobot: command not found`, or updating an existing install, see [Install and Quick Start](./docs/quick-start.md) and [Updating nanobot](./docs/updating.md).
-
-Supported platforms, bundled UIs, and release tracks - -Published packages include the WebUI, and supported platform wheels also include the native TUI. A source-distribution install can fetch a checksummed, version-matched TUI archive—with its licenses, notices, corresponding application source, source offer, and relinking instructions—on first use. - -Platform wheels include both the WebUI and the native terminal UI: macOS 13+ (Apple Silicon and Intel), glibc 2.17+ Linux (ARM64 and x64), and Windows x64. The x64 runtime requires SSE4.2. Pip selects the matching wheel; opening the TUI does not need a separate GitHub download or Bun installation. A source-distribution install on a supported target can use the matching checksummed GitHub release archive. On other platforms, use `nanobot --classic` or the WebUI. - -
- -
-Verify the installation or locate the nanobot command - -Verify the install: - -```bash -nanobot --version -``` - -If `nanobot` is not on `PATH`, reuse the installer's printed command or run the Python executable from the existing installation with `-I -m nanobot`. For uv/pipx, locate that environment with the original manager. Do not use a temporary tool environment to manage an existing installation. - -
- -After installation, continue with [Quick Start](#-quick-start). Use the exact command printed by the installer if `nanobot` is not on `PATH`. - ## 🚀 Quick Start -**Open nanobot in your browser** - -If the installer already opened the WebUI, continue there. Otherwise run: +If the installer already opened the WebUI in your browser, continue right there. Otherwise run: ```bash nanobot webui ``` -Keep the launcher terminal open while using the browser. It starts or joins the shared local gateway and binds the first-run WebUI to localhost. If the browser does not open, copy the complete login link printed in the terminal, including everything after `#`; keep this credential private. For SSH or a headless host, use the remote-browser or terminal-only instructions below. +**Your first three steps:** -**Your first three steps** +1. Open **Settings → Models**, create a preset, and add your provider API key (or sign in with OAuth). See [Configure Your Model](./docs/quick-start.md#2-configure-your-model). +2. Start a new topic and send `Hello!` to verify your model connection. +3. Try a file task: pick a practice folder with **Restricted** access and ask *"Read notes.txt and write a short summary to summary.md."* See [Your first file task](./docs/start-without-technical-background.md#your-first-file-task). -1. Open **Settings → Models** and save a provider/model preset with your credential or supported sign-in. See [model setup](./docs/quick-start.md#2-configure-your-model) if you need the full steps. -2. Start a new topic and send `Hello!` to verify the model connection. -3. To try file work, put a copy of `notes.txt` in a practice folder, select that folder and **Default Permission** (workspace-restricted access, not an OS sandbox), and ask: "Read notes.txt and write a short summary to summary.md." Open `summary.md` in that folder to check the result. See [Your first file task](./docs/start-without-technical-background.md#your-first-file-task). - -A normal reply verifies the provider/model and browser connection. The file task separately checks the selected project and its file permissions. Attaching a file sends it to the conversation; it does not change the selected project folder. - -Then describe your next goal in the same chat, for example: "I am already using the WebUI. Help me connect Telegram and allow only my account." An enabled `nanobot-document` skill can consult the documentation bundled with your installation; see [Continue with nanobot](./docs/quick-start.md#continue-with-nanobot) for examples, explicit invocation, and availability. +Once that works, you can ask nanobot right in chat to help configure your next feature—for example: *"I am using the WebUI. Help me connect Telegram and allow only my account."* (See [Continue with nanobot](./docs/quick-start.md#continue-with-nanobot).)
-Open the WebUI on a remote server through SSH +Terminal-only setup and interactive TUI -After installing nanobot on the server, start its WebUI without opening a server-side browser: - -```bash -nanobot webui --no-open -``` - -Keep that server terminal running. In a second terminal on your own computer, forward the default WebUI port through SSH: - -```bash -ssh -N -L 127.0.0.1:8765:127.0.0.1:8765 user@SERVER -``` - -Replace `user@SERVER` with your SSH login and leave the tunnel open. In your local browser, open the complete login link printed by the server launcher, preserving its `#` fragment. It uses `http://127.0.0.1:8765`, which now reaches the server through the tunnel. Complete **Settings → Models** and send `Hello!`. If local port `8765` is occupied, use another local port in the tunnel and change only the port in the browser link. Keep the server listener on localhost. For Docker, public endpoints, or service management, see [Deployment](./docs/deployment.md). - -
- -
-Terminal-only setup, one-shot checks, and the TUI - -If a model is not configured yet, use the terminal wizard: +Configure a model without a browser: ```bash nanobot onboard --wizard ``` -Check one reply without opening the browser: - -```bash -nanobot -m "Hello!" -``` - -For interactive work, open the terminal client: +Send a single test message or launch the interactive terminal UI (shares history and gateway with the WebUI): ```bash +nanobot agent -m "Hello!" nanobot ``` -The native TUI uses the launch directory as its project workspace and shares saved conversations and the local gateway with the WebUI. The explicit `nanobot agent` form remains available for compatibility. - -- Type `/` to discover commands, `/sessions` to switch conversations, or `@` to mention an app, MCP server, or saved session. -- Paste clipboard images with `Ctrl+V` or `Alt+V`, and use `$` to complete skill references. -- Use `/diff` to inspect file changes, `/context` to inspect session context, or `/branch` to continue from a completed reply in a new session. -- Press `Enter` to send. While nanobot is working, `Enter` sends now and `Tab` sends after the current response. Press `Shift+Enter` to add a newline (`Ctrl+J` works in terminals that cannot distinguish modified Enter keys). -- Use `/detach` to promote the gateway to background mode and close the TUI while work continues. - -Each launch starts a new session by default. Use `--session` to resume one and `--workspace` to choose another project workspace. See the [CLI reference](./docs/cli-reference.md#agent-cli) for session branching, diffs, history, shortcuts, gateway lifecycle, and compatibility options. +Useful TUI shortcuts: type `/` for commands, `@` for apps/topics, `$` for skills, `Ctrl+V` / `Alt+V` to paste images, `/diff` to view edits, `/context` to inspect usage, and `/detach` to keep the gateway running in the background after closing the TUI. See [CLI Reference](./docs/cli-reference.md#agent-cli).
-Save and check a preference +Open a remote server's WebUI over SSH -State a specific preference in your chat, for example: "For release notes, use concise bullet points." To consolidate it now, send `/compact` and then `/dream`, waiting for each to finish, and review `/dream-log`. Check the actual changes to `USER.md` or `memory/MEMORY.md` in the configured agent workspace, then test reuse in a new topic in the same instance. Dream may decide that no durable change is needed; a conversational acknowledgement alone does not prove the preference was saved. See [Save and Check a Preference](./docs/memory.md#save-and-check-a-preference) for file access, correction, and restoration steps. +On the remote server: -
- -
-Start and stop a sustained goal - -Use a regular topic for a bounded objective with a clear completion condition, for example: - -```text -/goal Review this project's tests and list the smallest missing test case. +```bash +nanobot webui --no-open ``` -An active goal keeps nanobot working beyond the ordinary iteration limit until it records completion, cancellation, or a blocked state. This can use more model tokens; `/stop` interrupts the current work, while asking nanobot to cancel the goal abandons the objective. Execution errors can also stop the work. A scheduled automation instead starts work at specified times. Keep the gateway running for unattended work using the background or service options below. +On your computer, forward port `8765`: -After a gateway restart, reopen the original topic and review saved results before explicitly continuing any interrupted work. Recovery does not blindly replay uncertain tool actions. See the [long-running agent guide](./docs/guides/long-running-ai-agent.md) for starting conditions and related automation options. +```bash +ssh -N -L 127.0.0.1:8765:127.0.0.1:8765 user@SERVER +``` + +Then open the **complete login link** printed on the server (including everything after `#`) in your local browser. You can also connect to existing remote servers directly from your local WebUI via **Manage connections…**—see [Connect to an Existing Remote nanobot](./docs/guides/remote-instances.md).
-Keep the gateway running after closing interactive clients +Keep nanobot running in the background -After model setup, keep channels and automations running when interactive launchers close: +With the official installer, nanobot already stays running in the background after you close the browser or terminal. For other installs, run: ```bash nanobot gateway --background ``` -This starts or promotes the shared gateway to persistent background mode. Fresh official-installer environments already use that lifetime when you open `nanobot webui`; other Python installations can explicitly use `nanobot webui --detach`. Channels and automations remain active after local clients exit. Complete first-time model setup in the WebUI, and use the gateway commands below to manage the same instance. - -From the TUI, `/detach` does the same before closing that client. Background mode does not configure startup after a machine reboot or restart after a crash; use an [OS-managed service](./docs/deployment.md#switch-an-existing-gateway-to-a-service) for that. Interrupted subagent tasks are not automatically relaunched after a restart, and missed scheduled times are not replayed; see [subagent recovery](./docs/concepts.md#subagents) and [automation delivery](./docs/automations.md#delivery-and-reliability). - -Manage the background gateway with: +Manage the background gateway anytime: ```bash nanobot gateway status @@ -316,58 +203,29 @@ nanobot gateway restart nanobot gateway stop ``` -To reopen the browser, run `nanobot webui` against the same instance and use its complete printed login link. +For automatic startup across reboots, see [Deployment](./docs/deployment.md).
-
-Run a configured gateway directly - -Use this once a model is configured and you want to run the gateway directly in the current terminal: - -```bash -nanobot gateway -``` - -It skips guided WebUI setup and browser opening. The WebUI remains available when its channel is configured. Use `nanobot gateway --background` for a detached process, or follow [Deployment](./docs/deployment.md) for startup and supervision by the operating system. - -
- -
-Read task guides or look up configuration details - -- Model/provider recipes: [Provider Cookbook](./docs/provider-cookbook.md) and [Providers and Models](./docs/providers.md). -- Local models: [Ollama](./docs/providers.md#ollama), [vLLM or another OpenAI-compatible server](./docs/providers.md#vllm-or-other-local-openai-compatible-server). -- Chat platforms: [Chat app guide](./docs/guides/chat-app-ai-agent.md), then the [full channel reference](./docs/chat-apps.md). -- Exact settings for web search, MCP, voice, image generation, and security: [Configuration](./docs/configuration.md). -- Manual JSON and other setup paths: [Install and Quick Start](./docs/quick-start.md). -- Failures after setup: [Troubleshooting](./docs/troubleshooting.md). - -
- -If nanobot worked for you, a star on GitHub is the simplest way to support the project. +If nanobot is helpful to you, giving the repo a star on GitHub is the simplest way to support the project! ## ☁️ Deploy -**Render — one click** +**One-click on Render** -Deploy nanobot's gateway and bundled WebUI from the repository's ready-to-use Blueprint: +Deploy the gateway and bundled WebUI with persistent storage (requires a paid Render Starter plan for the persistent disk): [![Deploy to Render](https://render.com/images/deploy-to-render-button.svg)](https://render.com/deploy?repo=https://github.com/HKUDS/nanobot) -Render will ask for `ANTHROPIC_API_KEY` and a private `NANOBOT_WEB_TOKEN`, then provision persistent storage for sessions, memory, and WebUI history. Persistent disks require a paid Render service. Existing disk configuration is preserved on redeploy; check it when changing credentials. - **Self-host** -Prefer your own infrastructure? Follow the [deployment guide](./docs/deployment.md) for Docker, Docker Compose, Linux services, and macOS LaunchAgent setup. +See the [Deployment Guide](./docs/deployment.md) for Docker Compose, Docker, Linux `systemd`, and macOS LaunchAgent setup. ## 🌐 WebUI -The WebUI ships **inside the published wheel** with no separate frontend build. It is the browser workbench for persistent topics, temporary chats, visible agent activity, workspace controls, Apps, Skills, Automations, and settings. Start it with `nanobot webui`. WebUI access grants administration of the same agent instance; share it only with trusted operators. See [Sharing access](./docs/webui.md#sharing-access). - -The screenshots show example conversations, illustrative token counts, and paused schedules; the interface may change. +The WebUI is included out of the box—just run `nanobot webui`.

Three conversations in one WebUI workbench @@ -377,63 +235,44 @@ The screenshots show example conversations, illustrative token counts, and pause

Mobile WebUI · dark theme

- Mobile WebUI in dark theme with a saved conversation, model controls, context usage, and Default Permission + Mobile WebUI in dark theme

-Use it to: - -- keep separate topics for different tasks and projects; -- fork a topic from an earlier reply, or use temporary chats outside saved history and memory; -- inspect reasoning, tool calls, file edits, diffs, command output, and generated artifacts; -- switch model presets and choose a project before starting a topic; -- attach images, documents, or video, and use voice input with a configured transcription provider; -- configure models in **Settings**, connect chat platforms in **Channels**, and manage Apps, Skills, and Automations. - -Videos can be played in WebUI, but the agent cannot directly analyze their contents. - ### Keep related work side by side -Group up to four conversations and arrange them in columns, rows, a grid, or a main pane with supporting panes. Each topic keeps its own history. Select another topic from the `@` menu, or drag it into the composer, to let the agent read its context and coordinate work across sessions. +Group up to four topics in resizable panes, fork any conversation from an earlier reply, or mention another topic with `@` to pull in its context. Pick a project folder and access mode per topic—and use [Temporary chats](./docs/webui.md#temporary-chats) for throwaway questions outside saved history and memory. [Explore topics and panes →](./docs/webui.md#conversation-groups-and-panes) -Choose a project, access mode, and model for each task. Topics separate conversation history; project folders select where file work happens. Neither creates separate long-term memory: one instance shares its agent profile, memory, and skills across projects. Use [separate instances](./docs/multiple-instances.md) when client data or preferences must stay isolated. [Explore topics and panes →](./docs/webui.md#conversation-groups-and-panes) +### Inspect every step and token -### Inspect the work and its context - -Expand agent activity to see reasoning, tool calls, and file changes. Switch **Settings → Appearance → Edit preview** to **Diff** for inline patches. The composer's context indicator shows the current context size, input tokens by round, and cache reuse when the provider reports it. +Expand agent activity to inspect reasoning, tool calls, inline file diffs, and read-only file previews. Click the context indicator to review token usage, cache reuse, and the file graph across turns.

- An expanded file-edit diff above the context usage chart, with input tokens and cache reuse shown across four rounds + Expanded file-edit diff and context usage chart

-Context compaction also appears in the conversation timeline. [Explore activity and context →](./docs/webui.md#activity-and-context-usage) +[Explore activity and context →](./docs/webui.md#activity-and-context-usage) -### Bring your tools into the conversation +### Connect tools, skills, and chat apps -Use Apps to connect MCP servers, enable Agent Plugins, and manage local CLI App adapters. Add a preset or a custom server, then attach an available tool with `@`. Skills provide reusable instructions. **Settings** holds model, voice, image, and web setup; **Channels** handles chat-platform connections. +Use **Apps** to add MCP servers (with built-in OAuth and keyless presets), Agent Plugins, and CLI Apps, then attach them in chat with `@`. Manage built-in and marketplace skills in **Skills**, and connect chat platforms with guided setup in **Channels**.

- The Apps MCP catalog with searchable integration presets and Connect actions + The Apps MCP catalog with searchable integration presets

[Explore Apps →](./docs/webui.md#apps) · [Discover Skills →](./docs/webui.md#skills) · [Connect chat apps →](./docs/guides/chat-app-ai-agent.md) -Before connecting a personal bot to shared channels, check the platform's DM pairing/allowlist and group-access policies separately. Approving a private sender does not restrict group access on every platform; see the [channel reference](./docs/chat-apps.md). +### Automate recurring work -### Let recurring work run on a schedule - -Ask for an automation from the topic that should receive its results. Use **Tasks** to review and manage schedules, or **Calendar** to scan completed and upcoming runs by date. Local triggers let a script start a saved task on demand. +Ask nanobot in any topic to schedule reminders or recurring reports, or create local triggers (`/trigger`) for scripts and CI jobs. Manage everything from **Automations** with list and calendar views.

- The Automations calendar with example completed runs arranged by date + The Automations calendar view

-Keep the gateway running and the host awake for scheduled delivery. Missed scheduled times are not replayed after a gateway restart. See [delivery and recovery rules](./docs/automations.md#delivery-and-reliability). [Explore Automations →](./docs/automations.md) - -For a conversation that should stay out of saved topic history and long-term memory, use [Temporary chat](./docs/webui.md#temporary-chats) from the header. Temporary chats end when the connection closes and use the default workspace with workspace-only permissions. Requests still go to the configured model provider, and files created by tools remain after the chat closes. - -See the [WebUI guide](./docs/webui.md) for LAN access, background operation, workspace controls, and the full feature tour. Working on the frontend itself? Use [`webui/README.md`](./webui/README.md). +[Explore Automations →](./docs/automations.md) · [Full WebUI Guide →](./docs/webui.md) ## Architecture @@ -441,34 +280,21 @@ See the [WebUI guide](./docs/webui.md) for LAN access, background operation, wor nanobot architecture

-The Python gateway owns agent execution, sessions, tools, memory, and security policy for the WebUI, TUI, and chat apps. The clients share that runtime; the core agent loop builds context, calls the model, executes requested tools, and returns the result. Memory, skills, channels, and MCP integrations extend that loop. - -The [Python SDK](./docs/python-sdk.md) embeds the agent runtime in your application process. - -See [Architecture](./docs/architecture.md) for source ownership and extension points. +A single Python gateway powers the WebUI, terminal UI, and all chat apps—handling sessions, tools, memory, automations, and security policy in one place. Use the [Python SDK](./docs/python-sdk.md) to embed nanobot in your own Python applications, or read [Architecture](./docs/architecture.md) for source-level details. ## Docs -Browse the [repo docs](./docs/README.md) for current source documentation, or visit [nanobot.wiki](https://nanobot.wiki/docs/latest/getting-started/nanobot-overview) for the stable release. The [task guide index](./docs/guides/README.md) groups walkthroughs by outcome. +Browse the [documentation index](./docs/README.md) (or [nanobot.wiki](https://nanobot.wiki/docs/latest/getting-started/nanobot-overview) for the latest stable release): -- Get started: [Beginner walkthrough](./docs/start-without-technical-background.md) or [Install and Quick Start](./docs/quick-start.md). -- Choose and configure a model: [Providers and Models](./docs/providers.md) and [Provider Cookbook](./docs/provider-cookbook.md). -- Connect a chat app: [Chat App AI Agent](./docs/guides/chat-app-ai-agent.md) and [channel reference](./docs/chat-apps.md). -- Schedule or deploy work: [Automations](./docs/automations.md) and [Deployment](./docs/deployment.md). -- Integrate from code: [Python SDK](./docs/python-sdk.md). -- Look up runtime concepts or exact settings: [Concepts](./docs/concepts.md) and [Configuration](./docs/configuration.md). -- Diagnose a failure: [Troubleshooting](./docs/troubleshooting.md). -- Extend the core: [Architecture](./docs/architecture.md) and [contribution workflow](./CONTRIBUTING.md). +- **Get started:** [Beginner walkthrough](./docs/start-without-technical-background.md) · [Install and Quick Start](./docs/quick-start.md) +- **Models & providers:** [Providers and Models](./docs/providers.md) · [Provider Cookbook](./docs/provider-cookbook.md) +- **Chat apps & tools:** [Chat Apps Guide](./docs/guides/chat-app-ai-agent.md) · [MCP Presets](./docs/mcp-presets.md) · [Image Generation](./docs/image-generation.md) +- **Memory & automations:** [Memory](./docs/memory.md) · [Automations](./docs/automations.md) · [Deployment](./docs/deployment.md) +- **Reference & help:** [Concepts](./docs/concepts.md) · [Configuration](./docs/configuration.md) · [Troubleshooting](./docs/troubleshooting.md) · [Task Guides](./docs/guides/README.md) ## Releases -**Latest release: [v0.4.1](https://github.com/HKUDS/nanobot/releases/tag/v0.4.1)** - -v0.4.1 improves workspace permissions, sandboxed commands, connection recovery, file-context previews, and navigation. It retains legacy history and proxy migration through 0.4.x. - -Back up the stopped instance and upgrade through its original installation method. v0.3.5 can upgrade directly to v0.4.1; in-app automatic installation is not enabled for this release. See [upgrade notes](https://github.com/HKUDS/nanobot/releases/tag/v0.4.1) and [Updating nanobot](./docs/updating.md). - -For other changes, see [GitHub releases](https://github.com/HKUDS/nanobot/releases) and the [release archive](./docs/release-archive.md). +**Latest release: [v0.4.1](https://github.com/HKUDS/nanobot/releases/tag/v0.4.1)** — improves workspace permissions, sandboxed commands, connection recovery, file-context previews, and navigation. See [release notes](https://github.com/HKUDS/nanobot/releases/tag/v0.4.1), [Updating nanobot](./docs/updating.md), and the [release archive](./docs/release-archive.md). ## Open Source Partners diff --git a/SECURITY.md b/SECURITY.md index 3d28de9e5..ad5881fc0 100644 --- a/SECURITY.md +++ b/SECURITY.md @@ -60,10 +60,10 @@ chmod 600 ~/.nanobot/config.json ``` **Security Notes:** -- In `v0.1.4.post3` and earlier, an empty `allowFrom` allowed all users. Since `v0.1.4.post4`, empty `allowFrom` denies all access by default — set `["*"]` to explicitly allow everyone. -- Get your Telegram user ID from `@userinfobot` -- Use WhatsApp sender IDs as full phone numbers with country code and no leading `+` -- Review access logs regularly for unauthorized access attempts +- An empty `allowFrom` denies all access by default (or uses DM pairing where supported). Set `["*"]` only if you intentionally want public access. +- Get your Telegram user ID from `@userinfobot`. +- Use WhatsApp sender IDs as full phone numbers with country code and no leading `+`. +- Review access logs regularly for unauthorized access attempts. ### 3. Shell Command Execution @@ -92,15 +92,10 @@ Set `"tools.exec.sandbox"` to wrap every shell command in an OS sandbox. Both ba | [bubblewrap](https://github.com/containers/bubblewrap) | `"bwrap"` | Linux | `bwrap` (`apt install bubblewrap`). Pre-installed in the official Docker image. | | Seatbelt | `"seatbelt"` | macOS | `sandbox-exec(1)`, shipped with macOS. | -**Windows has no backend**: nanobot logs a warning and runs the command unsandboxed. +**Windows has no OS shell sandbox:** nanobot logs a warning and runs commands unsandboxed (disable shell execution if workspace guards are not enough). -The backends protect the workspace's parent differently. `bwrap` masks it with a tmpfs and re-exposes the workspace and allowed binds. Seatbelt has no mount namespace: it denies the parent, re-allows traversal metadata, and exposes the workspace and allowed roots. Keep configuration and credentials outside the workspace and extra binds; choosing an overly broad workspace or explicitly exposing secret-bearing paths defeats that separation. - -Seatbelt does **not** expose the host's shared `/tmp`, `/var/folders`, `/Library`, or `/etc` trees. It allows system code, device reads and selected system configuration/certificate paths. `HOME` and `TMPDIR` point to the workspace. Tools must use that scratch location; on macOS use an explicit template such as `mktemp "$TMPDIR/job.XXXXXX"`, since bare `mktemp` may prefer the host's system temp directory. Tools that require other installations or caches need narrow `sandboxRoBinds` / `sandboxRwBinds`. Read-only binds revoke workspace writes beneath them; explicit read-write binds take precedence, matching bwrap's operator-controlled policy. Seatbelt also prevents renaming or removing ancestor directories of media and read-only roots, so moving a writable parent cannot bypass a read-only rule; unrelated children of those ancestors remain writable where otherwise allowed. An explicit read-write bind covering an entire read-only root overrides that root's protection, but a writable descendant does not unlock its ancestors. This is filesystem containment, not a VM or separate user identity. - -Neither backend restricts network access. - -Enabling the sandbox also automatically activates `restrictToWorkspace` for file tools. +> [!NOTE] +> The OS sandbox isolates the filesystem (not network access) and automatically enables `restrictToWorkspace` for file tools. Keep `~/.nanobot/config.json` and secrets outside your workspace, and use narrow `sandboxRoBinds` / `sandboxRwBinds` only when a tool needs extra paths. On macOS Seatbelt, `HOME` and `TMPDIR` point inside the workspace. **Blocked patterns:** - `rm -rf /` - Root filesystem deletion @@ -145,9 +140,9 @@ pip install --upgrade nanobot-ai ``` **Important Notes:** -- Keep `litellm` updated to the latest version for security fixes -- Run `pip-audit` regularly after enabling the channels used in production; their manifest-declared dependencies are installed into the same environment -- Subscribe to security advisories for nanobot and its dependencies +- Keep `nanobot-ai` and its dependencies up to date for security fixes. +- Run `pip-audit` regularly after enabling chat channels in production. +- Subscribe to security advisories for nanobot and its dependencies. ### 7. Production Deployment diff --git a/docs/README.md b/docs/README.md index bf400a3e2..c02a3516f 100644 --- a/docs/README.md +++ b/docs/README.md @@ -1,50 +1,47 @@ # nanobot Documentation -Use these docs to get a working agent first. After the first reply, describe your next goal to nanobot or choose a task guide to read yourself. Source-level design and extension details are kept in the contributor section. +Get nanobot running and answering your first message first. Once that works, you can ask nanobot to help you set up the next feature or follow a guide below. -Repository docs follow the current source tree and can be newer than the latest package release. For published release docs, visit [nanobot.wiki](https://nanobot.wiki/docs/latest/getting-started/nanobot-overview). +> [!NOTE] +> These docs follow the latest development version. For the latest published release, visit [nanobot.wiki](https://nanobot.wiki/docs/latest/getting-started/nanobot-overview). -Use the graphical setup steps first when the WebUI exposes the setting. Expand **Manual configuration** for headless deployments or configuration managed as code. Settings without a graphical control keep their direct configuration instructions. +When a setting is available in the WebUI, follow the graphical steps first. Expand **Manual configuration** when you manage `config.json` directly or run nanobot on a headless server. ## Start Here -| Your situation | Read this | You are done when... | +| Your situation | Read this | Done when... | |---|---|---| -| Terminals, Python, or API keys are new to you | [Beginner walkthrough](./start-without-technical-background.md) | The browser can send `Hello!` and receive a reply | -| You are comfortable running commands | [Install and Quick Start](./quick-start.md) | `nanobot status` is healthy and the WebUI or CLI can get one reply | -| nanobot will not start | [Troubleshooting: Installation Problems](./troubleshooting.md#installation-problems) | nanobot starts, or you know what to fix next | -| The browser or chat app opens, but nanobot does not reply | [Troubleshooting: Provider and Model Problems](./troubleshooting.md#provider-and-model-problems), [WebUI Problems](./troubleshooting.md#webui-problems), or [Chat App Problems](./troubleshooting.md#chat-app-problems) | You have a working reply or a specific next step | +| Terminals, Python, or API keys are new to you | [Start Without Technical Background](./start-without-technical-background.md) | You send `Hello!` in your browser and get a reply | +| You are comfortable running terminal commands | [Install and Quick Start](./quick-start.md) | `nanobot status` passes and you get a reply in the WebUI or terminal | +| nanobot will not start | [Installation Problems](./troubleshooting.md#installation-problems) | nanobot starts, or you know what to fix next | +| nanobot opens, but does not reply | [Provider & Model](./troubleshooting.md#provider-and-model-problems), [WebUI](./troubleshooting.md#webui-problems), or [Chat Apps](./troubleshooting.md#chat-app-problems) | You get a reply or a clear next step | -The recommended first-run path is: +The fastest first-run path: 1. Install nanobot. -2. Let the installer open `nanobot webui` on a fresh local desktop. -3. Configure a provider and model in **Settings → Models**. +2. Let the installer open the WebUI in your browser. +3. Add a provider and model in **Settings → Models**. 4. Send `Hello!` before configuring anything else. -Most people do not need to edit JSON for the first run. The WebUI handles the initial provider, model, and local browser settings. SSH, headless, existing-config, and older-release installs retain `nanobot onboard --wizard` as a terminal fallback. After the WebUI opens, use **Settings** for models and built-in capabilities, **Channels** for chat apps, and **Apps** for Agent Plugins, CLI Apps, and MCP integrations. +You do not need to edit JSON to get started. Use **Settings** for models and built-in capabilities, **Channels** for chat apps, and **Apps** for plugins, CLI apps, and MCP tools. On servers without a browser, use `nanobot onboard --wizard` instead. ## After the First Reply -When the built-in `nanobot-document` skill is available and enabled, nanobot can consult the documentation bundled with your installation as you ask about features, configuration, or errors. Describe your current setup and one goal in the same chat; see [Continue with nanobot](./quick-start.md#continue-with-nanobot) for examples and explicit skill invocation. The skill links to the task and reference pages below as needed. - -For independent reading, choose a task guide below. Use the reference section when you need an exact field, default, command, or protocol detail. +Once nanobot replies, you can ask it directly in chat to help configure your next feature—when the built-in `nanobot-document` skill is enabled, it reads the bundled docs for your version. See [Continue with nanobot](./quick-start.md#continue-with-nanobot) for examples, or pick a guide below. ## Add One Capability -Pick the row that matches what you want to accomplish next: - | Goal | Guide | |---|---| | Learn the browser workbench | [WebUI](./webui.md) | | Connect Telegram, Discord, Slack, Feishu, WeChat, Email, or another chat app | [Chat Apps](./chat-apps.md) | -| Choose a hosted, OAuth, company, or local model | [Provider Cookbook](./provider-cookbook.md) | +| Set up a hosted, OAuth, company, or local model | [Provider Cookbook](./provider-cookbook.md) | | Add model fallbacks | [Configure Model Fallback](./guides/configure-model-fallback.md) | | Enable web search | [Configure Web Search](./guides/configure-web-search.md) | | Manage Agent Plugins, CLI Apps, or MCP integrations | [WebUI Apps](./webui.md#apps) | | Add an MCP tool server | [Configure MCP Tools](./guides/configure-mcp-tools.md) | | Generate images | [Image Generation](./image-generation.md) | -| Schedule work or create a local trigger | [Automations](./automations.md) | +| Schedule recurring tasks or local triggers | [Automations](./automations.md) | | Understand and manage long-term memory | [Memory](./memory.md) | | Run nanobot continuously | [Deployment](./deployment.md) | | Run separate bots or workspaces | [Multiple Instances](./multiple-instances.md) | @@ -57,31 +54,32 @@ For shorter, outcome-focused walkthroughs, browse the [task guide index](./guide | Need | Read | |---|---| | Commands and flags | [CLI Reference](./cli-reference.md) | -| Update an installation or recover an interrupted update | [Updating nanobot](./updating.md) | +| Update nanobot or recover a failed update | [Updating nanobot](./updating.md) | | In-chat slash commands | [In-Chat Commands](./chat-commands.md) | -| Config, workspace, gateway, sessions, tools, and memory in plain language | [Concepts](./concepts.md) | -| Provider/model matching and selection | [Providers and Models](./providers.md) | -| Setup and runtime diagnosis | [Troubleshooting](./troubleshooting.md) | +| Plain-language overview of how nanobot works | [Concepts](./concepts.md) | +| Provider and model matching | [Providers and Models](./providers.md) | +| Diagnose setup or runtime problems | [Troubleshooting](./troubleshooting.md) | | Older development highlights | [Release Archive](./release-archive.md) | ## Reference -Use reference pages to look up an exact option after you know what you are trying to configure: +Use these pages when you need exact config keys, defaults, or API details: | Area | Reference | |---|---| -| Every configuration field and default | [Configuration](./configuration.md) | +| Configuration fields and defaults | [Configuration](./configuration.md) | | Provider and model behavior | [Providers and Models](./providers.md) | | Chat channel prerequisites and manual JSON | [Chat Apps](./chat-apps.md) | | WebSocket authentication and wire protocol | [WebSocket](./websocket.md) | | Python SDK classes, events, sessions, and hooks | [Python SDK](./python-sdk.md) | | Runtime self-inspection and tuning | [My Tool](./my-tool.md) | -Configuration examples are usually snippets to merge into `~/.nanobot/config.json`, not complete replacement files. The docs use camelCase because nanobot writes config that way. Keep real API keys, bot tokens, and passwords out of issues and public logs. +> [!TIP] +> JSON examples in these docs are usually snippets to merge into `~/.nanobot/config.json`, not complete files. Never share real API keys, bot tokens, or passwords in issues or logs. ## Extend or Contribute -These pages explain implementation and extension points. You do not need them to install or operate nanobot. +You do not need these pages to install or use nanobot. | Goal | Read | |---|---| @@ -89,7 +87,7 @@ These pages explain implementation and extension points. You do not need them to | Set up a development environment | [Development](./development.md) and [CONTRIBUTING.md](../CONTRIBUTING.md) | | Add a channel package | [Channel Package Guide](./channel-package-guide.md) | | Build the WebUI source | [WebUI Development](../webui/README.md) | -| Change update APIs, execution or recovery | [Update protocol](./update-protocol.md) | +| Change update APIs or execution | [Update protocol](./update-protocol.md) | | Prepare and publish a release | [Release checklist](./releasing.md) | -If a command or screen no longer matches these docs, please [open an issue](https://github.com/HKUDS/nanobot/issues) with your nanobot version, operating system, and the page that needs correction. +If a command or screen no longer matches these docs, please [open an issue](https://github.com/HKUDS/nanobot/issues) with your nanobot version, operating system, and the page that needs updating. diff --git a/docs/automations.md b/docs/automations.md index 66f440517..e2628c2e6 100644 --- a/docs/automations.md +++ b/docs/automations.md @@ -2,242 +2,121 @@ -Automations are agent turns that run later in a linked topic. Use them when nanobot should do work without someone actively typing: reminders, recurring checks, nightly summaries, CI follow-ups, local script reports, or webhook-driven events. +Automations let nanobot run tasks on its own—reminders, daily summaries, CI follow-ups, local script reports, or quiet background checks. -Create automations from the chat channel or WebUI topic where the result should appear. That lets nanobot keep the right session history, workspace, and reply target. +Always create an automation from the WebUI topic or chat channel where you want its replies to appear. Keep `nanobot gateway` running (your WebUI or TUI already runs one; use `nanobot gateway --background` to keep it alive after closing the terminal). ## Choose an Automation Type -| Type | Starts from | Best for | Created with | +| Type | Starts from | Best for | How to create | |---|---|---|---| -| Scheduled automation | Time, interval, or cron expression | Recurring reminders, scheduled summaries, one-time future tasks | Ask nanobot in the target topic to schedule it with the `cron` tool | -| Local trigger | A local `nanobot trigger ...` command | CI jobs, webhooks, shell scripts, generated reports | `/trigger ` in the target topic | -| Heartbeat | Protected system schedule | Quiet recurring checks that should only report useful results | Edit `/HEARTBEAT.md` | - -The two user-created automation types are scheduled automations and local triggers. Heartbeat uses the same background service but is system-managed and protected from normal automation edits. - -## Before You Create One - -Keep the gateway running. Your WebUI or TUI already uses one; you do not need a second gateway. To keep it alive after closing interactive launchers, run `nanobot gateway --background` with the same instance selectors, or use `/detach` in the TUI. The gateway owns background delivery for chat apps, WebUI topics, scheduled automations, local triggers, heartbeat, and Dream jobs. - -Use the same workspace and config for the gateway and any process that sends local trigger messages. If you run multiple nanobot instances, pass the matching `--config` or `--workspace` option to `nanobot trigger`. - -Create each automation from the target topic. An automation without a linked topic cannot be enabled or run from the WebUI because nanobot would not know where to deliver the turn. +| **Scheduled automation** | A time, interval, or cron schedule | Reminders, daily reports, one-time future tasks | Ask nanobot in the target chat | +| **Local trigger** | Running `nanobot trigger ...` from a script or webhook | CI failures, local scripts, external event alerts | Send `/trigger ` in the target chat | +| **Heartbeat** | Built-in periodic check | Quiet background monitoring that only messages you when action is needed | Edit `/HEARTBEAT.md` | ## Scheduled Automations -Scheduled automations are created by the agent's `cron` tool. In practice, ask nanobot from the target chat or WebUI topic: +To create a scheduled task, just ask nanobot in the chat where you want the results delivered: ```text Every weekday at 9am, check open pull requests and summarize blockers here. ``` -or: - ```text Tomorrow at 4pm, remind me to send the release notes. ``` -The cron tool supports interval schedules, cron expressions, and one-time scheduled tasks. Cron expressions can include an IANA timezone such as `America/Vancouver`; otherwise nanobot uses the runtime default timezone. +- **Schedules:** Supports one-time dates, recurring intervals, and cron expressions (with optional IANA timezones like `America/Vancouver`). +- **Delivery:** By default, nanobot sends the final reply back to the chat where the task was created—you do not need to mention a chat ID or channel name. If you want a task to send to additional chats or recipients, say so explicitly in the instructions. +- **Edit, pause, or inspect runs:** You can manage tasks right in chat—for example, *"Move my daily report from 9am to 10am"*, *"Pause my daily report"*, or *"Show the last five runs of my daily report"*—or use the WebUI **Automations** view. -Scheduled automations normally deliver the result back to the session where they were created. Use them for work that should run on a predictable schedule and report each run. +### Change the chat for a scheduled task -Write what the task should do, such as "Remind me to drink water". nanobot sends the final reply to the task's saved chat. You do not need to put a channel, chat ID, or a `message` tool call in the instructions for that reply. +To move a scheduled task to a different chat: -For separate sends, specify the recipients in the instructions. The agent can still use `message` to send to other chats, send to several recipients, or attach files. Existing tasks that explicitly request this tool remain supported. +1. Open the task in WebUI **Automations**. +2. Pick a new destination under **Run and reply in** (chat-app destinations appear once their channel is running and nanobot has received a message there). +3. Review the task instructions—click **Edit instructions** if you need to update any hardcoded destination text. +4. Click **Confirm change** (or **Save and change**). -Writing "send to WhatsApp" in the instructions does not change the task's saved chat. Its normal reply still returns to that chat. A separate send requires the agent to call `message` with the other destination. For a fixed destination, create the task in that chat or use [Change the Chat for a Scheduled Task](#change-the-chat-for-a-scheduled-task). Keep explicit `message` instructions when you want separate sends or several recipients. - -If a result does not arrive, check that the task finished, then check its saved chat and destination. For a separate send, review the run's `message` calls and the gateway's channel send errors. `Turn completed` means the task finished; it does not confirm that the chat service delivered the message. A successful `message` result means nanobot accepted it for sending, not that it arrived. Check the destination before trying again to avoid duplicates. - -For background checks that should stay quiet unless there is something useful to report, use heartbeat instead of a user-created scheduled automation. - -Repetition alone does not select heartbeat. "Every day at 8am, remind me to drink water" needs a cron schedule. "Keep an eye on open issues and tell me when one needs attention" can use heartbeat if the check time is flexible. Heartbeat does not guarantee a requested time or interval. - -An upgrade does not overwrite your workspace's `AGENTS.md` or convert existing heartbeat entries into cron jobs. The current scheduling rules are included in the system prompt. If an old workspace rule directs all recurring tasks to heartbeat, update that rule too. To correct an existing reminder, remove its old heartbeat entry and create the cron task once. Check the task list to avoid duplicates. - -### Change a Scheduled Task - -Ask nanobot, "Move my daily report from 9am to 10am." The agent can use `cron(action="update", job_id="...", cron_expr="0 10 * * *")` without deleting and recreating the task. It can also update `name` or `message` independently. Supply one complete schedule when changing its timing; omitted fields keep their values. Cron edits retain the existing timezone unless another `tz` is supplied with the expression. Naive `at` values use the runtime default timezone. - -The task keeps its ID, linked chat, execution history, enabled state, and automatic-deletion setting. A paused task stays paused. Changing only the name or instruction preserves the next run time. Existing tasks configured to delete after a one-time run still do so; tasks configured to remain keep that behavior. System-managed tasks remain protected. Invalid updates leave the task unchanged. - -### Pause and Resume a Scheduled Task - -Ask nanobot to pause a scheduled task instead of removing it. The agent can use `cron(action="disable", job_id="...")`, then `cron(action="enable", job_id="...")` to resume it with the same ID, schedule, chat, and run history. Use `cron(action="list", include_disabled=True)` to find paused tasks; the default list still shows only enabled jobs. - -Disabling affects future runs. It does not cancel a running task or recall an already queued result. System-managed heartbeat and Dream jobs remain protected; change their configuration instead. - -### Inspect Recent Runs - -Ask nanobot, "Show the last five runs of my daily report." The agent can use `cron(action="history", job_id="...", limit=5)` to read the retained execution time, status, duration, and error for that task. Results are newest first, using the task's timezone or the runtime default. The default is five records; `limit` accepts 1–20. - -This also works for disabled tasks and does not change their schedule or state. Only retained execution records are available: deleted jobs and automatically deleted one-time tasks cannot be queried. Run history does not include the generated reply or confirm message delivery. - -### Scheduled Result Delivery - -The gateway saves final scheduled messages before it accepts them into the outgoing queue. This includes explicit `message` calls in existing tasks. Each recipient has a separate delivery record. Progress, reasoning, and streaming events do not enter this queue. WebUI streaming and saved chat history keep their existing behavior. External channels receive a complete scheduled reply instead of a streamed reply. Ordinary chat streaming is unchanged. - -The queue cannot recover a send that the agent never requested. If an expected recipient has no delivery record, check the task's saved chat and the run's `message` calls first. - -If a channel reports that it has not sent any part of a message, the gateway retries every 30 seconds, for up to one hour after queue acceptance. It sends the saved message to the saved destination. It does not run the task or call the model again. A gateway restart resumes pending messages. Deleting or resetting the source chat cancels pending messages from that chat generation. Disabling a channel prevents its pending messages from being sent. Changing, pausing, or deleting a task affects future runs; it does not redirect or recall an already queued result. - -If a request times out after sending starts, or the gateway stops during a send, delivery is unknown. The gateway does not retry that message automatically: the service might already have accepted it. Check the destination before sending the result again. This is not an exactly-once delivery guarantee. Adapter or service-specific retries still follow their own protocol. - -Look for `Channel delivery` in the gateway log. The run ID links execution to each delivery ID: - -| Status | Meaning | -|---|---| -| `pending` | Saved locally; waiting for an attempt or a channel connection | -| `sent` | The channel adapter completed its send; not a recipient read receipt | -| `failed` | Not sent: expired, disabled channel, replaced source chat, or rejected destination/policy | -| `unknown` | An interrupted or failed attempt might have reached the service; no automatic retry | - -The queue is stored in `delivery/outbox.sqlite3`, beside the active config file. Include this directory in instance backups; stop the gateway before copying it. It holds at most 256 pending messages, with a 1 MiB serialized limit per message. A full queue or storage error rejects the enqueue operation instead of reporting it as accepted. Terminal records discard message text and keep status for up to seven days, capped at 1,000 records. Existing job and session files are not converted. Older versions ignore this queue. After an upgrade, pending messages can resume only within the original one-hour limit. +Future runs will use the new chat's history and reply there. Previous messages stay in the original chat. Note that members of the new chat will see future results, and moving a task does not isolate workspace files or shared memory. ## Local Triggers -Local triggers let a local script or external service send a message into a specific nanobot session later. +Local triggers let a shell script, CI job, or external webhook wake nanobot inside a specific chat. -Create the trigger from the chat or WebUI topic where future messages should arrive: +1. In the target chat or WebUI topic, create a trigger: ```text /trigger PR review ``` -nanobot replies with a trigger ID and a command shaped like: +2. nanobot replies with a trigger ID and ready-to-use command: ```bash nanobot trigger trg_8K4P2Q9X "Review PR #4502" ``` -Replace the quoted text with the message nanobot should receive. For generated or longer content, pipe stdin: +3. Run that command whenever an event happens, or pipe longer output through stdin: ```bash generate-report | nanobot trigger trg_8K4P2Q9X ``` -For multiple instances, use the same config or workspace selector as the gateway: +If you run multiple nanobot instances, pass the same `--config` or `--workspace` (your configured agent workspace) used by that gateway: ```bash -nanobot trigger --config ./bot-a/config.json trg_8K4P2Q9X "Nightly report" nanobot trigger --workspace ./bot-a/workspace trg_8K4P2Q9X "Nightly report" ``` -nanobot does not provide a built-in public webhook receiver for local triggers. If GitHub, CI, or another external system should wake nanobot, run your own small webhook service and have it call `nanobot trigger` after it builds the final message. +> [!NOTE] +> nanobot does not expose a public webhook server for local triggers. To connect GitHub, CI, or another external service, have your own small webhook receiver call `nanobot trigger`. ## Heartbeat -Heartbeat is for recurring workspace checks that should usually stay quiet. It reads `/HEARTBEAT.md`, executes active tasks, and sends only useful or actionable results to the most recently active chat target. +Use **Heartbeat** for recurring checks that should stay silent unless something needs your attention—for example, watching a repo for failures or scanning an inbox for urgent messages. (Use a scheduled automation instead when you want a reminder at a specific time every day.) -Use heartbeat for checks such as "watch this repo for important failures" or "periodically inspect this workspace and only tell me when action is needed." Use a scheduled automation instead when every run should produce a visible reminder or report. +Edit `~/.nanobot/workspace/HEARTBEAT.md` (or ask nanobot to add a periodic check): -Heartbeat is enabled by default when `nanobot gateway` starts. Configure it in [`configuration.md#gateway-heartbeat`](./configuration.md#gateway-heartbeat). +```markdown +## Active Tasks -## Manage Automations +- Check weather forecast and notify me only if storms are expected +- Scan inbox for urgent emails and notify me if any are found +``` -Use the WebUI Automations view to: +Heartbeat is enabled by default while `nanobot gateway` is running and sends actionable results to your most recently active chat. Configure its interval or disable it in [`configuration.md#gateway-heartbeat`](./configuration.md#gateway-heartbeat). -- filter by all, active, paused, needs-attention, or system jobs; -- search by task name, message, trigger command, linked topic, schedule, or status; -- sort by next run, last run, updated time, or name; -- run scheduled automations now; -- pause or resume, rename, or delete user-created automations; -- copy the CLI command for local triggers; -- inspect protected system automations without changing them. +## Manage Automations in WebUI -Local triggers do not have a WebUI "Run now" action because each run needs a message. Copy the `nanobot trigger ...` command from the WebUI and replace `"message"` with the content that should be delivered. +Open **Automations** in the WebUI to: -### Change the Chat for a Scheduled Task +- Filter by all, active, paused, needs-attention, or system jobs. +- Search by name, instructions, chat, schedule, or status (e.g. `chat:WeChat`, `status:paused`). +- Run a scheduled automation immediately, pause/resume it, rename it, or delete it. +- Copy the `nanobot trigger ...` command for a local trigger. -Open a scheduled task in **Automations**. **Run and reply in** shows its saved chat, with the channel logo and name. WebUI chats use the same display names as the sidebar. A renamed chat keeps its identity and task binding. Chats with the same name show an `@handle` to help you tell them apart. - -To change the chat: - -1. Select another chat from **Run and reply in**. -2. Review the task instructions, which are read-only by default. If they need changes, select **Edit instructions**. Remove recipients you no longer want, but keep intended separate sends. Members of the new chat can see future task messages and results. -3. Select **Confirm change**. Wait for the saved confirmation. - -If you edit the instructions, the button becomes **Save and change**. Both changes are saved together; nothing is saved when you select **Edit instructions**. To change the task name or schedule, use **Edit** in the task details instead. - -Select **Cancel** before saving to return to the task without changes. After a successful save, select **Change back to** to review a return to the previous chat. You must confirm this change too. You can also select a previous chat from the list later. This changes future runs; it does not recall messages already sent. - -Future runs use the new chat's history and reply there by default. Previous messages stay in their original chat. Previous run results remain available. Changing the chat does not run the task, enable it, or change its schedule. - -You can discuss each new result in that same chat. Background task results also return there. If you delete that chat, nanobot asks you to confirm deletion of its scheduled tasks as well. Cancelling the deletion keeps the chat and tasks. - -The list shows chats available on this gateway that use the same workspace and access permissions. A chat-app destination appears only after its channel is running and nanobot has received a message there. If the chat you want is missing, first send nanobot a message in that chat, then confirm its channel is running. You cannot choose a raw recipient ID, a chat on another host, a system job, or a local trigger. Older gateway versions show this list as read-only. - -If a scheduled turn is running or queued, wait for it to finish before changing the chat. The current scheduler also rejects a change while another scheduled turn is active. If another editor changes the task, reopen the task and review the latest instructions. A rejected save leaves the draft visible. - -This changes the whole task chat, not a separate forwarding address. Explicit `message` tool instructions can still send elsewhere. Shared workspace files and memory remain shared; changing the chat does not create a new security boundary. The confirmation screen lets you edit instructions such as "send to the original chat" before you save. nanobot does not silently rewrite those instructions. - -### Back Up Before Downgrading - -Chat changes store a binding version and the session used by each previous run. Existing jobs do not need a manual migration when upgrading. Older nanobot versions can discard these new fields when they write the cron store. After a chat change, that can make old run results unavailable in the WebUI and remove protection against stale CLI updates. - -Before trying this feature, stop the gateway and other cron writers, then back up the complete `cron/` directory in the configured agent workspace (`~/.nanobot/workspace/cron/` by default), including `jobs.json` and `runs/`. For a downgrade after changing a chat, stop those processes again and restore that coherent pre-change cron backup. This also restores the old schedules and task settings; later changes are not included. Chat messages are not moved or deleted. +Protected system jobs (such as Heartbeat and Dream) appear as read-only. ## Delivery and Reliability -Automation storage and queue delivery belong to the gateway's configured agent workspace. Scheduled and triggered turns linked to WebUI/TUI chats use the chat's saved project context and access mode; chat-app turns use the gateway's configured workspace. The selected project can differ from the agent workspace that stores jobs, memory, and queues. Starting the TUI inside a project selects that project for the chat but does not by itself create a separate gateway instance. Select the matching configured agent workspace when invoking `nanobot trigger --workspace`, not merely the project directory. See [Multiple Instances](multiple-instances.md) when these need to be separate. +Keep these behaviors in mind when relying on automations: -Schedules do not replay missed occurrences after a gateway restart: - -| Schedule | Behavior after restart | -|---|---| -| One-time (`at`) | A time already in the past has no next run and is not automatically executed. Review the task and run it manually or create a replacement. | -| Interval (`every`) | If the next run is still in the future and no more than one interval away, nanobot keeps that time. If it has already passed, that run is skipped and the next run is scheduled; missed runs are not replayed. | -| Cron expression | The next matching time after restart is used; missed matches are not replayed. | - -Intervals are also recalculated after a run finishes, so a long-running task can shift its next interval. Use a cron expression for wall-clock scheduling, and keep the host awake and gateway running when timing matters. These rules concern scheduled jobs; queued local trigger messages have the separate recovery behavior below. - -Local trigger messages are written to a durable queue. If the gateway is not running yet, the message waits in that workspace. If the linked topic is already running a turn, the trigger waits until the session becomes idle instead of being injected into the active turn. - -The local trigger queue is at-least-once, not exactly-once. If the gateway exits after claiming a delivery but before the linked turn completes, the next gateway start requeues that delivery. External scripts should make repeated trigger messages safe. If the delivery reaches the agent and the turn fails, the delivery is marked failed instead of retrying forever. - -Each local trigger delivery writes an audit record under `/triggers/runs`. Run one gateway consumer per workspace; the local queue is not a distributed multi-consumer queue. - -## Common Patterns - -For a nightly report, ask from the target topic: - -```text -Every night at 9pm, review today's workspace changes and summarize anything I should handle tomorrow. -``` - -For a CI follow-up, create a trigger once: - -```text -/trigger CI follow-up -``` - -Then have your CI or webhook adapter call: - -```bash -nanobot trigger "Build failed on main. Inspect the logs and suggest the next fix." -``` - -For a local report script: - -```bash -generate-report | nanobot trigger -``` +- **Missed schedules after downtime:** If the gateway was stopped during a scheduled time, nanobot does **not** replay missed runs when it restarts. Recurring schedules simply wait for their next future run; one-time tasks in the past will not run automatically. +- **Exact clock times:** Use a cron expression (not an interval) when exact wall-clock timing matters, since intervals recalculate after a run finishes. +- **Retry on channel failure:** If a chat app is temporarily unreachable before a scheduled reply is sent, the gateway automatically retries for up to one hour (without re-running the model). If a send times out mid-flight, nanobot will not auto-retry to avoid duplicate messages—check the destination first. +- **Local triggers:** Trigger messages wait in a durable workspace queue if the gateway is offline or if the target chat is busy. Delivery is **at-least-once** (a restart mid-run can replay a trigger), so external scripts should tolerate duplicate messages safely. ## Troubleshooting -If an automation does not run, check that `nanobot gateway` is running, the automation is enabled, and it was created from a linked topic. - -If a local trigger waits forever, confirm the command uses the same workspace or config as the gateway. - -If a trigger message appears twice after a restart, treat it as expected at-least-once delivery and make the external message idempotent. - -If you need to edit, pause, resume, rename, delete, or inspect automations, use the WebUI Automations view. +- **Automation never runs:** Confirm `nanobot gateway` is running, the automation is enabled, and it is linked to a chat. +- **Local trigger sits waiting:** Make sure `nanobot trigger` uses the same `--config` or `--workspace` as the running gateway. +- **Scheduled message did not arrive:** Check the task's run history in **Automations** and `nanobot gateway logs` for channel errors. ## Related Docs -- [`webui.md#automations`](./webui.md#automations) for the browser management view -- [`chat-commands.md#local-triggers`](./chat-commands.md#local-triggers) for `/trigger` -- [`cli-reference.md#local-triggers`](./cli-reference.md#local-triggers) for `nanobot trigger` -- [`configuration.md#gateway-heartbeat`](./configuration.md#gateway-heartbeat) for heartbeat settings -- [`guides/long-running-ai-agent.md`](./guides/long-running-ai-agent.md) for long-running agent work +- [WebUI Automations](./webui.md#automations) +- [In-Chat Commands: Local Triggers](./chat-commands.md#local-triggers) +- [CLI Reference: Local Triggers](./cli-reference.md#local-triggers) +- [Configuration: Heartbeat](./configuration.md#gateway-heartbeat) +- [Long-Running AI Agent Guide](./guides/long-running-ai-agent.md) diff --git a/docs/chat-commands.md b/docs/chat-commands.md index 9362379ff..8d1ccffb2 100644 --- a/docs/chat-commands.md +++ b/docs/chat-commands.md @@ -1,68 +1,53 @@ # In-Chat Commands -These commands work inside chat channels and interactive agent sessions: +Use these slash commands inside the WebUI, terminal chat, or connected chat apps: | Command | Description | |---------|-------------| -| `/new` | Stop current task and start a new conversation | +| `/new` | Stop the current task and start a new conversation | | `/compact` | Summarize the current conversation context while keeping saved chat history | | `/stop` | Stop the current task without cancelling its saved goal | | `/goal ` | Start a sustained goal for this conversation | -| `/cancel_goal` | Cancel the active or blocked goal; also stop work on an active goal | +| `/cancel_goal` | Cancel the active or blocked goal (also stops work on an active goal) | | `/restart` | Restart the bot | | `/status` | Show bot status | | `/model` | Show the current model and available model presets | -| `/model ` | Switch and persist the model preset for the current session | +| `/model ` | Switch and save the model preset for this conversation | | `/dream` | Run Dream memory consolidation now | | `/dream-log` | Show the latest Dream memory change | | `/dream-log ` | Show a specific Dream memory change | | `/dream-restore` | List recent Dream memory versions | | `/dream-restore ` | Restore memory to the state before a specific change | -| `/dream-prompt` | Show how Dream is being guided for memory | -| `/dream-prompt init` | Create an editable Dream memory guide at `prompts/dream.md` | +| `/dream-prompt` | Show how Dream is guided for memory | +| `/dream-prompt init` | Create an editable Dream guide at `prompts/dream.md` | | `/skill` | List enabled skills and their descriptions | -| `/trigger` | Show local trigger usage | -| `/trigger ` | Create a named local trigger for the current chat/session | +| `/trigger ` | Create a named local trigger for the current chat | | `/pairing` | List pending pairing requests | | `/pairing approve ` | Approve a pairing code | | `/pairing deny ` | Deny a pending pairing request | -| `/pairing revoke ` | Revoke a previously approved user on the current channel | -| `/pairing revoke ` | Revoke a previously approved user on a specific channel | -| `/help` | Show available in-chat commands | +| `/pairing revoke ` | Revoke an approved user on the current channel | +| `/pairing revoke ` | Revoke an approved user on a specific channel | +| `/help` | Show available commands | -## Commands and file paths +## Commands and File Paths -The gateway treats a message as a command only when its first word matches a registered command name. Names are case-insensitive. Arguments must follow the command's supported form. +Only recognized command names (case-insensitive) are handled as commands. Anything else—including file paths like `/tmp` or `/Users/alice/report.md`—is sent to the agent normally. If a folder happens to match a command name (like `/new`), add a trailing slash (`/new/`) or write it in a sentence (`Look at /new`). -Other text goes to the agent unchanged. This includes `/tmp`, `/home/user/project`, and `/Users/alice/report.md`. Unknown names such as `/neaw` also go to the agent; the gateway no longer returns a spelling suggestion. Use `/help` or the command menu to find a command. - -In the WebUI, Enter queues ordinary text while a response is running. Paths follow the same rule. Registered commands still go to the gateway immediately. If the command list is unavailable, slash-prefixed input goes to the gateway immediately, so commands such as `/stop` do not wait in the queue. - -A path can have the same name as a command. For example, `/new` starts a new conversation. To discuss that directory, write `/new/` or `Look at /new`. Chat platforms can apply their own command rules before a message reaches the gateway. +In the WebUI, recognized commands run immediately even while a reply is in progress (so `/stop` does not wait in the queue). ## Pairing -When someone sends a DM to the bot and isn't on the allowlist — whether it's a new user or an existing user on a new channel — nanobot automatically replies with a **pairing code** (like `ABCD-EFGH`) that expires in 10 minutes. To grant them access: +When an unapproved user sends a DM on a pairing-enabled chat app, nanobot replies with a short **pairing code** (such as `ABCD-EFGH`) that expires in 10 minutes. Approve them from any authorized chat or in the WebUI: ```text /pairing approve ABCD-EFGH ``` -To see who's waiting, use `/pairing`. To remove someone later, use `/pairing revoke ` — you can find user IDs in the `/pairing list` output. - -See [Configuration: Pairing](./configuration.md#pairing) for the full setup guide. +Use `/pairing` to see pending requests and `/pairing revoke ` to remove access later. See [Configuration: Pairing](./configuration.md#pairing) for setup options. ## Model Presets -Use `/model` to inspect the current runtime model: - -```text -/model -``` - -The response shows which model this conversation is using and the names of models you can switch to. `default` is also available and uses the instance's default model settings. - -To switch presets for future turns: +Run `/model` to see your active model and available presets, or switch presets for the current conversation: ```text /model fast @@ -70,62 +55,37 @@ To switch presets for future turns: /model default ``` -Switching changes the model used for future replies in this conversation and keeps that choice for later turns, including after a restart. It does not change other conversations or interrupt a reply already in progress. To add or configure model choices, see [Configuration: Model presets](./configuration.md#model-presets). +Switching persists for future turns in this conversation (even across restarts) without affecting other conversations or interrupting a reply in progress. To add presets, open **Settings → Models** or see [Configuration: Model presets](./configuration.md#model-presets). ## Goals -Only you can cancel a goal: use `/cancel_goal`, or expand the goal in WebUI and select **Cancel goal**. Cancelling an active goal also stops its work; cancelling a blocked goal leaves unrelated replies running. Chat history is kept. Asking the agent to stop can block the goal, but does not cancel it. +Use `/goal ` to start a sustained goal. Only you can cancel a goal—either run `/cancel_goal` or expand the goal in the WebUI and click **Cancel goal**. Cancelling an active goal stops its work while keeping chat history; cancelling a blocked goal leaves unrelated replies running. -## Local triggers +## Local Triggers -Use `/trigger ` when a local script or another service should be able to send a message into the current chat/session later. A name is required; plain `/trigger` only shows the usage hint. - -Create the trigger from the chat where future messages should arrive: +Create a local trigger inside the chat where future messages should appear: ```text /trigger PR review ``` -nanobot replies with a trigger ID and a command shaped like: +nanobot replies with a trigger ID and CLI command: ```bash nanobot trigger trg_8K4P2Q9X "Review PR #4502" ``` -Replace `"Review PR #4502"` with the message you want nanobot to receive. The trigger is bound to the session where it was created, so the message goes back to that same chat. Keep `nanobot gateway` running so trigger messages can be delivered. The trigger message starts an automation turn recorded in that session with the message you passed to the CLI; it is not treated as a normal user message. If that session is already running a turn, the trigger waits until the session is idle instead of being injected into the active turn. - -Trigger deliveries are stored in the workspace until their linked agent turn finishes successfully. If the gateway exits after claiming a delivery but before the turn completes, the next gateway start requeues that delivery. This is an at-least-once local queue: a delivery may run more than once if the process exits at the wrong time, so external scripts should make repeated trigger messages safe. If the delivery reaches the agent and the agent turn fails, the delivery is marked failed in Automations instead of retrying forever. - -For longer or generated content, omit the message argument and pipe stdin: +You can also pipe longer content from a script: ```bash printf '%s\n' "Review the latest failed CI job" | nanobot trigger trg_8K4P2Q9X ``` -If an external webhook should wake nanobot up, run your own small webhook service and have it call the trigger command after it builds the final message: +For multiple instances, pass the same `--config` or `--workspace` used by the running gateway. Keep `nanobot gateway` running so trigger messages can be delivered. Manage existing triggers in the WebUI **Automations** view, and see [Automations](./automations.md) for delivery behavior and examples. -```bash -nanobot trigger "" -``` +## Periodic Tasks (Heartbeat) -If you run multiple nanobot instances, pass the same config or workspace selector used by the gateway: - -```bash -nanobot trigger --config ./bot-a/config.json trg_8K4P2Q9X "Nightly report" -nanobot trigger --workspace ./bot-a/workspace trg_8K4P2Q9X "Nightly report" -``` - -Manage triggers from the WebUI Automations view. You can search, pause/resume, rename, delete, and copy the trigger command there. A session may have multiple triggers, just like it may have multiple scheduled automations. - -See [Automations](./automations.md) for how local triggers fit with scheduled automations, heartbeat, and gateway delivery. - -## Periodic Tasks - -Periodic background checks are driven by `HEARTBEAT.md` in your workspace (`~/.nanobot/workspace/HEARTBEAT.md`). When `nanobot gateway` starts, it registers a protected heartbeat cron job by default. Every 30 minutes, that job checks the file; if it finds tasks under `## Active Tasks`, the agent executes them and delivers only results that pass the notification gate to your most recently active chat channel. If there are no active tasks, or the result is routine with nothing useful to report, the heartbeat is skipped silently. - -Use heartbeat for recurring checks that should usually stay quiet. User-created cron jobs are different: they run as scheduled turns in the chat/session where they were created and normally deliver the result back to that channel. - -**Setup:** edit `~/.nanobot/workspace/HEARTBEAT.md` (created automatically by `nanobot onboard`): +Heartbeat runs quiet background checks from `~/.nanobot/workspace/HEARTBEAT.md` every 30 minutes while `nanobot gateway` is running, and only messages you when something needs attention. Add tasks under `## Active Tasks` (or ask nanobot to add one for you): ```markdown ## Active Tasks @@ -134,21 +94,4 @@ Use heartbeat for recurring checks that should usually stay quiet. User-created - Scan inbox for urgent emails and notify me if any are found ``` -The agent can also manage this file itself - ask it to "add a periodic background check" or "check this periodically but only notify me if something changes" and it will update `HEARTBEAT.md` for you. Completed tasks should be deleted from the file, not moved to another section. - -You can change the interval or disable the built-in heartbeat in `~/.nanobot/config.json`: - -```json -{ - "gateway": { - "heartbeat": { - "enabled": true, - "intervalS": 1800 - } - } -} -``` - -The heartbeat job is visible in `cron(action="list")` as `heartbeat`, but it is system-managed and cannot be removed with the `cron` tool. To stop it, set `gateway.heartbeat.enabled` to `false` and restart the gateway. - -> **Note:** The gateway must be running (`nanobot gateway`) and you must have chatted with the bot at least once so it knows which channel to deliver to. +Remove completed tasks from the file when they are no longer needed. To change the interval or disable heartbeat, see [Configuration: Heartbeat](./configuration.md#gateway-heartbeat). diff --git a/docs/concepts.md b/docs/concepts.md index e0782d6a9..94a281d95 100644 --- a/docs/concepts.md +++ b/docs/concepts.md @@ -1,99 +1,75 @@ # Concepts -Use this page when you want to understand nanobot before changing advanced settings. It explains the moving parts without requiring you to read the source first. +This page explains how nanobot's main pieces fit together in plain language, so you can configure models, workspaces, memory, and automations with confidence. -If you want source-file ownership and extension points, read [`architecture.md`](./architecture.md) after this page. +For source-code structure and contributor details, see [Architecture](./architecture.md). -## Runtime Shape +## Main Building Blocks -nanobot has one small core loop and several ways to enter it: +```mermaid +flowchart LR + U["WebUI / Terminal / Chat Apps"] --> G["Gateway"] + G --> A["Agent"] + A --> P["AI Provider"] + A --> T["Tools (Files, Shell, Web, MCP)"] + A --> M["Workspace & Memory"] +``` | Part | What it does | |---|---| -| Agent | Takes an incoming message, chooses the conversation and model, uses enabled tools when needed, and prepares a reply | -| Providers | LLM backends such as OpenRouter, Anthropic, OpenAI, Bedrock, Ollama, vLLM, and other OpenAI-compatible APIs | -| Channels | User-facing transports such as CLI, WebUI/WebSocket, Telegram, Discord, Slack, Feishu, WeChat, Email, Mattermost, and others | -| Tools | Capabilities the model may call, including files, shell, web search/fetch, MCP, cron, image generation, and subagents | -| Memory | Workspace files and session history that keep useful context across turns | -| Gateway | Long-running process that connects enabled channels and serves the health endpoint | +| Agent | Reads your message and conversation context, runs enabled tools when needed, and writes the reply | +| Providers | AI services or local servers (OpenRouter, Anthropic, OpenAI, Bedrock, Ollama, vLLM, and more) | +| Channels | Ways to talk to nanobot: WebUI, terminal (CLI/TUI), Telegram, Discord, Slack, Feishu, WeChat, Email, Mattermost, Linear, and others | +| Tools | Capabilities the agent can use, such as files, shell commands, web search, MCP servers, image generation, automations, and subagents | +| Memory | Saved conversation history and long-term workspace notes that carry context forward | +| Gateway | The background service that keeps the WebUI, chat apps, and automations running | -To test nanobot once, run `nanobot agent -m "Hello!"`; it prints a reply in your terminal. To keep nanobot running, start `nanobot gateway`. It receives messages from enabled chat apps or the WebUI and sends replies back to the same conversation. +To send a single test message, run `nanobot agent -m "Hello!"`. For everyday use with the WebUI, chat apps, or scheduled tasks, nanobot runs the gateway in the background. ## Config vs Workspace -The default instance lives under `~/.nanobot/`: +By default, everything lives under `~/.nanobot/`: -| Path | Meaning | +| Path | What it stores | |---|---| -| `~/.nanobot/config.json` | Instance configuration: providers, model defaults, channels, tools, gateway, API, and runtime options | -| `~/.nanobot/workspace/` | Agent workspace: memory, heartbeat tasks, cron jobs, skills, and generated artifacts | -| `~/.nanobot/sessions//` | Session history stored outside the agent-accessible workspace; the opaque ID follows workspace moves | +| `~/.nanobot/config.json` | Settings: providers, model presets, channels, tools, and security options | +| `~/.nanobot/workspace/` | Agent state: long-term memory, skills, `HEARTBEAT.md`, automations, and generated files | +| `~/.nanobot/sessions/` | Saved conversation history (stored separately from the workspace) | -You can override both with command flags: - -```bash -nanobot onboard --config ./bot-a/config.json --workspace ./bot-a/workspace -nanobot agent --config ./bot-a/config.json --workspace ./bot-a/workspace -m "Hello" -nanobot gateway --config ./bot-a/config.json --workspace ./bot-a/workspace -``` - -The config file controls what nanobot may use. The workspace is where nanobot keeps state for that instance. +The **config file** controls what nanobot is allowed to use. The **workspace** holds the agent's durable state. You can point commands at a different config or workspace with `--config` and `--workspace` (or `--home`; see [Multiple Instances](./multiple-instances.md)). ### Agent Workspace and Project Workspace -The configured workspace is the **agent workspace**. A WebUI chat can also select a different **project workspace** for repository-specific work without moving the agent's identity or durable state. +Your configured workspace is the **agent workspace**. In the WebUI, you can also pick a different **project workspace** (such as a code repository) for a specific topic without changing your agent's identity or memory: -| Resource | Owner when a project is selected | +| What | Comes from | |---|---| -| Project instructions | `AGENTS.md` from the selected project; there is no fallback to the agent workspace's `AGENTS.md` | -| Agent profile | `SOUL.md` and `USER.md` from the agent workspace; project-local files with those names are ignored | -| Memory and custom skills | `memory/` and `skills/` from the agent workspace | -| Relative file paths and shell working directory | The selected project workspace | +| Project instructions (`AGENTS.md`) | The selected project folder | +| Agent personality and user profile (`SOUL.md`, `USER.md`) | The agent workspace | +| Long-term memory and custom skills (`memory/`, `skills/`) | The agent workspace | +| Relative file paths and shell commands | The selected project folder | -When no separate project is selected, one directory normally serves both roles. Selecting a project changes the working context for that chat; it does not create a second agent or relocate the configured agent workspace. +When you do not pick a separate project, both roles use the same directory. Picking a project changes where the agent works for that topic; it does not create a separate agent or separate memory. -## Config Format +## Entry Points: CLI, WebUI, and Gateway -`config.json` accepts both camelCase and snake_case keys. The docs use camelCase because nanobot writes config back to disk with camelCase aliases, for example `apiKey`, `modelPresets`, `intervalS`, and `maxToolResultChars`. - -Most examples are partial snippets. Merge them into the existing file created by `nanobot onboard`; do not replace the whole file unless you want to reset the instance. - -## One Agent Turn - -A normal turn follows this flow: - -1. The CLI, WebUI, or a connected chat app receives your message. -2. nanobot uses the conversation's history and the files available to that chat to prepare the request. -3. Your selected AI service generates a response. If it needs an enabled tool, nanobot runs that tool and returns the result to the model. -4. nanobot saves the reply in the conversation and shows or sends it through the same app or channel. - -That flow is the same whether the message starts in the CLI, WebUI, Telegram, Discord, or another channel. - -## CLI, Gateway, API, and WebUI - -| Entry point | Command | Use it for | +| Entry point | Command | Best for | |---|---|---| -| CLI one-shot | `nanobot agent -m "..."` | First-run checks, scripts, and quick local questions | -| CLI interactive | `nanobot agent` | Terminal chat with persistent session history | -| Gateway | `nanobot gateway` | Chat apps, WebUI, heartbeat, Dream, and long-running service mode | -| WebUI | `nanobot webui` | Prepare the local WebUI, start the gateway, and open the browser workbench | +| One-shot CLI | `nanobot agent -m "..."` | Quick checks, scripts, and troubleshooting | +| Interactive CLI / TUI | `nanobot` (or `nanobot agent`) | Terminal chat with saved session history | +| WebUI | `nanobot webui` | Everyday browser workbench (starts the gateway automatically) | +| Gateway | `nanobot gateway` | Headless servers, chat apps, and background automations | -The WebUI launcher is the normal browser entry point. Underneath, the gateway keeps the WebSocket channel and other long-running services alive. The gateway health endpoint is on `gateway.port` (`18790` by default); the browser WebUI is served on `8765` by default, not by the health endpoint. +The WebUI runs on port `8765` by default (`http://127.0.0.1:8765`). The gateway health check runs on port `18790` (`http://127.0.0.1:18790/health`). -## Provider and Model Selection +## Providers and Model Presets -Choose and configure the primary model in **Settings → Models**, then select its preset in the chat composer. The config-file example below is an alternative for deployment-managed settings. +Configure your providers and models in **Settings → Models**, then pick a preset from the chat composer. -The active model should normally come from a named `modelPresets` entry selected by `agents.defaults.modelPreset`. Direct `agents.defaults.provider` and `agents.defaults.model` still form the implicit `default` preset for older or minimal configs. The active provider is resolved in this order: - -1. If the active preset provider or implicit default provider is not `"auto"`, nanobot uses that provider. -2. If provider is `"auto"`, nanobot tries to infer the provider from the model name, configured API keys, local provider base URLs, or gateway providers. -3. OAuth providers such as OpenAI Codex and GitHub Copilot require explicit login and explicit provider/model selection inside the active preset. - -Pin the provider inside the preset when setting up for the first time. It is easier to debug: +A **model preset** pairs a provider with a model ID (and optional settings). Pinning the provider explicitly inside each preset is the easiest way to avoid setup mistakes. OAuth providers (such as OpenAI Codex, xAI Grok, and GitHub Copilot) require signing in first and selecting that provider in your preset.
-Manual configuration +Manual configuration example ```json { @@ -113,88 +89,68 @@ Pin the provider inside the preset when setting up for the first time. It is eas
-See [`providers.md`](./providers.md) for practical examples and [`configuration.md#providers`](./configuration.md#providers) for the full provider reference. +See [Providers and Models](./providers.md) and the [Provider Cookbook](./provider-cookbook.md) for provider-specific setup. -## Channels and Sessions +## Sessions, Memory, and Dream -By default, each channel and chat has its own session and conversation history. The WebUI also supports multiple chats and workspace-scoped metadata for project workspaces. +nanobot separates short-term chat history from long-term memory: -## Memory, Sessions, and Dream +- **Sessions** keep the messages of each conversation. By default, each WebUI topic and each chat-app thread has its own session. +- **Long-term memory** lives in your agent workspace (`SOUL.md`, `USER.md`, `memory/MEMORY.md`, and optional `memory/wiki/` pages). +- **Dream** is a periodic background job that reviews summarized conversations and updates your long-term memory so important preferences and facts carry across topics. -nanobot uses two related stores: +See [Memory](./memory.md) for how memory works and how to inspect or restore it. -| Store | Location | Purpose | -|---|---|---| -| Sessions | `/sessions//sessions.sqlite3` | Recent conversation turns replayed into context | -| Memory | `/memory/MEMORY.md` and `/memory/history.jsonl` | Long-term facts and consolidated history | +## Apps, Plugins, and Skills -Dream is a periodic consolidation job. It reads accumulated history and updates workspace memory so useful context can survive beyond short session replay. +You can extend nanobot from the **Apps** and **Skills** pages in the WebUI: -The configured workspace contains a `.nanobot/workspace-id` file. It contains only an opaque random identifier—never conversation content or credentials. Keep it with workspace backups: it lets nanobot find the same external session namespace after the workspace is renamed, moved, or restored. A live copy opened alongside the original receives a new ID so the two workspaces do not share conversations accidentally. - -See [`memory.md`](./memory.md) for the detailed design. - -## Apps and Agent Plugins - -Agent Plugins are installable packages that help you add and manage capabilities in nanobot. A package can include one or more of these: - -| Part | Role | +| Concept | What it does | |---|---| -| Agent Plugin | Installable package that can bundle skills, MCP servers, or both | -| Skill | Workflow guidance loaded progressively or invoked with `$skill-name` | -| MCP server | Runtime tools exposed to the agent | -| CLI App | Locally managed executable whose adapter is packaged and activated like a plugin | -| Apps | WebUI surface for reviewing and managing these capabilities | +| Agent Plugin | An installable package that bundles skills, MCP servers, or both | +| Skill | Reusable instructions loaded when relevant or invoked with `$skill-name` | +| MCP server | External tools exposed to the agent over Model Context Protocol | +| CLI App | A local command-line tool adapter managed from **Apps** | -Native providers, channels, built-in tools, standalone workspace skills, and directly configured MCP servers keep their existing extension paths. See [`webui.md#apps`](./webui.md#apps) for the user-facing flow and [`configuration.md#agent-plugins-v1`](./configuration.md#agent-plugins-v1) for the package contract. +See [WebUI Apps](./webui.md#apps) and [Skills](./webui.md#skills) to manage them. ## Tools and Safety -nanobot can use built-in tools and tools enabled through Apps. Common tool groups include: +nanobot includes built-in tools for files, shell commands, web search/fetch, image generation, automations, and subagents, plus any tools added through **Apps**. -- file read/write/edit and patching; -- shell execution with configurable sandboxing; -- web search and web fetch with SSRF checks; -- MCP servers; -- cron reminders, local triggers, and heartbeat tasks; -- image generation; -- subagents and runtime self-inspection. - -Security-sensitive controls live in [`configuration.md#security`](./configuration.md#security). For production or shared chat apps, also configure channel access controls such as `allowFrom`, pairing, or WebSocket tokens. +- In the WebUI, use **Restricted** mode to keep file and shell work inside the selected workspace. +- For chat apps, use pairing or `allowFrom` allowlists so only people you approve can talk to your bot. +- For tighter restrictions, sandboxing, and network rules, see [Configuration: Security](./configuration.md#security). ## Subagents -Nanobot can delegate parts of a request to subagents while remaining responsible for the final answer. In the conversation that started the work, you can ask it to check progress, send follow-up instructions, wait for results, or cancel a task. Cancelling one task leaves the others running. A delivered instruction means the subagent received it, not that it has acted on it yet. +nanobot can delegate parts of a complex request to subagents while staying responsible for your final answer. Inside the same conversation, you can ask it to check progress, send follow-up instructions, wait for results, or cancel a specific subtask. -Background tasks return their results to the conversation that started them. Single-turn CLI and SDK calls wait for results when background delivery is unavailable. Tasks that reach their iteration limit are marked incomplete; cancelled, failed, and incomplete tasks retain available partial results. +- Background subtasks report back to the conversation that started them. +- `/stop` stops the current session and its subagents without affecting other sessions (it does not undo file changes already made). +- Subagents belong to their parent conversation: deleting that conversation stops and removes them, and forking does not copy them. +- If the gateway restarts while a subtask is running, unfinished subtasks are marked interrupted with any partial results saved; ask nanobot to start a new task if you want to continue. +- Subagents are not available in WebUI temporary chats. -Use `/stop` to stop the current session and its subagents. Other sessions are unaffected. Some operations may take time to stop, and cancellation does not undo file changes or other actions already taken. +See [Delegated work](./webui.md#delegated-work) for viewing subtasks in the WebUI. -Subagents belong to their original conversation. They do not appear as separate topics or in general conversation searches. Deleting the conversation stops its subagents and removes their saved history; forking it does not copy them. +## Automations and Background Jobs -Saved task history and results remain available after a gateway restart. Unfinished tasks are marked interrupted, with saved partial results when available. Nanobot does not automatically resume them or resend completion notifications; ask it to start a new task to continue the work. +While the gateway is running, nanobot can act on its own in three ways: -See [Delegated work in the WebUI](./webui.md#delegated-work) for progress and task details. WebUI temporary chats do not support subagents. SDK calls with `ephemeral=True` wait for delegated results without saving the temporary conversation or its subagent history. +- **Scheduled automations:** Tasks you ask nanobot to run at a specific time or on a schedule, replying back in the same chat. +- **Local triggers:** Created with `/trigger ` so a local script or webhook can wake nanobot in that chat with `nanobot trigger ""`. +- **Heartbeat:** A quiet periodic check driven by `/HEARTBEAT.md` that only messages you when something needs attention. -## Background Jobs - -When `nanobot gateway` starts, it runs workspace-scoped automations and registers system jobs: - -- `dream`, when `agents.defaults.dream.enabled` is true; -- `heartbeat`, when `gateway.heartbeat.enabled` is true. - -Heartbeat reads `/HEARTBEAT.md`. If the file has tasks under `## Active Tasks`, nanobot executes them and sends only useful/actionable results to the most recently active chat target. Routine "nothing changed" results are suppressed. - -User-created reminders use the same cron service but are not the same as the protected heartbeat system job. They run as scheduled turns in their origin chat/session and normally deliver the result back to that channel. - -Local triggers are also session-bound, but they do not have their own schedule. Create one from the target chat with `/trigger `, then call `nanobot trigger ""` when a local script or external service wants nanobot to respond in that session. Webhook servers, third-party auth, and event-to-message formatting stay outside nanobot. Trigger deliveries are stored in the workspace until the linked agent turn finishes successfully. If the target session is busy, the trigger waits until that session is idle instead of being injected into the active turn. The message is recorded as an automation turn in that session. Delivery is at-least-once, so external systems should tolerate repeated trigger messages; a delivery that reaches the agent but fails is marked failed rather than retried forever. +See [Automations](./automations.md) for the full guide. ## Where to Go Next | Need | Read | |---|---| -| First working install | [`quick-start.md`](./quick-start.md) | -| Provider/model setup | [`providers.md`](./providers.md) | -| Chat app setup | [`chat-apps.md`](./chat-apps.md) | -| Complete config reference | [`configuration.md`](./configuration.md) | -| Runtime debugging | [`troubleshooting.md`](./troubleshooting.md) | +| First working install | [Install and Quick Start](./quick-start.md) | +| Browser workbench | [WebUI](./webui.md) | +| Provider and model setup | [Providers and Models](./providers.md) | +| Chat app setup | [Chat Apps](./chat-apps.md) | +| Complete config reference | [Configuration](./configuration.md) | +| Runtime debugging | [Troubleshooting](./troubleshooting.md) | diff --git a/docs/deployment.md b/docs/deployment.md index f0eb80811..b130adaac 100644 --- a/docs/deployment.md +++ b/docs/deployment.md @@ -1,90 +1,45 @@ # Deployment -Use this page to keep an already working agent online, or start with the [Docker setup](#docker-compose) on a new headless host. A normal WebUI reply is sufficient to confirm an existing model setup; a CLI check is useful for terminal and container deployments. Deployment keeps long-running surfaces online: WebUI, chat apps, heartbeat, Dream, cron jobs, and channel connections. +Use this page to keep nanobot running reliably in the background—on a hosted platform, in Docker, or as a Linux/macOS system service. ## Before You Deploy -Check these before making a deployment persistent. For a new container host, perform them inside the container after the initialization steps below: +Confirm these basics first (for a new container host, check them inside the container after setup): -| Check | Why it matters | -|---|---| -| `nanobot status` shows the expected config and workspace | Confirms the process will read the instance you meant to run | -| `nanobot agent -m "Hello!"` works | Proves install, config, provider, model, and workspace writes before adding a service layer | -| Secrets are in environment variables or protected config files | API keys, bot tokens, OAuth state, and chat credentials should not be world-readable | -| The active config directory (including `sessions/`) and workspace are persistent | Sessions follow `--config`; memory, generated artifacts, and the workspace identity marker follow the workspace | -| Channel access control is intentional | Use `allowFrom`, pairing, WebSocket `token`/`tokenIssueSecret`, or private test channels before exposing the bot | -| Ports are planned | Gateway health defaults to local-only `127.0.0.1:18790`; WebUI/WebSocket defaults to `8765` | -| Logs are easy to reach | Use `docker compose logs`, `journalctl`, LaunchAgent log files, or `nanobot gateway --verbose` while diagnosing startup | +- **Local setup works:** `nanobot status` shows the right config and workspace, and `nanobot agent -m "Hello!"` returns a reply. +- **Secrets are protected:** Keep API keys, bot tokens, and WebUI passwords in environment variables or private config files. +- **Data persists:** Keep your config directory (including `sessions/`) and workspace on persistent storage. +- **Access is locked down:** Configure pairing, `allowFrom`, or a WebUI password (`tokenIssueSecret`) before exposing nanobot beyond localhost. +- **Restart after edits:** Long-running services read `config.json` at startup—restart the service after config changes. -Restart the deployed process after editing `config.json`. Long-running processes read config at startup. +## Choose a Deployment Option -## Choose a Runtime - -| Runtime | Use it for | State location | Useful first command | -|---|---|---|---| -| Render | One-click hosted gateway and WebUI | Persistent disk at `/home/nanobot/.nanobot` | [Deploy to Render](#render) | -| Docker Compose | Repeatable container runs on Linux servers or workstations | Bind-mount `~/.nanobot` to `/home/nanobot/.nanobot` | `docker compose run --rm nanobot-cli agent -m "Hello!"` | -| Docker CLI | Manual container testing or small one-off hosts | Bind-mount `~/.nanobot` to `/home/nanobot/.nanobot` | `docker run -v ~/.nanobot:/home/nanobot/.nanobot --rm nanobot status` | -| systemd user service | Linux user-level gateway that restarts automatically | Host user's `~/.nanobot` unless you pass explicit paths | `systemctl --user status nanobot-gateway` | -| macOS LaunchAgent | macOS gateway that starts after login | Host user's `~/.nanobot` unless the plist passes explicit paths | `launchctl list | grep ai.nanobot.gateway` | +| Option | Best for | Where data lives | +|---|---|---| +| [Render](#render) | One-click hosted gateway + WebUI without managing a server | Render persistent disk (`/home/nanobot/.nanobot`) | +| [Docker Compose](#docker-compose) | Linux servers and repeatable container deployments | Bind mount `~/.nanobot` → `/home/nanobot/.nanobot` | +| [Linux Service](#linux-service) | Always-on gateway on a Linux machine (systemd) | Host `~/.nanobot` | +| [macOS LaunchAgent](#macos-launchagent) | Always-on gateway after login on a Mac | Host `~/.nanobot` | ## Render -Run nanobot online without managing a server. The blueprint deploys the gateway and bundled WebUI together, with a persistent disk so sessions, memory, and chat history survive restarts. +Deploy the gateway and bundled WebUI together on Render with a persistent disk so your config, sessions, memory, and automations survive restarts. > [!IMPORTANT] -> This setup requires a paid Render service because persistent disks are not available on the free tier. During setup, provide `ANTHROPIC_API_KEY` and set `NANOBOT_WEB_TOKEN` to a strong private password (for example, generate one with `openssl rand -hex 32`). +> Requires a paid Render Starter plan because persistent disks are not available on the free tier. Have your `ANTHROPIC_API_KEY` ready, and generate a strong private password for `NANOBOT_WEB_TOKEN` (for example with `openssl rand -hex 32`). -[![Deploy to Render](https://render.com/images/deploy-to-render-button.svg)](https://render.com/deploy?repo=https://github.com/HKUDS/nanobot) +[![Deploy to Render](https://render.com/images/deploy-to-render-button.svg)](https://render.com/deploy?repo=https://github.com/HKUDS/nanobot) · [Review blueprint](../render.yaml) -[Review the deployment blueprint](../render.yaml) +1. Click **Deploy to Render**, sign in, and review the blueprint (one Starter web service + 1 GB persistent disk). +2. Enter your `ANTHROPIC_API_KEY` and set `NANOBOT_WEB_TOKEN` to a strong random password (save it in your password manager). +3. Create the blueprint and wait for the status to reach **Live** (the first build takes a few minutes). +4. Open your `onrender.com` URL and sign in with `NANOBOT_WEB_TOKEN`. -### First Deployment +Automatic deploys are disabled by default so upstream changes do not unexpectedly restart your bot. To update later, open the Render Dashboard and click **Manual Deploy → Deploy latest commit**. -1. Click **Deploy to Render**, sign in, and review the Blueprint. It creates one Starter web service and a 1 GB persistent disk. -2. Enter your `ANTHROPIC_API_KEY`. Set `NANOBOT_WEB_TOKEN` to a new random value and save it in your password manager; this is the password for the public WebUI. -3. Create the Blueprint and wait for the service status to become **Live**. The first build can take several minutes. -4. Open the generated `onrender.com` URL. The **Authentication required** page means the gateway is running: enter the same `NANOBOT_WEB_TOKEN` value to open the WebUI. +## Docker Compose -The model API key is used by nanobot to call Anthropic. The Web token only protects access to this deployment; do not share it in issues, screenshots, or chat. - -### Updates and Data - -The Blueprint disables automatic deploys so upstream repository changes do not unexpectedly restart your agent. To update, open the service in the Render Dashboard and choose **Manual Deploy → Deploy latest commit**. - -The persistent disk keeps `config.json`, sessions, memory, WebUI history, cron state, media, and logs across restarts and updates. The deployment initializes `config.json` only when it does not already exist, so settings changed later in the WebUI are not replaced on every boot. - -If deployment fails, open the service **Logs** page first. A missing model key fails provider requests after startup, while an incorrect Web token leaves you on the authentication page. - -## Docker - -> [!TIP] -> The `-v ~/.nanobot:/home/nanobot/.nanobot` flag mounts your local config directory into the container, so your config and workspace persist across container restarts. The container runs as the non-root user `nanobot` (UID 1000) and reads config from `/home/nanobot/.nanobot`. Always mount your host config directory to `/home/nanobot/.nanobot`, not `/root/.nanobot`. If you get **Permission denied**, fix ownership on the host first: `sudo chown -R 1000:1000 ~/.nanobot`, or pass `--user $(id -u):$(id -g)` to match your host UID. Podman users can use `--userns=keep-id` instead. -> -> [!IMPORTANT] -> Official Docker usage currently means building from this repository with the included `Dockerfile`. Docker Hub images under third-party namespaces are not maintained or verified by HKUDS/nanobot; do not mount API keys or bot tokens into them unless you trust the publisher. - -> [!IMPORTANT] -> The gateway and WebSocket channel default to `host: "127.0.0.1"` in `config.json` (set in `nanobot/config/schema.py`). Docker `-p` port forwarding cannot reach a container's loopback interface, so for the host or LAN to reach the exposed ports existing configurations and manual Docker runs must set both binds to `0.0.0.0` in `~/.nanobot/config.json` before starting the container. The Compose first-boot setup below sets these automatically. To serve the bundled WebUI from Docker, bind the WebSocket channel externally and protect bootstrap with `tokenIssueSecret`: -> -> ```json -> { -> "gateway": { "host": "0.0.0.0" }, -> "channels": { -> "websocket": { -> "host": "0.0.0.0", -> "port": 8765, -> "tokenIssueSecret": "your-secret-here" -> } -> } -> } -> ``` -> -> When the WebSocket `host` is `0.0.0.0`, the channel refuses to start unless `token`, `tokenIssueSecret`, or a fully configured `trustedProxyAuth` is also configured. See [`webui.md#lan-access`](./webui.md#lan-access) for details. The gateway health route itself is intentionally minimal and unauthenticated. When the container binds it to `0.0.0.0`, publish port `18790` to host loopback only; place any remotely monitored health endpoint behind a firewall or reverse proxy. If another host must probe it directly, replace `127.0.0.1` in the port mapping with a trusted host interface and restrict inbound traffic to the monitoring system. - -### Docker Compose - -On a new Linux host, install Git and Docker with the Compose plugin, then get the repository. You do not need to install Python or nanobot on the host: +On a Linux host with Git and Docker Compose installed (no host Python required): ```bash git clone https://github.com/HKUDS/nanobot.git @@ -93,99 +48,58 @@ docker compose up -d docker compose logs ``` -On first boot, Compose initializes `~/.nanobot/config.json` with container bind addresses and a random WebUI password. Open `http://HOST:8765`, enter the WebUI password printed in the first-boot logs, then configure your provider and model in **Settings → Models**. Send a message to verify the setup. No provider is required just to open the WebUI. +On first boot, Compose creates `~/.nanobot/config.json` with container network settings and a random WebUI password printed in the logs. Open `http://:8765`, enter that password, and configure your provider and model in **Settings → Models**. -Export `NANOBOT_WEB_TOKEN` before the first startup to supply your own WebUI password. Compose forwards this variable into the containers. Existing configuration is left untouched, including credentials and bind addresses; changing this variable later does not rotate persisted credentials. An explicit `--config` or `-c` selects a user-managed configuration and skips default-instance initialization. If you reuse an existing configuration, check the [Docker bind and authentication settings](#docker) above. +- **Set your own password:** Export `NANOBOT_WEB_TOKEN="your-secret"` before running `docker compose up -d` for the first time. +- **Common commands:** -The configuration and workspace persist in the `~/.nanobot` bind mount. Keep `agents.defaults.workspace` as a container path, normally `~/.nanobot/workspace`, rather than a host home-directory path. Other config `${VAR}` references require explicit `environment` entries in the CLI and gateway services; Compose does not forward arbitrary host variables. +```bash +docker compose run --rm nanobot-cli agent -m "Hello!" # test CLI +docker compose logs -f nanobot-gateway # follow logs +curl --fail http://127.0.0.1:18790/health # health check +docker compose down # stop +``` -The default Compose service runs the gateway and WebUI. If you are updating a deployment that used the former API service, follow the [API service removal steps](./updating.md#standalone-api-service-removal). - -CLI commands do not trigger Docker service initialization. For terminal setup, run `docker compose run --rm nanobot-cli onboard --wizard`, configure the model, and merge the [Docker bind and authentication settings](#docker) before starting the gateway. Plain `onboard` keeps its original first-run behavior without an extra overwrite prompt. Verify it with `docker compose run --rm nanobot-cli agent -m "Hello!"` before starting the persistent gateway. - -The default image preinstalls WhatsApp dependencies. To bake other enabled channels into an image (recommended for deployments without PyPI access), pass a comma-separated `NANOBOT_CHANNELS` build argument: +- **Preinstall chat channels into the image** (recommended when the container has slow or no PyPI access): ```bash NANOBOT_CHANNELS=telegram,slack docker compose build ``` -The image keeps nanobot in a virtual environment owned by its built-in non-root runtime user (UID 1000). If an enabled channel was not preinstalled, gateway startup can therefore install its manifest-declared dependencies. Rebuilding with `NANOBOT_CHANNELS` keeps that installation reproducible instead of relying on the container's writable layer. If you override the container with a different `--user`, bake every enabled channel into the image because that UID is not guaranteed write access to the virtual environment. +- **Remote access tip:** For a remote server, either restrict port `8765` with a firewall or connect over an SSH tunnel (`ssh -L 8765:127.0.0.1:8765 user@HOST`) and open `http://127.0.0.1:8765` locally. -```bash -curl --fail http://127.0.0.1:18790/health -``` +
+Reusing an existing config, permissions, manual Docker CLI, and bwrap sandbox -```bash -docker compose run --rm nanobot-cli agent -m "Hello!" # run CLI -docker compose logs -f nanobot-gateway # view logs -docker compose down # stop -``` - -Open `http://HOST:8765` and enter the configured `tokenIssueSecret` when prompted. For a remote host, allow access only from the intended network or use an SSH tunnel (`ssh -L 8765:127.0.0.1:8765 user@HOST`) and open `http://127.0.0.1:8765` locally. The health check confirms the process is reachable; send a browser message to verify the model and WebUI together. - -The default Compose file drops all Linux capabilities except `CHOWN`, `SETUID`, and `SETGID`, which the root entrypoint needs to fix bind-mount ownership and become UID 1000. It also enables `no-new-privileges`, so the non-root process cannot regain those bootstrap capabilities through setuid binaries or file capabilities. Docker's default AppArmor/seccomp profiles remain enabled. If you explicitly set `"tools.exec.sandbox": "bwrap"` in `~/.nanobot/config.json`, add the bwrap override file when starting containers: +- **Reusing an existing `config.json`:** Docker port forwarding cannot reach `127.0.0.1` inside a container. Set both `gateway.host` and `channels.websocket.host` to `"0.0.0.0"` and configure `channels.websocket.tokenIssueSecret` (see [LAN Access](./webui.md#lan-access)). Keep port `18790` (health check) bound to `127.0.0.1` on the host. +- **File permissions:** The container runs as UID `1000` (`nanobot`) and mounts `~/.nanobot` to `/home/nanobot/.nanobot`. If you see **Permission denied**, run `sudo chown -R 1000:1000 ~/.nanobot` on the host (or pass `--user $(id -u):$(id -g)` / Podman `--userns=keep-id`). +- **Official image note:** Build from this repository's `Dockerfile`; third-party images on Docker Hub are not maintained by HKUDS/nanobot. +- **Linux `bwrap` shell sandbox:** If you enable `"tools.exec.sandbox": "bwrap"`, start Compose with the bwrap override file so bubblewrap can create nested namespaces (requires host unprivileged user namespaces): ```bash docker compose -f docker-compose.yml -f docker-compose.bwrap.yml up -d nanobot-gateway -docker compose -f docker-compose.yml -f docker-compose.bwrap.yml run --rm nanobot-cli agent -m "Hello!" ``` -The override adds `CAP_SYS_ADMIN` and disables AppArmor/seccomp confinement for the container so bubblewrap can create its nested namespaces. It preserves `no-new-privileges`. The host must also allow unprivileged user namespaces; the override cannot bypass a host-level namespace restriction. Use it only when the bwrap sandbox is enabled. - -### Docker +- **Manual Docker CLI:** ```bash -# Build the image docker build -t nanobot . - -# Or preinstall a regular Python extra such as Bedrock support -docker build --build-arg NANOBOT_EXTRAS=bedrock -t nanobot . - -# Or preinstall dependencies for a specific set of channels -docker build --build-arg NANOBOT_CHANNELS=telegram,slack -t nanobot . - -# Initialize config (first time only) docker run -v ~/.nanobot:/home/nanobot/.nanobot --rm nanobot onboard - -# Merge model/provider and Docker bind/auth settings as described above. -vim ~/.nanobot/config.json - -# Verify the configuration and model before running the persistent gateway. -docker run -v ~/.nanobot:/home/nanobot/.nanobot --rm nanobot status docker run -v ~/.nanobot:/home/nanobot/.nanobot --rm nanobot agent -m "Hello!" - -# Run gateway (connects to enabled channels, e.g. Telegram/Discord/Mochat). -# `-p 8765:8765` exposes the WebSocket channel / WebUI alongside the gateway -# health endpoint on 18790. docker run \ - --cap-drop ALL \ - --cap-add CHOWN --cap-add SETGID --cap-add SETUID \ + --cap-drop ALL --cap-add CHOWN --cap-add SETGID --cap-add SETUID \ --security-opt no-new-privileges:true \ -v ~/.nanobot:/home/nanobot/.nanobot \ -p 127.0.0.1:18790:18790 -p 8765:8765 \ nanobot gateway - -# If `tools.exec.sandbox: "bwrap"` is enabled, run with the extra permissions -# bubblewrap needs for nested namespaces. Without them, `bwrap` may exit with -# `clone3: Operation not permitted`. -docker run \ - --cap-drop ALL \ - --cap-add CHOWN --cap-add SETGID --cap-add SETUID --cap-add SYS_ADMIN \ - --security-opt no-new-privileges:true \ - --security-opt apparmor=unconfined \ - --security-opt seccomp=unconfined \ - -v ~/.nanobot:/home/nanobot/.nanobot \ - -p 127.0.0.1:18790:18790 -p 8765:8765 \ - nanobot gateway - -# Or run a single command -docker run -v ~/.nanobot:/home/nanobot/.nanobot --rm nanobot agent -m "Hello!" -docker run -v ~/.nanobot:/home/nanobot/.nanobot --rm nanobot status ``` -### Cloudflare Tunnel + Cloudflare Access +
-For a local `cloudflared` process in front of nanobot, Cloudflare Access can authenticate the user before forwarding the request and add `Cf-Access-Jwt-Assertion`. Opt in to trusted-proxy no-token mode only when the direct TCP peer is the tunnel process and the assertion is non-empty: +
+Cloudflare Tunnel + Cloudflare Access + +If you place a local `cloudflared` tunnel with Cloudflare Access in front of nanobot, you can let Cloudflare Access handle browser authentication instead of a WebUI password: ```json { @@ -204,33 +118,27 @@ For a local `cloudflared` process in front of nanobot, Cloudflare Access can aut } ``` -This is two-part authorization: a trusted direct loopback peer **and** a non-empty Cloudflare Access assertion. A trusted CIDR alone is not a bypass. For this flow `/webui/bootstrap` returns connection metadata without a bootstrap token or REST API token; the proxy assertion authorizes the WebSocket handshake and REST requests directly. +nanobot requires both a direct loopback connection and a non-empty `Cf-Access-Jwt-Assertion` header (standard proxy headers like `X-Forwarded-*` are rejected). Because nanobot trusts the tunnel rather than cryptographically validating the JWT, never expose port `8765` directly to untrusted networks. -Set `publicWsUrl` to the browser-facing `wss://` endpoint when the tunnel sends the origin host header (such as `127.0.0.1:8765`); otherwise the WebUI could attempt to open its WebSocket directly against the loopback address. The assertion header must be generated by Cloudflare Access after authentication; routing/client metadata headers such as `Host`, `Forwarded`, `X-Forwarded-*`, `X-Real-IP`, and `CF-Connecting-IP` are rejected as `assertionHeader` values. Nanobot trusts the assertion but does not cryptographically validate the JWT, so configure the tunnel and Access policy carefully and do not expose the nanobot listener directly to untrusted clients. Forwarded client headers do not establish proxy trust. +
## Switch an Existing Gateway to a Service -Before installing an OS service, finish active work and close WebUI/TUI launchers that could start another gateway. Stop the existing instance: use `nanobot gateway stop` for a recorded background gateway (including one retained by `/detach`), or Ctrl+C in the terminal running a foreground gateway. Pass the same `--config` and `--workspace` selectors to stop, status, and service-install commands for a custom instance. +Before installing a Linux or macOS service, stop any manually running gateway so the ports do not conflict: -The service installer does not take over an existing standalone process. Starting both on the same ports makes the new service fail. If an OS service already owns the instance, manage it with its service manager instead of launching another process. +- Close WebUI/TUI windows that might restart the gateway. +- Run `nanobot gateway stop` (or press `Ctrl+C` in a foreground terminal). Pass the same `--config` and `--workspace` if you use a custom instance. ## Linux Service -Run the gateway as a systemd user service so it starts automatically and restarts on failure. Complete the [existing-gateway handoff](#switch-an-existing-gateway-to-a-service) first if an instance is already running. - -Preview the generated unit first: +Run the gateway as a `systemd` user service so it starts automatically and restarts on failure: ```bash -nanobot gateway install-service --manager systemd --dry-run +nanobot gateway install-service --manager systemd --dry-run # preview +nanobot gateway install-service --manager systemd # install & start ``` -Install, enable, and start it: - -```bash -nanobot gateway install-service --manager systemd -``` - -For a custom instance, pass the same config/workspace selector you use to run the gateway: +For a custom instance, pass `--name`, `--config`, and `--workspace`: ```bash nanobot gateway install-service \ @@ -240,51 +148,28 @@ nanobot gateway install-service \ --workspace ~/.nanobot-telegram/workspace ``` -Common operations: +Common commands: ```bash -systemctl --user status nanobot-gateway # check status -systemctl --user stop nanobot-gateway # stop the service -systemctl --user restart nanobot-gateway # restart after config changes -journalctl --user -u nanobot-gateway -f # follow logs +systemctl --user status nanobot-gateway +systemctl --user restart nanobot-gateway +journalctl --user -u nanobot-gateway -f nanobot gateway uninstall-service --manager systemd ``` -The installer writes `~/.config/systemd/user/nanobot-gateway.service`, runs `systemctl --user daemon-reload`, enables the unit, and restarts it. It uses the current Python executable with `python -m nanobot gateway --foreground`, so the service runs in the same environment you used to install nanobot. To update an existing unit after upgrading, rerun the install command with the same options; this overwrites the unit and restarts the service. Custom systemd overrides remain in effect. - -> **Note:** User services only run while you are logged in. To keep the gateway running after logout, enable lingering: -> -> ```bash -> loginctl enable-linger $USER -> ``` +> [!TIP] +> To keep a user service running after you log out of Linux, enable lingering: `loginctl enable-linger $USER`. ## macOS LaunchAgent -Use a LaunchAgent when you want `nanobot gateway` to stay online after you log in, without keeping a terminal open. Complete the [existing-gateway handoff](#switch-an-existing-gateway-to-a-service) first if an instance is already running. - -Preview the generated plist first: +Run the gateway automatically after you log in on macOS without keeping a terminal open: ```bash -nanobot gateway install-service --manager launchd --dry-run +nanobot gateway install-service --manager launchd --dry-run # preview +nanobot gateway install-service --manager launchd # install & start ``` -Install, load, enable, and start it: - -```bash -nanobot gateway install-service --manager launchd -``` - -For a custom instance: - -```bash -nanobot gateway install-service \ - --manager launchd \ - --name nanobot-telegram \ - --config ~/.nanobot-telegram/config.json \ - --workspace ~/.nanobot-telegram/workspace -``` - -Common operations: +Common commands: ```bash launchctl list | grep ai.nanobot.gateway @@ -292,6 +177,4 @@ launchctl kickstart -k gui/$(id -u)/ai.nanobot.gateway nanobot gateway uninstall-service --manager launchd ``` -The installer writes `~/Library/LaunchAgents/ai.nanobot.gateway.plist`, uses the current Python executable with `python -m nanobot gateway --foreground`, and writes LaunchAgent logs under `~/.nanobot/logs/`. - -> **Note:** if startup fails with "address already in use", stop the manually started `nanobot gateway` process first. +Logs are written under `~/.nanobot/logs/`. If startup fails with "address already in use", stop any manually started gateway first. diff --git a/docs/guides/README.md b/docs/guides/README.md index f28901714..5a2c00d94 100644 --- a/docs/guides/README.md +++ b/docs/guides/README.md @@ -11,6 +11,7 @@ You can ask nanobot to guide your next task using the built-in `nanobot-document | Build a personal AI agent | [Build a personal AI agent](./build-a-personal-ai-agent.md) | | Use the browser workbench | [AI agent WebUI](./ai-agent-webui.md) | | Run a self-hosted AI agent | [Self-hosted AI agent](./self-hosted-ai-agent.md) | +| Connect to a remote nanobot from your local WebUI | [Connect to an existing remote nanobot](./remote-instances.md) | | Run a sustained goal | [Long-running AI agent](./long-running-ai-agent.md) | | Add long-term memory | [AI agent memory](./ai-agent-memory.md) | diff --git a/docs/guides/remote-instances.md b/docs/guides/remote-instances.md index 072ccecac..7e4787de4 100644 --- a/docs/guides/remote-instances.md +++ b/docs/guides/remote-instances.md @@ -1,143 +1,71 @@ -# Connect to an existing remote nanobot +# Connect to an Existing Remote nanobot -Open your local **nanobot WebUI**, click the current host (initially **Local**) at the bottom of the sidebar, and choose **Manage connections…**. This is the single entry point for switching and managing hosts. The page lists this computer and your saved servers. Choose **Connect to remote nanobot** to copy a prepared pairing command, or choose **Other ways → Use existing SSH settings** to enter an SSH address such as `ubuntu@your-server` or pick a suggested host from your SSH config. Choose **Connect**. Next time, select the saved server directly. No port-forwarding command or `.command` launcher is needed. +Use your local nanobot WebUI to connect directly to a nanobot instance already running on a remote Linux server—without manually setting up SSH port forwarding or exposing a public admin port. -With more than five saved servers, the host menu includes search by name or SSH address. The current server and recently used servers appear first; the local computer stays at the top. Only the host list scrolls, so **Manage connections…** stays visible. Use the arrow keys to choose a result, Enter to connect, and Escape to close. Recent choices are remembered in this browser, not synced to servers. +Open your local WebUI, click the host name (**Local**) at the bottom of the sidebar, and choose **Manage connections…**. From there, pick one of two ways to connect: -To add another server, choose **Connect to remote nanobot** below your saved connections. Use a server's menu to edit or forget it. Editing opens the same dialog; **Save changes** saves without connecting or switching hosts. Disconnect an open server before editing its connection settings. The page supports browser back/forward and the `#/remote` route. Cancelling setup while saving or connecting prevents a later automatic switch. A profile or SSH tunnel already created is not rolled back; you can manage it from the directory. Adding the same connection settings again reuses that entry, without renaming it or disconnecting an open view. +- **Quick pairing (recommended for Linux servers):** Copy one command, run it on the server, and click the return link—no SSH key setup or config path needed. +- **Existing SSH settings:** Connect using an SSH address (like `ubuntu@your-server`) or an alias from your local `~/.ssh/config`. -This connects to the nanobot **already running on the server**. It does not install a worker, clone a workspace, move conversations, or start a second bot. It is separate from remote execution/worker deployment. +> [!NOTE] +> This connects to a nanobot instance **already running on your server**. It does not install nanobot, copy workspaces, or move conversations. -## Quick pairing: copy a command, follow a link back +## Quick Pairing (Recommended) -Repeated pairing to the same verified destination appears as one server in the directory and host switcher. The confirmation says **This nanobot is already saved**; **Save and open** keeps the new authorization as well as the old ones, preserves the saved name, and reuses a healthy open connection. When reconnecting, the directory prefers a non-expired authorization unless another is already selected. Use **Connection details** in that server's menu to choose or forget one specific connection. Forgetting one does not delete the others or revoke its server-side key. Disconnect an open connection before choosing a different authorization. The 20-connection limit counts retained authorizations, not just visible server rows. +For a Linux server with nanobot already installed: -Grouping is read-only: it requires matching encrypted-receipt evidence for the SSH endpoint, pinned host key, account, resolved nanobot configuration, WebUI port and credential. Names/IPs alone and restart-scoped gateway IDs are insufficient. Different instances remain separate, as do unverified manual SSH entries or changed addresses/credentials. No old authorization files are silently deleted. +1. In your local WebUI, open **Manage connections… → Connect to remote nanobot** and click **Copy command**. +2. Open your server's terminal (for example, your cloud provider's web console or SSH) and run the copied command in the environment where nanobot is installed. +3. Follow the prompts to pick the nanobot configuration (if there are multiple), confirm the server address if asked, and approve **full nanobot access** for this computer. +4. Click the **Return to nanobot** link printed in the terminal (on the same computer and browser), review the server details, and click **Connect**. -For a Linux server with this version of nanobot installed, you do not need to prepare a local SSH key or know the service account/config path: +If your terminal cannot open links, choose **Other ways → Use a connection code instead** in the WebUI and paste the `nbpc1.…` code from the terminal. -1. In your **local** WebUI choose **Connect to remote nanobot → Copy command**. The command is prepared when setup opens; **View command** lets you inspect it before running. After a successful copy, the dialog shows what to do in your server terminal. This is a clipboard confirmation, not a claim that the server is connected. **Other ways → Requirements & help** contains prerequisites and expiry details. -2. Open your cloud provider's server terminal. Run the command in the environment where nanobot is installed (activate its virtual environment for source installs). The command discovers the default config and named nanobot systemd services; choose a configuration if there is more than one. The connection account is detected from your current login, the original login under sudo, or the only regular account. In a root cloud console with several accounts, pairing checks [cloud-init's configured default user](https://docs.cloud-init.io/en/latest/explanation/instancedata.html) and uses it only if it matches an existing regular login account. It queries only the username, not passwords or other instance data. No account name or password needs to be entered when detection succeeds. If the account is still ambiguous, choose from a numbered list; this is an account **on this server**, not your cloud website account. Invalid numbers can be corrected without restarting pairing. No account is created and no device is authorized by making that choice. The account is shown in the authorization summary. A global server address reported by the SSH session can also be selected automatically. On recognized Tencent Cloud Linux instances, pairing can instead read this server's public IPv4 from the fixed, instance-local metadata endpoint, without cloud API keys. Only that public-address field is read; no role credentials or user data are requested. If neither source is available, enter **this server's** public IP from the cloud console, not your computer's IP. Private addresses and public-IP lookup services (which may report a shared NAT/proxy) are not used. The detected address is shown in the authorization summary, not proof that SSH is reachable. Use `--ssh-user` or `--host` to override. -3. Review the **full nanobot access** authorization on the server and confirm it. If its config belongs to another service account, the command first asks **Continue as server administrator?**. Confirm to continue via your existing sudo access (your server login password may be required). The same installation, config and SSH login account are retained; you do not need to rewrite the command. Declining leaves everything unchanged. Without sudo access, ask the server administrator to run the command. Pairing does not install sudo rules or weaken config permissions, and device authorization still requires a separate confirmation. -4. Open the terminal's **Return to nanobot** link on the same computer and in the same browser profile that started pairing. The local WebUI opens the server confirmation directly; review its identity and access, then choose **Connect**. The link does not authorize or connect automatically. If the terminal cannot open links, choose **Other ways → Use a connection code instead** and paste the returned `nbpc1.…` code, then **Review connection**. Both paths use the same verification. +- **Security:** The invitation expires in 10 minutes, the server's SSH host key is pinned automatically, and the dedicated device key expires after 90 days. No relay server or public WebUI port is used. +- **Requirements:** Linux server with OpenSSH (`restrict` and `expiry-time` support), `/usr/bin/python3`, and an Ed25519 host key. Windows servers and containers are not supported by quick pairing—use existing SSH settings instead. -The return link targets only an HTTP loopback origin (`127.0.0.1`, `localhost`, or `[::1]`). Its fragment contains an encrypted receipt, not a plaintext admin secret, and is scrubbed before the WebUI signs in. A new tab can continue the request even if the original setup tab was closed. Pending keys remain on the local backend for the ten-minute invitation lifetime; abandoned requests are cleaned when a new request is prepared. A link opened on another machine, an expired request, or a modified code fails closed. Native/non-loopback origins continue to use the code fallback. Existing local authentication is still required. +> [!CAUTION] +> A paired connection grants **full access to nanobot** on that server, including its tools and files. Never import a connection code from someone you do not trust. -No relay, public WebUI, uploaded private key, QR scan or new firewall rule is involved. The public invitation expires after ten minutes. The returned code is encrypted for that local instance; another computer/request cannot import it. The server host key is pinned from the code copied through your trusted terminal. Do not accept a connection code supplied by someone you do not trust. +## Connect with Existing SSH Settings -The dedicated device SSH key expires after 90 days. OpenSSH `restrict` disables shell-adjacent features and all SSH forwarding; a forced, fixed Python stdio bridge connects only to the selected loopback nanobot port. It cannot execute the client's SSH command. No extra daemon is installed or started. The server requires OpenSSH with `restrict` and `expiry-time` support, `/usr/bin/python3`, an Ed25519 host key, and the conventional `~/.ssh/authorized_keys` layout. Custom SSH policies/layouts may reject the grant; use existing SSH settings in that case. Windows servers and containers are not supported by quick pairing. +Choose **Other ways → Use existing SSH settings** if you already have SSH key access to the server (including Docker or non-systemd setups): -This is still **full access to nanobot**, not read-only access. Its configured tools may themselves run commands or modify files. The WebUI credential stays in the local backend, encrypted at rest alongside a private local decryption key and dedicated SSH identity (directories `0700`, files `0600`). This protects against other OS users, not compromise of your logged-in account. Provider keys are not exported by the pairing protocol. Changes to the remote WebUI secret or port require pairing again; they are not silently refreshed through sudo. +1. Enter an SSH address (such as `ubuntu@your-server`), pick a suggested host from your `~/.ssh/config`, or paste a simple SSH command like `ssh -p 2222 -i ~/.ssh/key ubuntu@your-server`. +2. Expand **Connection options** if you need a custom port, SSH config file, private key path, remote config path, or service account. +3. Click **Connect**. On first connection, verify the server's SSH fingerprint before continuing. -SSH network reachability is still required. Pairing cannot fix a blocked port or VPN route. A failed connection keeps the paired profile for retry. **Network route…** can explicitly reuse a saved connection's proxy/bound-interface route to the same host, without copying its identity settings. Jump-host routes should continue to use the ordinary SSH connection flow. +After SSH connects, nanobot looks for your server's config and `nanobot*.service` systemd units automatically. If it cannot find one (for example, in Docker or a custom path), enter the server's config path manually. -If the server rejects a paired device key, the UI asks you to pair again rather than unlock an unrelated SSH agent. This can happen after revocation or expiry. +**Prerequisites for existing SSH:** -**Disconnect** closes local streams. **Forget** removes the local directory entry, including that device's local pairing keys, but does not revoke server authorization. To revoke, run the command displayed in the connection details on the server: +- Your local WebUI runs on localhost with the system OpenSSH client available. +- Your SSH key already works for that server (encrypted keys should be unlocked in your SSH agent; interactive SSH passwords are not supported). +- Python 3 (`python3` or `python`) is available on the server, and the remote nanobot has `tokenIssueSecret` (or `token`) set in its `config.json`. + +## Switching, Disconnecting, and Revoking + +- **Switch hosts:** Click the host name at the bottom of the sidebar to switch between **Local** and saved servers (up to four connected at once). Each host keeps its own chat view and draft while connected. +- **Disconnect:** Closes the local SSH tunnel without stopping the remote nanobot. +- **Forget server:** Removes the saved entry and local pairing keys from this computer. It does not touch remote conversations or files. +- **Revoke a paired device:** Forgetting a server locally does not revoke its server-side key. To revoke access on the server, run the command shown in the server's **Connection details**: ```bash nanobot remote revoke DEVICE_ID --ssh-user LOGIN_ACCOUNT ``` -Only that device's exact managed key entry is removed; existing login keys stay unchanged. Current pairing bridges also check the grant and its expiry before each new stream, including streams on a reused SSH transport. Close any already-open remote sessions too: revocation does not terminate existing streams. Older bridges enforce the grant only at SSH authentication. If setup is cancelled after server authorization, use the revoke command printed in that terminal. Re-pairing after expiry uses a new independent key, not an extension of an old grant. - -## Existing SSH setup: server, then nanobot - -The setup dialog separates **Server** (SSH login) from **nanobot** (which installation to open). Start with an address or an existing SSH host. You do not need to know nanobot's config path in advance. - -After SSH signs in, a read-only check looks for the selected account's config and up to eight named `nanobot*.service` systemd units. It reads service metadata and checks config-file locations; it does not read their contents, scan other users' home directories, run sudo, install software or change permissions. One configuration belonging to the login account opens automatically. Multiple configurations are shown as choices. A service owned by another account always requires an explicit **Open nanobot** choice, showing that account and path; opening still requires existing passwordless sudo permission. - -If nothing is found, the dialog confirms **SSH connected** and asks for the server's config path and optional service account. Docker, custom service names, user services and non-systemd deployments may need this manual step. Failure to find a config is not proof that nanobot is absent. Finding a config is also not proof that its WebUI is running: the normal authenticated gateway check still happens before opening. - -SSH failures keep the entered address and offer **SSH login settings** for the local key path, SSH config and port. Connection refusal, name resolution, connection closure and authentication rejection have distinct messages. The application does not infer a missing key from a closed connection, nor change VPN, proxy or network-interface settings automatically. A custom SSH config outside standard locations must still be explicitly supplied by its owner. - -## Find a server you already use - -The add/edit dialog suggests named hosts from `~/.ssh/config` and the system SSH config, including ordinary `Include` files. Typing in **SSH address** filters these suggestions without a separate search field. Selecting a host fills the address; it does not connect until you choose **Connect**. Arrow keys navigate the suggestions. If your configuration lives elsewhere, expand **Connection options** and select the file beside **SSH config file**, or enter its local path. Suggestions update automatically; no separate file-reading step is needed. The private key field also has a native file chooser. Selecting a file returns only its path: it does not upload, copy or read the private key. Cancelling leaves the existing path unchanged. Headless hosts can use the manual path fields. - -Discovery is passive: it reads host names and source paths, not private keys, and does not contact servers or execute SSH hooks. Wildcard and negated patterns aren't destinations. Conditional includes may suggest hosts; only connecting checks reachability. Large or dynamic configurations show a partial-list notice; you can still enter an alias manually. Discovery is capped at 200 hosts, 64 files, 256 KiB per file, and approximately 1 MiB in total. - -At connection time, the system SSH client resolves your existing `User`, `Port`, `IdentityFile`, jump hosts and other connection settings. An empty port field inherits SSH configuration instead of overriding it with 22. Listing a host does not mean nanobot is installed there. - -You can also paste a simple command, for example `ssh -p 2222 -i "~/.ssh/team key" ubuntu@your-server`. The address field imports `-p` (port), `-i` (key path), `-F` (config path) and `-l` (login user) into the existing Connection options. Review these before connecting. Quoted paths can contain spaces, including Windows paths. This is an importer, not a terminal: remote commands, shell expansions, repeated options and other flags are rejected, not executed or silently discarded. Keep advanced options such as `ProxyJump` in your SSH config and enter the alias. An interactive alias's `RemoteCommand` and forced TTY are disabled for the fixed nanobot probe. - -## Prerequisites - -- Run the local WebUI on a loopback address, using the system OpenSSH client. -- For **existing SSH settings**, your key must already have access to the server. Encrypted keys should be unlocked in the system SSH agent. Interactive SSH passwords are not collected by this UI. -- For **existing SSH settings**, make Python 3 available to the SSH login as `python3` or `python`. A separate Linux service account still needs `python3` under `sudo`. The running nanobot WebUI needs a `tokenIssueSecret` (or `token`) in its UTF-8 JSON configuration. -- The remote gateway must support the authenticated `/webui/terminal` identity probe and the supported WebUI client contract. The local installation must have its WebUI bundle; the remote host only needs the backend endpoints. -- Both SSH flows can coexist with an HTTPS reverse proxy. Keep `publicWsUrl` for browsers that connect directly. SSH always uses the gateway's plain HTTP loopback listener and does not support TLS on that listener or `trustedProxyAuth`. - -If this machine has never connected to the server, nanobot displays its SSH fingerprint. Compare it with the server console or your administrator before confirming in the same dialog. **Back** returns to the filled-in form when adding a server. The public key is pinned for this connection, without changing your system `known_hosts`. A **changed** host key is blocked, not automatically accepted. Jump-host-only or non-Ed25519 hosts can use a previously verified system SSH configuration instead of the in-app first-contact verifier. - -## Connection options - -Most setups only need the SSH address. Expand **Connection options** when necessary. You can also give the server a recognizable name here; otherwise its address is used as the name. - -| Option | Meaning | -| --- | --- | -| SSH port | Optional override; empty inherits SSH config (normally 22) | -| SSH config file | Existing local config, including aliases or jump hosts | -| Private key path | Path to an existing local key; key contents aren't uploaded | -| nanobot config path | Server-side config, default `~/.nanobot/config.json` | -| nanobot service account | Optional account owning the remote config; requires existing passwordless `sudo -u` permission | - -For a service installation, the SSH login and nanobot owner may differ. For example, you might sign in as `ubuntu`, with nanobot running as `nanobot` and its config in `/var/lib/nanobot/.nanobot/config.json`. The discovery step offers these values when it finds the service; otherwise use **Specify a different location** in the nanobot step. Editing a saved connection also exposes these fields. The connection does not grant new sudo privileges. - -## Connection performance - -On macOS and Linux, connections with an app-pinned host key reuse a private OpenSSH transport instead of authenticating for every HTTP request. Each connection owns its control socket; nanobot never borrows your shell's shared SSH session. Disconnecting closes the transport. Windows and unpinned connections retain the independent-stream path. - -Paired connections enable reuse only after the server bridge confirms that it checks expiry and revocation on every new stream. Older bridges still work with fresh authentication per stream. Pair again after upgrading the server to install the guarded bridge; upgrading nanobot alone does not rewrite existing grants. - -The interface's HTML, JS, CSS and bundled images come from your **local nanobot installation**, not the server. Versioned local assets can be cached in the browser; HTML is revalidated. API responses, credentials and media capabilities remain uncached by the proxy. Initial authentication and network latency still affect the first connection; reuse does not bypass a blocked SSH route or VPN policy. - -## Using the remote instance - -The **local WebUI** displays the selected server's data. Interface updates follow your local installation; model settings, channels, tools and conversations still belong to the server. Every host uses an isolated browser origin and runtime, but all of them load the same locally installed frontend. The server's static WebUI bundle is not required for this mode. The isolated view cannot navigate the local application's top-level window. The first version has been exercised in macOS Chrome; native desktop-host packaging and other platforms still need their own acceptance. - -When upgrading from the earlier remote-page mode, the first reconnect reserves a fresh local browser origin. This prevents previously loaded remote service workers or cached code from controlling the local client. Saved SSH profiles, pairing authorizations, and server conversations remain intact; origin-local browser preferences may return to their defaults. Finish or copy unsent drafts before restarting the local application for this upgrade. - ### Versions and updating the right machine -Open a server's **… → Version & compatibility** in **Manage connections…** to see the local and server versions and the compatibility result. Support and test coverage are limited to same-version WebUI/gateway combinations. Different versions may work together, but cross-version functionality is not guaranteed even when protocol checks pass; align versions first when troubleshooting. The current compatibility check uses protocol metadata, not package-version equality, and does not block connections solely because versions differ. +Open a server's **… → Version & compatibility** in **Manage connections…** to check whether your local WebUI and remote gateway are compatible. Same-version local and remote installs are recommended—align versions first when troubleshooting. -- **Compatibility not confirmed:** the host has not advertised a supported WebUI contract. This is not evidence of a broken key, VPN issue, or simply an old version. Local-client mode cannot safely proceed until support is confirmed. For older installations, update nanobot on that server and reconnect. -- **Update this server:** its advertised contract lacks the client's required core features. Update the server, not merely this computer. -- **Update this computer:** the host requires a newer client protocol. Update the local installation; do not downgrade the server. +- **Update this server:** Update nanobot on the remote machine using its original install method, restart it, and reconnect. +- **Update this computer:** Update your local nanobot installation and reconnect. -The initial explicit contract is WebUI protocol 1 with `webui.core.v1`. Older hosts without this metadata need a compatible update to use local-client mode; their own server WebUI is unaffected. The terminal transport protocol is separate. +See [Updating nanobot](../updating.md) for update steps. -Use the [update instructions](../quick-start.md#updating) for the same installation method and environment that run nanobot on the target machine. For a container, update the deployed image; for a service, update its actual environment rather than an unrelated shell installation. Back up configuration and data and finish active tasks before a required restart. Verify the version of the restarted process, then reconnect. Version checks do not install packages, restart a host, or change its model, channel, or SSH configuration automatically. +## Troubleshooting -The host switcher lives beside **Settings at the bottom of the sidebar**, showing **Local** or your saved server name. It is also available in Settings. Its menu opens upward and shows the computer name, recent hosts, and **Manage connections…**. With the sidebar collapsed, the icon still opens the same menu. A check marks the host you are viewing; a separate green dot marks an established connection. Saved but disconnected hosts stay gray, and connecting or failed hosts have distinct progress/error indicators. **Manage connections…** opens a full page in the main content area beside the existing sidebar, without switching to Local, changing the route, or disconnecting the server. **Back** returns to the same view and draft. The page uses the same connection states with text labels, so color is never the only way to distinguish them. Selecting a host on the page switches only after its view is ready; a failed attempt leaves the original host selected. Remote connection setup is hidden inside the embedded remote view, and connecting back to the same gateway is rejected rather than creating a nested local session. - -Each isolated host view loads the same local WebUI and puts the switcher in the same sidebar location. A narrowly scoped, origin-, frame- and nonce-checked bridge sends the current host's display identity and coordinates menu placement, management layout and focus. The embedded view does not receive your host directory, SSH configuration or connection commands; the local shell owns those actions. This does not depend on the server's static WebUI bundle. - -Refreshing restores the selected remote instance. A failed connection stays on a remote error screen; it never silently redirects work to your local agent. The selected server ID is stored per browser tab, without credentials. Periodic connection checks run only while the tab is visible: for the current remote host, or for existing connections shown in the host menu or **Manage connections…**. Hidden tabs and inactive retained views do not keep probing. Returning to a remote view, showing the tab again, or recovering the network rechecks the connections currently in view without reloading the remote page, switching hosts, or resending messages. If the connection remains unavailable, use **Reconnect**. Different aliases resolving to the same already-connected gateway are rejected; choose its existing entry in the host switcher. Separate nanobot instances on one server can still use separate profiles and config paths. - -- **Switching hosts**, including returning local, keeps both pages mounted and keeps SSH connected. Each host retains its own chat, unsent draft, scroll position and UI state; nothing is copied between hosts. Up to three remote views are kept per tab. At the limit, explicitly disconnect one rather than silently discarding its work. Reloading the browser still follows each instance's normal draft persistence; unfinished uploads aren't guaranteed. -- A first connection prepares a hidden server page while the current page stays usable. It switches after the page loads; **Cancel switch** keeps you where you are. The most recent choice wins even if an earlier SSH request finishes later. Cancelling navigation does not stop an in-flight server connection. The host view may still show a sign-in/startup indicator while its data connection initializes; returning to an already loaded view avoids that startup. -- **Disconnect** in a server's menu confirms before closing its view and shared SSH tunnel. Unsaved view-only work can be lost; the remote bot keeps running. Idle views do not automatically close a tunnel another tab might be using. -- **Forget server** removes its local connection metadata and pinned public key. It does not delete remote conversations, keys, files, or the installation. -- Closing the local gateway cleans up its SSH processes. The independently running remote gateway, Linear integration, and scheduled tasks keep running. -- Connections to the same saved server share one tunnel; explicitly disconnecting it also disconnects other local tabs using that tunnel. Reloading a tab reuses a healthy connection. Up to four servers can be connected concurrently. - -## Security and troubleshooting - -The local connection directory is stored beside the local config under `webui/remote-instances.json`. It contains connection metadata, not private-key contents or model/channel credentials. A stable loopback port per saved server keeps browser preferences scoped to that server. Changing the SSH target, config path, service account or identity file assigns a fresh browser origin, rather than loading the previous instance's drafts. The adjacent `remote-origin-ports.json` records previously used ports, without credentials; these ports are not assigned to new targets, even after forgetting a profile. Keep that file alongside the connection directory when moving local settings. Port conflicts fail explicitly; nanobot does not attach to an unrelated listener. - -For a backup or move, stop the local gateway and preserve the entire adjacent `webui` directory, including `remote-hosts` and `remote-pairing`, with its private file permissions. Paired device keys and imported routes follow the restored directory automatically. Ordinary SSH profiles still reference your external SSH config/key paths; update those separately if they moved. Restoring only `remote-instances.json` cannot restore pairing credentials. Do not copy this directory to another user or untrusted computer: it grants full remote nanobot access. A downgrade to a version without remote connections leaves these files unused; keep the backup for upgrading again. - -The local gateway owns a browser-facing proxy and a separate, private SSH transport. Browser login, API, WebSocket and media credentials are local capabilities: they cannot authenticate to the remote gateway. The remote credentials stay in backend memory. System SSH's private stdin/stdout pipes, SSH configuration and host-key verification still secure the upstream transport. Disconnecting or forgetting closes active requests but retains disabled listeners until local gateway shutdown. Reconnecting the same saved instance reuses its browser origin. An offline profile can be edited without first disconnecting it in another tab. - -Closing the local gateway drains proxy requests before releasing its private transport. If an old tab retries the browser address after shutdown, it sends only local capabilities from the stopped proxy, not a remote login credential. Close old tabs anyway: after shutdown another local process can serve content at that address. This does not isolate nanobot from malware running as you. On Windows, exclusive socket ownership may delay reusing a port after shutdown; retry later if it remains occupied. Nanobot does not weaken socket ownership to force a reconnect. - -SSH authenticates the server. A read-only, fixed Python probe retrieves only WebUI login information from its config. The gateway's protocol and runtime ID are verified before navigation. Only a local proxy credential is passed in the remote view's URL fragment and stored by its existing login UI. Local gateway restart replaces that credential and invalidates local token/media mappings; reopening the saved connection handles this without an extra login step. Nothing opens a public administration port or forwards your SSH agent. - -**Upgrading the earlier remote-connection prototype:** it passed the remote WebUI login secret to browser storage. This version retires those old browser origins, but cannot revoke a secret already saved in an old tab. Close those tabs, clear their browser site data, and rotate the remote WebUI login secret to invalidate the old credential. This migration does not rotate credentials or restart your server automatically. - -Remote-connection actions require an authenticated local WebUI connection, a loopback-bound gateway, and local request origin. They are unavailable from a public/reverse-proxied administration page. Connecting requires server admin access; permission to mention nanobot in Linear is **not** that permission. - -Common errors explain whether SSH authentication, a missing config, a service account, WebUI authentication, protocol compatibility or networking failed. Key-agent refusal, unsafe key-file permissions, invalid SSH configuration and server-side port-forwarding denial have separate recovery hints. Login banners are ignored when reading the framed probe result. A failed probe is distinct from an invalid nanobot configuration; raw SSH output and credentials aren't displayed in error messages. If SSH works in a terminal but not in nanobot, check that nanobot was started with access to the same system SSH agent. Configurations whose WebUI secret is supplied only by a service environment and interactive SSH passwords need additional setup; this flow does not silently weaken their authentication. +- **SSH works in terminal but not in WebUI:** Make sure nanobot was started in an environment that can reach your SSH agent, and check **Connection options** for the right key or SSH config file. +- **Paired device rejected after expiry or revocation:** Re-run **Quick pairing** to issue a fresh device key. +- **Remote WebUI password or port changed:** Re-pair the server (or update the connection settings) so nanobot picks up the new config. +- **Backing up local remote-connection settings:** Stop your local gateway and back up the `webui/` folder beside your local `config.json` (preserving private file permissions). Do not copy it to an untrusted computer, as it grants access to your paired remote servers. diff --git a/docs/image-generation.md b/docs/image-generation.md index 7d70faf6b..866f0cdcf 100644 --- a/docs/image-generation.md +++ b/docs/image-generation.md @@ -1,22 +1,20 @@ # Image Generation -nanobot can generate and edit images through the `generate_image` tool. Enable the tool in WebUI Settings, then ask for an image normally in chat; the agent decides when to call it and can keep iterating on generated images in the same conversation. - -The feature is disabled by default. Open **Settings → Capabilities → Image generation**, choose a configured provider and model, enable image generation, and save. The running gateway applies the change immediately. If that screen is not available in your installed version, use the manual config below. +nanobot can generate new images and edit existing ones directly in chat. Image generation is off by default—enable it in Settings, then describe the image you want in plain language. ## Quick Setup -**WebUI** +**In the WebUI:** -1. Add the image provider credential under **Settings → Models → Provider → Add provider** if it is not already configured. +1. Make sure your image provider is added under **Settings → Models → Provider → Add provider**. 2. Open **Settings → Capabilities → Image generation**. -3. Select the provider and image model, then enable image generation. -4. Save and ask for a simple test image. If the gateway cannot apply the change live, WebUI will prompt you to restart it. +3. Choose the provider and image model, turn on **Image generation**, and click **Save**. +4. Ask nanobot for a test image in chat (if the WebUI asks for a restart, restart first).
Manual configuration -This snippet uses the current built-in image-generation default so the JSON has concrete names. It is not a provider recommendation; replace `provider` and `model` with any supported image provider and model you intend to use. +Merge this snippet into `~/.nanobot/config.json`, replacing `provider` and `model` with any supported image provider and model you use: ```json { @@ -37,67 +35,42 @@ This snippet uses the current built-in image-generation default so the JSON has
-See [Provider Notes](#provider-notes) for Custom, AIHubMix, MiniMax, Gemini, Ollama, StepFun, Zhipu, and ModelScope configuration examples. - > [!TIP] -> Prefer environment variables for API keys. nanobot resolves `${VAR_NAME}` values from the environment at startup. +> Prefer environment variables like `${OPENROUTER_API_KEY}` instead of pasting raw API keys into `config.json`. -## WebUI Usage +## Using Image Generation in Chat -1. Open Settings and enable **Image Generation** with a configured provider and model. -2. Describe the image or edit you want in chat. -3. Include an aspect ratio or size in the request when the configured defaults are not suitable. -4. Attach reference images when editing an existing image. +1. Describe the image you want—include aspect ratio or size if you want something other than the default. +2. Attach a reference image when you want to edit an existing picture (with a provider/model that supports editing). +3. Ask for follow-up tweaks in the same chat—such as *"make it warmer"*, *"change the background"*, or *"try a 16:9 version"*—and nanobot will build on the previous image automatically. -Generated images are rendered as assistant media in the chat. Follow-up prompts such as "make it warmer", "change the background", or "try a 16:9 version" can reuse the most recent generated artifact. - -The WebUI hides provider storage details from the user. The agent sees the saved artifact path internally and can pass it back to `generate_image` as `reference_images` for iterative edits. +Generated images are saved locally under `~/.nanobot/media/generated/YYYY-MM-DD/`. ## Configuration Reference -### Named custom connections +| Option | Default | Description | +|---|---|---| +| `tools.imageGeneration.enabled` | `false` | Enable or disable image generation | +| `tools.imageGeneration.provider` | `"openrouter"` | Provider name (`openrouter`, `openai`, `openai_codex`, `custom`, `aihubmix`, `minimax`, `gemini`, `ollama`, `stepfun`, `zhipu`, `modelscope`, or a named custom connection) | +| `tools.imageGeneration.model` | `"openai/gpt-5.4-image-2"` | Image model ID | +| `tools.imageGeneration.defaultAspectRatio` | `"1:1"` | Default aspect ratio when not specified in chat | +| `tools.imageGeneration.defaultImageSize` | `"1K"` | Default size hint (e.g. `1K`, `2K`, `4K`, or `1024x1024`) | +| `tools.imageGeneration.maxImagesPerTurn` | `4` | Maximum images per request (`1`–`8`) | +| `tools.imageGeneration.saveDir` | `"generated"` | Subfolder inside nanobot's media directory for saved images | -You can select a custom connection created in **Settings → Models → Manage providers**. Image generation uses its saved connection ID, URL, key, and proxy. Renaming the connection does not change its identity. You do not need a second connection named `custom`. +### Custom connections and advanced options -Selecting a custom connection uses the **OpenAI Images API** at its URL. Check that the endpoint supports `/images/generations`; support for chat alone does not imply image support. Existing built-in image adapters and the legacy `custom` connection keep their behavior. An unknown or removed connection is not replaced with another provider. +You can reuse any custom connection created in **Settings → Models → Manage providers** as long as its endpoint supports the OpenAI Images API (`/images/generations`). -In the image settings' **Advanced options**, use **Headers** and **Body parameters** for image-only request differences. These fields are also available as `tools.imageGeneration.extraHeaders` and `extraBody`. Empty fields inherit provider defaults. Header names match without case sensitivity; each body key replaces its complete value, including nested objects and arrays. Adapter-specific request assembly runs afterward. Use only options documented by your image provider; watermark controls do not have one universal name or location. - -Changing the image provider in WebUI clears these overrides so credentials do not follow the selection to another endpoint. Saved changes use the existing live image-tool reload. Chat model settings, prompts, and the tool schema are unchanged. Provider request headers are not added to generated-image downloads. - -Existing installations need no migration. Older releases ignore the new image-only fields and do not resolve named custom image connections. Before downgrading, select a provider supported by that release and check any required request settings. - -| Option | Type | Default | Description | -|--------|------|---------|-------------| -| `tools.imageGeneration.enabled` | boolean | `false` | Register the `generate_image` tool | -| `tools.imageGeneration.provider` | string | `"openrouter"` | Current built-in image provider default. Supported values: `openrouter`, `openai`, `openai_codex`, `custom`, `aihubmix`, `minimax`, `gemini`, `ollama`, `stepfun`, `zhipu`, `modelscope` | -| `tools.imageGeneration.model` | string | `"openai/gpt-5.4-image-2"` | Provider model name | -| `tools.imageGeneration.defaultAspectRatio` | string | `"1:1"` | Default ratio when the prompt/tool call does not specify one | -| `tools.imageGeneration.defaultImageSize` | string | `"1K"` | Default size hint, for example `1K`, `2K`, `4K`, or `1024x1024` | -| `tools.imageGeneration.maxImagesPerTurn` | number | `4` | Maximum `count` accepted by one tool call. Valid range: `1` to `8` | -| `tools.imageGeneration.saveDir` | string | `"generated"` | Relative directory under nanobot's media directory for generated artifacts | - -Provider settings reuse normal provider config fields: - -| Option | Description | -|--------|-------------| -| `providers..apiKey` | Provider API key. Prefer `${ENV_VAR}` | -| `providers..apiBase` | Optional custom base URL | -| `providers..extraHeaders` | Headers merged into provider requests | -| `providers..extraBody` | Extra JSON fields merged into provider request bodies | -| `providers..useProxy` | Use the shared `network.proxy` address for provider requests and returned image URL downloads | - -For providers that return image URLs, direct downloads use DNS pinning. When an explicit provider `proxy` is configured, nanobot rejects malformed URLs and locally identifiable private/internal targets on the initial URL and every redirect. Hostnames unavailable to local DNS are delegated to that trusted proxy, which owns final DNS resolution and network egress. Process-wide proxy environment variables are not used for these downloads. - -Both camelCase and snake_case config keys are accepted, but docs use camelCase to match `config.json`. +For image-only request differences (such as provider-specific quality or watermark parameters), use **Advanced options → Headers / Body parameters** in Image generation settings (or `tools.imageGeneration.extraHeaders` and `extraBody` in JSON). Switching image providers in the WebUI clears those overrides automatically so settings do not leak to another service. ## Provider Notes -For each provider below, add or edit its connection in **Settings → Models**, then choose the provider and image model in **Settings → Capabilities → Image generation**. Connection-specific headers, request bodies, and proxy settings are in the provider editor's **Advanced options**. The collapsed JSON examples are for manual deployments. +For all providers below, configure the connection in **Settings → Models** and select it under **Settings → Capabilities → Image generation**. Expand **Manual configuration** if you edit `config.json` directly. ### OpenRouter -OpenRouter uses a chat-completions style image response. Configure: +Use any OpenRouter model that supports image output (and image editing if you want reference-image edits).
Manual configuration @@ -116,13 +89,12 @@ OpenRouter uses a chat-completions style image response. Configure:
-Use a model that supports image generation and image editing if you want reference-image edits. - ### OpenAI Codex -Log in with `nanobot provider login openai-codex`, then select **OpenAI Codex** and `gpt-image-2` under **Settings → Image**. Image generation uses your Codex subscription. +Sign in with `nanobot provider login openai-codex`, then choose **OpenAI Codex** and `gpt-image-2` in image settings. Supports both generation and reference-image edits using your Codex subscription. -For manual configuration: +
+Manual configuration ```json { @@ -136,23 +108,15 @@ For manual configuration: } ``` -Use Codex to generate images from text or edit existing images with reference images. +
### Custom (OpenAI-compatible) -The `custom` image provider fits services that implement the synchronous OpenAI Images API: - -```text -POST /v1/images/generations -``` - -The response must include generated images in `data[].b64_json` or `data[].url`. Native prediction APIs, such as Replicate's `/v1/models/{owner}/{model}/predictions`, are not directly compatible unless you put an OpenAI-compatible gateway in front of them. +Works with services implementing `POST /v1/images/generations` (returning `b64_json` or `url`). Requires `apiBase`; `apiKey` is optional for local servers. Reference-image edits are not supported by the generic `custom` provider.
Manual configuration -Configure: - ```json { "providers": { @@ -171,31 +135,17 @@ Configure: } ``` +Use `extraBody` for provider-specific options—for example, `"response_format": "url"` (Agnes AI), `"response_format": "base64"` (Together AI), or explicit `size` values (Volcengine Ark Seedream). +
-The `apiBase` is required. The provider sends requests to `{apiBase}/images/generations` using the OpenAI Images API format with `response_format: "b64_json"`. The `apiKey` is optional for local or unauthenticated endpoints. Reference-image edits are not supported by the generic `custom` provider. - -`extraBody` can adapt provider-specific quirks because it is merged last into the request body. Examples: - -- Agnes AI documents URL responses, so use `"extraBody": {"response_format": "url"}`. -- Together AI documents `"response_format": "base64"`, so override the default. -- Volcengine Ark Seedream models may require size hints such as `"2K"`, `"3K"`, `"4K"`, or explicit dimensions. Set `tools.imageGeneration.defaultImageSize` or `providers.custom.extraBody.size` to a value supported by the selected model. - -For compatibility with the default nanobot setting, custom maps `defaultImageSize: "1K"` to `1024x1024`. Other explicit size hints are passed through unchanged. - ### AIHubMix -AIHubMix `gpt-image-2-free` is supported through AIHubMix's unified predictions API. Internally nanobot calls: - -```text -/v1/models/openai/gpt-image-2-free/predictions -``` +Supports `gpt-image-2-free`. Optional `extraBody: {"quality": "low"}` can make free generations faster and less likely to time out.
Manual configuration -Configure: - ```json { "providers": { @@ -218,15 +168,9 @@ Configure:
-`quality: low` is optional. It can make free image models faster and less likely to time out, but it is not required for correctness. - ### MiniMax -MiniMax supports text-to-image and reference-image edits with `MiniMax-H3-Image` and `MiniMax-H3-Image-Highspeed`. Set the image size to `1K`, `2K`, `4K`, or an explicit size such as `2720x1536`. Explicit sizes take precedence over the aspect ratio. H3 accepts up to 16 reference images. See [MiniMax's image generation documentation](https://platform.minimax.io/docs/guides/image-generation) for size limits and pricing. - -A timed-out or interrupted H3 request may still complete and be billed. Retrying starts another billable generation. - -The legacy `image-01` model remains available, with aspect ratios `1:1`, `16:9`, `4:3`, `3:2`, `2:3`, `3:4`, `9:16`, and `21:9`. +Supports text-to-image and editing (up to 16 reference images) with `MiniMax-H3-Image` and `MiniMax-H3-Image-Highspeed`, plus legacy `image-01`. Accepts `1K`, `2K`, `4K`, or explicit dimensions like `2720x1536`. See [MiniMax's image docs](https://platform.minimax.io/docs/guides/image-generation) for size limits and pricing. Note that a timed-out H3 request may still complete and be billed.
Manual configuration @@ -253,14 +197,7 @@ The legacy `image-01` model remains available, with aspect ratios `1:1`, `16:9`, ### Gemini -nanobot supports two Gemini image generation model families via Google's Generative Language API: - -| Model | Endpoint | Reference images | -|-------|----------|-----------------| -| `imagen-4.0-generate-001` | `:predict` | Not supported by this integration | -| `gemini-2.5-flash-image` | `:generateContent` | Supported | - -For reference-image edits, use a Gemini Flash image model: +Supports `gemini-2.5-flash-image` (supports reference-image edits) and `imagen-4.0-generate-001` (text-to-image only; supports `1:1`, `9:16`, `16:9`, `3:4`, `4:3`). Sizing is controlled by `defaultAspectRatio` (`defaultImageSize` is ignored).
Manual configuration @@ -284,11 +221,9 @@ For reference-image edits, use a Gemini Flash image model:
-Imagen 4 supports the aspect ratios `1:1`, `9:16`, `16:9`, `3:4`, and `4:3`. Unsupported ratios are ignored and the model uses its default. The `defaultImageSize` setting has no effect on Gemini models; sizing is controlled by `defaultAspectRatio` only. Reference images passed with an Imagen model are ignored (with a warning logged). - ### Ollama -Ollama's experimental native image generation API works with local servers and hosted ollama.com models. Local access at `http://localhost:11434/api` does not require an API key; set `providers.ollama.apiKey` only when targeting `https://ollama.com/api`. +Works with local Ollama (`http://localhost:11434/api`, no API key needed) and hosted `https://ollama.com/api` (requires API key). Reference images are not supported.
Manual configuration @@ -314,13 +249,9 @@ Ollama's experimental native image generation API works with local servers and h
-Ollama maps `defaultAspectRatio` and `defaultImageSize` to native `width` and `height` values. Reference images are not supported by this integration. - ### StepFun -StepFun (阶跃星辰) `step-image-edit-2` supports text-to-image generation. The `step-1x-medium` variant additionally supports **style-reference** image edits, where a reference image guides the visual style of the output. - -Supported aspect ratios: `1:1`, `16:9`, `9:16`, `3:4`, `4:3`. Sizes are specified as `WIDTHxHEIGHT` (e.g. `1024x1024`, `1280x800`, `800x1280`). +Supports `step-image-edit-2` (text-to-image) and `step-1x-medium` (adds style-reference edits). Shares `providers.stepfun.apiKey` with StepFun chat models. For StepPlan subscriptions, set `apiBase` to `https://api.stepfun.ai/step_plan/v1`.
Manual configuration @@ -344,45 +275,9 @@ Supported aspect ratios: `1:1`, `16:9`, `9:16`, `3:4`, `4:3`. Sizes are specifi
-> [!NOTE] -> The StepFun provider reuses the existing `providers.stepfun` config block (the same one used for StepFun's LLM API). Set `providers.stepfun.apiKey` once and it is shared between text and image generation. -> -> When `step-image-edit-2` is used, `reference_images` are ignored (the model does not support style reference). Switch to `step-1x-medium` to use reference-image-guided generation. - -#### StepPlan (Subscription) - -StepPlan is StepFun's subscription tier and uses a different API base URL. The image generation endpoint path is the same — just override `apiBase`: - -
-Manual configuration - -```json -{ - "providers": { - "stepfun": { - "apiKey": "${STEPFUN_API_KEY}", - "apiBase": "https://api.stepfun.ai/step_plan/v1" - } - }, - "tools": { - "imageGeneration": { - "enabled": true, - "provider": "stepfun", - "model": "step-image-edit-2" - } - } -} -``` - -
- -`apiBase` takes precedence over the registry default, so with the StepPlan base URL configured, image requests are sent to `https://api.stepfun.ai/step_plan/v1/images/generations` — the same path prefix used for LLM calls. The API key is shared with the standard StepFun provider. - ### Zhipu -Zhipu (智谱) `glm-image` model supports text-to-image generation. The API returns temporary image URLs (valid for 30 days); nanobot downloads and re-encodes them as base64 data URLs. - -Supported aspect ratios: `1:1`, `16:9`, `9:16`, `3:4`, `4:3`. Sizes can be specified as `WIDTHxHEIGHT` (e.g. `1280x1280`, `1728x960`) or using aspect ratio presets. +Supports `glm-image`, `cogview-4`, `cogview-4-250304`, and `cogview-3-flash` (text-to-image only). Supported aspect ratios: `1:1`, `16:9`, `9:16`, `3:4`, `4:3`, or explicit `WIDTHxHEIGHT`.
Manual configuration @@ -406,13 +301,9 @@ Supported aspect ratios: `1:1`, `16:9`, `9:16`, `3:4`, `4:3`. Sizes can be speci
-Other supported models: `cogview-4`, `cogview-4-250304`, `cogview-3-flash`. Reference images are not supported by this integration. - ### ModelScope -ModelScope (魔搭社区) API-Inference supports text-to-image generation and image editing via an async task pattern. - -Supported aspect ratios: `1:1`, `16:9`, `9:16`, `3:4`, `4:3`. Sizes can be specified as `WIDTHxHEIGHT` (e.g. `1024x1024`, `1664x928`) or using aspect ratio presets. +Supports text-to-image and image editing (e.g. `Qwen/Qwen-Image-2512`). Supported aspect ratios: `1:1`, `16:9`, `9:16`, `3:4`, `4:3`, or explicit `WIDTHxHEIGHT`.
Manual configuration @@ -436,61 +327,24 @@ Supported aspect ratios: `1:1`, `16:9`, `9:16`, `3:4`, `4:3`. Sizes can be speci
-## Artifacts +## Prompting Tips -Generated images are stored under the active nanobot instance's media directory: - -```text -~/.nanobot/media/generated/YYYY-MM-DD/img_. -~/.nanobot/media/generated/YYYY-MM-DD/img_.json -``` - -For non-default config locations, the media directory is relative to the active config file's directory. - -The JSON sidecar stores: - -| Field | Meaning | -|-------|---------| -| `id` | Short generated image id, such as `img_ab12cd34ef56` | -| `path` | Local image path used internally for follow-up edits | -| `mime` | Detected image MIME type | -| `prompt` | Prompt used for the generation | -| `model` | Provider model | -| `provider` | Provider name | -| `source_images` | Reference image paths used for edits | -| `created_at` | Creation timestamp | - -Do not paste base64 image payloads into chat. The agent should keep local artifact paths internal unless the user explicitly asks for debugging details. - -## Prompting - -Good image prompts include: - -- Subject and scene. -- Composition, camera, or layout. -- Style, mood, lighting, and color palette. -- Exact text that must appear in the image, quoted. -- Constraints such as "keep the same character" or "preserve the logo". - -Example: +For better results, include the subject, composition, style/mood/lighting, any exact quoted text, and what should stay unchanged when editing: ```text A minimal app icon for nanobot: friendly robot head, rounded square, soft blue and white palette, clean vector style, no text ``` -For edits, describe what should change and what must stay fixed: - ```text Use the reference image. Keep the same robot and composition, change the palette to warm orange, and add a subtle sunrise background. ``` ## Troubleshooting -| Symptom | Check | -|---------|-------| -| `generate_image` is not available | Enable image generation in **Settings → Capabilities → Image generation** and save. For manual config changes, restart the gateway | -| Missing API key error | Configure `providers..apiKey`; if using `${VAR_NAME}`, confirm the environment variable is visible to the gateway process | -| `unsupported image generation provider` | Use `openrouter`, `openai`, `openai_codex`, `custom`, `aihubmix`, `minimax`, `gemini`, `ollama`, `stepfun`, `zhipu`, or `modelscope` | -| AIHubMix says `Incorrect model ID` | Use `model: "gpt-image-2-free"`; nanobot expands it to the required `openai/gpt-image-2-free` model path internally | -| Generation times out | Try a smaller/default image size, set AIHubMix `extraBody.quality` to `"low"`, or retry later | -| Reference image rejected | Reference image paths must be inside the workspace or nanobot media directory and must be valid image files | +| Symptom | Fix | +|---|---| +| Image generation is unavailable | Enable it in **Settings → Capabilities → Image generation** and save (restart the gateway after manual JSON edits) | +| Missing API key | Configure the provider's API key; if using `${VAR_NAME}`, confirm the variable is set before starting nanobot | +| Unsupported image provider | Use one of the supported providers listed above or a saved custom connection | +| Generation times out | Try a smaller size, set `extraBody.quality: "low"` on AIHubMix, or retry later | +| Reference image rejected | Confirm the file is a valid image inside your workspace or nanobot media directory | diff --git a/docs/mcp-presets.md b/docs/mcp-presets.md index 9613bae10..dffda50fc 100644 --- a/docs/mcp-presets.md +++ b/docs/mcp-presets.md @@ -1,12 +1,13 @@ -# MCP service presets +# MCP Service Presets -Open **Apps → MCP** to find a service, configure its connection, and select **Connect**. Presets save MCP server configuration; the gateway discovers and runs the tools. Each service still requires its own account access and permissions. The tables below list all built-in presets. +Open **Apps → MCP** in the WebUI to pick a built-in service preset, enter its credentials (or sign in through your browser), and click **Connect**. Each service still requires your own account and permissions. -For a remote HTTP/SSE service that needs a proxy, first set the shared address in **Settings → Advanced → Shared proxy**, then turn on **Use proxy** in its connection dialog before selecting **Connect**. The gateway uses that route for MCP requests and authorization. The browser's sign-in page still uses your browser's own network settings. Local stdio servers keep their own networking configuration. +> [!TIP] +> If a remote HTTP/SSE service needs a proxy, configure **Settings → Advanced → Shared proxy** first, then enable **Use proxy** in that service's connection dialog before clicking **Connect**. -## Hosted services +## Hosted Services -Browser sign-in uses the service's MCP OAuth flow. API-key presets ask for the credential listed below and add it to the required HTTP header or URL parameter. Paste the token itself into the credential field. +Browser OAuth presets open your provider's sign-in page directly. API-key presets ask for your token and attach it automatically. | Service | Authentication | Setup | | --- | --- | --- | @@ -120,13 +121,9 @@ Browser sign-in uses the service's MCP OAuth flow. API-key presets ask for the c | Databricks Genie | API key or token; service MCP URL required | [Official guide](https://docs.databricks.com/aws/en/agents/mcp-tools/authentication-networking) | | TickTick | Browser OAuth | [Server metadata](https://mcp.ticktick.com/.well-known/oauth-protected-resource) | -Datadog uses the MCP endpoint for your Datadog site and a Personal or Service Access Token. DigitalOcean publishes separate endpoints for its services; copy the endpoint for the service you need. Metabase requires an instance with MCP enabled. Copy Sigma's URL from **Profile → Integrations** and Descript's URL from **Settings → Descript MCP**. +## Local Servers -Figma uses the desktop app's local MCP endpoint. Supabase starts a local server in read-only mode; **Supabase (remote)** uses browser sign-in. GitHub uses Docker; **GitHub (remote)** uses a personal access token. Changes to credentials retain the connection's tool selection, timeout, and other saved settings. - -## Local servers - -Local servers run on the gateway computer. Install the runtime or application listed for each service. Stdio servers use a managed working directory under the nanobot data directory so their runtime files stay outside the source checkout. Figma connects over HTTP to the local desktop app. +Local servers run on the gateway computer. Make sure the listed runtime (such as Node.js/`npx`, `uvx`, or Docker) is installed first. | Service | Requirements | Setup | | --- | --- | --- | @@ -143,44 +140,31 @@ Local servers run on the gateway computer. Install the runtime or application li | ClickHouse | uvx and ClickHouse connection credentials | [Server guide](https://github.com/ClickHouse/mcp-clickhouse) | | Redis | uvx and Redis connection URL | [Server guide](https://github.com/redis/mcp-redis) | | dbt | uvx and dbt account with a static subdomain | [Server guide](https://docs.getdbt.com/docs/dbt-ai/setup-local-mcp) | -| Google Workspace | uvx and Google Cloud OAuth app with the required APIs enabled | [Server guide](https://github.com/taylorwilsdon/google_workspace_mcp) | +| Google Workspace | uvx and Google Cloud OAuth app with required APIs enabled | [Server guide](https://github.com/taylorwilsdon/google_workspace_mcp) | | Microsoft 365 | Node.js, npx, and Microsoft work or school account | [Server guide](https://github.com/Softeria/ms-365-mcp-server) | | Adobe Express Developer | Node.js and npx | [Server guide](https://developer.adobe.com/express/add-ons/docs/guides/getting-started/local-development/mcp-server) | | Azure | Node.js, npx, Azure CLI, and Azure sign-in | [Server guide](https://github.com/microsoft/mcp/tree/main/servers/Azure.Mcp.Server) | -| Tableau | Node.js 22.7.5 or later, npx, and Tableau personal access token | [Server guide](https://github.com/tableau/tableau-mcp) | -| BigQuery | Node.js, npx, Google Application Default Credentials, and BigQuery access | [Server guide](https://docs.cloud.google.com/bigquery/docs/pre-built-tools-with-mcp-toolbox) | -| Salesforce DX | Node.js, npx, Salesforce CLI, and an authorized default target org | [Server guide](https://developer.salesforce.com/docs/platform/sfdx-dev/guide/sfdx-dev-mcp-server.html) | -| Shopify Developer | Node.js 18 or later and npx | [Server guide](https://shopify.dev/docs/apps/build/ai-toolkit) | -| AWS | uvx, AWS CLI, configured IAM credentials, and AWS MCP permissions | [Server guide](https://docs.aws.amazon.com/agent-toolkit/latest/userguide/getting-started-aws-mcp-server.html) | +| Tableau | Node.js 22.7.5+ and npx; Tableau personal access token | [Server guide](https://github.com/tableau/tableau-mcp) | +| BigQuery | Node.js, npx, Google Application Default Credentials | [Server guide](https://docs.cloud.google.com/bigquery/docs/pre-built-tools-with-mcp-toolbox) | +| Salesforce DX | Node.js, npx, Salesforce CLI, and default target org | [Server guide](https://developer.salesforce.com/docs/platform/sfdx-dev/guide/sfdx-dev-mcp-server.html) | +| Shopify Developer | Node.js 18+ and npx | [Server guide](https://shopify.dev/docs/apps/build/ai-toolkit) | +| AWS | uvx, AWS CLI, configured IAM credentials | [Server guide](https://docs.aws.amazon.com/agent-toolkit/latest/userguide/getting-started-aws-mcp-server.html) | | Alation | uvx and Alation service-account integration | [Server guide](https://github.com/Alation/alation-ai-agent-sdk/tree/main/python/dist-mcp) | -| Expedia Travel Recommendations | uvx and Expedia Travel Recommendations API key | [Server guide](https://github.com/ExpediaGroup/expedia-travel-recommendations-mcp) | +| Expedia Travel Recommendations | uvx and Expedia API key | [Server guide](https://github.com/ExpediaGroup/expedia-travel-recommendations-mcp) | -Google Workspace uses the community `workspace-mcp` server by Taylor Wilsdon. Create a Google Cloud OAuth app, enable the APIs you need, and follow the server's sign-in instructions. It provides Gmail, Drive, Calendar, Docs, Sheets, Slides, Contacts, and other Workspace tools. Microsoft 365 uses Softeria's community server for work or school accounts; ask its login tool to start the device-code flow. Tenant administrators may need to approve access. Personal Outlook accounts can use a custom configuration without `--org-mode`. +## Service-Specific Notes -Firebase uses your Firebase CLI sign-in. The dbt server completes its own browser sign-in and requires an account with a static subdomain. MongoDB starts with `--readOnly`; ClickHouse uses HTTPS and read-only queries by default. Redis takes a connection URL such as `rediss://default:password@your-redis-host:6379/0`; use `rediss://` for TLS and the port supplied by your deployment. +
+Setup notes for specific presets (Datadog, Google Workspace, Microsoft 365, databases, admin-gated services) -Azure uses your Azure CLI sign-in. BigQuery uses Google Application Default Credentials and the project ID you provide. Salesforce DX uses your authorized default target org and enables its data, orgs, and metadata toolsets. AWS uses the official SigV4 proxy with your IAM credentials; its preset connects to the `us-east-1` managed endpoint. Alation uses a service-account integration. Tableau uses a personal access token and requires a site name for Tableau Cloud. +- **Local vs. remote pairs:** **Supabase** runs locally in read-only mode while **Supabase (remote)** uses browser OAuth. **GitHub** runs locally via Docker while **GitHub (remote)** uses a personal access token. **Figma** connects to the local Figma desktop app. +- **Custom endpoint URLs:** Datadog, DigitalOcean, Metabase, Sigma (**Profile → Integrations**), Descript (**Settings → Descript MCP**), Snowflake, and Zoho CRM require copying your organization's MCP URL from their setup guide. +- **Google Workspace & Microsoft 365:** Google Workspace uses the community `workspace-mcp` server (create a Google Cloud OAuth app and enable the APIs you need). Microsoft 365 targets work/school accounts and may require tenant admin approval (personal Outlook accounts can use a custom MCP config without `--org-mode`). +- **Databases:** MongoDB and ClickHouse default to read-only queries. Redis expects a connection URL such as `rediss://default:password@your-host:6379/0`. +- **Admin approval required:** Gong, Vanta, Omni, and Clay require an organization admin to enable MCP integration first. +- **Documentation-only presets:** OpenAI Developers, Redis Docs, Adobe Express Developer, Shopify Developer, and ThoughtSpot Developer expose developer documentation rather than private account administration. +- **Services needing a custom MCP connection:** Services that require fixed OAuth clients or custom app registration (such as Asana, HubSpot, Slack, Canva, Dropbox, Box, Docusign, Zoom, and QuickBooks Online) are not built-in presets—add them through **Apps → Add MCP server** after completing their setup guide. -For Gong, a Tech admin must create an **Automatic** MCP integration and register nanobot's callback URL. Vanta requires an Admin account. Omni requires administrator-enabled AI, MCP, and personal access tokens. Supermetrics requires a subscription with API access. Zoho CRM provides separate server URLs for Data Insights, Data Operations, Module Customization, and Automation; copy the one you need from its setup guide. +
-Semrush's preset uses an API key and adds the `Apikey` authorization prefix. Snowflake requires a managed MCP server URL, a programmatic access token, and grants on the tools exposed by that server. Provider guides list regional alternatives for services whose presets use a US endpoint. - -Clay workspace administrators must enable MCP and allow **Unknown** clients for dynamic registration. Databricks' access-token preset supports provided and registered MCP services for local testing; servers hosted on Databricks Apps require OAuth with a registered client. Pocket, Hostinger Mail, GSC Wizard, and Talarion use the API keys or tokens issued by their own account settings. - -## Access and capability limits - -A listing in another product's plugin directory does not supply a portable MCP URL or reusable credentials. Native OAuth presets require authorization-server discovery and dynamic client registration. Services that require a fixed OAuth client, client allowlisting, or additional onboarding need their own setup. This includes [Asana](https://developers.asana.com/docs/integrating-with-asanas-mcp-server), [HubSpot](https://developers.hubspot.com/docs/apps/developer-platform/build-apps/integrate-with-the-remote-hubspot-mcp-server), [Slack](https://docs.slack.dev/ai/slack-mcp-server/), [Canva](https://www.canva.dev/docs/apps/mcp/verify-app/), and [Dropbox](https://help.dropbox.com/integrations/connect-dropbox-mcp-server). Use a compatible local server or custom connection when you have completed the service's requirements. - -Provider plans, quotas, enabled tools, and organization policies still apply. A configured connection is distinct from a connected runtime; test it from Apps to inspect the actual tool list. Tool access follows your provider permissions and nanobot's configured policy. [MCP configuration](./configuration.md#mcp-model-context-protocol) describes tool allowlists, timeouts, OAuth token storage, and private-host access. - -OpenAI Developers, Redis Docs, and Adobe Express Developer provide documentation. They do not grant access to private OpenAI accounts, Redis databases, or Adobe designs. Instacart's Developer Platform server creates recipe pages and shopping lists; it does not reproduce the account-based shopping plugin. MCP tools also do not imply support for another host's embedded plugin UI. - -Shopify Developer provides developer resources and validation; it does not supply an authenticated store-administration connection. The separate [Shop MCP](https://shopify.dev/changelog/posts/add-shopping-and-shop-pay-checkout-to-any-agent-with-shop-mcp) currently requires a protocol version unsupported by nanobot's MCP SDK. [tldraw's MCP App](https://tldraw.dev/blog/tldraw-mcp-app) depends on an embedded interactive canvas, which nanobot does not render. - -[Box](https://developer.box.com/guides/box-mcp), [G2](https://documentation.g2.com/docs/g2-mcp-server), [Lovable](https://github.com/lovablelabs/mcp), and [Docusign](https://developers.docusign.com/platform/mcp-server/) require client-specific OAuth setup. [QuickBooks Online's local server](https://github.com/intuit/quickbooks-online-mcp-server) requires an Intuit OAuth app, an initial authorization handshake, and a local build. These services need a custom connection rather than a native browser-sign-in preset. - -Expedia Travel Recommendations provides API-based travel recommendations and needs an Expedia API key. GoDaddy's preset searches public domain data. ThoughtSpot Developer provides documentation; its authenticated administrative endpoint needs a custom connection. [Zoom](https://developers.zoom.us/docs/mcp/servers/) and [Tredict](https://www.tredict.com/blog/mcp_server_docs/) also require provider-specific OAuth setup. - -## Maintaining presets - -The built-in catalogue is maintained in [`nanobot/webui/mcp_presets.json`](../nanobot/webui/mcp_presets.json). Each entry declares its server configuration and setup fields. Field types and defaults are defined in [`mcp_presets.py`](../nanobot/webui/mcp_presets.py); the gateway validates the catalogue when loading it. Add service connections to the JSON file and document their requirements here. +Test any newly saved connection from **Apps** to inspect the tools it exposes. For advanced options like tool allowlists and timeouts, see [Configuration: MCP](./configuration.md#mcp-model-context-protocol). diff --git a/docs/memory.md b/docs/memory.md index f6a7ab2d2..01ae5cd2d 100644 --- a/docs/memory.md +++ b/docs/memory.md @@ -1,225 +1,111 @@ # AI Agent Memory in nanobot -nanobot keeps recent conversation history separate from longer-term information such as your preferences. Conversations are summarized as they grow or when you run `/compact`; if Dream is enabled, it can use those summaries to update long-term memory on its schedule, or when you run `/dream`. You can inspect and correct saved preferences. A reply saying it understood your preference does not by itself confirm that the preference was saved. +nanobot keeps recent chat history separate from long-term memory like your preferences, background, and ongoing project knowledge. You can inspect, edit, and restore long-term memory at any time. -## The Design +> [!NOTE] +> An agent replying "Got it, I'll remember that" does not automatically guarantee a preference was written to long-term memory. You can verify or update it directly using the steps below. -nanobot does not treat memory as one giant file. +## How Memory Works -It separates memory into layers, because different kinds of remembering deserve different tools: - -- `session.messages` holds the living short-term conversation. -- `memory/history.jsonl` is the running archive of compressed past turns. -- `SOUL.md`, `USER.md`, and `memory/MEMORY.md` hold resident memory included in each conversation. -- `memory/wiki/` holds detailed Markdown knowledge read only when relevant to a task. -- `GitStore` records how resident memory and wiki pages change over time. - -This keeps the system light in the moment, but reflective over time. - -## The Flow - -Long-term memory is updated in two stages. - -### Stage 1: Consolidator - -When a conversation grows large, nanobot summarizes the conversation covered by compaction and appends the result to `memory/history.jsonl`. The model continues with the summary and any messages after it. The original messages remain in your saved chat history, but messages covered by the summary are no longer sent to the model verbatim. Each summary preserves useful long-term facts and a short handoff for active work. - -Compaction also runs after a configured period of inactivity, or when you send `/compact`. See [Auto Compact](./configuration.md#auto-compact) for idle timing and how to disable automatic idle compaction. - -Automatic compaction does not post lifecycle notices to built-in chat channels by default. This only silences chat messages: compaction still runs, and WebUI/TUI retain structured status and history. Manual `/compact` keeps its start and outcome feedback. Set `channels.showCompactionNotices: true` to enable automatic notices globally, or set `showCompactionNotices` in a channel's configuration to override that default. Omitted or `null` channel overrides inherit the global value; existing explicit QQ overrides are preserved. - -This file is updated as conversations are summarized. It uses one JSON record per line so nanobot can track which summaries have already been processed; it is primarily an internal working history, not a permanent archive. - -Each line is a JSON object: - -```json -{"cursor": 42, "timestamp": "2026-04-03 00:02", "content": "- User prefers dark mode\n- Decided to use PostgreSQL"} +```mermaid +flowchart LR + C["Active Chat"] -->|"/compact or auto-summarize"| H["Summaries (history.jsonl)"] + H -->|"/dream or periodic schedule"| R["Long-Term Memory (SOUL, USER, MEMORY, wiki/)"] + C -->|"Direct 'Remember...' request"| R ``` -After scheduled or manual Dream runs, nanobot can prune the oldest entries already processed by Dream and atomically rewrite the file. The default retention target is 1000 entries; entries Dream has not processed are retained even when this exceeds the target. The journal is therefore not a permanent archive of every summary. +nanobot organizes memory into four layers so conversations stay fast while useful knowledge builds up over time: -It is not the final memory. It is the material from which final memory is shaped. +| Layer | Where it lives | What it holds | +|---|---|---| +| Active conversation | Session history | Recent messages in the current topic or chat | +| Conversation summaries | `memory/history.jsonl` | Compact summaries of older turns created when a chat grows long or when you run `/compact` | +| Resident memory | `SOUL.md`, `USER.md`, `memory/MEMORY.md` | Core personality, user preferences, and key facts loaded into every conversation | +| Knowledge wiki | `memory/wiki/` | Detailed Markdown notes read on demand when relevant to a task | -### Stage 2: Dream +Long-term memory updates in two ways: -`Dream` is the slower, more thoughtful layer. It runs on a cron schedule while the gateway is running and Dream is enabled, and can also be triggered manually. A standalone Python SDK instance does not start this scheduler. +1. **Direct updates:** When you ask nanobot to remember something (or share a lasting preference) in a chat with write access, it can update the relevant memory file right away. +2. **Compaction + Dream:** As conversations grow long (or after idle time, or when you run `/compact`), nanobot summarizes older messages and saves the summary to `memory/history.jsonl`. Periodically (or when you run `/dream`), **Dream** reviews new summaries and makes focused edits to your resident memory files and `memory/wiki/`. -Dream reads: +Every Dream update is versioned with Git in your agent workspace, so you can inspect what changed and roll back if needed. -- new entries from `memory/history.jsonl` -- the current `SOUL.md` -- the current `USER.md` -- the current `memory/MEMORY.md` -- relevant linked pages in `memory/wiki/`, when more detail is needed +## Where Memory Files Live -Each manual or scheduled invocation starts one Dream task for all unprocessed history present when it begins. The runtime supplies the `history.jsonl` path, fixed start/end lines, and cursor range instead of embedding clipped records in the prompt. Dream reads and consolidates the full content of that range, oldest first; the instructions describe what to read without prescribing a tool or paging procedure. Records arriving after the fixed boundary belong to the next run. There is no outer loop restarting Dream every 20 records or enforcing an 8,000-token history batch. - -A normally completed task advances the cursor to the captured boundary even when no memory edit is needed. If the task fails or reaches its execution limits, the entire range remains pending for the next invocation; edits already written are retained, not rolled back. The model's normal context and tool-output limits still apply, so large reads should be paginated rather than treated as complete when truncated. Records added during a run wait for the next run, and overlapping manual and scheduled runs are serialized within the agent. Already processed records are not automatically replayed on upgrade. - -Dream makes focused edits to resident memory and relevant wiki pages rather than rewriting everything. Core preferences and behavior constraints remain resident; task-specific detail can move into the wiki with a brief navigation link. - -This is why nanobot's memory is not just archival. It is interpretive. - -## The Files - -In this page, `workspace` means the configured **agent workspace** (the default is `~/.nanobot/workspace/`, or the path passed with `--workspace`). Selecting a different project in the WebUI changes that chat's project context and tool working directory; it does not relocate the files below. +All memory files belong to your **agent workspace** (`~/.nanobot/workspace/` by default): ```text workspace/ -├── .git/ # Version history for long-term memory files -├── SOUL.md # The bot's long-term voice and communication style -├── USER.md # Stable knowledge about the user +├── SOUL.md # Agent voice and communication style +├── USER.md # Stable preferences and facts about you ├── prompts/ -│ ├── README.md # Notes for memory guidance files -│ └── dream.md # Optional instructions for how Dream organizes memory +│ └── dream.md # Optional custom instructions for Dream └── memory/ - ├── MEMORY.md # Resident facts and brief wiki navigation - ├── wiki/ # Optional, created when useful knowledge is added - │ ├── index.md # Topic links, read on demand - │ └── projects/ # Example topic grouping, not a required schema - ├── history.jsonl # History summaries with bounded retention after Dream - ├── .cursor # Consolidator write cursor - └── .dream_cursor # Dream consumption cursor + ├── MEMORY.md # Core facts and links to wiki pages + ├── wiki/ # Optional detailed Markdown notes + │ └── index.md # Topic index read on demand + └── history.jsonl # Recent conversation summaries ``` -A selected project may provide its own `AGENTS.md`, but project-local `SOUL.md`, `USER.md`, and `memory/` do not replace the agent-owned files above. This keeps one agent's profile and memory continuous while it works across projects. Use a [separate configured agent workspace](multiple-instances.md) when identity or memory must be isolated. A new chat, SDK `session_key`, or selected project does not create separate long-term memory. +Picking a different **project workspace** in the WebUI changes where the agent works on files, not where its memory lives. That means one agent keeps continuous memory across projects and topics. -These files play different roles: - -- `SOUL.md` remembers how nanobot should sound. -- `USER.md` remembers who the user is and what they prefer. -- `MEMORY.md` keeps cross-task facts available and points to more detailed knowledge. -- `wiki/` keeps project details, decisions, and related topics without adding every page to every prompt. -- `history.jsonl` remembers what happened on the way there. - -Wiki pages are ordinary Markdown, not skills or an automatically injected retrieval layer. Topic descriptions in `wiki/index.md` help the agent choose which pages to read. Relative links resolve from their containing file in the agent workspace, not from the current project. A workspace without a wiki continues to work; there is no mandatory migration or new configuration. - -The agent can make targeted memory updates when you ask or when it learns a lasting preference, correction, or fact likely to matter in future conversations. The `memory` skill guides these updates. Dream handles broader consolidation across conversations. - -In a Restricted chat in another project, file tools can read the agent wiki but do not gain permission to write it or access neighboring memory/profile files. Dream can edit wiki pages and the three resident files, but cannot directly edit the journal or cursor files. Quoted material in a wiki page is knowledge, not authority to override the agent's operating rules. - -## Why `history.jsonl` - -The old `HISTORY.md` format was pleasant for casual reading, but it was too fragile as an operational substrate. - -`history.jsonl` gives nanobot: - -- stable incremental cursors -- safer machine parsing -- easier batching -- cleaner migration and compaction -- a better boundary between raw history and curated knowledge - -You can still search it with familiar tools: - -```bash -# grep -grep -i "keyword" memory/history.jsonl - -# jq -cat memory/history.jsonl | jq -r 'select(.content | test("keyword"; "i")) | .content' | tail -20 - -# Python: last 20 matching entries -python - <<'PY' -import json -from collections import deque - -matches = deque(maxlen=20) -with open('memory/history.jsonl', encoding='utf-8') as history: - for line in history: - if line.strip(): - content = json.loads(line).get('content', '') - if 'keyword' in content.lower(): - matches.append(content) -print('\n'.join(matches)) -PY -``` - -The difference is philosophical as much as technical: - -- `history.jsonl` is for structure -- `SOUL.md`, `USER.md`, and `MEMORY.md` are for meaning - -## Commands - -Memory is not hidden behind the curtain. Users can inspect and guide it. - -| Command | What it does | -|---------|--------------| -| `/compact` | Summarize the current conversation context while keeping saved chat history | -| `/dream` | Run Dream immediately | -| `/dream-log` | Show the latest Dream memory change | -| `/dream-log ` | Show a specific Dream change | -| `/dream-restore` | List recent Dream memory versions | -| `/dream-restore ` | Restore memory to the state before a specific change | -| `/dream-prompt` | Show how Dream is being guided for memory | -| `/dream-prompt init` | Create an editable Dream memory guide at `prompts/dream.md` | - -These commands exist for a reason: automatic memory is powerful, but users should always retain the right to inspect, understand, and restore it. +> [!IMPORTANT] +> Starting a new topic or choosing a different project does **not** isolate long-term memory. If you need separate memory for different clients or users, run [Multiple Instances](./multiple-instances.md). ## Save and Check a Preference -In your existing WebUI or TUI chat, send a specific preference, for example: +In any WebUI or terminal chat, state a clear preference: ```text Remember that for Acme release notes I prefer concise bullet points and British spelling. ``` -If the chat has write access to the relevant memory file, the agent can save the preference in the same turn. Ask which file it updated and check the preference in a new chat in the same instance. To correct it, say what should replace the old value. +- If the chat has write access to your agent workspace, nanobot can save it right away. Ask which file it updated, then verify in a new topic. +- If you are in a **Restricted** chat inside a different project folder, nanobot can read `memory/wiki/` but cannot write to your agent memory files. Switch to the agent workspace, edit the file yourself, or run `/compact` followed by `/dream` to consolidate recent chats. -If a Restricted chat in another project cannot write the file, select the agent workspace or edit the file yourself. To consolidate conversations instead, run `/compact`, wait for it to finish, then run `/dream`. Dream reads compacted history, so it may find nothing new after a short conversation that has not been compacted. +## Memory Commands -`/dream-log` shows committed memory changes; a direct edit does not create its own version. `/dream-restore` lists versions, and `/dream-restore ` restores the memory state before that change, including other changes made in that version. +Use these slash commands in chat to inspect, run, or restore memory: -For separate clients with private context, create separate [instances](multiple-instances.md). Labelling a fact with a client name helps organization but does not isolate access. +| Command | What it does | +|---|---| +| `/compact` | Summarize the current conversation now (full chat history remains visible) | +| `/dream` | Run Dream consolidation now | +| `/dream-log` | Show the latest Dream memory change | +| `/dream-log ` | Show a specific Dream memory change | +| `/dream-restore` | List recent Dream memory versions | +| `/dream-restore ` | Restore memory files and wiki pages to the state before that change | +| `/dream-prompt` | Show the current instructions guiding Dream | +| `/dream-prompt init` | Create an editable `prompts/dream.md` guide for this workspace | -## Versioned Memory - -After Dream changes long-term memory files, nanobot can record that change with `GitStore`. - -This gives memory a history of its own: - -- you can inspect what changed -- you can compare versions -- you can restore a previous state, including wiki pages that were added, deleted, or renamed - -Restoring a version returns the managed memory files and wiki page set to the state before that change, including the saved Dream cursor when present. A snapshot from before the wiki existed removes later wiki pages. This is a whole-memory restore, not a selective undo of one page. If the memory repository has staged changes or uncommitted edits to memory (including new wiki pages), restore refuses to proceed. Commit or undo those changes before retrying. - -That turns memory from a silent mutation into an auditable process. +> [!NOTE] +> `/dream-restore ` restores all managed memory files and wiki pages together (not a single page). If you have uncommitted manual edits in memory files, commit or revert them before restoring. ## Guiding Dream -Dream decides what to keep, update, or forget using nanobot's built-in memory instructions. Most users can leave this alone. - -If one workspace needs a different memory style, create an editable guide: +Most users can leave Dream's built-in instructions as they are. To customize how Dream organizes memory for one workspace, run: ```text /dream-prompt init ``` -This creates: - -```text -workspace/prompts/dream.md -``` - -Edit that file in plain Markdown. When it has content, Dream follows it for this workspace before reading the latest conversation history. You do not need to paste history into the file; Dream adds a `## Conversation History` block with the file path and fixed reading range automatically. Existing custom guides are not overwritten: a guide that only maintains the resident files can continue doing so; add wiki routing and navigation guidance if you want it to use the new layer. - -To return to nanobot's default behavior, delete `prompts/dream.md` or leave it empty. - -Each workspace has its own guide. Changing this file does not affect other nanobot workspaces. +Edit `workspace/prompts/dream.md` in plain Markdown. Dream follows your guide automatically before reviewing new summaries. Delete or empty the file to return to nanobot's defaults. ## Configuration -Enable or disable Dream through **Settings → Capabilities → Memory consolidation**. Its frequency, cron override, and model override have no graphical controls; configure those fields directly below. +Turn Dream on or off in **Settings → Capabilities → Memory consolidation**. Dream runs automatically while `nanobot gateway` is running. -Dream is configured under `agents.defaults.dream`: +To change how often Dream runs or pick a dedicated model preset for it, configure `agents.defaults.dream` in `~/.nanobot/config.json`: + +
+Manual configuration ```json { "agents": { "defaults": { "dream": { + "enabled": true, "intervalH": 2, "modelOverride": null } @@ -229,25 +115,12 @@ Dream is configured under `agents.defaults.dream`: ``` | Field | Meaning | -|-------|---------| +|---|---| +| `enabled` | Turn periodic Dream consolidation on or off | | `intervalH` | How often Dream runs, in hours | -| `cron` | Cron expression override (takes precedence over `intervalH`) | -| `modelOverride` | Optional model preset name used for Dream | +| `cron` | Optional cron expression override (takes precedence over `intervalH`, e.g. `"0 */4 * * *"`) | +| `modelOverride` | Optional named model preset from `modelPresets` to use for Dream | -In practical terms: +To adjust automatic idle compaction, see [Auto Compact](./configuration.md#auto-compact). To show automatic compaction notices in chat apps (hidden by default; manual `/compact` always shows feedback), set `channels.showCompactionNotices: true`. -- `intervalH` is the normal way to configure Dream frequency. Internally it runs as an `every` schedule. -- `cron` overrides `intervalH` when set, allowing precise cron expressions (e.g. `0 */4 * * *`). -- `modelOverride` selects a named entry from `model_presets` for Dream. It accepts preset names only; raw model identifiers are not supported. If omitted, Dream uses the main agent's selected runtime. - -## In Practice - -What this means in daily use is simple: - -- conversations can stay fast without carrying infinite context -- durable facts can become clearer over time instead of noisier -- the user can inspect and restore memory when needed - -Memory should not feel like a dump. It should feel like continuity. - -That is what this design is trying to protect. +
diff --git a/docs/multiple-instances.md b/docs/multiple-instances.md index 31347c772..a20690277 100644 --- a/docs/multiple-instances.md +++ b/docs/multiple-instances.md @@ -1,21 +1,22 @@ # Multiple Instances -Use a separate home directory for each instance. Place `--home` before the subcommand; without it, nanobot uses `~/.nanobot`. +Run separate nanobot instances whenever you want completely independent settings, chat bots, and long-term memory—for example, separating personal and work agents or isolating different clients. -Use this for separate clients, users, or personal/work agents that need independent configuration and long-term memory. A new topic or a different project folder inside one instance does not provide that separation. - -Separate homes and workspaces separate stored application data; they do not create an operating-system security boundary. Processes running as the same OS user may still access each other's files through unrestricted tools. For mutually untrusted users, use separate OS accounts or containers with separate mounts and credentials, and configure [tool restrictions](./configuration.md#security) for each instance. +> [!NOTE] +> Starting a new topic or picking a different project folder inside one instance does **not** separate long-term memory. Use separate instances when data must not mix. +> +> Separate instances separate nanobot data, not OS permissions. For mutually untrusted users, run them under separate OS accounts or containers and configure [tool restrictions](./configuration.md#security). ## Quick Start +Pass `--home ` before the subcommand (without it, nanobot uses `~/.nanobot`). Give each running instance its own WebUI and gateway ports: + ```bash nanobot --home ~/.nanobot-work onboard nanobot --home ~/.nanobot-work webui --port 8766 --gateway-port 18791 ``` -Configure this instance's models in **Settings → Models** and chat apps through **Channels** in the sidebar. Onboarding saves its default workspace as `~/.nanobot-work/workspace`. Use the collapsed examples in the [configuration reference](./configuration.md) for deployment-managed JSON. - -Use the same home for other commands: +Configure this instance's models in **Settings → Models** and chat apps in **Channels**. Use the same `--home` flag for any other command targeting this instance: ```bash nanobot --home ~/.nanobot-work status @@ -23,34 +24,31 @@ nanobot --home ~/.nanobot-work agent nanobot --home ~/.nanobot-work gateway --port 18791 ``` -Concurrent instances need distinct gateway health ports and WebUI/channel ports. `webui --port` sets the WebUI/WebSocket port; `--gateway-port` sets the health port. For `gateway`, `--port` sets the health port. You can also save these ports in each config. Chat channels should use separate bot credentials. +Each concurrent instance needs distinct `--port` (WebUI, default `8765`) and `--gateway-port` (gateway health, default `18790`) values, plus its own chat-bot tokens. You can also save those ports in each instance's `config.json`. -## Path Resolution +## Where Each Instance Stores Data | Data | Location | -|------|----------| -| Config | `/config.json`, or explicit `--config` | -| Workspace | `/workspace` by default; saved `agents.defaults.workspace` takes precedence; `--workspace` overrides both | -| Sessions | `/sessions//` | -| Media, logs, runtime state | Under the config directory | -| Memory, skills, cron jobs | Under the workspace | -| CLI input history | `/history/cli_history` | +|---|---| +| Config | `/config.json` (or explicit `--config`) | +| Workspace (memory, skills, automations) | `/workspace/` by default (or explicit `--workspace`) | +| Sessions, media, logs, and CLI history | Inside `/` (or the directory of `--config`) | -An explicit `--config` also selects the runtime data directory. Keep each config in its own directory and use separate workspaces to isolate memory, skills, and sessions. A new home gets its own config and default workspace; existing paths saved in a config remain unchanged when you select a different `--home`. Check which paths this instance will use with `nanobot --home ~/.nanobot-work status`. Selecting a home does not move or rewrite paths saved in an existing config. +Verify which paths an instance will use at any time with: -For custom config/workspace locations: +```bash +nanobot --home ~/.nanobot-work status +``` + +If you prefer custom directories instead of `--home`, pass `--config` and `--workspace` directly: ```bash nanobot onboard --config ~/bots/work/config.json --workspace ~/work-agent nanobot webui --config ~/bots/work/config.json --port 8766 --gateway-port 18791 ``` -You can also copy an existing config into the new directory and change `agents.defaults.workspace`. Model presets can be reused; select a different `agents.defaults.modelPreset` when needed. - -Interactive `agent` and `webui` commands with the same config and explicit workspace selectors share a gateway. Different selectors produce separate runtime state and processes; one-shot and `--classic` agent runs execute directly. Background gateways receive `--home` through their command-line arguments. +Keep each instance's config file in its own directory and outside its workspace so sessions and runtime files stay cleanly separated. ## Health Check -Each gateway serves `GET /health` on `gateway.host:gateway.port`, bound to `127.0.0.1` by default. It returns `200` when the WebSocket channel is disabled or running, and `503` when enabled but not running. The JSON fields are `status`, `process`, `ready`, and `websocket`; other paths return `404`. - -This checks process liveness and WebSocket readiness, not other chat channels, MCP servers, or model connectivity. See [CLI Reference](./cli-reference.md#gateway) for gateway management commands. +Each gateway exposes `GET /health` on `127.0.0.1:` (`18790` by default), returning HTTP `200` when the gateway and WebSocket channel are ready (or `503` if WebSocket is enabled but not ready). See [CLI Reference: Gateway](./cli-reference.md#gateway) for service management commands. diff --git a/docs/my-tool.md b/docs/my-tool.md index d92dc710f..eee660abf 100644 --- a/docs/my-tool.md +++ b/docs/my-tool.md @@ -1,202 +1,53 @@ # My Tool -This page is for operators configuring the agent's runtime self-inspection tool. It describes what the agent can read or change at runtime, and what it saves. Scratchpad values survive across turns until the agent runtime restarts; they are shared by sessions using that runtime, not private per-session storage or durable preferences. +The `my` tool lets nanobot inspect its own runtime state—such as which model, workspace, or iteration limit it is using—and optionally adjust safe runtime settings without editing `config.json`. -## Why You Need It +## What It Lets the Agent Do -Normal tools let the agent operate on the outside world (read/write files, search code). But the agent knows nothing about itself — it doesn't know which model it's running on, which workspace it can access, or which runtime limits apply. - -My tool fills this gap. With it, the agent can: - -- **Inspect the current request**: What model am I using? Which project can I access? What is my per-turn iteration limit? -- **Tune runtime settings**: Adjust the iteration limit or select a configured model preset for the session's next turn when writes are enabled. -- **Keep temporary notes**: Store non-sensitive scratchpad values across turns, without relying on them surviving a restart. +- **Self-inspection (on by default):** Answer questions like *"What model are you using?"*, *"Which project folder is active?"*, *"Is web search enabled?"*, or *"What is your iteration limit?"*. +- **Runtime tuning (opt-in):** Switch the current session's model preset, raise or lower the per-turn iteration limit (`1`–`100`), or keep temporary scratchpad notes across turns. ## Configuration -Enabled by default (read-only mode). The agent can check its state but not set it. +The `my` tool is enabled in **read-only** mode by default. To let the agent adjust allowed runtime settings, merge this into `~/.nanobot/config.json`: -```yaml -tools: - my: - enable: true # default: true - allow_set: false # default: false (read-only) +```json +{ + "tools": { + "my": { + "enable": true, + "allowSet": false + } + } +} ``` -To allow the agent to set its configuration (e.g. switch models, adjust parameters), set `tools.my.allow_set: true`. +Set `"allowSet": true` to allow runtime adjustments. -Legacy `tools.myEnabled` / `tools.mySet` keys are auto-migrated on load, and rewritten in-place the next time `nanobot onboard` refreshes the config. +## What Persists and What Resets -Most modifications are held in memory only. `model_preset` is the exception: it is stored in the current session so the selection survives a restart. +| Change | Persists across turns? | Persists across gateway restart? | +|---|---|---| +| Switching `model_preset` | Yes (current session) | Yes (saved with the session) | +| Adjusting `max_iterations` | Yes (in memory) | No (resets to `config.json`) | +| Scratchpad notes | Yes (shared across turns in memory) | No (cleared on restart) | ---- +> [!NOTE] +> The `my` tool **never** modifies `config.json` on disk. Do not store sensitive secrets or durable user preferences in scratchpad notes—use [Memory](./memory.md) for preferences that should last. -## check — Check "my" current state +## Common Examples -Without a key, returns an overview of inspectable runtime settings. Example values: +You do not need to call the tool manually—just ask nanobot in plain language: -```text -my(action="check") -# → max_iterations: 40 -# context_window_tokens: 200000 -# model: 'anthropic/claude-sonnet-4-6' -# model_preset: 'deep' -# workspace: PosixPath('/tmp/agent-workspace') -# workspace_sandbox: {...} -# provider_retry_mode: 'standard' -# max_tool_result_chars: 16000 -# ... -``` +- *"What model and workspace are you using right now?"* +- *"Why didn't you search the web?"* (nanobot can check whether web search is enabled) +- *"Switch this conversation to my `deep` preset."* (when `allowSet` is enabled) +- *"Give yourself up to 80 iterations for this refactoring task."* (when `allowSet` is enabled) -With a key parameter, drill into a specific config: +Note that `context_window_tokens` reports the configured window capacity, not live token usage. To see live context usage and per-round stats, use the [WebUI context indicator](./webui.md#activity-and-context-usage). -```text -my(action="check", key="workspace_sandbox.workspace_root") -# → Current project path +## Safety Boundaries -my(action="check", key="model") -# → What model I'm currently running on - -my(action="check", key="web_config.enable") -# → Whether web search is enabled -``` - -### What you can do with it - -| Scenario | How | -|----------|-----| -| "What model are you using?" | `check("model")` | -| "Which model preset is active?" | `check("model_preset")` | -| "What is the per-turn iteration limit?" | `check("max_iterations")` | -| "What is the context-window capacity?" | `check("context_window_tokens")` — capacity, not current usage or remaining space | -| "Which project is active?" | `check("workspace_sandbox.workspace_root")` | -| "Is file access restricted to the project?" | `check("workspace_sandbox.restrict_to_workspace")` | -| "Show inspectable runtime settings" | `check()` | - -`workspace` is a legacy display of the agent workspace, not the current project or an access grant. Use `workspace_sandbox` for the active project and file restriction. `exec_config` separately reports shell sandbox settings; shell binds do not grant file tools access. - ---- - -## set — Runtime tuning - -Changes do not require a restart. `model_preset` is saved for the current session and applies to its next turn. Other writable settings are updated in memory; changing the iteration limit does not extend an already-running agent loop. Direct `model` and `context_window_tokens` writes are rejected during an active session because those setters change the shared instance default. Configure a named preset for model or context-window changes instead. - -```text -my(action="set", key="max_iterations", value=80) -# → Bump iteration limit from 40 to 80 - -my(action="set", key="model_preset", value="fast") -# → Use a configured model preset for this session's next turn -``` - -You can also store temporary, non-sensitive state in your scratchpad. Values remain available across turns until the runtime restarts, and are shared by its sessions: - -```text -my(action="set", key="task_focus", value="documentation") -my(action="set", key="response_style", value="concise") -my(action="set", key="task_complexity", value="high") -# → These notes survive across turns, but not a runtime restart -``` - -### Protected parameters - -These parameters have type and range validation — invalid values are rejected: - -| Parameter | Type | Range | Purpose | -|-----------|------|-------|---------| -| `max_iterations` | int | 1–100 | Max model/tool iterations per agent run | -| `context_window_tokens` | int | 4,096–1,000,000 | Instance default; during a session, select through a preset | -| `model` | str | non-empty | Instance default; during a session, select through a preset | -| `model_preset` | str | configured preset name | Current session's preset for its next turn | - -`provider_retry_mode` and `max_tool_result_chars` must match their existing value types. Setting `workspace` changes only the legacy display string, not the active project, shell directory, or file permissions. Unknown top-level keys store JSON-safe scratchpad values rather than creating runtime settings. Nested configuration fields cannot be changed through `my`. - ---- - -## Practical Scenarios - -### "This task is complex, I need more room" - -```text -Agent: This codebase is large, let me switch this session to the configured deep preset. -→ my(action="set", key="model_preset", value="deep") -``` - -### "Simple question, don't waste compute" - -```text -Agent: This is a straightforward question, let me switch to the fast preset. -→ my(action="set", key="model_preset", value="fast") -``` - -### "Remember user preferences across turns" - -```text -Turn 1: my(action="set", key="user_prefers_concise", value=True) -Turn 2: my(action="check", key="user_prefers_concise") -# → True (still remembers the user likes concise replies) -``` - -### "Self-diagnosis" - -```text -User: "Why aren't you searching the web?" -Agent: Let me check my web config. -→ my(action="check", key="web_config.enable") -# → False -Agent: Web search is disabled — please set tools.web.enable: true in your config. -``` - -### "Context capacity" - -```text -Agent: Let me check the context-window capacity. -→ my(action="check", key="context_window_tokens") -# → context_window_tokens: 200000 -``` - -This is the configured capacity, not current occupancy, remaining space, or cumulative token usage. `my` does not expose `_last_usage`. For context and per-round usage, see the [WebUI activity and context indicators](./webui.md#activity-and-context-usage). - -### "Subagent monitoring" - -Use the separate `subagent` tool, not `my`. To list the current session's live tasks or inspect a known task ID: - -```text -subagent(action="check") -subagent(action="check", task_id="") -``` - -Only tasks owned by the current session are accessible. A known task ID can retrieve retained results after completion; finished tasks leave the live list. Checks without a current session identity fail. Background results arrive automatically, so avoid repeated polling. - ---- - -## Safety Mechanisms - -Core design principle: **The tool does not rewrite `config.json`.** Instance-wide changes live in memory only, while `model_preset` persists only as the current session's selector. - -### Off-limits (BLOCKED) - -Cannot be checked or modified — fully hidden: - -| Category | Attributes | Reason | -|----------|-----------|--------| -| Core infrastructure | `bus`, `provider`, `_running` | Changes would crash the system | -| Tool registry | `tools` | Must not remove its own tools | -| Subsystems | `runner`, `sessions`, `consolidator`, `subagents`, etc. | Use dedicated tools instead of inspecting internal managers | -| Sensitive data | `_mcp_servers`, `_pending_queues`, etc. | Contains credentials and message routing | -| Security boundaries | `restrict_to_workspace`, `channels_config` | Bypassing would violate isolation | -| Python internals | `__class__`, `__dict__`, etc. | Prevents sandbox escape | - -### Read-only (check only) - -Can be checked but not set: - -| Category | Attributes | Reason | -|----------|-----------|--------| -| Workspace access | `workspace_sandbox` | Shows the active project and file restriction; cannot change access | -| Execution config | `exec_config` | Can check sandbox/enable status, cannot change it | -| Web config | `web_config` | Can check enable status, cannot change it | - -### Sensitive field protection - -Sub-fields matching sensitive names (`api_key`, `password`, `secret`, `token`, etc.) are blocked from both check and set, regardless of parent path. This prevents credential leaks via dot-path traversal (e.g. `web_config.search.api_key`). +- **Never accessible:** Secrets (`apiKey`, `token`, `password`, `secret`, etc.), internal system objects, and channel credentials are always hidden and blocked from both reading and writing. +- **Read-only:** Workspace security restrictions, shell sandbox settings, and web configuration can be inspected for self-diagnosis, but the agent cannot weaken or modify them. +- **Validated limits:** Writable settings like `max_iterations` (`1`–`100`) and `model_preset` (must be an existing configured preset) are strictly validated. diff --git a/docs/providers.md b/docs/providers.md index 2d37f6726..e54fc1446 100644 --- a/docs/providers.md +++ b/docs/providers.md @@ -2,17 +2,18 @@ Use this page when the first reply fails because of provider/model mismatch, or when you want to adapt the concrete setup example to a different provider. If you already know which provider you want and only need a pasteable setup, use [`provider-cookbook.md`](./provider-cookbook.md). -For normal local setup, open **Settings → Models → New preset**. Select your provider, or choose **Add provider** from the **Provider** menu. See [Configure Your Model](./quick-start.md#2-configure-your-model) for the steps. Enter local endpoints and provider-specific connection fields in that editor; expand **Advanced options** when needed. Expand **Manual configuration** below for headless deployments, config-file management, or diagnosis. +For normal local setup, open **Settings → Models → New preset**, select your provider (or click **Add provider**), and pick a model. Expand **Manual configuration** below if you manage `config.json` directly or deploy headlessly. -The model picker fetches online catalogs for OpenAI Codex, xAI Grok, and GitHub Copilot. An explicit authorization failure hides the picker’s search and model list and offers **Sign in again** using the existing provider login flow. Successful WebUI sign-in clears the catalog cache and restores model selection. Existing presets, selected models, and unsaved preset details are preserved. Network, rate-limit, and service failures instead keep cached or built-in lists available, label them as potentially out of date, and offer **Refresh failed. Click to retry**. Manual model IDs remain available for these temporary failures. A successful chat may have used a fallback preset and does not prove that the selected provider's authorization is still valid. When a live chat uses a fallback model, a dismissible notice above the composer names that model and links to model settings. If the provider explicitly rejected OAuth credentials, the notice instead names the provider that needs a new login, with fallback completion as secondary information. Network errors, ordinary permission denials, and rate limits do not request reauthentication. The notice does not change your selected preset. +> [!NOTE] +> For OAuth providers (OpenAI Codex, xAI Grok, and GitHub Copilot), the model picker fetches available models from your signed-in account. If your session expires, click **Sign in again**; if a fallback model handles a reply, a banner above the composer lets you know. -For every setup, answer three questions: +For every setup, make sure three things match: -1. Which provider owns the credential or endpoint? -2. What model name does that provider expect? -3. Does the provider need `apiKey`, `apiBase`, OAuth login, cloud credentials, or only a local server URL? +1. Which provider owns the credential or endpoint. +2. Which exact model ID that provider expects. +3. What authentication it uses (API key, OAuth sign-in, cloud credentials, or a local server URL). -Prefer a named preset created in **Settings → Models**, then select it in the chat composer. Direct `agents.defaults.provider` and `agents.defaults.model` still work for existing configs, but presets make runtime `/model` switching and fallback chains clearer. Pin `provider` inside the preset while setting up; you can switch back to `"auto"` later. +Prefer creating a named preset in **Settings → Models** and pinning its `provider` explicitly—it makes `/model` switching and fallbacks much easier to manage. ## Choose a Provider Without Guessing @@ -78,15 +79,9 @@ You usually omit `apiBase` for hosted built-in providers such as OpenRouter, Ant Use `proxy` when one provider must send HTTP traffic through a proxy without changing process-wide `HTTP_PROXY` / `HTTPS_PROXY`. Supported providers include `openai`, `custom`, named custom providers, OpenRouter-style gateways, local OpenAI-compatible servers, Anthropic Messages, `openai_codex`, and `xai_grok`. For OAuth providers, this also covers exchanging and refreshing tokens. `bedrock`, `azure_openai`, and `github_copilot` reject `proxy`; use their endpoint-specific configuration instead. -Tool execution requires the API's structured tool-call fields. OpenAI-compatible services that put `` markup in assistant text must expose structured tool calls to use nanobot's tools; nanobot preserves that markup as text. +Tool calling requires a model and endpoint that return structured tool calls (if replies show raw `` or `` text, enable your server's tool-call parser or switch to a tool-capable model). -If a reply contains raw `` or `` tags, check the model and serving endpoint's tool-calling support. For self-hosted models, configure the server's tool-call parser for that model. For hosted services, ask the provider to return structured `tool_calls`, or use a compatible model and endpoint. Code examples remain text and are not executed. Changing the chat channel or hiding tags does not repair an upstream tool-calling format error. - -## Inline Image Requests - -Before sending a large inline image batch, providers prepare smaller copies while keeping the attachment files intact. This applies to Responses, Chat Completions, Anthropic Messages, and Bedrock Converse requests, including images returned by tools and images in Responses history replay. Preparation first re-encodes at the original dimensions, then reduces each dimension by at most 25% if needed, with JPEG quality at least 65. PNG transparency is preserved. The shared 1 MB image data URL budget is a best-effort transport target; small image blocks, animated images, and remote references keep their original payloads. Gateway logs report image sizes and byte counts. - -Preparation preserves each adapter's model and API capability rules. When automatic Responses compatibility fallback is allowed, switching to Chat Completions retains the images. The shared retry policy can retry a non-transient image request error once without images, using text placeholders that explicitly say the images were not delivered. Responses state containing images is discarded before that text-only retry. +Large image attachments are automatically resized/compressed as needed before sending to your model provider while keeping your original files untouched. ## Common Provider Patterns @@ -650,41 +645,31 @@ See [`configuration.md#providers`](./configuration.md#providers) for Bedrock-spe ### OAuth Providers -Some providers do not use API keys in `config.json`. +These providers use account sign-in instead of API keys in `config.json`. You can sign in through **Settings → Models** in the WebUI or from the terminal: -For OpenAI Codex: +**OpenAI Codex** ```bash nanobot provider login openai-codex --set-main ``` -The WebUI reads the account's Codex model catalog online, including current context-window and reasoning-effort metadata. A small compatible catalog remains available when the service cannot be reached. - -After three WebSocket transport failures without a completed reply, the same authenticated session uses HTTP for subsequent attempts. The existing retry policy controls replay and cancellation. WebSocket logs include request bytes, first-event timing, and close codes; unrecognized close reasons are redacted. - -For an eligible X Premium / Grok subscription: +**xAI Grok (requires an eligible X Premium / Grok subscription)** ```bash nanobot provider login xai-grok --set-main ``` -This selects `xai-grok/grok-4.6`. The WebUI model selector reads xAI's online model catalog, so newly available subscription models appear without a nanobot release. Online metadata is cached and enriched with nanobot's curated labels; if xAI is temporarily unavailable, nanobot uses the last successful catalog or a small built-in fallback instead of emptying the selector. The same catalog controls whether the provider exposes the hosted `x_search` tool; models that do not advertise support continue without hosted X Search. When enabled, Grok can search current X posts and return inline source links without invoking a local nanobot tool. Credentials are stored under the active instance's `auth/xai.json` (normally `~/.nanobot/auth/xai.json`), not in `config.json` and not in Grok Build's credential file. Hosted X Search remains enabled by default and can be disabled with the WebUI switch or `providers.xaiGrok.extraBody.tools: []`. +Hosted X Search is enabled by default for supported Grok models and can be turned off in WebUI model settings (or via `providers.xaiGrok.extraBody.tools: []`). Credentials are stored in `~/.nanobot/auth/xai.json`. -The login is xAI subscription OAuth, not X Developer OAuth. It follows the public client contract documented and implemented by [Grok Build](https://github.com/xai-org/grok-build/blob/main/crates/codegen/xai-grok-pager/docs/user-guide/02-authentication.md); xAI may change that upstream contract independently of nanobot. +**GitHub Copilot** -For GitHub Copilot: - -You can also sign in from the WebUI's model settings. The sign-in dialog shows a device code: copy it, select **Open GitHub**, and enter the code on GitHub. Keep the dialog open; nanobot detects approval and refreshes the model catalog automatically. Closing the dialog cancels the pending sign-in without replacing your saved credentials. This works from a remote browser too; no browser needs to open on the gateway machine. - -For terminal sign-in: +Sign in from **Settings → Models** using the device-code flow (copy the code, click **Open GitHub**, and approve—works from remote browsers too), or from the terminal: ```bash nanobot provider login github-copilot --set-main ``` -The WebUI reads the models enabled for the signed-in Copilot account. nanobot lists entries that support its current Copilot chat-completions or Responses transport and hides models that it cannot route safely. - -Each command authenticates the selected provider and makes its current default model active. OpenAI Codex and eligible GitHub Copilot models participate in [Responses state retention](./configuration.md#responses-state-and-compaction), while native compaction remains provider-capability-specific. OAuth providers are not valid automatic fallbacks. See [`troubleshooting.md`](./troubleshooting.md#provider-and-model-problems) for proxy, headless-login, model-name, and config-key errors. +Each `--set-main` command signs in and sets that provider's default model as active. See [Provider and Model Problems](./troubleshooting.md#provider-and-model-problems) if you need proxy or headless-server login steps. ## Provider Resolution diff --git a/docs/quick-start.md b/docs/quick-start.md index 849bb02ec..b62dda201 100644 --- a/docs/quick-start.md +++ b/docs/quick-start.md @@ -1,22 +1,23 @@ # Install and Quick Start -This guide has one goal: get a normal nanobot reply in your browser. Do not add chat apps, MCP servers, fallback models, or deployment until this path works. +Get your first reply from nanobot in a few minutes. Skip chat apps, MCP servers, and deployment until this basic setup works. -If terminals, Python, or API keys are unfamiliar, use the [beginner walkthrough](./start-without-technical-background.md), which explains each term and screen. +If terminals, Python, or API keys are new to you, start with the [beginner walkthrough](./start-without-technical-background.md) instead. -These repository docs describe `main`, which can be newer than the released package. The installer below installs the latest stable release. Check `nanobot --version` and use the [matching stable guide](https://nanobot.wiki/docs/latest/getting-started/quick-start) if its setup screens differ from this page. +> [!NOTE] +> These docs follow the latest development branch, while the installer below installs the latest stable release. If a screen looks different, check `nanobot --version` and see the [matching release guide](https://nanobot.wiki/docs/latest/getting-started/quick-start). ## What You Need - Python 3.11 or newer. -- Access to one supported AI provider, company endpoint, or local model server. -- The credential, endpoint URL, and model ID required by that service. Local providers such as Ollama may not require a key. +- Access to a supported AI provider, company endpoint, or local model server (such as Ollama). +- The API key (or sign-in) and model ID for that service. -Official platform packages include the WebUI and matching native TUI for macOS 13+ (Apple Silicon and Intel), glibc 2.17+ Linux (ARM64 and x64), and Windows x64; no frontend build tools are needed. Other platforms can use the WebUI or `nanobot --classic`; see [terminal requirements](./cli-reference.md#agent-cli). Source installs need Git and use Bun, which nanobot downloads when needed. +Packaged releases include the WebUI and native terminal UI (TUI) for macOS, Linux, and Windows—no Node.js or frontend build tools are needed. ## 1. Install nanobot -The recommended installer keeps nanobot out of the system Python environment. On a fresh local desktop, it starts the WebUI when installation finishes. +The official installer sets up nanobot in its own isolated environment and automatically opens the WebUI on a local desktop. **macOS / Linux** @@ -30,122 +31,116 @@ curl -fsSL https://raw.githubusercontent.com/HKUDS/nanobot/main/scripts/install. irm https://raw.githubusercontent.com/HKUDS/nanobot/main/scripts/install.ps1 | iex ``` -A fresh install uses a dedicated environment under `~/.nanobot/venv`, even if uv or pipx is on PATH. Existing installations keep their original manager; an active ordinary virtual environment remains an explicit target and is not adopted. The installer installs the stable PyPI release and prints the exact command it used to run nanobot. If `nanobot` is not on `PATH`, reuse that full command below. - -If you prefer to inspect the scripts first, open [`install.sh`](../scripts/install.sh) or [`install.ps1`](../scripts/install.ps1). +You can inspect [`install.sh`](../scripts/install.sh) or [`install.ps1`](../scripts/install.ps1) before running them. If `nanobot` is not on your `PATH` afterward, use the full command printed at the end of the installer output. ## 2. Configure Your Model -Wait for installation and startup to finish. The browser opens the local WebUI; go to **Settings → Models** and: +When the WebUI opens in your browser, go to **Settings → Models**: -1. Choose **New preset** and give it a name. If **Convert to presets** appears, choose it first. -2. Open **Provider** and select your provider. To add one, choose **Add provider** from the same menu, then enter and save its connection details or complete sign-in. -3. Choose a model from the list or enter a model ID available to your account. -4. Choose **Save**. +1. Click **New preset** and give it a name (if **Convert to presets** appears, click it first). +2. Open **Provider** and select your provider—or click **Add provider** to enter its API key / sign in. +3. Select a model from the list or enter a model ID available to your account. +4. Click **Save**. -The WebUI launcher creates or updates: - -| Path | Purpose | -|---|---| -| `~/.nanobot/config.json` | Provider, model, WebUI, channel, tool, and runtime settings | -| `~/.nanobot/workspace/` | Memory, skills, automations, and generated files | -| `~/.nanobot/sessions//` | Recent session history stored outside the workspace; the ID remains stable across workspace moves | - -If the installer did not open the browser, run: +If the browser did not open automatically, run: ```bash nanobot webui ``` -SSH, headless, existing-config, and older-release installs retain the terminal setup path: +On a headless server or over SSH, use the terminal wizard instead: ```bash nanobot onboard --wizard ``` +By default, nanobot stores its files under `~/.nanobot/`: + +| Path | Purpose | +|---|---| +| `~/.nanobot/config.json` | Providers, models, channels, tools, and runtime settings | +| `~/.nanobot/workspace/` | Memory, skills, automations, and generated files | +| `~/.nanobot/sessions/` | Saved conversation history | + ## 3. Check the Setup +Verify your local configuration without making a model request: + ```bash nanobot status ``` -You want: - -- a check mark for **Config** and **Workspace**; -- the model or preset you selected; -- a configured state for the provider used by that model. - -Most other providers can say `not set`. This command validates local setup but does not call the model. +Confirm that **Config** and **Workspace** show a check mark, your chosen model/preset is listed, and its provider is configured. Unused providers showing `not set` is normal. ## 4. Get the First Reply -If the installer-started WebUI is no longer running, run `nanobot webui` again. The first-run WebUI is bound to localhost, so other devices on your network cannot reach it. - -Send: +In the WebUI (running locally on `http://127.0.0.1:8765`, reachable only from your machine), send: ```text Hello! ``` -Any normal assistant answer is success. It proves that nanobot can load the config, reach the selected model, use the workspace, and serve the browser UI. +Any normal reply confirms that your config, provider, workspace, and WebUI are all working. -Fresh official-installer environments start a persistent gateway: closing the browser or terminal does not stop it. Other installations keep their on-demand lifetime unless you explicitly use `nanobot webui --detach` or the gateway command below. An attached on-demand launcher must stay open; closing its last local client stops that gateway. +### Managing the background gateway -To start or inspect a persistent gateway: +With the official installer, nanobot runs a background gateway so closing the browser or terminal does not stop it. You can manage it anytime: ```bash -nanobot gateway --background nanobot gateway status +nanobot gateway logs +nanobot gateway restart +nanobot gateway stop ``` -Use `nanobot gateway logs`, `restart`, and `stop` to manage that background gateway. +If you installed nanobot another way (such as `uv` or `pip`), `nanobot webui` stops when you close the terminal unless you start it with `nanobot webui --detach` or `nanobot gateway --background`. ## Terminal-Only Check -If you do not want the browser or need to isolate a WebUI problem, send one message directly: +To test without a browser, send a single message from the terminal: ```bash -nanobot -m "Hello!" +nanobot agent -m "Hello!" ``` -Then start an interactive terminal chat with: +Or open an interactive terminal chat: ```bash nanobot ``` -In interactive mode, `Enter` sends and `Shift+Enter` inserts a newline (`Ctrl+J` is the universal fallback). While nanobot is working, `Enter` sends immediately, `Tab` waits until the current response is finished, and `Option+Up` on macOS (`Alt+Up` on Windows/Linux) edits the latest waiting message. Exit with `exit`, `/exit`, `:q`, or `Ctrl+D`. +In interactive mode, `Enter` sends and `Shift+Enter` (or `Ctrl+J`) inserts a newline. While nanobot is replying, `Enter` sends immediately, `Tab` queues your message for after the reply, and `Option+Up` (macOS) / `Alt+Up` (Windows/Linux) edits your queued message. Exit with `exit`, `/exit`, `:q`, or `Ctrl+D`. ## Continue with nanobot -After the first reply works, describe one next goal in the same chat. With the built-in `nanobot-document` skill, nanobot can consult documentation bundled with your installation to explain features, guide configuration, and troubleshoot. Include where you are using nanobot and what already works, for example: +Once you have your first reply, you can ask nanobot directly in chat to guide your next setup step. When the built-in `nanobot-document` skill is enabled (under **Skills → Installed**), nanobot reads the documentation bundled with your installation. For example: -- "I am already using the WebUI. Help me connect Telegram and allow only my account." -- "Explain what is shared when I start a new topic or choose a different project." -- "A second model preset returns an authentication error. Help me find which setting to check." +- *"I am already using the WebUI. Help me connect Telegram and allow only my account."* +- *"Explain what is shared when I start a new topic or choose a different project."* +- *"My second model preset returns an authentication error. Help me find which setting to check."* -To explicitly request the documentation skill, send: +To invoke the documentation skill explicitly: ```text $nanobot-document Explain how sessions, workspaces, and memory relate in this installation. ``` -This requires a model that supports tools and an enabled `nanobot-document` skill under **Skills → Installed**. Enter credentials in the relevant settings forms when needed. If your installed release does not include the skill, or you prefer to read the steps yourself, choose a guide below. Add one capability and test it before moving on: +Or read the guides yourself—add one capability and test it before moving on: | Goal | Recommended path | |---|---| -| Learn sessions, workspaces, tools, and access modes | [WebUI guide](./webui.md) | -| Connect a chat platform | Open **Channels**, then use [Chat Apps](./chat-apps.md) for platform prerequisites | -| Change or add a model | Open **Settings → Models**; use the [Provider Cookbook](./provider-cookbook.md) for a recipe | -| Add web search, voice, or image generation | Use the matching WebUI Settings page, then consult [Configuration](./configuration.md) for advanced fields | -| Add an App or MCP integration | Open **Apps** or follow [Configure MCP Tools](./guides/configure-mcp-tools.md) | -| Schedule agent work | Read [Automations](./automations.md) | +| Learn topics, workspaces, tools, and access modes | [WebUI guide](./webui.md) | +| Connect a chat app | Open **Channels**, then check [Chat Apps](./chat-apps.md) for platform steps | +| Change or add a model | Open **Settings → Models** or browse the [Provider Cookbook](./provider-cookbook.md) | +| Add web search, voice, or image generation | Open **Settings → Capabilities** (see [Configuration](./configuration.md) for advanced options) | +| Add a plugin, CLI App, or MCP server | Open **Apps** or follow [Configure MCP Tools](./guides/configure-mcp-tools.md) | +| Schedule tasks or triggers | Read [Automations](./automations.md) | | Run continuously or remotely | Read [Deployment](./deployment.md) | -| Integrate from code | Use the [Python SDK](./python-sdk.md) | +| Integrate from Python | Use the [Python SDK](./python-sdk.md) | ## Other Install Methods -Use one method, then continue at [Configure Your Model](#2-configure-your-model). +Pick one method below, then continue at [Configure Your Model](#2-configure-your-model). **uv** @@ -154,18 +149,18 @@ uv tool install nanobot-ai nanobot webui ``` -**pip in a virtual environment** +**pip (inside a virtual environment)** ```bash python -m pip install nanobot-ai nanobot webui ``` -If pip reports `externally-managed-environment`, use the recommended installer, `uv tool install nanobot-ai`, `pipx install nanobot-ai`, or create a virtual environment. Do not force a system-wide install. +If pip reports `externally-managed-environment`, use the official installer, `uv tool install nanobot-ai`, `pipx install nanobot-ai`, or a virtual environment instead of forcing a system-wide install. -**Current source** +**From source (latest `main`)** -Clone the repository and install it in editable mode. nanobot downloads the pinned Bun runtime to run the checkout's matching TUI; Node is not required. +Requires Git. nanobot downloads the matching Bun runtime automatically for the TUI; Node.js is not required. ```bash git clone https://github.com/HKUDS/nanobot.git @@ -173,37 +168,33 @@ cd nanobot python3 -m venv .venv ``` -On Windows, use `py -3 -m venv .venv` instead of `python3`. Activate it with `source .venv/bin/activate` on macOS/Linux or `.venv\Scripts\Activate.ps1` in Windows PowerShell, then run: +On Windows, use `py -3 -m venv .venv`. Activate the environment (`source .venv/bin/activate` on macOS/Linux or `.venv\Scripts\Activate.ps1` in PowerShell), then run: ```bash python -m pip install -e . nanobot webui ``` -The source path follows current `main` and can be newer than the published package. The editable install keeps Python pointed at the checkout; `nanobot` runs `tui/` with Bun, and `nanobot webui` prompts to rebuild stale frontend assets, or warns in non-interactive sessions; `--yes` builds automatically. All normal commands remain the same as a stable install. For development details, follow [`../CONTRIBUTING.md`](../CONTRIBUTING.md). +For contributor details, see [`CONTRIBUTING.md`](../CONTRIBUTING.md). -If the shell cannot find `nanobot`, reuse the installer's printed command or run Python from the existing installation. For uv or pipx, locate that environment with the original manager; do not start a temporary tool environment to manage it. The official installer's default paths are: +
+If the nanobot command is not found -```bash -~/.nanobot/venv/bin/python -I -m nanobot --version -``` +Reuse the full command printed by the official installer, or call Python directly from its dedicated environment: -Windows PowerShell: +- **macOS / Linux:** `~/.nanobot/venv/bin/python -I -m nanobot --version` +- **Windows PowerShell:** `& "$HOME\.nanobot\venv\Scripts\python.exe" -I -m nanobot --version` -```powershell -& "$HOME\.nanobot\venv\Scripts\python.exe" -I -m nanobot --version -``` +Replace `--version` with `webui`, `status`, or any other subcommand. For `uv` or `pipx` installs, use the same package manager's environment. -Replace `--version` with `webui`, `onboard --wizard`, or the arguments you need. Use plain `python -m nanobot` only when that Python belongs to the installed environment. +
## Manual Configuration Fallback
Manual configuration -Use this only when the wizard is unavailable or you intentionally manage JSON. First run `nanobot onboard`, then merge a provider and a named model preset into `~/.nanobot/config.json`. - -A generic OpenAI-compatible setup has this shape: +Use this only when the WebUI and terminal wizard are unavailable or you manage `config.json` directly. Run `nanobot onboard` first, then merge a provider and named model preset into `~/.nanobot/config.json`: ```json { @@ -227,26 +218,24 @@ A generic OpenAI-compatible setup has this shape: } ``` -Replace the provider, endpoint, and model together. Do not pair a credential from one service with a model ID from another. See [Provider Cookbook](./provider-cookbook.md) for hosted, OAuth, company, and local examples, and [Configuration](./configuration.md) for exact fields. +Keep the provider, endpoint URL, and model ID matched to the same service. See [Provider Cookbook](./provider-cookbook.md) for provider-specific examples and [Configuration](./configuration.md) for all fields.
## Updating -Open **Settings → About → Update**. Supported installations can update and restart there; others show instructions for their original package manager or deployment. Follow [Updating nanobot](./updating.md) for Preview selection, backups and recovery. Do not switch installation methods to work around an error. +Open **Settings → About → Update** in the WebUI. Supported installations update and restart in place; others display instructions for their package manager. See [Updating nanobot](./updating.md) for preview releases, backups, and recovery. -For an ordinary Python virtual environment, the [CLI updater](./cli-reference.md#updating) is also available: +For standard Python virtual environments, you can also update from the CLI: ```bash nanobot update --check nanobot update ``` -Stop affected processes and back up configuration and data first; restart and verify the running version afterward. Source checkouts should preserve local changes and follow the [development instructions](../CONTRIBUTING.md). - ## If the First Reply Fails -Do not change several settings at once. Start with: +Change one thing at a time. Start with: ```bash nanobot --version @@ -256,11 +245,11 @@ nanobot agent -m "Hello!" | Symptom | First check | |---|---| -| `nanobot: command not found` | Reuse the installer command or method-specific runner described under [Other Install Methods](#other-install-methods) | -| JSON parse error | Check commas and braces; remember that docs examples are usually snippets | -| `401` or invalid API key | Verify the selected provider owns that key and remove accidental spaces | -| Model not found | Use a model ID available from the provider selected in the active preset | -| CLI works but WebUI does not open | Use port `8765`, not gateway health port `18790` | -| WebUI works but a chat app does not | Check **Channels**, then run `nanobot channels status` | +| `nanobot: command not found` | Reuse the full command printed by the installer (see [Other Install Methods](#other-install-methods)) | +| JSON parse error | Check commas and braces; remember that doc examples are snippets to merge | +| `401` or invalid API key | Confirm the key belongs to the selected provider and has no extra spaces | +| Model not found | Use a model ID available to your account on the selected provider | +| CLI works, but WebUI does not open | Open port `8765`, not the gateway health port `18790` | +| WebUI works, but a chat app does not | Check **Channels** in WebUI, then run `nanobot channels status` | -Continue with the ordered [Troubleshooting guide](./troubleshooting.md) if the cause is still unclear. +Continue with [Troubleshooting](./troubleshooting.md) if the cause is still unclear. diff --git a/docs/start-without-technical-background.md b/docs/start-without-technical-background.md index 5889adbc2..910bf9204 100644 --- a/docs/start-without-technical-background.md +++ b/docs/start-without-technical-background.md @@ -1,73 +1,64 @@ # Start Without Technical Background -This walkthrough is for people who have not used a terminal, API key, or JSON config file before. The goal is only to get one reply in a browser. You do not need to understand nanobot's architecture or edit its config by hand. +This walkthrough is for people who have not used a terminal, API key, or config file before. The goal is simple: get your first reply from nanobot in a web browser. You do not need to edit any code or config files by hand. ## What You Will Need - A Windows, macOS, or Linux computer. - Python 3.11 or newer. -- An account or endpoint that can run an AI model. -- The API key, login, endpoint, and model name required by that service. A local model such as Ollama may not require an API key. +- An AI model service (such as OpenRouter, OpenAI, Anthropic, or a local model like Ollama) and its login or API key. -An API key is password-like. Do not post it in an issue, screenshot, chat, or public config file. +> [!CAUTION] +> Treat an API key like a password. Never paste it into screenshots, chats, or public support requests. ## A Few Useful Words -| Word | Meaning | +| Word | What it means | |---|---| | Terminal | A text window where you paste a command and press Enter | -| Command | One instruction typed into the terminal | -| Provider | The service or local server that runs the AI model | -| Model ID | The exact model name expected by that provider | -| API key | A secret credential that lets software call the provider | -| Wizard | A question-and-answer setup menu | -| WebUI | The local browser page where you use nanobot | +| Command | One line of instructions you run in the terminal | +| Provider | The AI service (or local app like Ollama) that runs the model | +| Model ID | The exact model name your provider expects | +| API key | A secret key that lets nanobot connect to your provider | +| WebUI | The browser page where you chat with and configure nanobot | ## 1. Install Python -Download Python from [python.org](https://www.python.org/downloads/) if you do not already have version 3.11 or newer. On Windows, enable **Add python.exe to PATH** if the installer shows that option. +If you do not already have Python 3.11 or newer, download it from [python.org](https://www.python.org/downloads/). On Windows, check the box labeled **Add python.exe to PATH** during installation so your terminal can find Python automatically. -Open a terminal: +Open your terminal: -| System | How | +| System | How to open | |---|---| -| Windows | Press `Win`, type `PowerShell`, and open Windows PowerShell | +| Windows | Press `Win`, type `PowerShell`, and open **Windows PowerShell** | | macOS | Press `Command+Space`, type `Terminal`, and press Enter | -| Linux | Open your application menu and search for Terminal | +| Linux | Open your app menu and search for **Terminal** | -Check Python: +Type this command and press Enter: ```bash python --version ``` -The result should start with `Python 3.11` or a newer number. If the command is not found, close and reopen the terminal. You can also try `python3 --version` on macOS/Linux or `py --version` on Windows. +You should see something like `Python 3.12.x` (any version `3.11` or higher works). If you get an error saying `python` is not recognized, close and reopen the terminal, or try `python3 --version` (macOS/Linux) or `py --version` (Windows). ## 2. Prepare Your Model Details -An account on a chat website does not automatically let nanobot use that service. Before you start, find out which AI service you will use, how nanobot can sign in (usually with an API key, sometimes with a supported sign-in flow), and the exact model name the service requires. Check the service's pricing and available models. Some services also require a URL; use it only if that service provides one. +Having a regular chat website subscription (like ChatGPT Plus or Claude Pro) does not automatically give you API access. Before continuing, make sure you have an AI provider ready. -If you do not have a provider yet, here is one API-based example: +If you do not have a provider yet, [OpenRouter](https://openrouter.ai/) is a simple starting point (any supported provider works): 1. Create an account at [OpenRouter](https://openrouter.ai/). -2. Open its [API keys page](https://openrouter.ai/settings/keys) and create a key. Keep it private; you will paste it into nanobot's provider form. -3. Choose a model from the [model catalog](https://openrouter.ai/models), check its price and account requirements, and copy its model ID. For file/tool tasks, choose a model that supports tool calling. See the [official quickstart](https://openrouter.ai/docs/quickstart). -4. In step 4 below, add the built-in **OpenRouter** provider with that key, keep its default endpoint, and select the model you chose. This is one option, not a required provider. +2. Open [API Keys](https://openrouter.ai/settings/keys) and create a key. Keep it somewhere private for Step 4. +3. Pick a model from the [model catalog](https://openrouter.ai/models) and copy its model ID. Pick a model that supports tools (often labeled **Tools**) if you want nanobot to read files or run actions for you. -For a model running on your own computer, use the [Ollama setup recipe](./provider-cookbook.md#recipe-ollama-local-model) instead. For a company-managed service, ask your administrator for the connection details. +If you prefer a model that runs locally on your own computer with no API key, see the [Ollama recipe](./provider-cookbook.md#recipe-ollama-local-model). If you are using a company-managed AI service, ask your administrator for the endpoint URL, key, and model ID. -If you already have a provider, have these details nearby: - -1. The provider or company endpoint name. -2. Its API key, if it requires one. -3. Its base URL, if its documentation gives you one. -4. A model ID your account can use. - -The provider, credential, endpoint, and model must belong together. For example, an API key from one provider usually cannot call a model name copied from a different provider. +Whatever provider you choose, make sure the **provider, key, and model ID all belong to the same service**. ## 3. Install nanobot -Copy the command for your system, paste it into the terminal, and press Enter. Copy only the text inside the code block. +Copy the command for your system, paste it into the terminal, and press Enter: **macOS / Linux** @@ -81,79 +72,80 @@ curl -fsSL https://raw.githubusercontent.com/HKUDS/nanobot/main/scripts/install. irm https://raw.githubusercontent.com/HKUDS/nanobot/main/scripts/install.ps1 | iex ``` -The installer downloads the stable nanobot package into an isolated Python environment. On a fresh local desktop, it then starts the WebUI and opens your browser. This can take a few minutes on the first run. Keep the terminal open. It prints the exact command used to run nanobot; if `nanobot` is not found later, reuse that whole command instead of switching to a different Python command. +The installer sets up nanobot in its own dedicated folder and automatically opens the WebUI in your browser when finished. This first setup can take a few minutes. -If your organization blocks downloaded install scripts, use the [alternative install methods](./quick-start.md#other-install-methods) or ask your administrator to review the scripts first. +> [!TIP] +> If your terminal says `nanobot` is not found later, reuse the full command printed at the end of the installer output. If your network or company blocks downloaded install scripts, see [Other Install Methods](./quick-start.md#other-install-methods). ## 4. Configure Your Model in the WebUI -In the browser, open **Settings → Models**. Then: +Once the WebUI opens in your browser, go to **Settings → Models**: -1. Choose **New preset** and give it a name. If **Convert to presets** appears, choose it first. -2. Open **Provider** and select your provider. To add one, choose **Add provider** from the same menu, then enter and save its connection details or complete sign-in. -3. Choose a model from the list or enter a model ID available to your account. -4. Choose **Save**. +1. Click **New preset** and give it a name (if you see **Convert to presets**, click that first). +2. Open **Provider** and choose your provider. To add a new one, choose **Add provider**, enter your API key (or complete sign-in), and save. +3. Pick a model from the list or paste your model ID. +4. Click **Save**. -Treat every API key like a password. Do not include it in screenshots or support requests. - -If the installer finishes without opening the browser and `nanobot` is available, run: +If the browser did not open automatically after installation, run: ```bash nanobot webui ``` -If the terminal cannot find `nanobot`, take the exact command printed by the installer and replace its final arguments with `webui`. It uses the Python executable from the persistent installation, not a temporary tool environment. - -On SSH, a computer without a desktop, an existing configuration, or an older nanobot release, the installer may open the terminal wizard instead. Choose **Quick Start** there and follow its prompts. +On a server without a browser (such as over SSH), the installer opens a terminal setup wizard instead—choose **Quick Start** and follow the prompts. ## 5. Get the First Reply -Wait for the startup summary. If the browser did not open automatically, copy the complete login link printed in that terminal, including everything after `#`, into your browser. The bare `http://127.0.0.1:8765` address does not sign a new browser in. Keep the login link private: it contains a credential. Fresh official-installer environments keep running in the background; if the launcher remains attached, leave that terminal open. +If your browser still did not open automatically, copy the **entire login link** printed in the terminal (including the `#...` part at the end) and paste it into your browser's address bar. Keep that link private because it signs your browser in. -Send this message: +Type this in the chat box and send it: ```text Hello! ``` -A normal assistant reply means setup is complete. The exact reply does not matter. - -The first-run address is local to your computer. It is not automatically available to other computers on your network. +Any normal reply means nanobot is set up and working. By default, nanobot only runs locally on your computer and cannot be reached by other devices on your network. ## 6. Add One Thing at a Time -Choose one next goal and ask nanobot in your current chat. For example: "I am already using the WebUI. Help me connect Telegram and allow only my account." When the built-in `nanobot-document` skill is available and enabled, nanobot can use its bundled documentation to guide you. See [Continue with nanobot](./quick-start.md#continue-with-nanobot) for how to request the skill directly. +Now that nanobot replies, you can ask it in chat to guide you through your next goal—for example: *"I am using the WebUI. Help me connect Telegram and allow only my account."* -You can also follow the steps yourself using the controls and guides below. Add one capability and test it before moving on: +You can also explore one feature at a time in the WebUI: -| Goal | What to do | +| What you want to do | Where to go | |---|---| -| Change the AI model | Open **Settings → Models** | -| Add a provider credential | Open **Settings → Models → Provider → Add provider** | -| Connect Telegram, Discord, Slack, Feishu, WeChat, or another chat app | Open **Channels**, choose the platform, and follow its connection steps | -| Add a tool integration | Open **Apps** and choose an App or MCP integration | -| Schedule a reminder or recurring task | Ask nanobot in the target chat, then manage it in **Automations** | -| Work with project files | Follow [Your first file task](#your-first-file-task), then see [Workspace and Access](./webui.md#workspace-and-access) | +| Change your AI model or add a provider | **Settings → Models** | +| Connect Telegram, Discord, Slack, Feishu, WeChat, or another chat app | **Channels** (see [Chat Apps](./chat-apps.md) for platform steps) | +| Add tools, plugins, or MCP integrations | **Apps** | +| Set a reminder or recurring task | Ask nanobot in chat, then manage it in **Automations** | +| Work with files on your computer | Try [Your first file task](#your-first-file-task) below | -Repository docs show the current development version. If your stable package does not yet show **Channels**, use the [Chat Apps guide](./chat-apps.md) or update to a release that includes it. - -Some runtime changes ask you to restart nanobot. Use the restart action shown by the WebUI or `nanobot gateway restart` for a background gateway. For an attached on-demand launcher, press `Ctrl+C` and run `nanobot webui` again. - -For a chat platform's account, bot, token, or permission prerequisites, use the [Chat Apps guide](./chat-apps.md). For local models and provider-specific recipes, use the [Provider Cookbook](./provider-cookbook.md). +If a setting asks you to restart nanobot, click the **Restart** button shown in the WebUI (or run `nanobot gateway restart` in the terminal). ## Your First File Task -1. Create a practice folder, for example `Documents/nanobot-practice`, and put a copy of a short text file in it. Keep originals elsewhere for this first task. -2. Start a new topic in the WebUI. Open the workspace folder selector, choose that folder, and select **Confirm**. Choose **Restricted** access. -3. Ask: "Read notes.txt and write a short summary to summary.md in this folder." Replace `notes.txt` with your file's name, then open `summary.md` in the selected folder. +1. Create a practice folder (for example `Documents/nanobot-practice`) and copy a short text file into it so your originals stay safe. +2. Start a new topic in the WebUI, click the folder selector, pick that practice folder, and click **Confirm**. Leave access set to **Restricted** (this keeps nanobot safely inside your chosen folder so it cannot touch files elsewhere on your computer). +3. Send: *"Read notes.txt and write a short summary to summary.md in this folder."* (Replace `notes.txt` with your file's name.) -The workspace selects the folder the agent works in on the machine running nanobot. Attaching a file sends that file to the conversation; it does not change the workspace. For PDF and Office files, see [File tools](./webui.md#apps). +Open your practice folder—you should see a new `summary.md` file there. -Return to the saved topic to continue later. A new topic or a different project folder does not create separate long-term memory. For clients whose preferences must stay separate, use [separate instances](./multiple-instances.md). +> [!NOTE] +> Choosing a workspace folder sets where nanobot reads and writes files. Attaching a file only shares that file with the chat. Also, starting a new topic or choosing a different folder does not separate long-term memory—if you need completely separate memory (for example, for different clients), see [Multiple Instances](./multiple-instances.md). + +## Open nanobot Later + +Whenever you want to open the WebUI again, run: + +```bash +nanobot webui +``` + +With the official installer, nanobot stays running in the background even after you close the browser or terminal. You can check or stop it anytime with `nanobot gateway status`, `nanobot gateway restart`, or `nanobot gateway stop`. ## If Something Fails -Run these commands one at a time: +Run these commands one by one to narrow down the issue: ```bash nanobot --version @@ -161,25 +153,13 @@ nanobot status nanobot agent -m "Hello!" ``` -| What you see | What it usually means | +| What you see | What to check | |---|---| -| `nanobot: command not found` | Reuse the exact nanobot command printed by the installer; it points to the isolated environment that contains the package | -| `401`, unauthorized, or invalid API key | The key is wrong, expired, or belongs to a different provider | -| Model not found | The model ID is misspelled or unavailable to your provider account | -| Browser does not open | Copy the complete login link printed by the launcher, including the fragment after `#`; keep the terminal open if the launcher is attached | -| Browser opens but messages fail | Test `nanobot agent -m "Hello!"` to separate a model problem from a WebUI problem | -| A change was saved but nothing changed | Restart nanobot so the running process reloads the config | +| `nanobot: command not found` | Reuse the full command printed by the installer | +| `401`, unauthorized, or invalid API key | Check that the key is complete, active, and belongs to the selected provider | +| Model not found | Double-check the spelling of the model ID and confirm your account can use it | +| Browser does not open | Copy the complete login link from the terminal (including everything after `#`) | +| Browser opens, but messages fail | Run `nanobot agent -m "Hello!"` to check whether the problem is the model or the browser | +| Saved a setting, but nothing changed | Restart nanobot so the new setting takes effect | -If you ask for help, include your operating system, `nanobot --version`, `nanobot status`, the exact command, and the exact error. Remove every API key, bot token, password, OAuth token, and private account ID first. - -Continue with the full [Troubleshooting guide](./troubleshooting.md) for an ordered diagnosis. - -## Open nanobot Later - -Run: - -```bash -nanobot webui -``` - -A fresh official-installer environment starts a background gateway and returns control to the terminal. Closing the browser does not stop it. Manage it with `nanobot gateway status`, `logs`, `restart`, and `stop`; use the exact commands printed for your instance. Other installation methods keep their attached on-demand launch: leave that launcher open, or explicitly use `nanobot webui --detach` after setup. The last attached client stops an on-demand gateway, not a background gateway. See [updates and recovery](./updating.md) for the matching installation method. +If you ask for help, share your operating system, `nanobot --version`, `nanobot status`, and the exact error—with all API keys, tokens, and passwords removed. For step-by-step diagnosis, see [Troubleshooting](./troubleshooting.md). diff --git a/docs/troubleshooting.md b/docs/troubleshooting.md index 71cfdd28c..24c6b17d2 100644 --- a/docs/troubleshooting.md +++ b/docs/troubleshooting.md @@ -1,44 +1,16 @@ # Troubleshooting -Use the first check that matches what you see, then follow its next step. This avoids investigating the browser or a chat app before confirming nanobot can start and contact its model. +Start at the top and follow the first step that matches your problem. This isolates installation or model errors before you debug the browser or a chat app. ## Fast Diagnosis Order -- **The `nanobot` command is not found, or nanobot will not start:** check [Installation Problems](#installation-problems). Run `nanobot --version` to confirm the command is available. -- **nanobot starts, but does not answer:** run `nanobot status`. Check that it points to the config and workspace you expect and that the active model is ready. This command does not contact the model; if setup is incomplete, follow its WebUI **Settings → Models** or CLI wizard instructions. -- **Status looks ready, but a test question fails:** run `nanobot agent -m "Hello!"`. If it fails, troubleshoot [Provider and Model Problems](#provider-and-model-problems) before testing the gateway or a chat app. -- **The test question works, but the browser or chat app does not:** start `nanobot gateway` and follow [Gateway Problems](#gateway-problems), [WebUI Problems](#webui-problems), or [Chat App Problems](#chat-app-problems), depending on what is failing. - -`nanobot status` checks local configuration and provider readiness without making a model request. A successful `nanobot agent -m "Hello!"` confirms the local agent can get a reply; it does not prove that a gateway, browser, or chat app is working. - -## Empty topics after a WebUI restart - -The Restart button in WebUI settings does not create a conversation or add messages to an existing conversation. Reopening WebUI or reconnecting to the gateway also does not save a topic until a message or another session action creates it. - -Older gateway versions could save an empty topic when the Restart button had no current chat. Update the gateway to stop creating these topics. Existing topics are not deleted by the update; check their contents before removing them. A typed `/restart` command remains part of that chat's display history. - -If settings stay disabled after a restart while another tab has reconnected, reload the affected page. Updated WebUI clients track restart completion per tab, so one tab cannot leave another tab waiting by clearing the shared restart marker. - -## Session storage overlaps the workspace - -Sessions live at `/sessions//`, outside the agent workspace. If startup reports a conflict, compare the printed paths. A valid layout is `bot/config.json`, `bot/sessions/`, and `bot/workspace/`. - -`--workspace` overrides `agents.defaults.workspace` without moving sessions. The override is temporary for `agent` and `gateway`; `webui --workspace` saves it to the config. - -To fix an existing instance: - -1. Stop the instance and back up its config directory and workspace. -2. Keep the workspace and `.nanobot/workspace-id` in place. Move the config file **and its runtime data, including sessions**, to a directory outside the workspace. -3. Update `--config` in your launch command or service, check relative paths, and restart. - -Moving only the config leaves history behind. Choosing a new workspace without moving its contents (including memory, skills, and `.nanobot/workspace-id`) can start an empty workspace with a different session identity. +1. **`nanobot` is not found or will not start:** Run `nanobot --version` and see [Installation Problems](#installation-problems). +2. **nanobot starts, but setup looks incomplete:** Run `nanobot status`. It checks your config, workspace, and active provider locally without calling a model. +3. **`nanobot status` looks healthy, but replies fail:** Run `nanobot agent -m "Hello!"`. If that fails, fix [Provider and Model Problems](#provider-and-model-problems) before testing the WebUI or chat apps. +4. **CLI replies work, but the browser or chat app does not:** Start `nanobot gateway` and check [Gateway Problems](#gateway-problems), [WebUI Problems](#webui-problems), or [Chat App Problems](#chat-app-problems). ## How to Read `nanobot status` -`nanobot status` does not call a model. It checks the selected config and workspace, resolves environment references, and validates the local settings required by the active provider/model without constructing a provider client. - -The output has this shape: - ```text nanobot Status @@ -48,248 +20,96 @@ Model: provider/model-name (preset: primary) Agent: ✓ provider/model configuration is ready Provider A: not set Provider B: ✓ -Local Provider: ✓ http://localhost:11434/v1 -OAuth Provider: ✓ (OAuth) ``` -Read it like this: - -| Line | Good sign | What to do if it looks wrong | +| Line | What you want | If it looks wrong | |---|---|---| -| `Config` | It points to the config file you meant to use and shows `✓`. | Run `nanobot onboard`, or pass `--config` to `nanobot agent`, `gateway`, or `serve` when testing a non-default instance. | -| `Workspace` | It points to the workspace you meant to use and shows `✓`. | Run `nanobot onboard`, create the folder, fix permissions, or pass `--workspace` on commands that support it. | -| `Model` | It shows the active model or the preset name you expect. | Set `agents.defaults.modelPreset` to the intended preset, or check `/model` if you changed models during a chat session. | -| `Agent` | It says `provider/model configuration is ready`. | Follow the printed WebUI or CLI setup route, then run `nanobot status` again. | -| Provider rows | The provider used by the active preset shows `✓`, an OAuth marker, or a local URL. | Configure only the active provider first. It is normal for unused providers to say `not set`. | - -If `nanobot status` looks right but `nanobot agent -m "Hello!"` fails, the install and config paths are probably fine. Continue with [Provider and Model Problems](#provider-and-model-problems). +| `Config` | Points to your expected config file with `✓` | Run `nanobot onboard`, or pass `--config` when using multiple instances | +| `Workspace` | Points to your expected workspace with `✓` | Run `nanobot onboard`, check folder permissions, or pass `--workspace` | +| `Model` | Shows your expected model or preset | Update it in **Settings → Models** or check `/model` in chat | +| `Agent` | Says `provider/model configuration is ready` | Follow the printed setup instructions, then re-run `nanobot status` | +| Providers | Your active provider shows `✓`, OAuth, or a local URL | Unused providers showing `not set` is normal | ## Installation Problems -Use the same Python command for install checks and module fallback. On macOS/Linux that may be `python3`; on Windows it may be `python` or `py`. - -| Symptom | Check | +| Symptom | Fix | |---|---| -| `python: command not found` | Try `python3 --version` on macOS/Linux or `py --version` on Windows. Then replace `python` in docs commands with the command that worked. | -| `curl: command not found` | The macOS/Linux one-command installer could not download the script. Install curl, or use a manual isolated install such as `uv tool install nanobot-ai` or `pipx install nanobot-ai`. | -| `irm` is not recognized | PowerShell could not run the download helper. Use manual install: `uv tool install nanobot-ai`, `pipx install nanobot-ai`, or `py -m pip install nanobot-ai` inside an environment you control. | -| Could not download `raw.githubusercontent.com` | Your network, proxy, or firewall blocked the installer script download. Use manual install from PyPI, or configure your proxy and rerun the command. | -| `nanobot: command not found` | With the recommended installer, reuse its printed full command; with uv/pipx, use `uv tool run --from nanobot-ai nanobot ...` / `pipx run --spec nanobot-ai nanobot ...`. For a pip install, use ` -m nanobot ...` from that same environment. A system `python` or `py` may not contain the isolated installation. | -| `No module named nanobot` | You are running a different Python than the one used for installation. Run `python -m pip show nanobot-ai`, `python3 -m pip show nanobot-ai`, or `py -m pip show nanobot-ai`, matching the command that installed nanobot. | -| `pip is not available` | When the installer uses a virtual environment, it tries `python -m ensurepip --upgrade`. If that fails, install pip for that Python, or use a Python installer/distribution that includes pip. | -| `externally-managed-environment` | Your system Python blocks global pip installs. Use the one-command installer, `uv tool install nanobot-ai`, `pipx install nanobot-ai`, or create a virtual environment; do not add `--break-system-packages` for nanobot. | -| Installer chose the wrong Python | Set `PYTHON` before running the installer, such as `curl -fsSL https://raw.githubusercontent.com/HKUDS/nanobot/main/scripts/install.sh | PYTHON=python3 sh` or `$env:PYTHON="py"` before the PowerShell command. | -| Editable source install does not update | From the repo root, run `python -m pip install -e .` again with the Python command used for development, then check `python -m nanobot --version` or `nanobot --version`. | -| WebUI build tools missing | They are only needed for WebUI development. Packaged installs already include the WebUI bundle. | +| `python: command not found` | Try `python3 --version` (macOS/Linux) or `py --version` (Windows), and use that command consistently | +| `curl` or `irm` not found, or GitHub blocked | Install directly from PyPI with `uv tool install nanobot-ai`, `pipx install nanobot-ai`, or `pip` inside a virtual environment | +| `nanobot: command not found` | Reuse the full command printed at the end of the official installer output; for `uv`/`pipx`/`pip`, run from that same environment | +| `No module named nanobot` | You are using a different Python than the one where nanobot was installed—check with `python -m pip show nanobot-ai` | +| `externally-managed-environment` | Use the official installer, `uv tool install nanobot-ai`, `pipx install nanobot-ai`, or a virtual environment (do not force a system-wide install) | +| Installer picked the wrong Python | Set `PYTHON` first: `PYTHON=python3` on macOS/Linux or `$env:PYTHON="py"` in PowerShell | +| WebUI build tools missing | Packaged installs already include the WebUI; build tools are only needed for frontend development | ## Config Problems -Default config path: +Default locations: `~/.nanobot/config.json` and `~/.nanobot/workspace/`. If you run multiple instances, pass the same `--home` (or `--config` and `--workspace`) to every command. -```text -~/.nanobot/config.json -``` - -Default workspace path: - -```text -~/.nanobot/workspace/ -``` - -`nanobot status` reads the default config unless you pass explicit paths. Use the same `--config` and `--workspace` across status checks and runtime commands when debugging multiple instances: - -```bash -nanobot status --config ./bot-a/config.json --workspace ./bot-a/workspace -nanobot agent --config ./bot-a/config.json --workspace ./bot-a/workspace -m "Hello" -nanobot gateway --config ./bot-a/config.json --workspace ./bot-a/workspace -``` - -Common config mistakes: - -| Symptom | Check | +| Symptom | Fix | |---|---| -| JSON parse error | Validate commas, braces, and quotes. Most docs examples are partial snippets to merge. | -| Unknown or missing provider | Use provider registry names such as `openrouter`, `anthropic`, `openai`, `ollama`, `vllm`, `lm_studio`, or define a custom OpenAI-compatible provider key under `providers` and reference that exact key from the active preset. | -| snake_case vs camelCase confusion | Both are accepted, but docs use camelCase because nanobot writes config with aliases such as `apiKey`, `modelPresets`, `intervalS`. | -| Environment variable error | `${VAR_NAME}` references are resolved at startup. Set the variable before running nanobot. | -| Edited config but behavior did not change | Restart `nanobot gateway`; long-running processes read config at startup. | - -After editing config, check the shortest path to an Agent reply: - -```bash -nanobot status -``` - -To refresh missing defaults without overwriting existing settings, run: - -```bash -nanobot onboard --refresh -``` - -For an interactive choice between resetting and refreshing, run `nanobot onboard` and choose the option that keeps current values and merges missing defaults. +| JSON parse error | Check commas, quotes, and braces—most doc examples are snippets to merge into `config.json` | +| Unknown or missing provider | Use a built-in provider name (`openrouter`, `anthropic`, `openai`, `ollama`, `vllm`, `lm_studio`, etc.) or match the exact custom provider key you defined | +| Environment variable error | `${VAR_NAME}` values are resolved at startup—set the variable before launching nanobot | +| Config changes had no effect | Restart `nanobot gateway` (long-running processes read config at startup) | +| Missing new default fields | Run `nanobot onboard --refresh` to add missing defaults without overwriting existing settings | ## Provider and Model Problems -First prove the provider in the CLI: +Test in the terminal first: ```bash nanobot agent -m "Hello!" ``` -Then compare your config against [`providers.md`](./providers.md). +Compare your setup against [Providers and Models](./providers.md) or grab a working recipe from the [Provider Cookbook](./provider-cookbook.md). -If you need a known-good snippet instead of diagnosis, use [`provider-cookbook.md`](./provider-cookbook.md). - -| Symptom | Likely cause | +| Symptom | Likely cause and fix | |---|---| -| 401, unauthorized, invalid API key | Key is missing, expired, pasted with whitespace, or under the wrong provider key. | -| Model not found | The model ID belongs to a different provider or gateway. | -| Provider cannot be inferred | Pin `modelPresets..provider` in the active preset instead of using `"auto"`. For legacy direct configs, pin `agents.defaults.provider`. | -| Local model connection refused | Ollama, vLLM, LM Studio, or another local server is not running, or `apiBase` points to the wrong port. | -| Bedrock validation error | Check AWS region, credentials, model access, model ID, and whether the model supports Converse. | -| OAuth provider fails | Run the matching login command: `openai-codex`, `xai-grok`, or `github-copilot`, normally with `--set-main`. | -| Codex OAuth needs a proxy | Set the address in **Settings → Advanced → Shared proxy** and enable **Use proxy** for OpenAI Codex before login. In `config.json`, use `network.proxy` and `providers.openaiCodex.useProxy: true`. This applies to login, token refresh, and Codex API requests. | -| Codex login runs on a remote/headless machine | In the WebUI, open ChatGPT in your local browser; when the localhost callback page cannot load, copy the full `http://localhost:1455/auth/callback?...` URL from the address bar and paste it into the WebUI dialog. From the CLI, open the printed URL locally and paste the same callback URL back into the terminal. | -| Codex login runs in Docker | Start the container with `docker run -it` so the OAuth flow has an interactive terminal. | -| Codex says a model is not supported with a ChatGPT account | Use provider `openai_codex` with a Codex model such as `openai-codex/gpt-5.6-sol`. Do not use the direct-API `openai/...` prefix with Codex OAuth. | -| Config says `providers.openai_codex` conflicts with the built-in provider | Under `providers`, keep only the canonical `openaiCodex` settings key and remove a duplicate `openai_codex` key. A model preset's `provider` value remains `openai_codex`. | -| xAI OAuth needs a proxy | Set `network.proxy` and `providers.xaiGrok.useProxy: true` before login, or use the shared address and provider switch in Settings. This applies to OAuth discovery, token exchange/refresh, and Grok subscription requests. | -| xAI login runs on a remote/headless machine | In the WebUI, finish sign-in in your local browser; if the loopback redirect cannot reach the server, copy the final URL from the address bar into the WebUI dialog. From the CLI, run `nanobot provider login xai-grok` interactively, open the printed URL elsewhere, and paste the final callback URL or authorization code when prompted. | -| xAI returns 403 or subscription access denied | Confirm the signed-in account has an eligible X Premium / Grok subscription, then run `nanobot provider login xai-grok` again. This provider does not use an xAI API key or X Developer OAuth. | -| xAI returns 400 `invalid-argument` | Read the bounded `Response body` appended to the provider error. Hosted `x_search` is sent only when xAI's model catalog advertises `supportsBackendSearch`; the model ID `grok-4.5` itself is valid. | -| xAI model or X Search stops working after an upstream release | The integration follows Grok Build's public OAuth/proxy client contract. Update nanobot if xAI changes that contract. | - -### Codex certificate verification errors - -Codex model requests fail if the server certificate is untrusted, expired, or does not match the hostname. nanobot does not retry these requests with certificate verification disabled. This also applies when WebSocket falls back to HTTP. - -Check the gateway machine's clock and the certificate chain used by your network or proxy. If your organization requires a private CA, obtain its trusted PEM bundle from your administrator and set `SSL_CERT_FILE` in the gateway process environment before restarting. `SSL_CERT_DIR` is also supported for an OpenSSL-compatible certificate directory. For model requests, these CA settings work with or without the explicit Codex proxy; they do not change the selected proxy route. Never trust a certificate supplied by an unknown error page or disable certificate verification. - -These model-request CA settings do not change OAuth login or model-catalog transport configuration. If those operations fail through a TLS-inspecting proxy, use an administrator-approved route that preserves the service's trusted certificate chain. Repeated sign-in does not repair a certificate error. Existing chats and credentials are not deleted by this failure. - -### Local Token Estimation - -Gateway loads the fallback tokenizer in the background, caching it beside the active config under `cache/tiktoken` unless `TIKTOKEN_CACHE_DIR` or `DATA_GYM_CACHE_DIR` is set; chats use UTF-8 byte estimates while loading or after failure (restart to retry), and token estimates may differ from model usage. - -## Langfuse Problems - -Langfuse tracing is optional and controlled by environment variables. - -| Symptom | Check | -|---|---| -| `LANGFUSE_SECRET_KEY is set but langfuse is not installed` | Install `langfuse` in the same Python environment that runs nanobot, then restart the process. | -| No traces appear | Set `LANGFUSE_SECRET_KEY`, `LANGFUSE_PUBLIC_KEY`, and `LANGFUSE_BASE_URL` before starting nanobot. | -| Wrong Langfuse project or region | Check that the key pair and `LANGFUSE_BASE_URL` come from the same Langfuse project/region. | -| Only some providers trace | Langfuse tracing applies to OpenAI-compatible provider calls and the Codex OAuth provider; other native providers may not use either client path. | - -See [`configuration.md#langfuse-observability`](./configuration.md#langfuse-observability) for setup commands. +| `401`, unauthorized, or invalid API key | Key is missing, expired, has extra whitespace, or belongs to a different provider | +| Model not found | Model ID is misspelled or unavailable on the selected provider | +| Provider cannot be inferred | Pin the provider explicitly inside your model preset instead of leaving it on `"auto"` | +| Local model connection refused | Start Ollama, vLLM, or LM Studio first and verify `apiBase` points to the right port | +| Bedrock validation error | Verify AWS region, credentials, model access, and that the model supports Converse | +| OAuth login fails | Run `nanobot provider login openai-codex`, `xai-grok`, or `github-copilot` (usually with `--set-main`) | +| OAuth login on a remote/headless machine | Sign in in your local browser; when the `localhost` redirect fails to load, copy the full URL from your browser's address bar and paste it into the WebUI dialog or CLI prompt | +| OAuth login in Docker | Start the container interactively with `docker run -it` | +| Codex or xAI needs a proxy | Set **Settings → Advanced → Shared proxy** (`network.proxy`) and enable **Use proxy** on that provider before signing in | +| Codex rejects an `openai/...` model | Use provider `openai_codex` with a Codex model (e.g. `openai-codex/gpt-5.6-sol`), not a direct API `openai/...` model | +| xAI returns `403` / access denied | Confirm your account has an active X Premium / Grok subscription, then sign in again with `nanobot provider login xai-grok` | +| Codex TLS / certificate error | Check the host's system clock and corporate proxy certificate chain; if your organization uses a private CA, set `SSL_CERT_FILE` (or `SSL_CERT_DIR`) in the gateway environment and restart | ## Gateway Problems -`nanobot gateway` is required for WebUI, chat apps, heartbeat, Dream, and long-running channel connections. +`nanobot gateway` powers the WebUI, chat apps, automations, heartbeat, and Dream. Run `nanobot gateway --verbose` to inspect live logs. -Default ports: +Default ports: **WebUI** `http://127.0.0.1:8765` · **Gateway health** `http://127.0.0.1:18790/health`. -| Surface | Default | +| Symptom | Fix | |---|---| -| Gateway health endpoint | `http://127.0.0.1:18790/health` | -| WebUI/WebSocket channel | `http://127.0.0.1:8765` | - -Common gateway checks: - -```bash -nanobot gateway --verbose -``` - -| Symptom | Check | -|---|---| -| Port already in use | Change `gateway.port`, `channels.websocket.port`, or the `--port` CLI flag for the relevant command. | -| WebUI opened on `18790` but shows nothing useful | Open `8765`; `18790` is the health endpoint. | -| Config changes ignored | Restart the gateway. | -| Startup pauses at `Installing optional feature` | An enabled channel is missing its Python dependencies. See [Slow Optional Channel Dependency Installation](#slow-optional-channel-dependency-installation). | -| Heartbeat never runs | Keep the gateway running, add tasks under `/HEARTBEAT.md` -> `## Active Tasks`, and make sure `gateway.heartbeat.enabled` is true. | -| Cron jobs disappeared after switching workspaces | Cron jobs are workspace-scoped at `/cron/jobs.json`; check you are using the intended workspace. | - -### Slow Optional Channel Dependency Installation - -Before loading enabled channels, the gateway checks the dependencies declared by their channel manifests. The CLI and WebUI normally install these dependencies when a channel is enabled. Installation during startup is a recovery path for an enabled config whose Python environment no longer has the required packages, for example after manually editing the config, upgrading nanobot, or recreating an isolated `uv tool`/`pipx` environment. The gateway waits for the install so an enabled channel is not silently skipped; later starts skip the installation once the dependencies are present. - -If access to PyPI is slow in your region, configure pip to use a trusted package index. The installer honors the standard `PIP_INDEX_URL` environment variable, including when nanobot itself was installed with `uv tool`: - -```bash -PIP_INDEX_URL=https://your-trusted-mirror.example/simple nanobot gateway -``` - -For the systemd user service created by `nanobot gateway install-service`, add a drop-in: - -```bash -systemctl --user edit nanobot-gateway.service -``` - -```ini -[Service] -Environment="PIP_INDEX_URL=https://your-trusted-mirror.example/simple" -``` - -Then reload and restart the service: - -```bash -systemctl --user daemon-reload -systemctl --user restart nanobot-gateway.service -``` - -For a system-level or custom service, use `sudo systemctl edit ` instead. Prefer an HTTPS index operated by an organization you trust, and do not put index credentials in commands or logs. +| Port already in use | Change `gateway.port`, `channels.websocket.port`, or pass `--port` | +| Port `18790` shows no WebUI | Open port `8765`—`18790` is only the health endpoint | +| Config changes ignored | Restart the gateway (`nanobot gateway restart`) | +| Startup pauses at `Installing optional feature` | An enabled chat channel is installing its missing Python dependencies; if PyPI is slow, set `PIP_INDEX_URL` to a trusted mirror | +| Heartbeat never runs | Keep the gateway running, add tasks under `## Active Tasks` in `/HEARTBEAT.md`, and verify `gateway.heartbeat.enabled` is `true` | +| Scheduled jobs missing after switching workspaces | Automations are stored per workspace—confirm you are running the intended workspace | ## WebUI Problems -Run `nanobot webui` to prepare the local WebSocket channel and open the browser. Finish model setup in **Settings → Models**. +Run `nanobot webui` to start the gateway and open your browser. -
-Manual WebSocket configuration - -The packaged WebUI is served by the WebSocket channel. - -Minimal config: - -```json -{ - "channels": { - "websocket": { - "enabled": true - } - } -} -``` - -Then run: - -```bash -nanobot gateway -``` - -Open: - -```text -http://127.0.0.1:8765 -``` - -
- -For first access, copy the complete login link printed by `nanobot webui`, including the fragment after `#`. In WSL, open that link in your Windows browser if automatic opening fails. The plain page address does not sign in a new browser. - -If accessing from another device, bind the WebSocket channel to `0.0.0.0` and set `token` or `tokenIssueSecret`. The WebSocket channel refuses public binds without a token or token issue secret. - -| Symptom | Check | +| Symptom | Fix | |---|---| -| A temporary chat disappeared after a reload or reconnect | This is expected. Temporary chats exist only for the current WebUI connection and are not saved to history or memory. Use a regular topic for anything you need to retain. | -| A skills.sh install says that `npx` is required | Install Node.js with `npx` on the gateway machine, or choose a SkillHub skill that does not require `npx`. | -| A remote browser says skill installation is disabled | Install from a same-machine WebUI. For a private deployment where every authenticated user is trusted to install third-party skill instructions or scripts, explicitly enable `tools.webuiAllowRemotePackageInstall`. | - -See [`webui.md#lan-access`](./webui.md#lan-access) for LAN setup and [`../webui/README.md`](../webui/README.md) for frontend development. +| Browser does not sign in | Copy the **complete login link** printed by `nanobot webui` (including everything after `#`)—the bare `http://127.0.0.1:8765` URL will not sign a new browser in | +| Cannot open from another device on LAN | Bind WebSocket `host` to `"0.0.0.0"` and set `tokenIssueSecret` (or `token`); see [LAN Access](./webui.md#lan-access) | +| Temporary chat disappeared after reload | Expected—temporary chats are not saved and end on reload or disconnect; use a regular topic for work you want to keep | +| Settings stay disabled after a restart | Reload the affected browser tab | +| `skills.sh` says `npx` is required | Install Node.js (which includes `npx`) on the gateway machine, or use SkillHub skills instead | +| Remote browser says installs are disabled | Install optional packages or skills from a local WebUI, or explicitly enable `tools.webuiAllowRemotePackageInstall` on trusted private deployments | ## Chat App Problems -Before debugging a chat app: +First confirm the CLI works and check channel status: ```bash nanobot agent -m "Hello!" @@ -297,52 +117,38 @@ nanobot channels status nanobot gateway ``` -Then check: - -| Symptom | Check | +| Symptom | Fix | |---|---| -| Bot never replies | Gateway is not running, the channel is not enabled, or the bot/app token is wrong. | -| Unknown sender ignored | Configure `allowFrom`, pairing, or the channel-specific allow list. | -| Telegram shows a saved configuration but cannot complete a live check | The token is saved. Confirm the gateway can reach `api.telegram.org`, or open **Channels → Telegram → Advanced → Network proxy** and enter an HTTP or SOCKS proxy. | -| Telegram rejects the token | Copy the current token from BotFather or regenerate it. | -| Telegram receives no messages | Confirm the channel is enabled, the gateway is running, and the sender is paired or listed in `allowFrom`. | -| Discord replies missing | Enable Message Content intent and invite the bot with the required permissions. | -| WhatsApp or WeChat login expired | Re-run `nanobot channels login whatsapp` or `nanobot channels login weixin`. | -| Chat app works but WebUI does not | The provider and gateway are likely fine; debug the WebSocket channel separately. | +| Bot never replies | Confirm the gateway is running, the channel is enabled, and the bot token/credentials are valid | +| Unknown sender ignored | Approve their pairing code (`/pairing approve `) or add them to `allowFrom` | +| Telegram saves token but live check fails | Confirm the gateway can reach `api.telegram.org`, or configure a shared proxy and enable **Use proxy** in Telegram settings | +| Discord replies missing | Enable **Message Content Intent** in the Discord Developer Portal and verify bot permissions | +| WhatsApp or WeChat login expired | Re-run `nanobot channels login whatsapp` or `nanobot channels login weixin` | -See [`chat-apps.md`](./chat-apps.md) for channel-specific setup. +See [Chat Apps](./chat-apps.md) for platform-specific setup. -## Tool and Workspace Problems +## Tools, Workspace, and Memory Problems -| Symptom | Check | +| Symptom | Fix | |---|---| -| File access denied | Check `tools.restrictToWorkspace` and whether the target path is inside the active workspace. | -| Shell commands fail in Docker | Sandbox settings may need Linux capabilities; see [`deployment.md`](./deployment.md). | -| Web fetch blocked | SSRF protection blocks unsafe targets; use `tools.ssrfWhitelist` only for trusted private networks. | -| MCP tools missing | Check `tools.mcpServers`, server startup command, environment variables, and tool allow list. | -| Generated artifacts are missing | Check the active workspace and channel media directory. | - -## Memory and Session Problems - -| Symptom | Check | -|---|---| -| Conversation context seems wrong | Confirm the active workspace and session. WebUI chats and chat app threads may use different sessions. | -| Memory does not update immediately | Dream consolidation is periodic; recent turns still live in session history. | -| Sessions disappear after changing `--config` | Sessions follow the config directory at `/sessions//`; use the original config path or copy that `sessions/` directory into the new config directory while nanobot is stopped. | -| Sessions disappear after moving a workspace | Keep the workspace's `.nanobot/workspace-id` file with the move or backup. If it was lost, restore that marker from backup before starting nanobot. | +| File access denied | Check whether the topic is in **Restricted** mode and the file is inside the active workspace | +| Shell commands fail in Docker | Sandbox mode may need extra container capabilities; see [Deployment](./deployment.md) | +| Web fetch blocked | Built-in SSRF protection blocks private/internal URLs; add trusted private hosts to `tools.ssrfWhitelist` only if intended | +| MCP tools missing | Check **Apps → MCP** (or `tools.mcpServers`), startup commands, and required environment variables | +| Memory does not update right away | Dream runs periodically (or when you run `/dream`); recent turns stay in session history until compacted | +| Startup reports session storage overlaps the workspace | Keep `config.json` and `sessions/` outside the workspace folder (e.g. `bot/config.json`, `bot/sessions/`, `bot/workspace/`), stop nanobot, back up both directories, and move config + sessions out of the workspace | +| Sessions disappeared after moving config or workspace | Keep `sessions/` alongside your config directory and keep `.nanobot/workspace-id` inside your workspace when moving or backing up | ## Collect Useful Evidence When opening an issue or asking for help, include: -- install method and `nanobot --version`; -- operating system and Python version; -- the command you ran; -- relevant `nanobot status` output; -- sanitized config snippets, especially provider, model, channel, and tool settings; -- gateway logs from `nanobot gateway --verbose`; -- whether `nanobot agent -m "Hello!"` works. +- Your OS, Python version, install method, and `nanobot --version`. +- The exact command you ran and the exact error message. +- `nanobot status` output and whether `nanobot agent -m "Hello!"` works. +- Relevant `nanobot gateway --verbose` logs and sanitized config snippets. -Never paste real API keys, bot tokens, OAuth tokens, or private chat IDs into public issues. +> [!CAUTION] +> Always remove real API keys, bot tokens, OAuth tokens, passwords, and private chat IDs before posting logs or configs. -If you find a docs mistake, outdated command, or confusing step, please open an issue: . +Found a doc error or confusing step? Please [open an issue](https://github.com/HKUDS/nanobot/issues). diff --git a/docs/updating.md b/docs/updating.md index 71866e927..bf868453f 100644 --- a/docs/updating.md +++ b/docs/updating.md @@ -1,125 +1,79 @@ # Updating nanobot -Use the update method that owns your installation. If your version does not include the WebUI updater, first upgrade through the original installer or package manager. This does not convert an existing installation into an installer-managed one. - -## Upgrade older JSONL installations - -The 0.4.x releases retain automatic import of legacy model JSONL history, WebUI JSONL / segments and per-feature proxy settings. You can upgrade an older installation directly to 0.4.1 through its original installation method; an intermediate 0.4.0 installation is not required. These importers are scheduled for removal in 0.5.0. - -1. Stop all writers and back up the complete instance, including the configuration directory and workspace. -2. Upgrade through the original installation method, preserving existing extras, constraints and installation ownership. -3. Start the updated instance with the same configuration and workspace selectors. Open existing conversations and verify both messages and displayed history. Check proxy settings and save the migrated shared-proxy configuration. -4. Verify the running version, a new message and another restart before considering the upgrade complete. - -Keep the original backup and retained JSONL import backups. Do not delete or overwrite old data to resolve a missing-history problem. Complete and verify the migration on a 0.4.x release before upgrading to 0.5.0. +Always update nanobot using the same method you used to install it. Do not switch package managers to work around an error. ## Update from the WebUI -1. Open the blue update entry in the sidebar or **Settings → About → Update**. Opening the dialog only checks the installation; it does not install or restart anything. -2. Review the exact version and affected gateways. Active work must finish before shutdown. Gateways that were already stopped are not started by the update. -3. Choose **Update & restart**. nanobot downloads and verifies the required files, backs up affected profiles, installs the update, and restarts the selected background gateways—not your computer or browser. -4. Wait for **Update complete**, which requires a reconnected gateway running the target version. Choose **Done** to reload the updated interface. If you hide the dialog, reopen it through **Settings → About → View details**. +1. Click the update notice in the sidebar, or open **Settings → About → Update** (opening the dialog only checks for updates—it does not install or restart anything). +2. Review the target version and affected gateways. Active tasks must finish before shutdown. +3. Click **Update & restart**. nanobot downloads and verifies the release, backs up affected profiles, installs the update, and restarts your background gateways (not your computer or browser). +4. Wait for **Update complete**, then click **Done** to reload the interface. -Inline updates support fresh official-installer environments and compatible POSIX uv 0.11.16 registry tool installations running a background gateway. Other installations show their own update instructions in the dialog; see [Installation owners](#installation-owners). Remote browsers need the gateway's explicit package-install permission. +In-app updates work for official-installer environments and supported `uv` tool installations running a background gateway. Other install methods display exact copy-and-run update commands in the dialog. Remote browsers require explicit package-install permission on the gateway. -On a local macOS desktop, the background WebUI's Dock icon stays available after closing the terminal and disappears when the gateway stops. A restarted or restored gateway recreates it after activation; it may disappear during package replacement and is not an update progress indicator. `--no-dock` remembers your choice for that instance. See the [Dock controls](webui.md#macos-dock-icon). - -Automatic installation requires official release approval and verified package checksums for both Stable and Preview. If verification fails, keep using the current version, retry later, and report persistent errors to a maintainer. Do not disable verification or install a replacement file from an error message. Verification confirms release approval; it is not a guarantee that all application or dependency code is harmless. +> [!NOTE] +> Automatic updates verify official release checksums before installing. If verification fails, stay on your current version, retry later, and report persistent errors rather than bypassing verification. ## Stable and Preview -**Settings → About → Receive preview updates** is off by default. Enable it to try new features earlier, with a higher risk of bugs. The preference applies to this installation, not just the browser; changing it requires the same local or remote permission as installing packages. It never downloads, installs, or restarts on its own. +**Settings → About → Receive preview updates** is off by default. Turn it on if you want early access to new features (with a higher risk of bugs). It never downloads or installs updates automatically. -Turn it off to receive only stable updates. If your Preview is newer than the latest stable release, nanobot keeps it until a newer stable release is available; it does not downgrade or restore old data. Installing a final release while Preview is enabled keeps Preview enabled for the next development cycle. You can skip intermediate previews. +Turning it back off returns you to stable updates without downgrading—if your Preview build is newer than the latest stable release, nanobot stays on it until a newer stable release arrives. -Stable fixes can arrive between feature releases. Preview availability depends on verified publication, not a promise of daily updates. Package-manager commands outside nanobot do not read this preference; choose their version or channel explicitly. +## Installation Owners -## Installation owners +When in-app updating is unavailable, update on the **gateway computer** using the original installation method: -When inline installation is unavailable, the update dialog identifies the installation method and guides you through its update. Run copied commands **on the gateway computer, as the original installation account**. For containers, use the deployment host rather than treating a container path as a host path. +| Installation method | How to update | +|---|---| +| Official installer | Use WebUI **Update & restart** | +| `uv` tool | Use WebUI **Update & restart**, or run `uv tool upgrade nanobot-ai` in the original environment | +| `pipx` | Run `pipx upgrade nanobot-ai` (preserve any custom options or injected packages) | +| Python virtual environment (`pip`) | Run `nanobot update` or ` -m pip install --upgrade nanobot-ai` (include any extras you originally installed) | +| Source checkout | Pull the latest branch in Git, preserve local changes, and follow [`CONTRIBUTING.md`](../CONTRIBUTING.md) | +| Docker / Compose | Pull or rebuild the image and recreate the service with your existing data volumes | -| Installation | Update route | -| --- | --- | -| Fresh official installer | Use WebUI **Update & restart** for a compatible release. Existing unrecorded environments are not automatically adopted. | -| uv registry tool | Use the supported inline flow above, or `uv tool upgrade nanobot-ai` in its original environment. Keep recorded extras, constraints and additional packages; a pin needs an explicitly reviewed new constraint. | -| pipx | Use `pipx upgrade nanobot-ai` only for an unconstrained registry install without recorded pip options. Otherwise preserve the original requirement, index/options, suffix and injected packages through the owner's workflow. | -| Ordinary pip venv | Use that environment's Python with `-m pip install --upgrade 'nanobot-ai[]'`; omit brackets for the base package. Do not guess optional extras. | -| Source checkout | Preserve local changes, update the selected ref and environment, and follow the [development instructions](../CONTRIBUTING.md). Source is not the Preview release channel. | -| Docker / Compose | Pull or build the selected image and recreate the service with its existing data volumes. Do not pip-install into a running container. | -| OS package, service manager or Desktop | Use the distributor or deployment's updater and launcher. | +For manual updates: stop nanobot, back up your config and workspace, run the update, restart, and verify the running version in **Settings → About** or `nanobot --version`. -For an external update, stop all affected writers, back up configuration and data, update through the original installation method, then restart the same profiles through their original launcher. New versions may migrate stored data. Verify the **running** version in **About** and check that configuration and conversations remain available. Package-manager success alone does not verify the gateway, and manual updates do not inherit the managed updater's automatic recovery. +## Recover an Interrupted Update -Do not switch package managers to work around an error. Fixed wheel sources, locked requirements and custom installations need their original settings reviewed. If a fresh official installation fails, fix the reported prerequisite or network error and rerun the same installer command. +Closing or refreshing your browser does not stop an in-progress update. If your connection drops, wait for it to reconnect and check status with **Check again**—do not start a second update while one is already running. -## Standalone API service removal +For official-installer environments, nanobot keeps a backup of the previous program before modifying packages. If installation fails, automatic recovery retries once or restores the previous version (without touching your config or conversations) and reports **Previous version restored**. -`nanobot serve` and its OpenAI-compatible `/v1` endpoints have been removed. This also removes the API server controls in Settings and the `nanobot-api` Compose service. The Gateway, WebUI, Python SDK, and OpenAI-compatible model connections are separate and still supported. The Python SDK embeds nanobot in a Python application; it is not an HTTP-compatible replacement. The `api` install extra is now empty so upgrades can preserve an existing installation's recorded extras. New installations do not need it. +### Standalone recovery -Before updating, stop any existing standalone API process through the launcher that started it. For a process started from Settings, use **Settings → System → Stop** in the old version. For Compose, use `docker compose stop nanobot-api` and `docker compose rm -f nanobot-api` with the old Compose file before switching to the new file. If you already switched, confirm which container belongs to your deployment and stop that old container explicitly; removing a service from the Compose file does not stop an existing container. Keep your bind mounts and volumes. +If automatic recovery fails, the WebUI displays a repair command with the saved job ID. Run it on the **gateway computer** as the original user (it only requires your base Python 3.11+): -Back up the configuration and data before updating. The old top-level `api` block is ignored on read and is omitted the next time nanobot saves the configuration. Session data and workspaces are not deleted or moved. If you must roll back, use the previous version and its matching deployment files, and recover the old service settings from your backup if necessary. Do not overwrite current configuration or conversations with a stale backup. - -To read old API conversations after updating, open the same configuration and workspace with [the Python SDK](./python-sdk.md#botsessions). Use `await bot.sessions.list()` to find keys such as `api:default` and `api:`, then use `await bot.sessions.get(key)` to read their messages. If the old launcher used a separate API workspace, pass that workspace to `Nanobot.from_config(config_path, workspace=workspace)` instead of using the Gateway's workspace. - -## Shared sessions removal - -The shared sessions feature has been removed. The old `agents.defaults.unifiedSession` or `unified_session` setting is ignored. - -## Recover an interrupted update - -Refreshing restores saved progress, **not installation consent**. A staged update may ask you to review and confirm it again. A disconnected page cannot tell whether the worker stopped: do not start another installation while it reconnects. Closing the browser does not stop the managed update or its recovery. - -**Check again** only reads saved status. **Review update** asks the gateway to settle an interrupted preparation or failed handoff before opening a fresh review. Settlement is refused while an owner is active or the operation has progressed too far to discard safely. It does not prepare or install another update; that requires a separate **Update & restart** confirmation. - -If settlement is refused or its response is lost, the saved job remains available for status checks and recovery. A timeout or missing response is not permission to create a second update. After package changes have begun, use recovery rather than trying another installation. - -## Automatic service recovery - -For installer-owned dedicated environments with supported background gateways, the update confirmation also authorizes bounded recovery of that exact operation. nanobot retains a separate copy of the original program and dependencies before changing packages; insufficient space aborts installation. - -If installation fails, recovery tries the already approved target once using saved files. If that also fails before the new gateway is activated, it can restore the original program and restart the reviewed gateways **only if protected user data is unchanged**. The dialog reports **Previous version restored**, not update success. A restored service needs a fresh review before another update. - -Recovery never replaces current configuration or conversations with an old backup. Changed user data, missing or corrupt saved files, changed installation ownership, persistent disk errors, a missing base Python, or loss of both recovery processes can require operator help. Keep the saved job and backup; do not delete recovery markers or install over them. This is not recovery after every power loss or a guarantee against malicious code. Other installation methods retain their original recovery route. - -## Standalone recovery - -When automatic recovery is unavailable or reports failure, the WebUI can show a repair command containing the saved job ID and exact Python and launcher paths. Copy that command and run it **on the gateway computer, as the original OS user**. It does not require a working nanobot environment, but it does need the original base Python. - -The following examples assume the gateway uses your terminal's normal home directory and a Python 3.11+ command. Prefer the exact paths shown by the WebUI when they differ. - -macOS / Linux: +**macOS / Linux** ```sh python3 -I -S ~/.nanobot/updates/recover.py python3 -I -S ~/.nanobot/updates/recover.py --repair ``` -Windows PowerShell: +**Windows PowerShell** ```powershell python -I -S "$env:USERPROFILE\.nanobot\updates\recover.py" python -I -S "$env:USERPROFILE\.nanobot\updates\recover.py" --repair ``` -The first command only inspects the job. `--repair` shows its saved version, environment and backup, then asks for confirmation; `--yes` skips that prompt only when used with `--repair`. Repair reuses the same verified files without downloading another release. If installation finished but restart failed, it retries restart rather than reinstalling packages. Merely preparing files does not make a job eligible for repair. +The first command inspects the saved job; `--repair` verifies the files and asks for confirmation before repairing (add `--yes` to skip the prompt). -Keep the original job directory and backup until recovery is verified. Missing or changed files and an independently modified environment require operator repair. Do not restore backups over live data. Downgrading and restoring user data are separate, owner-managed operations. +### Explicit recovery before package mutation -## Review an exact release +
+CLI plan inspection and pre-install retry + +To inspect an update plan from the CLI without installing anything (plans expire after 15 minutes): ```bash nanobot update --plan nanobot update --plan --channel preview ``` -These commands save a plan showing the installation method, installed and running versions, exact target, download details and expected action. They may write plan and metadata-cache files, but do not install, stop tasks or restart gateways. `--channel` is a one-time inspection; it does not change your saved subscription. - -Plans expire after fifteen minutes. Execution rechecks the reviewed release and refuses changed installations, withdrawn releases or changed artifacts. A plan is not installation permission. The separate `nanobot update`, `--check` and `--dev` commands do not execute saved plans; see the [CLI reference](cli-reference.md#updating). - -## Explicit recovery before package mutation - -If shutdown failed **before package changes began** and the application environment is still intact, you can inspect the saved job and explicitly retry its reviewed operation: +If an update failed during shutdown **before** packages were modified, you can inspect and retry the saved job: ```bash nanobot update --job @@ -127,8 +81,31 @@ nanobot update --job --retry-handoff \ --previous-confirmation --confirm-restart ``` -Read the saved facts and original plan before running the second command: it approves shutdown, installation and restart, not just a connection check. The same plan must still be valid, and live owners prevent retry. An accepted request is not proof of completion; check the saved result and running gateway. +If packages were already partially changed, use [Standalone recovery](#standalone-recovery) instead. -These commands cannot repair a broken installation or packages already changed by an interrupted update. Use [standalone recovery](#standalone-recovery) instead. +
-For contributor-facing APIs, ownership and execution rules, see [Update protocol](update-protocol.md). Maintainers should use the [release checklist](releasing.md). +## Version Migration Notes + +
+Upgrading from older JSONL installations (pre-0.4) + +0.4.x releases automatically import legacy JSONL chat history and per-feature proxy settings; these importers are scheduled for removal in 0.5.0. + +1. Stop nanobot and back up your complete config directory and workspace. +2. Upgrade to 0.4.x using your original installation method. +3. Start nanobot, verify your conversations and shared proxy settings, and confirm a restart works cleanly before eventually upgrading to 0.5.0. + +
+ +### Standalone API service removal + +
+Notes if you previously used nanobot serve or shared sessions + +- **`nanobot serve` removed:** The standalone OpenAI-compatible `/v1` HTTP server (`nanobot serve` and the `nanobot-api` Compose service) has been removed. The Gateway, WebUI, Python SDK, and OpenAI-compatible model connections remain supported. Stop any old `nanobot serve` process or `nanobot-api` container before upgrading. Old `api` config blocks are ignored, and old API sessions (`api:...`) remain readable via [the Python SDK](./python-sdk.md#botsessions). +- **Shared sessions removed:** `agents.defaults.unifiedSession` is no longer supported and is ignored. + +
+ +For contributor details on the update protocol, see [Update protocol](./update-protocol.md). diff --git a/docs/webui.md b/docs/webui.md index 179a6403b..6b00b1b03 100644 --- a/docs/webui.md +++ b/docs/webui.md @@ -2,11 +2,9 @@ -The WebUI shares its gateway and saved sessions with the native terminal client and is included with `nanobot-ai`. +The WebUI is nanobot's browser workbench. It is included with `nanobot-ai` and shares the same gateway, settings, and saved conversations as the terminal UI (TUI). -For a visual tour, see the [README feature gallery](../README.md#-webui). This guide follows the current source tree; some features are newer than the published release. - -In **Settings → Appearance → Background**, choose a PNG, JPEG, or WebP image up to 6 MiB and 32 megapixels, adjust blur and background fade, then save. The image and settings are shared by devices connected to the same instance; refresh another device to load changes. More fade makes the background subtler and can improve text readability. Images are centered and cropped as needed to fill the window. +For a visual tour, see the [README feature gallery](../README.md#-webui). ## Open the WebUI @@ -14,24 +12,16 @@ In **Settings → Appearance → Background**, choose a PNG, JPEG, or WebP image nanobot webui ``` -On a new installation, the launcher asks for confirmation to create the config and workspace, enables the local WebUI, and opens a signed-in browser. Configure a provider and model in **Settings → Models** before sending your first message; see [Configure Your Model](./quick-start.md#2-configure-your-model). The default address is `http://127.0.0.1:8765`, accessible only from the same machine. +On a fresh install, nanobot creates your config and workspace, starts the local gateway, and opens a signed-in browser window at `http://127.0.0.1:8765` (accessible only from your computer). Before your first chat, add a provider and model in **Settings → Models** (see [Configure Your Model](./quick-start.md#2-configure-your-model)). -Official-installer environments start a persistent gateway by default. Other installations keep it attached to the launchers: closing the last WebUI or TUI launcher stops an on-demand gateway. Use `nanobot webui --detach` to keep it running after the terminal closes, or start it explicitly: +With the official installer, the gateway stays running in the background after you close the browser or terminal. Manage it with `nanobot gateway status`, `logs`, `restart`, and `stop`. For other install methods (such as `uv` or `pip`), use `nanobot webui --detach` or `nanobot gateway --background` to keep it running in the background. -```bash -nanobot gateway --background -``` - -Manage a persistent gateway with `nanobot gateway status`, `nanobot gateway logs`, `nanobot gateway restart`, and `nanobot gateway stop`. Use the printed instance-specific commands for a custom config or workspace. The old `nanobot webui --background` flag is deprecated; `--detach` cannot be combined with `--dev`. - -To sign in another browser, use the complete printed login link, including the fragment after `#`. Treat it as a credential. `nanobot webui --no-open` prints the link without opening a browser. In WSL, the launcher uses the Windows default browser unless `BROWSER` is set; if automatic opening fails, use the printed link. - -The launcher displays gateway warnings and errors; use the printed logs command for full output. +To sign in from another browser on the same machine, copy the **complete login link** printed in the terminal (shaped like `http://127.0.0.1:8765/#...`, including everything after `#`)—the bare address without the `#...` token will not sign a new browser in. Keep that link private. Use `nanobot webui --no-open` to print the link without launching a browser.
Manual configuration for the local WebUI -Listener and authentication fields are configured in `config.json`. Localhost access can run without a browser password; set `tokenIssueSecret` for access beyond localhost or to require a password: +Localhost access does not require a browser password by default. To require a password or allow access from other devices, set `tokenIssueSecret` in `~/.nanobot/config.json`: ```json { @@ -50,259 +40,159 @@ Listener and authentication fields are configured in `config.json`. Localhost ac ### macOS Dock icon -On a local macOS desktop, `nanobot webui` provides a Dock shortcut to the running WebUI. `--no-open` keeps the shortcut without opening a page; `--no-dock` disables it. It is unavailable in SSH/headless sessions or for non-loopback browser addresses. +On a local macOS desktop, `nanobot webui` adds a Dock shortcut to your running WebUI (`--no-dock` disables it). Quitting or hiding the Dock icon only hides the shortcut; it does not stop the gateway or running tasks. -Attached launchers share the shortcut until the last matching WebUI launcher exits. With `--detach` or official-installer background launch, it remains until the gateway stops and returns after restart or update. It is a shortcut to a running instance, not a standalone app. +## Overview -**Hide Dock Icon** or quitting the icon hides the shortcut without stopping the gateway or its tasks, until the next explicit launch or service restart. In detached mode, `--no-dock` also disables it for later restarts; launching without that flag enables it again. - -## Navigate a long conversation - -The message rail on wide screens and prompt-summary search in the header jump to saved prompts, loading the surrounding messages as needed. Loading errors leave the current content available for retry. Older compatible hosts may only support navigation among already-loaded messages. - -## Sharing access - -The WebUI administers one nanobot instance. Signed-in users share saved topics and administrative controls; there are no per-user roles or private topic ownership boundaries. The [remote installation restriction](#lan-access) limits package installation, not other administrative access. - -Share WebUI access only with people you trust to administer the same agent. To give someone chat access without the administration interface, connect a [chat platform](./chat-apps.md) and configure its access policy. Channel approval still does not create a separate agent or memory store. For separate clients or users whose data must not mix, use [separate instances](./multiple-instances.md). - -## What It Is For - -| Area | Use it for | +| Area | What you can do | |---|---| -| Topics | Start persistent topics or temporary chats; switch, search, reorder, fork, or delete persistent topics | -| Conversation groups | Arrange up to four independent topics in one workbench with resizable panes | -| Agent activity | See thinking, tool calls, file edits with diffs, command output, and generated artifacts in context | -| Context usage | Inspect current context size, per-round token and cache usage, and compaction progress | -| Workspace | Pick the project workspace before asking for file or shell work | -| Access | Choose the access mode for local capabilities allowed by your gateway configuration | -| Composer | Send text, images, voice input, slash commands, and `@` mentions for topics, Apps, or MCP presets | -| Channels | Connect and validate chat platforms, install their optional support, and manage saved channel setup | -| Apps | Install, test, update, and use local CLI App adapters and MCP presets | -| Skills | Inspect and manage installed skills, or discover skills from supported marketplaces | -| Automations | Review, search, run, pause, edit, and delete scheduled and local-trigger agent turns | -| Settings | Adjust models, providers, image generation, voice, web tools, runtime, and safety options | +| Topics | Start persistent topics or temporary chats; search, reorder, rename, archive, fork, or delete topics | +| Conversation groups | Work in up to four topics side by side with resizable panes | +| Activity & context | Inspect reasoning, tool calls, file diffs, token/cache usage, and the file graph | +| Workspace & Access | Pick a project folder and choose **Restricted** or **Full Access** | +| Composer | Send text, images, files, videos, voice input, `!` shell commands, `/` commands, and `@` mentions | +| Channels | Connect Telegram, Discord, Slack, Feishu, WeChat, Linear, and more with guided setup | +| Apps | Manage Agent Plugins, CLI Apps, and MCP servers | +| Skills | Inspect installed skills or discover new ones from skills.sh and SkillHub | +| Automations | Review, run, pause, edit, and delete scheduled tasks and local triggers | +| Settings | Configure models, providers, capabilities, appearance, and updates | -## Check for updates +## Topics and Panes -Open **Settings → About** to check for updates automatically. Startup, reconnecting, and normal chatting do not trigger background version checks. Use **Check again** or **Retry** to check manually; changing the update channel also refreshes its status. Checking does not install updates or restart nanobot. +Each topic in the sidebar keeps its own history, title, project folder, and linked automations. Use **New topic** for a fresh context, or **Fork** to branch off an existing conversation without changing the original. -## Topic Workspace - -The sidebar is the topic switcher. Each topic keeps its own history, title, workspace selection, and linked automations. Use a new topic when you want a separate context; use fork when you want to continue from an existing point without changing the original thread. - -If creating or forking a topic times out, it may already have succeeded; it is not automatically retried. Reconnecting ends temporary chats. - -Drag topics within a sidebar group to reorder them. **Rename** edits a topic title in place; a failed save keeps the draft for retry. - -Use **Select** in a topic's action menu to archive or delete several topics at once. Click outside the topic rows and toolbar, or press **Esc**, to leave selection mode. Archiving removes pins and hides topics from the default list while keeping their conversations. Use **Show archived** to find them again; selecting only archived topics offers **Unarchive**. - -**Delete** hides topics and gives you 8 seconds to choose **Undo**. When that window ends, topics with linked automations reappear so you can confirm whether to delete them and their automations. +- **Organize:** Drag topics to reorder them, or use **Rename** to edit a title inline. +- **Bulk actions:** Choose **Select** in a topic's menu to archive or delete multiple topics at once (press `Esc` to exit selection mode). Archived topics stay saved and can be restored from **Show archived**. +- **Delete with undo:** Deleting a topic hides it with an 8-second **Undo** window. Topics with linked automations ask for confirmation before removing their automations. +- **Navigate long conversations:** Use the message rail on wide screens or prompt-summary search in the header to jump directly to earlier messages. Scroll past the top (or pull down on touch devices) to load older history. ### Conversation groups and panes -Open a topic's sidebar action menu and choose **Create group** to turn it into a conversation group. Use **Add pane** in the workbench header to start another topic alongside it. A group holds up to four panes. To bring in an existing topic, drag it onto the group or use **Move to** in its action menu. +Open a topic's menu and choose **Create group** to arrange up to four topics side by side. Use **Add pane** in the header to start another topic alongside it, or drag an existing topic into the group. -**Pane layout** controls the arrangement of resizable panes. Selecting a pane directs the shared composer to that topic. Group membership and layout persist across refreshes; grouping does not merge topic histories. - -To use work from another topic, mention it with `@` and tell nanobot what you need. See [Composer](#composer) for how to add a topic reference. +Selecting a pane targets the composer at that topic. Grouping only arranges panes—it does not merge topic histories. To pull context from another topic, mention it with `@`. ### Model options for a topic -Open the model preset menu beside the composer to choose **Reasoning effort** for the next message in this topic. Drag the slider to choose a known effort level. Codex presets also offer **Fast**, with an **Ultrafast** choice for supported models. The menu selects the current value, such as `medium`, when it opens. Selecting a value applies it to this topic without editing the preset; switching presets clears topic selections. The single lightning button requests Fast; the double lightning button requests Ultrafast. Select the active button again to turn speed boosts off. Faster processing increases Codex usage and depends on model and account availability. +Open the model preset menu beside the composer to adjust **Reasoning effort** (and **Fast** / **Ultrafast** speed boosts on supported Codex models) for the current topic without changing the shared preset. Switching presets resets these per-topic overrides. -Choices do not edit shared presets or provider settings and do not change an already-running task. Unsent choices are remembered in this browser; the last values sent with an ordinary message are saved with the topic and survive a gateway restart. Switching presets clears both overrides. Temporary chats do not show these controls. +## Composer -### Activity and context usage +The composer supports text, images, documents, videos, voice input, slash commands, and `@` mentions. -While nanobot works, **Working for** shows the latest activity beside the timer, or below it on narrow screens. Select the timer to see the full reasoning and tool activity. Set **Settings → Appearance → Activity details** to **Expanded** if you prefer to see the details by default. - -Expand the **Worked for** section to inspect the reasoning and tool activity for a completed turn. - -Scroll past the oldest loaded message, or pull down and release on touch devices, to load earlier history. A red indicator offers error details and retry; **No earlier messages** marks the history boundary. - -Tasks in persistent topics can continue while the connection is lost. Status and completed replies update after reconnecting; some missed text may appear only when the task finishes. [Temporary chats](#temporary-chats) end on connection loss. - -The context indicator beside the model badge shows context-window usage. **Recent rounds** includes token usage, generation time and KV cache hits when reported. Provider figures may be estimated or unavailable and are not a billing statement. - -Open the file graph to see files used since the latest compaction and local Markdown references discovered in those files. Click a node to see its estimated token count or open the file, and drag across the usage bar or use replay to review earlier rounds. A loaded node means the file was read or supplied during this phase; it does not guarantee that the whole file, or its original text, remains in the model's current request. Compaction starts a new replay phase; its graph appears with the next request. Previously saved snapshots remain readable, but missing historical snapshots are not reconstructed from current files. - -Switching topics closes the previous topic's graph. Reopen it from the context indicator for the selected topic. Large or continuously growing graphs may be less responsive on slower devices. - -During compaction, the model switches to a summary plus subsequent messages; the original messages remain in chat history. Use `/compact` to compact the current topic manually. See [Memory](./memory.md) for compaction and Dream consolidation. - -### File and diagram previews - -File activity shows the path, status and changed line counts. **Settings → Appearance → File edit display** offers **Summary**, inline **Diff**, or **Collapsed diff** with **View diff**. Large patches may omit unchanged lines or be truncated. Select a filename to open its read-only preview. - -Files share a tabbed preview pane. Tabs and pane width are remembered per topic until the session is deleted or the WebUI connection ends. - -Selecting a Markdown file opens **Preview**; **Source** shows the original text. Relative file links resolve from the document's folder and follow the same access checks. Images are not loaded automatically, section-only links remain text, and HTML/MDX components do not execute. - -Text previews are limited to 384 KiB and indicate truncation. Very large or minified source may remain plain text. Image previews support PNG, JPEG, GIF and WebP up to 8 MiB. HTML and SVG files display as read-only source. - -Explicit Markdown images appear inline; image attachments use a gallery. Other files appear as compact download cards below the image and video previews, with a file-type icon, filename and download action. File-type icons do not indicate preview support. Ordinary image file links open the preview instead. - -Mermaid diagrams render after the reply finishes. The source remains available if rendering fails. Links, external images and executable HTML inside diagrams are disabled. - -Right-click a file reference or preview tab to copy its absolute or project-relative path on the connected host. Files outside the project have no project-relative path; unresolved references can only be copied as written. - -File previews follow the active topic's access mode. Restricted workspace access previews only files under the selected workspace. Full Access can preview files outside the workspace when that access mode is allowed by the gateway. - -### Model failures - -If a model stream fails after producing reply text, the text is retained for reading and follow-up questions. A reply can look complete even when the request ended with a connection error. - -After a model request fails and automatic retries stop, the WebUI shows the failure category. Use **Continue** to resume from the saved conversation, or open model settings to change the model or correct its authorization. Review completed work before continuing: saved tool results are retained, but the model can choose to call tools again. Continuing does not resend the original message. Sending a new message or dismissing the notice clears the pending decision. Saved recovery decisions remain available after a refresh or gateway restart; temporary chats still follow their normal lifetime. - -### Delegated work - -When nanobot delegates work to subagents, **Subtasks** appears above the message input while tasks are queued, running, or stopping. It stays within reach as the conversation scrolls, even after the main reply finishes or you send another message. Open it for live activity; on narrow screens it opens from the bottom. The task list scrolls independently of the conversation. - -Finished tasks leave the live list when it is closed. If you are already reading the list, they remain until you close it. When all tasks finish with the list closed, a brief completion or failure summary appears and then disappears; focusing or hovering over it keeps it available. - -Saved results appear as compact, expandable records beside their associated requests, and scroll with the conversation. Results for earlier requests appear when their turns are loaded; tasks without a matching request in the displayed history are not shown there. Refreshing or reopening the WebUI restores active work in the fixed entry and finished work in the conversation, without restarting tasks or bringing all old tasks back into the live list. The WebUI retrieves finished tasks only for the loaded turns. - -Select a task for its read-only conversation and tool activity. Closing the details leaves it running; its stop button cancels only that task. Give follow-up instructions to nanobot in the main conversation. - -These controls appear when the connected host supports subagent tasks. See [Subagents](./concepts.md#subagents) for cancellation, saved history, and gateway restart behavior. - -## Temporary Chats - -Start **New topic → Temporary chat** to work without saved agent profiles, long-term memory, or the memory skill in the model context. The conversation is not added to topic history or long-term memory. Native file readers and editors cannot access the agent profile or memory files in this mode. Subagents are unavailable; project instructions and ordinary workspace files remain available. - -You can keep more than one temporary chat open and switch between them under **Temporary chats** in the sidebar while the current WebUI connection remains open. Reloading or closing the page, restarting the gateway, or losing the WebSocket connection ends all of them. They cannot be recovered afterward. - -Temporary chats do not create saved files for oversized text tool results; these stay in memory and are truncated to the configured tool-result limit. Tool-call arguments and execution-error details are hidden from the built-in tool logs, while tool activity remains visible in the current chat. - -Temporary does not mean consequence-free. Requests still go to the configured model provider, and tools can still change files, run commands, or affect external services. Files and image artifacts created or exported by tools (including images returned by MCP tools) are not erased when the chat closes. Temporary chats always use the default workspace in Restricted mode; the project picker and Full Access are unavailable. Commands and tools that create durable goals, automations, or subagent work are also unavailable. Native file tools can read `HEARTBEAT.md` but cannot edit it in a temporary chat. Use a regular topic when you need reusable context, scheduled work, or a result you must retain. +- **Sending:** On desktop, `Enter` sends and `Shift+Enter` adds a newline. On touch devices, `Enter` adds a newline and the send button submits. +- **Queuing while busy:** While nanobot is replying on desktop, pressing `Enter` adds to a waiting message that sends automatically when the reply finishes. Use **Send now** (or press `Enter` on an empty box) to send it immediately as guidance—a dashed border shows when a follow-up is waiting for the model, returning to normal once the model picks it up. +- **Attachments:** Drop or select images, PDFs, Office documents, or videos (MP4/WebM/MOV, one per message up to 20 MiB; videos play in the WebUI, though the agent cannot analyze video contents yet). +- **Attach host files by path:** Paste a file path on the nanobot host on its own line to reference it without uploading or copying (respects the topic's workspace permissions). +- **Direct shell commands:** Start a message with `!` (such as `!git status`) to run a command directly in the topic's workspace without calling the model. +- **Mention other topics:** Type `@` (or drag a topic from the sidebar) to reference up to eight topics in one message—for example, *"Summarize @luma"* or *"Send this update to @luma."* +- **Voice input:** When voice transcription is enabled in Settings, the empty composer shows a microphone button. +- **Image generation:** Enable image generation in Settings to create and edit images in chat (see [Image Generation](./image-generation.md)). ## Workspace and Access -Project selection and Full Access controls require an owner-authenticated WebUI connection. Ordinary WebSocket clients stay within the workspace and access mode configured by the operator; an owner's saved topic scope or WebUI preference does not grant a client additional access. Existing topics remain available to the owner, while clients attempting to resume a topic outside their configured authority receive an error instead of silently changing its scope. Legacy plain-text clients use the same permission boundary. Keep the configured `tokenIssueSecret` (or fallback `token`) private: it can issue owner credentials. Share short-lived client connection tokens, not that owner secret. +Click the workspace picker when starting a new topic to browse folders on the nanobot host, jump to recent or starred projects, or enter a path directly (`Cmd/Ctrl+Shift+G`). Changes apply when you click **Confirm**. Saved topics keep their project folder fixed; start a new topic to work in a different project. -Inputs to the same session with different workspace permissions wait for the active turn to finish, then run with their own permissions. Inputs with the same scope can still join the active turn. - -Use the workspace picker to browse folders on the connected nanobot host, enter an absolute path, or return to recent and starred projects; favorites persist across gateway restarts. The host name appears above saved locations. Project paths refer to that machine, not the browser's filesystem. - -Choose the project when starting a new topic. Saved topics, including forks, keep their project directory fixed. Start a new topic for another project. You can still change access mode within the same project while the topic is idle. - -Browsing does not change the topic's workspace until you choose **Confirm**. **Filter this folder** searches only the current directory. **Cmd/Ctrl+Shift+G** opens host-path entry, with Tab completion; **Last visited folder** returns to the previous location. - -Manual path entry remains available when the connected host does not support directory browsing. The host validates the selected path and access policy. - -Selecting a project does not replace the configured agent workspace. The two paths have different responsibilities: +Selecting a project folder sets the working directory for files and shell commands without changing your agent's identity or memory: | Selected project provides | Agent workspace continues to provide | |---|---| | Project `AGENTS.md` | `SOUL.md` and `USER.md` | -| Relative file paths and shell working directory | Long-term memory and history | -| The normal read/write boundary in Restricted mode | Custom skills and instance state | +| Relative file paths and shell working directory | Long-term memory (`memory/`) | +| The read/write boundary in **Restricted** mode | Custom skills (`skills/`) and instance state | -A new topic separates conversation history; a project selection changes the file working directory. Neither creates a separate long-term memory store. Choosing another project for a new topic can therefore carry preferences and facts learned in other topics into the new project. Use [separate instances](./multiple-instances.md) when client or user data must stay separate; see [Memory](./memory.md) for how shared memory is maintained. +> [!NOTE] +> Starting a new topic or selecting a different project does not create separate long-term memory. If you need strict separation between clients or users, use [Multiple Instances](./multiple-instances.md). -Project-local `SOUL.md` and `USER.md` files are ignored, and the agent workspace's `AGENTS.md` is not inherited by a separately selected project. When the selected project is the configured agent workspace, both roles naturally use the same directory. +Use the access control in the composer to choose between **Restricted** (file and shell work stays inside the selected project, with narrow read-only access to skills and agent memory wiki) and **Full Access** (when allowed by your gateway config). You can switch access mode while a topic is idle. -The access control in the composer controls the local capability level for the chat. It does not bypass your gateway, provider, shell sandbox, or operating system configuration; it only selects among the capabilities that are already available to the current topic. +## Activity, Previews, and Subtasks -In Restricted mode, ordinary file and shell work stays inside the selected project. To preserve agent continuity, filesystem/search tools receive narrow, read-only access to built-in skills, custom skills and `memory/wiki/` in the agent workspace, and the exact agent `memory/history.jsonl` file. This does not grant access to neighboring memory or profile files, and it does not allow writes outside the selected project. These tool exceptions do not broaden the browser's file preview boundary. +### Activity and context usage -## Composer +While nanobot works, **Working for** shows its live step and timer; click it to view full reasoning and tool calls (or set **Settings → Appearance → Activity details** to **Expanded**). After a turn finishes, expand **Worked for** to inspect the full trace. -The composer supports text, attachments (images, documents, and videos), slash commands and `@` mentions. With voice transcription configured, the empty composer offers voice input; transcription is added to the draft before sending. +Tasks in persistent topics keep running even if your browser disconnects; status and completed replies sync when you reconnect. -Start a message with `!` to run a Shell command directly in the topic's workspace, without calling the model (for example, `!git status`). Multiline commands are supported; remove attachments and quoted text before running a command. Commands run immediately, separately from waiting messages, and use the topic's existing permissions and Shell limits. +Click the context indicator beside the model badge to inspect: -Images appear as thumbnails above the draft. Hover over a thumbnail for its filename and size; use its top-right × to remove it before sending. Documents and videos keep their file cards, and attachment errors remain visible. +- **Context usage & recent rounds:** Estimated token usage, generation time, and cache hits (estimates only, not a billing statement). +- **File graph:** Files read since the last compaction and local Markdown links between them. Click any node to inspect its estimated size or preview the file, and scrub the usage bar to replay earlier rounds. -Choose or drop MP4, WebM, or MOV videos into the composer (one per message, up to 20 MiB per upload). You can play them in WebUI; the Agent cannot directly analyze their contents yet. +When a conversation grows long, nanobot summarizes earlier turns while keeping your full chat history visible. You can also run `/compact` anytime (see [Memory](./memory.md)). -To attach a file on the connected nanobot host, paste its path on its own. Quoted paths and spaces are supported; relative paths start from the topic's workspace. The topic's access permissions apply. Path references do not upload or copy the file and have no file-size or combined-size limit; supported formats and attachment counts still apply. If attaching fails, the text stays in your draft. +### File and diagram previews -Files attached by path reflect changes to the original file and become unavailable if it is moved or deleted. Removing an attachment or deleting a topic does not delete the original. +File edits show the path and changed line counts. Change **Settings → Appearance → File edit display** between **Summary**, inline **Diff**, and **Collapsed diff**. Click any filename to open a read-only preview tab (text previews up to 384 KiB; PNG/JPEG/GIF/WebP images up to 8 MiB; Markdown renders with a **Source** toggle; Mermaid diagrams render automatically). Right-click a file reference or tab to copy its path. -To reference another topic, type or paste its complete handle (such as `@luma`), choose it from the `@` menu, or drag it from the sidebar into the composer. Recognized handles are highlighted; unknown handles remain plain text. You can reference up to eight different topics in one message. +### Model failures -Ask nanobot to find, read, or send messages to other saved topics, including those in other projects. For example, “Summarize @luma” or “Send this update to @luma.” Mentioning a topic alone does not send a message to it. +If a model call fails after automatic retries stop, any partial reply is preserved and the WebUI shows why it failed. Click **Continue** to resume from the saved conversation, or open model settings to fix credentials or switch models. Review completed tool calls before continuing, as the model may re-run tools if needed. -On touch-primary phones and tablets, **Enter** inserts a newline; tap the send arrow to submit. This also applies when a coarse-pointer tablet has a hardware keyboard attached. On desktop, **Enter** sends and **Shift+Enter** adds a newline. An open slash-command or mention menu takes precedence: Enter selects its item. +### Delegated work -During a response, desktop Enter appends input to one waiting message, preserving order, attachments and references. It sends when the response finishes. **Send now** or Enter on an empty input sends it immediately as guidance; the send arrow submits the waiting content together with any draft. **Edit message** and **Delete message** act on the whole waiting message. Additions that exceed limits stay in the input. Stopping a turn or a failed send preserves the waiting message for manual sending. +When nanobot delegates work to subagents, a **Subtasks** bar appears above the composer while tasks are active. Open it to watch live progress, inspect a subtask's read-only trace, or stop an individual subtask. Finished subtasks appear inline beside the message that started them. See [Subagents](./concepts.md#subagents) for cancellation and restart behavior. -Automatic sending continues across topic switches and short reconnects while the page stays live. Reloading, reopening, leaving the page, or the browser freezing it restores waiting content for manual sending; choose **Send now** or edit and send it when ready. +## Temporary Chats -When you send a follow-up while the agent is busy, a dashed edge shows that the message is waiting for the model. The usual edge returns when the request that answers that message begins. This live hint is cleared on Stop or disconnect and is not restored from history. +Choose **New topic → Temporary chat** when you want a throwaway conversation that does not use your agent profile or long-term memory and is never saved to history. -For image generation, configure an image provider first and then use the WebUI image mode from the composer. See [`image-generation.md`](./image-generation.md) for provider setup and output behavior. +- You can keep multiple temporary chats open in the sidebar during one browser session. +- Reloading the page, closing the tab, losing the connection, or restarting the gateway permanently deletes all temporary chats. +- Temporary chats always run in the default workspace in **Restricted** mode and cannot create goals, automations, or subagents. + +> [!WARNING] +> Temporary does not mean consequence-free. Prompts still go to your AI provider, and tools can still edit files, run commands, or call external services. Files created by tools are not automatically deleted when the chat closes. ## Channels -**Channels** provides credential or QR-based setup, connection validation, and restart guidance. Missing channel support can be installed from a local WebUI. When newly installed support needs a restart, select the restart icon in that channel's row before continuing setup. +Open **Channels** to connect Telegram, Discord, Slack, Feishu, WeChat, Linear, and other platforms with credential forms or QR codes. On a local WebUI, nanobot can install missing channel packages for you and prompt to restart if needed. -The platform itself may still require you to create a bot, enable event permissions, copy a token, or configure a webhook. Use [`chat-apps.md`](./chat-apps.md) for those platform-side prerequisites and for manual JSON/reference options. - -Test a new channel with a private DM. When a supported channel sends a pairing code, the WebUI surfaces the pending request so you can approve the sender. Keep access narrow; do not use a wildcard allowlist unless public access is intentional. +Test each new channel with a direct message—if the channel replies with a pairing code, approve it right inside the WebUI. For platform-side setup steps (creating bots, tokens, or permissions), see [Chat Apps](./chat-apps.md). ## Apps -**Apps → Ready** lists capabilities available for use. Use the **CLI Apps**, **Agent Plugins**, and **MCP** filters to manage each kind separately: +Open **Apps → Ready** and filter by **Agent Plugins**, **CLI Apps**, or **MCP**: -- **Agent Plugins** are local packages that can bundle skills, MCP servers, or both. A package under `/plugins/` is installed but remains inactive until you enable it in Apps. -- **CLI Apps** are command-line tool adapters on the nanobot host. Install and enable an adapter before attaching it to a turn. -- **MCP** lists Model Context Protocol servers. Presets provide known configurations, and the **Add MCP server** panel accepts stdio, HTTP, and SSE servers. Custom HTTP/SSE servers can use no authentication, OAuth, or request headers. After saving an OAuth server, choose **Connect** to open its sign-in page. Presets such as Xmind, Notion, and Linear already use OAuth. HTTPS and localhost WebUIs return automatically; a remote plain-HTTP WebUI shows one field for pasting the complete localhost callback URL. +- **Agent Plugins:** Local packages under `/plugins/` that bundle skills, MCP servers, or both. Enable them in **Apps** to activate them. +- **CLI Apps:** Local command-line tool adapters on the nanobot host (run in a limited environment without your provider API keys). +- **MCP:** Add stdio, HTTP, or SSE Model Context Protocol servers, or pick from built-in presets (including OAuth presets like Notion, Linear, and Xmind, and keyless search presets like Firecrawl and Parallel Search). -A plugin generated by a CLI App is managed from that app's entry, including re-enabling it if needed. Other Agent Plugins appear in the **Agent Plugins** filter. Plugin details show declared permissions and MCP servers; declared permissions do not sandbox a plugin from nanobot's operating-system permissions. - -CLI Apps run with a limited environment that excludes provider API keys. On Unix, they inherit `XDG_RUNTIME_DIR` when it is set in the gateway's environment, so desktop CLIs such as Obsidian can locate the running application. Start the gateway in the same desktop session as the app to inherit that runtime directory. - -Manage optional runtime support from **System**, **Models**, or **Web**, or use [`nanobot plugins`](./cli-reference.md#optional-features). That command manages runtime extras, not Agent Plugin packages. PDF and common Office attachment readers require no setup. - -Keyless hosted presets include **Firecrawl** for search, scraping, crawling and extraction, and **Parallel Search** for `web_search` and `web_fetch`. They are optional MCP tools and do not change the built-in web search provider. - -After a CLI App or MCP server is available, mention it from the composer with `@` to attach that tool to the next message. Plugin-provided skills participate in normal skill discovery and can be invoked with `$skill-name`. +Once enabled, mention a CLI App or MCP server with `@` in the composer to use it in your next message, or invoke plugin skills with `$skill-name`. ## Skills -Open **Skills → Installed** to review built-in and workspace-provided skills. You can search and filter them, inspect their instructions and setup requirements, enable or disable them, and delete workspace skills you no longer want. +- **Skills → Installed:** Search, inspect, enable/disable, or delete built-in and workspace skills. +- **Skills → Discover:** Browse and install skills from **skills.sh** (requires Node.js / `npx`) and **SkillHub** (no `npx` needed). -Open **Skills → Discover** to browse or search skills from skills.sh and SkillHub. A marketplace skill is copied into the active agent workspace after you confirm the installation. skills.sh installation requires Node.js with `npx`; SkillHub installation does not. - -Marketplace skills are third-party instructions and may include executable scripts. Review the source and instructions before installing one, and enable only skills you trust with the same files, tools, and credentials available to your agent. - -Discover marks a skill as installed only when its recorded marketplace source matches. A skill with the same name from another source is a name conflict, not another installed copy. Older or manually copied skills without a source record remain usable and show “Installed source unknown.” Review the existing skill in **Installed** before removing it if you want a different source; installation never replaces it automatically. New installs keep a small `.nanobot-origin.json` receipt beside `SKILL.md`. Keep that receipt with the skill when moving or backing up the workspace. Older nanobot versions ignore it; no skill-directory rename or history migration is required. +> [!CAUTION] +> Marketplace skills are third-party instructions and may include scripts. Review them before installing, and only enable skills you trust with your workspace and tools. ## Automations -Automations are agent turns that run later in a linked topic. Create them from the topic or channel where they are supposed to run so nanobot keeps the correct target context. When an automation runs, it normally delivers the result back to that topic. +The **Automations** view lets you search, filter, run, pause, edit, and delete scheduled tasks and local triggers. Search supports plain text and filters like `name:backup`, `chat:WeChat`, `schedule:09:30`, `trigger`, and `status:paused`. -For the full automation model, creation flow, trigger CLI usage, and delivery semantics, see [`automations.md`](./automations.md). +Create automations from the topic where you want replies delivered. Local triggers need a message each time they run, so copy their `nanobot trigger ...` command instead of using "Run now". See [Automations](./automations.md) for the complete guide. -There are two user-facing automation types: +## Settings and Updates -- Scheduled automations, created by the agent's cron tool, run at a time, interval, or cron expression. -- Local triggers, created with `/trigger `, run when you call a local command such as `nanobot trigger trg_8K4P2Q9X "Review PR #4502"`. +Settings that require a gateway restart are clearly marked in the WebUI. -For recurring background checks that should stay quiet unless there is something useful to report, use the protected heartbeat job by editing `HEARTBEAT.md` instead of creating a chat automation. +- **Appearance:** Choose **System**, **Light**, or **Dark** theme, pick a reading text size (Small, Standard, Large, or custom 14–28 px), choose how much activity/diff detail to show, or set a custom background image (**Settings → Appearance → Background**—PNG, JPEG, or WebP up to 6 MiB, with adjustable blur and fade). +- **Notifications:** Open **Settings → Notifications** to turn on **Browser notifications** (alerts you when a background task finishes or needs attention; click **Test notification** to verify) and **Completion sound**. Works on localhost or HTTPS (on iPhone/iPad, open from the Home Screen). +- **Check for updates:** Open **Settings → About** to check for updates. nanobot does not run automatic background version checks or auto-install updates without your confirmation. See [Updating nanobot](./updating.md). -The Automations view manages user-created jobs and can run scheduled jobs immediately. Protected system jobs are read-only. +## Sharing Access -Search accepts plain text and field filters such as `name:backup`, `chat:WeChat`, `schedule:09:30`, `cron:"0 23 * * *"`, `trigger`, and `status:paused`. +The WebUI is an admin workbench for one nanobot instance. Everyone signed in to the WebUI shares all topics and administrative controls—there are no per-user accounts or private topics. -An automation without a linked topic cannot be enabled or run from the WebUI, because nanobot would not know where to deliver the scheduled turn. Recreate it from the target topic or channel so the automation has complete context. - -Local triggers do not have a WebUI "Run now" action because each run needs a message. Use the copied `nanobot trigger ...` command and replace `"message"` with the content that should be delivered. - -## Settings - -Runtime settings may require a gateway restart; the WebUI marks those controls. - -**Appearance** preferences apply immediately in the current browser without changing gateway configuration. These controls remain available while gateway settings are loading or unavailable. Choose **System**, **Light**, or **Dark** for the theme; **System** follows operating-system changes while the app is open. Existing explicit light/dark preferences are preserved. - -Under **Reading**, choose a small, standard or large preset, or enter a custom size in the inline **Custom** field beside them. Select the field to edit the saved custom value, using whole pixels from 14 to 28. Hovering or focusing the field shows the supported range and how reading sizes apply. An out-of-range or fractional entry is marked invalid when you finish editing, with a hint showing the size still in use; it does not silently clamp or replace your last valid size. The size applies to both desktop and narrow screens. The input retains a 16px minimum on every screen. The live preview uses the same reading typography as conversations: messages, Markdown and code scale together, while navigation and toolbars stay unchanged. Standard remains the default; switching to a preset preserves your custom value for later use. **Activity display** controls how much process and file-edit detail appears, not what the agent executes. +- Only share WebUI access with people you trust to administer the same agent. +- To let others chat without admin access, connect a [chat app](./chat-apps.md) and approve them via pairing or allowlists. +- To isolate memory and data between different users or clients, run [separate instances](./multiple-instances.md). ## LAN Access -To open the WebUI from another device on the same network, bind the WebSocket channel to all interfaces and set a token or token issue secret: +To access the WebUI from another device on your local network, bind it to `0.0.0.0` and set a password (`tokenIssueSecret`): ```json { @@ -316,39 +206,19 @@ To open the WebUI from another device on the same network, bind the WebSocket ch } ``` -The gateway refuses to start with `host` set to `"0.0.0.0"` unless `token` or `tokenIssueSecret` is configured. After the gateway starts, open `http://:8765` from the other device and enter the secret in the login form. +The gateway refuses to bind to `0.0.0.0` without `token` or `tokenIssueSecret`. After restarting, open `http://:8765` on the other device and sign in with your secret. -Plain HTTP is enough for basic WebUI access, but browsers expose microphone capture only in secure contexts. Voice input works on same-machine localhost; from another device, serve the WebUI over HTTPS with a certificate that device trusts. Configure [`sslCertfile` and `sslKeyfile`](./websocket.md#tlsssl) on the WebSocket channel and open `https://:8765`, or terminate HTTPS at a reverse proxy and use that proxy's HTTPS URL. - -Remote WebUI clients with a valid token can view and use Apps and installed skills. Actions that install missing nanobot support packages or third-party marketplace skills are blocked by default. To let trusted remote administrators perform those installations through the WebUI, opt in explicitly: - -
-Manual configuration - -```json -{ - "tools": { - "webuiAllowRemotePackageInstall": true - } -} -``` - -
- -Enable remote installation only for a private deployment whose users are trusted to change the Python environment and install skill instructions or scripts. Reverse-proxy and tunnel deployments count as remote access. - -Optional feature installs use pip's configured package index, including `PIP_INDEX_URL`. skills.sh marketplace installs use `npx` instead. +- **Voice input on LAN:** Browsers require HTTPS for microphone access on non-localhost addresses. Configure [TLS/SSL](./websocket.md#tlsssl) or put an HTTPS reverse proxy in front of the WebUI. +- **Remote installs:** By default, remote browsers cannot install optional packages or marketplace skills. Only enable `tools.webuiAllowRemotePackageInstall: true` on private deployments where every WebUI user is trusted to install packages and scripts on the host. ## Troubleshooting -### Connection checks - -If the page does not open, check these in order: +If the WebUI will not open, check these in order: 1. `nanobot agent -m "Hello!"` works in the same Python environment. -2. `~/.nanobot/config.json` does not explicitly set `channels.websocket.enabled` to `false`. -3. `nanobot gateway` is still running. -4. You are using the WebUI port (`8765` by default), not the health port (`18790` by default). -5. LAN access uses `host: "0.0.0.0"` and a token or token issue secret. +2. `channels.websocket.enabled` is not set to `false` in `~/.nanobot/config.json`. +3. `nanobot gateway` is running. +4. You are opening port `8765` (WebUI), not `18790` (gateway health check). +5. For LAN access, `host` is `"0.0.0.0"` and `tokenIssueSecret` (or `token`) is set. -For detailed diagnostics, see [`troubleshooting.md#webui-problems`](./troubleshooting.md#webui-problems). For frontend development, see [`../webui/README.md`](../webui/README.md). +For more help, see [WebUI Problems](./troubleshooting.md#webui-problems).