Skip to content

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

CodexRemote

A global CLI tool that runs a Telegram bot for controlling Codex CLI on your Mac.

Install

npm install -g codexremote
codexremote

On first run, codexremote asks for:

  • Telegram Bot Token
  • Allowed Telegram User ID
  • Default Project Directory, optional
  • Codex permission mode, default full-access

It validates the Telegram bot token, saves config under ~/.codexremote/, starts the Telegram bot in the background, then exits.

Local Development

npm install
npm link
npm test
npm run lint
codexremote

CLI Commands

codexremote
codexremote config
codexremote start
codexremote stop
codexremote restart
codexremote status
codexremote logs
codexremote commands
codexremote reset

Config And Logs

CodexRemote stores user-level files here:

~/.codexremote/
  config.json
  state.json
  projects.json
  tasks.json
  bot.log
  codex-runs/
  uploads/
  codexremote.pid

config.json is written with 0600 permissions when the filesystem supports it. The Telegram token is not printed in full after setup.

Codex run logs are stored in ~/.codexremote/codex-runs/.

Telegram Setup

  1. Create a bot with BotFather.
  2. Run codexremote.
  3. Enter the bot token.
  4. Enter your Telegram user ID.
  5. Open Telegram and send /start.

Only the configured Telegram user ID can use the bot.

Telegram Slash Command Suggestions

CodexRemote automatically registers Telegram bot commands on startup using Telegram Bot API setMyCommands.

After the bot starts, open the Telegram chat and type / to see available commands.

You can manually refresh commands with:

codexremote commands

Manual BotFather command configuration is not required.

Telegram Commands

/start
/help
/setproject /Users/me/Projects/app
/newproject <Project name>
/addproject <alias> <absolute_path>
/use <alias>
/removeproject <alias>
/current
/projects
/plan <task>
/note <message>
/pending
/approve
/reject
/codex <task>
/login
/logout
/authstatus
/sessions
/sessions all
/resume <session_id>
/resume_last <task>
/history
/task <id>
/retry <id>
/scripts
/setscript <name> <command>
/runscript <name>
/settings
/doctor
/dev
/preview
/stopdev
/cancel
/status
/log
/stop

Slash Commands, Inline Buttons, And Wizards

CodexRemote uses slash commands plus contextual inline buttons. Persistent Telegram reply buttons are removed so the chat input stays clean.

Guided flows are available for adding projects, creating plans, running Codex directly, adding notes, entering settings, and saving uploaded files. Use /cancel to exit the current wizard.

Projects And Aliases

Projects can be saved with aliases:

/newproject My App
/addproject seller /Users/me/Projects/seller-agent
/use seller
/removeproject seller

/newproject <Project name> creates a new folder, saves it as a project, and activates it immediately. It uses the configured default project directory when available, otherwise ~/Projects. Names are converted to safe folder aliases, for example My App becomes my-app.

/projects shows project buttons. Older project data containing plain paths is migrated automatically.

Planning Workflow

/setproject /Users/me/Projects/app
/plan create landing page hiển thị thông tin luật đá bóng sân 7 bằng tiếng Việt, giao diện rõ ràng
/pending
/note dùng responsive mobile, giao diện đơn giản, có các mục: số cầu thủ, thời gian thi đấu, lỗi phổ biến, phạt, thay người
/approve
/log

/plan asks Codex to create a plan only and saves it as the pending plan. /note adds instructions. /approve runs implementation using the original task, saved plan, and notes. /reject clears the pending plan.

If a pending plan exists and you send normal text outside a wizard, CodexRemote asks whether to add it as a note.

Telegram Inline Buttons

CodexRemote supports inline buttons for quick mobile actions.

After /plan, you can tap:

  • Approve
  • Reject
  • View Pending Plan
  • Latest Log

During a running task, you can tap:

  • Status
  • Stop
  • Latest Log

Authentication messages show contextual buttons too:

  • Login when Codex is signed out
  • Logout when Codex is signed in
  • Auth Status while login is in progress

All text commands still work.

After tasks finish, CodexRemote shows quick action buttons such as View Log, Retry, Run Tests, Build, Changed Files, and Ask Codex to Fix.

Direct Execution

/codex implement the requested change and run reasonable validation

Direct execution skips the approval workflow.

Codex Authentication From Telegram

CodexRemote supports authentication commands:

/login
/logout
/authstatus

/login uses:

codex login --device-auth

The bot sends the login URL/code to Telegram. Open it in your browser, complete sign-in, and the bot confirms when Codex is authenticated.

/logout runs:

codex logout

/authstatus runs:

codex login status

Task History And Retry

CodexRemote stores task history in ~/.codexremote/tasks.json.

/history
/task <id>
/retry <id>

History includes task mode, project, status, timestamps, exit code, log file, and a short summary. Retry reruns the saved task when possible.

Project Scripts

Configure or auto-detect common scripts:

/scripts
/setscript test npm test
/runscript test

CodexRemote can detect scripts from package.json, Makefile, go.mod, pom.xml, and pyproject.toml. Quick action buttons use scripts named test and build.

Settings Through Telegram

/settings
/doctor

Settings buttons support permission mode, Codex binary, message limit, log throttle, default project, and refreshing Telegram command suggestions. Changes are persisted to ~/.codexremote/config.json.

/doctor checks common setup problems, including Codex CLI availability, permission mode, configured Telegram user, default project directory, and active project path.

File Uploads

Send a supported file to the bot to save it under ~/.codexremote/uploads/. The bot shows actions to plan with the file, run Codex with the file, save it into the active project, or ignore it.

Supported file types include .txt, .md, .json, .yaml, .yml, .js, .ts, .tsx, .jsx, .py, .java, .go, .xml, .html, .css, .png, .jpg, .jpeg, and .webp.

Dev Server Preview

/dev
/preview
/stopdev

/dev runs the active project's dev script in the background and stores dev server state in ~/.codexremote/state.json. /preview shows the detected localhost URL when available.

Quota And Rate Limit Detection

CodexRemote scans Codex output for quota, rate limit, authentication, and token limit errors. If detected, the bot sends a clear explanation and marks task history with statuses such as quota_limited, rate_limited, auth_error, or token_limit.

Codex Permission Mode

CodexRemote supports two permission modes. Configure this with:

codexremote config

workspace-write

Safer mode:

codex exec --cd PROJECT_DIR --sandbox workspace-write "TASK"

Codex can write inside the project sandbox.

full-access

Full permission mode:

codex exec --cd PROJECT_DIR --dangerously-bypass-approvals-and-sandbox "TASK"

Full-access disables sandbox and approval prompts. Codex runs with the same permissions as your macOS user. Use only on trusted machines and trusted projects.

Codex Session Resume

CodexRemote can list and resume recent Codex sessions from Telegram without opening Codex's interactive terminal picker.

/sessions
/sessions all
/resume <session_id>
/resume_last tiếp tục sửa lỗi build và chạy npm test

/sessions scans ~/.codex/sessions/, shows recent sessions, and adds Resume buttons. Button callbacks use a short cache stored in ~/.codexremote/state.json.

/resume <session_id> runs Codex with that exact session id through codex exec resume. /resume_last <task> uses Codex's --last mode with a non-interactive prompt. CodexRemote never runs plain interactive codex resume from Telegram.

Non-Interactive Codex

CodexRemote always launches Codex with stdin ignored:

stdio: ['ignore', 'pipe', 'pipe']

The bot does not send follow-up input to Codex through stdin. User decisions happen through Telegram commands such as /note, /approve, and /reject.

Reset

codexremote reset

Reset stops the bot and removes saved config/state/project references. Logs are kept by default unless you confirm deleting them.

Limitations

  • One Telegram user.
  • One Codex process at a time.
  • No database, PM2, Docker, webhook mode, or multi-user support.
  • Codex CLI must be installed before /plan, /approve, or /codex can run successfully.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages