codex-copilot-dx 0.1.5 → 0.4.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.
- package/README.md +24 -11
- package/bin/cli.mjs +16 -16
- package/package.json +6 -2
- package/src/adapter.mjs +237 -257
- package/src/anthropic.mjs +267 -0
- package/src/auth.mjs +95 -0
- package/src/claude-config.mjs +56 -0
- package/src/config.mjs +77 -17
- package/src/copilot.mjs +316 -0
- package/src/launcher.mjs +8 -79
- package/src/status.mjs +11 -0
- package/src/stream.mjs +22 -0
package/README.md
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
# codex-copilot-dx
|
|
2
2
|
|
|
3
|
-
Use [Codex Desktop](https://openai.com/codex)
|
|
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
|
-
|
|
7
|
+
A single in-process adapter (port `2026`) exposes both APIs over your Copilot subscription:
|
|
8
8
|
|
|
9
|
-
- **
|
|
10
|
-
- **
|
|
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
|
|
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,19 +27,32 @@ 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
|
|
31
|
-
3.
|
|
32
|
-
4. Configure
|
|
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
|
-
| `
|
|
42
|
-
| `
|
|
45
|
+
| `ADAPTER_PORT` | `2026` | Port for the adapter |
|
|
46
|
+
| `CCDX_IMG_MAX_DIM` | `2048` | Max long edge in pixels for image downscaling |
|
|
47
|
+
| `CCDX_IMG_QUALITY` | `85` | WebP quality used when re-encoding images |
|
|
48
|
+
| `CCDX_IMG_MIN_BYTES` | `100000` | Images smaller than this are left untouched |
|
|
49
|
+
| `CCDX_DISABLE_IMG_OPT` | unset | Set to `1` to disable image optimization |
|
|
50
|
+
|
|
51
|
+
### Image optimization
|
|
52
|
+
|
|
53
|
+
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`.
|
|
54
|
+
|
|
55
|
+
The adapter automatically downsamples embedded screenshots to long-edge <= 2048 px and re-encodes them as WebP before forwarding `/v1/responses`.
|
|
43
56
|
|
|
44
57
|
## License
|
|
45
58
|
|
package/bin/cli.mjs
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
import { ensureAuth,
|
|
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";
|
|
6
9
|
|
|
7
|
-
const
|
|
8
|
-
const ADAPTER_PORT = parseInt(process.env.ADAPTER_PORT || "4142");
|
|
10
|
+
const ADAPTER_PORT = parseInt(process.env.ADAPTER_PORT || "2026");
|
|
9
11
|
|
|
10
12
|
console.log(`
|
|
11
13
|
codex-copilot-dx
|
|
@@ -13,37 +15,35 @@ console.log(`
|
|
|
13
15
|
`);
|
|
14
16
|
|
|
15
17
|
try {
|
|
16
|
-
//
|
|
18
|
+
// Ensure GitHub login, using device flow if no token exists.
|
|
17
19
|
await ensureAuth();
|
|
18
20
|
|
|
19
|
-
//
|
|
20
|
-
|
|
21
|
+
// Refresh the VS Code version in the background; fallback is non-blocking.
|
|
22
|
+
refreshVSCodeVersion();
|
|
21
23
|
|
|
22
|
-
//
|
|
24
|
+
// Start the in-process adapter.
|
|
23
25
|
await startAdapter(ADAPTER_PORT);
|
|
24
26
|
|
|
25
|
-
//
|
|
27
|
+
// Point Codex and Claude Code at the adapter.
|
|
26
28
|
ensureCodexConfig(ADAPTER_PORT);
|
|
29
|
+
ensureClaudeConfig(ADAPTER_PORT);
|
|
27
30
|
|
|
28
|
-
//
|
|
31
|
+
// Launch Codex when available.
|
|
29
32
|
openCodex();
|
|
30
33
|
|
|
31
34
|
console.log(`
|
|
32
|
-
Ready
|
|
35
|
+
${status("ok", "Ready. Codex and Claude Code are using your GitHub Copilot subscription.")}
|
|
33
36
|
|
|
34
|
-
Adapter:
|
|
35
|
-
copilot-api: http://localhost:${COPILOT_PORT}
|
|
37
|
+
Adapter: http://localhost:${ADAPTER_PORT}
|
|
36
38
|
|
|
37
39
|
Press Ctrl+C to stop.
|
|
38
40
|
`);
|
|
39
41
|
|
|
40
|
-
// Keep alive
|
|
41
42
|
process.on("SIGINT", () => {
|
|
42
|
-
console.log("
|
|
43
|
-
copilotProc?.kill();
|
|
43
|
+
console.log(`\n${status("wait", "Shutting down...")}`);
|
|
44
44
|
process.exit(0);
|
|
45
45
|
});
|
|
46
46
|
} catch (e) {
|
|
47
|
-
console.error(
|
|
47
|
+
console.error(status("err", e.message));
|
|
48
48
|
process.exit(1);
|
|
49
49
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "codex-copilot-dx",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "Use Codex Desktop app with your GitHub Copilot subscription",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -20,7 +20,11 @@
|
|
|
20
20
|
"responses-api"
|
|
21
21
|
],
|
|
22
22
|
"license": "MIT",
|
|
23
|
+
"scripts": {
|
|
24
|
+
"test": "node --test"
|
|
25
|
+
},
|
|
23
26
|
"dependencies": {
|
|
24
|
-
"
|
|
27
|
+
"gpt-tokenizer": "^3.4.0",
|
|
28
|
+
"sharp": "^0.34.5"
|
|
25
29
|
}
|
|
26
30
|
}
|