squeezr-ai 1.16.10 → 1.16.12
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 +53 -16
- package/package.json +1 -1
package/bin/squeezr.js
CHANGED
|
@@ -89,6 +89,24 @@ function getPort() {
|
|
|
89
89
|
return process.env.SQUEEZR_PORT || getPortFromToml() || 8080
|
|
90
90
|
}
|
|
91
91
|
|
|
92
|
+
/**
|
|
93
|
+
* Print a PowerShell/bash one-liner to refresh env vars in the current session.
|
|
94
|
+
* Copies it to the clipboard on Windows so the user can just Ctrl+V, Enter.
|
|
95
|
+
*/
|
|
96
|
+
function printEnvRefreshHint(port, mitmPort) {
|
|
97
|
+
const bundlePath = path.join(os.homedir(), '.squeezr', 'mitm-ca', 'bundle.crt')
|
|
98
|
+
if (process.platform === 'win32') {
|
|
99
|
+
const cmd = `$env:ANTHROPIC_BASE_URL="http://localhost:${port}"; $env:GEMINI_API_BASE_URL="http://localhost:${port}"; $env:HTTPS_PROXY="http://localhost:${mitmPort}"`
|
|
100
|
+
try { execSync(`powershell -NoProfile -Command "Set-Clipboard '${cmd.replace(/'/g, "''")}';"`, { stdio: 'pipe' }) } catch {}
|
|
101
|
+
console.log(`\n Run this to activate in the current terminal (already copied to clipboard):\n`)
|
|
102
|
+
console.log(` ${cmd}\n`)
|
|
103
|
+
} else if (isWSL()) {
|
|
104
|
+
const cmd = `export ANTHROPIC_BASE_URL=http://localhost:${port} GEMINI_API_BASE_URL=http://localhost:${port} HTTPS_PROXY=http://localhost:${mitmPort} SSL_CERT_FILE=${bundlePath}`
|
|
105
|
+
console.log(`\n Run this to activate in the current terminal:\n`)
|
|
106
|
+
console.log(` ${cmd}\n`)
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
92
110
|
const HELP = `
|
|
93
111
|
Squeezr v${pkg.version} — AI context compressor for Claude Code, Codex, Aider, Gemini CLI and Ollama
|
|
94
112
|
|
|
@@ -177,6 +195,17 @@ async function startDaemon() {
|
|
|
177
195
|
console.log(` HTTP proxy (Claude/Aider/Gemini): http://localhost:${port}`)
|
|
178
196
|
console.log(` MITM proxy (Codex): http://localhost:${mitmPort}`)
|
|
179
197
|
console.log(` Logs: ${logFile}`)
|
|
198
|
+
|
|
199
|
+
// Restore HTTPS_PROXY in Windows registry now that the proxy is alive
|
|
200
|
+
if (process.platform === 'win32') {
|
|
201
|
+
try { execSync(`setx HTTPS_PROXY "http://localhost:${mitmPort}"`, { stdio: 'pipe' }) } catch {}
|
|
202
|
+
} else if (isWSL()) {
|
|
203
|
+
try {
|
|
204
|
+
const setxExe = '/mnt/c/Windows/System32/setx.exe'
|
|
205
|
+
if (fs.existsSync(setxExe)) execSync(`"${setxExe}" HTTPS_PROXY "http://localhost:${mitmPort}"`, { stdio: 'pipe' })
|
|
206
|
+
} catch {}
|
|
207
|
+
}
|
|
208
|
+
printEnvRefreshHint(port, mitmPort)
|
|
180
209
|
}
|
|
181
210
|
|
|
182
211
|
function showLogs() {
|
|
@@ -232,6 +261,16 @@ function stopProxy() {
|
|
|
232
261
|
}
|
|
233
262
|
} catch {}
|
|
234
263
|
}
|
|
264
|
+
// Clear HTTPS_PROXY so npm and other tools don't try to use the dead proxy
|
|
265
|
+
if (process.platform === 'win32') {
|
|
266
|
+
try { execSync('setx HTTPS_PROXY ""', { stdio: 'pipe' }) } catch {}
|
|
267
|
+
} else if (isWSL()) {
|
|
268
|
+
try {
|
|
269
|
+
const setxExe = '/mnt/c/Windows/System32/setx.exe'
|
|
270
|
+
if (fs.existsSync(setxExe)) execSync(`"${setxExe}" HTTPS_PROXY ""`, { stdio: 'pipe' })
|
|
271
|
+
} catch {}
|
|
272
|
+
}
|
|
273
|
+
|
|
235
274
|
if (killed) {
|
|
236
275
|
console.log(`Squeezr stopped`)
|
|
237
276
|
console.log(` HTTP proxy (Claude/Aider/Gemini): http://localhost:${port}`)
|
|
@@ -657,12 +696,10 @@ Done!
|
|
|
657
696
|
MITM proxy on http://localhost:${mitmPort} (Codex TLS interception)
|
|
658
697
|
All CLIs (Claude Code, Codex, Aider, Gemini, Ollama) are configured.
|
|
659
698
|
|
|
660
|
-
Restart your terminal once for the env vars to take effect.
|
|
661
|
-
After that, everything is automatic — Squeezr starts silently on every login.
|
|
662
|
-
|
|
663
699
|
squeezr status — check it's running
|
|
664
700
|
squeezr gain — see token savings
|
|
665
701
|
`)
|
|
702
|
+
printEnvRefreshHint(port, mitmPort)
|
|
666
703
|
}
|
|
667
704
|
}
|
|
668
705
|
|
|
@@ -979,26 +1016,21 @@ WantedBy=default.target
|
|
|
979
1016
|
console.log(` [ok] Squeezr started in background (pid ${child.pid})`)
|
|
980
1017
|
console.log(` [ok] Logs → ${logFile}`)
|
|
981
1018
|
|
|
982
|
-
|
|
983
|
-
|
|
1019
|
+
const setupPort = getPort()
|
|
1020
|
+
const setupMitmPort = getMitmPort(setupPort)
|
|
984
1021
|
console.log(`
|
|
985
1022
|
Done!
|
|
986
1023
|
|
|
987
|
-
Squeezr is running on http://localhost
|
|
1024
|
+
Squeezr is running on http://localhost:${setupPort}
|
|
988
1025
|
All CLIs (Claude Code, Codex, Aider, Gemini, Ollama) are configured.
|
|
989
1026
|
|
|
990
1027
|
Windows env vars are set (effective in new terminals immediately).
|
|
991
1028
|
WSL env vars added to ${profile}.
|
|
992
1029
|
|
|
993
|
-
To activate in THIS terminal: source ${profile}
|
|
994
|
-
|
|
995
|
-
⚠️ IMPORTANT: Close this terminal and open a new one so the
|
|
996
|
-
environment variables take effect. Otherwise tools like
|
|
997
|
-
Claude Code may fail with 502 errors.
|
|
998
|
-
|
|
999
1030
|
squeezr status — check it's running
|
|
1000
1031
|
squeezr gain — see token savings
|
|
1001
1032
|
`)
|
|
1033
|
+
printEnvRefreshHint(setupPort, setupMitmPort)
|
|
1002
1034
|
}
|
|
1003
1035
|
|
|
1004
1036
|
// ── CLI router ────────────────────────────────────────────────────────────────
|
|
@@ -1086,11 +1118,16 @@ switch (command) {
|
|
|
1086
1118
|
console.log(` MITM proxy (Codex): http://localhost:${startMitmPort}`)
|
|
1087
1119
|
console.log(` Logs: ${logFile}`)
|
|
1088
1120
|
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1121
|
+
// Restore HTTPS_PROXY now that the proxy is alive
|
|
1122
|
+
if (process.platform === 'win32') {
|
|
1123
|
+
try { execSync(`setx HTTPS_PROXY "http://localhost:${startMitmPort}"`, { stdio: 'pipe' }) } catch {}
|
|
1124
|
+
} else if (isWSL()) {
|
|
1125
|
+
try {
|
|
1126
|
+
const setxExe = '/mnt/c/Windows/System32/setx.exe'
|
|
1127
|
+
if (fs.existsSync(setxExe)) execSync(`"${setxExe}" HTTPS_PROXY "http://localhost:${startMitmPort}"`, { stdio: 'pipe' })
|
|
1128
|
+
} catch {}
|
|
1093
1129
|
}
|
|
1130
|
+
printEnvRefreshHint(startPort, startMitmPort)
|
|
1094
1131
|
})()
|
|
1095
1132
|
break
|
|
1096
1133
|
case 'stop':
|
package/package.json
CHANGED