trimprompt 1.0.31 → 1.0.33

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/proxy-daemon.js DELETED
@@ -1,382 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
- Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.getProxyPort = getProxyPort;
37
- exports.isProxyRunning = isProxyRunning;
38
- exports.startProxyDaemon = startProxyDaemon;
39
- exports.stopProxyDaemon = stopProxyDaemon;
40
- exports.enableAutostart = enableAutostart;
41
- exports.disableAutostart = disableAutostart;
42
- exports.setAnthropicBaseUrl = setAnthropicBaseUrl;
43
- exports.removeAnthropicBaseUrl = removeAnthropicBaseUrl;
44
- const fs = __importStar(require("fs"));
45
- const path = __importStar(require("path"));
46
- const os = __importStar(require("os"));
47
- const child_process_1 = require("child_process");
48
- const baseDir = path.join(os.homedir(), '.trimprompt');
49
- const pidFile = path.join(baseDir, 'proxy.pid');
50
- const portFile = path.join(baseDir, 'proxy.port');
51
- const DEFAULT_PORT = 8080;
52
- function ensureDir() {
53
- if (!fs.existsSync(baseDir))
54
- fs.mkdirSync(baseDir, { recursive: true });
55
- }
56
- function getProxyPort() {
57
- try {
58
- if (fs.existsSync(portFile))
59
- return parseInt(fs.readFileSync(portFile, 'utf8').trim()) || DEFAULT_PORT;
60
- }
61
- catch { }
62
- return DEFAULT_PORT;
63
- }
64
- function isProxyRunning() {
65
- const port = getProxyPort();
66
- try {
67
- if (!fs.existsSync(pidFile))
68
- return { running: false, pid: null, port };
69
- const pid = parseInt(fs.readFileSync(pidFile, 'utf8').trim());
70
- if (!pid)
71
- return { running: false, pid: null, port };
72
- if (process.platform === 'win32') {
73
- const result = (0, child_process_1.execSync)(`tasklist /FI "PID eq ${pid}" /FO CSV /NH`, { encoding: 'utf8', timeout: 5000 });
74
- const pidStr = `"${pid}"`;
75
- if (result.split('\n').some(line => line.includes(pidStr)))
76
- return { running: true, pid, port };
77
- }
78
- else {
79
- process.kill(pid, 0);
80
- return { running: true, pid, port };
81
- }
82
- }
83
- catch { }
84
- try {
85
- fs.unlinkSync(pidFile);
86
- }
87
- catch { }
88
- return { running: false, pid: null, port };
89
- }
90
- function startProxyDaemon(port) {
91
- const status = isProxyRunning();
92
- if (status.running) {
93
- return { success: true, pid: status.pid, port: status.port, message: `Proxy already running (pid ${status.pid}) on port ${status.port}` };
94
- }
95
- ensureDir();
96
- const usePort = port || DEFAULT_PORT;
97
- try {
98
- const cliPath = path.join(__dirname, 'cli.js');
99
- if (!fs.existsSync(cliPath)) {
100
- return { success: false, pid: null, port: usePort, message: `CLI not found at ${cliPath}` };
101
- }
102
- const child = (0, child_process_1.spawn)(process.execPath, [cliPath, 'proxy', '--port', String(usePort)], {
103
- detached: true,
104
- stdio: 'ignore',
105
- env: { ...process.env, TRIMPROMPT_DISABLED: '1' },
106
- });
107
- child.unref();
108
- if (child.pid) {
109
- fs.writeFileSync(pidFile, String(child.pid), 'utf8');
110
- fs.writeFileSync(portFile, String(usePort), 'utf8');
111
- return { success: true, pid: child.pid, port: usePort, message: `Proxy started (pid ${child.pid}) on port ${usePort}` };
112
- }
113
- return { success: false, pid: null, port: usePort, message: 'Spawn returned no PID' };
114
- }
115
- catch (err) {
116
- return { success: false, pid: null, port: usePort, message: `Failed to start proxy: ${err.message}` };
117
- }
118
- }
119
- function stopProxyDaemon() {
120
- const status = isProxyRunning();
121
- if (!status.running || !status.pid) {
122
- return { success: true, message: 'Proxy is not running' };
123
- }
124
- try {
125
- if (process.platform === 'win32') {
126
- (0, child_process_1.execSync)(`taskkill /PID ${status.pid} /F`, { timeout: 5000 });
127
- }
128
- else {
129
- process.kill(status.pid, 'SIGTERM');
130
- }
131
- }
132
- catch { }
133
- try {
134
- fs.unlinkSync(pidFile);
135
- }
136
- catch { }
137
- return { success: true, message: `Proxy stopped (pid ${status.pid})` };
138
- }
139
- function setClaudeCodeSettings(url) {
140
- const claudeDir = path.join(os.homedir(), '.claude');
141
- const settingsPath = path.join(claudeDir, 'settings.json');
142
- try {
143
- if (!fs.existsSync(claudeDir))
144
- fs.mkdirSync(claudeDir, { recursive: true });
145
- let settings = {};
146
- if (fs.existsSync(settingsPath)) {
147
- try {
148
- settings = JSON.parse(fs.readFileSync(settingsPath, 'utf8'));
149
- }
150
- catch { }
151
- }
152
- if (!settings.env)
153
- settings.env = {};
154
- settings.env.ANTHROPIC_BASE_URL = url;
155
- fs.writeFileSync(settingsPath, JSON.stringify(settings, null, 2), 'utf8');
156
- }
157
- catch { }
158
- }
159
- function removeClaudeCodeSettings() {
160
- const settingsPath = path.join(os.homedir(), '.claude', 'settings.json');
161
- try {
162
- if (fs.existsSync(settingsPath)) {
163
- const settings = JSON.parse(fs.readFileSync(settingsPath, 'utf8'));
164
- if (settings.env && settings.env.ANTHROPIC_BASE_URL) {
165
- delete settings.env.ANTHROPIC_BASE_URL;
166
- if (Object.keys(settings.env).length === 0)
167
- delete settings.env;
168
- fs.writeFileSync(settingsPath, JSON.stringify(settings, null, 2), 'utf8');
169
- }
170
- }
171
- }
172
- catch { }
173
- }
174
- const RUN_KEY = 'HKCU:\\Software\\Microsoft\\Windows\\CurrentVersion\\Run';
175
- const RUN_VALUE_NAME = 'TrimPromptProxy';
176
- const vbsLauncher = path.join(baseDir, 'proxy-autostart.vbs');
177
- function enableAutostart() {
178
- ensureDir();
179
- const cliPath = path.join(__dirname, 'cli.js');
180
- if (process.platform === 'win32') {
181
- try {
182
- const vbs = 'Set WshShell = CreateObject("WScript.Shell")\r\n' +
183
- 'cmd = Chr(34) & "' + process.execPath.replace(/"/g, '""') + '" & Chr(34) & " " & Chr(34) & "' +
184
- cliPath.replace(/"/g, '""') + '" & Chr(34) & " proxy install"\r\n' +
185
- 'WshShell.Run cmd, 0, False\r\n';
186
- fs.writeFileSync(vbsLauncher, vbs, 'utf8');
187
- const runValue = `wscript.exe "${vbsLauncher}"`;
188
- const psSet = `New-Item -Path '${RUN_KEY}' -Force | Out-Null; Set-ItemProperty -Path '${RUN_KEY}' -Name '${RUN_VALUE_NAME}' -Value '${runValue.replace(/'/g, "''")}'`;
189
- (0, child_process_1.execSync)(`powershell.exe -NoProfile -Command "${psSet.replace(/"/g, '\\"')}"`, { stdio: 'ignore', timeout: 8000 });
190
- }
191
- catch { }
192
- return;
193
- }
194
- if (process.platform === 'darwin') {
195
- try {
196
- const agentsDir = path.join(os.homedir(), 'Library', 'LaunchAgents');
197
- if (!fs.existsSync(agentsDir))
198
- fs.mkdirSync(agentsDir, { recursive: true });
199
- const plistPath = path.join(agentsDir, 'ai.trimprompt.proxy.plist');
200
- const plist = '<?xml version="1.0" encoding="UTF-8"?>\n' +
201
- '<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">\n' +
202
- '<plist version="1.0"><dict>\n' +
203
- ' <key>Label</key><string>ai.trimprompt.proxy</string>\n' +
204
- ' <key>ProgramArguments</key><array>' +
205
- `<string>${process.execPath}</string><string>${cliPath}</string><string>proxy</string><string>start</string>` +
206
- '</array>\n' +
207
- ' <key>RunAtLoad</key><true/>\n' +
208
- ' <key>KeepAlive</key><true/>\n' +
209
- '</dict></plist>\n';
210
- fs.writeFileSync(plistPath, plist, 'utf8');
211
- try {
212
- (0, child_process_1.execSync)(`launchctl unload "${plistPath}"`, { stdio: 'ignore', timeout: 5000 });
213
- }
214
- catch { }
215
- (0, child_process_1.execSync)(`launchctl load "${plistPath}"`, { stdio: 'ignore', timeout: 5000 });
216
- }
217
- catch { }
218
- return;
219
- }
220
- try {
221
- const autostartDir = path.join(os.homedir(), '.config', 'autostart');
222
- if (!fs.existsSync(autostartDir))
223
- fs.mkdirSync(autostartDir, { recursive: true });
224
- const desktopPath = path.join(autostartDir, 'trimprompt-proxy.desktop');
225
- const entry = '[Desktop Entry]\n' +
226
- 'Type=Application\n' +
227
- 'Name=TrimPrompt Proxy\n' +
228
- `Exec=${process.execPath} ${cliPath} proxy install\n` +
229
- 'X-GNOME-Autostart-enabled=true\n' +
230
- 'NoDisplay=true\n';
231
- fs.writeFileSync(desktopPath, entry, 'utf8');
232
- }
233
- catch { }
234
- }
235
- function disableAutostart() {
236
- if (process.platform === 'win32') {
237
- try {
238
- const psRemove = `Remove-ItemProperty -Path '${RUN_KEY}' -Name '${RUN_VALUE_NAME}' -ErrorAction SilentlyContinue`;
239
- (0, child_process_1.execSync)(`powershell.exe -NoProfile -Command "${psRemove.replace(/"/g, '\\"')}"`, { stdio: 'ignore', timeout: 8000 });
240
- }
241
- catch { }
242
- try {
243
- if (fs.existsSync(vbsLauncher))
244
- fs.unlinkSync(vbsLauncher);
245
- }
246
- catch { }
247
- return;
248
- }
249
- if (process.platform === 'darwin') {
250
- try {
251
- const plistPath = path.join(os.homedir(), 'Library', 'LaunchAgents', 'ai.trimprompt.proxy.plist');
252
- try {
253
- (0, child_process_1.execSync)(`launchctl unload "${plistPath}"`, { stdio: 'ignore', timeout: 5000 });
254
- }
255
- catch { }
256
- if (fs.existsSync(plistPath))
257
- fs.unlinkSync(plistPath);
258
- }
259
- catch { }
260
- return;
261
- }
262
- try {
263
- const desktopPath = path.join(os.homedir(), '.config', 'autostart', 'trimprompt-proxy.desktop');
264
- if (fs.existsSync(desktopPath))
265
- fs.unlinkSync(desktopPath);
266
- }
267
- catch { }
268
- }
269
- function setAnthropicBaseUrl(port) {
270
- const url = `http://127.0.0.1:${port}`;
271
- const openAiUrl = `http://127.0.0.1:${port}/v1`;
272
- setClaudeCodeSettings(url);
273
- if (process.platform === 'win32') {
274
- try {
275
- (0, child_process_1.execSync)(`setx ANTHROPIC_BASE_URL "${url}"`, { timeout: 5000 });
276
- (0, child_process_1.execSync)(`setx OPENAI_BASE_URL "${openAiUrl}"`, { timeout: 5000 });
277
- (0, child_process_1.execSync)(`setx GEMINI_BASE_URL "${openAiUrl}"`, { timeout: 5000 });
278
- (0, child_process_1.execSync)(`setx GOOGLE_AI_BASE_URL "${openAiUrl}"`, { timeout: 5000 });
279
- }
280
- catch { }
281
- }
282
- const homeDir = os.homedir();
283
- const marker = '# TrimPrompt API Proxy';
284
- const line1 = `export ANTHROPIC_BASE_URL="${url}" ${marker}`;
285
- const line2 = `export OPENAI_BASE_URL="${openAiUrl}" ${marker}`;
286
- const line3 = `export GEMINI_BASE_URL="${openAiUrl}" ${marker}`;
287
- const line4 = `export GOOGLE_AI_BASE_URL="${openAiUrl}" ${marker}`;
288
- const profiles = [
289
- path.join(homeDir, '.bashrc'),
290
- path.join(homeDir, '.zshrc'),
291
- path.join(homeDir, '.bash_profile'),
292
- ];
293
- for (const profile of profiles) {
294
- try {
295
- if (fs.existsSync(profile)) {
296
- let content = fs.readFileSync(profile, 'utf8');
297
- if (content.includes(marker)) {
298
- content = content.replace(new RegExp(`.*${marker.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}.*\\n?`, 'g'), '');
299
- }
300
- content = content.trimEnd() + '\n' + line1 + '\n' + line2 + '\n' + line3 + '\n' + line4 + '\n';
301
- fs.writeFileSync(profile, content, 'utf8');
302
- }
303
- }
304
- catch { }
305
- }
306
- try {
307
- const psProfilePaths = [];
308
- for (const shell of ['powershell', 'pwsh']) {
309
- try {
310
- const p = (0, child_process_1.execSync)(`${shell} -NoProfile -Command "$PROFILE"`, { encoding: 'utf8', timeout: 3000, stdio: ['pipe', 'pipe', 'ignore'] }).trim();
311
- if (p && !psProfilePaths.includes(p))
312
- psProfilePaths.push(p);
313
- }
314
- catch { }
315
- }
316
- const psMarker = '# TrimPrompt API Proxy';
317
- const psLine1 = `$env:ANTHROPIC_BASE_URL = "${url}" ${psMarker}`;
318
- const psLine2 = `$env:OPENAI_BASE_URL = "${openAiUrl}" ${psMarker}`;
319
- const psLine3 = `$env:GEMINI_BASE_URL = "${openAiUrl}" ${psMarker}`;
320
- const psLine4 = `$env:GOOGLE_AI_BASE_URL = "${openAiUrl}" ${psMarker}`;
321
- for (const pp of psProfilePaths) {
322
- try {
323
- const dir = path.dirname(pp);
324
- if (!fs.existsSync(dir))
325
- fs.mkdirSync(dir, { recursive: true });
326
- let content = fs.existsSync(pp) ? fs.readFileSync(pp, 'utf8') : '';
327
- if (content.includes(psMarker)) {
328
- content = content.replace(new RegExp(`.*${psMarker.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}.*\\r?\\n?`, 'g'), '');
329
- }
330
- content = content.trimEnd() + '\n' + psLine1 + '\n' + psLine2 + '\n' + psLine3 + '\n' + psLine4 + '\n';
331
- fs.writeFileSync(pp, content, 'utf8');
332
- }
333
- catch { }
334
- }
335
- }
336
- catch { }
337
- }
338
- function removeAnthropicBaseUrl() {
339
- removeClaudeCodeSettings();
340
- if (process.platform === 'win32') {
341
- try {
342
- (0, child_process_1.execSync)('REG DELETE "HKCU\\Environment" /V ANTHROPIC_BASE_URL /F', { timeout: 5000 });
343
- }
344
- catch { }
345
- }
346
- const homeDir = os.homedir();
347
- const marker = '# TrimPrompt API Proxy';
348
- const profiles = [
349
- path.join(homeDir, '.bashrc'),
350
- path.join(homeDir, '.zshrc'),
351
- path.join(homeDir, '.bash_profile'),
352
- ];
353
- for (const profile of profiles) {
354
- try {
355
- if (fs.existsSync(profile)) {
356
- let content = fs.readFileSync(profile, 'utf8');
357
- if (content.includes(marker)) {
358
- content = content.replace(new RegExp(`.*${marker.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}.*\\r?\\n?`, 'g'), '');
359
- fs.writeFileSync(profile, content, 'utf8');
360
- }
361
- }
362
- }
363
- catch { }
364
- }
365
- try {
366
- for (const shell of ['powershell', 'pwsh']) {
367
- try {
368
- const p = (0, child_process_1.execSync)(`${shell} -NoProfile -Command "$PROFILE"`, { encoding: 'utf8', timeout: 3000, stdio: ['pipe', 'pipe', 'ignore'] }).trim();
369
- if (p && fs.existsSync(p)) {
370
- let content = fs.readFileSync(p, 'utf8');
371
- const psMarker = '# TrimPrompt API Proxy';
372
- if (content.includes(psMarker)) {
373
- content = content.replace(new RegExp(`.*${psMarker.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}.*\\r?\\n?`, 'g'), '');
374
- fs.writeFileSync(p, content, 'utf8');
375
- }
376
- }
377
- }
378
- catch { }
379
- }
380
- }
381
- catch { }
382
- }
@@ -1 +0,0 @@
1
- 'use strict';const a0_0x367e53=a0_0x594e;(function(_0x15013b,_0x3bf6e7){const _0x46df42=a0_0x594e,_0x49a746=_0x15013b();while(!![]){try{const _0x16b4bb=-parseInt(_0x46df42(0x11d))/0x1+-parseInt(_0x46df42(0x14e))/0x2+-parseInt(_0x46df42(0x120))/0x3*(parseInt(_0x46df42(0x129))/0x4)+parseInt(_0x46df42(0x169))/0x5*(parseInt(_0x46df42(0x130))/0x6)+-parseInt(_0x46df42(0x124))/0x7*(-parseInt(_0x46df42(0x118))/0x8)+parseInt(_0x46df42(0x134))/0x9*(-parseInt(_0x46df42(0x147))/0xa)+-parseInt(_0x46df42(0x167))/0xb*(-parseInt(_0x46df42(0x140))/0xc);if(_0x16b4bb===_0x3bf6e7)break;else _0x49a746['push'](_0x49a746['shift']());}catch(_0x4de4db){_0x49a746['push'](_0x49a746['shift']());}}}(a0_0x5ba6,0x9719a));function a0_0x594e(_0x4eec54,_0x10e92b){const _0x5ba639=a0_0x5ba6();return a0_0x594e=function(_0x594e0a,_0x512093){_0x594e0a=_0x594e0a-0x113;let _0x1d26c5=_0x5ba639[_0x594e0a];return _0x1d26c5;},a0_0x594e(_0x4eec54,_0x10e92b);}var __createBinding=this&&this[a0_0x367e53(0x15b)]||(Object[a0_0x367e53(0x11c)]?function(_0x2df8bc,_0x2d0741,_0x5158d2,_0x3def0e){const _0x1ca4e2=a0_0x367e53;if(_0x3def0e===undefined)_0x3def0e=_0x5158d2;var _0x4a8c5d=Object[_0x1ca4e2(0x150)](_0x2d0741,_0x5158d2);(!_0x4a8c5d||('get'in _0x4a8c5d?!_0x2d0741[_0x1ca4e2(0x14c)]:_0x4a8c5d[_0x1ca4e2(0x131)]||_0x4a8c5d[_0x1ca4e2(0x151)]))&&(_0x4a8c5d={'enumerable':!![],'get':function(){return _0x2d0741[_0x5158d2];}}),Object[_0x1ca4e2(0x123)](_0x2df8bc,_0x3def0e,_0x4a8c5d);}:function(_0x39d889,_0x5f10d2,_0x5d08f7,_0x4ba8d8){if(_0x4ba8d8===undefined)_0x4ba8d8=_0x5d08f7;_0x39d889[_0x4ba8d8]=_0x5f10d2[_0x5d08f7];}),__setModuleDefault=this&&this['__setModuleDefault']||(Object[a0_0x367e53(0x11c)]?function(_0x4781b7,_0x4c71b6){const _0x2bc508=a0_0x367e53;Object['defineProperty'](_0x4781b7,_0x2bc508(0x14a),{'enumerable':!![],'value':_0x4c71b6});}:function(_0x1585d2,_0xf7acaf){const _0xb85d51=a0_0x367e53;_0x1585d2[_0xb85d51(0x14a)]=_0xf7acaf;}),__importStar=this&&this[a0_0x367e53(0x145)]||(function(){var _0x11b664=function(_0x288ad2){const _0x11918f=a0_0x594e;return _0x11b664=Object[_0x11918f(0x133)]||function(_0x23c44b){const _0x25fea4=_0x11918f;var _0xf5aabb=[];for(var _0x5b3648 in _0x23c44b)if(Object['prototype'][_0x25fea4(0x166)][_0x25fea4(0x136)](_0x23c44b,_0x5b3648))_0xf5aabb[_0xf5aabb[_0x25fea4(0x14d)]]=_0x5b3648;return _0xf5aabb;},_0x11b664(_0x288ad2);};return function(_0x278e7d){const _0x4a5147=a0_0x594e;if(_0x278e7d&&_0x278e7d[_0x4a5147(0x14c)])return _0x278e7d;var _0x1f3571={};if(_0x278e7d!=null){for(var _0x3dbbe9=_0x11b664(_0x278e7d),_0x527a07=0x0;_0x527a07<_0x3dbbe9['length'];_0x527a07++)if(_0x3dbbe9[_0x527a07]!==_0x4a5147(0x14a))__createBinding(_0x1f3571,_0x278e7d,_0x3dbbe9[_0x527a07]);}return __setModuleDefault(_0x1f3571,_0x278e7d),_0x1f3571;};}());Object[a0_0x367e53(0x123)](exports,a0_0x367e53(0x14c),{'value':!![]}),exports[a0_0x367e53(0x162)]=generateCaCertificate,exports['installSystemCaCert']=installSystemCaCert,exports['enableSystemProxy']=enableSystemProxy,exports[a0_0x367e53(0x12a)]=disableSystemProxy,exports['startTrafficInterceptor']=startTrafficInterceptor;const fs=__importStar(require('fs')),path=__importStar(require(a0_0x367e53(0x128))),os=__importStar(require('os')),net=__importStar(require('net')),http=__importStar(require(a0_0x367e53(0x115))),crypto=__importStar(require('crypto')),child_process_1=require(a0_0x367e53(0x121)),baseDir=path[a0_0x367e53(0x13c)](os[a0_0x367e53(0x144)](),'.trimprompt'),caCertPath=path[a0_0x367e53(0x13c)](baseDir,'ca.crt'),caKeyPath=path['join'](baseDir,'ca.key');function ensureBaseDir(){const _0x7b4cb1=a0_0x367e53;if(!fs['existsSync'](baseDir))fs[_0x7b4cb1(0x13a)](baseDir,{'recursive':!![]});}function a0_0x5ba6(){const _0x4fee72=['http','[TrimPrompt\x20Traffic\x20Engine]\x20Port\x20','spki','814328DdyTfe','\x20is\x20occupied\x20by\x20existing\x20daemon.\x20Freeing\x20port...','connect','HTTP/1.1\x20200\x20Connection\x20Established\x0d\x0a\x0d\x0a','create','868758fuErSA','pipe','write','411SDoNUX','child_process','win32','defineProperty','7fcIxbz','\x20/F','readFileSync','split','path','644urhYYm','disableSystemProxy','ignore','\x27\x20-Name\x20\x27ProxyEnable\x27\x20-Value\x200','application/json','trim','url','1563522WhqwRa','writable','createServer','getOwnPropertyNames','227943KaFOPC','\x20|\x20findstr\x20LISTENING','call','\x20is\x20in\x20use.\x20Run\x20\x27trim\x20proxy\x20stop\x27\x20first.','generateKeyPairSync','taskkill\x20/PID\x20','mkdirSync','.\x20Retrying\x20listen...','join','sign','toString','replace','2129532MDLSbf','pid','Set-ItemProperty\x20-Path\x20\x27','sha256','homedir','__importStar','writeFileSync','430YYgchG','createPrivateKey','TrimPrompt\x20Traffic\x20Interceptor\x20Active','default','error','__esModule','length','1183526MsBNac','end','getOwnPropertyDescriptor','configurable','HKCU:\x5cSoftware\x5cMicrosoft\x5cWindows\x5cCurrentVersion\x5cInternet\x20Settings','execSync','certutil\x20-addstore\x20-f\x20\x22Root\x22\x20\x22','setSubject','rsa','\x27\x20-Name\x20\x27ProxyEnable\x27\x20-Value\x201;\x20Set-ItemProperty\x20-Path\x20\x27','powershell.exe\x20-NoProfile\x20-Command\x20\x22','platform','export','__createBinding','127.0.0.1','netstat\x20-ano\x20|\x20findstr\x20:','writeHead','[TrimPrompt\x20Traffic\x20Engine]\x20Server\x20error:\x20','createCertificate','127.0.0.1:','generateCaCertificate','\x27\x20-Name\x20\x27ProxyServer\x27\x20-Value\x20\x27','existsSync','listen','hasOwnProperty','143Uibskd','pem','15lalrYW','utf8','log','setIssuer','request'];a0_0x5ba6=function(){return _0x4fee72;};return a0_0x5ba6();}function generateCaCertificate(){const _0x3d5879=a0_0x367e53;ensureBaseDir();if(fs['existsSync'](caCertPath)&&fs[_0x3d5879(0x164)](caKeyPath))return{'cert':fs[_0x3d5879(0x126)](caCertPath,_0x3d5879(0x16a)),'key':fs['readFileSync'](caKeyPath,_0x3d5879(0x16a))};const {privateKey:_0x4376fe,publicKey:_0x10a529}=crypto[_0x3d5879(0x138)](_0x3d5879(0x156),{'modulusLength':0x800,'publicKeyEncoding':{'type':_0x3d5879(0x117),'format':_0x3d5879(0x168)},'privateKeyEncoding':{'type':'pkcs8','format':_0x3d5879(0x168)}}),_0x3fd0cb=crypto['createCertificate']?crypto[_0x3d5879(0x160)]():null;let _0x1241f1='';return _0x3fd0cb?(_0x3fd0cb[_0x3d5879(0x155)]('/CN=TrimPrompt\x20Root\x20CA/O=TrimPrompt\x20AI/OU=Security'),_0x3fd0cb[_0x3d5879(0x113)]('/CN=TrimPrompt\x20Root\x20CA/O=TrimPrompt\x20AI/OU=Security'),_0x3fd0cb['setPublicKey'](crypto['createPublicKey'](_0x10a529)),_0x3fd0cb[_0x3d5879(0x13d)](crypto[_0x3d5879(0x148)](_0x4376fe),_0x3d5879(0x143)),_0x1241f1=_0x3fd0cb[_0x3d5879(0x15a)](_0x3d5879(0x168))[_0x3d5879(0x13e)]()):_0x1241f1=_0x10a529,fs[_0x3d5879(0x146)](caKeyPath,_0x4376fe,'utf8'),fs[_0x3d5879(0x146)](caCertPath,_0x1241f1,'utf8'),{'cert':_0x1241f1,'key':_0x4376fe};}function installSystemCaCert(){const _0x7a57ff=a0_0x367e53;if(process['platform']!==_0x7a57ff(0x122))return![];try{return generateCaCertificate(),(0x0,child_process_1[_0x7a57ff(0x153)])(_0x7a57ff(0x154)+caCertPath+'\x22',{'stdio':_0x7a57ff(0x12b),'timeout':0x1f40}),!![];}catch{return![];}}function enableSystemProxy(_0x423c84=0x1f90){const _0x31df85=a0_0x367e53;if(process[_0x31df85(0x159)]!=='win32')return![];try{const _0x26fdc5=_0x31df85(0x152),_0x223eab=_0x31df85(0x161)+_0x423c84,_0x1ab1aa=_0x31df85(0x142)+_0x26fdc5+_0x31df85(0x157)+_0x26fdc5+_0x31df85(0x163)+_0x223eab+'\x27';return(0x0,child_process_1[_0x31df85(0x153)])(_0x31df85(0x158)+_0x1ab1aa[_0x31df85(0x13f)](/"/g,'\x5c\x22')+'\x22',{'stdio':'ignore','timeout':0x1f40}),!![];}catch{return![];}}function disableSystemProxy(){const _0x36124e=a0_0x367e53;if(process[_0x36124e(0x159)]!==_0x36124e(0x122))return![];try{const _0x48384e=_0x36124e(0x152),_0x298aa5=_0x36124e(0x142)+_0x48384e+_0x36124e(0x12c);return(0x0,child_process_1[_0x36124e(0x153)])('powershell.exe\x20-NoProfile\x20-Command\x20\x22'+_0x298aa5['replace'](/"/g,'\x5c\x22')+'\x22',{'stdio':_0x36124e(0x12b),'timeout':0x1f40}),!![];}catch{return![];}}function startTrafficInterceptor(_0x3926ff=0x1f90){const _0x4b8b98=a0_0x367e53,_0x327b32=http[_0x4b8b98(0x132)]();_0x327b32['on'](_0x4b8b98(0x14b),_0x5295fa=>{const _0x4190fc=_0x4b8b98;if(_0x5295fa['code']==='EADDRINUSE'){console[_0x4190fc(0x16b)](_0x4190fc(0x116)+_0x3926ff+_0x4190fc(0x119));try{if(process[_0x4190fc(0x159)]===_0x4190fc(0x122)){const _0x45622b=(0x0,child_process_1[_0x4190fc(0x153)])(_0x4190fc(0x15d)+_0x3926ff+_0x4190fc(0x135),{'encoding':_0x4190fc(0x16a),'timeout':0xbb8}),_0x2d2705=_0x45622b[_0x4190fc(0x12e)]()[_0x4190fc(0x127)](/\s+/),_0x2f9541=_0x2d2705[_0x2d2705['length']-0x1];if(_0x2f9541&&_0x2f9541!==String(process[_0x4190fc(0x141)])){(0x0,child_process_1[_0x4190fc(0x153)])(_0x4190fc(0x139)+_0x2f9541+_0x4190fc(0x125),{'stdio':_0x4190fc(0x12b),'timeout':0xbb8}),console[_0x4190fc(0x16b)]('[TrimPrompt\x20Traffic\x20Engine]\x20Terminated\x20background\x20process\x20'+_0x2f9541+_0x4190fc(0x13b)),setTimeout(()=>_0x327b32[_0x4190fc(0x165)](_0x3926ff,'127.0.0.1'),0x1f4);return;}}}catch{}console[_0x4190fc(0x14b)](_0x4190fc(0x116)+_0x3926ff+_0x4190fc(0x137));}else console[_0x4190fc(0x14b)](_0x4190fc(0x15f)+_0x5295fa['message']);}),_0x327b32['on'](_0x4b8b98(0x114),(_0x19c355,_0x2a2006)=>{const _0xd0e660=_0x4b8b98;_0x2a2006[_0xd0e660(0x15e)](0xc8,{'Content-Type':_0xd0e660(0x12d)}),_0x2a2006[_0xd0e660(0x14f)](JSON['stringify']({'status':_0xd0e660(0x149),'url':_0x19c355[_0xd0e660(0x12f)]}));}),_0x327b32['on']('connect',(_0x21b0d0,_0x5881e7,_0x90ac19)=>{const _0x1608ce=_0x4b8b98,[_0x207ee0,_0x42e0ad]=(_0x21b0d0['url']||'')[_0x1608ce(0x127)](':'),_0x3ccab3=parseInt(_0x42e0ad,0xa)||0x1bb,_0x386eeb=net[_0x1608ce(0x11a)](_0x3ccab3,_0x207ee0,()=>{const _0x2fa034=_0x1608ce;_0x5881e7[_0x2fa034(0x11f)](_0x2fa034(0x11b)),_0x386eeb[_0x2fa034(0x11f)](_0x90ac19),_0x386eeb[_0x2fa034(0x11e)](_0x5881e7),_0x5881e7[_0x2fa034(0x11e)](_0x386eeb);});_0x386eeb['on'](_0x1608ce(0x14b),()=>{const _0x343b18=_0x1608ce;try{_0x5881e7[_0x343b18(0x14f)]();}catch{}}),_0x5881e7['on'](_0x1608ce(0x14b),()=>{const _0x45fc5a=_0x1608ce;try{_0x386eeb[_0x45fc5a(0x14f)]();}catch{}});}),_0x327b32[_0x4b8b98(0x165)](_0x3926ff,_0x4b8b98(0x15c),()=>{console['log']('[TrimPrompt\x20Traffic\x20Engine]\x20Live\x20Traffic\x20Interceptor\x20listening\x20on\x20127.0.0.1:'+_0x3926ff);});}