codex-copilot-dx 0.1.2 → 0.1.3
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/package.json +1 -1
- package/src/config.mjs +1 -1
- package/src/launcher.mjs +9 -7
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
|
}
|