squeezr-ai 1.14.12 → 1.14.14
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/bin/squeezr.js +47 -33
- package/package.json +1 -1
package/bin/squeezr.js
CHANGED
|
@@ -65,7 +65,10 @@ async function startDaemon() {
|
|
|
65
65
|
req.setTimeout(2000, () => { req.destroy(); resolve(false) })
|
|
66
66
|
})
|
|
67
67
|
if (running) {
|
|
68
|
-
|
|
68
|
+
const mitmPort = Number(port) + 1
|
|
69
|
+
console.log(`Squeezr is already running`)
|
|
70
|
+
console.log(` HTTP proxy (Claude/Aider/Gemini): http://localhost:${port}`)
|
|
71
|
+
console.log(` MITM proxy (Codex): http://localhost:${mitmPort}`)
|
|
69
72
|
return
|
|
70
73
|
}
|
|
71
74
|
|
|
@@ -83,8 +86,11 @@ async function startDaemon() {
|
|
|
83
86
|
})
|
|
84
87
|
child.unref()
|
|
85
88
|
fs.closeSync(logFd)
|
|
86
|
-
|
|
87
|
-
console.log(`
|
|
89
|
+
const mitmPort = Number(port) + 1
|
|
90
|
+
console.log(`Squeezr started (pid ${child.pid})`)
|
|
91
|
+
console.log(` HTTP proxy (Claude/Aider/Gemini): http://localhost:${port}`)
|
|
92
|
+
console.log(` MITM proxy (Codex): http://localhost:${mitmPort}`)
|
|
93
|
+
console.log(` Logs: ${logFile}`)
|
|
88
94
|
}
|
|
89
95
|
|
|
90
96
|
function showLogs() {
|
|
@@ -106,43 +112,49 @@ function showLogs() {
|
|
|
106
112
|
|
|
107
113
|
function stopProxy() {
|
|
108
114
|
const port = process.env.SQUEEZR_PORT || 8080
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
}
|
|
121
|
-
// fallback: fuser (available on most Linux/WSL)
|
|
115
|
+
const mitmPort = Number(port) + 1
|
|
116
|
+
const ports = [port, mitmPort]
|
|
117
|
+
let killed = false
|
|
118
|
+
|
|
119
|
+
for (const p of ports) {
|
|
120
|
+
try {
|
|
121
|
+
let pids = []
|
|
122
|
+
if (process.platform === 'win32') {
|
|
123
|
+
const out = execSync(`netstat -ano | findstr ":${p} "`, { encoding: 'utf-8', stdio: 'pipe' })
|
|
124
|
+
const matches = [...out.matchAll(/LISTENING\s+(\d+)/g)]
|
|
125
|
+
pids = [...new Set(matches.map(m => m[1]))]
|
|
126
|
+
} else {
|
|
122
127
|
try {
|
|
123
|
-
|
|
128
|
+
const out = execSync(`lsof -ti :${p} -sTCP:LISTEN`, { encoding: 'utf-8', stdio: 'pipe' }).trim()
|
|
129
|
+
pids = out.split(/\s+/).filter(Boolean)
|
|
130
|
+
} catch {
|
|
131
|
+
try {
|
|
132
|
+
const out = execSync(`fuser ${p}/tcp 2>/dev/null`, { encoding: 'utf-8', stdio: 'pipe' }).trim()
|
|
133
|
+
pids = out.split(/\s+/).filter(Boolean)
|
|
134
|
+
} catch {}
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
for (const pid of pids) {
|
|
138
|
+
try {
|
|
139
|
+
if (process.platform === 'win32') {
|
|
140
|
+
execSync(`taskkill /F /PID ${pid}`, { stdio: 'pipe' })
|
|
141
|
+
} else {
|
|
142
|
+
execSync(`kill -9 ${pid}`, { stdio: 'pipe' })
|
|
143
|
+
}
|
|
144
|
+
console.log(`Squeezr stopped (pid ${pid} on port ${p})`)
|
|
145
|
+
killed = true
|
|
124
146
|
} catch {}
|
|
125
147
|
}
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
return
|
|
130
|
-
}
|
|
131
|
-
// Take only the first PID in case multiple are returned
|
|
132
|
-
pid = pid.split(/\s+/)[0]
|
|
133
|
-
if (process.platform === 'win32') {
|
|
134
|
-
execSync(`taskkill /F /PID ${pid}`, { stdio: 'pipe' })
|
|
135
|
-
} else {
|
|
136
|
-
execSync(`kill ${pid}`, { stdio: 'pipe' })
|
|
137
|
-
}
|
|
138
|
-
console.log(`Squeezr stopped (pid ${pid})`)
|
|
139
|
-
} catch {
|
|
148
|
+
} catch {}
|
|
149
|
+
}
|
|
150
|
+
if (!killed) {
|
|
140
151
|
console.log(`Squeezr is not running on port ${port}`)
|
|
141
152
|
}
|
|
142
153
|
}
|
|
143
154
|
|
|
144
155
|
async function checkStatus() {
|
|
145
156
|
const port = process.env.SQUEEZR_PORT || 8080
|
|
157
|
+
const mitmPort = Number(port) + 1
|
|
146
158
|
return new Promise(resolve => {
|
|
147
159
|
const req = http.get(`http://localhost:${port}/squeezr/health`, res => {
|
|
148
160
|
let data = ''
|
|
@@ -150,7 +162,9 @@ async function checkStatus() {
|
|
|
150
162
|
res.on('end', () => {
|
|
151
163
|
try {
|
|
152
164
|
const json = JSON.parse(data)
|
|
153
|
-
console.log(`Squeezr is running (v${json.version}
|
|
165
|
+
console.log(`Squeezr is running (v${json.version})`)
|
|
166
|
+
console.log(` HTTP proxy (Claude/Aider/Gemini): http://localhost:${port}`)
|
|
167
|
+
console.log(` MITM proxy (Codex): http://localhost:${mitmPort}`)
|
|
154
168
|
} catch {
|
|
155
169
|
console.log(`Squeezr is running on port ${port}`)
|
|
156
170
|
}
|
|
@@ -158,7 +172,7 @@ async function checkStatus() {
|
|
|
158
172
|
})
|
|
159
173
|
})
|
|
160
174
|
req.on('error', () => {
|
|
161
|
-
console.log(`Squeezr is NOT running
|
|
175
|
+
console.log(`Squeezr is NOT running`)
|
|
162
176
|
console.log('Start it with: squeezr start')
|
|
163
177
|
resolve(false)
|
|
164
178
|
})
|
package/package.json
CHANGED