mirror of
https://github.com/Ark0N/Codeman.git
synced 2026-09-30 12:39:42 +02:00
SessionMode gains 'grok', a first-class backend alongside Claude Code,
shell, OpenCode, Codex, Gemini, Antigravity and Pi: its own PTY, tmux
session, charcoal tab identity ('gk' badge), welcome button, run-mode
entry, cron agentType, Docker and remote-SSH command defaults, and
clone-repo Brain option. Flag surface verified live against grok 1.0.5.
Grok mixes two existing shapes and the wiring follows from that:
- Codex-shaped on permissions: the bypass switch is GrokConfig.alwaysApprove
(--always-approve, grok's bypassPermissions mode; config-level deny rules
still apply on top). The Run button sends it true, like runAntigravity(),
and clampExternalCliBypassForOwner() puts grok in the only-if-sent branch:
a bare grok spawn is grok's own ask-mode default, which is already safe,
so only a sent config needs the flag forced off. Cron needs nothing for
the same reason.
- OpenCode-shaped on rendering: grok is a fullscreen alternate-screen TUI
with mouse support, so it stays OUT of isAltScreenStripMode() and lands
on the narrow tmux-attach strip and the 'buffer' local-echo fallthrough
(unmeasured against an authenticated composer; documented fallback is the
'off' branch).
- Pi-shaped on resolution: 'grok' has npm squatters (@vibe-kit/grok-cli
also installs a grok bin), so grok-cli-resolver.ts version-probes every
candidate (grok --version, killSignal SIGKILL, VITEST-gated) and
GET /api/grok/status surfaces path AND version; GROK_VERSION_REGEX is
shared with the dependency registry so doctor and run mode cannot drift.
Env allowlist gains GROK_* plus the XAI_* vendor namespace (XAI_API_KEY is
grok's documented headless auth var), the same narrow-vendor reasoning as
GOOGLE_* for gemini. Resume is id-regexed on purpose: grok's own --resume
also matches session titles, which are arbitrary user strings that must
never reach the bash -c spawn line.
Docker: grok is not on npm, so the agent image installs it in its own step
(xAI's installer has no --dir override; the binary is copied to
/usr/local/bin and root's ~/.grok dropped in the same layer), and
credentials are seeded per-file (auth.json, config.toml, pager.toml; the
dir also holds sessions/, memory/ and the ~160MB binary). Remote SSH routes
through the login-shell wrapper like the other agent CLIs.
Verified end to end on an isolated CODEMAN_INSTANCE with grok 1.0.5
installed: /api/grok/status resolves and reports the probed version,
quick-start spawns a pane whose command line ends in 'grok
--always-approve', the real TUI renders (OAuth device screen on an
unauthenticated box), and grokConfig round-trips through state.json.
Docs: docs/grok-integration.md (user guide) + docs/grok-integration-plan.md
(decisions, verification record, follow-ups).
Tests: test/grok-mode.test.ts, test/grok-cli-resolver.test.ts, plus
extended clamp/system-routes/render-index-html/run-mode-ui/mobile-overview/
local-echo-gating coverage. npm test (the CI gate) green: 5910 tests.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
97 lines
4.9 KiB
Docker
97 lines
4.9 KiB
Docker
# Codeman agent base image (built locally by scripts/build-agent-image.mjs).
|
|
#
|
|
# Contains the agent toolchain (node + the CLIs + git/tmux/ripgrep) but NO
|
|
# secrets: credentials are delivered at RUNTIME via bind mounts (~/.claude etc.)
|
|
# or name-only `docker exec --env`, never baked in, so `docker save` exports stay
|
|
# secret-free. tmux is a HARD prerequisite (the in-container tmux is what makes a
|
|
# reconnect durable), so it is installed here and probed before launch.
|
|
#
|
|
# HOME is made writable by an ARBITRARY host uid via the OpenShift "gid 0,
|
|
# group-writable" convention: on Linux we run `--user <hostUid>:0`, so the agent
|
|
# uid is the host uid (workspace files stay host-owned) while gid 0 keeps $HOME
|
|
# writable even though the uid is not the baked 1000.
|
|
FROM node:22-bookworm-slim
|
|
|
|
# Base toolchain. `curl` is needed for the hook callbacks (`curl -sk $CODEMAN_API_URL`),
|
|
# `procps` for `ps`, `tmux` for the durable in-container session.
|
|
RUN apt-get update \
|
|
&& apt-get install -y --no-install-recommends \
|
|
git \
|
|
tmux \
|
|
ripgrep \
|
|
curl \
|
|
ca-certificates \
|
|
less \
|
|
procps \
|
|
openssh-client \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
# The npm-published agent CLIs. Pinning is left to the rebuild cadence (see
|
|
# docs/docker-cases-plan.md, user-decision 2).
|
|
RUN npm install -g \
|
|
@anthropic-ai/claude-code \
|
|
@openai/codex \
|
|
@google/gemini-cli \
|
|
opencode-ai \
|
|
&& npm cache clean --force
|
|
|
|
# Antigravity (`agy`) is NOT on npm — Google ships a standalone binary through its
|
|
# own installer, so it needs its own step. `--dir /usr/local/bin` is load-bearing:
|
|
# the installer's default target is `$HOME/.local/bin`, which at build time is
|
|
# root's home and would be unreachable by the `agent` user the container runs as.
|
|
# ⚠️ This binary is ~190MB on its own; it is the single largest layer in the image.
|
|
RUN curl -fsSL https://antigravity.google/cli/install.sh | bash -s -- --dir /usr/local/bin \
|
|
&& chmod 755 /usr/local/bin/agy \
|
|
&& agy --version
|
|
|
|
# Pi (pi.dev). Upstream documents --ignore-scripts (pi needs no lifecycle scripts);
|
|
# kept out of the shared npm block above so the flag cannot silently change how the
|
|
# other four CLIs install.
|
|
RUN npm install -g --ignore-scripts @earendil-works/pi-coding-agent \
|
|
&& npm cache clean --force \
|
|
&& pi --version
|
|
|
|
# Grok Build (`grok`, xAI) is NOT on npm: a standalone ~160MB Rust binary through
|
|
# xAI's installer, which targets $HOME/.grok/bin with no --dir override. At build
|
|
# time that is root's home and unreachable by the `agent` user, so copy the binary
|
|
# (through the bin/ symlink, hence -L) into /usr/local/bin and drop root's ~/.grok
|
|
# in the same layer so the image does not carry the download twice.
|
|
RUN curl -fsSL https://x.ai/cli/install.sh | bash \
|
|
&& cp -L /root/.grok/bin/grok /usr/local/bin/grok \
|
|
&& chmod 755 /usr/local/bin/grok \
|
|
&& rm -rf /root/.grok /root/.local/bin/grok /root/.local/bin/agent \
|
|
&& grok --version
|
|
|
|
# `agent` user (gid 0) with an arbitrary-uid-writable HOME. The uid is
|
|
# auto-assigned (node:22-slim already occupies uid 1000 with its `node` user); at
|
|
# runtime Codeman overrides with `--user <hostUid>:0` on Linux, so the baked uid
|
|
# only matters for a hand-run / Docker Desktop container. gid 0 + group-writable
|
|
# HOME (OpenShift arbitrary-uid convention) keeps $HOME writable for any uid.
|
|
# UTF-8 locale so tmux/Ink render Unicode box-drawing instead of VT100 ACS `q`
|
|
# glyphs (C.UTF-8 is built into glibc; no locales package needed). Codeman also
|
|
# sets these at run time so containers built before this line still get UTF-8.
|
|
ENV LANG=C.UTF-8 LC_ALL=C.UTF-8
|
|
ENV HOME=/home/agent
|
|
# `.claude` (+ `.claude/projects` mount point) and `.codex` (+ `.codex/sessions`) are
|
|
# pre-created gid-0 group-writable so the container owns its OWN credential config
|
|
# dirs: tokens/settings/config are seeded in as writable copies and each CLI's runtime
|
|
# state (backups, tasks, refreshed tokens) stays container-local, while ONLY the shared
|
|
# transcript/rollout dirs (`.claude/projects`, `.codex/sessions`) are bind-mounted from
|
|
# the host. (gemini/gcloud/opencode are whole seed-copies and need no pre-created dir;
|
|
# Antigravity nests its state inside `.gemini/antigravity-cli`, so it rides that seed.)
|
|
# `.pi/agent` and `.grok` ARE pre-created: both are seeded per-FILE (pi:
|
|
# auth/settings/trust/models; grok: auth.json/config.toml/pager.toml), and a
|
|
# per-file seed copy, unlike a whole-dir one, does not create its parent directory.
|
|
RUN useradd -g 0 -m -d /home/agent -s /bin/bash agent \
|
|
&& mkdir -p /home/agent/.npm /home/agent/.cache /home/agent/.config /home/agent/.codeman \
|
|
/home/agent/.claude/projects /home/agent/.codex/sessions /home/agent/.pi/agent /home/agent/.grok \
|
|
&& chgrp -R 0 /home/agent \
|
|
&& chmod -R g=u /home/agent
|
|
|
|
USER agent
|
|
WORKDIR /home/agent
|
|
|
|
# Codeman overrides the command with `sleep infinity` at create time; this is the
|
|
# fallback so a hand-run container also idles rather than exiting.
|
|
CMD ["sleep", "infinity"]
|