Skip to content

Add grok as a guest agent - #473

Open
alisaifee wants to merge 14 commits into
trailofbits:mainfrom
alisaifee:main
Open

alisaifee wants to merge 14 commits into
trailofbits:mainfrom
alisaifee:main

Conversation

@alisaifee

@alisaifee alisaifee commented Sep 11, 2026

Copy link
Copy Markdown

Problem

coop can launch Claude Code and Codex in the guest. Grok Build has to be
installed and configured by hand.

Description

coop grok launches Grok Build in the guest. coop setup installs it from
https://x.ai/cli/install.sh as the guest user. The image ships home skel
files as root, so setup chown -Rs the guest home first. The launcher
SSHes in with --always-approve, --trust, and --cwd /workspace.
--ask adds --permission-mode default. login and logout keep
--trust and --cwd /workspace.

Changes

  • Golden image: official installer, ~/.grok/bin on PATH,
    /usr/local/bin/grok, grok-yolo. The guest installers share one
    shell; Grok deletes its temp installer after it runs.
  • [grok]: api_key, env_forward, config_dir, marketplaces,
    plugins, Model Context Protocol servers.
  • Bootstrap: XAI_API_KEY goes in over SSH SendEnv. Allowlisted host
    files overlay into ~/.grok. Restart overwrites files still present
    on the host; guest-only files and config_dir = false keep prior
    copies. Directory symlinks, hidden directories, and bare git repos
    stay on the host. Host config.toml is merged except [plugins];
    guest [plugins] is kept. /workspace is recorded in
    trusted_folders.toml. A copied auth.json is mode 0600.
    Configured plugins install on first boot.
  • coop agent update --grok runs grok update. The guest user can run
    grok update directly. --check prints Claude Code, Codex, and
    Grok Build.
  • Lima: growing an instance disk updates lima.yaml disk: and
    restores the original yaml if the grow fails.
  • Docs: docs/grok-integration.md, commands, getting started, trust
    model, changelog. --no-agents names Grok Build.
  • Integration: binary, symlink, PATH, grok-yolo, settings merge after
    restart, --check names all three. The suite sets
    [grok] config_dir = false. The merge phase points config_dir at a
    fixture directory.

Existing images: coop setup --rebuild. Existing VMs:
coop restore <vm> --image <image> --reprovision (or destroy and
recreate).

Validation

  • Lima guest suite
  • Firecracker guest suite

@CLAassistant

CLAassistant commented Sep 11, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

Add the official installer, put grok and agent on the guest PATH, and
require the binary in the golden image. Marketplace baking comes later.
Parse api_key, env_forward, config_dir, marketplaces, plugins, and
Model Context Protocol servers the same way [claude] and [codex] work.
Add coop grok, forward XAI_API_KEY, and copy host allowlisted files
without following directory symlinks. Write managed settings and folder
trust, drop the host [plugins] table, set a copied auth.json to 0600,
and install configured plugins. coop agent update --grok runs grok update.
Add the integration guide and update the command, config, trust-model,
and getting-started docs so the third agent is listed with Claude and Codex.
A developer ~/.grok/skills can hold gigabytes of git lore and
venvs. Copying that into every VM start filled the Lima disk
and left read-only packs that a second scp could not overwrite.
The restart remove quoted ~ so it never expanded.

Skip hidden and bare-git directories, leave ~/ unquoted in the
guest remove, and isolate the integration suite from host ~/.grok.
Growing a disk with truncate left lima.yaml at the old size, so
the next start looked like a shrink and Lima refused to boot.
Update disk: with the grow, and revert the yaml if truncate fails.
@alisaifee
alisaifee marked this pull request as ready for review September 11, 2026 15:52
Comment thread src/backend.rs Outdated
Comment thread src/backend.rs Outdated
Comment thread src/lima.rs
Comment thread tests/integration.sh Outdated
Comment thread scripts/guest/grok.sh Outdated
@hbrodin

hbrodin commented Sep 14, 2026

Copy link
Copy Markdown
Collaborator

Thanks for contributing Grok Build support! The main changes I'd like to see are preserving guest-created config files and Grok plugin activation across restarts, restoring Lima's configuration on every resize failure path, failing the version check when an installed Grok binary cannot run, and reporting curl's actual failure status. I've left the details inline.

Overlay host Grok config onto the guest file instead of replacing it,
keep guest [plugins].enabled across merge, and chmod dest dirs before
scp so guest-only files survive restart.
The official installer already links ~/.grok/bin/agent. grok and
grok-yolo on the system PATH are enough.
# Conflicts:
#	docs/commands.md
#	docs/images-and-profiles.md
#	src/backend.rs
#	src/commands/agent.rs
#	src/guest.rs
Match Claude's overlay contract: restart overwrites host files,
guest-only entries and config_dir = false keep prior copies.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants