Ops
A resident daemon needs resident hygiene. All of it lives behind ka-agent service, backup, logs, and doctor.
Install
Section titled “Install”curl -fsSL https://ka-agent.com/install.sh | shBinary to ~/.local/bin (override with KA_AGENT_INSTALL_DIR), and on a fresh machine the installer hands off to the setup wizard (KA_AGENT_NO_SETUP=1 skips it).
Staying current
Section titled “Staying current”ka-agent update check # 0.8.1 → 0.9.0ka-agent update # verify, swap, restart the service(s)update fetches the release metadata and the platform tarball plus its checksum, verifies it (a mismatch installs nothing), atomically replaces the running binary, then restarts every installed profile’s service. status and doctor show “update available” from a cached daily check, and the daemon itself checks weekly and posts a notice plus a status line when a newer release exists. From a paired channel, /update [check] runs the same check and install with the phone-safe guards: it refuses while a turn is in flight, when the daemon cannot write its own binary’s directory (a root-owned system install), and while an install already runs; a supervised daemon stops itself afterwards and comes back on the new binary. Re-running curl | sh also still works.
The background service
Section titled “The background service”ka-agent service install # units + start at login + nightly 03:30 backup timerka-agent service status # service-manager state + daemon answering?ka-agent service print # show the generated unit fileska-agent service uninstall # stop and removeUnits are generated from the running binary: ka-agent.service, ka-agent-backup.service, ka-agent-backup.timer under $XDG_CONFIG_HOME/systemd/user/ (Linux) or ~/Library/LaunchAgents/ (macOS); a profile named work gets ka-agent-work.service / dev.ka-agent.work.daemon, so profiles run side by side. On Windows the service is a Task Scheduler entry (KaAgent, or KaAgent-<profile> for a named profile) that runs ka-agent run at log on and redirects stdout and stderr into <root>\logs\daemon.log. Install is idempotent and upgrade-safe: re-running it after an upgrade rewrites the definitions with the current binary and restarts the daemon. It refuses while a foreground ka-agent run or chat holds the data root.
ka-agent.service:Restart=always(a clean exit is also a restart;ka-agent restartdrives exactly that), start-rate limited (5 in 10 minutes stops the unit until you intervene),ProtectSystem=strictwith write access only to the data root and config dir.- On Linux,
sudo loginctl enable-linger $USERkeeps the service alive after logout; the installer tells you if that is missing. - Without a service manager (containers, WSL without systemd), run
ka-agent runinside a terminal multiplexer.
Backups and restore
Section titled “Backups and restore”ka-agent backup <dir> [--keep N]writes a consistent snapshot while the daemon runs:state.dbvia SQLiteVACUUM INTO, thememory/git history, andnotes/. Backups land in<data>/backups/<timestamp>and rotate to the newest 7; a named output is never pruned.ka-agent restore <dir>unpacks into the data root. It refuses a non-empty root without--force, and refuses while a daemon is running (admin.sockpresent).- The drill: restore into a fresh root, run
doctor, send a chat turn.ops_e2e.rsdoes exactly this in CI.
Logs and restart
Section titled “Logs and restart”ka-agent logs -f follows the daemon’s journal (-n <lines> for history; the daemon’s own log file rotates at 5 MB and keeps 3). On Linux that is journalctl --user; on macOS and Windows it is <root>/logs/daemon.log. ka-agent restart sends a graceful shutdown over the admin endpoint; the service brings it straight back. The daemon registers its SIGINT/SIGTERM handlers before any channel or socket starts, so an early kill can never bypass the graceful path.
doctor
Section titled “doctor”ka-agent doctor prints one line per check, each with the fix; exit 1 means something needs fixing. It reports the version, the ka pin (KA_PIN), the contract-suite hash (sha256 of the sixteen embedded docs/contract/*.md), config presence and validity, data/state/workspace state (including tree permissions; on Windows there are no POSIX modes and doctor skips them), the provider-key count, web-search and tool keys, git presence (memory is git-backed), the bubblewrap version, enabled skills, identities and their roles, plugins, the last backup age, whether an update is available, whether the web panel is bound beyond loopback (pairing codes travel over it; the remedy names a TLS reverse proxy), and the grants state (grants: N paths, install on/off, N rules, the durable allow-rules included). When grants.full is on it adds a warn line (plus the --json check entry) unless grants.advisory = false silences it. ka-agent doctor --online additionally verifies the provider key and channel tokens live and probes the configured model with one minimal request: it reports answers, the gateway’s own error verbatim, or not probed (no key); the probe names the key env it wants. Two scoping rules: the service, timer and logs lines describe the profile’s own unit (when KA_AGENT_DATA_DIR points at another root, doctor says so instead of reporting that unit’s state), and ka-agent doctor --fix applies only the safe repairs (data and secrets dirs to 0700, secret files to 0600, one line per change); everything else stays advisory.
ka-agent doctor --bundle <path> writes one JSON diagnostics file for support: the doctor lines, the effective config with secret: refs opaque by construction, the live status, the last turns of each recent non-private session (private sessions record no text), and the daemon-side prompt layers (the compiled identity, enabled skills and the user layer text, labeled as daemon layers only: the engine assembles the final prompt). It prints a privacy warning before writing, because the file contains conversation content, and makes zero network egress on the path.
The runtime also carries a cross-machine invariant checker (the November postmortems turned into asserts): at the four boundary events (ask, turn finished, idle, engine closed) it verifies invariants such as no terminal turn with pending asks, no busy session without a live worker, and no delivered-empty outbox chunk. It is always on in debug builds and opt-in in release builds with KA_CHECK_INVARIANTS=1; a violation surfaces as an internal error while the daemon keeps serving.
Windows
Section titled “Windows”The x86_64 binary ships as ka-agent-x86_64-pc-windows-msvc.zip (release tags cut the four Unix tarballs plus the zip, each with a SHA-256 file and a Sigstore provenance attestation). ka-agent update handles the Windows image the same way: verify, swap, restart the Task Scheduler entry. Everything that talks to real Task Scheduler and pipe objects is exercised on the Windows CI host; the Unix CI keeps running every test.