codex-copilot-dx 0.1.2 → 0.1.4
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 +3 -1
- package/package.json +1 -1
- package/src/config.mjs +1 -1
- package/src/launcher.mjs +9 -7
package/README.md
CHANGED
|
@@ -20,9 +20,11 @@ Supports both HTTP SSE streaming and WebSocket connections.
|
|
|
20
20
|
## Usage
|
|
21
21
|
|
|
22
22
|
```bash
|
|
23
|
-
npx codex-copilot-dx
|
|
23
|
+
npx codex-copilot-dx@latest
|
|
24
24
|
```
|
|
25
25
|
|
|
26
|
+
> Tip: the `@latest` suffix forces `npx` to fetch the newest release instead of using a stale cached copy.
|
|
27
|
+
|
|
26
28
|
On first run, it will:
|
|
27
29
|
1. Authenticate with GitHub via device flow (if needed)
|
|
28
30
|
2. Start `copilot-api` proxy (port 4141)
|
package/package.json
CHANGED
package/src/config.mjs
CHANGED
|
@@ -5,7 +5,7 @@ import os from "node:os";
|
|
|
5
5
|
const CONFIG_PATH = path.join(os.homedir(), ".codex", "config.toml");
|
|
6
6
|
|
|
7
7
|
export function ensureCodexConfig(adapterPort = 4142) {
|
|
8
|
-
const baseUrl = `http://
|
|
8
|
+
const baseUrl = `http://localhost:${adapterPort}/v1`;
|
|
9
9
|
|
|
10
10
|
if (!fs.existsSync(CONFIG_PATH)) {
|
|
11
11
|
// Codex not installed yet, create minimal config
|
package/src/launcher.mjs
CHANGED
|
@@ -6,12 +6,14 @@ import net from "node:net";
|
|
|
6
6
|
|
|
7
7
|
const GITHUB_TOKEN_PATH = path.join(os.homedir(), ".local", "share", "copilot-api", "github_token");
|
|
8
8
|
|
|
9
|
-
function
|
|
9
|
+
function isPortAccepting(port) {
|
|
10
10
|
return new Promise((resolve) => {
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
11
|
+
const sock = net.connect(port, "127.0.0.1");
|
|
12
|
+
let done = false;
|
|
13
|
+
const finish = (v) => { if (done) return; done = true; sock.destroy(); resolve(v); };
|
|
14
|
+
sock.once("connect", () => finish(true));
|
|
15
|
+
sock.once("error", () => finish(false));
|
|
16
|
+
sock.setTimeout(1000, () => finish(false));
|
|
15
17
|
});
|
|
16
18
|
}
|
|
17
19
|
|
|
@@ -42,7 +44,7 @@ function findCopilotApi() {
|
|
|
42
44
|
}
|
|
43
45
|
|
|
44
46
|
export async function startCopilotApi(port = 4141) {
|
|
45
|
-
if (await
|
|
47
|
+
if (await isPortAccepting(port)) {
|
|
46
48
|
console.log(`[codex-copilot-dx] copilot-api already running on :${port}`);
|
|
47
49
|
return null;
|
|
48
50
|
}
|
|
@@ -64,7 +66,7 @@ export async function startCopilotApi(port = 4141) {
|
|
|
64
66
|
// Wait for it to be ready
|
|
65
67
|
for (let i = 0; i < 30; i++) {
|
|
66
68
|
await new Promise((r) => setTimeout(r, 500));
|
|
67
|
-
if (await
|
|
69
|
+
if (await isPortAccepting(port)) {
|
|
68
70
|
console.log(`[codex-copilot-dx] copilot-api ready on :${port}`);
|
|
69
71
|
return child;
|
|
70
72
|
}
|