WARP.md
Documents the architecture, configuration, and development workflow for a dependency-free Web UI wrapping the local OpenAI Codex CLI.
What this file does
Documents the architecture, configuration, and development workflow for a dependency-free Web UI wrapping the local OpenAI Codex CLI.
When to use it
- Setting up a local Codex WebUI for the first time
- Understanding how the server spawns and manages Codex CLI processes
- Extending the single-file server or client with new endpoints or UI features
- Configuring session resume, memory persistence, or security settings
Assumes this stack
WARP.md
This file provides guidance to WARP (warp.dev) when working with code in this repository.
Project Overview
Codex WebUI is a dependency-free Web UI that wraps the local OpenAI Codex CLI. It provides a clean browser interface for interacting with Codex, featuring streaming output via Server-Sent Events (SSE), session management, and memory persistence.
Key Characteristics:
- Node.js 18+ ES module-based application
- Single-file server implementation (
server.js) with zero dependencies - Serves static HTML/CSS/JS client from
public/index.html - Integrates with local OpenAI Codex CLI binary
- Uses JSONL session files for persistence
Architecture
Core Components
Server (server.js):
- HTTP server with SSE streaming for real-time communication
- Spawns and manages Codex CLI child processes
- Handles session resume from
~/.codex/sessions/*.jsonlfiles - Manages persistent memory in
.codex/memory.md - TOML configuration system with whitelisted keys
- CORS and optional bearer token authentication
Client (public/index.html):
- Single-page application with vanilla JavaScript
- Dark/light theme switching
- Collapsible sidebar with sessions, projects, memory, and settings
- Real-time message streaming via EventSource
- Session management and memory viewer
Key Data Flows:
- Client connects via SSE to
/events - User messages sent to
/message→ forwarded to Codex CLI - Codex CLI stdout parsed for JSON events → broadcast to clients
- Memory facts extracted from agent responses and saved to
memory.md - Session files auto-resumed on startup unless disabled
Directory Structure
/
├── server.js # Main server application
├── package.json # Node.js project config (minimal, dependency-free)
├── public/index.html # Single-file client application
├── start-windows.bat # Windows batch launcher
├── tests/basic.test.js # Node.js built-in test suite
├── .env.example # Environment configuration template
└── config.toml # Runtime configuration (auto-generated)
Configuration
Environment Variables (.env):
HOST/PORT: Server binding (default: 127.0.0.1:5055)WEBUI_TOKEN: Optional bearer token for write operationsCODEX_CMD: Codex binary path (default: "codex")CODEX_WORKDIR: Working directory overrideCODEX_RESUME: Auto-resume latest rollout (default: 1)
Runtime Config (config.toml):
model: Codex model selection (default: gpt-5)approval_policy: Auto-approval setting (default: never)sandbox_mode: Execution safety (default: danger-full-access)use_streamable_shell: Enable streaming shell commandsinstructions_extra: Additional agent instructions
Common Development Commands
Running the Application
# Start server (development mode with auto-reload)
npm run dev
# Start server (production mode)
npm start
# Windows batch launcher
start-windows.bat
# Manual start with environment variables
HOST=127.0.0.1 PORT=5055 node server.js
Testing
# Run all tests using Node.js built-in test runner
npm test
# Run tests manually
node --test tests/*.test.js
# Run specific test file
node --test tests/basic.test.js
Development Workflow
Starting Development:
- Ensure Node.js 18+ is installed
- Ensure OpenAI Codex CLI is installed and configured
- Copy
.env.exampleto.envand customize if needed - Run
npm run devfor auto-reload during development
Testing Changes:
- Server tests validate HTTP endpoints, config management, and session listing
- Tests use different ports (5065-5068) to avoid conflicts
- Manual testing via browser at
http://127.0.0.1:5055
Key Development Areas:
- Server-side: Add new HTTP endpoints in
server.js - Client-side: Modify the single
public/index.htmlfile - Configuration: Update TOML parsing/writing functions
- Session management: Extend
scanSessions()and related functions
Integration Points
Codex CLI Integration
- Spawns Codex with specific arguments including workdir, tools, and model config
- Parses JSON-line stdout for events:
session_configured,agent_message_delta,exec_command_begin, etc. - Manages session resume via
experimental_resumeflag - Auto-applies approval policies and sandbox settings
File System Integration
- Sessions:
~/.codex/sessions/rollout-*.jsonlfiles - Memory:
.codex/memory.mdin working directory - History: Local
history.jsonfor tracking recent sessions - Config: Local
config.tomlfor runtime settings
Security Considerations
- Default binding to localhost only
- Optional bearer token authentication for write operations
- CORS restrictions to prevent unauthorized cross-origin requests
- Sandbox mode configuration for Codex execution safety
Windows-Specific Notes
- Uses
start-windows.batfor easy Windows launching - PowerShell environment variable syntax supported
- File path handling accounts for Windows path separators
- Process spawning compatible with Windows Codex binary locations
What's inside
6 sections covering overview, architecture, directory structure, config, commands, integration points, and Windows notes
Change this for your project
- Replace
codexwith your own Codex binary path inCODEX_CMD - Replace
gpt-5with your desired model inconfig.toml - Replace
~/.codex/sessions/rollout-*.jsonlwith your session file pattern if different
Where it goes
Save in docs/ or the repository root. Gives agents and new contributors a map of the codebase.
Worth borrowing
- Single-file server with zero dependencies for simplicity
- SSE streaming for real-time client updates without WebSockets
- TOML config with whitelisted keys to restrict runtime changes
Related Documents
Design Document: BharatSeva AI
Describes a 10-agent AWS system that helps India's informal workers access government schemes via voice-first, serverless architecture.
OpenClaw Enterprise Transformation Plan
Transforms a single-user AI agent into a dual-mode platform supporting both viral open-source and Fortune 500 enterprise deployments through phased security, IAM, audit, multi-tenancy, and Kubernetes features.
University of Guelph Rocketry Club - Complete Tech Stack
Documents the full tech stack of a university rocketry club website with AI chatbot, member management, and project showcases.
Qwen Image and Edit: Open-sourcing and Local GGUF Generations with Lightning
Documents the Qwen-Image and Qwen-Image-Edit models, covering architecture, training, benchmarks, ComfyUI setup, and prompting techniques for local GGUF deployment.