@treasuredata/tdx 0.16.12 → 0.16.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin.js +1 -1
- package/dist/build-info.json +3 -3
- package/dist/cli-categories.js +1 -1
- package/dist/cli.js +1 -1
- package/dist/commands/activations.js +1 -1
- package/dist/commands/agent-command.js +1 -1
- package/dist/commands/agent-test-command.js +1 -1
- package/dist/commands/api-command.js +1 -1
- package/dist/commands/auth-command.js +1 -1
- package/dist/commands/chat-command.js +1 -1
- package/dist/commands/claude-command.js +1 -1
- package/dist/commands/claude-statusline-command.js +1 -1
- package/dist/commands/claude-usage-command.js +1 -1
- package/dist/commands/command.js +1 -1
- package/dist/commands/connection-command.js +1 -1
- package/dist/commands/databases.js +1 -1
- package/dist/commands/describe.js +1 -1
- package/dist/commands/engage-command.js +1 -1
- package/dist/commands/job-command.js +1 -1
- package/dist/commands/journey-command.js +1 -1
- package/dist/commands/journey-validate-command.js +1 -1
- package/dist/commands/llm-command.js +1 -1
- package/dist/commands/llm-proxy.js +1 -1
- package/dist/commands/mcp-command.js +1 -1
- package/dist/commands/parent-segment-command.js +1 -1
- package/dist/commands/profile-command.js +1 -1
- package/dist/commands/profiles-command.js +1 -1
- package/dist/commands/query-command.js +1 -1
- package/dist/commands/segment-command.js +1 -1
- package/dist/commands/segment-create-command.js +1 -1
- package/dist/commands/segment-fields-command.js +1 -1
- package/dist/commands/segment-pull-command.js +1 -1
- package/dist/commands/segment-push-command.js +1 -1
- package/dist/commands/segment-update-command.js +1 -1
- package/dist/commands/segment-use-command.js +1 -1
- package/dist/commands/segment-validate-command.js +1 -1
- package/dist/commands/segments.js +1 -1
- package/dist/commands/show.js +1 -1
- package/dist/commands/status-command.js +1 -1
- package/dist/commands/tables.js +1 -1
- package/dist/commands/unset-command.js +1 -1
- package/dist/commands/use-command.js +1 -1
- package/dist/commands/user-command.js +1 -1
- package/dist/commands/workflow-command.js +1 -1
- package/dist/core/auth.js +1 -1
- package/dist/core/command-output.js +1 -1
- package/dist/core/config.js +1 -1
- package/dist/core/connection-cache.js +1 -1
- package/dist/core/constants.js +1 -1
- package/dist/core/credential-cache.js +1 -1
- package/dist/core/global-context.js +1 -1
- package/dist/core/keychain.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/core/user-cache.js +1 -1
- package/dist/core/version.js +1 -1
- package/dist/index.js +1 -1
- package/dist/mcp/server.js +1 -1
- package/dist/mcp/tools/index.js +1 -1
- package/dist/mcp/tools/tdx-run.js +1 -1
- package/dist/mcp/tools/tdx-search.js +1 -1
- package/dist/mcp/utils.js +1 -1
- package/dist/proxy/anthropic-adapter.js +1 -1
- package/dist/proxy/claude-usage-tracker.js +1 -1
- package/dist/proxy/context-signature.js +1 -1
- package/dist/proxy/conversation-utils.js +1 -1
- package/dist/proxy/passthrough-server.js +1 -1
- package/dist/proxy/server.js +1 -1
- package/dist/proxy/session-cache.js +1 -1
- package/dist/proxy/sse-usage-parser.js +1 -1
- package/dist/sdk/agent/agent-config.js +1 -1
- package/dist/sdk/agent/agent-ref-parser.js +1 -1
- package/dist/sdk/agent/agent-yaml.js +1 -1
- package/dist/sdk/agent/test/evaluator.js +1 -1
- package/dist/sdk/agent/test/executor.js +1 -1
- package/dist/sdk/agent/test/index.js +1 -1
- package/dist/sdk/agent/test/output.js +1 -1
- package/dist/sdk/agent/test/parser.js +1 -1
- package/dist/sdk/api.js +1 -1
- package/dist/sdk/client/cdp-api-client.js +1 -1
- package/dist/sdk/client/endpoints.js +1 -1
- package/dist/sdk/client/engage-api-client.js +1 -1
- package/dist/sdk/client/http-client.js +1 -1
- package/dist/sdk/client/llm-api-client.js +1 -1
- package/dist/sdk/client/rate-limiter.js +1 -1
- package/dist/sdk/client/td-api-client.js +1 -1
- package/dist/sdk/client/trino-api-client.js +1 -1
- package/dist/sdk/client/workflow-client.js +1 -1
- package/dist/sdk/connection-validator.js +1 -1
- package/dist/sdk/connection.js +1 -1
- package/dist/sdk/engage.js +1 -1
- package/dist/sdk/errors.js +1 -1
- package/dist/sdk/index.js +1 -1
- package/dist/sdk/io/index.js +1 -1
- package/dist/sdk/io/node-filesystem.js +1 -1
- package/dist/sdk/job.js +1 -1
- package/dist/sdk/journey.js +1 -1
- package/dist/sdk/llm/chat-cache.js +1 -1
- package/dist/sdk/llm/index.js +1 -1
- package/dist/sdk/llm/llm-backup-utils.js +1 -1
- package/dist/sdk/llm/model-aliases.js +1 -1
- package/dist/sdk/llm/model-factors.js +1 -1
- package/dist/sdk/query/index.js +1 -1
- package/dist/sdk/query/sql-parser.js +1 -1
- package/dist/sdk/segment/child-segment-yaml.js +1 -1
- package/dist/sdk/segment/fields-display.js +1 -1
- package/dist/sdk/segment/file-discovery.js +1 -1
- package/dist/sdk/segment/journey-utils.js +1 -1
- package/dist/sdk/segment/journey-yaml.js +1 -1
- package/dist/sdk/segment/parent-segment-preview.js +1 -1
- package/dist/sdk/segment/parent-segment-yaml.js +1 -1
- package/dist/sdk/segment/pull-workflow.js +1 -1
- package/dist/sdk/segment/push-workflow.js +1 -1
- package/dist/sdk/segment/resolution-context.js +1 -1
- package/dist/sdk/segment/segment-path-parser.js +1 -1
- package/dist/sdk/segment/segment-ref-parser.js +1 -1
- package/dist/sdk/segment/target-resolution.js +1 -1
- package/dist/sdk/segment/tdx-config.js +1 -1
- package/dist/sdk/segment/validate-files.js +1 -1
- package/dist/sdk/segment/yaml-validator.js +1 -1
- package/dist/sdk/segment.js +1 -1
- package/dist/sdk/types/index.js +1 -1
- package/dist/sdk/types/progress.js +1 -1
- package/dist/sdk/user.js +1 -1
- package/dist/sdk/util/format-detector.js +1 -1
- package/dist/sdk/util/formatters.js +1 -1
- package/dist/sdk/util/index.js +1 -1
- package/dist/sdk/util/tree-formatter.js +1 -1
- package/dist/sdk/workflow/clone-workflow.js +1 -1
- package/dist/sdk/workflow/index.js +1 -1
- package/dist/sdk/workflow/pull-workflow.js +1 -1
- package/dist/sdk/workflow/push-workflow.js +1 -1
- package/dist/sdk/workflow/tdx-config.js +1 -1
- package/dist/sdk/workflow/workflow-utils.js +1 -1
- package/dist/test-utils/command-runner.js +1 -1
- package/dist/test-utils/factories.js +1 -1
- package/dist/test-utils/fixtures.js +1 -1
- package/dist/test-utils/http-mock.js +1 -1
- package/dist/test-utils/index.js +1 -1
- package/dist/utils/async.js +1 -1
- package/dist/utils/colors.js +1 -1
- package/dist/utils/diff.js +1 -1
- package/dist/utils/file-permissions.js +1 -1
- package/dist/utils/global-cache.js +1 -1
- package/dist/utils/json-loader.js +1 -1
- package/dist/utils/local-cache.js +1 -1
- package/dist/utils/logger/formatters/default-formatter.js +1 -1
- package/dist/utils/logger/formatters/index.js +1 -1
- package/dist/utils/logger/handlers/console-handler.js +1 -1
- package/dist/utils/logger/handlers/file-handler.js +1 -1
- package/dist/utils/logger/handlers/index.js +1 -1
- package/dist/utils/logger/handlers/null-handler.js +1 -1
- package/dist/utils/logger/index.js +1 -1
- package/dist/utils/logger/logger.js +1 -1
- package/dist/utils/logger/types.js +1 -1
- package/dist/utils/option-validation.js +1 -1
- package/dist/utils/port.js +1 -1
- package/dist/utils/process.js +1 -1
- package/dist/utils/prompt.js +1 -1
- package/dist/utils/spinner.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/tdx-logger.js +1 -1
- package/dist/utils/version-check.js +1 -1
- package/package.json +1 -1
package/dist/core/config.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const a45_0x357fb8=a45_0x4b34;(function(_0x141fe8,_0x347dde){const _0x49cba9=a45_0x4b34,_0x5b6db3=_0x141fe8();while(!![]){try{const _0x4660d4=parseInt(_0x49cba9(0xfe))/0x1+parseInt(_0x49cba9(0x142))/0x2*(-parseInt(_0x49cba9(0x104))/0x3)+parseInt(_0x49cba9(0x12b))/0x4+-parseInt(_0x49cba9(0x13c))/0x5*(parseInt(_0x49cba9(0x10e))/0x6)+-parseInt(_0x49cba9(0x122))/0x7+parseInt(_0x49cba9(0x10a))/0x8+-parseInt(_0x49cba9(0x12d))/0x9*(-parseInt(_0x49cba9(0x10f))/0xa);if(_0x4660d4===_0x347dde)break;else _0x5b6db3['push'](_0x5b6db3['shift']());}catch(_0x11cade){_0x5b6db3['push'](_0x5b6db3['shift']());}}}(a45_0x2679,0xaff4c));import{homedir}from'os';function a45_0x4b34(_0x50fab2,_0x50076f){_0x50fab2=_0x50fab2-0xfd;const _0x26796a=a45_0x2679();let _0x4b3421=_0x26796a[_0x50fab2];return _0x4b3421;}import{join}from'path';import{existsSync,readFileSync,writeFileSync,mkdirSync,unlinkSync}from'fs';import*as a45_0x4f271c from'node:fs';import*as a45_0x181104 from'node:path';import{SITE_ALIASES}from'../sdk/types/index.js';import{validateSecureFilePermissions}from'../utils/file-permissions.js';import{getKeychainAPIKey,saveKeychainAPIKey,isKeychainAvailable}from'./keychain.js';import{getCachedCredential,setCachedCredential}from'./credential-cache.js';import a45_0x3beec3 from'chalk';import{getGlobalCacheDir,createOptionalProfileCache}from'../utils/global-cache.js';export function getConfigDir(){const _0x1f2a0d=a45_0x4b34;return process[_0x1f2a0d(0x149)][_0x1f2a0d(0x14e)]||join(homedir(),_0x1f2a0d(0x14c),'tdx');}export function getConfigFile(){const _0x3a3974=a45_0x4b34;return join(getConfigDir(),_0x3a3974(0x105));}export function getConfigFilePath(_0x32b12d){const _0x3596f7=a45_0x4b34,_0x54eb9e=getConfigDir();return _0x32b12d?a45_0x181104[_0x3596f7(0x106)](_0x54eb9e,_0x3596f7(0x13a)+_0x32b12d):getConfigFile();}export function getCacheDir(){return getGlobalCacheDir();}const llmProjectCache=createOptionalProfileCache(a45_0x357fb8(0xff),a45_0x357fb8(0x13e));export function getLLMProjectCacheFile(_0x172d1e){const _0x2cd29e=a45_0x357fb8;return llmProjectCache[_0x2cd29e(0x10d)](_0x172d1e);}export function readCachedLLMProject(_0x1248e6){const _0x45645c=a45_0x357fb8,_0xfa8eee=llmProjectCache[_0x45645c(0x134)](_0x1248e6);if(_0xfa8eee&&typeof _0xfa8eee['id']===_0x45645c(0x114)&&typeof _0xfa8eee[_0x45645c(0x11d)]==='string')return _0xfa8eee;return null;}export function writeCachedLLMProject(_0x51e109,_0x38b2b9,_0xa1a60){try{llmProjectCache['write']({'name':_0x51e109,'id':_0x38b2b9},_0xa1a60);}catch{}}const llmAgentCache=createOptionalProfileCache(a45_0x357fb8(0x132),'config/llm-agent');export function getLLMAgentCacheFile(_0x12f4d2){const _0x309b01=a45_0x357fb8;return llmAgentCache[_0x309b01(0x10d)](_0x12f4d2);}export function readCachedLLMAgent(_0x126b08){const _0x427576=a45_0x357fb8,_0x384cdb=llmAgentCache[_0x427576(0x134)](_0x126b08);if(_0x384cdb&&typeof _0x384cdb['id']===_0x427576(0x114)&&typeof _0x384cdb[_0x427576(0x11d)]===_0x427576(0x114)&&typeof _0x384cdb['projectId']===_0x427576(0x114))return _0x384cdb;return null;}export function writeCachedLLMAgent(_0x5bd72a,_0x1b1ea0,_0x392da3,_0x53e225){const _0x51303a=a45_0x357fb8;try{llmAgentCache[_0x51303a(0x109)]({'name':_0x5bd72a,'id':_0x1b1ea0,'projectId':_0x392da3},_0x53e225);}catch{}}export function clearCachedLLMAgent(_0x2136c1){const _0x58e8e5=a45_0x357fb8;try{llmAgentCache[_0x58e8e5(0x144)](_0x2136c1);}catch{}}const accountInfoCache=createOptionalProfileCache(a45_0x357fb8(0x107),a45_0x357fb8(0x10c),{'suffix':'.json'});export function getAccountInfoCacheFile(_0x2bdc88){const _0x170d65=a45_0x357fb8;return accountInfoCache[_0x170d65(0x10d)](_0x2bdc88);}export function readCachedAccountInfo(_0x58b72b){const _0x58f3f4=a45_0x357fb8,_0x383c1c=accountInfoCache['read'](_0x58b72b);if(_0x383c1c&&typeof _0x383c1c[_0x58f3f4(0x14b)]==='string'&&typeof _0x383c1c[_0x58f3f4(0x12a)]==='number')return _0x383c1c;return null;}export function writeCachedAccountInfo(_0x3aeff1,_0x2ebeee,_0x41c9d8){const _0x3b2172=a45_0x357fb8;try{accountInfoCache[_0x3b2172(0x109)]({'site':_0x3aeff1,'accountId':_0x2ebeee,'cachedAt':new Date()['toISOString']()},_0x41c9d8);}catch{}}export function parseEnvFile(_0x247c32){const _0x3e3916=a45_0x357fb8,_0x16b1a5={};for(const _0x17f174 of _0x247c32[_0x3e3916(0x101)]('\x0a')){const _0x5e09fa=_0x17f174[_0x3e3916(0x125)]();if(!_0x5e09fa||_0x5e09fa['startsWith']('#'))continue;const _0x70d648=_0x5e09fa['match'](/^([^=]+)=(.*)$/);if(_0x70d648){const _0x39f251=_0x70d648[0x1][_0x3e3916(0x125)]();let _0x50ada7=_0x70d648[0x2]['trim']();(_0x50ada7['startsWith']('\x22')&&_0x50ada7['endsWith']('\x22')||_0x50ada7[_0x3e3916(0x11a)]('\x27')&&_0x50ada7[_0x3e3916(0x148)]('\x27'))&&(_0x50ada7=_0x50ada7[_0x3e3916(0x124)](0x1,-0x1)),_0x16b1a5[_0x39f251]=_0x50ada7;}}return _0x16b1a5;}export function readUserConfig(){const _0x4c1889=a45_0x357fb8,_0x3a30e5=getConfigFile();if(!existsSync(_0x3a30e5))return{};try{const _0x2aa4f7=readFileSync(_0x3a30e5,_0x4c1889(0x128));return parseEnvFile(_0x2aa4f7);}catch(_0x11b0d4){return console[_0x4c1889(0x14a)](_0x4c1889(0x121)+_0x3a30e5+':',_0x11b0d4),{};}}export function resolveSite(_0x6c2d7d){const _0xcb6ea2=a45_0x357fb8,_0x367863=['us01',_0xcb6ea2(0x100),'eu01',_0xcb6ea2(0x131),_0xcb6ea2(0x13f),_0xcb6ea2(0x143),'dev-eu01','stg-us01',_0xcb6ea2(0x135),_0xcb6ea2(0x130)];if(_0x367863[_0xcb6ea2(0x117)](_0x6c2d7d))return _0x6c2d7d;if(_0x6c2d7d in SITE_ALIASES)return SITE_ALIASES[_0x6c2d7d];return console[_0xcb6ea2(0x14a)](_0xcb6ea2(0x113)+_0x6c2d7d+_0xcb6ea2(0x116)),_0xcb6ea2(0x13b);}function a45_0x2679(){const _0x2af142=['.config','Warning:\x20Failed\x20to\x20load\x20','TDX_CONFIG_DIR','Warning:\x20Failed\x20to\x20read\x20','918907oJjGNd','llm_default_project','jp01','split','⚠\x20Failed\x20to\x20migrate\x20API\x20key\x20to\x20keychain:\x20','toUpperCase','849vYJGob','.env','join','account_info','source','write','7627528HYDsAM','profiles','config/account-info','path','5694VPFaSt','960GDrKNy','TD_API_KEY_','keychain\x20(profile:\x20','replace','Warning:\x20Unknown\x20site\x20\x27','string','filter','\x27,\x20defaulting\x20to\x20us01','includes','apiKey','legacy\x20.env\x20file\x20(profile:\x20','startsWith','⚠\x20Cleaned\x20up\x20API\x20keys\x20from\x20legacy\x20.env\x20file','existsSync','name','TDX_API_KEY\x20env\x20var','eu01','legacy\x20.env\x20file','Warning:\x20Failed\x20to\x20read\x20config\x20file\x20','2349725oxImMr','TDX_API_KEY_','slice','trim','yellow','entries','utf-8','TD_API_KEY\x20env\x20var\x20(deprecated)','accountId','2176520oSHGSW','Warning:\x20Using\x20TD_API_KEY\x20is\x20deprecated.\x20Please\x20use\x20TDX_API_KEY\x20instead.\x0a','98478kENlDd','some','TDX_API_KEY','stg-ap03','ap02','llm_default_agent','dev-eu01','read','stg-jp01','isDeprecated','TD_API_KEY','\x20env\x20var','readFileSync','.env.','us01','6010PZhLLD','map','config/llm-project','ap03','keychain','apiKeys','8974oVcceV','dev-us01','clear','⚠\x20Migrated\x20API\x20key\x20from\x20.env\x20to\x20secure\x20keychain\x20storage','\x20\x20For\x20profile-specific\x20keys,\x20use\x20TDX_API_KEY_<PROFILE>\x20(e.g.,\x20','stg-us01','endsWith','env','warn','site'];a45_0x2679=function(){return _0x2af142;};return a45_0x2679();}let cachedUserConfig=null;export function loadUserConfigOnce(){return cachedUserConfig===null&&(cachedUserConfig=readUserConfig()),cachedUserConfig;}export function clearConfigCache(){cachedUserConfig=null;}export function getAPIKey(_0x1118aa,_0x53d3f9){const _0x668ce2=a45_0x357fb8,_0x18e54b=_0x53d3f9||getActiveProfileName();if(_0x18e54b){const _0x4e6793='TDX_API_KEY_'+normalizeProfileForEnvVar(_0x18e54b);if(process[_0x668ce2(0x149)][_0x4e6793])return process[_0x668ce2(0x149)][_0x4e6793];}if(process[_0x668ce2(0x149)][_0x668ce2(0x12f)])return process[_0x668ce2(0x149)]['TDX_API_KEY'];if(process['env']['TD_API_KEY'])return process[_0x668ce2(0x149)][_0x668ce2(0x137)];const _0x4bdc8b=_0x1118aa[_0x668ce2(0x103)]()[_0x668ce2(0x112)](/-/g,'_'),_0x1002f3=_0x668ce2(0x110)+_0x4bdc8b;if(_0x18e54b){const _0x290b45=loadProfileEnv(_0x18e54b);if(_0x290b45){if(_0x290b45[_0x1002f3])return _0x290b45[_0x1002f3];if(_0x290b45['TD_API_KEY'])return _0x290b45[_0x668ce2(0x137)];}}const _0x58c032=loadUserConfigOnce();if(_0x58c032[_0x1002f3])return _0x58c032[_0x1002f3];if(_0x58c032['TD_API_KEY'])return _0x58c032['TD_API_KEY'];return undefined;}export function normalizeProfileForEnvVar(_0x436719){const _0x3b8295=a45_0x357fb8;return _0x436719[_0x3b8295(0x103)]()[_0x3b8295(0x112)](/[^A-Z0-9]/g,'_');}export async function resolveAPIKeyAsync(_0x1ad6ae,_0x3622b8){const _0xae4d13=a45_0x357fb8,_0x53c96b=_0x3622b8||getActiveProfileName()||undefined;if(_0x53c96b){const _0x5dbde9='TDX_API_KEY_'+normalizeProfileForEnvVar(_0x53c96b);if(process[_0xae4d13(0x149)][_0x5dbde9])return{'apiKey':process['env'][_0x5dbde9],'source':_0x5dbde9+_0xae4d13(0x138),'isDeprecated':![]};const _0x30fe59=getCachedCredential(_0x1ad6ae,_0x53c96b);if(_0x30fe59)return{'apiKey':_0x30fe59,'source':_0xae4d13(0x111)+_0x53c96b+')','isDeprecated':![]};const _0x1580e0=await getKeychainAPIKey(_0x53c96b);if(_0x1580e0)return setCachedCredential(_0x1580e0,_0x1ad6ae,_0x53c96b),{'apiKey':_0x1580e0,'source':_0xae4d13(0x111)+_0x53c96b+')','isDeprecated':![]};}if(process[_0xae4d13(0x149)][_0xae4d13(0x12f)])return{'apiKey':process[_0xae4d13(0x149)][_0xae4d13(0x12f)],'source':_0xae4d13(0x11e),'isDeprecated':![]};if(!_0x53c96b){const _0x29f6fe=getCachedCredential(_0x1ad6ae,undefined);if(_0x29f6fe)return{'apiKey':_0x29f6fe,'source':'keychain','isDeprecated':![]};const _0xcfdd86=await getKeychainAPIKey(undefined);if(_0xcfdd86)return setCachedCredential(_0xcfdd86,_0x1ad6ae,undefined),{'apiKey':_0xcfdd86,'source':_0xae4d13(0x140),'isDeprecated':![]};}if(process[_0xae4d13(0x149)]['TD_API_KEY'])return{'apiKey':process[_0xae4d13(0x149)]['TD_API_KEY'],'source':_0xae4d13(0x129),'isDeprecated':!![]};const _0x2e8ca8=getLegacyEnvAPIKey(_0x1ad6ae,_0x53c96b);if(_0x2e8ca8){const _0x1dec30=await isKeychainAvailable();if(_0x1dec30)try{await saveKeychainAPIKey(_0x2e8ca8,_0x53c96b),setCachedCredential(_0x2e8ca8,_0x1ad6ae,_0x53c96b);const _0xa80c88=getConfigFilePath(_0x53c96b);cleanupLegacyEnvFile(_0xa80c88)&&console[_0xae4d13(0x14a)](a45_0x3beec3[_0xae4d13(0x126)](_0xae4d13(0x145)));}catch(_0x42cead){console[_0xae4d13(0x14a)](a45_0x3beec3[_0xae4d13(0x126)](_0xae4d13(0x102)+_0x42cead));}const _0x310b87=_0x53c96b?_0xae4d13(0x119)+_0x53c96b+')':_0xae4d13(0x120);return{'apiKey':_0x2e8ca8,'source':_0x310b87,'isDeprecated':!![]};}return null;}export async function getAPIKeyAsync(_0x11a81f,_0x19938b,_0x2acad3=!![]){const _0x3330ca=a45_0x357fb8,_0x2623ce=await resolveAPIKeyAsync(_0x11a81f,_0x19938b);if(!_0x2623ce)return undefined;if(_0x2acad3&&_0x2623ce[_0x3330ca(0x136)]&&_0x2623ce[_0x3330ca(0x108)]['includes'](_0x3330ca(0x137))){const _0xfa77a8=_0x19938b||getActiveProfileName()||undefined,_0x20d2cb=_0xfa77a8?_0x3330ca(0x123)+normalizeProfileForEnvVar(_0xfa77a8):'TDX_API_KEY_<PROFILE>';console[_0x3330ca(0x14a)](a45_0x3beec3[_0x3330ca(0x126)](_0x3330ca(0x12c)+(_0x3330ca(0x146)+_0x20d2cb+').')));}return _0x2623ce[_0x3330ca(0x118)];}function getLegacyEnvAPIKey(_0x244d64,_0x1b7451){const _0x368e89=a45_0x357fb8,_0x2f71f1=_0x244d64['toUpperCase']()[_0x368e89(0x112)](/-/g,'_'),_0x1d8460=_0x368e89(0x110)+_0x2f71f1;if(_0x1b7451){const _0x25f7d4=loadProfileEnv(_0x1b7451);if(_0x25f7d4){if(_0x25f7d4[_0x1d8460])return _0x25f7d4[_0x1d8460];if(_0x25f7d4['TD_API_KEY'])return _0x25f7d4[_0x368e89(0x137)];}}const _0x1a6a7e=loadUserConfigOnce();if(_0x1a6a7e[_0x1d8460])return _0x1a6a7e[_0x1d8460];if(_0x1a6a7e[_0x368e89(0x137)])return _0x1a6a7e[_0x368e89(0x137)];return undefined;}function cleanupLegacyEnvFile(_0x384837){const _0x5eec88=a45_0x357fb8;if(!existsSync(_0x384837))return![];try{const _0x3abf9a=readFileSync(_0x384837,'utf-8'),_0x5e3d4d=_0x3abf9a[_0x5eec88(0x101)]('\x0a'),_0x29e58c=_0x5e3d4d[_0x5eec88(0x115)](_0x5cd579=>{const _0x13bee6=_0x5eec88,_0x3dddea=_0x5cd579[_0x13bee6(0x125)]();if(!_0x3dddea||_0x3dddea['startsWith']('#'))return!![];const [_0x38db5d]=_0x3dddea[_0x13bee6(0x101)]('=');return!_0x38db5d['startsWith'](_0x13bee6(0x137));}),_0xa45770=_0x29e58c[_0x5eec88(0x12e)](_0x1bb7ab=>{const _0x242774=_0x5eec88,_0x239969=_0x1bb7ab['trim']();return _0x239969&&!_0x239969[_0x242774(0x11a)]('#');});if(!_0xa45770)return unlinkSync(_0x384837),!![];return writeFileSync(_0x384837,_0x29e58c['join']('\x0a'),{'mode':0x180}),!![];}catch{return![];}}function loadProfileEnv(_0x960ee7){const _0x3918b0=a45_0x357fb8,_0x47a11e=a45_0x181104[_0x3918b0(0x106)](getConfigDir(),_0x3918b0(0x13a)+_0x960ee7);if(a45_0x4f271c[_0x3918b0(0x11c)](_0x47a11e)){validateSecureFilePermissions(_0x47a11e);try{const _0x1f3aec=a45_0x4f271c[_0x3918b0(0x139)](_0x47a11e,_0x3918b0(0x128));return parseEnvFile(_0x1f3aec);}catch(_0x48d5b1){console['warn'](_0x3918b0(0x14d)+_0x47a11e+':\x20'+_0x48d5b1);}}const _0x473d70=a45_0x181104[_0x3918b0(0x106)](getConfigDir(),_0x3918b0(0x10b),_0x960ee7,'.env');if(a45_0x4f271c[_0x3918b0(0x11c)](_0x473d70)){validateSecureFilePermissions(_0x473d70);try{const _0x34ce41=a45_0x4f271c['readFileSync'](_0x473d70,_0x3918b0(0x128));return parseEnvFile(_0x34ce41);}catch(_0x339a57){return console[_0x3918b0(0x14a)](_0x3918b0(0x14d)+_0x473d70+':\x20'+_0x339a57),null;}}return null;}function getActiveProfileName(){const _0x2f9883=a45_0x357fb8,_0x549cc0=a45_0x181104['join'](getConfigDir(),'tdx.json');if(!a45_0x4f271c[_0x2f9883(0x11c)](_0x549cc0))return null;try{const _0x4eb5da=a45_0x4f271c[_0x2f9883(0x139)](_0x549cc0,_0x2f9883(0x128)),_0x496e90=JSON['parse'](_0x4eb5da);return _0x496e90['profile']||null;}catch{return null;}}export function saveAPIKey(_0xfe5986,_0x49571c,_0x2a63c7){const _0x3eb173=a45_0x357fb8,_0x28d124=getConfigDir(),_0x3c3891=getConfigFilePath(_0x2a63c7);!existsSync(_0x28d124)&&mkdirSync(_0x28d124,{'recursive':!![],'mode':0x1c0});let _0x3cd813={};if(existsSync(_0x3c3891))try{const _0x27f540=readFileSync(_0x3c3891,'utf-8');_0x3cd813=parseEnvFile(_0x27f540);}catch(_0x1067ce){console[_0x3eb173(0x14a)](_0x3eb173(0xfd)+_0x3c3891+':',_0x1067ce);}const _0x238a0a=_0xfe5986['toUpperCase']()[_0x3eb173(0x112)](/-/g,'_');_0x3cd813[_0x3eb173(0x110)+_0x238a0a]=_0x49571c;const _0x255b37=Object[_0x3eb173(0x127)](_0x3cd813)[_0x3eb173(0x13d)](([_0x20af0f,_0x580347])=>_0x20af0f+'='+_0x580347);writeFileSync(_0x3c3891,_0x255b37[_0x3eb173(0x106)]('\x0a')+'\x0a',{'mode':0x180});}export async function saveAPIKeyAsync(_0x5c9128,_0x2fee8b,_0x432a4c){const _0x3da165=a45_0x357fb8;await saveKeychainAPIKey(_0x5c9128,_0x432a4c),setCachedCredential(_0x5c9128,_0x2fee8b,_0x432a4c);const _0x2f09bb=getConfigFilePath(_0x432a4c);cleanupLegacyEnvFile(_0x2f09bb)&&console[_0x3da165(0x14a)](a45_0x3beec3['yellow'](_0x3da165(0x11b)));}export function loadConfig(){const _0x44b540=a45_0x357fb8,_0x150294={'apiKeys':{},'defaultSite':_0x44b540(0x13b)},_0x3ba77b=[_0x44b540(0x13b),_0x44b540(0x100),_0x44b540(0x11f),_0x44b540(0x131),_0x44b540(0x13f),_0x44b540(0x143),_0x44b540(0x133),_0x44b540(0x147),_0x44b540(0x135),_0x44b540(0x130)];for(const _0x4b7e16 of _0x3ba77b){const _0x5020b5=getAPIKey(_0x4b7e16);_0x5020b5&&(_0x150294[_0x44b540(0x141)][_0x4b7e16]=_0x5020b5);}return _0x150294;}
|
|
1
|
+
const a45_0x1400b9=a45_0x4498;(function(_0x336505,_0x4df1ce){const _0x545bfd=a45_0x4498,_0x1b0bab=_0x336505();while(!![]){try{const _0x4838c8=parseInt(_0x545bfd(0x176))/0x1*(parseInt(_0x545bfd(0x1bf))/0x2)+-parseInt(_0x545bfd(0x1b0))/0x3*(parseInt(_0x545bfd(0x170))/0x4)+-parseInt(_0x545bfd(0x195))/0x5*(parseInt(_0x545bfd(0x1aa))/0x6)+-parseInt(_0x545bfd(0x19e))/0x7*(-parseInt(_0x545bfd(0x19f))/0x8)+-parseInt(_0x545bfd(0x17e))/0x9*(parseInt(_0x545bfd(0x1a9))/0xa)+-parseInt(_0x545bfd(0x1a6))/0xb+parseInt(_0x545bfd(0x1a3))/0xc;if(_0x4838c8===_0x4df1ce)break;else _0x1b0bab['push'](_0x1b0bab['shift']());}catch(_0x313914){_0x1b0bab['push'](_0x1b0bab['shift']());}}}(a45_0x2ae0,0xe3720));import{homedir}from'os';import{join}from'path';import{existsSync,readFileSync,writeFileSync,mkdirSync,unlinkSync}from'fs';import*as a45_0x494676 from'node:fs';function a45_0x4498(_0x23a309,_0x19eea4){_0x23a309=_0x23a309-0x16d;const _0x2ae070=a45_0x2ae0();let _0x449892=_0x2ae070[_0x23a309];return _0x449892;}import*as a45_0x1b9596 from'node:path';import{SITE_ALIASES}from'../sdk/types/index.js';import{validateSecureFilePermissions}from'../utils/file-permissions.js';import{getKeychainAPIKey,saveKeychainAPIKey,isKeychainAvailable}from'./keychain.js';import{getCachedCredential,setCachedCredential}from'./credential-cache.js';import a45_0x54aec1 from'chalk';import{getGlobalCacheDir,createOptionalProfileCache}from'../utils/global-cache.js';export function getConfigDir(){const _0x5ef0aa=a45_0x4498;return process['env'][_0x5ef0aa(0x16f)]||join(homedir(),_0x5ef0aa(0x1b8),_0x5ef0aa(0x1a8));}export function getConfigFile(){const _0x292d2e=a45_0x4498;return join(getConfigDir(),_0x292d2e(0x1c1));}export function getConfigFilePath(_0x29f9aa){const _0x49a6c6=a45_0x4498,_0x21809c=getConfigDir();return _0x29f9aa?a45_0x1b9596['join'](_0x21809c,_0x49a6c6(0x191)+_0x29f9aa):getConfigFile();}export function getCacheDir(){return getGlobalCacheDir();}const llmProjectCache=createOptionalProfileCache(a45_0x1400b9(0x1a7),'config/llm-project');export function getLLMProjectCacheFile(_0x2edd52){const _0x5610e3=a45_0x1400b9;return llmProjectCache[_0x5610e3(0x1ad)](_0x2edd52);}export function readCachedLLMProject(_0x2c34fa){const _0x4b1349=a45_0x1400b9,_0x1faea0=llmProjectCache['read'](_0x2c34fa);if(_0x1faea0&&typeof _0x1faea0['id']===_0x4b1349(0x1af)&&typeof _0x1faea0[_0x4b1349(0x1b2)]===_0x4b1349(0x1af))return _0x1faea0;return null;}export function writeCachedLLMProject(_0x46970e,_0x429120,_0xd6fef){const _0x627b25=a45_0x1400b9;try{llmProjectCache[_0x627b25(0x197)]({'name':_0x46970e,'id':_0x429120},_0xd6fef);}catch{}}const llmAgentCache=createOptionalProfileCache(a45_0x1400b9(0x175),a45_0x1400b9(0x194));export function getLLMAgentCacheFile(_0x59fe5d){return llmAgentCache['path'](_0x59fe5d);}export function readCachedLLMAgent(_0x552c9d){const _0x41acec=a45_0x1400b9,_0x155d5c=llmAgentCache[_0x41acec(0x188)](_0x552c9d);if(_0x155d5c&&typeof _0x155d5c['id']==='string'&&typeof _0x155d5c[_0x41acec(0x1b2)]===_0x41acec(0x1af)&&typeof _0x155d5c['projectId']===_0x41acec(0x1af))return _0x155d5c;return null;}export function writeCachedLLMAgent(_0x1ebd5b,_0x427f9e,_0xbfcce4,_0x2ef24f){const _0x5cdc0e=a45_0x1400b9;try{llmAgentCache[_0x5cdc0e(0x197)]({'name':_0x1ebd5b,'id':_0x427f9e,'projectId':_0xbfcce4},_0x2ef24f);}catch{}}export function clearCachedLLMAgent(_0x4ddf81){const _0x294d2a=a45_0x1400b9;try{llmAgentCache[_0x294d2a(0x19a)](_0x4ddf81);}catch{}}const accountInfoCache=createOptionalProfileCache(a45_0x1400b9(0x187),a45_0x1400b9(0x190),{'suffix':a45_0x1400b9(0x192)});export function getAccountInfoCacheFile(_0x12436e){return accountInfoCache['path'](_0x12436e);}export function readCachedAccountInfo(_0x321b7e){const _0x348caf=a45_0x1400b9,_0x54e055=accountInfoCache[_0x348caf(0x188)](_0x321b7e);if(_0x54e055&&typeof _0x54e055[_0x348caf(0x1a5)]===_0x348caf(0x1af)&&typeof _0x54e055['accountId']==='number')return _0x54e055;return null;}export function writeCachedAccountInfo(_0x57fdee,_0x1a227c,_0x441b68){const _0x19a795=a45_0x1400b9;try{accountInfoCache[_0x19a795(0x197)]({'site':_0x57fdee,'accountId':_0x1a227c,'cachedAt':new Date()[_0x19a795(0x1ba)]()},_0x441b68);}catch{}}export function parseEnvFile(_0x2642a6){const _0x6f36bd=a45_0x1400b9,_0x2038b8={};for(const _0x51780e of _0x2642a6[_0x6f36bd(0x1a4)]('\x0a')){const _0x16a566=_0x51780e[_0x6f36bd(0x1bc)]();if(!_0x16a566||_0x16a566[_0x6f36bd(0x17c)]('#'))continue;const _0x3755f1=_0x16a566[_0x6f36bd(0x1b7)](/^([^=]+)=(.*)$/);if(_0x3755f1){const _0xf9e897=_0x3755f1[0x1][_0x6f36bd(0x1bc)]();let _0x27d9ef=_0x3755f1[0x2][_0x6f36bd(0x1bc)]();(_0x27d9ef[_0x6f36bd(0x17c)]('\x22')&&_0x27d9ef[_0x6f36bd(0x199)]('\x22')||_0x27d9ef[_0x6f36bd(0x17c)]('\x27')&&_0x27d9ef['endsWith']('\x27'))&&(_0x27d9ef=_0x27d9ef[_0x6f36bd(0x198)](0x1,-0x1)),_0x2038b8[_0xf9e897]=_0x27d9ef;}}return _0x2038b8;}export function readUserConfig(){const _0x76c450=a45_0x1400b9,_0x585a18=getConfigFile();if(!existsSync(_0x585a18))return{};try{const _0x5372b1=readFileSync(_0x585a18,_0x76c450(0x1b3));return parseEnvFile(_0x5372b1);}catch(_0x513e1e){return console[_0x76c450(0x18d)](_0x76c450(0x17f)+_0x585a18+':',_0x513e1e),{};}}export function resolveSite(_0x49e7fc){const _0x2bd952=a45_0x1400b9,_0x2a400e=['us01','jp01',_0x2bd952(0x16e),_0x2bd952(0x1b9),_0x2bd952(0x1b4),_0x2bd952(0x185),_0x2bd952(0x180),'stg-us01',_0x2bd952(0x18f),_0x2bd952(0x18e)];if(_0x2a400e[_0x2bd952(0x172)](_0x49e7fc))return _0x49e7fc;if(_0x49e7fc in SITE_ALIASES)return SITE_ALIASES[_0x49e7fc];return console[_0x2bd952(0x18d)](_0x2bd952(0x174)+_0x49e7fc+'\x27,\x20defaulting\x20to\x20us01'),_0x2bd952(0x17a);}let cachedUserConfig=null;export function loadUserConfigOnce(){return cachedUserConfig===null&&(cachedUserConfig=readUserConfig()),cachedUserConfig;}function a45_0x2ae0(){const _0x56b428=['us01','TDX_API_KEY_','startsWith','join','9219492IcBxpS','Warning:\x20Failed\x20to\x20read\x20config\x20file\x20','dev-eu01','Warning:\x20Failed\x20to\x20load\x20','jp01','profiles','keychain','dev-us01','toUpperCase','account_info','read','apiKey','env','profile','TDX_API_KEY\x20env\x20var','warn','stg-ap03','stg-jp01','config/account-info','.env.','.json','⚠\x20Cleaned\x20up\x20API\x20keys\x20from\x20legacy\x20.env\x20file','config/llm-agent','411235PSYeWf','filter','write','slice','endsWith','clear','replace','TDX_API_KEY_<PROFILE>','readFileSync','3801lzFCdU','22312YfjsXl','stg-us01','\x20\x20For\x20profile-specific\x20keys,\x20use\x20TDX_API_KEY_<PROFILE>\x20(e.g.,\x20','⚠\x20Migrated\x20API\x20key\x20from\x20.env\x20to\x20secure\x20keychain\x20storage','26530476XPcRiP','split','site','14140665LcvaEU','llm_default_project','tdx','10ffagdX','60FUHIPH','\x20env\x20var','legacy\x20.env\x20file','path','tdx.json','string','3cNOCbm','TDX_API_KEY','name','utf-8','ap03','map','some','match','.config','ap02','toISOString','yellow','trim','legacy\x20.env\x20file\x20(profile:\x20','TD_API_KEY\x20env\x20var\x20(deprecated)','648228HXSLfw','TD_API_KEY','.env','keychain\x20(profile:\x20','TD_API_KEY_','eu01','TDX_CONFIG_DIR','2534612qaBnpm','existsSync','includes','entries','Warning:\x20Unknown\x20site\x20\x27','llm_default_agent','3SxrYPs','Warning:\x20Failed\x20to\x20read\x20','parse','source'];a45_0x2ae0=function(){return _0x56b428;};return a45_0x2ae0();}export function clearConfigCache(){cachedUserConfig=null;}export function getAPIKey(_0x1b102a,_0x103ccd){const _0x266d3a=a45_0x1400b9,_0x5b14ef=_0x103ccd||getActiveProfileName();if(_0x5b14ef){const _0x5da0b9=_0x266d3a(0x17b)+normalizeProfileForEnvVar(_0x5b14ef);if(process[_0x266d3a(0x18a)][_0x5da0b9])return process[_0x266d3a(0x18a)][_0x5da0b9];}if(process['env'][_0x266d3a(0x1b1)])return process[_0x266d3a(0x18a)][_0x266d3a(0x1b1)];if(process[_0x266d3a(0x18a)][_0x266d3a(0x1c0)])return process[_0x266d3a(0x18a)][_0x266d3a(0x1c0)];const _0x15727a=_0x1b102a[_0x266d3a(0x186)]()['replace'](/-/g,'_'),_0x4a3152=_0x266d3a(0x16d)+_0x15727a;if(_0x5b14ef){const _0x826a58=loadProfileEnv(_0x5b14ef);if(_0x826a58){if(_0x826a58[_0x4a3152])return _0x826a58[_0x4a3152];if(_0x826a58[_0x266d3a(0x1c0)])return _0x826a58[_0x266d3a(0x1c0)];}}const _0x549063=loadUserConfigOnce();if(_0x549063[_0x4a3152])return _0x549063[_0x4a3152];if(_0x549063[_0x266d3a(0x1c0)])return _0x549063[_0x266d3a(0x1c0)];return undefined;}export function normalizeProfileForEnvVar(_0x2637b2){const _0x198c73=a45_0x1400b9;return _0x2637b2[_0x198c73(0x186)]()[_0x198c73(0x19b)](/[^A-Z0-9]/g,'_');}export async function resolveAPIKeyAsync(_0x288521,_0x199820){const _0x26f0d4=a45_0x1400b9,_0x17fc24=_0x199820||getActiveProfileName()||undefined;if(_0x17fc24){const _0x5d75a0=_0x26f0d4(0x17b)+normalizeProfileForEnvVar(_0x17fc24);if(process[_0x26f0d4(0x18a)][_0x5d75a0])return{'apiKey':process[_0x26f0d4(0x18a)][_0x5d75a0],'source':_0x5d75a0+_0x26f0d4(0x1ab),'isDeprecated':![]};const _0x45f837=getCachedCredential(_0x288521,_0x17fc24);if(_0x45f837)return{'apiKey':_0x45f837,'source':_0x26f0d4(0x1c2)+_0x17fc24+')','isDeprecated':![]};const _0x26a562=await getKeychainAPIKey(_0x17fc24);if(_0x26a562)return setCachedCredential(_0x26a562,_0x288521,_0x17fc24),{'apiKey':_0x26a562,'source':_0x26f0d4(0x1c2)+_0x17fc24+')','isDeprecated':![]};}if(process[_0x26f0d4(0x18a)][_0x26f0d4(0x1b1)])return{'apiKey':process['env'][_0x26f0d4(0x1b1)],'source':_0x26f0d4(0x18c),'isDeprecated':![]};if(!_0x17fc24){const _0x19c50c=getCachedCredential(_0x288521,undefined);if(_0x19c50c)return{'apiKey':_0x19c50c,'source':_0x26f0d4(0x184),'isDeprecated':![]};const _0x23fb6a=await getKeychainAPIKey(undefined);if(_0x23fb6a)return setCachedCredential(_0x23fb6a,_0x288521,undefined),{'apiKey':_0x23fb6a,'source':_0x26f0d4(0x184),'isDeprecated':![]};}if(process['env'][_0x26f0d4(0x1c0)])return{'apiKey':process[_0x26f0d4(0x18a)][_0x26f0d4(0x1c0)],'source':_0x26f0d4(0x1be),'isDeprecated':!![]};const _0x2ed3e5=getLegacyEnvAPIKey(_0x288521,_0x17fc24);if(_0x2ed3e5){const _0x2495cc=await isKeychainAvailable();if(_0x2495cc)try{await saveKeychainAPIKey(_0x2ed3e5,_0x17fc24),setCachedCredential(_0x2ed3e5,_0x288521,_0x17fc24);const _0x24d58d=getConfigFilePath(_0x17fc24);cleanupLegacyEnvFile(_0x24d58d)&&console['warn'](a45_0x54aec1[_0x26f0d4(0x1bb)](_0x26f0d4(0x1a2)));}catch(_0x5c6854){console[_0x26f0d4(0x18d)](a45_0x54aec1[_0x26f0d4(0x1bb)]('⚠\x20Failed\x20to\x20migrate\x20API\x20key\x20to\x20keychain:\x20'+_0x5c6854));}const _0x4f1abf=_0x17fc24?_0x26f0d4(0x1bd)+_0x17fc24+')':_0x26f0d4(0x1ac);return{'apiKey':_0x2ed3e5,'source':_0x4f1abf,'isDeprecated':!![]};}return null;}export async function getAPIKeyAsync(_0x1db6e5,_0x464c3c,_0x1da7a7=!![]){const _0x49eeac=a45_0x1400b9,_0x5608a4=await resolveAPIKeyAsync(_0x1db6e5,_0x464c3c);if(!_0x5608a4)return undefined;if(_0x1da7a7&&_0x5608a4['isDeprecated']&&_0x5608a4[_0x49eeac(0x179)][_0x49eeac(0x172)]('TD_API_KEY')){const _0x27c57e=_0x464c3c||getActiveProfileName()||undefined,_0x4db2c0=_0x27c57e?_0x49eeac(0x17b)+normalizeProfileForEnvVar(_0x27c57e):_0x49eeac(0x19c);console['warn'](a45_0x54aec1['yellow']('Warning:\x20Using\x20TD_API_KEY\x20is\x20deprecated.\x20Please\x20use\x20TDX_API_KEY\x20instead.\x0a'+(_0x49eeac(0x1a1)+_0x4db2c0+').')));}return _0x5608a4[_0x49eeac(0x189)];}function getLegacyEnvAPIKey(_0x35dd4f,_0x2a4582){const _0x3db5b8=a45_0x1400b9,_0x951069=_0x35dd4f['toUpperCase']()['replace'](/-/g,'_'),_0x5ce5cc=_0x3db5b8(0x16d)+_0x951069;if(_0x2a4582){const _0x3777b1=loadProfileEnv(_0x2a4582);if(_0x3777b1){if(_0x3777b1[_0x5ce5cc])return _0x3777b1[_0x5ce5cc];if(_0x3777b1['TD_API_KEY'])return _0x3777b1['TD_API_KEY'];}}const _0x2c85ce=loadUserConfigOnce();if(_0x2c85ce[_0x5ce5cc])return _0x2c85ce[_0x5ce5cc];if(_0x2c85ce[_0x3db5b8(0x1c0)])return _0x2c85ce['TD_API_KEY'];return undefined;}function cleanupLegacyEnvFile(_0x3b4cb3){const _0x60909=a45_0x1400b9;if(!existsSync(_0x3b4cb3))return![];try{const _0x4927c4=readFileSync(_0x3b4cb3,_0x60909(0x1b3)),_0x1cb288=_0x4927c4[_0x60909(0x1a4)]('\x0a'),_0x902f20=_0x1cb288[_0x60909(0x196)](_0x26cc52=>{const _0x24cf0e=_0x60909,_0xa19ce6=_0x26cc52[_0x24cf0e(0x1bc)]();if(!_0xa19ce6||_0xa19ce6['startsWith']('#'))return!![];const [_0x50458e]=_0xa19ce6[_0x24cf0e(0x1a4)]('=');return!_0x50458e['startsWith']('TD_API_KEY');}),_0x8e9ede=_0x902f20[_0x60909(0x1b6)](_0xaba34f=>{const _0x2f0726=_0x60909,_0x7e5854=_0xaba34f[_0x2f0726(0x1bc)]();return _0x7e5854&&!_0x7e5854['startsWith']('#');});if(!_0x8e9ede)return unlinkSync(_0x3b4cb3),!![];return writeFileSync(_0x3b4cb3,_0x902f20[_0x60909(0x17d)]('\x0a'),{'mode':0x180}),!![];}catch{return![];}}function loadProfileEnv(_0x5dbd65){const _0x281b5a=a45_0x1400b9,_0x1f2a4a=a45_0x1b9596[_0x281b5a(0x17d)](getConfigDir(),'.env.'+_0x5dbd65);if(a45_0x494676[_0x281b5a(0x171)](_0x1f2a4a)){validateSecureFilePermissions(_0x1f2a4a);try{const _0x5ccb5f=a45_0x494676[_0x281b5a(0x19d)](_0x1f2a4a,_0x281b5a(0x1b3));return parseEnvFile(_0x5ccb5f);}catch(_0x2e6129){console[_0x281b5a(0x18d)](_0x281b5a(0x181)+_0x1f2a4a+':\x20'+_0x2e6129);}}const _0x7b9479=a45_0x1b9596[_0x281b5a(0x17d)](getConfigDir(),_0x281b5a(0x183),_0x5dbd65,_0x281b5a(0x1c1));if(a45_0x494676[_0x281b5a(0x171)](_0x7b9479)){validateSecureFilePermissions(_0x7b9479);try{const _0x392f25=a45_0x494676[_0x281b5a(0x19d)](_0x7b9479,_0x281b5a(0x1b3));return parseEnvFile(_0x392f25);}catch(_0x4aa962){return console[_0x281b5a(0x18d)](_0x281b5a(0x181)+_0x7b9479+':\x20'+_0x4aa962),null;}}return null;}function getActiveProfileName(){const _0xa315a6=a45_0x1400b9,_0x2b73a9=a45_0x1b9596['join'](getConfigDir(),_0xa315a6(0x1ae));if(!a45_0x494676[_0xa315a6(0x171)](_0x2b73a9))return null;try{const _0x3208f4=a45_0x494676[_0xa315a6(0x19d)](_0x2b73a9,'utf-8'),_0x5ab825=JSON[_0xa315a6(0x178)](_0x3208f4);return _0x5ab825[_0xa315a6(0x18b)]||null;}catch{return null;}}export function saveAPIKey(_0x355612,_0x488236,_0x19298f){const _0x661a3d=a45_0x1400b9,_0xb9415e=getConfigDir(),_0x5e523f=getConfigFilePath(_0x19298f);!existsSync(_0xb9415e)&&mkdirSync(_0xb9415e,{'recursive':!![],'mode':0x1c0});let _0x520424={};if(existsSync(_0x5e523f))try{const _0x44dc29=readFileSync(_0x5e523f,_0x661a3d(0x1b3));_0x520424=parseEnvFile(_0x44dc29);}catch(_0x58cf20){console[_0x661a3d(0x18d)](_0x661a3d(0x177)+_0x5e523f+':',_0x58cf20);}const _0x1babb5=_0x355612[_0x661a3d(0x186)]()['replace'](/-/g,'_');_0x520424['TD_API_KEY_'+_0x1babb5]=_0x488236;const _0x489c07=Object[_0x661a3d(0x173)](_0x520424)[_0x661a3d(0x1b5)](([_0x5e1bf7,_0x129859])=>_0x5e1bf7+'='+_0x129859);writeFileSync(_0x5e523f,_0x489c07[_0x661a3d(0x17d)]('\x0a')+'\x0a',{'mode':0x180});}export async function saveAPIKeyAsync(_0x292bf4,_0x2f8d7b,_0x2e1be9){const _0x11264b=a45_0x1400b9;await saveKeychainAPIKey(_0x292bf4,_0x2e1be9),setCachedCredential(_0x292bf4,_0x2f8d7b,_0x2e1be9);const _0x4b626c=getConfigFilePath(_0x2e1be9);cleanupLegacyEnvFile(_0x4b626c)&&console[_0x11264b(0x18d)](a45_0x54aec1[_0x11264b(0x1bb)](_0x11264b(0x193)));}export function loadConfig(){const _0x111ec7=a45_0x1400b9,_0x47e137={'apiKeys':{},'defaultSite':'us01'},_0x31ba20=[_0x111ec7(0x17a),_0x111ec7(0x182),_0x111ec7(0x16e),_0x111ec7(0x1b9),_0x111ec7(0x1b4),'dev-us01',_0x111ec7(0x180),_0x111ec7(0x1a0),'stg-jp01',_0x111ec7(0x18e)];for(const _0x2e71e3 of _0x31ba20){const _0x4365ba=getAPIKey(_0x2e71e3);_0x4365ba&&(_0x47e137['apiKeys'][_0x2e71e3]=_0x4365ba);}return _0x47e137;}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a46_0x53c8c6=a46_0x3bfe;function a46_0xfbb2(){const _0x5b2393=['51816qqyxZC','1668996MAhOna','connections','536600HqlZnC','24ttoRXD','connections-{profile}.json','94638JvpHiy','clear','237761zxvqLY','686dZvdcR','9624VauJOr','797430DAlwiq'];a46_0xfbb2=function(){return _0x5b2393;};return a46_0xfbb2();}(function(_0x19c5fe,_0x2636b0){const _0xdcb1b6=a46_0x3bfe,_0x3e6a8e=_0x19c5fe();while(!![]){try{const _0x2a8d36=-parseInt(_0xdcb1b6(0x9e))/0x1+-parseInt(_0xdcb1b6(0xa2))/0x2+-parseInt(_0xdcb1b6(0x9c))/0x3*(-parseInt(_0xdcb1b6(0xa6))/0x4)+parseInt(_0xdcb1b6(0xa1))/0x5+-parseInt(_0xdcb1b6(0xa0))/0x6*(-parseInt(_0xdcb1b6(0x9f))/0x7)+parseInt(_0xdcb1b6(0xa5))/0x8+-parseInt(_0xdcb1b6(0xa3))/0x9;if(_0x2a8d36===_0x2636b0)break;else _0x3e6a8e['push'](_0x3e6a8e['shift']());}catch(_0xf7153a){_0x3e6a8e['push'](_0x3e6a8e['shift']());}}}(a46_0xfbb2,0x1e40c));import{createProfileCache}from'../utils/global-cache.js';function a46_0x3bfe(_0x45ce51,_0x363f8c){_0x45ce51=_0x45ce51-0x9b;const _0xfbb2fa=a46_0xfbb2();let _0x3bfe8c=_0xfbb2fa[_0x45ce51];return _0x3bfe8c;}const connectionCache=createProfileCache(a46_0x53c8c6(0x9b),'core/connection-cache');export function loadCachedConnections(_0xbc1250){const _0x4d2851=a46_0x53c8c6,_0x66e890=connectionCache['read'](_0xbc1250);return _0x66e890?.[_0x4d2851(0xa4)]??null;}export function saveCachedConnections(_0x3d0730,_0x277716){connectionCache['write'](_0x3d0730,{'connections':_0x277716,'cachedAt':Date['now']()});}export function clearConnectionCache(_0x140a00){const _0x35923c=a46_0x53c8c6;connectionCache[_0x35923c(0x9d)](_0x140a00);}
|
package/dist/core/constants.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
function a47_0x66c0(){const _0x147a57=['length','3cBhkrV','1191989sqeUtz','285495irsNOx','11572830lIIfxC','657564zNmDvj','us01','438366ijIdVO','ap02','eu01','value','2292968FeBUVi','push','50RUGIBC','eu\x20\x20\x20-\x20Europe','findIndex','us\x20\x20\x20-\x20United\x20States','other','ap02\x20-\x20Korea','858836GPCQWv','number','jp\x20\x20\x20-\x20Japan'];a47_0x66c0=function(){return _0x147a57;};return a47_0x66c0();}const a47_0xa970c4=a47_0x58e6;(function(_0x22efce,_0x49bc92){const _0x4aa82e=a47_0x58e6,_0x3155a8=_0x22efce();while(!![]){try{const _0x62a964=parseInt(_0x4aa82e(0x1fe))/0x1+-parseInt(_0x4aa82e(0x1f9))/0x2*(-parseInt(_0x4aa82e(0x1fd))/0x3)+-parseInt(_0x4aa82e(0x201))/0x4+-parseInt(_0x4aa82e(0x209))/0x5*(-parseInt(_0x4aa82e(0x203))/0x6)+parseInt(_0x4aa82e(0x1ff))/0x7+-parseInt(_0x4aa82e(0x207))/0x8+-parseInt(_0x4aa82e(0x200))/0x9;if(_0x62a964===_0x49bc92)break;else _0x3155a8['push'](_0x3155a8['shift']());}catch(_0x585d5d){_0x3155a8['push'](_0x3155a8['shift']());}}}(a47_0x66c0,0xa0230));export const DEFAULT_DISPLAY_LIMIT=0x28;export const DEFAULT_LISTING_LIMIT=0x2710;function a47_0x58e6(_0x142774,_0x45118b){_0x142774=_0x142774-0x1f4;const _0x66c0b2=a47_0x66c0();let _0x58e6a2=_0x66c0b2[_0x142774];return _0x58e6a2;}export const DEFAULT_LLM_LIMIT=0x32;export function resolveLimit(_0x206f9d,_0x584d72){const _0x3a0298=a47_0x58e6;if(_0x206f9d===undefined)return _0x584d72;if(typeof _0x206f9d===_0x3a0298(0x1fa))return _0x206f9d;return parseInt(_0x206f9d,0xa);}export const STANDARD_SITE_CHOICES=[{'title':a47_0xa970c4(0x1f6),'value':'us01'},{'title':a47_0xa970c4(0x1fb),'value':'jp01'},{'title':a47_0xa970c4(0x1f4),'value':a47_0xa970c4(0x205)},{'title':a47_0xa970c4(0x1f8),'value':a47_0xa970c4(0x204)}];export function buildSiteChoices(_0x22a4b3){const _0x3681b4=a47_0xa970c4,_0x3deb86=[...STANDARD_SITE_CHOICES];let _0x362e8c=_0x3deb86[_0x3681b4(0x1f5)](_0x4b2a6c=>_0x4b2a6c[_0x3681b4(0x206)]===_0x22a4b3);return _0x362e8c===-0x1&&_0x22a4b3!==_0x3681b4(0x202)&&(_0x3deb86[_0x3681b4(0x208)]({'title':_0x22a4b3,'value':_0x22a4b3}),_0x362e8c=_0x3deb86[_0x3681b4(0x1fc)]-0x1),_0x3deb86[_0x3681b4(0x208)]({'title':'Enter\x20custom\x20site','value':_0x3681b4(0x1f7)}),{'choices':_0x3deb86,'initialIndex':_0x362e8c>=0x0?_0x362e8c:0x0};}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
function a48_0x265c(_0xb11421,_0x48258b){_0xb11421=_0xb11421-0xee;const _0x54a29a=a48_0x54a2();let _0x265c29=_0x54a29a[_0xb11421];return _0x265c29;}(function(_0x10b43e,_0x4148ec){const _0x4e820d=a48_0x265c,_0x5c17c6=_0x10b43e();while(!![]){try{const _0x4a9cab=parseInt(_0x4e820d(0xfa))/0x1*(parseInt(_0x4e820d(0xff))/0x2)+parseInt(_0x4e820d(0xf9))/0x3*(parseInt(_0x4e820d(0x100))/0x4)+parseInt(_0x4e820d(0xf2))/0x5*(-parseInt(_0x4e820d(0xf1))/0x6)+-parseInt(_0x4e820d(0xef))/0x7*(-parseInt(_0x4e820d(0xee))/0x8)+-parseInt(_0x4e820d(0xfd))/0x9+-parseInt(_0x4e820d(0xf6))/0xa+-parseInt(_0x4e820d(0xfe))/0xb*(parseInt(_0x4e820d(0xf5))/0xc);if(_0x4a9cab===_0x4148ec)break;else _0x5c17c6['push'](_0x5c17c6['shift']());}catch(_0x46dd6b){_0x5c17c6['push'](_0x5c17c6['shift']());}}}(a48_0x54a2,0xea559));const cache=new Map(),CACHE_TTL_MS=0x5*0x3c*0x3e8;function getCacheKey(_0x5acb10,_0x15459b){const _0xe5d80a=a48_0x265c,_0x46d06c=_0x5acb10||_0xe5d80a(0xf7),_0x360511=_0x15459b||'__default_profile__';return _0x46d06c+':'+_0x360511;}export function getCachedCredential(_0x5ccc48,_0x1377d2){const _0x5d5daf=a48_0x265c,_0x12ef0a=getCacheKey(_0x5ccc48,_0x1377d2),_0x598e0a=cache['get'](_0x12ef0a);if(!_0x598e0a)return null;if(Date['now']()-_0x598e0a[_0x5d5daf(0xf8)]>CACHE_TTL_MS)return cache[_0x5d5daf(0xf0)](_0x12ef0a),null;return _0x598e0a[_0x5d5daf(0xf3)];}export function setCachedCredential(_0x48513c,_0x17ef90,_0x4c4ab8){const _0x10bdf9=a48_0x265c,_0x2b5bf3=getCacheKey(_0x17ef90,_0x4c4ab8);cache[_0x10bdf9(0xf4)](_0x2b5bf3,{'apiKey':_0x48513c,'loadedAt':Date[_0x10bdf9(0xfb)]()});}export function clearCredentialCache(){const _0x5693ea=a48_0x265c;cache[_0x5693ea(0xfc)]();}export function clearCachedCredential(_0x3ee8f2,_0x3e0b2b){const _0x22a1b7=a48_0x265c,_0xbd3954=getCacheKey(_0x3ee8f2,_0x3e0b2b);cache[_0x22a1b7(0xf0)](_0xbd3954);}function a48_0x54a2(){const _0x5baecc=['set','26388xIePHW','1174020ITPntZ','__default_site__','loadedAt','48MoPMAO','1507733EjaKxF','now','clear','5695956wOKkdZ','3630RJhPxr','2pAhCoB','353100rPLlHJ','16aswVWN','3199238oYOooB','delete','12qUNVSb','3496030ZFklFZ','apiKey'];a48_0x54a2=function(){return _0x5baecc;};return a48_0x54a2();}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const a49_0xaaea01=a49_0x1dd1;(function(_0x508bfe,_0x182583){const _0x2aeb64=a49_0x1dd1,_0x2b6038=_0x508bfe();while(!![]){try{const _0x21c74c=-parseInt(_0x2aeb64(0xfd))/0x1+-parseInt(_0x2aeb64(0x11d))/0x2+-parseInt(_0x2aeb64(0xfb))/0x3*(parseInt(_0x2aeb64(0x121))/0x4)+parseInt(_0x2aeb64(0x127))/0x5+-parseInt(_0x2aeb64(0x107))/0x6+parseInt(_0x2aeb64(0x11c))/0x7+parseInt(_0x2aeb64(0x125))/0x8*(parseInt(_0x2aeb64(0x139))/0x9);if(_0x21c74c===_0x182583)break;else _0x2b6038['push'](_0x2b6038['shift']());}catch(_0xdb75b3){_0x2b6038['push'](_0x2b6038['shift']());}}}(a49_0x3591,0x67361));import{resolveSite,getAPIKey,getAPIKeyAsync,getConfigDir}from'./config.js';import{loadSessionContext,getCurrentSessionPID}from'./session.js';function a49_0x3591(){const _0x2cb520=['existsSync','none','workflow_project','us01','replace','bold','resolveAPIKeyAsync','profileCredentials','logLevel','[configuration\x20files]','INFO','session','getParameters','verbose','Project','llm_agent','site','2372363RSvQqP','1433254snLRiv','sessions','assign','env','32adcxOV','globalCredentials','global','parse','12592312hJGyWl','segmentPath','357725QyIQSq','CLI\x20flag:\x20--','(using\x20session:\x20','Profile','profiles','default','database','project','configFiles','llmProject','readFileSync','injectIntoOptions','llmAgent','loadGlobalConfig','sessionId','tdx.json','.json','[context]','9sGvMlH','join','.env','green','(active)','not\x20set','Profile\x20Credentials','Global\x20Credentials','display','cyan','parent_segment','utf-8','config','layers','segment_path','getSource','15546IVeGfr','llm_project','393250WNLLBh','apiKey','cliFlags','Session','dim','activeProfile','Global','log','profile','entries','2462442xaUQbo','workflowProject','parentSegment','TDX_SITE'];a49_0x3591=function(){return _0x2cb520;};return a49_0x3591();}import{loadProjectConfig,findProjectConfigPath}from'./project-config.js';import{getActiveProfile,loadProfile}from'./profile.js';function a49_0x1dd1(_0x1637bd,_0x495ad8){_0x1637bd=_0x1637bd-0xf3;const _0x35912d=a49_0x3591();let _0x1dd126=_0x35912d[_0x1637bd];return _0x1dd126;}import{LogLevel}from'../utils/logger/index.js';import*as a49_0x54da58 from'node:fs';import*as a49_0x27b8c0 from'node:path';import a49_0x369919 from'chalk';export class GlobalContext{[a49_0xaaea01(0x11b)];['database'];[a49_0xaaea01(0xf5)];['segment_path'];['llm_project'];[a49_0xaaea01(0x11a)];[a49_0xaaea01(0x10d)];[a49_0xaaea01(0xfe)];['verbose'];['logLevel'];[a49_0xaaea01(0x105)];['layers'];[a49_0xaaea01(0x102)];['sessionId'];[a49_0xaaea01(0x12f)];constructor(_0x43ee65){const _0x3b22e7=a49_0xaaea01;this[_0x3b22e7(0x135)]=_0x43ee65[_0x3b22e7(0x116)]||getCurrentSessionPID()['toString']();const _0x529871=loadSessionContext(_0x43ee65[_0x3b22e7(0x116)]),_0x37a89b=loadProjectConfig(),_0x21fa0b=this[_0x3b22e7(0x134)]();this[_0x3b22e7(0x102)]=_0x43ee65[_0x3b22e7(0x105)]||_0x529871?.['profile']||_0x21fa0b[_0x3b22e7(0x105)]||getActiveProfile();const _0x29be42=this['activeProfile']?loadProfile(this[_0x3b22e7(0x102)]):null,_0x3d389a=_0xd31210=>{const _0xd6505d=_0x3b22e7;if(!_0xd31210)return{};const _0x17dd66=_0xd31210,_0x3e1ed9={};for(const [_0x3b422c,_0x4d995a]of Object[_0xd6505d(0x106)](_0x17dd66)){typeof _0x4d995a==='string'&&(_0x3e1ed9[_0x3b422c]=_0x4d995a);}return _0x3e1ed9;},_0x394786={},_0x3f4f28=(_0x33222e,_0x321497,_0x340377)=>{const _0x278124=_0x3b22e7;if(!_0x33222e)return![];if(_0x340377&&_0x33222e===_0x340377)return![];const _0x4447fe=_0x529871,_0x1ddaef=_0x37a89b,_0x490226=_0x29be42?.[_0x278124(0xf7)],_0xe6a130=_0x21fa0b,_0x4b44a0=_0x4447fe?.[_0x321497],_0x18209b=_0x1ddaef?.[_0x321497],_0x316cf3=_0x490226?.[_0x321497],_0x7198dd=_0xe6a130[_0x321497];return _0x33222e!==_0x4b44a0&&_0x33222e!==_0x18209b&&_0x33222e!==_0x316cf3&&_0x33222e!==_0x7198dd;},_0x42004d=[{'optionKey':_0x3b22e7(0x11b),'contextKey':_0x3b22e7(0x11b),'defaultValue':'us01'},{'optionKey':_0x3b22e7(0x12d),'contextKey':'database'},{'optionKey':_0x3b22e7(0x109),'contextKey':_0x3b22e7(0xf5)},{'optionKey':'llmProject','contextKey':'llm_project'},{'optionKey':_0x3b22e7(0x133),'contextKey':'llm_agent'},{'optionKey':'profile','contextKey':_0x3b22e7(0x105)}];for(const {optionKey:_0x4a28f6,contextKey:_0x2946e3,defaultValue:_0x28c4c2}of _0x42004d){const _0x3d9e0b=_0x43ee65[_0x4a28f6];_0x3f4f28(_0x3d9e0b,_0x2946e3,_0x28c4c2)&&(_0x394786[_0x2946e3]=_0x3d9e0b);}this[_0x3b22e7(0xf8)]={'cliFlags':_0x394786,'session':_0x3d389a(_0x529871),'project':_0x3d389a(_0x37a89b),'profile':_0x3d389a(_0x29be42?.[_0x3b22e7(0xf7)]),'global':_0x3d389a(_0x21fa0b)};const _0x107274={...this[_0x3b22e7(0xf8)]['global'],...this[_0x3b22e7(0xf8)][_0x3b22e7(0x105)],...this[_0x3b22e7(0xf8)][_0x3b22e7(0x12e)]};process[_0x3b22e7(0x120)]['TDX_SITE']&&!this[_0x3b22e7(0xf8)][_0x3b22e7(0x116)]['site']&&!this[_0x3b22e7(0xf8)][_0x3b22e7(0xff)]['site']&&(_0x107274[_0x3b22e7(0x11b)]=process['env'][_0x3b22e7(0x10a)]);Object['assign'](_0x107274,this[_0x3b22e7(0xf8)][_0x3b22e7(0x116)]),Object[_0x3b22e7(0x11f)](_0x107274,this['layers'][_0x3b22e7(0xff)]);const _0x2887c3=_0x107274[_0x3b22e7(0x11b)]||_0x3b22e7(0x10e);this[_0x3b22e7(0x11b)]=resolveSite(_0x2887c3),this['database']=_0x107274[_0x3b22e7(0x12d)],this['parent_segment']=_0x107274['parent_segment'],this[_0x3b22e7(0xf9)]=_0x107274[_0x3b22e7(0xf9)],this[_0x3b22e7(0xfc)]=_0x107274[_0x3b22e7(0xfc)],this['llm_agent']=_0x107274[_0x3b22e7(0x11a)],this[_0x3b22e7(0x10d)]=_0x107274['workflow_project'],this[_0x3b22e7(0x118)]=_0x43ee65[_0x3b22e7(0x118)]||![],this[_0x3b22e7(0x113)]=_0x43ee65[_0x3b22e7(0x113)]??LogLevel[_0x3b22e7(0x115)],this[_0x3b22e7(0x105)]=this['activeProfile']||undefined,this['apiKey']=getAPIKey(this[_0x3b22e7(0x11b)],this[_0x3b22e7(0x102)]||undefined);const _0x868e0c=getConfigDir(),_0x3eac41=a49_0x27b8c0[_0x3b22e7(0x13a)](_0x868e0c,_0x3b22e7(0x11e),this['sessionId']+_0x3b22e7(0x137)),_0x5933c2=findProjectConfigPath(),_0x52efb2=a49_0x27b8c0[_0x3b22e7(0x13a)](_0x868e0c,_0x3b22e7(0x136)),_0x17ae32=a49_0x27b8c0[_0x3b22e7(0x13a)](_0x868e0c,_0x3b22e7(0x13b));let _0x3bf3b6=null,_0x3be2b5=null;this[_0x3b22e7(0x102)]&&(_0x3bf3b6=a49_0x27b8c0[_0x3b22e7(0x13a)](_0x868e0c,_0x3b22e7(0x12b),this[_0x3b22e7(0x102)],_0x3b22e7(0x136)),_0x3be2b5=a49_0x27b8c0[_0x3b22e7(0x13a)](_0x868e0c,_0x3b22e7(0x12b),this[_0x3b22e7(0x102)],_0x3b22e7(0x13b))),this[_0x3b22e7(0x12f)]={'session':a49_0x54da58[_0x3b22e7(0x10b)](_0x3eac41)?_0x3eac41:null,'project':_0x5933c2,'profile':_0x3bf3b6&&a49_0x54da58['existsSync'](_0x3bf3b6)?_0x3bf3b6:null,'profileCredentials':_0x3be2b5&&a49_0x54da58[_0x3b22e7(0x10b)](_0x3be2b5)?_0x3be2b5:null,'global':a49_0x54da58[_0x3b22e7(0x10b)](_0x52efb2)?_0x52efb2:null,'globalCredentials':a49_0x54da58[_0x3b22e7(0x10b)](_0x17ae32)?_0x17ae32:null};}['getSource'](_0x1f1991,_0x1812e5){const _0x356bab=a49_0xaaea01;if(!_0x1812e5)return _0x356bab(0x13e);const _0xa5055a=_0x1812e5;if(this[_0x356bab(0xf8)][_0x356bab(0xff)][_0x1f1991]===_0xa5055a){if(_0x1f1991==='site'&&_0xa5055a==='us01'&&!this[_0x356bab(0xf8)][_0x356bab(0x116)][_0x356bab(0x11b)]&&!this[_0x356bab(0xf8)][_0x356bab(0x12e)][_0x356bab(0x11b)]&&!this['layers'][_0x356bab(0x105)][_0x356bab(0x11b)]&&!this[_0x356bab(0xf8)]['global'][_0x356bab(0x11b)])return _0x356bab(0x12c);return _0x356bab(0x128)+_0x1f1991[_0x356bab(0x10f)](/_/g,'-');}if(this[_0x356bab(0xf8)][_0x356bab(0x116)][_0x1f1991]===_0xa5055a)return _0x356bab(0x116);if(this['layers'][_0x356bab(0x12e)][_0x1f1991]===_0xa5055a)return _0x356bab(0x12e);if(this['layers']['profile'][_0x1f1991]===_0xa5055a)return'profile:\x20'+this['activeProfile'];if(this[_0x356bab(0xf8)]['global'][_0x1f1991]===_0xa5055a)return'global';return _0x356bab(0x12c);}['loadGlobalConfig'](){const _0x2c9f4a=a49_0xaaea01,_0x320136=a49_0x27b8c0['join'](getConfigDir(),_0x2c9f4a(0x136));if(!a49_0x54da58[_0x2c9f4a(0x10b)](_0x320136))return{};try{const _0x183368=a49_0x54da58[_0x2c9f4a(0x131)](_0x320136,_0x2c9f4a(0xf6));return JSON[_0x2c9f4a(0x124)](_0x183368);}catch{return{};}}[a49_0xaaea01(0x132)](_0x3d2389){const _0x1e32e1=a49_0xaaea01;_0x3d2389['site']=this[_0x1e32e1(0x11b)],!_0x3d2389['database']&&this[_0x1e32e1(0x12d)]&&(_0x3d2389['database']=this[_0x1e32e1(0x12d)]),!_0x3d2389[_0x1e32e1(0x109)]&&this[_0x1e32e1(0xf5)]&&(_0x3d2389[_0x1e32e1(0x109)]=this['parent_segment']),!_0x3d2389['segmentPath']&&this[_0x1e32e1(0xf9)]&&(_0x3d2389[_0x1e32e1(0x126)]=this['segment_path']),!_0x3d2389[_0x1e32e1(0x130)]&&this[_0x1e32e1(0xfc)]&&(_0x3d2389[_0x1e32e1(0x130)]=this['llm_project']),!_0x3d2389[_0x1e32e1(0x133)]&&this[_0x1e32e1(0x11a)]&&(_0x3d2389[_0x1e32e1(0x133)]=this['llm_agent']),!_0x3d2389['workflowProject']&&this[_0x1e32e1(0x10d)]&&(_0x3d2389[_0x1e32e1(0x108)]=this[_0x1e32e1(0x10d)]);}['getParameters'](){const _0x801f57=a49_0xaaea01;return[{'key':_0x801f57(0x11b),'value':this[_0x801f57(0x11b)]},{'key':_0x801f57(0x12d),'value':this['database']},{'key':_0x801f57(0xf5),'value':this[_0x801f57(0xf5)]},{'key':_0x801f57(0xf9),'value':this[_0x801f57(0xf9)]},{'key':_0x801f57(0xfc),'value':this['llm_project']},{'key':_0x801f57(0x11a),'value':this[_0x801f57(0x11a)]},{'key':_0x801f57(0x10d),'value':this[_0x801f57(0x10d)]},{'key':_0x801f57(0x105),'value':this[_0x801f57(0x102)]||undefined}];}[a49_0xaaea01(0xf3)](){const _0x2ace48=a49_0xaaea01;console[_0x2ace48(0x104)](a49_0x369919[_0x2ace48(0x110)](_0x2ace48(0x138)));for(const {key:_0x3871d2,value:_0x150422}of this[_0x2ace48(0x117)]()){_0x150422&&console['log'](a49_0x369919[_0x2ace48(0xf4)](_0x3871d2)+':\x20'+_0x150422);}}['displayWithSources'](){const _0x25f9ee=a49_0xaaea01;console[_0x25f9ee(0x104)](a49_0x369919[_0x25f9ee(0x110)](_0x25f9ee(0x138)));for(const {key:_0x145a6c,value:_0x13e577}of this[_0x25f9ee(0x117)]()){if(_0x13e577){const _0x2a23b0=_0x145a6c===_0x25f9ee(0x105)?_0x25f9ee(0x13d):'('+this[_0x25f9ee(0xfa)](_0x145a6c,_0x13e577)+')';console['log'](a49_0x369919[_0x25f9ee(0xf4)](_0x145a6c)+':\x20'+_0x13e577+'\x20'+a49_0x369919['dim'](_0x2a23b0));}}console['log']('\x0a'+a49_0x369919['bold'](_0x25f9ee(0x114)));const _0x3d7f43=[{'label':_0x25f9ee(0x100),'path':this[_0x25f9ee(0x12f)]['session'],'extra':'(session:\x20'+this[_0x25f9ee(0x135)]+')'},{'label':_0x25f9ee(0x119),'path':this[_0x25f9ee(0x12f)][_0x25f9ee(0x12e)]},{'label':_0x25f9ee(0x12a),'path':this['configFiles'][_0x25f9ee(0x105)]},{'label':_0x25f9ee(0x13f),'path':this[_0x25f9ee(0x12f)][_0x25f9ee(0x112)]},{'label':_0x25f9ee(0x103),'path':this['configFiles'][_0x25f9ee(0x123)]},{'label':_0x25f9ee(0x140),'path':this[_0x25f9ee(0x12f)][_0x25f9ee(0x122)]}];for(const {label:_0x4c1de1,path:_0x5f4571,extra:_0x249fc4}of _0x3d7f43){if(_0x5f4571)console[_0x25f9ee(0x104)](a49_0x369919[_0x25f9ee(0xf4)](_0x4c1de1)+':\x20'+_0x5f4571+'\x20'+a49_0x369919[_0x25f9ee(0x13c)]('✓')+(_0x249fc4?'\x20'+a49_0x369919[_0x25f9ee(0x101)](_0x249fc4):''));else{if(_0x4c1de1===_0x25f9ee(0x100))console[_0x25f9ee(0x104)](a49_0x369919[_0x25f9ee(0xf4)](_0x4c1de1)+':\x20'+a49_0x369919['dim']('none')+'\x20'+a49_0x369919[_0x25f9ee(0x101)](_0x25f9ee(0x129)+this[_0x25f9ee(0x135)]+')'));else(_0x4c1de1===_0x25f9ee(0x119)||_0x4c1de1===_0x25f9ee(0x103))&&console[_0x25f9ee(0x104)](a49_0x369919[_0x25f9ee(0xf4)](_0x4c1de1)+':\x20'+a49_0x369919['dim'](_0x25f9ee(0x10c)));}}}async[a49_0xaaea01(0x111)](){const _0x54496b=a49_0xaaea01;return this[_0x54496b(0xfe)]=await getAPIKeyAsync(this[_0x54496b(0x11b)],this[_0x54496b(0x102)]||undefined),this[_0x54496b(0xfe)];}static async['createAsync'](_0x11e138){const _0x3c6bcd=a49_0xaaea01,_0x541793=new GlobalContext(_0x11e138);return await _0x541793[_0x3c6bcd(0x111)](),_0x541793;}}
|
|
1
|
+
const a49_0x2c88a7=a49_0xf4e1;(function(_0xf4ead9,_0x1db227){const _0x526d38=a49_0xf4e1,_0x24c9be=_0xf4ead9();while(!![]){try{const _0x361f4f=parseInt(_0x526d38(0x1dc))/0x1*(-parseInt(_0x526d38(0x1d1))/0x2)+parseInt(_0x526d38(0x1eb))/0x3*(parseInt(_0x526d38(0x1b8))/0x4)+parseInt(_0x526d38(0x1c2))/0x5*(-parseInt(_0x526d38(0x1a9))/0x6)+-parseInt(_0x526d38(0x1b4))/0x7*(-parseInt(_0x526d38(0x1ce))/0x8)+parseInt(_0x526d38(0x1ac))/0x9+parseInt(_0x526d38(0x1ec))/0xa+-parseInt(_0x526d38(0x1a5))/0xb*(parseInt(_0x526d38(0x1cb))/0xc);if(_0x361f4f===_0x1db227)break;else _0x24c9be['push'](_0x24c9be['shift']());}catch(_0x4c10fa){_0x24c9be['push'](_0x24c9be['shift']());}}}(a49_0x1a23,0x1a112));import{resolveSite,getAPIKey,getAPIKeyAsync,getConfigDir}from'./config.js';import{loadSessionContext,getCurrentSessionPID}from'./session.js';import{loadProjectConfig,findProjectConfigPath}from'./project-config.js';function a49_0xf4e1(_0x3a0fcf,_0xd7f996){_0x3a0fcf=_0x3a0fcf-0x1a4;const _0x1a2360=a49_0x1a23();let _0xf4e1b0=_0x1a2360[_0x3a0fcf];return _0xf4e1b0;}import{getActiveProfile,loadProfile}from'./profile.js';import{LogLevel}from'../utils/logger/index.js';function a49_0x1a23(){const _0x2ecd7c=['replace','project','database','.env','parentSegment','cyan','[configuration\x20files]','[context]','5zOUIxG','Session','displayWithSources','Global\x20Credentials','globalCredentials','getParameters','TDX_SITE','Global','dim','156UcLqHP','global','workflowProject','16WjCAMe','Profile\x20Credentials','log','10pIbuoJ','(active)','Profile','injectIntoOptions','apiKey','activeProfile','profileCredentials','layers','profile','env','resolveAPIKeyAsync','27926fyReyj','assign','readFileSync','sessionId','entries','cliFlags','profile:\x20','llm_agent','not\x20set','logLevel','verbose','INFO','default','llmProject','join','4926TEmCfV','1891050xqVUHC','utf-8','loadGlobalConfig','parent_segment','profiles','tdx.json','llmAgent','270699ICuxId','none','bold','existsSync','437826wksaFD','configFiles','segmentPath','645435CSBOcp','session','config','Project','display','segment_path','site','.json','738444WLlIcM','getSource','llm_project','workflow_project','408chobjb','us01'];a49_0x1a23=function(){return _0x2ecd7c;};return a49_0x1a23();}import*as a49_0x35f8f4 from'node:fs';import*as a49_0x10da8a from'node:path';import a49_0x745889 from'chalk';export class GlobalContext{[a49_0x2c88a7(0x1b2)];[a49_0x2c88a7(0x1bc)];['parent_segment'];[a49_0x2c88a7(0x1b1)];[a49_0x2c88a7(0x1b6)];['llm_agent'];[a49_0x2c88a7(0x1b7)];[a49_0x2c88a7(0x1d5)];['verbose'];[a49_0x2c88a7(0x1e5)];[a49_0x2c88a7(0x1d9)];[a49_0x2c88a7(0x1d8)];[a49_0x2c88a7(0x1d6)];[a49_0x2c88a7(0x1df)];[a49_0x2c88a7(0x1aa)];constructor(_0x416a4a){const _0x497b93=a49_0x2c88a7;this[_0x497b93(0x1df)]=_0x416a4a[_0x497b93(0x1ad)]||getCurrentSessionPID()['toString']();const _0xbfed4=loadSessionContext(_0x416a4a['session']),_0x598df3=loadProjectConfig(),_0x3cfe6a=this['loadGlobalConfig']();this[_0x497b93(0x1d6)]=_0x416a4a[_0x497b93(0x1d9)]||_0xbfed4?.[_0x497b93(0x1d9)]||_0x3cfe6a[_0x497b93(0x1d9)]||getActiveProfile();const _0x22e96c=this[_0x497b93(0x1d6)]?loadProfile(this[_0x497b93(0x1d6)]):null,_0x3f740a=_0x32fe18=>{const _0x4d14fd=_0x497b93;if(!_0x32fe18)return{};const _0x3f688d=_0x32fe18,_0x762245={};for(const [_0x3122ca,_0x3ea5c0]of Object[_0x4d14fd(0x1e0)](_0x3f688d)){typeof _0x3ea5c0==='string'&&(_0x762245[_0x3122ca]=_0x3ea5c0);}return _0x762245;},_0x5296cb={},_0x12140f=(_0x55527f,_0x1c5b1c,_0x39a749)=>{const _0x424b00=_0x497b93;if(!_0x55527f)return![];if(_0x39a749&&_0x55527f===_0x39a749)return![];const _0x1f42d2=_0xbfed4,_0x59c584=_0x598df3,_0xe4b30e=_0x22e96c?.[_0x424b00(0x1ae)],_0x575d7b=_0x3cfe6a,_0xfe1bd1=_0x1f42d2?.[_0x1c5b1c],_0x5af8ae=_0x59c584?.[_0x1c5b1c],_0x5cf6b5=_0xe4b30e?.[_0x1c5b1c],_0x1970a3=_0x575d7b[_0x1c5b1c];return _0x55527f!==_0xfe1bd1&&_0x55527f!==_0x5af8ae&&_0x55527f!==_0x5cf6b5&&_0x55527f!==_0x1970a3;},_0x3ab635=[{'optionKey':'site','contextKey':'site','defaultValue':_0x497b93(0x1b9)},{'optionKey':_0x497b93(0x1bc),'contextKey':_0x497b93(0x1bc)},{'optionKey':'parentSegment','contextKey':_0x497b93(0x1ef)},{'optionKey':'llmProject','contextKey':_0x497b93(0x1b6)},{'optionKey':_0x497b93(0x1a4),'contextKey':_0x497b93(0x1e3)},{'optionKey':_0x497b93(0x1d9),'contextKey':_0x497b93(0x1d9)}];for(const {optionKey:_0x4555c0,contextKey:_0x252852,defaultValue:_0x189577}of _0x3ab635){const _0x1b7654=_0x416a4a[_0x4555c0];_0x12140f(_0x1b7654,_0x252852,_0x189577)&&(_0x5296cb[_0x252852]=_0x1b7654);}this[_0x497b93(0x1d8)]={'cliFlags':_0x5296cb,'session':_0x3f740a(_0xbfed4),'project':_0x3f740a(_0x598df3),'profile':_0x3f740a(_0x22e96c?.['config']),'global':_0x3f740a(_0x3cfe6a)};const _0x23f6b0={...this[_0x497b93(0x1d8)]['global'],...this['layers'][_0x497b93(0x1d9)],...this[_0x497b93(0x1d8)][_0x497b93(0x1bb)]};process[_0x497b93(0x1da)][_0x497b93(0x1c8)]&&!this[_0x497b93(0x1d8)][_0x497b93(0x1ad)][_0x497b93(0x1b2)]&&!this['layers'][_0x497b93(0x1e1)][_0x497b93(0x1b2)]&&(_0x23f6b0[_0x497b93(0x1b2)]=process[_0x497b93(0x1da)][_0x497b93(0x1c8)]);Object[_0x497b93(0x1dd)](_0x23f6b0,this[_0x497b93(0x1d8)][_0x497b93(0x1ad)]),Object[_0x497b93(0x1dd)](_0x23f6b0,this['layers'][_0x497b93(0x1e1)]);const _0x129cbc=_0x23f6b0[_0x497b93(0x1b2)]||_0x497b93(0x1b9);this[_0x497b93(0x1b2)]=resolveSite(_0x129cbc),this[_0x497b93(0x1bc)]=_0x23f6b0[_0x497b93(0x1bc)],this['parent_segment']=_0x23f6b0['parent_segment'],this['segment_path']=_0x23f6b0[_0x497b93(0x1b1)],this[_0x497b93(0x1b6)]=_0x23f6b0[_0x497b93(0x1b6)],this[_0x497b93(0x1e3)]=_0x23f6b0['llm_agent'],this[_0x497b93(0x1b7)]=_0x23f6b0[_0x497b93(0x1b7)],this[_0x497b93(0x1e6)]=_0x416a4a[_0x497b93(0x1e6)]||![],this['logLevel']=_0x416a4a[_0x497b93(0x1e5)]??LogLevel[_0x497b93(0x1e7)],this[_0x497b93(0x1d9)]=this['activeProfile']||undefined,this['apiKey']=getAPIKey(this[_0x497b93(0x1b2)],this[_0x497b93(0x1d6)]||undefined);const _0x4ffb01=getConfigDir(),_0xfaa4c1=a49_0x10da8a['join'](_0x4ffb01,'sessions',this['sessionId']+_0x497b93(0x1b3)),_0x3d358c=findProjectConfigPath(),_0x681900=a49_0x10da8a[_0x497b93(0x1ea)](_0x4ffb01,_0x497b93(0x1f1)),_0x1fc468=a49_0x10da8a[_0x497b93(0x1ea)](_0x4ffb01,_0x497b93(0x1bd));let _0xd2966b=null,_0x3b0f79=null;this[_0x497b93(0x1d6)]&&(_0xd2966b=a49_0x10da8a[_0x497b93(0x1ea)](_0x4ffb01,_0x497b93(0x1f0),this[_0x497b93(0x1d6)],_0x497b93(0x1f1)),_0x3b0f79=a49_0x10da8a[_0x497b93(0x1ea)](_0x4ffb01,_0x497b93(0x1f0),this['activeProfile'],'.env')),this[_0x497b93(0x1aa)]={'session':a49_0x35f8f4[_0x497b93(0x1a8)](_0xfaa4c1)?_0xfaa4c1:null,'project':_0x3d358c,'profile':_0xd2966b&&a49_0x35f8f4[_0x497b93(0x1a8)](_0xd2966b)?_0xd2966b:null,'profileCredentials':_0x3b0f79&&a49_0x35f8f4[_0x497b93(0x1a8)](_0x3b0f79)?_0x3b0f79:null,'global':a49_0x35f8f4['existsSync'](_0x681900)?_0x681900:null,'globalCredentials':a49_0x35f8f4[_0x497b93(0x1a8)](_0x1fc468)?_0x1fc468:null};}[a49_0x2c88a7(0x1b5)](_0x13e04d,_0x3a90cc){const _0x286765=a49_0x2c88a7;if(!_0x3a90cc)return _0x286765(0x1e4);const _0x317c14=_0x3a90cc;if(this['layers']['cliFlags'][_0x13e04d]===_0x317c14){if(_0x13e04d==='site'&&_0x317c14===_0x286765(0x1b9)&&!this[_0x286765(0x1d8)][_0x286765(0x1ad)]['site']&&!this[_0x286765(0x1d8)][_0x286765(0x1bb)]['site']&&!this['layers']['profile'][_0x286765(0x1b2)]&&!this[_0x286765(0x1d8)]['global'][_0x286765(0x1b2)])return _0x286765(0x1e8);return'CLI\x20flag:\x20--'+_0x13e04d[_0x286765(0x1ba)](/_/g,'-');}if(this[_0x286765(0x1d8)]['session'][_0x13e04d]===_0x317c14)return'session';if(this[_0x286765(0x1d8)][_0x286765(0x1bb)][_0x13e04d]===_0x317c14)return _0x286765(0x1bb);if(this[_0x286765(0x1d8)][_0x286765(0x1d9)][_0x13e04d]===_0x317c14)return _0x286765(0x1e2)+this[_0x286765(0x1d6)];if(this[_0x286765(0x1d8)]['global'][_0x13e04d]===_0x317c14)return'global';return _0x286765(0x1e8);}[a49_0x2c88a7(0x1ee)](){const _0x3ec31b=a49_0x2c88a7,_0x4ba2e6=a49_0x10da8a[_0x3ec31b(0x1ea)](getConfigDir(),'tdx.json');if(!a49_0x35f8f4['existsSync'](_0x4ba2e6))return{};try{const _0x475680=a49_0x35f8f4[_0x3ec31b(0x1de)](_0x4ba2e6,_0x3ec31b(0x1ed));return JSON['parse'](_0x475680);}catch{return{};}}[a49_0x2c88a7(0x1d4)](_0x5871b5){const _0xd90330=a49_0x2c88a7;_0x5871b5[_0xd90330(0x1b2)]=this[_0xd90330(0x1b2)],!_0x5871b5[_0xd90330(0x1bc)]&&this['database']&&(_0x5871b5[_0xd90330(0x1bc)]=this['database']),!_0x5871b5[_0xd90330(0x1be)]&&this[_0xd90330(0x1ef)]&&(_0x5871b5[_0xd90330(0x1be)]=this[_0xd90330(0x1ef)]),!_0x5871b5[_0xd90330(0x1ab)]&&this[_0xd90330(0x1b1)]&&(_0x5871b5[_0xd90330(0x1ab)]=this['segment_path']),!_0x5871b5[_0xd90330(0x1e9)]&&this[_0xd90330(0x1b6)]&&(_0x5871b5[_0xd90330(0x1e9)]=this['llm_project']),!_0x5871b5['llmAgent']&&this[_0xd90330(0x1e3)]&&(_0x5871b5[_0xd90330(0x1a4)]=this[_0xd90330(0x1e3)]),!_0x5871b5[_0xd90330(0x1cd)]&&this[_0xd90330(0x1b7)]&&(_0x5871b5['workflowProject']=this[_0xd90330(0x1b7)]);}[a49_0x2c88a7(0x1c7)](){const _0xb86712=a49_0x2c88a7;return[{'key':'site','value':this['site']},{'key':_0xb86712(0x1bc),'value':this[_0xb86712(0x1bc)]},{'key':_0xb86712(0x1ef),'value':this['parent_segment']},{'key':_0xb86712(0x1b1),'value':this['segment_path']},{'key':'llm_project','value':this[_0xb86712(0x1b6)]},{'key':_0xb86712(0x1e3),'value':this[_0xb86712(0x1e3)]},{'key':_0xb86712(0x1b7),'value':this[_0xb86712(0x1b7)]},{'key':_0xb86712(0x1d9),'value':this[_0xb86712(0x1d6)]||undefined}];}[a49_0x2c88a7(0x1b0)](){const _0x21f10a=a49_0x2c88a7;console[_0x21f10a(0x1d0)](a49_0x745889['bold'](_0x21f10a(0x1c1)));for(const {key:_0x1ac5ec,value:_0x2ee400}of this[_0x21f10a(0x1c7)]()){_0x2ee400&&console[_0x21f10a(0x1d0)](a49_0x745889[_0x21f10a(0x1bf)](_0x1ac5ec)+':\x20'+_0x2ee400);}}[a49_0x2c88a7(0x1c4)](){const _0x3e1bb9=a49_0x2c88a7;console[_0x3e1bb9(0x1d0)](a49_0x745889[_0x3e1bb9(0x1a7)](_0x3e1bb9(0x1c1)));for(const {key:_0x10c3fd,value:_0x4d3e94}of this[_0x3e1bb9(0x1c7)]()){if(_0x4d3e94){const _0x4b0903=_0x10c3fd==='profile'?_0x3e1bb9(0x1d2):'('+this[_0x3e1bb9(0x1b5)](_0x10c3fd,_0x4d3e94)+')';console['log'](a49_0x745889[_0x3e1bb9(0x1bf)](_0x10c3fd)+':\x20'+_0x4d3e94+'\x20'+a49_0x745889[_0x3e1bb9(0x1ca)](_0x4b0903));}}console[_0x3e1bb9(0x1d0)]('\x0a'+a49_0x745889[_0x3e1bb9(0x1a7)](_0x3e1bb9(0x1c0)));const _0x4abad0=[{'label':_0x3e1bb9(0x1c3),'path':this[_0x3e1bb9(0x1aa)]['session'],'extra':'(session:\x20'+this[_0x3e1bb9(0x1df)]+')'},{'label':_0x3e1bb9(0x1af),'path':this[_0x3e1bb9(0x1aa)][_0x3e1bb9(0x1bb)]},{'label':_0x3e1bb9(0x1d3),'path':this[_0x3e1bb9(0x1aa)][_0x3e1bb9(0x1d9)]},{'label':_0x3e1bb9(0x1cf),'path':this[_0x3e1bb9(0x1aa)][_0x3e1bb9(0x1d7)]},{'label':_0x3e1bb9(0x1c9),'path':this[_0x3e1bb9(0x1aa)][_0x3e1bb9(0x1cc)]},{'label':_0x3e1bb9(0x1c5),'path':this[_0x3e1bb9(0x1aa)][_0x3e1bb9(0x1c6)]}];for(const {label:_0x3a6bc6,path:_0x277579,extra:_0x1d049e}of _0x4abad0){if(_0x277579)console[_0x3e1bb9(0x1d0)](a49_0x745889['cyan'](_0x3a6bc6)+':\x20'+_0x277579+'\x20'+a49_0x745889['green']('✓')+(_0x1d049e?'\x20'+a49_0x745889['dim'](_0x1d049e):''));else{if(_0x3a6bc6==='Session')console[_0x3e1bb9(0x1d0)](a49_0x745889[_0x3e1bb9(0x1bf)](_0x3a6bc6)+':\x20'+a49_0x745889[_0x3e1bb9(0x1ca)](_0x3e1bb9(0x1a6))+'\x20'+a49_0x745889[_0x3e1bb9(0x1ca)]('(using\x20session:\x20'+this['sessionId']+')'));else(_0x3a6bc6===_0x3e1bb9(0x1af)||_0x3a6bc6===_0x3e1bb9(0x1c9))&&console[_0x3e1bb9(0x1d0)](a49_0x745889[_0x3e1bb9(0x1bf)](_0x3a6bc6)+':\x20'+a49_0x745889['dim'](_0x3e1bb9(0x1a6)));}}}async[a49_0x2c88a7(0x1db)](){const _0x389922=a49_0x2c88a7;return this[_0x389922(0x1d5)]=await getAPIKeyAsync(this[_0x389922(0x1b2)],this['activeProfile']||undefined),this[_0x389922(0x1d5)];}static async['createAsync'](_0x79b244){const _0x3a663c=a49_0x2c88a7,_0x51d33d=new GlobalContext(_0x79b244);return await _0x51d33d[_0x3a663c(0x1db)](),_0x51d33d;}}
|
package/dist/core/keychain.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
function a50_0x2a66(){const _0xc71ece=['204517fRcBNO','no\x20matching\x20entry','Warning:\x20','profile:','unavailable','deleteCredential','2680677xXGTjO','not_found','could\x20not\x20be\x20found','16004mrIrcY','setPassword','cannot\x20find','getPassword','2qBClZQ','5845335EgHxMP','Keychain\x20access\x20denied.\x20The\x20API\x20key\x20exists\x20but\x20cannot\x20be\x20accessed.\x20Try\x20running\x20\x22tdx\x20auth\x20setup\x22\x20to\x20re-authenticate,\x20or\x20check\x20your\x20keychain\x20permissions\x20for\x20\x22tdx\x22.','not\x20found',':api_key','tdx','9364938ozuert','4597308tUCTKu','error','System\x20keychain\x20is\x20not\x20available','2065NSVosi','28338gXbNZO','message','toLowerCase','__keychain_test__','not\x20supported','success','access_denied','10bBzuFl','not\x20available','39WQCDUp','includes','access','-25293','8iMfJrH','429RsXRpm'];a50_0x2a66=function(){return _0xc71ece;};return a50_0x2a66();}function a50_0x1242(_0x34fe6c,_0x1e77ee){_0x34fe6c=_0x34fe6c-0x15d;const _0x2a66a5=a50_0x2a66();let _0x12421a=_0x2a66a5[_0x34fe6c];return _0x12421a;}const a50_0x32f1a1=a50_0x1242;(function(_0x4cc57c,_0x3b67d0){const _0x56b2dd=a50_0x1242,_0xb1e54=_0x4cc57c();while(!![]){try{const _0x22c972=-parseInt(_0x56b2dd(0x178))/0x1*(parseInt(_0x56b2dd(0x15e))/0x2)+parseInt(_0x56b2dd(0x177))/0x3*(-parseInt(_0x56b2dd(0x181))/0x4)+parseInt(_0x56b2dd(0x15f))/0x5+-parseInt(_0x56b2dd(0x169))/0x6*(parseInt(_0x56b2dd(0x168))/0x7)+parseInt(_0x56b2dd(0x176))/0x8*(-parseInt(_0x56b2dd(0x17e))/0x9)+parseInt(_0x56b2dd(0x170))/0xa*(parseInt(_0x56b2dd(0x164))/0xb)+parseInt(_0x56b2dd(0x165))/0xc*(parseInt(_0x56b2dd(0x172))/0xd);if(_0x22c972===_0x3b67d0)break;else _0xb1e54['push'](_0xb1e54['shift']());}catch(_0x5083d8){_0xb1e54['push'](_0xb1e54['shift']());}}}(a50_0x2a66,0xab602));const SERVICE_NAME=a50_0x32f1a1(0x163);let EntryClass=null,keyringLoadError=null;async function getEntryClass(){if(EntryClass!==null)return EntryClass;if(keyringLoadError!==null)return null;try{const _0x1579ff=await import('@napi-rs/keyring');return EntryClass=_0x1579ff['Entry'],EntryClass;}catch(_0x8cb2d2){return keyringLoadError=_0x8cb2d2 instanceof Error?_0x8cb2d2:new Error(String(_0x8cb2d2)),null;}}function getAccountName(_0x5b10ab){const _0x44c93c=a50_0x32f1a1,_0x523603=_0x5b10ab||'';return _0x44c93c(0x17b)+_0x523603+_0x44c93c(0x162);}export async function getKeychainAPIKey(_0x24cb46){const _0x576ae1=a50_0x32f1a1,_0x5f33fa=await getKeychainAPIKeyWithStatus(_0x24cb46);if(_0x5f33fa[_0x576ae1(0x16e)])return _0x5f33fa['value'];return _0x5f33fa['reason']===_0x576ae1(0x16f)&&console[_0x576ae1(0x166)](_0x576ae1(0x17a)+_0x5f33fa[_0x576ae1(0x16a)]),null;}export async function getKeychainAPIKeyWithStatus(_0xaec671){const _0x2ddc02=a50_0x32f1a1;try{const _0x19a33f=await getEntryClass();if(!_0x19a33f)return{'success':![],'reason':_0x2ddc02(0x17c)};const _0x5e3b59=getAccountName(_0xaec671),_0x4d90d1=new _0x19a33f(SERVICE_NAME,_0x5e3b59),_0x2ff2d7=_0x4d90d1[_0x2ddc02(0x15d)]();if(_0x2ff2d7)return{'success':!![],'value':_0x2ff2d7};return{'success':![],'reason':'not_found'};}catch(_0x1ff35b){const _0x52ebfd=_0x1ff35b instanceof Error?_0x1ff35b['message']:String(_0x1ff35b);if(_0x52ebfd['includes']('-25300')||_0x52ebfd['toLowerCase']()['includes'](_0x2ddc02(0x180))||_0x52ebfd[_0x2ddc02(0x16b)]()[_0x2ddc02(0x173)](_0x2ddc02(0x161))||_0x52ebfd['toLowerCase']()[_0x2ddc02(0x173)](_0x2ddc02(0x179)))return{'success':![],'reason':_0x2ddc02(0x17f)};if(_0x52ebfd[_0x2ddc02(0x173)](_0x2ddc02(0x175))||_0x52ebfd['toLowerCase']()[_0x2ddc02(0x173)]('restricted')||_0x52ebfd[_0x2ddc02(0x16b)]()[_0x2ddc02(0x173)](_0x2ddc02(0x174)))return{'success':![],'reason':_0x2ddc02(0x16f),'message':_0x2ddc02(0x160)};return{'success':![],'reason':_0x2ddc02(0x17c),'message':_0x52ebfd};}}export async function saveKeychainAPIKey(_0x10b678,_0x4883e3){const _0x3eaede=a50_0x32f1a1,_0x5927fb=await getEntryClass();if(!_0x5927fb)throw new Error(_0x3eaede(0x167));const _0x347492=getAccountName(_0x4883e3),_0x273774=new _0x5927fb(SERVICE_NAME,_0x347492);_0x273774[_0x3eaede(0x182)](_0x10b678);}export async function deleteKeychainAPIKey(_0x1a5e64){const _0x221bc9=a50_0x32f1a1;try{const _0x34372d=await getEntryClass();if(!_0x34372d)return![];const _0xf3cde0=getAccountName(_0x1a5e64),_0x5367bd=new _0x34372d(SERVICE_NAME,_0xf3cde0);return _0x5367bd[_0x221bc9(0x17d)](),!![];}catch{return![];}}export async function isKeychainAvailable(){const _0x27efef=a50_0x32f1a1;try{const _0x27bc5a=await getEntryClass();if(!_0x27bc5a)return![];const _0x2fb553=new _0x27bc5a(SERVICE_NAME,_0x27efef(0x16c));return _0x2fb553['getPassword'](),!![];}catch(_0x1343fc){const _0x364c31=_0x1343fc instanceof Error?_0x1343fc[_0x27efef(0x16a)][_0x27efef(0x16b)]():'';if(_0x364c31[_0x27efef(0x173)](_0x27efef(0x171))||_0x364c31[_0x27efef(0x173)](_0x27efef(0x16d))||_0x364c31[_0x27efef(0x173)](_0x27efef(0x183)))return![];return!![];}}
|
package/dist/core/profile.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const a51_0x425176=a51_0x5c42;(function(_0x2e049e,_0x1c00f8){const _0x55249d=a51_0x5c42,_0x2e283b=_0x2e049e();while(!![]){try{const _0x4b5ce3=parseInt(_0x55249d(0x23b))/0x1*(-parseInt(_0x55249d(0x203))/0x2)+-parseInt(_0x55249d(0x205))/0x3*(-parseInt(_0x55249d(0x20c))/0x4)+parseInt(_0x55249d(0x201))/0x5+-parseInt(_0x55249d(0x1fa))/0x6*(-parseInt(_0x55249d(0x21d))/0x7)+parseInt(_0x55249d(0x23c))/0x8+parseInt(_0x55249d(0x227))/0x9*(-parseInt(_0x55249d(0x204))/0xa)+parseInt(_0x55249d(0x22c))/0xb*(-parseInt(_0x55249d(0x231))/0xc);if(_0x4b5ce3===_0x1c00f8)break;else _0x2e283b['push'](_0x2e283b['shift']());}catch(_0x465ddc){_0x2e283b['push'](_0x2e283b['shift']());}}}(a51_0x1ae8,0x9ee64));import*as a51_0x5d1973 from'node:fs';import*as a51_0x34748e from'node:path';import{getConfigDir}from'./config.js';import{createSecureDirectory,writeSecureFile}from'../utils/file-permissions.js';import{findProjectConfigPath}from'./project-config.js';import{loadSessionContext}from'./session.js';export const STUDIO_PROFILE_NAME=a51_0x425176(0x1f8);export function getProfileParams(_0x22d921){const _0x3d929a=a51_0x425176,_0x1c1372={};if(!_0x22d921)return _0x1c1372;for(const [_0x68b4fc,_0x8e989f]of Object['entries'](_0x22d921)){_0x68b4fc!==_0x3d929a(0x240)&&_0x8e989f!==undefined&&(_0x1c1372[_0x68b4fc]=_0x8e989f);}return _0x1c1372;}export function getProfilesDir(){const _0x5937a7=a51_0x425176;return a51_0x34748e[_0x5937a7(0x1f1)](getConfigDir(),'profiles');}function a51_0x1ae8(){const _0x55b8b7=['\x27:\x20\x27description\x27\x20must\x20be\x20a\x20string','stringify','includes','\x0aWarning:\x20Profiles\x20in\x20directories\x20are\x20deprecated:\x20','site','TDX_PROFILE','Profile\x20\x27','.env','\x0aWarning:\x20Skipping\x20invalid\x20profile\x20in\x20','existsSync','\x20\x20mv\x20\x22','7239757CCkYYb','Error:\x20','llm_project','rmSync','\x20already\x20exists',',\x20creating\x20new\x20file','env','name','toISOString','user','399411NytFAQ','local','\x22\x20\x22','keys','Warning:\x20Failed\x20to\x20parse\x20','776523zEKhgG','find','\x20\x202.\x20Add\x20profiles\x20under\x20a\x20\x22profiles\x22\x20key\x20(see\x20\x27tdx\x20profiles\x27\x20for\x20current\x20config)','\x0aWarning:\x20Failed\x20to\x20parse\x20','Failed\x20to\x20parse\x20','12ACDckX','filter','readFileSync','Invalid\x20profile\x20name:\x20','To\x20migrate:','Please\x20migrate\x20to\x20~/.config/tdx/tdx.json:','\x27:\x20\x27site\x27\x20must\x20be\x20a\x20string','directory','utf-8','parent_segment','466055edtKXD','6300368WVBGea','from','object','parse','description','push','join','Then\x20define\x20profiles\x20in\x20~/.config/tdx/tdx.json\x0a',':\x20Invalid\x20JSON\x20syntax','\x20\x203.\x20Move\x20credentials:\x20mv\x20~/.config/tdx/profiles/<name>/.env\x20~/.config/tdx/.env.<name>\x0a','profiles','message','\x27\x20not\x20found\x20in\x20user\x20configuration','@tdx-studio','\x27:\x20\x27database\x27\x20must\x20be\x20a\x20string','6cKjYGd','string','\x27\x20will\x20be\x20ignored','sort','database','.env.','warn','1125415WVjPGj','\x27:\x20\x27llm_project\x27\x20must\x20be\x20a\x20string','2DFnLzb','220bqPnoo','606ZzKoWc','Warning:\x20Profile\x20\x27','.\x20Must\x20contain\x20only\x20alphanumeric\x20characters,\x20dash,\x20underscore,\x20and\x20optional\x20@\x20prefix\x20for\x20reserved\x20profiles.','readdirSync','localeCompare','\x0aWarning:\x20Failed\x20to\x20load\x20profiles\x20from\x20','tdx.json','2316hUrMhI','map','llm_agent','\x20\x201.\x20Edit:\x20','profile','Profile\x20'];a51_0x1ae8=function(){return _0x55b8b7;};return a51_0x1ae8();}function getProfileDir(_0xed9141){const _0x4e1ebe=a51_0x425176;return a51_0x34748e[_0x4e1ebe(0x1f1)](getProfilesDir(),_0xed9141);}function getProfileConfigPath(_0x328844){const _0x359de2=a51_0x425176;return a51_0x34748e[_0x359de2(0x1f1)](getProfileDir(_0x328844),'tdx.json');}function getProfileEnvPath(_0x3d25e7){const _0x324bc5=a51_0x425176;return a51_0x34748e['join'](getProfileDir(_0x3d25e7),_0x324bc5(0x219));}function getGlobalConfigPath(){const _0x682749=a51_0x425176;return a51_0x34748e['join'](getConfigDir(),_0x682749(0x20b));}function validateProfileName(_0x48694f){const _0x4464ff=a51_0x425176;if(!/^@?[a-zA-Z0-9_-]+$/['test'](_0x48694f))throw new Error(_0x4464ff(0x234)+_0x48694f+_0x4464ff(0x207));}function validateProfileConfig(_0x5462f0,_0x16b796){const _0x41523c=a51_0x425176;if(typeof _0x5462f0!==_0x41523c(0x23e)||_0x5462f0===null)throw new Error('Profile\x20\x27'+_0x16b796+'\x27:\x20config\x20must\x20be\x20an\x20object');const _0x3c6b9e=[_0x41523c(0x240),'site','database',_0x41523c(0x23a),'llm_project',_0x41523c(0x20e)],_0x4febf0=_0x5462f0;for(const _0x2f7138 of Object[_0x41523c(0x22a)](_0x4febf0)){!_0x3c6b9e[_0x41523c(0x214)](_0x2f7138)&&console[_0x41523c(0x200)](_0x41523c(0x206)+_0x16b796+'\x27:\x20unknown\x20config\x20key\x20\x27'+_0x2f7138+_0x41523c(0x1fc));}if(_0x4febf0[_0x41523c(0x240)]!==undefined&&typeof _0x4febf0[_0x41523c(0x240)]!==_0x41523c(0x1fb))throw new Error('Profile\x20\x27'+_0x16b796+_0x41523c(0x212));if(_0x4febf0[_0x41523c(0x216)]!==undefined&&typeof _0x4febf0[_0x41523c(0x216)]!=='string')throw new Error(_0x41523c(0x218)+_0x16b796+_0x41523c(0x237));if(_0x4febf0[_0x41523c(0x1fe)]!==undefined&&typeof _0x4febf0['database']!==_0x41523c(0x1fb))throw new Error('Profile\x20\x27'+_0x16b796+_0x41523c(0x1f9));if(_0x4febf0[_0x41523c(0x23a)]!==undefined&&typeof _0x4febf0[_0x41523c(0x23a)]!==_0x41523c(0x1fb))throw new Error(_0x41523c(0x218)+_0x16b796+'\x27:\x20\x27parent_segment\x27\x20must\x20be\x20a\x20string');if(_0x4febf0['llm_project']!==undefined&&typeof _0x4febf0[_0x41523c(0x21f)]!==_0x41523c(0x1fb))throw new Error(_0x41523c(0x218)+_0x16b796+_0x41523c(0x202));if(_0x4febf0[_0x41523c(0x20e)]!==undefined&&typeof _0x4febf0[_0x41523c(0x20e)]!==_0x41523c(0x1fb))throw new Error(_0x41523c(0x218)+_0x16b796+'\x27:\x20\x27llm_agent\x27\x20must\x20be\x20a\x20string');return!![];}function loadProfilesFromTdxJson(_0x6bf432,_0x23380e){const _0x308755=a51_0x425176;if(!a51_0x5d1973[_0x308755(0x21b)](_0x6bf432))return[];try{const _0x103802=a51_0x5d1973[_0x308755(0x233)](_0x6bf432,_0x308755(0x239)),_0x366fdc=JSON[_0x308755(0x23f)](_0x103802);if(!_0x366fdc[_0x308755(0x1f5)]||typeof _0x366fdc['profiles']!==_0x308755(0x23e))return[];const _0x315c5f=[];for(const [_0x18b021,_0x11c2ea]of Object['entries'](_0x366fdc[_0x308755(0x1f5)])){try{validateProfileConfig(_0x11c2ea,_0x18b021);const _0x52ead2=getNewCredentialPath(_0x18b021),_0x573b16=getOldCredentialPath(_0x18b021),_0x3ef4d8=a51_0x5d1973[_0x308755(0x21b)](_0x52ead2)||a51_0x5d1973[_0x308755(0x21b)](_0x573b16);_0x315c5f[_0x308755(0x241)]({'name':_0x18b021,'config':_0x11c2ea,'metadata':{'name':_0x18b021,'createdAt':new Date()[_0x308755(0x225)]()},'hasCredentials':_0x3ef4d8,'scope':_0x23380e});}catch(_0x24c4fd){_0x24c4fd instanceof Error&&(console[_0x308755(0x200)](_0x308755(0x21a)+_0x6bf432+':'),console[_0x308755(0x200)]('\x20\x20'+_0x24c4fd[_0x308755(0x1f6)]+'\x0a'));}}return _0x315c5f;}catch(_0x1a3dcd){return _0x1a3dcd instanceof SyntaxError?(console[_0x308755(0x200)](_0x308755(0x22f)+_0x6bf432+_0x308755(0x1f3)),console[_0x308755(0x200)](_0x308755(0x21e)+_0x1a3dcd[_0x308755(0x1f6)]+'\x0a')):console[_0x308755(0x200)](_0x308755(0x20a)+_0x6bf432+':\x20'+_0x1a3dcd+'\x0a'),[];}}export function getNewCredentialPath(_0x3453dd){const _0x42a718=a51_0x425176;return a51_0x34748e[_0x42a718(0x1f1)](getConfigDir(),_0x42a718(0x1ff)+_0x3453dd);}function getOldCredentialPath(_0x459102){const _0x425012=a51_0x425176;return a51_0x34748e[_0x425012(0x1f1)](getProfilesDir(),_0x459102,_0x425012(0x219));}function loadProfilesFromTdxJsonFiles(){const _0x589004=a51_0x425176,_0x20c2ad=[],_0x256692=findProjectConfigPath();_0x256692&&_0x20c2ad[_0x589004(0x241)](...loadProfilesFromTdxJson(_0x256692,_0x589004(0x228)));const _0x215d7c=a51_0x34748e[_0x589004(0x1f1)](getConfigDir(),_0x589004(0x20b));return _0x20c2ad[_0x589004(0x241)](...loadProfilesFromTdxJson(_0x215d7c,_0x589004(0x226))),_0x20c2ad;}function loadProfilesFromDirectories(){const _0xab6648=a51_0x425176,_0x461017=getProfilesDir();if(!a51_0x5d1973['existsSync'](_0x461017))return[];try{return a51_0x5d1973[_0xab6648(0x208)](_0x461017,{'withFileTypes':!![]})[_0xab6648(0x232)](_0x11b249=>_0x11b249['isDirectory']())[_0xab6648(0x20d)](_0x36caab=>_0x36caab[_0xab6648(0x224)])['filter'](_0xb7c8=>{const _0x30099e=_0xab6648,_0x39eed3=getProfileConfigPath(_0xb7c8),_0x2b4460=getProfileEnvPath(_0xb7c8);return a51_0x5d1973[_0x30099e(0x21b)](_0x39eed3)||a51_0x5d1973[_0x30099e(0x21b)](_0x2b4460);})[_0xab6648(0x20d)](_0x1131d3=>{const _0x9ecc23=loadProfileFromDirectory(_0x1131d3);if(_0x9ecc23)return{..._0x9ecc23,'scope':'directory'};return null;})[_0xab6648(0x232)](_0x297aac=>_0x297aac!==null);}catch{return[];}}function a51_0x5c42(_0x4a7d14,_0x7b9485){_0x4a7d14=_0x4a7d14-0x1f1;const _0x1ae873=a51_0x1ae8();let _0x5c4281=_0x1ae873[_0x4a7d14];return _0x5c4281;}function loadProfileFromDirectory(_0x3ae139){const _0x19905b=a51_0x425176,_0xda579f=getProfileConfigPath(_0x3ae139),_0x4d69cb=getOldCredentialPath(_0x3ae139);if(!a51_0x5d1973[_0x19905b(0x21b)](_0xda579f)&&!a51_0x5d1973['existsSync'](_0x4d69cb))return null;let _0x2b719b={},_0xad472d={'name':_0x3ae139,'createdAt':new Date()[_0x19905b(0x225)]()};if(a51_0x5d1973[_0x19905b(0x21b)](_0xda579f))try{const _0x53c77f=a51_0x5d1973[_0x19905b(0x233)](_0xda579f,'utf-8'),_0x423477=JSON[_0x19905b(0x23f)](_0x53c77f),{metadata:_0x4f77f7,..._0x5c847e}=_0x423477;_0x2b719b=_0x5c847e,_0x4f77f7&&(_0xad472d=_0x4f77f7);}catch{}return{'name':_0x3ae139,'config':_0x2b719b,'metadata':_0xad472d,'hasCredentials':a51_0x5d1973[_0x19905b(0x21b)](_0x4d69cb),'scope':_0x19905b(0x238)};}export function listProfiles(){const _0x5dfcf5=a51_0x425176,_0x3bc73f=loadProfilesFromTdxJsonFiles(),_0x3d1e30=loadProfilesFromDirectories();if(_0x3d1e30['length']>0x0){const _0x3a4e90=_0x3d1e30[_0x5dfcf5(0x20d)](_0x21873d=>_0x21873d[_0x5dfcf5(0x224)])['join'](',\x20'),_0x598ef3=getConfigDir();console[_0x5dfcf5(0x200)](_0x5dfcf5(0x215)+_0x3a4e90),console[_0x5dfcf5(0x200)](_0x5dfcf5(0x236)),console[_0x5dfcf5(0x200)](_0x5dfcf5(0x20f)+a51_0x34748e[_0x5dfcf5(0x1f1)](_0x598ef3,_0x5dfcf5(0x20b))),console[_0x5dfcf5(0x200)](_0x5dfcf5(0x22e)),console[_0x5dfcf5(0x200)](_0x5dfcf5(0x1f4));}const _0x506989=[..._0x3bc73f,..._0x3d1e30],_0x194858=new Map();for(const _0x53bddd of _0x506989){!_0x194858['has'](_0x53bddd['name'])&&_0x194858['set'](_0x53bddd[_0x5dfcf5(0x224)],_0x53bddd);}return Array[_0x5dfcf5(0x23d)](_0x194858['values']())[_0x5dfcf5(0x1fd)]((_0x1bb85d,_0x138b0a)=>_0x1bb85d['name'][_0x5dfcf5(0x209)](_0x138b0a[_0x5dfcf5(0x224)]));}export function profileExists(_0x59a68e){const _0x20f45c=a51_0x425176,_0x5bfbb9=listProfiles();return _0x5bfbb9['some'](_0x35ed89=>_0x35ed89[_0x20f45c(0x224)]===_0x59a68e);}export function loadProfile(_0x1d670a){const _0x4f6202=a51_0x425176;validateProfileName(_0x1d670a);const _0x10c3b1=listProfiles(),_0x271123=_0x10c3b1[_0x4f6202(0x22d)](_0x5a166a=>_0x5a166a[_0x4f6202(0x224)]===_0x1d670a);return _0x271123||null;}export function saveProfile(_0xa6aac9,_0x426316,_0x32567e=![]){saveProfileToUserConfig(_0xa6aac9,_0x426316);}export function deleteProfile(_0x541074){const _0x5f4e28=a51_0x425176;validateProfileName(_0x541074);const _0x36325b=getProfileDir(_0x541074);if(!a51_0x5d1973[_0x5f4e28(0x21b)](_0x36325b))throw new Error(_0x5f4e28(0x211)+_0x541074+'\x20does\x20not\x20exist');a51_0x5d1973[_0x5f4e28(0x220)](_0x36325b,{'recursive':!![],'force':!![]});}export function saveProfileToUserConfig(_0x121dc0,_0x49d9da){const _0x2f4e05=a51_0x425176;validateProfileName(_0x121dc0);const _0x5b1bbb=getGlobalConfigPath(),_0x4e7007=getConfigDir();!a51_0x5d1973[_0x2f4e05(0x21b)](_0x4e7007)&&createSecureDirectory(_0x4e7007);let _0x20031b={};if(a51_0x5d1973[_0x2f4e05(0x21b)](_0x5b1bbb))try{const _0x3e79ea=a51_0x5d1973[_0x2f4e05(0x233)](_0x5b1bbb,'utf-8');_0x20031b=JSON[_0x2f4e05(0x23f)](_0x3e79ea);}catch{console['warn']('Warning:\x20Failed\x20to\x20parse\x20'+_0x5b1bbb+_0x2f4e05(0x222));}!_0x20031b['profiles']&&(_0x20031b['profiles']={}),_0x20031b[_0x2f4e05(0x1f5)][_0x121dc0]=_0x49d9da,writeSecureFile(_0x5b1bbb,JSON[_0x2f4e05(0x213)](_0x20031b,null,0x2));}export function removeProfileFromUserConfig(_0x496aa8){const _0x93d090=a51_0x425176;validateProfileName(_0x496aa8);const _0x2cc40b=getGlobalConfigPath();if(!a51_0x5d1973['existsSync'](_0x2cc40b))throw new Error(_0x93d090(0x218)+_0x496aa8+_0x93d090(0x1f7));let _0x606041={};try{const _0x28c9d1=a51_0x5d1973[_0x93d090(0x233)](_0x2cc40b,_0x93d090(0x239));_0x606041=JSON['parse'](_0x28c9d1);}catch{throw new Error(_0x93d090(0x230)+_0x2cc40b);}if(!_0x606041['profiles']||!_0x606041['profiles'][_0x496aa8])throw new Error(_0x93d090(0x218)+_0x496aa8+_0x93d090(0x1f7));delete _0x606041[_0x93d090(0x1f5)][_0x496aa8],_0x606041[_0x93d090(0x210)]===_0x496aa8&&delete _0x606041['profile'],writeSecureFile(_0x2cc40b,JSON[_0x93d090(0x213)](_0x606041,null,0x2));}export function getActiveProfile(){const _0x4737de=a51_0x425176,_0x5be5a1=loadSessionContext();if(_0x5be5a1?.[_0x4737de(0x210)])return _0x5be5a1[_0x4737de(0x210)];if(process[_0x4737de(0x223)][_0x4737de(0x217)])return process[_0x4737de(0x223)]['TDX_PROFILE'];const _0x3ff354=getGlobalConfigPath();if(!a51_0x5d1973[_0x4737de(0x21b)](_0x3ff354))return null;try{const _0x3331c2=a51_0x5d1973[_0x4737de(0x233)](_0x3ff354,_0x4737de(0x239)),_0x18b971=JSON[_0x4737de(0x23f)](_0x3331c2);return _0x18b971['profile']||null;}catch{return null;}}export function saveDefaultSiteToUserConfig(_0x425d21){const _0x54e852=a51_0x425176,_0xc90be5=getGlobalConfigPath(),_0x288e95=getConfigDir();!a51_0x5d1973['existsSync'](_0x288e95)&&createSecureDirectory(_0x288e95);let _0x2a183={};if(a51_0x5d1973[_0x54e852(0x21b)](_0xc90be5))try{const _0x54e7bd=a51_0x5d1973[_0x54e852(0x233)](_0xc90be5,_0x54e852(0x239));_0x2a183=JSON['parse'](_0x54e7bd);}catch{console[_0x54e852(0x200)](_0x54e852(0x22b)+_0xc90be5+_0x54e852(0x222));}_0x2a183[_0x54e852(0x216)]=_0x425d21,writeSecureFile(_0xc90be5,JSON[_0x54e852(0x213)](_0x2a183,null,0x2));}export function saveActiveProfileToUserConfig(_0x147b59){const _0x8c1791=a51_0x425176;validateProfileName(_0x147b59);const _0x3cfaaa=getGlobalConfigPath(),_0x43a8c8=getConfigDir();!a51_0x5d1973[_0x8c1791(0x21b)](_0x43a8c8)&&createSecureDirectory(_0x43a8c8);let _0x567bb8={};if(a51_0x5d1973['existsSync'](_0x3cfaaa))try{const _0xf45b7c=a51_0x5d1973[_0x8c1791(0x233)](_0x3cfaaa,'utf-8');_0x567bb8=JSON['parse'](_0xf45b7c);}catch{console[_0x8c1791(0x200)]('Warning:\x20Failed\x20to\x20parse\x20'+_0x3cfaaa+_0x8c1791(0x222));}_0x567bb8[_0x8c1791(0x210)]=_0x147b59,writeSecureFile(_0x3cfaaa,JSON['stringify'](_0x567bb8,null,0x2));}function clearFieldFromUserConfig(_0x172910){const _0x1261ad=a51_0x425176,_0x89199b=getGlobalConfigPath();if(!a51_0x5d1973[_0x1261ad(0x21b)](_0x89199b))return;let _0x5139b8={};try{const _0x2ccdb3=a51_0x5d1973[_0x1261ad(0x233)](_0x89199b,'utf-8');_0x5139b8=JSON[_0x1261ad(0x23f)](_0x2ccdb3);}catch{return;}delete _0x5139b8[_0x172910],writeSecureFile(_0x89199b,JSON[_0x1261ad(0x213)](_0x5139b8,null,0x2));}export function clearDefaultSiteFromUserConfig(){clearFieldFromUserConfig('site');}export function clearActiveProfileFromUserConfig(){const _0xb1b7df=a51_0x425176;clearFieldFromUserConfig(_0xb1b7df(0x210));}export function createProfile(_0x10c76d,_0x41a075){const _0x4c3945=a51_0x425176;validateProfileName(_0x10c76d);if(profileExists(_0x10c76d))throw new Error('Profile\x20'+_0x10c76d+_0x4c3945(0x221));saveProfile(_0x10c76d,_0x41a075);}export function saveProfileCredentials(_0x400c37,_0x3ee7ae){validateProfileName(_0x400c37);if(!profileExists(_0x400c37))throw new Error('Profile\x20'+_0x400c37+'\x20does\x20not\x20exist');const _0x5acfa7=getNewCredentialPath(_0x400c37);writeSecureFile(_0x5acfa7,_0x3ee7ae);}export function loadProfileCredentials(_0xd9dd58){const _0x5e5be0=a51_0x425176;validateProfileName(_0xd9dd58);const _0x2b6f60=getNewCredentialPath(_0xd9dd58);if(a51_0x5d1973[_0x5e5be0(0x21b)](_0x2b6f60))try{return a51_0x5d1973['readFileSync'](_0x2b6f60,_0x5e5be0(0x239));}catch{}const _0x59204d=getOldCredentialPath(_0xd9dd58);if(a51_0x5d1973[_0x5e5be0(0x21b)](_0x59204d)){console[_0x5e5be0(0x200)]('\x0aWarning:\x20Using\x20deprecated\x20credential\x20location\x20for\x20profile\x20\x27'+_0xd9dd58+'\x27'),console['warn'](_0x5e5be0(0x235)),console['warn'](_0x5e5be0(0x21c)+_0x59204d+_0x5e5be0(0x229)+_0x2b6f60+'\x22'),console[_0x5e5be0(0x200)](_0x5e5be0(0x1f2));try{return a51_0x5d1973['readFileSync'](_0x59204d,_0x5e5be0(0x239));}catch{return null;}}return null;}
|
|
1
|
+
(function(_0x63eacb,_0xb583b5){const _0x28787b=a51_0x7781,_0x16ea4b=_0x63eacb();while(!![]){try{const _0x2b67d3=parseInt(_0x28787b(0xfa))/0x1+parseInt(_0x28787b(0xc3))/0x2*(-parseInt(_0x28787b(0xf3))/0x3)+-parseInt(_0x28787b(0xf0))/0x4*(parseInt(_0x28787b(0xbf))/0x5)+-parseInt(_0x28787b(0xcd))/0x6*(parseInt(_0x28787b(0xd8))/0x7)+parseInt(_0x28787b(0xeb))/0x8*(parseInt(_0x28787b(0x10f))/0x9)+parseInt(_0x28787b(0x10b))/0xa*(parseInt(_0x28787b(0xe8))/0xb)+parseInt(_0x28787b(0x108))/0xc*(parseInt(_0x28787b(0xc2))/0xd);if(_0x2b67d3===_0xb583b5)break;else _0x16ea4b['push'](_0x16ea4b['shift']());}catch(_0x335a58){_0x16ea4b['push'](_0x16ea4b['shift']());}}}(a51_0xca36,0xce1a0));import*as a51_0x84ef67 from'node:fs';import*as a51_0x56887b from'node:path';import{getConfigDir}from'./config.js';import{createSecureDirectory,writeSecureFile}from'../utils/file-permissions.js';import{findProjectConfigPath}from'./project-config.js';import{loadSessionContext}from'./session.js';export const STUDIO_PROFILE_NAME='@tdx-studio';export function getProfileParams(_0x5daef2){const _0x40af71=a51_0x7781,_0x3c7de6={};if(!_0x5daef2)return _0x3c7de6;for(const [_0x5e5c4c,_0x59d793]of Object[_0x40af71(0xfe)](_0x5daef2)){_0x5e5c4c!==_0x40af71(0xe4)&&_0x59d793!==undefined&&(_0x3c7de6[_0x5e5c4c]=_0x59d793);}return _0x3c7de6;}export function getProfilesDir(){const _0x5a7294=a51_0x7781;return a51_0x56887b[_0x5a7294(0xf6)](getConfigDir(),_0x5a7294(0xc5));}function a51_0x7781(_0x1ac7da,_0x36fa89){_0x1ac7da=_0x1ac7da-0xbe;const _0xca366e=a51_0xca36();let _0x7781b4=_0xca366e[_0x1ac7da];return _0x7781b4;}function getProfileDir(_0x483ea0){const _0x42d07a=a51_0x7781;return a51_0x56887b[_0x42d07a(0xf6)](getProfilesDir(),_0x483ea0);}function getProfileConfigPath(_0x32c841){return a51_0x56887b['join'](getProfileDir(_0x32c841),'tdx.json');}function getProfileEnvPath(_0xfed012){return a51_0x56887b['join'](getProfileDir(_0xfed012),'.env');}function getGlobalConfigPath(){const _0x11e810=a51_0x7781;return a51_0x56887b[_0x11e810(0xf6)](getConfigDir(),'tdx.json');}function validateProfileName(_0x4e1db5){const _0x3153c7=a51_0x7781;if(!/^@?[a-zA-Z0-9_-]+$/[_0x3153c7(0xf8)](_0x4e1db5))throw new Error(_0x3153c7(0x110)+_0x4e1db5+_0x3153c7(0xc0));}function validateProfileConfig(_0x27df84,_0x23f56f){const _0x3df59f=a51_0x7781;if(typeof _0x27df84!==_0x3df59f(0xf4)||_0x27df84===null)throw new Error(_0x3df59f(0xf9)+_0x23f56f+_0x3df59f(0xc7));const _0x58a156=[_0x3df59f(0xe4),'site',_0x3df59f(0x109),_0x3df59f(0xe7),_0x3df59f(0x102),_0x3df59f(0x101)],_0x54b1de=_0x27df84;for(const _0x3407b2 of Object['keys'](_0x54b1de)){!_0x58a156[_0x3df59f(0xfc)](_0x3407b2)&&console[_0x3df59f(0xc8)](_0x3df59f(0xd4)+_0x23f56f+_0x3df59f(0x10e)+_0x3407b2+_0x3df59f(0xbe));}if(_0x54b1de[_0x3df59f(0xe4)]!==undefined&&typeof _0x54b1de[_0x3df59f(0xe4)]!==_0x3df59f(0xff))throw new Error('Profile\x20\x27'+_0x23f56f+_0x3df59f(0xcf));if(_0x54b1de[_0x3df59f(0xdc)]!==undefined&&typeof _0x54b1de[_0x3df59f(0xdc)]!==_0x3df59f(0xff))throw new Error(_0x3df59f(0xf9)+_0x23f56f+_0x3df59f(0x105));if(_0x54b1de[_0x3df59f(0x109)]!==undefined&&typeof _0x54b1de[_0x3df59f(0x109)]!==_0x3df59f(0xff))throw new Error(_0x3df59f(0xf9)+_0x23f56f+_0x3df59f(0x103));if(_0x54b1de[_0x3df59f(0xe7)]!==undefined&&typeof _0x54b1de['parent_segment']!==_0x3df59f(0xff))throw new Error(_0x3df59f(0xf9)+_0x23f56f+_0x3df59f(0x104));if(_0x54b1de[_0x3df59f(0x102)]!==undefined&&typeof _0x54b1de[_0x3df59f(0x102)]!==_0x3df59f(0xff))throw new Error(_0x3df59f(0xf9)+_0x23f56f+_0x3df59f(0xd3));if(_0x54b1de[_0x3df59f(0x101)]!==undefined&&typeof _0x54b1de['llm_agent']!==_0x3df59f(0xff))throw new Error(_0x3df59f(0xf9)+_0x23f56f+_0x3df59f(0x106));return!![];}function loadProfilesFromTdxJson(_0x26181b,_0xe50827){const _0xd67811=a51_0x7781;if(!a51_0x84ef67['existsSync'](_0x26181b))return[];try{const _0x5568ed=a51_0x84ef67['readFileSync'](_0x26181b,_0xd67811(0xec)),_0x1c70a8=JSON[_0xd67811(0xcc)](_0x5568ed);if(!_0x1c70a8[_0xd67811(0xc5)]||typeof _0x1c70a8[_0xd67811(0xc5)]!==_0xd67811(0xf4))return[];const _0x5cf9b4=[];for(const [_0xd4fe9b,_0x21f50d]of Object[_0xd67811(0xfe)](_0x1c70a8[_0xd67811(0xc5)])){try{validateProfileConfig(_0x21f50d,_0xd4fe9b);const _0x3cc92a=getNewCredentialPath(_0xd4fe9b),_0x5886a6=getOldCredentialPath(_0xd4fe9b),_0x34628e=a51_0x84ef67[_0xd67811(0xda)](_0x3cc92a)||a51_0x84ef67['existsSync'](_0x5886a6);_0x5cf9b4['push']({'name':_0xd4fe9b,'config':_0x21f50d,'metadata':{'name':_0xd4fe9b,'createdAt':new Date()[_0xd67811(0xcb)]()},'hasCredentials':_0x34628e,'scope':_0xe50827});}catch(_0x1e3502){_0x1e3502 instanceof Error&&(console[_0xd67811(0xc8)](_0xd67811(0xf1)+_0x26181b+':'),console[_0xd67811(0xc8)]('\x20\x20'+_0x1e3502[_0xd67811(0xe2)]+'\x0a'));}}return _0x5cf9b4;}catch(_0x75fcfc){return _0x75fcfc instanceof SyntaxError?(console[_0xd67811(0xc8)](_0xd67811(0xe6)+_0x26181b+_0xd67811(0xef)),console[_0xd67811(0xc8)](_0xd67811(0xd9)+_0x75fcfc['message']+'\x0a')):console[_0xd67811(0xc8)](_0xd67811(0xd1)+_0x26181b+':\x20'+_0x75fcfc+'\x0a'),[];}}export function getNewCredentialPath(_0xa6a730){const _0x584c40=a51_0x7781;return a51_0x56887b[_0x584c40(0xf6)](getConfigDir(),_0x584c40(0x10a)+_0xa6a730);}function getOldCredentialPath(_0x4a8df2){return a51_0x56887b['join'](getProfilesDir(),_0x4a8df2,'.env');}function loadProfilesFromTdxJsonFiles(){const _0x233fad=a51_0x7781,_0x1895fd=[],_0x3bca8f=findProjectConfigPath();_0x3bca8f&&_0x1895fd[_0x233fad(0x107)](...loadProfilesFromTdxJson(_0x3bca8f,_0x233fad(0xde)));const _0x37fe51=a51_0x56887b['join'](getConfigDir(),_0x233fad(0xea));return _0x1895fd[_0x233fad(0x107)](...loadProfilesFromTdxJson(_0x37fe51,_0x233fad(0xd7))),_0x1895fd;}function loadProfilesFromDirectories(){const _0x70c398=a51_0x7781,_0x763a93=getProfilesDir();if(!a51_0x84ef67[_0x70c398(0xda)](_0x763a93))return[];try{return a51_0x84ef67[_0x70c398(0xc1)](_0x763a93,{'withFileTypes':!![]})[_0x70c398(0xf7)](_0x8e6a26=>_0x8e6a26['isDirectory']())[_0x70c398(0xe3)](_0x2c70ae=>_0x2c70ae[_0x70c398(0x10d)])[_0x70c398(0xf7)](_0x3dca40=>{const _0x412fd2=_0x70c398,_0xb558a7=getProfileConfigPath(_0x3dca40),_0x3e977e=getProfileEnvPath(_0x3dca40);return a51_0x84ef67[_0x412fd2(0xda)](_0xb558a7)||a51_0x84ef67[_0x412fd2(0xda)](_0x3e977e);})[_0x70c398(0xe3)](_0x382838=>{const _0x1f558e=_0x70c398,_0x4569bc=loadProfileFromDirectory(_0x382838);if(_0x4569bc)return{..._0x4569bc,'scope':_0x1f558e(0xd2)};return null;})[_0x70c398(0xf7)](_0x3c8b1b=>_0x3c8b1b!==null);}catch{return[];}}function loadProfileFromDirectory(_0x28be21){const _0x394fd0=a51_0x7781,_0x9f57d2=getProfileConfigPath(_0x28be21),_0x488f39=getOldCredentialPath(_0x28be21);if(!a51_0x84ef67[_0x394fd0(0xda)](_0x9f57d2)&&!a51_0x84ef67[_0x394fd0(0xda)](_0x488f39))return null;let _0x4cf0ff={},_0x4f7d6e={'name':_0x28be21,'createdAt':new Date()[_0x394fd0(0xcb)]()};if(a51_0x84ef67[_0x394fd0(0xda)](_0x9f57d2))try{const _0x12e90e=a51_0x84ef67[_0x394fd0(0xe1)](_0x9f57d2,'utf-8'),_0x16026b=JSON[_0x394fd0(0xcc)](_0x12e90e),{metadata:_0x3e99fe,..._0x5b74d6}=_0x16026b;_0x4cf0ff=_0x5b74d6,_0x3e99fe&&(_0x4f7d6e=_0x3e99fe);}catch{}return{'name':_0x28be21,'config':_0x4cf0ff,'metadata':_0x4f7d6e,'hasCredentials':a51_0x84ef67[_0x394fd0(0xda)](_0x488f39),'scope':_0x394fd0(0xd2)};}export function listProfiles(){const _0x3a6aa1=a51_0x7781,_0x230850=loadProfilesFromTdxJsonFiles(),_0x29233f=loadProfilesFromDirectories();if(_0x29233f[_0x3a6aa1(0xf2)]>0x0){const _0x16a538=_0x29233f[_0x3a6aa1(0xe3)](_0x2f9856=>_0x2f9856['name'])[_0x3a6aa1(0xf6)](',\x20'),_0x524618=getConfigDir();console[_0x3a6aa1(0xc8)](_0x3a6aa1(0xc4)+_0x16a538),console[_0x3a6aa1(0xc8)]('Please\x20migrate\x20to\x20~/.config/tdx/tdx.json:'),console['warn']('\x20\x201.\x20Edit:\x20'+a51_0x56887b[_0x3a6aa1(0xf6)](_0x524618,'tdx.json')),console[_0x3a6aa1(0xc8)](_0x3a6aa1(0xe9)),console[_0x3a6aa1(0xc8)]('\x20\x203.\x20Move\x20credentials:\x20mv\x20~/.config/tdx/profiles/<name>/.env\x20~/.config/tdx/.env.<name>\x0a');}const _0x346ca3=[..._0x230850,..._0x29233f],_0x3b3654=new Map();for(const _0x298251 of _0x346ca3){!_0x3b3654[_0x3a6aa1(0xee)](_0x298251[_0x3a6aa1(0x10d)])&&_0x3b3654['set'](_0x298251[_0x3a6aa1(0x10d)],_0x298251);}return Array[_0x3a6aa1(0xd0)](_0x3b3654['values']())[_0x3a6aa1(0xc9)]((_0x1168be,_0x5bb238)=>_0x1168be[_0x3a6aa1(0x10d)][_0x3a6aa1(0xe0)](_0x5bb238[_0x3a6aa1(0x10d)]));}export function profileExists(_0x22f490){const _0x36dc92=listProfiles();return _0x36dc92['some'](_0x2376a2=>_0x2376a2['name']===_0x22f490);}export function loadProfile(_0x1183c0){const _0x5c482b=a51_0x7781;validateProfileName(_0x1183c0);const _0x258542=listProfiles(),_0x54e8d3=_0x258542['find'](_0x5ff39=>_0x5ff39[_0x5c482b(0x10d)]===_0x1183c0);return _0x54e8d3||null;}export function saveProfile(_0xdd6990,_0x148c71,_0x1f4bcd=![]){saveProfileToUserConfig(_0xdd6990,_0x148c71);}export function deleteProfile(_0xdd57ab){const _0x5f580b=a51_0x7781;validateProfileName(_0xdd57ab);const _0x4dcbc6=getProfileDir(_0xdd57ab);if(!a51_0x84ef67[_0x5f580b(0xda)](_0x4dcbc6))throw new Error(_0x5f580b(0xe5)+_0xdd57ab+_0x5f580b(0xfd));a51_0x84ef67[_0x5f580b(0xce)](_0x4dcbc6,{'recursive':!![],'force':!![]});}export function saveProfileToUserConfig(_0x140ada,_0x358c40){const _0x14d29d=a51_0x7781;validateProfileName(_0x140ada);const _0x33912e=getGlobalConfigPath(),_0x3adb48=getConfigDir();!a51_0x84ef67[_0x14d29d(0xda)](_0x3adb48)&&createSecureDirectory(_0x3adb48);let _0x20b52c={};if(a51_0x84ef67[_0x14d29d(0xda)](_0x33912e))try{const _0xbc4aa8=a51_0x84ef67[_0x14d29d(0xe1)](_0x33912e,_0x14d29d(0xec));_0x20b52c=JSON[_0x14d29d(0xcc)](_0xbc4aa8);}catch{console[_0x14d29d(0xc8)]('Warning:\x20Failed\x20to\x20parse\x20'+_0x33912e+_0x14d29d(0xdf));}!_0x20b52c['profiles']&&(_0x20b52c[_0x14d29d(0xc5)]={}),_0x20b52c['profiles'][_0x140ada]=_0x358c40,writeSecureFile(_0x33912e,JSON[_0x14d29d(0x100)](_0x20b52c,null,0x2));}export function removeProfileFromUserConfig(_0x499d18){const _0x2de0bb=a51_0x7781;validateProfileName(_0x499d18);const _0x5933be=getGlobalConfigPath();if(!a51_0x84ef67[_0x2de0bb(0xda)](_0x5933be))throw new Error(_0x2de0bb(0xf9)+_0x499d18+_0x2de0bb(0xf5));let _0x5517e6={};try{const _0x57593e=a51_0x84ef67[_0x2de0bb(0xe1)](_0x5933be,_0x2de0bb(0xec));_0x5517e6=JSON[_0x2de0bb(0xcc)](_0x57593e);}catch{throw new Error(_0x2de0bb(0x10c)+_0x5933be);}if(!_0x5517e6[_0x2de0bb(0xc5)]||!_0x5517e6[_0x2de0bb(0xc5)][_0x499d18])throw new Error(_0x2de0bb(0xf9)+_0x499d18+_0x2de0bb(0xf5));delete _0x5517e6[_0x2de0bb(0xc5)][_0x499d18],_0x5517e6[_0x2de0bb(0xed)]===_0x499d18&&delete _0x5517e6[_0x2de0bb(0xed)],writeSecureFile(_0x5933be,JSON[_0x2de0bb(0x100)](_0x5517e6,null,0x2));}export function getActiveProfile(){const _0x19660b=a51_0x7781,_0x57e691=loadSessionContext();if(_0x57e691?.[_0x19660b(0xed)])return _0x57e691[_0x19660b(0xed)];if(process[_0x19660b(0xdb)]['TDX_PROFILE'])return process[_0x19660b(0xdb)][_0x19660b(0xfb)];const _0x1ccd90=getGlobalConfigPath();if(!a51_0x84ef67[_0x19660b(0xda)](_0x1ccd90))return null;try{const _0x1c3869=a51_0x84ef67[_0x19660b(0xe1)](_0x1ccd90,_0x19660b(0xec)),_0x26befd=JSON['parse'](_0x1c3869);return _0x26befd[_0x19660b(0xed)]||null;}catch{return null;}}export function saveDefaultSiteToUserConfig(_0x2c943c){const _0x3c0b8a=a51_0x7781,_0x15052a=getGlobalConfigPath(),_0x567dad=getConfigDir();!a51_0x84ef67[_0x3c0b8a(0xda)](_0x567dad)&&createSecureDirectory(_0x567dad);let _0x327890={};if(a51_0x84ef67[_0x3c0b8a(0xda)](_0x15052a))try{const _0x344254=a51_0x84ef67[_0x3c0b8a(0xe1)](_0x15052a,_0x3c0b8a(0xec));_0x327890=JSON[_0x3c0b8a(0xcc)](_0x344254);}catch{console[_0x3c0b8a(0xc8)]('Warning:\x20Failed\x20to\x20parse\x20'+_0x15052a+_0x3c0b8a(0xdf));}_0x327890['site']=_0x2c943c,writeSecureFile(_0x15052a,JSON[_0x3c0b8a(0x100)](_0x327890,null,0x2));}export function saveActiveProfileToUserConfig(_0x5a7aa6){const _0x466ef5=a51_0x7781;validateProfileName(_0x5a7aa6);const _0x166129=getGlobalConfigPath(),_0x54236a=getConfigDir();!a51_0x84ef67[_0x466ef5(0xda)](_0x54236a)&&createSecureDirectory(_0x54236a);let _0x376d2d={};if(a51_0x84ef67[_0x466ef5(0xda)](_0x166129))try{const _0x5c5be5=a51_0x84ef67[_0x466ef5(0xe1)](_0x166129,_0x466ef5(0xec));_0x376d2d=JSON[_0x466ef5(0xcc)](_0x5c5be5);}catch{console[_0x466ef5(0xc8)](_0x466ef5(0xca)+_0x166129+',\x20creating\x20new\x20file');}_0x376d2d[_0x466ef5(0xed)]=_0x5a7aa6,writeSecureFile(_0x166129,JSON['stringify'](_0x376d2d,null,0x2));}function clearFieldFromUserConfig(_0x46dbec){const _0x444150=a51_0x7781,_0x23ca20=getGlobalConfigPath();if(!a51_0x84ef67[_0x444150(0xda)](_0x23ca20))return;let _0x46d1df={};try{const _0x1e4174=a51_0x84ef67['readFileSync'](_0x23ca20,_0x444150(0xec));_0x46d1df=JSON['parse'](_0x1e4174);}catch{return;}delete _0x46d1df[_0x46dbec],writeSecureFile(_0x23ca20,JSON['stringify'](_0x46d1df,null,0x2));}export function clearDefaultSiteFromUserConfig(){const _0x5e5903=a51_0x7781;clearFieldFromUserConfig(_0x5e5903(0xdc));}export function clearActiveProfileFromUserConfig(){const _0x387d01=a51_0x7781;clearFieldFromUserConfig(_0x387d01(0xed));}export function createProfile(_0x477b53,_0x40dab8){const _0x5f5a5f=a51_0x7781;validateProfileName(_0x477b53);if(profileExists(_0x477b53))throw new Error(_0x5f5a5f(0xe5)+_0x477b53+'\x20already\x20exists');saveProfile(_0x477b53,_0x40dab8);}function a51_0xca36(){const _0x16d760=['\x0aWarning:\x20Profiles\x20in\x20directories\x20are\x20deprecated:\x20','profiles','\x20\x20mv\x20\x22','\x27:\x20config\x20must\x20be\x20an\x20object','warn','sort','Warning:\x20Failed\x20to\x20parse\x20','toISOString','parse','12XzDMJk','rmSync','\x27:\x20\x27description\x27\x20must\x20be\x20a\x20string','from','\x0aWarning:\x20Failed\x20to\x20load\x20profiles\x20from\x20','directory','\x27:\x20\x27llm_project\x27\x20must\x20be\x20a\x20string','Warning:\x20Profile\x20\x27','\x0aWarning:\x20Using\x20deprecated\x20credential\x20location\x20for\x20profile\x20\x27','To\x20migrate:','user','3382323QbkbiP','Error:\x20','existsSync','env','site','Then\x20define\x20profiles\x20in\x20~/.config/tdx/tdx.json\x0a','local',',\x20creating\x20new\x20file','localeCompare','readFileSync','message','map','description','Profile\x20','\x0aWarning:\x20Failed\x20to\x20parse\x20','parent_segment','530486XFwSoB','\x20\x202.\x20Add\x20profiles\x20under\x20a\x20\x22profiles\x22\x20key\x20(see\x20\x27tdx\x20profiles\x27\x20for\x20current\x20config)','tdx.json','10679440ZypoLM','utf-8','profile','has',':\x20Invalid\x20JSON\x20syntax','124ljfEwL','\x0aWarning:\x20Skipping\x20invalid\x20profile\x20in\x20','length','12KWxOkF','object','\x27\x20not\x20found\x20in\x20user\x20configuration','join','filter','test','Profile\x20\x27','3298JENHQG','TDX_PROFILE','includes','\x20does\x20not\x20exist','entries','string','stringify','llm_agent','llm_project','\x27:\x20\x27database\x27\x20must\x20be\x20a\x20string','\x27:\x20\x27parent_segment\x27\x20must\x20be\x20a\x20string','\x27:\x20\x27site\x27\x20must\x20be\x20a\x20string','\x27:\x20\x27llm_agent\x27\x20must\x20be\x20a\x20string','push','60kzAIcp','database','.env.','280CshimJ','Failed\x20to\x20parse\x20','name','\x27:\x20unknown\x20config\x20key\x20\x27','9DdMIqu','Invalid\x20profile\x20name:\x20','\x27\x20will\x20be\x20ignored','87045qmMeyf','.\x20Must\x20contain\x20only\x20alphanumeric\x20characters,\x20dash,\x20underscore,\x20and\x20optional\x20@\x20prefix\x20for\x20reserved\x20profiles.','readdirSync','2519101tELOLH','653596JIiHAE'];a51_0xca36=function(){return _0x16d760;};return a51_0xca36();}export function saveProfileCredentials(_0x12557b,_0x53d0d4){const _0x59dff6=a51_0x7781;validateProfileName(_0x12557b);if(!profileExists(_0x12557b))throw new Error(_0x59dff6(0xe5)+_0x12557b+_0x59dff6(0xfd));const _0x409548=getNewCredentialPath(_0x12557b);writeSecureFile(_0x409548,_0x53d0d4);}export function loadProfileCredentials(_0x5c25d5){const _0x1bf0a7=a51_0x7781;validateProfileName(_0x5c25d5);const _0x46b092=getNewCredentialPath(_0x5c25d5);if(a51_0x84ef67[_0x1bf0a7(0xda)](_0x46b092))try{return a51_0x84ef67[_0x1bf0a7(0xe1)](_0x46b092,_0x1bf0a7(0xec));}catch{}const _0x3b4da8=getOldCredentialPath(_0x5c25d5);if(a51_0x84ef67[_0x1bf0a7(0xda)](_0x3b4da8)){console[_0x1bf0a7(0xc8)](_0x1bf0a7(0xd5)+_0x5c25d5+'\x27'),console[_0x1bf0a7(0xc8)](_0x1bf0a7(0xd6)),console[_0x1bf0a7(0xc8)](_0x1bf0a7(0xc6)+_0x3b4da8+'\x22\x20\x22'+_0x46b092+'\x22'),console[_0x1bf0a7(0xc8)](_0x1bf0a7(0xdd));try{return a51_0x84ef67[_0x1bf0a7(0xe1)](_0x3b4da8,_0x1bf0a7(0xec));}catch{return null;}}return null;}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
(function(_0x452cc0,_0x1eaea2){const _0x5871b4=a52_0x5f30,_0x4e2116=_0x452cc0();while(!![]){try{const _0x3e1691=parseInt(_0x5871b4(0xb0))/0x1+-parseInt(_0x5871b4(0xb1))/0x2*(parseInt(_0x5871b4(0xb2))/0x3)+-parseInt(_0x5871b4(0xab))/0x4+-parseInt(_0x5871b4(0xb6))/0x5+-parseInt(_0x5871b4(0xb8))/0x6*(parseInt(_0x5871b4(0xa5))/0x7)+-parseInt(_0x5871b4(0xa0))/0x8+parseInt(_0x5871b4(0x9d))/0x9;if(_0x3e1691===_0x1eaea2)break;else _0x4e2116['push'](_0x4e2116['shift']());}catch(_0x2b07c0){_0x4e2116['push'](_0x4e2116['shift']());}}}(a52_0x374b,0x36182));import*as a52_0x5f4346 from'node:fs';import*as a52_0x188969 from'node:path';function a52_0x5f30(_0x142f0c,_0x1fcb47){_0x142f0c=_0x142f0c-0x9d;const _0x374bd2=a52_0x374b();let _0x5f305d=_0x374bd2[_0x142f0c];return _0x5f305d;}const PROJECT_CONFIG_FILENAME='tdx.json';function a52_0x374b(){const _0x1bd8b9=['40mWGGPe','32367DXEEuA','ENOENT','cwd','join','2102820TwDJJx','Security\x20error:\x20API\x20keys\x20must\x20not\x20be\x20stored\x20in\x20project\x20config\x20(','6yTPCmp','10467639JfCYYL','Active\x20profile\x20is\x20set\x20in\x20~/.config/tdx/tdx.json','TD_API_KEY','1348568VPTgOf','apiKey','Use\x20~/.config/tdx/.env\x20or\x20profile\x20.env\x20files\x20instead.','dirname','profile','474523dDAvMh','Failed\x20to\x20load\x20project\x20config\x20from\x20','code','\x20is\x20ignored.\x20','Warning:\x20\x27profile\x27\x20field\x20in\x20','api_key','1668676hEhsMy','includes','existsSync','stringify',').\x20','348372PexNhi'];a52_0x374b=function(){return _0x1bd8b9;};return a52_0x374b();}export function findProjectConfigPath(_0x3c84ea){const _0x383749=a52_0x5f30;let _0x443615=_0x3c84ea||process[_0x383749(0xb4)]();while(!![]){const _0x424ec9=a52_0x188969[_0x383749(0xb5)](_0x443615,PROJECT_CONFIG_FILENAME);if(a52_0x5f4346[_0x383749(0xad)](_0x424ec9))return _0x424ec9;const _0x3c704d=a52_0x188969[_0x383749(0xa3)](_0x443615);if(_0x3c704d===_0x443615)return null;_0x443615=_0x3c704d;}}export function loadProjectConfig(_0x3a0390){const _0x4b2bb1=a52_0x5f30,_0x41d67b=findProjectConfigPath(_0x3a0390);if(!_0x41d67b)return null;try{const _0x3f58c4=a52_0x5f4346['readFileSync'](_0x41d67b,'utf-8'),_0xdf9013=JSON['parse'](_0x3f58c4),_0x2397c2=JSON[_0x4b2bb1(0xae)](_0xdf9013);if(_0x2397c2['includes'](_0x4b2bb1(0x9f))||_0x2397c2[_0x4b2bb1(0xac)]('apiKey')||_0x2397c2[_0x4b2bb1(0xac)](_0x4b2bb1(0xaa)))throw new Error(_0x4b2bb1(0xb7)+_0x41d67b+_0x4b2bb1(0xaf)+_0x4b2bb1(0xa2));const {metadata:_0x1df692,profile:_0x2d580f,..._0x45ea9e}=_0xdf9013;return _0x2d580f&&console['warn'](_0x4b2bb1(0xa9)+_0x41d67b+_0x4b2bb1(0xa8)+_0x4b2bb1(0x9e)),_0x45ea9e;}catch(_0x5c8b1b){if(_0x5c8b1b instanceof Error&&_0x4b2bb1(0xa7)in _0x5c8b1b&&_0x5c8b1b[_0x4b2bb1(0xa7)]===_0x4b2bb1(0xb3))return null;throw new Error(_0x4b2bb1(0xa6)+_0x41d67b+':\x20'+_0x5c8b1b);}}export function saveProjectConfig(_0x2dcadf,_0x1e9a7c){const _0x2556c1=a52_0x5f30,_0x2899a3=_0x1e9a7c||process[_0x2556c1(0xb4)](),_0x243f37=a52_0x188969[_0x2556c1(0xb5)](_0x2899a3,PROJECT_CONFIG_FILENAME),_0x3e48bb=JSON[_0x2556c1(0xae)](_0x2dcadf);if(_0x3e48bb[_0x2556c1(0xac)](_0x2556c1(0x9f))||_0x3e48bb[_0x2556c1(0xac)](_0x2556c1(0xa1))||_0x3e48bb[_0x2556c1(0xac)](_0x2556c1(0xaa)))throw new Error('API\x20keys\x20must\x20not\x20be\x20stored\x20in\x20project\x20configuration.\x20Use\x20.env\x20files\x20instead.');if(_0x2556c1(0xa4)in _0x2dcadf)throw new Error('\x27profile\x27\x20should\x20not\x20be\x20set\x20in\x20project\x20config.\x20Use\x20\x27tdx\x20profile\x20use\x27\x20instead.');a52_0x5f4346['writeFileSync'](_0x243f37,JSON[_0x2556c1(0xae)](_0x2dcadf,null,0x2));}export function hasProjectConfig(_0x2c4008){return findProjectConfigPath(_0x2c4008)!==null;}export function getProjectRoot(_0x375db8){const _0x6952af=a52_0x5f30,_0x1b5cb6=findProjectConfigPath(_0x375db8);return _0x1b5cb6?a52_0x188969[_0x6952af(0xa3)](_0x1b5cb6):null;}
|
package/dist/core/session.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(_0x419fd8,_0x4ad7f1){const _0xe34dbb=a53_0x5d24,_0x44346c=_0x419fd8();while(!![]){try{const _0x45a992=-parseInt(_0xe34dbb(0x192))/0x1+-parseInt(_0xe34dbb(0x182))/0x2*(-parseInt(_0xe34dbb(0x18d))/0x3)+parseInt(_0xe34dbb(0x19d))/0x4*(-parseInt(_0xe34dbb(0x17d))/0x5)+parseInt(_0xe34dbb(0x19f))/0x6*(-parseInt(_0xe34dbb(0x194))/0x7)+parseInt(_0xe34dbb(0x186))/0x8*(parseInt(_0xe34dbb(0x198))/0x9)+-parseInt(_0xe34dbb(0x19c))/0xa*(-parseInt(_0xe34dbb(0x183))/0xb)+parseInt(_0xe34dbb(0x19a))/0xc;if(_0x45a992===_0x4ad7f1)break;else _0x44346c['push'](_0x44346c['shift']());}catch(_0x2bc4cb){_0x44346c['push'](_0x44346c['shift']());}}}(a53_0x34ec,0xe1472));import*as a53_0x48f8dd from'node:fs';import*as a53_0xba8d12 from'node:path';import*as a53_0x521cdd from'node:os';import{getPPID,isProcessRunning}from'../utils/process.js';import{createSecureDirectory}from'../utils/file-permissions.js';const SESSION_EXPIRATION_MS=0x18*0x3c*0x3c*0x3e8;function getSessionsDir(){const _0x42b814=a53_0x5d24,_0xee23dd=process[_0x42b814(0x175)][_0x42b814(0x173)]||a53_0xba8d12[_0x42b814(0x19e)](a53_0x521cdd[_0x42b814(0x17a)](),_0x42b814(0x196),_0x42b814(0x195));return a53_0xba8d12[_0x42b814(0x19e)](_0xee23dd,_0x42b814(0x185));}function getSessionPath(_0x446c50){const _0x3bc37a=a53_0x5d24;return a53_0xba8d12[_0x3bc37a(0x19e)](getSessionsDir(),_0x446c50+_0x3bc37a(0x181));}export function getCurrentSessionPID(){return getPPID();}export function getSessionID(_0x872e24){const _0x3c2796=a53_0x5d24;if(_0x872e24)return _0x872e24;return getCurrentSessionPID()[_0x3c2796(0x18f)]();}export function loadSessionContext(_0x429501){const _0x5b3044=a53_0x5d24,_0xd9bca1=_0x429501||getCurrentSessionPID()[_0x5b3044(0x18f)](),_0x31f5cc=/^\d+$/[_0x5b3044(0x17b)](_0xd9bca1)?parseInt(_0xd9bca1,0xa):null;return _0x31f5cc!==null?loadSessionContextByPID(_0x31f5cc):loadSessionContextByString(_0xd9bca1);}export function loadSessionContextByPID(_0x4cd9b1){const _0x166852=a53_0x5d24,_0x5f2295=getSessionPath(_0x4cd9b1);if(!a53_0x48f8dd[_0x166852(0x17e)](_0x5f2295))return null;try{const _0x318a92=a53_0x48f8dd[_0x166852(0x18b)](_0x5f2295,'utf-8'),_0x1af342=JSON['parse'](_0x318a92),_0x6bae81=new Date(_0x1af342['createdAt'])['getTime'](),_0x24039f=Date[_0x166852(0x178)]();if(_0x24039f-_0x6bae81>SESSION_EXPIRATION_MS)return a53_0x48f8dd[_0x166852(0x193)](_0x5f2295),null;const _0x2a7fc2=JSON[_0x166852(0x19b)](_0x1af342);if(_0x2a7fc2[_0x166852(0x17c)]('TD_API_KEY')||_0x2a7fc2[_0x166852(0x17c)](_0x166852(0x191))||_0x2a7fc2[_0x166852(0x17c)](_0x166852(0x18c)))return console['warn'](_0x166852(0x18e)+_0x5f2295+_0x166852(0x187)),a53_0x48f8dd[_0x166852(0x193)](_0x5f2295),null;return _0x1af342;}catch{try{a53_0x48f8dd['unlinkSync'](_0x5f2295);}catch{}return null;}}function loadSessionContextByString(_0x4a51c1){const _0x232068=a53_0x5d24,_0xe7628d=a53_0xba8d12[_0x232068(0x19e)](getSessionsDir(),_0x4a51c1+_0x232068(0x181));if(!a53_0x48f8dd[_0x232068(0x17e)](_0xe7628d))return null;try{const _0x181d7d=a53_0x48f8dd[_0x232068(0x18b)](_0xe7628d,_0x232068(0x180)),_0x2240c4=JSON['parse'](_0x181d7d),_0x2f73be=new Date(_0x2240c4[_0x232068(0x189)])[_0x232068(0x188)](),_0x102b5c=Date[_0x232068(0x178)]();if(_0x102b5c-_0x2f73be>SESSION_EXPIRATION_MS)return a53_0x48f8dd[_0x232068(0x193)](_0xe7628d),null;const _0x1f12bf=JSON[_0x232068(0x19b)](_0x2240c4);if(_0x1f12bf[_0x232068(0x17c)]('TD_API_KEY')||_0x1f12bf[_0x232068(0x17c)]('apiKey')||_0x1f12bf['includes'](_0x232068(0x18c)))return console[_0x232068(0x176)]('Warning:\x20API\x20keys\x20found\x20in\x20session\x20file\x20'+_0xe7628d+_0x232068(0x187)),a53_0x48f8dd[_0x232068(0x193)](_0xe7628d),null;return _0x2240c4;}catch{try{a53_0x48f8dd['unlinkSync'](_0xe7628d);}catch{}return null;}}function a53_0x5d24(_0x13938e,_0x55f747){_0x13938e=_0x13938e-0x173;const _0x34ec79=a53_0x34ec();let _0x5d24dc=_0x34ec79[_0x13938e];return _0x5d24dc;}export function saveSessionContext(_0x2ce9ad,_0x2714b1){const _0x40e092=a53_0x5d24,_0x147786=_0x2714b1||getCurrentSessionPID()['toString'](),_0x4adc27=/^\d+$/[_0x40e092(0x17b)](_0x147786)?parseInt(_0x147786,0xa):getCurrentSessionPID(),_0x5e0f9b=a53_0xba8d12[_0x40e092(0x19e)](getSessionsDir(),_0x147786+_0x40e092(0x181)),_0x2bc85c=getSessionsDir();createSecureDirectory(_0x2bc85c);const _0x3797fc=JSON['stringify'](_0x2ce9ad);if(_0x3797fc['includes'](_0x40e092(0x199))||_0x3797fc[_0x40e092(0x17c)](_0x40e092(0x191))||_0x3797fc['includes'](_0x40e092(0x18c)))throw new Error(_0x40e092(0x179));let _0x3fa210;const _0x22a5e4=/^\d+$/[_0x40e092(0x17b)](_0x147786)?loadSessionContextByPID(parseInt(_0x147786,0xa)):loadSessionContextByString(_0x147786);_0x22a5e4?_0x3fa210={..._0x22a5e4,..._0x2ce9ad,'pid':_0x4adc27,'sessionId':_0x147786!==_0x4adc27[_0x40e092(0x18f)]()?_0x147786:undefined,'updatedAt':new Date()[_0x40e092(0x17f)]()}:_0x3fa210={'pid':_0x4adc27,'sessionId':_0x147786!==_0x4adc27[_0x40e092(0x18f)]()?_0x147786:undefined,..._0x2ce9ad,'createdAt':new Date()[_0x40e092(0x17f)](),'updatedAt':new Date()[_0x40e092(0x17f)]()},a53_0x48f8dd['writeFileSync'](_0x5e0f9b,JSON[_0x40e092(0x19b)](_0x3fa210,null,0x2));}function a53_0x34ec(){const _0x1e080b=['10194772FWMRFD','tdx','.config','endsWith','36JAiofZ','TD_API_KEY','14200812eozkJi','stringify','43960LHXRlp','4TSKBkF','join','6otnmVY','TDX_CONFIG_DIR','sort','env','warn','replace','now','API\x20keys\x20must\x20not\x20be\x20stored\x20in\x20session\x20context.\x20Use\x20.env\x20files\x20instead.','homedir','test','includes','5924285JHiUCd','existsSync','toISOString','utf-8','.json','2806374HdPvyq','3751HsugvT','readdirSync','sessions','2567696xeBLBM','.\x20This\x20is\x20insecure.\x20Removing\x20session.','getTime','createdAt','parse','readFileSync','api_key','3zZLOTU','Warning:\x20API\x20keys\x20found\x20in\x20session\x20file\x20','toString','writeFileSync','apiKey','1805481GclggW','unlinkSync'];a53_0x34ec=function(){return _0x1e080b;};return a53_0x34ec();}export function clearSessionContext(_0x5d81a8){const _0x36d491=a53_0x5d24,_0x2092b1=_0x5d81a8||getCurrentSessionPID()[_0x36d491(0x18f)](),_0x53354a=a53_0xba8d12['join'](getSessionsDir(),_0x2092b1+_0x36d491(0x181));a53_0x48f8dd['existsSync'](_0x53354a)&&a53_0x48f8dd['unlinkSync'](_0x53354a);}export function clearSessionContextField(_0xf7bc39,_0x14d945){const _0x31447a=a53_0x5d24,_0x3898db=_0x14d945||getCurrentSessionPID()[_0x31447a(0x18f)](),_0x380053=a53_0xba8d12['join'](getSessionsDir(),_0x3898db+'.json');if(!a53_0x48f8dd[_0x31447a(0x17e)](_0x380053))return;try{const _0xfb5a49=a53_0x48f8dd['readFileSync'](_0x380053,'utf-8'),_0x4671d9=JSON[_0x31447a(0x18a)](_0xfb5a49);delete _0x4671d9[_0xf7bc39],a53_0x48f8dd[_0x31447a(0x190)](_0x380053,JSON[_0x31447a(0x19b)](_0x4671d9,null,0x2));}catch{}}export function cleanExpiredSessions(){const _0xdcc5d7=a53_0x5d24,_0x9a8b8b=getSessionsDir();if(!a53_0x48f8dd[_0xdcc5d7(0x17e)](_0x9a8b8b))return 0x0;let _0x271dea=0x0;const _0x24c7ad=Date[_0xdcc5d7(0x178)]();try{const _0x350a54=a53_0x48f8dd[_0xdcc5d7(0x184)](_0x9a8b8b);for(const _0x24d95b of _0x350a54){if(!_0x24d95b['endsWith']('.json'))continue;const _0x5caf79=a53_0xba8d12[_0xdcc5d7(0x19e)](_0x9a8b8b,_0x24d95b),_0x3877f0=_0x24d95b[_0xdcc5d7(0x177)]('.json',''),_0x536517=parseInt(_0x3877f0,0xa),_0x143bbc=!isNaN(_0x536517);if(_0x143bbc){if(!isProcessRunning(_0x536517)){a53_0x48f8dd[_0xdcc5d7(0x193)](_0x5caf79),_0x271dea++;continue;}}try{const _0x482fe4=a53_0x48f8dd['readFileSync'](_0x5caf79,'utf-8'),_0xae5fcb=JSON[_0xdcc5d7(0x18a)](_0x482fe4),_0x14239d=new Date(_0xae5fcb[_0xdcc5d7(0x189)])[_0xdcc5d7(0x188)]();_0x24c7ad-_0x14239d>SESSION_EXPIRATION_MS&&(a53_0x48f8dd['unlinkSync'](_0x5caf79),_0x271dea++);}catch{a53_0x48f8dd[_0xdcc5d7(0x193)](_0x5caf79),_0x271dea++;}}}catch{}return _0x271dea;}export function listActiveSessions(){const _0x29abdd=a53_0x5d24,_0x587ab4=getSessionsDir();if(!a53_0x48f8dd[_0x29abdd(0x17e)](_0x587ab4))return[];try{const _0x12037f=a53_0x48f8dd['readdirSync'](_0x587ab4),_0x6a8314=[];for(const _0x39f57a of _0x12037f){if(!_0x39f57a[_0x29abdd(0x197)](_0x29abdd(0x181)))continue;const _0x41a73f=_0x39f57a[_0x29abdd(0x177)](_0x29abdd(0x181),''),_0x229dab=parseInt(_0x41a73f,0xa);!isNaN(_0x229dab)&&isProcessRunning(_0x229dab)&&_0x6a8314['push'](_0x229dab);}return _0x6a8314[_0x29abdd(0x174)]((_0x308741,_0x52e415)=>_0x308741-_0x52e415);}catch{return[];}}
|
package/dist/core/user-cache.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
function a54_0x4548(_0x3ddb0b,_0x27373a){_0x3ddb0b=_0x3ddb0b-0x1b2;const _0x3f4b84=a54_0x3f4b();let _0x45485f=_0x3f4b84[_0x3ddb0b];return _0x45485f;}const a54_0x57dd77=a54_0x4548;(function(_0x253290,_0xb43076){const _0x26468c=a54_0x4548,_0x29bf73=_0x253290();while(!![]){try{const _0x477294=parseInt(_0x26468c(0x1b5))/0x1+-parseInt(_0x26468c(0x1b4))/0x2+parseInt(_0x26468c(0x1ba))/0x3*(parseInt(_0x26468c(0x1b7))/0x4)+-parseInt(_0x26468c(0x1bd))/0x5+-parseInt(_0x26468c(0x1b8))/0x6*(-parseInt(_0x26468c(0x1b9))/0x7)+parseInt(_0x26468c(0x1bf))/0x8*(parseInt(_0x26468c(0x1b3))/0x9)+parseInt(_0x26468c(0x1bb))/0xa;if(_0x477294===_0xb43076)break;else _0x29bf73['push'](_0x29bf73['shift']());}catch(_0x3c6dc5){_0x29bf73['push'](_0x29bf73['shift']());}}}(a54_0x3f4b,0x3d8ba));import{createProfileCache}from'../utils/global-cache.js';const userCache=createProfileCache('users-{profile}.json',a54_0x57dd77(0x1b6));export function loadCachedUsers(_0x2db1a0){const _0x34ed2b=a54_0x57dd77,_0x15e3cc=userCache['read'](_0x2db1a0);return _0x15e3cc?.[_0x34ed2b(0x1b2)]??null;}export function saveCachedUsers(_0x7c364e,_0x2a3965){const _0xee1994=a54_0x57dd77;userCache[_0xee1994(0x1bc)](_0x7c364e,{'users':_0x2a3965,'cachedAt':Date[_0xee1994(0x1c0)]()});}function a54_0x3f4b(){const _0x4dad5b=['886380yoeyHj','clear','1015720bDwnMc','now','users','18OiLNpq','614442BcujiL','49411LwbeeU','core/user-cache','65596rHPjTO','28614gAzdBY','266AhkGqi','15ZkhXDD','1700290uEkkuJ','write'];a54_0x3f4b=function(){return _0x4dad5b;};return a54_0x3f4b();}export function clearUserCache(_0x2a9273){const _0x444437=a54_0x57dd77;userCache[_0x444437(0x1be)](_0x2a9273);}
|
package/dist/core/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(_0x180af5,_0x457f75){const _0x35e15e=a55_0x263f,_0x1763a6=_0x180af5();while(!![]){try{const _0x103448=parseInt(_0x35e15e(0x116))/0x1*(parseInt(_0x35e15e(0x109))/0x2)+parseInt(_0x35e15e(0x10a))/0x3+parseInt(_0x35e15e(0x108))/0x4*(-parseInt(_0x35e15e(0x10f))/0x5)+parseInt(_0x35e15e(0x107))/0x6+parseInt(_0x35e15e(0x105))/0x7*(parseInt(_0x35e15e(0x106))/0x8)+-parseInt(_0x35e15e(0x112))/0x9+parseInt(_0x35e15e(0x114))/0xa*(-parseInt(_0x35e15e(0x110))/0xb);if(_0x103448===_0x457f75)break;else _0x1763a6['push'](_0x1763a6['shift']());}catch(_0x54b2aa){_0x1763a6['push'](_0x1763a6['shift']());}}}(a55_0x2c67,0x328e0));import{readFileSync}from'fs';function a55_0x2c67(){const _0x5c35ab=['180434qkANEU','27579SklYRe','0.0.0','../../package.json','version','parse','5mHHsfN','36311FkyRbK','utf-8','505935zzMaaS','includes','1270XbGXmq','../build-info.json','1MdQpoQ','.dev','7HHxkBS','2294408AhPvhF','2233272rOnJHE','303636rUGVSK'];a55_0x2c67=function(){return _0x5c35ab;};return a55_0x2c67();}import{fileURLToPath}from'url';import{dirname,join}from'path';let cachedBuildInfo=null,cachedVersion=null;export function getBuildInfo(){const _0x379c87=a55_0x263f;if(cachedBuildInfo!==null)return cachedBuildInfo;const _0x4d1fe5=fileURLToPath(import.meta.url),_0x9254a0=dirname(_0x4d1fe5);try{const _0x2b1c8c=join(_0x9254a0,_0x379c87(0x115));cachedBuildInfo=JSON[_0x379c87(0x10e)](readFileSync(_0x2b1c8c,_0x379c87(0x111)));}catch{cachedBuildInfo={};}return cachedBuildInfo;}function a55_0x263f(_0x310e97,_0x52555a){_0x310e97=_0x310e97-0x104;const _0x2c67a3=a55_0x2c67();let _0x263fe6=_0x2c67a3[_0x310e97];return _0x263fe6;}export function getVersion(){const _0x27baf5=a55_0x263f;if(cachedVersion!==null)return cachedVersion;const _0x51ff59=fileURLToPath(import.meta.url),_0x5314d2=dirname(_0x51ff59),_0x384d85=getBuildInfo();if(_0x384d85[_0x27baf5(0x10d)])return cachedVersion=_0x384d85['version'],cachedVersion;try{const _0x263a3e=join(_0x5314d2,_0x27baf5(0x10c)),_0x2f743d=JSON[_0x27baf5(0x10e)](readFileSync(_0x263a3e,_0x27baf5(0x111)));cachedVersion=_0x2f743d[_0x27baf5(0x10d)];}catch{cachedVersion=_0x27baf5(0x10b);}return cachedVersion;}export function isDevVersion(){const _0x522dc1=a55_0x263f,_0x3cdccc=getVersion();return _0x3cdccc[_0x522dc1(0x113)](_0x522dc1(0x104))||_0x3cdccc[_0x522dc1(0x113)]('-');}
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(_0x367a52,_0x1d83a2){var _0x2abaeb=a56_0x49a3,_0x2c8851=_0x367a52();while(!![]){try{var _0x30ddec=-parseInt(_0x2abaeb(0x92))/0x1*(parseInt(_0x2abaeb(0x94))/0x2)+parseInt(_0x2abaeb(0x98))/0x3*(parseInt(_0x2abaeb(0x90))/0x4)+-parseInt(_0x2abaeb(0x96))/0x5+-parseInt(_0x2abaeb(0x95))/0x6*(parseInt(_0x2abaeb(0x91))/0x7)+parseInt(_0x2abaeb(0x93))/0x8+-parseInt(_0x2abaeb(0x97))/0x9*(-parseInt(_0x2abaeb(0x8e))/0xa)+parseInt(_0x2abaeb(0x8f))/0xb*(parseInt(_0x2abaeb(0x8d))/0xc);if(_0x30ddec===_0x1d83a2)break;else _0x2c8851['push'](_0x2c8851['shift']());}catch(_0x36045a){_0x2c8851['push'](_0x2c8851['shift']());}}}(a56_0x4b0f,0x98527));export*from'./sdk/types/index.js';export*from'./core/config.js';function a56_0x4b0f(){var _0x5372bf=['133eMVLrH','1072844BSwXgq','5856728uJFrlj','2BehNau','276366iTTyEt','3627885vcPUaQ','36gxSeaZ','9jbjDAa','12ICQKbN','1939660vgdvQS','10550265GdTRDz','1107228uZeksP'];a56_0x4b0f=function(){return _0x5372bf;};return a56_0x4b0f();}export*from'./core/auth.js';export*from'./sdk/client/http-client.js';export*from'./sdk/client/td-api-client.js';export{TrinoApiClient}from'./sdk/client/trino-api-client.js';export*from'./sdk/client/rate-limiter.js';export*from'./sdk/types/trino.js';export*from'./commands/command.js';export*from'./commands/query-command.js';export*from'./commands/databases.js';export*from'./commands/tables.js';export*from'./commands/segments.js';export*from'./commands/activations.js';function a56_0x49a3(_0xa95535,_0x31c1b2){_0xa95535=_0xa95535-0x8d;var _0x4b0fce=a56_0x4b0f();var _0x49a3da=_0x4b0fce[_0xa95535];return _0x49a3da;}export*from'./commands/show.js';export*from'./commands/describe.js';export*from'./sdk/index.js';
|
package/dist/mcp/server.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
(function(_0x5dd942,_0x512da3){const _0x49e774=a57_0x94d3,_0x3e8806=_0x5dd942();while(!![]){try{const _0x2cf2eb=-parseInt(_0x49e774(0x1f4))/0x1*(parseInt(_0x49e774(0x1fb))/0x2)+-parseInt(_0x49e774(0x1ff))/0x3*(-parseInt(_0x49e774(0x21b))/0x4)+-parseInt(_0x49e774(0x1fd))/0x5+parseInt(_0x49e774(0x202))/0x6+-parseInt(_0x49e774(0x200))/0x7*(parseInt(_0x49e774(0x208))/0x8)+-parseInt(_0x49e774(0x1f2))/0x9+parseInt(_0x49e774(0x212))/0xa;if(_0x2cf2eb===_0x512da3)break;else _0x3e8806['push'](_0x3e8806['shift']());}catch(_0x292dd6){_0x3e8806['push'](_0x3e8806['shift']());}}}(a57_0x1cfd,0x4bf4e));import{McpServer}from'@modelcontextprotocol/sdk/server/mcp.js';import{StdioServerTransport}from'@modelcontextprotocol/sdk/server/stdio.js';import{z}from'zod';function a57_0x1cfd(){const _0x4b549b=['Context','Data','text','No\x20commands\x20found\x20matching\x20\x22','Natural\x20language\x20query\x20(e.g.,\x20\x22list\x20databases\x22,\x20\x22run\x20SQL\x22,\x20\x22manage\x20segments\x22)','map','2HNMKXw','join','1088655RRuCsF','describe','204mdMbgA','7HHLbpt','array','744264XOFZJz','enum','Execute\x20any\x20tdx\x20CLI\x20command.\x20Returns\x20JSON\x20output.\x0a\x0aExamples:\x0a-\x20List\x20databases:\x20{\x22args\x22:\x20[\x22databases\x22]}\x0a-\x20Run\x20SQL\x20query:\x20{\x22args\x22:\x20[\x22query\x22,\x20\x22SELECT\x20*\x20FROM\x20mydb.users\x20LIMIT\x2010\x22]}\x0a-\x20List\x20segments:\x20{\x22args\x22:\x20[\x22segments\x22,\x20\x22--recursive\x22]}\x0a-\x20Show\x20job\x20details:\x20{\x22args\x22:\x20[\x22job\x22,\x20\x22show\x22,\x20\x2212345\x22]}\x0a-\x20List\x20tables:\x20{\x22args\x22:\x20[\x22tables\x22,\x20\x22mydb.*\x22]}\x0a\x0aNote:\x20Some\x20commands\x20(auth,\x20profile\x20management,\x20mcp)\x20are\x20blocked\x20for\x20security.','stdin','optional','close','3755800oKBhEF','description','category','Search\x20for\x20relevant\x20tdx\x20commands\x20based\x20on\x20what\x20you\x20want\x20to\x20do.\x0a\x0aExamples:\x0a-\x20{\x22query\x22:\x20\x22how\x20to\x20run\x20SQL\x20queries\x22}\x0a-\x20{\x22query\x22:\x20\x22list\x20databases\x20and\x20tables\x22}\x0a-\x20{\x22query\x22:\x20\x22manage\x20customer\x20segments\x22,\x20\x22category\x22:\x20\x22CDP\x22}\x0a-\x20{\x22query\x22:\x20\x22workflow\x20logs\x22}\x0a\x0aCategories:\x20Data,\x20CDP,\x20AI,\x20Context,\x20Utilities\x0a\x0aReturns\x20matching\x20commands\x20with\x20descriptions\x20and\x20example\x20usage.','output','\x0a\x0aExamples:\x0a','once','Command\x20completed\x20successfully','success','Command\x20and\x20arguments\x20as\x20array\x20(e.g.,\x20[\x22query\x22,\x20\x22SELECT\x20...\x22])','6464490bNMiwB','SIGTERM','Utilities','SIGINT','tdx','error','env','tdx_search','string','24160BiRWlV','registerTool','1.0.0','Optional\x20filter\x20by\x20category','1271232ZqEPjF','CDP','41641FktMBr'];a57_0x1cfd=function(){return _0x4b549b;};return a57_0x1cfd();}import{executeTdxRun,searchCommands}from'./tools/index.js';export function createMCPServer(_0x6ad4b8={}){const _0x2849a7=a57_0x94d3,_0x176f5b=new McpServer({'name':_0x2849a7(0x216),'version':_0x2849a7(0x21d)});return _0x176f5b[_0x2849a7(0x21c)]('tdx_run',{'description':_0x2849a7(0x204),'inputSchema':{'args':z[_0x2849a7(0x201)](z['string']())[_0x2849a7(0x1fe)](_0x2849a7(0x211))}},async({args:_0x2a37fa})=>{const _0x51f655=_0x2849a7,_0x323044=await executeTdxRun({'args':_0x2a37fa},_0x6ad4b8[_0x51f655(0x218)]||{});return _0x323044[_0x51f655(0x210)]?{'content':[{'type':_0x51f655(0x1f7),'text':_0x323044[_0x51f655(0x20c)]||_0x51f655(0x20f)}]}:{'content':[{'type':'text','text':_0x323044[_0x51f655(0x217)]||_0x323044[_0x51f655(0x20c)]||'Command\x20failed'}],'isError':!![]};}),_0x176f5b[_0x2849a7(0x21c)](_0x2849a7(0x219),{'description':_0x2849a7(0x20b),'inputSchema':{'query':z[_0x2849a7(0x21a)]()['describe'](_0x2849a7(0x1f9)),'category':z[_0x2849a7(0x203)]([_0x2849a7(0x1f6),_0x2849a7(0x1f3),'AI',_0x2849a7(0x1f5),_0x2849a7(0x214)])[_0x2849a7(0x206)]()[_0x2849a7(0x1fe)](_0x2849a7(0x1f1))}},async({query:_0x3b813a,category:_0x234951})=>{const _0x11c53c=_0x2849a7,_0x5401e0=searchCommands({'query':_0x3b813a,'category':_0x234951});if(_0x5401e0['length']===0x0)return{'content':[{'type':_0x11c53c(0x1f7),'text':_0x11c53c(0x1f8)+_0x3b813a+'\x22'}]};const _0x3db621=_0x5401e0[_0x11c53c(0x1fa)](_0x515f99=>{const _0xb5ffc2=_0x11c53c,_0x386fad=_0x515f99['examples']['map'](_0x25538b=>'\x20\x20'+_0x25538b)['join']('\x0a');return'**'+_0x515f99['name']+'**\x20('+_0x515f99[_0xb5ffc2(0x20a)]+')\x0a'+_0x515f99[_0xb5ffc2(0x209)]+_0xb5ffc2(0x20d)+_0x386fad;})[_0x11c53c(0x1fc)]('\x0a\x0a---\x0a\x0a');return{'content':[{'type':_0x11c53c(0x1f7),'text':_0x3db621}]};}),_0x176f5b;}function a57_0x94d3(_0x2be5b0,_0x245130){_0x2be5b0=_0x2be5b0-0x1f1;const _0x1cfdcb=a57_0x1cfd();let _0x94d368=_0x1cfdcb[_0x2be5b0];return _0x94d368;}export async function startMCPServer(_0x5f4d2a={}){const _0x25ef20=createMCPServer(_0x5f4d2a),_0x2c4847=new StdioServerTransport();return await _0x25ef20['connect'](_0x2c4847),new Promise(_0x934aad=>{const _0x16de69=a57_0x94d3;let _0x24ceac=![];const _0x3cd9d9=async()=>{const _0x3f0d7d=a57_0x94d3;if(_0x24ceac)return;_0x24ceac=!![],await _0x25ef20[_0x3f0d7d(0x207)](),_0x934aad();};process[_0x16de69(0x20e)](_0x16de69(0x215),_0x3cd9d9),process[_0x16de69(0x20e)](_0x16de69(0x213),_0x3cd9d9),process[_0x16de69(0x205)][_0x16de69(0x20e)](_0x16de69(0x207),_0x3cd9d9);});}
|
package/dist/mcp/tools/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(_0x5b15a4,_0x27ce48){var _0x2c3796=a58_0x162a,_0x427250=_0x5b15a4();while(!![]){try{var _0x220094=parseInt(_0x2c3796(0x1e5))/0x1+parseInt(_0x2c3796(0x1e8))/0x2*(-parseInt(_0x2c3796(0x1ea))/0x3)+-parseInt(_0x2c3796(0x1e9))/0x4*(-parseInt(_0x2c3796(0x1e3))/0x5)+-parseInt(_0x2c3796(0x1e7))/0x6+-parseInt(_0x2c3796(0x1e4))/0x7+parseInt(_0x2c3796(0x1eb))/0x8+parseInt(_0x2c3796(0x1e6))/0x9;if(_0x220094===_0x27ce48)break;else _0x427250['push'](_0x427250['shift']());}catch(_0x45d669){_0x427250['push'](_0x427250['shift']());}}}(a58_0xa526,0x7ce3f));function a58_0x162a(_0x3297d3,_0x51a10c){_0x3297d3=_0x3297d3-0x1e3;var _0xa526fc=a58_0xa526();var _0x162a4f=_0xa526fc[_0x3297d3];return _0x162a4f;}export{executeTdxRun,TdxRunInputSchema}from'./tdx-run.js';export{searchCommands,TdxSearchInputSchema}from'./tdx-search.js';function a58_0xa526(){var _0x2c4922=['4OgWxHE','18888pbMJiF','6163240VRQpbc','4941035obKLBP','4222316FWqpvh','322640BzwfVe','1792521BaQyfj','1629900JzTOVg','284AzfazK'];a58_0xa526=function(){return _0x2c4922;};return a58_0xa526();}
|