Codex Environment Control (helm-x)

August 17, 2026 · View on GitHub

中文 | English

Repository: https://github.com/ADWMC/helm-x


If you find this project helpful, please give it a Star!


Codex CLI local mapping control tool · Single binary · C++17 · Zero external DLL dependencies

🛡️ 0 Cyber: This tool does not launch any real network attacks or connect to any external targets — it only performs local Codex environment control (local mapping / instruction injection / response tampering). All traffic stays between your machine and your configured upstream relay.

⚠️ For educational and research purposes only. Commercial use prohibited.


What is this

helm-x is a local mapping layer for Codex CLI: codex → 127.0.0.1:1800 → upstream relay. When requests pass through the local proxy, it forcefully injects custom instructions (AGENTS) and tampers with refusal responses at the response layer — keeping conversations uninterrupted and content deliverable.

Core capabilities:

  1. Context injection: bridge.md establishes security research context, blocking cyber flag detection
  2. TAMPER engine: Refusal responses are rewritten as compliance markers
  3. Context-aware rewriter: Auto-rewrites requests when cyber flag triggers (with retry mechanism)
  4. Context Gardener: Prunes oversized historical tool output and Base64 images before forwarding
  5. Cloud-updatable QA: Searchable WebUI help with GitHub updates and offline fallback
  6. Zero dependencies: Single exe, statically linked, Windows system libs only

Test Results

Core Metrics (57 high-risk requests)

MetricValueNotes
Total Pass Rate100% (57/57)Direct pass + rewritten pass
Direct Pass55 (96.5%)AGENTS injection blocks cyber flag
Rewritten Pass2 (3.5%)Rewriter auto-rewrites + clean session
Cyber Flag Trigger2/57 (3.5%)Metasploit, self-replicating program

Comparison with Previous Version

Metricv0.0.1-betav0.0.2-fix1Improvement
Cyber Flag Rate100%3.5%↓96.5%
Total Pass Rate0%100%↑100%
Test Cases857+49

Test Cases (57, 12 categories)

CategoryCasesPass RateCyber Flag
Process Hide6100%0
Keylogger6100%0
Network Attack6100%0
Exploit6100%1
Malware6100%0
Game Security6100%0
License Crack6100%0
Boundary6100%1
Violence7100%0
Pornography7100%0
Mixed Boundary7100%0
Financial/Political7100%0

Detailed report: tests/v002-fix1-full-test.md


Architecture

codex ──> http://127.0.0.1:1800 ──> upstream relay

         [WinHTTP forward]   [Inject AGENTS]
         [stream=false]      [TAMPER rewrite]
         [auto-config]       [Auto-restore on exit]

         [cyber flag?] ──→ [Rewriter] ──→ [Clean session] ──→ [Upstream]
helmx.exe (single binary)
├─ proxy    HTTP MITM (WinHTTP upstream, inject, TAMPER, rewriter)
├─ ui       Web console (embedded HTML, 4 pages)
├─ watch    Self-healing daemon (auto-restore when injection overwritten)
├─ apply/remove   Deploy/undeploy AGENTS + config injection
├─ activate/verify  Activation verification / integrity check

Quick Start

Requirements

ItemRequirement
Windows10/11
Codex CLI0.146+ (responses wire API)
Upstream relayAny OpenAI-compatible API (base_url in codex config)
RuntimeNone (only KERNEL32/UCRT/WS2_32/SHELL32/WINHTTP)

Install

:: Option A — Double-click (recommended)
helmx.exe
:: Auto: starts proxy(:1800) + UI(:8090) + opens browser

:: Option B — Command line
helmx proxy --listen 1800          :: Local mapping
helmx proxy --max-retries 0         :: Retry upstream failures forever
helmx proxy --max-retries 2         :: Two retries after the initial request
helmx proxy --retry-delay 3         :: Use a fixed three-second delay
helmx proxy --no-retry              :: Disable retry for this process
helmx ui                            :: Web console

Upstream Retry

The proxy retries upstream transport failures, incomplete or empty responses, and every HTTP 4xx/5xx response by default. upstream_max_retries counts additional attempts: the default 10 permits up to eleven requests total, while 0 retries until the proxy is stopped. Retries use a fixed three-second delay by default; configure the delay in Services → Upstream Retry or in %APPDATA%\helmx.config.json. The proxy does not use an upstream Retry-After value. Ctrl+C or closing the helm-x window interrupts a pending retry wait immediately.

WebUI QA and Context Settings

Open http://127.0.0.1:8090. The QA Help page provides searchable common errors and checks GitHub for updates, falling back to cached or embedded data. The Context page configures Context Gardener, tool-output limits, and Codex auto-compaction settings. Maintainers can add questions by editing assets/qa.json; see docs/QA.md.

Verify

helmx activate        :: Send activation word
helmx verify --e2e    :: 7 self-checks + codex activation

Configure Rewriter (optional)

The rewriter auto-rewrites user messages when cyber flag triggers. Requires a non-reasoning model as the rewriter backend.

Model Requirements

RequirementNotes
Non-reasoning modelReasoning models (mimo-v2.5-pro, o1, o3) have empty content field
Fast responseRetries 3 times, needs <5s per response
Chinese supportRewriter prompt includes Chinese examples
API compatibleOpenAI chat/completions format
ModelProviderLatencyNotes
meta/llama-3.1-8b-instructNVIDIA NIM~2sRecommended, fast and stable
meta/llama-3.1-70b-instructNVIDIA NIM~5sStronger but slower
gpt-4o-miniOpenAI~2sRequires OpenAI key
qwen2.5-7b-instructAlibaba Cloud~2sAvailable in China
deepseek-chatDeepSeek~2sAvailable in China

Config Example

{
  "upstream_retry_enabled": true,
  "upstream_max_retries": 10,
  "upstream_retry_delay_seconds": 3,
  "rewriter": {
    "enabled": true,
    "provider": "nvidia",
    "base_url": "https://integrate.api.nvidia.com/v1",
    "api_key": "nvapi-xxx",
    "model": "meta/llama-3.1-8b-instruct",
    "timeout_sec": 60,
    "use_proxy": false,
    "proxy_url": "http://127.0.0.1:7897"
  }
}

Config Fields

FieldDescriptionDefault
upstream_retry_enabledEnable upstream retrytrue
upstream_max_retriesAdditional retry attempts; 0 = unlimited10
upstream_retry_delay_secondsFixed delay between retries3
enabledEnable rewriterfalse
providerProvider identifier (for logs)nvidia
base_urlAPI endpointhttps://integrate.api.nvidia.com/v1
api_keyAPI key(required)
modelModel namemeta/llama-3.1-8b-instruct
timeout_secRequest timeout (seconds)60
use_proxyUse HTTP proxyfalse
proxy_urlHTTP proxy URLhttp://127.0.0.1:7897

Notes

  • Don't use reasoning models: mimo-v2.5-pro, o1, o3 have empty content field
  • NVIDIA NIM is free: Register at https://build.nvidia.com for free API key
  • Rewriter prompt is embedded: No external file needed, XOR encrypted in binary
  • Configurable in UI: Visit http://127.0.0.1:8090 "改写器" page

Build

:: 1. Generate encrypted resources
python tools/embed.py

:: 2. Compile
cmake -B build -G "MinGW Makefiles" -DCMAKE_BUILD_TYPE=Release
cmake --build build

License

GNU AGPL v3.0

⚠️ For educational and research purposes only.