@treasuredata/tdx 0.1.7 → 0.1.9
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/README.md +85 -0
- 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/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.d.ts +24 -0
- package/dist/commands/llm-proxy.d.ts.map +1 -0
- package/dist/commands/llm-proxy.js +1 -0
- package/dist/commands/llm-proxy.js.map +1 -0
- 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.d.ts +79 -0
- package/dist/proxy/anthropic-adapter.d.ts.map +1 -0
- package/dist/proxy/anthropic-adapter.js +1 -0
- package/dist/proxy/anthropic-adapter.js.map +1 -0
- package/dist/proxy/server.d.ts +59 -0
- package/dist/proxy/server.d.ts.map +1 -0
- package/dist/proxy/server.js +1 -0
- package/dist/proxy/server.js.map +1 -0
- 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/anthropic.d.ts +139 -0
- package/dist/types/anthropic.d.ts.map +1 -0
- package/dist/types/anthropic.js +1 -0
- package/dist/types/anthropic.js.map +1 -0
- 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/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 +3 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
const a23_0x22a59e=a23_0x2db5;function a23_0x2db5(_0x231621,_0x309d5f){const _0x296d6c=a23_0x296d();return a23_0x2db5=function(_0x2db5df,_0x3f28f5){_0x2db5df=_0x2db5df-0x160;let _0x4cfe86=_0x296d6c[_0x2db5df];return _0x4cfe86;},a23_0x2db5(_0x231621,_0x309d5f);}(function(_0x19db9b,_0x52e03d){const _0x269080=a23_0x2db5,_0x6fea5d=_0x19db9b();while(!![]){try{const _0xd50e28=-parseInt(_0x269080(0x1b5))/0x1*(-parseInt(_0x269080(0x1a3))/0x2)+parseInt(_0x269080(0x1c0))/0x3*(-parseInt(_0x269080(0x1d1))/0x4)+parseInt(_0x269080(0x1c1))/0x5*(-parseInt(_0x269080(0x1e5))/0x6)+parseInt(_0x269080(0x1a1))/0x7*(-parseInt(_0x269080(0x175))/0x8)+parseInt(_0x269080(0x19b))/0x9+parseInt(_0x269080(0x1b9))/0xa*(parseInt(_0x269080(0x1d2))/0xb)+parseInt(_0x269080(0x1b2))/0xc;if(_0xd50e28===_0x52e03d)break;else _0x6fea5d['push'](_0x6fea5d['shift']());}catch(_0x62bda4){_0x6fea5d['push'](_0x6fea5d['shift']());}}}(a23_0x296d,0x7c95c));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 a23_0x90bdf3 from'readline';async function confirm(_0x253d2a){const _0x4464f7=a23_0x2db5,_0x122bc6=a23_0x90bdf3[_0x4464f7(0x1a6)]({'input':process[_0x4464f7(0x173)],'output':process[_0x4464f7(0x1ba)]});return new Promise(_0x4fd6fc=>{const _0x5a3f96=_0x4464f7;_0x122bc6[_0x5a3f96(0x16c)](_0x253d2a+_0x5a3f96(0x1d3),_0x2bdd32=>{const _0x2bbd85=_0x5a3f96;_0x122bc6[_0x2bbd85(0x1dd)](),_0x4fd6fc(_0x2bdd32[_0x2bbd85(0x17e)]()==='y'||_0x2bdd32[_0x2bbd85(0x17e)]()===_0x2bbd85(0x168));});});}export class WorkflowProjectsCommand extends BaseCommand{[a23_0x22a59e(0x1c4)]=a23_0x22a59e(0x180);['description']=a23_0x22a59e(0x1d7);async[a23_0x22a59e(0x196)](_0x12672e){const _0x3c898c=a23_0x22a59e,{options:_0x2b0130,args:_0x395d79,tdx:_0x159546}=_0x12672e,_0x2ffe9e=_0x395d79[0x0];try{_0x2b0130['verbose']&&_0x2ffe9e&&console[_0x3c898c(0x1c2)](_0x3c898c(0x188)+_0x2ffe9e);const _0x34aa48=await withSpinner(_0x3c898c(0x1e2),()=>_0x159546[_0x3c898c(0x1d9)][_0x3c898c(0x1a7)](_0x2ffe9e,{'limit':_0x2b0130[_0x3c898c(0x1ca)]}),{'verbose':_0x2b0130['verbose']}),_0x3c104f=_0x34aa48[_0x3c898c(0x174)];return console[_0x3c898c(0x1c2)](_0x3c898c(0x1c8)+_0x3c104f[_0x3c898c(0x17c)]+_0x3c898c(0x171)+(_0x3c104f[_0x3c898c(0x17c)]!==0x1?'s':'')),await handleSDKOutput(_0x3c104f,_0x2b0130),0x0;}catch(_0x18a3d7){if(_0x18a3d7 instanceof SDKError)return console[_0x3c898c(0x1c2)](_0x3c898c(0x19c)+_0x18a3d7['message']),_0x18a3d7[_0x3c898c(0x177)]&&console[_0x3c898c(0x1c2)](_0x3c898c(0x1ad)+_0x18a3d7[_0x3c898c(0x177)]),0x1;throw _0x18a3d7;}}}export class WorkflowWorkflowsCommand extends BaseCommand{[a23_0x22a59e(0x1c4)]=a23_0x22a59e(0x19d);[a23_0x22a59e(0x1a2)]=a23_0x22a59e(0x1bc);async[a23_0x22a59e(0x196)](_0x495253){const _0x2afe76=a23_0x22a59e,{options:_0x5acd4b,args:_0x3c8176,tdx:_0xcc120c}=_0x495253,_0x4f668c=_0x3c8176[0x0];try{_0x5acd4b[_0x2afe76(0x199)]&&_0x4f668c&&console['error']('Project\x20filter:\x20'+_0x4f668c);const _0x5256a9=await withSpinner(_0x2afe76(0x1ae),()=>_0xcc120c[_0x2afe76(0x1d9)][_0x2afe76(0x1e3)](_0x4f668c,{'limit':_0x5acd4b['limit']}),{'verbose':_0x5acd4b['verbose']}),_0x1b3fc2=_0x5256a9[_0x2afe76(0x174)];return console[_0x2afe76(0x1c2)](_0x2afe76(0x1c8)+_0x1b3fc2[_0x2afe76(0x17c)]+_0x2afe76(0x18a)+(_0x1b3fc2['length']!==0x1?'s':'')),await handleSDKOutput(_0x1b3fc2,_0x5acd4b),0x0;}catch(_0x271217){if(_0x271217 instanceof SDKError)return console['error']('Error:\x20'+_0x271217[_0x2afe76(0x1dc)]),_0x271217[_0x2afe76(0x177)]&&console[_0x2afe76(0x1c2)](_0x2afe76(0x1ad)+_0x271217[_0x2afe76(0x177)]),0x1;throw _0x271217;}}}export class WorkflowSessionsCommand extends BaseCommand{[a23_0x22a59e(0x1c4)]=a23_0x22a59e(0x195);[a23_0x22a59e(0x1a2)]=a23_0x22a59e(0x194);async[a23_0x22a59e(0x196)](_0x38a972){const _0x1cd06c=a23_0x22a59e,{options:_0x1b170f,args:_0x46da55,tdx:_0x4ae655}=_0x38a972;let _0xa562d0,_0x14bf23;if(_0x46da55[0x0]){const _0x428f79=_0x46da55[0x0][_0x1cd06c(0x1f1)]('.');if(_0x428f79['length']===0x1)_0xa562d0=_0x428f79[0x0];else{if(_0x428f79['length']===0x2)[_0xa562d0,_0x14bf23]=_0x428f79;else return console[_0x1cd06c(0x1c2)](_0x1cd06c(0x186)),0x1;}}try{if(_0x1b170f[_0x1cd06c(0x199)]){if(_0xa562d0&&_0x14bf23)console[_0x1cd06c(0x1c2)]('Filter:\x20'+_0xa562d0+'.'+_0x14bf23);else _0xa562d0&&console['error'](_0x1cd06c(0x1be)+_0xa562d0);const _0x268c42=_0x1b170f[_0x1cd06c(0x184)];_0x268c42&&console['error']('Status:\x20'+_0x268c42);}const _0x3d2029=await withSpinner(_0x1cd06c(0x193),()=>_0x4ae655[_0x1cd06c(0x1d9)]['sessions']({'projectName':_0xa562d0,'workflowName':_0x14bf23,'status':_0x1b170f[_0x1cd06c(0x184)],'fromTime':_0x1b170f[_0x1cd06c(0x182)],'toTime':_0x1b170f['to'],'limit':_0x1b170f[_0x1cd06c(0x1ca)]}),{'verbose':_0x1b170f['verbose']}),_0x2c5110=_0x3d2029[_0x1cd06c(0x174)];return console[_0x1cd06c(0x1c2)](_0x1cd06c(0x1c8)+_0x2c5110['length']+_0x1cd06c(0x179)+(_0x2c5110[_0x1cd06c(0x17c)]!==0x1?'s':'')),await handleSDKOutput(_0x2c5110,_0x1b170f),0x0;}catch(_0x6ed038){if(_0x6ed038 instanceof SDKError)return console[_0x1cd06c(0x1c2)](_0x1cd06c(0x19c)+_0x6ed038[_0x1cd06c(0x1dc)]),_0x6ed038['cause']&&console[_0x1cd06c(0x1c2)]('\x20\x20Cause:\x20'+_0x6ed038[_0x1cd06c(0x177)]),0x1;throw _0x6ed038;}}}export class WorkflowAttemptsCommand extends BaseCommand{['name']='workflow:attempts';[a23_0x22a59e(0x1a2)]=a23_0x22a59e(0x16e);async[a23_0x22a59e(0x196)](_0x490cf8){const _0x36a8f6=a23_0x22a59e,{options:_0x498690,args:_0x239d3c,tdx:_0x5f2b08}=_0x490cf8;let _0xd42acf,_0x481db1;if(_0x239d3c[0x0]){const _0x5cc88d=_0x239d3c[0x0]['split']('.');if(_0x5cc88d[_0x36a8f6(0x17c)]===0x1)_0xd42acf=_0x5cc88d[0x0];else{if(_0x5cc88d[_0x36a8f6(0x17c)]===0x2)[_0xd42acf,_0x481db1]=_0x5cc88d;else return console[_0x36a8f6(0x1c2)](_0x36a8f6(0x186)),0x1;}}try{const _0x1faf1f=_0x498690[_0x36a8f6(0x1cd)];if(_0x498690[_0x36a8f6(0x199)]){if(_0xd42acf&&_0x481db1)console[_0x36a8f6(0x1c2)](_0x36a8f6(0x1b8)+_0xd42acf+'.'+_0x481db1);else _0xd42acf&&console[_0x36a8f6(0x1c2)]('Filter:\x20project='+_0xd42acf);_0x1faf1f&&console[_0x36a8f6(0x1c2)](_0x36a8f6(0x1ea));}const _0x464ec3=await withSpinner(_0x36a8f6(0x18b),()=>_0x5f2b08[_0x36a8f6(0x1d9)]['attempts']({'projectName':_0xd42acf,'workflowName':_0x481db1,'includeRetried':_0x1faf1f,'limit':_0x498690[_0x36a8f6(0x1ca)]}),{'verbose':_0x498690[_0x36a8f6(0x199)]}),_0x40b20e=_0x464ec3['data'];return console['error']('✔\x20Found\x20'+_0x40b20e['length']+_0x36a8f6(0x1bd)+(_0x40b20e[_0x36a8f6(0x17c)]!==0x1?'s':'')),await handleSDKOutput(_0x40b20e,_0x498690),0x0;}catch(_0x30f4c4){if(_0x30f4c4 instanceof SDKError)return console[_0x36a8f6(0x1c2)](_0x36a8f6(0x19c)+_0x30f4c4[_0x36a8f6(0x1dc)]),_0x30f4c4[_0x36a8f6(0x177)]&&console[_0x36a8f6(0x1c2)](_0x36a8f6(0x1ad)+_0x30f4c4[_0x36a8f6(0x177)]),0x1;throw _0x30f4c4;}}}export class WorkflowAttemptCommand extends BaseCommand{[a23_0x22a59e(0x1c4)]='workflow:attempt';[a23_0x22a59e(0x1a2)]='Show\x20specific\x20attempt\x20details';async[a23_0x22a59e(0x196)](_0x5602d3){const _0x519879=a23_0x22a59e,{options:_0x36bf38,args:_0x2bbf83,tdx:_0xebcd9c}=_0x5602d3,_0x3cec5b=_0x2bbf83[0x0];if(!_0x3cec5b)return console['error'](_0x519879(0x1ac)),0x1;try{_0x36bf38[_0x519879(0x199)]&&console[_0x519879(0x1c2)]('Attempt\x20ID:\x20'+_0x3cec5b);const _0xf7bcc7=await withSpinner(_0x519879(0x19f),()=>_0xebcd9c[_0x519879(0x1d9)][_0x519879(0x190)](_0x3cec5b),{'verbose':_0x36bf38['verbose']}),_0x146bea=_0xf7bcc7['data'];return await handleSDKOutput([_0x146bea],_0x36bf38),0x0;}catch(_0xbda5db){if(_0xbda5db instanceof SDKError)return console[_0x519879(0x1c2)](_0x519879(0x19c)+_0xbda5db[_0x519879(0x1dc)]),_0xbda5db[_0x519879(0x177)]&&console[_0x519879(0x1c2)]('\x20\x20Cause:\x20'+_0xbda5db['cause']),0x1;throw _0xbda5db;}}}function a23_0x296d(){const _0x4c65b1=['workflow:logs','Listing\x20workflow\x20projects...','workflows','skipValidation','1662IYTMSM','readFile','Usage:\x20workflow:download\x20<project-name>\x20[output-dir]','Project\x20directory:\x20','Project:\x20','Include\x20retried:\x20yes','attemptId','Error:\x20Session\x20ID\x20or\x20attempt\x20ID\x20is\x20required','Validation:\x20skipped','Error:\x20Project\x20name\x20is\x20required','\x20\x20Files\x20extracted:\x20','substring','split','Task\x20name:\x20','Killing\x20attempt...','\x20task','logs','stat','workflow:tasks','Cancelled','Force:\x20yes','...','Retrying\x20attempt...','yes','includeSubtasks','workflow:download','kill','question','Are\x20you\x20sure\x20you\x20want\x20to\x20delete\x20project\x20\x22','List\x20workflow\x20attempts','fromTask','filesExtracted','\x20project','Error:\x20Target\x20must\x20be\x20prefixed\x20with\x20\x22session:\x22\x20or\x20\x22attempt:\x22','stdin','data','10104qWIKNq','resumeFrom','cause','Delete\x20workflow\x20project\x20from\x20Treasure\x20Data','\x20session','download','Downloading\x20project\x20','length','Show\x20logs\x20for\x20a\x20specific\x20task','toLowerCase','Reason:\x20','workflow:projects','Error:\x20Project\x20name\x20or\x20ID\x20is\x20required','from','Download\x20workflow\x20project\x20from\x20Treasure\x20Data','status','Including\x20subtasks:\x20yes','Error:\x20Invalid\x20pattern.\x20Use\x20format:\x20project\x20or\x20project.workflow','offset','Pattern:\x20','\x20\x20Project\x20ID:\x20','\x20workflow','Listing\x20workflow\x20attempts...','utf-8','\x22?\x20This\x20cannot\x20be\x20undone.','session','fs/promises','attempt','Getting\x20attempt\x20tasks...','Error:\x20Invalid\x20JSON\x20in\x20--params','Listing\x20workflow\x20sessions...','List\x20workflow\x20execution\x20sessions','workflow:sessions','execute','✔\x20Downloaded\x20','Error:\x20Attempt\x20ID\x20and\x20task\x20name\x20are\x20required','verbose','workflow:retry','301887pGdaXg','Error:\x20','workflow:workflows','parse','Getting\x20attempt\x20details...','session:','2345JUqUlb','description','676898jONWQA','✔\x20Deleted\x20project\x20','Getting\x20task\x20logs...','createInterface','projects','tasks','sessionId','\x20is\x20not\x20a\x20directory','Output\x20directory:\x20','Error:\x20Attempt\x20ID\x20is\x20required','\x20\x20Cause:\x20','Listing\x20workflows...','Resume\x20from:\x20','Attempt\x20ID:\x20','\x20\x20Revision:\x20','17419488zLRekG','✔\x20Pushed\x20','\x20\x20Location:\x20','1ABQjvx','Are\x20you\x20sure\x20you\x20want\x20to\x20kill\x20attempt\x20','startsWith','Filter:\x20','3680ibJlru','stdout','Usage:\x20workflow:delete\x20<project-name-or-id>','List\x20workflows','\x20attempt','Filter:\x20project=','retrySession','6LEFufR','4925TDgREm','error','\x20\x20New\x20attempt\x20ID:\x20','name','\x20\x20Session\x20ID:\x20','force','params','✔\x20Found\x20','revision','limit','Target:\x20','Kill\x20a\x20running\x20attempt','includeRetried','Push\x20workflow\x20project\x20to\x20Treasure\x20Data','workflow:push','projectName','1754348MDlsWh','7766mruUPz','\x20(y/N):\x20','Pushing\x20workflow\x20project...','isDirectory','Usage:\x20workflow\x20retry\x20session:<id>\x20or\x20workflow\x20retry\x20attempt:<id>','List\x20all\x20workflow\x20projects','workflow:delete','workflow','workflow:kill','Revision:\x20','message','close','Show\x20tasks\x20for\x20an\x20attempt','Retrying\x20session...','reason'];a23_0x296d=function(){return _0x4c65b1;};return a23_0x296d();}export class WorkflowTasksCommand extends BaseCommand{['name']=a23_0x22a59e(0x163);['description']=a23_0x22a59e(0x1de);async[a23_0x22a59e(0x196)](_0x216c99){const _0x482198=a23_0x22a59e,{options:_0x34e25c,args:_0x1a5ba4,tdx:_0xf2786f}=_0x216c99,_0x5d12a5=_0x1a5ba4[0x0];if(!_0x5d12a5)return console['error'](_0x482198(0x1ac)),0x1;try{const _0x159f01=_0x34e25c[_0x482198(0x169)];_0x34e25c[_0x482198(0x199)]&&(console[_0x482198(0x1c2)](_0x482198(0x1b0)+_0x5d12a5),_0x159f01&&console[_0x482198(0x1c2)](_0x482198(0x185)));const _0x2623f0=await withSpinner(_0x482198(0x191),()=>_0xf2786f['workflow'][_0x482198(0x1a8)](_0x5d12a5,_0x159f01||![]),{'verbose':_0x34e25c[_0x482198(0x199)]}),_0x1a5518=_0x2623f0['data'];return console[_0x482198(0x1c2)](_0x482198(0x1c8)+_0x1a5518['length']+_0x482198(0x160)+(_0x1a5518[_0x482198(0x17c)]!==0x1?'s':'')),await handleSDKOutput(_0x1a5518,_0x34e25c),0x0;}catch(_0x172d7d){if(_0x172d7d instanceof SDKError)return console[_0x482198(0x1c2)](_0x482198(0x19c)+_0x172d7d['message']),_0x172d7d[_0x482198(0x177)]&&console[_0x482198(0x1c2)]('\x20\x20Cause:\x20'+_0x172d7d[_0x482198(0x177)]),0x1;throw _0x172d7d;}}}export class WorkflowLogsCommand extends BaseCommand{[a23_0x22a59e(0x1c4)]=a23_0x22a59e(0x1e1);[a23_0x22a59e(0x1a2)]=a23_0x22a59e(0x17d);async[a23_0x22a59e(0x196)](_0xdcfa21){const _0x2e9ddb=a23_0x22a59e,{options:_0x3b0b29,args:_0x409fea,tdx:_0xbfeb80}=_0xdcfa21,_0x3db019=_0x409fea[0x0],_0x1e1bd2=_0x409fea[0x1];if(!_0x3db019||!_0x1e1bd2)return console['error'](_0x2e9ddb(0x198)),0x1;try{_0x3b0b29[_0x2e9ddb(0x199)]&&(console[_0x2e9ddb(0x1c2)](_0x2e9ddb(0x1b0)+_0x3db019),console[_0x2e9ddb(0x1c2)](_0x2e9ddb(0x1f2)+_0x1e1bd2));const _0xcc958b=_0x3b0b29[_0x2e9ddb(0x187)],_0x2840f3=await withSpinner(_0x2e9ddb(0x1a5),()=>_0xbfeb80[_0x2e9ddb(0x1d9)][_0x2e9ddb(0x161)](_0x3db019,_0x1e1bd2,{'offset':_0xcc958b,'limit':_0x3b0b29[_0x2e9ddb(0x1ca)]}),{'verbose':_0x3b0b29['verbose']}),_0x167142=_0x2840f3[_0x2e9ddb(0x174)];return console[_0x2e9ddb(0x1c2)](_0x2e9ddb(0x1c8)+_0x167142['length']+'\x20log\x20entr'+(_0x167142[_0x2e9ddb(0x17c)]!==0x1?'ies':'y')),await handleSDKOutput(_0x167142,_0x3b0b29),0x0;}catch(_0x5f4987){if(_0x5f4987 instanceof SDKError)return console['error'](_0x2e9ddb(0x19c)+_0x5f4987['message']),_0x5f4987[_0x2e9ddb(0x177)]&&console['error'](_0x2e9ddb(0x1ad)+_0x5f4987[_0x2e9ddb(0x177)]),0x1;throw _0x5f4987;}}}export class WorkflowKillCommand extends BaseCommand{[a23_0x22a59e(0x1c4)]=a23_0x22a59e(0x1da);['description']=a23_0x22a59e(0x1cc);async[a23_0x22a59e(0x196)](_0x3201a8){const _0x2a7d96=a23_0x22a59e,{options:_0x41270f,args:_0x68fd43,tdx:_0x114632}=_0x3201a8,_0x67e01=_0x68fd43[0x0];if(!_0x67e01)return console['error'](_0x2a7d96(0x1ac)),0x1;try{const _0x2aec0f=_0x41270f[_0x2a7d96(0x1e0)];_0x41270f[_0x2a7d96(0x199)]&&(console[_0x2a7d96(0x1c2)](_0x2a7d96(0x1b0)+_0x67e01),_0x2aec0f&&console[_0x2a7d96(0x1c2)](_0x2a7d96(0x17f)+_0x2aec0f));if(!_0x41270f[_0x2a7d96(0x168)]){const _0x5f1602=await confirm(_0x2a7d96(0x1b6)+_0x67e01+'?');if(!_0x5f1602)return console[_0x2a7d96(0x1c2)](_0x2a7d96(0x164)),0x0;}const _0x2dcf52=await withSpinner(_0x2a7d96(0x1f3),()=>_0x114632[_0x2a7d96(0x1d9)][_0x2a7d96(0x16b)](_0x67e01,_0x2aec0f),{'verbose':_0x41270f[_0x2a7d96(0x199)]}),_0xe8773b=_0x2dcf52[_0x2a7d96(0x174)];return console[_0x2a7d96(0x1c2)]('✔\x20'+_0xe8773b),0x0;}catch(_0xf956c2){if(_0xf956c2 instanceof SDKError)return console[_0x2a7d96(0x1c2)](_0x2a7d96(0x19c)+_0xf956c2['message']),_0xf956c2[_0x2a7d96(0x177)]&&console[_0x2a7d96(0x1c2)](_0x2a7d96(0x1ad)+_0xf956c2[_0x2a7d96(0x177)]),0x1;throw _0xf956c2;}}}export class WorkflowRetryCommand extends BaseCommand{['name']=a23_0x22a59e(0x19a);[a23_0x22a59e(0x1a2)]='Retry\x20a\x20session\x20or\x20attempt';async['execute'](_0x2112a6){const _0x325a74=a23_0x22a59e,{options:_0x448b21,args:_0x3eba57,tdx:_0x5cd9a1}=_0x2112a6,_0x20ccfb=_0x3eba57[0x0];if(!_0x20ccfb)return console[_0x325a74(0x1c2)](_0x325a74(0x1ec)),console[_0x325a74(0x1c2)](_0x325a74(0x1d6)),0x1;let _0x31b640=![],_0x334f9c=_0x20ccfb;if(_0x20ccfb['startsWith'](_0x325a74(0x1a0)))_0x31b640=!![],_0x334f9c=_0x20ccfb[_0x325a74(0x1f0)](0x8);else{if(_0x20ccfb[_0x325a74(0x1b7)]('attempt:'))_0x31b640=![],_0x334f9c=_0x20ccfb[_0x325a74(0x1f0)](0x8);else return console[_0x325a74(0x1c2)](_0x325a74(0x172)),console[_0x325a74(0x1c2)](_0x325a74(0x1d6)),0x1;}try{const _0x330671=_0x448b21[_0x325a74(0x16f)],_0x26bc01=_0x448b21[_0x325a74(0x176)],_0x4c48c1=_0x448b21[_0x325a74(0x1c7)],_0x13b7ac=_0x448b21[_0x325a74(0x1c6)];_0x448b21[_0x325a74(0x199)]&&(console[_0x325a74(0x1c2)](_0x325a74(0x1cb)+(_0x31b640?'session':'attempt')+'\x20'+_0x334f9c),_0x330671&&console['error']('From\x20task:\x20'+_0x330671),_0x26bc01&&console['error'](_0x325a74(0x1af)+_0x26bc01),_0x4c48c1&&console[_0x325a74(0x1c2)]('Params:\x20'+_0x4c48c1),_0x13b7ac&&console[_0x325a74(0x1c2)](_0x325a74(0x165)));let _0x5a3945;if(_0x4c48c1)try{if(_0x4c48c1['startsWith']('@')){const _0x1584ec=await import(_0x325a74(0x18f)),_0x3242f2=_0x4c48c1['substring'](0x1),_0x3bc327=await _0x1584ec[_0x325a74(0x1e6)](_0x3242f2,_0x325a74(0x18c));_0x5a3945=JSON[_0x325a74(0x19e)](_0x3bc327);}else _0x5a3945=JSON['parse'](_0x4c48c1);}catch{return console['error'](_0x325a74(0x192)),0x1;}if(!_0x448b21[_0x325a74(0x168)]){const _0x5ae2f1=await confirm('Are\x20you\x20sure\x20you\x20want\x20to\x20retry\x20'+(_0x31b640?_0x325a74(0x18e):'attempt')+'\x20'+_0x334f9c+'?');if(!_0x5ae2f1)return console[_0x325a74(0x1c2)](_0x325a74(0x164)),0x0;}let _0x2223ab;_0x31b640?_0x2223ab=await withSpinner(_0x325a74(0x1df),()=>_0x5cd9a1[_0x325a74(0x1d9)][_0x325a74(0x1bf)](_0x334f9c,{'fromTask':_0x330671,'retryParams':_0x5a3945}),{'verbose':_0x448b21[_0x325a74(0x199)]}):_0x2223ab=await withSpinner(_0x325a74(0x167),()=>_0x5cd9a1['workflow']['retryAttempt'](_0x334f9c,{'resumeFrom':_0x26bc01,'retryParams':_0x5a3945,'force':_0x13b7ac}),{'verbose':_0x448b21[_0x325a74(0x199)]});const _0x12468d=_0x2223ab['data'];return console[_0x325a74(0x1c2)]('✔\x20Retry\x20started'),console[_0x325a74(0x1c2)](_0x325a74(0x1c3)+_0x12468d[_0x325a74(0x1eb)]),console[_0x325a74(0x1c2)](_0x325a74(0x1c5)+_0x12468d[_0x325a74(0x1a9)]),0x0;}catch(_0x303a13){if(_0x303a13 instanceof SDKError)return console[_0x325a74(0x1c2)](_0x325a74(0x19c)+_0x303a13[_0x325a74(0x1dc)]),_0x303a13[_0x325a74(0x177)]&&console['error'](_0x325a74(0x1ad)+_0x303a13[_0x325a74(0x177)]),0x1;throw _0x303a13;}}}export class WorkflowDownloadCommand extends BaseCommand{['name']=a23_0x22a59e(0x16a);[a23_0x22a59e(0x1a2)]=a23_0x22a59e(0x183);async[a23_0x22a59e(0x196)](_0xe44c73){const _0x4d10e7=a23_0x22a59e,{options:_0x53bb9e,args:_0x50387a,tdx:_0x2219a3}=_0xe44c73,_0x37f8a2=_0x50387a[0x0],_0x3df03d=_0x50387a[0x1]||'.';if(!_0x37f8a2)return console[_0x4d10e7(0x1c2)](_0x4d10e7(0x1ee)),console['error'](_0x4d10e7(0x1e7)),0x1;const _0x5aeb13=_0x53bb9e[_0x4d10e7(0x1c9)];_0x53bb9e[_0x4d10e7(0x199)]&&(console[_0x4d10e7(0x1c2)](_0x4d10e7(0x1e9)+_0x37f8a2),console[_0x4d10e7(0x1c2)](_0x4d10e7(0x1ab)+_0x3df03d),_0x5aeb13&&console[_0x4d10e7(0x1c2)](_0x4d10e7(0x1db)+_0x5aeb13));const _0x4d5782=await withSpinner(_0x4d10e7(0x17b)+_0x37f8a2+_0x4d10e7(0x166),()=>_0x2219a3[_0x4d10e7(0x1d9)][_0x4d10e7(0x17a)](_0x37f8a2,_0x3df03d,{'revision':_0x5aeb13}),{'verbose':_0x53bb9e[_0x4d10e7(0x199)]}),_0x2294d0=_0x4d5782[_0x4d10e7(0x174)];return console[_0x4d10e7(0x1c2)](_0x4d10e7(0x197)+_0x2294d0[_0x4d10e7(0x1d0)]),console[_0x4d10e7(0x1c2)](_0x4d10e7(0x1b1)+_0x2294d0[_0x4d10e7(0x1c9)]),console[_0x4d10e7(0x1c2)](_0x4d10e7(0x1ef)+_0x2294d0[_0x4d10e7(0x170)]),console[_0x4d10e7(0x1c2)](_0x4d10e7(0x1b4)+_0x3df03d+'/'+_0x2294d0['projectName']),0x0;}}export class WorkflowPushCommand extends BaseCommand{[a23_0x22a59e(0x1c4)]=a23_0x22a59e(0x1cf);[a23_0x22a59e(0x1a2)]=a23_0x22a59e(0x1ce);async[a23_0x22a59e(0x196)](_0x2abc8b){const _0x582bfa=a23_0x22a59e,{options:_0x22e50c,args:_0x141a3e,tdx:_0x322566}=_0x2abc8b;let _0x31443a='.',_0x3fbafe=_0x22e50c[_0x582bfa(0x1c4)];if(_0x141a3e[0x0]){const {promises:_0x5ee68f}=await import('fs');try{const _0x1b2692=await _0x5ee68f[_0x582bfa(0x162)](_0x141a3e[0x0]);if(_0x1b2692[_0x582bfa(0x1d5)]())_0x31443a=_0x141a3e[0x0];else return console[_0x582bfa(0x1c2)](_0x582bfa(0x19c)+_0x141a3e[0x0]+_0x582bfa(0x1aa)),0x1;}catch{_0x3fbafe=_0x141a3e[0x0],_0x31443a='.';}}const _0x4ca063=_0x22e50c['revision'],_0x3e0056=_0x22e50c[_0x582bfa(0x1e4)];_0x22e50c[_0x582bfa(0x199)]&&(console[_0x582bfa(0x1c2)](_0x582bfa(0x1e8)+_0x31443a),_0x3fbafe&&console[_0x582bfa(0x1c2)]('Project\x20name:\x20'+_0x3fbafe),_0x4ca063&&console[_0x582bfa(0x1c2)](_0x582bfa(0x1db)+_0x4ca063),_0x3e0056&&console[_0x582bfa(0x1c2)](_0x582bfa(0x1ed)));const _0x3d5681=await withSpinner(_0x582bfa(0x1d4),()=>_0x322566[_0x582bfa(0x1d9)]['push'](_0x31443a,{'projectName':_0x3fbafe,'revision':_0x4ca063,'skipValidation':_0x3e0056}),{'verbose':_0x22e50c[_0x582bfa(0x199)]}),_0x310325=_0x3d5681[_0x582bfa(0x174)];return console[_0x582bfa(0x1c2)](_0x582bfa(0x1b3)+_0x310325['projectName']),console[_0x582bfa(0x1c2)]('\x20\x20Project\x20ID:\x20'+_0x310325['projectId']),console[_0x582bfa(0x1c2)](_0x582bfa(0x1b1)+_0x310325[_0x582bfa(0x1c9)]),0x0;}}export class WorkflowDeleteCommand extends BaseCommand{['name']=a23_0x22a59e(0x1d8);[a23_0x22a59e(0x1a2)]=a23_0x22a59e(0x178);async[a23_0x22a59e(0x196)](_0x2e6933){const _0x2e2262=a23_0x22a59e,{options:_0x30ad3b,args:_0xee1055,tdx:_0x4bd55a}=_0x2e6933,_0x59313b=_0xee1055[0x0];if(!_0x59313b)return console[_0x2e2262(0x1c2)](_0x2e2262(0x181)),console[_0x2e2262(0x1c2)](_0x2e2262(0x1bb)),0x1;_0x30ad3b[_0x2e2262(0x199)]&&console[_0x2e2262(0x1c2)](_0x2e2262(0x1e9)+_0x59313b);if(!_0x30ad3b[_0x2e2262(0x168)]){const _0x26cb37=await confirm(_0x2e2262(0x16d)+_0x59313b+_0x2e2262(0x18d));if(!_0x26cb37)return console[_0x2e2262(0x1c2)]('Cancelled'),0x0;}const _0x44e4cd=await withSpinner('Deleting\x20project\x20'+_0x59313b+_0x2e2262(0x166),()=>_0x4bd55a['workflow']['delete'](_0x59313b),{'verbose':_0x30ad3b[_0x2e2262(0x199)]}),_0x226ffb=_0x44e4cd[_0x2e2262(0x174)];return console[_0x2e2262(0x1c2)](_0x2e2262(0x1a4)+_0x226ffb[_0x2e2262(0x1d0)]),console['error'](_0x2e2262(0x189)+_0x226ffb['projectId']),0x0;}}
|
|
1
|
+
const a24_0xbb13ff=a24_0x3903;(function(_0x4a6012,_0x3671db){const _0x45e3e7=a24_0x3903,_0x3f086d=_0x4a6012();while(!![]){try{const _0x155dcf=parseInt(_0x45e3e7(0x116))/0x1*(-parseInt(_0x45e3e7(0x12a))/0x2)+-parseInt(_0x45e3e7(0x15f))/0x3+-parseInt(_0x45e3e7(0x11c))/0x4*(-parseInt(_0x45e3e7(0x130))/0x5)+-parseInt(_0x45e3e7(0x13d))/0x6+parseInt(_0x45e3e7(0x149))/0x7+-parseInt(_0x45e3e7(0x141))/0x8+-parseInt(_0x45e3e7(0x15d))/0x9*(-parseInt(_0x45e3e7(0x121))/0xa);if(_0x155dcf===_0x3671db)break;else _0x3f086d['push'](_0x3f086d['shift']());}catch(_0x3020c3){_0x3f086d['push'](_0x3f086d['shift']());}}}(a24_0x5703,0x9f958));import{BaseCommand}from'./command.js';import{SDKError}from'../sdk/index.js';import{handleSDKOutput}from'../utils/command-output.js';import{withSpinner}from'../utils/spinner.js';import*as a24_0xbefb4a from'readline';async function confirm(_0x6c66c1){const _0x226d1f=a24_0x3903,_0x56d898=a24_0xbefb4a[_0x226d1f(0x153)]({'input':process[_0x226d1f(0x12e)],'output':process[_0x226d1f(0x16e)]});return new Promise(_0x45d48b=>{const _0x32cc74=_0x226d1f;_0x56d898[_0x32cc74(0x13e)](_0x6c66c1+'\x20(y/N):\x20',_0x14be9c=>{const _0x5540b9=_0x32cc74;_0x56d898[_0x5540b9(0x165)](),_0x45d48b(_0x14be9c[_0x5540b9(0x167)]()==='y'||_0x14be9c[_0x5540b9(0x167)]()===_0x5540b9(0x13c));});});}export class WorkflowProjectsCommand extends BaseCommand{[a24_0xbb13ff(0x100)]='workflow:projects';[a24_0xbb13ff(0x103)]=a24_0xbb13ff(0x15b);async['execute'](_0x724ef9){const _0x24d074=a24_0xbb13ff,{options:_0x4bb825,args:_0x483f1f,tdx:_0xd3cc5a}=_0x724ef9,_0x2ed0e2=_0x483f1f[0x0];try{_0x4bb825[_0x24d074(0x14e)]&&_0x2ed0e2&&console['error'](_0x24d074(0x109)+_0x2ed0e2);const _0x23aee6=await withSpinner('Listing\x20workflow\x20projects...',()=>_0xd3cc5a['workflow'][_0x24d074(0x173)](_0x2ed0e2,{'limit':_0x4bb825['limit']}),{'verbose':_0x4bb825['verbose']}),_0x119128=_0x23aee6['data'];return console['error'](_0x24d074(0x10c)+_0x119128[_0x24d074(0x120)]+_0x24d074(0x177)+(_0x119128[_0x24d074(0x120)]!==0x1?'s':'')),await handleSDKOutput(_0x119128,_0x4bb825),0x0;}catch(_0x45ed83){if(_0x45ed83 instanceof SDKError)return console['error'](_0x24d074(0x145)+_0x45ed83[_0x24d074(0x174)]),_0x45ed83[_0x24d074(0x11e)]&&console[_0x24d074(0x10d)](_0x24d074(0x136)+_0x45ed83[_0x24d074(0x11e)]),0x1;throw _0x45ed83;}}}export class WorkflowWorkflowsCommand extends BaseCommand{[a24_0xbb13ff(0x100)]=a24_0xbb13ff(0x164);['description']=a24_0xbb13ff(0x12d);async[a24_0xbb13ff(0x10e)](_0x272cdf){const _0x3053f7=a24_0xbb13ff,{options:_0xa7f249,args:_0x4c1dab,tdx:_0x1290b2}=_0x272cdf,_0x4f2bc1=_0x4c1dab[0x0];try{_0xa7f249[_0x3053f7(0x14e)]&&_0x4f2bc1&&console[_0x3053f7(0x10d)](_0x3053f7(0x163)+_0x4f2bc1);const _0x47e69b=await withSpinner(_0x3053f7(0x158),()=>_0x1290b2['workflow'][_0x3053f7(0x10f)](_0x4f2bc1,{'limit':_0xa7f249['limit']}),{'verbose':_0xa7f249[_0x3053f7(0x14e)]}),_0x34d34b=_0x47e69b['data'];return console['error'](_0x3053f7(0x10c)+_0x34d34b[_0x3053f7(0x120)]+_0x3053f7(0x13f)+(_0x34d34b[_0x3053f7(0x120)]!==0x1?'s':'')),await handleSDKOutput(_0x34d34b,_0xa7f249),0x0;}catch(_0x172309){if(_0x172309 instanceof SDKError)return console[_0x3053f7(0x10d)](_0x3053f7(0x145)+_0x172309[_0x3053f7(0x174)]),_0x172309['cause']&&console[_0x3053f7(0x10d)](_0x3053f7(0x136)+_0x172309[_0x3053f7(0x11e)]),0x1;throw _0x172309;}}}export class WorkflowSessionsCommand extends BaseCommand{['name']='workflow:sessions';['description']=a24_0xbb13ff(0x17c);async[a24_0xbb13ff(0x10e)](_0x3e2628){const _0x569af2=a24_0xbb13ff,{options:_0x28515b,args:_0x5ba3d,tdx:_0x1482a4}=_0x3e2628;let _0x41a3a4,_0x146be3;if(_0x5ba3d[0x0]){const _0x4ede05=_0x5ba3d[0x0][_0x569af2(0x101)]('.');if(_0x4ede05[_0x569af2(0x120)]===0x1)_0x41a3a4=_0x4ede05[0x0];else{if(_0x4ede05['length']===0x2)[_0x41a3a4,_0x146be3]=_0x4ede05;else return console[_0x569af2(0x10d)](_0x569af2(0x171)),0x1;}}try{if(_0x28515b[_0x569af2(0x14e)]){if(_0x41a3a4&&_0x146be3)console[_0x569af2(0x10d)](_0x569af2(0x178)+_0x41a3a4+'.'+_0x146be3);else _0x41a3a4&&console[_0x569af2(0x10d)](_0x569af2(0x112)+_0x41a3a4);const _0x281bfb=_0x28515b[_0x569af2(0x14b)];_0x281bfb&&console[_0x569af2(0x10d)]('Status:\x20'+_0x281bfb);}const _0x1b5c28=await withSpinner(_0x569af2(0x131),()=>_0x1482a4[_0x569af2(0x14d)]['sessions']({'projectName':_0x41a3a4,'workflowName':_0x146be3,'status':_0x28515b['status'],'fromTime':_0x28515b[_0x569af2(0x105)],'toTime':_0x28515b['to'],'limit':_0x28515b['limit']}),{'verbose':_0x28515b[_0x569af2(0x14e)]}),_0x261673=_0x1b5c28[_0x569af2(0x15c)];return console[_0x569af2(0x10d)](_0x569af2(0x10c)+_0x261673[_0x569af2(0x120)]+_0x569af2(0x129)+(_0x261673[_0x569af2(0x120)]!==0x1?'s':'')),await handleSDKOutput(_0x261673,_0x28515b),0x0;}catch(_0x49bfc5){if(_0x49bfc5 instanceof SDKError)return console['error'](_0x569af2(0x145)+_0x49bfc5[_0x569af2(0x174)]),_0x49bfc5['cause']&&console[_0x569af2(0x10d)](_0x569af2(0x136)+_0x49bfc5[_0x569af2(0x11e)]),0x1;throw _0x49bfc5;}}}export class WorkflowAttemptsCommand extends BaseCommand{['name']=a24_0xbb13ff(0xfc);[a24_0xbb13ff(0x103)]='List\x20workflow\x20attempts';async[a24_0xbb13ff(0x10e)](_0xcb8078){const _0x253156=a24_0xbb13ff,{options:_0x531818,args:_0x2ac4e4,tdx:_0x2e3d4f}=_0xcb8078;let _0x4c3123,_0x2ce65a;if(_0x2ac4e4[0x0]){const _0x153aa4=_0x2ac4e4[0x0][_0x253156(0x101)]('.');if(_0x153aa4[_0x253156(0x120)]===0x1)_0x4c3123=_0x153aa4[0x0];else{if(_0x153aa4[_0x253156(0x120)]===0x2)[_0x4c3123,_0x2ce65a]=_0x153aa4;else return console[_0x253156(0x10d)](_0x253156(0x171)),0x1;}}try{const _0x504d15=_0x531818[_0x253156(0x114)];if(_0x531818[_0x253156(0x14e)]){if(_0x4c3123&&_0x2ce65a)console[_0x253156(0x10d)](_0x253156(0x178)+_0x4c3123+'.'+_0x2ce65a);else _0x4c3123&&console[_0x253156(0x10d)]('Filter:\x20project='+_0x4c3123);_0x504d15&&console[_0x253156(0x10d)](_0x253156(0x155));}const _0x53ee12=await withSpinner('Listing\x20workflow\x20attempts...',()=>_0x2e3d4f[_0x253156(0x14d)][_0x253156(0x104)]({'projectName':_0x4c3123,'workflowName':_0x2ce65a,'includeRetried':_0x504d15,'limit':_0x531818[_0x253156(0x11b)]}),{'verbose':_0x531818['verbose']}),_0x5aa78d=_0x53ee12['data'];return console[_0x253156(0x10d)](_0x253156(0x10c)+_0x5aa78d[_0x253156(0x120)]+_0x253156(0x12c)+(_0x5aa78d[_0x253156(0x120)]!==0x1?'s':'')),await handleSDKOutput(_0x5aa78d,_0x531818),0x0;}catch(_0xe0bce9){if(_0xe0bce9 instanceof SDKError)return console['error'](_0x253156(0x145)+_0xe0bce9[_0x253156(0x174)]),_0xe0bce9[_0x253156(0x11e)]&&console[_0x253156(0x10d)](_0x253156(0x136)+_0xe0bce9[_0x253156(0x11e)]),0x1;throw _0xe0bce9;}}}export class WorkflowAttemptCommand extends BaseCommand{[a24_0xbb13ff(0x100)]=a24_0xbb13ff(0x140);[a24_0xbb13ff(0x103)]=a24_0xbb13ff(0x172);async[a24_0xbb13ff(0x10e)](_0x5de7b9){const _0x3a24fe=a24_0xbb13ff,{options:_0x191d71,args:_0x3874ad,tdx:_0x23fa47}=_0x5de7b9,_0x412f23=_0x3874ad[0x0];if(!_0x412f23)return console[_0x3a24fe(0x10d)](_0x3a24fe(0x127)),0x1;try{_0x191d71[_0x3a24fe(0x14e)]&&console[_0x3a24fe(0x10d)](_0x3a24fe(0x176)+_0x412f23);const _0x209650=await withSpinner('Getting\x20attempt\x20details...',()=>_0x23fa47[_0x3a24fe(0x14d)][_0x3a24fe(0x160)](_0x412f23),{'verbose':_0x191d71[_0x3a24fe(0x14e)]}),_0x51a861=_0x209650[_0x3a24fe(0x15c)];return await handleSDKOutput([_0x51a861],_0x191d71),0x0;}catch(_0x111955){if(_0x111955 instanceof SDKError)return console['error'](_0x3a24fe(0x145)+_0x111955[_0x3a24fe(0x174)]),_0x111955['cause']&&console['error'](_0x3a24fe(0x136)+_0x111955['cause']),0x1;throw _0x111955;}}}export class WorkflowTasksCommand extends BaseCommand{[a24_0xbb13ff(0x100)]='workflow:tasks';[a24_0xbb13ff(0x103)]=a24_0xbb13ff(0x170);async[a24_0xbb13ff(0x10e)](_0x7d9ffb){const _0x568f3b=a24_0xbb13ff,{options:_0x557b85,args:_0x305509,tdx:_0x1255bd}=_0x7d9ffb,_0xa581e6=_0x305509[0x0];if(!_0xa581e6)return console[_0x568f3b(0x10d)]('Error:\x20Attempt\x20ID\x20is\x20required'),0x1;try{const _0x147052=_0x557b85[_0x568f3b(0x157)];_0x557b85[_0x568f3b(0x14e)]&&(console[_0x568f3b(0x10d)](_0x568f3b(0x176)+_0xa581e6),_0x147052&&console[_0x568f3b(0x10d)](_0x568f3b(0x181)));const _0x52ed2b=await withSpinner(_0x568f3b(0x133),()=>_0x1255bd[_0x568f3b(0x14d)]['tasks'](_0xa581e6,_0x147052||![]),{'verbose':_0x557b85[_0x568f3b(0x14e)]}),_0x348997=_0x52ed2b[_0x568f3b(0x15c)];return console[_0x568f3b(0x10d)](_0x568f3b(0x10c)+_0x348997['length']+_0x568f3b(0x15e)+(_0x348997[_0x568f3b(0x120)]!==0x1?'s':'')),await handleSDKOutput(_0x348997,_0x557b85),0x0;}catch(_0x30b273){if(_0x30b273 instanceof SDKError)return console[_0x568f3b(0x10d)](_0x568f3b(0x145)+_0x30b273[_0x568f3b(0x174)]),_0x30b273[_0x568f3b(0x11e)]&&console['error'](_0x568f3b(0x136)+_0x30b273[_0x568f3b(0x11e)]),0x1;throw _0x30b273;}}}function a24_0x3903(_0x12f4d4,_0x481055){const _0x5703f2=a24_0x5703();return a24_0x3903=function(_0x390352,_0x35f513){_0x390352=_0x390352-0xfc;let _0xea08c3=_0x5703f2[_0x390352];return _0xea08c3;},a24_0x3903(_0x12f4d4,_0x481055);}export class WorkflowLogsCommand extends BaseCommand{[a24_0xbb13ff(0x100)]=a24_0xbb13ff(0x15a);[a24_0xbb13ff(0x103)]=a24_0xbb13ff(0x166);async['execute'](_0x229cc4){const _0xe0bd56=a24_0xbb13ff,{options:_0x3a5d33,args:_0x1fa17b,tdx:_0x781212}=_0x229cc4,_0x2f0f3c=_0x1fa17b[0x0],_0x3feba1=_0x1fa17b[0x1];if(!_0x2f0f3c||!_0x3feba1)return console[_0xe0bd56(0x10d)](_0xe0bd56(0x151)),0x1;try{_0x3a5d33[_0xe0bd56(0x14e)]&&(console[_0xe0bd56(0x10d)]('Attempt\x20ID:\x20'+_0x2f0f3c),console[_0xe0bd56(0x10d)](_0xe0bd56(0x148)+_0x3feba1));const _0x1cf878=_0x3a5d33[_0xe0bd56(0x119)],_0x52e450=await withSpinner('Getting\x20task\x20logs...',()=>_0x781212['workflow'][_0xe0bd56(0x137)](_0x2f0f3c,_0x3feba1,{'offset':_0x1cf878,'limit':_0x3a5d33['limit']}),{'verbose':_0x3a5d33[_0xe0bd56(0x14e)]}),_0xffc504=_0x52e450[_0xe0bd56(0x15c)];return console['error'](_0xe0bd56(0x10c)+_0xffc504[_0xe0bd56(0x120)]+'\x20log\x20entr'+(_0xffc504[_0xe0bd56(0x120)]!==0x1?_0xe0bd56(0x111):'y')),await handleSDKOutput(_0xffc504,_0x3a5d33),0x0;}catch(_0x5ad06c){if(_0x5ad06c instanceof SDKError)return console[_0xe0bd56(0x10d)](_0xe0bd56(0x145)+_0x5ad06c['message']),_0x5ad06c[_0xe0bd56(0x11e)]&&console[_0xe0bd56(0x10d)]('\x20\x20Cause:\x20'+_0x5ad06c[_0xe0bd56(0x11e)]),0x1;throw _0x5ad06c;}}}export class WorkflowKillCommand extends BaseCommand{[a24_0xbb13ff(0x100)]='workflow:kill';['description']=a24_0xbb13ff(0x11d);async[a24_0xbb13ff(0x10e)](_0x39074c){const _0x4a5fff=a24_0xbb13ff,{options:_0x5e00a2,args:_0x1f952f,tdx:_0x148949}=_0x39074c,_0x1fb66b=_0x1f952f[0x0];if(!_0x1fb66b)return console[_0x4a5fff(0x10d)]('Error:\x20Attempt\x20ID\x20is\x20required'),0x1;try{const _0x2a81dd=_0x5e00a2[_0x4a5fff(0x14a)];_0x5e00a2[_0x4a5fff(0x14e)]&&(console[_0x4a5fff(0x10d)](_0x4a5fff(0x176)+_0x1fb66b),_0x2a81dd&&console[_0x4a5fff(0x10d)](_0x4a5fff(0x138)+_0x2a81dd));if(!_0x5e00a2[_0x4a5fff(0x13c)]){const _0x541189=await confirm('Are\x20you\x20sure\x20you\x20want\x20to\x20kill\x20attempt\x20'+_0x1fb66b+'?');if(!_0x541189)return console['error'](_0x4a5fff(0x17f)),0x0;}const _0x3fd6e5=await withSpinner(_0x4a5fff(0x124),()=>_0x148949['workflow'][_0x4a5fff(0x150)](_0x1fb66b,_0x2a81dd),{'verbose':_0x5e00a2['verbose']}),_0x5e60e9=_0x3fd6e5[_0x4a5fff(0x15c)];return console['error']('✔\x20'+_0x5e60e9),0x0;}catch(_0x53b884){if(_0x53b884 instanceof SDKError)return console[_0x4a5fff(0x10d)](_0x4a5fff(0x145)+_0x53b884[_0x4a5fff(0x174)]),_0x53b884['cause']&&console[_0x4a5fff(0x10d)]('\x20\x20Cause:\x20'+_0x53b884[_0x4a5fff(0x11e)]),0x1;throw _0x53b884;}}}export class WorkflowRetryCommand extends BaseCommand{['name']=a24_0xbb13ff(0xfe);[a24_0xbb13ff(0x103)]=a24_0xbb13ff(0x13b);async[a24_0xbb13ff(0x10e)](_0x1140c7){const _0x3bbd55=a24_0xbb13ff,{options:_0x4847ad,args:_0x381d77,tdx:_0x15bfe7}=_0x1140c7,_0x4618bb=_0x381d77[0x0];if(!_0x4618bb)return console[_0x3bbd55(0x10d)](_0x3bbd55(0x17e)),console[_0x3bbd55(0x10d)](_0x3bbd55(0x122)),0x1;let _0x38249d=![],_0xc1d20a=_0x4618bb;if(_0x4618bb[_0x3bbd55(0x143)](_0x3bbd55(0x16c)))_0x38249d=!![],_0xc1d20a=_0x4618bb[_0x3bbd55(0x11f)](0x8);else{if(_0x4618bb['startsWith']('attempt:'))_0x38249d=![],_0xc1d20a=_0x4618bb['substring'](0x8);else return console[_0x3bbd55(0x10d)](_0x3bbd55(0x142)),console[_0x3bbd55(0x10d)](_0x3bbd55(0x122)),0x1;}try{const _0x2eef93=_0x4847ad['fromTask'],_0xded081=_0x4847ad[_0x3bbd55(0x17a)],_0x4be5ce=_0x4847ad[_0x3bbd55(0x175)],_0x574acf=_0x4847ad[_0x3bbd55(0x156)];_0x4847ad[_0x3bbd55(0x14e)]&&(console[_0x3bbd55(0x10d)](_0x3bbd55(0x132)+(_0x38249d?_0x3bbd55(0x106):_0x3bbd55(0x160))+'\x20'+_0xc1d20a),_0x2eef93&&console[_0x3bbd55(0x10d)](_0x3bbd55(0x12f)+_0x2eef93),_0xded081&&console['error']('Resume\x20from:\x20'+_0xded081),_0x4be5ce&&console['error'](_0x3bbd55(0x134)+_0x4be5ce),_0x574acf&&console[_0x3bbd55(0x10d)](_0x3bbd55(0x10b)));let _0xe56496;if(_0x4be5ce)try{if(_0x4be5ce[_0x3bbd55(0x143)]('@')){const _0x3826ed=await import('fs/promises'),_0x54ce51=_0x4be5ce[_0x3bbd55(0x11f)](0x1),_0x466f19=await _0x3826ed['readFile'](_0x54ce51,'utf-8');_0xe56496=JSON[_0x3bbd55(0x135)](_0x466f19);}else _0xe56496=JSON[_0x3bbd55(0x135)](_0x4be5ce);}catch{return console['error'](_0x3bbd55(0x179)),0x1;}if(!_0x4847ad[_0x3bbd55(0x13c)]){const _0x2fd55f=await confirm(_0x3bbd55(0x16d)+(_0x38249d?'session':_0x3bbd55(0x160))+'\x20'+_0xc1d20a+'?');if(!_0x2fd55f)return console['error']('Cancelled'),0x0;}let _0xbb748b;_0x38249d?_0xbb748b=await withSpinner('Retrying\x20session...',()=>_0x15bfe7[_0x3bbd55(0x14d)]['retrySession'](_0xc1d20a,{'fromTask':_0x2eef93,'retryParams':_0xe56496}),{'verbose':_0x4847ad[_0x3bbd55(0x14e)]}):_0xbb748b=await withSpinner(_0x3bbd55(0x107),()=>_0x15bfe7[_0x3bbd55(0x14d)][_0x3bbd55(0x14c)](_0xc1d20a,{'resumeFrom':_0xded081,'retryParams':_0xe56496,'force':_0x574acf}),{'verbose':_0x4847ad['verbose']});const _0x143d02=_0xbb748b[_0x3bbd55(0x15c)];return console['error']('✔\x20Retry\x20started'),console[_0x3bbd55(0x10d)]('\x20\x20New\x20attempt\x20ID:\x20'+_0x143d02[_0x3bbd55(0x17d)]),console[_0x3bbd55(0x10d)](_0x3bbd55(0x159)+_0x143d02[_0x3bbd55(0x14f)]),0x0;}catch(_0x40b818){if(_0x40b818 instanceof SDKError)return console[_0x3bbd55(0x10d)](_0x3bbd55(0x145)+_0x40b818[_0x3bbd55(0x174)]),_0x40b818[_0x3bbd55(0x11e)]&&console[_0x3bbd55(0x10d)]('\x20\x20Cause:\x20'+_0x40b818[_0x3bbd55(0x11e)]),0x1;throw _0x40b818;}}}export class WorkflowDownloadCommand extends BaseCommand{['name']=a24_0xbb13ff(0x161);[a24_0xbb13ff(0x103)]='Download\x20workflow\x20project\x20from\x20Treasure\x20Data';async['execute'](_0x23b4d6){const _0xbe670d=a24_0xbb13ff,{options:_0x29a493,args:_0x203970,tdx:_0x437ab2}=_0x23b4d6,_0x1ea345=_0x203970[0x0],_0x5a5caa=_0x203970[0x1]||'.';if(!_0x1ea345)return console['error'](_0xbe670d(0x11a)),console[_0xbe670d(0x10d)]('Usage:\x20workflow:download\x20<project-name>\x20[output-dir]'),0x1;const _0x44749e=_0x29a493[_0xbe670d(0x146)];_0x29a493['verbose']&&(console[_0xbe670d(0x10d)](_0xbe670d(0x126)+_0x1ea345),console[_0xbe670d(0x10d)](_0xbe670d(0x17b)+_0x5a5caa),_0x44749e&&console['error'](_0xbe670d(0x168)+_0x44749e));const _0x38f8e7=await withSpinner(_0xbe670d(0x115)+_0x1ea345+_0xbe670d(0x180),()=>_0x437ab2[_0xbe670d(0x14d)][_0xbe670d(0x113)](_0x1ea345,_0x5a5caa,{'revision':_0x44749e}),{'verbose':_0x29a493['verbose']}),_0x1a691a=_0x38f8e7[_0xbe670d(0x15c)];return console[_0xbe670d(0x10d)](_0xbe670d(0x108)+_0x1a691a['projectName']),console[_0xbe670d(0x10d)](_0xbe670d(0x10a)+_0x1a691a['revision']),console[_0xbe670d(0x10d)](_0xbe670d(0xfd)+_0x1a691a[_0xbe670d(0x117)]),console['error']('\x20\x20Location:\x20'+_0x5a5caa+'/'+_0x1a691a[_0xbe670d(0x169)]),0x0;}}export class WorkflowPushCommand extends BaseCommand{['name']=a24_0xbb13ff(0x123);['description']='Push\x20workflow\x20project\x20to\x20Treasure\x20Data';async[a24_0xbb13ff(0x10e)](_0x565709){const _0x224bee=a24_0xbb13ff,{options:_0x1db893,args:_0x1a086f,tdx:_0x300c34}=_0x565709;let _0x373368='.',_0x58faf1=_0x1db893[_0x224bee(0x100)];if(_0x1a086f[0x0]){const {promises:_0x6752e4}=await import('fs');try{const _0x41e734=await _0x6752e4[_0x224bee(0x147)](_0x1a086f[0x0]);if(_0x41e734[_0x224bee(0x16a)]())_0x373368=_0x1a086f[0x0];else return console[_0x224bee(0x10d)](_0x224bee(0x145)+_0x1a086f[0x0]+_0x224bee(0xff)),0x1;}catch{_0x58faf1=_0x1a086f[0x0],_0x373368='.';}}const _0x22875f=_0x1db893['revision'],_0x398344=_0x1db893[_0x224bee(0x139)];_0x1db893[_0x224bee(0x14e)]&&(console[_0x224bee(0x10d)]('Project\x20directory:\x20'+_0x373368),_0x58faf1&&console[_0x224bee(0x10d)](_0x224bee(0x125)+_0x58faf1),_0x22875f&&console[_0x224bee(0x10d)](_0x224bee(0x168)+_0x22875f),_0x398344&&console[_0x224bee(0x10d)](_0x224bee(0x102)));const _0x23d36c=await withSpinner(_0x224bee(0x110),()=>_0x300c34[_0x224bee(0x14d)]['push'](_0x373368,{'projectName':_0x58faf1,'revision':_0x22875f,'skipValidation':_0x398344}),{'verbose':_0x1db893[_0x224bee(0x14e)]}),_0x4dda50=_0x23d36c[_0x224bee(0x15c)];return console[_0x224bee(0x10d)](_0x224bee(0x118)+_0x4dda50['projectName']),console[_0x224bee(0x10d)](_0x224bee(0x154)+_0x4dda50['projectId']),console['error'](_0x224bee(0x10a)+_0x4dda50[_0x224bee(0x146)]),0x0;}}function a24_0x5703(){const _0x5cd825=['offset','Error:\x20Project\x20name\x20is\x20required','limit','161156rrTgMo','Kill\x20a\x20running\x20attempt','cause','substring','length','10wKpeRG','Usage:\x20workflow\x20retry\x20session:<id>\x20or\x20workflow\x20retry\x20attempt:<id>','workflow:push','Killing\x20attempt...','Project\x20name:\x20','Project:\x20','Error:\x20Attempt\x20ID\x20is\x20required','delete','\x20session','2vBkXsf','projectId','\x20attempt','List\x20workflows','stdin','From\x20task:\x20','10tTwOhS','Listing\x20workflow\x20sessions...','Target:\x20','Getting\x20attempt\x20tasks...','Params:\x20','parse','\x20\x20Cause:\x20','logs','Reason:\x20','skipValidation','Delete\x20workflow\x20project\x20from\x20Treasure\x20Data','Retry\x20a\x20session\x20or\x20attempt','yes','7435254Lyjigl','question','\x20workflow','workflow:attempt','4409512InfSZz','Error:\x20Target\x20must\x20be\x20prefixed\x20with\x20\x22session:\x22\x20or\x20\x22attempt:\x22','startsWith','Error:\x20Project\x20name\x20or\x20ID\x20is\x20required','Error:\x20','revision','stat','Task\x20name:\x20','8157702ymseOm','reason','status','retryAttempt','workflow','verbose','sessionId','kill','Error:\x20Attempt\x20ID\x20and\x20task\x20name\x20are\x20required','Are\x20you\x20sure\x20you\x20want\x20to\x20delete\x20project\x20\x22','createInterface','\x20\x20Project\x20ID:\x20','Include\x20retried:\x20yes','force','includeSubtasks','Listing\x20workflows...','\x20\x20Session\x20ID:\x20','workflow:logs','List\x20all\x20workflow\x20projects','data','21103299ogjwRK','\x20task','1965096PyAcLi','attempt','workflow:download','workflow:delete','Project\x20filter:\x20','workflow:workflows','close','Show\x20logs\x20for\x20a\x20specific\x20task','toLowerCase','Revision:\x20','projectName','isDirectory','\x22?\x20This\x20cannot\x20be\x20undone.','session:','Are\x20you\x20sure\x20you\x20want\x20to\x20retry\x20','stdout','Deleting\x20project\x20','Show\x20tasks\x20for\x20an\x20attempt','Error:\x20Invalid\x20pattern.\x20Use\x20format:\x20project\x20or\x20project.workflow','Show\x20specific\x20attempt\x20details','projects','message','params','Attempt\x20ID:\x20','\x20project','Filter:\x20','Error:\x20Invalid\x20JSON\x20in\x20--params','resumeFrom','Output\x20directory:\x20','List\x20workflow\x20execution\x20sessions','attemptId','Error:\x20Session\x20ID\x20or\x20attempt\x20ID\x20is\x20required','Cancelled','...','Including\x20subtasks:\x20yes','workflow:attempts','\x20\x20Files\x20extracted:\x20','workflow:retry','\x20is\x20not\x20a\x20directory','name','split','Validation:\x20skipped','description','attempts','from','session','Retrying\x20attempt...','✔\x20Downloaded\x20','Pattern:\x20','\x20\x20Revision:\x20','Force:\x20yes','✔\x20Found\x20','error','execute','workflows','Pushing\x20workflow\x20project...','ies','Filter:\x20project=','download','includeRetried','Downloading\x20project\x20','491689jLgPPl','filesExtracted','✔\x20Pushed\x20'];a24_0x5703=function(){return _0x5cd825;};return a24_0x5703();}export class WorkflowDeleteCommand extends BaseCommand{[a24_0xbb13ff(0x100)]=a24_0xbb13ff(0x162);[a24_0xbb13ff(0x103)]=a24_0xbb13ff(0x13a);async[a24_0xbb13ff(0x10e)](_0x2ff935){const _0x48c137=a24_0xbb13ff,{options:_0x3ca140,args:_0x3b7c0a,tdx:_0x31cbb9}=_0x2ff935,_0x179c9c=_0x3b7c0a[0x0];if(!_0x179c9c)return console[_0x48c137(0x10d)](_0x48c137(0x144)),console[_0x48c137(0x10d)]('Usage:\x20workflow:delete\x20<project-name-or-id>'),0x1;_0x3ca140[_0x48c137(0x14e)]&&console[_0x48c137(0x10d)]('Project:\x20'+_0x179c9c);if(!_0x3ca140[_0x48c137(0x13c)]){const _0x9e8eb0=await confirm(_0x48c137(0x152)+_0x179c9c+_0x48c137(0x16b));if(!_0x9e8eb0)return console[_0x48c137(0x10d)](_0x48c137(0x17f)),0x0;}const _0x66b5eb=await withSpinner(_0x48c137(0x16f)+_0x179c9c+_0x48c137(0x180),()=>_0x31cbb9['workflow'][_0x48c137(0x128)](_0x179c9c),{'verbose':_0x3ca140[_0x48c137(0x14e)]}),_0x5ef519=_0x66b5eb['data'];return console[_0x48c137(0x10d)]('✔\x20Deleted\x20project\x20'+_0x5ef519[_0x48c137(0x169)]),console[_0x48c137(0x10d)](_0x48c137(0x154)+_0x5ef519[_0x48c137(0x12b)]),0x0;}}
|
package/dist/core/auth.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(_0x428819,_0x110f99){const _0x5ecca4=a25_0x98c0,_0x2efdf0=_0x428819();while(!![]){try{const _0x3c5d9a=-parseInt(_0x5ecca4(0x116))/0x1+-parseInt(_0x5ecca4(0x113))/0x2+-parseInt(_0x5ecca4(0x11b))/0x3*(parseInt(_0x5ecca4(0x10d))/0x4)+-parseInt(_0x5ecca4(0x110))/0x5+parseInt(_0x5ecca4(0x118))/0x6*(parseInt(_0x5ecca4(0x10e))/0x7)+-parseInt(_0x5ecca4(0x11a))/0x8+parseInt(_0x5ecca4(0x124))/0x9;if(_0x3c5d9a===_0x110f99)break;else _0x2efdf0['push'](_0x2efdf0['shift']());}catch(_0x594024){_0x2efdf0['push'](_0x2efdf0['shift']());}}}(a25_0x338d,0x9133d));import{platform}from'os';import{readFileSync}from'fs';import{fileURLToPath}from'url';import{dirname,join}from'path';function a25_0x98c0(_0x360eeb,_0x17a8bd){const _0x338d46=a25_0x338d();return a25_0x98c0=function(_0x98c0a5,_0x56405d){_0x98c0a5=_0x98c0a5-0x10d;let _0x1dc53a=_0x338d46[_0x98c0a5];return _0x1dc53a;},a25_0x98c0(_0x360eeb,_0x17a8bd);}import{getAPIKey}from'./config.js';export function getVersion(){const _0x51b171=a25_0x98c0;try{const _0x4d23b9=fileURLToPath(import.meta[_0x51b171(0x11f)]),_0x3b55bd=dirname(_0x4d23b9),_0x12825c=join(_0x3b55bd,'../../package.json'),_0x222860=JSON[_0x51b171(0x122)](readFileSync(_0x12825c,_0x51b171(0x117)));return _0x222860[_0x51b171(0x11e)];}catch{return _0x51b171(0x114);}}export function getUserAgent(){const _0x186453=a25_0x98c0,_0x54cd5f=getVersion(),_0x341436=platform(),_0x5133b4=process[_0x186453(0x11e)][_0x186453(0x10f)]('v','');return _0x186453(0x115)+_0x54cd5f+'\x20('+_0x341436+_0x186453(0x111)+_0x5133b4+')';}export function getAuthHeaders(_0x460da9,_0x3f4634){const _0x18221a=a25_0x98c0,_0x38b43b=getVersion(),_0x4aa968={'User-Agent':getUserAgent(),'X-TD-Client':_0x18221a(0x119),'X-TD-Client-Version':_0x38b43b};return _0x3f4634&&(_0x4aa968[_0x18221a(0x123)]=_0x18221a(0x121)+_0x3f4634),_0x4aa968;}export function toHeaderRecord(_0x3e5810){const _0x44f358=a25_0x98c0,_0xf60fd0={};for(const [_0x15a21c,_0x10aeb4]of Object[_0x44f358(0x120)](_0x3e5810)){_0x10aeb4!==undefined&&(_0xf60fd0[_0x15a21c]=_0x10aeb4);}return _0xf60fd0;}export function getTrinoHeaders(_0x5e4835,_0x5dea84){const _0x382fd7=a25_0x98c0,_0x35848b=getAuthHeaders(_0x5e4835,_0x5dea84),_0x17a504=toHeaderRecord(_0x35848b);return delete _0x17a504[_0x382fd7(0x123)],_0x5dea84&&(_0x17a504[_0x382fd7(0x11d)]=_0x5dea84),_0x17a504;}export function validateAPIKey(_0x50215d){const _0x502a17=a25_0x98c0;return _0x50215d[_0x502a17(0x11c)]('/')&&_0x50215d[_0x502a17(0x112)]('/')['length']===0x2;}export function hasAPIKey(_0x4677a2){const _0x5923d9=getAPIKey(_0x4677a2);return _0x5923d9!==undefined&&validateAPIKey(_0x5923d9);}function a25_0x338d(){const _0x2f4e9b=['7kbQdPa','replace','2283985zvmkBO',';\x20node/','split','1913344CkjXQj','0.0.0','tdx/','669467mInUSZ','utf-8','1996614KjRVug','tdx','4209968KjIByy','214437VxLcfT','includes','X-Trino-User','version','url','entries','TD1\x20','parse','Authorization','30986946yWhBUh','32SNEcpU'];a25_0x338d=function(){return _0x2f4e9b;};return a25_0x338d();}
|
package/dist/core/config.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(_0x1e6771,_0x46245c){const _0x3f6d69=a26_0x1073,_0x759829=_0x1e6771();while(!![]){try{const _0x4730b7=parseInt(_0x3f6d69(0x1b6))/0x1*(-parseInt(_0x3f6d69(0x1d9))/0x2)+parseInt(_0x3f6d69(0x1e4))/0x3+parseInt(_0x3f6d69(0x1c3))/0x4+parseInt(_0x3f6d69(0x1df))/0x5+-parseInt(_0x3f6d69(0x1d2))/0x6*(parseInt(_0x3f6d69(0x1ca))/0x7)+-parseInt(_0x3f6d69(0x1c9))/0x8*(-parseInt(_0x3f6d69(0x1de))/0x9)+parseInt(_0x3f6d69(0x1e6))/0xa*(parseInt(_0x3f6d69(0x1d0))/0xb);if(_0x4730b7===_0x46245c)break;else _0x759829['push'](_0x759829['shift']());}catch(_0x5804de){_0x759829['push'](_0x759829['shift']());}}}(a26_0x3480,0x48860));import{homedir}from'os';function a26_0x3480(){const _0x9d81f5=['TD_API_KEY_','parse','105052SOndEe','TD_API_KEY','.env.','ap03','replace','us01','1418840CuPmdN','7945JVHOav','profile:\x20','jp01','eu01','tdx','stg-us01','33oRsXdB','map','2712YwMzFj','env:\x20TD_API_KEY','Warning:\x20Failed\x20to\x20read\x20config\x20file\x20','.env','global:\x20','.config','Warning:\x20Unknown\x20site\x20\x27','464336OtvUHu','TDX_CACHE_DIR','TDX_CONFIG_DIR','env','match','18TimhRK','1039235rHIlek','env:\x20','toUpperCase','stg-jp01','join','1201368vqziIB','stg-ap03','176560JawmIg','error','.cache','apiKeys','existsSync','llm_default_project','\x27,\x20defaulting\x20to\x20us01','startsWith','dev-us01','1uYbBPn','dev-eu01','profile','readFileSync','ap02','endsWith','utf-8','profiles','warn','trim','\x20(TD_API_KEY)'];a26_0x3480=function(){return _0x9d81f5;};return a26_0x3480();}import{join}from'path';function a26_0x1073(_0x3c38cd,_0x57a213){const _0x348067=a26_0x3480();return a26_0x1073=function(_0x10730e,_0x278aeb){_0x10730e=_0x10730e-0x1af;let _0x222cc8=_0x348067[_0x10730e];return _0x222cc8;},a26_0x1073(_0x3c38cd,_0x57a213);}import{existsSync,readFileSync,writeFileSync,mkdirSync}from'fs';import*as a26_0x4a96fb from'node:fs';import*as a26_0x6eb913 from'node:path';import{SITE_ALIASES}from'../types/index.js';import{validateSecureFilePermissions}from'../utils/file-permissions.js';export function getConfigDir(){const _0x3dfd13=a26_0x1073;return process[_0x3dfd13(0x1dc)][_0x3dfd13(0x1db)]||join(homedir(),_0x3dfd13(0x1d7),_0x3dfd13(0x1ce));}export function getConfigFile(){const _0x1ae4fb=a26_0x1073;return join(getConfigDir(),_0x1ae4fb(0x1d5));}export function getCacheDir(){const _0x2326ba=a26_0x1073;return process[_0x2326ba(0x1dc)][_0x2326ba(0x1da)]||join(homedir(),_0x2326ba(0x1af),_0x2326ba(0x1ce));}export function getLLMProjectCacheFile(){const _0x4c369a=a26_0x1073;return join(getCacheDir(),_0x4c369a(0x1b2));}export function readCachedLLMProject(){const _0x376d1d=a26_0x1073;try{const _0x1b8709=getLLMProjectCacheFile();if(!existsSync(_0x1b8709))return null;return readFileSync(_0x1b8709,_0x376d1d(0x1bc))[_0x376d1d(0x1bf)]();}catch{return null;}}export function writeCachedLLMProject(_0x4da0b3){const _0x3ea5df=a26_0x1073;try{const _0x5dc76d=getCacheDir(),_0x3aeb8b=getLLMProjectCacheFile();!existsSync(_0x5dc76d)&&mkdirSync(_0x5dc76d,{'recursive':!![]}),writeFileSync(_0x3aeb8b,_0x4da0b3,'utf-8');}catch(_0x2fb5d6){console[_0x3ea5df(0x1e7)]('Warning:\x20Failed\x20to\x20cache\x20LLM\x20project\x20name:',_0x2fb5d6);}}export function parseEnvFile(_0x28e194){const _0x3ae25c=a26_0x1073,_0x2577a1={};for(const _0xf54b38 of _0x28e194['split']('\x0a')){const _0x335a71=_0xf54b38['trim']();if(!_0x335a71||_0x335a71[_0x3ae25c(0x1b4)]('#'))continue;const _0x4f7241=_0x335a71[_0x3ae25c(0x1dd)](/^([^=]+)=(.*)$/);if(_0x4f7241){const _0x3e09ac=_0x4f7241[0x1][_0x3ae25c(0x1bf)]();let _0x5a50c2=_0x4f7241[0x2][_0x3ae25c(0x1bf)]();(_0x5a50c2[_0x3ae25c(0x1b4)]('\x22')&&_0x5a50c2[_0x3ae25c(0x1bb)]('\x22')||_0x5a50c2['startsWith']('\x27')&&_0x5a50c2[_0x3ae25c(0x1bb)]('\x27'))&&(_0x5a50c2=_0x5a50c2['slice'](0x1,-0x1)),_0x2577a1[_0x3e09ac]=_0x5a50c2;}}return _0x2577a1;}export function readUserConfig(){const _0x3bb311=a26_0x1073,_0x107119=getConfigFile();if(!existsSync(_0x107119))return{};try{const _0x11ebce=readFileSync(_0x107119,'utf-8');return parseEnvFile(_0x11ebce);}catch(_0x42898b){return console[_0x3bb311(0x1be)](_0x3bb311(0x1d4)+_0x107119+':',_0x42898b),{};}}export function resolveSite(_0x28d49d){const _0x2336e3=a26_0x1073,_0x5c10df=[_0x2336e3(0x1c8),_0x2336e3(0x1cc),'eu01',_0x2336e3(0x1ba),_0x2336e3(0x1c6),_0x2336e3(0x1b5),_0x2336e3(0x1b7),'stg-us01',_0x2336e3(0x1e2),_0x2336e3(0x1e5)];if(_0x5c10df['includes'](_0x28d49d))return _0x28d49d;if(_0x28d49d in SITE_ALIASES)return SITE_ALIASES[_0x28d49d];return console['warn'](_0x2336e3(0x1d8)+_0x28d49d+_0x2336e3(0x1b3)),_0x2336e3(0x1c8);}let cachedUserConfig=null;export function loadUserConfigOnce(){return cachedUserConfig===null&&(cachedUserConfig=readUserConfig()),cachedUserConfig;}export function clearConfigCache(){cachedUserConfig=null;}export function getAPIKey(_0xa4d073,_0x185f76){const _0x45c526=a26_0x1073,_0x5918fe=_0xa4d073[_0x45c526(0x1e1)]()[_0x45c526(0x1c7)](/-/g,'_'),_0x16e13e=_0x45c526(0x1c1)+_0x5918fe;if(process[_0x45c526(0x1dc)][_0x16e13e])return process[_0x45c526(0x1dc)][_0x16e13e];if(process[_0x45c526(0x1dc)][_0x45c526(0x1c4)])return process['env'][_0x45c526(0x1c4)];const _0x52283d=_0x185f76||getActiveProfileName();if(_0x52283d){const _0x451cb5=loadProfileEnv(_0x52283d);if(_0x451cb5){if(_0x451cb5[_0x16e13e])return _0x451cb5[_0x16e13e];if(_0x451cb5['TD_API_KEY'])return _0x451cb5[_0x45c526(0x1c4)];}}const _0x469004=loadUserConfigOnce();if(_0x469004[_0x16e13e])return _0x469004[_0x16e13e];if(_0x469004[_0x45c526(0x1c4)])return _0x469004[_0x45c526(0x1c4)];return undefined;}export function getAPIKeySource(_0x588d1b,_0x3ef725){const _0x4b13af=a26_0x1073,_0x1e1eb0=_0x4b13af(0x1c1)+_0x588d1b[_0x4b13af(0x1e1)]()[_0x4b13af(0x1c7)](/-/g,'_');if(process[_0x4b13af(0x1dc)][_0x1e1eb0])return _0x4b13af(0x1e0)+_0x1e1eb0;if(process[_0x4b13af(0x1dc)]['TD_API_KEY'])return _0x4b13af(0x1d3);const _0x4eb4c3=_0x3ef725||getActiveProfileName();if(_0x4eb4c3){const _0x386ad1=loadProfileEnv(_0x4eb4c3);if(_0x386ad1){if(_0x386ad1[_0x1e1eb0])return _0x4b13af(0x1cb)+_0x4eb4c3+'\x20('+_0x1e1eb0+')';if(_0x386ad1[_0x4b13af(0x1c4)])return _0x4b13af(0x1cb)+_0x4eb4c3+_0x4b13af(0x1c0);}}const _0x35f5fc=loadUserConfigOnce(),_0x353e42=getConfigFile();if(_0x35f5fc[_0x1e1eb0])return _0x4b13af(0x1d6)+_0x353e42+'\x20('+_0x1e1eb0+')';if(_0x35f5fc['TD_API_KEY'])return _0x4b13af(0x1d6)+_0x353e42+_0x4b13af(0x1c0);return null;}function loadProfileEnv(_0x4bade5){const _0x56a38a=a26_0x1073,_0x220470=a26_0x6eb913['join'](getConfigDir(),_0x56a38a(0x1c5)+_0x4bade5);if(a26_0x4a96fb['existsSync'](_0x220470)){validateSecureFilePermissions(_0x220470);try{const _0xcf850a=a26_0x4a96fb[_0x56a38a(0x1b9)](_0x220470,_0x56a38a(0x1bc));return parseEnvFile(_0xcf850a);}catch(_0x577d82){console[_0x56a38a(0x1be)]('Warning:\x20Failed\x20to\x20load\x20'+_0x220470+':\x20'+_0x577d82);}}const _0x39eb86=a26_0x6eb913[_0x56a38a(0x1e3)](getConfigDir(),_0x56a38a(0x1bd),_0x4bade5,_0x56a38a(0x1d5));if(a26_0x4a96fb[_0x56a38a(0x1b1)](_0x39eb86)){validateSecureFilePermissions(_0x39eb86);try{const _0x1b7cbc=a26_0x4a96fb['readFileSync'](_0x39eb86,_0x56a38a(0x1bc));return parseEnvFile(_0x1b7cbc);}catch(_0x2b0eaf){return console['warn']('Warning:\x20Failed\x20to\x20load\x20'+_0x39eb86+':\x20'+_0x2b0eaf),null;}}return null;}function getActiveProfileName(){const _0x312191=a26_0x1073,_0x20c8a9=a26_0x6eb913[_0x312191(0x1e3)](getConfigDir(),'tdx.json');if(!a26_0x4a96fb[_0x312191(0x1b1)](_0x20c8a9))return null;try{const _0x1b6c46=a26_0x4a96fb[_0x312191(0x1b9)](_0x20c8a9,_0x312191(0x1bc)),_0x10c26c=JSON[_0x312191(0x1c2)](_0x1b6c46);return _0x10c26c[_0x312191(0x1b8)]||null;}catch{return null;}}export function saveAPIKey(_0x336380,_0x11c63e){const _0x1f5517=a26_0x1073,_0x45d2f4=getConfigDir(),_0x223c72=getConfigFile();!existsSync(_0x45d2f4)&&mkdirSync(_0x45d2f4,{'recursive':!![],'mode':0x1c0});const _0x4129c6=readUserConfig(),_0x54730f=_0x336380[_0x1f5517(0x1e1)]()['replace'](/-/g,'_');_0x4129c6['TD_API_KEY_'+_0x54730f]=_0x11c63e;const _0x338d68=Object['entries'](_0x4129c6)[_0x1f5517(0x1d1)](([_0x8a2427,_0x37c569])=>_0x8a2427+'='+_0x37c569);writeFileSync(_0x223c72,_0x338d68[_0x1f5517(0x1e3)]('\x0a')+'\x0a',{'mode':0x180});}export function loadConfig(){const _0x281b58=a26_0x1073,_0x17c8ea={'apiKeys':{},'defaultSite':_0x281b58(0x1c8)},_0x3e7316=[_0x281b58(0x1c8),_0x281b58(0x1cc),_0x281b58(0x1cd),_0x281b58(0x1ba),'ap03',_0x281b58(0x1b5),_0x281b58(0x1b7),_0x281b58(0x1cf),_0x281b58(0x1e2),_0x281b58(0x1e5)];for(const _0x52d49a of _0x3e7316){const _0x144d4d=getAPIKey(_0x52d49a);_0x144d4d&&(_0x17c8ea[_0x281b58(0x1b0)][_0x52d49a]=_0x144d4d);}return _0x17c8ea;}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a27_0x3d7e13=a27_0x4ff8;function a27_0x4ff8(_0x42dcca,_0x59bb36){const _0x197d9f=a27_0x197d();return a27_0x4ff8=function(_0x4ff8a6,_0x5b3f7f){_0x4ff8a6=_0x4ff8a6-0x1c1;let _0x5b5f06=_0x197d9f[_0x4ff8a6];return _0x5b5f06;},a27_0x4ff8(_0x42dcca,_0x59bb36);}(function(_0x1e79f1,_0x151667){const _0x34673b=a27_0x4ff8,_0x3aef81=_0x1e79f1();while(!![]){try{const _0x998962=-parseInt(_0x34673b(0x1f1))/0x1+-parseInt(_0x34673b(0x1fd))/0x2*(-parseInt(_0x34673b(0x1c8))/0x3)+-parseInt(_0x34673b(0x1ee))/0x4*(parseInt(_0x34673b(0x1c6))/0x5)+parseInt(_0x34673b(0x1fc))/0x6+parseInt(_0x34673b(0x1d0))/0x7*(-parseInt(_0x34673b(0x1f4))/0x8)+-parseInt(_0x34673b(0x1c2))/0x9+parseInt(_0x34673b(0x1da))/0xa;if(_0x998962===_0x151667)break;else _0x3aef81['push'](_0x3aef81['shift']());}catch(_0x21ca2c){_0x3aef81['push'](_0x3aef81['shift']());}}}(a27_0x197d,0x89cee));import{resolveSite,getAPIKey,getConfigDir}from'./config.js';import{loadSessionContext}from'./session.js';import{loadProjectConfig,findProjectConfigPath}from'./project-config.js';import{getActiveProfile,loadProfile}from'./profile.js';function a27_0x197d(){const _0x4db6da=['CLI\x20flag:\x20--','profile:\x20','14wwWMYb','injectIntoOptions','log','entries','(active)','Session','join','project','.json','displayWithSources','21742300RSXNBR','getSource',':\x20none','tdx.json','layers','cliFlags','Project','llm_project','session','us01','loadGlobalConfig','verbose','database',':\x20none\x20(using\x20session:\x20','globalCredentials','existsSync','profileCredentials','config','\x0a[configuration\x20files]','sessions','4agJOPs','parent_segment','parentSegment','650687kMVUOI','string','ppid','3012848HwrvCe','toString','configFiles','parse','global','[context]','not\x20set','Global','1619892SbXEhj','74PwJkfm','llmProject','sessionId','Profile','549297WdaBRn','apiKey','profiles','profile','2534555oMolfk','default','7467qCpLky','getParameters','.env','replace','site','activeProfile'];a27_0x197d=function(){return _0x4db6da;};return a27_0x197d();}import*as a27_0x2bdb72 from'node:fs';import*as a27_0x51964d from'node:path';export class GlobalContext{[a27_0x3d7e13(0x1cc)];[a27_0x3d7e13(0x1e6)];[a27_0x3d7e13(0x1ef)];[a27_0x3d7e13(0x1e1)];[a27_0x3d7e13(0x1c3)];['verbose'];[a27_0x3d7e13(0x1de)];['activeProfile'];[a27_0x3d7e13(0x1ff)];[a27_0x3d7e13(0x1f6)];constructor(_0x4a21fe){const _0x456b52=a27_0x3d7e13;this['sessionId']=_0x4a21fe[_0x456b52(0x1e2)]||process[_0x456b52(0x1f3)][_0x456b52(0x1f5)]();const _0x2b0b9d=loadSessionContext(_0x4a21fe['session']),_0x16a173=loadProjectConfig(),_0x9cc3ad=this[_0x456b52(0x1e4)]();this['activeProfile']=_0x4a21fe['profile']||_0x2b0b9d?.['profile']||_0x9cc3ad[_0x456b52(0x1c5)]||getActiveProfile();const _0x3ea2ed=this[_0x456b52(0x1cd)]?loadProfile(this[_0x456b52(0x1cd)]):null,_0x144075=_0x5e0c31=>{const _0x5b18e7=_0x456b52;if(!_0x5e0c31)return{};const _0x352e2b=_0x5e0c31,_0x3410f3={};for(const [_0x82e445,_0x127fe6]of Object[_0x5b18e7(0x1d3)](_0x352e2b)){typeof _0x127fe6===_0x5b18e7(0x1f2)&&(_0x3410f3[_0x82e445]=_0x127fe6);}return _0x3410f3;},_0x36362a={};if(_0x4a21fe[_0x456b52(0x1cc)]&&_0x4a21fe[_0x456b52(0x1cc)]!==_0x456b52(0x1e3))_0x36362a[_0x456b52(0x1cc)]=_0x4a21fe['site'];const _0x4487c9=_0x2b0b9d?.[_0x456b52(0x1e6)],_0x5d6bbc=_0x16a173?.[_0x456b52(0x1e6)],_0x42a0c9=_0x3ea2ed?.[_0x456b52(0x1eb)]?.[_0x456b52(0x1e6)],_0x18bdc5=_0x9cc3ad[_0x456b52(0x1e6)];_0x4a21fe[_0x456b52(0x1e6)]&&(_0x4a21fe[_0x456b52(0x1e6)]!==_0x4487c9&&_0x4a21fe[_0x456b52(0x1e6)]!==_0x5d6bbc&&_0x4a21fe[_0x456b52(0x1e6)]!==_0x42a0c9&&_0x4a21fe[_0x456b52(0x1e6)]!==_0x18bdc5)&&(_0x36362a[_0x456b52(0x1e6)]=_0x4a21fe[_0x456b52(0x1e6)]);if(_0x4a21fe[_0x456b52(0x1f0)])_0x36362a[_0x456b52(0x1ef)]=_0x4a21fe[_0x456b52(0x1f0)];if(_0x4a21fe['llmProject'])_0x36362a['llm_project']=_0x4a21fe[_0x456b52(0x1fe)];if(_0x4a21fe[_0x456b52(0x1c5)])_0x36362a[_0x456b52(0x1c5)]=_0x4a21fe[_0x456b52(0x1c5)];this[_0x456b52(0x1de)]={'cliFlags':_0x36362a,'session':_0x144075(_0x2b0b9d),'project':_0x144075(_0x16a173),'profile':_0x144075(_0x3ea2ed?.['config']),'global':_0x144075(_0x9cc3ad)};const _0x279ab5={...this[_0x456b52(0x1de)]['global'],...this[_0x456b52(0x1de)][_0x456b52(0x1c5)],...this['layers'][_0x456b52(0x1d7)],...this[_0x456b52(0x1de)][_0x456b52(0x1e2)],...this[_0x456b52(0x1de)][_0x456b52(0x1df)]},_0xa8faaf=_0x279ab5[_0x456b52(0x1cc)]||_0x456b52(0x1e3);this[_0x456b52(0x1cc)]=resolveSite(_0xa8faaf),this[_0x456b52(0x1e6)]=_0x279ab5[_0x456b52(0x1e6)],this[_0x456b52(0x1ef)]=_0x279ab5[_0x456b52(0x1ef)],this[_0x456b52(0x1e1)]=_0x279ab5[_0x456b52(0x1e1)],this[_0x456b52(0x1e5)]=_0x4a21fe['verbose']||![],this[_0x456b52(0x1c3)]=getAPIKey(this[_0x456b52(0x1cc)],this[_0x456b52(0x1cd)]||undefined);const _0x3b9b48=getConfigDir(),_0x71da54=a27_0x51964d[_0x456b52(0x1d6)](_0x3b9b48,_0x456b52(0x1ed),this[_0x456b52(0x1ff)]+_0x456b52(0x1d8)),_0x18b146=findProjectConfigPath(),_0x2c7df1=a27_0x51964d[_0x456b52(0x1d6)](_0x3b9b48,_0x456b52(0x1dd)),_0x1b1c60=a27_0x51964d[_0x456b52(0x1d6)](_0x3b9b48,_0x456b52(0x1ca));let _0x40a6e1=null,_0x377349=null;this['activeProfile']&&(_0x40a6e1=a27_0x51964d['join'](_0x3b9b48,_0x456b52(0x1c4),this[_0x456b52(0x1cd)],_0x456b52(0x1dd)),_0x377349=a27_0x51964d['join'](_0x3b9b48,_0x456b52(0x1c4),this[_0x456b52(0x1cd)],_0x456b52(0x1ca))),this[_0x456b52(0x1f6)]={'session':a27_0x2bdb72[_0x456b52(0x1e9)](_0x71da54)?_0x71da54:null,'project':_0x18b146,'profile':_0x40a6e1&&a27_0x2bdb72[_0x456b52(0x1e9)](_0x40a6e1)?_0x40a6e1:null,'profileCredentials':_0x377349&&a27_0x2bdb72[_0x456b52(0x1e9)](_0x377349)?_0x377349:null,'global':a27_0x2bdb72[_0x456b52(0x1e9)](_0x2c7df1)?_0x2c7df1:null,'globalCredentials':a27_0x2bdb72[_0x456b52(0x1e9)](_0x1b1c60)?_0x1b1c60:null};}[a27_0x3d7e13(0x1db)](_0x23eb1c,_0x15bcac){const _0x369d85=a27_0x3d7e13;if(!_0x15bcac)return _0x369d85(0x1fa);const _0x45fd0a=_0x15bcac;if(this[_0x369d85(0x1de)][_0x369d85(0x1df)][_0x23eb1c]===_0x45fd0a){if(_0x23eb1c===_0x369d85(0x1cc)&&_0x45fd0a==='us01'&&!this[_0x369d85(0x1de)][_0x369d85(0x1e2)][_0x369d85(0x1cc)]&&!this[_0x369d85(0x1de)][_0x369d85(0x1d7)][_0x369d85(0x1cc)]&&!this[_0x369d85(0x1de)][_0x369d85(0x1c5)][_0x369d85(0x1cc)]&&!this[_0x369d85(0x1de)][_0x369d85(0x1f8)][_0x369d85(0x1cc)])return _0x369d85(0x1c7);return _0x369d85(0x1ce)+_0x23eb1c[_0x369d85(0x1cb)](/_/g,'-');}if(this[_0x369d85(0x1de)][_0x369d85(0x1e2)][_0x23eb1c]===_0x45fd0a)return _0x369d85(0x1e2);if(this[_0x369d85(0x1de)][_0x369d85(0x1d7)][_0x23eb1c]===_0x45fd0a)return _0x369d85(0x1d7);if(this[_0x369d85(0x1de)][_0x369d85(0x1c5)][_0x23eb1c]===_0x45fd0a)return _0x369d85(0x1cf)+this[_0x369d85(0x1cd)];if(this[_0x369d85(0x1de)]['global'][_0x23eb1c]===_0x45fd0a)return _0x369d85(0x1f8);return'default';}[a27_0x3d7e13(0x1e4)](){const _0x38a14d=a27_0x3d7e13,_0x1a4659=a27_0x51964d[_0x38a14d(0x1d6)](getConfigDir(),'tdx.json');if(!a27_0x2bdb72[_0x38a14d(0x1e9)](_0x1a4659))return{};try{const _0x4ebd2a=a27_0x2bdb72['readFileSync'](_0x1a4659,'utf-8');return JSON[_0x38a14d(0x1f7)](_0x4ebd2a);}catch{return{};}}[a27_0x3d7e13(0x1d1)](_0x18651b){const _0x43ae16=a27_0x3d7e13;_0x18651b['site']=this[_0x43ae16(0x1cc)],!_0x18651b['database']&&this[_0x43ae16(0x1e6)]&&(_0x18651b[_0x43ae16(0x1e6)]=this[_0x43ae16(0x1e6)]),!_0x18651b['parentSegment']&&this['parent_segment']&&(_0x18651b[_0x43ae16(0x1f0)]=this[_0x43ae16(0x1ef)]),!_0x18651b[_0x43ae16(0x1fe)]&&this[_0x43ae16(0x1e1)]&&(_0x18651b[_0x43ae16(0x1fe)]=this[_0x43ae16(0x1e1)]);}[a27_0x3d7e13(0x1c9)](){const _0x2524fa=a27_0x3d7e13;return[{'key':_0x2524fa(0x1cc),'value':this['site']},{'key':_0x2524fa(0x1e6),'value':this['database']},{'key':_0x2524fa(0x1ef),'value':this['parent_segment']},{'key':_0x2524fa(0x1e1),'value':this[_0x2524fa(0x1e1)]},{'key':_0x2524fa(0x1c5),'value':this['activeProfile']||undefined}];}['display'](){const _0x5991e7=a27_0x3d7e13;console[_0x5991e7(0x1d2)](_0x5991e7(0x1f9));for(const {key:_0x5b8ecf,value:_0x246e00}of this[_0x5991e7(0x1c9)]()){_0x246e00&&console[_0x5991e7(0x1d2)](_0x5b8ecf+':\x20'+_0x246e00);}}[a27_0x3d7e13(0x1d9)](){const _0x4bc1cf=a27_0x3d7e13;console[_0x4bc1cf(0x1d2)]('[context]');for(const {key:_0x2553e2,value:_0x571b02}of this[_0x4bc1cf(0x1c9)]()){if(_0x571b02){const _0x22eedd=_0x2553e2==='profile'?_0x4bc1cf(0x1d4):'('+this['getSource'](_0x2553e2,_0x571b02)+')';console[_0x4bc1cf(0x1d2)](_0x2553e2+':\x20'+_0x571b02+'\x20'+_0x22eedd);}}console[_0x4bc1cf(0x1d2)](_0x4bc1cf(0x1ec));const _0x1b11dc=[{'label':_0x4bc1cf(0x1d5),'path':this[_0x4bc1cf(0x1f6)][_0x4bc1cf(0x1e2)],'extra':'(session:\x20'+this[_0x4bc1cf(0x1ff)]+')'},{'label':_0x4bc1cf(0x1e0),'path':this[_0x4bc1cf(0x1f6)][_0x4bc1cf(0x1d7)]},{'label':_0x4bc1cf(0x1c1),'path':this[_0x4bc1cf(0x1f6)][_0x4bc1cf(0x1c5)]},{'label':'Profile\x20Credentials','path':this['configFiles'][_0x4bc1cf(0x1ea)]},{'label':_0x4bc1cf(0x1fb),'path':this['configFiles']['global']},{'label':'Global\x20Credentials','path':this['configFiles'][_0x4bc1cf(0x1e8)]}];for(const {label:_0x5105e3,path:_0x8d7db3,extra:_0x3b8224}of _0x1b11dc){if(_0x8d7db3)console[_0x4bc1cf(0x1d2)](_0x5105e3+':\x20'+_0x8d7db3+'\x20✓'+(_0x3b8224?'\x20'+_0x3b8224:''));else{if(_0x5105e3===_0x4bc1cf(0x1d5))console['log'](_0x5105e3+_0x4bc1cf(0x1e7)+this[_0x4bc1cf(0x1ff)]+')');else(_0x5105e3===_0x4bc1cf(0x1e0)||_0x5105e3===_0x4bc1cf(0x1fb))&&console[_0x4bc1cf(0x1d2)](_0x5105e3+_0x4bc1cf(0x1dc));}}}}
|
package/dist/core/profile.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(_0x162d97,_0xcd6918){const _0x3c5d93=a27_0x1528,_0x475936=_0x162d97();while(!![]){try{const _0x7971e9=parseInt(_0x3c5d93(0x12d))/0x1*(-parseInt(_0x3c5d93(0xf4))/0x2)+-parseInt(_0x3c5d93(0x13f))/0x3+parseInt(_0x3c5d93(0x129))/0x4*(parseInt(_0x3c5d93(0xfb))/0x5)+-parseInt(_0x3c5d93(0x133))/0x6*(-parseInt(_0x3c5d93(0x110))/0x7)+parseInt(_0x3c5d93(0x141))/0x8+-parseInt(_0x3c5d93(0x137))/0x9+parseInt(_0x3c5d93(0x136))/0xa;if(_0x7971e9===_0xcd6918)break;else _0x475936['push'](_0x475936['shift']());}catch(_0x3ca6d2){_0x475936['push'](_0x475936['shift']());}}}(a27_0x257d,0xd8969));import*as a27_0x47a4ea from'node:fs';import*as a27_0x1908e7 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(_0x5c237c){const _0x4d475f=a27_0x1528,_0xb29a91={};if(!_0x5c237c)return _0xb29a91;for(const [_0x296348,_0x587065]of Object[_0x4d475f(0x132)](_0x5c237c)){_0x296348!==_0x4d475f(0x111)&&_0x587065!==undefined&&(_0xb29a91[_0x296348]=_0x587065);}return _0xb29a91;}export function getProfilesDir(){return a27_0x1908e7['join'](getConfigDir(),'profiles');}function getProfileDir(_0x373592){const _0x2ad9df=a27_0x1528;return a27_0x1908e7[_0x2ad9df(0x109)](getProfilesDir(),_0x373592);}function getProfileConfigPath(_0x5d2998){const _0x4661bc=a27_0x1528;return a27_0x1908e7[_0x4661bc(0x109)](getProfileDir(_0x5d2998),'tdx.json');}function getProfileEnvPath(_0x578427){const _0x2cceee=a27_0x1528;return a27_0x1908e7['join'](getProfileDir(_0x578427),_0x2cceee(0x139));}function getGlobalConfigPath(){const _0x117e50=a27_0x1528;return a27_0x1908e7[_0x117e50(0x109)](getConfigDir(),'tdx.json');}function validateProfileName(_0x26a26e){const _0x424c9b=a27_0x1528;if(!/^[a-zA-Z0-9_-]+$/[_0x424c9b(0x101)](_0x26a26e))throw new Error('Invalid\x20profile\x20name:\x20'+_0x26a26e+'.\x20Must\x20contain\x20only\x20alphanumeric\x20characters,\x20dash,\x20and\x20underscore.');}function validateProfileConfig(_0x5014a2,_0x112dd4){const _0x350c8d=a27_0x1528;if(typeof _0x5014a2!==_0x350c8d(0x11c)||_0x5014a2===null)throw new Error('Profile\x20\x27'+_0x112dd4+_0x350c8d(0x11f));const _0x1d45b8=['description',_0x350c8d(0x12b),_0x350c8d(0x11a),'parent_segment',_0x350c8d(0x107),_0x350c8d(0x138)],_0x2c8c8c=_0x5014a2;for(const _0x44fdda of Object[_0x350c8d(0x123)](_0x2c8c8c)){!_0x1d45b8[_0x350c8d(0x11e)](_0x44fdda)&&console[_0x350c8d(0x11b)](_0x350c8d(0xfe)+_0x112dd4+_0x350c8d(0x103)+_0x44fdda+_0x350c8d(0x120));}if(_0x2c8c8c[_0x350c8d(0x111)]!==undefined&&typeof _0x2c8c8c['description']!=='string')throw new Error(_0x350c8d(0x13e)+_0x112dd4+'\x27:\x20\x27description\x27\x20must\x20be\x20a\x20string');if(_0x2c8c8c[_0x350c8d(0x12b)]!==undefined&&typeof _0x2c8c8c['site']!=='string')throw new Error('Profile\x20\x27'+_0x112dd4+_0x350c8d(0x108));if(_0x2c8c8c[_0x350c8d(0x11a)]!==undefined&&typeof _0x2c8c8c[_0x350c8d(0x11a)]!==_0x350c8d(0x112))throw new Error('Profile\x20\x27'+_0x112dd4+_0x350c8d(0x131));if(_0x2c8c8c[_0x350c8d(0x140)]!==undefined&&typeof _0x2c8c8c[_0x350c8d(0x140)]!=='string')throw new Error(_0x350c8d(0x13e)+_0x112dd4+'\x27:\x20\x27parent_segment\x27\x20must\x20be\x20a\x20string');if(_0x2c8c8c[_0x350c8d(0x107)]!==undefined&&typeof _0x2c8c8c[_0x350c8d(0x107)]!==_0x350c8d(0x112))throw new Error(_0x350c8d(0x13e)+_0x112dd4+_0x350c8d(0x12c));if(_0x2c8c8c[_0x350c8d(0x138)]!==undefined&&typeof _0x2c8c8c[_0x350c8d(0x138)]!==_0x350c8d(0x112))throw new Error('Profile\x20\x27'+_0x112dd4+'\x27:\x20\x27llm_agent\x27\x20must\x20be\x20a\x20string');return!![];}function loadProfilesFromTdxJson(_0x7e786e,_0x414635){const _0x2f246e=a27_0x1528;if(!a27_0x47a4ea['existsSync'](_0x7e786e))return[];try{const _0x89c9f7=a27_0x47a4ea[_0x2f246e(0x125)](_0x7e786e,_0x2f246e(0x122)),_0x379a8a=JSON[_0x2f246e(0xf7)](_0x89c9f7);if(!_0x379a8a[_0x2f246e(0x10b)]||typeof _0x379a8a['profiles']!==_0x2f246e(0x11c))return[];const _0x3dca38=[];for(const [_0x2d95ad,_0x9dcd9e]of Object[_0x2f246e(0x132)](_0x379a8a[_0x2f246e(0x10b)])){try{validateProfileConfig(_0x9dcd9e,_0x2d95ad);const _0x589d6a=getNewCredentialPath(_0x2d95ad),_0x3f1d9c=getOldCredentialPath(_0x2d95ad),_0x5d8e83=a27_0x47a4ea['existsSync'](_0x589d6a)||a27_0x47a4ea[_0x2f246e(0x118)](_0x3f1d9c);_0x3dca38[_0x2f246e(0x134)]({'name':_0x2d95ad,'config':_0x9dcd9e,'metadata':{'name':_0x2d95ad,'createdAt':new Date()[_0x2f246e(0x114)]()},'hasCredentials':_0x5d8e83,'scope':_0x414635});}catch(_0x2e5b58){_0x2e5b58 instanceof Error&&(console[_0x2f246e(0x11b)](_0x2f246e(0x142)+_0x7e786e+':'),console[_0x2f246e(0x11b)]('\x20\x20'+_0x2e5b58[_0x2f246e(0x117)]+'\x0a'));}}return _0x3dca38;}catch(_0x2f8fd5){return _0x2f8fd5 instanceof SyntaxError?(console['warn'](_0x2f246e(0xf9)+_0x7e786e+_0x2f246e(0xfd)),console['warn'](_0x2f246e(0x121)+_0x2f8fd5[_0x2f246e(0x117)]+'\x0a')):console[_0x2f246e(0x11b)](_0x2f246e(0x13b)+_0x7e786e+':\x20'+_0x2f8fd5+'\x0a'),[];}}function a27_0x257d(){const _0x8c7c35=['\x22\x20\x22','set','metadata','4586169lwAKzC','description','string','To\x20migrate:','toISOString','sort','filter','message','existsSync','readdirSync','database','warn','object','api_key','includes','\x27:\x20config\x20must\x20be\x20an\x20object','\x27\x20will\x20be\x20ignored','Error:\x20','utf-8','keys','\x20does\x20not\x20exist','readFileSync','from','\x20\x203.\x20Move\x20credentials:\x20mv\x20~/.config/tdx/profiles/<name>/.env\x20~/.config/tdx/.env.<name>\x0a','\x0aWarning:\x20Profiles\x20in\x20directories\x20are\x20deprecated:\x20','1032UwJEEc','rmSync','site','\x27:\x20\x27llm_project\x27\x20must\x20be\x20a\x20string','707746JIePzv','\x20already\x20exists','Profile\x20','stringify','\x27:\x20\x27database\x27\x20must\x20be\x20a\x20string','entries','6UHKySP','push','API\x20keys\x20must\x20not\x20be\x20stored\x20in\x20profile\x20configuration.\x20Use\x20.env\x20file\x20instead.','9549620bcqVIv','9572238UhTBGi','llm_agent','.env','find','\x0aWarning:\x20Failed\x20to\x20load\x20profiles\x20from\x20','apiKey','values','Profile\x20\x27','5080557XhMMOK','parent_segment','12448760SMuBql','\x0aWarning:\x20Skipping\x20invalid\x20profile\x20in\x20','\x20\x202.\x20Add\x20profiles\x20under\x20a\x20\x22profiles\x22\x20key\x20(see\x20\x27tdx\x20profiles\x27\x20for\x20current\x20config)','name','Then\x20define\x20profiles\x20in\x20~/.config/tdx/tdx.json\x0a','2TwehqQ','\x20\x201.\x20Edit:\x20','length','parse','writeFileSync','\x0aWarning:\x20Failed\x20to\x20parse\x20','.env.','22980rEWvum','profile',':\x20Invalid\x20JSON\x20syntax','Warning:\x20Profile\x20\x27','tdx.json','map','test','directory','\x27:\x20unknown\x20config\x20key\x20\x27','has','Please\x20migrate\x20to\x20~/.config/tdx/tdx.json:','\x20\x20mv\x20\x22','llm_project','\x27:\x20\x27site\x27\x20must\x20be\x20a\x20string','join','\x0aWarning:\x20Using\x20deprecated\x20credential\x20location\x20for\x20profile\x20\x27','profiles','user'];a27_0x257d=function(){return _0x8c7c35;};return a27_0x257d();}export function getNewCredentialPath(_0x13384f){const _0x439d3b=a27_0x1528;return a27_0x1908e7[_0x439d3b(0x109)](getConfigDir(),_0x439d3b(0xfa)+_0x13384f);}function getOldCredentialPath(_0x57d03d){const _0x1147ee=a27_0x1528;return a27_0x1908e7[_0x1147ee(0x109)](getProfilesDir(),_0x57d03d,_0x1147ee(0x139));}function loadProfilesFromTdxJsonFiles(){const _0x1c6070=a27_0x1528,_0x3e88da=[],_0x2bcaed=findProjectConfigPath();_0x2bcaed&&_0x3e88da[_0x1c6070(0x134)](...loadProfilesFromTdxJson(_0x2bcaed,'local'));const _0x3f1df0=a27_0x1908e7[_0x1c6070(0x109)](getConfigDir(),'tdx.json');return _0x3e88da[_0x1c6070(0x134)](...loadProfilesFromTdxJson(_0x3f1df0,_0x1c6070(0x10c))),_0x3e88da;}function loadProfilesFromDirectories(){const _0xb212=a27_0x1528,_0x23bd89=getProfilesDir();if(!a27_0x47a4ea['existsSync'](_0x23bd89))return[];try{return a27_0x47a4ea[_0xb212(0x119)](_0x23bd89,{'withFileTypes':!![]})[_0xb212(0x116)](_0x2f4c8b=>_0x2f4c8b['isDirectory']())[_0xb212(0x100)](_0x24625a=>_0x24625a[_0xb212(0x144)])[_0xb212(0x116)](_0xc1467c=>{const _0x3ceb17=_0xb212,_0x5b2fa9=getProfileConfigPath(_0xc1467c),_0x36fdf7=getProfileEnvPath(_0xc1467c);return a27_0x47a4ea[_0x3ceb17(0x118)](_0x5b2fa9)||a27_0x47a4ea[_0x3ceb17(0x118)](_0x36fdf7);})[_0xb212(0x100)](_0x2ff10b=>{const _0x513bdc=_0xb212,_0x175fe9=loadProfileFromDirectory(_0x2ff10b);if(_0x175fe9)return{..._0x175fe9,'scope':_0x513bdc(0x102)};return null;})['filter'](_0x5b39bc=>_0x5b39bc!==null);}catch{return[];}}function loadProfileFromDirectory(_0x4b3f49){const _0x551dff=a27_0x1528,_0x5a01fb=getProfileConfigPath(_0x4b3f49),_0x48840b=getOldCredentialPath(_0x4b3f49);if(!a27_0x47a4ea[_0x551dff(0x118)](_0x5a01fb)&&!a27_0x47a4ea['existsSync'](_0x48840b))return null;let _0x775e2f={},_0x43b6a0={'name':_0x4b3f49,'createdAt':new Date()[_0x551dff(0x114)]()};if(a27_0x47a4ea[_0x551dff(0x118)](_0x5a01fb))try{const _0x20604c=a27_0x47a4ea[_0x551dff(0x125)](_0x5a01fb,_0x551dff(0x122)),_0x375cd8=JSON['parse'](_0x20604c),{metadata:_0x2e7da0,..._0x4a4ddb}=_0x375cd8;_0x775e2f=_0x4a4ddb,_0x2e7da0&&(_0x43b6a0=_0x2e7da0);}catch{}return{'name':_0x4b3f49,'config':_0x775e2f,'metadata':_0x43b6a0,'hasCredentials':a27_0x47a4ea[_0x551dff(0x118)](_0x48840b),'scope':'directory'};}export function listProfiles(){const _0x14522b=a27_0x1528,_0x2523ee=loadProfilesFromTdxJsonFiles(),_0x1d1a3b=loadProfilesFromDirectories();if(_0x1d1a3b[_0x14522b(0xf6)]>0x0){const _0x44da4d=_0x1d1a3b[_0x14522b(0x100)](_0x2234eb=>_0x2234eb[_0x14522b(0x144)])['join'](',\x20'),_0x131026=getConfigDir();console[_0x14522b(0x11b)](_0x14522b(0x128)+_0x44da4d),console[_0x14522b(0x11b)](_0x14522b(0x105)),console['warn'](_0x14522b(0xf5)+a27_0x1908e7[_0x14522b(0x109)](_0x131026,_0x14522b(0xff))),console[_0x14522b(0x11b)](_0x14522b(0x143)),console[_0x14522b(0x11b)](_0x14522b(0x127));}const _0x3497f8=[..._0x2523ee,..._0x1d1a3b],_0x3326ec=new Map();for(const _0x5b63df of _0x3497f8){!_0x3326ec[_0x14522b(0x104)](_0x5b63df[_0x14522b(0x144)])&&_0x3326ec[_0x14522b(0x10e)](_0x5b63df[_0x14522b(0x144)],_0x5b63df);}return Array[_0x14522b(0x126)](_0x3326ec[_0x14522b(0x13d)]())[_0x14522b(0x115)]((_0x5e877f,_0x218c2c)=>_0x5e877f[_0x14522b(0x144)]['localeCompare'](_0x218c2c['name']));}export function profileExists(_0x1f52a3){const _0x4b00f0=a27_0x1528,_0x30d266=listProfiles();return _0x30d266['some'](_0x50d803=>_0x50d803[_0x4b00f0(0x144)]===_0x1f52a3);}export function loadProfile(_0x12eb11){const _0x22d13d=a27_0x1528;validateProfileName(_0x12eb11);const _0x4d0f80=listProfiles(),_0x2ddef8=_0x4d0f80[_0x22d13d(0x13a)](_0x3cbd29=>_0x3cbd29['name']===_0x12eb11);return _0x2ddef8||null;}export function saveProfile(_0x17e8b1,_0x4bcfd8,_0x16b16b=![]){const _0xf84d9=a27_0x1528;validateProfileName(_0x17e8b1);const _0x585ba7=getProfileDir(_0x17e8b1),_0x332e5e=getProfileConfigPath(_0x17e8b1);createSecureDirectory(_0x585ba7);let _0x171fa9;const _0x152c48=loadProfile(_0x17e8b1);_0x152c48?(_0x171fa9=_0x152c48[_0xf84d9(0x10f)],_0x16b16b&&(_0x171fa9['lastUsed']=new Date()[_0xf84d9(0x114)]())):_0x171fa9={'name':_0x17e8b1,'createdAt':new Date()[_0xf84d9(0x114)]()};const _0xf4c4cc=JSON[_0xf84d9(0x130)](_0x4bcfd8);if(_0xf4c4cc['includes']('TD_API_KEY')||_0xf4c4cc[_0xf84d9(0x11e)](_0xf84d9(0x13c))||_0xf4c4cc[_0xf84d9(0x11e)](_0xf84d9(0x11d)))throw new Error(_0xf84d9(0x135));const _0x216840={..._0x4bcfd8,'metadata':_0x171fa9};a27_0x47a4ea[_0xf84d9(0xf8)](_0x332e5e,JSON[_0xf84d9(0x130)](_0x216840,null,0x2));}export function deleteProfile(_0x43210e){const _0x1acec6=a27_0x1528;validateProfileName(_0x43210e);const _0x536abf=getProfileDir(_0x43210e);if(!a27_0x47a4ea[_0x1acec6(0x118)](_0x536abf))throw new Error(_0x1acec6(0x12f)+_0x43210e+_0x1acec6(0x124));a27_0x47a4ea[_0x1acec6(0x12a)](_0x536abf,{'recursive':!![],'force':!![]});}export function getActiveProfile(){const _0x362d25=a27_0x1528,_0xcf4d40=getGlobalConfigPath();if(!a27_0x47a4ea[_0x362d25(0x118)](_0xcf4d40))return null;try{const _0x4c7a42=a27_0x47a4ea[_0x362d25(0x125)](_0xcf4d40,_0x362d25(0x122)),_0x2e944e=JSON[_0x362d25(0xf7)](_0x4c7a42);return _0x2e944e[_0x362d25(0xfc)]||null;}catch{return null;}}export function createProfile(_0x3c19b5,_0x300862){const _0x5df66e=a27_0x1528;validateProfileName(_0x3c19b5);if(profileExists(_0x3c19b5))throw new Error(_0x5df66e(0x12f)+_0x3c19b5+_0x5df66e(0x12e));saveProfile(_0x3c19b5,_0x300862);}function a27_0x1528(_0x435d7c,_0x405094){const _0x257d34=a27_0x257d();return a27_0x1528=function(_0x1528bf,_0x12bb20){_0x1528bf=_0x1528bf-0xf4;let _0x5e6020=_0x257d34[_0x1528bf];return _0x5e6020;},a27_0x1528(_0x435d7c,_0x405094);}export function saveProfileCredentials(_0x4e6bc9,_0x3ae738){const _0x7a33b6=a27_0x1528;validateProfileName(_0x4e6bc9);if(!profileExists(_0x4e6bc9))throw new Error(_0x7a33b6(0x12f)+_0x4e6bc9+_0x7a33b6(0x124));const _0x22def0=getNewCredentialPath(_0x4e6bc9);writeSecureFile(_0x22def0,_0x3ae738);}export function loadProfileCredentials(_0x538348){const _0x4b6efd=a27_0x1528;validateProfileName(_0x538348);const _0x3588c6=getNewCredentialPath(_0x538348);if(a27_0x47a4ea[_0x4b6efd(0x118)](_0x3588c6))try{return a27_0x47a4ea[_0x4b6efd(0x125)](_0x3588c6,'utf-8');}catch{}const _0xdce67e=getOldCredentialPath(_0x538348);if(a27_0x47a4ea[_0x4b6efd(0x118)](_0xdce67e)){console[_0x4b6efd(0x11b)](_0x4b6efd(0x10a)+_0x538348+'\x27'),console[_0x4b6efd(0x11b)](_0x4b6efd(0x113)),console[_0x4b6efd(0x11b)](_0x4b6efd(0x106)+_0xdce67e+_0x4b6efd(0x10d)+_0x3588c6+'\x22'),console[_0x4b6efd(0x11b)](_0x4b6efd(0x145));try{return a27_0x47a4ea['readFileSync'](_0xdce67e,_0x4b6efd(0x122));}catch{return null;}}return null;}
|
|
1
|
+
function a28_0x5a1c(){const _0x38c395=['set','filter','696072yPfCmH','parse','Profile\x20','map','\x27:\x20unknown\x20config\x20key\x20\x27','llm_agent','\x27:\x20\x27llm_project\x27\x20must\x20be\x20a\x20string','\x27:\x20config\x20must\x20be\x20an\x20object','\x27\x20will\x20be\x20ignored','2LxhOTz','values','\x0aWarning:\x20Profiles\x20in\x20directories\x20are\x20deprecated:\x20','Warning:\x20Profile\x20\x27','parent_segment','\x27:\x20\x27llm_agent\x27\x20must\x20be\x20a\x20string','site','readFileSync','\x20does\x20not\x20exist','\x22\x20\x22','.\x20Must\x20contain\x20only\x20alphanumeric\x20characters,\x20dash,\x20and\x20underscore.','description','\x20already\x20exists','Please\x20migrate\x20to\x20~/.config/tdx/tdx.json:','13692EFFiMp','string','969157reSbex','entries','profile',':\x20Invalid\x20JSON\x20syntax','Profile\x20\x27','1127276msggnL','warn','push','1990MFchjR','.env','name','test','API\x20keys\x20must\x20not\x20be\x20stored\x20in\x20profile\x20configuration.\x20Use\x20.env\x20file\x20instead.','message','some','profiles','Invalid\x20profile\x20name:\x20','toISOString','sort','lastUsed','keys','Error:\x20','find','2711870nxXYhN','llm_project','writeFileSync','\x0aWarning:\x20Skipping\x20invalid\x20profile\x20in\x20','isDirectory','utf-8','localeCompare','user','rmSync','\x27:\x20\x27description\x27\x20must\x20be\x20a\x20string','stringify','\x20\x202.\x20Add\x20profiles\x20under\x20a\x20\x22profiles\x22\x20key\x20(see\x20\x27tdx\x20profiles\x27\x20for\x20current\x20config)','120kqDFXd','object','To\x20migrate:','includes','api_key','metadata','9ALnbuu','\x0aWarning:\x20Using\x20deprecated\x20credential\x20location\x20for\x20profile\x20\x27','local','\x20\x203.\x20Move\x20credentials:\x20mv\x20~/.config/tdx/profiles/<name>/.env\x20~/.config/tdx/.env.<name>\x0a','database','\x27:\x20\x27site\x27\x20must\x20be\x20a\x20string','\x0aWarning:\x20Failed\x20to\x20parse\x20','\x20\x201.\x20Edit:\x20','from','\x0aWarning:\x20Failed\x20to\x20load\x20profiles\x20from\x20','215937YlpgMB','join','242gjddew','length','6970782AtDqkO','existsSync','Then\x20define\x20profiles\x20in\x20~/.config/tdx/tdx.json\x0a','tdx.json','directory'];a28_0x5a1c=function(){return _0x38c395;};return a28_0x5a1c();}(function(_0x89e2d5,_0x4c5df6){const _0x330335=a28_0x23c6,_0x1044d9=_0x89e2d5();while(!![]){try{const _0x585895=parseInt(_0x330335(0x10e))/0x1*(parseInt(_0x330335(0xfe))/0x2)+-parseInt(_0x330335(0x137))/0x3*(-parseInt(_0x330335(0x113))/0x4)+-parseInt(_0x330335(0x116))/0x5*(parseInt(_0x330335(0x10c))/0x6)+parseInt(_0x330335(0xee))/0x7+-parseInt(_0x330335(0x131))/0x8*(parseInt(_0x330335(0xea))/0x9)+parseInt(_0x330335(0x125))/0xa+-parseInt(_0x330335(0xec))/0xb*(parseInt(_0x330335(0xf5))/0xc);if(_0x585895===_0x4c5df6)break;else _0x1044d9['push'](_0x1044d9['shift']());}catch(_0x54c077){_0x1044d9['push'](_0x1044d9['shift']());}}}(a28_0x5a1c,0x83314));import*as a28_0x4abcfe from'node:fs';import*as a28_0x3e7f36 from'node:path';import{getConfigDir}from'./config.js';import{createSecureDirectory,writeSecureFile}from'../utils/file-permissions.js';import{findProjectConfigPath}from'./project-config.js';function a28_0x23c6(_0x57ac34,_0x5ceda1){const _0x5a1c8e=a28_0x5a1c();return a28_0x23c6=function(_0x23c692,_0x482d7a){_0x23c692=_0x23c692-0xe5;let _0x284c8b=_0x5a1c8e[_0x23c692];return _0x284c8b;},a28_0x23c6(_0x57ac34,_0x5ceda1);}export function getProfileParams(_0x46c07a){const _0x1c82d7=a28_0x23c6,_0x1f5503={};if(!_0x46c07a)return _0x1f5503;for(const [_0x4074af,_0x91bcef]of Object[_0x1c82d7(0x10f)](_0x46c07a)){_0x4074af!==_0x1c82d7(0x109)&&_0x91bcef!==undefined&&(_0x1f5503[_0x4074af]=_0x91bcef);}return _0x1f5503;}export function getProfilesDir(){const _0x2cb065=a28_0x23c6;return a28_0x3e7f36[_0x2cb065(0xeb)](getConfigDir(),_0x2cb065(0x11d));}function getProfileDir(_0x591f45){const _0xe0999b=a28_0x23c6;return a28_0x3e7f36[_0xe0999b(0xeb)](getProfilesDir(),_0x591f45);}function getProfileConfigPath(_0xe041f2){const _0x3b068d=a28_0x23c6;return a28_0x3e7f36[_0x3b068d(0xeb)](getProfileDir(_0xe041f2),_0x3b068d(0xf1));}function getProfileEnvPath(_0x4b70f7){const _0x51353f=a28_0x23c6;return a28_0x3e7f36['join'](getProfileDir(_0x4b70f7),_0x51353f(0x117));}function getGlobalConfigPath(){const _0x48a14c=a28_0x23c6;return a28_0x3e7f36[_0x48a14c(0xeb)](getConfigDir(),_0x48a14c(0xf1));}function validateProfileName(_0x15bf77){const _0x49d86f=a28_0x23c6;if(!/^[a-zA-Z0-9_-]+$/[_0x49d86f(0x119)](_0x15bf77))throw new Error(_0x49d86f(0x11e)+_0x15bf77+_0x49d86f(0x108));}function validateProfileConfig(_0x212b36,_0x9a56aa){const _0x3686a9=a28_0x23c6;if(typeof _0x212b36!==_0x3686a9(0x132)||_0x212b36===null)throw new Error(_0x3686a9(0x112)+_0x9a56aa+_0x3686a9(0xfc));const _0x26741e=[_0x3686a9(0x109),'site','database',_0x3686a9(0x102),_0x3686a9(0x126),_0x3686a9(0xfa)],_0xf1d548=_0x212b36;for(const _0xa90e02 of Object[_0x3686a9(0x122)](_0xf1d548)){!_0x26741e['includes'](_0xa90e02)&&console[_0x3686a9(0x114)](_0x3686a9(0x101)+_0x9a56aa+_0x3686a9(0xf9)+_0xa90e02+_0x3686a9(0xfd));}if(_0xf1d548[_0x3686a9(0x109)]!==undefined&&typeof _0xf1d548['description']!==_0x3686a9(0x10d))throw new Error(_0x3686a9(0x112)+_0x9a56aa+_0x3686a9(0x12e));if(_0xf1d548[_0x3686a9(0x104)]!==undefined&&typeof _0xf1d548[_0x3686a9(0x104)]!==_0x3686a9(0x10d))throw new Error(_0x3686a9(0x112)+_0x9a56aa+_0x3686a9(0xe5));if(_0xf1d548['database']!==undefined&&typeof _0xf1d548[_0x3686a9(0x13b)]!=='string')throw new Error(_0x3686a9(0x112)+_0x9a56aa+'\x27:\x20\x27database\x27\x20must\x20be\x20a\x20string');if(_0xf1d548[_0x3686a9(0x102)]!==undefined&&typeof _0xf1d548[_0x3686a9(0x102)]!==_0x3686a9(0x10d))throw new Error(_0x3686a9(0x112)+_0x9a56aa+'\x27:\x20\x27parent_segment\x27\x20must\x20be\x20a\x20string');if(_0xf1d548[_0x3686a9(0x126)]!==undefined&&typeof _0xf1d548[_0x3686a9(0x126)]!==_0x3686a9(0x10d))throw new Error('Profile\x20\x27'+_0x9a56aa+_0x3686a9(0xfb));if(_0xf1d548[_0x3686a9(0xfa)]!==undefined&&typeof _0xf1d548['llm_agent']!==_0x3686a9(0x10d))throw new Error('Profile\x20\x27'+_0x9a56aa+_0x3686a9(0x103));return!![];}function loadProfilesFromTdxJson(_0x3d4285,_0x586fb8){const _0x1a10b1=a28_0x23c6;if(!a28_0x4abcfe[_0x1a10b1(0xef)](_0x3d4285))return[];try{const _0x2c60e0=a28_0x4abcfe['readFileSync'](_0x3d4285,'utf-8'),_0x1d664f=JSON[_0x1a10b1(0xf6)](_0x2c60e0);if(!_0x1d664f[_0x1a10b1(0x11d)]||typeof _0x1d664f[_0x1a10b1(0x11d)]!=='object')return[];const _0x5b5fd5=[];for(const [_0x16b632,_0x477c06]of Object['entries'](_0x1d664f[_0x1a10b1(0x11d)])){try{validateProfileConfig(_0x477c06,_0x16b632);const _0x2fcbea=getNewCredentialPath(_0x16b632),_0x40e574=getOldCredentialPath(_0x16b632),_0x5d5200=a28_0x4abcfe[_0x1a10b1(0xef)](_0x2fcbea)||a28_0x4abcfe[_0x1a10b1(0xef)](_0x40e574);_0x5b5fd5['push']({'name':_0x16b632,'config':_0x477c06,'metadata':{'name':_0x16b632,'createdAt':new Date()[_0x1a10b1(0x11f)]()},'hasCredentials':_0x5d5200,'scope':_0x586fb8});}catch(_0x261958){_0x261958 instanceof Error&&(console[_0x1a10b1(0x114)](_0x1a10b1(0x128)+_0x3d4285+':'),console[_0x1a10b1(0x114)]('\x20\x20'+_0x261958[_0x1a10b1(0x11b)]+'\x0a'));}}return _0x5b5fd5;}catch(_0x7bcd9a){return _0x7bcd9a instanceof SyntaxError?(console[_0x1a10b1(0x114)](_0x1a10b1(0xe6)+_0x3d4285+_0x1a10b1(0x111)),console[_0x1a10b1(0x114)](_0x1a10b1(0x123)+_0x7bcd9a[_0x1a10b1(0x11b)]+'\x0a')):console[_0x1a10b1(0x114)](_0x1a10b1(0xe9)+_0x3d4285+':\x20'+_0x7bcd9a+'\x0a'),[];}}export function getNewCredentialPath(_0x1b50d5){return a28_0x3e7f36['join'](getConfigDir(),'.env.'+_0x1b50d5);}function getOldCredentialPath(_0x5bd157){const _0xcf85eb=a28_0x23c6;return a28_0x3e7f36[_0xcf85eb(0xeb)](getProfilesDir(),_0x5bd157,_0xcf85eb(0x117));}function loadProfilesFromTdxJsonFiles(){const _0x4b694d=a28_0x23c6,_0x510d45=[],_0xa2af1a=findProjectConfigPath();_0xa2af1a&&_0x510d45['push'](...loadProfilesFromTdxJson(_0xa2af1a,_0x4b694d(0x139)));const _0x2959a4=a28_0x3e7f36['join'](getConfigDir(),_0x4b694d(0xf1));return _0x510d45[_0x4b694d(0x115)](...loadProfilesFromTdxJson(_0x2959a4,_0x4b694d(0x12c))),_0x510d45;}function loadProfilesFromDirectories(){const _0x39622c=a28_0x23c6,_0x53a713=getProfilesDir();if(!a28_0x4abcfe['existsSync'](_0x53a713))return[];try{return a28_0x4abcfe['readdirSync'](_0x53a713,{'withFileTypes':!![]})[_0x39622c(0xf4)](_0x520006=>_0x520006[_0x39622c(0x129)]())[_0x39622c(0xf8)](_0x5344b6=>_0x5344b6[_0x39622c(0x118)])[_0x39622c(0xf4)](_0x395955=>{const _0x133049=_0x39622c,_0x12ca51=getProfileConfigPath(_0x395955),_0x1f2d1e=getProfileEnvPath(_0x395955);return a28_0x4abcfe[_0x133049(0xef)](_0x12ca51)||a28_0x4abcfe[_0x133049(0xef)](_0x1f2d1e);})[_0x39622c(0xf8)](_0x6306e=>{const _0x42ce56=_0x39622c,_0x4ba969=loadProfileFromDirectory(_0x6306e);if(_0x4ba969)return{..._0x4ba969,'scope':_0x42ce56(0xf2)};return null;})[_0x39622c(0xf4)](_0x42ab2a=>_0x42ab2a!==null);}catch{return[];}}function loadProfileFromDirectory(_0xc37db3){const _0x404c42=a28_0x23c6,_0x478857=getProfileConfigPath(_0xc37db3),_0x306da2=getOldCredentialPath(_0xc37db3);if(!a28_0x4abcfe['existsSync'](_0x478857)&&!a28_0x4abcfe[_0x404c42(0xef)](_0x306da2))return null;let _0x2f68f8={},_0xcc5ee3={'name':_0xc37db3,'createdAt':new Date()[_0x404c42(0x11f)]()};if(a28_0x4abcfe[_0x404c42(0xef)](_0x478857))try{const _0x314db0=a28_0x4abcfe['readFileSync'](_0x478857,'utf-8'),_0x535627=JSON[_0x404c42(0xf6)](_0x314db0),{metadata:_0x4707d2,..._0x276181}=_0x535627;_0x2f68f8=_0x276181,_0x4707d2&&(_0xcc5ee3=_0x4707d2);}catch{}return{'name':_0xc37db3,'config':_0x2f68f8,'metadata':_0xcc5ee3,'hasCredentials':a28_0x4abcfe[_0x404c42(0xef)](_0x306da2),'scope':_0x404c42(0xf2)};}export function listProfiles(){const _0x208f78=a28_0x23c6,_0x552545=loadProfilesFromTdxJsonFiles(),_0x2fb2f5=loadProfilesFromDirectories();if(_0x2fb2f5[_0x208f78(0xed)]>0x0){const _0x3b767a=_0x2fb2f5[_0x208f78(0xf8)](_0x510fcd=>_0x510fcd[_0x208f78(0x118)])['join'](',\x20'),_0x5ccc65=getConfigDir();console['warn'](_0x208f78(0x100)+_0x3b767a),console[_0x208f78(0x114)](_0x208f78(0x10b)),console[_0x208f78(0x114)](_0x208f78(0xe7)+a28_0x3e7f36[_0x208f78(0xeb)](_0x5ccc65,_0x208f78(0xf1))),console[_0x208f78(0x114)](_0x208f78(0x130)),console[_0x208f78(0x114)](_0x208f78(0x13a));}const _0x559e36=[..._0x552545,..._0x2fb2f5],_0x3b684e=new Map();for(const _0x5768fb of _0x559e36){!_0x3b684e['has'](_0x5768fb[_0x208f78(0x118)])&&_0x3b684e[_0x208f78(0xf3)](_0x5768fb[_0x208f78(0x118)],_0x5768fb);}return Array[_0x208f78(0xe8)](_0x3b684e[_0x208f78(0xff)]())[_0x208f78(0x120)]((_0x13100e,_0x108d31)=>_0x13100e[_0x208f78(0x118)][_0x208f78(0x12b)](_0x108d31['name']));}export function profileExists(_0x479f42){const _0x1f8d3a=a28_0x23c6,_0xba3d7b=listProfiles();return _0xba3d7b[_0x1f8d3a(0x11c)](_0x42415f=>_0x42415f[_0x1f8d3a(0x118)]===_0x479f42);}export function loadProfile(_0x3a5dab){const _0x3a7cd4=a28_0x23c6;validateProfileName(_0x3a5dab);const _0x6ba2c3=listProfiles(),_0x3bfc45=_0x6ba2c3[_0x3a7cd4(0x124)](_0x39129e=>_0x39129e['name']===_0x3a5dab);return _0x3bfc45||null;}export function saveProfile(_0x22e170,_0x49fee3,_0xb2d2a1=![]){const _0x20ec72=a28_0x23c6;validateProfileName(_0x22e170);const _0x2d29e9=getProfileDir(_0x22e170),_0x5d03ba=getProfileConfigPath(_0x22e170);createSecureDirectory(_0x2d29e9);let _0x17a462;const _0x39a1b8=loadProfile(_0x22e170);_0x39a1b8?(_0x17a462=_0x39a1b8[_0x20ec72(0x136)],_0xb2d2a1&&(_0x17a462[_0x20ec72(0x121)]=new Date()['toISOString']())):_0x17a462={'name':_0x22e170,'createdAt':new Date()[_0x20ec72(0x11f)]()};const _0xd02b2c=JSON[_0x20ec72(0x12f)](_0x49fee3);if(_0xd02b2c['includes']('TD_API_KEY')||_0xd02b2c[_0x20ec72(0x134)]('apiKey')||_0xd02b2c['includes'](_0x20ec72(0x135)))throw new Error(_0x20ec72(0x11a));const _0x171743={..._0x49fee3,'metadata':_0x17a462};a28_0x4abcfe[_0x20ec72(0x127)](_0x5d03ba,JSON[_0x20ec72(0x12f)](_0x171743,null,0x2));}export function deleteProfile(_0x2c1543){const _0x184755=a28_0x23c6;validateProfileName(_0x2c1543);const _0x457995=getProfileDir(_0x2c1543);if(!a28_0x4abcfe['existsSync'](_0x457995))throw new Error(_0x184755(0xf7)+_0x2c1543+'\x20does\x20not\x20exist');a28_0x4abcfe[_0x184755(0x12d)](_0x457995,{'recursive':!![],'force':!![]});}export function getActiveProfile(){const _0x8742e5=a28_0x23c6,_0x18068e=getGlobalConfigPath();if(!a28_0x4abcfe[_0x8742e5(0xef)](_0x18068e))return null;try{const _0x48dfe3=a28_0x4abcfe[_0x8742e5(0x105)](_0x18068e,'utf-8'),_0x430144=JSON['parse'](_0x48dfe3);return _0x430144[_0x8742e5(0x110)]||null;}catch{return null;}}export function createProfile(_0x34a7b0,_0x37a7c4){const _0x210dca=a28_0x23c6;validateProfileName(_0x34a7b0);if(profileExists(_0x34a7b0))throw new Error(_0x210dca(0xf7)+_0x34a7b0+_0x210dca(0x10a));saveProfile(_0x34a7b0,_0x37a7c4);}export function saveProfileCredentials(_0x40bd9f,_0x3f189e){const _0x5dac3c=a28_0x23c6;validateProfileName(_0x40bd9f);if(!profileExists(_0x40bd9f))throw new Error('Profile\x20'+_0x40bd9f+_0x5dac3c(0x106));const _0x1efda3=getNewCredentialPath(_0x40bd9f);writeSecureFile(_0x1efda3,_0x3f189e);}export function loadProfileCredentials(_0x3344ad){const _0x141aa3=a28_0x23c6;validateProfileName(_0x3344ad);const _0xd9324c=getNewCredentialPath(_0x3344ad);if(a28_0x4abcfe['existsSync'](_0xd9324c))try{return a28_0x4abcfe[_0x141aa3(0x105)](_0xd9324c,_0x141aa3(0x12a));}catch{}const _0xd31474=getOldCredentialPath(_0x3344ad);if(a28_0x4abcfe['existsSync'](_0xd31474)){console[_0x141aa3(0x114)](_0x141aa3(0x138)+_0x3344ad+'\x27'),console[_0x141aa3(0x114)](_0x141aa3(0x133)),console[_0x141aa3(0x114)]('\x20\x20mv\x20\x22'+_0xd31474+_0x141aa3(0x107)+_0xd9324c+'\x22'),console[_0x141aa3(0x114)](_0x141aa3(0xf0));try{return a28_0x4abcfe[_0x141aa3(0x105)](_0xd31474,_0x141aa3(0x12a));}catch{return null;}}return null;}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a29_0x551ca1=a29_0x2162;(function(_0x41cf74,_0x3b9d10){const _0x39e036=a29_0x2162,_0x40bbac=_0x41cf74();while(!![]){try{const _0x7be06e=parseInt(_0x39e036(0x1b3))/0x1+-parseInt(_0x39e036(0x1c2))/0x2+-parseInt(_0x39e036(0x1b1))/0x3+parseInt(_0x39e036(0x1c7))/0x4*(parseInt(_0x39e036(0x1ae))/0x5)+-parseInt(_0x39e036(0x1b5))/0x6*(-parseInt(_0x39e036(0x1bb))/0x7)+-parseInt(_0x39e036(0x1b4))/0x8+parseInt(_0x39e036(0x1b8))/0x9;if(_0x7be06e===_0x3b9d10)break;else _0x40bbac['push'](_0x40bbac['shift']());}catch(_0x13bfd4){_0x40bbac['push'](_0x40bbac['shift']());}}}(a29_0x1bce,0x9031f));import*as a29_0x56b0ec from'node:fs';import*as a29_0x48b0c5 from'node:path';function a29_0x2162(_0x312410,_0x26e52b){const _0x1bce7f=a29_0x1bce();return a29_0x2162=function(_0x2162ce,_0x243f0b){_0x2162ce=_0x2162ce-0x1ab;let _0x1c3c12=_0x1bce7f[_0x2162ce];return _0x1c3c12;},a29_0x2162(_0x312410,_0x26e52b);}const PROJECT_CONFIG_FILENAME=a29_0x551ca1(0x1c8);export function findProjectConfigPath(_0x1cd67e){const _0x43c6ba=a29_0x551ca1;let _0x4e58ac=_0x1cd67e||process['cwd']();while(!![]){const _0x5a8d30=a29_0x48b0c5[_0x43c6ba(0x1b2)](_0x4e58ac,PROJECT_CONFIG_FILENAME);if(a29_0x56b0ec[_0x43c6ba(0x1c3)](_0x5a8d30))return _0x5a8d30;const _0x4d0c10=a29_0x48b0c5[_0x43c6ba(0x1ad)](_0x4e58ac);if(_0x4d0c10===_0x4e58ac)return null;_0x4e58ac=_0x4d0c10;}}export function loadProjectConfig(_0x12a43c){const _0x2cefb4=a29_0x551ca1,_0x89cc84=findProjectConfigPath(_0x12a43c);if(!_0x89cc84)return null;try{const _0x4c4c0f=a29_0x56b0ec[_0x2cefb4(0x1c0)](_0x89cc84,'utf-8'),_0x50a3f7=JSON[_0x2cefb4(0x1af)](_0x4c4c0f),_0x4995ce=JSON[_0x2cefb4(0x1c9)](_0x50a3f7);if(_0x4995ce[_0x2cefb4(0x1be)]('TD_API_KEY')||_0x4995ce[_0x2cefb4(0x1be)](_0x2cefb4(0x1b0))||_0x4995ce['includes'](_0x2cefb4(0x1c5)))throw new Error('Security\x20error:\x20API\x20keys\x20must\x20not\x20be\x20stored\x20in\x20project\x20config\x20('+_0x89cc84+_0x2cefb4(0x1b6)+_0x2cefb4(0x1bd));const {metadata:_0x425ce2,profile:_0x3337ca,..._0x4c19ca}=_0x50a3f7;return _0x3337ca&&console[_0x2cefb4(0x1bc)]('Warning:\x20\x27profile\x27\x20field\x20in\x20'+_0x89cc84+'\x20is\x20ignored.\x20'+'Active\x20profile\x20is\x20set\x20in\x20~/.config/tdx/tdx.json'),_0x4c19ca;}catch(_0x3bf7c5){if(_0x3bf7c5 instanceof Error&&_0x2cefb4(0x1b9)in _0x3bf7c5&&_0x3bf7c5[_0x2cefb4(0x1b9)]===_0x2cefb4(0x1c1))return null;throw new Error(_0x2cefb4(0x1b7)+_0x89cc84+':\x20'+_0x3bf7c5);}}export function saveProjectConfig(_0x4c6c59,_0x122f40){const _0x27f6a5=a29_0x551ca1,_0x3915b6=_0x122f40||process[_0x27f6a5(0x1bf)](),_0x5c2ea8=a29_0x48b0c5[_0x27f6a5(0x1b2)](_0x3915b6,PROJECT_CONFIG_FILENAME),_0x1471b4=JSON[_0x27f6a5(0x1c9)](_0x4c6c59);if(_0x1471b4[_0x27f6a5(0x1be)](_0x27f6a5(0x1ba))||_0x1471b4['includes'](_0x27f6a5(0x1b0))||_0x1471b4['includes'](_0x27f6a5(0x1c5)))throw new Error(_0x27f6a5(0x1ab));if(_0x27f6a5(0x1c6)in _0x4c6c59)throw new Error(_0x27f6a5(0x1c4));a29_0x56b0ec[_0x27f6a5(0x1ac)](_0x5c2ea8,JSON[_0x27f6a5(0x1c9)](_0x4c6c59,null,0x2));}function a29_0x1bce(){const _0x5dd2c8=['600448kRZOQM','5324768ZEXXSy','198DxIVBr',').\x20','Failed\x20to\x20load\x20project\x20config\x20from\x20','12977280PRgGoQ','code','TD_API_KEY','117957BRhnen','warn','Use\x20~/.config/tdx/.env\x20or\x20profile\x20.env\x20files\x20instead.','includes','cwd','readFileSync','ENOENT','1494360AFtEex','existsSync','\x27profile\x27\x20should\x20not\x20be\x20set\x20in\x20project\x20config.\x20Use\x20\x27tdx\x20profile\x20use\x27\x20instead.','api_key','profile','2332972axspNp','tdx.json','stringify','API\x20keys\x20must\x20not\x20be\x20stored\x20in\x20project\x20configuration.\x20Use\x20.env\x20files\x20instead.','writeFileSync','dirname','5zPNrYX','parse','apiKey','3534885EhlqvP','join'];a29_0x1bce=function(){return _0x5dd2c8;};return a29_0x1bce();}export function hasProjectConfig(_0xf2e6b6){return findProjectConfigPath(_0xf2e6b6)!==null;}export function getProjectRoot(_0x427399){const _0x54829b=a29_0x551ca1,_0x45ad44=findProjectConfigPath(_0x427399);return _0x45ad44?a29_0x48b0c5[_0x54829b(0x1ad)](_0x45ad44):null;}
|
package/dist/core/session.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(_0x3086fd,_0x314beb){const _0x388b4e=a30_0x3641,_0x4f6f81=_0x3086fd();while(!![]){try{const _0xc6f0de=-parseInt(_0x388b4e(0x1cb))/0x1+-parseInt(_0x388b4e(0x1a9))/0x2+-parseInt(_0x388b4e(0x1a7))/0x3*(parseInt(_0x388b4e(0x1b5))/0x4)+-parseInt(_0x388b4e(0x1a8))/0x5+-parseInt(_0x388b4e(0x1a6))/0x6*(-parseInt(_0x388b4e(0x1ce))/0x7)+-parseInt(_0x388b4e(0x1b9))/0x8+parseInt(_0x388b4e(0x1ad))/0x9;if(_0xc6f0de===_0x314beb)break;else _0x4f6f81['push'](_0x4f6f81['shift']());}catch(_0x87eeb3){_0x4f6f81['push'](_0x4f6f81['shift']());}}}(a30_0x3bc7,0xebc7a));import*as a30_0x5a32fa from'node:fs';import*as a30_0x722665 from'node:path';import*as a30_0x373acb from'node:os';import{getPPID,isProcessRunning}from'../utils/process.js';import{createSecureDirectory}from'../utils/file-permissions.js';const SESSION_EXPIRATION_MS=0x18*0x3c*0x3c*0x3e8;function a30_0x3641(_0x6ef845,_0x3a0da8){const _0x3bc7cf=a30_0x3bc7();return a30_0x3641=function(_0x3641b3,_0x1d9bd6){_0x3641b3=_0x3641b3-0x1a5;let _0x546d9f=_0x3bc7cf[_0x3641b3];return _0x546d9f;},a30_0x3641(_0x6ef845,_0x3a0da8);}function getSessionsDir(){const _0xde851f=a30_0x3641,_0x359d8d=process[_0xde851f(0x1aa)][_0xde851f(0x1cf)]||a30_0x722665[_0xde851f(0x1b1)](a30_0x373acb[_0xde851f(0x1b4)](),_0xde851f(0x1c1),_0xde851f(0x1c7));return a30_0x722665[_0xde851f(0x1b1)](_0x359d8d,_0xde851f(0x1c3));}function getSessionPath(_0x408c6d){const _0x3a2fa4=a30_0x3641;return a30_0x722665[_0x3a2fa4(0x1b1)](getSessionsDir(),_0x408c6d+'.json');}export function getCurrentSessionPID(){return getPPID();}export function getSessionID(_0x3f678b){const _0xc6f3cc=a30_0x3641;if(_0x3f678b)return _0x3f678b;return getCurrentSessionPID()[_0xc6f3cc(0x1b2)]();}function a30_0x3bc7(){const _0x3dc24c=['writeFileSync','sessions','api_key','stringify','endsWith','tdx','parse','utf-8','apiKey','910690ISmUfH','createdAt','push','4688838vaDFDp','TDX_CONFIG_DIR','Warning:\x20API\x20keys\x20found\x20in\x20session\x20file\x20','12IjpIiP','3ujllSl','3289130IRRJuE','3096212oasunC','env','warn','replace','45971091JRSPvG','.json','includes','now','join','toString','TD_API_KEY','homedir','5875572GtpKnT','readFileSync','API\x20keys\x20must\x20not\x20be\x20stored\x20in\x20session\x20context.\x20Use\x20.env\x20files\x20instead.','toISOString','7170384WaTPeh','unlinkSync','readdirSync','existsSync','.\x20This\x20is\x20insecure.\x20Removing\x20session.','test','getTime','sort','.config'];a30_0x3bc7=function(){return _0x3dc24c;};return a30_0x3bc7();}export function loadSessionContext(_0x53f4cb){const _0x1f1d82=a30_0x3641,_0x47e5d3=_0x53f4cb||getCurrentSessionPID()[_0x1f1d82(0x1b2)](),_0x1fb9aa=/^\d+$/[_0x1f1d82(0x1be)](_0x47e5d3)?parseInt(_0x47e5d3,0xa):null;return _0x1fb9aa!==null?loadSessionContextByPID(_0x1fb9aa):loadSessionContextByString(_0x47e5d3);}export function loadSessionContextByPID(_0x542e3e){const _0x43e28c=a30_0x3641,_0x299ec9=getSessionPath(_0x542e3e);if(!a30_0x5a32fa['existsSync'](_0x299ec9))return null;try{const _0x28dfe4=a30_0x5a32fa[_0x43e28c(0x1b6)](_0x299ec9,_0x43e28c(0x1c9)),_0x2968dd=JSON[_0x43e28c(0x1c8)](_0x28dfe4),_0x4ff37c=new Date(_0x2968dd[_0x43e28c(0x1cc)])['getTime'](),_0x3d45e1=Date[_0x43e28c(0x1b0)]();if(_0x3d45e1-_0x4ff37c>SESSION_EXPIRATION_MS)return a30_0x5a32fa[_0x43e28c(0x1ba)](_0x299ec9),null;const _0x338d61=JSON['stringify'](_0x2968dd);if(_0x338d61[_0x43e28c(0x1af)]('TD_API_KEY')||_0x338d61['includes'](_0x43e28c(0x1ca))||_0x338d61[_0x43e28c(0x1af)](_0x43e28c(0x1c4)))return console[_0x43e28c(0x1ab)](_0x43e28c(0x1a5)+_0x299ec9+'.\x20This\x20is\x20insecure.\x20Removing\x20session.'),a30_0x5a32fa[_0x43e28c(0x1ba)](_0x299ec9),null;return _0x2968dd;}catch{try{a30_0x5a32fa[_0x43e28c(0x1ba)](_0x299ec9);}catch{}return null;}}function loadSessionContextByString(_0x39fb4e){const _0x5da6f0=a30_0x3641,_0x1bfb8c=a30_0x722665['join'](getSessionsDir(),_0x39fb4e+'.json');if(!a30_0x5a32fa[_0x5da6f0(0x1bc)](_0x1bfb8c))return null;try{const _0x2767a5=a30_0x5a32fa[_0x5da6f0(0x1b6)](_0x1bfb8c,_0x5da6f0(0x1c9)),_0x18dcf6=JSON['parse'](_0x2767a5),_0x2d1c98=new Date(_0x18dcf6[_0x5da6f0(0x1cc)])[_0x5da6f0(0x1bf)](),_0x4c01d2=Date[_0x5da6f0(0x1b0)]();if(_0x4c01d2-_0x2d1c98>SESSION_EXPIRATION_MS)return a30_0x5a32fa[_0x5da6f0(0x1ba)](_0x1bfb8c),null;const _0xc5dfd5=JSON['stringify'](_0x18dcf6);if(_0xc5dfd5[_0x5da6f0(0x1af)](_0x5da6f0(0x1b3))||_0xc5dfd5[_0x5da6f0(0x1af)](_0x5da6f0(0x1ca))||_0xc5dfd5[_0x5da6f0(0x1af)](_0x5da6f0(0x1c4)))return console[_0x5da6f0(0x1ab)](_0x5da6f0(0x1a5)+_0x1bfb8c+_0x5da6f0(0x1bd)),a30_0x5a32fa[_0x5da6f0(0x1ba)](_0x1bfb8c),null;return _0x18dcf6;}catch{try{a30_0x5a32fa[_0x5da6f0(0x1ba)](_0x1bfb8c);}catch{}return null;}}export function saveSessionContext(_0x2f6782,_0x391091){const _0x5694ef=a30_0x3641,_0x1a7434=_0x391091||getCurrentSessionPID()[_0x5694ef(0x1b2)](),_0x21d8c8=/^\d+$/[_0x5694ef(0x1be)](_0x1a7434)?parseInt(_0x1a7434,0xa):getCurrentSessionPID(),_0x1ba8bf=a30_0x722665[_0x5694ef(0x1b1)](getSessionsDir(),_0x1a7434+_0x5694ef(0x1ae)),_0x42b99c=getSessionsDir();createSecureDirectory(_0x42b99c);const _0x4eba8e=JSON[_0x5694ef(0x1c5)](_0x2f6782);if(_0x4eba8e[_0x5694ef(0x1af)](_0x5694ef(0x1b3))||_0x4eba8e[_0x5694ef(0x1af)](_0x5694ef(0x1ca))||_0x4eba8e[_0x5694ef(0x1af)]('api_key'))throw new Error(_0x5694ef(0x1b7));let _0x4aecc7;const _0x246a84=/^\d+$/[_0x5694ef(0x1be)](_0x1a7434)?loadSessionContextByPID(parseInt(_0x1a7434,0xa)):loadSessionContextByString(_0x1a7434);_0x246a84?_0x4aecc7={..._0x246a84,..._0x2f6782,'pid':_0x21d8c8,'sessionId':_0x1a7434!==_0x21d8c8[_0x5694ef(0x1b2)]()?_0x1a7434:undefined,'updatedAt':new Date()[_0x5694ef(0x1b8)]()}:_0x4aecc7={'pid':_0x21d8c8,'sessionId':_0x1a7434!==_0x21d8c8['toString']()?_0x1a7434:undefined,..._0x2f6782,'createdAt':new Date()[_0x5694ef(0x1b8)](),'updatedAt':new Date()['toISOString']()},a30_0x5a32fa[_0x5694ef(0x1c2)](_0x1ba8bf,JSON[_0x5694ef(0x1c5)](_0x4aecc7,null,0x2));}export function clearSessionContext(_0x53587e){const _0xf55945=a30_0x3641,_0x53acaa=_0x53587e||getCurrentSessionPID()[_0xf55945(0x1b2)](),_0x1e103b=a30_0x722665[_0xf55945(0x1b1)](getSessionsDir(),_0x53acaa+'.json');a30_0x5a32fa['existsSync'](_0x1e103b)&&a30_0x5a32fa[_0xf55945(0x1ba)](_0x1e103b);}export function cleanExpiredSessions(){const _0xe579a0=a30_0x3641,_0x178a2d=getSessionsDir();if(!a30_0x5a32fa[_0xe579a0(0x1bc)](_0x178a2d))return 0x0;let _0x4fa830=0x0;const _0xeb6d71=Date['now']();try{const _0x357b04=a30_0x5a32fa['readdirSync'](_0x178a2d);for(const _0x1f3e45 of _0x357b04){if(!_0x1f3e45['endsWith']('.json'))continue;const _0x90f421=a30_0x722665['join'](_0x178a2d,_0x1f3e45),_0x4f81f7=_0x1f3e45[_0xe579a0(0x1ac)](_0xe579a0(0x1ae),''),_0x3aa11e=parseInt(_0x4f81f7,0xa),_0x31b94d=!isNaN(_0x3aa11e);if(_0x31b94d){if(!isProcessRunning(_0x3aa11e)){a30_0x5a32fa[_0xe579a0(0x1ba)](_0x90f421),_0x4fa830++;continue;}}try{const _0x14962f=a30_0x5a32fa[_0xe579a0(0x1b6)](_0x90f421,_0xe579a0(0x1c9)),_0x5843b5=JSON['parse'](_0x14962f),_0x5a7ef4=new Date(_0x5843b5[_0xe579a0(0x1cc)])[_0xe579a0(0x1bf)]();_0xeb6d71-_0x5a7ef4>SESSION_EXPIRATION_MS&&(a30_0x5a32fa[_0xe579a0(0x1ba)](_0x90f421),_0x4fa830++);}catch{a30_0x5a32fa[_0xe579a0(0x1ba)](_0x90f421),_0x4fa830++;}}}catch{}return _0x4fa830;}export function listActiveSessions(){const _0x1dd4b9=a30_0x3641,_0x1660b8=getSessionsDir();if(!a30_0x5a32fa[_0x1dd4b9(0x1bc)](_0x1660b8))return[];try{const _0x3d22a9=a30_0x5a32fa[_0x1dd4b9(0x1bb)](_0x1660b8),_0x36588f=[];for(const _0x44d8a9 of _0x3d22a9){if(!_0x44d8a9[_0x1dd4b9(0x1c6)](_0x1dd4b9(0x1ae)))continue;const _0x311280=_0x44d8a9['replace'](_0x1dd4b9(0x1ae),''),_0x5c06f4=parseInt(_0x311280,0xa);!isNaN(_0x5c06f4)&&isProcessRunning(_0x5c06f4)&&_0x36588f[_0x1dd4b9(0x1cd)](_0x5c06f4);}return _0x36588f[_0x1dd4b9(0x1c0)]((_0x5cf6a9,_0x587b3a)=>_0x5cf6a9-_0x587b3a);}catch{return[];}}
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(_0x2faf8e,_0x36aa61){var _0x4e0e6a=a31_0x1e9f,_0x525d21=_0x2faf8e();while(!![]){try{var _0x3de76a=parseInt(_0x4e0e6a(0x156))/0x1+-parseInt(_0x4e0e6a(0x157))/0x2+-parseInt(_0x4e0e6a(0x15b))/0x3+-parseInt(_0x4e0e6a(0x15a))/0x4+parseInt(_0x4e0e6a(0x159))/0x5*(parseInt(_0x4e0e6a(0x158))/0x6)+parseInt(_0x4e0e6a(0x15c))/0x7+parseInt(_0x4e0e6a(0x155))/0x8*(parseInt(_0x4e0e6a(0x154))/0x9);if(_0x3de76a===_0x36aa61)break;else _0x525d21['push'](_0x525d21['shift']());}catch(_0x467010){_0x525d21['push'](_0x525d21['shift']());}}}(a31_0x2627,0x8f8ef));export*from'./types/index.js';export*from'./core/config.js';export*from'./core/auth.js';export*from'./client/http-client.js';export*from'./client/td-client.js';export{TrinoClient}from'./client/trino-client.js';export*from'./client/rate-limiter.js';export*from'./types/trino.js';export*from'./commands/command.js';export*from'./commands/query-command.js';export*from'./commands/databases.js';function a31_0x1e9f(_0x3c4456,_0x58d52f){var _0x2627d9=a31_0x2627();return a31_0x1e9f=function(_0x1e9f42,_0x233c41){_0x1e9f42=_0x1e9f42-0x154;var _0x167ccc=_0x2627d9[_0x1e9f42];return _0x167ccc;},a31_0x1e9f(_0x3c4456,_0x58d52f);}export*from'./commands/tables.js';export*from'./commands/segments.js';export*from'./commands/activations.js';function a31_0x2627(){var _0x177193=['948QFgfWB','25195flLptU','3368288xttKSe','1136655jfmHbM','1274497IfdtnS','400167ZvoBSS','136HmlCNk','142863Mffthy','135990TiquZh'];a31_0x2627=function(){return _0x177193;};return a31_0x2627();}export*from'./commands/show.js';export*from'./commands/describe.js';export*from'./sdk/index.js';
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* API translation layer for converting between Anthropic Messages API and TD LLM API formats
|
|
3
|
+
*/
|
|
4
|
+
import type { AnthropicMessage, AnthropicMessagesRequest, AnthropicStreamEvent, AnthropicTool } from '../types/anthropic.js';
|
|
5
|
+
import type { SSEEvent } from '../types/index.js';
|
|
6
|
+
/**
|
|
7
|
+
* Generate a unique message ID (simulating Anthropic's format)
|
|
8
|
+
*/
|
|
9
|
+
declare function generateMessageId(): string;
|
|
10
|
+
/**
|
|
11
|
+
* Extract text content from Anthropic messages
|
|
12
|
+
* Converts message history to simple string format for TD API
|
|
13
|
+
*/
|
|
14
|
+
export declare function extractTextFromAnthropicMessage(message: AnthropicMessage): string;
|
|
15
|
+
/**
|
|
16
|
+
* Calculate conversation delta
|
|
17
|
+
* Returns only the new messages that haven't been sent to TD API yet
|
|
18
|
+
*/
|
|
19
|
+
export declare function calculateConversationDelta(currentMessages: AnthropicMessage[], previousMessages: AnthropicMessage[]): AnthropicMessage[];
|
|
20
|
+
/**
|
|
21
|
+
* Transform Anthropic request to TD LLM API format
|
|
22
|
+
* Extracts the user message for TD's continue_chat endpoint
|
|
23
|
+
*/
|
|
24
|
+
export declare function transformAnthropicRequestToTD(request: AnthropicMessagesRequest, previousMessages: AnthropicMessage[]): {
|
|
25
|
+
userMessage: string;
|
|
26
|
+
deltaMessages: AnthropicMessage[];
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* Transform TD SSE events to Anthropic SSE format
|
|
30
|
+
* Creates an async generator that converts TD events to Anthropic streaming format
|
|
31
|
+
*/
|
|
32
|
+
export declare function transformTDStreamToAnthropic(tdStream: AsyncGenerator<SSEEvent, void, unknown>, messageId: string, model: string): AsyncGenerator<AnthropicStreamEvent, void, unknown>;
|
|
33
|
+
/**
|
|
34
|
+
* Format Anthropic SSE event for transmission
|
|
35
|
+
* Follows Server-Sent Events format: https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events
|
|
36
|
+
*/
|
|
37
|
+
export declare function formatAnthropicSSE(event: AnthropicStreamEvent): string;
|
|
38
|
+
/**
|
|
39
|
+
* Map Anthropic model names to TD model names
|
|
40
|
+
* Supports common Anthropic model aliases
|
|
41
|
+
*/
|
|
42
|
+
export declare function mapAnthropicModelToTD(anthropicModel: string): string;
|
|
43
|
+
/**
|
|
44
|
+
* Generate tool instruction prompt from Anthropic tool definitions
|
|
45
|
+
* This prompt instructs the LLM to output tool calls as JSON
|
|
46
|
+
*/
|
|
47
|
+
export declare function generateToolPrompt(tools: AnthropicTool[]): string;
|
|
48
|
+
/**
|
|
49
|
+
* Extract tool results from Anthropic messages and format for TD API
|
|
50
|
+
* Converts tool_result content blocks into continuation prompt
|
|
51
|
+
*/
|
|
52
|
+
export declare function extractToolResults(messages: AnthropicMessage[]): string;
|
|
53
|
+
/**
|
|
54
|
+
* Parse tool call JSON from text content
|
|
55
|
+
* Returns parsed tool call with start/end indices, or null if not found
|
|
56
|
+
*/
|
|
57
|
+
export declare function parseToolCallFromText(text: string): {
|
|
58
|
+
id: string;
|
|
59
|
+
name: string;
|
|
60
|
+
input: Record<string, unknown>;
|
|
61
|
+
startIndex: number;
|
|
62
|
+
endIndex: number;
|
|
63
|
+
} | null;
|
|
64
|
+
/**
|
|
65
|
+
* Generate Anthropic SSE events for a tool call
|
|
66
|
+
* Returns array of events: start → input deltas → stop → message_delta → message_stop
|
|
67
|
+
*/
|
|
68
|
+
export declare function generateToolCallEvents(toolCall: {
|
|
69
|
+
id: string;
|
|
70
|
+
name: string;
|
|
71
|
+
input: Record<string, unknown>;
|
|
72
|
+
}, contentIndex: number): Generator<AnthropicStreamEvent, void, unknown>;
|
|
73
|
+
/**
|
|
74
|
+
* Process TD stream and detect tool calls in text content
|
|
75
|
+
* Buffers text to detect JSON patterns and emits appropriate events
|
|
76
|
+
*/
|
|
77
|
+
export declare function transformTDStreamWithToolDetection(tdStream: AsyncGenerator<SSEEvent, void, unknown>, messageId: string, model: string, debug?: boolean): AsyncGenerator<AnthropicStreamEvent, void, unknown>;
|
|
78
|
+
export { generateMessageId };
|
|
79
|
+
//# sourceMappingURL=anthropic-adapter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"anthropic-adapter.d.ts","sourceRoot":"","sources":["../../src/proxy/anthropic-adapter.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EACV,gBAAgB,EAChB,wBAAwB,EACxB,oBAAoB,EAOpB,aAAa,EAEd,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EAAE,QAAQ,EAAoD,MAAM,mBAAmB,CAAC;AAEpG;;GAEG;AACH,iBAAS,iBAAiB,IAAI,MAAM,CAEnC;AAED;;;GAGG;AACH,wBAAgB,+BAA+B,CAAC,OAAO,EAAE,gBAAgB,GAAG,MAAM,CAUjF;AAED;;;GAGG;AACH,wBAAgB,0BAA0B,CACxC,eAAe,EAAE,gBAAgB,EAAE,EACnC,gBAAgB,EAAE,gBAAgB,EAAE,GACnC,gBAAgB,EAAE,CAYpB;AAED;;;GAGG;AACH,wBAAgB,6BAA6B,CAC3C,OAAO,EAAE,wBAAwB,EACjC,gBAAgB,EAAE,gBAAgB,EAAE,GACnC;IAAE,WAAW,EAAE,MAAM,CAAC;IAAC,aAAa,EAAE,gBAAgB,EAAE,CAAA;CAAE,CAgB5D;AAED;;;GAGG;AACH,wBAAuB,4BAA4B,CACjD,QAAQ,EAAE,cAAc,CAAC,QAAQ,EAAE,IAAI,EAAE,OAAO,CAAC,EACjD,SAAS,EAAE,MAAM,EACjB,KAAK,EAAE,MAAM,GACZ,cAAc,CAAC,oBAAoB,EAAE,IAAI,EAAE,OAAO,CAAC,CAwGrD;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,oBAAoB,GAAG,MAAM,CAEtE;AAED;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,cAAc,EAAE,MAAM,GAAG,MAAM,CAiBpE;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,aAAa,EAAE,GAAG,MAAM,CA2CjE;AAcD;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,gBAAgB,EAAE,GAAG,MAAM,CAmCvE;AA6CD;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,MAAM,GAAG;IACnD,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC/B,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;CAClB,GAAG,IAAI,CAmCP;AAED;;;GAGG;AACH,wBAAiB,sBAAsB,CACrC,QAAQ,EAAE;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAAE,EACtE,YAAY,EAAE,MAAM,GACnB,SAAS,CAAC,oBAAoB,EAAE,IAAI,EAAE,OAAO,CAAC,CAoDhD;AAED;;;GAGG;AACH,wBAAuB,kCAAkC,CACvD,QAAQ,EAAE,cAAc,CAAC,QAAQ,EAAE,IAAI,EAAE,OAAO,CAAC,EACjD,SAAS,EAAE,MAAM,EACjB,KAAK,EAAE,MAAM,EACb,KAAK,UAAQ,GACZ,cAAc,CAAC,oBAAoB,EAAE,IAAI,EAAE,OAAO,CAAC,CAoPrD;AAED,OAAO,EAAE,iBAAiB,EAAE,CAAC"}
|