Skip to content

Installation

Requirements

  • Python 3.12 or newer (the code uses PEP 695 type-parameter syntax def f[T](...); TypeVar(default=...) falls back to typing_extensions on 3.12)
  • Linux / macOS (the bash tool is not registered on Windows, see Tool system)
  • An OpenAI-compatible model endpoint

Main runtime dependencies: openai, pydantic, aiohttp, fastapi, rich, jinja2, json-repair, markdown, pillow, playwright, docker, html-to-markdown, python-dotenv.

Install

pip install xun-agent

If you want to use the built-in browser tools, install the browser binaries once more:

playwright install          # or playwright install chromium

Installing from source

The web frontend assets and the documentation site are packaged into src/xun/assets/. When installing from source and you need the web UI, build the frontend first:

git clone https://github.com/MenxLi/xun.git
cd xun
make build-web      # cd web && npm i && npm run build, output written to src/xun/assets/web
pip install .
Target Purpose
build-web build the Vue frontend into src/xun/assets/web
build-docker run build-web first, then docker build -t xun -f docker/Dockerfile .
doc inside a container, generate the bilingual documentation site into site/ following docs/AGENTS.md
doc-dist copy site/ into src/xun/assets/docs so that xuns serves it at /docs/
doc-clean delete the generated docs and mkdocs.yml, restoring the tracked files under docs/
test python -m unittest discover -s test -t . -v

Building the Docker image

xunc and xunx use an image named xun:

make build-docker

The image is based on ubuntu:24.04 and preinstalls Playwright Chromium, Node, LibreOffice, the mkdocs toolchain and more. Two environment variables are fixed: XUN_HOME=/.xun (the host xun home is copied in when the container is created, taking only config.json and extensions) and _XUN_INFO_TOOL_OVERRIDE=1. The image has no ENTRYPOINT/CMD; xunc passes the command to run explicitly.

Configuration

Xun reads its configuration from $XUN_HOME/config.json; when XUN_HOME is unset it is .xun/ under the current working directory (not ~/.xun). Write only the fields you want to change — missing fields fall back to the built-in defaults:

{
    "model": {
        "name": "my-model"
    }
}

The configuration supports ${XUN_...} placeholders whose values come from environment variables (so secrets can live in .env, which is loaded automatically via load_dotenv() when the configuration is read):

# .env
XUN_OPENAI_BASE_URL=https://api.example.com/v1
XUN_OPENAI_API_KEY=sk-...
XUN_OPENAI_MODEL=        # leave empty to use the first model reported by the server
Configuration field Environment variable When missing
provider.openai_base_url ${XUN_OPENAI_BASE_URL} startup raises RuntimeError
provider.openai_api_key ${XUN_OPENAI_API_KEY} startup raises RuntimeError
model.name ${XUN_OPENAI_MODEL} falls back to an empty string → the model is detected automatically
auto_confirm ${XUN_AUTO_CONFIRM} falls back to false

For the full field list, the merge rules and all environment variables, see Configuration.

Confirmation prompts and auto-confirm

By default, writing files and running commands that are not on the allow list require confirmation. In scripts or CI you can set XUN_AUTO_CONFIRM=true (or toggle it temporarily with the /yolo command). Auto-confirm never adds commands or paths to the allow list.

Verifying the installation

xun "Print the current directory and say hello"

Once you are in interactive mode:

>>> /config        # show the currently effective configuration
>>> /tools         # show the registered tools
>>> /extensions    # show the loaded extensions
>>> /help          # show all commands

Non-interactive mode (single turn, suited to scripts and CI):

xun --non-interactive "Summarize README.md in one line"

Optional steps after installation

What you want to do Reference
Change the model, tune temperature, set reasoning effort Configuration
Add custom tools, hooks or commands Extension system
Embed the agent into your own program API guide
Deploy in a container, expose it to several people xunc, xunx