Xibe Daemon (24/7)
Xibe Daemon — long-lived coding agent for Telegram, Discord, Slack, cron, /cmd shell, media delivery, and systemd.
Xibe Daemon (24/7)
Xibe Daemon is the always-on coding agent: Telegram / Discord / Slack, cron, pairing, delivery ledger, screenshots/files in chat, and operator shell via /cmd.
| CLI | Notes |
|---|---|
xibecode daemon | Primary command |
xibecode gateway | Full alias (same process) |
This is separate from the E2B cloud gateway (sandbox HTTP proxy). See Cloud / E2B.
Home layout (~/.xibecode or $XIBECODE_HOME)
| Path | Purpose |
|---|---|
profile-*.json | Interactive CLI profiles |
.env / daemon.env / gateway.env | Secrets (API keys, bot tokens) |
daemon-<profile>.env | Per-profile secrets (overrides global when --profile is set) |
daemon/ | Daemon runtime (migrates from legacy gateway/) |
daemon/sessions/ | Messaging chat sessions (kept across E2B /update restart) |
daemon/logs/daemon.log | Daemon log (daemon-<profile>.log for non-default profiles) |
daemon/pairing.json | DM pairing state |
daemon/delivery-ledger.json | At-least-once outbound delivery |
cron/ | Scheduled jobs |
memories/ | Curated MEMORY.md / USER.md |
skills/ | Learned / user skills |
projects/ | JSONL transcripts per project cwd |
logs/ | Shared logs |
Override root with XIBECODE_HOME.
Quick start
# Configure tokens (wizard)
xibecode setup gateway
# Or edit secrets manually:
# ~/.xibecode/daemon.env (or gateway.env / .env)
# TELEGRAM_BOT_TOKEN=...
# TELEGRAM_ALLOWED_USERS=123456789
# ANTHROPIC_API_KEY=... # or your provider key
# Foreground
xibecode daemon --workdir /path/to/repo
# Always-on (systemd user service)
xibecode daemon --install --workdir /path/to/repo
xibecode daemon --start
xibecode daemon --statusMulti-profile bots
xibecode daemon --profile test --workdir /path/to/repo
# Loads ~/.xibecode/daemon-test.env over global secrets
# Logs: ~/.xibecode/daemon/logs/daemon-test.logStart / stop / status
| Command | Effect |
|---|---|
xibecode daemon | Run in foreground (Ctrl+C stops) |
xibecode daemon --install | Install systemd unit xibecode-daemon.service |
xibecode daemon --start | Start the service |
xibecode daemon --stop | Stop the service |
xibecode daemon --status | Service status |
xibecode daemon --cron-only | Cron only (no messaging) |
xibecode daemon --workdir <path> | Default project directory |
xibecode daemon --profile <name> | Use named profile + daemon-<name>.env |
xibecode gateway … accepts the same flags.
Systemd helpers after install:
systemctl --user daemon-reload
systemctl --user enable --now xibecode-daemon
# Optional: keep running after logout
sudo loginctl enable-linger $USERTelegram 409 Conflict
Do not run two processes polling the same bot token. Legacy xibecode-gateway.service is a oneshot alias of the daemon — enable only one unit.
Environment (~/.xibecode/daemon.env or gateway.env)
| Variable | Purpose |
|---|---|
TELEGRAM_BOT_TOKEN | BotFather token |
TELEGRAM_ALLOWED_USERS | Comma-separated Telegram user ids |
TELEGRAM_HOME_CHANNEL | Default channel for cron delivery |
DISCORD_* / SLACK_* | Optional adapters |
| Provider API keys | ANTHROPIC_API_KEY, OPENAI_API_KEY, OPENROUTER_API_KEY, … |
XIBECODE_FALLBACK_PROVIDERS | Failover pool string |
XIBECODE_GATEWAY_WORKDIR | Default workdir |
GATEWAY_ALLOW_ALL_USERS | Dev-only; do not enable on public bots |
XIBECODE_BUSY_INPUT_MODE | steer (default) | queue | interrupt |
XIBECODE_RUNTIME_MODE | default | e2b (auto-detected on hosted sandboxes) |
XIBECODE_CMD_TIMEOUT_MS | /cmd shell timeout (default 60000) |
XIBECODE_DAEMON_VERBOSE / XIBECODE_VERBOSE | Headless tool tracing in daemon logs |
XIBECODE_PROGRESS_GROUPING | accumulate to edit one progress bubble (default: new message per tool line) |
XIBECODE_STREAM_EDIT | 1 to restore mid-turn draft edits (off by default) |
XIBECODE_DISABLE_UPDATE_CHECK | Skip npm update offers |
XIBECODE_DISABLE_AUTO_UPDATE | Skip auto-update behavior |
Messaging slash commands
Registered on Telegram’s / menu and answered in all adapters:
| Slash | Meaning |
|---|---|
/start | Welcome + list commands |
/help | Full help text |
/new /reset /clear | Clear conversation (keep workdir) |
/stop | Interrupt run + free the chat immediately (next message is not stuck) |
/status | Workdir, busy state, progress, sandbox id when in e2b mode |
/queue | List queue · /queue <prompt> force FIFO · /queue clear |
/workdir [path] | Show or set project directory for this chat |
/progress on|off | Tool progress updates |
/level | Rigor: yolo | default | strict |
/model /models | Show/list/set model (--global to save profile default) |
/skills /skill | List / search / view skills |
/cmd <command> | Shell in chat workdir — no agent loop (aliases: /sh, /shell) |
/update | Check CLI update · /update yes install (e2b: + daemon restart) · /update no |
/mode | Show runtime mode (default | e2b) |
/sethome | Set this chat as cron delivery home |
/once /session /always /deny | Resolve pending dangerous-command approval |
Process lifecycle = daemon --start / --stop.
Run lifecycle = /stop or natural completion.
/cmd — operator shell (no agent)
/cmd ls -la
/cmd pwd
/cmd tail -n 40 ~/.xibecode/daemon/logs/daemon.log- Runs in the chat workdir via spawn + shell.
- Default timeout 60s (
XIBECODE_CMD_TIMEOUT_MS). - Large stdout/stderr is truncated (tail kept).
- Empty
/cmdprints usage.
While the agent is busy
| Mode | Behavior |
|---|---|
steer (default) | Plain text injects into the same run after tools / before the next model step |
queue | Follow-ups wait until the current run finishes |
interrupt | Next plain message aborts and starts a new run |
# In daemon.env
XIBECODE_BUSY_INPUT_MODE=steer # default/queue <prompt>always forces FIFO without interrupt./stophard-interrupts and frees the chat so the next message is not blocked.?can request a quick status without queueing.
Approvals and questions
- Dangerous commands pause for Once / Session / Always / Deny (inline buttons or slash commands). After resolve, the prompt message is edited and the keyboard is removed.
- Mid-run agent questions use numbered options; reply with a number or free text (not
/status).
Media & screenshots (Telegram)
Agent replies can deliver files with:
MEDIA:screenshots/home.png
MEDIA:dist/report.pdf
MEDIA:relative/path/from/workdir.zip| Type | Telegram API |
|---|---|
| Images | sendPhoto |
| Video | sendVideo |
| Audio | sendAudio / sendVoice |
| Other (PDF, zip, code, …) | sendDocument (≤50MB) |
- Relative paths resolve against the session workdir.
- Successful
take_screenshotis auto-queued if the model omitsMEDIA:. - Optional directives:
[[as_document]],[[audio_as_voice]]. - Text file attachments you send (
.txt,.md, code, … up to 512KB) are downloaded and inlined into the prompt.
Progress UX
- Tool progress is sent as new messages by default (not one long edited bubble).
- Heartbeats about every 30s while busy.
- Final answer is a new message (mid-turn draft edits off unless
XIBECODE_STREAM_EDIT=1). - Curated memory progress: saving… then Saved · MEMORY/USER · usage%.
- Auto-compact progress: compacting… then Context compacted.
[[TASK_COMPLETE | summary=…]]is stripped and shown as a plain Done footer.
Runtime modes (default vs e2b)
| Mode | When | Behavior |
|---|---|---|
default | Local host daemon | No auto self-update restart |
e2b | Hosted sandbox (auto-detect or XIBECODE_RUNTIME_MODE=e2b) | /update yes → install latest CLI (sudo when needed) → restart daemon; chat sessions under daemon/sessions/ kept; agent knows sandbox id; preview https://{port}-{sandboxId}.e2b.dev |
# Force mode (then restart daemon)
XIBECODE_RUNTIME_MODE=e2b/mode shows the current runtime mode and sandbox id when applicable.
/update flow (E2B)
- Daemon or
/updatereports a newer npm version. - Reply
/update yes(or use the dashboard Update button). - Install tries
sudo -n npm i -g xibecode@…first when the global prefix is root-owned, then plain npm, then user-local prefix fallback. - Daemon restarts; messaging chat history is preserved.
CLI equivalent (any machine):
xibecode update --check
xibecode update --apply --yes
# Pin: xibecode update --apply --yes --to 1.17.0Never silent — always requires explicit apply / /update yes.
Security
- Prefer allowlists (
TELEGRAM_ALLOWED_USERS) or pairing (xibecode pair). - Never commit
daemon.env/gateway.env. - Treat bot tokens like production secrets.
/cmdruns as the daemon user in the chat workdir — lock down who can talk to the bot.
Pairing
xibecode pair list
xibecode pair approve telegram <code>
xibecode pair revoke telegram <userId>Logs & sessions
- Logs:
~/.xibecode/daemon/logs/daemon.log(anddaemon-<profile>.log) - Sessions:
~/.xibecode/daemon/sessions/ - Verbose agent tools:
XIBECODE_DAEMON_VERBOSE=1
Iterations
Daemon agent runs default to unlimited iterations (0). Abort with /stop if needed. See Agent engine.
Related
- Cron — scheduled tasks (requires daemon running)
- Chat slash commands — TUI + gateway summary
- Memory — curated MEMORY / USER
- Cloud / E2B — sandbox runtime and
/updateon hosted boxes - Setup — wizard path for Telegram
- Providers — API keys for the agent