@bman654/clodex 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,54 @@
1
+ # Bridging Claude Code's agents view and background agents
2
+
3
+ This page explains how to bridge **every** Claude Code process on your machine — your own terminal sessions *and* the extra `claude` processes Claude Code spawns for its agents view and background agents — through one long-running clodex server. It is written so a Claude Code agent can execute the setup for you: if you are an agent reading this, follow the steps below on the user's behalf, asking before editing their shell profile.
4
+
5
+ ## How it works
6
+
7
+ - One global **`clodex server --proxy`** runs in the background (proxy mode is the recommended mode for this setup: your existing Anthropic login keeps working, and only `clodex:` models / aliases are rerouted to OpenAI).
8
+ - On startup the server advertises itself in `~/.clodex/server-runtime.json` (`mode`, `port`, `pid`, and in proxy mode the CA certificate path). The file is removed on shutdown.
9
+ - The **`clodex-claude`** bin (installed alongside `clodex`) reads that file, checks the server is actually alive (pid + TCP probe), and launches the real `claude` binary with the right env injected:
10
+ - proxy-mode server: `HTTPS_PROXY`/`HTTP_PROXY` + `NODE_EXTRA_CA_CERTS`, with `ANTHROPIC_BASE_URL` removed;
11
+ - endpoint-mode server: `ANTHROPIC_BASE_URL` pointing at the gateway;
12
+ - **no live server: env untouched** — `claude` always launches normally, a stopped server never breaks anything.
13
+ - Setting **`CLAUDE_CODE_PROCESS_WRAPPER`** to `clodex-claude` makes Claude Code invoke it as `clodex-claude <claude-binary-path> <args...>` for every process it spawns — agents view sessions and background agents are bridged automatically.
14
+ - For your own terminal sessions, run **`clodex-claude`** instead of `claude` — same auto-discovery, no port or CA path to hardcode anywhere.
15
+
16
+ ## Setup steps
17
+
18
+ 1. **Install clodex globally** (puts both `clodex` and `clodex-claude` on your PATH):
19
+
20
+ ```bash
21
+ npm install -g @bman654/clodex
22
+ ```
23
+
24
+ 2. **Start the server and keep it running** (a terminal tab, tmux pane, or your service manager of choice):
25
+
26
+ ```bash
27
+ clodex server --proxy
28
+ ```
29
+
30
+ Bridging only happens while this server is running. When it is not, `clodex-claude` falls back cleanly and launches `claude` with an untouched environment.
31
+
32
+ 3. **Point Claude Code's process wrapper at `clodex-claude`.** Add to your shell profile — `~/.zprofile` or `~/.zshrc` (zsh), or `~/.bash_profile` (bash):
33
+
34
+ ```bash
35
+ export CLAUDE_CODE_PROCESS_WRAPPER="$(command -v clodex-claude)"
36
+ ```
37
+
38
+ Then open a new terminal (or `source` the profile). Every `claude` process Claude Code spawns from sessions started in that environment is now bridged.
39
+
40
+ 4. **Use `clodex-claude` (not `claude`) for terminal sessions you want bridged:**
41
+
42
+ ```bash
43
+ clodex-claude # instead of: claude
44
+ clodex-claude -p "hi" # all claude flags pass through
45
+ ```
46
+
47
+ Port and CA discovery are automatic via `~/.clodex/server-runtime.json` — do not hardcode `HTTPS_PROXY`, ports, or certificate paths in your profile.
48
+
49
+ ## Troubleshooting
50
+
51
+ - **Is my session bridged?** In a session started via `clodex-claude` (or spawned by Claude Code with the wrapper set), `/model` accepts your `clodex:` model names and aliases (run `clodex models --list` to see them). If those models are rejected and you haven't run `clodex patch`, that's expected for unpatched binaries — but a bridged session still routes them; an unbridged one errors at the API instead.
52
+ - **Server not running:** `clodex-claude` silently launches plain `claude`. Check `cat ~/.clodex/server-runtime.json` — missing file (or a `pid` that is no longer alive) means no server is advertised; start `clodex server --proxy`.
53
+ - **Stale wrapper variable:** if `CLAUDE_CODE_PROCESS_WRAPPER` points at a path that no longer exists (e.g. after a reinstall moved global npm bins, or it still points at an old hand-written script), Claude Code's spawned processes may fail to start or silently skip bridging. Verify with `ls "$CLAUDE_CODE_PROCESS_WRAPPER"` and re-export using `command -v clodex-claude`.
54
+ - **Port conflicts:** the server default is 17645; `clodex server --proxy --port <n>` picks another. `clodex-claude` reads the actual port from the runtime file, so no other change is needed.
package/package.json ADDED
@@ -0,0 +1,82 @@
1
+ {
2
+ "name": "@bman654/clodex",
3
+ "version": "0.1.0",
4
+ "publishConfig": {
5
+ "access": "public"
6
+ },
7
+ "description": "Bridge Claude Code to OpenAI models — OpenAI API key or ChatGPT/Codex-plan OAuth, with prompt caching, auto-compaction, model switching, and a Claude Code binary patcher",
8
+ "author": "Brandon Wallace",
9
+ "license": "MIT",
10
+ "keywords": [
11
+ "claude",
12
+ "claude-code",
13
+ "openai",
14
+ "chatgpt",
15
+ "codex",
16
+ "ai",
17
+ "llm",
18
+ "cli",
19
+ "bridge",
20
+ "proxy"
21
+ ],
22
+ "type": "module",
23
+ "packageManager": "pnpm@10.34.5",
24
+ "bin": {
25
+ "clodex": "dist/cli.js",
26
+ "clodex-claude": "dist/claude-wrapper.js"
27
+ },
28
+ "files": [
29
+ "dist",
30
+ "docs",
31
+ "README.md"
32
+ ],
33
+ "engines": {
34
+ "node": ">=22"
35
+ },
36
+ "scripts": {
37
+ "build": "tsup",
38
+ "dev": "tsup --watch",
39
+ "test": "vitest run",
40
+ "test:watch": "vitest",
41
+ "typecheck": "tsc --noEmit",
42
+ "prepare": "husky",
43
+ "prepublishOnly": "pnpm build"
44
+ },
45
+ "dependencies": {
46
+ "@ai-sdk/anthropic": "4.0.12",
47
+ "@ai-sdk/openai": "4.0.11",
48
+ "@ai-sdk/openai-compatible": "3.0.7",
49
+ "@ai-sdk/provider-utils": "5.0.7",
50
+ "@clack/prompts": "0.9.1",
51
+ "ai": "7.0.22",
52
+ "https-proxy-agent": "9.1.0",
53
+ "ipaddr.js": "2.4.0",
54
+ "node-forge": "1.4.0",
55
+ "open": "11.0.0",
56
+ "picocolors": "1.1.1",
57
+ "undici": "7.28.0",
58
+ "ws": "8.21.0"
59
+ },
60
+ "devDependencies": {
61
+ "@commitlint/cli": "19.8.1",
62
+ "@commitlint/config-conventional": "19.8.1",
63
+ "@types/node": "22.19.19",
64
+ "@types/node-forge": "1.3.14",
65
+ "@types/ws": "8.18.1",
66
+ "husky": "9.1.7",
67
+ "tsup": "8.5.1",
68
+ "typescript": "5.9.3",
69
+ "vitest": "2.1.9"
70
+ },
71
+ "optionalDependencies": {
72
+ "@napi-rs/keyring": "1.3.0"
73
+ },
74
+ "repository": {
75
+ "type": "git",
76
+ "url": "git+https://github.com/bman654/clodex.git"
77
+ },
78
+ "homepage": "https://github.com/bman654/clodex#readme",
79
+ "bugs": {
80
+ "url": "https://github.com/bman654/clodex/issues"
81
+ }
82
+ }