ProductsSelected

Grok Bot Reverse Engineering Project

Why we picked it

The project enables Grok Bot users to route conversations to alternative backends like Claude Code and OpenRouter while maintaining local usage statistics and Docker sandboxing capabilities.

Developer @b_nnett decompiled the closed-source application into approximately 440,000 lines of readable TypeScript (runtime) and 54,000 lines of React (rendering layer).

Body

The project adds four utility extensions including a reasoning router that can route conversations to four backends: Cursor, Claude Code, Codex, and OpenRouter.

The reverse engineering reveals a layered architecture with rendering, preload, Electron main process, coordinator, and host components.

Original · shao__meng

Grok Bot 被逆向构建了 作者 @b_nnett 把编译后的闭源应用反推成约 44 万行可读 TypeScript(运行时)+ 5.4 万行 React(渲染层),并在此基础上做了功能扩展。 github.com/b-nnett/grok-b… 整体分层:渲染层 → preload 窄桥 → Electron 主进程(设置/密钥/认证/窗口)→ coordinator(utilityProcess 托管,崩溃退避重启)→ host(推理、工具、MCP、turn 执行)。主进程被拆成依赖注入图,缺绑定即 fail-closed。 在此之上加了四个实用扩展: 1. 推理路由器:对话可路由到四个后端——Cursor(默认,原生会话)、Claude Code(复用本地 CLI 登录)、Codex(读取 ~/.codex 的 ChatGPT OAuth,直连 Responses SSE 端点,401 自动刷新 token,且校验凭据文件权限/非符号链接)、OpenRouter(API key 走系统 safeStorage 加密存储)。 2. MCP 工具桥:在本机回环地址起一个带随机 secret 路径的临时 MCP HTTP 服务,把 Grok Bot 已连接的插件工具暴露给被路由的后端;工具按名称启发式标注 readOnly/destructive。系统提示明确告知模型"你在 Grok Bot 里",防止它拒用已连接插件。 3. 本地用量统计:按 provider 累计请求数与 token 数,与云端账单分离。 4. 本地 Docker 沙箱:用内容寻址的只读挂载容器替代远端 box,仅绑回环端口,经设置页开关切换。 路由会话的体验保真做得细致:流式增量、思考中状态(250ms 脉冲防止远端空闲名单冲掉 UI)、表情回应、每 agent 200 条本地 transcript(原子写 + 0o600 权限)。📊 3 ⚡

Industry Coordinates & Source Verification

This report is categorized under AITOP's "Products" desk, focusing on US frontier AI labs and Silicon Valley technology leaders. Key entities and technical topics under continuous tracking include Grok Bot, TypeScript, React.

Source attribution: curated from shao__meng (@shao__meng).