@treasuredata/tdx 0.1.9 → 0.1.11

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.
Files changed (76) hide show
  1. package/README.md +68 -0
  2. package/dist/cli.js +1 -1
  3. package/dist/cli.js.map +1 -1
  4. package/dist/client/cdp-client.js +1 -1
  5. package/dist/client/http-client.js +1 -1
  6. package/dist/client/llm-client.js +1 -1
  7. package/dist/client/rate-limiter.js +1 -1
  8. package/dist/client/td-client.js +1 -1
  9. package/dist/client/trino-client.js +1 -1
  10. package/dist/client/workflow-client.js +1 -1
  11. package/dist/commands/activations.js +1 -1
  12. package/dist/commands/api-command.js +1 -1
  13. package/dist/commands/chat-command.js +1 -1
  14. package/dist/commands/claude-command.d.ts +21 -0
  15. package/dist/commands/claude-command.d.ts.map +1 -0
  16. package/dist/commands/claude-command.js +1 -0
  17. package/dist/commands/claude-command.js.map +1 -0
  18. package/dist/commands/command.js +1 -1
  19. package/dist/commands/context-command.js +1 -1
  20. package/dist/commands/databases.js +1 -1
  21. package/dist/commands/describe.js +1 -1
  22. package/dist/commands/llm-command.js +1 -1
  23. package/dist/commands/llm-proxy.js +1 -1
  24. package/dist/commands/profiles-command.js +1 -1
  25. package/dist/commands/query-command.js +1 -1
  26. package/dist/commands/segment-command.js +1 -1
  27. package/dist/commands/segments.js +1 -1
  28. package/dist/commands/show.js +1 -1
  29. package/dist/commands/tables.js +1 -1
  30. package/dist/commands/use-command.js +1 -1
  31. package/dist/commands/workflow-command.js +1 -1
  32. package/dist/core/auth.js +1 -1
  33. package/dist/core/config.js +1 -1
  34. package/dist/core/global-context.js +1 -1
  35. package/dist/core/profile.js +1 -1
  36. package/dist/core/project-config.js +1 -1
  37. package/dist/core/session.js +1 -1
  38. package/dist/index.js +1 -1
  39. package/dist/proxy/anthropic-adapter.js +1 -1
  40. package/dist/proxy/server.js +1 -1
  41. package/dist/sdk/api.js +1 -1
  42. package/dist/sdk/database.js +1 -1
  43. package/dist/sdk/errors.d.ts +2 -0
  44. package/dist/sdk/errors.d.ts.map +1 -1
  45. package/dist/sdk/errors.js +1 -1
  46. package/dist/sdk/errors.js.map +1 -1
  47. package/dist/sdk/index.js +1 -1
  48. package/dist/sdk/llm.js +1 -1
  49. package/dist/sdk/query.js +1 -1
  50. package/dist/sdk/segment.js +1 -1
  51. package/dist/sdk/table.js +1 -1
  52. package/dist/sdk/workflow.js +1 -1
  53. package/dist/types/endpoints.js +1 -1
  54. package/dist/types/index.js +1 -1
  55. package/dist/utils/agent-ref-parser.js +1 -1
  56. package/dist/utils/chat-cache.js +1 -1
  57. package/dist/utils/colors.js +1 -1
  58. package/dist/utils/command-output.js +1 -1
  59. package/dist/utils/file-permissions.js +1 -1
  60. package/dist/utils/format-detector.js +1 -1
  61. package/dist/utils/formatters.js +1 -1
  62. package/dist/utils/model-aliases.js +1 -1
  63. package/dist/utils/option-validation.js +1 -1
  64. package/dist/utils/port.d.ts +18 -0
  65. package/dist/utils/port.d.ts.map +1 -0
  66. package/dist/utils/port.js +1 -0
  67. package/dist/utils/port.js.map +1 -0
  68. package/dist/utils/process.js +1 -1
  69. package/dist/utils/segment-ref-parser.js +1 -1
  70. package/dist/utils/spinner.js +1 -1
  71. package/dist/utils/sql-parser.js +1 -1
  72. package/dist/utils/sse-parser.js +1 -1
  73. package/dist/utils/string-utils.js +1 -1
  74. package/dist/utils/table-ref-parser.js +1 -1
  75. package/dist/utils/workflow-utils.js +1 -1
  76. package/package.json +1 -1
@@ -1 +1 @@
1
- const a24_0xbb13ff=a24_0x3903;(function(_0x4a6012,_0x3671db){const _0x45e3e7=a24_0x3903,_0x3f086d=_0x4a6012();while(!![]){try{const _0x155dcf=parseInt(_0x45e3e7(0x116))/0x1*(-parseInt(_0x45e3e7(0x12a))/0x2)+-parseInt(_0x45e3e7(0x15f))/0x3+-parseInt(_0x45e3e7(0x11c))/0x4*(-parseInt(_0x45e3e7(0x130))/0x5)+-parseInt(_0x45e3e7(0x13d))/0x6+parseInt(_0x45e3e7(0x149))/0x7+-parseInt(_0x45e3e7(0x141))/0x8+-parseInt(_0x45e3e7(0x15d))/0x9*(-parseInt(_0x45e3e7(0x121))/0xa);if(_0x155dcf===_0x3671db)break;else _0x3f086d['push'](_0x3f086d['shift']());}catch(_0x3020c3){_0x3f086d['push'](_0x3f086d['shift']());}}}(a24_0x5703,0x9f958));import{BaseCommand}from'./command.js';import{SDKError}from'../sdk/index.js';import{handleSDKOutput}from'../utils/command-output.js';import{withSpinner}from'../utils/spinner.js';import*as a24_0xbefb4a from'readline';async function confirm(_0x6c66c1){const _0x226d1f=a24_0x3903,_0x56d898=a24_0xbefb4a[_0x226d1f(0x153)]({'input':process[_0x226d1f(0x12e)],'output':process[_0x226d1f(0x16e)]});return new Promise(_0x45d48b=>{const _0x32cc74=_0x226d1f;_0x56d898[_0x32cc74(0x13e)](_0x6c66c1+'\x20(y/N):\x20',_0x14be9c=>{const _0x5540b9=_0x32cc74;_0x56d898[_0x5540b9(0x165)](),_0x45d48b(_0x14be9c[_0x5540b9(0x167)]()==='y'||_0x14be9c[_0x5540b9(0x167)]()===_0x5540b9(0x13c));});});}export class WorkflowProjectsCommand extends BaseCommand{[a24_0xbb13ff(0x100)]='workflow:projects';[a24_0xbb13ff(0x103)]=a24_0xbb13ff(0x15b);async['execute'](_0x724ef9){const _0x24d074=a24_0xbb13ff,{options:_0x4bb825,args:_0x483f1f,tdx:_0xd3cc5a}=_0x724ef9,_0x2ed0e2=_0x483f1f[0x0];try{_0x4bb825[_0x24d074(0x14e)]&&_0x2ed0e2&&console['error'](_0x24d074(0x109)+_0x2ed0e2);const _0x23aee6=await withSpinner('Listing\x20workflow\x20projects...',()=>_0xd3cc5a['workflow'][_0x24d074(0x173)](_0x2ed0e2,{'limit':_0x4bb825['limit']}),{'verbose':_0x4bb825['verbose']}),_0x119128=_0x23aee6['data'];return console['error'](_0x24d074(0x10c)+_0x119128[_0x24d074(0x120)]+_0x24d074(0x177)+(_0x119128[_0x24d074(0x120)]!==0x1?'s':'')),await handleSDKOutput(_0x119128,_0x4bb825),0x0;}catch(_0x45ed83){if(_0x45ed83 instanceof SDKError)return console['error'](_0x24d074(0x145)+_0x45ed83[_0x24d074(0x174)]),_0x45ed83[_0x24d074(0x11e)]&&console[_0x24d074(0x10d)](_0x24d074(0x136)+_0x45ed83[_0x24d074(0x11e)]),0x1;throw _0x45ed83;}}}export class WorkflowWorkflowsCommand extends BaseCommand{[a24_0xbb13ff(0x100)]=a24_0xbb13ff(0x164);['description']=a24_0xbb13ff(0x12d);async[a24_0xbb13ff(0x10e)](_0x272cdf){const _0x3053f7=a24_0xbb13ff,{options:_0xa7f249,args:_0x4c1dab,tdx:_0x1290b2}=_0x272cdf,_0x4f2bc1=_0x4c1dab[0x0];try{_0xa7f249[_0x3053f7(0x14e)]&&_0x4f2bc1&&console[_0x3053f7(0x10d)](_0x3053f7(0x163)+_0x4f2bc1);const _0x47e69b=await withSpinner(_0x3053f7(0x158),()=>_0x1290b2['workflow'][_0x3053f7(0x10f)](_0x4f2bc1,{'limit':_0xa7f249['limit']}),{'verbose':_0xa7f249[_0x3053f7(0x14e)]}),_0x34d34b=_0x47e69b['data'];return console['error'](_0x3053f7(0x10c)+_0x34d34b[_0x3053f7(0x120)]+_0x3053f7(0x13f)+(_0x34d34b[_0x3053f7(0x120)]!==0x1?'s':'')),await handleSDKOutput(_0x34d34b,_0xa7f249),0x0;}catch(_0x172309){if(_0x172309 instanceof SDKError)return console[_0x3053f7(0x10d)](_0x3053f7(0x145)+_0x172309[_0x3053f7(0x174)]),_0x172309['cause']&&console[_0x3053f7(0x10d)](_0x3053f7(0x136)+_0x172309[_0x3053f7(0x11e)]),0x1;throw _0x172309;}}}export class WorkflowSessionsCommand extends BaseCommand{['name']='workflow:sessions';['description']=a24_0xbb13ff(0x17c);async[a24_0xbb13ff(0x10e)](_0x3e2628){const _0x569af2=a24_0xbb13ff,{options:_0x28515b,args:_0x5ba3d,tdx:_0x1482a4}=_0x3e2628;let _0x41a3a4,_0x146be3;if(_0x5ba3d[0x0]){const _0x4ede05=_0x5ba3d[0x0][_0x569af2(0x101)]('.');if(_0x4ede05[_0x569af2(0x120)]===0x1)_0x41a3a4=_0x4ede05[0x0];else{if(_0x4ede05['length']===0x2)[_0x41a3a4,_0x146be3]=_0x4ede05;else return console[_0x569af2(0x10d)](_0x569af2(0x171)),0x1;}}try{if(_0x28515b[_0x569af2(0x14e)]){if(_0x41a3a4&&_0x146be3)console[_0x569af2(0x10d)](_0x569af2(0x178)+_0x41a3a4+'.'+_0x146be3);else _0x41a3a4&&console[_0x569af2(0x10d)](_0x569af2(0x112)+_0x41a3a4);const _0x281bfb=_0x28515b[_0x569af2(0x14b)];_0x281bfb&&console[_0x569af2(0x10d)]('Status:\x20'+_0x281bfb);}const _0x1b5c28=await withSpinner(_0x569af2(0x131),()=>_0x1482a4[_0x569af2(0x14d)]['sessions']({'projectName':_0x41a3a4,'workflowName':_0x146be3,'status':_0x28515b['status'],'fromTime':_0x28515b[_0x569af2(0x105)],'toTime':_0x28515b['to'],'limit':_0x28515b['limit']}),{'verbose':_0x28515b[_0x569af2(0x14e)]}),_0x261673=_0x1b5c28[_0x569af2(0x15c)];return console[_0x569af2(0x10d)](_0x569af2(0x10c)+_0x261673[_0x569af2(0x120)]+_0x569af2(0x129)+(_0x261673[_0x569af2(0x120)]!==0x1?'s':'')),await handleSDKOutput(_0x261673,_0x28515b),0x0;}catch(_0x49bfc5){if(_0x49bfc5 instanceof SDKError)return console['error'](_0x569af2(0x145)+_0x49bfc5[_0x569af2(0x174)]),_0x49bfc5['cause']&&console[_0x569af2(0x10d)](_0x569af2(0x136)+_0x49bfc5[_0x569af2(0x11e)]),0x1;throw _0x49bfc5;}}}export class WorkflowAttemptsCommand extends BaseCommand{['name']=a24_0xbb13ff(0xfc);[a24_0xbb13ff(0x103)]='List\x20workflow\x20attempts';async[a24_0xbb13ff(0x10e)](_0xcb8078){const _0x253156=a24_0xbb13ff,{options:_0x531818,args:_0x2ac4e4,tdx:_0x2e3d4f}=_0xcb8078;let _0x4c3123,_0x2ce65a;if(_0x2ac4e4[0x0]){const _0x153aa4=_0x2ac4e4[0x0][_0x253156(0x101)]('.');if(_0x153aa4[_0x253156(0x120)]===0x1)_0x4c3123=_0x153aa4[0x0];else{if(_0x153aa4[_0x253156(0x120)]===0x2)[_0x4c3123,_0x2ce65a]=_0x153aa4;else return console[_0x253156(0x10d)](_0x253156(0x171)),0x1;}}try{const _0x504d15=_0x531818[_0x253156(0x114)];if(_0x531818[_0x253156(0x14e)]){if(_0x4c3123&&_0x2ce65a)console[_0x253156(0x10d)](_0x253156(0x178)+_0x4c3123+'.'+_0x2ce65a);else _0x4c3123&&console[_0x253156(0x10d)]('Filter:\x20project='+_0x4c3123);_0x504d15&&console[_0x253156(0x10d)](_0x253156(0x155));}const _0x53ee12=await withSpinner('Listing\x20workflow\x20attempts...',()=>_0x2e3d4f[_0x253156(0x14d)][_0x253156(0x104)]({'projectName':_0x4c3123,'workflowName':_0x2ce65a,'includeRetried':_0x504d15,'limit':_0x531818[_0x253156(0x11b)]}),{'verbose':_0x531818['verbose']}),_0x5aa78d=_0x53ee12['data'];return console[_0x253156(0x10d)](_0x253156(0x10c)+_0x5aa78d[_0x253156(0x120)]+_0x253156(0x12c)+(_0x5aa78d[_0x253156(0x120)]!==0x1?'s':'')),await handleSDKOutput(_0x5aa78d,_0x531818),0x0;}catch(_0xe0bce9){if(_0xe0bce9 instanceof SDKError)return console['error'](_0x253156(0x145)+_0xe0bce9[_0x253156(0x174)]),_0xe0bce9[_0x253156(0x11e)]&&console[_0x253156(0x10d)](_0x253156(0x136)+_0xe0bce9[_0x253156(0x11e)]),0x1;throw _0xe0bce9;}}}export class WorkflowAttemptCommand extends BaseCommand{[a24_0xbb13ff(0x100)]=a24_0xbb13ff(0x140);[a24_0xbb13ff(0x103)]=a24_0xbb13ff(0x172);async[a24_0xbb13ff(0x10e)](_0x5de7b9){const _0x3a24fe=a24_0xbb13ff,{options:_0x191d71,args:_0x3874ad,tdx:_0x23fa47}=_0x5de7b9,_0x412f23=_0x3874ad[0x0];if(!_0x412f23)return console[_0x3a24fe(0x10d)](_0x3a24fe(0x127)),0x1;try{_0x191d71[_0x3a24fe(0x14e)]&&console[_0x3a24fe(0x10d)](_0x3a24fe(0x176)+_0x412f23);const _0x209650=await withSpinner('Getting\x20attempt\x20details...',()=>_0x23fa47[_0x3a24fe(0x14d)][_0x3a24fe(0x160)](_0x412f23),{'verbose':_0x191d71[_0x3a24fe(0x14e)]}),_0x51a861=_0x209650[_0x3a24fe(0x15c)];return await handleSDKOutput([_0x51a861],_0x191d71),0x0;}catch(_0x111955){if(_0x111955 instanceof SDKError)return console['error'](_0x3a24fe(0x145)+_0x111955[_0x3a24fe(0x174)]),_0x111955['cause']&&console['error'](_0x3a24fe(0x136)+_0x111955['cause']),0x1;throw _0x111955;}}}export class WorkflowTasksCommand extends BaseCommand{[a24_0xbb13ff(0x100)]='workflow:tasks';[a24_0xbb13ff(0x103)]=a24_0xbb13ff(0x170);async[a24_0xbb13ff(0x10e)](_0x7d9ffb){const _0x568f3b=a24_0xbb13ff,{options:_0x557b85,args:_0x305509,tdx:_0x1255bd}=_0x7d9ffb,_0xa581e6=_0x305509[0x0];if(!_0xa581e6)return console[_0x568f3b(0x10d)]('Error:\x20Attempt\x20ID\x20is\x20required'),0x1;try{const _0x147052=_0x557b85[_0x568f3b(0x157)];_0x557b85[_0x568f3b(0x14e)]&&(console[_0x568f3b(0x10d)](_0x568f3b(0x176)+_0xa581e6),_0x147052&&console[_0x568f3b(0x10d)](_0x568f3b(0x181)));const _0x52ed2b=await withSpinner(_0x568f3b(0x133),()=>_0x1255bd[_0x568f3b(0x14d)]['tasks'](_0xa581e6,_0x147052||![]),{'verbose':_0x557b85[_0x568f3b(0x14e)]}),_0x348997=_0x52ed2b[_0x568f3b(0x15c)];return console[_0x568f3b(0x10d)](_0x568f3b(0x10c)+_0x348997['length']+_0x568f3b(0x15e)+(_0x348997[_0x568f3b(0x120)]!==0x1?'s':'')),await handleSDKOutput(_0x348997,_0x557b85),0x0;}catch(_0x30b273){if(_0x30b273 instanceof SDKError)return console[_0x568f3b(0x10d)](_0x568f3b(0x145)+_0x30b273[_0x568f3b(0x174)]),_0x30b273[_0x568f3b(0x11e)]&&console['error'](_0x568f3b(0x136)+_0x30b273[_0x568f3b(0x11e)]),0x1;throw _0x30b273;}}}function a24_0x3903(_0x12f4d4,_0x481055){const _0x5703f2=a24_0x5703();return a24_0x3903=function(_0x390352,_0x35f513){_0x390352=_0x390352-0xfc;let _0xea08c3=_0x5703f2[_0x390352];return _0xea08c3;},a24_0x3903(_0x12f4d4,_0x481055);}export class WorkflowLogsCommand extends BaseCommand{[a24_0xbb13ff(0x100)]=a24_0xbb13ff(0x15a);[a24_0xbb13ff(0x103)]=a24_0xbb13ff(0x166);async['execute'](_0x229cc4){const _0xe0bd56=a24_0xbb13ff,{options:_0x3a5d33,args:_0x1fa17b,tdx:_0x781212}=_0x229cc4,_0x2f0f3c=_0x1fa17b[0x0],_0x3feba1=_0x1fa17b[0x1];if(!_0x2f0f3c||!_0x3feba1)return console[_0xe0bd56(0x10d)](_0xe0bd56(0x151)),0x1;try{_0x3a5d33[_0xe0bd56(0x14e)]&&(console[_0xe0bd56(0x10d)]('Attempt\x20ID:\x20'+_0x2f0f3c),console[_0xe0bd56(0x10d)](_0xe0bd56(0x148)+_0x3feba1));const _0x1cf878=_0x3a5d33[_0xe0bd56(0x119)],_0x52e450=await withSpinner('Getting\x20task\x20logs...',()=>_0x781212['workflow'][_0xe0bd56(0x137)](_0x2f0f3c,_0x3feba1,{'offset':_0x1cf878,'limit':_0x3a5d33['limit']}),{'verbose':_0x3a5d33[_0xe0bd56(0x14e)]}),_0xffc504=_0x52e450[_0xe0bd56(0x15c)];return console['error'](_0xe0bd56(0x10c)+_0xffc504[_0xe0bd56(0x120)]+'\x20log\x20entr'+(_0xffc504[_0xe0bd56(0x120)]!==0x1?_0xe0bd56(0x111):'y')),await handleSDKOutput(_0xffc504,_0x3a5d33),0x0;}catch(_0x5ad06c){if(_0x5ad06c instanceof SDKError)return console[_0xe0bd56(0x10d)](_0xe0bd56(0x145)+_0x5ad06c['message']),_0x5ad06c[_0xe0bd56(0x11e)]&&console[_0xe0bd56(0x10d)]('\x20\x20Cause:\x20'+_0x5ad06c[_0xe0bd56(0x11e)]),0x1;throw _0x5ad06c;}}}export class WorkflowKillCommand extends BaseCommand{[a24_0xbb13ff(0x100)]='workflow:kill';['description']=a24_0xbb13ff(0x11d);async[a24_0xbb13ff(0x10e)](_0x39074c){const _0x4a5fff=a24_0xbb13ff,{options:_0x5e00a2,args:_0x1f952f,tdx:_0x148949}=_0x39074c,_0x1fb66b=_0x1f952f[0x0];if(!_0x1fb66b)return console[_0x4a5fff(0x10d)]('Error:\x20Attempt\x20ID\x20is\x20required'),0x1;try{const _0x2a81dd=_0x5e00a2[_0x4a5fff(0x14a)];_0x5e00a2[_0x4a5fff(0x14e)]&&(console[_0x4a5fff(0x10d)](_0x4a5fff(0x176)+_0x1fb66b),_0x2a81dd&&console[_0x4a5fff(0x10d)](_0x4a5fff(0x138)+_0x2a81dd));if(!_0x5e00a2[_0x4a5fff(0x13c)]){const _0x541189=await confirm('Are\x20you\x20sure\x20you\x20want\x20to\x20kill\x20attempt\x20'+_0x1fb66b+'?');if(!_0x541189)return console['error'](_0x4a5fff(0x17f)),0x0;}const _0x3fd6e5=await withSpinner(_0x4a5fff(0x124),()=>_0x148949['workflow'][_0x4a5fff(0x150)](_0x1fb66b,_0x2a81dd),{'verbose':_0x5e00a2['verbose']}),_0x5e60e9=_0x3fd6e5[_0x4a5fff(0x15c)];return console['error']('✔\x20'+_0x5e60e9),0x0;}catch(_0x53b884){if(_0x53b884 instanceof SDKError)return console[_0x4a5fff(0x10d)](_0x4a5fff(0x145)+_0x53b884[_0x4a5fff(0x174)]),_0x53b884['cause']&&console[_0x4a5fff(0x10d)]('\x20\x20Cause:\x20'+_0x53b884[_0x4a5fff(0x11e)]),0x1;throw _0x53b884;}}}export class WorkflowRetryCommand extends BaseCommand{['name']=a24_0xbb13ff(0xfe);[a24_0xbb13ff(0x103)]=a24_0xbb13ff(0x13b);async[a24_0xbb13ff(0x10e)](_0x1140c7){const _0x3bbd55=a24_0xbb13ff,{options:_0x4847ad,args:_0x381d77,tdx:_0x15bfe7}=_0x1140c7,_0x4618bb=_0x381d77[0x0];if(!_0x4618bb)return console[_0x3bbd55(0x10d)](_0x3bbd55(0x17e)),console[_0x3bbd55(0x10d)](_0x3bbd55(0x122)),0x1;let _0x38249d=![],_0xc1d20a=_0x4618bb;if(_0x4618bb[_0x3bbd55(0x143)](_0x3bbd55(0x16c)))_0x38249d=!![],_0xc1d20a=_0x4618bb[_0x3bbd55(0x11f)](0x8);else{if(_0x4618bb['startsWith']('attempt:'))_0x38249d=![],_0xc1d20a=_0x4618bb['substring'](0x8);else return console[_0x3bbd55(0x10d)](_0x3bbd55(0x142)),console[_0x3bbd55(0x10d)](_0x3bbd55(0x122)),0x1;}try{const _0x2eef93=_0x4847ad['fromTask'],_0xded081=_0x4847ad[_0x3bbd55(0x17a)],_0x4be5ce=_0x4847ad[_0x3bbd55(0x175)],_0x574acf=_0x4847ad[_0x3bbd55(0x156)];_0x4847ad[_0x3bbd55(0x14e)]&&(console[_0x3bbd55(0x10d)](_0x3bbd55(0x132)+(_0x38249d?_0x3bbd55(0x106):_0x3bbd55(0x160))+'\x20'+_0xc1d20a),_0x2eef93&&console[_0x3bbd55(0x10d)](_0x3bbd55(0x12f)+_0x2eef93),_0xded081&&console['error']('Resume\x20from:\x20'+_0xded081),_0x4be5ce&&console['error'](_0x3bbd55(0x134)+_0x4be5ce),_0x574acf&&console[_0x3bbd55(0x10d)](_0x3bbd55(0x10b)));let _0xe56496;if(_0x4be5ce)try{if(_0x4be5ce[_0x3bbd55(0x143)]('@')){const _0x3826ed=await import('fs/promises'),_0x54ce51=_0x4be5ce[_0x3bbd55(0x11f)](0x1),_0x466f19=await _0x3826ed['readFile'](_0x54ce51,'utf-8');_0xe56496=JSON[_0x3bbd55(0x135)](_0x466f19);}else _0xe56496=JSON[_0x3bbd55(0x135)](_0x4be5ce);}catch{return console['error'](_0x3bbd55(0x179)),0x1;}if(!_0x4847ad[_0x3bbd55(0x13c)]){const _0x2fd55f=await confirm(_0x3bbd55(0x16d)+(_0x38249d?'session':_0x3bbd55(0x160))+'\x20'+_0xc1d20a+'?');if(!_0x2fd55f)return console['error']('Cancelled'),0x0;}let _0xbb748b;_0x38249d?_0xbb748b=await withSpinner('Retrying\x20session...',()=>_0x15bfe7[_0x3bbd55(0x14d)]['retrySession'](_0xc1d20a,{'fromTask':_0x2eef93,'retryParams':_0xe56496}),{'verbose':_0x4847ad[_0x3bbd55(0x14e)]}):_0xbb748b=await withSpinner(_0x3bbd55(0x107),()=>_0x15bfe7[_0x3bbd55(0x14d)][_0x3bbd55(0x14c)](_0xc1d20a,{'resumeFrom':_0xded081,'retryParams':_0xe56496,'force':_0x574acf}),{'verbose':_0x4847ad['verbose']});const _0x143d02=_0xbb748b[_0x3bbd55(0x15c)];return console['error']('✔\x20Retry\x20started'),console[_0x3bbd55(0x10d)]('\x20\x20New\x20attempt\x20ID:\x20'+_0x143d02[_0x3bbd55(0x17d)]),console[_0x3bbd55(0x10d)](_0x3bbd55(0x159)+_0x143d02[_0x3bbd55(0x14f)]),0x0;}catch(_0x40b818){if(_0x40b818 instanceof SDKError)return console[_0x3bbd55(0x10d)](_0x3bbd55(0x145)+_0x40b818[_0x3bbd55(0x174)]),_0x40b818[_0x3bbd55(0x11e)]&&console[_0x3bbd55(0x10d)]('\x20\x20Cause:\x20'+_0x40b818[_0x3bbd55(0x11e)]),0x1;throw _0x40b818;}}}export class WorkflowDownloadCommand extends BaseCommand{['name']=a24_0xbb13ff(0x161);[a24_0xbb13ff(0x103)]='Download\x20workflow\x20project\x20from\x20Treasure\x20Data';async['execute'](_0x23b4d6){const _0xbe670d=a24_0xbb13ff,{options:_0x29a493,args:_0x203970,tdx:_0x437ab2}=_0x23b4d6,_0x1ea345=_0x203970[0x0],_0x5a5caa=_0x203970[0x1]||'.';if(!_0x1ea345)return console['error'](_0xbe670d(0x11a)),console[_0xbe670d(0x10d)]('Usage:\x20workflow:download\x20<project-name>\x20[output-dir]'),0x1;const _0x44749e=_0x29a493[_0xbe670d(0x146)];_0x29a493['verbose']&&(console[_0xbe670d(0x10d)](_0xbe670d(0x126)+_0x1ea345),console[_0xbe670d(0x10d)](_0xbe670d(0x17b)+_0x5a5caa),_0x44749e&&console['error'](_0xbe670d(0x168)+_0x44749e));const _0x38f8e7=await withSpinner(_0xbe670d(0x115)+_0x1ea345+_0xbe670d(0x180),()=>_0x437ab2[_0xbe670d(0x14d)][_0xbe670d(0x113)](_0x1ea345,_0x5a5caa,{'revision':_0x44749e}),{'verbose':_0x29a493['verbose']}),_0x1a691a=_0x38f8e7[_0xbe670d(0x15c)];return console[_0xbe670d(0x10d)](_0xbe670d(0x108)+_0x1a691a['projectName']),console[_0xbe670d(0x10d)](_0xbe670d(0x10a)+_0x1a691a['revision']),console[_0xbe670d(0x10d)](_0xbe670d(0xfd)+_0x1a691a[_0xbe670d(0x117)]),console['error']('\x20\x20Location:\x20'+_0x5a5caa+'/'+_0x1a691a[_0xbe670d(0x169)]),0x0;}}export class WorkflowPushCommand extends BaseCommand{['name']=a24_0xbb13ff(0x123);['description']='Push\x20workflow\x20project\x20to\x20Treasure\x20Data';async[a24_0xbb13ff(0x10e)](_0x565709){const _0x224bee=a24_0xbb13ff,{options:_0x1db893,args:_0x1a086f,tdx:_0x300c34}=_0x565709;let _0x373368='.',_0x58faf1=_0x1db893[_0x224bee(0x100)];if(_0x1a086f[0x0]){const {promises:_0x6752e4}=await import('fs');try{const _0x41e734=await _0x6752e4[_0x224bee(0x147)](_0x1a086f[0x0]);if(_0x41e734[_0x224bee(0x16a)]())_0x373368=_0x1a086f[0x0];else return console[_0x224bee(0x10d)](_0x224bee(0x145)+_0x1a086f[0x0]+_0x224bee(0xff)),0x1;}catch{_0x58faf1=_0x1a086f[0x0],_0x373368='.';}}const _0x22875f=_0x1db893['revision'],_0x398344=_0x1db893[_0x224bee(0x139)];_0x1db893[_0x224bee(0x14e)]&&(console[_0x224bee(0x10d)]('Project\x20directory:\x20'+_0x373368),_0x58faf1&&console[_0x224bee(0x10d)](_0x224bee(0x125)+_0x58faf1),_0x22875f&&console[_0x224bee(0x10d)](_0x224bee(0x168)+_0x22875f),_0x398344&&console[_0x224bee(0x10d)](_0x224bee(0x102)));const _0x23d36c=await withSpinner(_0x224bee(0x110),()=>_0x300c34[_0x224bee(0x14d)]['push'](_0x373368,{'projectName':_0x58faf1,'revision':_0x22875f,'skipValidation':_0x398344}),{'verbose':_0x1db893[_0x224bee(0x14e)]}),_0x4dda50=_0x23d36c[_0x224bee(0x15c)];return console[_0x224bee(0x10d)](_0x224bee(0x118)+_0x4dda50['projectName']),console[_0x224bee(0x10d)](_0x224bee(0x154)+_0x4dda50['projectId']),console['error'](_0x224bee(0x10a)+_0x4dda50[_0x224bee(0x146)]),0x0;}}function a24_0x5703(){const _0x5cd825=['offset','Error:\x20Project\x20name\x20is\x20required','limit','161156rrTgMo','Kill\x20a\x20running\x20attempt','cause','substring','length','10wKpeRG','Usage:\x20workflow\x20retry\x20session:<id>\x20or\x20workflow\x20retry\x20attempt:<id>','workflow:push','Killing\x20attempt...','Project\x20name:\x20','Project:\x20','Error:\x20Attempt\x20ID\x20is\x20required','delete','\x20session','2vBkXsf','projectId','\x20attempt','List\x20workflows','stdin','From\x20task:\x20','10tTwOhS','Listing\x20workflow\x20sessions...','Target:\x20','Getting\x20attempt\x20tasks...','Params:\x20','parse','\x20\x20Cause:\x20','logs','Reason:\x20','skipValidation','Delete\x20workflow\x20project\x20from\x20Treasure\x20Data','Retry\x20a\x20session\x20or\x20attempt','yes','7435254Lyjigl','question','\x20workflow','workflow:attempt','4409512InfSZz','Error:\x20Target\x20must\x20be\x20prefixed\x20with\x20\x22session:\x22\x20or\x20\x22attempt:\x22','startsWith','Error:\x20Project\x20name\x20or\x20ID\x20is\x20required','Error:\x20','revision','stat','Task\x20name:\x20','8157702ymseOm','reason','status','retryAttempt','workflow','verbose','sessionId','kill','Error:\x20Attempt\x20ID\x20and\x20task\x20name\x20are\x20required','Are\x20you\x20sure\x20you\x20want\x20to\x20delete\x20project\x20\x22','createInterface','\x20\x20Project\x20ID:\x20','Include\x20retried:\x20yes','force','includeSubtasks','Listing\x20workflows...','\x20\x20Session\x20ID:\x20','workflow:logs','List\x20all\x20workflow\x20projects','data','21103299ogjwRK','\x20task','1965096PyAcLi','attempt','workflow:download','workflow:delete','Project\x20filter:\x20','workflow:workflows','close','Show\x20logs\x20for\x20a\x20specific\x20task','toLowerCase','Revision:\x20','projectName','isDirectory','\x22?\x20This\x20cannot\x20be\x20undone.','session:','Are\x20you\x20sure\x20you\x20want\x20to\x20retry\x20','stdout','Deleting\x20project\x20','Show\x20tasks\x20for\x20an\x20attempt','Error:\x20Invalid\x20pattern.\x20Use\x20format:\x20project\x20or\x20project.workflow','Show\x20specific\x20attempt\x20details','projects','message','params','Attempt\x20ID:\x20','\x20project','Filter:\x20','Error:\x20Invalid\x20JSON\x20in\x20--params','resumeFrom','Output\x20directory:\x20','List\x20workflow\x20execution\x20sessions','attemptId','Error:\x20Session\x20ID\x20or\x20attempt\x20ID\x20is\x20required','Cancelled','...','Including\x20subtasks:\x20yes','workflow:attempts','\x20\x20Files\x20extracted:\x20','workflow:retry','\x20is\x20not\x20a\x20directory','name','split','Validation:\x20skipped','description','attempts','from','session','Retrying\x20attempt...','✔\x20Downloaded\x20','Pattern:\x20','\x20\x20Revision:\x20','Force:\x20yes','✔\x20Found\x20','error','execute','workflows','Pushing\x20workflow\x20project...','ies','Filter:\x20project=','download','includeRetried','Downloading\x20project\x20','491689jLgPPl','filesExtracted','✔\x20Pushed\x20'];a24_0x5703=function(){return _0x5cd825;};return a24_0x5703();}export class WorkflowDeleteCommand extends BaseCommand{[a24_0xbb13ff(0x100)]=a24_0xbb13ff(0x162);[a24_0xbb13ff(0x103)]=a24_0xbb13ff(0x13a);async[a24_0xbb13ff(0x10e)](_0x2ff935){const _0x48c137=a24_0xbb13ff,{options:_0x3ca140,args:_0x3b7c0a,tdx:_0x31cbb9}=_0x2ff935,_0x179c9c=_0x3b7c0a[0x0];if(!_0x179c9c)return console[_0x48c137(0x10d)](_0x48c137(0x144)),console[_0x48c137(0x10d)]('Usage:\x20workflow:delete\x20<project-name-or-id>'),0x1;_0x3ca140[_0x48c137(0x14e)]&&console[_0x48c137(0x10d)]('Project:\x20'+_0x179c9c);if(!_0x3ca140[_0x48c137(0x13c)]){const _0x9e8eb0=await confirm(_0x48c137(0x152)+_0x179c9c+_0x48c137(0x16b));if(!_0x9e8eb0)return console[_0x48c137(0x10d)](_0x48c137(0x17f)),0x0;}const _0x66b5eb=await withSpinner(_0x48c137(0x16f)+_0x179c9c+_0x48c137(0x180),()=>_0x31cbb9['workflow'][_0x48c137(0x128)](_0x179c9c),{'verbose':_0x3ca140[_0x48c137(0x14e)]}),_0x5ef519=_0x66b5eb['data'];return console[_0x48c137(0x10d)]('✔\x20Deleted\x20project\x20'+_0x5ef519[_0x48c137(0x169)]),console[_0x48c137(0x10d)](_0x48c137(0x154)+_0x5ef519[_0x48c137(0x12b)]),0x0;}}
1
+ const a25_0x3a8bc3=a25_0xdc50;(function(_0x40ae05,_0x57b747){const _0x299bcc=a25_0xdc50,_0x28df54=_0x40ae05();while(!![]){try{const _0x426198=-parseInt(_0x299bcc(0x1ef))/0x1*(-parseInt(_0x299bcc(0x200))/0x2)+parseInt(_0x299bcc(0x1f5))/0x3*(parseInt(_0x299bcc(0x212))/0x4)+parseInt(_0x299bcc(0x1d7))/0x5+parseInt(_0x299bcc(0x1fc))/0x6*(parseInt(_0x299bcc(0x218))/0x7)+parseInt(_0x299bcc(0x199))/0x8*(parseInt(_0x299bcc(0x1e6))/0x9)+-parseInt(_0x299bcc(0x201))/0xa+-parseInt(_0x299bcc(0x20a))/0xb;if(_0x426198===_0x57b747)break;else _0x28df54['push'](_0x28df54['shift']());}catch(_0xca8b9c){_0x28df54['push'](_0x28df54['shift']());}}}(a25_0x3e55,0xac8fa));import{BaseCommand}from'./command.js';import{SDKError}from'../sdk/index.js';import{handleSDKOutput}from'../utils/command-output.js';import{withSpinner}from'../utils/spinner.js';import*as a25_0x123961 from'readline';async function confirm(_0x302549){const _0x39bf50=a25_0xdc50,_0xd76341=a25_0x123961[_0x39bf50(0x226)]({'input':process[_0x39bf50(0x1f8)],'output':process[_0x39bf50(0x1db)]});return new Promise(_0x169fae=>{const _0x542225=_0x39bf50;_0xd76341[_0x542225(0x206)](_0x302549+_0x542225(0x1af),_0x4c7e51=>{const _0x949b5c=_0x542225;_0xd76341[_0x949b5c(0x1ec)](),_0x169fae(_0x4c7e51['toLowerCase']()==='y'||_0x4c7e51[_0x949b5c(0x217)]()===_0x949b5c(0x22a));});});}export class WorkflowProjectsCommand extends BaseCommand{[a25_0x3a8bc3(0x1c8)]=a25_0x3a8bc3(0x1a9);[a25_0x3a8bc3(0x1fb)]='List\x20all\x20workflow\x20projects';async['execute'](_0x37eb6d){const _0x5078ac=a25_0x3a8bc3,{options:_0x43747d,args:_0x1ef102,tdx:_0x542183}=_0x37eb6d,_0x3a84e3=_0x1ef102[0x0];try{_0x43747d[_0x5078ac(0x1fd)]&&_0x3a84e3&&console[_0x5078ac(0x1f1)](_0x5078ac(0x1df)+_0x3a84e3);const _0x3d89b1=await withSpinner(_0x5078ac(0x1b4),()=>_0x542183['workflow']['projects'](_0x3a84e3,{'limit':_0x43747d[_0x5078ac(0x19d)]}),{'verbose':_0x43747d[_0x5078ac(0x1fd)]}),_0x5f57c9=_0x3d89b1[_0x5078ac(0x1d9)];return console[_0x5078ac(0x1f1)](_0x5078ac(0x1e5)+_0x5f57c9[_0x5078ac(0x1cb)]+_0x5078ac(0x219)+(_0x5f57c9[_0x5078ac(0x1cb)]!==0x1?'s':'')),await handleSDKOutput(_0x5f57c9,_0x43747d),0x0;}catch(_0x3aee9a){if(_0x3aee9a instanceof SDKError)return console[_0x5078ac(0x1f1)](_0x5078ac(0x1c3)+_0x3aee9a[_0x5078ac(0x1f0)]),_0x3aee9a['cause']&&console['error'](_0x5078ac(0x21d)+_0x3aee9a[_0x5078ac(0x20d)]),0x1;throw _0x3aee9a;}}}export class WorkflowWorkflowsCommand extends BaseCommand{[a25_0x3a8bc3(0x1c8)]='workflow:workflows';[a25_0x3a8bc3(0x1fb)]=a25_0x3a8bc3(0x1d8);async[a25_0x3a8bc3(0x220)](_0xa687b2){const _0x54a4a3=a25_0x3a8bc3,{options:_0x1da5e9,args:_0x1bddab,tdx:_0x1754cf}=_0xa687b2,_0x22879c=_0x1bddab[0x0];try{_0x1da5e9['verbose']&&_0x22879c&&console[_0x54a4a3(0x1f1)](_0x54a4a3(0x1a4)+_0x22879c);const _0x31a6a1=await withSpinner(_0x54a4a3(0x1b0),()=>_0x1754cf[_0x54a4a3(0x1e7)][_0x54a4a3(0x1bb)](_0x22879c,{'limit':_0x1da5e9[_0x54a4a3(0x19d)]}),{'verbose':_0x1da5e9[_0x54a4a3(0x1fd)]}),_0x5828f7=_0x31a6a1[_0x54a4a3(0x1d9)];return console[_0x54a4a3(0x1f1)]('✔\x20Found\x20'+_0x5828f7[_0x54a4a3(0x1cb)]+_0x54a4a3(0x1ce)+(_0x5828f7['length']!==0x1?'s':'')),await handleSDKOutput(_0x5828f7,_0x1da5e9),0x0;}catch(_0x462c89){if(_0x462c89 instanceof SDKError)return console[_0x54a4a3(0x1f1)](_0x54a4a3(0x1c3)+_0x462c89[_0x54a4a3(0x1f0)]),_0x462c89[_0x54a4a3(0x20d)]&&console[_0x54a4a3(0x1f1)]('\x20\x20Cause:\x20'+_0x462c89[_0x54a4a3(0x20d)]),0x1;throw _0x462c89;}}}function a25_0x3e55(){const _0x1f222e=['Push\x20workflow\x20project\x20to\x20Treasure\x20Data','Reason:\x20','createInterface','stat','readFile','✔\x20Retry\x20started','yes','48qNBmec','retrySession','Output\x20directory:\x20','\x20task','limit','substring','Error:\x20Attempt\x20ID\x20is\x20required','Retrying\x20session...','ies','includeSubtasks','From\x20task:\x20','Project\x20filter:\x20','Usage:\x20workflow\x20retry\x20session:<id>\x20or\x20workflow\x20retry\x20attempt:<id>','attempt:','workflow:logs','split','workflow:projects','Error:\x20Project\x20name\x20or\x20ID\x20is\x20required','Retrying\x20attempt...','Killing\x20attempt...','Include\x20retried:\x20yes','Project\x20name:\x20','\x20(y/N):\x20','Listing\x20workflows...','Target:\x20','\x20\x20Location:\x20','\x20\x20Files\x20extracted:\x20','Listing\x20workflow\x20projects...','Task\x20name:\x20','workflow:attempt','Project\x20directory:\x20','Filter:\x20','logs','\x20\x20Session\x20ID:\x20','workflows','Usage:\x20workflow:delete\x20<project-name-or-id>','Error:\x20Target\x20must\x20be\x20prefixed\x20with\x20\x22session:\x22\x20or\x20\x22attempt:\x22','push','List\x20workflow\x20attempts','Resume\x20from:\x20','skipValidation','download','Error:\x20','fromTask','✔\x20Pushed\x20','Force:\x20yes','isDirectory','name','Validation:\x20skipped','sessionId','length','\x20attempt','Delete\x20workflow\x20project\x20from\x20Treasure\x20Data','\x20workflow','Usage:\x20workflow:download\x20<project-name>\x20[output-dir]','workflow:tasks','offset','workflow:retry','Listing\x20workflow\x20attempts...','\x22?\x20This\x20cannot\x20be\x20undone.','projectName','Are\x20you\x20sure\x20you\x20want\x20to\x20kill\x20attempt\x20','4123030fFciIe','List\x20workflows','data','Attempt\x20ID:\x20','stdout','fs/promises','sessions','Filter:\x20project=','Pattern:\x20','Kill\x20a\x20running\x20attempt','✔\x20Downloaded\x20','status','projectId','Show\x20specific\x20attempt\x20details','✔\x20Found\x20','1425159BTqpHE','workflow','startsWith','params','attemptId','includeRetried','close','workflow:kill','List\x20workflow\x20execution\x20sessions','13038dwPMsZ','message','error','session:','session','force','643767Loelfi','✔\x20Deleted\x20project\x20','\x20\x20Project\x20ID:\x20','stdin','reason','retryAttempt','description','6mwNnAk','verbose','Cancelled','\x20session','174wwjkYt','11446360ctaWwF','Listing\x20workflow\x20sessions...','Pushing\x20workflow\x20project...','workflow:push','parse','question','Params:\x20','kill','Revision:\x20','31340133HZrNGK','Project:\x20','\x20log\x20entr','cause','workflow:delete','\x20\x20Revision:\x20','revision','workflow:download','8QqzjIA','from','Retry\x20a\x20session\x20or\x20attempt','Getting\x20attempt\x20details...','Status:\x20','toLowerCase','9536471pjGfOc','\x20project','Getting\x20attempt\x20tasks...','Show\x20logs\x20for\x20a\x20specific\x20task','attempt','\x20\x20Cause:\x20','...','\x20\x20New\x20attempt\x20ID:\x20','execute','workflow:attempts','Error:\x20Invalid\x20JSON\x20in\x20--params','Downloading\x20project\x20'];a25_0x3e55=function(){return _0x1f222e;};return a25_0x3e55();}export class WorkflowSessionsCommand extends BaseCommand{[a25_0x3a8bc3(0x1c8)]='workflow:sessions';['description']=a25_0x3a8bc3(0x1ee);async[a25_0x3a8bc3(0x220)](_0x5702d0){const _0x34048d=a25_0x3a8bc3,{options:_0x427bd5,args:_0x226850,tdx:_0x4a56b7}=_0x5702d0;let _0x2b4873,_0x5b6906;if(_0x226850[0x0]){const _0x18955c=_0x226850[0x0][_0x34048d(0x1a8)]('.');if(_0x18955c[_0x34048d(0x1cb)]===0x1)_0x2b4873=_0x18955c[0x0];else{if(_0x18955c['length']===0x2)[_0x2b4873,_0x5b6906]=_0x18955c;else return console[_0x34048d(0x1f1)]('Error:\x20Invalid\x20pattern.\x20Use\x20format:\x20project\x20or\x20project.workflow'),0x1;}}try{if(_0x427bd5['verbose']){if(_0x2b4873&&_0x5b6906)console[_0x34048d(0x1f1)](_0x34048d(0x1b8)+_0x2b4873+'.'+_0x5b6906);else _0x2b4873&&console[_0x34048d(0x1f1)]('Filter:\x20project='+_0x2b4873);const _0x2971dc=_0x427bd5[_0x34048d(0x1e2)];_0x2971dc&&console[_0x34048d(0x1f1)](_0x34048d(0x216)+_0x2971dc);}const _0xdd2003=await withSpinner(_0x34048d(0x202),()=>_0x4a56b7[_0x34048d(0x1e7)][_0x34048d(0x1dd)]({'projectName':_0x2b4873,'workflowName':_0x5b6906,'status':_0x427bd5['status'],'fromTime':_0x427bd5[_0x34048d(0x213)],'toTime':_0x427bd5['to'],'limit':_0x427bd5[_0x34048d(0x19d)]}),{'verbose':_0x427bd5['verbose']}),_0x529d01=_0xdd2003[_0x34048d(0x1d9)];return console[_0x34048d(0x1f1)](_0x34048d(0x1e5)+_0x529d01['length']+_0x34048d(0x1ff)+(_0x529d01[_0x34048d(0x1cb)]!==0x1?'s':'')),await handleSDKOutput(_0x529d01,_0x427bd5),0x0;}catch(_0x2c79dc){if(_0x2c79dc instanceof SDKError)return console[_0x34048d(0x1f1)](_0x34048d(0x1c3)+_0x2c79dc[_0x34048d(0x1f0)]),_0x2c79dc[_0x34048d(0x20d)]&&console[_0x34048d(0x1f1)]('\x20\x20Cause:\x20'+_0x2c79dc['cause']),0x1;throw _0x2c79dc;}}}export class WorkflowAttemptsCommand extends BaseCommand{['name']=a25_0x3a8bc3(0x221);[a25_0x3a8bc3(0x1fb)]=a25_0x3a8bc3(0x1bf);async['execute'](_0x51afa6){const _0x564987=a25_0x3a8bc3,{options:_0x30b584,args:_0x1aef1c,tdx:_0x2845cb}=_0x51afa6;let _0x114245,_0x22794f;if(_0x1aef1c[0x0]){const _0x44daa3=_0x1aef1c[0x0]['split']('.');if(_0x44daa3['length']===0x1)_0x114245=_0x44daa3[0x0];else{if(_0x44daa3[_0x564987(0x1cb)]===0x2)[_0x114245,_0x22794f]=_0x44daa3;else return console[_0x564987(0x1f1)]('Error:\x20Invalid\x20pattern.\x20Use\x20format:\x20project\x20or\x20project.workflow'),0x1;}}try{const _0xaa908e=_0x30b584[_0x564987(0x1eb)];if(_0x30b584[_0x564987(0x1fd)]){if(_0x114245&&_0x22794f)console[_0x564987(0x1f1)]('Filter:\x20'+_0x114245+'.'+_0x22794f);else _0x114245&&console[_0x564987(0x1f1)](_0x564987(0x1de)+_0x114245);_0xaa908e&&console['error'](_0x564987(0x1ad));}const _0x5467ca=await withSpinner(_0x564987(0x1d3),()=>_0x2845cb[_0x564987(0x1e7)]['attempts']({'projectName':_0x114245,'workflowName':_0x22794f,'includeRetried':_0xaa908e,'limit':_0x30b584[_0x564987(0x19d)]}),{'verbose':_0x30b584[_0x564987(0x1fd)]}),_0x38f154=_0x5467ca[_0x564987(0x1d9)];return console[_0x564987(0x1f1)](_0x564987(0x1e5)+_0x38f154['length']+_0x564987(0x1cc)+(_0x38f154[_0x564987(0x1cb)]!==0x1?'s':'')),await handleSDKOutput(_0x38f154,_0x30b584),0x0;}catch(_0x1ea2ad){if(_0x1ea2ad instanceof SDKError)return console[_0x564987(0x1f1)](_0x564987(0x1c3)+_0x1ea2ad[_0x564987(0x1f0)]),_0x1ea2ad[_0x564987(0x20d)]&&console['error'](_0x564987(0x21d)+_0x1ea2ad[_0x564987(0x20d)]),0x1;throw _0x1ea2ad;}}}export class WorkflowAttemptCommand extends BaseCommand{[a25_0x3a8bc3(0x1c8)]=a25_0x3a8bc3(0x1b6);[a25_0x3a8bc3(0x1fb)]=a25_0x3a8bc3(0x1e4);async[a25_0x3a8bc3(0x220)](_0x562900){const _0x38f1c3=a25_0x3a8bc3,{options:_0x2c52fc,args:_0xa8278a,tdx:_0x4d6820}=_0x562900,_0x2dd7d7=_0xa8278a[0x0];if(!_0x2dd7d7)return console['error'](_0x38f1c3(0x19f)),0x1;try{_0x2c52fc[_0x38f1c3(0x1fd)]&&console[_0x38f1c3(0x1f1)](_0x38f1c3(0x1da)+_0x2dd7d7);const _0x65d203=await withSpinner(_0x38f1c3(0x215),()=>_0x4d6820[_0x38f1c3(0x1e7)][_0x38f1c3(0x21c)](_0x2dd7d7),{'verbose':_0x2c52fc[_0x38f1c3(0x1fd)]}),_0x296b11=_0x65d203[_0x38f1c3(0x1d9)];return await handleSDKOutput([_0x296b11],_0x2c52fc),0x0;}catch(_0x4d824a){if(_0x4d824a instanceof SDKError)return console['error'](_0x38f1c3(0x1c3)+_0x4d824a[_0x38f1c3(0x1f0)]),_0x4d824a[_0x38f1c3(0x20d)]&&console[_0x38f1c3(0x1f1)](_0x38f1c3(0x21d)+_0x4d824a[_0x38f1c3(0x20d)]),0x1;throw _0x4d824a;}}}export class WorkflowTasksCommand extends BaseCommand{[a25_0x3a8bc3(0x1c8)]=a25_0x3a8bc3(0x1d0);['description']='Show\x20tasks\x20for\x20an\x20attempt';async['execute'](_0x6d13ce){const _0x434c24=a25_0x3a8bc3,{options:_0x28a3db,args:_0x4e341f,tdx:_0x1f92e0}=_0x6d13ce,_0x5be764=_0x4e341f[0x0];if(!_0x5be764)return console[_0x434c24(0x1f1)]('Error:\x20Attempt\x20ID\x20is\x20required'),0x1;try{const _0x910a11=_0x28a3db[_0x434c24(0x1a2)];_0x28a3db[_0x434c24(0x1fd)]&&(console[_0x434c24(0x1f1)]('Attempt\x20ID:\x20'+_0x5be764),_0x910a11&&console[_0x434c24(0x1f1)]('Including\x20subtasks:\x20yes'));const _0x53595b=await withSpinner(_0x434c24(0x21a),()=>_0x1f92e0[_0x434c24(0x1e7)]['tasks'](_0x5be764,_0x910a11||![]),{'verbose':_0x28a3db[_0x434c24(0x1fd)]}),_0x3f339f=_0x53595b[_0x434c24(0x1d9)];return console[_0x434c24(0x1f1)]('✔\x20Found\x20'+_0x3f339f[_0x434c24(0x1cb)]+_0x434c24(0x19c)+(_0x3f339f[_0x434c24(0x1cb)]!==0x1?'s':'')),await handleSDKOutput(_0x3f339f,_0x28a3db),0x0;}catch(_0x4db68a){if(_0x4db68a instanceof SDKError)return console[_0x434c24(0x1f1)](_0x434c24(0x1c3)+_0x4db68a['message']),_0x4db68a[_0x434c24(0x20d)]&&console[_0x434c24(0x1f1)]('\x20\x20Cause:\x20'+_0x4db68a[_0x434c24(0x20d)]),0x1;throw _0x4db68a;}}}export class WorkflowLogsCommand extends BaseCommand{[a25_0x3a8bc3(0x1c8)]=a25_0x3a8bc3(0x1a7);[a25_0x3a8bc3(0x1fb)]=a25_0x3a8bc3(0x21b);async[a25_0x3a8bc3(0x220)](_0x3a62f1){const _0x2752e7=a25_0x3a8bc3,{options:_0x2f2c25,args:_0x411eb7,tdx:_0x4f078f}=_0x3a62f1,_0x3c64b0=_0x411eb7[0x0],_0x55d6c3=_0x411eb7[0x1];if(!_0x3c64b0||!_0x55d6c3)return console[_0x2752e7(0x1f1)]('Error:\x20Attempt\x20ID\x20and\x20task\x20name\x20are\x20required'),0x1;try{_0x2f2c25[_0x2752e7(0x1fd)]&&(console[_0x2752e7(0x1f1)](_0x2752e7(0x1da)+_0x3c64b0),console['error'](_0x2752e7(0x1b5)+_0x55d6c3));const _0x26cbd1=_0x2f2c25[_0x2752e7(0x1d1)],_0xe0422b=await withSpinner('Getting\x20task\x20logs...',()=>_0x4f078f[_0x2752e7(0x1e7)][_0x2752e7(0x1b9)](_0x3c64b0,_0x55d6c3,{'offset':_0x26cbd1,'limit':_0x2f2c25[_0x2752e7(0x19d)]}),{'verbose':_0x2f2c25[_0x2752e7(0x1fd)]}),_0x320043=_0xe0422b['data'];return console[_0x2752e7(0x1f1)](_0x2752e7(0x1e5)+_0x320043['length']+_0x2752e7(0x20c)+(_0x320043[_0x2752e7(0x1cb)]!==0x1?_0x2752e7(0x1a1):'y')),await handleSDKOutput(_0x320043,_0x2f2c25),0x0;}catch(_0x1975c0){if(_0x1975c0 instanceof SDKError)return console[_0x2752e7(0x1f1)](_0x2752e7(0x1c3)+_0x1975c0[_0x2752e7(0x1f0)]),_0x1975c0['cause']&&console[_0x2752e7(0x1f1)](_0x2752e7(0x21d)+_0x1975c0[_0x2752e7(0x20d)]),0x1;throw _0x1975c0;}}}export class WorkflowKillCommand extends BaseCommand{[a25_0x3a8bc3(0x1c8)]=a25_0x3a8bc3(0x1ed);[a25_0x3a8bc3(0x1fb)]=a25_0x3a8bc3(0x1e0);async[a25_0x3a8bc3(0x220)](_0x184cc6){const _0x3c4560=a25_0x3a8bc3,{options:_0x203c28,args:_0x4f806e,tdx:_0x20381e}=_0x184cc6,_0x1a085c=_0x4f806e[0x0];if(!_0x1a085c)return console[_0x3c4560(0x1f1)](_0x3c4560(0x19f)),0x1;try{const _0x15f1f7=_0x203c28[_0x3c4560(0x1f9)];_0x203c28['verbose']&&(console[_0x3c4560(0x1f1)]('Attempt\x20ID:\x20'+_0x1a085c),_0x15f1f7&&console[_0x3c4560(0x1f1)](_0x3c4560(0x225)+_0x15f1f7));if(!_0x203c28[_0x3c4560(0x22a)]){const _0xe34eda=await confirm(_0x3c4560(0x1d6)+_0x1a085c+'?');if(!_0xe34eda)return console[_0x3c4560(0x1f1)]('Cancelled'),0x0;}const _0x5b9794=await withSpinner(_0x3c4560(0x1ac),()=>_0x20381e[_0x3c4560(0x1e7)][_0x3c4560(0x208)](_0x1a085c,_0x15f1f7),{'verbose':_0x203c28[_0x3c4560(0x1fd)]}),_0x5eeb28=_0x5b9794[_0x3c4560(0x1d9)];return console['error']('✔\x20'+_0x5eeb28),0x0;}catch(_0x5ad5a8){if(_0x5ad5a8 instanceof SDKError)return console[_0x3c4560(0x1f1)]('Error:\x20'+_0x5ad5a8['message']),_0x5ad5a8[_0x3c4560(0x20d)]&&console[_0x3c4560(0x1f1)](_0x3c4560(0x21d)+_0x5ad5a8['cause']),0x1;throw _0x5ad5a8;}}}function a25_0xdc50(_0x5cb170,_0x751a17){const _0x3e5523=a25_0x3e55();return a25_0xdc50=function(_0xdc50e,_0x9ce8d6){_0xdc50e=_0xdc50e-0x199;let _0x2d916a=_0x3e5523[_0xdc50e];return _0x2d916a;},a25_0xdc50(_0x5cb170,_0x751a17);}export class WorkflowRetryCommand extends BaseCommand{[a25_0x3a8bc3(0x1c8)]=a25_0x3a8bc3(0x1d2);[a25_0x3a8bc3(0x1fb)]=a25_0x3a8bc3(0x214);async[a25_0x3a8bc3(0x220)](_0x4338cd){const _0x3db7cf=a25_0x3a8bc3,{options:_0x10ef0e,args:_0x3b7e1a,tdx:_0x2906a1}=_0x4338cd,_0x524f74=_0x3b7e1a[0x0];if(!_0x524f74)return console['error']('Error:\x20Session\x20ID\x20or\x20attempt\x20ID\x20is\x20required'),console[_0x3db7cf(0x1f1)](_0x3db7cf(0x1a5)),0x1;let _0x561692=![],_0x236ec7=_0x524f74;if(_0x524f74[_0x3db7cf(0x1e8)](_0x3db7cf(0x1f2)))_0x561692=!![],_0x236ec7=_0x524f74[_0x3db7cf(0x19e)](0x8);else{if(_0x524f74[_0x3db7cf(0x1e8)](_0x3db7cf(0x1a6)))_0x561692=![],_0x236ec7=_0x524f74[_0x3db7cf(0x19e)](0x8);else return console[_0x3db7cf(0x1f1)](_0x3db7cf(0x1bd)),console[_0x3db7cf(0x1f1)]('Usage:\x20workflow\x20retry\x20session:<id>\x20or\x20workflow\x20retry\x20attempt:<id>'),0x1;}try{const _0x2a2b6a=_0x10ef0e[_0x3db7cf(0x1c4)],_0x4464e6=_0x10ef0e['resumeFrom'],_0x444e52=_0x10ef0e[_0x3db7cf(0x1e9)],_0xf6d011=_0x10ef0e[_0x3db7cf(0x1f4)];_0x10ef0e[_0x3db7cf(0x1fd)]&&(console[_0x3db7cf(0x1f1)](_0x3db7cf(0x1b1)+(_0x561692?_0x3db7cf(0x1f3):'attempt')+'\x20'+_0x236ec7),_0x2a2b6a&&console[_0x3db7cf(0x1f1)](_0x3db7cf(0x1a3)+_0x2a2b6a),_0x4464e6&&console['error'](_0x3db7cf(0x1c0)+_0x4464e6),_0x444e52&&console['error'](_0x3db7cf(0x207)+_0x444e52),_0xf6d011&&console[_0x3db7cf(0x1f1)](_0x3db7cf(0x1c6)));let _0x12ec46;if(_0x444e52)try{if(_0x444e52[_0x3db7cf(0x1e8)]('@')){const _0x424992=await import(_0x3db7cf(0x1dc)),_0x2a3c86=_0x444e52['substring'](0x1),_0x127178=await _0x424992[_0x3db7cf(0x228)](_0x2a3c86,'utf-8');_0x12ec46=JSON[_0x3db7cf(0x205)](_0x127178);}else _0x12ec46=JSON[_0x3db7cf(0x205)](_0x444e52);}catch{return console[_0x3db7cf(0x1f1)](_0x3db7cf(0x222)),0x1;}if(!_0x10ef0e['yes']){const _0x1edbe4=await confirm('Are\x20you\x20sure\x20you\x20want\x20to\x20retry\x20'+(_0x561692?_0x3db7cf(0x1f3):_0x3db7cf(0x21c))+'\x20'+_0x236ec7+'?');if(!_0x1edbe4)return console[_0x3db7cf(0x1f1)](_0x3db7cf(0x1fe)),0x0;}let _0x5891b6;_0x561692?_0x5891b6=await withSpinner(_0x3db7cf(0x1a0),()=>_0x2906a1[_0x3db7cf(0x1e7)][_0x3db7cf(0x19a)](_0x236ec7,{'fromTask':_0x2a2b6a,'retryParams':_0x12ec46}),{'verbose':_0x10ef0e[_0x3db7cf(0x1fd)]}):_0x5891b6=await withSpinner(_0x3db7cf(0x1ab),()=>_0x2906a1['workflow'][_0x3db7cf(0x1fa)](_0x236ec7,{'resumeFrom':_0x4464e6,'retryParams':_0x12ec46,'force':_0xf6d011}),{'verbose':_0x10ef0e[_0x3db7cf(0x1fd)]});const _0x59a4fa=_0x5891b6['data'];return console[_0x3db7cf(0x1f1)](_0x3db7cf(0x229)),console[_0x3db7cf(0x1f1)](_0x3db7cf(0x21f)+_0x59a4fa[_0x3db7cf(0x1ea)]),console[_0x3db7cf(0x1f1)](_0x3db7cf(0x1ba)+_0x59a4fa[_0x3db7cf(0x1ca)]),0x0;}catch(_0x20c40b){if(_0x20c40b instanceof SDKError)return console[_0x3db7cf(0x1f1)](_0x3db7cf(0x1c3)+_0x20c40b['message']),_0x20c40b[_0x3db7cf(0x20d)]&&console['error'](_0x3db7cf(0x21d)+_0x20c40b[_0x3db7cf(0x20d)]),0x1;throw _0x20c40b;}}}export class WorkflowDownloadCommand extends BaseCommand{['name']=a25_0x3a8bc3(0x211);[a25_0x3a8bc3(0x1fb)]='Download\x20workflow\x20project\x20from\x20Treasure\x20Data';async['execute'](_0x1cc531){const _0x38ea13=a25_0x3a8bc3,{options:_0x2c667e,args:_0x583ab6,tdx:_0x2f40a2}=_0x1cc531,_0x4d136d=_0x583ab6[0x0],_0x57b9a9=_0x583ab6[0x1]||'.';if(!_0x4d136d)return console[_0x38ea13(0x1f1)]('Error:\x20Project\x20name\x20is\x20required'),console[_0x38ea13(0x1f1)](_0x38ea13(0x1cf)),0x1;const _0x42c642=_0x2c667e[_0x38ea13(0x210)];_0x2c667e[_0x38ea13(0x1fd)]&&(console[_0x38ea13(0x1f1)](_0x38ea13(0x20b)+_0x4d136d),console[_0x38ea13(0x1f1)](_0x38ea13(0x19b)+_0x57b9a9),_0x42c642&&console[_0x38ea13(0x1f1)](_0x38ea13(0x209)+_0x42c642));const _0xc34de2=await withSpinner(_0x38ea13(0x223)+_0x4d136d+_0x38ea13(0x21e),()=>_0x2f40a2[_0x38ea13(0x1e7)][_0x38ea13(0x1c2)](_0x4d136d,_0x57b9a9,{'revision':_0x42c642}),{'verbose':_0x2c667e[_0x38ea13(0x1fd)]}),_0x298bdb=_0xc34de2[_0x38ea13(0x1d9)];return console[_0x38ea13(0x1f1)](_0x38ea13(0x1e1)+_0x298bdb[_0x38ea13(0x1d5)]),console[_0x38ea13(0x1f1)](_0x38ea13(0x20f)+_0x298bdb[_0x38ea13(0x210)]),console[_0x38ea13(0x1f1)](_0x38ea13(0x1b3)+_0x298bdb['filesExtracted']),console[_0x38ea13(0x1f1)](_0x38ea13(0x1b2)+_0x57b9a9+'/'+_0x298bdb[_0x38ea13(0x1d5)]),0x0;}}export class WorkflowPushCommand extends BaseCommand{[a25_0x3a8bc3(0x1c8)]=a25_0x3a8bc3(0x204);[a25_0x3a8bc3(0x1fb)]=a25_0x3a8bc3(0x224);async[a25_0x3a8bc3(0x220)](_0x5b8cfa){const _0x1d98c0=a25_0x3a8bc3,{options:_0x236d66,args:_0x37adcb,tdx:_0x4301b0}=_0x5b8cfa;let _0x2c4e3f='.',_0x132b21=_0x236d66[_0x1d98c0(0x1c8)];if(_0x37adcb[0x0]){const {promises:_0x31c088}=await import('fs');try{const _0x4042d7=await _0x31c088[_0x1d98c0(0x227)](_0x37adcb[0x0]);if(_0x4042d7[_0x1d98c0(0x1c7)]())_0x2c4e3f=_0x37adcb[0x0];else return console['error'](_0x1d98c0(0x1c3)+_0x37adcb[0x0]+'\x20is\x20not\x20a\x20directory'),0x1;}catch{_0x132b21=_0x37adcb[0x0],_0x2c4e3f='.';}}const _0x5195d5=_0x236d66[_0x1d98c0(0x210)],_0x5f43d6=_0x236d66[_0x1d98c0(0x1c1)];_0x236d66[_0x1d98c0(0x1fd)]&&(console[_0x1d98c0(0x1f1)](_0x1d98c0(0x1b7)+_0x2c4e3f),_0x132b21&&console['error'](_0x1d98c0(0x1ae)+_0x132b21),_0x5195d5&&console[_0x1d98c0(0x1f1)](_0x1d98c0(0x209)+_0x5195d5),_0x5f43d6&&console[_0x1d98c0(0x1f1)](_0x1d98c0(0x1c9)));const _0x4b4ca5=await withSpinner(_0x1d98c0(0x203),()=>_0x4301b0['workflow'][_0x1d98c0(0x1be)](_0x2c4e3f,{'projectName':_0x132b21,'revision':_0x5195d5,'skipValidation':_0x5f43d6}),{'verbose':_0x236d66[_0x1d98c0(0x1fd)]}),_0x422686=_0x4b4ca5[_0x1d98c0(0x1d9)];return console[_0x1d98c0(0x1f1)](_0x1d98c0(0x1c5)+_0x422686[_0x1d98c0(0x1d5)]),console[_0x1d98c0(0x1f1)](_0x1d98c0(0x1f7)+_0x422686[_0x1d98c0(0x1e3)]),console[_0x1d98c0(0x1f1)](_0x1d98c0(0x20f)+_0x422686[_0x1d98c0(0x210)]),0x0;}}export class WorkflowDeleteCommand extends BaseCommand{[a25_0x3a8bc3(0x1c8)]=a25_0x3a8bc3(0x20e);[a25_0x3a8bc3(0x1fb)]=a25_0x3a8bc3(0x1cd);async[a25_0x3a8bc3(0x220)](_0x14b160){const _0xc09bd5=a25_0x3a8bc3,{options:_0x4f3f2d,args:_0x5dad47,tdx:_0x50c27a}=_0x14b160,_0x4cfd39=_0x5dad47[0x0];if(!_0x4cfd39)return console[_0xc09bd5(0x1f1)](_0xc09bd5(0x1aa)),console[_0xc09bd5(0x1f1)](_0xc09bd5(0x1bc)),0x1;_0x4f3f2d['verbose']&&console['error'](_0xc09bd5(0x20b)+_0x4cfd39);if(!_0x4f3f2d[_0xc09bd5(0x22a)]){const _0x591924=await confirm('Are\x20you\x20sure\x20you\x20want\x20to\x20delete\x20project\x20\x22'+_0x4cfd39+_0xc09bd5(0x1d4));if(!_0x591924)return console[_0xc09bd5(0x1f1)]('Cancelled'),0x0;}const _0x4ef80b=await withSpinner('Deleting\x20project\x20'+_0x4cfd39+_0xc09bd5(0x21e),()=>_0x50c27a[_0xc09bd5(0x1e7)]['delete'](_0x4cfd39),{'verbose':_0x4f3f2d[_0xc09bd5(0x1fd)]}),_0x166570=_0x4ef80b[_0xc09bd5(0x1d9)];return console[_0xc09bd5(0x1f1)](_0xc09bd5(0x1f6)+_0x166570[_0xc09bd5(0x1d5)]),console[_0xc09bd5(0x1f1)](_0xc09bd5(0x1f7)+_0x166570[_0xc09bd5(0x1e3)]),0x0;}}
package/dist/core/auth.js CHANGED
@@ -1 +1 @@
1
- (function(_0x428819,_0x110f99){const _0x5ecca4=a25_0x98c0,_0x2efdf0=_0x428819();while(!![]){try{const _0x3c5d9a=-parseInt(_0x5ecca4(0x116))/0x1+-parseInt(_0x5ecca4(0x113))/0x2+-parseInt(_0x5ecca4(0x11b))/0x3*(parseInt(_0x5ecca4(0x10d))/0x4)+-parseInt(_0x5ecca4(0x110))/0x5+parseInt(_0x5ecca4(0x118))/0x6*(parseInt(_0x5ecca4(0x10e))/0x7)+-parseInt(_0x5ecca4(0x11a))/0x8+parseInt(_0x5ecca4(0x124))/0x9;if(_0x3c5d9a===_0x110f99)break;else _0x2efdf0['push'](_0x2efdf0['shift']());}catch(_0x594024){_0x2efdf0['push'](_0x2efdf0['shift']());}}}(a25_0x338d,0x9133d));import{platform}from'os';import{readFileSync}from'fs';import{fileURLToPath}from'url';import{dirname,join}from'path';function a25_0x98c0(_0x360eeb,_0x17a8bd){const _0x338d46=a25_0x338d();return a25_0x98c0=function(_0x98c0a5,_0x56405d){_0x98c0a5=_0x98c0a5-0x10d;let _0x1dc53a=_0x338d46[_0x98c0a5];return _0x1dc53a;},a25_0x98c0(_0x360eeb,_0x17a8bd);}import{getAPIKey}from'./config.js';export function getVersion(){const _0x51b171=a25_0x98c0;try{const _0x4d23b9=fileURLToPath(import.meta[_0x51b171(0x11f)]),_0x3b55bd=dirname(_0x4d23b9),_0x12825c=join(_0x3b55bd,'../../package.json'),_0x222860=JSON[_0x51b171(0x122)](readFileSync(_0x12825c,_0x51b171(0x117)));return _0x222860[_0x51b171(0x11e)];}catch{return _0x51b171(0x114);}}export function getUserAgent(){const _0x186453=a25_0x98c0,_0x54cd5f=getVersion(),_0x341436=platform(),_0x5133b4=process[_0x186453(0x11e)][_0x186453(0x10f)]('v','');return _0x186453(0x115)+_0x54cd5f+'\x20('+_0x341436+_0x186453(0x111)+_0x5133b4+')';}export function getAuthHeaders(_0x460da9,_0x3f4634){const _0x18221a=a25_0x98c0,_0x38b43b=getVersion(),_0x4aa968={'User-Agent':getUserAgent(),'X-TD-Client':_0x18221a(0x119),'X-TD-Client-Version':_0x38b43b};return _0x3f4634&&(_0x4aa968[_0x18221a(0x123)]=_0x18221a(0x121)+_0x3f4634),_0x4aa968;}export function toHeaderRecord(_0x3e5810){const _0x44f358=a25_0x98c0,_0xf60fd0={};for(const [_0x15a21c,_0x10aeb4]of Object[_0x44f358(0x120)](_0x3e5810)){_0x10aeb4!==undefined&&(_0xf60fd0[_0x15a21c]=_0x10aeb4);}return _0xf60fd0;}export function getTrinoHeaders(_0x5e4835,_0x5dea84){const _0x382fd7=a25_0x98c0,_0x35848b=getAuthHeaders(_0x5e4835,_0x5dea84),_0x17a504=toHeaderRecord(_0x35848b);return delete _0x17a504[_0x382fd7(0x123)],_0x5dea84&&(_0x17a504[_0x382fd7(0x11d)]=_0x5dea84),_0x17a504;}export function validateAPIKey(_0x50215d){const _0x502a17=a25_0x98c0;return _0x50215d[_0x502a17(0x11c)]('/')&&_0x50215d[_0x502a17(0x112)]('/')['length']===0x2;}export function hasAPIKey(_0x4677a2){const _0x5923d9=getAPIKey(_0x4677a2);return _0x5923d9!==undefined&&validateAPIKey(_0x5923d9);}function a25_0x338d(){const _0x2f4e9b=['7kbQdPa','replace','2283985zvmkBO',';\x20node/','split','1913344CkjXQj','0.0.0','tdx/','669467mInUSZ','utf-8','1996614KjRVug','tdx','4209968KjIByy','214437VxLcfT','includes','X-Trino-User','version','url','entries','TD1\x20','parse','Authorization','30986946yWhBUh','32SNEcpU'];a25_0x338d=function(){return _0x2f4e9b;};return a25_0x338d();}
1
+ (function(_0x3be339,_0x5c8f81){const _0x16447d=a26_0x3d85,_0x5d523c=_0x3be339();while(!![]){try{const _0x1a0cea=-parseInt(_0x16447d(0x1a8))/0x1*(parseInt(_0x16447d(0x19a))/0x2)+parseInt(_0x16447d(0x1a2))/0x3+-parseInt(_0x16447d(0x19b))/0x4+-parseInt(_0x16447d(0x1a0))/0x5*(-parseInt(_0x16447d(0x19c))/0x6)+-parseInt(_0x16447d(0x1af))/0x7*(-parseInt(_0x16447d(0x19f))/0x8)+parseInt(_0x16447d(0x1a9))/0x9*(-parseInt(_0x16447d(0x196))/0xa)+parseInt(_0x16447d(0x1ad))/0xb*(parseInt(_0x16447d(0x1a7))/0xc);if(_0x1a0cea===_0x5c8f81)break;else _0x5d523c['push'](_0x5d523c['shift']());}catch(_0x4e3b5f){_0x5d523c['push'](_0x5d523c['shift']());}}}(a26_0x47d0,0x450f1));import{platform}from'os';import{readFileSync}from'fs';function a26_0x3d85(_0xd6b097,_0x22b032){const _0x47d09f=a26_0x47d0();return a26_0x3d85=function(_0x3d8544,_0x40ef8d){_0x3d8544=_0x3d8544-0x194;let _0x571c04=_0x47d09f[_0x3d8544];return _0x571c04;},a26_0x3d85(_0xd6b097,_0x22b032);}import{fileURLToPath}from'url';import{dirname,join}from'path';import{getAPIKey}from'./config.js';function a26_0x47d0(){const _0xd560fe=['1794784kEfTPX','8706yNMpYD','utf-8',';\x20node/','31992occMag','140qqTlNn','version','1651170fNVaqO','split','url','X-Trino-User','Authorization','5976RZgxRy','11vhyglq','369pBVdcZ','includes','replace','parse','15609ZVQxvu','TD1\x20','63TSVcwZ','../../package.json','tdx/','37390iPqHMn','entries','tdx','length','81602YHGnld'];a26_0x47d0=function(){return _0xd560fe;};return a26_0x47d0();}export function getVersion(){const _0x421da7=a26_0x3d85;try{const _0x36c67b=fileURLToPath(import.meta[_0x421da7(0x1a4)]),_0x1fb0c9=dirname(_0x36c67b),_0x5bb1cf=join(_0x1fb0c9,_0x421da7(0x194)),_0x2da0af=JSON[_0x421da7(0x1ac)](readFileSync(_0x5bb1cf,_0x421da7(0x19d)));return _0x2da0af[_0x421da7(0x1a1)];}catch{return'0.0.0';}}export function getUserAgent(){const _0x2d278f=a26_0x3d85,_0x490d5f=getVersion(),_0x41e65c=platform(),_0x1e8a5c=process[_0x2d278f(0x1a1)][_0x2d278f(0x1ab)]('v','');return _0x2d278f(0x195)+_0x490d5f+'\x20('+_0x41e65c+_0x2d278f(0x19e)+_0x1e8a5c+')';}export function getAuthHeaders(_0x48f115,_0x13c566){const _0xfe634d=a26_0x3d85,_0x141ff8=getVersion(),_0x3d09ee={'User-Agent':getUserAgent(),'X-TD-Client':_0xfe634d(0x198),'X-TD-Client-Version':_0x141ff8};return _0x13c566&&(_0x3d09ee[_0xfe634d(0x1a6)]=_0xfe634d(0x1ae)+_0x13c566),_0x3d09ee;}export function toHeaderRecord(_0x11bc85){const _0x5935cf=a26_0x3d85,_0x4d3033={};for(const [_0xe875e1,_0x5e35a5]of Object[_0x5935cf(0x197)](_0x11bc85)){_0x5e35a5!==undefined&&(_0x4d3033[_0xe875e1]=_0x5e35a5);}return _0x4d3033;}export function getTrinoHeaders(_0x118767,_0xac1d88){const _0x33921a=a26_0x3d85,_0x24870a=getAuthHeaders(_0x118767,_0xac1d88),_0x27d0f9=toHeaderRecord(_0x24870a);return delete _0x27d0f9['Authorization'],_0xac1d88&&(_0x27d0f9[_0x33921a(0x1a5)]=_0xac1d88),_0x27d0f9;}export function validateAPIKey(_0x3c9d1c){const _0x181005=a26_0x3d85;return _0x3c9d1c[_0x181005(0x1aa)]('/')&&_0x3c9d1c[_0x181005(0x1a3)]('/')[_0x181005(0x199)]===0x2;}export function hasAPIKey(_0x119a13){const _0x4e4b5b=getAPIKey(_0x119a13);return _0x4e4b5b!==undefined&&validateAPIKey(_0x4e4b5b);}
@@ -1 +1 @@
1
- (function(_0x1e6771,_0x46245c){const _0x3f6d69=a26_0x1073,_0x759829=_0x1e6771();while(!![]){try{const _0x4730b7=parseInt(_0x3f6d69(0x1b6))/0x1*(-parseInt(_0x3f6d69(0x1d9))/0x2)+parseInt(_0x3f6d69(0x1e4))/0x3+parseInt(_0x3f6d69(0x1c3))/0x4+parseInt(_0x3f6d69(0x1df))/0x5+-parseInt(_0x3f6d69(0x1d2))/0x6*(parseInt(_0x3f6d69(0x1ca))/0x7)+-parseInt(_0x3f6d69(0x1c9))/0x8*(-parseInt(_0x3f6d69(0x1de))/0x9)+parseInt(_0x3f6d69(0x1e6))/0xa*(parseInt(_0x3f6d69(0x1d0))/0xb);if(_0x4730b7===_0x46245c)break;else _0x759829['push'](_0x759829['shift']());}catch(_0x5804de){_0x759829['push'](_0x759829['shift']());}}}(a26_0x3480,0x48860));import{homedir}from'os';function a26_0x3480(){const _0x9d81f5=['TD_API_KEY_','parse','105052SOndEe','TD_API_KEY','.env.','ap03','replace','us01','1418840CuPmdN','7945JVHOav','profile:\x20','jp01','eu01','tdx','stg-us01','33oRsXdB','map','2712YwMzFj','env:\x20TD_API_KEY','Warning:\x20Failed\x20to\x20read\x20config\x20file\x20','.env','global:\x20','.config','Warning:\x20Unknown\x20site\x20\x27','464336OtvUHu','TDX_CACHE_DIR','TDX_CONFIG_DIR','env','match','18TimhRK','1039235rHIlek','env:\x20','toUpperCase','stg-jp01','join','1201368vqziIB','stg-ap03','176560JawmIg','error','.cache','apiKeys','existsSync','llm_default_project','\x27,\x20defaulting\x20to\x20us01','startsWith','dev-us01','1uYbBPn','dev-eu01','profile','readFileSync','ap02','endsWith','utf-8','profiles','warn','trim','\x20(TD_API_KEY)'];a26_0x3480=function(){return _0x9d81f5;};return a26_0x3480();}import{join}from'path';function a26_0x1073(_0x3c38cd,_0x57a213){const _0x348067=a26_0x3480();return a26_0x1073=function(_0x10730e,_0x278aeb){_0x10730e=_0x10730e-0x1af;let _0x222cc8=_0x348067[_0x10730e];return _0x222cc8;},a26_0x1073(_0x3c38cd,_0x57a213);}import{existsSync,readFileSync,writeFileSync,mkdirSync}from'fs';import*as a26_0x4a96fb from'node:fs';import*as a26_0x6eb913 from'node:path';import{SITE_ALIASES}from'../types/index.js';import{validateSecureFilePermissions}from'../utils/file-permissions.js';export function getConfigDir(){const _0x3dfd13=a26_0x1073;return process[_0x3dfd13(0x1dc)][_0x3dfd13(0x1db)]||join(homedir(),_0x3dfd13(0x1d7),_0x3dfd13(0x1ce));}export function getConfigFile(){const _0x1ae4fb=a26_0x1073;return join(getConfigDir(),_0x1ae4fb(0x1d5));}export function getCacheDir(){const _0x2326ba=a26_0x1073;return process[_0x2326ba(0x1dc)][_0x2326ba(0x1da)]||join(homedir(),_0x2326ba(0x1af),_0x2326ba(0x1ce));}export function getLLMProjectCacheFile(){const _0x4c369a=a26_0x1073;return join(getCacheDir(),_0x4c369a(0x1b2));}export function readCachedLLMProject(){const _0x376d1d=a26_0x1073;try{const _0x1b8709=getLLMProjectCacheFile();if(!existsSync(_0x1b8709))return null;return readFileSync(_0x1b8709,_0x376d1d(0x1bc))[_0x376d1d(0x1bf)]();}catch{return null;}}export function writeCachedLLMProject(_0x4da0b3){const _0x3ea5df=a26_0x1073;try{const _0x5dc76d=getCacheDir(),_0x3aeb8b=getLLMProjectCacheFile();!existsSync(_0x5dc76d)&&mkdirSync(_0x5dc76d,{'recursive':!![]}),writeFileSync(_0x3aeb8b,_0x4da0b3,'utf-8');}catch(_0x2fb5d6){console[_0x3ea5df(0x1e7)]('Warning:\x20Failed\x20to\x20cache\x20LLM\x20project\x20name:',_0x2fb5d6);}}export function parseEnvFile(_0x28e194){const _0x3ae25c=a26_0x1073,_0x2577a1={};for(const _0xf54b38 of _0x28e194['split']('\x0a')){const _0x335a71=_0xf54b38['trim']();if(!_0x335a71||_0x335a71[_0x3ae25c(0x1b4)]('#'))continue;const _0x4f7241=_0x335a71[_0x3ae25c(0x1dd)](/^([^=]+)=(.*)$/);if(_0x4f7241){const _0x3e09ac=_0x4f7241[0x1][_0x3ae25c(0x1bf)]();let _0x5a50c2=_0x4f7241[0x2][_0x3ae25c(0x1bf)]();(_0x5a50c2[_0x3ae25c(0x1b4)]('\x22')&&_0x5a50c2[_0x3ae25c(0x1bb)]('\x22')||_0x5a50c2['startsWith']('\x27')&&_0x5a50c2[_0x3ae25c(0x1bb)]('\x27'))&&(_0x5a50c2=_0x5a50c2['slice'](0x1,-0x1)),_0x2577a1[_0x3e09ac]=_0x5a50c2;}}return _0x2577a1;}export function readUserConfig(){const _0x3bb311=a26_0x1073,_0x107119=getConfigFile();if(!existsSync(_0x107119))return{};try{const _0x11ebce=readFileSync(_0x107119,'utf-8');return parseEnvFile(_0x11ebce);}catch(_0x42898b){return console[_0x3bb311(0x1be)](_0x3bb311(0x1d4)+_0x107119+':',_0x42898b),{};}}export function resolveSite(_0x28d49d){const _0x2336e3=a26_0x1073,_0x5c10df=[_0x2336e3(0x1c8),_0x2336e3(0x1cc),'eu01',_0x2336e3(0x1ba),_0x2336e3(0x1c6),_0x2336e3(0x1b5),_0x2336e3(0x1b7),'stg-us01',_0x2336e3(0x1e2),_0x2336e3(0x1e5)];if(_0x5c10df['includes'](_0x28d49d))return _0x28d49d;if(_0x28d49d in SITE_ALIASES)return SITE_ALIASES[_0x28d49d];return console['warn'](_0x2336e3(0x1d8)+_0x28d49d+_0x2336e3(0x1b3)),_0x2336e3(0x1c8);}let cachedUserConfig=null;export function loadUserConfigOnce(){return cachedUserConfig===null&&(cachedUserConfig=readUserConfig()),cachedUserConfig;}export function clearConfigCache(){cachedUserConfig=null;}export function getAPIKey(_0xa4d073,_0x185f76){const _0x45c526=a26_0x1073,_0x5918fe=_0xa4d073[_0x45c526(0x1e1)]()[_0x45c526(0x1c7)](/-/g,'_'),_0x16e13e=_0x45c526(0x1c1)+_0x5918fe;if(process[_0x45c526(0x1dc)][_0x16e13e])return process[_0x45c526(0x1dc)][_0x16e13e];if(process[_0x45c526(0x1dc)][_0x45c526(0x1c4)])return process['env'][_0x45c526(0x1c4)];const _0x52283d=_0x185f76||getActiveProfileName();if(_0x52283d){const _0x451cb5=loadProfileEnv(_0x52283d);if(_0x451cb5){if(_0x451cb5[_0x16e13e])return _0x451cb5[_0x16e13e];if(_0x451cb5['TD_API_KEY'])return _0x451cb5[_0x45c526(0x1c4)];}}const _0x469004=loadUserConfigOnce();if(_0x469004[_0x16e13e])return _0x469004[_0x16e13e];if(_0x469004[_0x45c526(0x1c4)])return _0x469004[_0x45c526(0x1c4)];return undefined;}export function getAPIKeySource(_0x588d1b,_0x3ef725){const _0x4b13af=a26_0x1073,_0x1e1eb0=_0x4b13af(0x1c1)+_0x588d1b[_0x4b13af(0x1e1)]()[_0x4b13af(0x1c7)](/-/g,'_');if(process[_0x4b13af(0x1dc)][_0x1e1eb0])return _0x4b13af(0x1e0)+_0x1e1eb0;if(process[_0x4b13af(0x1dc)]['TD_API_KEY'])return _0x4b13af(0x1d3);const _0x4eb4c3=_0x3ef725||getActiveProfileName();if(_0x4eb4c3){const _0x386ad1=loadProfileEnv(_0x4eb4c3);if(_0x386ad1){if(_0x386ad1[_0x1e1eb0])return _0x4b13af(0x1cb)+_0x4eb4c3+'\x20('+_0x1e1eb0+')';if(_0x386ad1[_0x4b13af(0x1c4)])return _0x4b13af(0x1cb)+_0x4eb4c3+_0x4b13af(0x1c0);}}const _0x35f5fc=loadUserConfigOnce(),_0x353e42=getConfigFile();if(_0x35f5fc[_0x1e1eb0])return _0x4b13af(0x1d6)+_0x353e42+'\x20('+_0x1e1eb0+')';if(_0x35f5fc['TD_API_KEY'])return _0x4b13af(0x1d6)+_0x353e42+_0x4b13af(0x1c0);return null;}function loadProfileEnv(_0x4bade5){const _0x56a38a=a26_0x1073,_0x220470=a26_0x6eb913['join'](getConfigDir(),_0x56a38a(0x1c5)+_0x4bade5);if(a26_0x4a96fb['existsSync'](_0x220470)){validateSecureFilePermissions(_0x220470);try{const _0xcf850a=a26_0x4a96fb[_0x56a38a(0x1b9)](_0x220470,_0x56a38a(0x1bc));return parseEnvFile(_0xcf850a);}catch(_0x577d82){console[_0x56a38a(0x1be)]('Warning:\x20Failed\x20to\x20load\x20'+_0x220470+':\x20'+_0x577d82);}}const _0x39eb86=a26_0x6eb913[_0x56a38a(0x1e3)](getConfigDir(),_0x56a38a(0x1bd),_0x4bade5,_0x56a38a(0x1d5));if(a26_0x4a96fb[_0x56a38a(0x1b1)](_0x39eb86)){validateSecureFilePermissions(_0x39eb86);try{const _0x1b7cbc=a26_0x4a96fb['readFileSync'](_0x39eb86,_0x56a38a(0x1bc));return parseEnvFile(_0x1b7cbc);}catch(_0x2b0eaf){return console['warn']('Warning:\x20Failed\x20to\x20load\x20'+_0x39eb86+':\x20'+_0x2b0eaf),null;}}return null;}function getActiveProfileName(){const _0x312191=a26_0x1073,_0x20c8a9=a26_0x6eb913[_0x312191(0x1e3)](getConfigDir(),'tdx.json');if(!a26_0x4a96fb[_0x312191(0x1b1)](_0x20c8a9))return null;try{const _0x1b6c46=a26_0x4a96fb[_0x312191(0x1b9)](_0x20c8a9,_0x312191(0x1bc)),_0x10c26c=JSON[_0x312191(0x1c2)](_0x1b6c46);return _0x10c26c[_0x312191(0x1b8)]||null;}catch{return null;}}export function saveAPIKey(_0x336380,_0x11c63e){const _0x1f5517=a26_0x1073,_0x45d2f4=getConfigDir(),_0x223c72=getConfigFile();!existsSync(_0x45d2f4)&&mkdirSync(_0x45d2f4,{'recursive':!![],'mode':0x1c0});const _0x4129c6=readUserConfig(),_0x54730f=_0x336380[_0x1f5517(0x1e1)]()['replace'](/-/g,'_');_0x4129c6['TD_API_KEY_'+_0x54730f]=_0x11c63e;const _0x338d68=Object['entries'](_0x4129c6)[_0x1f5517(0x1d1)](([_0x8a2427,_0x37c569])=>_0x8a2427+'='+_0x37c569);writeFileSync(_0x223c72,_0x338d68[_0x1f5517(0x1e3)]('\x0a')+'\x0a',{'mode':0x180});}export function loadConfig(){const _0x281b58=a26_0x1073,_0x17c8ea={'apiKeys':{},'defaultSite':_0x281b58(0x1c8)},_0x3e7316=[_0x281b58(0x1c8),_0x281b58(0x1cc),_0x281b58(0x1cd),_0x281b58(0x1ba),'ap03',_0x281b58(0x1b5),_0x281b58(0x1b7),_0x281b58(0x1cf),_0x281b58(0x1e2),_0x281b58(0x1e5)];for(const _0x52d49a of _0x3e7316){const _0x144d4d=getAPIKey(_0x52d49a);_0x144d4d&&(_0x17c8ea[_0x281b58(0x1b0)][_0x52d49a]=_0x144d4d);}return _0x17c8ea;}
1
+ (function(_0x4d1f7b,_0x54fbe3){const _0x4bee1f=a27_0xb7e6,_0x2bad93=_0x4d1f7b();while(!![]){try{const _0x560e62=parseInt(_0x4bee1f(0x190))/0x1*(parseInt(_0x4bee1f(0x189))/0x2)+parseInt(_0x4bee1f(0x170))/0x3*(-parseInt(_0x4bee1f(0x186))/0x4)+-parseInt(_0x4bee1f(0x19b))/0x5*(-parseInt(_0x4bee1f(0x197))/0x6)+parseInt(_0x4bee1f(0x171))/0x7*(-parseInt(_0x4bee1f(0x1a4))/0x8)+parseInt(_0x4bee1f(0x1a7))/0x9*(-parseInt(_0x4bee1f(0x183))/0xa)+parseInt(_0x4bee1f(0x174))/0xb+parseInt(_0x4bee1f(0x194))/0xc*(parseInt(_0x4bee1f(0x1a2))/0xd);if(_0x560e62===_0x54fbe3)break;else _0x2bad93['push'](_0x2bad93['shift']());}catch(_0x2d2fa4){_0x2bad93['push'](_0x2bad93['shift']());}}}(a27_0x262b,0x20fbe));import{homedir}from'os';import{join}from'path';import{existsSync,readFileSync,writeFileSync,mkdirSync}from'fs';function a27_0xb7e6(_0x23c0ff,_0x241990){const _0x262b53=a27_0x262b();return a27_0xb7e6=function(_0xb7e63f,_0x4d900c){_0xb7e63f=_0xb7e63f-0x16f;let _0x298aa1=_0x262b53[_0xb7e63f];return _0x298aa1;},a27_0xb7e6(_0x23c0ff,_0x241990);}import*as a27_0x56cb42 from'node:fs';import*as a27_0x1d3787 from'node:path';import{SITE_ALIASES}from'../types/index.js';import{validateSecureFilePermissions}from'../utils/file-permissions.js';export function getConfigDir(){const _0x468179=a27_0xb7e6;return process['env'][_0x468179(0x193)]||join(homedir(),_0x468179(0x177),_0x468179(0x187));}export function getConfigFile(){const _0x50e378=a27_0xb7e6;return join(getConfigDir(),_0x50e378(0x199));}export function getCacheDir(){const _0x81ec6b=a27_0xb7e6;return process[_0x81ec6b(0x16f)][_0x81ec6b(0x1a9)]||join(homedir(),_0x81ec6b(0x172),_0x81ec6b(0x187));}export function getLLMProjectCacheFile(){const _0x577938=a27_0xb7e6;return join(getCacheDir(),_0x577938(0x18f));}function a27_0x262b(){const _0x4c3de4=['jp01','toUpperCase','93116dGAznw','tdx','TD_API_KEY','281018jZHWKz','warn','trim','dev-us01','\x27,\x20defaulting\x20to\x20us01','stg-ap03','llm_default_project','1DEFavP','ap02','profile','TDX_CONFIG_DIR','167028cUMwvX','Warning:\x20Failed\x20to\x20load\x20','replace','2142FDTTmP','existsSync','.env','split','2535jfEzNv','join','Warning:\x20Failed\x20to\x20cache\x20LLM\x20project\x20name:','tdx.json','\x20(TD_API_KEY)','profiles','env:\x20','39LPNAVa','entries','8rcCqQQ','parse','Warning:\x20Failed\x20to\x20read\x20config\x20file\x20','207135xldmBP','includes','TDX_CACHE_DIR','profile:\x20','env','21LLOMwF','1107617oYDgnt','.cache','TD_API_KEY_','2289056uUMcDd','dev-eu01','stg-us01','.config','utf-8','error','env:\x20TD_API_KEY','map','eu01','startsWith','us01','endsWith','ap03','match','stg-jp01','50YLmNyR'];a27_0x262b=function(){return _0x4c3de4;};return a27_0x262b();}export function readCachedLLMProject(){const _0x480e86=a27_0xb7e6;try{const _0x25815a=getLLMProjectCacheFile();if(!existsSync(_0x25815a))return null;return readFileSync(_0x25815a,_0x480e86(0x178))[_0x480e86(0x18b)]();}catch{return null;}}export function writeCachedLLMProject(_0x189db0){const _0x4531cd=a27_0xb7e6;try{const _0x2b949a=getCacheDir(),_0x231b25=getLLMProjectCacheFile();!existsSync(_0x2b949a)&&mkdirSync(_0x2b949a,{'recursive':!![]}),writeFileSync(_0x231b25,_0x189db0,_0x4531cd(0x178));}catch(_0x1e5ff9){console[_0x4531cd(0x179)](_0x4531cd(0x19d),_0x1e5ff9);}}export function parseEnvFile(_0x4063ca){const _0xec526a=a27_0xb7e6,_0x20e292={};for(const _0x2eb14f of _0x4063ca[_0xec526a(0x19a)]('\x0a')){const _0x20cee1=_0x2eb14f[_0xec526a(0x18b)]();if(!_0x20cee1||_0x20cee1[_0xec526a(0x17d)]('#'))continue;const _0x536829=_0x20cee1[_0xec526a(0x181)](/^([^=]+)=(.*)$/);if(_0x536829){const _0x2584bd=_0x536829[0x1]['trim']();let _0xf6c667=_0x536829[0x2][_0xec526a(0x18b)]();(_0xf6c667[_0xec526a(0x17d)]('\x22')&&_0xf6c667['endsWith']('\x22')||_0xf6c667['startsWith']('\x27')&&_0xf6c667[_0xec526a(0x17f)]('\x27'))&&(_0xf6c667=_0xf6c667['slice'](0x1,-0x1)),_0x20e292[_0x2584bd]=_0xf6c667;}}return _0x20e292;}export function readUserConfig(){const _0x27796d=a27_0xb7e6,_0x1f5e59=getConfigFile();if(!existsSync(_0x1f5e59))return{};try{const _0x8dc6ac=readFileSync(_0x1f5e59,_0x27796d(0x178));return parseEnvFile(_0x8dc6ac);}catch(_0x174402){return console['warn'](_0x27796d(0x1a6)+_0x1f5e59+':',_0x174402),{};}}export function resolveSite(_0x1c44c0){const _0x231d8c=a27_0xb7e6,_0x7239f=[_0x231d8c(0x17e),_0x231d8c(0x184),_0x231d8c(0x17c),_0x231d8c(0x191),_0x231d8c(0x180),_0x231d8c(0x18c),_0x231d8c(0x175),_0x231d8c(0x176),_0x231d8c(0x182),_0x231d8c(0x18e)];if(_0x7239f[_0x231d8c(0x1a8)](_0x1c44c0))return _0x1c44c0;if(_0x1c44c0 in SITE_ALIASES)return SITE_ALIASES[_0x1c44c0];return console[_0x231d8c(0x18a)]('Warning:\x20Unknown\x20site\x20\x27'+_0x1c44c0+_0x231d8c(0x18d)),_0x231d8c(0x17e);}let cachedUserConfig=null;export function loadUserConfigOnce(){return cachedUserConfig===null&&(cachedUserConfig=readUserConfig()),cachedUserConfig;}export function clearConfigCache(){cachedUserConfig=null;}export function getAPIKey(_0x326f2e,_0x4e6246){const _0x4a1f0f=a27_0xb7e6,_0x43bdc7=_0x326f2e['toUpperCase']()[_0x4a1f0f(0x196)](/-/g,'_'),_0x3b0ab3=_0x4a1f0f(0x173)+_0x43bdc7;if(process[_0x4a1f0f(0x16f)][_0x3b0ab3])return process['env'][_0x3b0ab3];if(process['env'][_0x4a1f0f(0x188)])return process[_0x4a1f0f(0x16f)][_0x4a1f0f(0x188)];const _0x2e7dcf=_0x4e6246||getActiveProfileName();if(_0x2e7dcf){const _0xfba0fd=loadProfileEnv(_0x2e7dcf);if(_0xfba0fd){if(_0xfba0fd[_0x3b0ab3])return _0xfba0fd[_0x3b0ab3];if(_0xfba0fd['TD_API_KEY'])return _0xfba0fd[_0x4a1f0f(0x188)];}}const _0x219684=loadUserConfigOnce();if(_0x219684[_0x3b0ab3])return _0x219684[_0x3b0ab3];if(_0x219684[_0x4a1f0f(0x188)])return _0x219684[_0x4a1f0f(0x188)];return undefined;}export function getAPIKeySource(_0x35dcdf,_0x411f4e){const _0x4222e6=a27_0xb7e6,_0x19efbb=_0x4222e6(0x173)+_0x35dcdf[_0x4222e6(0x185)]()['replace'](/-/g,'_');if(process[_0x4222e6(0x16f)][_0x19efbb])return _0x4222e6(0x1a1)+_0x19efbb;if(process[_0x4222e6(0x16f)]['TD_API_KEY'])return _0x4222e6(0x17a);const _0x57289a=_0x411f4e||getActiveProfileName();if(_0x57289a){const _0x4411f2=loadProfileEnv(_0x57289a);if(_0x4411f2){if(_0x4411f2[_0x19efbb])return _0x4222e6(0x1aa)+_0x57289a+'\x20('+_0x19efbb+')';if(_0x4411f2[_0x4222e6(0x188)])return _0x4222e6(0x1aa)+_0x57289a+_0x4222e6(0x19f);}}const _0x882e1f=loadUserConfigOnce(),_0x44f9be=getConfigFile();if(_0x882e1f[_0x19efbb])return'global:\x20'+_0x44f9be+'\x20('+_0x19efbb+')';if(_0x882e1f[_0x4222e6(0x188)])return'global:\x20'+_0x44f9be+_0x4222e6(0x19f);return null;}function loadProfileEnv(_0x21f103){const _0x3302cf=a27_0xb7e6,_0x28edb6=a27_0x1d3787[_0x3302cf(0x19c)](getConfigDir(),'.env.'+_0x21f103);if(a27_0x56cb42[_0x3302cf(0x198)](_0x28edb6)){validateSecureFilePermissions(_0x28edb6);try{const _0x2026c1=a27_0x56cb42['readFileSync'](_0x28edb6,_0x3302cf(0x178));return parseEnvFile(_0x2026c1);}catch(_0x5189db){console[_0x3302cf(0x18a)](_0x3302cf(0x195)+_0x28edb6+':\x20'+_0x5189db);}}const _0x236c6a=a27_0x1d3787[_0x3302cf(0x19c)](getConfigDir(),_0x3302cf(0x1a0),_0x21f103,'.env');if(a27_0x56cb42[_0x3302cf(0x198)](_0x236c6a)){validateSecureFilePermissions(_0x236c6a);try{const _0x37d6c3=a27_0x56cb42['readFileSync'](_0x236c6a,'utf-8');return parseEnvFile(_0x37d6c3);}catch(_0x34a447){return console[_0x3302cf(0x18a)]('Warning:\x20Failed\x20to\x20load\x20'+_0x236c6a+':\x20'+_0x34a447),null;}}return null;}function getActiveProfileName(){const _0x2de0f2=a27_0xb7e6,_0x3a3c81=a27_0x1d3787[_0x2de0f2(0x19c)](getConfigDir(),_0x2de0f2(0x19e));if(!a27_0x56cb42[_0x2de0f2(0x198)](_0x3a3c81))return null;try{const _0x4bbf4d=a27_0x56cb42['readFileSync'](_0x3a3c81,_0x2de0f2(0x178)),_0x20b81b=JSON[_0x2de0f2(0x1a5)](_0x4bbf4d);return _0x20b81b[_0x2de0f2(0x192)]||null;}catch{return null;}}export function saveAPIKey(_0x37da79,_0x475942){const _0x1950c4=a27_0xb7e6,_0xc75efb=getConfigDir(),_0x56b56b=getConfigFile();!existsSync(_0xc75efb)&&mkdirSync(_0xc75efb,{'recursive':!![],'mode':0x1c0});const _0x4edfcb=readUserConfig(),_0x33d56b=_0x37da79[_0x1950c4(0x185)]()[_0x1950c4(0x196)](/-/g,'_');_0x4edfcb['TD_API_KEY_'+_0x33d56b]=_0x475942;const _0x2a74e5=Object[_0x1950c4(0x1a3)](_0x4edfcb)[_0x1950c4(0x17b)](([_0x49bc43,_0x1421e9])=>_0x49bc43+'='+_0x1421e9);writeFileSync(_0x56b56b,_0x2a74e5['join']('\x0a')+'\x0a',{'mode':0x180});}export function loadConfig(){const _0x3f5f82=a27_0xb7e6,_0x540952={'apiKeys':{},'defaultSite':_0x3f5f82(0x17e)},_0x280435=[_0x3f5f82(0x17e),_0x3f5f82(0x184),'eu01',_0x3f5f82(0x191),'ap03',_0x3f5f82(0x18c),_0x3f5f82(0x175),_0x3f5f82(0x176),'stg-jp01','stg-ap03'];for(const _0x353512 of _0x280435){const _0xdd789c=getAPIKey(_0x353512);_0xdd789c&&(_0x540952['apiKeys'][_0x353512]=_0xdd789c);}return _0x540952;}
@@ -1 +1 @@
1
- const a27_0x3d7e13=a27_0x4ff8;function a27_0x4ff8(_0x42dcca,_0x59bb36){const _0x197d9f=a27_0x197d();return a27_0x4ff8=function(_0x4ff8a6,_0x5b3f7f){_0x4ff8a6=_0x4ff8a6-0x1c1;let _0x5b5f06=_0x197d9f[_0x4ff8a6];return _0x5b5f06;},a27_0x4ff8(_0x42dcca,_0x59bb36);}(function(_0x1e79f1,_0x151667){const _0x34673b=a27_0x4ff8,_0x3aef81=_0x1e79f1();while(!![]){try{const _0x998962=-parseInt(_0x34673b(0x1f1))/0x1+-parseInt(_0x34673b(0x1fd))/0x2*(-parseInt(_0x34673b(0x1c8))/0x3)+-parseInt(_0x34673b(0x1ee))/0x4*(parseInt(_0x34673b(0x1c6))/0x5)+parseInt(_0x34673b(0x1fc))/0x6+parseInt(_0x34673b(0x1d0))/0x7*(-parseInt(_0x34673b(0x1f4))/0x8)+-parseInt(_0x34673b(0x1c2))/0x9+parseInt(_0x34673b(0x1da))/0xa;if(_0x998962===_0x151667)break;else _0x3aef81['push'](_0x3aef81['shift']());}catch(_0x21ca2c){_0x3aef81['push'](_0x3aef81['shift']());}}}(a27_0x197d,0x89cee));import{resolveSite,getAPIKey,getConfigDir}from'./config.js';import{loadSessionContext}from'./session.js';import{loadProjectConfig,findProjectConfigPath}from'./project-config.js';import{getActiveProfile,loadProfile}from'./profile.js';function a27_0x197d(){const _0x4db6da=['CLI\x20flag:\x20--','profile:\x20','14wwWMYb','injectIntoOptions','log','entries','(active)','Session','join','project','.json','displayWithSources','21742300RSXNBR','getSource',':\x20none','tdx.json','layers','cliFlags','Project','llm_project','session','us01','loadGlobalConfig','verbose','database',':\x20none\x20(using\x20session:\x20','globalCredentials','existsSync','profileCredentials','config','\x0a[configuration\x20files]','sessions','4agJOPs','parent_segment','parentSegment','650687kMVUOI','string','ppid','3012848HwrvCe','toString','configFiles','parse','global','[context]','not\x20set','Global','1619892SbXEhj','74PwJkfm','llmProject','sessionId','Profile','549297WdaBRn','apiKey','profiles','profile','2534555oMolfk','default','7467qCpLky','getParameters','.env','replace','site','activeProfile'];a27_0x197d=function(){return _0x4db6da;};return a27_0x197d();}import*as a27_0x2bdb72 from'node:fs';import*as a27_0x51964d from'node:path';export class GlobalContext{[a27_0x3d7e13(0x1cc)];[a27_0x3d7e13(0x1e6)];[a27_0x3d7e13(0x1ef)];[a27_0x3d7e13(0x1e1)];[a27_0x3d7e13(0x1c3)];['verbose'];[a27_0x3d7e13(0x1de)];['activeProfile'];[a27_0x3d7e13(0x1ff)];[a27_0x3d7e13(0x1f6)];constructor(_0x4a21fe){const _0x456b52=a27_0x3d7e13;this['sessionId']=_0x4a21fe[_0x456b52(0x1e2)]||process[_0x456b52(0x1f3)][_0x456b52(0x1f5)]();const _0x2b0b9d=loadSessionContext(_0x4a21fe['session']),_0x16a173=loadProjectConfig(),_0x9cc3ad=this[_0x456b52(0x1e4)]();this['activeProfile']=_0x4a21fe['profile']||_0x2b0b9d?.['profile']||_0x9cc3ad[_0x456b52(0x1c5)]||getActiveProfile();const _0x3ea2ed=this[_0x456b52(0x1cd)]?loadProfile(this[_0x456b52(0x1cd)]):null,_0x144075=_0x5e0c31=>{const _0x5b18e7=_0x456b52;if(!_0x5e0c31)return{};const _0x352e2b=_0x5e0c31,_0x3410f3={};for(const [_0x82e445,_0x127fe6]of Object[_0x5b18e7(0x1d3)](_0x352e2b)){typeof _0x127fe6===_0x5b18e7(0x1f2)&&(_0x3410f3[_0x82e445]=_0x127fe6);}return _0x3410f3;},_0x36362a={};if(_0x4a21fe[_0x456b52(0x1cc)]&&_0x4a21fe[_0x456b52(0x1cc)]!==_0x456b52(0x1e3))_0x36362a[_0x456b52(0x1cc)]=_0x4a21fe['site'];const _0x4487c9=_0x2b0b9d?.[_0x456b52(0x1e6)],_0x5d6bbc=_0x16a173?.[_0x456b52(0x1e6)],_0x42a0c9=_0x3ea2ed?.[_0x456b52(0x1eb)]?.[_0x456b52(0x1e6)],_0x18bdc5=_0x9cc3ad[_0x456b52(0x1e6)];_0x4a21fe[_0x456b52(0x1e6)]&&(_0x4a21fe[_0x456b52(0x1e6)]!==_0x4487c9&&_0x4a21fe[_0x456b52(0x1e6)]!==_0x5d6bbc&&_0x4a21fe[_0x456b52(0x1e6)]!==_0x42a0c9&&_0x4a21fe[_0x456b52(0x1e6)]!==_0x18bdc5)&&(_0x36362a[_0x456b52(0x1e6)]=_0x4a21fe[_0x456b52(0x1e6)]);if(_0x4a21fe[_0x456b52(0x1f0)])_0x36362a[_0x456b52(0x1ef)]=_0x4a21fe[_0x456b52(0x1f0)];if(_0x4a21fe['llmProject'])_0x36362a['llm_project']=_0x4a21fe[_0x456b52(0x1fe)];if(_0x4a21fe[_0x456b52(0x1c5)])_0x36362a[_0x456b52(0x1c5)]=_0x4a21fe[_0x456b52(0x1c5)];this[_0x456b52(0x1de)]={'cliFlags':_0x36362a,'session':_0x144075(_0x2b0b9d),'project':_0x144075(_0x16a173),'profile':_0x144075(_0x3ea2ed?.['config']),'global':_0x144075(_0x9cc3ad)};const _0x279ab5={...this[_0x456b52(0x1de)]['global'],...this[_0x456b52(0x1de)][_0x456b52(0x1c5)],...this['layers'][_0x456b52(0x1d7)],...this[_0x456b52(0x1de)][_0x456b52(0x1e2)],...this[_0x456b52(0x1de)][_0x456b52(0x1df)]},_0xa8faaf=_0x279ab5[_0x456b52(0x1cc)]||_0x456b52(0x1e3);this[_0x456b52(0x1cc)]=resolveSite(_0xa8faaf),this[_0x456b52(0x1e6)]=_0x279ab5[_0x456b52(0x1e6)],this[_0x456b52(0x1ef)]=_0x279ab5[_0x456b52(0x1ef)],this[_0x456b52(0x1e1)]=_0x279ab5[_0x456b52(0x1e1)],this[_0x456b52(0x1e5)]=_0x4a21fe['verbose']||![],this[_0x456b52(0x1c3)]=getAPIKey(this[_0x456b52(0x1cc)],this[_0x456b52(0x1cd)]||undefined);const _0x3b9b48=getConfigDir(),_0x71da54=a27_0x51964d[_0x456b52(0x1d6)](_0x3b9b48,_0x456b52(0x1ed),this[_0x456b52(0x1ff)]+_0x456b52(0x1d8)),_0x18b146=findProjectConfigPath(),_0x2c7df1=a27_0x51964d[_0x456b52(0x1d6)](_0x3b9b48,_0x456b52(0x1dd)),_0x1b1c60=a27_0x51964d[_0x456b52(0x1d6)](_0x3b9b48,_0x456b52(0x1ca));let _0x40a6e1=null,_0x377349=null;this['activeProfile']&&(_0x40a6e1=a27_0x51964d['join'](_0x3b9b48,_0x456b52(0x1c4),this[_0x456b52(0x1cd)],_0x456b52(0x1dd)),_0x377349=a27_0x51964d['join'](_0x3b9b48,_0x456b52(0x1c4),this[_0x456b52(0x1cd)],_0x456b52(0x1ca))),this[_0x456b52(0x1f6)]={'session':a27_0x2bdb72[_0x456b52(0x1e9)](_0x71da54)?_0x71da54:null,'project':_0x18b146,'profile':_0x40a6e1&&a27_0x2bdb72[_0x456b52(0x1e9)](_0x40a6e1)?_0x40a6e1:null,'profileCredentials':_0x377349&&a27_0x2bdb72[_0x456b52(0x1e9)](_0x377349)?_0x377349:null,'global':a27_0x2bdb72[_0x456b52(0x1e9)](_0x2c7df1)?_0x2c7df1:null,'globalCredentials':a27_0x2bdb72[_0x456b52(0x1e9)](_0x1b1c60)?_0x1b1c60:null};}[a27_0x3d7e13(0x1db)](_0x23eb1c,_0x15bcac){const _0x369d85=a27_0x3d7e13;if(!_0x15bcac)return _0x369d85(0x1fa);const _0x45fd0a=_0x15bcac;if(this[_0x369d85(0x1de)][_0x369d85(0x1df)][_0x23eb1c]===_0x45fd0a){if(_0x23eb1c===_0x369d85(0x1cc)&&_0x45fd0a==='us01'&&!this[_0x369d85(0x1de)][_0x369d85(0x1e2)][_0x369d85(0x1cc)]&&!this[_0x369d85(0x1de)][_0x369d85(0x1d7)][_0x369d85(0x1cc)]&&!this[_0x369d85(0x1de)][_0x369d85(0x1c5)][_0x369d85(0x1cc)]&&!this[_0x369d85(0x1de)][_0x369d85(0x1f8)][_0x369d85(0x1cc)])return _0x369d85(0x1c7);return _0x369d85(0x1ce)+_0x23eb1c[_0x369d85(0x1cb)](/_/g,'-');}if(this[_0x369d85(0x1de)][_0x369d85(0x1e2)][_0x23eb1c]===_0x45fd0a)return _0x369d85(0x1e2);if(this[_0x369d85(0x1de)][_0x369d85(0x1d7)][_0x23eb1c]===_0x45fd0a)return _0x369d85(0x1d7);if(this[_0x369d85(0x1de)][_0x369d85(0x1c5)][_0x23eb1c]===_0x45fd0a)return _0x369d85(0x1cf)+this[_0x369d85(0x1cd)];if(this[_0x369d85(0x1de)]['global'][_0x23eb1c]===_0x45fd0a)return _0x369d85(0x1f8);return'default';}[a27_0x3d7e13(0x1e4)](){const _0x38a14d=a27_0x3d7e13,_0x1a4659=a27_0x51964d[_0x38a14d(0x1d6)](getConfigDir(),'tdx.json');if(!a27_0x2bdb72[_0x38a14d(0x1e9)](_0x1a4659))return{};try{const _0x4ebd2a=a27_0x2bdb72['readFileSync'](_0x1a4659,'utf-8');return JSON[_0x38a14d(0x1f7)](_0x4ebd2a);}catch{return{};}}[a27_0x3d7e13(0x1d1)](_0x18651b){const _0x43ae16=a27_0x3d7e13;_0x18651b['site']=this[_0x43ae16(0x1cc)],!_0x18651b['database']&&this[_0x43ae16(0x1e6)]&&(_0x18651b[_0x43ae16(0x1e6)]=this[_0x43ae16(0x1e6)]),!_0x18651b['parentSegment']&&this['parent_segment']&&(_0x18651b[_0x43ae16(0x1f0)]=this[_0x43ae16(0x1ef)]),!_0x18651b[_0x43ae16(0x1fe)]&&this[_0x43ae16(0x1e1)]&&(_0x18651b[_0x43ae16(0x1fe)]=this[_0x43ae16(0x1e1)]);}[a27_0x3d7e13(0x1c9)](){const _0x2524fa=a27_0x3d7e13;return[{'key':_0x2524fa(0x1cc),'value':this['site']},{'key':_0x2524fa(0x1e6),'value':this['database']},{'key':_0x2524fa(0x1ef),'value':this['parent_segment']},{'key':_0x2524fa(0x1e1),'value':this[_0x2524fa(0x1e1)]},{'key':_0x2524fa(0x1c5),'value':this['activeProfile']||undefined}];}['display'](){const _0x5991e7=a27_0x3d7e13;console[_0x5991e7(0x1d2)](_0x5991e7(0x1f9));for(const {key:_0x5b8ecf,value:_0x246e00}of this[_0x5991e7(0x1c9)]()){_0x246e00&&console[_0x5991e7(0x1d2)](_0x5b8ecf+':\x20'+_0x246e00);}}[a27_0x3d7e13(0x1d9)](){const _0x4bc1cf=a27_0x3d7e13;console[_0x4bc1cf(0x1d2)]('[context]');for(const {key:_0x2553e2,value:_0x571b02}of this[_0x4bc1cf(0x1c9)]()){if(_0x571b02){const _0x22eedd=_0x2553e2==='profile'?_0x4bc1cf(0x1d4):'('+this['getSource'](_0x2553e2,_0x571b02)+')';console[_0x4bc1cf(0x1d2)](_0x2553e2+':\x20'+_0x571b02+'\x20'+_0x22eedd);}}console[_0x4bc1cf(0x1d2)](_0x4bc1cf(0x1ec));const _0x1b11dc=[{'label':_0x4bc1cf(0x1d5),'path':this[_0x4bc1cf(0x1f6)][_0x4bc1cf(0x1e2)],'extra':'(session:\x20'+this[_0x4bc1cf(0x1ff)]+')'},{'label':_0x4bc1cf(0x1e0),'path':this[_0x4bc1cf(0x1f6)][_0x4bc1cf(0x1d7)]},{'label':_0x4bc1cf(0x1c1),'path':this[_0x4bc1cf(0x1f6)][_0x4bc1cf(0x1c5)]},{'label':'Profile\x20Credentials','path':this['configFiles'][_0x4bc1cf(0x1ea)]},{'label':_0x4bc1cf(0x1fb),'path':this['configFiles']['global']},{'label':'Global\x20Credentials','path':this['configFiles'][_0x4bc1cf(0x1e8)]}];for(const {label:_0x5105e3,path:_0x8d7db3,extra:_0x3b8224}of _0x1b11dc){if(_0x8d7db3)console[_0x4bc1cf(0x1d2)](_0x5105e3+':\x20'+_0x8d7db3+'\x20✓'+(_0x3b8224?'\x20'+_0x3b8224:''));else{if(_0x5105e3===_0x4bc1cf(0x1d5))console['log'](_0x5105e3+_0x4bc1cf(0x1e7)+this[_0x4bc1cf(0x1ff)]+')');else(_0x5105e3===_0x4bc1cf(0x1e0)||_0x5105e3===_0x4bc1cf(0x1fb))&&console[_0x4bc1cf(0x1d2)](_0x5105e3+_0x4bc1cf(0x1dc));}}}}
1
+ const a28_0xd124c4=a28_0x5b79;function a28_0x2536(){const _0x1162dc=['us01','Global','getParameters','project','getSource','configFiles','injectIntoOptions','site','llm_project','cliFlags','join','7147497IUkMsF','layers','.json','5715Okmuad','1086864cLyRVl','Project','parentSegment','apiKey','sessions','profileCredentials','3302331bLWJuk','activeProfile','log','CLI\x20flag:\x20--','2634pRcRDC','167206Zkzpsc','verbose','profiles','15168yKiwWq','1305rXrNbB',':\x20none\x20(using\x20session:\x20','toString','profile','profile:\x20','readFileSync','globalCredentials','Profile\x20Credentials','default','parent_segment','utf-8','existsSync','.env','ppid','string','tdx.json','(session:\x20','Session','llmProject','sessionId','Profile','global','539342qVmXYR','database','displayWithSources','session','(active)','Global\x20Credentials','[context]','config','not\x20set','\x0a[configuration\x20files]','entries','loadGlobalConfig','display'];a28_0x2536=function(){return _0x1162dc;};return a28_0x2536();}(function(_0x457e03,_0x460fde){const _0x39cb3d=a28_0x5b79,_0x34df34=_0x457e03();while(!![]){try{const _0x41fbb8=-parseInt(_0x39cb3d(0xb3))/0x1+parseInt(_0x39cb3d(0xda))/0x2+parseInt(_0x39cb3d(0xd5))/0x3+parseInt(_0x39cb3d(0xcf))/0x4+parseInt(_0x39cb3d(0xde))/0x5*(-parseInt(_0x39cb3d(0xd9))/0x6)+parseInt(_0x39cb3d(0xcb))/0x7+-parseInt(_0x39cb3d(0xdd))/0x8*(parseInt(_0x39cb3d(0xce))/0x9);if(_0x41fbb8===_0x460fde)break;else _0x34df34['push'](_0x34df34['shift']());}catch(_0x3e20f5){_0x34df34['push'](_0x34df34['shift']());}}}(a28_0x2536,0x97316));import{resolveSite,getAPIKey,getConfigDir}from'./config.js';import{loadSessionContext}from'./session.js';function a28_0x5b79(_0x57873d,_0x24680f){const _0x253696=a28_0x2536();return a28_0x5b79=function(_0x5b794f,_0x3fdec6){_0x5b794f=_0x5b794f-0xa3;let _0x12e3f3=_0x253696[_0x5b794f];return _0x12e3f3;},a28_0x5b79(_0x57873d,_0x24680f);}import{loadProjectConfig,findProjectConfigPath}from'./project-config.js';import{getActiveProfile,loadProfile}from'./profile.js';import*as a28_0x3ca49d from'node:fs';import*as a28_0x4fa3af from'node:path';export class GlobalContext{[a28_0xd124c4(0xc7)];[a28_0xd124c4(0xb4)];[a28_0xd124c4(0xa6)];['llm_project'];[a28_0xd124c4(0xd2)];[a28_0xd124c4(0xdb)];['layers'];[a28_0xd124c4(0xd6)];[a28_0xd124c4(0xb0)];['configFiles'];constructor(_0xd07fa7){const _0x5bc2d4=a28_0xd124c4;this[_0x5bc2d4(0xb0)]=_0xd07fa7[_0x5bc2d4(0xb6)]||process[_0x5bc2d4(0xaa)][_0x5bc2d4(0xe0)]();const _0x247167=loadSessionContext(_0xd07fa7[_0x5bc2d4(0xb6)]),_0x44b2c1=loadProjectConfig(),_0x3fdf02=this['loadGlobalConfig']();this['activeProfile']=_0xd07fa7['profile']||_0x247167?.[_0x5bc2d4(0xe1)]||_0x3fdf02[_0x5bc2d4(0xe1)]||getActiveProfile();const _0x13b7f1=this[_0x5bc2d4(0xd6)]?loadProfile(this['activeProfile']):null,_0x2fa2f3=_0x18cbca=>{const _0x5cd582=_0x5bc2d4;if(!_0x18cbca)return{};const _0x349913=_0x18cbca,_0x486ee8={};for(const [_0x480cde,_0xeb1f26]of Object[_0x5cd582(0xbd)](_0x349913)){typeof _0xeb1f26===_0x5cd582(0xab)&&(_0x486ee8[_0x480cde]=_0xeb1f26);}return _0x486ee8;},_0x58850d={};if(_0xd07fa7['site']&&_0xd07fa7[_0x5bc2d4(0xc7)]!==_0x5bc2d4(0xc0))_0x58850d[_0x5bc2d4(0xc7)]=_0xd07fa7[_0x5bc2d4(0xc7)];const _0x2fc416=_0x247167?.['database'],_0x5129f5=_0x44b2c1?.[_0x5bc2d4(0xb4)],_0x4ec9b4=_0x13b7f1?.[_0x5bc2d4(0xba)]?.[_0x5bc2d4(0xb4)],_0x26e03b=_0x3fdf02[_0x5bc2d4(0xb4)];_0xd07fa7[_0x5bc2d4(0xb4)]&&(_0xd07fa7['database']!==_0x2fc416&&_0xd07fa7[_0x5bc2d4(0xb4)]!==_0x5129f5&&_0xd07fa7[_0x5bc2d4(0xb4)]!==_0x4ec9b4&&_0xd07fa7[_0x5bc2d4(0xb4)]!==_0x26e03b)&&(_0x58850d[_0x5bc2d4(0xb4)]=_0xd07fa7[_0x5bc2d4(0xb4)]);if(_0xd07fa7[_0x5bc2d4(0xd1)])_0x58850d[_0x5bc2d4(0xa6)]=_0xd07fa7[_0x5bc2d4(0xd1)];if(_0xd07fa7[_0x5bc2d4(0xaf)])_0x58850d['llm_project']=_0xd07fa7['llmProject'];if(_0xd07fa7[_0x5bc2d4(0xe1)])_0x58850d[_0x5bc2d4(0xe1)]=_0xd07fa7[_0x5bc2d4(0xe1)];this['layers']={'cliFlags':_0x58850d,'session':_0x2fa2f3(_0x247167),'project':_0x2fa2f3(_0x44b2c1),'profile':_0x2fa2f3(_0x13b7f1?.['config']),'global':_0x2fa2f3(_0x3fdf02)};const _0x3a1bf7={...this['layers'][_0x5bc2d4(0xb2)],...this['layers'][_0x5bc2d4(0xe1)],...this['layers']['project'],...this[_0x5bc2d4(0xcc)][_0x5bc2d4(0xb6)],...this[_0x5bc2d4(0xcc)][_0x5bc2d4(0xc9)]},_0x55f25d=_0x3a1bf7['site']||_0x5bc2d4(0xc0);this['site']=resolveSite(_0x55f25d),this[_0x5bc2d4(0xb4)]=_0x3a1bf7[_0x5bc2d4(0xb4)],this[_0x5bc2d4(0xa6)]=_0x3a1bf7[_0x5bc2d4(0xa6)],this[_0x5bc2d4(0xc8)]=_0x3a1bf7[_0x5bc2d4(0xc8)],this[_0x5bc2d4(0xdb)]=_0xd07fa7[_0x5bc2d4(0xdb)]||![],this[_0x5bc2d4(0xd2)]=getAPIKey(this[_0x5bc2d4(0xc7)],this[_0x5bc2d4(0xd6)]||undefined);const _0x5737d6=getConfigDir(),_0x1b131e=a28_0x4fa3af[_0x5bc2d4(0xca)](_0x5737d6,_0x5bc2d4(0xd3),this[_0x5bc2d4(0xb0)]+_0x5bc2d4(0xcd)),_0x174af4=findProjectConfigPath(),_0x15da00=a28_0x4fa3af[_0x5bc2d4(0xca)](_0x5737d6,_0x5bc2d4(0xac)),_0x342014=a28_0x4fa3af['join'](_0x5737d6,_0x5bc2d4(0xa9));let _0xc5b29b=null,_0x3f282e=null;this[_0x5bc2d4(0xd6)]&&(_0xc5b29b=a28_0x4fa3af[_0x5bc2d4(0xca)](_0x5737d6,_0x5bc2d4(0xdc),this['activeProfile'],_0x5bc2d4(0xac)),_0x3f282e=a28_0x4fa3af['join'](_0x5737d6,_0x5bc2d4(0xdc),this[_0x5bc2d4(0xd6)],_0x5bc2d4(0xa9))),this['configFiles']={'session':a28_0x3ca49d[_0x5bc2d4(0xa8)](_0x1b131e)?_0x1b131e:null,'project':_0x174af4,'profile':_0xc5b29b&&a28_0x3ca49d[_0x5bc2d4(0xa8)](_0xc5b29b)?_0xc5b29b:null,'profileCredentials':_0x3f282e&&a28_0x3ca49d[_0x5bc2d4(0xa8)](_0x3f282e)?_0x3f282e:null,'global':a28_0x3ca49d[_0x5bc2d4(0xa8)](_0x15da00)?_0x15da00:null,'globalCredentials':a28_0x3ca49d[_0x5bc2d4(0xa8)](_0x342014)?_0x342014:null};}[a28_0xd124c4(0xc4)](_0x42bfd0,_0x55fa3a){const _0xd1a82a=a28_0xd124c4;if(!_0x55fa3a)return _0xd1a82a(0xbb);const _0x26cf2e=_0x55fa3a;if(this[_0xd1a82a(0xcc)][_0xd1a82a(0xc9)][_0x42bfd0]===_0x26cf2e){if(_0x42bfd0==='site'&&_0x26cf2e===_0xd1a82a(0xc0)&&!this[_0xd1a82a(0xcc)]['session'][_0xd1a82a(0xc7)]&&!this[_0xd1a82a(0xcc)][_0xd1a82a(0xc3)]['site']&&!this[_0xd1a82a(0xcc)][_0xd1a82a(0xe1)][_0xd1a82a(0xc7)]&&!this[_0xd1a82a(0xcc)][_0xd1a82a(0xb2)][_0xd1a82a(0xc7)])return _0xd1a82a(0xa5);return _0xd1a82a(0xd8)+_0x42bfd0['replace'](/_/g,'-');}if(this[_0xd1a82a(0xcc)]['session'][_0x42bfd0]===_0x26cf2e)return _0xd1a82a(0xb6);if(this['layers'][_0xd1a82a(0xc3)][_0x42bfd0]===_0x26cf2e)return _0xd1a82a(0xc3);if(this[_0xd1a82a(0xcc)]['profile'][_0x42bfd0]===_0x26cf2e)return _0xd1a82a(0xe2)+this[_0xd1a82a(0xd6)];if(this[_0xd1a82a(0xcc)][_0xd1a82a(0xb2)][_0x42bfd0]===_0x26cf2e)return _0xd1a82a(0xb2);return _0xd1a82a(0xa5);}[a28_0xd124c4(0xbe)](){const _0x54ca9d=a28_0xd124c4,_0x28ba0c=a28_0x4fa3af[_0x54ca9d(0xca)](getConfigDir(),'tdx.json');if(!a28_0x3ca49d['existsSync'](_0x28ba0c))return{};try{const _0x5b30ea=a28_0x3ca49d[_0x54ca9d(0xe3)](_0x28ba0c,_0x54ca9d(0xa7));return JSON['parse'](_0x5b30ea);}catch{return{};}}[a28_0xd124c4(0xc6)](_0x45fa87){const _0x22496b=a28_0xd124c4;_0x45fa87['site']=this[_0x22496b(0xc7)],!_0x45fa87[_0x22496b(0xb4)]&&this[_0x22496b(0xb4)]&&(_0x45fa87[_0x22496b(0xb4)]=this[_0x22496b(0xb4)]),!_0x45fa87['parentSegment']&&this['parent_segment']&&(_0x45fa87[_0x22496b(0xd1)]=this[_0x22496b(0xa6)]),!_0x45fa87[_0x22496b(0xaf)]&&this['llm_project']&&(_0x45fa87[_0x22496b(0xaf)]=this[_0x22496b(0xc8)]);}[a28_0xd124c4(0xc2)](){const _0x1e1d68=a28_0xd124c4;return[{'key':_0x1e1d68(0xc7),'value':this['site']},{'key':_0x1e1d68(0xb4),'value':this['database']},{'key':'parent_segment','value':this[_0x1e1d68(0xa6)]},{'key':'llm_project','value':this['llm_project']},{'key':_0x1e1d68(0xe1),'value':this[_0x1e1d68(0xd6)]||undefined}];}[a28_0xd124c4(0xbf)](){const _0x4e627f=a28_0xd124c4;console[_0x4e627f(0xd7)](_0x4e627f(0xb9));for(const {key:_0x1c28d0,value:_0x4b2cdc}of this['getParameters']()){_0x4b2cdc&&console[_0x4e627f(0xd7)](_0x1c28d0+':\x20'+_0x4b2cdc);}}[a28_0xd124c4(0xb5)](){const _0x57e48b=a28_0xd124c4;console[_0x57e48b(0xd7)](_0x57e48b(0xb9));for(const {key:_0x221ab1,value:_0x23f7a9}of this['getParameters']()){if(_0x23f7a9){const _0x599c78=_0x221ab1==='profile'?_0x57e48b(0xb7):'('+this['getSource'](_0x221ab1,_0x23f7a9)+')';console[_0x57e48b(0xd7)](_0x221ab1+':\x20'+_0x23f7a9+'\x20'+_0x599c78);}}console['log'](_0x57e48b(0xbc));const _0x91fbb6=[{'label':'Session','path':this['configFiles'][_0x57e48b(0xb6)],'extra':_0x57e48b(0xad)+this[_0x57e48b(0xb0)]+')'},{'label':_0x57e48b(0xd0),'path':this[_0x57e48b(0xc5)]['project']},{'label':_0x57e48b(0xb1),'path':this[_0x57e48b(0xc5)]['profile']},{'label':_0x57e48b(0xa4),'path':this['configFiles'][_0x57e48b(0xd4)]},{'label':_0x57e48b(0xc1),'path':this[_0x57e48b(0xc5)][_0x57e48b(0xb2)]},{'label':_0x57e48b(0xb8),'path':this[_0x57e48b(0xc5)][_0x57e48b(0xa3)]}];for(const {label:_0x435a1d,path:_0x10ab92,extra:_0x167ed7}of _0x91fbb6){if(_0x10ab92)console['log'](_0x435a1d+':\x20'+_0x10ab92+'\x20✓'+(_0x167ed7?'\x20'+_0x167ed7:''));else{if(_0x435a1d===_0x57e48b(0xae))console[_0x57e48b(0xd7)](_0x435a1d+_0x57e48b(0xdf)+this[_0x57e48b(0xb0)]+')');else(_0x435a1d===_0x57e48b(0xd0)||_0x435a1d===_0x57e48b(0xc1))&&console[_0x57e48b(0xd7)](_0x435a1d+':\x20none');}}}}
@@ -1 +1 @@
1
- function a28_0x5a1c(){const _0x38c395=['set','filter','696072yPfCmH','parse','Profile\x20','map','\x27:\x20unknown\x20config\x20key\x20\x27','llm_agent','\x27:\x20\x27llm_project\x27\x20must\x20be\x20a\x20string','\x27:\x20config\x20must\x20be\x20an\x20object','\x27\x20will\x20be\x20ignored','2LxhOTz','values','\x0aWarning:\x20Profiles\x20in\x20directories\x20are\x20deprecated:\x20','Warning:\x20Profile\x20\x27','parent_segment','\x27:\x20\x27llm_agent\x27\x20must\x20be\x20a\x20string','site','readFileSync','\x20does\x20not\x20exist','\x22\x20\x22','.\x20Must\x20contain\x20only\x20alphanumeric\x20characters,\x20dash,\x20and\x20underscore.','description','\x20already\x20exists','Please\x20migrate\x20to\x20~/.config/tdx/tdx.json:','13692EFFiMp','string','969157reSbex','entries','profile',':\x20Invalid\x20JSON\x20syntax','Profile\x20\x27','1127276msggnL','warn','push','1990MFchjR','.env','name','test','API\x20keys\x20must\x20not\x20be\x20stored\x20in\x20profile\x20configuration.\x20Use\x20.env\x20file\x20instead.','message','some','profiles','Invalid\x20profile\x20name:\x20','toISOString','sort','lastUsed','keys','Error:\x20','find','2711870nxXYhN','llm_project','writeFileSync','\x0aWarning:\x20Skipping\x20invalid\x20profile\x20in\x20','isDirectory','utf-8','localeCompare','user','rmSync','\x27:\x20\x27description\x27\x20must\x20be\x20a\x20string','stringify','\x20\x202.\x20Add\x20profiles\x20under\x20a\x20\x22profiles\x22\x20key\x20(see\x20\x27tdx\x20profiles\x27\x20for\x20current\x20config)','120kqDFXd','object','To\x20migrate:','includes','api_key','metadata','9ALnbuu','\x0aWarning:\x20Using\x20deprecated\x20credential\x20location\x20for\x20profile\x20\x27','local','\x20\x203.\x20Move\x20credentials:\x20mv\x20~/.config/tdx/profiles/<name>/.env\x20~/.config/tdx/.env.<name>\x0a','database','\x27:\x20\x27site\x27\x20must\x20be\x20a\x20string','\x0aWarning:\x20Failed\x20to\x20parse\x20','\x20\x201.\x20Edit:\x20','from','\x0aWarning:\x20Failed\x20to\x20load\x20profiles\x20from\x20','215937YlpgMB','join','242gjddew','length','6970782AtDqkO','existsSync','Then\x20define\x20profiles\x20in\x20~/.config/tdx/tdx.json\x0a','tdx.json','directory'];a28_0x5a1c=function(){return _0x38c395;};return a28_0x5a1c();}(function(_0x89e2d5,_0x4c5df6){const _0x330335=a28_0x23c6,_0x1044d9=_0x89e2d5();while(!![]){try{const _0x585895=parseInt(_0x330335(0x10e))/0x1*(parseInt(_0x330335(0xfe))/0x2)+-parseInt(_0x330335(0x137))/0x3*(-parseInt(_0x330335(0x113))/0x4)+-parseInt(_0x330335(0x116))/0x5*(parseInt(_0x330335(0x10c))/0x6)+parseInt(_0x330335(0xee))/0x7+-parseInt(_0x330335(0x131))/0x8*(parseInt(_0x330335(0xea))/0x9)+parseInt(_0x330335(0x125))/0xa+-parseInt(_0x330335(0xec))/0xb*(parseInt(_0x330335(0xf5))/0xc);if(_0x585895===_0x4c5df6)break;else _0x1044d9['push'](_0x1044d9['shift']());}catch(_0x54c077){_0x1044d9['push'](_0x1044d9['shift']());}}}(a28_0x5a1c,0x83314));import*as a28_0x4abcfe from'node:fs';import*as a28_0x3e7f36 from'node:path';import{getConfigDir}from'./config.js';import{createSecureDirectory,writeSecureFile}from'../utils/file-permissions.js';import{findProjectConfigPath}from'./project-config.js';function a28_0x23c6(_0x57ac34,_0x5ceda1){const _0x5a1c8e=a28_0x5a1c();return a28_0x23c6=function(_0x23c692,_0x482d7a){_0x23c692=_0x23c692-0xe5;let _0x284c8b=_0x5a1c8e[_0x23c692];return _0x284c8b;},a28_0x23c6(_0x57ac34,_0x5ceda1);}export function getProfileParams(_0x46c07a){const _0x1c82d7=a28_0x23c6,_0x1f5503={};if(!_0x46c07a)return _0x1f5503;for(const [_0x4074af,_0x91bcef]of Object[_0x1c82d7(0x10f)](_0x46c07a)){_0x4074af!==_0x1c82d7(0x109)&&_0x91bcef!==undefined&&(_0x1f5503[_0x4074af]=_0x91bcef);}return _0x1f5503;}export function getProfilesDir(){const _0x2cb065=a28_0x23c6;return a28_0x3e7f36[_0x2cb065(0xeb)](getConfigDir(),_0x2cb065(0x11d));}function getProfileDir(_0x591f45){const _0xe0999b=a28_0x23c6;return a28_0x3e7f36[_0xe0999b(0xeb)](getProfilesDir(),_0x591f45);}function getProfileConfigPath(_0xe041f2){const _0x3b068d=a28_0x23c6;return a28_0x3e7f36[_0x3b068d(0xeb)](getProfileDir(_0xe041f2),_0x3b068d(0xf1));}function getProfileEnvPath(_0x4b70f7){const _0x51353f=a28_0x23c6;return a28_0x3e7f36['join'](getProfileDir(_0x4b70f7),_0x51353f(0x117));}function getGlobalConfigPath(){const _0x48a14c=a28_0x23c6;return a28_0x3e7f36[_0x48a14c(0xeb)](getConfigDir(),_0x48a14c(0xf1));}function validateProfileName(_0x15bf77){const _0x49d86f=a28_0x23c6;if(!/^[a-zA-Z0-9_-]+$/[_0x49d86f(0x119)](_0x15bf77))throw new Error(_0x49d86f(0x11e)+_0x15bf77+_0x49d86f(0x108));}function validateProfileConfig(_0x212b36,_0x9a56aa){const _0x3686a9=a28_0x23c6;if(typeof _0x212b36!==_0x3686a9(0x132)||_0x212b36===null)throw new Error(_0x3686a9(0x112)+_0x9a56aa+_0x3686a9(0xfc));const _0x26741e=[_0x3686a9(0x109),'site','database',_0x3686a9(0x102),_0x3686a9(0x126),_0x3686a9(0xfa)],_0xf1d548=_0x212b36;for(const _0xa90e02 of Object[_0x3686a9(0x122)](_0xf1d548)){!_0x26741e['includes'](_0xa90e02)&&console[_0x3686a9(0x114)](_0x3686a9(0x101)+_0x9a56aa+_0x3686a9(0xf9)+_0xa90e02+_0x3686a9(0xfd));}if(_0xf1d548[_0x3686a9(0x109)]!==undefined&&typeof _0xf1d548['description']!==_0x3686a9(0x10d))throw new Error(_0x3686a9(0x112)+_0x9a56aa+_0x3686a9(0x12e));if(_0xf1d548[_0x3686a9(0x104)]!==undefined&&typeof _0xf1d548[_0x3686a9(0x104)]!==_0x3686a9(0x10d))throw new Error(_0x3686a9(0x112)+_0x9a56aa+_0x3686a9(0xe5));if(_0xf1d548['database']!==undefined&&typeof _0xf1d548[_0x3686a9(0x13b)]!=='string')throw new Error(_0x3686a9(0x112)+_0x9a56aa+'\x27:\x20\x27database\x27\x20must\x20be\x20a\x20string');if(_0xf1d548[_0x3686a9(0x102)]!==undefined&&typeof _0xf1d548[_0x3686a9(0x102)]!==_0x3686a9(0x10d))throw new Error(_0x3686a9(0x112)+_0x9a56aa+'\x27:\x20\x27parent_segment\x27\x20must\x20be\x20a\x20string');if(_0xf1d548[_0x3686a9(0x126)]!==undefined&&typeof _0xf1d548[_0x3686a9(0x126)]!==_0x3686a9(0x10d))throw new Error('Profile\x20\x27'+_0x9a56aa+_0x3686a9(0xfb));if(_0xf1d548[_0x3686a9(0xfa)]!==undefined&&typeof _0xf1d548['llm_agent']!==_0x3686a9(0x10d))throw new Error('Profile\x20\x27'+_0x9a56aa+_0x3686a9(0x103));return!![];}function loadProfilesFromTdxJson(_0x3d4285,_0x586fb8){const _0x1a10b1=a28_0x23c6;if(!a28_0x4abcfe[_0x1a10b1(0xef)](_0x3d4285))return[];try{const _0x2c60e0=a28_0x4abcfe['readFileSync'](_0x3d4285,'utf-8'),_0x1d664f=JSON[_0x1a10b1(0xf6)](_0x2c60e0);if(!_0x1d664f[_0x1a10b1(0x11d)]||typeof _0x1d664f[_0x1a10b1(0x11d)]!=='object')return[];const _0x5b5fd5=[];for(const [_0x16b632,_0x477c06]of Object['entries'](_0x1d664f[_0x1a10b1(0x11d)])){try{validateProfileConfig(_0x477c06,_0x16b632);const _0x2fcbea=getNewCredentialPath(_0x16b632),_0x40e574=getOldCredentialPath(_0x16b632),_0x5d5200=a28_0x4abcfe[_0x1a10b1(0xef)](_0x2fcbea)||a28_0x4abcfe[_0x1a10b1(0xef)](_0x40e574);_0x5b5fd5['push']({'name':_0x16b632,'config':_0x477c06,'metadata':{'name':_0x16b632,'createdAt':new Date()[_0x1a10b1(0x11f)]()},'hasCredentials':_0x5d5200,'scope':_0x586fb8});}catch(_0x261958){_0x261958 instanceof Error&&(console[_0x1a10b1(0x114)](_0x1a10b1(0x128)+_0x3d4285+':'),console[_0x1a10b1(0x114)]('\x20\x20'+_0x261958[_0x1a10b1(0x11b)]+'\x0a'));}}return _0x5b5fd5;}catch(_0x7bcd9a){return _0x7bcd9a instanceof SyntaxError?(console[_0x1a10b1(0x114)](_0x1a10b1(0xe6)+_0x3d4285+_0x1a10b1(0x111)),console[_0x1a10b1(0x114)](_0x1a10b1(0x123)+_0x7bcd9a[_0x1a10b1(0x11b)]+'\x0a')):console[_0x1a10b1(0x114)](_0x1a10b1(0xe9)+_0x3d4285+':\x20'+_0x7bcd9a+'\x0a'),[];}}export function getNewCredentialPath(_0x1b50d5){return a28_0x3e7f36['join'](getConfigDir(),'.env.'+_0x1b50d5);}function getOldCredentialPath(_0x5bd157){const _0xcf85eb=a28_0x23c6;return a28_0x3e7f36[_0xcf85eb(0xeb)](getProfilesDir(),_0x5bd157,_0xcf85eb(0x117));}function loadProfilesFromTdxJsonFiles(){const _0x4b694d=a28_0x23c6,_0x510d45=[],_0xa2af1a=findProjectConfigPath();_0xa2af1a&&_0x510d45['push'](...loadProfilesFromTdxJson(_0xa2af1a,_0x4b694d(0x139)));const _0x2959a4=a28_0x3e7f36['join'](getConfigDir(),_0x4b694d(0xf1));return _0x510d45[_0x4b694d(0x115)](...loadProfilesFromTdxJson(_0x2959a4,_0x4b694d(0x12c))),_0x510d45;}function loadProfilesFromDirectories(){const _0x39622c=a28_0x23c6,_0x53a713=getProfilesDir();if(!a28_0x4abcfe['existsSync'](_0x53a713))return[];try{return a28_0x4abcfe['readdirSync'](_0x53a713,{'withFileTypes':!![]})[_0x39622c(0xf4)](_0x520006=>_0x520006[_0x39622c(0x129)]())[_0x39622c(0xf8)](_0x5344b6=>_0x5344b6[_0x39622c(0x118)])[_0x39622c(0xf4)](_0x395955=>{const _0x133049=_0x39622c,_0x12ca51=getProfileConfigPath(_0x395955),_0x1f2d1e=getProfileEnvPath(_0x395955);return a28_0x4abcfe[_0x133049(0xef)](_0x12ca51)||a28_0x4abcfe[_0x133049(0xef)](_0x1f2d1e);})[_0x39622c(0xf8)](_0x6306e=>{const _0x42ce56=_0x39622c,_0x4ba969=loadProfileFromDirectory(_0x6306e);if(_0x4ba969)return{..._0x4ba969,'scope':_0x42ce56(0xf2)};return null;})[_0x39622c(0xf4)](_0x42ab2a=>_0x42ab2a!==null);}catch{return[];}}function loadProfileFromDirectory(_0xc37db3){const _0x404c42=a28_0x23c6,_0x478857=getProfileConfigPath(_0xc37db3),_0x306da2=getOldCredentialPath(_0xc37db3);if(!a28_0x4abcfe['existsSync'](_0x478857)&&!a28_0x4abcfe[_0x404c42(0xef)](_0x306da2))return null;let _0x2f68f8={},_0xcc5ee3={'name':_0xc37db3,'createdAt':new Date()[_0x404c42(0x11f)]()};if(a28_0x4abcfe[_0x404c42(0xef)](_0x478857))try{const _0x314db0=a28_0x4abcfe['readFileSync'](_0x478857,'utf-8'),_0x535627=JSON[_0x404c42(0xf6)](_0x314db0),{metadata:_0x4707d2,..._0x276181}=_0x535627;_0x2f68f8=_0x276181,_0x4707d2&&(_0xcc5ee3=_0x4707d2);}catch{}return{'name':_0xc37db3,'config':_0x2f68f8,'metadata':_0xcc5ee3,'hasCredentials':a28_0x4abcfe[_0x404c42(0xef)](_0x306da2),'scope':_0x404c42(0xf2)};}export function listProfiles(){const _0x208f78=a28_0x23c6,_0x552545=loadProfilesFromTdxJsonFiles(),_0x2fb2f5=loadProfilesFromDirectories();if(_0x2fb2f5[_0x208f78(0xed)]>0x0){const _0x3b767a=_0x2fb2f5[_0x208f78(0xf8)](_0x510fcd=>_0x510fcd[_0x208f78(0x118)])['join'](',\x20'),_0x5ccc65=getConfigDir();console['warn'](_0x208f78(0x100)+_0x3b767a),console[_0x208f78(0x114)](_0x208f78(0x10b)),console[_0x208f78(0x114)](_0x208f78(0xe7)+a28_0x3e7f36[_0x208f78(0xeb)](_0x5ccc65,_0x208f78(0xf1))),console[_0x208f78(0x114)](_0x208f78(0x130)),console[_0x208f78(0x114)](_0x208f78(0x13a));}const _0x559e36=[..._0x552545,..._0x2fb2f5],_0x3b684e=new Map();for(const _0x5768fb of _0x559e36){!_0x3b684e['has'](_0x5768fb[_0x208f78(0x118)])&&_0x3b684e[_0x208f78(0xf3)](_0x5768fb[_0x208f78(0x118)],_0x5768fb);}return Array[_0x208f78(0xe8)](_0x3b684e[_0x208f78(0xff)]())[_0x208f78(0x120)]((_0x13100e,_0x108d31)=>_0x13100e[_0x208f78(0x118)][_0x208f78(0x12b)](_0x108d31['name']));}export function profileExists(_0x479f42){const _0x1f8d3a=a28_0x23c6,_0xba3d7b=listProfiles();return _0xba3d7b[_0x1f8d3a(0x11c)](_0x42415f=>_0x42415f[_0x1f8d3a(0x118)]===_0x479f42);}export function loadProfile(_0x3a5dab){const _0x3a7cd4=a28_0x23c6;validateProfileName(_0x3a5dab);const _0x6ba2c3=listProfiles(),_0x3bfc45=_0x6ba2c3[_0x3a7cd4(0x124)](_0x39129e=>_0x39129e['name']===_0x3a5dab);return _0x3bfc45||null;}export function saveProfile(_0x22e170,_0x49fee3,_0xb2d2a1=![]){const _0x20ec72=a28_0x23c6;validateProfileName(_0x22e170);const _0x2d29e9=getProfileDir(_0x22e170),_0x5d03ba=getProfileConfigPath(_0x22e170);createSecureDirectory(_0x2d29e9);let _0x17a462;const _0x39a1b8=loadProfile(_0x22e170);_0x39a1b8?(_0x17a462=_0x39a1b8[_0x20ec72(0x136)],_0xb2d2a1&&(_0x17a462[_0x20ec72(0x121)]=new Date()['toISOString']())):_0x17a462={'name':_0x22e170,'createdAt':new Date()[_0x20ec72(0x11f)]()};const _0xd02b2c=JSON[_0x20ec72(0x12f)](_0x49fee3);if(_0xd02b2c['includes']('TD_API_KEY')||_0xd02b2c[_0x20ec72(0x134)]('apiKey')||_0xd02b2c['includes'](_0x20ec72(0x135)))throw new Error(_0x20ec72(0x11a));const _0x171743={..._0x49fee3,'metadata':_0x17a462};a28_0x4abcfe[_0x20ec72(0x127)](_0x5d03ba,JSON[_0x20ec72(0x12f)](_0x171743,null,0x2));}export function deleteProfile(_0x2c1543){const _0x184755=a28_0x23c6;validateProfileName(_0x2c1543);const _0x457995=getProfileDir(_0x2c1543);if(!a28_0x4abcfe['existsSync'](_0x457995))throw new Error(_0x184755(0xf7)+_0x2c1543+'\x20does\x20not\x20exist');a28_0x4abcfe[_0x184755(0x12d)](_0x457995,{'recursive':!![],'force':!![]});}export function getActiveProfile(){const _0x8742e5=a28_0x23c6,_0x18068e=getGlobalConfigPath();if(!a28_0x4abcfe[_0x8742e5(0xef)](_0x18068e))return null;try{const _0x48dfe3=a28_0x4abcfe[_0x8742e5(0x105)](_0x18068e,'utf-8'),_0x430144=JSON['parse'](_0x48dfe3);return _0x430144[_0x8742e5(0x110)]||null;}catch{return null;}}export function createProfile(_0x34a7b0,_0x37a7c4){const _0x210dca=a28_0x23c6;validateProfileName(_0x34a7b0);if(profileExists(_0x34a7b0))throw new Error(_0x210dca(0xf7)+_0x34a7b0+_0x210dca(0x10a));saveProfile(_0x34a7b0,_0x37a7c4);}export function saveProfileCredentials(_0x40bd9f,_0x3f189e){const _0x5dac3c=a28_0x23c6;validateProfileName(_0x40bd9f);if(!profileExists(_0x40bd9f))throw new Error('Profile\x20'+_0x40bd9f+_0x5dac3c(0x106));const _0x1efda3=getNewCredentialPath(_0x40bd9f);writeSecureFile(_0x1efda3,_0x3f189e);}export function loadProfileCredentials(_0x3344ad){const _0x141aa3=a28_0x23c6;validateProfileName(_0x3344ad);const _0xd9324c=getNewCredentialPath(_0x3344ad);if(a28_0x4abcfe['existsSync'](_0xd9324c))try{return a28_0x4abcfe[_0x141aa3(0x105)](_0xd9324c,_0x141aa3(0x12a));}catch{}const _0xd31474=getOldCredentialPath(_0x3344ad);if(a28_0x4abcfe['existsSync'](_0xd31474)){console[_0x141aa3(0x114)](_0x141aa3(0x138)+_0x3344ad+'\x27'),console[_0x141aa3(0x114)](_0x141aa3(0x133)),console[_0x141aa3(0x114)]('\x20\x20mv\x20\x22'+_0xd31474+_0x141aa3(0x107)+_0xd9324c+'\x22'),console[_0x141aa3(0x114)](_0x141aa3(0xf0));try{return a28_0x4abcfe[_0x141aa3(0x105)](_0xd31474,_0x141aa3(0x12a));}catch{return null;}}return null;}
1
+ (function(_0x585c78,_0x450568){const _0x118c3c=a29_0x29c9,_0x3e1090=_0x585c78();while(!![]){try{const _0x2f4e9b=parseInt(_0x118c3c(0xf9))/0x1*(-parseInt(_0x118c3c(0x113))/0x2)+parseInt(_0x118c3c(0x125))/0x3+-parseInt(_0x118c3c(0xfe))/0x4*(-parseInt(_0x118c3c(0xfc))/0x5)+parseInt(_0x118c3c(0x130))/0x6+parseInt(_0x118c3c(0x126))/0x7+-parseInt(_0x118c3c(0xfa))/0x8*(parseInt(_0x118c3c(0x115))/0x9)+parseInt(_0x118c3c(0x11d))/0xa*(-parseInt(_0x118c3c(0x105))/0xb);if(_0x2f4e9b===_0x450568)break;else _0x3e1090['push'](_0x3e1090['shift']());}catch(_0x4b4a0c){_0x3e1090['push'](_0x3e1090['shift']());}}}(a29_0x24f3,0xcdd8c));import*as a29_0x15c894 from'node:fs';import*as a29_0x74f908 from'node:path';import{getConfigDir}from'./config.js';import{createSecureDirectory,writeSecureFile}from'../utils/file-permissions.js';import{findProjectConfigPath}from'./project-config.js';export function getProfileParams(_0x37de91){const _0x124eb6=a29_0x29c9,_0x50068e={};if(!_0x37de91)return _0x50068e;for(const [_0x51e284,_0x401c84]of Object[_0x124eb6(0x11f)](_0x37de91)){_0x51e284!==_0x124eb6(0x12f)&&_0x401c84!==undefined&&(_0x50068e[_0x51e284]=_0x401c84);}return _0x50068e;}export function getProfilesDir(){const _0x3c2276=a29_0x29c9;return a29_0x74f908[_0x3c2276(0x110)](getConfigDir(),'profiles');}function getProfileDir(_0x30262c){const _0x34a819=a29_0x29c9;return a29_0x74f908[_0x34a819(0x110)](getProfilesDir(),_0x30262c);}function getProfileConfigPath(_0xe3cd5a){const _0x1334ee=a29_0x29c9;return a29_0x74f908[_0x1334ee(0x110)](getProfileDir(_0xe3cd5a),'tdx.json');}function getProfileEnvPath(_0x2b3bf){const _0x337457=a29_0x29c9;return a29_0x74f908[_0x337457(0x110)](getProfileDir(_0x2b3bf),_0x337457(0x100));}function getGlobalConfigPath(){const _0x2ed594=a29_0x29c9;return a29_0x74f908[_0x2ed594(0x110)](getConfigDir(),_0x2ed594(0x108));}function validateProfileName(_0x59a474){const _0x2e007e=a29_0x29c9;if(!/^[a-zA-Z0-9_-]+$/[_0x2e007e(0x143)](_0x59a474))throw new Error(_0x2e007e(0x13e)+_0x59a474+_0x2e007e(0x131));}function validateProfileConfig(_0x591d63,_0x2a02a2){const _0x3bd77e=a29_0x29c9;if(typeof _0x591d63!=='object'||_0x591d63===null)throw new Error(_0x3bd77e(0xfd)+_0x2a02a2+_0x3bd77e(0x128));const _0x5d86da=['description','site',_0x3bd77e(0x144),_0x3bd77e(0x127),_0x3bd77e(0x104),'llm_agent'],_0xd4d494=_0x591d63;for(const _0x3f7fc9 of Object[_0x3bd77e(0xf6)](_0xd4d494)){!_0x5d86da[_0x3bd77e(0x12e)](_0x3f7fc9)&&console[_0x3bd77e(0x13d)](_0x3bd77e(0x106)+_0x2a02a2+_0x3bd77e(0x107)+_0x3f7fc9+_0x3bd77e(0xfb));}if(_0xd4d494[_0x3bd77e(0x12f)]!==undefined&&typeof _0xd4d494[_0x3bd77e(0x12f)]!==_0x3bd77e(0x124))throw new Error(_0x3bd77e(0xfd)+_0x2a02a2+_0x3bd77e(0x147));if(_0xd4d494[_0x3bd77e(0x134)]!==undefined&&typeof _0xd4d494['site']!==_0x3bd77e(0x124))throw new Error(_0x3bd77e(0xfd)+_0x2a02a2+_0x3bd77e(0x103));if(_0xd4d494[_0x3bd77e(0x144)]!==undefined&&typeof _0xd4d494['database']!==_0x3bd77e(0x124))throw new Error('Profile\x20\x27'+_0x2a02a2+_0x3bd77e(0x117));if(_0xd4d494[_0x3bd77e(0x127)]!==undefined&&typeof _0xd4d494[_0x3bd77e(0x127)]!==_0x3bd77e(0x124))throw new Error(_0x3bd77e(0xfd)+_0x2a02a2+'\x27:\x20\x27parent_segment\x27\x20must\x20be\x20a\x20string');if(_0xd4d494[_0x3bd77e(0x104)]!==undefined&&typeof _0xd4d494[_0x3bd77e(0x104)]!==_0x3bd77e(0x124))throw new Error('Profile\x20\x27'+_0x2a02a2+_0x3bd77e(0x118));if(_0xd4d494[_0x3bd77e(0x11c)]!==undefined&&typeof _0xd4d494[_0x3bd77e(0x11c)]!=='string')throw new Error(_0x3bd77e(0xfd)+_0x2a02a2+_0x3bd77e(0x141));return!![];}function loadProfilesFromTdxJson(_0x5c94ab,_0xfdad7d){const _0x965d2a=a29_0x29c9;if(!a29_0x15c894['existsSync'](_0x5c94ab))return[];try{const _0x167ee9=a29_0x15c894[_0x965d2a(0x139)](_0x5c94ab,'utf-8'),_0x4ea074=JSON[_0x965d2a(0x142)](_0x167ee9);if(!_0x4ea074[_0x965d2a(0x123)]||typeof _0x4ea074['profiles']!==_0x965d2a(0x10b))return[];const _0x1ce548=[];for(const [_0x3edb08,_0x57359c]of Object[_0x965d2a(0x11f)](_0x4ea074[_0x965d2a(0x123)])){try{validateProfileConfig(_0x57359c,_0x3edb08);const _0x5caaed=getNewCredentialPath(_0x3edb08),_0x3542cb=getOldCredentialPath(_0x3edb08),_0x805501=a29_0x15c894[_0x965d2a(0x136)](_0x5caaed)||a29_0x15c894[_0x965d2a(0x136)](_0x3542cb);_0x1ce548[_0x965d2a(0x109)]({'name':_0x3edb08,'config':_0x57359c,'metadata':{'name':_0x3edb08,'createdAt':new Date()[_0x965d2a(0x146)]()},'hasCredentials':_0x805501,'scope':_0xfdad7d});}catch(_0x44ba2c){_0x44ba2c instanceof Error&&(console[_0x965d2a(0x13d)](_0x965d2a(0x138)+_0x5c94ab+':'),console[_0x965d2a(0x13d)]('\x20\x20'+_0x44ba2c[_0x965d2a(0x120)]+'\x0a'));}}return _0x1ce548;}catch(_0x545c91){return _0x545c91 instanceof SyntaxError?(console[_0x965d2a(0x13d)]('\x0aWarning:\x20Failed\x20to\x20parse\x20'+_0x5c94ab+_0x965d2a(0x111)),console[_0x965d2a(0x13d)](_0x965d2a(0x11b)+_0x545c91[_0x965d2a(0x120)]+'\x0a')):console[_0x965d2a(0x13d)]('\x0aWarning:\x20Failed\x20to\x20load\x20profiles\x20from\x20'+_0x5c94ab+':\x20'+_0x545c91+'\x0a'),[];}}export function getNewCredentialPath(_0x34dada){const _0x271103=a29_0x29c9;return a29_0x74f908[_0x271103(0x110)](getConfigDir(),'.env.'+_0x34dada);}function getOldCredentialPath(_0xe4dbaf){const _0x4273f3=a29_0x29c9;return a29_0x74f908[_0x4273f3(0x110)](getProfilesDir(),_0xe4dbaf,_0x4273f3(0x100));}function loadProfilesFromTdxJsonFiles(){const _0x3569e1=a29_0x29c9,_0x50f744=[],_0x4b6db6=findProjectConfigPath();_0x4b6db6&&_0x50f744[_0x3569e1(0x109)](...loadProfilesFromTdxJson(_0x4b6db6,_0x3569e1(0x13c)));const _0x5c4673=a29_0x74f908[_0x3569e1(0x110)](getConfigDir(),_0x3569e1(0x108));return _0x50f744[_0x3569e1(0x109)](...loadProfilesFromTdxJson(_0x5c4673,_0x3569e1(0x116))),_0x50f744;}function loadProfilesFromDirectories(){const _0x19604b=a29_0x29c9,_0x33944f=getProfilesDir();if(!a29_0x15c894[_0x19604b(0x136)](_0x33944f))return[];try{return a29_0x15c894[_0x19604b(0x10f)](_0x33944f,{'withFileTypes':!![]})['filter'](_0x3c2a9e=>_0x3c2a9e[_0x19604b(0xf7)]())[_0x19604b(0xf8)](_0x187cbe=>_0x187cbe[_0x19604b(0x140)])['filter'](_0xe1af62=>{const _0x36e700=_0x19604b,_0x16c40a=getProfileConfigPath(_0xe1af62),_0x431789=getProfileEnvPath(_0xe1af62);return a29_0x15c894[_0x36e700(0x136)](_0x16c40a)||a29_0x15c894[_0x36e700(0x136)](_0x431789);})[_0x19604b(0xf8)](_0x128bb9=>{const _0x56f182=_0x19604b,_0x285d35=loadProfileFromDirectory(_0x128bb9);if(_0x285d35)return{..._0x285d35,'scope':_0x56f182(0x121)};return null;})[_0x19604b(0x10a)](_0x5bfa79=>_0x5bfa79!==null);}catch{return[];}}function loadProfileFromDirectory(_0x3f9974){const _0x467c5e=a29_0x29c9,_0x13e6c4=getProfileConfigPath(_0x3f9974),_0x1f3f4b=getOldCredentialPath(_0x3f9974);if(!a29_0x15c894[_0x467c5e(0x136)](_0x13e6c4)&&!a29_0x15c894['existsSync'](_0x1f3f4b))return null;let _0x4e2bc7={},_0x2ec469={'name':_0x3f9974,'createdAt':new Date()[_0x467c5e(0x146)]()};if(a29_0x15c894['existsSync'](_0x13e6c4))try{const _0x583292=a29_0x15c894[_0x467c5e(0x139)](_0x13e6c4,_0x467c5e(0x12d)),_0x17289b=JSON[_0x467c5e(0x142)](_0x583292),{metadata:_0xc73aff,..._0x5da1fe}=_0x17289b;_0x4e2bc7=_0x5da1fe,_0xc73aff&&(_0x2ec469=_0xc73aff);}catch{}return{'name':_0x3f9974,'config':_0x4e2bc7,'metadata':_0x2ec469,'hasCredentials':a29_0x15c894[_0x467c5e(0x136)](_0x1f3f4b),'scope':_0x467c5e(0x121)};}function a29_0x29c9(_0x140b39,_0x8ec4fc){const _0x24f391=a29_0x24f3();return a29_0x29c9=function(_0x29c999,_0x598cf2){_0x29c999=_0x29c999-0xf6;let _0x5eb997=_0x24f391[_0x29c999];return _0x5eb997;},a29_0x29c9(_0x140b39,_0x8ec4fc);}export function listProfiles(){const _0x6eaf6=a29_0x29c9,_0x5f03d3=loadProfilesFromTdxJsonFiles(),_0x516e91=loadProfilesFromDirectories();if(_0x516e91[_0x6eaf6(0x112)]>0x0){const _0x349a8b=_0x516e91[_0x6eaf6(0xf8)](_0x5cee7f=>_0x5cee7f['name'])[_0x6eaf6(0x110)](',\x20'),_0x2d16f3=getConfigDir();console['warn'](_0x6eaf6(0x119)+_0x349a8b),console[_0x6eaf6(0x13d)](_0x6eaf6(0x132)),console[_0x6eaf6(0x13d)](_0x6eaf6(0x13a)+a29_0x74f908['join'](_0x2d16f3,_0x6eaf6(0x108))),console[_0x6eaf6(0x13d)](_0x6eaf6(0xff)),console[_0x6eaf6(0x13d)]('\x20\x203.\x20Move\x20credentials:\x20mv\x20~/.config/tdx/profiles/<name>/.env\x20~/.config/tdx/.env.<name>\x0a');}const _0x1cc3c0=[..._0x5f03d3,..._0x516e91],_0x213984=new Map();for(const _0xf2723 of _0x1cc3c0){!_0x213984[_0x6eaf6(0x13f)](_0xf2723[_0x6eaf6(0x140)])&&_0x213984[_0x6eaf6(0x114)](_0xf2723['name'],_0xf2723);}return Array[_0x6eaf6(0x133)](_0x213984[_0x6eaf6(0x12c)]())['sort']((_0x5d495f,_0xfc323d)=>_0x5d495f[_0x6eaf6(0x140)]['localeCompare'](_0xfc323d[_0x6eaf6(0x140)]));}export function profileExists(_0x276595){const _0x3de3e6=a29_0x29c9,_0xa82f0=listProfiles();return _0xa82f0[_0x3de3e6(0x10d)](_0x365995=>_0x365995[_0x3de3e6(0x140)]===_0x276595);}export function loadProfile(_0x5106f7){const _0x1d3343=a29_0x29c9;validateProfileName(_0x5106f7);const _0x10f72a=listProfiles(),_0x2a3a4a=_0x10f72a[_0x1d3343(0x10c)](_0x345994=>_0x345994['name']===_0x5106f7);return _0x2a3a4a||null;}export function saveProfile(_0x3dc8fa,_0x5a7883,_0x9a2aa0=![]){const _0x1d3f4a=a29_0x29c9;validateProfileName(_0x3dc8fa);const _0x5b8bac=getProfileDir(_0x3dc8fa),_0x461c40=getProfileConfigPath(_0x3dc8fa);createSecureDirectory(_0x5b8bac);let _0x192071;const _0x450d50=loadProfile(_0x3dc8fa);_0x450d50?(_0x192071=_0x450d50[_0x1d3f4a(0x135)],_0x9a2aa0&&(_0x192071[_0x1d3f4a(0x129)]=new Date()[_0x1d3f4a(0x146)]())):_0x192071={'name':_0x3dc8fa,'createdAt':new Date()[_0x1d3f4a(0x146)]()};const _0x5f0f07=JSON[_0x1d3f4a(0x11a)](_0x5a7883);if(_0x5f0f07['includes'](_0x1d3f4a(0x122))||_0x5f0f07[_0x1d3f4a(0x12e)](_0x1d3f4a(0x11e))||_0x5f0f07['includes'](_0x1d3f4a(0x12a)))throw new Error(_0x1d3f4a(0x10e));const _0x4fa65e={..._0x5a7883,'metadata':_0x192071};a29_0x15c894['writeFileSync'](_0x461c40,JSON['stringify'](_0x4fa65e,null,0x2));}export function deleteProfile(_0x2959d6){const _0x32880e=a29_0x29c9;validateProfileName(_0x2959d6);const _0x43171f=getProfileDir(_0x2959d6);if(!a29_0x15c894[_0x32880e(0x136)](_0x43171f))throw new Error(_0x32880e(0x145)+_0x2959d6+_0x32880e(0x101));a29_0x15c894['rmSync'](_0x43171f,{'recursive':!![],'force':!![]});}export function getActiveProfile(){const _0x5b27c4=a29_0x29c9,_0x40a9dc=getGlobalConfigPath();if(!a29_0x15c894[_0x5b27c4(0x136)](_0x40a9dc))return null;try{const _0x5bfb5b=a29_0x15c894[_0x5b27c4(0x139)](_0x40a9dc,'utf-8'),_0x432901=JSON[_0x5b27c4(0x142)](_0x5bfb5b);return _0x432901[_0x5b27c4(0x102)]||null;}catch{return null;}}export function createProfile(_0x46c5a6,_0x648c8e){const _0x392f0f=a29_0x29c9;validateProfileName(_0x46c5a6);if(profileExists(_0x46c5a6))throw new Error(_0x392f0f(0x145)+_0x46c5a6+_0x392f0f(0x12b));saveProfile(_0x46c5a6,_0x648c8e);}export function saveProfileCredentials(_0x1a0eec,_0x1e309f){const _0x4d8d2e=a29_0x29c9;validateProfileName(_0x1a0eec);if(!profileExists(_0x1a0eec))throw new Error(_0x4d8d2e(0x145)+_0x1a0eec+_0x4d8d2e(0x101));const _0x3e864e=getNewCredentialPath(_0x1a0eec);writeSecureFile(_0x3e864e,_0x1e309f);}function a29_0x24f3(){const _0x466b5a=['\x20does\x20not\x20exist','profile','\x27:\x20\x27site\x27\x20must\x20be\x20a\x20string','llm_project','11LHromq','Warning:\x20Profile\x20\x27','\x27:\x20unknown\x20config\x20key\x20\x27','tdx.json','push','filter','object','find','some','API\x20keys\x20must\x20not\x20be\x20stored\x20in\x20profile\x20configuration.\x20Use\x20.env\x20file\x20instead.','readdirSync','join',':\x20Invalid\x20JSON\x20syntax','length','38Vnvslb','set','497916atFzQn','user','\x27:\x20\x27database\x27\x20must\x20be\x20a\x20string','\x27:\x20\x27llm_project\x27\x20must\x20be\x20a\x20string','\x0aWarning:\x20Profiles\x20in\x20directories\x20are\x20deprecated:\x20','stringify','Error:\x20','llm_agent','24721670TrNbPg','apiKey','entries','message','directory','TD_API_KEY','profiles','string','2968695Djvcbh','133777IPGWAA','parent_segment','\x27:\x20config\x20must\x20be\x20an\x20object','lastUsed','api_key','\x20already\x20exists','values','utf-8','includes','description','4926732bArLtT','.\x20Must\x20contain\x20only\x20alphanumeric\x20characters,\x20dash,\x20and\x20underscore.','Please\x20migrate\x20to\x20~/.config/tdx/tdx.json:','from','site','metadata','existsSync','\x22\x20\x22','\x0aWarning:\x20Skipping\x20invalid\x20profile\x20in\x20','readFileSync','\x20\x201.\x20Edit:\x20','\x0aWarning:\x20Using\x20deprecated\x20credential\x20location\x20for\x20profile\x20\x27','local','warn','Invalid\x20profile\x20name:\x20','has','name','\x27:\x20\x27llm_agent\x27\x20must\x20be\x20a\x20string','parse','test','database','Profile\x20','toISOString','\x27:\x20\x27description\x27\x20must\x20be\x20a\x20string','keys','isDirectory','map','2179eQcMsc','16YgzbjC','\x27\x20will\x20be\x20ignored','4093915nMcJqO','Profile\x20\x27','8thaxZr','\x20\x202.\x20Add\x20profiles\x20under\x20a\x20\x22profiles\x22\x20key\x20(see\x20\x27tdx\x20profiles\x27\x20for\x20current\x20config)','.env'];a29_0x24f3=function(){return _0x466b5a;};return a29_0x24f3();}export function loadProfileCredentials(_0x1548e8){const _0x2e1f5d=a29_0x29c9;validateProfileName(_0x1548e8);const _0x1a1b23=getNewCredentialPath(_0x1548e8);if(a29_0x15c894[_0x2e1f5d(0x136)](_0x1a1b23))try{return a29_0x15c894[_0x2e1f5d(0x139)](_0x1a1b23,_0x2e1f5d(0x12d));}catch{}const _0x4590c7=getOldCredentialPath(_0x1548e8);if(a29_0x15c894[_0x2e1f5d(0x136)](_0x4590c7)){console[_0x2e1f5d(0x13d)](_0x2e1f5d(0x13b)+_0x1548e8+'\x27'),console['warn']('To\x20migrate:'),console[_0x2e1f5d(0x13d)]('\x20\x20mv\x20\x22'+_0x4590c7+_0x2e1f5d(0x137)+_0x1a1b23+'\x22'),console[_0x2e1f5d(0x13d)]('Then\x20define\x20profiles\x20in\x20~/.config/tdx/tdx.json\x0a');try{return a29_0x15c894[_0x2e1f5d(0x139)](_0x4590c7,_0x2e1f5d(0x12d));}catch{return null;}}return null;}
@@ -1 +1 @@
1
- const a29_0x551ca1=a29_0x2162;(function(_0x41cf74,_0x3b9d10){const _0x39e036=a29_0x2162,_0x40bbac=_0x41cf74();while(!![]){try{const _0x7be06e=parseInt(_0x39e036(0x1b3))/0x1+-parseInt(_0x39e036(0x1c2))/0x2+-parseInt(_0x39e036(0x1b1))/0x3+parseInt(_0x39e036(0x1c7))/0x4*(parseInt(_0x39e036(0x1ae))/0x5)+-parseInt(_0x39e036(0x1b5))/0x6*(-parseInt(_0x39e036(0x1bb))/0x7)+-parseInt(_0x39e036(0x1b4))/0x8+parseInt(_0x39e036(0x1b8))/0x9;if(_0x7be06e===_0x3b9d10)break;else _0x40bbac['push'](_0x40bbac['shift']());}catch(_0x13bfd4){_0x40bbac['push'](_0x40bbac['shift']());}}}(a29_0x1bce,0x9031f));import*as a29_0x56b0ec from'node:fs';import*as a29_0x48b0c5 from'node:path';function a29_0x2162(_0x312410,_0x26e52b){const _0x1bce7f=a29_0x1bce();return a29_0x2162=function(_0x2162ce,_0x243f0b){_0x2162ce=_0x2162ce-0x1ab;let _0x1c3c12=_0x1bce7f[_0x2162ce];return _0x1c3c12;},a29_0x2162(_0x312410,_0x26e52b);}const PROJECT_CONFIG_FILENAME=a29_0x551ca1(0x1c8);export function findProjectConfigPath(_0x1cd67e){const _0x43c6ba=a29_0x551ca1;let _0x4e58ac=_0x1cd67e||process['cwd']();while(!![]){const _0x5a8d30=a29_0x48b0c5[_0x43c6ba(0x1b2)](_0x4e58ac,PROJECT_CONFIG_FILENAME);if(a29_0x56b0ec[_0x43c6ba(0x1c3)](_0x5a8d30))return _0x5a8d30;const _0x4d0c10=a29_0x48b0c5[_0x43c6ba(0x1ad)](_0x4e58ac);if(_0x4d0c10===_0x4e58ac)return null;_0x4e58ac=_0x4d0c10;}}export function loadProjectConfig(_0x12a43c){const _0x2cefb4=a29_0x551ca1,_0x89cc84=findProjectConfigPath(_0x12a43c);if(!_0x89cc84)return null;try{const _0x4c4c0f=a29_0x56b0ec[_0x2cefb4(0x1c0)](_0x89cc84,'utf-8'),_0x50a3f7=JSON[_0x2cefb4(0x1af)](_0x4c4c0f),_0x4995ce=JSON[_0x2cefb4(0x1c9)](_0x50a3f7);if(_0x4995ce[_0x2cefb4(0x1be)]('TD_API_KEY')||_0x4995ce[_0x2cefb4(0x1be)](_0x2cefb4(0x1b0))||_0x4995ce['includes'](_0x2cefb4(0x1c5)))throw new Error('Security\x20error:\x20API\x20keys\x20must\x20not\x20be\x20stored\x20in\x20project\x20config\x20('+_0x89cc84+_0x2cefb4(0x1b6)+_0x2cefb4(0x1bd));const {metadata:_0x425ce2,profile:_0x3337ca,..._0x4c19ca}=_0x50a3f7;return _0x3337ca&&console[_0x2cefb4(0x1bc)]('Warning:\x20\x27profile\x27\x20field\x20in\x20'+_0x89cc84+'\x20is\x20ignored.\x20'+'Active\x20profile\x20is\x20set\x20in\x20~/.config/tdx/tdx.json'),_0x4c19ca;}catch(_0x3bf7c5){if(_0x3bf7c5 instanceof Error&&_0x2cefb4(0x1b9)in _0x3bf7c5&&_0x3bf7c5[_0x2cefb4(0x1b9)]===_0x2cefb4(0x1c1))return null;throw new Error(_0x2cefb4(0x1b7)+_0x89cc84+':\x20'+_0x3bf7c5);}}export function saveProjectConfig(_0x4c6c59,_0x122f40){const _0x27f6a5=a29_0x551ca1,_0x3915b6=_0x122f40||process[_0x27f6a5(0x1bf)](),_0x5c2ea8=a29_0x48b0c5[_0x27f6a5(0x1b2)](_0x3915b6,PROJECT_CONFIG_FILENAME),_0x1471b4=JSON[_0x27f6a5(0x1c9)](_0x4c6c59);if(_0x1471b4[_0x27f6a5(0x1be)](_0x27f6a5(0x1ba))||_0x1471b4['includes'](_0x27f6a5(0x1b0))||_0x1471b4['includes'](_0x27f6a5(0x1c5)))throw new Error(_0x27f6a5(0x1ab));if(_0x27f6a5(0x1c6)in _0x4c6c59)throw new Error(_0x27f6a5(0x1c4));a29_0x56b0ec[_0x27f6a5(0x1ac)](_0x5c2ea8,JSON[_0x27f6a5(0x1c9)](_0x4c6c59,null,0x2));}function a29_0x1bce(){const _0x5dd2c8=['600448kRZOQM','5324768ZEXXSy','198DxIVBr',').\x20','Failed\x20to\x20load\x20project\x20config\x20from\x20','12977280PRgGoQ','code','TD_API_KEY','117957BRhnen','warn','Use\x20~/.config/tdx/.env\x20or\x20profile\x20.env\x20files\x20instead.','includes','cwd','readFileSync','ENOENT','1494360AFtEex','existsSync','\x27profile\x27\x20should\x20not\x20be\x20set\x20in\x20project\x20config.\x20Use\x20\x27tdx\x20profile\x20use\x27\x20instead.','api_key','profile','2332972axspNp','tdx.json','stringify','API\x20keys\x20must\x20not\x20be\x20stored\x20in\x20project\x20configuration.\x20Use\x20.env\x20files\x20instead.','writeFileSync','dirname','5zPNrYX','parse','apiKey','3534885EhlqvP','join'];a29_0x1bce=function(){return _0x5dd2c8;};return a29_0x1bce();}export function hasProjectConfig(_0xf2e6b6){return findProjectConfigPath(_0xf2e6b6)!==null;}export function getProjectRoot(_0x427399){const _0x54829b=a29_0x551ca1,_0x45ad44=findProjectConfigPath(_0x427399);return _0x45ad44?a29_0x48b0c5[_0x54829b(0x1ad)](_0x45ad44):null;}
1
+ (function(_0x3a9547,_0xa42d83){const _0x274850=a30_0x5886,_0x6fa2e8=_0x3a9547();while(!![]){try{const _0x12f9c9=-parseInt(_0x274850(0x204))/0x1+parseInt(_0x274850(0x202))/0x2+-parseInt(_0x274850(0x1ef))/0x3+parseInt(_0x274850(0x1f0))/0x4+-parseInt(_0x274850(0x1ec))/0x5+parseInt(_0x274850(0x1f4))/0x6*(-parseInt(_0x274850(0x1f8))/0x7)+parseInt(_0x274850(0x1f5))/0x8*(parseInt(_0x274850(0x1ff))/0x9);if(_0x12f9c9===_0xa42d83)break;else _0x6fa2e8['push'](_0x6fa2e8['shift']());}catch(_0x34d422){_0x6fa2e8['push'](_0x6fa2e8['shift']());}}}(a30_0x4dc5,0x1976c));import*as a30_0x712c31 from'node:fs';import*as a30_0x15d6f3 from'node:path';const PROJECT_CONFIG_FILENAME='tdx.json';export function findProjectConfigPath(_0x9ab564){const _0x270a7e=a30_0x5886;let _0x525098=_0x9ab564||process[_0x270a7e(0x1fb)]();while(!![]){const _0x362a25=a30_0x15d6f3[_0x270a7e(0x1ea)](_0x525098,PROJECT_CONFIG_FILENAME);if(a30_0x712c31['existsSync'](_0x362a25))return _0x362a25;const _0x13945a=a30_0x15d6f3[_0x270a7e(0x1e9)](_0x525098);if(_0x13945a===_0x525098)return null;_0x525098=_0x13945a;}}export function loadProjectConfig(_0x413ef6){const _0x4e3399=a30_0x5886,_0x3cd18f=findProjectConfigPath(_0x413ef6);if(!_0x3cd18f)return null;try{const _0x28829e=a30_0x712c31[_0x4e3399(0x1f3)](_0x3cd18f,_0x4e3399(0x1fc)),_0x19f6dc=JSON[_0x4e3399(0x1f7)](_0x28829e),_0x2a07f2=JSON[_0x4e3399(0x1ed)](_0x19f6dc);if(_0x2a07f2[_0x4e3399(0x1eb)](_0x4e3399(0x1ee))||_0x2a07f2['includes'](_0x4e3399(0x201))||_0x2a07f2['includes'](_0x4e3399(0x1fe)))throw new Error('Security\x20error:\x20API\x20keys\x20must\x20not\x20be\x20stored\x20in\x20project\x20config\x20('+_0x3cd18f+_0x4e3399(0x1f1)+'Use\x20~/.config/tdx/.env\x20or\x20profile\x20.env\x20files\x20instead.');const {metadata:_0x3e4a4c,profile:_0x46b542,..._0x37c51d}=_0x19f6dc;return _0x46b542&&console[_0x4e3399(0x203)](_0x4e3399(0x1fa)+_0x3cd18f+_0x4e3399(0x1fd)+'Active\x20profile\x20is\x20set\x20in\x20~/.config/tdx/tdx.json'),_0x37c51d;}catch(_0x5ccb37){if(_0x5ccb37 instanceof Error&&'code'in _0x5ccb37&&_0x5ccb37['code']==='ENOENT')return null;throw new Error(_0x4e3399(0x1f2)+_0x3cd18f+':\x20'+_0x5ccb37);}}function a30_0x5886(_0xf64359,_0x3524b){const _0x4dc532=a30_0x4dc5();return a30_0x5886=function(_0x588685,_0x12044e){_0x588685=_0x588685-0x1e9;let _0x4424a8=_0x4dc532[_0x588685];return _0x4424a8;},a30_0x5886(_0xf64359,_0x3524b);}export function saveProjectConfig(_0x40aae3,_0x11ba5e){const _0x7ed779=a30_0x5886,_0x2cf76b=_0x11ba5e||process[_0x7ed779(0x1fb)](),_0x84ade9=a30_0x15d6f3[_0x7ed779(0x1ea)](_0x2cf76b,PROJECT_CONFIG_FILENAME),_0x27beb5=JSON[_0x7ed779(0x1ed)](_0x40aae3);if(_0x27beb5['includes'](_0x7ed779(0x1ee))||_0x27beb5[_0x7ed779(0x1eb)]('apiKey')||_0x27beb5[_0x7ed779(0x1eb)](_0x7ed779(0x1fe)))throw new Error('API\x20keys\x20must\x20not\x20be\x20stored\x20in\x20project\x20configuration.\x20Use\x20.env\x20files\x20instead.');if(_0x7ed779(0x1f9)in _0x40aae3)throw new Error(_0x7ed779(0x200));a30_0x712c31[_0x7ed779(0x1f6)](_0x84ade9,JSON['stringify'](_0x40aae3,null,0x2));}export function hasProjectConfig(_0xc34833){return findProjectConfigPath(_0xc34833)!==null;}export function getProjectRoot(_0x3573a1){const _0x8d9275=findProjectConfigPath(_0x3573a1);return _0x8d9275?a30_0x15d6f3['dirname'](_0x8d9275):null;}function a30_0x4dc5(){const _0x54b385=['550542nVqMKN','574908cuORLu',').\x20','Failed\x20to\x20load\x20project\x20config\x20from\x20','readFileSync','332358EckoUL','40GwqDHg','writeFileSync','parse','7CXDWMj','profile','Warning:\x20\x27profile\x27\x20field\x20in\x20','cwd','utf-8','\x20is\x20ignored.\x20','api_key','825633kzEEYc','\x27profile\x27\x20should\x20not\x20be\x20set\x20in\x20project\x20config.\x20Use\x20\x27tdx\x20profile\x20use\x27\x20instead.','apiKey','198448VoAlHs','warn','171463YPNCar','dirname','join','includes','934830KwFzEu','stringify','TD_API_KEY'];a30_0x4dc5=function(){return _0x54b385;};return a30_0x4dc5();}
@@ -1 +1 @@
1
- (function(_0x3086fd,_0x314beb){const _0x388b4e=a30_0x3641,_0x4f6f81=_0x3086fd();while(!![]){try{const _0xc6f0de=-parseInt(_0x388b4e(0x1cb))/0x1+-parseInt(_0x388b4e(0x1a9))/0x2+-parseInt(_0x388b4e(0x1a7))/0x3*(parseInt(_0x388b4e(0x1b5))/0x4)+-parseInt(_0x388b4e(0x1a8))/0x5+-parseInt(_0x388b4e(0x1a6))/0x6*(-parseInt(_0x388b4e(0x1ce))/0x7)+-parseInt(_0x388b4e(0x1b9))/0x8+parseInt(_0x388b4e(0x1ad))/0x9;if(_0xc6f0de===_0x314beb)break;else _0x4f6f81['push'](_0x4f6f81['shift']());}catch(_0x87eeb3){_0x4f6f81['push'](_0x4f6f81['shift']());}}}(a30_0x3bc7,0xebc7a));import*as a30_0x5a32fa from'node:fs';import*as a30_0x722665 from'node:path';import*as a30_0x373acb from'node:os';import{getPPID,isProcessRunning}from'../utils/process.js';import{createSecureDirectory}from'../utils/file-permissions.js';const SESSION_EXPIRATION_MS=0x18*0x3c*0x3c*0x3e8;function a30_0x3641(_0x6ef845,_0x3a0da8){const _0x3bc7cf=a30_0x3bc7();return a30_0x3641=function(_0x3641b3,_0x1d9bd6){_0x3641b3=_0x3641b3-0x1a5;let _0x546d9f=_0x3bc7cf[_0x3641b3];return _0x546d9f;},a30_0x3641(_0x6ef845,_0x3a0da8);}function getSessionsDir(){const _0xde851f=a30_0x3641,_0x359d8d=process[_0xde851f(0x1aa)][_0xde851f(0x1cf)]||a30_0x722665[_0xde851f(0x1b1)](a30_0x373acb[_0xde851f(0x1b4)](),_0xde851f(0x1c1),_0xde851f(0x1c7));return a30_0x722665[_0xde851f(0x1b1)](_0x359d8d,_0xde851f(0x1c3));}function getSessionPath(_0x408c6d){const _0x3a2fa4=a30_0x3641;return a30_0x722665[_0x3a2fa4(0x1b1)](getSessionsDir(),_0x408c6d+'.json');}export function getCurrentSessionPID(){return getPPID();}export function getSessionID(_0x3f678b){const _0xc6f3cc=a30_0x3641;if(_0x3f678b)return _0x3f678b;return getCurrentSessionPID()[_0xc6f3cc(0x1b2)]();}function a30_0x3bc7(){const _0x3dc24c=['writeFileSync','sessions','api_key','stringify','endsWith','tdx','parse','utf-8','apiKey','910690ISmUfH','createdAt','push','4688838vaDFDp','TDX_CONFIG_DIR','Warning:\x20API\x20keys\x20found\x20in\x20session\x20file\x20','12IjpIiP','3ujllSl','3289130IRRJuE','3096212oasunC','env','warn','replace','45971091JRSPvG','.json','includes','now','join','toString','TD_API_KEY','homedir','5875572GtpKnT','readFileSync','API\x20keys\x20must\x20not\x20be\x20stored\x20in\x20session\x20context.\x20Use\x20.env\x20files\x20instead.','toISOString','7170384WaTPeh','unlinkSync','readdirSync','existsSync','.\x20This\x20is\x20insecure.\x20Removing\x20session.','test','getTime','sort','.config'];a30_0x3bc7=function(){return _0x3dc24c;};return a30_0x3bc7();}export function loadSessionContext(_0x53f4cb){const _0x1f1d82=a30_0x3641,_0x47e5d3=_0x53f4cb||getCurrentSessionPID()[_0x1f1d82(0x1b2)](),_0x1fb9aa=/^\d+$/[_0x1f1d82(0x1be)](_0x47e5d3)?parseInt(_0x47e5d3,0xa):null;return _0x1fb9aa!==null?loadSessionContextByPID(_0x1fb9aa):loadSessionContextByString(_0x47e5d3);}export function loadSessionContextByPID(_0x542e3e){const _0x43e28c=a30_0x3641,_0x299ec9=getSessionPath(_0x542e3e);if(!a30_0x5a32fa['existsSync'](_0x299ec9))return null;try{const _0x28dfe4=a30_0x5a32fa[_0x43e28c(0x1b6)](_0x299ec9,_0x43e28c(0x1c9)),_0x2968dd=JSON[_0x43e28c(0x1c8)](_0x28dfe4),_0x4ff37c=new Date(_0x2968dd[_0x43e28c(0x1cc)])['getTime'](),_0x3d45e1=Date[_0x43e28c(0x1b0)]();if(_0x3d45e1-_0x4ff37c>SESSION_EXPIRATION_MS)return a30_0x5a32fa[_0x43e28c(0x1ba)](_0x299ec9),null;const _0x338d61=JSON['stringify'](_0x2968dd);if(_0x338d61[_0x43e28c(0x1af)]('TD_API_KEY')||_0x338d61['includes'](_0x43e28c(0x1ca))||_0x338d61[_0x43e28c(0x1af)](_0x43e28c(0x1c4)))return console[_0x43e28c(0x1ab)](_0x43e28c(0x1a5)+_0x299ec9+'.\x20This\x20is\x20insecure.\x20Removing\x20session.'),a30_0x5a32fa[_0x43e28c(0x1ba)](_0x299ec9),null;return _0x2968dd;}catch{try{a30_0x5a32fa[_0x43e28c(0x1ba)](_0x299ec9);}catch{}return null;}}function loadSessionContextByString(_0x39fb4e){const _0x5da6f0=a30_0x3641,_0x1bfb8c=a30_0x722665['join'](getSessionsDir(),_0x39fb4e+'.json');if(!a30_0x5a32fa[_0x5da6f0(0x1bc)](_0x1bfb8c))return null;try{const _0x2767a5=a30_0x5a32fa[_0x5da6f0(0x1b6)](_0x1bfb8c,_0x5da6f0(0x1c9)),_0x18dcf6=JSON['parse'](_0x2767a5),_0x2d1c98=new Date(_0x18dcf6[_0x5da6f0(0x1cc)])[_0x5da6f0(0x1bf)](),_0x4c01d2=Date[_0x5da6f0(0x1b0)]();if(_0x4c01d2-_0x2d1c98>SESSION_EXPIRATION_MS)return a30_0x5a32fa[_0x5da6f0(0x1ba)](_0x1bfb8c),null;const _0xc5dfd5=JSON['stringify'](_0x18dcf6);if(_0xc5dfd5[_0x5da6f0(0x1af)](_0x5da6f0(0x1b3))||_0xc5dfd5[_0x5da6f0(0x1af)](_0x5da6f0(0x1ca))||_0xc5dfd5[_0x5da6f0(0x1af)](_0x5da6f0(0x1c4)))return console[_0x5da6f0(0x1ab)](_0x5da6f0(0x1a5)+_0x1bfb8c+_0x5da6f0(0x1bd)),a30_0x5a32fa[_0x5da6f0(0x1ba)](_0x1bfb8c),null;return _0x18dcf6;}catch{try{a30_0x5a32fa[_0x5da6f0(0x1ba)](_0x1bfb8c);}catch{}return null;}}export function saveSessionContext(_0x2f6782,_0x391091){const _0x5694ef=a30_0x3641,_0x1a7434=_0x391091||getCurrentSessionPID()[_0x5694ef(0x1b2)](),_0x21d8c8=/^\d+$/[_0x5694ef(0x1be)](_0x1a7434)?parseInt(_0x1a7434,0xa):getCurrentSessionPID(),_0x1ba8bf=a30_0x722665[_0x5694ef(0x1b1)](getSessionsDir(),_0x1a7434+_0x5694ef(0x1ae)),_0x42b99c=getSessionsDir();createSecureDirectory(_0x42b99c);const _0x4eba8e=JSON[_0x5694ef(0x1c5)](_0x2f6782);if(_0x4eba8e[_0x5694ef(0x1af)](_0x5694ef(0x1b3))||_0x4eba8e[_0x5694ef(0x1af)](_0x5694ef(0x1ca))||_0x4eba8e[_0x5694ef(0x1af)]('api_key'))throw new Error(_0x5694ef(0x1b7));let _0x4aecc7;const _0x246a84=/^\d+$/[_0x5694ef(0x1be)](_0x1a7434)?loadSessionContextByPID(parseInt(_0x1a7434,0xa)):loadSessionContextByString(_0x1a7434);_0x246a84?_0x4aecc7={..._0x246a84,..._0x2f6782,'pid':_0x21d8c8,'sessionId':_0x1a7434!==_0x21d8c8[_0x5694ef(0x1b2)]()?_0x1a7434:undefined,'updatedAt':new Date()[_0x5694ef(0x1b8)]()}:_0x4aecc7={'pid':_0x21d8c8,'sessionId':_0x1a7434!==_0x21d8c8['toString']()?_0x1a7434:undefined,..._0x2f6782,'createdAt':new Date()[_0x5694ef(0x1b8)](),'updatedAt':new Date()['toISOString']()},a30_0x5a32fa[_0x5694ef(0x1c2)](_0x1ba8bf,JSON[_0x5694ef(0x1c5)](_0x4aecc7,null,0x2));}export function clearSessionContext(_0x53587e){const _0xf55945=a30_0x3641,_0x53acaa=_0x53587e||getCurrentSessionPID()[_0xf55945(0x1b2)](),_0x1e103b=a30_0x722665[_0xf55945(0x1b1)](getSessionsDir(),_0x53acaa+'.json');a30_0x5a32fa['existsSync'](_0x1e103b)&&a30_0x5a32fa[_0xf55945(0x1ba)](_0x1e103b);}export function cleanExpiredSessions(){const _0xe579a0=a30_0x3641,_0x178a2d=getSessionsDir();if(!a30_0x5a32fa[_0xe579a0(0x1bc)](_0x178a2d))return 0x0;let _0x4fa830=0x0;const _0xeb6d71=Date['now']();try{const _0x357b04=a30_0x5a32fa['readdirSync'](_0x178a2d);for(const _0x1f3e45 of _0x357b04){if(!_0x1f3e45['endsWith']('.json'))continue;const _0x90f421=a30_0x722665['join'](_0x178a2d,_0x1f3e45),_0x4f81f7=_0x1f3e45[_0xe579a0(0x1ac)](_0xe579a0(0x1ae),''),_0x3aa11e=parseInt(_0x4f81f7,0xa),_0x31b94d=!isNaN(_0x3aa11e);if(_0x31b94d){if(!isProcessRunning(_0x3aa11e)){a30_0x5a32fa[_0xe579a0(0x1ba)](_0x90f421),_0x4fa830++;continue;}}try{const _0x14962f=a30_0x5a32fa[_0xe579a0(0x1b6)](_0x90f421,_0xe579a0(0x1c9)),_0x5843b5=JSON['parse'](_0x14962f),_0x5a7ef4=new Date(_0x5843b5[_0xe579a0(0x1cc)])[_0xe579a0(0x1bf)]();_0xeb6d71-_0x5a7ef4>SESSION_EXPIRATION_MS&&(a30_0x5a32fa[_0xe579a0(0x1ba)](_0x90f421),_0x4fa830++);}catch{a30_0x5a32fa[_0xe579a0(0x1ba)](_0x90f421),_0x4fa830++;}}}catch{}return _0x4fa830;}export function listActiveSessions(){const _0x1dd4b9=a30_0x3641,_0x1660b8=getSessionsDir();if(!a30_0x5a32fa[_0x1dd4b9(0x1bc)](_0x1660b8))return[];try{const _0x3d22a9=a30_0x5a32fa[_0x1dd4b9(0x1bb)](_0x1660b8),_0x36588f=[];for(const _0x44d8a9 of _0x3d22a9){if(!_0x44d8a9[_0x1dd4b9(0x1c6)](_0x1dd4b9(0x1ae)))continue;const _0x311280=_0x44d8a9['replace'](_0x1dd4b9(0x1ae),''),_0x5c06f4=parseInt(_0x311280,0xa);!isNaN(_0x5c06f4)&&isProcessRunning(_0x5c06f4)&&_0x36588f[_0x1dd4b9(0x1cd)](_0x5c06f4);}return _0x36588f[_0x1dd4b9(0x1c0)]((_0x5cf6a9,_0x587b3a)=>_0x5cf6a9-_0x587b3a);}catch{return[];}}
1
+ (function(_0x43c2cf,_0x54e35e){const _0x32688a=a31_0x49b8,_0x139faa=_0x43c2cf();while(!![]){try{const _0xcea637=parseInt(_0x32688a(0x103))/0x1+parseInt(_0x32688a(0xfc))/0x2*(parseInt(_0x32688a(0xf3))/0x3)+-parseInt(_0x32688a(0xee))/0x4+-parseInt(_0x32688a(0xfe))/0x5+-parseInt(_0x32688a(0xe9))/0x6+parseInt(_0x32688a(0x100))/0x7*(parseInt(_0x32688a(0x106))/0x8)+parseInt(_0x32688a(0xe8))/0x9;if(_0xcea637===_0x54e35e)break;else _0x139faa['push'](_0x139faa['shift']());}catch(_0x5a0f02){_0x139faa['push'](_0x139faa['shift']());}}}(a31_0x444f,0xf39c6));import*as a31_0x15f5f7 from'node:fs';import*as a31_0x47dd4f from'node:path';import*as a31_0x1a5c37 from'node:os';import{getPPID,isProcessRunning}from'../utils/process.js';import{createSecureDirectory}from'../utils/file-permissions.js';const SESSION_EXPIRATION_MS=0x18*0x3c*0x3c*0x3e8;function getSessionsDir(){const _0x7f8187=a31_0x49b8,_0x360228=process[_0x7f8187(0xf1)][_0x7f8187(0xea)]||a31_0x47dd4f[_0x7f8187(0xfd)](a31_0x1a5c37[_0x7f8187(0xfa)](),_0x7f8187(0xf2),_0x7f8187(0x109));return a31_0x47dd4f[_0x7f8187(0xfd)](_0x360228,_0x7f8187(0xf6));}function a31_0x444f(){const _0x102382=['warn','6895324LRENfz','API\x20keys\x20must\x20not\x20be\x20stored\x20in\x20session\x20context.\x20Use\x20.env\x20files\x20instead.','createdAt','env','.config','3WDlEZS','existsSync','parse','sessions','unlinkSync','TD_API_KEY','readFileSync','homedir','push','3067058ZOVvPk','join','7792620JGBhyt','toString','62979BHbwjh','test','sort','337719pRGXqU','now','writeFileSync','8vWdfxx','readdirSync','toISOString','tdx','.\x20This\x20is\x20insecure.\x20Removing\x20session.','utf-8','replace','Warning:\x20API\x20keys\x20found\x20in\x20session\x20file\x20','apiKey','stringify','getTime','api_key','39193911aFYyEM','11729634hNZsTL','TDX_CONFIG_DIR','.json','includes'];a31_0x444f=function(){return _0x102382;};return a31_0x444f();}function getSessionPath(_0x4453ca){const _0x3b4e5c=a31_0x49b8;return a31_0x47dd4f[_0x3b4e5c(0xfd)](getSessionsDir(),_0x4453ca+_0x3b4e5c(0xeb));}export function getCurrentSessionPID(){return getPPID();}export function getSessionID(_0x12495a){const _0x2dc948=a31_0x49b8;if(_0x12495a)return _0x12495a;return getCurrentSessionPID()[_0x2dc948(0xff)]();}export function loadSessionContext(_0x547adb){const _0x5c899d=a31_0x49b8,_0x5b5ab0=_0x547adb||getCurrentSessionPID()[_0x5c899d(0xff)](),_0x50d898=/^\d+$/[_0x5c899d(0x101)](_0x5b5ab0)?parseInt(_0x5b5ab0,0xa):null;return _0x50d898!==null?loadSessionContextByPID(_0x50d898):loadSessionContextByString(_0x5b5ab0);}export function loadSessionContextByPID(_0x2cce5f){const _0x4dcb38=a31_0x49b8,_0x1e2551=getSessionPath(_0x2cce5f);if(!a31_0x15f5f7['existsSync'](_0x1e2551))return null;try{const _0x1b4a6a=a31_0x15f5f7[_0x4dcb38(0xf9)](_0x1e2551,_0x4dcb38(0xe1)),_0x4be0a2=JSON[_0x4dcb38(0xf5)](_0x1b4a6a),_0x17ce73=new Date(_0x4be0a2[_0x4dcb38(0xf0)])[_0x4dcb38(0xe6)](),_0x2a4776=Date[_0x4dcb38(0x104)]();if(_0x2a4776-_0x17ce73>SESSION_EXPIRATION_MS)return a31_0x15f5f7[_0x4dcb38(0xf7)](_0x1e2551),null;const _0x4553bb=JSON[_0x4dcb38(0xe5)](_0x4be0a2);if(_0x4553bb['includes'](_0x4dcb38(0xf8))||_0x4553bb['includes'](_0x4dcb38(0xe4))||_0x4553bb['includes'](_0x4dcb38(0xe7)))return console['warn'](_0x4dcb38(0xe3)+_0x1e2551+_0x4dcb38(0xe0)),a31_0x15f5f7[_0x4dcb38(0xf7)](_0x1e2551),null;return _0x4be0a2;}catch{try{a31_0x15f5f7[_0x4dcb38(0xf7)](_0x1e2551);}catch{}return null;}}function loadSessionContextByString(_0x3c3ddd){const _0x33efc0=a31_0x49b8,_0x305301=a31_0x47dd4f[_0x33efc0(0xfd)](getSessionsDir(),_0x3c3ddd+_0x33efc0(0xeb));if(!a31_0x15f5f7['existsSync'](_0x305301))return null;try{const _0x212c2b=a31_0x15f5f7[_0x33efc0(0xf9)](_0x305301,_0x33efc0(0xe1)),_0xddbd60=JSON[_0x33efc0(0xf5)](_0x212c2b),_0x44cbe5=new Date(_0xddbd60[_0x33efc0(0xf0)])[_0x33efc0(0xe6)](),_0x2a5700=Date[_0x33efc0(0x104)]();if(_0x2a5700-_0x44cbe5>SESSION_EXPIRATION_MS)return a31_0x15f5f7[_0x33efc0(0xf7)](_0x305301),null;const _0x31e776=JSON[_0x33efc0(0xe5)](_0xddbd60);if(_0x31e776[_0x33efc0(0xec)](_0x33efc0(0xf8))||_0x31e776[_0x33efc0(0xec)]('apiKey')||_0x31e776[_0x33efc0(0xec)]('api_key'))return console[_0x33efc0(0xed)](_0x33efc0(0xe3)+_0x305301+_0x33efc0(0xe0)),a31_0x15f5f7[_0x33efc0(0xf7)](_0x305301),null;return _0xddbd60;}catch{try{a31_0x15f5f7[_0x33efc0(0xf7)](_0x305301);}catch{}return null;}}export function saveSessionContext(_0x2a5a75,_0x11585b){const _0x4407d4=a31_0x49b8,_0x467ecf=_0x11585b||getCurrentSessionPID()['toString'](),_0x2447e4=/^\d+$/[_0x4407d4(0x101)](_0x467ecf)?parseInt(_0x467ecf,0xa):getCurrentSessionPID(),_0x47c481=a31_0x47dd4f[_0x4407d4(0xfd)](getSessionsDir(),_0x467ecf+_0x4407d4(0xeb)),_0x59a606=getSessionsDir();createSecureDirectory(_0x59a606);const _0x11141b=JSON['stringify'](_0x2a5a75);if(_0x11141b[_0x4407d4(0xec)](_0x4407d4(0xf8))||_0x11141b['includes'](_0x4407d4(0xe4))||_0x11141b['includes']('api_key'))throw new Error(_0x4407d4(0xef));let _0x20db9f;const _0x339d0b=/^\d+$/['test'](_0x467ecf)?loadSessionContextByPID(parseInt(_0x467ecf,0xa)):loadSessionContextByString(_0x467ecf);_0x339d0b?_0x20db9f={..._0x339d0b,..._0x2a5a75,'pid':_0x2447e4,'sessionId':_0x467ecf!==_0x2447e4[_0x4407d4(0xff)]()?_0x467ecf:undefined,'updatedAt':new Date()[_0x4407d4(0x108)]()}:_0x20db9f={'pid':_0x2447e4,'sessionId':_0x467ecf!==_0x2447e4[_0x4407d4(0xff)]()?_0x467ecf:undefined,..._0x2a5a75,'createdAt':new Date()[_0x4407d4(0x108)](),'updatedAt':new Date()['toISOString']()},a31_0x15f5f7[_0x4407d4(0x105)](_0x47c481,JSON[_0x4407d4(0xe5)](_0x20db9f,null,0x2));}function a31_0x49b8(_0x31e240,_0x521a8a){const _0x444f21=a31_0x444f();return a31_0x49b8=function(_0x49b875,_0x525c83){_0x49b875=_0x49b875-0xe0;let _0x546b7f=_0x444f21[_0x49b875];return _0x546b7f;},a31_0x49b8(_0x31e240,_0x521a8a);}export function clearSessionContext(_0x44dd29){const _0x2f701a=a31_0x49b8,_0x428d83=_0x44dd29||getCurrentSessionPID()[_0x2f701a(0xff)](),_0x410431=a31_0x47dd4f[_0x2f701a(0xfd)](getSessionsDir(),_0x428d83+_0x2f701a(0xeb));a31_0x15f5f7[_0x2f701a(0xf4)](_0x410431)&&a31_0x15f5f7[_0x2f701a(0xf7)](_0x410431);}export function cleanExpiredSessions(){const _0x18bd3d=a31_0x49b8,_0x4e6d91=getSessionsDir();if(!a31_0x15f5f7['existsSync'](_0x4e6d91))return 0x0;let _0x56fdae=0x0;const _0x2c2f73=Date['now']();try{const _0x365682=a31_0x15f5f7['readdirSync'](_0x4e6d91);for(const _0x4dcf02 of _0x365682){if(!_0x4dcf02['endsWith'](_0x18bd3d(0xeb)))continue;const _0x1a5f86=a31_0x47dd4f['join'](_0x4e6d91,_0x4dcf02),_0x2d3955=_0x4dcf02[_0x18bd3d(0xe2)](_0x18bd3d(0xeb),''),_0x790d=parseInt(_0x2d3955,0xa),_0x546461=!isNaN(_0x790d);if(_0x546461){if(!isProcessRunning(_0x790d)){a31_0x15f5f7[_0x18bd3d(0xf7)](_0x1a5f86),_0x56fdae++;continue;}}try{const _0x9af893=a31_0x15f5f7['readFileSync'](_0x1a5f86,_0x18bd3d(0xe1)),_0x4b3e65=JSON[_0x18bd3d(0xf5)](_0x9af893),_0x369f76=new Date(_0x4b3e65[_0x18bd3d(0xf0)])['getTime']();_0x2c2f73-_0x369f76>SESSION_EXPIRATION_MS&&(a31_0x15f5f7[_0x18bd3d(0xf7)](_0x1a5f86),_0x56fdae++);}catch{a31_0x15f5f7['unlinkSync'](_0x1a5f86),_0x56fdae++;}}}catch{}return _0x56fdae;}export function listActiveSessions(){const _0x64c876=a31_0x49b8,_0x454388=getSessionsDir();if(!a31_0x15f5f7[_0x64c876(0xf4)](_0x454388))return[];try{const _0x18b3b3=a31_0x15f5f7[_0x64c876(0x107)](_0x454388),_0x1cf697=[];for(const _0x341254 of _0x18b3b3){if(!_0x341254['endsWith'](_0x64c876(0xeb)))continue;const _0x11682b=_0x341254['replace']('.json',''),_0x22ba2a=parseInt(_0x11682b,0xa);!isNaN(_0x22ba2a)&&isProcessRunning(_0x22ba2a)&&_0x1cf697[_0x64c876(0xfb)](_0x22ba2a);}return _0x1cf697[_0x64c876(0x102)]((_0x33536b,_0x1d4dff)=>_0x33536b-_0x1d4dff);}catch{return[];}}
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- (function(_0x2faf8e,_0x36aa61){var _0x4e0e6a=a31_0x1e9f,_0x525d21=_0x2faf8e();while(!![]){try{var _0x3de76a=parseInt(_0x4e0e6a(0x156))/0x1+-parseInt(_0x4e0e6a(0x157))/0x2+-parseInt(_0x4e0e6a(0x15b))/0x3+-parseInt(_0x4e0e6a(0x15a))/0x4+parseInt(_0x4e0e6a(0x159))/0x5*(parseInt(_0x4e0e6a(0x158))/0x6)+parseInt(_0x4e0e6a(0x15c))/0x7+parseInt(_0x4e0e6a(0x155))/0x8*(parseInt(_0x4e0e6a(0x154))/0x9);if(_0x3de76a===_0x36aa61)break;else _0x525d21['push'](_0x525d21['shift']());}catch(_0x467010){_0x525d21['push'](_0x525d21['shift']());}}}(a31_0x2627,0x8f8ef));export*from'./types/index.js';export*from'./core/config.js';export*from'./core/auth.js';export*from'./client/http-client.js';export*from'./client/td-client.js';export{TrinoClient}from'./client/trino-client.js';export*from'./client/rate-limiter.js';export*from'./types/trino.js';export*from'./commands/command.js';export*from'./commands/query-command.js';export*from'./commands/databases.js';function a31_0x1e9f(_0x3c4456,_0x58d52f){var _0x2627d9=a31_0x2627();return a31_0x1e9f=function(_0x1e9f42,_0x233c41){_0x1e9f42=_0x1e9f42-0x154;var _0x167ccc=_0x2627d9[_0x1e9f42];return _0x167ccc;},a31_0x1e9f(_0x3c4456,_0x58d52f);}export*from'./commands/tables.js';export*from'./commands/segments.js';export*from'./commands/activations.js';function a31_0x2627(){var _0x177193=['948QFgfWB','25195flLptU','3368288xttKSe','1136655jfmHbM','1274497IfdtnS','400167ZvoBSS','136HmlCNk','142863Mffthy','135990TiquZh'];a31_0x2627=function(){return _0x177193;};return a31_0x2627();}export*from'./commands/show.js';export*from'./commands/describe.js';export*from'./sdk/index.js';
1
+ (function(_0x12739,_0x455d1e){var _0x1f92a4=a32_0x242d,_0x118907=_0x12739();while(!![]){try{var _0x4a6d5a=-parseInt(_0x1f92a4(0x122))/0x1*(-parseInt(_0x1f92a4(0x124))/0x2)+parseInt(_0x1f92a4(0x129))/0x3*(-parseInt(_0x1f92a4(0x12a))/0x4)+-parseInt(_0x1f92a4(0x127))/0x5+-parseInt(_0x1f92a4(0x128))/0x6*(parseInt(_0x1f92a4(0x120))/0x7)+-parseInt(_0x1f92a4(0x11f))/0x8*(parseInt(_0x1f92a4(0x123))/0x9)+-parseInt(_0x1f92a4(0x126))/0xa+parseInt(_0x1f92a4(0x121))/0xb*(parseInt(_0x1f92a4(0x125))/0xc);if(_0x4a6d5a===_0x455d1e)break;else _0x118907['push'](_0x118907['shift']());}catch(_0x17442f){_0x118907['push'](_0x118907['shift']());}}}(a32_0x158f,0xd23b5));export*from'./types/index.js';export*from'./core/config.js';function a32_0x242d(_0x1d4833,_0x106add){var _0x158fb5=a32_0x158f();return a32_0x242d=function(_0x242dfa,_0x247113){_0x242dfa=_0x242dfa-0x11f;var _0x55d473=_0x158fb5[_0x242dfa];return _0x55d473;},a32_0x242d(_0x1d4833,_0x106add);}export*from'./core/auth.js';export*from'./client/http-client.js';function a32_0x158f(){var _0x3f893c=['2224gadMGS','1060872wrJOmW','1498TBqjqR','12914LXnotd','6037EqNeqC','27JiKJdu','38Kconve','39516asHSiX','2592970ToMhwg','8557510PvyjQk','6978RwXDLl','2709qeegWY'];a32_0x158f=function(){return _0x3f893c;};return a32_0x158f();}export*from'./client/td-client.js';export{TrinoClient}from'./client/trino-client.js';export*from'./client/rate-limiter.js';export*from'./types/trino.js';export*from'./commands/command.js';export*from'./commands/query-command.js';export*from'./commands/databases.js';export*from'./commands/tables.js';export*from'./commands/segments.js';export*from'./commands/activations.js';export*from'./commands/show.js';export*from'./commands/describe.js';export*from'./sdk/index.js';
@@ -1 +1 @@
1
- (function(_0xcaad48,_0x4f5e4c){const _0x525732=a32_0x4ce8,_0x5e2599=_0xcaad48();while(!![]){try{const _0x33da04=-parseInt(_0x525732(0x11a))/0x1*(parseInt(_0x525732(0x12a))/0x2)+parseInt(_0x525732(0x15f))/0x3*(-parseInt(_0x525732(0x121))/0x4)+-parseInt(_0x525732(0x145))/0x5*(parseInt(_0x525732(0x13e))/0x6)+parseInt(_0x525732(0x13d))/0x7+parseInt(_0x525732(0x13c))/0x8+-parseInt(_0x525732(0x11b))/0x9*(-parseInt(_0x525732(0x12d))/0xa)+parseInt(_0x525732(0x14a))/0xb;if(_0x33da04===_0x4f5e4c)break;else _0x5e2599['push'](_0x5e2599['shift']());}catch(_0x25d076){_0x5e2599['push'](_0x5e2599['shift']());}}}(a32_0x3303,0xed1e1));function generateMessageId(){const _0x1a4314=a32_0x4ce8;return _0x1a4314(0x137)+Math[_0x1a4314(0x155)]()[_0x1a4314(0x156)](0x24)[_0x1a4314(0x11c)](0x2,0xf)+Math['random']()[_0x1a4314(0x156)](0x24)['substring'](0x2,0xf);}export function extractTextFromAnthropicMessage(_0x198fe3){const _0x133e7f=a32_0x4ce8;if(typeof _0x198fe3[_0x133e7f(0x15d)]===_0x133e7f(0x164))return _0x198fe3[_0x133e7f(0x15d)];return _0x198fe3[_0x133e7f(0x15d)][_0x133e7f(0x13f)](_0x394466=>_0x394466[_0x133e7f(0x147)]===_0x133e7f(0x123)&&_0x394466[_0x133e7f(0x123)])['map'](_0x3ecea2=>_0x3ecea2[_0x133e7f(0x123)])[_0x133e7f(0x14b)]('\x0a');}export function calculateConversationDelta(_0x218bc6,_0x26c28c){const _0x77b663=a32_0x4ce8;if(_0x26c28c[_0x77b663(0x128)]===0x0)return _0x218bc6;const _0x49b21a=_0x26c28c['length'];return _0x218bc6[_0x77b663(0x150)](_0x49b21a);}export function transformAnthropicRequestToTD(_0x2cf423,_0x2273b1){const _0x5817e1=a32_0x4ce8,_0x95d829=calculateConversationDelta(_0x2cf423[_0x5817e1(0x138)],_0x2273b1),_0x31b745=_0x95d829[_0x5817e1(0x13f)](_0xa22983=>_0xa22983['role']===_0x5817e1(0x140))[_0x5817e1(0x157)]();if(!_0x31b745)throw new Error(_0x5817e1(0x124));const _0x41b90c=extractTextFromAnthropicMessage(_0x31b745);return{'userMessage':_0x41b90c,'deltaMessages':_0x95d829};}export async function*transformTDStreamToAnthropic(_0x2d0bac,_0x483b44,_0x1e87b1){const _0x3d9797=a32_0x4ce8;let _0xb0d707=0x0,_0x1a3a1c=0x0,_0x34b86b=0x0,_0x46258b=![];const _0x541f26={'type':_0x3d9797(0x15a),'message':{'id':_0x483b44,'type':_0x3d9797(0x13a),'role':_0x3d9797(0x142),'content':[],'model':_0x1e87b1,'stop_reason':null,'stop_sequence':null,'usage':{'input_tokens':_0xb0d707,'output_tokens':0x0}}};yield _0x541f26;for await(const _0x28e3a8 of _0x2d0bac){if(_0x3d9797(0x15d)in _0x28e3a8){const _0x33c57a=_0x28e3a8;if(!_0x46258b){const _0x52f463={'type':'content_block_start','index':_0x34b86b,'content_block':{'type':_0x3d9797(0x123),'text':''}};yield _0x52f463,_0x46258b=!![];}const _0x592723={'type':_0x3d9797(0x139),'index':_0x34b86b,'delta':{'type':_0x3d9797(0x165),'text':_0x33c57a[_0x3d9797(0x15d)]}};yield _0x592723,_0x1a3a1c+=Math[_0x3d9797(0x122)](_0x33c57a['content'][_0x3d9797(0x128)]/0x4);}else{if('tool_call'in _0x28e3a8){const _0x58a466=_0x28e3a8;console[_0x3d9797(0x12f)](_0x3d9797(0x14d),_0x58a466);}else{if('error'in _0x28e3a8){const _0x182f50=_0x28e3a8;yield{'type':_0x3d9797(0x167),'error':{'type':_0x3d9797(0x16a),'message':_0x182f50[_0x3d9797(0x167)]}};return;}}}}if(_0x46258b){const _0x57f058={'type':_0x3d9797(0x146),'index':_0x34b86b};yield _0x57f058;}const _0x3e9df7={'type':_0x3d9797(0x161),'delta':{'stop_reason':'end_turn','stop_sequence':null},'usage':{'output_tokens':_0x1a3a1c}};yield _0x3e9df7;const _0x424e19={'type':_0x3d9797(0x14c)};yield _0x424e19;}export function formatAnthropicSSE(_0x1c723a){const _0x534089=a32_0x4ce8;return'event:\x20'+_0x1c723a[_0x534089(0x147)]+_0x534089(0x151)+JSON[_0x534089(0x14f)](_0x1c723a)+'\x0a\x0a';}export function mapAnthropicModelToTD(_0x264811){const _0x473496=a32_0x4ce8,_0x38f856={'sonnet':_0x473496(0x120),'claude-sonnet':_0x473496(0x120),'claude-3-5-sonnet':_0x473496(0x120),'claude-3-sonnet':'sonnet','haiku':_0x473496(0x11e),'claude-haiku':'haiku','claude-3-5-haiku':_0x473496(0x11e),'claude-3-haiku':'haiku','opus':'opus','claude-opus':_0x473496(0x154),'claude-3-opus':_0x473496(0x154)},_0x2e5b3a=_0x264811[_0x473496(0x168)]();return _0x38f856[_0x2e5b3a]||_0x473496(0x120);}export function generateToolPrompt(_0x576242){const _0x1d10e7=a32_0x4ce8;if(!_0x576242||_0x576242[_0x1d10e7(0x128)]===0x0)return'';const _0x4c7980=_0x576242['map'](_0x1e3b28=>{const _0x4f3872=_0x1d10e7,_0xb80d4f=_0x1e3b28[_0x4f3872(0x152)][_0x4f3872(0x143)]?Object[_0x4f3872(0x134)](_0x1e3b28['input_schema'][_0x4f3872(0x143)])[_0x4f3872(0x130)](([_0x14e982,_0x3d89ac])=>{const _0x276d08=_0x4f3872,_0x460ecb=_0x1e3b28['input_schema']['required']?.[_0x276d08(0x148)](_0x14e982)?_0x276d08(0x144):'',_0x41622f=_0x3d89ac,_0x41db35=_0x41622f['description']?':\x20'+_0x41622f[_0x276d08(0x136)]:'';return'\x20\x20\x20\x20-\x20'+_0x14e982+_0x460ecb+_0x41db35;})[_0x4f3872(0x14b)]('\x0a'):_0x4f3872(0x11f);return'-\x20'+_0x1e3b28['name']+':\x20'+(_0x1e3b28[_0x4f3872(0x136)]||'No\x20description')+_0x4f3872(0x11d)+_0xb80d4f;})[_0x1d10e7(0x14b)]('\x0a\x0a');return _0x1d10e7(0x159)+_0x4c7980+_0x1d10e7(0x163);}function escapeXml(_0xf7c79a){const _0x50688b=a32_0x4ce8;return _0xf7c79a[_0x50688b(0x169)](/&/g,'&amp;')[_0x50688b(0x169)](/</g,_0x50688b(0x125))[_0x50688b(0x169)](/>/g,_0x50688b(0x135))[_0x50688b(0x169)](/"/g,_0x50688b(0x14e))[_0x50688b(0x169)](/'/g,_0x50688b(0x13b));}export function extractToolResults(_0x5bcdb0){const _0x18d6a5=a32_0x4ce8,_0x33893f=[];for(const _0x11e7f9 of _0x5bcdb0){if(_0x11e7f9[_0x18d6a5(0x12c)]===_0x18d6a5(0x140)&&typeof _0x11e7f9[_0x18d6a5(0x15d)]!==_0x18d6a5(0x164))for(const _0x4fa84d of _0x11e7f9[_0x18d6a5(0x15d)]){if(_0x4fa84d['type']===_0x18d6a5(0x149)&&_0x4fa84d[_0x18d6a5(0x15c)]){let _0x18b476='';if(typeof _0x4fa84d[_0x18d6a5(0x15d)]===_0x18d6a5(0x164))_0x18b476=_0x4fa84d[_0x18d6a5(0x15d)];else Array['isArray'](_0x4fa84d[_0x18d6a5(0x15d)])&&(_0x18b476=_0x4fa84d['content'][_0x18d6a5(0x13f)](_0x4bc0e5=>_0x4bc0e5['type']===_0x18d6a5(0x123)&&_0x4bc0e5[_0x18d6a5(0x123)])[_0x18d6a5(0x130)](_0x1d0170=>_0x1d0170['text'])[_0x18d6a5(0x14b)]('\x0a'));const _0x4b3b67=escapeXml(_0x4fa84d[_0x18d6a5(0x15c)]),_0x346f88=escapeXml(_0x18b476),_0xc62cbc=_0x4fa84d['is_error']?_0x18d6a5(0x141):'';_0x33893f[_0x18d6a5(0x133)](_0x18d6a5(0x15b)+_0x4b3b67+'\x22'+_0xc62cbc+'>\x0a'+_0x346f88+_0x18d6a5(0x166));}}}if(_0x33893f[_0x18d6a5(0x128)]===0x0)return'';return _0x33893f[_0x18d6a5(0x14b)]('\x0a\x0a')+_0x18d6a5(0x158);}function findJsonEndIndex(_0x1ab96c,_0x136055){const _0x3b931e=a32_0x4ce8;let _0x57b5a4=0x0,_0x11b8fa=![],_0xa7222f=![];for(let _0x4e5bce=_0x136055;_0x4e5bce<_0x1ab96c[_0x3b931e(0x128)];_0x4e5bce++){const _0x740e40=_0x1ab96c[_0x4e5bce];if(_0xa7222f){_0xa7222f=![];continue;}if(_0x740e40==='\x5c'){_0xa7222f=!![];continue;}if(_0x740e40==='\x22'){_0x11b8fa=!_0x11b8fa;continue;}if(!_0x11b8fa){if(_0x740e40==='{')_0x57b5a4++;else{if(_0x740e40==='}'){_0x57b5a4--;if(_0x57b5a4===0x0)return _0x4e5bce+0x1;}}}}return-0x1;}function a32_0x4ce8(_0x23bc38,_0x358e38){const _0x3303f5=a32_0x3303();return a32_0x4ce8=function(_0x4ce852,_0x58cbec){_0x4ce852=_0x4ce852-0x11a;let _0x10ce13=_0x3303f5[_0x4ce852];return _0x10ce13;},a32_0x4ce8(_0x23bc38,_0x358e38);}function a32_0x3303(){const _0x56dbd0=['1btgcdN','4705902oUFiyl','substring','\x0a\x20\x20Parameters:\x0a','haiku','\x20\x20\x20\x20(no\x20parameters)','sonnet','761952XlWIYL','ceil','text','No\x20user\x20message\x20found\x20in\x20request\x20delta','&lt;','content_block_start','indexOf','length','end_turn','2076422NSRzpY','input','role','10rOtGyb','exec','warn','map','output_tokens','[DEBUG]\x20Tool\x20call\x20detected:','push','entries','&gt;','description','msg_','messages','content_block_delta','message','&apos;','14645576sJDnZA','9438905TWJWao','106980olpOJa','filter','user','\x20error=\x22true\x22','assistant','properties','\x20(required)','260jdXTNY','content_block_stop','type','includes','tool_result','6248330dWQlpJ','join','message_stop','Tool\x20calls\x20not\x20yet\x20supported\x20in\x20proxy:','&quot;','stringify','slice','\x0adata:\x20','input_schema','parse','opus','random','toString','pop','\x0a\x0aPlease\x20continue\x20your\x20response\x20based\x20on\x20the\x20tool\x20results\x20above.\x0a\x0a','<tools>\x0aYou\x20have\x20access\x20to\x20the\x20following\x20tools:\x0a\x0a','message_start','<tool_result\x20tool_use_id=\x22','tool_use_id','content','input_json_delta','21tHlDSx','tool_use','message_delta','name','\x0a\x0aTo\x20use\x20a\x20tool,\x20you\x20MUST\x20output\x20EXACTLY\x20this\x20JSON\x20format\x20on\x20its\x20own\x20line:\x0a{\x22tool_use\x22:{\x22id\x22:\x22toolu_<random>\x22,\x22name\x22:\x22<tool_name>\x22,\x22input\x22:{<parameters>}}}\x0a\x0aImportant:\x0a-\x20The\x20JSON\x20must\x20be\x20valid\x20and\x20on\x20a\x20single\x20line\x0a-\x20Generate\x20a\x20unique\x20random\x20ID\x20starting\x20with\x20\x22toolu_\x22\x0a-\x20Do\x20NOT\x20include\x20any\x20other\x20text\x20on\x20the\x20line\x20with\x20the\x20JSON\x0a-\x20After\x20outputting\x20the\x20tool\x20use\x20JSON,\x20stop\x20and\x20wait\x20for\x20the\x20tool\x20result\x0a-\x20Once\x20you\x20receive\x20a\x20tool\x20result,\x20continue\x20your\x20response\x20naturally\x0a\x0aExample:\x0aUser:\x20\x22What\x27s\x2025\x20*\x204?\x22\x0aAssistant:\x20I\x27ll\x20calculate\x20that\x20for\x20you.\x0a{\x22tool_use\x22:{\x22id\x22:\x22toolu_abc123\x22,\x22name\x22:\x22calculator\x22,\x22input\x22:{\x22expression\x22:\x2225\x20*\x204\x22}}}\x0a\x0a</tools>\x0a\x0a','string','text_delta','\x0a</tool_result>','error','toLowerCase','replace','api_error'];a32_0x3303=function(){return _0x56dbd0;};return a32_0x3303();}export function parseToolCallFromText(_0x17c7b3){const _0x14c11b=a32_0x4ce8,_0x5d1008=/\{"tool_use":/g,_0x10e08d=_0x5d1008[_0x14c11b(0x12e)](_0x17c7b3);if(!_0x10e08d)return null;const _0x47a500=_0x10e08d['index'],_0x27b996=findJsonEndIndex(_0x17c7b3,_0x47a500);if(_0x27b996===-0x1)return null;const _0x515c7f=_0x17c7b3[_0x14c11b(0x11c)](_0x47a500,_0x27b996);try{const _0x10511a=JSON[_0x14c11b(0x153)](_0x515c7f);if(_0x10511a[_0x14c11b(0x160)]&&_0x10511a[_0x14c11b(0x160)]['id']&&_0x10511a[_0x14c11b(0x160)][_0x14c11b(0x162)])return{'id':_0x10511a[_0x14c11b(0x160)]['id'],'name':_0x10511a[_0x14c11b(0x160)][_0x14c11b(0x162)],'input':_0x10511a['tool_use'][_0x14c11b(0x12b)]||{},'startIndex':_0x47a500,'endIndex':_0x27b996};}catch{return null;}return null;}export function*generateToolCallEvents(_0x40bebd,_0x5d9bbb){const _0x38c0c0=a32_0x4ce8,_0x4a29f3={'type':'content_block_start','index':_0x5d9bbb,'content_block':{'type':_0x38c0c0(0x160),'id':_0x40bebd['id'],'name':_0x40bebd[_0x38c0c0(0x162)],'input':{}}};yield _0x4a29f3;const _0x25523b=JSON[_0x38c0c0(0x14f)](_0x40bebd[_0x38c0c0(0x12b)]),_0x106e17={'type':'content_block_delta','index':_0x5d9bbb,'delta':{'type':_0x38c0c0(0x15e),'partial_json':_0x25523b}};yield _0x106e17;const _0x144210={'type':_0x38c0c0(0x146),'index':_0x5d9bbb};yield _0x144210;const _0x148c29={'type':'message_delta','delta':{'stop_reason':_0x38c0c0(0x160),'stop_sequence':null},'usage':{'output_tokens':0x0}};yield _0x148c29;const _0xcfabd9={'type':'message_stop'};yield _0xcfabd9;}export async function*transformTDStreamWithToolDetection(_0x377832,_0x322185,_0x1bc34d,_0x157545=![]){const _0x123266=a32_0x4ce8;let _0x4eb8a6=0x0,_0x3b00d6=0x0,_0xc018ad=0x0,_0x102544=![],_0x177f72='',_0x5e62f6=0x0,_0x5ac1b3=![];const _0x235494=0xc8,_0x405aa4={'type':_0x123266(0x15a),'message':{'id':_0x322185,'type':_0x123266(0x13a),'role':_0x123266(0x142),'content':[],'model':_0x1bc34d,'stop_reason':null,'stop_sequence':null,'usage':{'input_tokens':_0x4eb8a6,'output_tokens':0x0}}};yield _0x405aa4;for await(const _0x47647c of _0x377832){if(_0x123266(0x15d)in _0x47647c){const _0x2400d1=_0x47647c;_0x177f72+=_0x2400d1['content'];const _0x54f643=_0x177f72[_0x123266(0x127)]('{\x22tool_use\x22:');if(_0x54f643!==-0x1){const _0x446882=parseToolCallFromText(_0x177f72);if(_0x446882){_0x5ac1b3=!![];_0x157545&&(console[_0x123266(0x167)](_0x123266(0x132),_0x446882[_0x123266(0x162)]),console[_0x123266(0x167)](''));const _0x44d643=_0x177f72[_0x123266(0x11c)](_0x5e62f6,_0x446882['startIndex'])['trim']();if(_0x44d643){if(!_0x102544){const _0xfef8d={'type':_0x123266(0x126),'index':_0xc018ad,'content_block':{'type':_0x123266(0x123),'text':''}};yield _0xfef8d,_0x102544=!![];}const _0x49f451={'type':_0x123266(0x139),'index':_0xc018ad,'delta':{'type':_0x123266(0x165),'text':_0x44d643}};yield _0x49f451,_0x3b00d6+=Math['ceil'](_0x44d643[_0x123266(0x128)]/0x4);}if(_0x102544){const _0x491d5e={'type':'content_block_stop','index':_0xc018ad};yield _0x491d5e,_0xc018ad++;}for(const _0x3374db of generateToolCallEvents(_0x446882,_0xc018ad)){_0x3374db['type']===_0x123266(0x161)&&(_0x3374db['usage'][_0x123266(0x131)]=_0x3b00d6),yield _0x3374db;}return;}const _0x55848a=_0x177f72['substring'](_0x5e62f6,_0x54f643);if(_0x55848a){if(!_0x102544){const _0x4deba1={'type':_0x123266(0x126),'index':_0xc018ad,'content_block':{'type':_0x123266(0x123),'text':''}};yield _0x4deba1,_0x102544=!![];}const _0xfa969={'type':_0x123266(0x139),'index':_0xc018ad,'delta':{'type':_0x123266(0x165),'text':_0x55848a}};yield _0xfa969,_0x3b00d6+=Math[_0x123266(0x122)](_0x55848a['length']/0x4),_0x5e62f6=_0x54f643;}continue;}const _0x3b835f=_0x177f72['length']-_0x235494;if(_0x3b835f>_0x5e62f6){const _0x5df794=_0x177f72[_0x123266(0x11c)](_0x5e62f6,_0x3b835f);if(_0x5df794){if(!_0x102544){const _0x56037c={'type':_0x123266(0x126),'index':_0xc018ad,'content_block':{'type':_0x123266(0x123),'text':''}};yield _0x56037c,_0x102544=!![];}const _0x3ad37a={'type':_0x123266(0x139),'index':_0xc018ad,'delta':{'type':_0x123266(0x165),'text':_0x5df794}};yield _0x3ad37a,_0x3b00d6+=Math[_0x123266(0x122)](_0x5df794[_0x123266(0x128)]/0x4),_0x5e62f6=_0x3b835f;}}}else{if(_0x123266(0x167)in _0x47647c){const _0x1b3ef4=_0x47647c;yield{'type':_0x123266(0x167),'error':{'type':_0x123266(0x16a),'message':_0x1b3ef4[_0x123266(0x167)]}};return;}}}if(!_0x5ac1b3){const _0x1132a4=_0x177f72[_0x123266(0x11c)](_0x5e62f6);if(_0x1132a4){if(!_0x102544){const _0x4d05e9={'type':_0x123266(0x126),'index':_0xc018ad,'content_block':{'type':'text','text':''}};yield _0x4d05e9,_0x102544=!![];}const _0x1b20a8={'type':'content_block_delta','index':_0xc018ad,'delta':{'type':_0x123266(0x165),'text':_0x1132a4}};yield _0x1b20a8,_0x3b00d6+=Math[_0x123266(0x122)](_0x1132a4[_0x123266(0x128)]/0x4);}if(_0x102544){const _0x4ce30={'type':_0x123266(0x146),'index':_0xc018ad};yield _0x4ce30;}const _0x55aed5={'type':_0x123266(0x161),'delta':{'stop_reason':_0x123266(0x129),'stop_sequence':null},'usage':{'output_tokens':_0x3b00d6}};yield _0x55aed5;const _0x19e6a4={'type':'message_stop'};yield _0x19e6a4;}}export{generateMessageId};
1
+ (function(_0x1a225a,_0x5adbf0){const _0xe864a3=a33_0x506e,_0x3c570b=_0x1a225a();while(!![]){try{const _0x4f552c=-parseInt(_0xe864a3(0x1a7))/0x1+-parseInt(_0xe864a3(0x196))/0x2+parseInt(_0xe864a3(0x186))/0x3+-parseInt(_0xe864a3(0x172))/0x4+parseInt(_0xe864a3(0x189))/0x5*(-parseInt(_0xe864a3(0x1a1))/0x6)+-parseInt(_0xe864a3(0x19e))/0x7+-parseInt(_0xe864a3(0x1a4))/0x8*(-parseInt(_0xe864a3(0x194))/0x9);if(_0x4f552c===_0x5adbf0)break;else _0x3c570b['push'](_0x3c570b['shift']());}catch(_0x55b01b){_0x3c570b['push'](_0x3c570b['shift']());}}}(a33_0x416d,0x7997c));function generateMessageId(){const _0x274934=a33_0x506e;return _0x274934(0x1a0)+Math['random']()[_0x274934(0x18d)](0x24)[_0x274934(0x185)](0x2,0xf)+Math[_0x274934(0x184)]()['toString'](0x24)[_0x274934(0x185)](0x2,0xf);}export function extractTextFromAnthropicMessage(_0x5465c9){const _0x33a1a9=a33_0x506e;if(typeof _0x5465c9[_0x33a1a9(0x1a9)]==='string')return _0x5465c9['content'];return _0x5465c9[_0x33a1a9(0x1a9)][_0x33a1a9(0x169)](_0x4df4b4=>_0x4df4b4['type']===_0x33a1a9(0x17c)&&_0x4df4b4['text'])['map'](_0x23ea1a=>_0x23ea1a['text'])[_0x33a1a9(0x16e)]('\x0a');}function a33_0x506e(_0x55d1ba,_0x1789c5){const _0x416da0=a33_0x416d();return a33_0x506e=function(_0x506e28,_0x23eddd){_0x506e28=_0x506e28-0x162;let _0x4cc49f=_0x416da0[_0x506e28];return _0x4cc49f;},a33_0x506e(_0x55d1ba,_0x1789c5);}export function calculateConversationDelta(_0x1e7548,_0x484267){const _0x2bff0b=a33_0x506e;if(_0x484267['length']===0x0)return _0x1e7548;const _0x38f304=_0x484267[_0x2bff0b(0x192)];return _0x1e7548[_0x2bff0b(0x1a6)](_0x38f304);}function a33_0x416d(){const _0x207936=['27NUwvZg','message_start','1977490oRPJRk','Tool\x20calls\x20not\x20yet\x20supported\x20in\x20proxy:','[DEBUG]\x20Tool\x20call\x20detected:','includes','message','content_block_stop','<tool_result\x20tool_use_id=\x22','content_block_start','934080TylfGJ','usage','msg_','30hyvJeB','\x20\x20\x20\x20(no\x20parameters)','string','9132280RceDXa','content_block_delta','slice','638564ngYVoK','No\x20user\x20message\x20found\x20in\x20request\x20delta','content','opus','No\x20description','&lt;','type','map','&amp;','input_schema','\x20(required)','required','tool_use_id','\x0a\x0aTo\x20use\x20a\x20tool,\x20you\x20MUST\x20output\x20EXACTLY\x20this\x20JSON\x20format\x20on\x20its\x20own\x20line:\x0a{\x22tool_use\x22:{\x22id\x22:\x22toolu_<random>\x22,\x22name\x22:\x22<tool_name>\x22,\x22input\x22:{<parameters>}}}\x0a\x0aImportant:\x0a-\x20The\x20JSON\x20must\x20be\x20valid\x20and\x20on\x20a\x20single\x20line\x0a-\x20Generate\x20a\x20unique\x20random\x20ID\x20starting\x20with\x20\x22toolu_\x22\x0a-\x20Do\x20NOT\x20include\x20any\x20other\x20text\x20on\x20the\x20line\x20with\x20the\x20JSON\x0a-\x20After\x20outputting\x20the\x20tool\x20use\x20JSON,\x20stop\x20and\x20wait\x20for\x20the\x20tool\x20result\x0a-\x20Once\x20you\x20receive\x20a\x20tool\x20result,\x20continue\x20your\x20response\x20naturally\x0a\x0aExample:\x0aUser:\x20\x22What\x27s\x2025\x20*\x204?\x22\x0aAssistant:\x20I\x27ll\x20calculate\x20that\x20for\x20you.\x0a{\x22tool_use\x22:{\x22id\x22:\x22toolu_abc123\x22,\x22name\x22:\x22calculator\x22,\x22input\x22:{\x22expression\x22:\x2225\x20*\x204\x22}}}\x0a\x0a</tools>\x0a\x0a','end_turn','name','input_json_delta','index','filter','parse','api_error','haiku','warn','join','indexOf','role','sonnet','3496952yEEGmB','{\x22tool_use\x22:','trim','\x20error=\x22true\x22','description','stringify','is_error','replace','error','messages','text','&gt;','message_stop','tool_result','&quot;','tool_use','assistant','user','random','substring','1584933YIaQwr','ceil','message_delta','819885eTmtLv','isArray','tool_call','text_delta','toString','&apos;','properties','push','input','length','pop'];a33_0x416d=function(){return _0x207936;};return a33_0x416d();}export function transformAnthropicRequestToTD(_0x52f08a,_0x46bb43){const _0x1c67c7=a33_0x506e,_0x492edd=calculateConversationDelta(_0x52f08a[_0x1c67c7(0x17b)],_0x46bb43),_0x3179c1=_0x492edd['filter'](_0x282b38=>_0x282b38[_0x1c67c7(0x170)]===_0x1c67c7(0x183))[_0x1c67c7(0x193)]();if(!_0x3179c1)throw new Error(_0x1c67c7(0x1a8));const _0x1b1cdc=extractTextFromAnthropicMessage(_0x3179c1);return{'userMessage':_0x1b1cdc,'deltaMessages':_0x492edd};}export async function*transformTDStreamToAnthropic(_0x5b38f0,_0x3a2402,_0x44f604){const _0x3b8738=a33_0x506e;let _0x8b9968=0x0,_0x6b93c7=0x0,_0x43389e=0x0,_0x5087ae=![];const _0x340018={'type':_0x3b8738(0x195),'message':{'id':_0x3a2402,'type':_0x3b8738(0x19a),'role':_0x3b8738(0x182),'content':[],'model':_0x44f604,'stop_reason':null,'stop_sequence':null,'usage':{'input_tokens':_0x8b9968,'output_tokens':0x0}}};yield _0x340018;for await(const _0xdabf73 of _0x5b38f0){if(_0x3b8738(0x1a9)in _0xdabf73){const _0x3ba4e7=_0xdabf73;if(!_0x5087ae){const _0x14683e={'type':_0x3b8738(0x19d),'index':_0x43389e,'content_block':{'type':_0x3b8738(0x17c),'text':''}};yield _0x14683e,_0x5087ae=!![];}const _0x258b31={'type':_0x3b8738(0x1a5),'index':_0x43389e,'delta':{'type':_0x3b8738(0x18c),'text':_0x3ba4e7[_0x3b8738(0x1a9)]}};yield _0x258b31,_0x6b93c7+=Math[_0x3b8738(0x187)](_0x3ba4e7[_0x3b8738(0x1a9)]['length']/0x4);}else{if(_0x3b8738(0x18b)in _0xdabf73){const _0x372439=_0xdabf73;console[_0x3b8738(0x16d)](_0x3b8738(0x197),_0x372439);}else{if(_0x3b8738(0x17a)in _0xdabf73){const _0x2364fb=_0xdabf73;yield{'type':_0x3b8738(0x17a),'error':{'type':_0x3b8738(0x16b),'message':_0x2364fb[_0x3b8738(0x17a)]}};return;}}}}if(_0x5087ae){const _0x4bdae2={'type':_0x3b8738(0x19b),'index':_0x43389e};yield _0x4bdae2;}const _0x4a1527={'type':'message_delta','delta':{'stop_reason':_0x3b8738(0x165),'stop_sequence':null},'usage':{'output_tokens':_0x6b93c7}};yield _0x4a1527;const _0x233b21={'type':_0x3b8738(0x17e)};yield _0x233b21;}export function formatAnthropicSSE(_0x235611){const _0x232bee=a33_0x506e;return'event:\x20'+_0x235611[_0x232bee(0x1ad)]+'\x0adata:\x20'+JSON[_0x232bee(0x177)](_0x235611)+'\x0a\x0a';}export function mapAnthropicModelToTD(_0x5f42fa){const _0x4883d7=a33_0x506e,_0x42bb10={'sonnet':'sonnet','claude-sonnet':_0x4883d7(0x171),'claude-3-5-sonnet':_0x4883d7(0x171),'claude-3-sonnet':_0x4883d7(0x171),'haiku':_0x4883d7(0x16c),'claude-haiku':_0x4883d7(0x16c),'claude-3-5-haiku':_0x4883d7(0x16c),'claude-3-haiku':_0x4883d7(0x16c),'opus':'opus','claude-opus':_0x4883d7(0x1aa),'claude-3-opus':'opus'},_0x309844=_0x5f42fa['toLowerCase']();return _0x42bb10[_0x309844]||'sonnet';}export function generateToolPrompt(_0x2573e2){const _0x1cca1b=a33_0x506e;if(!_0x2573e2||_0x2573e2[_0x1cca1b(0x192)]===0x0)return'';const _0x1a8c3e=_0x2573e2[_0x1cca1b(0x1ae)](_0x57af22=>{const _0x187acd=_0x1cca1b,_0x4aab6a=_0x57af22[_0x187acd(0x1b0)][_0x187acd(0x18f)]?Object['entries'](_0x57af22[_0x187acd(0x1b0)][_0x187acd(0x18f)])['map'](([_0x450301,_0x5d66af])=>{const _0x299b21=_0x187acd,_0x2ba35a=_0x57af22['input_schema'][_0x299b21(0x162)]?.[_0x299b21(0x199)](_0x450301)?_0x299b21(0x1b1):'',_0x1ed1a0=_0x5d66af,_0x59bf48=_0x1ed1a0[_0x299b21(0x176)]?':\x20'+_0x1ed1a0['description']:'';return'\x20\x20\x20\x20-\x20'+_0x450301+_0x2ba35a+_0x59bf48;})[_0x187acd(0x16e)]('\x0a'):_0x187acd(0x1a2);return'-\x20'+_0x57af22[_0x187acd(0x166)]+':\x20'+(_0x57af22['description']||_0x187acd(0x1ab))+'\x0a\x20\x20Parameters:\x0a'+_0x4aab6a;})[_0x1cca1b(0x16e)]('\x0a\x0a');return'<tools>\x0aYou\x20have\x20access\x20to\x20the\x20following\x20tools:\x0a\x0a'+_0x1a8c3e+_0x1cca1b(0x164);}function escapeXml(_0x47747c){const _0x17b759=a33_0x506e;return _0x47747c[_0x17b759(0x179)](/&/g,_0x17b759(0x1af))[_0x17b759(0x179)](/</g,_0x17b759(0x1ac))[_0x17b759(0x179)](/>/g,_0x17b759(0x17d))[_0x17b759(0x179)](/"/g,_0x17b759(0x180))[_0x17b759(0x179)](/'/g,_0x17b759(0x18e));}export function extractToolResults(_0x56afab){const _0x24fb2b=a33_0x506e,_0x2b8f69=[];for(const _0x46b592 of _0x56afab){if(_0x46b592[_0x24fb2b(0x170)]==='user'&&typeof _0x46b592['content']!==_0x24fb2b(0x1a3))for(const _0x1e1cc1 of _0x46b592[_0x24fb2b(0x1a9)]){if(_0x1e1cc1['type']===_0x24fb2b(0x17f)&&_0x1e1cc1[_0x24fb2b(0x163)]){let _0x44ad77='';if(typeof _0x1e1cc1[_0x24fb2b(0x1a9)]==='string')_0x44ad77=_0x1e1cc1[_0x24fb2b(0x1a9)];else Array[_0x24fb2b(0x18a)](_0x1e1cc1[_0x24fb2b(0x1a9)])&&(_0x44ad77=_0x1e1cc1['content'][_0x24fb2b(0x169)](_0x3da4a1=>_0x3da4a1[_0x24fb2b(0x1ad)]===_0x24fb2b(0x17c)&&_0x3da4a1[_0x24fb2b(0x17c)])[_0x24fb2b(0x1ae)](_0x2b30df=>_0x2b30df[_0x24fb2b(0x17c)])[_0x24fb2b(0x16e)]('\x0a'));const _0x7ad34d=escapeXml(_0x1e1cc1[_0x24fb2b(0x163)]),_0x56d38a=escapeXml(_0x44ad77),_0x4d44dc=_0x1e1cc1[_0x24fb2b(0x178)]?_0x24fb2b(0x175):'';_0x2b8f69[_0x24fb2b(0x190)](_0x24fb2b(0x19c)+_0x7ad34d+'\x22'+_0x4d44dc+'>\x0a'+_0x56d38a+'\x0a</tool_result>');}}}if(_0x2b8f69[_0x24fb2b(0x192)]===0x0)return'';return _0x2b8f69['join']('\x0a\x0a')+'\x0a\x0aPlease\x20continue\x20your\x20response\x20based\x20on\x20the\x20tool\x20results\x20above.\x0a\x0a';}function findJsonEndIndex(_0x22382b,_0x16d6bc){const _0x28b407=a33_0x506e;let _0x4b71bd=0x0,_0x379ce9=![],_0x1a1eae=![];for(let _0x2a0821=_0x16d6bc;_0x2a0821<_0x22382b[_0x28b407(0x192)];_0x2a0821++){const _0x4d9d41=_0x22382b[_0x2a0821];if(_0x1a1eae){_0x1a1eae=![];continue;}if(_0x4d9d41==='\x5c'){_0x1a1eae=!![];continue;}if(_0x4d9d41==='\x22'){_0x379ce9=!_0x379ce9;continue;}if(!_0x379ce9){if(_0x4d9d41==='{')_0x4b71bd++;else{if(_0x4d9d41==='}'){_0x4b71bd--;if(_0x4b71bd===0x0)return _0x2a0821+0x1;}}}}return-0x1;}export function parseToolCallFromText(_0x35dcec){const _0x147ea4=a33_0x506e,_0x2aabac=/\{"tool_use":/g,_0x4edbf2=_0x2aabac['exec'](_0x35dcec);if(!_0x4edbf2)return null;const _0x37d3e3=_0x4edbf2[_0x147ea4(0x168)],_0x261d5b=findJsonEndIndex(_0x35dcec,_0x37d3e3);if(_0x261d5b===-0x1)return null;const _0x2554b5=_0x35dcec['substring'](_0x37d3e3,_0x261d5b);try{const _0xd0b1c9=JSON[_0x147ea4(0x16a)](_0x2554b5);if(_0xd0b1c9['tool_use']&&_0xd0b1c9[_0x147ea4(0x181)]['id']&&_0xd0b1c9[_0x147ea4(0x181)][_0x147ea4(0x166)])return{'id':_0xd0b1c9['tool_use']['id'],'name':_0xd0b1c9['tool_use'][_0x147ea4(0x166)],'input':_0xd0b1c9[_0x147ea4(0x181)][_0x147ea4(0x191)]||{},'startIndex':_0x37d3e3,'endIndex':_0x261d5b};}catch{return null;}return null;}export function*generateToolCallEvents(_0x5acfff,_0xa8ad6a){const _0x2cf29c=a33_0x506e,_0x7ede51={'type':_0x2cf29c(0x19d),'index':_0xa8ad6a,'content_block':{'type':_0x2cf29c(0x181),'id':_0x5acfff['id'],'name':_0x5acfff[_0x2cf29c(0x166)],'input':{}}};yield _0x7ede51;const _0x1de338=JSON[_0x2cf29c(0x177)](_0x5acfff[_0x2cf29c(0x191)]),_0x23ee76={'type':'content_block_delta','index':_0xa8ad6a,'delta':{'type':_0x2cf29c(0x167),'partial_json':_0x1de338}};yield _0x23ee76;const _0x178c9e={'type':_0x2cf29c(0x19b),'index':_0xa8ad6a};yield _0x178c9e;const _0x1d9dda={'type':_0x2cf29c(0x188),'delta':{'stop_reason':_0x2cf29c(0x181),'stop_sequence':null},'usage':{'output_tokens':0x0}};yield _0x1d9dda;const _0x604118={'type':_0x2cf29c(0x17e)};yield _0x604118;}export async function*transformTDStreamWithToolDetection(_0xab3145,_0x2b2493,_0x418abe,_0x27299b=![]){const _0x4c7144=a33_0x506e;let _0x3fda1c=0x0,_0x2c5e1e=0x0,_0x32a90c=0x0,_0x5beaa5=![],_0x471064='',_0x942ac9=0x0,_0x2bb3ba=![];const _0x1c5a41=0xc8,_0x5784e2={'type':'message_start','message':{'id':_0x2b2493,'type':'message','role':'assistant','content':[],'model':_0x418abe,'stop_reason':null,'stop_sequence':null,'usage':{'input_tokens':_0x3fda1c,'output_tokens':0x0}}};yield _0x5784e2;for await(const _0x259257 of _0xab3145){if('content'in _0x259257){const _0x33f89c=_0x259257;_0x471064+=_0x33f89c['content'];const _0x4c5aa3=_0x471064[_0x4c7144(0x16f)](_0x4c7144(0x173));if(_0x4c5aa3!==-0x1){const _0x3afd28=parseToolCallFromText(_0x471064);if(_0x3afd28){_0x2bb3ba=!![];_0x27299b&&(console[_0x4c7144(0x17a)](_0x4c7144(0x198),_0x3afd28['name']),console['error'](''));const _0x15fb50=_0x471064['substring'](_0x942ac9,_0x3afd28['startIndex'])[_0x4c7144(0x174)]();if(_0x15fb50){if(!_0x5beaa5){const _0x869c12={'type':'content_block_start','index':_0x32a90c,'content_block':{'type':_0x4c7144(0x17c),'text':''}};yield _0x869c12,_0x5beaa5=!![];}const _0x41dafc={'type':_0x4c7144(0x1a5),'index':_0x32a90c,'delta':{'type':_0x4c7144(0x18c),'text':_0x15fb50}};yield _0x41dafc,_0x2c5e1e+=Math[_0x4c7144(0x187)](_0x15fb50['length']/0x4);}if(_0x5beaa5){const _0x20c39e={'type':_0x4c7144(0x19b),'index':_0x32a90c};yield _0x20c39e,_0x32a90c++;}for(const _0x16f800 of generateToolCallEvents(_0x3afd28,_0x32a90c)){_0x16f800[_0x4c7144(0x1ad)]==='message_delta'&&(_0x16f800[_0x4c7144(0x19f)]['output_tokens']=_0x2c5e1e),yield _0x16f800;}return;}const _0x4c1b5a=_0x471064[_0x4c7144(0x185)](_0x942ac9,_0x4c5aa3);if(_0x4c1b5a){if(!_0x5beaa5){const _0x35dc07={'type':'content_block_start','index':_0x32a90c,'content_block':{'type':_0x4c7144(0x17c),'text':''}};yield _0x35dc07,_0x5beaa5=!![];}const _0x301479={'type':'content_block_delta','index':_0x32a90c,'delta':{'type':'text_delta','text':_0x4c1b5a}};yield _0x301479,_0x2c5e1e+=Math[_0x4c7144(0x187)](_0x4c1b5a['length']/0x4),_0x942ac9=_0x4c5aa3;}continue;}const _0x427859=_0x471064[_0x4c7144(0x192)]-_0x1c5a41;if(_0x427859>_0x942ac9){const _0x4b3b7d=_0x471064[_0x4c7144(0x185)](_0x942ac9,_0x427859);if(_0x4b3b7d){if(!_0x5beaa5){const _0x33d2a6={'type':'content_block_start','index':_0x32a90c,'content_block':{'type':_0x4c7144(0x17c),'text':''}};yield _0x33d2a6,_0x5beaa5=!![];}const _0x3a1dcf={'type':'content_block_delta','index':_0x32a90c,'delta':{'type':_0x4c7144(0x18c),'text':_0x4b3b7d}};yield _0x3a1dcf,_0x2c5e1e+=Math[_0x4c7144(0x187)](_0x4b3b7d['length']/0x4),_0x942ac9=_0x427859;}}}else{if(_0x4c7144(0x17a)in _0x259257){const _0x1057cd=_0x259257;yield{'type':_0x4c7144(0x17a),'error':{'type':_0x4c7144(0x16b),'message':_0x1057cd[_0x4c7144(0x17a)]}};return;}}}if(!_0x2bb3ba){const _0x405a24=_0x471064[_0x4c7144(0x185)](_0x942ac9);if(_0x405a24){if(!_0x5beaa5){const _0x1aaae7={'type':_0x4c7144(0x19d),'index':_0x32a90c,'content_block':{'type':_0x4c7144(0x17c),'text':''}};yield _0x1aaae7,_0x5beaa5=!![];}const _0x546608={'type':_0x4c7144(0x1a5),'index':_0x32a90c,'delta':{'type':_0x4c7144(0x18c),'text':_0x405a24}};yield _0x546608,_0x2c5e1e+=Math['ceil'](_0x405a24[_0x4c7144(0x192)]/0x4);}if(_0x5beaa5){const _0x86b79d={'type':_0x4c7144(0x19b),'index':_0x32a90c};yield _0x86b79d;}const _0x4ec8ce={'type':_0x4c7144(0x188),'delta':{'stop_reason':'end_turn','stop_sequence':null},'usage':{'output_tokens':_0x2c5e1e}};yield _0x4ec8ce;const _0x3ef772={'type':_0x4c7144(0x17e)};yield _0x3ef772;}}export{generateMessageId};