trimprompt 1.0.40 → 1.0.42

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/cli.js CHANGED
@@ -1,2 +1,494 @@
1
1
  #!/usr/bin/env node
2
- 'use strict';const a0_0x3525f1=a0_0x5bd7;(function(_0x42c58f,_0x4e29f0){const _0x3242f3=a0_0x5bd7,_0x38516b=_0x42c58f();while(!![]){try{const _0x59f9e9=parseInt(_0x3242f3(0x1a3))/0x1*(-parseInt(_0x3242f3(0x1b6))/0x2)+-parseInt(_0x3242f3(0x125))/0x3*(parseInt(_0x3242f3(0x15f))/0x4)+-parseInt(_0x3242f3(0x1d1))/0x5*(-parseInt(_0x3242f3(0x1b9))/0x6)+-parseInt(_0x3242f3(0x16f))/0x7*(parseInt(_0x3242f3(0x11e))/0x8)+-parseInt(_0x3242f3(0x1be))/0x9*(-parseInt(_0x3242f3(0x120))/0xa)+-parseInt(_0x3242f3(0x1e4))/0xb*(-parseInt(_0x3242f3(0x1b8))/0xc)+-parseInt(_0x3242f3(0x1d4))/0xd*(-parseInt(_0x3242f3(0x1ad))/0xe);if(_0x59f9e9===_0x4e29f0)break;else _0x38516b['push'](_0x38516b['shift']());}catch(_0x28a56d){_0x38516b['push'](_0x38516b['shift']());}}}(a0_0x5b17,0xa69fe));var __createBinding=this&&this[a0_0x3525f1(0x1df)]||(Object[a0_0x3525f1(0x181)]?function(_0x2b5198,_0x589227,_0x5579bb,_0x5c5a44){const _0xab1221=a0_0x3525f1;if(_0x5c5a44===undefined)_0x5c5a44=_0x5579bb;var _0x321912=Object[_0xab1221(0x111)](_0x589227,_0x5579bb);(!_0x321912||(_0xab1221(0x108)in _0x321912?!_0x589227[_0xab1221(0x10a)]:_0x321912[_0xab1221(0x141)]||_0x321912['configurable']))&&(_0x321912={'enumerable':!![],'get':function(){return _0x589227[_0x5579bb];}}),Object[_0xab1221(0x103)](_0x2b5198,_0x5c5a44,_0x321912);}:function(_0x27ef3c,_0x64bb1b,_0x505e1c,_0x16d6df){if(_0x16d6df===undefined)_0x16d6df=_0x505e1c;_0x27ef3c[_0x16d6df]=_0x64bb1b[_0x505e1c];}),__setModuleDefault=this&&this[a0_0x3525f1(0x178)]||(Object[a0_0x3525f1(0x181)]?function(_0x3b73e5,_0x565bf5){const _0x2f5702=a0_0x3525f1;Object[_0x2f5702(0x103)](_0x3b73e5,_0x2f5702(0x130),{'enumerable':!![],'value':_0x565bf5});}:function(_0x47383a,_0x5d95e4){_0x47383a['default']=_0x5d95e4;}),__importStar=this&&this[a0_0x3525f1(0x1c7)]||(function(){var _0x47e033=function(_0x413467){const _0x12b4f6=a0_0x5bd7;return _0x47e033=Object[_0x12b4f6(0x172)]||function(_0x106f8a){const _0x4856d6=_0x12b4f6;var _0x6956e5=[];for(var _0x183a1a in _0x106f8a)if(Object[_0x4856d6(0x128)][_0x4856d6(0x14a)][_0x4856d6(0x144)](_0x106f8a,_0x183a1a))_0x6956e5[_0x6956e5[_0x4856d6(0x187)]]=_0x183a1a;return _0x6956e5;},_0x47e033(_0x413467);};return function(_0x3ddd40){const _0x2c97f0=a0_0x5bd7;if(_0x3ddd40&&_0x3ddd40[_0x2c97f0(0x10a)])return _0x3ddd40;var _0x434ab4={};if(_0x3ddd40!=null){for(var _0x4a80a4=_0x47e033(_0x3ddd40),_0x23d68e=0x0;_0x23d68e<_0x4a80a4[_0x2c97f0(0x187)];_0x23d68e++)if(_0x4a80a4[_0x23d68e]!==_0x2c97f0(0x130))__createBinding(_0x434ab4,_0x3ddd40,_0x4a80a4[_0x23d68e]);}return __setModuleDefault(_0x434ab4,_0x3ddd40),_0x434ab4;};}());Object['defineProperty'](exports,a0_0x3525f1(0x10a),{'value':!![]});const commander_1=require('commander'),executor_1=require('./executor'),filters_1=require(a0_0x3525f1(0x100)),tracker_1=require(a0_0x3525f1(0x1b3)),cache_1=require(a0_0x3525f1(0x1bd)),shims_1=require(a0_0x3525f1(0xff)),dashboard_1=require('./dashboard'),program=new commander_1['Command']();function isDisabled(){const _0x36adeb=a0_0x3525f1;return process[_0x36adeb(0x169)][_0x36adeb(0x171)]==='1';}function adjustCommandArgs(_0x5b4bf6,_0x5ed1a7){const _0x50df48=a0_0x3525f1,_0x4cd0d3=_0x5b4bf6[_0x50df48(0x104)]();if(_0x4cd0d3===_0x50df48(0x196)||_0x4cd0d3==='yadm'){const _0x40ec31=_0x5ed1a7[0x0];if(_0x40ec31===_0x50df48(0x110)){const _0x14218c=_0x5ed1a7['slice'](0x1),_0x20612c=_0x14218c[_0x50df48(0x187)]===0x0||_0x14218c[_0x50df48(0x102)](_0x5a8beb=>{const _0x53463f=_0x50df48;return _0x5a8beb==='-b'||_0x5a8beb==='--branch'||_0x5a8beb===_0x53463f(0x174)||_0x5a8beb===_0x53463f(0x1c2)||_0x5a8beb==='-s'||_0x5a8beb===_0x53463f(0x1e3);});if(_0x20612c)return{'cmd':_0x5b4bf6,'args':[_0x50df48(0x110),_0x50df48(0x1c6),'-b']};}else{if(_0x40ec31===_0x50df48(0x17c)){const _0x4abdaa=_0x5ed1a7[_0x50df48(0x17b)](0x1),_0x511f09=_0x4abdaa[_0x50df48(0x1e6)](_0x5b9954=>_0x5b9954[_0x50df48(0x18b)]('--oneline')||_0x5b9954[_0x50df48(0x18b)](_0x50df48(0x176))||_0x5b9954[_0x50df48(0x18b)](_0x50df48(0x1d9))),_0x170707=_0x4abdaa[_0x50df48(0x1e6)](_0xc4c7f8=>_0xc4c7f8[_0x50df48(0x18b)]('-')&&/^\d+$/[_0x50df48(0x13d)](_0xc4c7f8[_0x50df48(0x17b)](0x1))||_0xc4c7f8==='-n'||_0xc4c7f8[_0x50df48(0x18b)]('--max-count')),_0x10a2b0=[..._0x5ed1a7];if(!_0x511f09){const _0x56c60b=_0x50df48(0x14f);_0x10a2b0[_0x50df48(0x146)](process['platform']===_0x50df48(0x12d)?'\x22'+_0x56c60b+'\x22':_0x56c60b);}!_0x170707&&(_0x511f09?_0x10a2b0['push'](_0x50df48(0x19e)):_0x10a2b0[_0x50df48(0x146)](_0x50df48(0x138)));const _0xb74eea=_0x4abdaa['some'](_0x1a3aa4=>_0x1a3aa4===_0x50df48(0x152)||_0x1a3aa4===_0x50df48(0x1a8)||_0x1a3aa4[_0x50df48(0x18b)]('--min-parents'));return!_0xb74eea&&!_0x170707&&_0x10a2b0['push'](_0x50df48(0x1a8)),{'cmd':_0x5b4bf6,'args':_0x10a2b0};}}}return{'cmd':_0x5b4bf6,'args':_0x5ed1a7};}function isMcpServerExecution(_0x56ff72,_0x811caa){const _0x26559e=a0_0x3525f1,_0x1ad079=_0x56ff72['toLowerCase'](),_0x13b2f8=_0x811caa['join']('\x20')[_0x26559e(0x104)]();if(_0x1ad079[_0x26559e(0x1e0)]('mcp')&&(_0x1ad079[_0x26559e(0x1e0)](_0x26559e(0x195))||_0x1ad079[_0x26559e(0x1e0)](_0x26559e(0x1ac))))return!![];if(_0x1ad079===_0x26559e(0x147)||_0x1ad079===_0x26559e(0x170)||_0x1ad079==='bun'||_0x1ad079==='npm'||_0x1ad079===_0x26559e(0x1b0)||_0x1ad079==='yarn'){if(_0x13b2f8['includes'](_0x26559e(0x12c))||_0x13b2f8[_0x26559e(0x1e0)](_0x26559e(0x1e1))||_0x13b2f8[_0x26559e(0x1e0)](_0x26559e(0x1e2))||_0x13b2f8['includes'](_0x26559e(0x1d6)))return!![];}if(_0x811caa['some'](_0xd80794=>{const _0x3a40a7=_0x26559e,_0x9b5bf2=_0xd80794[_0x3a40a7(0x104)]();return _0x9b5bf2[_0x3a40a7(0x1e0)](_0x3a40a7(0x1e2))||_0x9b5bf2[_0x3a40a7(0x1e0)](_0x3a40a7(0x1d6))||_0x9b5bf2['includes'](_0x3a40a7(0x12c))||_0x9b5bf2===_0x3a40a7(0x194)||_0x9b5bf2==='mcp';}))return!![];return![];}async function runProxy(_0x5863ad){const _0x20b4fa=a0_0x3525f1;if(_0x5863ad['length']===0x0){program[_0x20b4fa(0x188)]();return;}const _0x3e733c=_0x5863ad[0x0],_0x3e8bf9=_0x5863ad[_0x20b4fa(0x17b)](0x1),_0x45d3b6=_0x5863ad[_0x20b4fa(0x19b)]('\x20');if(isDisabled()){const _0x24b2b9=await(0x0,executor_1['executeCommand'])(_0x3e733c,_0x3e8bf9);process[_0x20b4fa(0x165)][_0x20b4fa(0x106)](_0x24b2b9['stdout']),process[_0x20b4fa(0xf7)][_0x20b4fa(0x106)](_0x24b2b9[_0x20b4fa(0xf7)]),process[_0x20b4fa(0x197)](_0x24b2b9[_0x20b4fa(0x153)]);}if(isMcpServerExecution(_0x3e733c,_0x3e8bf9)){console[_0x20b4fa(0x1bc)](_0x20b4fa(0x1e8));const {runMcpProxy:_0x468b96}=await Promise[_0x20b4fa(0x175)]()['then'](()=>__importStar(require(_0x20b4fa(0x10e))));_0x468b96(_0x3e733c,_0x3e8bf9);return;}const _0x5e6d3f=adjustCommandArgs(_0x3e733c,_0x3e8bf9),_0x5511d7=await(0x0,executor_1['executeCommand'])(_0x5e6d3f[_0x20b4fa(0x16c)],_0x5e6d3f[_0x20b4fa(0xfb)]),_0x2232dd=(0x0,filters_1[_0x20b4fa(0x129)])(_0x45d3b6,_0x5511d7[_0x20b4fa(0x165)],_0x5511d7['stderr'],tracker_1[_0x20b4fa(0x1a1)][_0x20b4fa(0x1cf)]()[_0x20b4fa(0x192)]),_0x44692b={...filters_1[_0x20b4fa(0x13f)]},_0x2d03c2=_0x5511d7[_0x20b4fa(0x165)]+(_0x5511d7['stderr'][_0x20b4fa(0x19c)]()[_0x20b4fa(0x187)]>0x0?'\x0a'+_0x5511d7[_0x20b4fa(0xf7)]:''),_0x13d733=_0x2232dd[_0x20b4fa(0x187)]<_0x2d03c2[_0x20b4fa(0x187)]?_0x2232dd:_0x2d03c2,_0x6d04a3=_0x5511d7[_0x20b4fa(0x153)]===0x0?(0x0,cache_1['dedup'])(_0x45d3b6,_0x13d733):null;tracker_1['tracker'][_0x20b4fa(0x150)](_0x45d3b6,_0x2d03c2,_0x6d04a3||_0x13d733,_0x5511d7[_0x20b4fa(0x153)],_0x44692b,[...filters_1[_0x20b4fa(0x121)]]);_0x5511d7[_0x20b4fa(0x153)]===0x0?process['stdout'][_0x20b4fa(0x106)](_0x13d733+'\x0a'):(process[_0x20b4fa(0x165)][_0x20b4fa(0x106)](_0x2232dd+'\x0a'),_0x5511d7[_0x20b4fa(0xf7)][_0x20b4fa(0x19c)]()[_0x20b4fa(0x187)]>0x0&&!_0x2232dd[_0x20b4fa(0x1e0)](_0x5511d7[_0x20b4fa(0xf7)][_0x20b4fa(0x19c)]())&&process[_0x20b4fa(0xf7)][_0x20b4fa(0x106)](_0x5511d7[_0x20b4fa(0xf7)]+'\x0a'));try{const {loadSessionsState:_0x4deedc,getLatestSessionFile:_0x38820f}=await Promise['resolve']()[_0x20b4fa(0x166)](()=>__importStar(require(_0x20b4fa(0x161)))),_0x131667=_0x4deedc(),_0x1a7e4e=(0x0,tracker_1['detectSessionTool'])(),_0x2b0721=_0x1a7e4e[_0x20b4fa(0x191)]==='antigravity'?_0x20b4fa(0x114):_0x1a7e4e[_0x20b4fa(0x191)]||'claude',_0xe37129=_0x38820f(_0x2b0721);let _0x53cf94=0x0;_0xe37129&&_0xe37129[_0x20b4fa(0x190)]&&_0x131667[_0xe37129[_0x20b4fa(0x190)]]&&(_0x53cf94=_0x131667[_0xe37129[_0x20b4fa(0x190)]][_0x20b4fa(0x18d)]||0x0);let _0x7f7823=0x0;for(const _0x58ecec of Object['keys'](_0x131667)){_0x7f7823+=_0x131667[_0x58ecec][_0x20b4fa(0x18d)]||0x0;}(_0x53cf94>0x0||_0x7f7823>0x0)&&process[_0x20b4fa(0xf7)][_0x20b4fa(0x106)](_0x20b4fa(0x1e7)+_0x2b0721+')\x20saved\x20'+_0x53cf94['toLocaleString']()+_0x20b4fa(0x189)+_0x7f7823[_0x20b4fa(0x137)]()+_0x20b4fa(0x163));}catch{}process[_0x20b4fa(0x197)](_0x5511d7[_0x20b4fa(0x153)]);}const PKG_VERSION=((()=>{const _0x16b220=a0_0x3525f1,_0xaf6d86='1.0.40';if(_0xaf6d86!==_0x16b220(0xf4))return _0xaf6d86;try{return require('../package.json')[_0x16b220(0x136)];}catch{try{return require('./package.json')[_0x16b220(0x136)];}catch{return _0x16b220(0x1d0);}}})());program[a0_0x3525f1(0x1e5)](a0_0x3525f1(0x19c))[a0_0x3525f1(0x11a)]('TrimPrompt.ai\x20-\x20Reduce\x20LLM\x20token\x20consumption\x20by\x2060-90%')[a0_0x3525f1(0x136)](PKG_VERSION,a0_0x3525f1(0x155),a0_0x3525f1(0x164)),program[a0_0x3525f1(0x1cc)](a0_0x3525f1(0x136))[a0_0x3525f1(0x11a)](a0_0x3525f1(0x162))[a0_0x3525f1(0x1ab)](()=>{console['log'](PKG_VERSION);}),program[a0_0x3525f1(0x1cc)]('ui')[a0_0x3525f1(0x123)](a0_0x3525f1(0x118))[a0_0x3525f1(0x11a)](a0_0x3525f1(0x1b2))[a0_0x3525f1(0x179)](a0_0x3525f1(0x122),a0_0x3525f1(0xf6),a0_0x3525f1(0x1af))[a0_0x3525f1(0x1ab)](_0x54e644=>{const _0x1f4139=a0_0x3525f1,_0x4e6aac=parseInt(_0x54e644[_0x1f4139(0x19f)],0xa);(0x0,dashboard_1[_0x1f4139(0x14d)])(_0x4e6aac);}),program[a0_0x3525f1(0x1cc)](a0_0x3525f1(0x186))[a0_0x3525f1(0x11a)](a0_0x3525f1(0x148))[a0_0x3525f1(0x179)](a0_0x3525f1(0x1a2),'Select\x20pricing\x20model\x20(e.g.\x20claude-3-5-sonnet,\x20gpt-4o)',a0_0x3525f1(0x1c4))[a0_0x3525f1(0x1ab)](_0xd64c2e=>{const _0xa74ea0=a0_0x3525f1,_0x3aa701=tracker_1[_0xa74ea0(0x1a1)][_0xa74ea0(0x10d)](_0xd64c2e[_0xa74ea0(0x157)]);console[_0xa74ea0(0x17c)]('\x0a============================================='),console[_0xa74ea0(0x17c)](_0xa74ea0(0x15d)),console['log'](_0xa74ea0(0x18f)),console[_0xa74ea0(0x17c)](_0xa74ea0(0xfc)+_0x3aa701[_0xa74ea0(0x132)]),console[_0xa74ea0(0x17c)](_0xa74ea0(0x1b1)+_0x3aa701['total_raw_tokens'][_0xa74ea0(0x137)]()),console[_0xa74ea0(0x17c)](_0xa74ea0(0x107)+_0x3aa701[_0xa74ea0(0x149)]['toLocaleString']()),console['log']('Tokens\x20Saved:\x20\x20\x20\x20\x20\x20'+_0x3aa701['total_tokens_saved'][_0xa74ea0(0x137)]()),console[_0xa74ea0(0x17c)](_0xa74ea0(0x183)+_0x3aa701[_0xa74ea0(0x117)]+'%'),console[_0xa74ea0(0x17c)](_0xa74ea0(0x133)+_0x3aa701[_0xa74ea0(0x1a9)]['toFixed'](0x4)+_0xa74ea0(0x12b)),console['log'](_0xa74ea0(0x1d8)+_0x3aa701['compressed_cost_usd'][_0xa74ea0(0x156)](0x4)+_0xa74ea0(0x158)),console[_0xa74ea0(0x17c)](_0xa74ea0(0x1a5)),console[_0xa74ea0(0x17c)](_0xa74ea0(0x1db)+_0x3aa701['money_saved_usd'][_0xa74ea0(0x156)](0x4)+_0xa74ea0(0x17e)),console[_0xa74ea0(0x17c)](_0xa74ea0(0x16d));}),program['command'](a0_0x3525f1(0x1d7))['description']('Manage\x20local\x20configuration\x20parameters')[a0_0x3525f1(0x131)](a0_0x3525f1(0x15a),a0_0x3525f1(0x13c))[a0_0x3525f1(0x131)](a0_0x3525f1(0x15e),a0_0x3525f1(0x1c3))[a0_0x3525f1(0x131)](a0_0x3525f1(0x17f),a0_0x3525f1(0x11c))[a0_0x3525f1(0x1ab)]((_0x5d6834,_0x3cc993,_0x36c5c4)=>{const _0x2dbb72=a0_0x3525f1;if(_0x5d6834===_0x2dbb72(0x108)){const _0x41b640=tracker_1[_0x2dbb72(0x1a1)][_0x2dbb72(0x1cf)]();console[_0x2dbb72(0x17c)](_0x3cc993+':\x20'+_0x41b640[_0x3cc993]);}else{if(_0x5d6834===_0x2dbb72(0x159)){_0x36c5c4===undefined&&(console[_0x2dbb72(0x1bc)]('Error:\x20Value\x20required\x20for\x20set\x20action'),process[_0x2dbb72(0x197)](0x1));let _0x22bebb=_0x36c5c4;if(_0x36c5c4===_0x2dbb72(0x134))_0x22bebb=!![];if(_0x36c5c4===_0x2dbb72(0x1aa))_0x22bebb=![];if(/^\d+$/[_0x2dbb72(0x13d)](_0x36c5c4))_0x22bebb=parseInt(_0x36c5c4,0xa);tracker_1[_0x2dbb72(0x1a1)][_0x2dbb72(0x1b5)](_0x3cc993,_0x22bebb),console[_0x2dbb72(0x17c)](_0x2dbb72(0x14e)+_0x3cc993+_0x2dbb72(0x143)+_0x36c5c4);}else console[_0x2dbb72(0x1bc)](_0x2dbb72(0xf9)),process[_0x2dbb72(0x197)](0x1);}});function welcomeBanner(){const _0xc763f5=a0_0x3525f1,_0x3337ad='\x1b[1m',_0x2e5b05=_0xc763f5(0x142),_0x339711=_0xc763f5(0x199),_0x1d528d=_0xc763f5(0xfd),_0x42648c='\x1b[90m',_0x4032d7=_0xc763f5(0x1c5),_0x4e4f8b=_0x2e5b05+_0xc763f5(0x1c0)+_0x4032d7;return['',_0x4e4f8b,_0xc763f5(0x1dd)+_0x3337ad+_0xc763f5(0x1a7)+_0x4032d7,_0x4e4f8b,'','\x20\x20'+_0x1d528d+_0xc763f5(0x14c)+_0x4032d7+_0xc763f5(0x127),_0xc763f5(0x1ca),'',_0xc763f5(0x19d),_0xc763f5(0x139),'','\x20\x20'+_0x3337ad+'Try\x20it:'+_0x4032d7,_0xc763f5(0x16b)+_0x339711+_0xc763f5(0x1ba)+_0x4032d7+'\x20\x20\x20'+_0x42648c+_0xc763f5(0x15b)+_0x4032d7,_0xc763f5(0x16b)+_0x339711+_0xc763f5(0x1d3)+_0x4032d7+_0xc763f5(0xf8)+_0x42648c+_0xc763f5(0x19a)+_0x4032d7,'','\x20\x20'+_0x42648c+_0xc763f5(0x101)+_0x4032d7,'','\x20\x20'+_0x42648c+'Telemetry:\x20sends\x20usage\x20stats\x20+\x20your\x20computer\x20username\x20and\x20email','\x20\x20domain\x20(e.g.\x20acme.com)\x20to\x20our\x20cloud.\x20Opt\x20out:\x20'+_0x4032d7+_0x1d528d+_0xc763f5(0x180)+_0x4032d7,'\x20\x20'+_0x42648c+_0xc763f5(0x1cd)+_0x4032d7,''][_0xc763f5(0x19b)]('\x0a');}function markerPath(_0x1cdd20){const _0x5c77bc=a0_0x3525f1,_0x22d8d4=require('os'),_0xc358=require(_0x5c77bc(0x11b));return _0xc358[_0x5c77bc(0x19b)](_0x22d8d4[_0x5c77bc(0x11d)](),'.trimprompt',_0x1cdd20);}function hasMarker(_0x1e8219){try{return require('fs')['existsSync'](markerPath(_0x1e8219));}catch{return![];}}function setMarker(_0x4ba0aa){const _0x2712d1=a0_0x3525f1;try{const _0xa7739d=require('fs'),_0xa6584c=require(_0x2712d1(0x11b));_0xa7739d['mkdirSync'](_0xa6584c['dirname'](markerPath(_0x4ba0aa)),{'recursive':!![]}),_0xa7739d['writeFileSync'](markerPath(_0x4ba0aa),new Date()['toISOString']());}catch{}}function writeToTerminal(_0xbcbd9c){const _0x2e10e9=a0_0x3525f1;try{const _0x194d3b=require('fs'),_0x4b774a=process[_0x2e10e9(0x160)]===_0x2e10e9(0x12d)?_0x2e10e9(0x14b):_0x2e10e9(0x115),_0x4fc7d8=_0xbcbd9c['replace'](/\x1b\[[0-9;]*m/g,'');return _0x194d3b[_0x2e10e9(0x154)](_0x4b774a,_0x4fc7d8+'\x0a'),!![];}catch{return![];}}function fireDomainInstallPing(){const _0x3b514b=a0_0x3525f1;try{const _0x11c673=require('fs'),_0x544926=require(_0x3b514b(0x11b)),_0x1e55a1=require(_0x3b514b(0x17a)),_0x21d1b5=_0x544926[_0x3b514b(0x19b)](__dirname,_0x3b514b(0xf3));if(_0x11c673[_0x3b514b(0x1c8)](_0x21d1b5)){const _0x59e77a=_0x1e55a1[_0x3b514b(0x13a)](process['execPath'],[_0x21d1b5,_0x3b514b(0x109)],{'detached':!![],'stdio':_0x3b514b(0x124),'windowsHide':!![]});_0x59e77a[_0x3b514b(0x1b4)]();}}catch{}}function showPostinstallBanner(){const _0x4e18e1=a0_0x3525f1;try{require('fs')[_0x4e18e1(0x12f)](markerPath('.welcomed'));}catch{}writeToTerminal(welcomeBanner());}function showWelcomeIfFirstRun(_0x552bed=![]){const _0x56603c=a0_0x3525f1;try{const _0x2566cc=hasMarker(_0x56603c(0x16a));return(_0x552bed||!_0x2566cc)&&(console[_0x56603c(0x17c)](welcomeBanner()),setMarker(_0x56603c(0x16a))),hasMarker(_0x56603c(0x16a))&&!hasMarker(_0x56603c(0x10b))&&(setMarker('.install_pinged'),fireDomainInstallPing()),!![];}catch{return![];}}function printMessage(_0x568640){const _0x16d35c=a0_0x3525f1;if(process[_0x16d35c(0x169)]['npm_lifecycle_event']===_0x16d35c(0x1d5))try{const _0x11ffd7=require('fs'),_0xfa86de=process[_0x16d35c(0x160)]===_0x16d35c(0x12d)?_0x16d35c(0x14b):'/dev/tty';_0x11ffd7[_0x16d35c(0x154)](_0xfa86de,'\x0a'+_0x568640+'\x0a');return;}catch{}console[_0x16d35c(0x17c)](_0x568640);}program[a0_0x3525f1(0x1cc)](a0_0x3525f1(0x1b7))[a0_0x3525f1(0x11a)]('Install\x20or\x20uninstall\x20system\x20command\x20shims')[a0_0x3525f1(0x131)](a0_0x3525f1(0x15a),a0_0x3525f1(0x119))[a0_0x3525f1(0x1ab)](_0x4949fc=>{const _0x3745f6=a0_0x3525f1;if(_0x4949fc==='install'){const _0x5e5f98=(0x0,shims_1[_0x3745f6(0xf5)])();printMessage(_0x5e5f98['message']);}else{if(_0x4949fc==='uninstall'){const _0x465de3=(0x0,shims_1['uninstallShims'])();printMessage(_0x465de3['message']);}else console[_0x3745f6(0x1bc)](_0x3745f6(0x168)),process[_0x3745f6(0x197)](0x1);}}),program[a0_0x3525f1(0x1cc)](a0_0x3525f1(0x1a4))['description'](a0_0x3525f1(0x1a0))[a0_0x3525f1(0x1ab)](()=>{showPostinstallBanner();}),program[a0_0x3525f1(0x1cc)](a0_0x3525f1(0x1c9))[a0_0x3525f1(0x11a)](a0_0x3525f1(0x18e))['argument'](a0_0x3525f1(0xfe),a0_0x3525f1(0x18c))['action'](_0x52fe05=>{const _0x35d97d=a0_0x3525f1;if(isDisabled()){console[_0x35d97d(0x17c)](_0x52fe05);return;}const _0x361978=(0x0,filters_1[_0x35d97d(0x126)])(_0x52fe05);console['log'](_0x361978);}),program['command'](a0_0x3525f1(0x1ae))['description']('Live\x20conversation\x20file-watcher\x20daemon\x20—\x20start,\x20install')[a0_0x3525f1(0x1ab)](async _0x5dbb44=>{const _0x39f6f5=a0_0x3525f1,{startWatcherDaemon:_0x1dda24}=await Promise[_0x39f6f5(0x175)]()[_0x39f6f5(0x166)](()=>__importStar(require(_0x39f6f5(0x161))));(!_0x5dbb44||_0x5dbb44===_0x39f6f5(0x116)||_0x5dbb44===_0x39f6f5(0x11f))&&_0x1dda24();}),program[a0_0x3525f1(0x1cc)](a0_0x3525f1(0x113))[a0_0x3525f1(0x11a)](a0_0x3525f1(0x10f))[a0_0x3525f1(0x1ab)](async _0x3ed12f=>{const _0x238798=a0_0x3525f1,{retrieveChunk:_0x425cf5}=await Promise['resolve']()[_0x238798(0x166)](()=>__importStar(require('./cache-manager'))),_0x9e74b6=_0x425cf5(_0x3ed12f);_0x9e74b6?console[_0x238798(0x17c)](_0x9e74b6[_0x238798(0x135)]):(console[_0x238798(0x1bc)](_0x238798(0x1d2)+_0x3ed12f+_0x238798(0x1bb)),process[_0x238798(0x197)](0x1));}),program[a0_0x3525f1(0x1cc)](a0_0x3525f1(0x145))['description']('Generate\x20a\x20clean,\x20compressed\x20copy\x20of\x20a\x20conversation\x20session\x20file\x20for\x20safe\x20resume')['option'](a0_0x3525f1(0x1bf),a0_0x3525f1(0x12e),a0_0x3525f1(0x13b))[a0_0x3525f1(0x1ab)](async(_0x1fe86a,_0x247b98)=>{const _0x1586b4=a0_0x3525f1,{getLatestSessionFile:_0x3ede93,compactSessionCopy:_0x1f8690}=await Promise[_0x1586b4(0x175)]()[_0x1586b4(0x166)](()=>__importStar(require(_0x1586b4(0x161)))),_0xa8d177=await Promise[_0x1586b4(0x175)]()['then'](()=>__importStar(require('fs'))),_0x680b0d=_0x247b98&&_0x247b98[_0x1586b4(0x151)]||_0x1586b4(0x13b);let _0x281a3d=_0x1fe86a;if(!_0x1fe86a||!_0xa8d177['existsSync'](_0x1fe86a)){const _0x281177=_0x3ede93(_0x680b0d);_0x281a3d=_0x281177[_0x1586b4(0x190)];}if(!_0x281a3d||!_0xa8d177[_0x1586b4(0x1c8)](_0x281a3d)){console[_0x1586b4(0x1bc)]('[TrimPrompt\x20Compact]\x20Could\x20not\x20find\x20a\x20session\x20file\x20for\x20\x27'+_0x680b0d+'\x27.');return;}const _0x40f2f4=_0x1f8690(_0x281a3d,_0x680b0d);if(!_0x40f2f4['ok']){console[_0x1586b4(0x1bc)](_0x1586b4(0x1c1)+_0x40f2f4[_0x1586b4(0x198)]);return;}console['log']('\x0a[TrimPrompt\x20Compact]\x20Clean\x20compressed\x20session\x20copy\x20generated.'),console[_0x1586b4(0x17c)](_0x1586b4(0x177)+_0x281a3d),console[_0x1586b4(0x17c)](_0x1586b4(0x1de)+_0x40f2f4[_0x1586b4(0x18a)]),console['log']('Raw:\x20\x20\x20\x20\x20\x20\x20\x20'+_0x40f2f4[_0x1586b4(0x16e)]?.['toLocaleString']()+_0x1586b4(0x173)+_0x40f2f4[_0x1586b4(0x17d)]?.[_0x1586b4(0x137)]()+'\x20bytes)'),console[_0x1586b4(0x17c)]('Compressed:\x20'+_0x40f2f4[_0x1586b4(0x10c)]?.[_0x1586b4(0x137)]()+'\x20tokens\x20('+_0x40f2f4['compressedBytes']?.['toLocaleString']()+_0x1586b4(0x185)),console['log'](_0x1586b4(0x140)+_0x40f2f4[_0x1586b4(0x1a6)]?.[_0x1586b4(0x137)]()+_0x1586b4(0x173)+_0x40f2f4['reductionPct']+_0x1586b4(0x167)),(_0x40f2f4[_0x1586b4(0x1a6)]||0x0)===0x0?console[_0x1586b4(0x17c)](_0x1586b4(0x184)):(console[_0x1586b4(0x17c)](_0x1586b4(0x13e)),console[_0x1586b4(0x17c)](_0x1586b4(0x193)+_0x40f2f4['compactPath']+'\x22')),console[_0x1586b4(0x17c)]('');});function a0_0x5bd7(_0x2f3a29,_0x1cc1e9){const _0x5b1751=a0_0x5b17();return a0_0x5bd7=function(_0x5bd734,_0x318af9){_0x5bd734=_0x5bd734-0xf3;let _0xd32fe3=_0x5b1751[_0x5bd734];return _0xd32fe3;},a0_0x5bd7(_0x2f3a29,_0x1cc1e9);}function a0_0x5b17(){const _0x158821=['<key>','148flQTvw','platform','./file-watcher','Print\x20the\x20TrimPrompt\x20version','\x20tokens\x1b[39m\x0a','output\x20the\x20version','stdout','then','%\x20reduction)','Error:\x20Action\x20must\x20be\x20install\x20or\x20uninstall','env','.welcomed','\x20\x20\x20\x20','cmd','=============================================\x0a','rawTokens','2520511cJPhnL','node','TRIMPROMPT_DISABLED','getOwnPropertyNames','\x20tokens\x20(','-sb','resolve','--pretty','Original\x20file\x20untouched:\x20','__setModuleDefault','option','child_process','slice','log','rawBytes','\x20USD','[value]','TRIMPROMPT_NO_TELEMETRY=1','create','compact','Reduction\x20Rate:\x20\x20\x20\x20','(No\x20content\x20exceeded\x20the\x20offload\x20threshold\x20—\x20nothing\x20to\x20compress.)','\x20bytes)','stats','length','help','\x20tokens\x20|\x20Total\x20savings:\x20','compactPath','startsWith','Command\x20line\x20to\x20evaluate','activeSavedTokens','Check\x20a\x20command\x20line\x20and\x20return\x20the\x20optimized\x20command\x20line','=============================================','fullPath','tool','redaction_enabled','\x20\x20claude\x20--resume\x20\x22','mcp-proxy','server','git','exit','reason','\x1b[32m','→\x20\x20open\x20the\x20live\x20dashboard\x20in\x20your\x20browser','join','trim','\x20\x20Then\x20just\x20work\x20normally.\x20TrimPrompt\x20trims\x20your\x20command','-50','port','Print\x20the\x20first-run\x20welcome\x20banner\x20(used\x20by\x20the\x20installer)','tracker','-m,\x20--model\x20<string>','2MBXFDY','welcome','---------------------------------------------','savedTokens','TrimPrompt\x20is\x20installed\x20—\x20you\x27re\x20saving\x20tokens!','--no-merges','raw_cost_usd','false','action','proxy','4383694gQTfAT','watcher\x20[action]','4000','pnpm','Raw\x20Tokens:\x20\x20\x20\x20\x20\x20\x20\x20','Start\x20the\x20local\x20developer\x20dashboard','./tracker','unref','setConfig','639634nKyTji','shims','24NAhXUM','2468010VUipDZ','trim\x20stats','\x27\x20not\x20found\x20or\x20expired.','error','./cache','6700356lDLncA','-a,\x20--agent\x20<agent>','──────────────────────────────────────────────────────────','[TrimPrompt\x20Compact]\x20','-bs','config\x20parameter\x20name','claude-3-5-sonnet','\x1b[0m','--porcelain','__importStar','existsSync','rewrite','\x20\x20\x20\x20\x20Claude\x20Code)\x20so\x20the\x20optimized\x20commands\x20take\x20effect.','catch','command','Details:\x20npmjs.com/package/trimprompt','[TrimPrompt]\x20Fatal\x20Proxy\x20Error:\x20','getConfig','1.0.0','5UiJarB','[TrimPrompt\x20Cache]\x20Chunk\x20\x27','trim\x20ui','65jPnPZs','postinstall','server-mcp','config','Actual\x20Cost:\x20\x20\x20\x20\x20\x20\x20$','--format','watcher','Money\x20Saved:\x20\x20\x20\x20\x20\x20\x20$','retrieve','\x20\x20✂\x20\x20','Compact\x20session\x20copy:\x20\x20\x20\x20','__createBinding','includes','modelcontextprotocol','mcp-server','--short','53174qssKiR','name','some','\x0a\x1b[90m[TrimPrompt]\x20⚡\x20Active\x20session\x20(','[TrimPrompt]\x20Autodetected\x20MCP\x20server\x20execution.\x20Activating\x20real-time\x20JSON-RPC\x20proxy...','sync.js','__VERSION__','installShims','Port\x20to\x20run\x20the\x20dashboard\x20on','stderr','\x20\x20\x20\x20\x20\x20','Error:\x20Action\x20must\x20be\x20get\x20or\x20set','parse','args','Model\x20Context:\x20\x20\x20\x20\x20','\x1b[33m','<commandLine>','./shims','./filters','Dashboard:\x20http://localhost:4000','every','defineProperty','toLowerCase','npm_lifecycle_event','write','Compressed:\x20\x20\x20\x20\x20\x20\x20\x20','get','--install-id','__esModule','.install_pinged','compressedTokens','getStatsSummary','./mcp','Retrieve\x20raw\x20offloaded\x20content\x20chunk\x20from\x20local\x20side-cache','status','getOwnPropertyDescriptor','mcp','retrieve\x20<chunkId>','gemini','/dev/tty','start','savings_percentage','dashboard','install\x20or\x20uninstall','description','path','value\x20to\x20set','homedir','24XmOsGC','install','10fyMZzb','lastFeatures','-p,\x20--port\x20<number>','alias','ignore','26655tUTzbN','rewriteCommand','\x20(or\x20your\x20AI\x20editor\x20—\x20Cursor\x20/','prototype','compressOutput','argv','\x20(before\x20Trim)','@modelcontextprotocol/','win32','Agent\x20key\x20(claude,\x20cursor,\x20codex,\x20...)','unlinkSync','default','argument','model_name','Estimated\x20Cost:\x20\x20\x20\x20$','true','raw_payload','version','toLocaleString','-10','\x20\x20output\x20automatically\x20in\x20the\x20background\x20—\x20nothing\x20to\x20configure.','spawn','claude','get\x20or\x20set','test','\x0aTo\x20resume\x20with\x20lightweight\x20context,\x20execute:','lastRedactAudit','Saved:\x20\x20\x20\x20\x20\x20','writable','\x1b[36m','\x20=\x20','call','compact\x20[sessionId]','push','npx','Show\x20token\x20and\x20cost\x20savings\x20summary','total_compressed_tokens','hasOwnProperty','\x5c\x5c.\x5cCON','⚠\x20\x20Restart\x20your\x20terminal\x20once','startDashboard','Config\x20set\x20','--pretty=format:%h\x20%s\x20(%ar)\x20(%an)%n%b%n---END---','logExecution','agent','--merges','exitCode','writeFileSync','-v,\x20--version','toFixed','model','\x20(after\x20Trim)','set','<action>','→\x20\x20tokens\x20&\x20money\x20you\x27ve\x20saved\x20so\x20far','message','\x20\x20\x20\x20\x20\x20\x20TRIMPROMPT.AI\x20SAVINGS\x20SUMMARY\x20\x20\x20\x20\x20\x20\x20\x20'];a0_0x5b17=function(){return _0x158821;};return a0_0x5b17();}const args=process[a0_0x3525f1(0x12a)][a0_0x3525f1(0x17b)](0x2),firstArg=args[0x0],subcommands=['ui',a0_0x3525f1(0x118),a0_0x3525f1(0x186),'config',a0_0x3525f1(0x1b7),'welcome',a0_0x3525f1(0x1c9),a0_0x3525f1(0x194),a0_0x3525f1(0x112),'watcher','retrieve',a0_0x3525f1(0x182),a0_0x3525f1(0x188),'--help','-h',a0_0x3525f1(0x136),'--version','-v'];if(firstArg&&!subcommands[a0_0x3525f1(0x1e0)](firstArg))runProxy(args)[a0_0x3525f1(0x1cb)](_0x31668f=>{const _0x45418b=a0_0x3525f1;console['error'](_0x45418b(0x1ce)+_0x31668f[_0x45418b(0x15c)]),process['exit'](0x1);});else{const machineFacing=['shims','welcome',a0_0x3525f1(0x1da),a0_0x3525f1(0x194),a0_0x3525f1(0x112),a0_0x3525f1(0x1dc),a0_0x3525f1(0x182)],isPostinstall=process[a0_0x3525f1(0x169)][a0_0x3525f1(0x105)]===a0_0x3525f1(0x1d5);if(!isPostinstall){if(!firstArg)showWelcomeIfFirstRun(!![]);else!machineFacing['includes'](firstArg)&&showWelcomeIfFirstRun(![]);}program[a0_0x3525f1(0xfa)](process['argv']);}
2
+ "use strict";
3
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
4
+ if (k2 === undefined) k2 = k;
5
+ var desc = Object.getOwnPropertyDescriptor(m, k);
6
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
7
+ desc = { enumerable: true, get: function() { return m[k]; } };
8
+ }
9
+ Object.defineProperty(o, k2, desc);
10
+ }) : (function(o, m, k, k2) {
11
+ if (k2 === undefined) k2 = k;
12
+ o[k2] = m[k];
13
+ }));
14
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
15
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
16
+ }) : function(o, v) {
17
+ o["default"] = v;
18
+ });
19
+ var __importStar = (this && this.__importStar) || (function () {
20
+ var ownKeys = function(o) {
21
+ ownKeys = Object.getOwnPropertyNames || function (o) {
22
+ var ar = [];
23
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
24
+ return ar;
25
+ };
26
+ return ownKeys(o);
27
+ };
28
+ return function (mod) {
29
+ if (mod && mod.__esModule) return mod;
30
+ var result = {};
31
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
32
+ __setModuleDefault(result, mod);
33
+ return result;
34
+ };
35
+ })();
36
+ Object.defineProperty(exports, "__esModule", { value: true });
37
+ const commander_1 = require("commander");
38
+ const executor_1 = require("./executor");
39
+ const filters_1 = require("./filters");
40
+ const tracker_1 = require("./tracker");
41
+ const cache_1 = require("./cache");
42
+ const shims_1 = require("./shims");
43
+ const dashboard_1 = require("./dashboard");
44
+ const program = new commander_1.Command();
45
+ function isDisabled() {
46
+ return process.env.TRIMPROMPT_DISABLED === '1';
47
+ }
48
+ function adjustCommandArgs(cmd, args) {
49
+ const cmdLower = cmd.toLowerCase();
50
+ if (cmdLower === 'git' || cmdLower === 'yadm') {
51
+ const sub = args[0];
52
+ if (sub === 'status') {
53
+ const statusArgs = args.slice(1);
54
+ const isCompatible = statusArgs.length === 0 || statusArgs.every(arg => {
55
+ return arg === '-b' || arg === '--branch' || arg === '-sb' || arg === '-bs' || arg === '-s' || arg === '--short';
56
+ });
57
+ if (isCompatible) {
58
+ return { cmd, args: ['status', '--porcelain', '-b'] };
59
+ }
60
+ }
61
+ else if (sub === 'log') {
62
+ const logArgs = args.slice(1);
63
+ const hasFormat = logArgs.some(arg => arg.startsWith('--oneline') || arg.startsWith('--pretty') || arg.startsWith('--format'));
64
+ const hasLimit = logArgs.some(arg => (arg.startsWith('-') && /^\d+$/.test(arg.slice(1))) || arg === '-n' || arg.startsWith('--max-count'));
65
+ const newArgs = [...args];
66
+ if (!hasFormat) {
67
+ const formatStr = '--pretty=format:%h %s (%ar) (%an)%n%b%n---END---';
68
+ newArgs.push(process.platform === 'win32' ? `"${formatStr}"` : formatStr);
69
+ }
70
+ if (!hasLimit) {
71
+ if (hasFormat) {
72
+ newArgs.push('-50');
73
+ }
74
+ else {
75
+ newArgs.push('-10');
76
+ }
77
+ }
78
+ const hasMergeFlag = logArgs.some(arg => arg === '--merges' || arg === '--no-merges' || arg.startsWith('--min-parents'));
79
+ if (!hasMergeFlag && !hasLimit) {
80
+ newArgs.push('--no-merges');
81
+ }
82
+ return { cmd, args: newArgs };
83
+ }
84
+ }
85
+ return { cmd, args };
86
+ }
87
+ function isMcpServerExecution(cmd, args) {
88
+ const cmdLower = cmd.toLowerCase();
89
+ const argsString = args.join(' ').toLowerCase();
90
+ if (cmdLower.includes('mcp') && (cmdLower.includes('server') || cmdLower.includes('proxy'))) {
91
+ return true;
92
+ }
93
+ if (cmdLower === 'npx' || cmdLower === 'node' || cmdLower === 'bun' || cmdLower === 'npm' || cmdLower === 'pnpm' || cmdLower === 'yarn') {
94
+ if (argsString.includes('@modelcontextprotocol/') || argsString.includes('modelcontextprotocol') || argsString.includes('mcp-server') || argsString.includes('server-mcp')) {
95
+ return true;
96
+ }
97
+ }
98
+ if (args.some(arg => {
99
+ const l = arg.toLowerCase();
100
+ return l.includes('mcp-server') || l.includes('server-mcp') || l.includes('@modelcontextprotocol/') || l === 'mcp-proxy' || l === 'mcp';
101
+ })) {
102
+ return true;
103
+ }
104
+ return false;
105
+ }
106
+ async function runProxy(args) {
107
+ if (args.length === 0) {
108
+ program.help();
109
+ return;
110
+ }
111
+ const rawCmd = args[0];
112
+ const rawArgs = args.slice(1);
113
+ const commandLine = args.join(' ');
114
+ if (isDisabled()) {
115
+ const result = await (0, executor_1.executeCommand)(rawCmd, rawArgs);
116
+ process.stdout.write(result.stdout);
117
+ process.stderr.write(result.stderr);
118
+ process.exit(result.exitCode);
119
+ }
120
+ if (isMcpServerExecution(rawCmd, rawArgs)) {
121
+ console.error('[TrimPrompt] Autodetected MCP server execution. Activating real-time JSON-RPC proxy...');
122
+ const { runMcpProxy } = await Promise.resolve().then(() => __importStar(require('./mcp')));
123
+ runMcpProxy(rawCmd, rawArgs);
124
+ return;
125
+ }
126
+ const adjusted = adjustCommandArgs(rawCmd, rawArgs);
127
+ const result = await (0, executor_1.executeCommand)(adjusted.cmd, adjusted.args);
128
+ const compressed = (0, filters_1.compressOutput)(commandLine, result.stdout, result.stderr, tracker_1.tracker.getConfig().redaction_enabled);
129
+ const securityAudit = { ...filters_1.lastRedactAudit };
130
+ const combinedRaw = result.stdout + (result.stderr.trim().length > 0 ? '\n' + result.stderr : '');
131
+ const safeCompressed = compressed.length < combinedRaw.length ? compressed : combinedRaw;
132
+ const cached = (result.exitCode === 0) ? (0, cache_1.dedup)(commandLine, safeCompressed) : null;
133
+ tracker_1.tracker.logExecution(commandLine, combinedRaw, cached || safeCompressed, result.exitCode, securityAudit, [...filters_1.lastFeatures]);
134
+ if (result.exitCode === 0) {
135
+ process.stdout.write(safeCompressed + '\n');
136
+ }
137
+ else {
138
+ process.stdout.write(compressed + '\n');
139
+ if (result.stderr.trim().length > 0 && !compressed.includes(result.stderr.trim())) {
140
+ process.stderr.write(result.stderr + '\n');
141
+ }
142
+ }
143
+ try {
144
+ const { loadSessionsState, getLatestSessionFile } = await Promise.resolve().then(() => __importStar(require('./file-watcher')));
145
+ const state = loadSessionsState();
146
+ const activeTool = (0, tracker_1.detectSessionTool)();
147
+ const agentKey = activeTool.tool === 'antigravity' ? 'gemini' : (activeTool.tool || 'claude');
148
+ const latest = getLatestSessionFile(agentKey);
149
+ let activeSaved = 0;
150
+ if (latest && latest.fullPath && state[latest.fullPath]) {
151
+ activeSaved = state[latest.fullPath].activeSavedTokens || 0;
152
+ }
153
+ let totalSaved = 0;
154
+ for (const key of Object.keys(state)) {
155
+ totalSaved += state[key].activeSavedTokens || 0;
156
+ }
157
+ if (activeSaved > 0 || totalSaved > 0) {
158
+ process.stderr.write(`\n\u001b[90m[TrimPrompt] ⚡ Active session (${agentKey}) saved ${activeSaved.toLocaleString()} tokens | Total savings: ${totalSaved.toLocaleString()} tokens\u001b[39m\n`);
159
+ }
160
+ }
161
+ catch { }
162
+ process.exit(result.exitCode);
163
+ }
164
+ const PKG_VERSION = (() => {
165
+ const version = '1.0.42';
166
+ if (version !== '__VERSION__')
167
+ return version;
168
+ try {
169
+ return require('../package.json').version;
170
+ }
171
+ catch {
172
+ try {
173
+ return require('./package.json').version;
174
+ }
175
+ catch {
176
+ return '1.0.0';
177
+ }
178
+ }
179
+ })();
180
+ program
181
+ .name('trim')
182
+ .description('TrimPrompt.ai - Reduce LLM token consumption by 60-90%')
183
+ .version(PKG_VERSION, '-v, --version', 'output the version');
184
+ program
185
+ .command('version')
186
+ .description('Print the TrimPrompt version')
187
+ .action(() => {
188
+ console.log(PKG_VERSION);
189
+ });
190
+ program
191
+ .command('ui')
192
+ .alias('dashboard')
193
+ .description('Start the local developer dashboard')
194
+ .option('-p, --port <number>', 'Port to run the dashboard on', '4000')
195
+ .action((options) => {
196
+ const port = parseInt(options.port, 10);
197
+ (0, dashboard_1.startDashboard)(port);
198
+ });
199
+ program
200
+ .command('stats')
201
+ .description('Show token and cost savings summary')
202
+ .option('-m, --model <string>', 'Select pricing model (e.g. claude-3-5-sonnet, gpt-4o)', 'claude-3-5-sonnet')
203
+ .action((options) => {
204
+ const summary = tracker_1.tracker.getStatsSummary(options.model);
205
+ console.log('\n=============================================');
206
+ console.log(' TRIMPROMPT.AI SAVINGS SUMMARY ');
207
+ console.log('=============================================');
208
+ console.log(`Model Context: ${summary.model_name}`);
209
+ console.log(`Raw Tokens: ${summary.total_raw_tokens.toLocaleString()}`);
210
+ console.log(`Compressed: ${summary.total_compressed_tokens.toLocaleString()}`);
211
+ console.log(`Tokens Saved: ${summary.total_tokens_saved.toLocaleString()}`);
212
+ console.log(`Reduction Rate: ${summary.savings_percentage}%`);
213
+ console.log(`Estimated Cost: $${summary.raw_cost_usd.toFixed(4)} (before Trim)`);
214
+ console.log(`Actual Cost: $${summary.compressed_cost_usd.toFixed(4)} (after Trim)`);
215
+ console.log(`---------------------------------------------`);
216
+ console.log(`Money Saved: $${summary.money_saved_usd.toFixed(4)} USD`);
217
+ console.log('=============================================\n');
218
+ });
219
+ program
220
+ .command('config')
221
+ .description('Manage local configuration parameters')
222
+ .argument('<action>', 'get or set')
223
+ .argument('<key>', 'config parameter name')
224
+ .argument('[value]', 'value to set')
225
+ .action((action, key, value) => {
226
+ if (action === 'get') {
227
+ const config = tracker_1.tracker.getConfig();
228
+ console.log(`${key}: ${config[key]}`);
229
+ }
230
+ else if (action === 'set') {
231
+ if (value === undefined) {
232
+ console.error('Error: Value required for set action');
233
+ process.exit(1);
234
+ }
235
+ let parsedValue = value;
236
+ if (value === 'true')
237
+ parsedValue = true;
238
+ if (value === 'false')
239
+ parsedValue = false;
240
+ if (/^\d+$/.test(value))
241
+ parsedValue = parseInt(value, 10);
242
+ tracker_1.tracker.setConfig(key, parsedValue);
243
+ console.log(`Config set ${key} = ${value}`);
244
+ }
245
+ else {
246
+ console.error('Error: Action must be get or set');
247
+ process.exit(1);
248
+ }
249
+ });
250
+ function welcomeBanner() {
251
+ const B = '\x1b[1m', C = '\x1b[36m', G = '\x1b[32m', Y = '\x1b[33m', D = '\x1b[90m', R = '\x1b[0m';
252
+ const rule = C + '──────────────────────────────────────────────────────────' + R;
253
+ return [
254
+ '',
255
+ rule,
256
+ ` ✂ ${B}TrimPrompt is installed — you're saving tokens!${R}`,
257
+ rule,
258
+ '',
259
+ ` ${Y}⚠ Restart your terminal once${R} (or your AI editor — Cursor /`,
260
+ ` Claude Code) so the optimized commands take effect.`,
261
+ '',
262
+ ` Then just work normally. TrimPrompt trims your command`,
263
+ ` output automatically in the background — nothing to configure.`,
264
+ '',
265
+ ` ${B}Try it:${R}`,
266
+ ` ${G}trim stats${R} ${D}→ tokens & money you've saved so far${R}`,
267
+ ` ${G}trim ui${R} ${D}→ open the live dashboard in your browser${R}`,
268
+ '',
269
+ ` ${D}Dashboard: http://localhost:4000${R}`,
270
+ '',
271
+ ` ${D}Telemetry: sends usage stats + your computer name, username and`,
272
+ ` email domain (e.g. acme.com) to our cloud. Opt out: ${R}${Y}TRIMPROMPT_NO_TELEMETRY=1${R}`,
273
+ ` ${D}Details: npmjs.com/package/trimprompt${R}`,
274
+ '',
275
+ ].join('\n');
276
+ }
277
+ function markerPath(name) {
278
+ const os = require('os');
279
+ const path = require('path');
280
+ return path.join(os.homedir(), '.trimprompt', name);
281
+ }
282
+ function hasMarker(name) {
283
+ try {
284
+ return require('fs').existsSync(markerPath(name));
285
+ }
286
+ catch {
287
+ return false;
288
+ }
289
+ }
290
+ function setMarker(name) {
291
+ try {
292
+ const fs = require('fs');
293
+ const path = require('path');
294
+ fs.mkdirSync(path.dirname(markerPath(name)), { recursive: true });
295
+ fs.writeFileSync(markerPath(name), new Date().toISOString());
296
+ }
297
+ catch { }
298
+ }
299
+ function writeToTerminal(text) {
300
+ try {
301
+ const fs = require('fs');
302
+ const dev = process.platform === 'win32' ? '\\\\.\\CON' : '/dev/tty';
303
+ const plain = text.replace(/\x1b\[[0-9;]*m/g, '');
304
+ fs.writeFileSync(dev, plain + '\n');
305
+ return true;
306
+ }
307
+ catch (err) {
308
+ try {
309
+ const fs = require('fs');
310
+ const path = require('path');
311
+ const os = require('os');
312
+ fs.appendFileSync(path.join(os.homedir(), '.trimprompt', 'install_debug.log'), `[writeToTerminal Error] ${err.message}\n`);
313
+ }
314
+ catch { }
315
+ return false;
316
+ }
317
+ }
318
+ function fireDomainInstallPing() {
319
+ try {
320
+ const fs = require('fs');
321
+ const path = require('path');
322
+ const cp = require('child_process');
323
+ const syncPath = path.join(__dirname, 'sync.js');
324
+ if (fs.existsSync(syncPath)) {
325
+ const child = cp.spawn(process.execPath, [syncPath, '--install-id'], {
326
+ detached: true, stdio: 'ignore', windowsHide: true
327
+ });
328
+ child.unref();
329
+ }
330
+ }
331
+ catch { }
332
+ }
333
+ function showPostinstallBanner() {
334
+ try {
335
+ require('fs').unlinkSync(markerPath('.welcomed'));
336
+ }
337
+ catch { }
338
+ writeToTerminal(welcomeBanner());
339
+ }
340
+ function showWelcomeIfFirstRun(force = false) {
341
+ try {
342
+ const alreadyShown = hasMarker('.welcomed');
343
+ if (force || !alreadyShown) {
344
+ console.log(welcomeBanner());
345
+ setMarker('.welcomed');
346
+ }
347
+ if (hasMarker('.welcomed') && !hasMarker('.install_pinged')) {
348
+ setMarker('.install_pinged');
349
+ fireDomainInstallPing();
350
+ }
351
+ return true;
352
+ }
353
+ catch {
354
+ return false;
355
+ }
356
+ }
357
+ function printMessage(msg) {
358
+ if (process.env.npm_lifecycle_event === 'postinstall') {
359
+ try {
360
+ const fs = require('fs');
361
+ const ttyPath = process.platform === 'win32' ? '\\\\.\\CON' : '/dev/tty';
362
+ fs.writeFileSync(ttyPath, '\n' + msg + '\n');
363
+ return;
364
+ }
365
+ catch (err) {
366
+ try {
367
+ const fs = require('fs');
368
+ const path = require('path');
369
+ const os = require('os');
370
+ fs.appendFileSync(path.join(os.homedir(), '.trimprompt', 'install_debug.log'), `[printMessage Error] ${err.message}\n`);
371
+ }
372
+ catch { }
373
+ }
374
+ }
375
+ console.log(msg);
376
+ }
377
+ program
378
+ .command('shims')
379
+ .description('Install or uninstall system command shims')
380
+ .argument('<action>', 'install or uninstall')
381
+ .action((action) => {
382
+ if (action === 'install') {
383
+ const result = (0, shims_1.installShims)();
384
+ printMessage(result.message);
385
+ }
386
+ else if (action === 'uninstall') {
387
+ const result = (0, shims_1.uninstallShims)();
388
+ printMessage(result.message);
389
+ }
390
+ else {
391
+ console.error('Error: Action must be install or uninstall');
392
+ process.exit(1);
393
+ }
394
+ });
395
+ program
396
+ .command('welcome')
397
+ .description('Print the first-run welcome banner (used by the installer)')
398
+ .action(() => {
399
+ showPostinstallBanner();
400
+ });
401
+ program
402
+ .command('rewrite')
403
+ .description('Check a command line and return the optimized command line')
404
+ .argument('<commandLine>', 'Command line to evaluate')
405
+ .action((commandLine) => {
406
+ if (isDisabled()) {
407
+ console.log(commandLine);
408
+ return;
409
+ }
410
+ const rewritten = (0, filters_1.rewriteCommand)(commandLine);
411
+ console.log(rewritten);
412
+ });
413
+ program
414
+ .command('watcher [action]')
415
+ .description('Live conversation file-watcher daemon — start, install')
416
+ .action(async (action) => {
417
+ const { startWatcherDaemon } = await Promise.resolve().then(() => __importStar(require('./file-watcher')));
418
+ if (!action || action === 'start' || action === 'install') {
419
+ startWatcherDaemon();
420
+ }
421
+ });
422
+ program
423
+ .command('retrieve <chunkId>')
424
+ .description('Retrieve raw offloaded content chunk from local side-cache')
425
+ .action(async (chunkId) => {
426
+ const { retrieveChunk } = await Promise.resolve().then(() => __importStar(require('./cache-manager')));
427
+ const chunk = retrieveChunk(chunkId);
428
+ if (chunk) {
429
+ console.log(chunk.raw_payload);
430
+ }
431
+ else {
432
+ console.error(`[TrimPrompt Cache] Chunk '${chunkId}' not found or expired.`);
433
+ process.exit(1);
434
+ }
435
+ });
436
+ program
437
+ .command('compact [sessionId]')
438
+ .description('Generate a clean, compressed copy of a conversation session file for safe resume')
439
+ .option('-a, --agent <agent>', 'Agent key (claude, cursor, codex, ...)', 'claude')
440
+ .action(async (sessionId, options) => {
441
+ const { getLatestSessionFile, compactSessionCopy } = await Promise.resolve().then(() => __importStar(require('./file-watcher')));
442
+ const fs = await Promise.resolve().then(() => __importStar(require('fs')));
443
+ const agentKey = (options && options.agent) || 'claude';
444
+ let targetPath = sessionId;
445
+ if (!sessionId || !fs.existsSync(sessionId)) {
446
+ const latest = getLatestSessionFile(agentKey);
447
+ targetPath = latest.fullPath;
448
+ }
449
+ if (!targetPath || !fs.existsSync(targetPath)) {
450
+ console.error(`[TrimPrompt Compact] Could not find a session file for '${agentKey}'.`);
451
+ return;
452
+ }
453
+ const result = compactSessionCopy(targetPath, agentKey);
454
+ if (!result.ok) {
455
+ console.error(`[TrimPrompt Compact] ${result.reason}`);
456
+ return;
457
+ }
458
+ console.log(`\n[TrimPrompt Compact] Clean compressed session copy generated.`);
459
+ console.log(`Original file untouched: ${targetPath}`);
460
+ console.log(`Compact session copy: ${result.compactPath}`);
461
+ console.log(`Raw: ${result.rawTokens?.toLocaleString()} tokens (${result.rawBytes?.toLocaleString()} bytes)`);
462
+ console.log(`Compressed: ${result.compressedTokens?.toLocaleString()} tokens (${result.compressedBytes?.toLocaleString()} bytes)`);
463
+ console.log(`Saved: ${result.savedTokens?.toLocaleString()} tokens (${result.reductionPct}% reduction)`);
464
+ if ((result.savedTokens || 0) === 0) {
465
+ console.log(`(No content exceeded the offload threshold — nothing to compress.)`);
466
+ }
467
+ else {
468
+ console.log(`\nTo resume with lightweight context, execute:`);
469
+ console.log(` claude --resume "${result.compactPath}"`);
470
+ }
471
+ console.log('');
472
+ });
473
+ const args = process.argv.slice(2);
474
+ const firstArg = args[0];
475
+ const subcommands = ['ui', 'dashboard', 'stats', 'config', 'shims', 'welcome', 'rewrite', 'mcp-proxy', 'mcp', 'watcher', 'retrieve', 'compact', 'help', '--help', '-h', 'version', '--version', '-v'];
476
+ if (firstArg && !subcommands.includes(firstArg)) {
477
+ runProxy(args).catch(err => {
478
+ console.error(`[TrimPrompt] Fatal Proxy Error: ${err.message}`);
479
+ process.exit(1);
480
+ });
481
+ }
482
+ else {
483
+ const machineFacing = ['shims', 'welcome', 'watcher', 'mcp-proxy', 'mcp', 'retrieve', 'compact'];
484
+ const isPostinstall = process.env.npm_lifecycle_event === 'postinstall';
485
+ if (!isPostinstall) {
486
+ if (!firstArg) {
487
+ showWelcomeIfFirstRun(true);
488
+ }
489
+ else if (!machineFacing.includes(firstArg)) {
490
+ showWelcomeIfFirstRun(false);
491
+ }
492
+ }
493
+ program.parse(process.argv);
494
+ }
package/dashboard.js CHANGED
@@ -1 +1 @@
1
- 'use strict';function a0_0x55da(_0x26fef7,_0x57121e){const _0xda1105=a0_0xda11();return a0_0x55da=function(_0x55da8a,_0x237aa2){_0x55da8a=_0x55da8a-0xff;let _0x4dfbac=_0xda1105[_0x55da8a];return _0x4dfbac;},a0_0x55da(_0x26fef7,_0x57121e);}const a0_0x2fcf0d=a0_0x55da;(function(_0x227bfb,_0x29ac0c){const _0x54f17c=a0_0x55da,_0x4c5305=_0x227bfb();while(!![]){try{const _0x23dd00=-parseInt(_0x54f17c(0x13b))/0x1*(-parseInt(_0x54f17c(0x148))/0x2)+parseInt(_0x54f17c(0x146))/0x3*(-parseInt(_0x54f17c(0x114))/0x4)+parseInt(_0x54f17c(0x172))/0x5*(-parseInt(_0x54f17c(0x14d))/0x6)+-parseInt(_0x54f17c(0x156))/0x7+parseInt(_0x54f17c(0x109))/0x8+parseInt(_0x54f17c(0x125))/0x9+parseInt(_0x54f17c(0x16c))/0xa*(parseInt(_0x54f17c(0x12f))/0xb);if(_0x23dd00===_0x29ac0c)break;else _0x4c5305['push'](_0x4c5305['shift']());}catch(_0xc32bfc){_0x4c5305['push'](_0x4c5305['shift']());}}}(a0_0xda11,0xb81a6));var __createBinding=this&&this['__createBinding']||(Object['create']?function(_0x3ee122,_0x369969,_0x16452c,_0x2cfbdd){const _0x23f6d7=a0_0x55da;if(_0x2cfbdd===undefined)_0x2cfbdd=_0x16452c;var _0x2a2383=Object[_0x23f6d7(0x141)](_0x369969,_0x16452c);(!_0x2a2383||(_0x23f6d7(0x14f)in _0x2a2383?!_0x369969[_0x23f6d7(0x151)]:_0x2a2383[_0x23f6d7(0x142)]||_0x2a2383[_0x23f6d7(0x10c)]))&&(_0x2a2383={'enumerable':!![],'get':function(){return _0x369969[_0x16452c];}}),Object['defineProperty'](_0x3ee122,_0x2cfbdd,_0x2a2383);}:function(_0x3d0b27,_0x45db6f,_0x4bf00c,_0xbf7c44){if(_0xbf7c44===undefined)_0xbf7c44=_0x4bf00c;_0x3d0b27[_0xbf7c44]=_0x45db6f[_0x4bf00c];}),__setModuleDefault=this&&this[a0_0x2fcf0d(0x147)]||(Object[a0_0x2fcf0d(0x122)]?function(_0x41c36a,_0x46336f){const _0x27d242=a0_0x2fcf0d;Object['defineProperty'](_0x41c36a,_0x27d242(0x157),{'enumerable':!![],'value':_0x46336f});}:function(_0x3bcfd7,_0x5e161e){_0x3bcfd7['default']=_0x5e161e;}),__importStar=this&&this[a0_0x2fcf0d(0x129)]||(function(){var _0x980d46=function(_0x4e34ba){const _0xfd8b67=a0_0x55da;return _0x980d46=Object[_0xfd8b67(0x160)]||function(_0xc492e){const _0x4d83ea=_0xfd8b67;var _0x29106e=[];for(var _0x255c79 in _0xc492e)if(Object[_0x4d83ea(0x120)][_0x4d83ea(0x15c)][_0x4d83ea(0x11f)](_0xc492e,_0x255c79))_0x29106e[_0x29106e[_0x4d83ea(0x113)]]=_0x255c79;return _0x29106e;},_0x980d46(_0x4e34ba);};return function(_0x556863){const _0x24a8a8=a0_0x55da;if(_0x556863&&_0x556863[_0x24a8a8(0x151)])return _0x556863;var _0x4bfdae={};if(_0x556863!=null){for(var _0x27f34f=_0x980d46(_0x556863),_0x1eb5c7=0x0;_0x1eb5c7<_0x27f34f['length'];_0x1eb5c7++)if(_0x27f34f[_0x1eb5c7]!==_0x24a8a8(0x157))__createBinding(_0x4bfdae,_0x556863,_0x27f34f[_0x1eb5c7]);}return __setModuleDefault(_0x4bfdae,_0x556863),_0x4bfdae;};}()),__importDefault=this&&this[a0_0x2fcf0d(0x132)]||function(_0x3979d1){return _0x3979d1&&_0x3979d1['__esModule']?_0x3979d1:{'default':_0x3979d1};};Object[a0_0x2fcf0d(0x161)](exports,a0_0x2fcf0d(0x151),{'value':!![]}),exports[a0_0x2fcf0d(0x145)]=startDashboard;const express_1=__importDefault(require(a0_0x2fcf0d(0x12b))),path=__importStar(require(a0_0x2fcf0d(0x14e))),fs=__importStar(require('fs')),os=__importStar(require('os')),open_1=__importDefault(require(a0_0x2fcf0d(0x100))),tracker_1=require(a0_0x2fcf0d(0x131)),app=(0x0,express_1[a0_0x2fcf0d(0x157)])();app['use'](express_1[a0_0x2fcf0d(0x157)]['json']());const baseDir=path[a0_0x2fcf0d(0x153)](os[a0_0x2fcf0d(0x17a)](),'.trimprompt'),logsDir=path[a0_0x2fcf0d(0x153)](baseDir,a0_0x2fcf0d(0x123));let configPayloadCache=null;const CONFIG_CACHE_TTL_MS=0x2710;function a0_0xda11(){const _0x2f2116=['/api/stats/summary','/api/config/toggle','5696056CMePmj','TRIMPROMPT_HEADLESS','reductionPct','configurable','compactPath','--headless','index.html','win32','/api/stats/history','.comp.txt','length','12vktWsP','then','claude','activeSavedTokens','Compressed\x20output\x20log\x20file\x20not\x20found.','filter','TRIMPROMPT_NO_OPEN','darwin','/api/config/open-dir','Raw\x20output\x20log\x20file\x20not\x20found.','codex','call','prototype','compressedTokens','create','logs','listen','12673107CgPDCt','SIGINT','catch','getConfig','__importStar','./file-watcher','express','auto','query','opencode','65263dIzPBr','lastModified','./tracker','__importDefault','No\x20active\x20session\x20file\x20found','readFileSync','getLogs','openclaw','favicon.png','child_process','sendFile','json','1vKjQRq','xdg-open\x20\x22','No\x20compressible\x20content\x20found\x20in\x20this\x20session','.raw.txt','code','Press\x20Ctrl+C\x20in\x20this\x20terminal\x20to\x20shut\x20down.','getOwnPropertyDescriptor','writable','\x0a[TrimPrompt]\x20Dashboard\x20server\x20started\x20at:\x20','includes','startDashboard','1305027koieKd','__setModuleDefault','32194ITOFoZ','ignore','payload','fileName','slice','6fPLhQc','path','get','../src/favicon.png','__esModule','command','join','EADDRINUSE','params','291956LxOTxY','default','gemini','fullPath','now','env','hasOwnProperty','setConfig','features_enabled','/api/config/custom-path','getOwnPropertyNames','defineProperty','kill','error','existsSync','tracker','SIGTERM','copilot','savedTokens','message','[TrimPrompt]\x20Dashboard\x20error:\x20','mkdirSync','2370NEgboT','open\x20\x22','utf8','cli.js','watcher','exit','7207635EJmDDb','/api/agent/compact','status','timestamp','/api/config/features','resolve','post','cursor','homedir','Missing\x20key','explorer\x20\x22','open','log','model','body','aider','execPath','platform'];a0_0xda11=function(){return _0x2f2116;};return a0_0xda11();}function invalidateConfigCache(){configPayloadCache=null;}app[a0_0x2fcf0d(0x14f)]('/',(_0x20d0bf,_0x15215b)=>{const _0x3975f8=a0_0x2fcf0d,_0x548390=path['join'](__dirname,_0x3975f8(0x10f));fs[_0x3975f8(0x164)](_0x548390)?_0x15215b[_0x3975f8(0x139)](_0x548390):_0x15215b[_0x3975f8(0x139)](path[_0x3975f8(0x153)](__dirname,'../src/index.html'));}),app[a0_0x2fcf0d(0x14f)]('/favicon.png',(_0x4e4e8d,_0x313a9e)=>{const _0x360516=a0_0x2fcf0d,_0x4780cb=path[_0x360516(0x153)](__dirname,_0x360516(0x137));fs[_0x360516(0x164)](_0x4780cb)?_0x313a9e[_0x360516(0x139)](_0x4780cb):_0x313a9e[_0x360516(0x139)](path['join'](__dirname,_0x360516(0x150)));}),app[a0_0x2fcf0d(0x14f)](a0_0x2fcf0d(0x107),(_0x3ba65a,_0x32c059)=>{const _0x1030b1=a0_0x2fcf0d,_0x5d1483=_0x3ba65a[_0x1030b1(0x12d)][_0x1030b1(0x102)]||_0x1030b1(0x12c),_0x28dac8=tracker_1[_0x1030b1(0x165)]['getStatsSummary'](_0x5d1483);_0x32c059[_0x1030b1(0x13a)](_0x28dac8);}),app['get'](a0_0x2fcf0d(0x111),(_0x55ffe3,_0x3c2d62)=>{const _0x4e305b=a0_0x2fcf0d,_0x1f2221=tracker_1[_0x4e305b(0x165)][_0x4e305b(0x135)]();_0x3c2d62[_0x4e305b(0x13a)](_0x1f2221['length']>0x1f4?_0x1f2221[_0x4e305b(0x14c)](-0x1f4):_0x1f2221);}),app[a0_0x2fcf0d(0x14f)]('/api/stats/inspect/:id',(_0x93632a,_0x26202d)=>{const _0x98a084=a0_0x2fcf0d,_0x199a4f=_0x93632a[_0x98a084(0x155)]['id'],_0x6fe0ed=path[_0x98a084(0x153)](logsDir,_0x199a4f+_0x98a084(0x13e)),_0x560aa2=path[_0x98a084(0x153)](logsDir,_0x199a4f+_0x98a084(0x112));let _0x28e9a6=_0x98a084(0x11d),_0x3a5a85=_0x98a084(0x118);try{fs['existsSync'](_0x6fe0ed)&&(_0x28e9a6=fs['readFileSync'](_0x6fe0ed,_0x98a084(0x16e))),fs['existsSync'](_0x560aa2)&&(_0x3a5a85=fs[_0x98a084(0x134)](_0x560aa2,_0x98a084(0x16e)));}catch(_0xda5e87){}_0x26202d[_0x98a084(0x13a)]({'id':_0x199a4f,'raw':_0x28e9a6,'compressed':_0x3a5a85});}),app[a0_0x2fcf0d(0x14f)](a0_0x2fcf0d(0x176),(_0x51f3ca,_0x1e8fdd)=>{const _0x5a1673=a0_0x2fcf0d,_0x5bf1b1=tracker_1[_0x5a1673(0x165)][_0x5a1673(0x128)]();_0x1e8fdd[_0x5a1673(0x13a)](_0x5bf1b1[_0x5a1673(0x15e)]||{});}),app[a0_0x2fcf0d(0x178)](a0_0x2fcf0d(0x176),(_0x1ed4f2,_0x9c908e)=>{const _0x11d1bd=a0_0x2fcf0d,_0x9a299b=_0x1ed4f2['body'];tracker_1[_0x11d1bd(0x165)][_0x11d1bd(0x15d)](_0x11d1bd(0x15e),_0x9a299b),invalidateConfigCache(),_0x9c908e['json']({'ok':!![]});}),app[a0_0x2fcf0d(0x178)](a0_0x2fcf0d(0x173),async(_0x11fe6a,_0x5d29fa)=>{const _0x508904=a0_0x2fcf0d;try{const {getLatestSessionFile:_0x326538,compactSessionCopy:_0xbe84fc}=await Promise[_0x508904(0x177)]()[_0x508904(0x115)](()=>__importStar(require(_0x508904(0x12a)))),{agentKey:_0x4a5eab}=_0x11fe6a[_0x508904(0x103)]||{},_0x2fd245=_0x4a5eab||_0x508904(0x116),_0x502bbb=_0x326538(_0x2fd245);if(_0x502bbb&&_0x502bbb[_0x508904(0x159)]&&fs[_0x508904(0x164)](_0x502bbb[_0x508904(0x159)])){const _0x393bd4=_0xbe84fc(_0x502bbb[_0x508904(0x159)],_0x2fd245);_0x393bd4['ok']&&(_0x393bd4[_0x508904(0x168)]||0x0)>0x0?_0x5d29fa[_0x508904(0x13a)]({'ok':!![],'fileName':_0x502bbb[_0x508904(0x14b)],'tokensSaved':_0x393bd4[_0x508904(0x168)],'rawTokens':_0x393bd4['rawTokens'],'compressedTokens':_0x393bd4[_0x508904(0x121)],'reductionPct':_0x393bd4[_0x508904(0x10b)],'compactPath':_0x393bd4[_0x508904(0x10d)]}):_0x5d29fa[_0x508904(0x13a)]({'ok':![],'message':_0x393bd4['reason']||_0x508904(0x13d)});}else _0x5d29fa[_0x508904(0x13a)]({'ok':![],'message':_0x508904(0x133)});}catch(_0x3606ce){_0x5d29fa['status'](0x1f4)[_0x508904(0x13a)]({'ok':![],'error':_0x3606ce[_0x508904(0x169)]});}}),app[a0_0x2fcf0d(0x14f)]('/api/config',async(_0x1d374d,_0x2b1e8f)=>{const _0x3d1715=a0_0x2fcf0d;if(configPayloadCache&&Date[_0x3d1715(0x15a)]()-configPayloadCache['at']<CONFIG_CACHE_TTL_MS)return _0x2b1e8f[_0x3d1715(0x13a)](configPayloadCache[_0x3d1715(0x14a)]);const {loadConfig:_0x5339ec,getAgentStoragePaths:_0x456f68,getLatestSessionFile:_0x2dba71,loadSessionsState:_0x563c80}=await Promise['resolve']()[_0x3d1715(0x115)](()=>__importStar(require(_0x3d1715(0x12a)))),_0x5ceddd=_0x5339ec(),_0xeb30a3=[_0x3d1715(0x116),_0x3d1715(0x158),_0x3d1715(0x11e),_0x3d1715(0x179),_0x3d1715(0x104),_0x3d1715(0x167),_0x3d1715(0x136),_0x3d1715(0x12e),'cortex'],_0x1ab7f9={},_0xbd3c46={},_0x2e43ab={},_0x239691=_0x563c80(),_0x336306=tracker_1[_0x3d1715(0x165)]['getLogs']()||[];for(const _0x3d0f40 of _0xeb30a3){_0x1ab7f9[_0x3d0f40]=_0x456f68(_0x3d0f40);const _0x5cc63d=_0x2dba71(_0x3d0f40);if(_0x5cc63d&&_0x5cc63d[_0x3d1715(0x159)]&&_0x239691[_0x5cc63d[_0x3d1715(0x159)]])_0x5cc63d[_0x3d1715(0x117)]=_0x239691[_0x5cc63d['fullPath']][_0x3d1715(0x117)]||0x0;else{if(_0x5cc63d)_0x5cc63d['activeSavedTokens']=0x0;}_0x2e43ab[_0x3d0f40]=_0x5cc63d;const _0x53e82e=_0x336306[_0x3d1715(0x119)](_0x2658d5=>_0x2658d5[_0x3d1715(0x152)]&&_0x2658d5[_0x3d1715(0x152)]['includes']('conv:'+_0x3d0f40));_0x53e82e[_0x3d1715(0x113)]>0x0?_0xbd3c46[_0x3d0f40]=_0x53e82e[_0x53e82e[_0x3d1715(0x113)]-0x1][_0x3d1715(0x175)]:_0xbd3c46[_0x3d0f40]=_0x5cc63d?_0x5cc63d[_0x3d1715(0x130)]:null;}const _0x3675b0={..._0x5ceddd,'resolvedPaths':_0x1ab7f9,'lastActiveTimestamps':_0xbd3c46,'latestSessions':_0x2e43ab};configPayloadCache={'at':Date[_0x3d1715(0x15a)](),'payload':_0x3675b0},_0x2b1e8f[_0x3d1715(0x13a)](_0x3675b0);}),app[a0_0x2fcf0d(0x178)](a0_0x2fcf0d(0x11c),async(_0x53c71f,_0x4e451e)=>{const _0x223880=a0_0x2fcf0d,{getAgentStoragePaths:_0x44ada1}=await Promise[_0x223880(0x177)]()[_0x223880(0x115)](()=>__importStar(require('./file-watcher'))),{agentKey:_0x4067b7}=_0x53c71f['body']||{};if(!_0x4067b7)return _0x4e451e[_0x223880(0x174)](0x190)[_0x223880(0x13a)]({'error':'Missing\x20agentKey'});const _0x2c1959=_0x44ada1(_0x4067b7),_0x1d731a=_0x2c1959['find'](_0x14e064=>fs[_0x223880(0x164)](_0x14e064))||_0x2c1959[0x0];if(_0x1d731a){if(!fs[_0x223880(0x164)](_0x1d731a))try{fs[_0x223880(0x16b)](_0x1d731a,{'recursive':!![]});}catch{}const {exec:_0x2f16a8}=await Promise[_0x223880(0x177)]()[_0x223880(0x115)](()=>__importStar(require(_0x223880(0x138)))),_0x1549fd=process[_0x223880(0x106)]===_0x223880(0x110)?_0x223880(0xff)+_0x1d731a+'\x22':process[_0x223880(0x106)]===_0x223880(0x11b)?_0x223880(0x16d)+_0x1d731a+'\x22':_0x223880(0x13c)+_0x1d731a+'\x22';return _0x2f16a8(_0x1549fd),_0x4e451e[_0x223880(0x13a)]({'success':!![],'openedPath':_0x1d731a});}_0x4e451e[_0x223880(0x174)](0x194)[_0x223880(0x13a)]({'error':'Directory\x20not\x20found'});}),app[a0_0x2fcf0d(0x178)](a0_0x2fcf0d(0x108),async(_0x387014,_0x387795)=>{const _0x16287e=a0_0x2fcf0d,{saveConfig:_0x468d90}=await Promise[_0x16287e(0x177)]()[_0x16287e(0x115)](()=>__importStar(require(_0x16287e(0x12a)))),{key:_0x18954b,value:_0x327c3b}=_0x387014[_0x16287e(0x103)]||{};if(_0x18954b){const _0x4b1a75=_0x468d90({'conversation_toggles':{[_0x18954b]:_0x327c3b}});return invalidateConfigCache(),_0x387795[_0x16287e(0x13a)](_0x4b1a75);}_0x387795[_0x16287e(0x174)](0x190)[_0x16287e(0x13a)]({'error':_0x16287e(0x17b)});}),app['post'](a0_0x2fcf0d(0x15f),async(_0xcd99ef,_0x1a5807)=>{const _0x58dec6=a0_0x2fcf0d,{saveConfig:_0x6b64f}=await Promise[_0x58dec6(0x177)]()[_0x58dec6(0x115)](()=>__importStar(require(_0x58dec6(0x12a)))),{agentKey:_0x489f6d,path:_0x47f344}=_0xcd99ef[_0x58dec6(0x103)]||{};if(_0x489f6d){const _0x10f34f=_0x6b64f({'custom_storage_paths':{[_0x489f6d]:_0x47f344||null}});return invalidateConfigCache(),_0x1a5807['json'](_0x10f34f);}_0x1a5807[_0x58dec6(0x174)](0x190)[_0x58dec6(0x13a)]({'error':'Missing\x20agentKey'});});function startDashboard(_0x51e225=0xfa0){const _0x5286e3=a0_0x2fcf0d;let _0x4ee161=_0x51e225;const _0x1dcc42=process['argv'][_0x5286e3(0x144)](_0x5286e3(0x10e))||process[_0x5286e3(0x15b)][_0x5286e3(0x10a)]==='1',_0x177bc9=app[_0x5286e3(0x124)](_0x4ee161,()=>{const _0x3c0c29=_0x5286e3,_0x97a479='http://localhost:'+_0x4ee161;!_0x1dcc42&&(console[_0x3c0c29(0x101)](_0x3c0c29(0x143)+_0x97a479),console['log'](_0x3c0c29(0x140)));try{const {spawn:_0x4cd5a3}=require(_0x3c0c29(0x138)),_0x388eb8=_0x4cd5a3(process[_0x3c0c29(0x105)],[path[_0x3c0c29(0x153)](__dirname,_0x3c0c29(0x16f)),_0x3c0c29(0x170),'start'],{'stdio':_0x3c0c29(0x149),'windowsHide':!![]}),_0x2d8250=()=>{const _0x47b5fd=_0x3c0c29;try{_0x388eb8[_0x47b5fd(0x162)]();}catch{}};process['on'](_0x3c0c29(0x171),_0x2d8250),process['on'](_0x3c0c29(0x126),()=>{const _0x365c3e=_0x3c0c29;_0x2d8250(),process[_0x365c3e(0x171)](0x0);}),process['on'](_0x3c0c29(0x166),()=>{const _0x47a2db=_0x3c0c29;_0x2d8250(),process[_0x47a2db(0x171)](0x0);});}catch{}!_0x1dcc42&&process['env'][_0x3c0c29(0x11a)]!=='1'&&(0x0,open_1[_0x3c0c29(0x157)])(_0x97a479)[_0x3c0c29(0x127)](()=>{});});_0x177bc9['on']('error',_0xc2fbf8=>{const _0x8f06c9=_0x5286e3;_0xc2fbf8[_0x8f06c9(0x13f)]===_0x8f06c9(0x154)?startDashboard(_0x4ee161+0x1):console[_0x8f06c9(0x163)](_0x8f06c9(0x16a)+_0xc2fbf8[_0x8f06c9(0x169)]);});}
1
+ 'use strict';const a0_0x413d4c=a0_0x4b54;(function(_0x2442cc,_0x2a56ff){const _0x47aeac=a0_0x4b54,_0x418e01=_0x2442cc();while(!![]){try{const _0x51def3=-parseInt(_0x47aeac(0x174))/0x1*(-parseInt(_0x47aeac(0x12c))/0x2)+parseInt(_0x47aeac(0x148))/0x3*(-parseInt(_0x47aeac(0x147))/0x4)+parseInt(_0x47aeac(0x126))/0x5*(-parseInt(_0x47aeac(0x112))/0x6)+-parseInt(_0x47aeac(0x16b))/0x7+-parseInt(_0x47aeac(0x13c))/0x8*(parseInt(_0x47aeac(0x15e))/0x9)+parseInt(_0x47aeac(0x11f))/0xa+parseInt(_0x47aeac(0x162))/0xb;if(_0x51def3===_0x2a56ff)break;else _0x418e01['push'](_0x418e01['shift']());}catch(_0x2bf17a){_0x418e01['push'](_0x418e01['shift']());}}}(a0_0xc155,0xa0cf6));var __createBinding=this&&this['__createBinding']||(Object[a0_0x413d4c(0x11b)]?function(_0x498ec9,_0x7c80cd,_0x239e02,_0xcd4bc7){const _0x397f53=a0_0x413d4c;if(_0xcd4bc7===undefined)_0xcd4bc7=_0x239e02;var _0xec05a1=Object['getOwnPropertyDescriptor'](_0x7c80cd,_0x239e02);(!_0xec05a1||('get'in _0xec05a1?!_0x7c80cd[_0x397f53(0x11c)]:_0xec05a1[_0x397f53(0x17c)]||_0xec05a1[_0x397f53(0x151)]))&&(_0xec05a1={'enumerable':!![],'get':function(){return _0x7c80cd[_0x239e02];}}),Object[_0x397f53(0x138)](_0x498ec9,_0xcd4bc7,_0xec05a1);}:function(_0x1d6922,_0x6d6fd9,_0x2bc8e5,_0x21337a){if(_0x21337a===undefined)_0x21337a=_0x2bc8e5;_0x1d6922[_0x21337a]=_0x6d6fd9[_0x2bc8e5];}),__setModuleDefault=this&&this[a0_0x413d4c(0x11a)]||(Object[a0_0x413d4c(0x11b)]?function(_0x24592a,_0x5d969f){const _0x2cfc1e=a0_0x413d4c;Object['defineProperty'](_0x24592a,_0x2cfc1e(0x161),{'enumerable':!![],'value':_0x5d969f});}:function(_0x4b01cd,_0x4a3cf5){_0x4b01cd['default']=_0x4a3cf5;}),__importStar=this&&this[a0_0x413d4c(0x12e)]||(function(){var _0x68780c=function(_0x34a3a2){return _0x68780c=Object['getOwnPropertyNames']||function(_0x309f39){const _0x4fd819=a0_0x4b54;var _0x2682f4=[];for(var _0x5a2f85 in _0x309f39)if(Object[_0x4fd819(0x120)][_0x4fd819(0x144)]['call'](_0x309f39,_0x5a2f85))_0x2682f4[_0x2682f4[_0x4fd819(0x175)]]=_0x5a2f85;return _0x2682f4;},_0x68780c(_0x34a3a2);};return function(_0x274b59){const _0x30c974=a0_0x4b54;if(_0x274b59&&_0x274b59['__esModule'])return _0x274b59;var _0x277407={};if(_0x274b59!=null){for(var _0x471a7b=_0x68780c(_0x274b59),_0x3127f4=0x0;_0x3127f4<_0x471a7b[_0x30c974(0x175)];_0x3127f4++)if(_0x471a7b[_0x3127f4]!=='default')__createBinding(_0x277407,_0x274b59,_0x471a7b[_0x3127f4]);}return __setModuleDefault(_0x277407,_0x274b59),_0x277407;};}()),__importDefault=this&&this[a0_0x413d4c(0x136)]||function(_0x96626e){const _0x36f502=a0_0x413d4c;return _0x96626e&&_0x96626e[_0x36f502(0x11c)]?_0x96626e:{'default':_0x96626e};};Object[a0_0x413d4c(0x138)](exports,'__esModule',{'value':!![]}),exports[a0_0x413d4c(0x170)]=startDashboard;const express_1=__importDefault(require('express')),path=__importStar(require(a0_0x413d4c(0x16e))),fs=__importStar(require('fs')),os=__importStar(require('os')),open_1=__importDefault(require(a0_0x413d4c(0x179))),tracker_1=require('./tracker'),app=(0x0,express_1['default'])();app['use'](express_1[a0_0x413d4c(0x161)][a0_0x413d4c(0x153)]());const baseDir=path[a0_0x413d4c(0x16a)](os['homedir'](),'.trimprompt'),logsDir=path[a0_0x413d4c(0x16a)](baseDir,'logs');let configPayloadCache=null;const CONFIG_CACHE_TTL_MS=0x2710;function a0_0xc155(){const _0x5871e7=['/api/stats/inspect/:id','../src/index.html','mkdirSync','tracker','reason','join','8660078LUfdYe','/api/stats/summary','No\x20active\x20session\x20file\x20found','path','--headless','startDashboard','query','then','darwin','4370RaEMml','length','post','existsSync','http://localhost:','open','body','readFileSync','writable','cortex','command','48YDNxJI','status','xdg-open\x20\x22','params','conv:','features_enabled','compressedTokens','listen','__setModuleDefault','create','__esModule','ignore','fullPath','8567180lMWwPo','prototype','message','get','codex','auto','activeSavedTokens','47865tcVGRz','watcher','timestamp','No\x20compressible\x20content\x20found\x20in\x20this\x20session','setConfig','fileName','392LokzJC','/api/agent/compact','__importStar','./file-watcher','open\x20\x22','.raw.txt','gemini','opencode','explorer\x20\x22','EADDRINUSE','__importDefault','SIGINT','defineProperty','rawTokens','sendFile','Missing\x20key','4699216itnTEN','exit','savedTokens','/api/config/open-dir','/api/stats/history','.comp.txt','getLogs','getStatsSummary','hasOwnProperty','child_process','log','8mkUFtu','157203tzRtYu','find','cli.js','platform','../src/favicon.png','/api/config/toggle','getConfig','/api/config/features','includes','configurable','catch','json','cursor','/api/config','aider','error','\x0a[TrimPrompt]\x20Dashboard\x20server\x20started\x20at:\x20','Press\x20Ctrl+C\x20in\x20this\x20terminal\x20to\x20shut\x20down.','resolve','payload','compactPath','execPath','9WvRnoX','now','Missing\x20agentKey','default','10465202bVyYwa','index.html','Raw\x20output\x20log\x20file\x20not\x20found.'];a0_0xc155=function(){return _0x5871e7;};return a0_0xc155();}function invalidateConfigCache(){configPayloadCache=null;}function a0_0x4b54(_0x4be6f0,_0x54a070){_0x4be6f0=_0x4be6f0-0x110;const _0xc15501=a0_0xc155();let _0x4b5497=_0xc15501[_0x4be6f0];return _0x4b5497;}app[a0_0x413d4c(0x122)]('/',(_0x2b9f21,_0x5113a6)=>{const _0x4e84e3=a0_0x413d4c,_0x230b10=path[_0x4e84e3(0x16a)](__dirname,_0x4e84e3(0x163));fs[_0x4e84e3(0x177)](_0x230b10)?_0x5113a6[_0x4e84e3(0x13a)](_0x230b10):_0x5113a6[_0x4e84e3(0x13a)](path[_0x4e84e3(0x16a)](__dirname,_0x4e84e3(0x166)));}),app[a0_0x413d4c(0x122)]('/favicon.png',(_0x396d56,_0x39ee48)=>{const _0x5f26fe=a0_0x413d4c,_0x54f735=path['join'](__dirname,'favicon.png');fs['existsSync'](_0x54f735)?_0x39ee48[_0x5f26fe(0x13a)](_0x54f735):_0x39ee48[_0x5f26fe(0x13a)](path[_0x5f26fe(0x16a)](__dirname,_0x5f26fe(0x14c)));}),app[a0_0x413d4c(0x122)](a0_0x413d4c(0x16c),(_0x52720b,_0x3f9f88)=>{const _0x386a32=a0_0x413d4c,_0x2c436b=_0x52720b[_0x386a32(0x171)]['model']||_0x386a32(0x124),_0x16161f=tracker_1[_0x386a32(0x168)][_0x386a32(0x143)](_0x2c436b);_0x3f9f88['json'](_0x16161f);}),app[a0_0x413d4c(0x122)](a0_0x413d4c(0x140),(_0x329e09,_0x539e23)=>{const _0x428727=a0_0x413d4c,_0x11719d=tracker_1[_0x428727(0x168)][_0x428727(0x142)]();_0x539e23[_0x428727(0x153)](_0x11719d['length']>0x1f4?_0x11719d['slice'](-0x1f4):_0x11719d);}),app[a0_0x413d4c(0x122)](a0_0x413d4c(0x165),(_0x264b81,_0x1afa09)=>{const _0x248a7d=a0_0x413d4c,_0x15cd5f=_0x264b81[_0x248a7d(0x115)]['id'],_0x51fa36=path[_0x248a7d(0x16a)](logsDir,_0x15cd5f+_0x248a7d(0x131)),_0x2c8750=path['join'](logsDir,_0x15cd5f+_0x248a7d(0x141));let _0x4d28a6=_0x248a7d(0x164),_0x17a0f6='Compressed\x20output\x20log\x20file\x20not\x20found.';try{fs[_0x248a7d(0x177)](_0x51fa36)&&(_0x4d28a6=fs[_0x248a7d(0x17b)](_0x51fa36,'utf8')),fs[_0x248a7d(0x177)](_0x2c8750)&&(_0x17a0f6=fs['readFileSync'](_0x2c8750,'utf8'));}catch(_0x4f2cf3){}_0x1afa09[_0x248a7d(0x153)]({'id':_0x15cd5f,'raw':_0x4d28a6,'compressed':_0x17a0f6});}),app[a0_0x413d4c(0x122)](a0_0x413d4c(0x14f),(_0x4e7550,_0xd7982e)=>{const _0xc28192=a0_0x413d4c,_0x1edc02=tracker_1[_0xc28192(0x168)][_0xc28192(0x14e)]();_0xd7982e[_0xc28192(0x153)](_0x1edc02[_0xc28192(0x117)]||{});}),app[a0_0x413d4c(0x176)](a0_0x413d4c(0x14f),(_0x4f55f4,_0x19eb1c)=>{const _0x1eb556=a0_0x413d4c,_0x3e67a6=_0x4f55f4[_0x1eb556(0x17a)];tracker_1[_0x1eb556(0x168)][_0x1eb556(0x12a)](_0x1eb556(0x117),_0x3e67a6),invalidateConfigCache(),_0x19eb1c[_0x1eb556(0x153)]({'ok':!![]});}),app[a0_0x413d4c(0x176)](a0_0x413d4c(0x12d),async(_0xd227f1,_0x1ddca9)=>{const _0x1de704=a0_0x413d4c;try{const {getLatestSessionFile:_0x3719ee,compactSessionCopy:_0x334667}=await Promise['resolve']()[_0x1de704(0x172)](()=>__importStar(require(_0x1de704(0x12f)))),{agentKey:_0x57ac66}=_0xd227f1[_0x1de704(0x17a)]||{},_0x3c217b=_0x57ac66||'claude',_0x2a8f9f=_0x3719ee(_0x3c217b);if(_0x2a8f9f&&_0x2a8f9f[_0x1de704(0x11e)]&&fs['existsSync'](_0x2a8f9f[_0x1de704(0x11e)])){const _0x1a5089=_0x334667(_0x2a8f9f['fullPath'],_0x3c217b);_0x1a5089['ok']&&(_0x1a5089[_0x1de704(0x13e)]||0x0)>0x0?_0x1ddca9[_0x1de704(0x153)]({'ok':!![],'fileName':_0x2a8f9f[_0x1de704(0x12b)],'tokensSaved':_0x1a5089['savedTokens'],'rawTokens':_0x1a5089[_0x1de704(0x139)],'compressedTokens':_0x1a5089[_0x1de704(0x118)],'reductionPct':_0x1a5089['reductionPct'],'compactPath':_0x1a5089[_0x1de704(0x15c)]}):_0x1ddca9[_0x1de704(0x153)]({'ok':![],'message':_0x1a5089[_0x1de704(0x169)]||_0x1de704(0x129)});}else _0x1ddca9[_0x1de704(0x153)]({'ok':![],'message':_0x1de704(0x16d)});}catch(_0x41b861){_0x1ddca9['status'](0x1f4)['json']({'ok':![],'error':_0x41b861['message']});}}),app[a0_0x413d4c(0x122)](a0_0x413d4c(0x155),async(_0x1d3b62,_0x21c0cc)=>{const _0x376046=a0_0x413d4c;if(configPayloadCache&&Date[_0x376046(0x15f)]()-configPayloadCache['at']<CONFIG_CACHE_TTL_MS)return _0x21c0cc[_0x376046(0x153)](configPayloadCache[_0x376046(0x15b)]);const {loadConfig:_0x5240be,getAgentStoragePaths:_0x52eb85,getLatestSessionFile:_0x56e09f,loadSessionsState:_0x1d0b71}=await Promise[_0x376046(0x15a)]()[_0x376046(0x172)](()=>__importStar(require(_0x376046(0x12f)))),_0x3ee2c9=_0x5240be(),_0xa78385=['claude',_0x376046(0x132),_0x376046(0x123),_0x376046(0x154),_0x376046(0x156),'copilot','openclaw',_0x376046(0x133),_0x376046(0x110)],_0x1e15ef={},_0x57d274={},_0x5c5f7d={},_0x224ab7=_0x1d0b71(),_0x2fe6ff=tracker_1[_0x376046(0x168)]['getLogs']()||[];for(const _0x502bd3 of _0xa78385){_0x1e15ef[_0x502bd3]=_0x52eb85(_0x502bd3);const _0x252031=_0x56e09f(_0x502bd3);if(_0x252031&&_0x252031['fullPath']&&_0x224ab7[_0x252031[_0x376046(0x11e)]])_0x252031[_0x376046(0x125)]=_0x224ab7[_0x252031[_0x376046(0x11e)]][_0x376046(0x125)]||0x0;else{if(_0x252031)_0x252031[_0x376046(0x125)]=0x0;}_0x5c5f7d[_0x502bd3]=_0x252031;const _0xc85471=_0x2fe6ff['filter'](_0x29b4c8=>_0x29b4c8[_0x376046(0x111)]&&_0x29b4c8[_0x376046(0x111)][_0x376046(0x150)](_0x376046(0x116)+_0x502bd3));_0xc85471[_0x376046(0x175)]>0x0?_0x57d274[_0x502bd3]=_0xc85471[_0xc85471[_0x376046(0x175)]-0x1][_0x376046(0x128)]:_0x57d274[_0x502bd3]=_0x252031?_0x252031['lastModified']:null;}const _0x31f026={..._0x3ee2c9,'resolvedPaths':_0x1e15ef,'lastActiveTimestamps':_0x57d274,'latestSessions':_0x5c5f7d};configPayloadCache={'at':Date[_0x376046(0x15f)](),'payload':_0x31f026},_0x21c0cc[_0x376046(0x153)](_0x31f026);}),app['post'](a0_0x413d4c(0x13f),async(_0x3d189b,_0x472d21)=>{const _0x4a4716=a0_0x413d4c,{getAgentStoragePaths:_0x62b97d}=await Promise[_0x4a4716(0x15a)]()[_0x4a4716(0x172)](()=>__importStar(require(_0x4a4716(0x12f)))),{agentKey:_0x254326}=_0x3d189b[_0x4a4716(0x17a)]||{};if(!_0x254326)return _0x472d21[_0x4a4716(0x113)](0x190)['json']({'error':'Missing\x20agentKey'});const _0x2800d3=_0x62b97d(_0x254326),_0x5dbb1e=_0x2800d3[_0x4a4716(0x149)](_0xde03f3=>fs[_0x4a4716(0x177)](_0xde03f3))||_0x2800d3[0x0];if(_0x5dbb1e){if(!fs[_0x4a4716(0x177)](_0x5dbb1e))try{fs[_0x4a4716(0x167)](_0x5dbb1e,{'recursive':!![]});}catch{}const {exec:_0x460944}=await Promise[_0x4a4716(0x15a)]()['then'](()=>__importStar(require(_0x4a4716(0x145)))),_0x33fb85=process[_0x4a4716(0x14b)]==='win32'?_0x4a4716(0x134)+_0x5dbb1e+'\x22':process['platform']===_0x4a4716(0x173)?_0x4a4716(0x130)+_0x5dbb1e+'\x22':_0x4a4716(0x114)+_0x5dbb1e+'\x22';return _0x460944(_0x33fb85),_0x472d21['json']({'success':!![],'openedPath':_0x5dbb1e});}_0x472d21[_0x4a4716(0x113)](0x194)[_0x4a4716(0x153)]({'error':'Directory\x20not\x20found'});}),app[a0_0x413d4c(0x176)](a0_0x413d4c(0x14d),async(_0x15ce74,_0x2f7f4e)=>{const _0x4cea19=a0_0x413d4c,{saveConfig:_0x416a49}=await Promise[_0x4cea19(0x15a)]()[_0x4cea19(0x172)](()=>__importStar(require(_0x4cea19(0x12f)))),{key:_0x17f000,value:_0x316b16}=_0x15ce74['body']||{};if(_0x17f000){const _0x49469a=_0x416a49({'conversation_toggles':{[_0x17f000]:_0x316b16}});return invalidateConfigCache(),_0x2f7f4e[_0x4cea19(0x153)](_0x49469a);}_0x2f7f4e[_0x4cea19(0x113)](0x190)['json']({'error':_0x4cea19(0x13b)});}),app[a0_0x413d4c(0x176)]('/api/config/custom-path',async(_0x47ef5f,_0x33541e)=>{const _0x6bdc60=a0_0x413d4c,{saveConfig:_0x5edca0}=await Promise[_0x6bdc60(0x15a)]()[_0x6bdc60(0x172)](()=>__importStar(require('./file-watcher'))),{agentKey:_0x595804,path:_0x14a69b}=_0x47ef5f[_0x6bdc60(0x17a)]||{};if(_0x595804){const _0x4b6b34=_0x5edca0({'custom_storage_paths':{[_0x595804]:_0x14a69b||null}});return invalidateConfigCache(),_0x33541e['json'](_0x4b6b34);}_0x33541e[_0x6bdc60(0x113)](0x190)[_0x6bdc60(0x153)]({'error':_0x6bdc60(0x160)});});function startDashboard(_0x3d94cf=0xfa0){const _0x20e661=a0_0x413d4c;let _0x454ab8=_0x3d94cf;const _0x30025d=process['argv'][_0x20e661(0x150)](_0x20e661(0x16f))||process.env.TRIMPROMPT_HEADLESS==='1',_0x551496=app[_0x20e661(0x119)](_0x454ab8,()=>{const _0x4e21a0=_0x20e661,_0x566711=_0x4e21a0(0x178)+_0x454ab8;!_0x30025d&&(console[_0x4e21a0(0x146)](_0x4e21a0(0x158)+_0x566711),console[_0x4e21a0(0x146)](_0x4e21a0(0x159)));try{const {spawn:_0x456b86}=require(_0x4e21a0(0x145)),_0x5be189=_0x456b86(process[_0x4e21a0(0x15d)],[path[_0x4e21a0(0x16a)](__dirname,_0x4e21a0(0x14a)),_0x4e21a0(0x127),'start'],{'stdio':_0x4e21a0(0x11d),'windowsHide':!![]}),_0x985a2c=()=>{try{_0x5be189['kill']();}catch{}};process['on'](_0x4e21a0(0x13d),_0x985a2c),process['on'](_0x4e21a0(0x137),()=>{const _0x5d3bf4=_0x4e21a0;_0x985a2c(),process[_0x5d3bf4(0x13d)](0x0);}),process['on']('SIGTERM',()=>{_0x985a2c(),process['exit'](0x0);});}catch{}!_0x30025d&&process.env.TRIMPROMPT_NO_OPEN!=='1'&&(0x0,open_1['default'])(_0x566711)[_0x4e21a0(0x152)](()=>{});});_0x551496['on'](_0x20e661(0x157),_0x1892a3=>{const _0x35a4a8=_0x20e661;_0x1892a3['code']===_0x35a4a8(0x135)?startDashboard(_0x454ab8+0x1):console[_0x35a4a8(0x157)]('[TrimPrompt]\x20Dashboard\x20error:\x20'+_0x1892a3[_0x35a4a8(0x121)]);});}