From 0c4a6c5ba4334658db25bf3e57893d0cc1db1da2 Mon Sep 17 00:00:00 2001 From: thatben Date: Thu, 13 Feb 2025 15:33:21 +0100 Subject: [PATCH 1/4] Trying the tool on win --- win.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 win.md diff --git a/win.md b/win.md new file mode 100644 index 0000000..4e51741 --- /dev/null +++ b/win.md @@ -0,0 +1,17 @@ +# Setting up and running on Win11 + +## Setup +- Download and run Nodejs installer 'node-v22.14.0-x64.msi' from https://nodejs.org/en/download + +## CMD (not powershell) +- 'node --version' returns 'v22.14.0` +- 'npm --version' returns '10.9.2' + +### In repository root +- 'npm install' successfully installs package +- 'npm start' run the CLI tool + +### Using CLI tool +- After installing Codex: Restart of terminal was required. +- Attempt to start Codex failed: command for firewall modification failed. +- Disabled firewall commands and tried again: tool reports Codex is running and to open a new terminal to interact with it. Then (with no action) the tool stops. (No Codex process is running.) From 993625affc8e5455ab6a0db6a6a327add7a2a969 Mon Sep 17 00:00:00 2001 From: thatben Date: Fri, 14 Feb 2025 09:22:04 +0100 Subject: [PATCH 2/4] Fixes args formatting on win --- src/handlers/nodeHandlers.js | 29 +++++++++++++---------------- win.md | 7 ++++++- 2 files changed, 19 insertions(+), 17 deletions(-) diff --git a/src/handlers/nodeHandlers.js b/src/handlers/nodeHandlers.js index 295e2a3..2219dd5 100644 --- a/src/handlers/nodeHandlers.js +++ b/src/handlers/nodeHandlers.js @@ -71,22 +71,19 @@ export async function runCodex(showNavigationMenu) { nat = await runCommand('curl -s https://ip.codex.storage'); } - const command = platform === 'win32' - ? `codex ^ - --data-dir=datadir ^ - --disc-port=${discPort} ^ - --listen-addrs=/ip4/0.0.0.0/tcp/${listenPort} ^ - --nat=${nat} ^ - --api-cors-origin="*" ^ - --bootstrap-node=spr:CiUIAhIhAiJvIcA_ZwPZ9ugVKDbmqwhJZaig5zKyLiuaicRcCGqLEgIDARo8CicAJQgCEiECIm8hwD9nA9n26BUoNuarCEllqKDnMrIuK5qJxFwIaosQ3d6esAYaCwoJBJ_f8zKRAnU6KkYwRAIgM0MvWNJL296kJ9gWvfatfmVvT-A7O2s8Mxp8l9c8EW0CIC-h-H-jBVSgFjg3Eny2u33qF7BDnWFzo7fGfZ7_qc9P` - : `codex \ - --data-dir=datadir \ - --disc-port=${discPort} \ - --listen-addrs=/ip4/0.0.0.0/tcp/${listenPort} \ - --nat=\`curl -s https://ip.codex.storage\` \ - --api-cors-origin="*" \ - --bootstrap-node=spr:CiUIAhIhAiJvIcA_ZwPZ9ugVKDbmqwhJZaig5zKyLiuaicRcCGqLEgIDARo8CicAJQgCEiECIm8hwD9nA9n26BUoNuarCEllqKDnMrIuK5qJxFwIaosQ3d6esAYaCwoJBJ_f8zKRAnU6KkYwRAIgM0MvWNJL296kJ9gWvfatfmVvT-A7O2s8Mxp8l9c8EW0CIC-h-H-jBVSgFjg3Eny2u33qF7BDnWFzo7fGfZ7_qc9P`; + const executable = `codex`; + const args = [ + `--data-dir=datadir`, + `--disc-port=${discPort}`, + `--listen-addrs=/ip4/0.0.0.0/tcp/${listenPort}`, + `--nat=${nat}`, + `--api-cors-origin="*"`, + `--bootstrap-node=spr:CiUIAhIhAiJvIcA_ZwPZ9ugVKDbmqwhJZaig5zKyLiuaicRcCGqLEgIDARo8CicAJQgCEiECIm8hwD9nA9n26BUoNuarCEllqKDnMrIuK5qJxFwIaosQ3d6esAYaCwoJBJ_f8zKRAnU6KkYwRAIgM0MvWNJL296kJ9gWvfatfmVvT-A7O2s8Mxp8l9c8EW0CIC-h-H-jBVSgFjg3Eny2u33qF7BDnWFzo7fGfZ7_qc9P` + ]; + const command = + `${executable} ${args.join(" ")}` + console.log(showInfoMessage( '🚀 Codex node is running...\n\n' + 'Please keep this terminal open. Start a new terminal to interact with the node.\n\n' + @@ -256,7 +253,7 @@ export async function checkNodeStatus(showNavigationMenu) { if (nodeRunning) { const spinner = createSpinner('Checking node status...').start(); - const response = await runCommand('curl http://localhost:8080/api/codex/v1/debug/info -w \'\\n\''); + const response = await runCommand('curl http://localhost:8080/api/codex/v1/debug/info'); spinner.success(); const data = JSON.parse(response); diff --git a/win.md b/win.md index 4e51741..0f82bb3 100644 --- a/win.md +++ b/win.md @@ -3,7 +3,12 @@ ## Setup - Download and run Nodejs installer 'node-v22.14.0-x64.msi' from https://nodejs.org/en/download -## CMD (not powershell) +## Enable npm for powershell +- Open ps in admin mode +- Run `Set-ExecutionPolicy -ExecutionPolicy RemoteSigned` +- Close admin ps + +## Powershell - 'node --version' returns 'v22.14.0` - 'npm --version' returns '10.9.2' From 09a6f1518ffaf2c68c93ceb8c23689431c59c7c6 Mon Sep 17 00:00:00 2001 From: thatben Date: Fri, 14 Feb 2025 10:00:01 +0100 Subject: [PATCH 3/4] adds message that terminal restart may be needed --- src/handlers/installationHandlers.js | 4 +++- win.md | 5 ----- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/src/handlers/installationHandlers.js b/src/handlers/installationHandlers.js index 6256a95..6616416 100644 --- a/src/handlers/installationHandlers.js +++ b/src/handlers/installationHandlers.js @@ -94,7 +94,9 @@ export async function installCodex(showNavigationMenu) { try { await runCommand('setx PATH "%PATH%;%LOCALAPPDATA%\\Codex"'); spinner.success(); - console.log(showSuccessMessage('Codex has been installed and PATH has been updated automatically!')); + console.log(showSuccessMessage('Codex has been installed and PATH has been updated automatically!\n' + + `You may need to restart your terminal.` + )); } catch (error) { spinner.success(); console.log(showInfoMessage( diff --git a/win.md b/win.md index 0f82bb3..48e620a 100644 --- a/win.md +++ b/win.md @@ -15,8 +15,3 @@ ### In repository root - 'npm install' successfully installs package - 'npm start' run the CLI tool - -### Using CLI tool -- After installing Codex: Restart of terminal was required. -- Attempt to start Codex failed: command for firewall modification failed. -- Disabled firewall commands and tried again: tool reports Codex is running and to open a new terminal to interact with it. Then (with no action) the tool stops. (No Codex process is running.) From 2114d737cbf2cc61828b744f405b0b6a4a4de300 Mon Sep 17 00:00:00 2001 From: thatben Date: Fri, 14 Feb 2025 10:13:42 +0100 Subject: [PATCH 4/4] Removes firewall section for windows node start --- src/handlers/nodeHandlers.js | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/handlers/nodeHandlers.js b/src/handlers/nodeHandlers.js index 2219dd5..5988935 100644 --- a/src/handlers/nodeHandlers.js +++ b/src/handlers/nodeHandlers.js @@ -57,12 +57,6 @@ export async function runCodex(showNavigationMenu) { ]); try { - if (platform === 'win32') { - console.log(showInfoMessage('Setting up firewall rules...')); - await runCommand(`netsh advfirewall firewall add rule name="Allow Codex (TCP-In)" protocol=TCP dir=in localport=${listenPort} action=allow`); - await runCommand(`netsh advfirewall firewall add rule name="Allow Codex (UDP-In)" protocol=UDP dir=in localport=${discPort} action=allow`); - } - let nat; if (platform === 'win32') { const result = await runCommand('for /f "delims=" %a in (\'curl -s --ssl-reqd ip.codex.storage\') do @echo %a');