8000 GitHub - DominicVonk/CodexClaw: Go bridge from Telegram and WhatsApp to Codex app-server with sessions, memory, skills, and media · GitHub
[go: up one dir, main page]

Skip to content
DominicVonkPublic

About

Go bridge from Telegram and WhatsApp to Codex app-server with sessions, memory, skills, and media

Resources

Stars

0 stars

Watchers

1 watching

Forks

Repository files navigation

CodexClaw

CodexClaw is a Go daemon that turns Telegram, WhatsApp, and Discord into chat interfaces for Codex. It is built for private, allowlisted use: send a message from a configured chat transport, let Codex work in the configured workspace, and get progress plus the final answer back in chat.

Highlights

  • Codex app-server gateway through the Go agent-cli-wrapper/codex client
  • Telegram bot support with groups, supergroups, and forum topic threads
  • Telegram command menu registered automatically with the supported slash commands
  • WhatsApp support through whatsmeow with terminal QR login
  • Discord bot support with DMs, guild channels, threads, attachments, and native replies
  • Sender allowlist for Telegram user IDs, WhatsApp phone/JID senders, and Discord user IDs
  • Persistent chat sessions with /new, /session, and configurable minimal or persistent Codex thread context
  • Model and reasoning controls per session or globally with /model and /reasoning
  • Graph memory per chat scope with /remember, /memory, /memory graph, /link, /unlink, and /forget
  • Skills with $skill-name, /skills, $memory, $skill-creator, and the built-in $skills dictionary
  • Agent Browser integration with $agent-browser, $browser, /browser, auto-injection for browser tasks, and mise install/doctor tasks
  • Self-management commands to refresh or fast-forward the daemon against origin/main
  • Attachments for Telegram, WhatsApp, and Discord images and documents
  • Tool progress messages while Codex runs commands, edits files, searches, compacts, and calls tools
  • Pure-Go SQLite via modernc.org/sqlite, so CGO is not required

Requirements

  • Go 1.25+
  • mise is optional but supported via .mise.toml
  • Codex CLI installed and authenticated
  • Telegram bot token if Telegram is enabled
  • A WhatsApp account for QR login if WhatsApp is enabled
  • Discord bot token with the Message Content intent enabled if Discord is enabled

Quick Start

cp config.example.yaml ~/.codex-claw/config.yml
cp .env.example ~/.codex-claw/.env

Edit ~/.codex-claw/config.yml:

  • Set telegram.token or set TELEGRAM_BOT_TOKEN in ~/.codex-claw/.env
  • Set discord.token or set DISCORD_BOT_TOKEN in ~/.codex-claw/.env
  • Add your Telegram sender ID as telegram:<user_id>
  • Add your WhatsApp sender as whatsapp:<phone_number> or whatsapp:<jid>
  • Add your Discord sender ID as discord:<user_id>
  • Choose service.mode: telegram, whatsapp, discord, both, or all

Run locally:

mise exec -- go run ./cmd/codexclaw serve

For WhatsApp, scan the QR code printed in the terminal or service logs. The authenticated WhatsApp session defaults to ./whatsapp-session/whatsapp.db. If QR pairing is unreliable from service logs, use phone-number pairing:

pm2 stop codex-claw
mise exec -- go run ./cmd/codexclaw whatsapp-login -phone 31612345678
pm2 restart codex-claw --update-env

Enter the printed pairing code in WhatsApp under Linked devices > Link with phone number instead.

Service Mode

service:
  mode: both

Valid modes:

  • telegram
  • whatsapp
  • discord
  • both
  • all

The mode selects which transports run. Each transport also has its own enabled flag. You can override the mode with:

CODEXCLAW_SERVICE_MODE=telegram

Configuration

CodexClaw loads .env from $HOME/.codex-claw and then the current directory. It then searches for config files in this order:

./config.yml
./config.yaml
$HOME/.codex-claw/config.yml
$HOME/.codex-claw/config.yaml

YAML values can reference environment variables with ${VAR}. Common settings can also be overridden with CODEXCLAW_* variables.

Default runtime paths:

$HOME/.codex-claw/config.yml
$HOME/.codex-claw/.env
$HOME/.codex-claw/sessions.db
$HOME/.codex-claw/media
./whatsapp-session/whatsapp.db

CodexClaw uses the Codex app-server protocol through the Go github.com/bazelment/yoloswe/agent-cli-wrapper/codex client. The gateway keeps a long-lived app-server process, creates or resumes Codex threads, streams tool and token events, and sends turns with model, reasoning, approval, sandbox, and workspace settings.

Agent Browser is optional but first-class. CodexClaw can inject compact agent-browser workflow guidance into turns that need browser automation, screenshots, login-state reuse, or page interaction. The integration follows the upstream agent-browser CLI workflow: open a page, inspect snapshot -i, interact by @e refs, re-snapshot after changes, and close the session when done.

Allowlist

When allowlist.enabled is true, CodexClaw ignores messages unless the sender is listed.

allowlist:
  enabled: true
  entries:
    - telegram:123456789
    - whatsapp:31612345678
    - whatsapp:31612345678@s.whatsapp.net
    - discord:123456789012345678

Telegram authorization uses message.from.id. WhatsApp authorization uses the sender phone/user JID. Discord authorization uses the message author user ID. Sessions still map to the chat destination, so Telegram topics, WhatsApp DMs/groups, Discord DMs, Discord channels, and Discord threads each keep separate Codex sessions.

Chat Commands

/new [name]
/session
/session <id|name>
/status
/model [model-name|default] [--global]
/reasoning [low|medium|high|xhigh|default] [--global]
/skills
/self_refresh
/self_update
/remember <text>
/memory
/memory graph
/link <from-memory-id> <relation> <to-memory-id>
/unlink <link-id>
/forget <id|all>
/browser

Session commands:

  • /new [name] creates a fresh Codex thread and makes it active.
  • /session lists stored sessions for the current chat scope.
  • /session <id|name> switches to a stored session.

Status, model, and reasoning:

  • /status shows active session, thread ID, context mode, model, cumulative token usage, last-turn token usage, reasoning level, and compaction settings.
  • /model <model-name> changes the model for the active session.
  • /model <model-name> --global updates codex.model in the loaded config file and persists across restarts.
  • /model default resets the active session to the config default.
  • /reasoning <level> changes reasoning for the active session.
  • /reasoning <level> --global updates codex.effort in the loaded config file and persists across restarts.
  • /reasoning default resets the active session to the config default.

Memory:

  • /remember <text> saves persistent memory for the current chat scope.
  • The memory skill is loaded by default, quietly remembers durable personal facts such as I'm Dutch, my name is Dominic, or I prefer concise answers, and keeps replies natural. Add $memory to explicitly inject selected saved memory graph context.
  • /memory lists saved memory nodes.
  • /memory graph lists memory nodes plus graph links.
  • /link <from-memory-id> <relation> <to-memory-id> manually creates a typed edge between memories.
  • /unlink <link-id> removes one graph edge.
  • /forget <id|all> deletes one memory item or clears all memory for the current scope. Links are removed with deleted memories.
  • CodexClaw automatically links new memories to related existing memories and includes a tiny relevant graph neighborhood when the message matches saved memory. Add $memory or $memories for manual graph context, or $memory all for every memory.

Skills:

  • /skills lists available skills.
  • $skill-name attaches a matching Codex skill to the next turn.
  • $skills and $skill-dictionary inject a compact dictionary of available skill names into the next turn.
  • $memory and $memories explicitly inject selected saved memory graph context for the current chat; the memory skill itself is loaded by default.
  • $skill-creator injects a compact dictionary entry for creating or updating Codex skills.
  • $agent-browser and $browser inject compact agent-browser CLI guidance. When agent_browser.auto_inject is enabled, CodexClaw also adds this guidance automatically for URL/browser/page-interaction requests.
  • $stt and $speech-to-text use configured speech-to-text for attached Telegram voice/audio and WhatsApp audio messages.
  • $tts and $text-to-speech synthesize the final answer into an audio message when text-to-speech is configured.
  • /browser shows whether the integration is enabled, which command is configured, auto-inject state, the shared browser session name, and whether agent-browser is on PATH.
  • /speech shows whether STT and TTS are configured.

Self-management:

  • /self_refresh fetches origin/main, verifies the running checkout is aligned with it, and then schedules a process restart. If the checkout is behind, ahead, or diverged, it reports the state and leaves the process running.
  • /self_update fetches origin/main, fast-forwards the local main branch when the worktree is clean, and then schedules a process restart. It refuses to run from another branch or with uncommitted changes.

Speech

Speech is built in as transport plumbing plus tiny dictionary skills. The default setup uses Edge TTS for text-to-speech and faster-whisper for speech-to-text through uv, so the runtime stays configurable without injecting provider docs into every prompt. Faster-whisper runs locally; Edge TTS uses Microsoft's online speech service.

speech:
  timeout_seconds: 300
  stt:
    enabled: true
    command: "uv run --with faster-whisper scripts/stt-faster-whisper.py --json {input}"
  tts:
    enabled: true
    command: "scripts/tts-edge-tts.sh {text} {output}"
    mime: audio/mpeg
    file_name: reply.mp3
    auto_for_audio: true

Command placeholders are shell-quoted by CodexClaw:

  • STT receives {input} and should print JSON with text and language fields. Plain transcript stdout is still accepted.
  • TTS receives {text}. If the command contains {output}, it must write audio to that path; otherwise stdout is treated as audio bytes.
  • auto_for_audio sends a synthesized audio reply automatically when the incoming message contains voice/audio. $tts still forces audio replies for text messages.

Install or prime the speech dependencies with:

mise install
mise run speech:install

Useful environment overrides:

  • CODEXCLAW_WHISPER_MODEL=base selects the faster-whisper model.
  • CODEXCLAW_WHISPER_DEVICE=cpu and CODEXCLAW_WHISPER_COMPUTE_TYPE=int8 control inference.
  • CODEXCLAW_EDGE_TTS_VOICE=en-US-AriaNeural selects the Edge TTS voice.
  • CODEXCLAW_EDGE_TTS_VOICE_NL=nl-NL-ColetteNeural overrides the Dutch voice used when faster-whisper detects nl.

Agent Browser

agent_browser:
  enabled: true
  command: agent-browser
  auto_inject: true
  session: codexclaw
  max_output: 12000

Use these tasks to install or repair the local browser tooling:

mise run browser:install
mise run browser:doctor
mise run browser:skill
mise run browser:core -- --full

browser:skill installs the upstream vercel-labs/agent-browser skill globally for Codex through skills.sh. browser:core prints the version-matched CLI skill from the installed agent-browser binary.

Skills.sh And Scaffolding

CodexClaw includes mise tasks for skills.sh discovery/installation and local skill/plugin creation.

mise run skills:find -- github
mise run skills:add -- vercel-labs/agent-skills
mise run skills:list
mise run skills:update

skills:add runs npx --yes skills add with telemetry disabled by default and installs globally for the Codex agent. Override the target with SKILLS_AGENT=<agent>.

Local scaffolds:

mise run skill:new -- repo-maintainer "Repository maintenance workflow"
mise run plugin:new -- repo-tools "Repository tools for Codex"

New skills are created under ./skills/<name>/SKILL.md. New plugins are created under ./plugins/<name>/.codex-plugin/plugin.json with an empty skills/ directory ready for plugin-owned skills.

Attachments

Telegram photos/documents and WhatsApp images/documents are downloaded to media.dir.

  • Documents are saved locally and included in the text input as filesystem paths so Codex can inspect them with workspace tools.
  • Images are saved locally and included in the Codex turn as local attachment paths. Their paths are also listed in the text input for traceability.

Context Mode

CodexClaw defaults to persistent context mode. A chat session keeps using the same Codex app-server thread ID until /new creates a new one or /session switches to another stored session.

Minimal context mode is available when you explicitly want every message to run in a fresh Codex thread with only the selected memory, skill dictionary entries, and current message.

sessions:
  context_mode: persistent

Valid values are minimal and persistent. You can override the mode with:

CODEXCLAW_SESSIONS_CONTEXT_MODE=persistent

Auto-Compaction

The Codex app-server wrapper does not expose an explicit compaction endpoint. When sessions.auto_compact is true and the threshold is reached, CodexClaw records the threshold as handled and reports that explicit compaction is unavailable for this backend.

sessions:
  context_mode: persistent
  auto_compact: true
  auto_compact_after_tokens: 120000

Running With PM2

pm2 start /usr/bin/mise --name codex-claw --cwd "$PWD" -- exec -- go run ./cmd/codexclaw serve
pm2 status codex-claw
pm2 logs codex-claw

Codex Gateway

The active runtime gateway lives in internal/codexapp and uses the Codex app-server wrapper on every supported platform.

Development

mise install
mise exec -- gofmt -w ./cmd ./internal
mise exec -- env CGO_ENABLED=0 go test ./...
mise exec -- env CGO_ENABLED=0 go build ./...

CI Builds

GitHub Actions builds 0.0.0-alpha.1 artifacts for:

  • linux/amd64
  • linux/arm64
  • darwin/amd64
  • darwin/arm64
  • windows/amd64
  • windows/arm64

Each artifact is named codexclaw_0.0.0-alpha.1_<os>_<arch> and includes a SHA256 file.

Security Notes

CodexClaw is intended for private, allowlisted operation. Do not commit real config.yml, .env, WhatsApp sessions, or runtime databases. The included .gitignore excludes those files by default.

Disclaimer

CodexClaw is an independent, free open-source project and is not affiliated, associated, authorized, endorsed by, or in any way officially connected with OpenAI, OpenClaw, or any of their subsidiaries or affiliates. "OpenAI", "Codex", and "OpenClaw" are trademarks of their respective owners.

License

MIT License. You can use, copy, modify, merge, publish, distribute, sublicense, and sell copies under the MIT terms. Published versions of CodexClaw that are released under MIT remain available under those MIT terms for people who receive them; later project changes do not take those granted rights away from those copies.

About

Go bridge from Telegram and WhatsApp to Codex app-server with sessions, memory, skills, and media

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages

0