trimprompt 1.0.41 → 1.0.43

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_0x4df239=a0_0x3086;(function(_0x28bc90,_0x50bd21){const _0x56c500=a0_0x3086,_0x595b75=_0x28bc90();while(!![]){try{const _0x4e8304=-parseInt(_0x56c500(0x156))/0x1*(parseInt(_0x56c500(0x175))/0x2)+parseInt(_0x56c500(0x210))/0x3*(parseInt(_0x56c500(0x1ef))/0x4)+-parseInt(_0x56c500(0x20f))/0x5*(parseInt(_0x56c500(0x19d))/0x6)+-parseInt(_0x56c500(0x172))/0x7+parseInt(_0x56c500(0x186))/0x8*(-parseInt(_0x56c500(0x1d6))/0x9)+-parseInt(_0x56c500(0x176))/0xa+parseInt(_0x56c500(0x20b))/0xb*(parseInt(_0x56c500(0x1b8))/0xc);if(_0x4e8304===_0x50bd21)break;else _0x595b75['push'](_0x595b75['shift']());}catch(_0x3bef47){_0x595b75['push'](_0x595b75['shift']());}}}(a0_0x2c7f,0x3777b));function a0_0x3086(_0xc56f66,_0x3cf6c2){_0xc56f66=_0xc56f66-0x13d;const _0x2c7f8c=a0_0x2c7f();let _0x3086b5=_0x2c7f8c[_0xc56f66];return _0x3086b5;}var __createBinding=this&&this[a0_0x4df239(0x1bc)]||(Object[a0_0x4df239(0x1cc)]?function(_0xd22015,_0x39fe60,_0x138aef,_0x3f4cfd){const _0x5388bb=a0_0x4df239;if(_0x3f4cfd===undefined)_0x3f4cfd=_0x138aef;var _0x190dac=Object['getOwnPropertyDescriptor'](_0x39fe60,_0x138aef);(!_0x190dac||('get'in _0x190dac?!_0x39fe60[_0x5388bb(0x226)]:_0x190dac[_0x5388bb(0x1e6)]||_0x190dac[_0x5388bb(0x21a)]))&&(_0x190dac={'enumerable':!![],'get':function(){return _0x39fe60[_0x138aef];}}),Object['defineProperty'](_0xd22015,_0x3f4cfd,_0x190dac);}:function(_0x50c889,_0x20ae9b,_0x53145a,_0x21a5ec){if(_0x21a5ec===undefined)_0x21a5ec=_0x53145a;_0x50c889[_0x21a5ec]=_0x20ae9b[_0x53145a];}),__setModuleDefault=this&&this[a0_0x4df239(0x1be)]||(Object[a0_0x4df239(0x1cc)]?function(_0x11900a,_0xdf4ee0){const _0x4a3e77=a0_0x4df239;Object[_0x4a3e77(0x18e)](_0x11900a,_0x4a3e77(0x18c),{'enumerable':!![],'value':_0xdf4ee0});}:function(_0x58109f,_0x583058){const _0x559ee8=a0_0x4df239;_0x58109f[_0x559ee8(0x18c)]=_0x583058;}),__importStar=this&&this[a0_0x4df239(0x1ec)]||(function(){var _0x3ddd81=function(_0x1bf772){return _0x3ddd81=Object['getOwnPropertyNames']||function(_0x19a74a){const _0xcd3dce=a0_0x3086;var _0x12a4a0=[];for(var _0x5e3c60 in _0x19a74a)if(Object['prototype']['hasOwnProperty']['call'](_0x19a74a,_0x5e3c60))_0x12a4a0[_0x12a4a0[_0xcd3dce(0x14d)]]=_0x5e3c60;return _0x12a4a0;},_0x3ddd81(_0x1bf772);};return function(_0x20e9d6){const _0x456248=a0_0x3086;if(_0x20e9d6&&_0x20e9d6[_0x456248(0x226)])return _0x20e9d6;var _0xf7ebdd={};if(_0x20e9d6!=null){for(var _0x1d71f8=_0x3ddd81(_0x20e9d6),_0x5e0098=0x0;_0x5e0098<_0x1d71f8[_0x456248(0x14d)];_0x5e0098++)if(_0x1d71f8[_0x5e0098]!==_0x456248(0x18c))__createBinding(_0xf7ebdd,_0x20e9d6,_0x1d71f8[_0x5e0098]);}return __setModuleDefault(_0xf7ebdd,_0x20e9d6),_0xf7ebdd;};}());Object[a0_0x4df239(0x18e)](exports,a0_0x4df239(0x226),{'value':!![]});const commander_1=require(a0_0x4df239(0x1cd)),executor_1=require('./executor'),filters_1=require(a0_0x4df239(0x140)),tracker_1=require(a0_0x4df239(0x204)),cache_1=require(a0_0x4df239(0x1f4)),shims_1=require(a0_0x4df239(0x1a1)),dashboard_1=require(a0_0x4df239(0x1d4)),program=new commander_1['Command']();function isDisabled(){return process.env.TRIMPROMPT_DISABLED==='1';}function adjustCommandArgs(_0x576c30,_0x1b353c){const _0x5218cd=a0_0x4df239,_0x151b27=_0x576c30['toLowerCase']();if(_0x151b27==='git'||_0x151b27===_0x5218cd(0x207)){const _0x371cd1=_0x1b353c[0x0];if(_0x371cd1===_0x5218cd(0x145)){const _0x25a460=_0x1b353c[_0x5218cd(0x161)](0x1),_0x5ba9a=_0x25a460['length']===0x0||_0x25a460[_0x5218cd(0x148)](_0xaa4526=>{const _0x318076=_0x5218cd;return _0xaa4526==='-b'||_0xaa4526==='--branch'||_0xaa4526===_0x318076(0x169)||_0xaa4526===_0x318076(0x1ba)||_0xaa4526==='-s'||_0xaa4526===_0x318076(0x1cb);});if(_0x5ba9a)return{'cmd':_0x576c30,'args':[_0x5218cd(0x145),_0x5218cd(0x21f),'-b']};}else{if(_0x371cd1===_0x5218cd(0x1a3)){const _0x5d7f81=_0x1b353c[_0x5218cd(0x161)](0x1),_0x161ae1=_0x5d7f81['some'](_0x5c3681=>_0x5c3681[_0x5218cd(0x1f1)](_0x5218cd(0x19f))||_0x5c3681[_0x5218cd(0x1f1)](_0x5218cd(0x20c))||_0x5c3681['startsWith'](_0x5218cd(0x196))),_0x2a7c07=_0x5d7f81[_0x5218cd(0x211)](_0x3be338=>_0x3be338['startsWith']('-')&&/^\d+$/[_0x5218cd(0x1e2)](_0x3be338[_0x5218cd(0x161)](0x1))||_0x3be338==='-n'||_0x3be338[_0x5218cd(0x1f1)](_0x5218cd(0x1c6))),_0x455c2f=[..._0x1b353c];if(!_0x161ae1){const _0x5f4cfc='--pretty=format:%h\x20%s\x20(%ar)\x20(%an)%n%b%n---END---';_0x455c2f[_0x5218cd(0x1bf)](process[_0x5218cd(0x197)]==='win32'?'\x22'+_0x5f4cfc+'\x22':_0x5f4cfc);}!_0x2a7c07&&(_0x161ae1?_0x455c2f[_0x5218cd(0x1bf)](_0x5218cd(0x189)):_0x455c2f[_0x5218cd(0x1bf)]('-10'));const _0x171323=_0x5d7f81[_0x5218cd(0x211)](_0x9e3087=>_0x9e3087===_0x5218cd(0x16f)||_0x9e3087==='--no-merges'||_0x9e3087[_0x5218cd(0x1f1)](_0x5218cd(0x1f9)));return!_0x171323&&!_0x2a7c07&&_0x455c2f[_0x5218cd(0x1bf)](_0x5218cd(0x1e3)),{'cmd':_0x576c30,'args':_0x455c2f};}}}return{'cmd':_0x576c30,'args':_0x1b353c};}function a0_0x2c7f(){const _0x50e9a8=['Tokens\x20Saved:\x20\x20\x20\x20\x20\x20','-50','Command\x20line\x20to\x20evaluate','../package.json','default','\x20\x20\x20\x20\x20\x20\x20TRIMPROMPT.AI\x20SAVINGS\x20SUMMARY\x20\x20\x20\x20\x20\x20\x20\x20','defineProperty','mcp','\x20\x20Then\x20just\x20work\x20normally.\x20TrimPrompt\x20trims\x20your\x20command','install\x20or\x20uninstall','toFixed','Actual\x20Cost:\x20\x20\x20\x20\x20\x20\x20$','argv','tracker','--format','platform','Original\x20file\x20untouched:\x20','version','\x20\x20\x20\x20\x20Claude\x20Code)\x20so\x20the\x20optimized\x20commands\x20take\x20effect.','cmd','write','24KBPtiV','Saved:\x20\x20\x20\x20\x20\x20','--oneline','child_process','./shims','\x20tokens\x20|\x20Total\x20savings:\x20','log','Manage\x20local\x20configuration\x20parameters','detectSessionTool','mcp-server','set','\x0a[TrimPrompt\x20Compact]\x20Clean\x20compressed\x20session\x20copy\x20generated.','resolve','\x20\x20email\x20domain\x20(e.g.\x20acme.com)\x20to\x20our\x20cloud.\x20Opt\x20out:\x20','Estimated\x20Cost:\x20\x20\x20\x20$','\x20\x20\x20\x20','\x0a\x1b[90m[TrimPrompt]\x20⚡\x20Active\x20session\x20(','Reduction\x20Rate:\x20\x20\x20\x20','TrimPrompt.ai\x20-\x20Reduce\x20LLM\x20token\x20consumption\x20by\x2060-90%','-p,\x20--port\x20<number>','gemini','rawBytes','toLowerCase','compressedTokens','\x1b[33m','\x1b[36m','getConfig','12AEbKoa','error','-bs','mcp-proxy','__createBinding','Error:\x20Value\x20required\x20for\x20set\x20action','__setModuleDefault','push','spawn','<commandLine>','\x20\x20output\x20automatically\x20in\x20the\x20background\x20—\x20nothing\x20to\x20configure.','npx','win32','__VERSION__','--max-count','argument','toISOString','false','option','--short','create','commander','path','\x20bytes)','raw_cost_usd','./mcp','server','Live\x20conversation\x20file-watcher\x20daemon\x20—\x20start,\x20install','./dashboard','\x20\x20claude\x20--resume\x20\x22','819umdTBO','parse','compressOutput','@modelcontextprotocol/','server-mcp','shims','\x20tokens\x20(','Generate\x20a\x20clean,\x20compressed\x20copy\x20of\x20a\x20conversation\x20session\x20file\x20for\x20safe\x20resume','Dashboard:\x20http://localhost:4000','[TrimPrompt\x20Compact]\x20Could\x20not\x20find\x20a\x20session\x20file\x20for\x20\x27','-m,\x20--model\x20<string>','includes','test','--no-merges','Port\x20to\x20run\x20the\x20dashboard\x20on','\x20(before\x20Trim)','writable','tool','name','message','rawTokens','Money\x20Saved:\x20\x20\x20\x20\x20\x20\x20$','__importStar','compact\x20[sessionId]','Raw\x20Tokens:\x20\x20\x20\x20\x20\x20\x20\x20','32mLFNRY','antigravity','startsWith','bun','watcher','./cache','description','activeSavedTokens','.trimprompt','logExecution','--min-parents','agent','money_saved_usd','action','Config\x20set\x20','output\x20the\x20version','command','Error:\x20Action\x20must\x20be\x20get\x20or\x20set','stderr','welcome','%\x20reduction)','./tracker','\x20=\x20','--help','yadm','dedup','exitCode','./file-watcher','8925213jHVhUr','--pretty','then','dirname','115730jSAPUX','146619HkrFPY','some','exit','sync.js','Compact\x20session\x20copy:\x20\x20\x20\x20','catch','\x0aTo\x20resume\x20with\x20lightweight\x20context,\x20execute:','help','\x1b[0m','/dev/tty','configurable','compressedBytes','Start\x20the\x20local\x20developer\x20dashboard','join','4000','--porcelain','stdout','TRIMPROMPT_NO_TELEMETRY=1','Check\x20a\x20command\x20line\x20and\x20return\x20the\x20optimized\x20command\x20line','redaction_enabled','node','Model\x20Context:\x20\x20\x20\x20\x20','__esModule','\x20tokens\x1b[39m\x0a','trim','.welcomed','savings_percentage','→\x20\x20open\x20the\x20live\x20dashboard\x20in\x20your\x20browser','./filters','1.0.41','dashboard','get','config','status','modelcontextprotocol','<action>','every','setConfig','Agent\x20key\x20(claude,\x20cursor,\x20codex,\x20...)','Compressed:\x20\x20\x20\x20\x20\x20\x20\x20','./cache-manager','length','fullPath','\x20\x20\x20','model','total_compressed_tokens','──────────────────────────────────────────────────────────','pnpm','stats','unlinkSync','52rFxkAO','toLocaleString','Retrieve\x20raw\x20offloaded\x20content\x20chunk\x20from\x20local\x20side-cache','trim\x20ui','Print\x20the\x20first-run\x20welcome\x20banner\x20(used\x20by\x20the\x20installer)','---------------------------------------------','savedTokens','retrieve','[value]','replace','raw_payload','slice','postinstall','\x27\x20not\x20found\x20or\x20expired.','total_raw_tokens','trim\x20stats','-v,\x20--version','\x20\x20✂\x20\x20',')\x20saved\x20','-sb','proxy','[TrimPrompt\x20Cache]\x20Chunk\x20\x27','getStatsSummary','config\x20parameter\x20name','Raw:\x20\x20\x20\x20\x20\x20\x20\x20','--merges','npm','rewrite','674093jdAaDx','lastFeatures','[TrimPrompt]\x20Autodetected\x20MCP\x20server\x20execution.\x20Activating\x20real-time\x20JSON-RPC\x20proxy...','6872ATrDFI','2753760bAZrAo','writeFileSync','→\x20\x20tokens\x20&\x20money\x20you\x27ve\x20saved\x20so\x20far','(No\x20content\x20exceeded\x20the\x20offload\x20threshold\x20—\x20nothing\x20to\x20compress.)','compactPath','lastRedactAudit','existsSync','\x20(after\x20Trim)','mkdirSync','.install_pinged','\x5c\x5c.\x5cCON','installShims','executeCommand','\x20\x20\x20\x20\x20\x20','port','ignore','29208wNJfwr','claude'];a0_0x2c7f=function(){return _0x50e9a8;};return a0_0x2c7f();}function isMcpServerExecution(_0x55c37a,_0x25746d){const _0x2590bb=a0_0x4df239,_0x567610=_0x55c37a['toLowerCase'](),_0x29432b=_0x25746d[_0x2590bb(0x21d)]('\x20')['toLowerCase']();if(_0x567610[_0x2590bb(0x1e1)](_0x2590bb(0x18f))&&(_0x567610[_0x2590bb(0x1e1)](_0x2590bb(0x1d2))||_0x567610[_0x2590bb(0x1e1)](_0x2590bb(0x16a))))return!![];if(_0x567610===_0x2590bb(0x1c3)||_0x567610===_0x2590bb(0x224)||_0x567610===_0x2590bb(0x1f2)||_0x567610===_0x2590bb(0x170)||_0x567610===_0x2590bb(0x153)||_0x567610==='yarn'){if(_0x29432b['includes'](_0x2590bb(0x1d9))||_0x29432b[_0x2590bb(0x1e1)](_0x2590bb(0x146))||_0x29432b['includes'](_0x2590bb(0x1a6))||_0x29432b['includes'](_0x2590bb(0x1da)))return!![];}if(_0x25746d[_0x2590bb(0x211)](_0x135c2d=>{const _0xa939c6=_0x2590bb,_0x5573f9=_0x135c2d[_0xa939c6(0x1b3)]();return _0x5573f9['includes'](_0xa939c6(0x1a6))||_0x5573f9[_0xa939c6(0x1e1)](_0xa939c6(0x1da))||_0x5573f9[_0xa939c6(0x1e1)](_0xa939c6(0x1d9))||_0x5573f9===_0xa939c6(0x1bb)||_0x5573f9===_0xa939c6(0x18f);}))return!![];return![];}async function runProxy(_0x3d7eae){const _0x364548=a0_0x4df239;if(_0x3d7eae[_0x364548(0x14d)]===0x0){program[_0x364548(0x217)]();return;}const _0x3c45b5=_0x3d7eae[0x0],_0x1cf63a=_0x3d7eae[_0x364548(0x161)](0x1),_0x404fc1=_0x3d7eae[_0x364548(0x21d)]('\x20');if(isDisabled()){const _0x597fc5=await(0x0,executor_1[_0x364548(0x182)])(_0x3c45b5,_0x1cf63a);process['stdout'][_0x364548(0x19c)](_0x597fc5[_0x364548(0x220)]),process[_0x364548(0x201)][_0x364548(0x19c)](_0x597fc5[_0x364548(0x201)]),process[_0x364548(0x212)](_0x597fc5[_0x364548(0x209)]);}if(isMcpServerExecution(_0x3c45b5,_0x1cf63a)){console[_0x364548(0x1b9)](_0x364548(0x174));const {runMcpProxy:_0x10b795}=await Promise[_0x364548(0x1a9)]()[_0x364548(0x20d)](()=>__importStar(require(_0x364548(0x1d1))));_0x10b795(_0x3c45b5,_0x1cf63a);return;}const _0x5a9cc0=adjustCommandArgs(_0x3c45b5,_0x1cf63a),_0x19bc78=await(0x0,executor_1[_0x364548(0x182)])(_0x5a9cc0[_0x364548(0x19b)],_0x5a9cc0['args']),_0x1ef628=(0x0,filters_1[_0x364548(0x1d8)])(_0x404fc1,_0x19bc78[_0x364548(0x220)],_0x19bc78['stderr'],tracker_1[_0x364548(0x195)][_0x364548(0x1b7)]()[_0x364548(0x223)]),_0x13312c={...filters_1[_0x364548(0x17b)]},_0x49ac89=_0x19bc78['stdout']+(_0x19bc78['stderr'][_0x364548(0x228)]()['length']>0x0?'\x0a'+_0x19bc78[_0x364548(0x201)]:''),_0x4aecca=_0x1ef628[_0x364548(0x14d)]<_0x49ac89['length']?_0x1ef628:_0x49ac89,_0x13de8e=_0x19bc78[_0x364548(0x209)]===0x0?(0x0,cache_1[_0x364548(0x208)])(_0x404fc1,_0x4aecca):null;tracker_1[_0x364548(0x195)][_0x364548(0x1f8)](_0x404fc1,_0x49ac89,_0x13de8e||_0x4aecca,_0x19bc78['exitCode'],_0x13312c,[...filters_1[_0x364548(0x173)]]);_0x19bc78[_0x364548(0x209)]===0x0?process[_0x364548(0x220)][_0x364548(0x19c)](_0x4aecca+'\x0a'):(process[_0x364548(0x220)][_0x364548(0x19c)](_0x1ef628+'\x0a'),_0x19bc78[_0x364548(0x201)][_0x364548(0x228)]()[_0x364548(0x14d)]>0x0&&!_0x1ef628[_0x364548(0x1e1)](_0x19bc78['stderr'][_0x364548(0x228)]())&&process[_0x364548(0x201)]['write'](_0x19bc78[_0x364548(0x201)]+'\x0a'));try{const {loadSessionsState:_0x520f3f,getLatestSessionFile:_0x1f5b86}=await Promise[_0x364548(0x1a9)]()[_0x364548(0x20d)](()=>__importStar(require(_0x364548(0x20a)))),_0x2c2d82=_0x520f3f(),_0xe1db93=(0x0,tracker_1[_0x364548(0x1a5)])(),_0x2c921c=_0xe1db93['tool']===_0x364548(0x1f0)?_0x364548(0x1b1):_0xe1db93[_0x364548(0x1e7)]||_0x364548(0x187),_0x1bb4f6=_0x1f5b86(_0x2c921c);let _0x4171d8=0x0;_0x1bb4f6&&_0x1bb4f6[_0x364548(0x14e)]&&_0x2c2d82[_0x1bb4f6['fullPath']]&&(_0x4171d8=_0x2c2d82[_0x1bb4f6[_0x364548(0x14e)]][_0x364548(0x1f6)]||0x0);let _0x4f608c=0x0;for(const _0x205fa1 of Object['keys'](_0x2c2d82)){_0x4f608c+=_0x2c2d82[_0x205fa1]['activeSavedTokens']||0x0;}(_0x4171d8>0x0||_0x4f608c>0x0)&&process[_0x364548(0x201)][_0x364548(0x19c)](_0x364548(0x1ad)+_0x2c921c+_0x364548(0x168)+_0x4171d8[_0x364548(0x157)]()+_0x364548(0x1a2)+_0x4f608c[_0x364548(0x157)]()+_0x364548(0x227));}catch{}process[_0x364548(0x212)](_0x19bc78[_0x364548(0x209)]);}const PKG_VERSION=((()=>{const _0x1b75a0=a0_0x4df239,_0x36224e=_0x1b75a0(0x141);if(_0x36224e!==_0x1b75a0(0x1c5))return _0x36224e;try{return require(_0x1b75a0(0x18b))[_0x1b75a0(0x199)];}catch{try{return require('./package.json')[_0x1b75a0(0x199)];}catch{return'1.0.0';}}})());program[a0_0x4df239(0x1e8)](a0_0x4df239(0x228))[a0_0x4df239(0x1f5)](a0_0x4df239(0x1af))[a0_0x4df239(0x199)](PKG_VERSION,a0_0x4df239(0x166),a0_0x4df239(0x1fe)),program[a0_0x4df239(0x1ff)](a0_0x4df239(0x199))[a0_0x4df239(0x1f5)]('Print\x20the\x20TrimPrompt\x20version')[a0_0x4df239(0x1fc)](()=>{const _0x332c3d=a0_0x4df239;console[_0x332c3d(0x1a3)](PKG_VERSION);}),program[a0_0x4df239(0x1ff)]('ui')['alias'](a0_0x4df239(0x142))['description'](a0_0x4df239(0x21c))['option'](a0_0x4df239(0x1b0),a0_0x4df239(0x1e4),a0_0x4df239(0x21e))['action'](_0x347822=>{const _0xa02fa6=a0_0x4df239,_0x114762=parseInt(_0x347822[_0xa02fa6(0x184)],0xa);(0x0,dashboard_1['startDashboard'])(_0x114762);}),program[a0_0x4df239(0x1ff)](a0_0x4df239(0x154))[a0_0x4df239(0x1f5)]('Show\x20token\x20and\x20cost\x20savings\x20summary')['option'](a0_0x4df239(0x1e0),'Select\x20pricing\x20model\x20(e.g.\x20claude-3-5-sonnet,\x20gpt-4o)','claude-3-5-sonnet')[a0_0x4df239(0x1fc)](_0x48988e=>{const _0x4fd524=a0_0x4df239,_0x58d529=tracker_1['tracker'][_0x4fd524(0x16c)](_0x48988e[_0x4fd524(0x150)]);console[_0x4fd524(0x1a3)]('\x0a============================================='),console[_0x4fd524(0x1a3)](_0x4fd524(0x18d)),console[_0x4fd524(0x1a3)]('============================================='),console[_0x4fd524(0x1a3)](_0x4fd524(0x225)+_0x58d529['model_name']),console['log'](_0x4fd524(0x1ee)+_0x58d529[_0x4fd524(0x164)][_0x4fd524(0x157)]()),console[_0x4fd524(0x1a3)](_0x4fd524(0x14b)+_0x58d529[_0x4fd524(0x151)][_0x4fd524(0x157)]()),console[_0x4fd524(0x1a3)](_0x4fd524(0x188)+_0x58d529['total_tokens_saved'][_0x4fd524(0x157)]()),console[_0x4fd524(0x1a3)](_0x4fd524(0x1ae)+_0x58d529[_0x4fd524(0x13e)]+'%'),console[_0x4fd524(0x1a3)](_0x4fd524(0x1ab)+_0x58d529[_0x4fd524(0x1d0)]['toFixed'](0x4)+_0x4fd524(0x1e5)),console['log'](_0x4fd524(0x193)+_0x58d529['compressed_cost_usd'][_0x4fd524(0x192)](0x4)+_0x4fd524(0x17d)),console[_0x4fd524(0x1a3)](_0x4fd524(0x15b)),console[_0x4fd524(0x1a3)](_0x4fd524(0x1eb)+_0x58d529[_0x4fd524(0x1fb)][_0x4fd524(0x192)](0x4)+'\x20USD'),console[_0x4fd524(0x1a3)]('=============================================\x0a');}),program[a0_0x4df239(0x1ff)](a0_0x4df239(0x144))[a0_0x4df239(0x1f5)](a0_0x4df239(0x1a4))[a0_0x4df239(0x1c7)]('<action>','get\x20or\x20set')[a0_0x4df239(0x1c7)]('<key>',a0_0x4df239(0x16d))[a0_0x4df239(0x1c7)](a0_0x4df239(0x15e),'value\x20to\x20set')[a0_0x4df239(0x1fc)]((_0x1feea2,_0x3b9382,_0x315cec)=>{const _0xcf18c9=a0_0x4df239;if(_0x1feea2===_0xcf18c9(0x143)){const _0x4e39c7=tracker_1[_0xcf18c9(0x195)]['getConfig']();console[_0xcf18c9(0x1a3)](_0x3b9382+':\x20'+_0x4e39c7[_0x3b9382]);}else{if(_0x1feea2===_0xcf18c9(0x1a7)){_0x315cec===undefined&&(console['error'](_0xcf18c9(0x1bd)),process[_0xcf18c9(0x212)](0x1));let _0x3a43bc=_0x315cec;if(_0x315cec==='true')_0x3a43bc=!![];if(_0x315cec===_0xcf18c9(0x1c9))_0x3a43bc=![];if(/^\d+$/[_0xcf18c9(0x1e2)](_0x315cec))_0x3a43bc=parseInt(_0x315cec,0xa);tracker_1['tracker'][_0xcf18c9(0x149)](_0x3b9382,_0x3a43bc),console[_0xcf18c9(0x1a3)](_0xcf18c9(0x1fd)+_0x3b9382+_0xcf18c9(0x205)+_0x315cec);}else console[_0xcf18c9(0x1b9)](_0xcf18c9(0x200)),process[_0xcf18c9(0x212)](0x1);}});function welcomeBanner(){const _0x41127c=a0_0x4df239,_0x2ba8ef='\x1b[1m',_0x88f75c=_0x41127c(0x1b6),_0x33a52a='\x1b[32m',_0x2bbe14=_0x41127c(0x1b5),_0x4bc746='\x1b[90m',_0x4b78a3=_0x41127c(0x218),_0x450337=_0x88f75c+_0x41127c(0x152)+_0x4b78a3;return['',_0x450337,_0x41127c(0x167)+_0x2ba8ef+'TrimPrompt\x20is\x20installed\x20—\x20you\x27re\x20saving\x20tokens!'+_0x4b78a3,_0x450337,'','\x20\x20'+_0x2bbe14+'⚠\x20\x20Restart\x20your\x20terminal\x20once'+_0x4b78a3+'\x20(or\x20your\x20AI\x20editor\x20—\x20Cursor\x20/',_0x41127c(0x19a),'',_0x41127c(0x190),_0x41127c(0x1c2),'','\x20\x20'+_0x2ba8ef+'Try\x20it:'+_0x4b78a3,_0x41127c(0x1ac)+_0x33a52a+_0x41127c(0x165)+_0x4b78a3+_0x41127c(0x14f)+_0x4bc746+_0x41127c(0x178)+_0x4b78a3,_0x41127c(0x1ac)+_0x33a52a+_0x41127c(0x159)+_0x4b78a3+_0x41127c(0x183)+_0x4bc746+_0x41127c(0x13f)+_0x4b78a3,'','\x20\x20'+_0x4bc746+_0x41127c(0x1de)+_0x4b78a3,'','\x20\x20'+_0x4bc746+'Telemetry:\x20sends\x20usage\x20stats\x20+\x20your\x20computer\x20name,\x20username\x20and',_0x41127c(0x1aa)+_0x4b78a3+_0x2bbe14+_0x41127c(0x221)+_0x4b78a3,'\x20\x20'+_0x4bc746+'Details:\x20npmjs.com/package/trimprompt'+_0x4b78a3,''][_0x41127c(0x21d)]('\x0a');}function markerPath(_0xd6e54c){const _0x3ca3ac=a0_0x4df239,_0x16e146=require('os'),_0x4f5cca=require('path');return _0x4f5cca[_0x3ca3ac(0x21d)](_0x16e146['homedir'](),_0x3ca3ac(0x1f7),_0xd6e54c);}function hasMarker(_0xea6f07){try{return require('fs')['existsSync'](markerPath(_0xea6f07));}catch{return![];}}function setMarker(_0x5b71c0){const _0x46941c=a0_0x4df239;try{const _0x8f9e63=require('fs'),_0x3645a7=require(_0x46941c(0x1ce));_0x8f9e63[_0x46941c(0x17e)](_0x3645a7[_0x46941c(0x20e)](markerPath(_0x5b71c0)),{'recursive':!![]}),_0x8f9e63[_0x46941c(0x177)](markerPath(_0x5b71c0),new Date()[_0x46941c(0x1c8)]());}catch{}}function writeToTerminal(_0x1b0f9f){const _0x140f4e=a0_0x4df239;try{const _0x2d19c7=require('fs'),_0x287051=process['platform']===_0x140f4e(0x1c4)?_0x140f4e(0x180):'/dev/tty',_0x5e779f=_0x1b0f9f[_0x140f4e(0x15f)](/\x1b\[[0-9;]*m/g,'');return _0x2d19c7[_0x140f4e(0x177)](_0x287051,_0x5e779f+'\x0a'),!![];}catch{return![];}}function fireDomainInstallPing(){const _0x446b9e=a0_0x4df239;try{const _0x40c4be=require('fs'),_0x531c09=require(_0x446b9e(0x1ce)),_0x463e33=require(_0x446b9e(0x1a0)),_0x3047e0=_0x531c09['join'](__dirname,_0x446b9e(0x213));if(_0x40c4be['existsSync'](_0x3047e0)){const _0x42e363=_0x463e33[_0x446b9e(0x1c0)](process['execPath'],[_0x3047e0,'--install-id'],{'detached':!![],'stdio':_0x446b9e(0x185),'windowsHide':!![]});_0x42e363['unref']();}}catch{}}function showPostinstallBanner(){const _0x523061=a0_0x4df239;try{require('fs')[_0x523061(0x155)](markerPath('.welcomed'));}catch{}writeToTerminal(welcomeBanner());}function showWelcomeIfFirstRun(_0x3363c3=![]){const _0x19b387=a0_0x4df239;try{const _0x533394=hasMarker(_0x19b387(0x13d));return(_0x3363c3||!_0x533394)&&(console[_0x19b387(0x1a3)](welcomeBanner()),setMarker(_0x19b387(0x13d))),hasMarker(_0x19b387(0x13d))&&!hasMarker('.install_pinged')&&(setMarker(_0x19b387(0x17f)),fireDomainInstallPing()),!![];}catch{return![];}}function printMessage(_0x241d0d){const _0x56bf7d=a0_0x4df239;if(process.env.npm_lifecycle_event===_0x56bf7d(0x162))try{const _0x13f3a4=require('fs'),_0x57f679=process[_0x56bf7d(0x197)]===_0x56bf7d(0x1c4)?_0x56bf7d(0x180):_0x56bf7d(0x219);_0x13f3a4[_0x56bf7d(0x177)](_0x57f679,'\x0a'+_0x241d0d+'\x0a');return;}catch{}console[_0x56bf7d(0x1a3)](_0x241d0d);}program[a0_0x4df239(0x1ff)]('shims')['description']('Install\x20or\x20uninstall\x20system\x20command\x20shims')['argument'](a0_0x4df239(0x147),a0_0x4df239(0x191))[a0_0x4df239(0x1fc)](_0xaf11e6=>{const _0x1550ab=a0_0x4df239;if(_0xaf11e6==='install'){const _0x37f8f4=(0x0,shims_1[_0x1550ab(0x181)])();printMessage(_0x37f8f4[_0x1550ab(0x1e9)]);}else{if(_0xaf11e6==='uninstall'){const _0x3887e7=(0x0,shims_1['uninstallShims'])();printMessage(_0x3887e7['message']);}else console[_0x1550ab(0x1b9)]('Error:\x20Action\x20must\x20be\x20install\x20or\x20uninstall'),process[_0x1550ab(0x212)](0x1);}}),program[a0_0x4df239(0x1ff)]('welcome')[a0_0x4df239(0x1f5)](a0_0x4df239(0x15a))[a0_0x4df239(0x1fc)](()=>{showPostinstallBanner();}),program[a0_0x4df239(0x1ff)](a0_0x4df239(0x171))[a0_0x4df239(0x1f5)](a0_0x4df239(0x222))[a0_0x4df239(0x1c7)](a0_0x4df239(0x1c1),a0_0x4df239(0x18a))[a0_0x4df239(0x1fc)](_0x2f77e9=>{const _0x524cac=a0_0x4df239;if(isDisabled()){console['log'](_0x2f77e9);return;}const _0x144918=(0x0,filters_1['rewriteCommand'])(_0x2f77e9);console[_0x524cac(0x1a3)](_0x144918);}),program['command']('watcher\x20[action]')[a0_0x4df239(0x1f5)](a0_0x4df239(0x1d3))['action'](async _0x306693=>{const _0x31bf11=a0_0x4df239,{startWatcherDaemon:_0x2b784e}=await Promise[_0x31bf11(0x1a9)]()[_0x31bf11(0x20d)](()=>__importStar(require(_0x31bf11(0x20a))));(!_0x306693||_0x306693==='start'||_0x306693==='install')&&_0x2b784e();}),program['command']('retrieve\x20<chunkId>')['description'](a0_0x4df239(0x158))['action'](async _0x565748=>{const _0x3e94d5=a0_0x4df239,{retrieveChunk:_0x2b720e}=await Promise[_0x3e94d5(0x1a9)]()[_0x3e94d5(0x20d)](()=>__importStar(require(_0x3e94d5(0x14c)))),_0xa7111f=_0x2b720e(_0x565748);_0xa7111f?console[_0x3e94d5(0x1a3)](_0xa7111f[_0x3e94d5(0x160)]):(console[_0x3e94d5(0x1b9)](_0x3e94d5(0x16b)+_0x565748+_0x3e94d5(0x163)),process[_0x3e94d5(0x212)](0x1));}),program[a0_0x4df239(0x1ff)](a0_0x4df239(0x1ed))[a0_0x4df239(0x1f5)](a0_0x4df239(0x1dd))[a0_0x4df239(0x1ca)]('-a,\x20--agent\x20<agent>',a0_0x4df239(0x14a),a0_0x4df239(0x187))[a0_0x4df239(0x1fc)](async(_0x299ee0,_0x4f8210)=>{const _0x293257=a0_0x4df239,{getLatestSessionFile:_0x4276f5,compactSessionCopy:_0x48f83d}=await Promise['resolve']()[_0x293257(0x20d)](()=>__importStar(require(_0x293257(0x20a)))),_0x344545=await Promise['resolve']()[_0x293257(0x20d)](()=>__importStar(require('fs'))),_0x2b8d40=_0x4f8210&&_0x4f8210[_0x293257(0x1fa)]||'claude';let _0x22e739=_0x299ee0;if(!_0x299ee0||!_0x344545[_0x293257(0x17c)](_0x299ee0)){const _0x178c59=_0x4276f5(_0x2b8d40);_0x22e739=_0x178c59['fullPath'];}if(!_0x22e739||!_0x344545[_0x293257(0x17c)](_0x22e739)){console[_0x293257(0x1b9)](_0x293257(0x1df)+_0x2b8d40+'\x27.');return;}const _0x4058de=_0x48f83d(_0x22e739,_0x2b8d40);if(!_0x4058de['ok']){console[_0x293257(0x1b9)]('[TrimPrompt\x20Compact]\x20'+_0x4058de['reason']);return;}console['log'](_0x293257(0x1a8)),console[_0x293257(0x1a3)](_0x293257(0x198)+_0x22e739),console[_0x293257(0x1a3)](_0x293257(0x214)+_0x4058de[_0x293257(0x17a)]),console[_0x293257(0x1a3)](_0x293257(0x16e)+_0x4058de[_0x293257(0x1ea)]?.[_0x293257(0x157)]()+'\x20tokens\x20('+_0x4058de[_0x293257(0x1b2)]?.['toLocaleString']()+_0x293257(0x1cf)),console[_0x293257(0x1a3)]('Compressed:\x20'+_0x4058de[_0x293257(0x1b4)]?.[_0x293257(0x157)]()+_0x293257(0x1dc)+_0x4058de[_0x293257(0x21b)]?.['toLocaleString']()+_0x293257(0x1cf)),console[_0x293257(0x1a3)](_0x293257(0x19e)+_0x4058de[_0x293257(0x15c)]?.[_0x293257(0x157)]()+_0x293257(0x1dc)+_0x4058de['reductionPct']+_0x293257(0x203)),(_0x4058de[_0x293257(0x15c)]||0x0)===0x0?console[_0x293257(0x1a3)](_0x293257(0x179)):(console[_0x293257(0x1a3)](_0x293257(0x216)),console[_0x293257(0x1a3)](_0x293257(0x1d5)+_0x4058de[_0x293257(0x17a)]+'\x22')),console[_0x293257(0x1a3)]('');});const args=process[a0_0x4df239(0x194)][a0_0x4df239(0x161)](0x2),firstArg=args[0x0],subcommands=['ui',a0_0x4df239(0x142),a0_0x4df239(0x154),a0_0x4df239(0x144),'shims',a0_0x4df239(0x202),a0_0x4df239(0x171),a0_0x4df239(0x1bb),a0_0x4df239(0x18f),a0_0x4df239(0x1f3),a0_0x4df239(0x15d),'compact',a0_0x4df239(0x217),a0_0x4df239(0x206),'-h',a0_0x4df239(0x199),'--version','-v'];if(firstArg&&!subcommands[a0_0x4df239(0x1e1)](firstArg))runProxy(args)[a0_0x4df239(0x215)](_0x34fd69=>{const _0x5a3a97=a0_0x4df239;console[_0x5a3a97(0x1b9)]('[TrimPrompt]\x20Fatal\x20Proxy\x20Error:\x20'+_0x34fd69[_0x5a3a97(0x1e9)]),process[_0x5a3a97(0x212)](0x1);});else{const machineFacing=[a0_0x4df239(0x1db),a0_0x4df239(0x202),a0_0x4df239(0x1f3),a0_0x4df239(0x1bb),a0_0x4df239(0x18f),a0_0x4df239(0x15d),'compact'],isPostinstall=process.env.npm_lifecycle_event==='postinstall';if(!isPostinstall){if(!firstArg)showWelcomeIfFirstRun(!![]);else!machineFacing['includes'](firstArg)&&showWelcomeIfFirstRun(![]);}program[a0_0x4df239(0x1d7)](process[a0_0x4df239(0x194)]);}
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.43';
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';const a0_0x2df8ff=a0_0x5e4c;(function(_0x58c463,_0x42ec85){const _0x5c85c6=a0_0x5e4c,_0x2437c6=_0x58c463();while(!![]){try{const _0x4e87b8=-parseInt(_0x5c85c6(0x17e))/0x1*(-parseInt(_0x5c85c6(0x157))/0x2)+-parseInt(_0x5c85c6(0x1a9))/0x3*(-parseInt(_0x5c85c6(0x1b4))/0x4)+-parseInt(_0x5c85c6(0x164))/0x5+parseInt(_0x5c85c6(0x16d))/0x6*(-parseInt(_0x5c85c6(0x169))/0x7)+parseInt(_0x5c85c6(0x18d))/0x8+-parseInt(_0x5c85c6(0x1aa))/0x9*(parseInt(_0x5c85c6(0x156))/0xa)+-parseInt(_0x5c85c6(0x1cb))/0xb*(-parseInt(_0x5c85c6(0x180))/0xc);if(_0x4e87b8===_0x42ec85)break;else _0x2437c6['push'](_0x2437c6['shift']());}catch(_0x3e39b3){_0x2437c6['push'](_0x2437c6['shift']());}}}(a0_0x4e39,0x92dca));var __createBinding=this&&this['__createBinding']||(Object['create']?function(_0x40309e,_0x2a9a20,_0x5515b5,_0x26faea){const _0x1177f8=a0_0x5e4c;if(_0x26faea===undefined)_0x26faea=_0x5515b5;var _0x2e3215=Object[_0x1177f8(0x178)](_0x2a9a20,_0x5515b5);(!_0x2e3215||(_0x1177f8(0x173)in _0x2e3215?!_0x2a9a20[_0x1177f8(0x1ad)]:_0x2e3215[_0x1177f8(0x188)]||_0x2e3215['configurable']))&&(_0x2e3215={'enumerable':!![],'get':function(){return _0x2a9a20[_0x5515b5];}}),Object[_0x1177f8(0x1a8)](_0x40309e,_0x26faea,_0x2e3215);}:function(_0x415a9a,_0x2f1f0e,_0x224431,_0x14e776){if(_0x14e776===undefined)_0x14e776=_0x224431;_0x415a9a[_0x14e776]=_0x2f1f0e[_0x224431];}),__setModuleDefault=this&&this[a0_0x2df8ff(0x1bf)]||(Object[a0_0x2df8ff(0x1c8)]?function(_0x570d4b,_0xfc79a4){const _0x485ce7=a0_0x2df8ff;Object[_0x485ce7(0x1a8)](_0x570d4b,'default',{'enumerable':!![],'value':_0xfc79a4});}:function(_0x5ca99,_0x166d33){const _0x1681c6=a0_0x2df8ff;_0x5ca99[_0x1681c6(0x1b2)]=_0x166d33;}),__importStar=this&&this[a0_0x2df8ff(0x199)]||(function(){var _0x4eede8=function(_0x1e6d1d){const _0x339eee=a0_0x5e4c;return _0x4eede8=Object[_0x339eee(0x17a)]||function(_0x40064f){const _0x3fb1e8=_0x339eee;var _0x1ea85f=[];for(var _0x44ff9c in _0x40064f)if(Object[_0x3fb1e8(0x1a3)][_0x3fb1e8(0x1ca)][_0x3fb1e8(0x19e)](_0x40064f,_0x44ff9c))_0x1ea85f[_0x1ea85f['length']]=_0x44ff9c;return _0x1ea85f;},_0x4eede8(_0x1e6d1d);};return function(_0x4b966a){const _0x57cd8f=a0_0x5e4c;if(_0x4b966a&&_0x4b966a[_0x57cd8f(0x1ad)])return _0x4b966a;var _0x48b235={};if(_0x4b966a!=null){for(var _0x11983b=_0x4eede8(_0x4b966a),_0x2b07aa=0x0;_0x2b07aa<_0x11983b[_0x57cd8f(0x18c)];_0x2b07aa++)if(_0x11983b[_0x2b07aa]!==_0x57cd8f(0x1b2))__createBinding(_0x48b235,_0x4b966a,_0x11983b[_0x2b07aa]);}return __setModuleDefault(_0x48b235,_0x4b966a),_0x48b235;};}()),__importDefault=this&&this[a0_0x2df8ff(0x1af)]||function(_0x4571cc){const _0x2a880d=a0_0x2df8ff;return _0x4571cc&&_0x4571cc[_0x2a880d(0x1ad)]?_0x4571cc:{'default':_0x4571cc};};Object[a0_0x2df8ff(0x1a8)](exports,'__esModule',{'value':!![]}),exports[a0_0x2df8ff(0x1bb)]=startDashboard;const express_1=__importDefault(require('express')),path=__importStar(require(a0_0x2df8ff(0x196))),fs=__importStar(require('fs')),os=__importStar(require('os')),open_1=__importDefault(require(a0_0x2df8ff(0x187))),tracker_1=require(a0_0x2df8ff(0x15a)),app=(0x0,express_1[a0_0x2df8ff(0x1b2)])();function a0_0x5e4c(_0xb0bba6,_0x4db6b6){_0xb0bba6=_0xb0bba6-0x156;const _0x4e393b=a0_0x4e39();let _0x5e4c06=_0x4e393b[_0xb0bba6];return _0x5e4c06;}app[a0_0x2df8ff(0x15c)](express_1['default'][a0_0x2df8ff(0x1c0)]());function a0_0x4e39(){const _0x5c5b10=['285148JzMMqq','catch','sendFile','cortex','fullPath','http://localhost:','favicon.png','startDashboard','payload','xdg-open\x20\x22','codex','__setModuleDefault','json','resolve','index.html','exit','win32','.comp.txt','kill','activeSavedTokens','create','/api/config/custom-path','hasOwnProperty','55QPSwvs','/api/agent/compact','30bGLfpL','4268yqDeGb','savedTokens','getConfig','./tracker','post','use','SIGTERM','message','./file-watcher','find','aider','model','/api/stats/history','4901710sxZqDT','getStatsSummary','start','setConfig','join','5467ktDwNq','mkdirSync','darwin','Missing\x20key','3678KAoNyv','.trimprompt','Directory\x20not\x20found','platform','utf8','timestamp','get','slice','SIGINT','Press\x20Ctrl+C\x20in\x20this\x20terminal\x20to\x20shut\x20down.','EADDRINUSE','getOwnPropertyDescriptor','../src/favicon.png','getOwnPropertyNames','logs','error','watcher','1YIrgIs','tracker','3830724aFlqmk','command','Missing\x20agentKey','existsSync','cli.js','query','compressedTokens','open','writable','--headless','open\x20\x22','child_process','length','1444072mLNjgu','\x0a[TrimPrompt]\x20Dashboard\x20server\x20started\x20at:\x20','No\x20compressible\x20content\x20found\x20in\x20this\x20session','openclaw','conv:','argv','/api/stats/summary','claude','log','path','fileName','ignore','__importStar','getLogs','then','../src/index.html','/api/config','call','features_enabled','compactPath','rawTokens','filter','prototype','body','now','/api/config/features','/api/stats/inspect/:id','defineProperty','48EjyXjw','2576187DHMTmP','readFileSync','includes','__esModule','status','__importDefault','/favicon.png','/api/config/open-dir','default','listen'];a0_0x4e39=function(){return _0x5c5b10;};return a0_0x4e39();}const baseDir=path['join'](os['homedir'](),a0_0x2df8ff(0x16e)),logsDir=path[a0_0x2df8ff(0x168)](baseDir,a0_0x2df8ff(0x17b));let configPayloadCache=null;const CONFIG_CACHE_TTL_MS=0x2710;function invalidateConfigCache(){configPayloadCache=null;}app['get']('/',(_0x5e53c9,_0x2a6775)=>{const _0x43a20a=a0_0x2df8ff,_0x342d56=path[_0x43a20a(0x168)](__dirname,_0x43a20a(0x1c2));fs[_0x43a20a(0x183)](_0x342d56)?_0x2a6775[_0x43a20a(0x1b6)](_0x342d56):_0x2a6775[_0x43a20a(0x1b6)](path['join'](__dirname,_0x43a20a(0x19c)));}),app['get'](a0_0x2df8ff(0x1b0),(_0x724887,_0x186618)=>{const _0x2f3f6c=a0_0x2df8ff,_0x3e193b=path[_0x2f3f6c(0x168)](__dirname,_0x2f3f6c(0x1ba));fs[_0x2f3f6c(0x183)](_0x3e193b)?_0x186618[_0x2f3f6c(0x1b6)](_0x3e193b):_0x186618[_0x2f3f6c(0x1b6)](path[_0x2f3f6c(0x168)](__dirname,_0x2f3f6c(0x179)));}),app[a0_0x2df8ff(0x173)](a0_0x2df8ff(0x193),(_0xb6731c,_0x42d41b)=>{const _0x92b702=a0_0x2df8ff,_0x197bd5=_0xb6731c[_0x92b702(0x185)][_0x92b702(0x162)]||'auto',_0x1066a4=tracker_1[_0x92b702(0x17f)][_0x92b702(0x165)](_0x197bd5);_0x42d41b[_0x92b702(0x1c0)](_0x1066a4);}),app[a0_0x2df8ff(0x173)](a0_0x2df8ff(0x163),(_0x4e2e1e,_0x3ffcf0)=>{const _0x14fe39=a0_0x2df8ff,_0x219860=tracker_1[_0x14fe39(0x17f)][_0x14fe39(0x19a)]();_0x3ffcf0['json'](_0x219860[_0x14fe39(0x18c)]>0x1f4?_0x219860[_0x14fe39(0x174)](-0x1f4):_0x219860);}),app[a0_0x2df8ff(0x173)](a0_0x2df8ff(0x1a7),(_0x570f91,_0x91246d)=>{const _0x47b92d=a0_0x2df8ff,_0x4a8a36=_0x570f91['params']['id'],_0x20a445=path['join'](logsDir,_0x4a8a36+'.raw.txt'),_0x594ebc=path['join'](logsDir,_0x4a8a36+_0x47b92d(0x1c5));let _0x43624a='Raw\x20output\x20log\x20file\x20not\x20found.',_0x3b3487='Compressed\x20output\x20log\x20file\x20not\x20found.';try{fs[_0x47b92d(0x183)](_0x20a445)&&(_0x43624a=fs[_0x47b92d(0x1ab)](_0x20a445,_0x47b92d(0x171))),fs['existsSync'](_0x594ebc)&&(_0x3b3487=fs[_0x47b92d(0x1ab)](_0x594ebc,'utf8'));}catch(_0x56183f){}_0x91246d[_0x47b92d(0x1c0)]({'id':_0x4a8a36,'raw':_0x43624a,'compressed':_0x3b3487});}),app[a0_0x2df8ff(0x173)](a0_0x2df8ff(0x1a6),(_0x598982,_0x4f6628)=>{const _0x6cdf1e=a0_0x2df8ff,_0x1c8ef1=tracker_1['tracker'][_0x6cdf1e(0x159)]();_0x4f6628[_0x6cdf1e(0x1c0)](_0x1c8ef1[_0x6cdf1e(0x19f)]||{});}),app[a0_0x2df8ff(0x15b)](a0_0x2df8ff(0x1a6),(_0x4fdab7,_0x124722)=>{const _0x46391a=a0_0x2df8ff,_0x40a9ca=_0x4fdab7[_0x46391a(0x1a4)];tracker_1['tracker'][_0x46391a(0x167)](_0x46391a(0x19f),_0x40a9ca),invalidateConfigCache(),_0x124722[_0x46391a(0x1c0)]({'ok':!![]});}),app[a0_0x2df8ff(0x15b)](a0_0x2df8ff(0x1cc),async(_0x316073,_0x141d27)=>{const _0x55ab17=a0_0x2df8ff;try{const {getLatestSessionFile:_0x129004,compactSessionCopy:_0x276457}=await Promise[_0x55ab17(0x1c1)]()[_0x55ab17(0x19b)](()=>__importStar(require(_0x55ab17(0x15f)))),{agentKey:_0x4cea0e}=_0x316073[_0x55ab17(0x1a4)]||{},_0x4e9855=_0x4cea0e||_0x55ab17(0x194),_0x453d13=_0x129004(_0x4e9855);if(_0x453d13&&_0x453d13['fullPath']&&fs['existsSync'](_0x453d13[_0x55ab17(0x1b8)])){const _0x277862=_0x276457(_0x453d13[_0x55ab17(0x1b8)],_0x4e9855);_0x277862['ok']&&(_0x277862[_0x55ab17(0x158)]||0x0)>0x0?_0x141d27[_0x55ab17(0x1c0)]({'ok':!![],'fileName':_0x453d13[_0x55ab17(0x197)],'tokensSaved':_0x277862[_0x55ab17(0x158)],'rawTokens':_0x277862[_0x55ab17(0x1a1)],'compressedTokens':_0x277862[_0x55ab17(0x186)],'reductionPct':_0x277862['reductionPct'],'compactPath':_0x277862[_0x55ab17(0x1a0)]}):_0x141d27[_0x55ab17(0x1c0)]({'ok':![],'message':_0x277862['reason']||_0x55ab17(0x18f)});}else _0x141d27[_0x55ab17(0x1c0)]({'ok':![],'message':'No\x20active\x20session\x20file\x20found'});}catch(_0x2bc9e9){_0x141d27['status'](0x1f4)[_0x55ab17(0x1c0)]({'ok':![],'error':_0x2bc9e9[_0x55ab17(0x15e)]});}}),app[a0_0x2df8ff(0x173)](a0_0x2df8ff(0x19d),async(_0x3cd6bc,_0x2c74e4)=>{const _0x19659b=a0_0x2df8ff;if(configPayloadCache&&Date['now']()-configPayloadCache['at']<CONFIG_CACHE_TTL_MS)return _0x2c74e4[_0x19659b(0x1c0)](configPayloadCache[_0x19659b(0x1bc)]);const {loadConfig:_0x54e3a0,getAgentStoragePaths:_0x3d8f1b,getLatestSessionFile:_0x35ac1b,loadSessionsState:_0x1a3803}=await Promise['resolve']()[_0x19659b(0x19b)](()=>__importStar(require('./file-watcher'))),_0x1b0ea8=_0x54e3a0(),_0x25dc80=['claude','gemini',_0x19659b(0x1be),'cursor',_0x19659b(0x161),'copilot',_0x19659b(0x190),'opencode',_0x19659b(0x1b7)],_0x26673d={},_0x1462a0={},_0x1c633b={},_0x3d8f81=_0x1a3803(),_0x58aee5=tracker_1[_0x19659b(0x17f)]['getLogs']()||[];for(const _0x25f04a of _0x25dc80){_0x26673d[_0x25f04a]=_0x3d8f1b(_0x25f04a);const _0x30d7ee=_0x35ac1b(_0x25f04a);if(_0x30d7ee&&_0x30d7ee[_0x19659b(0x1b8)]&&_0x3d8f81[_0x30d7ee[_0x19659b(0x1b8)]])_0x30d7ee[_0x19659b(0x1c7)]=_0x3d8f81[_0x30d7ee['fullPath']][_0x19659b(0x1c7)]||0x0;else{if(_0x30d7ee)_0x30d7ee[_0x19659b(0x1c7)]=0x0;}_0x1c633b[_0x25f04a]=_0x30d7ee;const _0x4e5bc3=_0x58aee5[_0x19659b(0x1a2)](_0x1583b1=>_0x1583b1[_0x19659b(0x181)]&&_0x1583b1[_0x19659b(0x181)]['includes'](_0x19659b(0x191)+_0x25f04a));_0x4e5bc3[_0x19659b(0x18c)]>0x0?_0x1462a0[_0x25f04a]=_0x4e5bc3[_0x4e5bc3[_0x19659b(0x18c)]-0x1][_0x19659b(0x172)]:_0x1462a0[_0x25f04a]=_0x30d7ee?_0x30d7ee['lastModified']:null;}const _0x272a24={..._0x1b0ea8,'resolvedPaths':_0x26673d,'lastActiveTimestamps':_0x1462a0,'latestSessions':_0x1c633b};configPayloadCache={'at':Date[_0x19659b(0x1a5)](),'payload':_0x272a24},_0x2c74e4[_0x19659b(0x1c0)](_0x272a24);}),app[a0_0x2df8ff(0x15b)](a0_0x2df8ff(0x1b1),async(_0x10d723,_0x4efd3e)=>{const _0x5901b4=a0_0x2df8ff,{getAgentStoragePaths:_0x8e636f}=await Promise[_0x5901b4(0x1c1)]()[_0x5901b4(0x19b)](()=>__importStar(require(_0x5901b4(0x15f)))),{agentKey:_0x391269}=_0x10d723[_0x5901b4(0x1a4)]||{};if(!_0x391269)return _0x4efd3e[_0x5901b4(0x1ae)](0x190)[_0x5901b4(0x1c0)]({'error':_0x5901b4(0x182)});const _0x3dc122=_0x8e636f(_0x391269),_0x38218e=_0x3dc122[_0x5901b4(0x160)](_0x506d36=>fs['existsSync'](_0x506d36))||_0x3dc122[0x0];if(_0x38218e){if(!fs[_0x5901b4(0x183)](_0x38218e))try{fs[_0x5901b4(0x16a)](_0x38218e,{'recursive':!![]});}catch{}const {exec:_0x3e5a4b}=await Promise[_0x5901b4(0x1c1)]()['then'](()=>__importStar(require(_0x5901b4(0x18b)))),_0x5d4d32=process[_0x5901b4(0x170)]===_0x5901b4(0x1c4)?'explorer\x20\x22'+_0x38218e+'\x22':process[_0x5901b4(0x170)]===_0x5901b4(0x16b)?_0x5901b4(0x18a)+_0x38218e+'\x22':_0x5901b4(0x1bd)+_0x38218e+'\x22';return _0x3e5a4b(_0x5d4d32),_0x4efd3e[_0x5901b4(0x1c0)]({'success':!![],'openedPath':_0x38218e});}_0x4efd3e[_0x5901b4(0x1ae)](0x194)['json']({'error':_0x5901b4(0x16f)});}),app['post']('/api/config/toggle',async(_0xbc769d,_0x2ece9a)=>{const _0x4c9167=a0_0x2df8ff,{saveConfig:_0x2505ff}=await Promise[_0x4c9167(0x1c1)]()['then'](()=>__importStar(require(_0x4c9167(0x15f)))),{key:_0x3e95d8,value:_0xc57883}=_0xbc769d[_0x4c9167(0x1a4)]||{};if(_0x3e95d8){const _0x7f2987=_0x2505ff({'conversation_toggles':{[_0x3e95d8]:_0xc57883}});return invalidateConfigCache(),_0x2ece9a[_0x4c9167(0x1c0)](_0x7f2987);}_0x2ece9a['status'](0x190)['json']({'error':_0x4c9167(0x16c)});}),app[a0_0x2df8ff(0x15b)](a0_0x2df8ff(0x1c9),async(_0x1a560a,_0x83096c)=>{const _0x13e7e5=a0_0x2df8ff,{saveConfig:_0x373523}=await Promise[_0x13e7e5(0x1c1)]()['then'](()=>__importStar(require(_0x13e7e5(0x15f)))),{agentKey:_0x525113,path:_0x5aa55e}=_0x1a560a['body']||{};if(_0x525113){const _0x5b95dd=_0x373523({'custom_storage_paths':{[_0x525113]:_0x5aa55e||null}});return invalidateConfigCache(),_0x83096c['json'](_0x5b95dd);}_0x83096c['status'](0x190)[_0x13e7e5(0x1c0)]({'error':_0x13e7e5(0x182)});});function startDashboard(_0x1cc1f0=0xfa0){const _0x1e4d6e=a0_0x2df8ff;let _0x227b0d=_0x1cc1f0;const _0x580ff4=process[_0x1e4d6e(0x192)][_0x1e4d6e(0x1ac)](_0x1e4d6e(0x189))||process.env.TRIMPROMPT_HEADLESS==='1',_0x36eb35=app[_0x1e4d6e(0x1b3)](_0x227b0d,()=>{const _0xa1246a=_0x1e4d6e,_0x388924=_0xa1246a(0x1b9)+_0x227b0d;!_0x580ff4&&(console[_0xa1246a(0x195)](_0xa1246a(0x18e)+_0x388924),console[_0xa1246a(0x195)](_0xa1246a(0x176)));try{const {spawn:_0x2e8eaa}=require(_0xa1246a(0x18b)),_0x5c838f=_0x2e8eaa(process['execPath'],[path['join'](__dirname,_0xa1246a(0x184)),_0xa1246a(0x17d),_0xa1246a(0x166)],{'stdio':_0xa1246a(0x198),'windowsHide':!![]}),_0x7d3bbc=()=>{const _0x1f4f8a=_0xa1246a;try{_0x5c838f[_0x1f4f8a(0x1c6)]();}catch{}};process['on'](_0xa1246a(0x1c3),_0x7d3bbc),process['on'](_0xa1246a(0x175),()=>{const _0xb6c95e=_0xa1246a;_0x7d3bbc(),process[_0xb6c95e(0x1c3)](0x0);}),process['on'](_0xa1246a(0x15d),()=>{const _0x412025=_0xa1246a;_0x7d3bbc(),process[_0x412025(0x1c3)](0x0);});}catch{}!_0x580ff4&&process.env.TRIMPROMPT_NO_OPEN!=='1'&&(0x0,open_1[_0xa1246a(0x1b2)])(_0x388924)[_0xa1246a(0x1b5)](()=>{});});_0x36eb35['on']('error',_0x52f47a=>{const _0x46a15c=_0x1e4d6e;_0x52f47a['code']===_0x46a15c(0x177)?startDashboard(_0x227b0d+0x1):console[_0x46a15c(0x17c)]('[TrimPrompt]\x20Dashboard\x20error:\x20'+_0x52f47a[_0x46a15c(0x15e)]);});}
1
+ 'use strict';const a0_0x33a1cc=a0_0x8dea;(function(_0x5e8eba,_0x47595d){const _0x215e3c=a0_0x8dea,_0x93a598=_0x5e8eba();while(!![]){try{const _0x2e5df3=-parseInt(_0x215e3c(0x184))/0x1*(-parseInt(_0x215e3c(0x195))/0x2)+-parseInt(_0x215e3c(0x1a0))/0x3+-parseInt(_0x215e3c(0x165))/0x4*(parseInt(_0x215e3c(0x146))/0x5)+parseInt(_0x215e3c(0x185))/0x6*(parseInt(_0x215e3c(0x193))/0x7)+-parseInt(_0x215e3c(0x15a))/0x8*(-parseInt(_0x215e3c(0x17e))/0x9)+parseInt(_0x215e3c(0x134))/0xa+parseInt(_0x215e3c(0x14e))/0xb;if(_0x2e5df3===_0x47595d)break;else _0x93a598['push'](_0x93a598['shift']());}catch(_0x223efb){_0x93a598['push'](_0x93a598['shift']());}}}(a0_0x4410,0xcaac1));var __createBinding=this&&this[a0_0x33a1cc(0x19d)]||(Object[a0_0x33a1cc(0x135)]?function(_0x8eedad,_0x41149e,_0x371c6b,_0x47a2f9){const _0x1fbafb=a0_0x33a1cc;if(_0x47a2f9===undefined)_0x47a2f9=_0x371c6b;var _0x115363=Object[_0x1fbafb(0x152)](_0x41149e,_0x371c6b);(!_0x115363||(_0x1fbafb(0x143)in _0x115363?!_0x41149e[_0x1fbafb(0x151)]:_0x115363[_0x1fbafb(0x173)]||_0x115363[_0x1fbafb(0x167)]))&&(_0x115363={'enumerable':!![],'get':function(){return _0x41149e[_0x371c6b];}}),Object[_0x1fbafb(0x12a)](_0x8eedad,_0x47a2f9,_0x115363);}:function(_0x47762f,_0x2f0e0c,_0x58ea69,_0x5c0498){if(_0x5c0498===undefined)_0x5c0498=_0x58ea69;_0x47762f[_0x5c0498]=_0x2f0e0c[_0x58ea69];}),__setModuleDefault=this&&this[a0_0x33a1cc(0x16d)]||(Object['create']?function(_0x3bc5a9,_0x316d16){const _0x3cce93=a0_0x33a1cc;Object[_0x3cce93(0x12a)](_0x3bc5a9,_0x3cce93(0x186),{'enumerable':!![],'value':_0x316d16});}:function(_0x5a76d6,_0x1ccb83){_0x5a76d6['default']=_0x1ccb83;}),__importStar=this&&this['__importStar']||(function(){var _0x47f4d7=function(_0x22ab3c){const _0x24b07b=a0_0x8dea;return _0x47f4d7=Object[_0x24b07b(0x196)]||function(_0x43d1ce){const _0x33f4d0=_0x24b07b;var _0x3f6138=[];for(var _0x304c64 in _0x43d1ce)if(Object[_0x33f4d0(0x12e)]['hasOwnProperty'][_0x33f4d0(0x166)](_0x43d1ce,_0x304c64))_0x3f6138[_0x3f6138[_0x33f4d0(0x13a)]]=_0x304c64;return _0x3f6138;},_0x47f4d7(_0x22ab3c);};return function(_0x2da17e){const _0x6e10ab=a0_0x8dea;if(_0x2da17e&&_0x2da17e[_0x6e10ab(0x151)])return _0x2da17e;var _0x1ef465={};if(_0x2da17e!=null){for(var _0x269466=_0x47f4d7(_0x2da17e),_0x2ed819=0x0;_0x2ed819<_0x269466[_0x6e10ab(0x13a)];_0x2ed819++)if(_0x269466[_0x2ed819]!==_0x6e10ab(0x186))__createBinding(_0x1ef465,_0x2da17e,_0x269466[_0x2ed819]);}return __setModuleDefault(_0x1ef465,_0x2da17e),_0x1ef465;};}()),__importDefault=this&&this[a0_0x33a1cc(0x13d)]||function(_0xdd5cea){const _0x15446e=a0_0x33a1cc;return _0xdd5cea&&_0xdd5cea[_0x15446e(0x151)]?_0xdd5cea:{'default':_0xdd5cea};};function a0_0x4410(){const _0xae6eed=['469284YvQZeU','/api/config','defineProperty','--headless','auto','slice','prototype','sendFile','tracker','post','now','readFileSync','8054470aJLdht','create','execPath','rawTokens','platform','codex','length','opencode','Missing\x20key','__importDefault','../src/favicon.png','log','use','exit','No\x20active\x20session\x20file\x20found','get','/api/stats/inspect/:id','listen','5jZqaLk','aider','savedTokens','ignore','gemini','open\x20\x22','SIGTERM','darwin','1550824oVFKkR','openclaw','timestamp','__esModule','getOwnPropertyDescriptor','index.html','status','http://localhost:','compactPath','message','xdg-open\x20\x22','Directory\x20not\x20found','14616ZVbOka','logs','join','copilot','params','fullPath','Missing\x20agentKey','/api/stats/history','lastModified','utf8','/favicon.png','6006588muuGFA','call','configurable','then','fileName','getLogs','.raw.txt','/api/stats/summary','__setModuleDefault','includes','./tracker','claude','mkdirSync','getConfig','writable','catch','startDashboard','/api/config/open-dir','code','/api/config/features','compressedTokens','existsSync','favicon.png','filter','child_process','2718snkSfU','reason','features_enabled','query','Compressed\x20output\x20log\x20file\x20not\x20found.','./file-watcher','109FETLnZ','5142XnjaDF','default','EADDRINUSE','[TrimPrompt]\x20Dashboard\x20error:\x20','error','json','resolve','Press\x20Ctrl+C\x20in\x20this\x20terminal\x20to\x20shut\x20down.','explorer\x20\x22','watcher','homedir','No\x20compressible\x20content\x20found\x20in\x20this\x20session','argv','command','1379WuyCSF','/api/config/custom-path','15068KzGjgG','getOwnPropertyNames','SIGINT','cli.js','Raw\x20output\x20log\x20file\x20not\x20found.','activeSavedTokens','find','../src/index.html','__createBinding','/api/config/toggle','body'];a0_0x4410=function(){return _0xae6eed;};return a0_0x4410();}Object[a0_0x33a1cc(0x12a)](exports,a0_0x33a1cc(0x151),{'value':!![]}),exports[a0_0x33a1cc(0x175)]=startDashboard;const express_1=__importDefault(require('express')),path=__importStar(require('path')),fs=__importStar(require('fs')),os=__importStar(require('os')),open_1=__importDefault(require('open')),tracker_1=require(a0_0x33a1cc(0x16f)),app=(0x0,express_1[a0_0x33a1cc(0x186)])();app[a0_0x33a1cc(0x140)](express_1[a0_0x33a1cc(0x186)]['json']());function a0_0x8dea(_0xe4642c,_0x48a88c){_0xe4642c=_0xe4642c-0x12a;const _0x441076=a0_0x4410();let _0x8deab6=_0x441076[_0xe4642c];return _0x8deab6;}const baseDir=path[a0_0x33a1cc(0x15c)](os[a0_0x33a1cc(0x18f)](),'.trimprompt'),logsDir=path[a0_0x33a1cc(0x15c)](baseDir,a0_0x33a1cc(0x15b));let configPayloadCache=null;const CONFIG_CACHE_TTL_MS=0x2710;function invalidateConfigCache(){configPayloadCache=null;}app[a0_0x33a1cc(0x143)]('/',(_0x4fa5d3,_0x5b2506)=>{const _0x1d45c8=a0_0x33a1cc,_0x55bc19=path[_0x1d45c8(0x15c)](__dirname,_0x1d45c8(0x153));fs[_0x1d45c8(0x17a)](_0x55bc19)?_0x5b2506[_0x1d45c8(0x12f)](_0x55bc19):_0x5b2506[_0x1d45c8(0x12f)](path[_0x1d45c8(0x15c)](__dirname,_0x1d45c8(0x19c)));}),app['get'](a0_0x33a1cc(0x164),(_0x2b9c94,_0xe4e61e)=>{const _0x1f3572=a0_0x33a1cc,_0xdb90f7=path['join'](__dirname,_0x1f3572(0x17b));fs['existsSync'](_0xdb90f7)?_0xe4e61e[_0x1f3572(0x12f)](_0xdb90f7):_0xe4e61e['sendFile'](path[_0x1f3572(0x15c)](__dirname,_0x1f3572(0x13e)));}),app['get'](a0_0x33a1cc(0x16c),(_0x44f34b,_0x2a9d4d)=>{const _0x4b3a44=a0_0x33a1cc,_0x22f09e=_0x44f34b[_0x4b3a44(0x181)]['model']||_0x4b3a44(0x12c),_0x25c858=tracker_1[_0x4b3a44(0x130)]['getStatsSummary'](_0x22f09e);_0x2a9d4d['json'](_0x25c858);}),app[a0_0x33a1cc(0x143)](a0_0x33a1cc(0x161),(_0x5a0bdc,_0x798054)=>{const _0xa4a020=a0_0x33a1cc,_0x4267d8=tracker_1[_0xa4a020(0x130)][_0xa4a020(0x16a)]();_0x798054[_0xa4a020(0x18a)](_0x4267d8[_0xa4a020(0x13a)]>0x1f4?_0x4267d8[_0xa4a020(0x12d)](-0x1f4):_0x4267d8);}),app[a0_0x33a1cc(0x143)](a0_0x33a1cc(0x144),(_0x6fda3d,_0x43d10b)=>{const _0x3bf5e9=a0_0x33a1cc,_0xddbbed=_0x6fda3d[_0x3bf5e9(0x15e)]['id'],_0x5c7b25=path[_0x3bf5e9(0x15c)](logsDir,_0xddbbed+_0x3bf5e9(0x16b)),_0xfbfef5=path[_0x3bf5e9(0x15c)](logsDir,_0xddbbed+'.comp.txt');let _0x596502=_0x3bf5e9(0x199),_0x6de6be=_0x3bf5e9(0x182);try{fs[_0x3bf5e9(0x17a)](_0x5c7b25)&&(_0x596502=fs[_0x3bf5e9(0x133)](_0x5c7b25,_0x3bf5e9(0x163))),fs[_0x3bf5e9(0x17a)](_0xfbfef5)&&(_0x6de6be=fs['readFileSync'](_0xfbfef5,_0x3bf5e9(0x163)));}catch(_0x3f13c0){}_0x43d10b['json']({'id':_0xddbbed,'raw':_0x596502,'compressed':_0x6de6be});}),app[a0_0x33a1cc(0x143)](a0_0x33a1cc(0x178),(_0x4992d5,_0x49661d)=>{const _0x52e47b=a0_0x33a1cc,_0x26c7a=tracker_1['tracker'][_0x52e47b(0x172)]();_0x49661d['json'](_0x26c7a[_0x52e47b(0x180)]||{});}),app[a0_0x33a1cc(0x131)](a0_0x33a1cc(0x178),(_0x52e4ad,_0x4450a6)=>{const _0x3f9a48=a0_0x33a1cc,_0x2a50d2=_0x52e4ad[_0x3f9a48(0x19f)];tracker_1['tracker']['setConfig']('features_enabled',_0x2a50d2),invalidateConfigCache(),_0x4450a6[_0x3f9a48(0x18a)]({'ok':!![]});}),app['post']('/api/agent/compact',async(_0x4a0a50,_0x2ce8b0)=>{const _0x267732=a0_0x33a1cc;try{const {getLatestSessionFile:_0x4267d4,compactSessionCopy:_0x5916b4}=await Promise[_0x267732(0x18b)]()['then'](()=>__importStar(require(_0x267732(0x183)))),{agentKey:_0x5a4dc8}=_0x4a0a50[_0x267732(0x19f)]||{},_0x23a314=_0x5a4dc8||_0x267732(0x170),_0x5305ef=_0x4267d4(_0x23a314);if(_0x5305ef&&_0x5305ef[_0x267732(0x15f)]&&fs[_0x267732(0x17a)](_0x5305ef[_0x267732(0x15f)])){const _0x49f9c4=_0x5916b4(_0x5305ef['fullPath'],_0x23a314);_0x49f9c4['ok']&&(_0x49f9c4[_0x267732(0x148)]||0x0)>0x0?_0x2ce8b0['json']({'ok':!![],'fileName':_0x5305ef[_0x267732(0x169)],'tokensSaved':_0x49f9c4['savedTokens'],'rawTokens':_0x49f9c4[_0x267732(0x137)],'compressedTokens':_0x49f9c4[_0x267732(0x179)],'reductionPct':_0x49f9c4['reductionPct'],'compactPath':_0x49f9c4[_0x267732(0x156)]}):_0x2ce8b0[_0x267732(0x18a)]({'ok':![],'message':_0x49f9c4[_0x267732(0x17f)]||_0x267732(0x190)});}else _0x2ce8b0[_0x267732(0x18a)]({'ok':![],'message':_0x267732(0x142)});}catch(_0x5f2076){_0x2ce8b0['status'](0x1f4)[_0x267732(0x18a)]({'ok':![],'error':_0x5f2076[_0x267732(0x157)]});}}),app[a0_0x33a1cc(0x143)](a0_0x33a1cc(0x1a1),async(_0x56cb95,_0xe79c7e)=>{const _0x1ffd3b=a0_0x33a1cc;if(configPayloadCache&&Date[_0x1ffd3b(0x132)]()-configPayloadCache['at']<CONFIG_CACHE_TTL_MS)return _0xe79c7e['json'](configPayloadCache['payload']);const {loadConfig:_0x5878a0,getAgentStoragePaths:_0x57623d,getLatestSessionFile:_0x42d225,loadSessionsState:_0x57d6cd}=await Promise[_0x1ffd3b(0x18b)]()['then'](()=>__importStar(require(_0x1ffd3b(0x183)))),_0x7c20d1=_0x5878a0(),_0x12ae89=[_0x1ffd3b(0x170),_0x1ffd3b(0x14a),_0x1ffd3b(0x139),'cursor',_0x1ffd3b(0x147),_0x1ffd3b(0x15d),_0x1ffd3b(0x14f),_0x1ffd3b(0x13b),'cortex'],_0x3556b4={},_0x148e25={},_0x20e9f8={},_0x5e499f=_0x57d6cd(),_0x44b051=tracker_1[_0x1ffd3b(0x130)]['getLogs']()||[];for(const _0x4e1fd6 of _0x12ae89){_0x3556b4[_0x4e1fd6]=_0x57623d(_0x4e1fd6);const _0x3b1ad1=_0x42d225(_0x4e1fd6);if(_0x3b1ad1&&_0x3b1ad1[_0x1ffd3b(0x15f)]&&_0x5e499f[_0x3b1ad1[_0x1ffd3b(0x15f)]])_0x3b1ad1['activeSavedTokens']=_0x5e499f[_0x3b1ad1[_0x1ffd3b(0x15f)]][_0x1ffd3b(0x19a)]||0x0;else{if(_0x3b1ad1)_0x3b1ad1['activeSavedTokens']=0x0;}_0x20e9f8[_0x4e1fd6]=_0x3b1ad1;const _0x460cbb=_0x44b051[_0x1ffd3b(0x17c)](_0x186a78=>_0x186a78[_0x1ffd3b(0x192)]&&_0x186a78[_0x1ffd3b(0x192)][_0x1ffd3b(0x16e)]('conv:'+_0x4e1fd6));_0x460cbb[_0x1ffd3b(0x13a)]>0x0?_0x148e25[_0x4e1fd6]=_0x460cbb[_0x460cbb['length']-0x1][_0x1ffd3b(0x150)]:_0x148e25[_0x4e1fd6]=_0x3b1ad1?_0x3b1ad1[_0x1ffd3b(0x162)]:null;}const _0x12f3d9={..._0x7c20d1,'resolvedPaths':_0x3556b4,'lastActiveTimestamps':_0x148e25,'latestSessions':_0x20e9f8};configPayloadCache={'at':Date[_0x1ffd3b(0x132)](),'payload':_0x12f3d9},_0xe79c7e['json'](_0x12f3d9);}),app[a0_0x33a1cc(0x131)](a0_0x33a1cc(0x176),async(_0x6a0274,_0x294a19)=>{const _0x2ab52f=a0_0x33a1cc,{getAgentStoragePaths:_0x275a21}=await Promise[_0x2ab52f(0x18b)]()[_0x2ab52f(0x168)](()=>__importStar(require('./file-watcher'))),{agentKey:_0x923932}=_0x6a0274[_0x2ab52f(0x19f)]||{};if(!_0x923932)return _0x294a19['status'](0x190)[_0x2ab52f(0x18a)]({'error':'Missing\x20agentKey'});const _0x1f12d2=_0x275a21(_0x923932),_0x10ea13=_0x1f12d2[_0x2ab52f(0x19b)](_0x58c310=>fs['existsSync'](_0x58c310))||_0x1f12d2[0x0];if(_0x10ea13){if(!fs[_0x2ab52f(0x17a)](_0x10ea13))try{fs[_0x2ab52f(0x171)](_0x10ea13,{'recursive':!![]});}catch{}const {exec:_0x1e226c}=await Promise[_0x2ab52f(0x18b)]()['then'](()=>__importStar(require(_0x2ab52f(0x17d)))),_0x562867=process[_0x2ab52f(0x138)]==='win32'?_0x2ab52f(0x18d)+_0x10ea13+'\x22':process['platform']===_0x2ab52f(0x14d)?_0x2ab52f(0x14b)+_0x10ea13+'\x22':_0x2ab52f(0x158)+_0x10ea13+'\x22';return _0x1e226c(_0x562867),_0x294a19[_0x2ab52f(0x18a)]({'success':!![],'openedPath':_0x10ea13});}_0x294a19[_0x2ab52f(0x154)](0x194)[_0x2ab52f(0x18a)]({'error':_0x2ab52f(0x159)});}),app[a0_0x33a1cc(0x131)](a0_0x33a1cc(0x19e),async(_0x324d8b,_0x540b41)=>{const _0x25c1f1=a0_0x33a1cc,{saveConfig:_0x4eb729}=await Promise[_0x25c1f1(0x18b)]()[_0x25c1f1(0x168)](()=>__importStar(require(_0x25c1f1(0x183)))),{key:_0x49e249,value:_0x20a0c6}=_0x324d8b[_0x25c1f1(0x19f)]||{};if(_0x49e249){const _0x2d22bc=_0x4eb729({'conversation_toggles':{[_0x49e249]:_0x20a0c6}});return invalidateConfigCache(),_0x540b41['json'](_0x2d22bc);}_0x540b41[_0x25c1f1(0x154)](0x190)[_0x25c1f1(0x18a)]({'error':_0x25c1f1(0x13c)});}),app['post'](a0_0x33a1cc(0x194),async(_0x56ab78,_0x22e646)=>{const _0x241a88=a0_0x33a1cc,{saveConfig:_0x3c56a2}=await Promise['resolve']()[_0x241a88(0x168)](()=>__importStar(require('./file-watcher'))),{agentKey:_0x2cccc4,path:_0x2a04b7}=_0x56ab78['body']||{};if(_0x2cccc4){const _0x58d4cb=_0x3c56a2({'custom_storage_paths':{[_0x2cccc4]:_0x2a04b7||null}});return invalidateConfigCache(),_0x22e646['json'](_0x58d4cb);}_0x22e646[_0x241a88(0x154)](0x190)[_0x241a88(0x18a)]({'error':_0x241a88(0x160)});});function startDashboard(_0xe7e11e=0xfa0){const _0x5e00b7=a0_0x33a1cc;let _0x406cbe=_0xe7e11e;const _0x242ac7=process[_0x5e00b7(0x191)][_0x5e00b7(0x16e)](_0x5e00b7(0x12b))||process.env.TRIMPROMPT_HEADLESS==='1',_0x44940d=app[_0x5e00b7(0x145)](_0x406cbe,()=>{const _0x775d89=_0x5e00b7,_0x4278e9=_0x775d89(0x155)+_0x406cbe;!_0x242ac7&&(console[_0x775d89(0x13f)]('\x0a[TrimPrompt]\x20Dashboard\x20server\x20started\x20at:\x20'+_0x4278e9),console[_0x775d89(0x13f)](_0x775d89(0x18c)));try{const {spawn:_0x1f26ef}=require(_0x775d89(0x17d)),_0x4ae25f=_0x1f26ef(process[_0x775d89(0x136)],[path[_0x775d89(0x15c)](__dirname,_0x775d89(0x198)),_0x775d89(0x18e),'start'],{'stdio':_0x775d89(0x149),'windowsHide':!![]}),_0x44ff95=()=>{try{_0x4ae25f['kill']();}catch{}};process['on'](_0x775d89(0x141),_0x44ff95),process['on'](_0x775d89(0x197),()=>{_0x44ff95(),process['exit'](0x0);}),process['on'](_0x775d89(0x14c),()=>{_0x44ff95(),process['exit'](0x0);});}catch{}!_0x242ac7&&process.env.TRIMPROMPT_NO_OPEN!=='1'&&(0x0,open_1[_0x775d89(0x186)])(_0x4278e9)[_0x775d89(0x174)](()=>{});});_0x44940d['on'](_0x5e00b7(0x189),_0x375b61=>{const _0x1399d8=_0x5e00b7;_0x375b61[_0x1399d8(0x177)]===_0x1399d8(0x187)?startDashboard(_0x406cbe+0x1):console['error'](_0x1399d8(0x188)+_0x375b61[_0x1399d8(0x157)]);});}