English
Session Entrypoints
Five console scripts ship with the package. They differ only in where the session runs and who drives it — the underlying agent is the same one the Python API builds.
| Command | Form | Use case |
|---|---|---|
xun | terminal session | Work interactively in the current directory. |
xuns | web service | Browser UI, file browsing and previews, managed browser. |
xunc | container session | Run xuns (or xun) inside an isolated Docker container. |
xunx | multiplexed gateway | One public server, one persistent container per user. |
xune | extension CLI | Run the command line an extension declares, e.g. xune stat. |
All of them read configuration from $XUN_HOME/config.json (default ./.xun) and load extensions from $XUN_HOME/extensions/.
xun — terminal session
bash
xun # interactive session, workspace = current directory
xun "Write hello.py and run it" # start from an instruction
cat prompt.txt | xun # not a TTY → non-interactive| Argument | Default | Meaning |
|---|---|---|
instruction (positional, optional) | empty | First instruction. In non-interactive mode (piped stdin, or --non-interactive) it is required. |
--non-interactive | off | Run once and exit, even on a TTY. |
Input syntax in an interactive session:
/name rest…runs a slash command;\/textsends a literal leading slash.[image:./cat.png image:https://example.com/dog.png] compare themattaches images — paths or URLs — to the message.- History search with
Up, slash-command and@filecompletion via prompt_toolkit.
Built-in slash commands
/help lists the commands of the current session. Extensions can add more.
| Command | Purpose |
|---|---|
/help | List available commands. |
/tokens | Tokens used by the conversation. |
/history | Show the conversation history. |
/tools | List registered tools. |
/config [key.sub=value] | Show the config, or set one dotted field. |
/compact [toolcall] | Compact the whole history; toolcall compacts only old tool results. |
/clear [all] | Drop history; all also empties the workspace temp dir. |
/continue | Continue the loop without a new instruction. |
/retry | Re-run from the last user message. |
/revise [content] | Replace (or drop) the last user message; continue with /continue. |
/yolo | Toggle auto-confirm. |
/render <file> | Export the history as a standalone HTML file (.html appended when missing). |
/save, /load <n|latest> | Store / restore a conversation snapshot (experimental), kept under $XUN_HOME/conversation/. |
/handoff [name] | Have the model package the task into name.zip in the workspace (default handoff_<timestamp>). |
/extensions | List discovered extensions and their status. |
/policy <sub> | Manage tool confirmation allowlists: cmd_allowlist / path_allowlist and their _add / _remove forms. |
/long [eol] | Multi-line input mode, ended by a line equal to eol (default .); the text then runs as one instruction. |
/exit | Quit. |
/long and /exit are registered only by xun. /policy appears when the session uses the default tool set (both xun and xuns do); /render, /save, /load and /handoff come from the file-writing command set the interactive entrypoints add. Pass setup_agent(default_commands=False) — or build a bare Agent() — to start with an empty command registry.
xuns — web service
bash
xuns # temporary workspace per session
xuns . # all sessions share the current directory| Argument | Default | Meaning |
|---|---|---|
workdir (positional, optional) | none | Workspace for every session; omit so each session gets a temporary one. |
--host | localhost | Bind address. Use 0.0.0.0 inside a container. |
--port | 18960 | Listen port. |
--token | random | Access token. A generated one is printed at startup. |
--base-path | root | URL prefix, e.g. /alice when the service sits behind a reverse proxy. |
--manage-sessions / --no-manage-sessions | on | Allow — or forbid — creating, removing and renaming sessions from the UI. |
--no-initial-agent | agent created | Start without an agent, e.g. to browse /docs/ with no provider configured. |
With --base-path PREFIX, the service exposes:
| Path | Contents |
|---|---|
PREFIX/chat/ | The chat UI — the page you should open. |
PREFIX/session/<id>/ | One display backend per session; the UI reconnects to it without a reload. |
PREFIX/docs/ | This documentation, no login required. |
PREFIX/login | Token login form (sets the xun_web_token cookie). |
PREFIX/api/sessions… | Session list/create/remove/rename endpoints. |
Authentication accepts Authorization: Bearer <token>, the cookie, or ?token=… on the chat URL. Requests to PREFIX/ redirect to the chat UI.
xunc — container session
Requires the image built by make build-docker (see Installation).
bash
xunc . --exec "xun" # terminal agent on the mounted directory
xunc --copy . --env "XUN_OPENAI_*" # copy instead of mount, forward provider vars| Argument | Default | Meaning |
|---|---|---|
mount (positional, optional) | none | Host directory bind-mounted read-write to /workspace and used as the working directory. |
--copy | off | Copy the mount directory into /workspace instead of bind-mounting. Requires a mount. |
--image | xun | Image to run. |
--name | xun-<hash> | Container name. |
--network | bridge | bridge publishes --port; host shares the Docker VM's network namespace (unreachable from a macOS host browser). |
--port | 18960 | Ports to publish, same number on both sides; several values after the flag, or one comma-separated value; --port "" publishes none. |
--env | — | Several values after the flag, each also comma-separated: NAME=VALUE sets a variable, any other token is an fnmatch pattern forwarded from the host. XUN_*, _XUN_* and TERM are always forwarded; XUN_HOME never is. |
--exec | xuns … --host 0.0.0.0 | Command line to run inside the container, split with shlex. An empty string falls back to the image's default CMD. |
The container is created with auto_remove, and its stdout/stdin are attached, so Ctrl-C and the inner session behave like a local run. --exec is how you reach every xun/xuns flag inside the container.
xunx — multiplexed gateway
Runs one persistent container per user behind a single HTTP/WebSocket server, routing http://host:port/<username>/… to that user's container. Users and tokens live in $XUN_HOME/x/xunx.db.
bash
xunx user-add alice # prints the token and base path
xunx serve --host 0.0.0.0
xunx pause alice && xunx resume alice
xunx shell alice --exec "bash" --cwd /workspace| Subcommand | Arguments | Meaning |
|---|---|---|
user-add | username | Create a user with a random token and print it. Names match ^[A-Za-z0-9_-]+$. |
user-del | username | Remove a user. |
user-list | — | Print the user table. |
pause / resume | username | Freeze a user's container without discarding its state, or unfreeze it. A paused user gets 503 with Retry-After: 60. |
upgrade | [username …], --all | Recreate containers from the current image at the next reconciliation; in-container data is discarded. |
shell | username, --exec CMD (default bash), --cwd DIR | docker exec -it into the user's container; exits with the command's code. |
serve | --host (0.0.0.0), --port (18960), --port-range START-END (default 17960-18958), --image (xun), --env … | Run the gateway. Container ports are allocated from the range and published on 127.0.0.1 only. --env behaves as in xunc. |
serve adopts containers it already owns after a restart, so sessions survive; a --copy-style upgrade does not. Note that containers are temporary instances: stopping serve leaves them running, but removing their user, upgrading, or restarting the Docker daemon discards them; an xunx upgrade discards them by design.
xune — extension CLI
bash
xune # list extensions that declare a CLI (exit code 2)
xune -h # same listing, exit code 0
xune stat show --days 7 # run one extension's command lineAn extension opts in by declaring cli=(parser, handler) — see Extension Attributes. xune imports extensions the same way an agent does, so the extension resolves its own data directory identically; a handler's int return value becomes the exit code.