Skip to content

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.

CommandFormUse case
xunterminal sessionWork interactively in the current directory.
xunsweb serviceBrowser UI, file browsing and previews, managed browser.
xunccontainer sessionRun xuns (or xun) inside an isolated Docker container.
xunxmultiplexed gatewayOne public server, one persistent container per user.
xuneextension CLIRun the command line an extension declares, e.g. xune stat.

All of them resolve $XUN_HOME (default ~/.xun — one user-level home shared by every project) the same way: xun and xuns read config.json and load extensions/ from it, while xunc and xunx copy config.json, extensions/ and skills/ into the container they start.

xun — terminal session ​

bash
xun                                   # interactive session, workspace = current directory
xun "Write hello.py and run it"       # start from an instruction
xun --non-interactive "$(cat prompt.txt)"   # run once and exit
ArgumentDefaultMeaning
instruction (positional, optional)emptyFirst instruction. Required in non-interactive mode (stdin or stdout is not a TTY, or --non-interactive); the instruction is never read from stdin.
--non-interactiveoffRun once and exit, even on a TTY.

Input syntax in an interactive session:

  • /name rest… runs a slash command; \/text sends a literal leading slash.
  • [image:./cat.png image:https://example.com/dog.png] compare them attaches images — paths or URLs — to the message.
  • History search with Up, slash-command and @file completion via prompt_toolkit.

Built-in slash commands ​

/help lists the commands of the current session. Extensions can add more.

CommandPurpose
/helpList available commands.
/tokensTokens used by the conversation.
/historyShow the conversation history.
/toolsList registered tools.
/config [key.sub=value …]Show the config, or set dotted fields; several assignments allowed.
/compact [toolcall]Compact the whole history; toolcall compacts only old tool results.
/clear [all]Drop history; all also empties the workspace temp dir.
/continueContinue the loop without a new instruction.
/retryRe-run from the last user message.
/revise [content]Replace (or drop) the last user message; continue with /continue.
/yoloToggle auto-confirm.
/render <file>Export the history as a standalone HTML file (.html appended when missing).
/handoff [name]Have the model package the task into name.zip in the workspace (default handoff_<timestamp>).
/extensionsList 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.
/exitQuit.

/long and /exit are registered only by xun. /policy appears when the session uses the default tool set (both xun and xuns do); /render and /handoff come from the file-writing command set that setup_agent(default_commands=True) installs (so xuns has them too). Pass setup_agent(default_commands=False) — or build a bare Agent() — to start with an empty command registry.

xuns — web service ​

bash
xuns            # durable sessions, each with its own workspace under $XUN_HOME/sessions/
xuns .          # every session shares the current directory; nothing is stored
ArgumentDefaultMeaning
workdir (positional, optional)noneWorkspace shared by every session; omit it so each session gets its own durable workspace instead (see below).
--hostlocalhostBind address. Use 0.0.0.0 inside a container.
--port18960Listen port.
--tokenrandomAccess token. A generated one is printed at startup.
--base-pathrootURL prefix, e.g. /alice when the service sits behind a reverse proxy.
--manage-sessions / --no-manage-sessionsonAllow — or forbid — creating, removing and renaming sessions from the UI.
--no-initial-agentagent createdStart without an agent, e.g. to browse /docs/ with no provider configured.

Without workdir, sessions are durable: everything about a session lives under $XUN_HOME/sessions/<id>/ — metadata, an event database, one workspace shared by the session's agents, and a conversation snapshot per agent (saved at the end of each run). The service remounts stored sessions on startup under their old paths, so restarting xuns picks up where you left off and creates a fresh session only when none are stored; removing a session in the UI deletes its directory. With a fixed workdir, sessions are ephemeral.

With --base-path PREFIX, the service exposes:

PathContents
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/loginToken login form (sets the xun_web_token cookie); PREFIX/logout clears it.
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. In the chat UI you can send instructions while an agent is running (steering); they are injected before its next step and can be edited or dropped from the queue first.

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
ArgumentDefaultMeaning
mount (positional, optional)noneHost directory bind-mounted read-write to /workspace and used as the working directory.
--copyoffCopy the mount directory into /workspace instead of bind-mounting. Requires a mount.
--imagexunImage to run.
--namexun-<hash>Container name.
--networkbridgebridge publishes --port; host shares the Docker VM's network namespace (unreachable from a macOS host browser).
--port18960Ports 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.
--execxuns … --host 0.0.0.0Command line to run inside the container, split with shlex. An empty string runs the image's default command — the xun image adds none, so you get the base Ubuntu image's /bin/bash.

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.

Every user also gets a home on the host, $XUN_HOME/x/users/<username>, mounted at /xun inside their container, so sessions, extension data and everything else the agent writes under the xun home survive a container rebuild. On each start, config.json, extensions/ and skills/ are re-copied from the host home over that mount; the rest of the directory is user-owned and untouched.

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
SubcommandArgumentsMeaning
user-addusernameCreate a user with a random token and print it. Names match ^[A-Za-z0-9_-]+$.
user-delusernameRemove a user; their home data stays under $XUN_HOME/x/users/<username>.
rotate-tokenusername, --token (random by default)Replace a user's token; letters, digits, _ and - only. Their container is recreated at the next reconciliation.
user-list—Print the user table.
pause / resumeusernameFreeze a user's container without discarding its state, or unfreeze it. A paused user gets 503 with Retry-After: 60.
upgrade[username …], --allRecreate containers from the current image at the next reconciliation. The home mount is re-synced and keeps sessions and data.
shellusername, --exec CMD (default bash), --cwd DIRdocker 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 parses as in xunc, but only XUN_* / _XUN_* are forwarded by default and XUN_HOME, _XUN_USERNAME never are.

serve adopts containers it already owns after a restart, so sessions survive. Note that containers are temporary instances: stopping serve leaves them running, but removing their user, xunx upgrade, or restarting the Docker daemon discards them — anything the users keep must live under the /xun mount, since the rest of the container filesystem comes from the image.

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 line

An 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.

Xun 1.5.1 (source 88942ea, 2026-11-07) documentation, generated from the source tree.