@treasuredata/tdx 0.1.10 → 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.
- package/dist/cli.js +1 -1
- package/dist/cli.js.map +1 -1
- package/dist/client/cdp-client.js +1 -1
- package/dist/client/http-client.js +1 -1
- package/dist/client/llm-client.js +1 -1
- package/dist/client/rate-limiter.js +1 -1
- package/dist/client/td-client.js +1 -1
- package/dist/client/trino-client.js +1 -1
- package/dist/client/workflow-client.js +1 -1
- package/dist/commands/activations.js +1 -1
- package/dist/commands/api-command.js +1 -1
- package/dist/commands/chat-command.js +1 -1
- package/dist/commands/claude-command.d.ts +1 -0
- package/dist/commands/claude-command.d.ts.map +1 -1
- package/dist/commands/claude-command.js +1 -1
- package/dist/commands/claude-command.js.map +1 -1
- package/dist/commands/command.js +1 -1
- package/dist/commands/context-command.js +1 -1
- package/dist/commands/databases.js +1 -1
- package/dist/commands/describe.js +1 -1
- package/dist/commands/llm-command.js +1 -1
- package/dist/commands/llm-proxy.js +1 -1
- package/dist/commands/profiles-command.js +1 -1
- package/dist/commands/query-command.js +1 -1
- package/dist/commands/segment-command.js +1 -1
- package/dist/commands/segments.js +1 -1
- package/dist/commands/show.js +1 -1
- package/dist/commands/tables.js +1 -1
- package/dist/commands/use-command.js +1 -1
- package/dist/commands/workflow-command.js +1 -1
- package/dist/core/auth.js +1 -1
- package/dist/core/config.js +1 -1
- package/dist/core/global-context.js +1 -1
- package/dist/core/profile.js +1 -1
- package/dist/core/project-config.js +1 -1
- package/dist/core/session.js +1 -1
- package/dist/index.js +1 -1
- package/dist/proxy/anthropic-adapter.js +1 -1
- package/dist/proxy/server.js +1 -1
- package/dist/sdk/api.js +1 -1
- package/dist/sdk/database.js +1 -1
- package/dist/sdk/errors.js +1 -1
- package/dist/sdk/index.js +1 -1
- package/dist/sdk/llm.js +1 -1
- package/dist/sdk/query.js +1 -1
- package/dist/sdk/segment.js +1 -1
- package/dist/sdk/table.js +1 -1
- package/dist/sdk/workflow.js +1 -1
- package/dist/types/endpoints.js +1 -1
- package/dist/types/index.js +1 -1
- package/dist/utils/agent-ref-parser.js +1 -1
- package/dist/utils/chat-cache.js +1 -1
- package/dist/utils/colors.js +1 -1
- package/dist/utils/command-output.js +1 -1
- package/dist/utils/file-permissions.js +1 -1
- package/dist/utils/format-detector.js +1 -1
- package/dist/utils/formatters.js +1 -1
- package/dist/utils/model-aliases.js +1 -1
- package/dist/utils/option-validation.js +1 -1
- package/dist/utils/port.js +1 -1
- package/dist/utils/process.js +1 -1
- package/dist/utils/segment-ref-parser.js +1 -1
- package/dist/utils/spinner.js +1 -1
- package/dist/utils/sql-parser.js +1 -1
- package/dist/utils/sse-parser.js +1 -1
- package/dist/utils/string-utils.js +1 -1
- package/dist/utils/table-ref-parser.js +1 -1
- package/dist/utils/workflow-utils.js +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
const a25_0x3b2214=a25_0x13d4;(function(_0xfa3d05,_0x464914){const _0x57fcd4=a25_0x13d4,_0x3da891=_0xfa3d05();while(!![]){try{const _0x1cc2ed=parseInt(_0x57fcd4(0x16b))/0x1*(-parseInt(_0x57fcd4(0x1bc))/0x2)+parseInt(_0x57fcd4(0x1b3))/0x3*(-parseInt(_0x57fcd4(0x1bf))/0x4)+-parseInt(_0x57fcd4(0x1c2))/0x5*(-parseInt(_0x57fcd4(0x1c0))/0x6)+-parseInt(_0x57fcd4(0x183))/0x7*(-parseInt(_0x57fcd4(0x187))/0x8)+-parseInt(_0x57fcd4(0x149))/0x9*(-parseInt(_0x57fcd4(0x1a8))/0xa)+-parseInt(_0x57fcd4(0x185))/0xb+-parseInt(_0x57fcd4(0x18a))/0xc;if(_0x1cc2ed===_0x464914)break;else _0x3da891['push'](_0x3da891['shift']());}catch(_0x139d05){_0x3da891['push'](_0x3da891['shift']());}}}(a25_0x3d52,0x58df2));import{BaseCommand}from'./command.js';import{SDKError}from'../sdk/index.js';function a25_0x13d4(_0x58a4e8,_0x59f357){const _0x3d525a=a25_0x3d52();return a25_0x13d4=function(_0x13d4bd,_0x5689ee){_0x13d4bd=_0x13d4bd-0x145;let _0x2ef5fa=_0x3d525a[_0x13d4bd];return _0x2ef5fa;},a25_0x13d4(_0x58a4e8,_0x59f357);}import{handleSDKOutput}from'../utils/command-output.js';import{withSpinner}from'../utils/spinner.js';import*as a25_0x5d22c2 from'readline';async function confirm(_0x5f9931){const _0x4d53a1=a25_0x13d4,_0x332f9b=a25_0x5d22c2[_0x4d53a1(0x16a)]({'input':process[_0x4d53a1(0x1b4)],'output':process[_0x4d53a1(0x1a5)]});return new Promise(_0x3609ab=>{const _0x449ad2=_0x4d53a1;_0x332f9b[_0x449ad2(0x1b8)](_0x5f9931+_0x449ad2(0x15a),_0x7e13df=>{const _0x57937b=_0x449ad2;_0x332f9b['close'](),_0x3609ab(_0x7e13df[_0x57937b(0x181)]()==='y'||_0x7e13df[_0x57937b(0x181)]()==='yes');});});}export class WorkflowProjectsCommand extends BaseCommand{[a25_0x3b2214(0x17d)]=a25_0x3b2214(0x195);['description']=a25_0x3b2214(0x166);async[a25_0x3b2214(0x152)](_0x4f7ed1){const _0x5cb74e=a25_0x3b2214,{options:_0x1296bd,args:_0x28271a,tdx:_0x4c776c}=_0x4f7ed1,_0x37c0ed=_0x28271a[0x0];try{_0x1296bd[_0x5cb74e(0x1ae)]&&_0x37c0ed&&console['error']('Pattern:\x20'+_0x37c0ed);const _0x3e2cb8=await withSpinner(_0x5cb74e(0x19a),()=>_0x4c776c['workflow'][_0x5cb74e(0x18b)](_0x37c0ed,{'limit':_0x1296bd['limit']}),{'verbose':_0x1296bd['verbose']}),_0x503876=_0x3e2cb8[_0x5cb74e(0x1ba)];return console['error'](_0x5cb74e(0x196)+_0x503876[_0x5cb74e(0x19e)]+_0x5cb74e(0x18d)+(_0x503876[_0x5cb74e(0x19e)]!==0x1?'s':'')),await handleSDKOutput(_0x503876,_0x1296bd),0x0;}catch(_0x28638e){if(_0x28638e instanceof SDKError)return console[_0x5cb74e(0x170)](_0x5cb74e(0x17a)+_0x28638e['message']),_0x28638e[_0x5cb74e(0x16c)]&&console[_0x5cb74e(0x170)](_0x5cb74e(0x186)+_0x28638e['cause']),0x1;throw _0x28638e;}}}export class WorkflowWorkflowsCommand extends BaseCommand{[a25_0x3b2214(0x17d)]=a25_0x3b2214(0x1b7);[a25_0x3b2214(0x178)]='List\x20workflows';async[a25_0x3b2214(0x152)](_0x14abd3){const _0x10d236=a25_0x3b2214,{options:_0x2ce531,args:_0x379a95,tdx:_0x1ea230}=_0x14abd3,_0x4c759d=_0x379a95[0x0];try{_0x2ce531['verbose']&&_0x4c759d&&console['error'](_0x10d236(0x199)+_0x4c759d);const _0x567036=await withSpinner('Listing\x20workflows...',()=>_0x1ea230[_0x10d236(0x162)][_0x10d236(0x14d)](_0x4c759d,{'limit':_0x2ce531['limit']}),{'verbose':_0x2ce531[_0x10d236(0x1ae)]}),_0x5429db=_0x567036[_0x10d236(0x1ba)];return console[_0x10d236(0x170)]('✔\x20Found\x20'+_0x5429db['length']+'\x20workflow'+(_0x5429db[_0x10d236(0x19e)]!==0x1?'s':'')),await handleSDKOutput(_0x5429db,_0x2ce531),0x0;}catch(_0x223207){if(_0x223207 instanceof SDKError)return console['error'](_0x10d236(0x17a)+_0x223207[_0x10d236(0x175)]),_0x223207[_0x10d236(0x16c)]&&console[_0x10d236(0x170)]('\x20\x20Cause:\x20'+_0x223207[_0x10d236(0x16c)]),0x1;throw _0x223207;}}}export class WorkflowSessionsCommand extends BaseCommand{[a25_0x3b2214(0x17d)]=a25_0x3b2214(0x1bd);[a25_0x3b2214(0x178)]=a25_0x3b2214(0x180);async['execute'](_0x1ed03a){const _0x5c2e66=a25_0x3b2214,{options:_0x23560f,args:_0x51a20d,tdx:_0x34a2ed}=_0x1ed03a;let _0x42f301,_0x3991d0;if(_0x51a20d[0x0]){const _0x18cb0b=_0x51a20d[0x0][_0x5c2e66(0x179)]('.');if(_0x18cb0b[_0x5c2e66(0x19e)]===0x1)_0x42f301=_0x18cb0b[0x0];else{if(_0x18cb0b[_0x5c2e66(0x19e)]===0x2)[_0x42f301,_0x3991d0]=_0x18cb0b;else return console[_0x5c2e66(0x170)]('Error:\x20Invalid\x20pattern.\x20Use\x20format:\x20project\x20or\x20project.workflow'),0x1;}}try{if(_0x23560f[_0x5c2e66(0x1ae)]){if(_0x42f301&&_0x3991d0)console['error']('Filter:\x20'+_0x42f301+'.'+_0x3991d0);else _0x42f301&&console[_0x5c2e66(0x170)](_0x5c2e66(0x1ac)+_0x42f301);const _0x424a31=_0x23560f['status'];_0x424a31&&console['error'](_0x5c2e66(0x192)+_0x424a31);}const _0x50b482=await withSpinner(_0x5c2e66(0x158),()=>_0x34a2ed[_0x5c2e66(0x162)][_0x5c2e66(0x1b6)]({'projectName':_0x42f301,'workflowName':_0x3991d0,'status':_0x23560f[_0x5c2e66(0x164)],'fromTime':_0x23560f[_0x5c2e66(0x15f)],'toTime':_0x23560f['to'],'limit':_0x23560f[_0x5c2e66(0x1c3)]}),{'verbose':_0x23560f['verbose']}),_0x26de8b=_0x50b482[_0x5c2e66(0x1ba)];return console[_0x5c2e66(0x170)]('✔\x20Found\x20'+_0x26de8b[_0x5c2e66(0x19e)]+'\x20session'+(_0x26de8b[_0x5c2e66(0x19e)]!==0x1?'s':'')),await handleSDKOutput(_0x26de8b,_0x23560f),0x0;}catch(_0x83d751){if(_0x83d751 instanceof SDKError)return console[_0x5c2e66(0x170)](_0x5c2e66(0x17a)+_0x83d751[_0x5c2e66(0x175)]),_0x83d751[_0x5c2e66(0x16c)]&&console[_0x5c2e66(0x170)](_0x5c2e66(0x186)+_0x83d751[_0x5c2e66(0x16c)]),0x1;throw _0x83d751;}}}export class WorkflowAttemptsCommand extends BaseCommand{['name']=a25_0x3b2214(0x16e);['description']=a25_0x3b2214(0x19b);async['execute'](_0x49c1c4){const _0x23e339=a25_0x3b2214,{options:_0x3ae211,args:_0x483254,tdx:_0x1312af}=_0x49c1c4;let _0x4bd11e,_0x5c01f0;if(_0x483254[0x0]){const _0x339800=_0x483254[0x0][_0x23e339(0x179)]('.');if(_0x339800['length']===0x1)_0x4bd11e=_0x339800[0x0];else{if(_0x339800[_0x23e339(0x19e)]===0x2)[_0x4bd11e,_0x5c01f0]=_0x339800;else return console[_0x23e339(0x170)](_0x23e339(0x171)),0x1;}}try{const _0x12a736=_0x3ae211[_0x23e339(0x1c8)];if(_0x3ae211['verbose']){if(_0x4bd11e&&_0x5c01f0)console['error'](_0x23e339(0x194)+_0x4bd11e+'.'+_0x5c01f0);else _0x4bd11e&&console[_0x23e339(0x170)](_0x23e339(0x1ac)+_0x4bd11e);_0x12a736&&console[_0x23e339(0x170)](_0x23e339(0x168));}const _0x596ee0=await withSpinner('Listing\x20workflow\x20attempts...',()=>_0x1312af[_0x23e339(0x162)][_0x23e339(0x1c7)]({'projectName':_0x4bd11e,'workflowName':_0x5c01f0,'includeRetried':_0x12a736,'limit':_0x3ae211[_0x23e339(0x1c3)]}),{'verbose':_0x3ae211[_0x23e339(0x1ae)]}),_0x45cc1a=_0x596ee0['data'];return console[_0x23e339(0x170)](_0x23e339(0x196)+_0x45cc1a[_0x23e339(0x19e)]+'\x20attempt'+(_0x45cc1a[_0x23e339(0x19e)]!==0x1?'s':'')),await handleSDKOutput(_0x45cc1a,_0x3ae211),0x0;}catch(_0x12c366){if(_0x12c366 instanceof SDKError)return console[_0x23e339(0x170)](_0x23e339(0x17a)+_0x12c366[_0x23e339(0x175)]),_0x12c366['cause']&&console[_0x23e339(0x170)]('\x20\x20Cause:\x20'+_0x12c366[_0x23e339(0x16c)]),0x1;throw _0x12c366;}}}export class WorkflowAttemptCommand extends BaseCommand{[a25_0x3b2214(0x17d)]=a25_0x3b2214(0x169);[a25_0x3b2214(0x178)]='Show\x20specific\x20attempt\x20details';async['execute'](_0x42395e){const _0x5322a2=a25_0x3b2214,{options:_0x3cc791,args:_0x1f6ec8,tdx:_0x21eb2b}=_0x42395e,_0x28aebf=_0x1f6ec8[0x0];if(!_0x28aebf)return console[_0x5322a2(0x170)](_0x5322a2(0x1a9)),0x1;try{_0x3cc791['verbose']&&console[_0x5322a2(0x170)]('Attempt\x20ID:\x20'+_0x28aebf);const _0x2eeede=await withSpinner(_0x5322a2(0x14e),()=>_0x21eb2b['workflow'][_0x5322a2(0x172)](_0x28aebf),{'verbose':_0x3cc791[_0x5322a2(0x1ae)]}),_0x4804f6=_0x2eeede['data'];return await handleSDKOutput([_0x4804f6],_0x3cc791),0x0;}catch(_0x429353){if(_0x429353 instanceof SDKError)return console[_0x5322a2(0x170)](_0x5322a2(0x17a)+_0x429353[_0x5322a2(0x175)]),_0x429353[_0x5322a2(0x16c)]&&console[_0x5322a2(0x170)](_0x5322a2(0x186)+_0x429353[_0x5322a2(0x16c)]),0x1;throw _0x429353;}}}export class WorkflowTasksCommand extends BaseCommand{[a25_0x3b2214(0x17d)]=a25_0x3b2214(0x16d);[a25_0x3b2214(0x178)]=a25_0x3b2214(0x14c);async[a25_0x3b2214(0x152)](_0x24013b){const _0xe36c0b=a25_0x3b2214,{options:_0x368064,args:_0x34fa31,tdx:_0xdaa90a}=_0x24013b,_0x98efe7=_0x34fa31[0x0];if(!_0x98efe7)return console[_0xe36c0b(0x170)](_0xe36c0b(0x1a9)),0x1;try{const _0x35ce39=_0x368064[_0xe36c0b(0x19f)];_0x368064[_0xe36c0b(0x1ae)]&&(console[_0xe36c0b(0x170)]('Attempt\x20ID:\x20'+_0x98efe7),_0x35ce39&&console[_0xe36c0b(0x170)](_0xe36c0b(0x1b1)));const _0x25beb5=await withSpinner(_0xe36c0b(0x157),()=>_0xdaa90a['workflow'][_0xe36c0b(0x1a2)](_0x98efe7,_0x35ce39||![]),{'verbose':_0x368064[_0xe36c0b(0x1ae)]}),_0x2fc138=_0x25beb5[_0xe36c0b(0x1ba)];return console[_0xe36c0b(0x170)]('✔\x20Found\x20'+_0x2fc138[_0xe36c0b(0x19e)]+_0xe36c0b(0x197)+(_0x2fc138[_0xe36c0b(0x19e)]!==0x1?'s':'')),await handleSDKOutput(_0x2fc138,_0x368064),0x0;}catch(_0x37f29e){if(_0x37f29e instanceof SDKError)return console[_0xe36c0b(0x170)](_0xe36c0b(0x17a)+_0x37f29e[_0xe36c0b(0x175)]),_0x37f29e[_0xe36c0b(0x16c)]&&console[_0xe36c0b(0x170)]('\x20\x20Cause:\x20'+_0x37f29e['cause']),0x1;throw _0x37f29e;}}}export class WorkflowLogsCommand extends BaseCommand{[a25_0x3b2214(0x17d)]=a25_0x3b2214(0x1a3);['description']=a25_0x3b2214(0x14f);async[a25_0x3b2214(0x152)](_0x355fd0){const _0x32de2d=a25_0x3b2214,{options:_0xe2fbe5,args:_0x28a376,tdx:_0xfa4569}=_0x355fd0,_0x38e0bc=_0x28a376[0x0],_0x29fdec=_0x28a376[0x1];if(!_0x38e0bc||!_0x29fdec)return console[_0x32de2d(0x170)](_0x32de2d(0x167)),0x1;try{_0xe2fbe5[_0x32de2d(0x1ae)]&&(console[_0x32de2d(0x170)]('Attempt\x20ID:\x20'+_0x38e0bc),console[_0x32de2d(0x170)](_0x32de2d(0x1be)+_0x29fdec));const _0x5b51b7=_0xe2fbe5['offset'],_0x1036ff=await withSpinner(_0x32de2d(0x182),()=>_0xfa4569['workflow']['logs'](_0x38e0bc,_0x29fdec,{'offset':_0x5b51b7,'limit':_0xe2fbe5[_0x32de2d(0x1c3)]}),{'verbose':_0xe2fbe5[_0x32de2d(0x1ae)]}),_0x223cba=_0x1036ff[_0x32de2d(0x1ba)];return console[_0x32de2d(0x170)](_0x32de2d(0x196)+_0x223cba[_0x32de2d(0x19e)]+'\x20log\x20entr'+(_0x223cba[_0x32de2d(0x19e)]!==0x1?_0x32de2d(0x176):'y')),await handleSDKOutput(_0x223cba,_0xe2fbe5),0x0;}catch(_0x1ea3c3){if(_0x1ea3c3 instanceof SDKError)return console[_0x32de2d(0x170)](_0x32de2d(0x17a)+_0x1ea3c3[_0x32de2d(0x175)]),_0x1ea3c3[_0x32de2d(0x16c)]&&console[_0x32de2d(0x170)](_0x32de2d(0x186)+_0x1ea3c3['cause']),0x1;throw _0x1ea3c3;}}}export class WorkflowKillCommand extends BaseCommand{[a25_0x3b2214(0x17d)]=a25_0x3b2214(0x159);['description']='Kill\x20a\x20running\x20attempt';async[a25_0x3b2214(0x152)](_0xe02bbc){const _0x272e00=a25_0x3b2214,{options:_0x580223,args:_0x3607da,tdx:_0x2ea1dc}=_0xe02bbc,_0x4f5737=_0x3607da[0x0];if(!_0x4f5737)return console[_0x272e00(0x170)](_0x272e00(0x1a9)),0x1;try{const _0x1d4c47=_0x580223['reason'];_0x580223[_0x272e00(0x1ae)]&&(console[_0x272e00(0x170)](_0x272e00(0x177)+_0x4f5737),_0x1d4c47&&console[_0x272e00(0x170)](_0x272e00(0x1ad)+_0x1d4c47));if(!_0x580223[_0x272e00(0x193)]){const _0xf7a55d=await confirm(_0x272e00(0x18f)+_0x4f5737+'?');if(!_0xf7a55d)return console[_0x272e00(0x170)](_0x272e00(0x1aa)),0x0;}const _0xcc8ad7=await withSpinner('Killing\x20attempt...',()=>_0x2ea1dc[_0x272e00(0x162)][_0x272e00(0x190)](_0x4f5737,_0x1d4c47),{'verbose':_0x580223[_0x272e00(0x1ae)]}),_0xea2a19=_0xcc8ad7[_0x272e00(0x1ba)];return console[_0x272e00(0x170)]('✔\x20'+_0xea2a19),0x0;}catch(_0x4e6e2a){if(_0x4e6e2a instanceof SDKError)return console[_0x272e00(0x170)](_0x272e00(0x17a)+_0x4e6e2a[_0x272e00(0x175)]),_0x4e6e2a['cause']&&console['error'](_0x272e00(0x186)+_0x4e6e2a[_0x272e00(0x16c)]),0x1;throw _0x4e6e2a;}}}function a25_0x3d52(){const _0xe571fd=['question','workflow:download','data','✔\x20Downloaded\x20','86lcZsSL','workflow:sessions','Task\x20name:\x20','512uRlvGO','78PUSdsx','Target:\x20','268115avNzod','limit','attemptId','Resume\x20from:\x20','force','attempts','includeRetried','projectName','session','push','params','\x20\x20New\x20attempt\x20ID:\x20','4066992kbipdQ','\x20\x20Revision:\x20','session:','Show\x20tasks\x20for\x20an\x20attempt','workflows','Getting\x20attempt\x20details...','Show\x20logs\x20for\x20a\x20specific\x20task','Are\x20you\x20sure\x20you\x20want\x20to\x20delete\x20project\x20\x22','✔\x20Deleted\x20project\x20','execute','\x20\x20Session\x20ID:\x20','Error:\x20Session\x20ID\x20or\x20attempt\x20ID\x20is\x20required','Delete\x20workflow\x20project\x20from\x20Treasure\x20Data','substring','Getting\x20attempt\x20tasks...','Listing\x20workflow\x20sessions...','workflow:kill','\x20(y/N):\x20','✔\x20Retry\x20started','Validation:\x20skipped','Project\x20directory:\x20','From\x20task:\x20','from','isDirectory','parse','workflow','...','status','download','List\x20all\x20workflow\x20projects','Error:\x20Attempt\x20ID\x20and\x20task\x20name\x20are\x20required','Include\x20retried:\x20yes','workflow:attempt','createInterface','7903GNesIi','cause','workflow:tasks','workflow:attempts','startsWith','error','Error:\x20Invalid\x20pattern.\x20Use\x20format:\x20project\x20or\x20project.workflow','attempt','\x22?\x20This\x20cannot\x20be\x20undone.','revision','message','ies','Attempt\x20ID:\x20','description','split','Error:\x20','readFile','\x20is\x20not\x20a\x20directory','name','Usage:\x20workflow\x20retry\x20session:<id>\x20or\x20workflow\x20retry\x20attempt:<id>','Download\x20workflow\x20project\x20from\x20Treasure\x20Data','List\x20workflow\x20execution\x20sessions','toLowerCase','Getting\x20task\x20logs...','7ogGDDq','Error:\x20Project\x20name\x20is\x20required','7826764eJOSKm','\x20\x20Cause:\x20','4449144KIiXSO','Error:\x20Invalid\x20JSON\x20in\x20--params','workflow:push','2626164HoxdcL','projects','\x20\x20Location:\x20','\x20project','Deleting\x20project\x20','Are\x20you\x20sure\x20you\x20want\x20to\x20kill\x20attempt\x20','kill','utf-8','Status:\x20','yes','Filter:\x20','workflow:projects','✔\x20Found\x20','\x20task','stat','Project\x20filter:\x20','Listing\x20workflow\x20projects...','List\x20workflow\x20attempts','✔\x20Pushed\x20','Error:\x20Project\x20name\x20or\x20ID\x20is\x20required','length','includeSubtasks','resumeFrom','Usage:\x20workflow:delete\x20<project-name-or-id>','tasks','workflow:logs','Usage:\x20workflow:download\x20<project-name>\x20[output-dir]','stdout','Retrying\x20attempt...','\x20\x20Files\x20extracted:\x20','10XRLnMc','Error:\x20Attempt\x20ID\x20is\x20required','Cancelled','Downloading\x20project\x20','Filter:\x20project=','Reason:\x20','verbose','Output\x20directory:\x20','skipValidation','Including\x20subtasks:\x20yes','Project:\x20','1662lllIDn','stdin','Are\x20you\x20sure\x20you\x20want\x20to\x20retry\x20','sessions','workflow:workflows'];a25_0x3d52=function(){return _0xe571fd;};return a25_0x3d52();}export class WorkflowRetryCommand extends BaseCommand{[a25_0x3b2214(0x17d)]='workflow:retry';['description']='Retry\x20a\x20session\x20or\x20attempt';async[a25_0x3b2214(0x152)](_0x1e6981){const _0x33832a=a25_0x3b2214,{options:_0x50ef7c,args:_0x18c337,tdx:_0x1a9887}=_0x1e6981,_0x73883e=_0x18c337[0x0];if(!_0x73883e)return console[_0x33832a(0x170)](_0x33832a(0x154)),console['error']('Usage:\x20workflow\x20retry\x20session:<id>\x20or\x20workflow\x20retry\x20attempt:<id>'),0x1;let _0x365f3f=![],_0x18e4fd=_0x73883e;if(_0x73883e[_0x33832a(0x16f)](_0x33832a(0x14b)))_0x365f3f=!![],_0x18e4fd=_0x73883e['substring'](0x8);else{if(_0x73883e[_0x33832a(0x16f)]('attempt:'))_0x365f3f=![],_0x18e4fd=_0x73883e[_0x33832a(0x156)](0x8);else return console[_0x33832a(0x170)]('Error:\x20Target\x20must\x20be\x20prefixed\x20with\x20\x22session:\x22\x20or\x20\x22attempt:\x22'),console[_0x33832a(0x170)](_0x33832a(0x17e)),0x1;}try{const _0xf03e3=_0x50ef7c['fromTask'],_0x9b2edc=_0x50ef7c[_0x33832a(0x1a0)],_0x48a3d0=_0x50ef7c[_0x33832a(0x147)],_0x3f14b0=_0x50ef7c[_0x33832a(0x1c6)];_0x50ef7c[_0x33832a(0x1ae)]&&(console[_0x33832a(0x170)](_0x33832a(0x1c1)+(_0x365f3f?_0x33832a(0x145):_0x33832a(0x172))+'\x20'+_0x18e4fd),_0xf03e3&&console['error'](_0x33832a(0x15e)+_0xf03e3),_0x9b2edc&&console[_0x33832a(0x170)](_0x33832a(0x1c5)+_0x9b2edc),_0x48a3d0&&console['error']('Params:\x20'+_0x48a3d0),_0x3f14b0&&console[_0x33832a(0x170)]('Force:\x20yes'));let _0x8f2dc5;if(_0x48a3d0)try{if(_0x48a3d0[_0x33832a(0x16f)]('@')){const _0x2ed77e=await import('fs/promises'),_0x16d2fc=_0x48a3d0[_0x33832a(0x156)](0x1),_0x53a560=await _0x2ed77e[_0x33832a(0x17b)](_0x16d2fc,_0x33832a(0x191));_0x8f2dc5=JSON[_0x33832a(0x161)](_0x53a560);}else _0x8f2dc5=JSON[_0x33832a(0x161)](_0x48a3d0);}catch{return console['error'](_0x33832a(0x188)),0x1;}if(!_0x50ef7c[_0x33832a(0x193)]){const _0x7cabe7=await confirm(_0x33832a(0x1b5)+(_0x365f3f?_0x33832a(0x145):_0x33832a(0x172))+'\x20'+_0x18e4fd+'?');if(!_0x7cabe7)return console[_0x33832a(0x170)](_0x33832a(0x1aa)),0x0;}let _0x3ca8ce;_0x365f3f?_0x3ca8ce=await withSpinner('Retrying\x20session...',()=>_0x1a9887[_0x33832a(0x162)]['retrySession'](_0x18e4fd,{'fromTask':_0xf03e3,'retryParams':_0x8f2dc5}),{'verbose':_0x50ef7c[_0x33832a(0x1ae)]}):_0x3ca8ce=await withSpinner(_0x33832a(0x1a6),()=>_0x1a9887[_0x33832a(0x162)]['retryAttempt'](_0x18e4fd,{'resumeFrom':_0x9b2edc,'retryParams':_0x8f2dc5,'force':_0x3f14b0}),{'verbose':_0x50ef7c['verbose']});const _0x22733a=_0x3ca8ce['data'];return console[_0x33832a(0x170)](_0x33832a(0x15b)),console[_0x33832a(0x170)](_0x33832a(0x148)+_0x22733a[_0x33832a(0x1c4)]),console[_0x33832a(0x170)](_0x33832a(0x153)+_0x22733a['sessionId']),0x0;}catch(_0x39c8a9){if(_0x39c8a9 instanceof SDKError)return console[_0x33832a(0x170)](_0x33832a(0x17a)+_0x39c8a9[_0x33832a(0x175)]),_0x39c8a9[_0x33832a(0x16c)]&&console[_0x33832a(0x170)](_0x33832a(0x186)+_0x39c8a9[_0x33832a(0x16c)]),0x1;throw _0x39c8a9;}}}export class WorkflowDownloadCommand extends BaseCommand{[a25_0x3b2214(0x17d)]=a25_0x3b2214(0x1b9);['description']=a25_0x3b2214(0x17f);async['execute'](_0x352665){const _0x206282=a25_0x3b2214,{options:_0x541655,args:_0x2ffef2,tdx:_0x150bf1}=_0x352665,_0x497986=_0x2ffef2[0x0],_0x1c47ed=_0x2ffef2[0x1]||'.';if(!_0x497986)return console[_0x206282(0x170)](_0x206282(0x184)),console[_0x206282(0x170)](_0x206282(0x1a4)),0x1;const _0x3b2c7c=_0x541655[_0x206282(0x174)];_0x541655[_0x206282(0x1ae)]&&(console[_0x206282(0x170)](_0x206282(0x1b2)+_0x497986),console['error'](_0x206282(0x1af)+_0x1c47ed),_0x3b2c7c&&console[_0x206282(0x170)]('Revision:\x20'+_0x3b2c7c));const _0x507b44=await withSpinner(_0x206282(0x1ab)+_0x497986+_0x206282(0x163),()=>_0x150bf1[_0x206282(0x162)][_0x206282(0x165)](_0x497986,_0x1c47ed,{'revision':_0x3b2c7c}),{'verbose':_0x541655[_0x206282(0x1ae)]}),_0x3e23c5=_0x507b44[_0x206282(0x1ba)];return console[_0x206282(0x170)](_0x206282(0x1bb)+_0x3e23c5[_0x206282(0x1c9)]),console['error'](_0x206282(0x14a)+_0x3e23c5[_0x206282(0x174)]),console[_0x206282(0x170)](_0x206282(0x1a7)+_0x3e23c5['filesExtracted']),console[_0x206282(0x170)](_0x206282(0x18c)+_0x1c47ed+'/'+_0x3e23c5[_0x206282(0x1c9)]),0x0;}}export class WorkflowPushCommand extends BaseCommand{[a25_0x3b2214(0x17d)]=a25_0x3b2214(0x189);[a25_0x3b2214(0x178)]='Push\x20workflow\x20project\x20to\x20Treasure\x20Data';async[a25_0x3b2214(0x152)](_0x365182){const _0x5652d0=a25_0x3b2214,{options:_0x4cfe02,args:_0x860e03,tdx:_0x57649d}=_0x365182;let _0x6ee7f='.',_0x4aa314=_0x4cfe02[_0x5652d0(0x17d)];if(_0x860e03[0x0]){const {promises:_0x5114a4}=await import('fs');try{const _0x138984=await _0x5114a4[_0x5652d0(0x198)](_0x860e03[0x0]);if(_0x138984[_0x5652d0(0x160)]())_0x6ee7f=_0x860e03[0x0];else return console['error'](_0x5652d0(0x17a)+_0x860e03[0x0]+_0x5652d0(0x17c)),0x1;}catch{_0x4aa314=_0x860e03[0x0],_0x6ee7f='.';}}const _0x42fee4=_0x4cfe02[_0x5652d0(0x174)],_0x244782=_0x4cfe02[_0x5652d0(0x1b0)];_0x4cfe02['verbose']&&(console[_0x5652d0(0x170)](_0x5652d0(0x15d)+_0x6ee7f),_0x4aa314&&console['error']('Project\x20name:\x20'+_0x4aa314),_0x42fee4&&console[_0x5652d0(0x170)]('Revision:\x20'+_0x42fee4),_0x244782&&console['error'](_0x5652d0(0x15c)));const _0x4e0143=await withSpinner('Pushing\x20workflow\x20project...',()=>_0x57649d[_0x5652d0(0x162)][_0x5652d0(0x146)](_0x6ee7f,{'projectName':_0x4aa314,'revision':_0x42fee4,'skipValidation':_0x244782}),{'verbose':_0x4cfe02[_0x5652d0(0x1ae)]}),_0x4e49db=_0x4e0143[_0x5652d0(0x1ba)];return console['error'](_0x5652d0(0x19c)+_0x4e49db['projectName']),console[_0x5652d0(0x170)]('\x20\x20Project\x20ID:\x20'+_0x4e49db['projectId']),console[_0x5652d0(0x170)](_0x5652d0(0x14a)+_0x4e49db[_0x5652d0(0x174)]),0x0;}}export class WorkflowDeleteCommand extends BaseCommand{[a25_0x3b2214(0x17d)]='workflow:delete';[a25_0x3b2214(0x178)]=a25_0x3b2214(0x155);async[a25_0x3b2214(0x152)](_0xb73721){const _0x26b554=a25_0x3b2214,{options:_0x275f1c,args:_0xe43f67,tdx:_0x3e7ed7}=_0xb73721,_0x4257e6=_0xe43f67[0x0];if(!_0x4257e6)return console[_0x26b554(0x170)](_0x26b554(0x19d)),console[_0x26b554(0x170)](_0x26b554(0x1a1)),0x1;_0x275f1c['verbose']&&console[_0x26b554(0x170)](_0x26b554(0x1b2)+_0x4257e6);if(!_0x275f1c[_0x26b554(0x193)]){const _0x49c222=await confirm(_0x26b554(0x150)+_0x4257e6+_0x26b554(0x173));if(!_0x49c222)return console[_0x26b554(0x170)](_0x26b554(0x1aa)),0x0;}const _0x25b861=await withSpinner(_0x26b554(0x18e)+_0x4257e6+'...',()=>_0x3e7ed7[_0x26b554(0x162)]['delete'](_0x4257e6),{'verbose':_0x275f1c[_0x26b554(0x1ae)]}),_0x212286=_0x25b861[_0x26b554(0x1ba)];return console['error'](_0x26b554(0x151)+_0x212286[_0x26b554(0x1c9)]),console[_0x26b554(0x170)]('\x20\x20Project\x20ID:\x20'+_0x212286['projectId']),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(
|
|
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);}
|
package/dist/core/config.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
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
|
-
|
|
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');}}}}
|
package/dist/core/profile.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(_0x34f8c6,_0x1dd2da){const _0x137749=a29_0x1094,_0x56fc2c=_0x34f8c6();while(!![]){try{const _0x210235=-parseInt(_0x137749(0x7a))/0x1+parseInt(_0x137749(0x83))/0x2*(-parseInt(_0x137749(0xb2))/0x3)+parseInt(_0x137749(0x88))/0x4+parseInt(_0x137749(0x8c))/0x5*(parseInt(_0x137749(0xbc))/0x6)+parseInt(_0x137749(0xb3))/0x7*(-parseInt(_0x137749(0x84))/0x8)+parseInt(_0x137749(0x75))/0x9+-parseInt(_0x137749(0x7e))/0xa;if(_0x210235===_0x1dd2da)break;else _0x56fc2c['push'](_0x56fc2c['shift']());}catch(_0x260c8a){_0x56fc2c['push'](_0x56fc2c['shift']());}}}(a29_0x18ef,0xd50db));import*as a29_0x7d1ca5 from'node:fs';import*as a29_0x20d995 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(_0x347309){const _0xd5689=a29_0x1094,_0x112021={};if(!_0x347309)return _0x112021;for(const [_0x39b093,_0x24dec0]of Object['entries'](_0x347309)){_0x39b093!==_0xd5689(0x7c)&&_0x24dec0!==undefined&&(_0x112021[_0x39b093]=_0x24dec0);}return _0x112021;}export function getProfilesDir(){const _0xf75b07=a29_0x1094;return a29_0x20d995[_0xf75b07(0xa0)](getConfigDir(),_0xf75b07(0xb8));}function getProfileDir(_0x2b0576){return a29_0x20d995['join'](getProfilesDir(),_0x2b0576);}function getProfileConfigPath(_0x3a04e3){const _0x4e4fc3=a29_0x1094;return a29_0x20d995['join'](getProfileDir(_0x3a04e3),_0x4e4fc3(0x87));}function getProfileEnvPath(_0x9fe322){const _0x1a031f=a29_0x1094;return a29_0x20d995[_0x1a031f(0xa0)](getProfileDir(_0x9fe322),_0x1a031f(0xbb));}function getGlobalConfigPath(){const _0x2e0cdb=a29_0x1094;return a29_0x20d995['join'](getConfigDir(),_0x2e0cdb(0x87));}function validateProfileName(_0x28a17e){const _0x22b39b=a29_0x1094;if(!/^[a-zA-Z0-9_-]+$/[_0x22b39b(0x8e)](_0x28a17e))throw new Error(_0x22b39b(0xa9)+_0x28a17e+_0x22b39b(0x89));}function a29_0x18ef(){const _0x92ae99=['Then\x20define\x20profiles\x20in\x20~/.config/tdx/tdx.json\x0a','13858002BGZmtB','llm_project','sort','TD_API_KEY','\x27:\x20\x27llm_project\x27\x20must\x20be\x20a\x20string','93189FjywnM','parse','description','Warning:\x20Profile\x20\x27','11695320KETnov','entries','has','Profile\x20','\x0aWarning:\x20Profiles\x20in\x20directories\x20are\x20deprecated:\x20','18LhJKKQ','8HRhQGV','\x27\x20will\x20be\x20ignored','profile','tdx.json','6506144gRNUDD','.\x20Must\x20contain\x20only\x20alphanumeric\x20characters,\x20dash,\x20and\x20underscore.','llm_agent','parent_segment','40iavdAh','user','test','toISOString','\x27:\x20\x27parent_segment\x27\x20must\x20be\x20a\x20string','local','apiKey','isDirectory','\x27:\x20\x27description\x27\x20must\x20be\x20a\x20string','keys','readdirSync','some','filter','\x0aWarning:\x20Failed\x20to\x20parse\x20','api_key','stringify','Error:\x20','localeCompare','\x0aWarning:\x20Failed\x20to\x20load\x20profiles\x20from\x20','\x22\x20\x22','join','warn','object','\x20\x20mv\x20\x22','push','string','find','message','map','Invalid\x20profile\x20name:\x20','\x27:\x20\x27site\x27\x20must\x20be\x20a\x20string','site','existsSync','includes','readFileSync','To\x20migrate:','\x20\x203.\x20Move\x20credentials:\x20mv\x20~/.config/tdx/profiles/<name>/.env\x20~/.config/tdx/.env.<name>\x0a','\x20does\x20not\x20exist','40647fLFdAb','11961383JFcQvG','\x27:\x20unknown\x20config\x20key\x20\x27','\x0aWarning:\x20Skipping\x20invalid\x20profile\x20in\x20','database','writeFileSync','profiles','utf-8','lastUsed','.env','599838BgzAoB','\x0aWarning:\x20Using\x20deprecated\x20credential\x20location\x20for\x20profile\x20\x27','directory','.env.','name','Profile\x20\x27'];a29_0x18ef=function(){return _0x92ae99;};return a29_0x18ef();}function validateProfileConfig(_0xad8bc4,_0x57ee4e){const _0x4e1be3=a29_0x1094;if(typeof _0xad8bc4!==_0x4e1be3(0xa2)||_0xad8bc4===null)throw new Error(_0x4e1be3(0x73)+_0x57ee4e+'\x27:\x20config\x20must\x20be\x20an\x20object');const _0x310c31=['description','site',_0x4e1be3(0xb6),'parent_segment',_0x4e1be3(0x76),_0x4e1be3(0x8a)],_0x5b5220=_0xad8bc4;for(const _0x58226b of Object[_0x4e1be3(0x95)](_0x5b5220)){!_0x310c31[_0x4e1be3(0xad)](_0x58226b)&&console[_0x4e1be3(0xa1)](_0x4e1be3(0x7d)+_0x57ee4e+_0x4e1be3(0xb4)+_0x58226b+_0x4e1be3(0x85));}if(_0x5b5220[_0x4e1be3(0x7c)]!==undefined&&typeof _0x5b5220['description']!==_0x4e1be3(0xa5))throw new Error(_0x4e1be3(0x73)+_0x57ee4e+_0x4e1be3(0x94));if(_0x5b5220[_0x4e1be3(0xab)]!==undefined&&typeof _0x5b5220[_0x4e1be3(0xab)]!=='string')throw new Error('Profile\x20\x27'+_0x57ee4e+_0x4e1be3(0xaa));if(_0x5b5220['database']!==undefined&&typeof _0x5b5220[_0x4e1be3(0xb6)]!==_0x4e1be3(0xa5))throw new Error(_0x4e1be3(0x73)+_0x57ee4e+'\x27:\x20\x27database\x27\x20must\x20be\x20a\x20string');if(_0x5b5220['parent_segment']!==undefined&&typeof _0x5b5220[_0x4e1be3(0x8b)]!==_0x4e1be3(0xa5))throw new Error('Profile\x20\x27'+_0x57ee4e+_0x4e1be3(0x90));if(_0x5b5220[_0x4e1be3(0x76)]!==undefined&&typeof _0x5b5220['llm_project']!==_0x4e1be3(0xa5))throw new Error(_0x4e1be3(0x73)+_0x57ee4e+_0x4e1be3(0x79));if(_0x5b5220[_0x4e1be3(0x8a)]!==undefined&&typeof _0x5b5220[_0x4e1be3(0x8a)]!==_0x4e1be3(0xa5))throw new Error(_0x4e1be3(0x73)+_0x57ee4e+'\x27:\x20\x27llm_agent\x27\x20must\x20be\x20a\x20string');return!![];}function loadProfilesFromTdxJson(_0x54589f,_0x3ac282){const _0x5e928c=a29_0x1094;if(!a29_0x7d1ca5[_0x5e928c(0xac)](_0x54589f))return[];try{const _0x2a3284=a29_0x7d1ca5[_0x5e928c(0xae)](_0x54589f,_0x5e928c(0xb9)),_0x25b279=JSON[_0x5e928c(0x7b)](_0x2a3284);if(!_0x25b279[_0x5e928c(0xb8)]||typeof _0x25b279[_0x5e928c(0xb8)]!==_0x5e928c(0xa2))return[];const _0x3666ee=[];for(const [_0x563240,_0x2ae0a1]of Object[_0x5e928c(0x7f)](_0x25b279[_0x5e928c(0xb8)])){try{validateProfileConfig(_0x2ae0a1,_0x563240);const _0x47fb4b=getNewCredentialPath(_0x563240),_0x34cb30=getOldCredentialPath(_0x563240),_0x4ef623=a29_0x7d1ca5['existsSync'](_0x47fb4b)||a29_0x7d1ca5[_0x5e928c(0xac)](_0x34cb30);_0x3666ee[_0x5e928c(0xa4)]({'name':_0x563240,'config':_0x2ae0a1,'metadata':{'name':_0x563240,'createdAt':new Date()['toISOString']()},'hasCredentials':_0x4ef623,'scope':_0x3ac282});}catch(_0x426d3f){_0x426d3f instanceof Error&&(console[_0x5e928c(0xa1)](_0x5e928c(0xb5)+_0x54589f+':'),console['warn']('\x20\x20'+_0x426d3f[_0x5e928c(0xa7)]+'\x0a'));}}return _0x3666ee;}catch(_0x300709){return _0x300709 instanceof SyntaxError?(console[_0x5e928c(0xa1)](_0x5e928c(0x99)+_0x54589f+':\x20Invalid\x20JSON\x20syntax'),console['warn'](_0x5e928c(0x9c)+_0x300709[_0x5e928c(0xa7)]+'\x0a')):console['warn'](_0x5e928c(0x9e)+_0x54589f+':\x20'+_0x300709+'\x0a'),[];}}function a29_0x1094(_0xdd3a7,_0x4766ba){const _0x18ef04=a29_0x18ef();return a29_0x1094=function(_0x109446,_0x55b287){_0x109446=_0x109446-0x73;let _0xd15baf=_0x18ef04[_0x109446];return _0xd15baf;},a29_0x1094(_0xdd3a7,_0x4766ba);}export function getNewCredentialPath(_0x352e7c){const _0x45537f=a29_0x1094;return a29_0x20d995['join'](getConfigDir(),_0x45537f(0xbf)+_0x352e7c);}function getOldCredentialPath(_0x374bbf){const _0x4af4cd=a29_0x1094;return a29_0x20d995[_0x4af4cd(0xa0)](getProfilesDir(),_0x374bbf,'.env');}function loadProfilesFromTdxJsonFiles(){const _0x80d1ad=a29_0x1094,_0xe34d65=[],_0x5d5b71=findProjectConfigPath();_0x5d5b71&&_0xe34d65[_0x80d1ad(0xa4)](...loadProfilesFromTdxJson(_0x5d5b71,_0x80d1ad(0x91)));const _0x4779fa=a29_0x20d995[_0x80d1ad(0xa0)](getConfigDir(),_0x80d1ad(0x87));return _0xe34d65['push'](...loadProfilesFromTdxJson(_0x4779fa,_0x80d1ad(0x8d))),_0xe34d65;}function loadProfilesFromDirectories(){const _0x17c411=a29_0x1094,_0xe1d055=getProfilesDir();if(!a29_0x7d1ca5[_0x17c411(0xac)](_0xe1d055))return[];try{return a29_0x7d1ca5[_0x17c411(0x96)](_0xe1d055,{'withFileTypes':!![]})[_0x17c411(0x98)](_0x43546f=>_0x43546f[_0x17c411(0x93)]())[_0x17c411(0xa8)](_0x8a6a94=>_0x8a6a94[_0x17c411(0xc0)])[_0x17c411(0x98)](_0x2e2e50=>{const _0x59ae03=_0x17c411,_0x48006a=getProfileConfigPath(_0x2e2e50),_0x156a7e=getProfileEnvPath(_0x2e2e50);return a29_0x7d1ca5[_0x59ae03(0xac)](_0x48006a)||a29_0x7d1ca5['existsSync'](_0x156a7e);})[_0x17c411(0xa8)](_0x332c98=>{const _0x182b2f=loadProfileFromDirectory(_0x332c98);if(_0x182b2f)return{..._0x182b2f,'scope':'directory'};return null;})[_0x17c411(0x98)](_0x552690=>_0x552690!==null);}catch{return[];}}function loadProfileFromDirectory(_0x34ac17){const _0x171e39=a29_0x1094,_0x2168f5=getProfileConfigPath(_0x34ac17),_0x183032=getOldCredentialPath(_0x34ac17);if(!a29_0x7d1ca5[_0x171e39(0xac)](_0x2168f5)&&!a29_0x7d1ca5[_0x171e39(0xac)](_0x183032))return null;let _0x4cda55={},_0x776df9={'name':_0x34ac17,'createdAt':new Date()[_0x171e39(0x8f)]()};if(a29_0x7d1ca5[_0x171e39(0xac)](_0x2168f5))try{const _0x273219=a29_0x7d1ca5[_0x171e39(0xae)](_0x2168f5,'utf-8'),_0x1e42df=JSON['parse'](_0x273219),{metadata:_0x554f76,..._0x52ee54}=_0x1e42df;_0x4cda55=_0x52ee54,_0x554f76&&(_0x776df9=_0x554f76);}catch{}return{'name':_0x34ac17,'config':_0x4cda55,'metadata':_0x776df9,'hasCredentials':a29_0x7d1ca5[_0x171e39(0xac)](_0x183032),'scope':_0x171e39(0xbe)};}export function listProfiles(){const _0x18498e=a29_0x1094,_0x5b28bb=loadProfilesFromTdxJsonFiles(),_0x44ae27=loadProfilesFromDirectories();if(_0x44ae27['length']>0x0){const _0x5203f9=_0x44ae27[_0x18498e(0xa8)](_0x299e14=>_0x299e14[_0x18498e(0xc0)])[_0x18498e(0xa0)](',\x20'),_0x3baa2d=getConfigDir();console['warn'](_0x18498e(0x82)+_0x5203f9),console[_0x18498e(0xa1)]('Please\x20migrate\x20to\x20~/.config/tdx/tdx.json:'),console[_0x18498e(0xa1)]('\x20\x201.\x20Edit:\x20'+a29_0x20d995[_0x18498e(0xa0)](_0x3baa2d,_0x18498e(0x87))),console[_0x18498e(0xa1)]('\x20\x202.\x20Add\x20profiles\x20under\x20a\x20\x22profiles\x22\x20key\x20(see\x20\x27tdx\x20profiles\x27\x20for\x20current\x20config)'),console[_0x18498e(0xa1)](_0x18498e(0xb0));}const _0x35f27d=[..._0x5b28bb,..._0x44ae27],_0x50948b=new Map();for(const _0x5eb43f of _0x35f27d){!_0x50948b[_0x18498e(0x80)](_0x5eb43f[_0x18498e(0xc0)])&&_0x50948b['set'](_0x5eb43f[_0x18498e(0xc0)],_0x5eb43f);}return Array['from'](_0x50948b['values']())[_0x18498e(0x77)]((_0x94723d,_0x52ba0d)=>_0x94723d[_0x18498e(0xc0)][_0x18498e(0x9d)](_0x52ba0d[_0x18498e(0xc0)]));}export function profileExists(_0x4a0e34){const _0x3bc1eb=a29_0x1094,_0x5acdbf=listProfiles();return _0x5acdbf[_0x3bc1eb(0x97)](_0x105be0=>_0x105be0[_0x3bc1eb(0xc0)]===_0x4a0e34);}export function loadProfile(_0x11c00b){const _0x40dad6=a29_0x1094;validateProfileName(_0x11c00b);const _0x1870c2=listProfiles(),_0x93fdd0=_0x1870c2[_0x40dad6(0xa6)](_0x39ba51=>_0x39ba51[_0x40dad6(0xc0)]===_0x11c00b);return _0x93fdd0||null;}export function saveProfile(_0xbf85db,_0x43ce6d,_0x50e097=![]){const _0x24e311=a29_0x1094;validateProfileName(_0xbf85db);const _0x4dafc9=getProfileDir(_0xbf85db),_0x102021=getProfileConfigPath(_0xbf85db);createSecureDirectory(_0x4dafc9);let _0x1c5299;const _0x1750fc=loadProfile(_0xbf85db);_0x1750fc?(_0x1c5299=_0x1750fc['metadata'],_0x50e097&&(_0x1c5299[_0x24e311(0xba)]=new Date()['toISOString']())):_0x1c5299={'name':_0xbf85db,'createdAt':new Date()['toISOString']()};const _0x4c0e5a=JSON[_0x24e311(0x9b)](_0x43ce6d);if(_0x4c0e5a[_0x24e311(0xad)](_0x24e311(0x78))||_0x4c0e5a[_0x24e311(0xad)](_0x24e311(0x92))||_0x4c0e5a[_0x24e311(0xad)](_0x24e311(0x9a)))throw new Error('API\x20keys\x20must\x20not\x20be\x20stored\x20in\x20profile\x20configuration.\x20Use\x20.env\x20file\x20instead.');const _0x243e78={..._0x43ce6d,'metadata':_0x1c5299};a29_0x7d1ca5[_0x24e311(0xb7)](_0x102021,JSON['stringify'](_0x243e78,null,0x2));}export function deleteProfile(_0x499cb7){const _0xb8405a=a29_0x1094;validateProfileName(_0x499cb7);const _0x294412=getProfileDir(_0x499cb7);if(!a29_0x7d1ca5['existsSync'](_0x294412))throw new Error(_0xb8405a(0x81)+_0x499cb7+'\x20does\x20not\x20exist');a29_0x7d1ca5['rmSync'](_0x294412,{'recursive':!![],'force':!![]});}export function getActiveProfile(){const _0x5b3eed=a29_0x1094,_0x1edaf0=getGlobalConfigPath();if(!a29_0x7d1ca5[_0x5b3eed(0xac)](_0x1edaf0))return null;try{const _0x8f8505=a29_0x7d1ca5['readFileSync'](_0x1edaf0,_0x5b3eed(0xb9)),_0x1db168=JSON[_0x5b3eed(0x7b)](_0x8f8505);return _0x1db168[_0x5b3eed(0x86)]||null;}catch{return null;}}export function createProfile(_0x4872b3,_0x3f4583){const _0x1c9517=a29_0x1094;validateProfileName(_0x4872b3);if(profileExists(_0x4872b3))throw new Error(_0x1c9517(0x81)+_0x4872b3+'\x20already\x20exists');saveProfile(_0x4872b3,_0x3f4583);}export function saveProfileCredentials(_0x519d21,_0x47b793){const _0x5cca47=a29_0x1094;validateProfileName(_0x519d21);if(!profileExists(_0x519d21))throw new Error('Profile\x20'+_0x519d21+_0x5cca47(0xb1));const _0xa14fad=getNewCredentialPath(_0x519d21);writeSecureFile(_0xa14fad,_0x47b793);}export function loadProfileCredentials(_0xa4431a){const _0x25488b=a29_0x1094;validateProfileName(_0xa4431a);const _0x951ac6=getNewCredentialPath(_0xa4431a);if(a29_0x7d1ca5[_0x25488b(0xac)](_0x951ac6))try{return a29_0x7d1ca5[_0x25488b(0xae)](_0x951ac6,_0x25488b(0xb9));}catch{}const _0xed7cff=getOldCredentialPath(_0xa4431a);if(a29_0x7d1ca5['existsSync'](_0xed7cff)){console['warn'](_0x25488b(0xbd)+_0xa4431a+'\x27'),console[_0x25488b(0xa1)](_0x25488b(0xaf)),console[_0x25488b(0xa1)](_0x25488b(0xa3)+_0xed7cff+_0x25488b(0x9f)+_0x951ac6+'\x22'),console[_0x25488b(0xa1)](_0x25488b(0x74));try{return a29_0x7d1ca5[_0x25488b(0xae)](_0xed7cff,_0x25488b(0xb9));}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
|
-
(function(
|
|
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();}
|
package/dist/core/session.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(
|
|
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(
|
|
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(_0x3e5d24,_0x5a44e6){const _0x449f1a=a33_0x5cad,_0x32360f=_0x3e5d24();while(!![]){try{const _0xf8c6e3=-parseInt(_0x449f1a(0x210))/0x1+-parseInt(_0x449f1a(0x1d9))/0x2*(parseInt(_0x449f1a(0x1dd))/0x3)+parseInt(_0x449f1a(0x20c))/0x4+parseInt(_0x449f1a(0x1d3))/0x5+parseInt(_0x449f1a(0x212))/0x6+-parseInt(_0x449f1a(0x1ea))/0x7+parseInt(_0x449f1a(0x1e1))/0x8;if(_0xf8c6e3===_0x5a44e6)break;else _0x32360f['push'](_0x32360f['shift']());}catch(_0x89c7c4){_0x32360f['push'](_0x32360f['shift']());}}}(a33_0x343e,0x88f52));function generateMessageId(){const _0x5f231b=a33_0x5cad;return'msg_'+Math[_0x5f231b(0x1cd)]()[_0x5f231b(0x1fa)](0x24)[_0x5f231b(0x1f0)](0x2,0xf)+Math[_0x5f231b(0x1cd)]()[_0x5f231b(0x1fa)](0x24)[_0x5f231b(0x1f0)](0x2,0xf);}export function extractTextFromAnthropicMessage(_0x290e6e){const _0x84409e=a33_0x5cad;if(typeof _0x290e6e[_0x84409e(0x1f7)]===_0x84409e(0x1e7))return _0x290e6e[_0x84409e(0x1f7)];return _0x290e6e[_0x84409e(0x1f7)][_0x84409e(0x1d1)](_0xc0c42c=>_0xc0c42c[_0x84409e(0x1fe)]===_0x84409e(0x1cf)&&_0xc0c42c[_0x84409e(0x1cf)])[_0x84409e(0x1fd)](_0x2830cb=>_0x2830cb[_0x84409e(0x1cf)])['join']('\x0a');}export function calculateConversationDelta(_0xa2f417,_0x5f46e6){const _0x1af5ef=a33_0x5cad;if(_0x5f46e6['length']===0x0)return _0xa2f417;const _0x4f498c=_0x5f46e6[_0x1af5ef(0x218)];return _0xa2f417[_0x1af5ef(0x1eb)](_0x4f498c);}export function transformAnthropicRequestToTD(_0xe4df90,_0x1b70d0){const _0x36cb84=a33_0x5cad,_0x90e125=calculateConversationDelta(_0xe4df90[_0x36cb84(0x1ca)],_0x1b70d0),_0x336e35=_0x90e125[_0x36cb84(0x1d1)](_0x306101=>_0x306101[_0x36cb84(0x1f6)]===_0x36cb84(0x217))[_0x36cb84(0x1e2)]();if(!_0x336e35)throw new Error(_0x36cb84(0x1e5));const _0x30d757=extractTextFromAnthropicMessage(_0x336e35);return{'userMessage':_0x30d757,'deltaMessages':_0x90e125};}export async function*transformTDStreamToAnthropic(_0x528b1a,_0x19f1dd,_0x1c510d){const _0x2c0c56=a33_0x5cad;let _0x2e6cea=0x0,_0xb6fe0f=0x0,_0x26ca92=0x0,_0x2fbe7a=![];const _0x9f8bc6={'type':_0x2c0c56(0x1d0),'message':{'id':_0x19f1dd,'type':_0x2c0c56(0x201),'role':_0x2c0c56(0x1e0),'content':[],'model':_0x1c510d,'stop_reason':null,'stop_sequence':null,'usage':{'input_tokens':_0x2e6cea,'output_tokens':0x0}}};yield _0x9f8bc6;for await(const _0x106334 of _0x528b1a){if(_0x2c0c56(0x1f7)in _0x106334){const _0x264d93=_0x106334;if(!_0x2fbe7a){const _0x396617={'type':_0x2c0c56(0x1f1),'index':_0x26ca92,'content_block':{'type':_0x2c0c56(0x1cf),'text':''}};yield _0x396617,_0x2fbe7a=!![];}const _0x318942={'type':'content_block_delta','index':_0x26ca92,'delta':{'type':_0x2c0c56(0x20e),'text':_0x264d93[_0x2c0c56(0x1f7)]}};yield _0x318942,_0xb6fe0f+=Math[_0x2c0c56(0x1d8)](_0x264d93['content']['length']/0x4);}else{if(_0x2c0c56(0x1f9)in _0x106334){const _0x4a8d4e=_0x106334;console[_0x2c0c56(0x20b)](_0x2c0c56(0x1e9),_0x4a8d4e);}else{if(_0x2c0c56(0x209)in _0x106334){const _0x236710=_0x106334;yield{'type':'error','error':{'type':'api_error','message':_0x236710[_0x2c0c56(0x209)]}};return;}}}}if(_0x2fbe7a){const _0x17b5be={'type':_0x2c0c56(0x1fb),'index':_0x26ca92};yield _0x17b5be;}const _0x4a1cae={'type':'message_delta','delta':{'stop_reason':_0x2c0c56(0x1f2),'stop_sequence':null},'usage':{'output_tokens':_0xb6fe0f}};yield _0x4a1cae;const _0xb27ad={'type':_0x2c0c56(0x1d2)};yield _0xb27ad;}export function formatAnthropicSSE(_0x59879c){const _0xbaf0b1=a33_0x5cad;return _0xbaf0b1(0x20a)+_0x59879c[_0xbaf0b1(0x1fe)]+'\x0adata:\x20'+JSON[_0xbaf0b1(0x1c9)](_0x59879c)+'\x0a\x0a';}export function mapAnthropicModelToTD(_0x4aa659){const _0xfc0d20=a33_0x5cad,_0x1c5c6e={'sonnet':_0xfc0d20(0x1ff),'claude-sonnet':'sonnet','claude-3-5-sonnet':_0xfc0d20(0x1ff),'claude-3-sonnet':'sonnet','haiku':_0xfc0d20(0x1cc),'claude-haiku':_0xfc0d20(0x1cc),'claude-3-5-haiku':_0xfc0d20(0x1cc),'claude-3-haiku':_0xfc0d20(0x1cc),'opus':_0xfc0d20(0x1f4),'claude-opus':_0xfc0d20(0x1f4),'claude-3-opus':_0xfc0d20(0x1f4)},_0x45c088=_0x4aa659[_0xfc0d20(0x1ce)]();return _0x1c5c6e[_0x45c088]||_0xfc0d20(0x1ff);}export function generateToolPrompt(_0x2933d8){const _0x486784=a33_0x5cad;if(!_0x2933d8||_0x2933d8[_0x486784(0x218)]===0x0)return'';const _0x5e0108=_0x2933d8['map'](_0x1ca2a4=>{const _0x52f2c2=_0x486784,_0x4b4ff6=_0x1ca2a4['input_schema'][_0x52f2c2(0x1ed)]?Object[_0x52f2c2(0x204)](_0x1ca2a4[_0x52f2c2(0x1dc)][_0x52f2c2(0x1ed)])[_0x52f2c2(0x1fd)](([_0xd93a65,_0x35cefd])=>{const _0x48bede=_0x52f2c2,_0x1db3d1=_0x1ca2a4[_0x48bede(0x1dc)]['required']?.[_0x48bede(0x1d6)](_0xd93a65)?_0x48bede(0x1df):'',_0x5845b3=_0x35cefd,_0x49f214=_0x5845b3['description']?':\x20'+_0x5845b3[_0x48bede(0x219)]:'';return _0x48bede(0x205)+_0xd93a65+_0x1db3d1+_0x49f214;})[_0x52f2c2(0x216)]('\x0a'):_0x52f2c2(0x207);return'-\x20'+_0x1ca2a4['name']+':\x20'+(_0x1ca2a4[_0x52f2c2(0x219)]||'No\x20description')+'\x0a\x20\x20Parameters:\x0a'+_0x4b4ff6;})[_0x486784(0x216)]('\x0a\x0a');return _0x486784(0x1de)+_0x5e0108+_0x486784(0x214);}function escapeXml(_0x2b13e4){const _0x533e4d=a33_0x5cad;return _0x2b13e4[_0x533e4d(0x20f)](/&/g,_0x533e4d(0x213))[_0x533e4d(0x20f)](/</g,_0x533e4d(0x20d))[_0x533e4d(0x20f)](/>/g,'>')['replace'](/"/g,_0x533e4d(0x1f5))[_0x533e4d(0x20f)](/'/g,''');}export function extractToolResults(_0x3130f1){const _0x378928=a33_0x5cad,_0x39db17=[];for(const _0x4b3531 of _0x3130f1){if(_0x4b3531[_0x378928(0x1f6)]==='user'&&typeof _0x4b3531['content']!==_0x378928(0x1e7))for(const _0x46cdbc of _0x4b3531[_0x378928(0x1f7)]){if(_0x46cdbc[_0x378928(0x1fe)]===_0x378928(0x200)&&_0x46cdbc[_0x378928(0x1e6)]){let _0xeb3ea1='';if(typeof _0x46cdbc['content']===_0x378928(0x1e7))_0xeb3ea1=_0x46cdbc[_0x378928(0x1f7)];else Array['isArray'](_0x46cdbc['content'])&&(_0xeb3ea1=_0x46cdbc['content'][_0x378928(0x1d1)](_0x2c528e=>_0x2c528e['type']===_0x378928(0x1cf)&&_0x2c528e[_0x378928(0x1cf)])['map'](_0x4e78e3=>_0x4e78e3['text'])[_0x378928(0x216)]('\x0a'));const _0x2e3d0a=escapeXml(_0x46cdbc[_0x378928(0x1e6)]),_0x8e102e=escapeXml(_0xeb3ea1),_0x248a2e=_0x46cdbc[_0x378928(0x1e3)]?_0x378928(0x1f8):'';_0x39db17[_0x378928(0x1c8)](_0x378928(0x1db)+_0x2e3d0a+'\x22'+_0x248a2e+'>\x0a'+_0x8e102e+_0x378928(0x1d4));}}}if(_0x39db17[_0x378928(0x218)]===0x0)return'';return _0x39db17['join']('\x0a\x0a')+_0x378928(0x1e8);}function a33_0x5cad(_0x492b42,_0xcfb10f){const _0x343e78=a33_0x343e();return a33_0x5cad=function(_0x5cad07,_0x1d882b){_0x5cad07=_0x5cad07-0x1c8;let _0x12a31d=_0x343e78[_0x5cad07];return _0x12a31d;},a33_0x5cad(_0x492b42,_0xcfb10f);}function findJsonEndIndex(_0x4aa806,_0x1d8929){const _0x117df5=a33_0x5cad;let _0x50e022=0x0,_0x1a9c3b=![],_0x5db0b4=![];for(let _0x6f6a88=_0x1d8929;_0x6f6a88<_0x4aa806[_0x117df5(0x218)];_0x6f6a88++){const _0xd59e6e=_0x4aa806[_0x6f6a88];if(_0x5db0b4){_0x5db0b4=![];continue;}if(_0xd59e6e==='\x5c'){_0x5db0b4=!![];continue;}if(_0xd59e6e==='\x22'){_0x1a9c3b=!_0x1a9c3b;continue;}if(!_0x1a9c3b){if(_0xd59e6e==='{')_0x50e022++;else{if(_0xd59e6e==='}'){_0x50e022--;if(_0x50e022===0x0)return _0x6f6a88+0x1;}}}}return-0x1;}export function parseToolCallFromText(_0x157736){const _0x4c6908=a33_0x5cad,_0xa72109=/\{"tool_use":/g,_0x27b088=_0xa72109['exec'](_0x157736);if(!_0x27b088)return null;const _0x5c06e5=_0x27b088[_0x4c6908(0x202)],_0x173dbe=findJsonEndIndex(_0x157736,_0x5c06e5);if(_0x173dbe===-0x1)return null;const _0x21cd49=_0x157736[_0x4c6908(0x1f0)](_0x5c06e5,_0x173dbe);try{const _0x235d2b=JSON[_0x4c6908(0x1cb)](_0x21cd49);if(_0x235d2b[_0x4c6908(0x203)]&&_0x235d2b[_0x4c6908(0x203)]['id']&&_0x235d2b[_0x4c6908(0x203)]['name'])return{'id':_0x235d2b['tool_use']['id'],'name':_0x235d2b[_0x4c6908(0x203)][_0x4c6908(0x1da)],'input':_0x235d2b['tool_use'][_0x4c6908(0x1ee)]||{},'startIndex':_0x5c06e5,'endIndex':_0x173dbe};}catch{return null;}return null;}export function*generateToolCallEvents(_0x2aebdc,_0x516354){const _0x49bbf5=a33_0x5cad,_0x455932={'type':_0x49bbf5(0x1f1),'index':_0x516354,'content_block':{'type':_0x49bbf5(0x203),'id':_0x2aebdc['id'],'name':_0x2aebdc[_0x49bbf5(0x1da)],'input':{}}};yield _0x455932;const _0x465177=JSON[_0x49bbf5(0x1c9)](_0x2aebdc[_0x49bbf5(0x1ee)]),_0x3ed318={'type':'content_block_delta','index':_0x516354,'delta':{'type':_0x49bbf5(0x1f3),'partial_json':_0x465177}};yield _0x3ed318;const _0x48dc09={'type':_0x49bbf5(0x1fb),'index':_0x516354};yield _0x48dc09;const _0x28a914={'type':_0x49bbf5(0x206),'delta':{'stop_reason':_0x49bbf5(0x203),'stop_sequence':null},'usage':{'output_tokens':0x0}};yield _0x28a914;const _0x132570={'type':_0x49bbf5(0x1d2)};yield _0x132570;}export async function*transformTDStreamWithToolDetection(_0x212b9c,_0xf01e18,_0x2a4bb7,_0x2d9653=![]){const _0x582d26=a33_0x5cad;let _0x159bc2=0x0,_0x234f89=0x0,_0x4a2ce1=0x0,_0xec3dc1=![],_0x1050c6='',_0x2804b5=0x0,_0x12e460=![];const _0x223d07=0xc8,_0xfa0d8b={'type':'message_start','message':{'id':_0xf01e18,'type':_0x582d26(0x201),'role':_0x582d26(0x1e0),'content':[],'model':_0x2a4bb7,'stop_reason':null,'stop_sequence':null,'usage':{'input_tokens':_0x159bc2,'output_tokens':0x0}}};yield _0xfa0d8b;for await(const _0x39913f of _0x212b9c){if(_0x582d26(0x1f7)in _0x39913f){const _0xc014b1=_0x39913f;_0x1050c6+=_0xc014b1[_0x582d26(0x1f7)];const _0x44e812=_0x1050c6[_0x582d26(0x1ef)](_0x582d26(0x1d7));if(_0x44e812!==-0x1){const _0xc91aca=parseToolCallFromText(_0x1050c6);if(_0xc91aca){_0x12e460=!![];_0x2d9653&&(console[_0x582d26(0x209)](_0x582d26(0x1d5),_0xc91aca[_0x582d26(0x1da)]),console[_0x582d26(0x209)](''));const _0x2d228b=_0x1050c6[_0x582d26(0x1f0)](_0x2804b5,_0xc91aca[_0x582d26(0x1e4)])[_0x582d26(0x208)]();if(_0x2d228b){if(!_0xec3dc1){const _0x4bbffc={'type':_0x582d26(0x1f1),'index':_0x4a2ce1,'content_block':{'type':_0x582d26(0x1cf),'text':''}};yield _0x4bbffc,_0xec3dc1=!![];}const _0x1f9eb9={'type':_0x582d26(0x211),'index':_0x4a2ce1,'delta':{'type':_0x582d26(0x20e),'text':_0x2d228b}};yield _0x1f9eb9,_0x234f89+=Math[_0x582d26(0x1d8)](_0x2d228b[_0x582d26(0x218)]/0x4);}if(_0xec3dc1){const _0x2ab5={'type':'content_block_stop','index':_0x4a2ce1};yield _0x2ab5,_0x4a2ce1++;}for(const _0x148c5e of generateToolCallEvents(_0xc91aca,_0x4a2ce1)){_0x148c5e['type']===_0x582d26(0x206)&&(_0x148c5e[_0x582d26(0x215)][_0x582d26(0x1ec)]=_0x234f89),yield _0x148c5e;}return;}const _0x1cc717=_0x1050c6[_0x582d26(0x1f0)](_0x2804b5,_0x44e812);if(_0x1cc717){if(!_0xec3dc1){const _0x5194a0={'type':_0x582d26(0x1f1),'index':_0x4a2ce1,'content_block':{'type':'text','text':''}};yield _0x5194a0,_0xec3dc1=!![];}const _0x312ce1={'type':'content_block_delta','index':_0x4a2ce1,'delta':{'type':'text_delta','text':_0x1cc717}};yield _0x312ce1,_0x234f89+=Math['ceil'](_0x1cc717['length']/0x4),_0x2804b5=_0x44e812;}continue;}const _0x59dfcd=_0x1050c6[_0x582d26(0x218)]-_0x223d07;if(_0x59dfcd>_0x2804b5){const _0x53dfd0=_0x1050c6[_0x582d26(0x1f0)](_0x2804b5,_0x59dfcd);if(_0x53dfd0){if(!_0xec3dc1){const _0x4b18ea={'type':'content_block_start','index':_0x4a2ce1,'content_block':{'type':_0x582d26(0x1cf),'text':''}};yield _0x4b18ea,_0xec3dc1=!![];}const _0x540a74={'type':_0x582d26(0x211),'index':_0x4a2ce1,'delta':{'type':_0x582d26(0x20e),'text':_0x53dfd0}};yield _0x540a74,_0x234f89+=Math[_0x582d26(0x1d8)](_0x53dfd0[_0x582d26(0x218)]/0x4),_0x2804b5=_0x59dfcd;}}}else{if(_0x582d26(0x209)in _0x39913f){const _0x1de4cb=_0x39913f;yield{'type':_0x582d26(0x209),'error':{'type':_0x582d26(0x1fc),'message':_0x1de4cb[_0x582d26(0x209)]}};return;}}}if(!_0x12e460){const _0x56d5b1=_0x1050c6[_0x582d26(0x1f0)](_0x2804b5);if(_0x56d5b1){if(!_0xec3dc1){const _0x51e37e={'type':_0x582d26(0x1f1),'index':_0x4a2ce1,'content_block':{'type':_0x582d26(0x1cf),'text':''}};yield _0x51e37e,_0xec3dc1=!![];}const _0x363f61={'type':_0x582d26(0x211),'index':_0x4a2ce1,'delta':{'type':'text_delta','text':_0x56d5b1}};yield _0x363f61,_0x234f89+=Math[_0x582d26(0x1d8)](_0x56d5b1[_0x582d26(0x218)]/0x4);}if(_0xec3dc1){const _0x1fdca6={'type':_0x582d26(0x1fb),'index':_0x4a2ce1};yield _0x1fdca6;}const _0x4c6f0e={'type':_0x582d26(0x206),'delta':{'stop_reason':'end_turn','stop_sequence':null},'usage':{'output_tokens':_0x234f89}};yield _0x4c6f0e;const _0x319e9f={'type':_0x582d26(0x1d2)};yield _0x319e9f;}}export{generateMessageId};function a33_0x343e(){const _0x15c8f4=['user','length','description','push','stringify','messages','parse','haiku','random','toLowerCase','text','message_start','filter','message_stop','5047505YDZrhA','\x0a</tool_result>','[DEBUG]\x20Tool\x20call\x20detected:','includes','{\x22tool_use\x22:','ceil','37834KjzxSK','name','<tool_result\x20tool_use_id=\x22','input_schema','15HZxcTM','<tools>\x0aYou\x20have\x20access\x20to\x20the\x20following\x20tools:\x0a\x0a','\x20(required)','assistant','684808FjQOwY','pop','is_error','startIndex','No\x20user\x20message\x20found\x20in\x20request\x20delta','tool_use_id','string','\x0a\x0aPlease\x20continue\x20your\x20response\x20based\x20on\x20the\x20tool\x20results\x20above.\x0a\x0a','Tool\x20calls\x20not\x20yet\x20supported\x20in\x20proxy:','5886111jdlWGU','slice','output_tokens','properties','input','indexOf','substring','content_block_start','end_turn','input_json_delta','opus','"','role','content','\x20error=\x22true\x22','tool_call','toString','content_block_stop','api_error','map','type','sonnet','tool_result','message','index','tool_use','entries','\x20\x20\x20\x20-\x20','message_delta','\x20\x20\x20\x20(no\x20parameters)','trim','error','event:\x20','warn','1784924jVitmr','<','text_delta','replace','700897qjkQTo','content_block_delta','3936000omrING','&','\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','usage','join'];a33_0x343e=function(){return _0x15c8f4;};return a33_0x343e();}
|
|
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','<','type','map','&','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','>','message_stop','tool_result','"','tool_use','assistant','user','random','substring','1584933YIaQwr','ceil','message_delta','819885eTmtLv','isArray','tool_call','text_delta','toString',''','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};
|