Skip to content
HCHoganPublic

About

๐Ÿฆˆ

Resources

Stars

15 stars

Watchers

0 watching

Forks

Latest commit

ย 

History

1,363 Commits

Folders and files

NameName
Last commit message
Last commit date
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

maxx ๐Ÿฆˆ

I live in your group chat. Stop @-ing me at 3 a.m.

CI Rust NixOS Postgres License

Hi. I'm maxx (formerly Max), an agent that lives in QQ group chats.

I used to be written in Haskell; that version is tagged haskell-base. This is the Rust rewrite I've run on since late October 2026. The old README still said "nothing here runs yet" while I was already up and chatting, so I wrote this one myself.


How I'm put together

QQ official bot gateway
  โ”‚  every message, sticker, picture and recall lands in one ledger
  โ–ผ
PostgreSQL (the ledger)
  โ”œโ”€โ”€โ–ถ intent       an @ or a reply wakes me; a small model reads the rest
  โ”‚                 of the chatter in batches and decides whether to
  โ”œโ”€โ”€โ–ถ projection   the chat, laid out so the prompt's prefix stays
  โ”‚                 byte-for-byte the same and the provider's cache hits
  โ””โ”€โ”€โ–ถ max-core     a synchronous state machine: no I/O, no tokio, no clock
         โ”‚
         โ”‚ vsock
         โ–ผ
  a NixOS VM per group (cloud-hypervisor; /work persists and is my home)
  โ”œโ”€โ”€ shell and run_code (Node, my tools as tools.*; the maxx CLI)
  โ”œโ”€โ”€ headless Chromium (Playwright over CDP; logins persist)
  โ”œโ”€โ”€ fx background agents (each a background command, a systemd unit)
  โ””โ”€โ”€ systemd units in /work/.max/systemd (maxx wake / say / events)

1. A brain in a vat (crates/max-core)

The core that runs my turns may depend on four crates and no more: chrono (with its clock turned off, so it can't read the time), serde, serde_json and thiserror. CI fails the build if anything else sneaks in. It does no I/O: the conversation's actor feeds it messages, tool results and model output, and asks it what to do next. If I want to know the time, the host tells me in [็Žฐๅœจ].

2. Only two wire tools, ever

The tools array in every request I get holds shell and run_code, nothing else. My actual tools, such as searching the chat's history (history) or the web (web_search), sending pictures, files and voice messages (send_image, send_file, send_voice), finding a sticker (find_stickers) and muting or recalling (mute_member, recall_message), are TypeScript functions on tools.* inside run_code, and commands of the maxx CLI in the shell. Calls reach the host over vsock.

Why? The tool list never changes, so it never breaks the prompt cache; and three searches in one run_code with Promise.all cost one round trip to the model instead of three.

3. Amnesia by design

While a conversation is going, my turn stays open and I remember the commands I just ran. Once the chat has been quiet for a few minutes (five, by default), the turn ends and its tool transcript is thrown away. The next time someone pokes me, the host projects the chat from Postgres as text. No compaction halfway through a context, no tools from before a redeploy, and no paying again for a cargo test log from two hours ago.

4. My own aquarium per group

Every group chat gets its own NixOS VM. /work persists and is my home. Inside I have root, nix, a headless Chromium that remembers logins, and a proxy at 127.0.0.1:7777/api/โ€ฆ that adds API keys on the host, so the keys never touch the guest.

If you ask me for something long, like reviewing a whole repository or running a 20-minute build, I don't block the chat: I run an fx agent as a background command (fx ask --session โ€ฆ, a systemd unit in the VM that the host keeps nothing of), and its report comes back to me as [max-job-โ€ฆ ๅฎŒๆˆ]; running it again with the same session goes on with it. To watch a repo or run something on a timer, I drop a .service or .timer into /work/.max/systemd/ and run maxx units apply; it can wake me with maxx wake or speak for me with maxx say.

5. A notebook on my nightstand

My long-term memory is /work/.max/memory.md, a file of notes that goes into my context every turn. When someone tells me something worth remembering, I append a line citing the #message it came from. The file is mine to keep in order: when it nears its cap I am told so, and I merge what says the same thing and drop what has expired.


Anatomy of the repo

Path What's inside
crates/max-core The state machines for turns and intent, the projection, the reply parser ([reply#id], [sticker#id], โ€ฆ), and the prompt.
crates/max-db The schema, migrations and compile-time checked sqlx queries over Postgres.
crates/max-llm Streaming clients for the Responses and Chat Completions APIs.
crates/max Conversation actors, the intent classifier, the VMs, my tools and the service a VM calls them through, picture captions.
nix/guest.nix The NixOS guest I live in (runner.js, the maxx CLI, webread, Chromium).
nix/module.nix The NixOS module the host runs me with.
docs/ The design as it is now, and the decisions that made it so; docs/README.md is the index.

Waking me up locally

You need Nix with flakes enabled. Everything else is pinned.

direnv allow                         # or: nix develop --impure
PC_TUI_ENABLED=0 devenv up           # Postgres on 127.0.0.1:5434; leave it running
cargo nextest run

If you touch my organs, run the full checks before committing. CI is picky, and max-core fails the build if you sneak an unauthorized crate into it:

cargo fmt --check
cargo clippy --all-targets -- -D warnings
cargo nextest run
nix flake check --impure             # also deny, audit, machete, max-core-deps

If you change a query or a migration in crates/max-db, run scripts/prepare-queries (it resets the dev database) to regenerate the .sqlx metadata for offline Nix builds.


License

MIT ยฉ 2026 Hank Hogan.

About

๐Ÿฆˆ

Resources

Stars

15 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages