codex-copilot-dx 0.1.6 → 0.4.1

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.
package/README.md CHANGED
@@ -1,21 +1,21 @@
1
1
  # codex-copilot-dx
2
2
 
3
- Use [Codex Desktop](https://openai.com/codex) app with your **GitHub Copilot** subscription.
3
+ Use [Codex Desktop](https://openai.com/codex) **and** [Claude Code](https://claude.com/claude-code) with your **GitHub Copilot** subscription.
4
4
 
5
5
  ## How it works
6
6
 
7
- Codex Desktop uses OpenAI's Responses API (`/v1/responses`), which isn't directly exposed by the GitHub Copilot API proxy. This tool bridges the gap:
7
+ A single in-process adapter (port `2026`) exposes both APIs over your Copilot subscription:
8
8
 
9
- - **GPT-5.5, GPT-5.4** and other Responses-only models → proxied directly to `api.githubcopilot.com/v1/responses`
10
- - **GPT-4o, GPT-4.1** and other chat models → converted from Responses API to Chat Completions format via `copilot-api`
9
+ - **Codex** -> OpenAI Responses API (`/v1/responses`, `/v1/responses/compact`); Responses-only models and compaction proxy directly, chat models convert to Chat Completions.
10
+ - **Claude Code** -> Anthropic Messages API (`/v1/messages`, `/v1/messages/count_tokens`), translated to/from Chat Completions.
11
11
 
12
- Supports both HTTP SSE streaming and WebSocket connections.
12
+ Supports both HTTP SSE streaming and non-streaming.
13
13
 
14
14
  ## Prerequisites
15
15
 
16
- - [Codex Desktop](https://openai.com/codex) app installed
17
16
  - GitHub Copilot subscription (Individual, Business, or Enterprise)
18
17
  - Node.js 18+
18
+ - [Codex Desktop](https://openai.com/codex) and/or [Claude Code](https://claude.com/claude-code) installed
19
19
 
20
20
  ## Usage
21
21
 
@@ -27,30 +27,42 @@ npx codex-copilot-dx@latest
27
27
 
28
28
  On first run, it will:
29
29
  1. Authenticate with GitHub via device flow (if needed)
30
- 2. Start `copilot-api` proxy (port 4141)
31
- 3. Start the Responses API adapter (port 4142)
32
- 4. Configure Codex to use the adapter
30
+ 2. Start the adapter (port `2026`)
31
+ 3. Configure Codex (`~/.codex/config.toml`) to use the adapter, including stale shell env base URLs if present
32
+ 4. Configure Claude Code (`~/.claude/settings.json`) to use the adapter; it creates the file when missing, otherwise backs up `settings.json.bak` before updating the local API env keys
33
33
  5. Launch Codex Desktop
34
34
 
35
+ Claude Code picks up the new `ANTHROPIC_BASE_URL` on its next launch.
36
+
37
+ Do not set Claude Code by manually exporting `ANTHROPIC_BASE_URL` or `ANTHROPIC_AUTH_TOKEN` in your shell. Let `codex-copilot-dx` write the local config files instead. If you previously exported those variables, remove them from shell startup files and restart the terminal before launching Claude Code.
38
+
35
39
  ## Configuration
36
40
 
37
41
  Environment variables:
38
42
 
39
43
  | Variable | Default | Description |
40
44
  |----------|---------|-------------|
41
- | `COPILOT_API_PORT` | `4141` | Port for copilot-api |
42
- | `ADAPTER_PORT` | `4142` | Port for the adapter |
43
- | `CCDX_IMG_MAX_DIM` | `2048` | Max long-edge (px) for image downscaling |
45
+ | `ADAPTER_PORT` | `2026` | Port for the adapter |
46
+ | `CCDX_IMG_MAX_DIM` | `2048` | Max long edge in pixels for image downscaling |
44
47
  | `CCDX_IMG_QUALITY` | `85` | WebP quality used when re-encoding images |
45
48
  | `CCDX_IMG_MIN_BYTES` | `100000` | Images smaller than this are left untouched |
46
49
  | `CCDX_DISABLE_IMG_OPT` | unset | Set to `1` to disable image optimization |
47
- | `CCDX_DEBUG` | unset | Set to `1` for verbose request diagnostics |
50
+ | `CCDX_USAGE_PATH` | `~/.local/share/codex-copilot-dx/usage.jsonl` | Local JSONL token usage log |
51
+ | `CCDX_DISABLE_USAGE` | unset | Set to `1` to disable usage logging |
52
+
53
+ ### Usage logging
54
+
55
+ The adapter records token usage metadata to `~/.local/share/codex-copilot-dx/usage.jsonl` when upstream responses include usage fields. It logs counts, model names, API surface, and response IDs only; it does not log prompts, completions, tool arguments, or image content.
56
+
57
+ ```bash
58
+ codex-copilot-dx usage
59
+ ```
48
60
 
49
61
  ### Image optimization
50
62
 
51
- Long computer-use sessions can accumulate dozens of screenshots inside the conversation history. Each screenshot is shipped on every subsequent turn, and GitHub Copilot's `/v1/responses` endpoint rejects requests larger than ~5 MB with `413 Payload Too Large`.
63
+ Long computer-use sessions can accumulate screenshots inside the conversation history. Each screenshot is shipped on later turns, and GitHub Copilot's `/responses` endpoint can reject oversized requests with `413 Payload Too Large`.
52
64
 
53
- To avoid that, the adapter automatically downsamples embedded screenshots to long-edge ≤ 2048 px and re-encodes them as WebP before forwarding the request. Typical UI screenshots shrink to 10–15% of their original size with minimal perceptual loss. Disable with `CCDX_DISABLE_IMG_OPT=1` if you need pixel-perfect originals.
65
+ The adapter automatically downsamples embedded screenshots to long-edge <= 2048 px and re-encodes them as WebP before forwarding `/v1/responses`.
54
66
 
55
67
  ## License
56
68
 
package/bin/cli.mjs CHANGED
@@ -1,11 +1,19 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- import { ensureAuth, startCopilotApi, openCodex } from "../src/launcher.mjs";
3
+ import { ensureAuth, openCodex } from "../src/launcher.mjs";
4
4
  import { ensureCodexConfig } from "../src/config.mjs";
5
+ import { ensureClaudeConfig } from "../src/claude-config.mjs";
5
6
  import { startAdapter } from "../src/adapter.mjs";
7
+ import { refreshVSCodeVersion } from "../src/copilot.mjs";
8
+ import { status } from "../src/status.mjs";
9
+ import { printUsageSummary } from "../src/usage.mjs";
6
10
 
7
- const COPILOT_PORT = parseInt(process.env.COPILOT_API_PORT || "4141");
8
- const ADAPTER_PORT = parseInt(process.env.ADAPTER_PORT || "4142");
11
+ const ADAPTER_PORT = parseInt(process.env.ADAPTER_PORT || "2026");
12
+
13
+ if (process.argv[2] === "usage") {
14
+ await printUsageSummary();
15
+ process.exit(0);
16
+ }
9
17
 
10
18
  console.log(`
11
19
  codex-copilot-dx
@@ -13,37 +21,35 @@ console.log(`
13
21
  `);
14
22
 
15
23
  try {
16
- // 1. Ensure GitHub auth
24
+ // Ensure GitHub login, using device flow if no token exists.
17
25
  await ensureAuth();
18
26
 
19
- // 2. Start copilot-api (for legacy models)
20
- const copilotProc = await startCopilotApi(COPILOT_PORT);
27
+ // Refresh the VS Code version in the background; fallback is non-blocking.
28
+ refreshVSCodeVersion();
21
29
 
22
- // 3. Start adapter
30
+ // Start the in-process adapter.
23
31
  await startAdapter(ADAPTER_PORT);
24
32
 
25
- // 4. Configure Codex
33
+ // Point Codex and Claude Code at the adapter.
26
34
  ensureCodexConfig(ADAPTER_PORT);
35
+ ensureClaudeConfig(ADAPTER_PORT);
27
36
 
28
- // 5. Launch Codex
37
+ // Launch Codex when available.
29
38
  openCodex();
30
39
 
31
40
  console.log(`
32
- Ready! Codex is using your GitHub Copilot subscription.
41
+ ${status("ok", "Ready. Codex and Claude Code are using your GitHub Copilot subscription.")}
33
42
 
34
- Adapter: http://localhost:${ADAPTER_PORT}
35
- copilot-api: http://localhost:${COPILOT_PORT}
43
+ Adapter: http://localhost:${ADAPTER_PORT}
36
44
 
37
45
  Press Ctrl+C to stop.
38
46
  `);
39
47
 
40
- // Keep alive
41
48
  process.on("SIGINT", () => {
42
- console.log("\nShutting down...");
43
- copilotProc?.kill();
49
+ console.log(`\n${status("wait", "Shutting down...")}`);
44
50
  process.exit(0);
45
51
  });
46
52
  } catch (e) {
47
- console.error(`Error: ${e.message}`);
53
+ console.error(status("err", e.message));
48
54
  process.exit(1);
49
55
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codex-copilot-dx",
3
- "version": "0.1.6",
3
+ "version": "0.4.1",
4
4
  "description": "Use Codex Desktop app with your GitHub Copilot subscription",
5
5
  "type": "module",
6
6
  "bin": {
@@ -9,8 +9,7 @@
9
9
  "files": [
10
10
  "bin/",
11
11
  "src/",
12
- "README.md",
13
- "CHANGELOG.md"
12
+ "README.md"
14
13
  ],
15
14
  "keywords": [
16
15
  "codex",
@@ -21,8 +20,11 @@
21
20
  "responses-api"
22
21
  ],
23
22
  "license": "MIT",
23
+ "scripts": {
24
+ "test": "node --test"
25
+ },
24
26
  "dependencies": {
25
- "copilot-api": "^0.7.0",
26
- "sharp": "^0.33.5"
27
+ "gpt-tokenizer": "^3.4.0",
28
+ "sharp": "^0.34.5"
27
29
  }
28
30
  }