Skip to content

Latest commit

 

History

History
152 lines (103 loc) · 4.98 KB

File metadata and controls

152 lines (103 loc) · 4.98 KB

WeChat Codex/DeepSeek Bot

This directory runs a WeChat iLink bot through cc-connect. Incoming WeChat messages are bridged to a local AI coding agent and the agent response is sent back to WeChat.

WeChat message -> cc-connect -> local agent -> WeChat reply

Supported Agents

  • ./start.sh codex: runs the real Codex CLI with an OpenAI API key.
  • ./start.sh deepseek: runs the local bin/codex shim, which forwards requests to deepseek exec.

cc-connect is still configured with type = "codex" in both modes. DeepSeek is not configured as a Codex provider because the DeepSeek API does not support the Codex /responses endpoint expected by that path.

Required Configuration

Set runtime credentials with environment variables. Do not store real keys or tokens in repository files.

Variable Required For Description
WEIXIN_BOT_TOKEN All real starts WeChat iLink bot token.
WEIXIN_ACCOUNT_ID All real starts WeChat iLink bot account id.
WEIXIN_ALLOW_FROM Optional Allowed sender filter. Defaults to *.
WEIXIN_BASE_URL Optional WeChat iLink base URL. Defaults to https://ilinkai.weixin.qq.com.
OPENAI_API_KEY First Codex setup OpenAI API key for Codex mode.
DEEPSEEK_API_KEY DeepSeek mode DeepSeek API key.
DEEPSEEK_MODEL Optional DeepSeek model name. Defaults to deepseek-v4-pro.
DEEPSEEK_BASE_URL Optional DeepSeek API base URL. Defaults to https://api.deepseek.com/v1.

Files

  • start.sh: the recommended entry point. It generates config.toml, selects Codex or DeepSeek, prepares environment variables, and starts cc-connect.
  • config.toml: generated runtime configuration. The checked-in version only contains placeholders.
  • bin/codex: the DeepSeek shim. It is only placed first in PATH during ./start.sh deepseek.
  • data/sessions/: local WeChat conversation state written by cc-connect.
  • data/deepseek-shim/sessions.json: local mapping between Codex thread ids and DeepSeek session ids.
  • data/codex-openai-home/: project-local Codex home. Runtime auth/state files should remain local.
  • data/current-agent: records the last selected backend so old agent session ids can be cleared when switching modes.

Start Codex Mode

cd llm-wechat-cli
export WEIXIN_BOT_TOKEN="<real weixin bot token>"
export WEIXIN_ACCOUNT_ID="<real weixin account id>"
export OPENAI_API_KEY="<real OpenAI API key>"
./start.sh codex

On the first successful start, start.sh writes the OpenAI key to the project-local Codex auth file:

data/codex-openai-home/auth.json

Later Codex starts can omit OPENAI_API_KEY if that local auth file already contains a usable key.

Start DeepSeek Mode

cd llm-wechat-cli
export WEIXIN_BOT_TOKEN="<real weixin bot token>"
export WEIXIN_ACCOUNT_ID="<real weixin account id>"
export DEEPSEEK_API_KEY="<real DeepSeek API key>"
./start.sh deepseek

Optional model override:

export DEEPSEEK_MODEL="deepseek-v4-flash"
./start.sh deepseek

Generate Config Without Starting

./start.sh codex --no-start
./start.sh deepseek --no-start

This only writes config.toml. A real bot start still needs the required environment variables.

Switching Modes

Codex and DeepSeek can be switched at any time:

./start.sh codex
./start.sh deepseek

When the selected backend changes, start.sh clears stale agent_session_id values under data/sessions/*.json. The chat history stays in place, but the next WeChat message creates a fresh underlying agent session.

Verify

After startup, cc-connect should print messages similar to:

platform ready    project=wechat-bot  platform=weixin
cc-connect is running  projects=1

Then send a message to the configured WeChat bot and verify that the agent replies.

Stop

Find the process:

pgrep -af cc-connect

Stop it:

kill <PID>

start.sh ultimately runs:

cc-connect --config "$DIR/config.toml" --force

The --force flag lets cc-connect replace an older instance using the same config.

Troubleshooting

OpenAI 401

Make sure OPENAI_API_KEY is a real OpenAI key and not a DeepSeek key. Then run ./start.sh codex again.

DeepSeek 404 for /responses

The process is bypassing the local shim and using the wrong provider path. Start DeepSeek mode with ./start.sh deepseek.

thread/resume failed: no rollout found

The stored agent_session_id points at another backend or another Codex home. Switch modes with start.sh so stale ids are cleaned automatically, or start a new chat session.

DeepSeek replies that it is Codex

The cc-connect agent type is still named codex for compatibility. The real execution path is determined by the startup command.

Do Not

  • Do not commit real API keys, bot tokens, chat ids, or local auth files.
  • Do not change [projects.agent].type to deepseek.
  • Do not configure DeepSeek as a Codex provider.
  • Do not bypass start.sh when running DeepSeek mode.