@treasuredata/tdx 0.16.5 → 0.16.6
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.d.ts.map +1 -1
- package/dist/cli.js +1 -1
- package/dist/cli.js.map +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/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/claude-agent/claude-agent-client.d.ts +13 -0
- package/dist/sdk/claude-agent/claude-agent-client.d.ts.map +1 -1
- package/dist/sdk/claude-agent/claude-agent-client.js +1 -1
- package/dist/sdk/claude-agent/claude-agent-client.js.map +1 -1
- package/dist/sdk/claude-agent/environment.js +1 -1
- package/dist/sdk/claude-agent/index.js +1 -1
- package/dist/sdk/claude-agent/system-prompts.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/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/option-validation.js +1 -1
- package/dist/utils/port.js +1 -1
- package/dist/utils/process.d.ts +10 -0
- package/dist/utils/process.d.ts.map +1 -1
- package/dist/utils/process.js +1 -1
- package/dist/utils/process.js.map +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 a44_0x678239=a44_0x5c4a;(function(_0x390df1,_0x13e9f6){const _0x1d1a1e=a44_0x5c4a,_0x3b3dda=_0x390df1();while(!![]){try{const _0x68dffa=parseInt(_0x1d1a1e(0x126))/0x1+parseInt(_0x1d1a1e(0x143))/0x2*(-parseInt(_0x1d1a1e(0x125))/0x3)+-parseInt(_0x1d1a1e(0x11e))/0x4+-parseInt(_0x1d1a1e(0x147))/0x5*(-parseInt(_0x1d1a1e(0x108))/0x6)+-parseInt(_0x1d1a1e(0x124))/0x7*(parseInt(_0x1d1a1e(0x10c))/0x8)+parseInt(_0x1d1a1e(0x145))/0x9+parseInt(_0x1d1a1e(0x100))/0xa*(-parseInt(_0x1d1a1e(0x12d))/0xb);if(_0x68dffa===_0x13e9f6)break;else _0x3b3dda['push'](_0x3b3dda['shift']());}catch(_0x45dd7d){_0x3b3dda['push'](_0x3b3dda['shift']());}}}(a44_0x5e1f,0xd6381));import{homedir}from'os';import{join}from'path';import{existsSync,readFileSync,writeFileSync,mkdirSync,unlinkSync}from'fs';function a44_0x5e1f(){const _0x3a9e74=['config/llm-project','10491132fUltBv','map','jp01','some','184DICyqH','keychain','Warning:\x20Unknown\x20site\x20\x27','.config','eu01','isDeprecated','tdx.json','write','.env','filter','ap03','dev-us01','toISOString','config/llm-agent','stg-ap03','replace','join','site','6692048EzIAyC','keychain\x20(profile:\x20','\x20\x20For\x20profile-specific\x20keys,\x20use\x20TDX_API_KEY_<PROFILE>\x20(e.g.,\x20','.env.','env','stg-jp01','14847TVJhEi','15fGJlUj','736781MpHVLo','slice','toUpperCase','dev-eu01','Warning:\x20Failed\x20to\x20load\x20','warn','path','14392301xSXtcA','clear','read','parse','Warning:\x20Failed\x20to\x20read\x20config\x20file\x20','split','\x20env\x20var','⚠\x20Cleaned\x20up\x20API\x20keys\x20from\x20legacy\x20.env\x20file','llm_default_agent','\x27,\x20defaulting\x20to\x20us01','string','TD_API_KEY\x20env\x20var\x20(deprecated)','name','us01','readFileSync','endsWith','Warning:\x20Using\x20TD_API_KEY\x20is\x20deprecated.\x20Please\x20use\x20TDX_API_KEY\x20instead.\x0a','profiles','number','existsSync','legacy\x20.env\x20file\x20(profile:\x20','ap02','113494GaErrd','trim','15354531rMoDpk','config/account-info','5DRHNPw','includes','⚠\x20Failed\x20to\x20migrate\x20API\x20key\x20to\x20keychain:\x20','TDX_API_KEY_','TDX_API_KEY_<PROFILE>','yellow','apiKeys','startsWith','10PlLmJM','accountId','TD_API_KEY','match','utf-8','TDX_API_KEY\x20env\x20var','TDX_API_KEY'];a44_0x5e1f=function(){return _0x3a9e74;};return a44_0x5e1f();}function a44_0x5c4a(_0x385274,_0x1b47a8){_0x385274=_0x385274-0xf9;const _0x5e1fa4=a44_0x5e1f();let _0x5c4ab5=_0x5e1fa4[_0x385274];return _0x5c4ab5;}import*as a44_0x3c8810 from'node:fs';import*as a44_0x2237af 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 a44_0xac113b from'chalk';import{getGlobalCacheDir,createOptionalProfileCache}from'../utils/global-cache.js';export function getConfigDir(){const _0x1a8624=a44_0x5c4a;return process[_0x1a8624(0x122)]['TDX_CONFIG_DIR']||join(homedir(),_0x1a8624(0x10f),'tdx');}export function getConfigFile(){return join(getConfigDir(),'.env');}export function getConfigFilePath(_0x2936cf){const _0x29f68a=a44_0x5c4a,_0x2a2188=getConfigDir();return _0x2936cf?a44_0x2237af[_0x29f68a(0x11c)](_0x2a2188,'.env.'+_0x2936cf):getConfigFile();}export function getCacheDir(){return getGlobalCacheDir();}const llmProjectCache=createOptionalProfileCache('llm_default_project',a44_0x678239(0x107));export function getLLMProjectCacheFile(_0x477df3){const _0x487f8d=a44_0x678239;return llmProjectCache[_0x487f8d(0x12c)](_0x477df3);}export function readCachedLLMProject(_0x3570f1){const _0x5b9693=a44_0x678239,_0x287873=llmProjectCache['read'](_0x3570f1);if(_0x287873&&typeof _0x287873['id']===_0x5b9693(0x137)&&typeof _0x287873[_0x5b9693(0x139)]==='string')return _0x287873;return null;}export function writeCachedLLMProject(_0x1bd2bc,_0x59fbe0,_0x1103de){const _0x5f1f88=a44_0x678239;try{llmProjectCache[_0x5f1f88(0x113)]({'name':_0x1bd2bc,'id':_0x59fbe0},_0x1103de);}catch{}}const llmAgentCache=createOptionalProfileCache(a44_0x678239(0x135),a44_0x678239(0x119));export function getLLMAgentCacheFile(_0x41c871){const _0x31fc76=a44_0x678239;return llmAgentCache[_0x31fc76(0x12c)](_0x41c871);}export function readCachedLLMAgent(_0x96586a){const _0x2f60af=a44_0x678239,_0x5bd5f7=llmAgentCache[_0x2f60af(0x12f)](_0x96586a);if(_0x5bd5f7&&typeof _0x5bd5f7['id']==='string'&&typeof _0x5bd5f7[_0x2f60af(0x139)]===_0x2f60af(0x137)&&typeof _0x5bd5f7['projectId']===_0x2f60af(0x137))return _0x5bd5f7;return null;}export function writeCachedLLMAgent(_0x4b082f,_0x352577,_0x544b64,_0x39bdb2){const _0x5e8aa3=a44_0x678239;try{llmAgentCache[_0x5e8aa3(0x113)]({'name':_0x4b082f,'id':_0x352577,'projectId':_0x544b64},_0x39bdb2);}catch{}}export function clearCachedLLMAgent(_0x5f2dbe){const _0x5d13ea=a44_0x678239;try{llmAgentCache[_0x5d13ea(0x12e)](_0x5f2dbe);}catch{}}const accountInfoCache=createOptionalProfileCache('account_info',a44_0x678239(0x146),{'suffix':'.json'});export function getAccountInfoCacheFile(_0x93b3e){return accountInfoCache['path'](_0x93b3e);}export function readCachedAccountInfo(_0x34bb3e){const _0x1b2e78=a44_0x678239,_0xde353e=accountInfoCache[_0x1b2e78(0x12f)](_0x34bb3e);if(_0xde353e&&typeof _0xde353e[_0x1b2e78(0x11d)]===_0x1b2e78(0x137)&&typeof _0xde353e[_0x1b2e78(0x101)]===_0x1b2e78(0x13f))return _0xde353e;return null;}export function writeCachedAccountInfo(_0x2fdec1,_0x24e648,_0x4986d1){const _0x41e936=a44_0x678239;try{accountInfoCache[_0x41e936(0x113)]({'site':_0x2fdec1,'accountId':_0x24e648,'cachedAt':new Date()[_0x41e936(0x118)]()},_0x4986d1);}catch{}}export function parseEnvFile(_0x3dd964){const _0x33c047=a44_0x678239,_0x2c81a1={};for(const _0x51e333 of _0x3dd964[_0x33c047(0x132)]('\x0a')){const _0x38abad=_0x51e333[_0x33c047(0x144)]();if(!_0x38abad||_0x38abad[_0x33c047(0xff)]('#'))continue;const _0x586029=_0x38abad[_0x33c047(0x103)](/^([^=]+)=(.*)$/);if(_0x586029){const _0x1a9c16=_0x586029[0x1][_0x33c047(0x144)]();let _0x152644=_0x586029[0x2]['trim']();(_0x152644[_0x33c047(0xff)]('\x22')&&_0x152644['endsWith']('\x22')||_0x152644[_0x33c047(0xff)]('\x27')&&_0x152644[_0x33c047(0x13c)]('\x27'))&&(_0x152644=_0x152644[_0x33c047(0x127)](0x1,-0x1)),_0x2c81a1[_0x1a9c16]=_0x152644;}}return _0x2c81a1;}export function readUserConfig(){const _0x502341=a44_0x678239,_0x171873=getConfigFile();if(!existsSync(_0x171873))return{};try{const _0x5db0fa=readFileSync(_0x171873,_0x502341(0x104));return parseEnvFile(_0x5db0fa);}catch(_0x21ba7b){return console[_0x502341(0x12b)](_0x502341(0x131)+_0x171873+':',_0x21ba7b),{};}}export function resolveSite(_0x290ee1){const _0x76976d=a44_0x678239,_0x140dc8=[_0x76976d(0x13a),_0x76976d(0x10a),_0x76976d(0x110),_0x76976d(0x142),_0x76976d(0x116),_0x76976d(0x117),'dev-eu01','stg-us01',_0x76976d(0x123),_0x76976d(0x11a)];if(_0x140dc8[_0x76976d(0xf9)](_0x290ee1))return _0x290ee1;if(_0x290ee1 in SITE_ALIASES)return SITE_ALIASES[_0x290ee1];return console['warn'](_0x76976d(0x10e)+_0x290ee1+_0x76976d(0x136)),_0x76976d(0x13a);}let cachedUserConfig=null;export function loadUserConfigOnce(){return cachedUserConfig===null&&(cachedUserConfig=readUserConfig()),cachedUserConfig;}export function clearConfigCache(){cachedUserConfig=null;}export function getAPIKey(_0x4d6ad9,_0xdb1abb){const _0x4906f7=a44_0x678239,_0x2278a4=_0xdb1abb||getActiveProfileName();if(_0x2278a4){const _0x353b00='TDX_API_KEY_'+normalizeProfileForEnvVar(_0x2278a4);if(process[_0x4906f7(0x122)][_0x353b00])return process[_0x4906f7(0x122)][_0x353b00];}if(process[_0x4906f7(0x122)][_0x4906f7(0x106)])return process[_0x4906f7(0x122)][_0x4906f7(0x106)];if(process[_0x4906f7(0x122)][_0x4906f7(0x102)])return process['env'][_0x4906f7(0x102)];const _0x5a1b52=_0x4d6ad9[_0x4906f7(0x128)]()[_0x4906f7(0x11b)](/-/g,'_'),_0xc9160b='TD_API_KEY_'+_0x5a1b52;if(_0x2278a4){const _0x24cc53=loadProfileEnv(_0x2278a4);if(_0x24cc53){if(_0x24cc53[_0xc9160b])return _0x24cc53[_0xc9160b];if(_0x24cc53[_0x4906f7(0x102)])return _0x24cc53[_0x4906f7(0x102)];}}const _0x2923c3=loadUserConfigOnce();if(_0x2923c3[_0xc9160b])return _0x2923c3[_0xc9160b];if(_0x2923c3[_0x4906f7(0x102)])return _0x2923c3[_0x4906f7(0x102)];return undefined;}export function normalizeProfileForEnvVar(_0x4c601f){const _0x5a28ae=a44_0x678239;return _0x4c601f[_0x5a28ae(0x128)]()['replace'](/[^A-Z0-9]/g,'_');}export async function resolveAPIKeyAsync(_0x264abe,_0x257ee0){const _0x1ae731=a44_0x678239,_0x260e5e=_0x257ee0||getActiveProfileName()||undefined;if(_0x260e5e){const _0x3f209b=_0x1ae731(0xfb)+normalizeProfileForEnvVar(_0x260e5e);if(process['env'][_0x3f209b])return{'apiKey':process[_0x1ae731(0x122)][_0x3f209b],'source':_0x3f209b+_0x1ae731(0x133),'isDeprecated':![]};const _0x1b8844=getCachedCredential(_0x264abe,_0x260e5e);if(_0x1b8844)return{'apiKey':_0x1b8844,'source':_0x1ae731(0x11f)+_0x260e5e+')','isDeprecated':![]};const _0x31cc05=await getKeychainAPIKey(_0x260e5e);if(_0x31cc05)return setCachedCredential(_0x31cc05,_0x264abe,_0x260e5e),{'apiKey':_0x31cc05,'source':_0x1ae731(0x11f)+_0x260e5e+')','isDeprecated':![]};}if(process['env']['TDX_API_KEY'])return{'apiKey':process[_0x1ae731(0x122)][_0x1ae731(0x106)],'source':_0x1ae731(0x105),'isDeprecated':![]};if(!_0x260e5e){const _0x5da2b1=getCachedCredential(_0x264abe,undefined);if(_0x5da2b1)return{'apiKey':_0x5da2b1,'source':_0x1ae731(0x10d),'isDeprecated':![]};const _0x2e0d62=await getKeychainAPIKey(undefined);if(_0x2e0d62)return setCachedCredential(_0x2e0d62,_0x264abe,undefined),{'apiKey':_0x2e0d62,'source':_0x1ae731(0x10d),'isDeprecated':![]};}if(process[_0x1ae731(0x122)]['TD_API_KEY'])return{'apiKey':process[_0x1ae731(0x122)][_0x1ae731(0x102)],'source':_0x1ae731(0x138),'isDeprecated':!![]};const _0xa174e7=getLegacyEnvAPIKey(_0x264abe,_0x260e5e);if(_0xa174e7){const _0x5790e0=await isKeychainAvailable();if(_0x5790e0)try{await saveKeychainAPIKey(_0xa174e7,_0x260e5e),setCachedCredential(_0xa174e7,_0x264abe,_0x260e5e);const _0x30bd1c=getConfigFilePath(_0x260e5e);cleanupLegacyEnvFile(_0x30bd1c)&&console[_0x1ae731(0x12b)](a44_0xac113b['yellow']('⚠\x20Migrated\x20API\x20key\x20from\x20.env\x20to\x20secure\x20keychain\x20storage'));}catch(_0x4181b3){console[_0x1ae731(0x12b)](a44_0xac113b[_0x1ae731(0xfd)](_0x1ae731(0xfa)+_0x4181b3));}const _0x34096b=_0x260e5e?_0x1ae731(0x141)+_0x260e5e+')':'legacy\x20.env\x20file';return{'apiKey':_0xa174e7,'source':_0x34096b,'isDeprecated':!![]};}return null;}export async function getAPIKeyAsync(_0x92d5f,_0x1a7b1a,_0x1caba1=!![]){const _0x3b3da2=a44_0x678239,_0x515cc1=await resolveAPIKeyAsync(_0x92d5f,_0x1a7b1a);if(!_0x515cc1)return undefined;if(_0x1caba1&&_0x515cc1[_0x3b3da2(0x111)]&&_0x515cc1['source'][_0x3b3da2(0xf9)](_0x3b3da2(0x102))){const _0x35ca28=_0x1a7b1a||getActiveProfileName()||undefined,_0x266eae=_0x35ca28?'TDX_API_KEY_'+normalizeProfileForEnvVar(_0x35ca28):_0x3b3da2(0xfc);console['warn'](a44_0xac113b[_0x3b3da2(0xfd)](_0x3b3da2(0x13d)+(_0x3b3da2(0x120)+_0x266eae+').')));}return _0x515cc1['apiKey'];}function getLegacyEnvAPIKey(_0x380f89,_0x2b047b){const _0xfaace4=a44_0x678239,_0x5f0066=_0x380f89[_0xfaace4(0x128)]()[_0xfaace4(0x11b)](/-/g,'_'),_0x51487b='TD_API_KEY_'+_0x5f0066;if(_0x2b047b){const _0x4acc01=loadProfileEnv(_0x2b047b);if(_0x4acc01){if(_0x4acc01[_0x51487b])return _0x4acc01[_0x51487b];if(_0x4acc01[_0xfaace4(0x102)])return _0x4acc01[_0xfaace4(0x102)];}}const _0x51960a=loadUserConfigOnce();if(_0x51960a[_0x51487b])return _0x51960a[_0x51487b];if(_0x51960a[_0xfaace4(0x102)])return _0x51960a['TD_API_KEY'];return undefined;}function cleanupLegacyEnvFile(_0x55b0e0){const _0x100cf2=a44_0x678239;if(!existsSync(_0x55b0e0))return![];try{const _0xe3a9ed=readFileSync(_0x55b0e0,'utf-8'),_0x5acf3b=_0xe3a9ed[_0x100cf2(0x132)]('\x0a'),_0x39caf1=_0x5acf3b[_0x100cf2(0x115)](_0x35f40c=>{const _0x316cb3=_0x100cf2,_0x294185=_0x35f40c[_0x316cb3(0x144)]();if(!_0x294185||_0x294185[_0x316cb3(0xff)]('#'))return!![];const [_0x5c100f]=_0x294185[_0x316cb3(0x132)]('=');return!_0x5c100f['startsWith'](_0x316cb3(0x102));}),_0x64bb95=_0x39caf1[_0x100cf2(0x10b)](_0x4092a2=>{const _0x19ecfa=_0x100cf2,_0x17e872=_0x4092a2[_0x19ecfa(0x144)]();return _0x17e872&&!_0x17e872[_0x19ecfa(0xff)]('#');});if(!_0x64bb95)return unlinkSync(_0x55b0e0),!![];return writeFileSync(_0x55b0e0,_0x39caf1['join']('\x0a'),{'mode':0x180}),!![];}catch{return![];}}function loadProfileEnv(_0x146f08){const _0x122e39=a44_0x678239,_0x5da677=a44_0x2237af[_0x122e39(0x11c)](getConfigDir(),_0x122e39(0x121)+_0x146f08);if(a44_0x3c8810[_0x122e39(0x140)](_0x5da677)){validateSecureFilePermissions(_0x5da677);try{const _0x4d36bb=a44_0x3c8810[_0x122e39(0x13b)](_0x5da677,_0x122e39(0x104));return parseEnvFile(_0x4d36bb);}catch(_0x24a42b){console[_0x122e39(0x12b)]('Warning:\x20Failed\x20to\x20load\x20'+_0x5da677+':\x20'+_0x24a42b);}}const _0x12c5ea=a44_0x2237af['join'](getConfigDir(),_0x122e39(0x13e),_0x146f08,_0x122e39(0x114));if(a44_0x3c8810[_0x122e39(0x140)](_0x12c5ea)){validateSecureFilePermissions(_0x12c5ea);try{const _0x126f67=a44_0x3c8810[_0x122e39(0x13b)](_0x12c5ea,_0x122e39(0x104));return parseEnvFile(_0x126f67);}catch(_0x457d24){return console[_0x122e39(0x12b)](_0x122e39(0x12a)+_0x12c5ea+':\x20'+_0x457d24),null;}}return null;}function getActiveProfileName(){const _0x42cec2=a44_0x678239,_0x4bd9aa=a44_0x2237af['join'](getConfigDir(),_0x42cec2(0x112));if(!a44_0x3c8810[_0x42cec2(0x140)](_0x4bd9aa))return null;try{const _0x45f412=a44_0x3c8810[_0x42cec2(0x13b)](_0x4bd9aa,_0x42cec2(0x104)),_0x2b26b5=JSON[_0x42cec2(0x130)](_0x45f412);return _0x2b26b5['profile']||null;}catch{return null;}}export function saveAPIKey(_0x360fce,_0x597517,_0x410bbc){const _0x1481e5=a44_0x678239,_0x521aff=getConfigDir(),_0x2e4c2e=getConfigFilePath(_0x410bbc);!existsSync(_0x521aff)&&mkdirSync(_0x521aff,{'recursive':!![],'mode':0x1c0});let _0x408011={};if(existsSync(_0x2e4c2e))try{const _0x5d2488=readFileSync(_0x2e4c2e,_0x1481e5(0x104));_0x408011=parseEnvFile(_0x5d2488);}catch(_0x1503ee){console[_0x1481e5(0x12b)]('Warning:\x20Failed\x20to\x20read\x20'+_0x2e4c2e+':',_0x1503ee);}const _0x1d1641=_0x360fce[_0x1481e5(0x128)]()[_0x1481e5(0x11b)](/-/g,'_');_0x408011['TD_API_KEY_'+_0x1d1641]=_0x597517;const _0x2c2fd4=Object['entries'](_0x408011)[_0x1481e5(0x109)](([_0x5f5542,_0x1daf35])=>_0x5f5542+'='+_0x1daf35);writeFileSync(_0x2e4c2e,_0x2c2fd4[_0x1481e5(0x11c)]('\x0a')+'\x0a',{'mode':0x180});}export async function saveAPIKeyAsync(_0xd5330c,_0x13e20f,_0x10b47b){const _0xde8449=a44_0x678239;await saveKeychainAPIKey(_0xd5330c,_0x10b47b),setCachedCredential(_0xd5330c,_0x13e20f,_0x10b47b);const _0x1a2b63=getConfigFilePath(_0x10b47b);cleanupLegacyEnvFile(_0x1a2b63)&&console['warn'](a44_0xac113b['yellow'](_0xde8449(0x134)));}export function loadConfig(){const _0x2c39c0=a44_0x678239,_0xe2005={'apiKeys':{},'defaultSite':'us01'},_0x449449=[_0x2c39c0(0x13a),_0x2c39c0(0x10a),'eu01',_0x2c39c0(0x142),_0x2c39c0(0x116),_0x2c39c0(0x117),_0x2c39c0(0x129),'stg-us01',_0x2c39c0(0x123),_0x2c39c0(0x11a)];for(const _0x439dc3 of _0x449449){const _0x471cb9=getAPIKey(_0x439dc3);_0x471cb9&&(_0xe2005[_0x2c39c0(0xfe)][_0x439dc3]=_0x471cb9);}return _0xe2005;}
|
|
1
|
+
const a44_0x38d491=a44_0xfecb;function a44_0x2d3c(){const _0x465092=['TDX_API_KEY_','split','TD_API_KEY\x20env\x20var\x20(deprecated)','env','.env','jp01','some','⚠\x20Migrated\x20API\x20key\x20from\x20.env\x20to\x20secure\x20keychain\x20storage','us01','parse','apiKeys','projectId','startsWith','stg-ap03','TDX_API_KEY_<PROFILE>','replace','utf-8','TDX_API_KEY\x20env\x20var','profile','1198671CzdwiK','Warning:\x20Failed\x20to\x20read\x20config\x20file\x20','3696978rLNWtE','TDX_CONFIG_DIR','2632520lvROKl','272XZIJdx','\x20env\x20var','TD_API_KEY','914715FNuqZl','.config','toUpperCase','keychain','entries','number','yellow','eu01','site','TDX_API_KEY','stg-jp01','warn','\x20\x20For\x20profile-specific\x20keys,\x20use\x20TDX_API_KEY_<PROFILE>\x20(e.g.,\x20','⚠\x20Cleaned\x20up\x20API\x20keys\x20from\x20legacy\x20.env\x20file','⚠\x20Failed\x20to\x20migrate\x20API\x20key\x20to\x20keychain:\x20','match','profiles','legacy\x20.env\x20file\x20(profile:\x20','\x27,\x20defaulting\x20to\x20us01','apiKey','config/account-info','name','TD_API_KEY_','ap03','Warning:\x20Failed\x20to\x20load\x20','config/llm-project','legacy\x20.env\x20file','Warning:\x20Using\x20TD_API_KEY\x20is\x20deprecated.\x20Please\x20use\x20TDX_API_KEY\x20instead.\x0a','Warning:\x20Failed\x20to\x20read\x20','string','ap02','stg-us01','5DLZLji','accountId','.json','endsWith','tdx','existsSync','2665722FxfDKG','includes','Warning:\x20Unknown\x20site\x20\x27','.env.','path','toISOString','join','dev-eu01','tdx.json','readFileSync','2678752stWBuC','4835362qrcjme','filter','write','keychain\x20(profile:\x20','read','map','source','trim'];a44_0x2d3c=function(){return _0x465092;};return a44_0x2d3c();}(function(_0x184e5c,_0x242fd5){const _0x5d931c=a44_0xfecb,_0xb9cd3e=_0x184e5c();while(!![]){try{const _0x4437b4=parseInt(_0x5d931c(0xc2))/0x1+parseInt(_0x5d931c(0xc6))/0x2+parseInt(_0x5d931c(0xc4))/0x3+-parseInt(_0x5d931c(0xa6))/0x4+parseInt(_0x5d931c(0x96))/0x5*(parseInt(_0x5d931c(0x9c))/0x6)+parseInt(_0x5d931c(0xa7))/0x7+-parseInt(_0x5d931c(0xc7))/0x8*(parseInt(_0x5d931c(0xca))/0x9);if(_0x4437b4===_0x242fd5)break;else _0xb9cd3e['push'](_0xb9cd3e['shift']());}catch(_0x345b1c){_0xb9cd3e['push'](_0xb9cd3e['shift']());}}}(a44_0x2d3c,0xb8d28));import{homedir}from'os';function a44_0xfecb(_0x107878,_0x5dae3e){_0x107878=_0x107878-0x88;const _0x2d3cbc=a44_0x2d3c();let _0xfecb9=_0x2d3cbc[_0x107878];return _0xfecb9;}import{join}from'path';import{existsSync,readFileSync,writeFileSync,mkdirSync,unlinkSync}from'fs';import*as a44_0x236c5f from'node:fs';import*as a44_0x337d15 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 a44_0x5d5bac from'chalk';import{getGlobalCacheDir,createOptionalProfileCache}from'../utils/global-cache.js';export function getConfigDir(){const _0x114b78=a44_0xfecb;return process[_0x114b78(0xb2)][_0x114b78(0xc5)]||join(homedir(),_0x114b78(0xcb),_0x114b78(0x9a));}export function getConfigFile(){return join(getConfigDir(),'.env');}export function getConfigFilePath(_0xfd17fb){const _0x4e095b=a44_0xfecb,_0x5f55b9=getConfigDir();return _0xfd17fb?a44_0x337d15[_0x4e095b(0xa2)](_0x5f55b9,_0x4e095b(0x9f)+_0xfd17fb):getConfigFile();}export function getCacheDir(){return getGlobalCacheDir();}const llmProjectCache=createOptionalProfileCache('llm_default_project',a44_0x38d491(0x8f));export function getLLMProjectCacheFile(_0xa57b0c){return llmProjectCache['path'](_0xa57b0c);}export function readCachedLLMProject(_0x4d7c8d){const _0x2f25f6=a44_0x38d491,_0x2da348=llmProjectCache[_0x2f25f6(0xab)](_0x4d7c8d);if(_0x2da348&&typeof _0x2da348['id']===_0x2f25f6(0x93)&&typeof _0x2da348[_0x2f25f6(0x8b)]===_0x2f25f6(0x93))return _0x2da348;return null;}export function writeCachedLLMProject(_0x538ee6,_0x279e5d,_0x36ae47){const _0x3d3836=a44_0x38d491;try{llmProjectCache[_0x3d3836(0xa9)]({'name':_0x538ee6,'id':_0x279e5d},_0x36ae47);}catch{}}const llmAgentCache=createOptionalProfileCache('llm_default_agent','config/llm-agent');export function getLLMAgentCacheFile(_0xa16509){return llmAgentCache['path'](_0xa16509);}export function readCachedLLMAgent(_0x5cb17b){const _0x9b3e02=a44_0x38d491,_0x28ab96=llmAgentCache['read'](_0x5cb17b);if(_0x28ab96&&typeof _0x28ab96['id']===_0x9b3e02(0x93)&&typeof _0x28ab96[_0x9b3e02(0x8b)]===_0x9b3e02(0x93)&&typeof _0x28ab96[_0x9b3e02(0xba)]==='string')return _0x28ab96;return null;}export function writeCachedLLMAgent(_0x1a4621,_0x5396d6,_0xaf2b0d,_0x39c4c3){const _0x1c6cd9=a44_0x38d491;try{llmAgentCache[_0x1c6cd9(0xa9)]({'name':_0x1a4621,'id':_0x5396d6,'projectId':_0xaf2b0d},_0x39c4c3);}catch{}}export function clearCachedLLMAgent(_0x522e82){try{llmAgentCache['clear'](_0x522e82);}catch{}}const accountInfoCache=createOptionalProfileCache('account_info',a44_0x38d491(0x8a),{'suffix':a44_0x38d491(0x98)});export function getAccountInfoCacheFile(_0x57427a){const _0x1cc5ca=a44_0x38d491;return accountInfoCache[_0x1cc5ca(0xa0)](_0x57427a);}export function readCachedAccountInfo(_0x1fdcea){const _0x9b0c45=a44_0x38d491,_0x4aa400=accountInfoCache['read'](_0x1fdcea);if(_0x4aa400&&typeof _0x4aa400[_0x9b0c45(0xd2)]===_0x9b0c45(0x93)&&typeof _0x4aa400[_0x9b0c45(0x97)]===_0x9b0c45(0xcf))return _0x4aa400;return null;}export function writeCachedAccountInfo(_0x1f3c6d,_0x21beed,_0x43a528){const _0x361596=a44_0x38d491;try{accountInfoCache[_0x361596(0xa9)]({'site':_0x1f3c6d,'accountId':_0x21beed,'cachedAt':new Date()[_0x361596(0xa1)]()},_0x43a528);}catch{}}export function parseEnvFile(_0x48f445){const _0x502a1c=a44_0x38d491,_0x327bae={};for(const _0x5f28fc of _0x48f445['split']('\x0a')){const _0x5290d6=_0x5f28fc[_0x502a1c(0xae)]();if(!_0x5290d6||_0x5290d6[_0x502a1c(0xbb)]('#'))continue;const _0x349755=_0x5290d6[_0x502a1c(0xd9)](/^([^=]+)=(.*)$/);if(_0x349755){const _0xc68609=_0x349755[0x1][_0x502a1c(0xae)]();let _0x59eeaf=_0x349755[0x2][_0x502a1c(0xae)]();(_0x59eeaf[_0x502a1c(0xbb)]('\x22')&&_0x59eeaf[_0x502a1c(0x99)]('\x22')||_0x59eeaf['startsWith']('\x27')&&_0x59eeaf[_0x502a1c(0x99)]('\x27'))&&(_0x59eeaf=_0x59eeaf['slice'](0x1,-0x1)),_0x327bae[_0xc68609]=_0x59eeaf;}}return _0x327bae;}export function readUserConfig(){const _0x4f8669=a44_0x38d491,_0x5c7223=getConfigFile();if(!existsSync(_0x5c7223))return{};try{const _0x5eca10=readFileSync(_0x5c7223,_0x4f8669(0xbf));return parseEnvFile(_0x5eca10);}catch(_0x4289e){return console['warn'](_0x4f8669(0xc3)+_0x5c7223+':',_0x4289e),{};}}export function resolveSite(_0x669e1f){const _0x463a9c=a44_0x38d491,_0x3118ef=[_0x463a9c(0xb7),_0x463a9c(0xb4),_0x463a9c(0xd1),_0x463a9c(0x94),_0x463a9c(0x8d),'dev-us01',_0x463a9c(0xa3),_0x463a9c(0x95),'stg-jp01','stg-ap03'];if(_0x3118ef[_0x463a9c(0x9d)](_0x669e1f))return _0x669e1f;if(_0x669e1f in SITE_ALIASES)return SITE_ALIASES[_0x669e1f];return console[_0x463a9c(0xd5)](_0x463a9c(0x9e)+_0x669e1f+_0x463a9c(0x88)),'us01';}let cachedUserConfig=null;export function loadUserConfigOnce(){return cachedUserConfig===null&&(cachedUserConfig=readUserConfig()),cachedUserConfig;}export function clearConfigCache(){cachedUserConfig=null;}export function getAPIKey(_0x17abdf,_0x3c350c){const _0x271f7a=a44_0x38d491,_0x44c23d=_0x3c350c||getActiveProfileName();if(_0x44c23d){const _0xe1c268=_0x271f7a(0xaf)+normalizeProfileForEnvVar(_0x44c23d);if(process[_0x271f7a(0xb2)][_0xe1c268])return process[_0x271f7a(0xb2)][_0xe1c268];}if(process[_0x271f7a(0xb2)][_0x271f7a(0xd3)])return process['env']['TDX_API_KEY'];if(process[_0x271f7a(0xb2)][_0x271f7a(0xc9)])return process[_0x271f7a(0xb2)][_0x271f7a(0xc9)];const _0x1a176a=_0x17abdf['toUpperCase']()[_0x271f7a(0xbe)](/-/g,'_'),_0x72d365=_0x271f7a(0x8c)+_0x1a176a;if(_0x44c23d){const _0x5c5c68=loadProfileEnv(_0x44c23d);if(_0x5c5c68){if(_0x5c5c68[_0x72d365])return _0x5c5c68[_0x72d365];if(_0x5c5c68[_0x271f7a(0xc9)])return _0x5c5c68['TD_API_KEY'];}}const _0xa103de=loadUserConfigOnce();if(_0xa103de[_0x72d365])return _0xa103de[_0x72d365];if(_0xa103de[_0x271f7a(0xc9)])return _0xa103de[_0x271f7a(0xc9)];return undefined;}export function normalizeProfileForEnvVar(_0x418224){const _0x417c56=a44_0x38d491;return _0x418224[_0x417c56(0xcc)]()[_0x417c56(0xbe)](/[^A-Z0-9]/g,'_');}export async function resolveAPIKeyAsync(_0x3067ab,_0x4597cb){const _0x5e1fd0=a44_0x38d491,_0x18e2af=_0x4597cb||getActiveProfileName()||undefined;if(_0x18e2af){const _0x1e4e49='TDX_API_KEY_'+normalizeProfileForEnvVar(_0x18e2af);if(process[_0x5e1fd0(0xb2)][_0x1e4e49])return{'apiKey':process[_0x5e1fd0(0xb2)][_0x1e4e49],'source':_0x1e4e49+_0x5e1fd0(0xc8),'isDeprecated':![]};const _0x14bb05=getCachedCredential(_0x3067ab,_0x18e2af);if(_0x14bb05)return{'apiKey':_0x14bb05,'source':_0x5e1fd0(0xaa)+_0x18e2af+')','isDeprecated':![]};const _0x572b71=await getKeychainAPIKey(_0x18e2af);if(_0x572b71)return setCachedCredential(_0x572b71,_0x3067ab,_0x18e2af),{'apiKey':_0x572b71,'source':_0x5e1fd0(0xaa)+_0x18e2af+')','isDeprecated':![]};}if(process[_0x5e1fd0(0xb2)][_0x5e1fd0(0xd3)])return{'apiKey':process[_0x5e1fd0(0xb2)][_0x5e1fd0(0xd3)],'source':_0x5e1fd0(0xc0),'isDeprecated':![]};if(!_0x18e2af){const _0xfb215c=getCachedCredential(_0x3067ab,undefined);if(_0xfb215c)return{'apiKey':_0xfb215c,'source':_0x5e1fd0(0xcd),'isDeprecated':![]};const _0x60c203=await getKeychainAPIKey(undefined);if(_0x60c203)return setCachedCredential(_0x60c203,_0x3067ab,undefined),{'apiKey':_0x60c203,'source':'keychain','isDeprecated':![]};}if(process[_0x5e1fd0(0xb2)]['TD_API_KEY'])return{'apiKey':process[_0x5e1fd0(0xb2)][_0x5e1fd0(0xc9)],'source':_0x5e1fd0(0xb1),'isDeprecated':!![]};const _0x3bf775=getLegacyEnvAPIKey(_0x3067ab,_0x18e2af);if(_0x3bf775){const _0x584cd4=await isKeychainAvailable();if(_0x584cd4)try{await saveKeychainAPIKey(_0x3bf775,_0x18e2af),setCachedCredential(_0x3bf775,_0x3067ab,_0x18e2af);const _0x124799=getConfigFilePath(_0x18e2af);cleanupLegacyEnvFile(_0x124799)&&console[_0x5e1fd0(0xd5)](a44_0x5d5bac[_0x5e1fd0(0xd0)](_0x5e1fd0(0xb6)));}catch(_0x22709e){console[_0x5e1fd0(0xd5)](a44_0x5d5bac['yellow'](_0x5e1fd0(0xd8)+_0x22709e));}const _0x4fbe6e=_0x18e2af?_0x5e1fd0(0xdb)+_0x18e2af+')':_0x5e1fd0(0x90);return{'apiKey':_0x3bf775,'source':_0x4fbe6e,'isDeprecated':!![]};}return null;}export async function getAPIKeyAsync(_0x161113,_0x2d3629,_0x22a319=!![]){const _0x55e20a=a44_0x38d491,_0x30e976=await resolveAPIKeyAsync(_0x161113,_0x2d3629);if(!_0x30e976)return undefined;if(_0x22a319&&_0x30e976['isDeprecated']&&_0x30e976[_0x55e20a(0xad)][_0x55e20a(0x9d)](_0x55e20a(0xc9))){const _0x4616f2=_0x2d3629||getActiveProfileName()||undefined,_0x194643=_0x4616f2?_0x55e20a(0xaf)+normalizeProfileForEnvVar(_0x4616f2):_0x55e20a(0xbd);console[_0x55e20a(0xd5)](a44_0x5d5bac['yellow'](_0x55e20a(0x91)+(_0x55e20a(0xd6)+_0x194643+').')));}return _0x30e976[_0x55e20a(0x89)];}function getLegacyEnvAPIKey(_0x5a49fa,_0xea8d47){const _0x2a7950=a44_0x38d491,_0x1edcf3=_0x5a49fa[_0x2a7950(0xcc)]()[_0x2a7950(0xbe)](/-/g,'_'),_0x242d1a='TD_API_KEY_'+_0x1edcf3;if(_0xea8d47){const _0x14710e=loadProfileEnv(_0xea8d47);if(_0x14710e){if(_0x14710e[_0x242d1a])return _0x14710e[_0x242d1a];if(_0x14710e[_0x2a7950(0xc9)])return _0x14710e['TD_API_KEY'];}}const _0x146a0a=loadUserConfigOnce();if(_0x146a0a[_0x242d1a])return _0x146a0a[_0x242d1a];if(_0x146a0a[_0x2a7950(0xc9)])return _0x146a0a[_0x2a7950(0xc9)];return undefined;}function cleanupLegacyEnvFile(_0x3ac2bc){const _0x214f5e=a44_0x38d491;if(!existsSync(_0x3ac2bc))return![];try{const _0x30381d=readFileSync(_0x3ac2bc,_0x214f5e(0xbf)),_0x458906=_0x30381d[_0x214f5e(0xb0)]('\x0a'),_0x463f5b=_0x458906[_0x214f5e(0xa8)](_0x5dd0a1=>{const _0x1b1ab0=_0x214f5e,_0x1528fd=_0x5dd0a1[_0x1b1ab0(0xae)]();if(!_0x1528fd||_0x1528fd[_0x1b1ab0(0xbb)]('#'))return!![];const [_0x41cc41]=_0x1528fd[_0x1b1ab0(0xb0)]('=');return!_0x41cc41[_0x1b1ab0(0xbb)](_0x1b1ab0(0xc9));}),_0x4f7183=_0x463f5b[_0x214f5e(0xb5)](_0x46fdd6=>{const _0x46040e=_0x214f5e,_0x5bfb7f=_0x46fdd6[_0x46040e(0xae)]();return _0x5bfb7f&&!_0x5bfb7f[_0x46040e(0xbb)]('#');});if(!_0x4f7183)return unlinkSync(_0x3ac2bc),!![];return writeFileSync(_0x3ac2bc,_0x463f5b['join']('\x0a'),{'mode':0x180}),!![];}catch{return![];}}function loadProfileEnv(_0xced4e8){const _0x4cd62d=a44_0x38d491,_0x3e1be2=a44_0x337d15[_0x4cd62d(0xa2)](getConfigDir(),_0x4cd62d(0x9f)+_0xced4e8);if(a44_0x236c5f[_0x4cd62d(0x9b)](_0x3e1be2)){validateSecureFilePermissions(_0x3e1be2);try{const _0x59547e=a44_0x236c5f[_0x4cd62d(0xa5)](_0x3e1be2,'utf-8');return parseEnvFile(_0x59547e);}catch(_0x56d633){console[_0x4cd62d(0xd5)](_0x4cd62d(0x8e)+_0x3e1be2+':\x20'+_0x56d633);}}const _0x20729f=a44_0x337d15[_0x4cd62d(0xa2)](getConfigDir(),_0x4cd62d(0xda),_0xced4e8,_0x4cd62d(0xb3));if(a44_0x236c5f[_0x4cd62d(0x9b)](_0x20729f)){validateSecureFilePermissions(_0x20729f);try{const _0x38dc6f=a44_0x236c5f[_0x4cd62d(0xa5)](_0x20729f,'utf-8');return parseEnvFile(_0x38dc6f);}catch(_0x3b5677){return console[_0x4cd62d(0xd5)](_0x4cd62d(0x8e)+_0x20729f+':\x20'+_0x3b5677),null;}}return null;}function getActiveProfileName(){const _0x1f04db=a44_0x38d491,_0x56baec=a44_0x337d15['join'](getConfigDir(),_0x1f04db(0xa4));if(!a44_0x236c5f[_0x1f04db(0x9b)](_0x56baec))return null;try{const _0x2cc192=a44_0x236c5f[_0x1f04db(0xa5)](_0x56baec,'utf-8'),_0x568642=JSON[_0x1f04db(0xb8)](_0x2cc192);return _0x568642[_0x1f04db(0xc1)]||null;}catch{return null;}}export function saveAPIKey(_0x3eaf73,_0x42e8a7,_0x520bb0){const _0x34883f=a44_0x38d491,_0x43b8a9=getConfigDir(),_0x46dbda=getConfigFilePath(_0x520bb0);!existsSync(_0x43b8a9)&&mkdirSync(_0x43b8a9,{'recursive':!![],'mode':0x1c0});let _0xea85e8={};if(existsSync(_0x46dbda))try{const _0x5aa7ce=readFileSync(_0x46dbda,'utf-8');_0xea85e8=parseEnvFile(_0x5aa7ce);}catch(_0x2b239b){console[_0x34883f(0xd5)](_0x34883f(0x92)+_0x46dbda+':',_0x2b239b);}const _0x44d037=_0x3eaf73[_0x34883f(0xcc)]()[_0x34883f(0xbe)](/-/g,'_');_0xea85e8[_0x34883f(0x8c)+_0x44d037]=_0x42e8a7;const _0x363059=Object[_0x34883f(0xce)](_0xea85e8)[_0x34883f(0xac)](([_0x2c7f27,_0x1513f9])=>_0x2c7f27+'='+_0x1513f9);writeFileSync(_0x46dbda,_0x363059[_0x34883f(0xa2)]('\x0a')+'\x0a',{'mode':0x180});}export async function saveAPIKeyAsync(_0x3b3ffa,_0x3dc499,_0xa1e79e){const _0x13b787=a44_0x38d491;await saveKeychainAPIKey(_0x3b3ffa,_0xa1e79e),setCachedCredential(_0x3b3ffa,_0x3dc499,_0xa1e79e);const _0x7f92c8=getConfigFilePath(_0xa1e79e);cleanupLegacyEnvFile(_0x7f92c8)&&console[_0x13b787(0xd5)](a44_0x5d5bac[_0x13b787(0xd0)](_0x13b787(0xd7)));}export function loadConfig(){const _0x33a844=a44_0x38d491,_0x36112a={'apiKeys':{},'defaultSite':_0x33a844(0xb7)},_0x4746c3=[_0x33a844(0xb7),_0x33a844(0xb4),_0x33a844(0xd1),_0x33a844(0x94),_0x33a844(0x8d),'dev-us01',_0x33a844(0xa3),'stg-us01',_0x33a844(0xd4),_0x33a844(0xbc)];for(const _0x2c1fc9 of _0x4746c3){const _0x33470e=getAPIKey(_0x2c1fc9);_0x33470e&&(_0x36112a[_0x33a844(0xb9)][_0x2c1fc9]=_0x33470e);}return _0x36112a;}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
function a45_0x332d(_0x5e1549,_0x4215e6){_0x5e1549=_0x5e1549-0xf4;const _0x3bb538=a45_0x3bb5();let _0x332dc4=_0x3bb538[_0x5e1549];return _0x332dc4;}const a45_0x598664=a45_0x332d;(function(_0x19c869,_0x1bd972){const _0x71c16a=a45_0x332d,_0x3b06a9=_0x19c869();while(!![]){try{const _0x40c90a=parseInt(_0x71c16a(0xfe))/0x1+parseInt(_0x71c16a(0xf6))/0x2+parseInt(_0x71c16a(0xfc))/0x3+-parseInt(_0x71c16a(0xfd))/0x4*(-parseInt(_0x71c16a(0xfa))/0x5)+-parseInt(_0x71c16a(0xf9))/0x6*(-parseInt(_0x71c16a(0x100))/0x7)+-parseInt(_0x71c16a(0x101))/0x8+parseInt(_0x71c16a(0xf5))/0x9*(-parseInt(_0x71c16a(0xf4))/0xa);if(_0x40c90a===_0x1bd972)break;else _0x3b06a9['push'](_0x3b06a9['shift']());}catch(_0x5bf47b){_0x3b06a9['push'](_0x3b06a9['shift']());}}}(a45_0x3bb5,0x73d5a));import{createProfileCache}from'../utils/global-cache.js';const connectionCache=createProfileCache(a45_0x598664(0xf7),'core/connection-cache');export function loadCachedConnections(_0x271c6c){const _0x5a2cd8=connectionCache['read'](_0x271c6c);return _0x5a2cd8?.['connections']??null;}function a45_0x3bb5(){const _0x202ea7=['379863HqwzQE','105900WWSzcG','connections-{profile}.json','write','4495524yWfZFI','36955EQTAvi','clear','1939893vPjtiC','172kIiNbk','196358nHLEGt','now','7pVhdJZ','6505888GUmKYl','160sOFIiN'];a45_0x3bb5=function(){return _0x202ea7;};return a45_0x3bb5();}export function saveCachedConnections(_0x2f934c,_0x31987b){const _0x30fdbc=a45_0x598664;connectionCache[_0x30fdbc(0xf8)](_0x2f934c,{'connections':_0x31987b,'cachedAt':Date[_0x30fdbc(0xff)]()});}export function clearConnectionCache(_0x368166){const _0x225a5d=a45_0x598664;connectionCache[_0x225a5d(0xfb)](_0x368166);}
|
package/dist/core/constants.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
function a46_0x2d6c(_0x2d1aa6,_0x5c7e3e){_0x2d1aa6=_0x2d1aa6-0x14f;const _0x5f1d47=a46_0x5f1d();let _0x2d6c56=_0x5f1d47[_0x2d1aa6];return _0x2d6c56;}const a46_0x80b678=a46_0x2d6c;(function(_0x494dba,_0x5c025c){const _0x19d17a=a46_0x2d6c,_0x45d881=_0x494dba();while(!![]){try{const _0x2733da=-parseInt(_0x19d17a(0x161))/0x1*(-parseInt(_0x19d17a(0x155))/0x2)+parseInt(_0x19d17a(0x15e))/0x3+-parseInt(_0x19d17a(0x153))/0x4*(-parseInt(_0x19d17a(0x15f))/0x5)+-parseInt(_0x19d17a(0x15b))/0x6+parseInt(_0x19d17a(0x156))/0x7+parseInt(_0x19d17a(0x162))/0x8*(-parseInt(_0x19d17a(0x151))/0x9)+-parseInt(_0x19d17a(0x15d))/0xa*(parseInt(_0x19d17a(0x152))/0xb);if(_0x2733da===_0x5c025c)break;else _0x45d881['push'](_0x45d881['shift']());}catch(_0x5d96c8){_0x45d881['push'](_0x45d881['shift']());}}}(a46_0x5f1d,0xb8842));export const DEFAULT_DISPLAY_LIMIT=0x28;export const DEFAULT_LISTING_LIMIT=0x2710;export const DEFAULT_LLM_LIMIT=0x32;function a46_0x5f1d(){const _0x5229cb=['Enter\x20custom\x20site','us01','1804707zgPdjF','44dufXuD','5507764enDlbi','us\x20\x20\x20-\x20United\x20States','2MvdBiI','2945320LlsQHf','jp01','value','number','length','1132170rJFkyO','findIndex','1231660jVyzGO','478680iGqbRL','5HNmyWa','eu01','81445KnaPxb','24EfYAio','jp\x20\x20\x20-\x20Japan','eu\x20\x20\x20-\x20Europe','ap02','push','ap02\x20-\x20Korea','other'];a46_0x5f1d=function(){return _0x5229cb;};return a46_0x5f1d();}export function resolveLimit(_0x57057e,_0x1cf66d){const _0x447171=a46_0x2d6c;if(_0x57057e===undefined)return _0x1cf66d;if(typeof _0x57057e===_0x447171(0x159))return _0x57057e;return parseInt(_0x57057e,0xa);}export const STANDARD_SITE_CHOICES=[{'title':a46_0x80b678(0x154),'value':a46_0x80b678(0x150)},{'title':a46_0x80b678(0x163),'value':a46_0x80b678(0x157)},{'title':a46_0x80b678(0x164),'value':a46_0x80b678(0x160)},{'title':a46_0x80b678(0x167),'value':a46_0x80b678(0x165)}];export function buildSiteChoices(_0x6e2133){const _0x3c2a38=a46_0x80b678,_0x47fcd1=[...STANDARD_SITE_CHOICES];let _0x2a38d2=_0x47fcd1[_0x3c2a38(0x15c)](_0x373918=>_0x373918[_0x3c2a38(0x158)]===_0x6e2133);return _0x2a38d2===-0x1&&_0x6e2133!=='us01'&&(_0x47fcd1['push']({'title':_0x6e2133,'value':_0x6e2133}),_0x2a38d2=_0x47fcd1[_0x3c2a38(0x15a)]-0x1),_0x47fcd1[_0x3c2a38(0x166)]({'title':_0x3c2a38(0x14f),'value':_0x3c2a38(0x168)}),{'choices':_0x47fcd1,'initialIndex':_0x2a38d2>=0x0?_0x2a38d2:0x0};}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
function a47_0x47e3(_0x4d998c,_0x3c310a){_0x4d998c=_0x4d998c-0xe6;const _0x41780f=a47_0x4178();let _0x47e354=_0x41780f[_0x4d998c];return _0x47e354;}(function(_0x405c97,_0x2ef236){const _0x5ca57b=a47_0x47e3,_0x566a61=_0x405c97();while(!![]){try{const _0x421a32=-parseInt(_0x5ca57b(0xec))/0x1+-parseInt(_0x5ca57b(0xf6))/0x2*(-parseInt(_0x5ca57b(0xf0))/0x3)+parseInt(_0x5ca57b(0xf4))/0x4+-parseInt(_0x5ca57b(0xed))/0x5+-parseInt(_0x5ca57b(0xea))/0x6*(parseInt(_0x5ca57b(0xe8))/0x7)+-parseInt(_0x5ca57b(0xf1))/0x8+parseInt(_0x5ca57b(0xf2))/0x9*(parseInt(_0x5ca57b(0xe9))/0xa);if(_0x421a32===_0x2ef236)break;else _0x566a61['push'](_0x566a61['shift']());}catch(_0x3f2224){_0x566a61['push'](_0x566a61['shift']());}}}(a47_0x4178,0x63311));const cache=new Map(),CACHE_TTL_MS=0x5*0x3c*0x3e8;function getCacheKey(_0x170f53,_0x10e33b){const _0x1e4920=a47_0x47e3,_0x38638d=_0x170f53||_0x1e4920(0xe6),_0x4ae9cc=_0x10e33b||'__default_profile__';return _0x38638d+':'+_0x4ae9cc;}function a47_0x4178(){const _0x48b7bd=['19290mzzfaq','1578OcoAMU','loadedAt','107895QIZbUa','721070QVbumA','set','delete','3YLlJzr','2698016ZWsrLt','6300WlYXQl','now','57736wofDGz','get','166026sCGrzc','__default_site__','apiKey','12033bwiNgV'];a47_0x4178=function(){return _0x48b7bd;};return a47_0x4178();}export function getCachedCredential(_0x40bdff,_0x154074){const _0x87683=a47_0x47e3,_0x389a5b=getCacheKey(_0x40bdff,_0x154074),_0x4b13c8=cache[_0x87683(0xf5)](_0x389a5b);if(!_0x4b13c8)return null;if(Date[_0x87683(0xf3)]()-_0x4b13c8[_0x87683(0xeb)]>CACHE_TTL_MS)return cache['delete'](_0x389a5b),null;return _0x4b13c8[_0x87683(0xe7)];}export function setCachedCredential(_0x543a90,_0x4cf1fc,_0x30317d){const _0x45d39f=a47_0x47e3,_0x6de06=getCacheKey(_0x4cf1fc,_0x30317d);cache[_0x45d39f(0xee)](_0x6de06,{'apiKey':_0x543a90,'loadedAt':Date[_0x45d39f(0xf3)]()});}export function clearCredentialCache(){cache['clear']();}export function clearCachedCredential(_0x259004,_0x3292eb){const _0x3b5d84=a47_0x47e3,_0x315893=getCacheKey(_0x259004,_0x3292eb);cache[_0x3b5d84(0xef)](_0x315893);}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const a48_0x1a9180=a48_0x1e9a;(function(_0x4c165e,_0xe2506a){const _0x59247a=a48_0x1e9a,_0x251937=_0x4c165e();while(!![]){try{const _0x2d825d=-parseInt(_0x59247a(0x1c1))/0x1*(-parseInt(_0x59247a(0x1c9))/0x2)+-parseInt(_0x59247a(0x1da))/0x3*(parseInt(_0x59247a(0x19a))/0x4)+parseInt(_0x59247a(0x19f))/0x5*(parseInt(_0x59247a(0x1bb))/0x6)+parseInt(_0x59247a(0x1c8))/0x7*(-parseInt(_0x59247a(0x1e3))/0x8)+parseInt(_0x59247a(0x1b9))/0x9+-parseInt(_0x59247a(0x1a2))/0xa*(parseInt(_0x59247a(0x1e2))/0xb)+parseInt(_0x59247a(0x1d7))/0xc;if(_0x2d825d===_0xe2506a)break;else _0x251937['push'](_0x251937['shift']());}catch(_0x5b26e1){_0x251937['push'](_0x251937['shift']());}}}(a48_0x7d95,0x4b4ad));import{resolveSite,getAPIKey,getAPIKeyAsync,getConfigDir}from'./config.js';import{loadSessionContext,getCurrentSessionPID}from'./session.js';import{loadProjectConfig,findProjectConfigPath}from'./project-config.js';import{getActiveProfile,loadProfile}from'./profile.js';import{LogLevel}from'../utils/tdx-logger.js';import*as a48_0x597f04 from'node:fs';function a48_0x1e9a(_0x5ae8b5,_0x2a8023){_0x5ae8b5=_0x5ae8b5-0x19a;const _0x7d9572=a48_0x7d95();let _0x1e9a42=_0x7d9572[_0x5ae8b5];return _0x1e9a42;}function a48_0x7d95(){const _0x1185a6=['[context]','display','assign','logLevel','verbose','44xhjpyG','4326360AZBEBA','Global','1556iCUclv','llmAgent','injectIntoOptions','profile:\x20','join','10sXSQel','CLI\x20flag:\x20--','Session','403660FVXcmN','config',':\x20none\x20(using\x20session:\x20','profile','workflow_project','Profile','log','project','utf-8','env','layers','configFiles','llmProject','(session:\x20','sessionId','.env','default','Global\x20Credentials','resolveAPIKeyAsync','displayWithSources','database','INFO','Project','1850949OKPjiv','parentSegment','795438fyaPtI','TDX_SITE','workflowProject','sessions','loadGlobalConfig','apiKey','9064JKBDtE','existsSync','readFileSync','\x0a[configuration\x20files]','session','createAsync','profileCredentials','7IFhcOV','8ZweBWY','getParameters','global','parent_segment','activeProfile','llm_agent','cliFlags','tdx.json','segment_path','segmentPath','us01','getSource','entries','string','7364160YkqBKI','(active)','llm_project','849iXmnKS','replace','site'];a48_0x7d95=function(){return _0x1185a6;};return a48_0x7d95();}import*as a48_0x4ae054 from'node:path';export class GlobalContext{[a48_0x1a9180(0x1dc)];[a48_0x1a9180(0x1b6)];[a48_0x1a9180(0x1cc)];[a48_0x1a9180(0x1d1)];[a48_0x1a9180(0x1d9)];[a48_0x1a9180(0x1ce)];[a48_0x1a9180(0x1a6)];[a48_0x1a9180(0x1c0)];[a48_0x1a9180(0x1e1)];['logLevel'];[a48_0x1a9180(0x1a5)];['layers'];[a48_0x1a9180(0x1cd)];[a48_0x1a9180(0x1b0)];['configFiles'];constructor(_0x274b15){const _0x42b47a=a48_0x1a9180;this[_0x42b47a(0x1b0)]=_0x274b15[_0x42b47a(0x1c5)]||getCurrentSessionPID()['toString']();const _0x10f689=loadSessionContext(_0x274b15[_0x42b47a(0x1c5)]),_0x48a5ee=loadProjectConfig(),_0x675906=this[_0x42b47a(0x1bf)]();this[_0x42b47a(0x1cd)]=_0x274b15[_0x42b47a(0x1a5)]||_0x10f689?.[_0x42b47a(0x1a5)]||_0x675906[_0x42b47a(0x1a5)]||getActiveProfile();const _0x453c71=this[_0x42b47a(0x1cd)]?loadProfile(this['activeProfile']):null,_0x2f0512=_0x49add4=>{const _0x13b6a0=_0x42b47a;if(!_0x49add4)return{};const _0x576afe=_0x49add4,_0x4b1795={};for(const [_0x2a8925,_0x363edd]of Object[_0x13b6a0(0x1d5)](_0x576afe)){typeof _0x363edd===_0x13b6a0(0x1d6)&&(_0x4b1795[_0x2a8925]=_0x363edd);}return _0x4b1795;},_0x361969={};if(_0x274b15[_0x42b47a(0x1dc)]&&_0x274b15[_0x42b47a(0x1dc)]!==_0x42b47a(0x1d3))_0x361969['site']=_0x274b15[_0x42b47a(0x1dc)];const _0x3ce845=_0x10f689?.[_0x42b47a(0x1b6)],_0x52aedb=_0x48a5ee?.['database'],_0x3f8eed=_0x453c71?.[_0x42b47a(0x1a3)]?.[_0x42b47a(0x1b6)],_0x91e11a=_0x675906[_0x42b47a(0x1b6)];_0x274b15['database']&&(_0x274b15[_0x42b47a(0x1b6)]!==_0x3ce845&&_0x274b15[_0x42b47a(0x1b6)]!==_0x52aedb&&_0x274b15[_0x42b47a(0x1b6)]!==_0x3f8eed&&_0x274b15[_0x42b47a(0x1b6)]!==_0x91e11a)&&(_0x361969[_0x42b47a(0x1b6)]=_0x274b15[_0x42b47a(0x1b6)]);if(_0x274b15[_0x42b47a(0x1ba)])_0x361969[_0x42b47a(0x1cc)]=_0x274b15[_0x42b47a(0x1ba)];if(_0x274b15[_0x42b47a(0x1ae)])_0x361969[_0x42b47a(0x1d9)]=_0x274b15[_0x42b47a(0x1ae)];if(_0x274b15[_0x42b47a(0x19b)])_0x361969[_0x42b47a(0x1ce)]=_0x274b15[_0x42b47a(0x19b)];if(_0x274b15[_0x42b47a(0x1a5)])_0x361969[_0x42b47a(0x1a5)]=_0x274b15[_0x42b47a(0x1a5)];this[_0x42b47a(0x1ac)]={'cliFlags':_0x361969,'session':_0x2f0512(_0x10f689),'project':_0x2f0512(_0x48a5ee),'profile':_0x2f0512(_0x453c71?.[_0x42b47a(0x1a3)]),'global':_0x2f0512(_0x675906)};const _0x509354={...this[_0x42b47a(0x1ac)]['global'],...this[_0x42b47a(0x1ac)]['profile'],...this[_0x42b47a(0x1ac)][_0x42b47a(0x1a9)]};process[_0x42b47a(0x1ab)][_0x42b47a(0x1bc)]&&!this['layers'][_0x42b47a(0x1c5)][_0x42b47a(0x1dc)]&&!this[_0x42b47a(0x1ac)][_0x42b47a(0x1cf)]['site']&&(_0x509354['site']=process[_0x42b47a(0x1ab)][_0x42b47a(0x1bc)]);Object[_0x42b47a(0x1df)](_0x509354,this[_0x42b47a(0x1ac)][_0x42b47a(0x1c5)]),Object[_0x42b47a(0x1df)](_0x509354,this[_0x42b47a(0x1ac)][_0x42b47a(0x1cf)]);const _0x1787ac=_0x509354[_0x42b47a(0x1dc)]||_0x42b47a(0x1d3);this[_0x42b47a(0x1dc)]=resolveSite(_0x1787ac),this['database']=_0x509354[_0x42b47a(0x1b6)],this[_0x42b47a(0x1cc)]=_0x509354['parent_segment'],this[_0x42b47a(0x1d1)]=_0x509354[_0x42b47a(0x1d1)],this[_0x42b47a(0x1d9)]=_0x509354[_0x42b47a(0x1d9)],this['llm_agent']=_0x509354['llm_agent'],this[_0x42b47a(0x1a6)]=_0x509354[_0x42b47a(0x1a6)],this[_0x42b47a(0x1e1)]=_0x274b15[_0x42b47a(0x1e1)]||![],this['logLevel']=_0x274b15[_0x42b47a(0x1e0)]??LogLevel[_0x42b47a(0x1b7)],this['profile']=this[_0x42b47a(0x1cd)]||undefined,this[_0x42b47a(0x1c0)]=getAPIKey(this['site'],this['activeProfile']||undefined);const _0x2616be=getConfigDir(),_0x2470f5=a48_0x4ae054[_0x42b47a(0x19e)](_0x2616be,_0x42b47a(0x1be),this[_0x42b47a(0x1b0)]+'.json'),_0x22b43e=findProjectConfigPath(),_0x296ae9=a48_0x4ae054['join'](_0x2616be,_0x42b47a(0x1d0)),_0x146b1e=a48_0x4ae054[_0x42b47a(0x19e)](_0x2616be,_0x42b47a(0x1b1));let _0x58b524=null,_0x1cdf19=null;this[_0x42b47a(0x1cd)]&&(_0x58b524=a48_0x4ae054[_0x42b47a(0x19e)](_0x2616be,'profiles',this[_0x42b47a(0x1cd)],_0x42b47a(0x1d0)),_0x1cdf19=a48_0x4ae054[_0x42b47a(0x19e)](_0x2616be,'profiles',this[_0x42b47a(0x1cd)],_0x42b47a(0x1b1))),this[_0x42b47a(0x1ad)]={'session':a48_0x597f04[_0x42b47a(0x1c2)](_0x2470f5)?_0x2470f5:null,'project':_0x22b43e,'profile':_0x58b524&&a48_0x597f04[_0x42b47a(0x1c2)](_0x58b524)?_0x58b524:null,'profileCredentials':_0x1cdf19&&a48_0x597f04[_0x42b47a(0x1c2)](_0x1cdf19)?_0x1cdf19:null,'global':a48_0x597f04[_0x42b47a(0x1c2)](_0x296ae9)?_0x296ae9:null,'globalCredentials':a48_0x597f04[_0x42b47a(0x1c2)](_0x146b1e)?_0x146b1e:null};}[a48_0x1a9180(0x1d4)](_0x759e,_0x1ef170){const _0x21f073=a48_0x1a9180;if(!_0x1ef170)return'not\x20set';const _0x45062d=_0x1ef170;if(this['layers'][_0x21f073(0x1cf)][_0x759e]===_0x45062d){if(_0x759e===_0x21f073(0x1dc)&&_0x45062d===_0x21f073(0x1d3)&&!this[_0x21f073(0x1ac)][_0x21f073(0x1c5)][_0x21f073(0x1dc)]&&!this[_0x21f073(0x1ac)][_0x21f073(0x1a9)][_0x21f073(0x1dc)]&&!this['layers'][_0x21f073(0x1a5)][_0x21f073(0x1dc)]&&!this[_0x21f073(0x1ac)][_0x21f073(0x1cb)][_0x21f073(0x1dc)])return _0x21f073(0x1b2);return _0x21f073(0x1a0)+_0x759e[_0x21f073(0x1db)](/_/g,'-');}if(this['layers'][_0x21f073(0x1c5)][_0x759e]===_0x45062d)return _0x21f073(0x1c5);if(this['layers'][_0x21f073(0x1a9)][_0x759e]===_0x45062d)return _0x21f073(0x1a9);if(this[_0x21f073(0x1ac)][_0x21f073(0x1a5)][_0x759e]===_0x45062d)return _0x21f073(0x19d)+this[_0x21f073(0x1cd)];if(this[_0x21f073(0x1ac)]['global'][_0x759e]===_0x45062d)return _0x21f073(0x1cb);return'default';}[a48_0x1a9180(0x1bf)](){const _0x48baea=a48_0x1a9180,_0x129aef=a48_0x4ae054[_0x48baea(0x19e)](getConfigDir(),_0x48baea(0x1d0));if(!a48_0x597f04[_0x48baea(0x1c2)](_0x129aef))return{};try{const _0x27cbf2=a48_0x597f04[_0x48baea(0x1c3)](_0x129aef,_0x48baea(0x1aa));return JSON['parse'](_0x27cbf2);}catch{return{};}}[a48_0x1a9180(0x19c)](_0x5302b3){const _0x1f2fcd=a48_0x1a9180;_0x5302b3[_0x1f2fcd(0x1dc)]=this[_0x1f2fcd(0x1dc)],!_0x5302b3[_0x1f2fcd(0x1b6)]&&this[_0x1f2fcd(0x1b6)]&&(_0x5302b3['database']=this[_0x1f2fcd(0x1b6)]),!_0x5302b3[_0x1f2fcd(0x1ba)]&&this[_0x1f2fcd(0x1cc)]&&(_0x5302b3[_0x1f2fcd(0x1ba)]=this[_0x1f2fcd(0x1cc)]),!_0x5302b3[_0x1f2fcd(0x1d2)]&&this[_0x1f2fcd(0x1d1)]&&(_0x5302b3['segmentPath']=this[_0x1f2fcd(0x1d1)]),!_0x5302b3['llmProject']&&this[_0x1f2fcd(0x1d9)]&&(_0x5302b3['llmProject']=this['llm_project']),!_0x5302b3['llmAgent']&&this[_0x1f2fcd(0x1ce)]&&(_0x5302b3[_0x1f2fcd(0x19b)]=this[_0x1f2fcd(0x1ce)]),!_0x5302b3['workflowProject']&&this[_0x1f2fcd(0x1a6)]&&(_0x5302b3[_0x1f2fcd(0x1bd)]=this[_0x1f2fcd(0x1a6)]);}[a48_0x1a9180(0x1ca)](){const _0xc7901=a48_0x1a9180;return[{'key':'site','value':this[_0xc7901(0x1dc)]},{'key':'database','value':this['database']},{'key':_0xc7901(0x1cc),'value':this[_0xc7901(0x1cc)]},{'key':'segment_path','value':this[_0xc7901(0x1d1)]},{'key':_0xc7901(0x1d9),'value':this[_0xc7901(0x1d9)]},{'key':_0xc7901(0x1ce),'value':this[_0xc7901(0x1ce)]},{'key':_0xc7901(0x1a6),'value':this[_0xc7901(0x1a6)]},{'key':_0xc7901(0x1a5),'value':this[_0xc7901(0x1cd)]||undefined}];}[a48_0x1a9180(0x1de)](){const _0x3e7904=a48_0x1a9180;console['log'](_0x3e7904(0x1dd));for(const {key:_0x454818,value:_0x327279}of this[_0x3e7904(0x1ca)]()){_0x327279&&console[_0x3e7904(0x1a8)](_0x454818+':\x20'+_0x327279);}}[a48_0x1a9180(0x1b5)](){const _0x3ac6c6=a48_0x1a9180;console['log']('[context]');for(const {key:_0x4a6f2e,value:_0x59119a}of this['getParameters']()){if(_0x59119a){const _0x5db08c=_0x4a6f2e==='profile'?_0x3ac6c6(0x1d8):'('+this[_0x3ac6c6(0x1d4)](_0x4a6f2e,_0x59119a)+')';console[_0x3ac6c6(0x1a8)](_0x4a6f2e+':\x20'+_0x59119a+'\x20'+_0x5db08c);}}console['log'](_0x3ac6c6(0x1c4));const _0x1fbb4b=[{'label':_0x3ac6c6(0x1a1),'path':this[_0x3ac6c6(0x1ad)][_0x3ac6c6(0x1c5)],'extra':_0x3ac6c6(0x1af)+this[_0x3ac6c6(0x1b0)]+')'},{'label':_0x3ac6c6(0x1b8),'path':this[_0x3ac6c6(0x1ad)]['project']},{'label':_0x3ac6c6(0x1a7),'path':this[_0x3ac6c6(0x1ad)][_0x3ac6c6(0x1a5)]},{'label':'Profile\x20Credentials','path':this['configFiles'][_0x3ac6c6(0x1c7)]},{'label':_0x3ac6c6(0x1e4),'path':this[_0x3ac6c6(0x1ad)][_0x3ac6c6(0x1cb)]},{'label':_0x3ac6c6(0x1b3),'path':this['configFiles']['globalCredentials']}];for(const {label:_0x555cf1,path:_0x10f3f3,extra:_0x38c724}of _0x1fbb4b){if(_0x10f3f3)console[_0x3ac6c6(0x1a8)](_0x555cf1+':\x20'+_0x10f3f3+'\x20✓'+(_0x38c724?'\x20'+_0x38c724:''));else{if(_0x555cf1==='Session')console['log'](_0x555cf1+_0x3ac6c6(0x1a4)+this[_0x3ac6c6(0x1b0)]+')');else(_0x555cf1===_0x3ac6c6(0x1b8)||_0x555cf1==='Global')&&console[_0x3ac6c6(0x1a8)](_0x555cf1+':\x20none');}}}async[a48_0x1a9180(0x1b4)](){const _0x33de97=a48_0x1a9180;return this['apiKey']=await getAPIKeyAsync(this[_0x33de97(0x1dc)],this[_0x33de97(0x1cd)]||undefined),this[_0x33de97(0x1c0)];}static async[a48_0x1a9180(0x1c6)](_0x493a57){const _0x418180=a48_0x1a9180,_0x1c63fc=new GlobalContext(_0x493a57);return await _0x1c63fc[_0x418180(0x1b4)](),_0x1c63fc;}}
|
|
1
|
+
const a48_0x22b304=a48_0x45cc;(function(_0x2c977d,_0x31dcdf){const _0x6e6a3=a48_0x45cc,_0x43f14d=_0x2c977d();while(!![]){try{const _0x29ddb6=parseInt(_0x6e6a3(0x162))/0x1+parseInt(_0x6e6a3(0x189))/0x2+-parseInt(_0x6e6a3(0x161))/0x3*(-parseInt(_0x6e6a3(0x165))/0x4)+parseInt(_0x6e6a3(0x177))/0x5+parseInt(_0x6e6a3(0x16a))/0x6*(-parseInt(_0x6e6a3(0x168))/0x7)+-parseInt(_0x6e6a3(0x176))/0x8*(parseInt(_0x6e6a3(0x18a))/0x9)+parseInt(_0x6e6a3(0x17d))/0xa*(parseInt(_0x6e6a3(0x181))/0xb);if(_0x29ddb6===_0x31dcdf)break;else _0x43f14d['push'](_0x43f14d['shift']());}catch(_0x517fa4){_0x43f14d['push'](_0x43f14d['shift']());}}}(a48_0x1f7f,0xa1540));import{resolveSite,getAPIKey,getAPIKeyAsync,getConfigDir}from'./config.js';import{loadSessionContext,getCurrentSessionPID}from'./session.js';import{loadProjectConfig,findProjectConfigPath}from'./project-config.js';import{getActiveProfile,loadProfile}from'./profile.js';import{LogLevel}from'../utils/tdx-logger.js';function a48_0x45cc(_0x3f69fe,_0x2bd6a3){_0x3f69fe=_0x3f69fe-0x14e;const _0x1f7f74=a48_0x1f7f();let _0x45cc75=_0x1f7f74[_0x3f69fe];return _0x45cc75;}import*as a48_0x29ab65 from'node:fs';import*as a48_0x3b0226 from'node:path';export class GlobalContext{[a48_0x22b304(0x194)];[a48_0x22b304(0x155)];[a48_0x22b304(0x186)];[a48_0x22b304(0x195)];[a48_0x22b304(0x175)];[a48_0x22b304(0x150)];[a48_0x22b304(0x164)];[a48_0x22b304(0x192)];[a48_0x22b304(0x170)];[a48_0x22b304(0x15e)];['profile'];['layers'];[a48_0x22b304(0x16d)];[a48_0x22b304(0x153)];['configFiles'];constructor(_0x32240e){const _0x1ecfe7=a48_0x22b304;this[_0x1ecfe7(0x153)]=_0x32240e[_0x1ecfe7(0x17c)]||getCurrentSessionPID()[_0x1ecfe7(0x152)]();const _0x2acf0f=loadSessionContext(_0x32240e[_0x1ecfe7(0x17c)]),_0xdb8e11=loadProjectConfig(),_0x4c5058=this['loadGlobalConfig']();this[_0x1ecfe7(0x16d)]=_0x32240e['profile']||_0x2acf0f?.[_0x1ecfe7(0x18e)]||_0x4c5058[_0x1ecfe7(0x18e)]||getActiveProfile();const _0x3ce7ad=this[_0x1ecfe7(0x16d)]?loadProfile(this[_0x1ecfe7(0x16d)]):null,_0x54bf63=_0x4044aa=>{const _0x1aa17b=_0x1ecfe7;if(!_0x4044aa)return{};const _0x3a15e3=_0x4044aa,_0x553454={};for(const [_0x3c9789,_0x58a4ba]of Object[_0x1aa17b(0x157)](_0x3a15e3)){typeof _0x58a4ba===_0x1aa17b(0x16b)&&(_0x553454[_0x3c9789]=_0x58a4ba);}return _0x553454;},_0x21eee5={};if(_0x32240e['site']&&_0x32240e['site']!==_0x1ecfe7(0x17f))_0x21eee5[_0x1ecfe7(0x194)]=_0x32240e[_0x1ecfe7(0x194)];const _0x38a416=_0x2acf0f?.[_0x1ecfe7(0x155)],_0x292b18=_0xdb8e11?.['database'],_0x5dfcd2=_0x3ce7ad?.[_0x1ecfe7(0x18f)]?.[_0x1ecfe7(0x155)],_0x5d06c9=_0x4c5058['database'];_0x32240e['database']&&(_0x32240e[_0x1ecfe7(0x155)]!==_0x38a416&&_0x32240e[_0x1ecfe7(0x155)]!==_0x292b18&&_0x32240e[_0x1ecfe7(0x155)]!==_0x5dfcd2&&_0x32240e[_0x1ecfe7(0x155)]!==_0x5d06c9)&&(_0x21eee5[_0x1ecfe7(0x155)]=_0x32240e['database']);if(_0x32240e[_0x1ecfe7(0x193)])_0x21eee5['parent_segment']=_0x32240e['parentSegment'];if(_0x32240e[_0x1ecfe7(0x166)])_0x21eee5[_0x1ecfe7(0x175)]=_0x32240e['llmProject'];if(_0x32240e[_0x1ecfe7(0x15c)])_0x21eee5[_0x1ecfe7(0x150)]=_0x32240e[_0x1ecfe7(0x15c)];if(_0x32240e[_0x1ecfe7(0x18e)])_0x21eee5[_0x1ecfe7(0x18e)]=_0x32240e[_0x1ecfe7(0x18e)];this[_0x1ecfe7(0x14f)]={'cliFlags':_0x21eee5,'session':_0x54bf63(_0x2acf0f),'project':_0x54bf63(_0xdb8e11),'profile':_0x54bf63(_0x3ce7ad?.[_0x1ecfe7(0x18f)]),'global':_0x54bf63(_0x4c5058)};const _0x306383={...this[_0x1ecfe7(0x14f)][_0x1ecfe7(0x17b)],...this[_0x1ecfe7(0x14f)]['profile'],...this['layers']['project']};process[_0x1ecfe7(0x15b)][_0x1ecfe7(0x15a)]&&!this['layers']['session'][_0x1ecfe7(0x194)]&&!this[_0x1ecfe7(0x14f)][_0x1ecfe7(0x185)]['site']&&(_0x306383[_0x1ecfe7(0x194)]=process[_0x1ecfe7(0x15b)]['TDX_SITE']);Object[_0x1ecfe7(0x187)](_0x306383,this['layers'][_0x1ecfe7(0x17c)]),Object[_0x1ecfe7(0x187)](_0x306383,this[_0x1ecfe7(0x14f)]['cliFlags']);const _0x473d2a=_0x306383[_0x1ecfe7(0x194)]||_0x1ecfe7(0x17f);this[_0x1ecfe7(0x194)]=resolveSite(_0x473d2a),this['database']=_0x306383[_0x1ecfe7(0x155)],this[_0x1ecfe7(0x186)]=_0x306383[_0x1ecfe7(0x186)],this[_0x1ecfe7(0x195)]=_0x306383[_0x1ecfe7(0x195)],this[_0x1ecfe7(0x175)]=_0x306383[_0x1ecfe7(0x175)],this['llm_agent']=_0x306383[_0x1ecfe7(0x150)],this[_0x1ecfe7(0x164)]=_0x306383[_0x1ecfe7(0x164)],this[_0x1ecfe7(0x170)]=_0x32240e['verbose']||![],this[_0x1ecfe7(0x15e)]=_0x32240e['logLevel']??LogLevel[_0x1ecfe7(0x154)],this[_0x1ecfe7(0x18e)]=this['activeProfile']||undefined,this[_0x1ecfe7(0x192)]=getAPIKey(this[_0x1ecfe7(0x194)],this[_0x1ecfe7(0x16d)]||undefined);const _0x47b4fe=getConfigDir(),_0x3d4fe1=a48_0x3b0226['join'](_0x47b4fe,'sessions',this[_0x1ecfe7(0x153)]+_0x1ecfe7(0x184)),_0x226bc4=findProjectConfigPath(),_0x5a83be=a48_0x3b0226[_0x1ecfe7(0x174)](_0x47b4fe,_0x1ecfe7(0x17a)),_0x2e4be2=a48_0x3b0226['join'](_0x47b4fe,_0x1ecfe7(0x156));let _0xcecf02=null,_0x28a536=null;this[_0x1ecfe7(0x16d)]&&(_0xcecf02=a48_0x3b0226[_0x1ecfe7(0x174)](_0x47b4fe,'profiles',this['activeProfile'],'tdx.json'),_0x28a536=a48_0x3b0226['join'](_0x47b4fe,_0x1ecfe7(0x172),this[_0x1ecfe7(0x16d)],'.env')),this[_0x1ecfe7(0x18d)]={'session':a48_0x29ab65[_0x1ecfe7(0x190)](_0x3d4fe1)?_0x3d4fe1:null,'project':_0x226bc4,'profile':_0xcecf02&&a48_0x29ab65[_0x1ecfe7(0x190)](_0xcecf02)?_0xcecf02:null,'profileCredentials':_0x28a536&&a48_0x29ab65[_0x1ecfe7(0x190)](_0x28a536)?_0x28a536:null,'global':a48_0x29ab65[_0x1ecfe7(0x190)](_0x5a83be)?_0x5a83be:null,'globalCredentials':a48_0x29ab65[_0x1ecfe7(0x190)](_0x2e4be2)?_0x2e4be2:null};}['getSource'](_0x1cfdc2,_0x578611){const _0x994199=a48_0x22b304;if(!_0x578611)return _0x994199(0x17e);const _0x21b347=_0x578611;if(this[_0x994199(0x14f)][_0x994199(0x185)][_0x1cfdc2]===_0x21b347){if(_0x1cfdc2===_0x994199(0x194)&&_0x21b347===_0x994199(0x17f)&&!this['layers'][_0x994199(0x17c)][_0x994199(0x194)]&&!this['layers'][_0x994199(0x182)][_0x994199(0x194)]&&!this[_0x994199(0x14f)]['profile'][_0x994199(0x194)]&&!this[_0x994199(0x14f)][_0x994199(0x17b)][_0x994199(0x194)])return'default';return'CLI\x20flag:\x20--'+_0x1cfdc2[_0x994199(0x173)](/_/g,'-');}if(this['layers'][_0x994199(0x17c)][_0x1cfdc2]===_0x21b347)return _0x994199(0x17c);if(this[_0x994199(0x14f)][_0x994199(0x182)][_0x1cfdc2]===_0x21b347)return _0x994199(0x182);if(this[_0x994199(0x14f)][_0x994199(0x18e)][_0x1cfdc2]===_0x21b347)return _0x994199(0x16c)+this[_0x994199(0x16d)];if(this[_0x994199(0x14f)][_0x994199(0x17b)][_0x1cfdc2]===_0x21b347)return _0x994199(0x17b);return'default';}[a48_0x22b304(0x179)](){const _0x2f7d79=a48_0x22b304,_0xda842=a48_0x3b0226['join'](getConfigDir(),_0x2f7d79(0x17a));if(!a48_0x29ab65[_0x2f7d79(0x190)](_0xda842))return{};try{const _0xfe9de9=a48_0x29ab65['readFileSync'](_0xda842,'utf-8');return JSON[_0x2f7d79(0x159)](_0xfe9de9);}catch{return{};}}[a48_0x22b304(0x178)](_0x1cca36){const _0x4d2222=a48_0x22b304;_0x1cca36[_0x4d2222(0x194)]=this[_0x4d2222(0x194)],!_0x1cca36[_0x4d2222(0x155)]&&this[_0x4d2222(0x155)]&&(_0x1cca36[_0x4d2222(0x155)]=this['database']),!_0x1cca36[_0x4d2222(0x193)]&&this[_0x4d2222(0x186)]&&(_0x1cca36['parentSegment']=this[_0x4d2222(0x186)]),!_0x1cca36['segmentPath']&&this['segment_path']&&(_0x1cca36[_0x4d2222(0x163)]=this[_0x4d2222(0x195)]),!_0x1cca36[_0x4d2222(0x166)]&&this[_0x4d2222(0x175)]&&(_0x1cca36[_0x4d2222(0x166)]=this['llm_project']),!_0x1cca36[_0x4d2222(0x15c)]&&this['llm_agent']&&(_0x1cca36[_0x4d2222(0x15c)]=this[_0x4d2222(0x150)]),!_0x1cca36[_0x4d2222(0x158)]&&this['workflow_project']&&(_0x1cca36['workflowProject']=this['workflow_project']);}[a48_0x22b304(0x169)](){const _0x498fcb=a48_0x22b304;return[{'key':'site','value':this[_0x498fcb(0x194)]},{'key':_0x498fcb(0x155),'value':this[_0x498fcb(0x155)]},{'key':_0x498fcb(0x186),'value':this[_0x498fcb(0x186)]},{'key':_0x498fcb(0x195),'value':this[_0x498fcb(0x195)]},{'key':_0x498fcb(0x175),'value':this[_0x498fcb(0x175)]},{'key':_0x498fcb(0x150),'value':this[_0x498fcb(0x150)]},{'key':_0x498fcb(0x164),'value':this[_0x498fcb(0x164)]},{'key':_0x498fcb(0x18e),'value':this[_0x498fcb(0x16d)]||undefined}];}[a48_0x22b304(0x18b)](){const _0x36a91a=a48_0x22b304;console[_0x36a91a(0x15f)](_0x36a91a(0x191));for(const {key:_0x3cea04,value:_0x47b1ea}of this[_0x36a91a(0x169)]()){_0x47b1ea&&console[_0x36a91a(0x15f)](_0x3cea04+':\x20'+_0x47b1ea);}}['displayWithSources'](){const _0x3fd93a=a48_0x22b304;console[_0x3fd93a(0x15f)](_0x3fd93a(0x191));for(const {key:_0x28115a,value:_0x287e14}of this[_0x3fd93a(0x169)]()){if(_0x287e14){const _0x3b72a1=_0x28115a===_0x3fd93a(0x18e)?_0x3fd93a(0x151):'('+this[_0x3fd93a(0x16f)](_0x28115a,_0x287e14)+')';console[_0x3fd93a(0x15f)](_0x28115a+':\x20'+_0x287e14+'\x20'+_0x3b72a1);}}console[_0x3fd93a(0x15f)](_0x3fd93a(0x16e));const _0x2faf57=[{'label':_0x3fd93a(0x171),'path':this[_0x3fd93a(0x18d)]['session'],'extra':'(session:\x20'+this['sessionId']+')'},{'label':'Project','path':this['configFiles']['project']},{'label':_0x3fd93a(0x15d),'path':this[_0x3fd93a(0x18d)][_0x3fd93a(0x18e)]},{'label':'Profile\x20Credentials','path':this['configFiles'][_0x3fd93a(0x18c)]},{'label':'Global','path':this['configFiles'][_0x3fd93a(0x17b)]},{'label':_0x3fd93a(0x188),'path':this[_0x3fd93a(0x18d)][_0x3fd93a(0x183)]}];for(const {label:_0x4f2b66,path:_0x1b6969,extra:_0x13a1ea}of _0x2faf57){if(_0x1b6969)console['log'](_0x4f2b66+':\x20'+_0x1b6969+'\x20✓'+(_0x13a1ea?'\x20'+_0x13a1ea:''));else{if(_0x4f2b66===_0x3fd93a(0x171))console[_0x3fd93a(0x15f)](_0x4f2b66+':\x20none\x20(using\x20session:\x20'+this['sessionId']+')');else(_0x4f2b66===_0x3fd93a(0x160)||_0x4f2b66===_0x3fd93a(0x196))&&console[_0x3fd93a(0x15f)](_0x4f2b66+_0x3fd93a(0x14e));}}}async[a48_0x22b304(0x180)](){const _0x539501=a48_0x22b304;return this[_0x539501(0x192)]=await getAPIKeyAsync(this[_0x539501(0x194)],this[_0x539501(0x16d)]||undefined),this['apiKey'];}static async[a48_0x22b304(0x167)](_0x404069){const _0x53883d=a48_0x22b304,_0x5a1045=new GlobalContext(_0x404069);return await _0x5a1045[_0x53883d(0x180)](),_0x5a1045;}}function a48_0x1f7f(){const _0x1f8209=['20mJDmGO','not\x20set','us01','resolveAPIKeyAsync','549373GKLsYb','project','globalCredentials','.json','cliFlags','parent_segment','assign','Global\x20Credentials','1885226RVkZUH','72sKRKMn','display','profileCredentials','configFiles','profile','config','existsSync','[context]','apiKey','parentSegment','site','segment_path','Global',':\x20none','layers','llm_agent','(active)','toString','sessionId','INFO','database','.env','entries','workflowProject','parse','TDX_SITE','env','llmAgent','Profile','logLevel','log','Project','714633COyMHG','706145KkJghB','segmentPath','workflow_project','4KoAFCY','llmProject','createAsync','14AzzkMo','getParameters','1913514HwAhva','string','profile:\x20','activeProfile','\x0a[configuration\x20files]','getSource','verbose','Session','profiles','replace','join','llm_project','985648NAEweH','1487155omQCdV','injectIntoOptions','loadGlobalConfig','tdx.json','global','session'];a48_0x1f7f=function(){return _0x1f8209;};return a48_0x1f7f();}
|
package/dist/core/keychain.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a49_0x6729f6=a49_0x4952;(function(_0x4f0efa,_0x554c49){const _0xafcff1=a49_0x4952,_0x214707=_0x4f0efa();while(!![]){try{const _0xfdbb5=-parseInt(_0xafcff1(0xcd))/0x1+-parseInt(_0xafcff1(0xc0))/0x2+parseInt(_0xafcff1(0xd4))/0x3+parseInt(_0xafcff1(0xd1))/0x4*(parseInt(_0xafcff1(0xb9))/0x5)+-parseInt(_0xafcff1(0xbe))/0x6*(parseInt(_0xafcff1(0xba))/0x7)+-parseInt(_0xafcff1(0xcb))/0x8*(parseInt(_0xafcff1(0xd0))/0x9)+-parseInt(_0xafcff1(0xbb))/0xa*(-parseInt(_0xafcff1(0xd2))/0xb);if(_0xfdbb5===_0x554c49)break;else _0x214707['push'](_0x214707['shift']());}catch(_0x21d18a){_0x214707['push'](_0x214707['shift']());}}}(a49_0x145d,0xe97e5));const SERVICE_NAME=a49_0x6729f6(0xc8);let EntryClass=null,keyringLoadError=null;function a49_0x4952(_0xe2cc70,_0x1a022f){_0xe2cc70=_0xe2cc70-0xb7;const _0x145de=a49_0x145d();let _0x495268=_0x145de[_0xe2cc70];return _0x495268;}async function getEntryClass(){const _0x23ebcc=a49_0x6729f6;if(EntryClass!==null)return EntryClass;if(keyringLoadError!==null)return null;try{const _0x45eec2=await import(_0x23ebcc(0xce));return EntryClass=_0x45eec2[_0x23ebcc(0xb8)],EntryClass;}catch(_0x21ff54){return keyringLoadError=_0x21ff54 instanceof Error?_0x21ff54:new Error(String(_0x21ff54)),null;}}function getAccountName(_0x4d7f5e){const _0x1cd7dd=a49_0x6729f6,_0x252076=_0x4d7f5e||'';return'profile:'+_0x252076+_0x1cd7dd(0xc1);}function a49_0x145d(){const _0xf91f75=['not\x20supported','10638784vmdHaI','-25293','1100675iLyarI','@napi-rs/keyring','-25300','9uCurOa','130428bZKjyj','22VmILWx','message','3962880FBrNVE','toLowerCase','setPassword','error','Entry','65jrKYzu','227605wpOoXh','15202820KByGqr','success','access','234CYTHSc','__keychain_test__','260836MAaGMw',':api_key','could\x20not\x20be\x20found','not_found','unavailable','includes','not\x20found','access_denied','tdx','System\x20keychain\x20is\x20not\x20available'];a49_0x145d=function(){return _0xf91f75;};return a49_0x145d();}export async function getKeychainAPIKey(_0x54d2e2){const _0x5175a1=a49_0x6729f6,_0x643936=await getKeychainAPIKeyWithStatus(_0x54d2e2);if(_0x643936[_0x5175a1(0xbc)])return _0x643936['value'];return _0x643936['reason']===_0x5175a1(0xc7)&&console[_0x5175a1(0xb7)]('Warning:\x20'+_0x643936[_0x5175a1(0xd3)]),null;}export async function getKeychainAPIKeyWithStatus(_0xf7bb63){const _0x7f1f23=a49_0x6729f6;try{const _0x1a0974=await getEntryClass();if(!_0x1a0974)return{'success':![],'reason':_0x7f1f23(0xc4)};const _0x1451db=getAccountName(_0xf7bb63),_0x547643=new _0x1a0974(SERVICE_NAME,_0x1451db),_0x4afa0c=_0x547643['getPassword']();if(_0x4afa0c)return{'success':!![],'value':_0x4afa0c};return{'success':![],'reason':_0x7f1f23(0xc3)};}catch(_0x5f0fbb){const _0x5cc151=_0x5f0fbb instanceof Error?_0x5f0fbb['message']:String(_0x5f0fbb);if(_0x5cc151[_0x7f1f23(0xc5)](_0x7f1f23(0xcf))||_0x5cc151['toLowerCase']()[_0x7f1f23(0xc5)](_0x7f1f23(0xc2))||_0x5cc151[_0x7f1f23(0xd5)]()[_0x7f1f23(0xc5)](_0x7f1f23(0xc6))||_0x5cc151[_0x7f1f23(0xd5)]()['includes']('no\x20matching\x20entry'))return{'success':![],'reason':_0x7f1f23(0xc3)};if(_0x5cc151[_0x7f1f23(0xc5)](_0x7f1f23(0xcc))||_0x5cc151[_0x7f1f23(0xd5)]()[_0x7f1f23(0xc5)]('restricted')||_0x5cc151[_0x7f1f23(0xd5)]()[_0x7f1f23(0xc5)](_0x7f1f23(0xbd)))return{'success':![],'reason':_0x7f1f23(0xc7),'message':'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.'};return{'success':![],'reason':'unavailable','message':_0x5cc151};}}export async function saveKeychainAPIKey(_0x542ed6,_0x1f5815){const _0x13afee=a49_0x6729f6,_0x5efe4c=await getEntryClass();if(!_0x5efe4c)throw new Error(_0x13afee(0xc9));const _0x3b2e1d=getAccountName(_0x1f5815),_0x53a756=new _0x5efe4c(SERVICE_NAME,_0x3b2e1d);_0x53a756[_0x13afee(0xd6)](_0x542ed6);}export async function deleteKeychainAPIKey(_0x388800){try{const _0x262c6c=await getEntryClass();if(!_0x262c6c)return![];const _0x2bcb99=getAccountName(_0x388800),_0x1c7734=new _0x262c6c(SERVICE_NAME,_0x2bcb99);return _0x1c7734['deleteCredential'](),!![];}catch{return![];}}export async function isKeychainAvailable(){const _0x52570e=a49_0x6729f6;try{const _0x3f0e70=await getEntryClass();if(!_0x3f0e70)return![];const _0x30c6a5=new _0x3f0e70(SERVICE_NAME,_0x52570e(0xbf));return _0x30c6a5['getPassword'](),!![];}catch(_0x16091b){const _0x4847ef=_0x16091b instanceof Error?_0x16091b[_0x52570e(0xd3)][_0x52570e(0xd5)]():'';if(_0x4847ef[_0x52570e(0xc5)]('not\x20available')||_0x4847ef[_0x52570e(0xc5)](_0x52570e(0xca))||_0x4847ef[_0x52570e(0xc5)]('cannot\x20find'))return![];return!![];}}
|
package/dist/core/profile.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(_0x3dfc45,_0x1a2032){const _0x2cb707=a50_0x24c7,_0x2fb466=_0x3dfc45();while(!![]){try{const _0x58282d=-parseInt(_0x2cb707(0x8f))/0x1+-parseInt(_0x2cb707(0x96))/0x2*(-parseInt(_0x2cb707(0x81))/0x3)+parseInt(_0x2cb707(0x8a))/0x4*(parseInt(_0x2cb707(0xcd))/0x5)+parseInt(_0x2cb707(0x93))/0x6+-parseInt(_0x2cb707(0x8d))/0x7+parseInt(_0x2cb707(0xa7))/0x8*(parseInt(_0x2cb707(0xbe))/0x9)+parseInt(_0x2cb707(0xac))/0xa*(-parseInt(_0x2cb707(0xbd))/0xb);if(_0x58282d===_0x1a2032)break;else _0x2fb466['push'](_0x2fb466['shift']());}catch(_0x2d181c){_0x2fb466['push'](_0x2fb466['shift']());}}}(a50_0x2b05,0xa5ac4));import*as a50_0xabd6f8 from'node:fs';import*as a50_0x14892a 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 function getProfileParams(_0x3709a8){const _0x13d6a7=a50_0x24c7,_0x2aab93={};if(!_0x3709a8)return _0x2aab93;for(const [_0x81d20a,_0x4e5f91]of Object[_0x13d6a7(0xb7)](_0x3709a8)){_0x81d20a!==_0x13d6a7(0x94)&&_0x4e5f91!==undefined&&(_0x2aab93[_0x81d20a]=_0x4e5f91);}return _0x2aab93;}export function getProfilesDir(){const _0x2337cc=a50_0x24c7;return a50_0x14892a[_0x2337cc(0xcf)](getConfigDir(),'profiles');}function getProfileDir(_0x51fa39){const _0x561e9c=a50_0x24c7;return a50_0x14892a[_0x561e9c(0xcf)](getProfilesDir(),_0x51fa39);}function getProfileConfigPath(_0x572140){const _0x41576c=a50_0x24c7;return a50_0x14892a[_0x41576c(0xcf)](getProfileDir(_0x572140),'tdx.json');}function getProfileEnvPath(_0x4255bb){const _0x54ed86=a50_0x24c7;return a50_0x14892a[_0x54ed86(0xcf)](getProfileDir(_0x4255bb),'.env');}function getGlobalConfigPath(){const _0xf77308=a50_0x24c7;return a50_0x14892a[_0xf77308(0xcf)](getConfigDir(),'tdx.json');}function validateProfileName(_0x11f451){const _0x3a73a5=a50_0x24c7;if(!/^[a-zA-Z0-9_-]+$/['test'](_0x11f451))throw new Error(_0x3a73a5(0xbb)+_0x11f451+'.\x20Must\x20contain\x20only\x20alphanumeric\x20characters,\x20dash,\x20and\x20underscore.');}function validateProfileConfig(_0x5c4087,_0x46d826){const _0x27f34d=a50_0x24c7;if(typeof _0x5c4087!==_0x27f34d(0xc8)||_0x5c4087===null)throw new Error(_0x27f34d(0xd4)+_0x46d826+_0x27f34d(0xcc));const _0x3d0bf5=[_0x27f34d(0x94),_0x27f34d(0xaa),_0x27f34d(0xb1),_0x27f34d(0xa2),_0x27f34d(0xd3),_0x27f34d(0x8c)],_0x2465a9=_0x5c4087;for(const _0x1c322e of Object[_0x27f34d(0xa8)](_0x2465a9)){!_0x3d0bf5[_0x27f34d(0x92)](_0x1c322e)&&console[_0x27f34d(0xbf)](_0x27f34d(0xce)+_0x46d826+'\x27:\x20unknown\x20config\x20key\x20\x27'+_0x1c322e+'\x27\x20will\x20be\x20ignored');}if(_0x2465a9[_0x27f34d(0x94)]!==undefined&&typeof _0x2465a9[_0x27f34d(0x94)]!==_0x27f34d(0xc4))throw new Error(_0x27f34d(0xd4)+_0x46d826+_0x27f34d(0x85));if(_0x2465a9[_0x27f34d(0xaa)]!==undefined&&typeof _0x2465a9[_0x27f34d(0xaa)]!==_0x27f34d(0xc4))throw new Error(_0x27f34d(0xd4)+_0x46d826+_0x27f34d(0xa0));if(_0x2465a9[_0x27f34d(0xb1)]!==undefined&&typeof _0x2465a9[_0x27f34d(0xb1)]!==_0x27f34d(0xc4))throw new Error(_0x27f34d(0xd4)+_0x46d826+'\x27:\x20\x27database\x27\x20must\x20be\x20a\x20string');if(_0x2465a9['parent_segment']!==undefined&&typeof _0x2465a9[_0x27f34d(0xa2)]!=='string')throw new Error('Profile\x20\x27'+_0x46d826+_0x27f34d(0xa5));if(_0x2465a9['llm_project']!==undefined&&typeof _0x2465a9['llm_project']!==_0x27f34d(0xc4))throw new Error(_0x27f34d(0xd4)+_0x46d826+'\x27:\x20\x27llm_project\x27\x20must\x20be\x20a\x20string');if(_0x2465a9['llm_agent']!==undefined&&typeof _0x2465a9['llm_agent']!==_0x27f34d(0xc4))throw new Error(_0x27f34d(0xd4)+_0x46d826+_0x27f34d(0xa4));return!![];}function a50_0x2b05(){const _0x4fd7ed=['local','.env.','To\x20migrate:','profiles','\x27:\x20\x27site\x27\x20must\x20be\x20a\x20string','Please\x20migrate\x20to\x20~/.config/tdx/tdx.json:','parent_segment',',\x20creating\x20new\x20file','\x27:\x20\x27llm_agent\x27\x20must\x20be\x20a\x20string','\x27:\x20\x27parent_segment\x27\x20must\x20be\x20a\x20string','toISOString','1448024EXpwRK','keys','some','site','\x20\x202.\x20Add\x20profiles\x20under\x20a\x20\x22profiles\x22\x20key\x20(see\x20\x27tdx\x20profiles\x27\x20for\x20current\x20config)','61780IjMAQQ','\x20already\x20exists','values','Failed\x20to\x20parse\x20','user','database','Warning:\x20Failed\x20to\x20parse\x20','Error:\x20','\x22\x20\x22','map','directory','entries','\x27\x20not\x20found\x20in\x20user\x20configuration','isDirectory','stringify','Invalid\x20profile\x20name:\x20','set','55iWICaV','45TcYRWh','warn','readFileSync','localeCompare','env','from','string','parse','.env','\x20\x203.\x20Move\x20credentials:\x20mv\x20~/.config/tdx/profiles/<name>/.env\x20~/.config/tdx/.env.<name>\x0a','object','\x0aWarning:\x20Using\x20deprecated\x20credential\x20location\x20for\x20profile\x20\x27','readdirSync','TDX_PROFILE','\x27:\x20config\x20must\x20be\x20an\x20object','2292490ChBqzp','Warning:\x20Profile\x20\x27','join','sort','find','profile','llm_project','Profile\x20\x27','12IhRJNF','rmSync','filter','\x0aWarning:\x20Failed\x20to\x20parse\x20','\x27:\x20\x27description\x27\x20must\x20be\x20a\x20string','\x0aWarning:\x20Failed\x20to\x20load\x20profiles\x20from\x20','name','\x0aWarning:\x20Profiles\x20in\x20directories\x20are\x20deprecated:\x20','push','8nQhcYe','\x20does\x20not\x20exist','llm_agent','7923209rqKFoh','\x20\x20mv\x20\x22','1216055vWGLZE','Profile\x20','tdx.json','includes','4906734QGYWEX','description','existsSync','208814lKVnsa','length','message','\x0aWarning:\x20Skipping\x20invalid\x20profile\x20in\x20',':\x20Invalid\x20JSON\x20syntax','utf-8'];a50_0x2b05=function(){return _0x4fd7ed;};return a50_0x2b05();}function a50_0x24c7(_0x452335,_0x24d216){_0x452335=_0x452335-0x81;const _0x2b0558=a50_0x2b05();let _0x24c7c2=_0x2b0558[_0x452335];return _0x24c7c2;}function loadProfilesFromTdxJson(_0x523801,_0x2146c1){const _0x415ed7=a50_0x24c7;if(!a50_0xabd6f8[_0x415ed7(0x95)](_0x523801))return[];try{const _0x2a9229=a50_0xabd6f8[_0x415ed7(0xc0)](_0x523801,_0x415ed7(0x9b)),_0x1cf1d2=JSON['parse'](_0x2a9229);if(!_0x1cf1d2[_0x415ed7(0x9f)]||typeof _0x1cf1d2[_0x415ed7(0x9f)]!==_0x415ed7(0xc8))return[];const _0x4e4018=[];for(const [_0x4965a3,_0x1f48fe]of Object[_0x415ed7(0xb7)](_0x1cf1d2[_0x415ed7(0x9f)])){try{validateProfileConfig(_0x1f48fe,_0x4965a3);const _0x4875af=getNewCredentialPath(_0x4965a3),_0x2af206=getOldCredentialPath(_0x4965a3),_0x58ecbf=a50_0xabd6f8[_0x415ed7(0x95)](_0x4875af)||a50_0xabd6f8[_0x415ed7(0x95)](_0x2af206);_0x4e4018[_0x415ed7(0x89)]({'name':_0x4965a3,'config':_0x1f48fe,'metadata':{'name':_0x4965a3,'createdAt':new Date()[_0x415ed7(0xa6)]()},'hasCredentials':_0x58ecbf,'scope':_0x2146c1});}catch(_0x7f0712){_0x7f0712 instanceof Error&&(console[_0x415ed7(0xbf)](_0x415ed7(0x99)+_0x523801+':'),console[_0x415ed7(0xbf)]('\x20\x20'+_0x7f0712[_0x415ed7(0x98)]+'\x0a'));}}return _0x4e4018;}catch(_0x37ac18){return _0x37ac18 instanceof SyntaxError?(console['warn'](_0x415ed7(0x84)+_0x523801+_0x415ed7(0x9a)),console[_0x415ed7(0xbf)](_0x415ed7(0xb3)+_0x37ac18[_0x415ed7(0x98)]+'\x0a')):console[_0x415ed7(0xbf)](_0x415ed7(0x86)+_0x523801+':\x20'+_0x37ac18+'\x0a'),[];}}export function getNewCredentialPath(_0xb0ef2e){const _0x7333dc=a50_0x24c7;return a50_0x14892a[_0x7333dc(0xcf)](getConfigDir(),_0x7333dc(0x9d)+_0xb0ef2e);}function getOldCredentialPath(_0xa1a0c1){const _0xa1b7c0=a50_0x24c7;return a50_0x14892a['join'](getProfilesDir(),_0xa1a0c1,_0xa1b7c0(0xc6));}function loadProfilesFromTdxJsonFiles(){const _0x37d585=a50_0x24c7,_0x5c7ea1=[],_0x54d850=findProjectConfigPath();_0x54d850&&_0x5c7ea1[_0x37d585(0x89)](...loadProfilesFromTdxJson(_0x54d850,_0x37d585(0x9c)));const _0x3ec814=a50_0x14892a[_0x37d585(0xcf)](getConfigDir(),_0x37d585(0x91));return _0x5c7ea1[_0x37d585(0x89)](...loadProfilesFromTdxJson(_0x3ec814,_0x37d585(0xb0))),_0x5c7ea1;}function loadProfilesFromDirectories(){const _0x3d3c04=a50_0x24c7,_0xc48129=getProfilesDir();if(!a50_0xabd6f8[_0x3d3c04(0x95)](_0xc48129))return[];try{return a50_0xabd6f8[_0x3d3c04(0xca)](_0xc48129,{'withFileTypes':!![]})['filter'](_0x2c2c47=>_0x2c2c47[_0x3d3c04(0xb9)]())[_0x3d3c04(0xb5)](_0x36ae25=>_0x36ae25[_0x3d3c04(0x87)])[_0x3d3c04(0x83)](_0x326798=>{const _0x4fcdbc=_0x3d3c04,_0x92d985=getProfileConfigPath(_0x326798),_0x67c8bb=getProfileEnvPath(_0x326798);return a50_0xabd6f8['existsSync'](_0x92d985)||a50_0xabd6f8[_0x4fcdbc(0x95)](_0x67c8bb);})[_0x3d3c04(0xb5)](_0x232ed7=>{const _0x3fe9c8=_0x3d3c04,_0x3ebf1f=loadProfileFromDirectory(_0x232ed7);if(_0x3ebf1f)return{..._0x3ebf1f,'scope':_0x3fe9c8(0xb6)};return null;})[_0x3d3c04(0x83)](_0xe8bdf1=>_0xe8bdf1!==null);}catch{return[];}}function loadProfileFromDirectory(_0x5513bd){const _0x220e67=a50_0x24c7,_0xd2375=getProfileConfigPath(_0x5513bd),_0x3e12aa=getOldCredentialPath(_0x5513bd);if(!a50_0xabd6f8[_0x220e67(0x95)](_0xd2375)&&!a50_0xabd6f8[_0x220e67(0x95)](_0x3e12aa))return null;let _0x3dc4fc={},_0x274a0b={'name':_0x5513bd,'createdAt':new Date()[_0x220e67(0xa6)]()};if(a50_0xabd6f8[_0x220e67(0x95)](_0xd2375))try{const _0x4afa22=a50_0xabd6f8[_0x220e67(0xc0)](_0xd2375,_0x220e67(0x9b)),_0x2107e3=JSON[_0x220e67(0xc5)](_0x4afa22),{metadata:_0x1850bb,..._0x1a408c}=_0x2107e3;_0x3dc4fc=_0x1a408c,_0x1850bb&&(_0x274a0b=_0x1850bb);}catch{}return{'name':_0x5513bd,'config':_0x3dc4fc,'metadata':_0x274a0b,'hasCredentials':a50_0xabd6f8[_0x220e67(0x95)](_0x3e12aa),'scope':_0x220e67(0xb6)};}export function listProfiles(){const _0x3ececa=a50_0x24c7,_0x10ad1d=loadProfilesFromTdxJsonFiles(),_0x4d9309=loadProfilesFromDirectories();if(_0x4d9309[_0x3ececa(0x97)]>0x0){const _0x4b585f=_0x4d9309[_0x3ececa(0xb5)](_0x17afe0=>_0x17afe0[_0x3ececa(0x87)])['join'](',\x20'),_0x42619c=getConfigDir();console[_0x3ececa(0xbf)](_0x3ececa(0x88)+_0x4b585f),console[_0x3ececa(0xbf)](_0x3ececa(0xa1)),console['warn']('\x20\x201.\x20Edit:\x20'+a50_0x14892a[_0x3ececa(0xcf)](_0x42619c,'tdx.json')),console[_0x3ececa(0xbf)](_0x3ececa(0xab)),console[_0x3ececa(0xbf)](_0x3ececa(0xc7));}const _0x48d33c=[..._0x10ad1d,..._0x4d9309],_0x59019b=new Map();for(const _0x3aad13 of _0x48d33c){!_0x59019b['has'](_0x3aad13[_0x3ececa(0x87)])&&_0x59019b[_0x3ececa(0xbc)](_0x3aad13[_0x3ececa(0x87)],_0x3aad13);}return Array[_0x3ececa(0xc3)](_0x59019b[_0x3ececa(0xae)]())[_0x3ececa(0xd0)]((_0x8fa4b2,_0x14eed8)=>_0x8fa4b2[_0x3ececa(0x87)][_0x3ececa(0xc1)](_0x14eed8[_0x3ececa(0x87)]));}export function profileExists(_0x323fdb){const _0x2ec0d0=a50_0x24c7,_0x3931f7=listProfiles();return _0x3931f7[_0x2ec0d0(0xa9)](_0xd6ff9e=>_0xd6ff9e['name']===_0x323fdb);}export function loadProfile(_0x396198){const _0x19ad32=a50_0x24c7;validateProfileName(_0x396198);const _0x46169e=listProfiles(),_0x54d4bc=_0x46169e[_0x19ad32(0xd1)](_0x41e2b0=>_0x41e2b0[_0x19ad32(0x87)]===_0x396198);return _0x54d4bc||null;}export function saveProfile(_0x53e14d,_0x9f26d0,_0x2e8924=![]){saveProfileToUserConfig(_0x53e14d,_0x9f26d0);}export function deleteProfile(_0x1d3205){const _0xdb3504=a50_0x24c7;validateProfileName(_0x1d3205);const _0x3a2972=getProfileDir(_0x1d3205);if(!a50_0xabd6f8['existsSync'](_0x3a2972))throw new Error(_0xdb3504(0x90)+_0x1d3205+_0xdb3504(0x8b));a50_0xabd6f8[_0xdb3504(0x82)](_0x3a2972,{'recursive':!![],'force':!![]});}export function saveProfileToUserConfig(_0x1302d1,_0x3e51cf){const _0x6e3937=a50_0x24c7;validateProfileName(_0x1302d1);const _0x228e99=getGlobalConfigPath(),_0x517b2a=getConfigDir();!a50_0xabd6f8[_0x6e3937(0x95)](_0x517b2a)&&createSecureDirectory(_0x517b2a);let _0x4cb454={};if(a50_0xabd6f8[_0x6e3937(0x95)](_0x228e99))try{const _0x23c17d=a50_0xabd6f8[_0x6e3937(0xc0)](_0x228e99,_0x6e3937(0x9b));_0x4cb454=JSON[_0x6e3937(0xc5)](_0x23c17d);}catch{console['warn'](_0x6e3937(0xb2)+_0x228e99+',\x20creating\x20new\x20file');}!_0x4cb454[_0x6e3937(0x9f)]&&(_0x4cb454[_0x6e3937(0x9f)]={}),_0x4cb454['profiles'][_0x1302d1]=_0x3e51cf,writeSecureFile(_0x228e99,JSON[_0x6e3937(0xba)](_0x4cb454,null,0x2));}export function removeProfileFromUserConfig(_0xb9e17f){const _0x5ec3b1=a50_0x24c7;validateProfileName(_0xb9e17f);const _0x2cd46c=getGlobalConfigPath();if(!a50_0xabd6f8[_0x5ec3b1(0x95)](_0x2cd46c))throw new Error(_0x5ec3b1(0xd4)+_0xb9e17f+'\x27\x20not\x20found\x20in\x20user\x20configuration');let _0xd4645c={};try{const _0xc393aa=a50_0xabd6f8['readFileSync'](_0x2cd46c,_0x5ec3b1(0x9b));_0xd4645c=JSON['parse'](_0xc393aa);}catch{throw new Error(_0x5ec3b1(0xaf)+_0x2cd46c);}if(!_0xd4645c['profiles']||!_0xd4645c[_0x5ec3b1(0x9f)][_0xb9e17f])throw new Error(_0x5ec3b1(0xd4)+_0xb9e17f+_0x5ec3b1(0xb8));delete _0xd4645c[_0x5ec3b1(0x9f)][_0xb9e17f],_0xd4645c[_0x5ec3b1(0xd2)]===_0xb9e17f&&delete _0xd4645c['profile'],writeSecureFile(_0x2cd46c,JSON[_0x5ec3b1(0xba)](_0xd4645c,null,0x2));}export function getActiveProfile(){const _0x11a143=a50_0x24c7,_0x154086=loadSessionContext();if(_0x154086?.[_0x11a143(0xd2)])return _0x154086['profile'];if(process['env'][_0x11a143(0xcb)])return process[_0x11a143(0xc2)][_0x11a143(0xcb)];const _0x1d7ba7=getGlobalConfigPath();if(!a50_0xabd6f8[_0x11a143(0x95)](_0x1d7ba7))return null;try{const _0x12671f=a50_0xabd6f8[_0x11a143(0xc0)](_0x1d7ba7,_0x11a143(0x9b)),_0x1c920c=JSON[_0x11a143(0xc5)](_0x12671f);return _0x1c920c[_0x11a143(0xd2)]||null;}catch{return null;}}export function saveDefaultSiteToUserConfig(_0x4e0ae9){const _0x2a1791=a50_0x24c7,_0x53e965=getGlobalConfigPath(),_0x5d0f12=getConfigDir();!a50_0xabd6f8['existsSync'](_0x5d0f12)&&createSecureDirectory(_0x5d0f12);let _0x508532={};if(a50_0xabd6f8[_0x2a1791(0x95)](_0x53e965))try{const _0x315a0e=a50_0xabd6f8[_0x2a1791(0xc0)](_0x53e965,'utf-8');_0x508532=JSON[_0x2a1791(0xc5)](_0x315a0e);}catch{console[_0x2a1791(0xbf)]('Warning:\x20Failed\x20to\x20parse\x20'+_0x53e965+_0x2a1791(0xa3));}_0x508532[_0x2a1791(0xaa)]=_0x4e0ae9,writeSecureFile(_0x53e965,JSON[_0x2a1791(0xba)](_0x508532,null,0x2));}export function saveActiveProfileToUserConfig(_0x55d3d7){const _0x56d826=a50_0x24c7;validateProfileName(_0x55d3d7);const _0x483ab7=getGlobalConfigPath(),_0x5e951f=getConfigDir();!a50_0xabd6f8[_0x56d826(0x95)](_0x5e951f)&&createSecureDirectory(_0x5e951f);let _0x321443={};if(a50_0xabd6f8[_0x56d826(0x95)](_0x483ab7))try{const _0xd65329=a50_0xabd6f8[_0x56d826(0xc0)](_0x483ab7,_0x56d826(0x9b));_0x321443=JSON[_0x56d826(0xc5)](_0xd65329);}catch{console[_0x56d826(0xbf)](_0x56d826(0xb2)+_0x483ab7+_0x56d826(0xa3));}_0x321443[_0x56d826(0xd2)]=_0x55d3d7,writeSecureFile(_0x483ab7,JSON['stringify'](_0x321443,null,0x2));}function clearFieldFromUserConfig(_0x444e1a){const _0x409f47=a50_0x24c7,_0xc2122d=getGlobalConfigPath();if(!a50_0xabd6f8[_0x409f47(0x95)](_0xc2122d))return;let _0x5afcdd={};try{const _0x44dbe7=a50_0xabd6f8[_0x409f47(0xc0)](_0xc2122d,_0x409f47(0x9b));_0x5afcdd=JSON[_0x409f47(0xc5)](_0x44dbe7);}catch{return;}delete _0x5afcdd[_0x444e1a],writeSecureFile(_0xc2122d,JSON[_0x409f47(0xba)](_0x5afcdd,null,0x2));}export function clearDefaultSiteFromUserConfig(){const _0x32ceb0=a50_0x24c7;clearFieldFromUserConfig(_0x32ceb0(0xaa));}export function clearActiveProfileFromUserConfig(){const _0x1e4db0=a50_0x24c7;clearFieldFromUserConfig(_0x1e4db0(0xd2));}export function createProfile(_0x27b499,_0x3fda18){const _0x42730b=a50_0x24c7;validateProfileName(_0x27b499);if(profileExists(_0x27b499))throw new Error(_0x42730b(0x90)+_0x27b499+_0x42730b(0xad));saveProfile(_0x27b499,_0x3fda18);}export function saveProfileCredentials(_0x487226,_0x29abdf){const _0x2d9603=a50_0x24c7;validateProfileName(_0x487226);if(!profileExists(_0x487226))throw new Error('Profile\x20'+_0x487226+_0x2d9603(0x8b));const _0x23caf1=getNewCredentialPath(_0x487226);writeSecureFile(_0x23caf1,_0x29abdf);}export function loadProfileCredentials(_0xe58909){const _0x507584=a50_0x24c7;validateProfileName(_0xe58909);const _0xa649e5=getNewCredentialPath(_0xe58909);if(a50_0xabd6f8[_0x507584(0x95)](_0xa649e5))try{return a50_0xabd6f8[_0x507584(0xc0)](_0xa649e5,_0x507584(0x9b));}catch{}const _0x597099=getOldCredentialPath(_0xe58909);if(a50_0xabd6f8[_0x507584(0x95)](_0x597099)){console[_0x507584(0xbf)](_0x507584(0xc9)+_0xe58909+'\x27'),console[_0x507584(0xbf)](_0x507584(0x9e)),console[_0x507584(0xbf)](_0x507584(0x8e)+_0x597099+_0x507584(0xb4)+_0xa649e5+'\x22'),console[_0x507584(0xbf)]('Then\x20define\x20profiles\x20in\x20~/.config/tdx/tdx.json\x0a');try{return a50_0xabd6f8[_0x507584(0xc0)](_0x597099,'utf-8');}catch{return null;}}return null;}
|
|
1
|
+
(function(_0x2ab958,_0x418e62){const _0xaf91bd=a50_0x2422,_0x122469=_0x2ab958();while(!![]){try{const _0x1f9889=-parseInt(_0xaf91bd(0x22a))/0x1*(parseInt(_0xaf91bd(0x20d))/0x2)+-parseInt(_0xaf91bd(0x1ef))/0x3+-parseInt(_0xaf91bd(0x20b))/0x4*(-parseInt(_0xaf91bd(0x1ec))/0x5)+parseInt(_0xaf91bd(0x1ea))/0x6*(-parseInt(_0xaf91bd(0x1f4))/0x7)+-parseInt(_0xaf91bd(0x1ee))/0x8*(-parseInt(_0xaf91bd(0x214))/0x9)+-parseInt(_0xaf91bd(0x1e8))/0xa*(parseInt(_0xaf91bd(0x1ed))/0xb)+parseInt(_0xaf91bd(0x1f8))/0xc;if(_0x1f9889===_0x418e62)break;else _0x122469['push'](_0x122469['shift']());}catch(_0x140589){_0x122469['push'](_0x122469['shift']());}}}(a50_0x55a5,0xeec5a));import*as a50_0x3600a3 from'node:fs';import*as a50_0x2663f8 from'node:path';import{getConfigDir}from'./config.js';import{createSecureDirectory,writeSecureFile}from'../utils/file-permissions.js';function a50_0x2422(_0x1b90d5,_0x64dc44){_0x1b90d5=_0x1b90d5-0x1e1;const _0x55a565=a50_0x55a5();let _0x24221f=_0x55a565[_0x1b90d5];return _0x24221f;}import{findProjectConfigPath}from'./project-config.js';import{loadSessionContext}from'./session.js';export function getProfileParams(_0x28e563){const _0x26911f=a50_0x2422,_0x1bcfcc={};if(!_0x28e563)return _0x1bcfcc;for(const [_0x1afc86,_0x575080]of Object['entries'](_0x28e563)){_0x1afc86!==_0x26911f(0x209)&&_0x575080!==undefined&&(_0x1bcfcc[_0x1afc86]=_0x575080);}return _0x1bcfcc;}export function getProfilesDir(){const _0x3af7a4=a50_0x2422;return a50_0x2663f8[_0x3af7a4(0x221)](getConfigDir(),_0x3af7a4(0x204));}function getProfileDir(_0x451c3f){const _0x343376=a50_0x2422;return a50_0x2663f8[_0x343376(0x221)](getProfilesDir(),_0x451c3f);}function getProfileConfigPath(_0xf1e64b){const _0x2563d9=a50_0x2422;return a50_0x2663f8[_0x2563d9(0x221)](getProfileDir(_0xf1e64b),_0x2563d9(0x21b));}function getProfileEnvPath(_0x428534){const _0x217d16=a50_0x2422;return a50_0x2663f8[_0x217d16(0x221)](getProfileDir(_0x428534),_0x217d16(0x1f3));}function getGlobalConfigPath(){const _0x327fed=a50_0x2422;return a50_0x2663f8[_0x327fed(0x221)](getConfigDir(),'tdx.json');}function validateProfileName(_0x10de76){const _0x380d92=a50_0x2422;if(!/^[a-zA-Z0-9_-]+$/[_0x380d92(0x213)](_0x10de76))throw new Error(_0x380d92(0x1f6)+_0x10de76+_0x380d92(0x20a));}function validateProfileConfig(_0x2a25c4,_0x4ec057){const _0x4c4514=a50_0x2422;if(typeof _0x2a25c4!=='object'||_0x2a25c4===null)throw new Error(_0x4c4514(0x226)+_0x4ec057+_0x4c4514(0x202));const _0x541fcb=['description',_0x4c4514(0x1e9),_0x4c4514(0x228),_0x4c4514(0x229),_0x4c4514(0x1e1),_0x4c4514(0x1f0)],_0x48cf89=_0x2a25c4;for(const _0x29006a of Object[_0x4c4514(0x224)](_0x48cf89)){!_0x541fcb['includes'](_0x29006a)&&console['warn'](_0x4c4514(0x218)+_0x4ec057+_0x4c4514(0x222)+_0x29006a+_0x4c4514(0x225));}if(_0x48cf89[_0x4c4514(0x209)]!==undefined&&typeof _0x48cf89[_0x4c4514(0x209)]!==_0x4c4514(0x210))throw new Error(_0x4c4514(0x226)+_0x4ec057+'\x27:\x20\x27description\x27\x20must\x20be\x20a\x20string');if(_0x48cf89['site']!==undefined&&typeof _0x48cf89[_0x4c4514(0x1e9)]!=='string')throw new Error(_0x4c4514(0x226)+_0x4ec057+'\x27:\x20\x27site\x27\x20must\x20be\x20a\x20string');if(_0x48cf89[_0x4c4514(0x228)]!==undefined&&typeof _0x48cf89[_0x4c4514(0x228)]!==_0x4c4514(0x210))throw new Error('Profile\x20\x27'+_0x4ec057+'\x27:\x20\x27database\x27\x20must\x20be\x20a\x20string');if(_0x48cf89[_0x4c4514(0x229)]!==undefined&&typeof _0x48cf89[_0x4c4514(0x229)]!=='string')throw new Error(_0x4c4514(0x226)+_0x4ec057+'\x27:\x20\x27parent_segment\x27\x20must\x20be\x20a\x20string');if(_0x48cf89[_0x4c4514(0x1e1)]!==undefined&&typeof _0x48cf89[_0x4c4514(0x1e1)]!=='string')throw new Error(_0x4c4514(0x226)+_0x4ec057+'\x27:\x20\x27llm_project\x27\x20must\x20be\x20a\x20string');if(_0x48cf89[_0x4c4514(0x1f0)]!==undefined&&typeof _0x48cf89[_0x4c4514(0x1f0)]!==_0x4c4514(0x210))throw new Error('Profile\x20\x27'+_0x4ec057+_0x4c4514(0x219));return!![];}function loadProfilesFromTdxJson(_0x9a7dd1,_0x11f453){const _0x15eb65=a50_0x2422;if(!a50_0x3600a3['existsSync'](_0x9a7dd1))return[];try{const _0x14dd03=a50_0x3600a3[_0x15eb65(0x1e3)](_0x9a7dd1,_0x15eb65(0x216)),_0x7dbf70=JSON[_0x15eb65(0x207)](_0x14dd03);if(!_0x7dbf70['profiles']||typeof _0x7dbf70[_0x15eb65(0x204)]!==_0x15eb65(0x215))return[];const _0x38f7d1=[];for(const [_0x2884d9,_0x37fdf2]of Object[_0x15eb65(0x20f)](_0x7dbf70[_0x15eb65(0x204)])){try{validateProfileConfig(_0x37fdf2,_0x2884d9);const _0x2282eb=getNewCredentialPath(_0x2884d9),_0x53dfb5=getOldCredentialPath(_0x2884d9),_0x568bb8=a50_0x3600a3[_0x15eb65(0x1f1)](_0x2282eb)||a50_0x3600a3[_0x15eb65(0x1f1)](_0x53dfb5);_0x38f7d1[_0x15eb65(0x21f)]({'name':_0x2884d9,'config':_0x37fdf2,'metadata':{'name':_0x2884d9,'createdAt':new Date()[_0x15eb65(0x1e6)]()},'hasCredentials':_0x568bb8,'scope':_0x11f453});}catch(_0x1a07fa){_0x1a07fa instanceof Error&&(console[_0x15eb65(0x227)](_0x15eb65(0x1ff)+_0x9a7dd1+':'),console['warn']('\x20\x20'+_0x1a07fa[_0x15eb65(0x21c)]+'\x0a'));}}return _0x38f7d1;}catch(_0xac2236){return _0xac2236 instanceof SyntaxError?(console[_0x15eb65(0x227)](_0x15eb65(0x1f2)+_0x9a7dd1+':\x20Invalid\x20JSON\x20syntax'),console[_0x15eb65(0x227)]('Error:\x20'+_0xac2236[_0x15eb65(0x21c)]+'\x0a')):console[_0x15eb65(0x227)](_0x15eb65(0x1fe)+_0x9a7dd1+':\x20'+_0xac2236+'\x0a'),[];}}export function getNewCredentialPath(_0xea65b4){const _0x127b22=a50_0x2422;return a50_0x2663f8[_0x127b22(0x221)](getConfigDir(),_0x127b22(0x22b)+_0xea65b4);}function getOldCredentialPath(_0x55f477){const _0x1d8e6f=a50_0x2422;return a50_0x2663f8[_0x1d8e6f(0x221)](getProfilesDir(),_0x55f477,_0x1d8e6f(0x1f3));}function loadProfilesFromTdxJsonFiles(){const _0x3ee1ec=a50_0x2422,_0x5f465e=[],_0x397e02=findProjectConfigPath();_0x397e02&&_0x5f465e[_0x3ee1ec(0x21f)](...loadProfilesFromTdxJson(_0x397e02,_0x3ee1ec(0x1fd)));const _0x3f4168=a50_0x2663f8[_0x3ee1ec(0x221)](getConfigDir(),_0x3ee1ec(0x21b));return _0x5f465e[_0x3ee1ec(0x21f)](...loadProfilesFromTdxJson(_0x3f4168,'user')),_0x5f465e;}function loadProfilesFromDirectories(){const _0x4879db=a50_0x2422,_0x127b2d=getProfilesDir();if(!a50_0x3600a3[_0x4879db(0x1f1)](_0x127b2d))return[];try{return a50_0x3600a3[_0x4879db(0x212)](_0x127b2d,{'withFileTypes':!![]})[_0x4879db(0x1e4)](_0xaecf7b=>_0xaecf7b[_0x4879db(0x1f9)]())['map'](_0xd0fcc6=>_0xd0fcc6[_0x4879db(0x205)])['filter'](_0x5461f1=>{const _0x218a73=_0x4879db,_0x54e426=getProfileConfigPath(_0x5461f1),_0x2fb25e=getProfileEnvPath(_0x5461f1);return a50_0x3600a3[_0x218a73(0x1f1)](_0x54e426)||a50_0x3600a3[_0x218a73(0x1f1)](_0x2fb25e);})[_0x4879db(0x20e)](_0x1dd061=>{const _0x4a5b27=loadProfileFromDirectory(_0x1dd061);if(_0x4a5b27)return{..._0x4a5b27,'scope':'directory'};return null;})[_0x4879db(0x1e4)](_0x20efe3=>_0x20efe3!==null);}catch{return[];}}function loadProfileFromDirectory(_0x555c36){const _0x421f5a=a50_0x2422,_0x28463b=getProfileConfigPath(_0x555c36),_0x508883=getOldCredentialPath(_0x555c36);if(!a50_0x3600a3[_0x421f5a(0x1f1)](_0x28463b)&&!a50_0x3600a3[_0x421f5a(0x1f1)](_0x508883))return null;let _0x23ed0d={},_0x5f2886={'name':_0x555c36,'createdAt':new Date()[_0x421f5a(0x1e6)]()};if(a50_0x3600a3['existsSync'](_0x28463b))try{const _0xe33785=a50_0x3600a3[_0x421f5a(0x1e3)](_0x28463b,_0x421f5a(0x216)),_0x40b43b=JSON[_0x421f5a(0x207)](_0xe33785),{metadata:_0x571620,..._0x2ac744}=_0x40b43b;_0x23ed0d=_0x2ac744,_0x571620&&(_0x5f2886=_0x571620);}catch{}return{'name':_0x555c36,'config':_0x23ed0d,'metadata':_0x5f2886,'hasCredentials':a50_0x3600a3['existsSync'](_0x508883),'scope':'directory'};}export function listProfiles(){const _0x2d59ae=a50_0x2422,_0x2aa131=loadProfilesFromTdxJsonFiles(),_0xc32b41=loadProfilesFromDirectories();if(_0xc32b41['length']>0x0){const _0x362cb7=_0xc32b41[_0x2d59ae(0x20e)](_0x10298a=>_0x10298a[_0x2d59ae(0x205)])[_0x2d59ae(0x221)](',\x20'),_0x3a52a7=getConfigDir();console[_0x2d59ae(0x227)](_0x2d59ae(0x220)+_0x362cb7),console[_0x2d59ae(0x227)]('Please\x20migrate\x20to\x20~/.config/tdx/tdx.json:'),console['warn'](_0x2d59ae(0x1fb)+a50_0x2663f8['join'](_0x3a52a7,'tdx.json')),console[_0x2d59ae(0x227)](_0x2d59ae(0x1f5)),console[_0x2d59ae(0x227)]('\x20\x203.\x20Move\x20credentials:\x20mv\x20~/.config/tdx/profiles/<name>/.env\x20~/.config/tdx/.env.<name>\x0a');}const _0x34873b=[..._0x2aa131,..._0xc32b41],_0x429aba=new Map();for(const _0xd33dcb of _0x34873b){!_0x429aba['has'](_0xd33dcb['name'])&&_0x429aba['set'](_0xd33dcb[_0x2d59ae(0x205)],_0xd33dcb);}return Array[_0x2d59ae(0x1e7)](_0x429aba[_0x2d59ae(0x1fc)]())['sort']((_0xbf14e9,_0xa53c8a)=>_0xbf14e9[_0x2d59ae(0x205)][_0x2d59ae(0x223)](_0xa53c8a[_0x2d59ae(0x205)]));}export function profileExists(_0x44509b){const _0x5b36c3=a50_0x2422,_0x15c818=listProfiles();return _0x15c818['some'](_0x5d24c0=>_0x5d24c0[_0x5b36c3(0x205)]===_0x44509b);}export function loadProfile(_0x345d0f){const _0x4e6813=a50_0x2422;validateProfileName(_0x345d0f);const _0x4e429e=listProfiles(),_0x4f4ba0=_0x4e429e['find'](_0x12fc9a=>_0x12fc9a[_0x4e6813(0x205)]===_0x345d0f);return _0x4f4ba0||null;}export function saveProfile(_0x435964,_0x30c362,_0x4f0e7=![]){saveProfileToUserConfig(_0x435964,_0x30c362);}export function deleteProfile(_0x4158b1){const _0x40cc5c=a50_0x2422;validateProfileName(_0x4158b1);const _0x2788d5=getProfileDir(_0x4158b1);if(!a50_0x3600a3[_0x40cc5c(0x1f1)](_0x2788d5))throw new Error(_0x40cc5c(0x1e5)+_0x4158b1+_0x40cc5c(0x21d));a50_0x3600a3[_0x40cc5c(0x21a)](_0x2788d5,{'recursive':!![],'force':!![]});}export function saveProfileToUserConfig(_0x59d9db,_0x4f0c48){const _0x599405=a50_0x2422;validateProfileName(_0x59d9db);const _0x5d979c=getGlobalConfigPath(),_0x344c20=getConfigDir();!a50_0x3600a3[_0x599405(0x1f1)](_0x344c20)&&createSecureDirectory(_0x344c20);let _0x35e6ba={};if(a50_0x3600a3['existsSync'](_0x5d979c))try{const _0x80f0b9=a50_0x3600a3['readFileSync'](_0x5d979c,_0x599405(0x216));_0x35e6ba=JSON[_0x599405(0x207)](_0x80f0b9);}catch{console[_0x599405(0x227)]('Warning:\x20Failed\x20to\x20parse\x20'+_0x5d979c+_0x599405(0x1fa));}!_0x35e6ba[_0x599405(0x204)]&&(_0x35e6ba[_0x599405(0x204)]={}),_0x35e6ba[_0x599405(0x204)][_0x59d9db]=_0x4f0c48,writeSecureFile(_0x5d979c,JSON['stringify'](_0x35e6ba,null,0x2));}export function removeProfileFromUserConfig(_0x1288f8){const _0x355168=a50_0x2422;validateProfileName(_0x1288f8);const _0x2afb2e=getGlobalConfigPath();if(!a50_0x3600a3[_0x355168(0x1f1)](_0x2afb2e))throw new Error(_0x355168(0x226)+_0x1288f8+_0x355168(0x211));let _0x17997d={};try{const _0x4bc202=a50_0x3600a3[_0x355168(0x1e3)](_0x2afb2e,'utf-8');_0x17997d=JSON[_0x355168(0x207)](_0x4bc202);}catch{throw new Error(_0x355168(0x203)+_0x2afb2e);}if(!_0x17997d[_0x355168(0x204)]||!_0x17997d[_0x355168(0x204)][_0x1288f8])throw new Error('Profile\x20\x27'+_0x1288f8+_0x355168(0x211));delete _0x17997d['profiles'][_0x1288f8],_0x17997d[_0x355168(0x208)]===_0x1288f8&&delete _0x17997d[_0x355168(0x208)],writeSecureFile(_0x2afb2e,JSON[_0x355168(0x1f7)](_0x17997d,null,0x2));}export function getActiveProfile(){const _0x2c0bad=a50_0x2422,_0x562f5c=loadSessionContext();if(_0x562f5c?.['profile'])return _0x562f5c['profile'];if(process[_0x2c0bad(0x200)]['TDX_PROFILE'])return process['env'][_0x2c0bad(0x1eb)];const _0x3d13b8=getGlobalConfigPath();if(!a50_0x3600a3[_0x2c0bad(0x1f1)](_0x3d13b8))return null;try{const _0x3e0924=a50_0x3600a3[_0x2c0bad(0x1e3)](_0x3d13b8,_0x2c0bad(0x216)),_0x2e6071=JSON[_0x2c0bad(0x207)](_0x3e0924);return _0x2e6071[_0x2c0bad(0x208)]||null;}catch{return null;}}function a50_0x55a5(){const _0x3d5e59=['filter','Profile\x20','toISOString','from','120CVduoe','site','540858vKcTwu','TDX_PROFILE','10950fUZAbB','1251283eqZCaf','1832ZeBEhb','1523319YfpHXy','llm_agent','existsSync','\x0aWarning:\x20Failed\x20to\x20parse\x20','.env','77mBEtvc','\x20\x202.\x20Add\x20profiles\x20under\x20a\x20\x22profiles\x22\x20key\x20(see\x20\x27tdx\x20profiles\x27\x20for\x20current\x20config)','Invalid\x20profile\x20name:\x20','stringify','46477452DwKRtg','isDirectory',',\x20creating\x20new\x20file','\x20\x201.\x20Edit:\x20','values','local','\x0aWarning:\x20Failed\x20to\x20load\x20profiles\x20from\x20','\x0aWarning:\x20Skipping\x20invalid\x20profile\x20in\x20','env','Warning:\x20Failed\x20to\x20parse\x20','\x27:\x20config\x20must\x20be\x20an\x20object','Failed\x20to\x20parse\x20','profiles','name','Then\x20define\x20profiles\x20in\x20~/.config/tdx/tdx.json\x0a','parse','profile','description','.\x20Must\x20contain\x20only\x20alphanumeric\x20characters,\x20dash,\x20and\x20underscore.','2108QoXPkf','\x20already\x20exists','2xCrVjZ','map','entries','string','\x27\x20not\x20found\x20in\x20user\x20configuration','readdirSync','test','19683YIqAVa','object','utf-8','\x0aWarning:\x20Using\x20deprecated\x20credential\x20location\x20for\x20profile\x20\x27','Warning:\x20Profile\x20\x27','\x27:\x20\x27llm_agent\x27\x20must\x20be\x20a\x20string','rmSync','tdx.json','message','\x20does\x20not\x20exist','\x20\x20mv\x20\x22','push','\x0aWarning:\x20Profiles\x20in\x20directories\x20are\x20deprecated:\x20','join','\x27:\x20unknown\x20config\x20key\x20\x27','localeCompare','keys','\x27\x20will\x20be\x20ignored','Profile\x20\x27','warn','database','parent_segment','1685682EHRcaB','.env.','llm_project','To\x20migrate:','readFileSync'];a50_0x55a5=function(){return _0x3d5e59;};return a50_0x55a5();}export function saveDefaultSiteToUserConfig(_0x5c33c5){const _0x1a20c6=a50_0x2422,_0x258c15=getGlobalConfigPath(),_0x46b565=getConfigDir();!a50_0x3600a3[_0x1a20c6(0x1f1)](_0x46b565)&&createSecureDirectory(_0x46b565);let _0x3d1580={};if(a50_0x3600a3[_0x1a20c6(0x1f1)](_0x258c15))try{const _0xb7cfd0=a50_0x3600a3[_0x1a20c6(0x1e3)](_0x258c15,_0x1a20c6(0x216));_0x3d1580=JSON[_0x1a20c6(0x207)](_0xb7cfd0);}catch{console[_0x1a20c6(0x227)](_0x1a20c6(0x201)+_0x258c15+_0x1a20c6(0x1fa));}_0x3d1580[_0x1a20c6(0x1e9)]=_0x5c33c5,writeSecureFile(_0x258c15,JSON[_0x1a20c6(0x1f7)](_0x3d1580,null,0x2));}export function saveActiveProfileToUserConfig(_0x4ded85){const _0x5189e3=a50_0x2422;validateProfileName(_0x4ded85);const _0x337ea9=getGlobalConfigPath(),_0xa9557=getConfigDir();!a50_0x3600a3[_0x5189e3(0x1f1)](_0xa9557)&&createSecureDirectory(_0xa9557);let _0x179901={};if(a50_0x3600a3['existsSync'](_0x337ea9))try{const _0x46ea19=a50_0x3600a3[_0x5189e3(0x1e3)](_0x337ea9,_0x5189e3(0x216));_0x179901=JSON['parse'](_0x46ea19);}catch{console[_0x5189e3(0x227)]('Warning:\x20Failed\x20to\x20parse\x20'+_0x337ea9+',\x20creating\x20new\x20file');}_0x179901['profile']=_0x4ded85,writeSecureFile(_0x337ea9,JSON[_0x5189e3(0x1f7)](_0x179901,null,0x2));}function clearFieldFromUserConfig(_0x1bf92b){const _0x291841=a50_0x2422,_0x3c9d28=getGlobalConfigPath();if(!a50_0x3600a3[_0x291841(0x1f1)](_0x3c9d28))return;let _0x44bf63={};try{const _0x4e219c=a50_0x3600a3[_0x291841(0x1e3)](_0x3c9d28,_0x291841(0x216));_0x44bf63=JSON[_0x291841(0x207)](_0x4e219c);}catch{return;}delete _0x44bf63[_0x1bf92b],writeSecureFile(_0x3c9d28,JSON[_0x291841(0x1f7)](_0x44bf63,null,0x2));}export function clearDefaultSiteFromUserConfig(){clearFieldFromUserConfig('site');}export function clearActiveProfileFromUserConfig(){clearFieldFromUserConfig('profile');}export function createProfile(_0x59c2e9,_0x3ef858){const _0x1234c9=a50_0x2422;validateProfileName(_0x59c2e9);if(profileExists(_0x59c2e9))throw new Error('Profile\x20'+_0x59c2e9+_0x1234c9(0x20c));saveProfile(_0x59c2e9,_0x3ef858);}export function saveProfileCredentials(_0xa48f03,_0x3b7732){const _0x267a1c=a50_0x2422;validateProfileName(_0xa48f03);if(!profileExists(_0xa48f03))throw new Error(_0x267a1c(0x1e5)+_0xa48f03+_0x267a1c(0x21d));const _0x1b826e=getNewCredentialPath(_0xa48f03);writeSecureFile(_0x1b826e,_0x3b7732);}export function loadProfileCredentials(_0x3cc237){const _0x5a813a=a50_0x2422;validateProfileName(_0x3cc237);const _0x577403=getNewCredentialPath(_0x3cc237);if(a50_0x3600a3[_0x5a813a(0x1f1)](_0x577403))try{return a50_0x3600a3['readFileSync'](_0x577403,_0x5a813a(0x216));}catch{}const _0x1a6115=getOldCredentialPath(_0x3cc237);if(a50_0x3600a3[_0x5a813a(0x1f1)](_0x1a6115)){console[_0x5a813a(0x227)](_0x5a813a(0x217)+_0x3cc237+'\x27'),console[_0x5a813a(0x227)](_0x5a813a(0x1e2)),console[_0x5a813a(0x227)](_0x5a813a(0x21e)+_0x1a6115+'\x22\x20\x22'+_0x577403+'\x22'),console[_0x5a813a(0x227)](_0x5a813a(0x206));try{return a50_0x3600a3[_0x5a813a(0x1e3)](_0x1a6115,_0x5a813a(0x216));}catch{return null;}}return null;}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a51_0x4556f6=a51_0x429a;function a51_0x429a(_0x3063f1,_0x565033){_0x3063f1=_0x3063f1-0x7e;const _0x126fea=a51_0x126f();let _0x429abc=_0x126fea[_0x3063f1];return _0x429abc;}(function(_0xe8fc87,_0x6ada60){const _0x10444d=a51_0x429a,_0x55b356=_0xe8fc87();while(!![]){try{const _0x1b4577=parseInt(_0x10444d(0x8f))/0x1+-parseInt(_0x10444d(0x98))/0x2+-parseInt(_0x10444d(0x84))/0x3+-parseInt(_0x10444d(0x91))/0x4*(parseInt(_0x10444d(0x9c))/0x5)+-parseInt(_0x10444d(0x8c))/0x6*(parseInt(_0x10444d(0x93))/0x7)+parseInt(_0x10444d(0x99))/0x8*(parseInt(_0x10444d(0x85))/0x9)+-parseInt(_0x10444d(0x94))/0xa*(-parseInt(_0x10444d(0x8a))/0xb);if(_0x1b4577===_0x6ada60)break;else _0x55b356['push'](_0x55b356['shift']());}catch(_0x4643cd){_0x55b356['push'](_0x55b356['shift']());}}}(a51_0x126f,0xd2685));import*as a51_0x5e690d from'node:fs';import*as a51_0x19e40d from'node:path';const PROJECT_CONFIG_FILENAME=a51_0x4556f6(0x8d);export function findProjectConfigPath(_0x543dc9){const _0x4a4b8c=a51_0x4556f6;let _0x3ef60d=_0x543dc9||process[_0x4a4b8c(0x80)]();while(!![]){const _0x4614df=a51_0x19e40d['join'](_0x3ef60d,PROJECT_CONFIG_FILENAME);if(a51_0x5e690d[_0x4a4b8c(0x9e)](_0x4614df))return _0x4614df;const _0xacf902=a51_0x19e40d[_0x4a4b8c(0x89)](_0x3ef60d);if(_0xacf902===_0x3ef60d)return null;_0x3ef60d=_0xacf902;}}function a51_0x126f(){const _0x55ff9d=['415220Kaevsh','api_key','existsSync','join','includes','warn','cwd','\x27profile\x27\x20should\x20not\x20be\x20set\x20in\x20project\x20config.\x20Use\x20\x27tdx\x20profile\x20use\x27\x20instead.','\x20is\x20ignored.\x20','Active\x20profile\x20is\x20set\x20in\x20~/.config/tdx/tdx.json','3018480HNJeSX','13086jiDkcn','API\x20keys\x20must\x20not\x20be\x20stored\x20in\x20project\x20configuration.\x20Use\x20.env\x20files\x20instead.','writeFileSync','profile','dirname','7711blostP','code','42QkXNma','tdx.json','utf-8','45528MpkthX','stringify','16jybVne','ENOENT','1490951COnRkr','42970CuOgaX','TD_API_KEY','Use\x20~/.config/tdx/.env\x20or\x20profile\x20.env\x20files\x20instead.','readFileSync','131966TjoTvL','3848ZzwAyb','Security\x20error:\x20API\x20keys\x20must\x20not\x20be\x20stored\x20in\x20project\x20config\x20(','Warning:\x20\x27profile\x27\x20field\x20in\x20'];a51_0x126f=function(){return _0x55ff9d;};return a51_0x126f();}export function loadProjectConfig(_0x4742db){const _0x1b42c8=a51_0x4556f6,_0x2ca36d=findProjectConfigPath(_0x4742db);if(!_0x2ca36d)return null;try{const _0x432dbf=a51_0x5e690d[_0x1b42c8(0x97)](_0x2ca36d,_0x1b42c8(0x8e)),_0xdf6e15=JSON['parse'](_0x432dbf),_0x2a3158=JSON[_0x1b42c8(0x90)](_0xdf6e15);if(_0x2a3158['includes']('TD_API_KEY')||_0x2a3158[_0x1b42c8(0x7e)]('apiKey')||_0x2a3158['includes'](_0x1b42c8(0x9d)))throw new Error(_0x1b42c8(0x9a)+_0x2ca36d+').\x20'+_0x1b42c8(0x96));const {metadata:_0x355087,profile:_0x4a058a,..._0x2a3787}=_0xdf6e15;return _0x4a058a&&console[_0x1b42c8(0x7f)](_0x1b42c8(0x9b)+_0x2ca36d+_0x1b42c8(0x82)+_0x1b42c8(0x83)),_0x2a3787;}catch(_0x3608a3){if(_0x3608a3 instanceof Error&&_0x1b42c8(0x8b)in _0x3608a3&&_0x3608a3[_0x1b42c8(0x8b)]===_0x1b42c8(0x92))return null;throw new Error('Failed\x20to\x20load\x20project\x20config\x20from\x20'+_0x2ca36d+':\x20'+_0x3608a3);}}export function saveProjectConfig(_0x250e43,_0x518f0a){const _0x41f079=a51_0x4556f6,_0xfb8d82=_0x518f0a||process[_0x41f079(0x80)](),_0x13ecf3=a51_0x19e40d[_0x41f079(0x9f)](_0xfb8d82,PROJECT_CONFIG_FILENAME),_0x2f0adc=JSON[_0x41f079(0x90)](_0x250e43);if(_0x2f0adc[_0x41f079(0x7e)](_0x41f079(0x95))||_0x2f0adc[_0x41f079(0x7e)]('apiKey')||_0x2f0adc[_0x41f079(0x7e)](_0x41f079(0x9d)))throw new Error(_0x41f079(0x86));if(_0x41f079(0x88)in _0x250e43)throw new Error(_0x41f079(0x81));a51_0x5e690d[_0x41f079(0x87)](_0x13ecf3,JSON[_0x41f079(0x90)](_0x250e43,null,0x2));}export function hasProjectConfig(_0x384205){return findProjectConfigPath(_0x384205)!==null;}export function getProjectRoot(_0x3f9614){const _0x719c27=a51_0x4556f6,_0x43515f=findProjectConfigPath(_0x3f9614);return _0x43515f?a51_0x19e40d[_0x719c27(0x89)](_0x43515f):null;}
|
package/dist/core/session.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(_0x4f3a77,_0x23c7a3){const _0x2f8025=a52_0x507e,_0x638831=_0x4f3a77();while(!![]){try{const _0x5a973d=parseInt(_0x2f8025(0x1f4))/0x1+-parseInt(_0x2f8025(0x1dd))/0x2+-parseInt(_0x2f8025(0x1f3))/0x3+-parseInt(_0x2f8025(0x1f0))/0x4*(-parseInt(_0x2f8025(0x1d7))/0x5)+parseInt(_0x2f8025(0x1e2))/0x6*(parseInt(_0x2f8025(0x1dc))/0x7)+parseInt(_0x2f8025(0x1cd))/0x8*(parseInt(_0x2f8025(0x1d5))/0x9)+-parseInt(_0x2f8025(0x1e8))/0xa;if(_0x5a973d===_0x23c7a3)break;else _0x638831['push'](_0x638831['shift']());}catch(_0x222c0f){_0x638831['push'](_0x638831['shift']());}}}(a52_0x41b9,0xace45));import*as a52_0x117241 from'node:fs';import*as a52_0x282eb9 from'node:path';import*as a52_0x37f626 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 _0x107101=a52_0x507e,_0x67e83e=process[_0x107101(0x1db)]['TDX_CONFIG_DIR']||a52_0x282eb9[_0x107101(0x1d0)](a52_0x37f626[_0x107101(0x1e0)](),_0x107101(0x1ec),_0x107101(0x1d6));return a52_0x282eb9[_0x107101(0x1d0)](_0x67e83e,_0x107101(0x1ea));}function getSessionPath(_0x1d0180){const _0x13d5ed=a52_0x507e;return a52_0x282eb9[_0x13d5ed(0x1d0)](getSessionsDir(),_0x1d0180+_0x13d5ed(0x1d2));}export function getCurrentSessionPID(){return getPPID();}export function getSessionID(_0x4a584b){const _0x370d56=a52_0x507e;if(_0x4a584b)return _0x4a584b;return getCurrentSessionPID()[_0x370d56(0x1f6)]();}export function loadSessionContext(_0x1c6399){const _0x1c8036=a52_0x507e,_0xd99c4b=_0x1c6399||getCurrentSessionPID()[_0x1c8036(0x1f6)](),_0x20d176=/^\d+$/['test'](_0xd99c4b)?parseInt(_0xd99c4b,0xa):null;return _0x20d176!==null?loadSessionContextByPID(_0x20d176):loadSessionContextByString(_0xd99c4b);}export function loadSessionContextByPID(_0x49e3f9){const _0x264aaf=a52_0x507e,_0x5bbb1c=getSessionPath(_0x49e3f9);if(!a52_0x117241['existsSync'](_0x5bbb1c))return null;try{const _0x4c5f0b=a52_0x117241['readFileSync'](_0x5bbb1c,_0x264aaf(0x1cf)),_0x1f4b21=JSON[_0x264aaf(0x1d8)](_0x4c5f0b),_0x370217=new Date(_0x1f4b21[_0x264aaf(0x1e6)])['getTime'](),_0x23905d=Date['now']();if(_0x23905d-_0x370217>SESSION_EXPIRATION_MS)return a52_0x117241[_0x264aaf(0x1eb)](_0x5bbb1c),null;const _0x1067f0=JSON[_0x264aaf(0x1e4)](_0x1f4b21);if(_0x1067f0[_0x264aaf(0x1ee)](_0x264aaf(0x1da))||_0x1067f0[_0x264aaf(0x1ee)](_0x264aaf(0x1f1))||_0x1067f0['includes'](_0x264aaf(0x1e9)))return console[_0x264aaf(0x1f5)](_0x264aaf(0x1e3)+_0x5bbb1c+_0x264aaf(0x1d4)),a52_0x117241[_0x264aaf(0x1eb)](_0x5bbb1c),null;return _0x1f4b21;}catch{try{a52_0x117241[_0x264aaf(0x1eb)](_0x5bbb1c);}catch{}return null;}}function loadSessionContextByString(_0x16f2d5){const _0x4e9947=a52_0x507e,_0x3b7a16=a52_0x282eb9[_0x4e9947(0x1d0)](getSessionsDir(),_0x16f2d5+_0x4e9947(0x1d2));if(!a52_0x117241[_0x4e9947(0x1de)](_0x3b7a16))return null;try{const _0x404932=a52_0x117241['readFileSync'](_0x3b7a16,_0x4e9947(0x1cf)),_0xdac8a7=JSON[_0x4e9947(0x1d8)](_0x404932),_0x289634=new Date(_0xdac8a7[_0x4e9947(0x1e6)])[_0x4e9947(0x1ce)](),_0x5d1cd2=Date[_0x4e9947(0x1e7)]();if(_0x5d1cd2-_0x289634>SESSION_EXPIRATION_MS)return a52_0x117241[_0x4e9947(0x1eb)](_0x3b7a16),null;const _0x1d75ba=JSON[_0x4e9947(0x1e4)](_0xdac8a7);if(_0x1d75ba[_0x4e9947(0x1ee)](_0x4e9947(0x1da))||_0x1d75ba[_0x4e9947(0x1ee)](_0x4e9947(0x1f1))||_0x1d75ba[_0x4e9947(0x1ee)](_0x4e9947(0x1e9)))return console['warn'](_0x4e9947(0x1e3)+_0x3b7a16+_0x4e9947(0x1d4)),a52_0x117241['unlinkSync'](_0x3b7a16),null;return _0xdac8a7;}catch{try{a52_0x117241[_0x4e9947(0x1eb)](_0x3b7a16);}catch{}return null;}}export function saveSessionContext(_0x1a45ce,_0x3c41b1){const _0x5b9e2b=a52_0x507e,_0x46408a=_0x3c41b1||getCurrentSessionPID()[_0x5b9e2b(0x1f6)](),_0xdb2db9=/^\d+$/['test'](_0x46408a)?parseInt(_0x46408a,0xa):getCurrentSessionPID(),_0x102891=a52_0x282eb9['join'](getSessionsDir(),_0x46408a+_0x5b9e2b(0x1d2)),_0x1df578=getSessionsDir();createSecureDirectory(_0x1df578);const _0x52f557=JSON[_0x5b9e2b(0x1e4)](_0x1a45ce);if(_0x52f557[_0x5b9e2b(0x1ee)](_0x5b9e2b(0x1da))||_0x52f557[_0x5b9e2b(0x1ee)](_0x5b9e2b(0x1f1))||_0x52f557[_0x5b9e2b(0x1ee)](_0x5b9e2b(0x1e9)))throw new Error(_0x5b9e2b(0x1ed));let _0x27d554;const _0x254862=/^\d+$/[_0x5b9e2b(0x1ef)](_0x46408a)?loadSessionContextByPID(parseInt(_0x46408a,0xa)):loadSessionContextByString(_0x46408a);_0x254862?_0x27d554={..._0x254862,..._0x1a45ce,'pid':_0xdb2db9,'sessionId':_0x46408a!==_0xdb2db9[_0x5b9e2b(0x1f6)]()?_0x46408a:undefined,'updatedAt':new Date()[_0x5b9e2b(0x1cc)]()}:_0x27d554={'pid':_0xdb2db9,'sessionId':_0x46408a!==_0xdb2db9[_0x5b9e2b(0x1f6)]()?_0x46408a:undefined,..._0x1a45ce,'createdAt':new Date()[_0x5b9e2b(0x1cc)](),'updatedAt':new Date()[_0x5b9e2b(0x1cc)]()},a52_0x117241[_0x5b9e2b(0x1d1)](_0x102891,JSON[_0x5b9e2b(0x1e4)](_0x27d554,null,0x2));}function a52_0x41b9(){const _0x419f07=['2694fiWriA','Warning:\x20API\x20keys\x20found\x20in\x20session\x20file\x20','stringify','readFileSync','createdAt','now','10492200ZubokZ','api_key','sessions','unlinkSync','.config','API\x20keys\x20must\x20not\x20be\x20stored\x20in\x20session\x20context.\x20Use\x20.env\x20files\x20instead.','includes','test','4Ntvxhq','apiKey','sort','728613cHwPzd','947474mTxQij','warn','toString','toISOString','797416wekhaA','getTime','utf-8','join','writeFileSync','.json','endsWith','.\x20This\x20is\x20insecure.\x20Removing\x20session.','27YIAxUU','tdx','6068070ycEqyE','parse','push','TD_API_KEY','env','4228NcegAw','1462118WqTBUy','existsSync','replace','homedir','readdirSync'];a52_0x41b9=function(){return _0x419f07;};return a52_0x41b9();}export function clearSessionContext(_0x54f003){const _0x279f5c=a52_0x507e,_0x81602f=_0x54f003||getCurrentSessionPID()[_0x279f5c(0x1f6)](),_0x32614b=a52_0x282eb9[_0x279f5c(0x1d0)](getSessionsDir(),_0x81602f+'.json');a52_0x117241['existsSync'](_0x32614b)&&a52_0x117241[_0x279f5c(0x1eb)](_0x32614b);}export function clearSessionContextField(_0x4242ba,_0x57d62d){const _0x1bebc0=a52_0x507e,_0x3c62cd=_0x57d62d||getCurrentSessionPID()[_0x1bebc0(0x1f6)](),_0x152a6e=a52_0x282eb9[_0x1bebc0(0x1d0)](getSessionsDir(),_0x3c62cd+_0x1bebc0(0x1d2));if(!a52_0x117241[_0x1bebc0(0x1de)](_0x152a6e))return;try{const _0x404cc7=a52_0x117241[_0x1bebc0(0x1e5)](_0x152a6e,_0x1bebc0(0x1cf)),_0x4d9324=JSON['parse'](_0x404cc7);delete _0x4d9324[_0x4242ba],a52_0x117241['writeFileSync'](_0x152a6e,JSON[_0x1bebc0(0x1e4)](_0x4d9324,null,0x2));}catch{}}export function cleanExpiredSessions(){const _0x56643f=a52_0x507e,_0x21166e=getSessionsDir();if(!a52_0x117241['existsSync'](_0x21166e))return 0x0;let _0x25eec8=0x0;const _0x11b138=Date['now']();try{const _0x31bcf8=a52_0x117241[_0x56643f(0x1e1)](_0x21166e);for(const _0x5c792e of _0x31bcf8){if(!_0x5c792e[_0x56643f(0x1d3)](_0x56643f(0x1d2)))continue;const _0x100447=a52_0x282eb9['join'](_0x21166e,_0x5c792e),_0x35ac0e=_0x5c792e[_0x56643f(0x1df)](_0x56643f(0x1d2),''),_0x473beb=parseInt(_0x35ac0e,0xa),_0x1dc4d=!isNaN(_0x473beb);if(_0x1dc4d){if(!isProcessRunning(_0x473beb)){a52_0x117241[_0x56643f(0x1eb)](_0x100447),_0x25eec8++;continue;}}try{const _0x38b439=a52_0x117241[_0x56643f(0x1e5)](_0x100447,_0x56643f(0x1cf)),_0xff8b5c=JSON[_0x56643f(0x1d8)](_0x38b439),_0x4691d2=new Date(_0xff8b5c[_0x56643f(0x1e6)])['getTime']();_0x11b138-_0x4691d2>SESSION_EXPIRATION_MS&&(a52_0x117241['unlinkSync'](_0x100447),_0x25eec8++);}catch{a52_0x117241[_0x56643f(0x1eb)](_0x100447),_0x25eec8++;}}}catch{}return _0x25eec8;}function a52_0x507e(_0x27cacf,_0xc21b8f){_0x27cacf=_0x27cacf-0x1cc;const _0x41b945=a52_0x41b9();let _0x507ec5=_0x41b945[_0x27cacf];return _0x507ec5;}export function listActiveSessions(){const _0x5e3dcc=a52_0x507e,_0x1a50f6=getSessionsDir();if(!a52_0x117241['existsSync'](_0x1a50f6))return[];try{const _0x32b0c2=a52_0x117241[_0x5e3dcc(0x1e1)](_0x1a50f6),_0x5ec14f=[];for(const _0x349277 of _0x32b0c2){if(!_0x349277['endsWith'](_0x5e3dcc(0x1d2)))continue;const _0x32ee55=_0x349277['replace']('.json',''),_0x2f4402=parseInt(_0x32ee55,0xa);!isNaN(_0x2f4402)&&isProcessRunning(_0x2f4402)&&_0x5ec14f[_0x5e3dcc(0x1d9)](_0x2f4402);}return _0x5ec14f[_0x5e3dcc(0x1f2)]((_0x549159,_0x26357d)=>_0x549159-_0x26357d);}catch{return[];}}
|
package/dist/core/user-cache.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a53_0x552027=a53_0x285b;(function(_0x2e05b9,_0x1669e3){const _0xc4ad30=a53_0x285b,_0x174510=_0x2e05b9();while(!![]){try{const _0xa089c7=parseInt(_0xc4ad30(0x12b))/0x1*(-parseInt(_0xc4ad30(0x121))/0x2)+parseInt(_0xc4ad30(0x129))/0x3+-parseInt(_0xc4ad30(0x127))/0x4+-parseInt(_0xc4ad30(0x12a))/0x5*(parseInt(_0xc4ad30(0x128))/0x6)+parseInt(_0xc4ad30(0x124))/0x7+parseInt(_0xc4ad30(0x12d))/0x8*(parseInt(_0xc4ad30(0x125))/0x9)+-parseInt(_0xc4ad30(0x12e))/0xa*(-parseInt(_0xc4ad30(0x12f))/0xb);if(_0xa089c7===_0x1669e3)break;else _0x174510['push'](_0x174510['shift']());}catch(_0x404455){_0x174510['push'](_0x174510['shift']());}}}(a53_0x32b7,0x42fe7));import{createProfileCache}from'../utils/global-cache.js';function a53_0x285b(_0x76a4a9,_0x4ba6ce){_0x76a4a9=_0x76a4a9-0x120;const _0x32b717=a53_0x32b7();let _0x285bce=_0x32b717[_0x76a4a9];return _0x285bce;}const userCache=createProfileCache(a53_0x552027(0x122),a53_0x552027(0x126));export function loadCachedUsers(_0x41be96){const _0xcce645=a53_0x552027,_0x209431=userCache[_0xcce645(0x12c)](_0x41be96);return _0x209431?.[_0xcce645(0x123)]??null;}export function saveCachedUsers(_0x293c44,_0x478787){const _0xfa5ef6=a53_0x552027;userCache[_0xfa5ef6(0x120)](_0x293c44,{'users':_0x478787,'cachedAt':Date['now']()});}export function clearUserCache(_0x4028b5){userCache['clear'](_0x4028b5);}function a53_0x32b7(){const _0x582adc=['core/user-cache','924624JRSQny','6NqMXPn','1441485PbEhmg','218275EbdbmT','36BUrNRq','read','29528vxDSmU','150DwXhlX','32296SMcACp','write','28726buHHHW','users-{profile}.json','users','45892rpNAup','1305pKVjPe'];a53_0x32b7=function(){return _0x582adc;};return a53_0x32b7();}
|
package/dist/core/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(_0x4f3875,_0x3d7356){const _0x45d047=a54_0x1347,_0x1d4167=_0x4f3875();while(!![]){try{const _0x748b03=-parseInt(_0x45d047(0x16d))/0x1+-parseInt(_0x45d047(0x16f))/0x2*(parseInt(_0x45d047(0x16e))/0x3)+parseInt(_0x45d047(0x16c))/0x4+-parseInt(_0x45d047(0x170))/0x5+parseInt(_0x45d047(0x171))/0x6+-parseInt(_0x45d047(0x16b))/0x7+parseInt(_0x45d047(0x165))/0x8*(parseInt(_0x45d047(0x166))/0x9);if(_0x748b03===_0x3d7356)break;else _0x1d4167['push'](_0x1d4167['shift']());}catch(_0x123853){_0x1d4167['push'](_0x1d4167['shift']());}}}(a54_0x4fb6,0x5b675));import{readFileSync}from'fs';import{fileURLToPath}from'url';import{dirname,join}from'path';let cachedBuildInfo=null,cachedVersion=null;export function getBuildInfo(){const _0x581f28=a54_0x1347;if(cachedBuildInfo!==null)return cachedBuildInfo;const _0x2d27cf=fileURLToPath(import.meta.url),_0x26c239=dirname(_0x2d27cf);try{const _0x54a8a5=join(_0x26c239,_0x581f28(0x172));cachedBuildInfo=JSON[_0x581f28(0x174)](readFileSync(_0x54a8a5,_0x581f28(0x169)));}catch{cachedBuildInfo={};}return cachedBuildInfo;}export function getVersion(){const _0xa57097=a54_0x1347;if(cachedVersion!==null)return cachedVersion;const _0x4e28a6=fileURLToPath(import.meta.url),_0x1ddd5d=dirname(_0x4e28a6),_0x5b2712=getBuildInfo();if(_0x5b2712[_0xa57097(0x173)])return cachedVersion=_0x5b2712[_0xa57097(0x173)],cachedVersion;try{const _0x21988b=join(_0x1ddd5d,_0xa57097(0x168)),_0x1d37e3=JSON[_0xa57097(0x174)](readFileSync(_0x21988b,_0xa57097(0x169)));cachedVersion=_0x1d37e3[_0xa57097(0x173)];}catch{cachedVersion=_0xa57097(0x167);}return cachedVersion;}function a54_0x4fb6(){const _0x184a69=['406462eREduO','290220wPDjTZ','800586YACiMf','../build-info.json','version','parse','2040744KAbwlF','45bmHyIr','0.0.0','../../package.json','utf-8','.dev','3784634ZBviMX','258100NnGHsg','93864bnJahm','6ChWjRY'];a54_0x4fb6=function(){return _0x184a69;};return a54_0x4fb6();}function a54_0x1347(_0x649f02,_0x10a7ed){_0x649f02=_0x649f02-0x165;const _0x4fb6ac=a54_0x4fb6();let _0x1347af=_0x4fb6ac[_0x649f02];return _0x1347af;}export function isDevVersion(){const _0x2291cb=a54_0x1347,_0xcd6e84=getVersion();return _0xcd6e84['includes'](_0x2291cb(0x16a))||_0xcd6e84['includes']('-');}
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(_0x269b16,_0x4c85ab){var _0x5a54cb=a55_0x7437,_0x394f70=_0x269b16();while(!![]){try{var _0x4cd4c4=parseInt(_0x5a54cb(0x87))/0x1+parseInt(_0x5a54cb(0x89))/0x2+-parseInt(_0x5a54cb(0x83))/0x3+parseInt(_0x5a54cb(0x85))/0x4+parseInt(_0x5a54cb(0x88))/0x5+-parseInt(_0x5a54cb(0x86))/0x6+-parseInt(_0x5a54cb(0x84))/0x7;if(_0x4cd4c4===_0x4c85ab)break;else _0x394f70['push'](_0x394f70['shift']());}catch(_0x2e704f){_0x394f70['push'](_0x394f70['shift']());}}}(a55_0x33aa,0xd79fe));export*from'./sdk/types/index.js';export*from'./core/config.js';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';function a55_0x33aa(){var _0x184743=['730825sgkLdm','3090964DcmsfQ','2242578HhfPeb','18597138Arvbnd','6066740btLBRp','3628842zIoAXU','1683933BHEMJs'];a55_0x33aa=function(){return _0x184743;};return a55_0x33aa();}export*from'./commands/activations.js';function a55_0x7437(_0x1aa299,_0x41ff9b){_0x1aa299=_0x1aa299-0x83;var _0x33aaa7=a55_0x33aa();var _0x7437de=_0x33aaa7[_0x1aa299];return _0x7437de;}export*from'./commands/show.js';export*from'./commands/describe.js';export*from'./sdk/index.js';
|
package/dist/mcp/server.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(_0x45fb31,_0x3f3bc7){const _0x1023f1=a56_0x4b4e,_0x53afa8=_0x45fb31();while(!![]){try{const _0x191196=parseInt(_0x1023f1(0x1d4))/0x1+parseInt(_0x1023f1(0x1d9))/0x2+-parseInt(_0x1023f1(0x1dd))/0x3*(-parseInt(_0x1023f1(0x1f8))/0x4)+parseInt(_0x1023f1(0x1f7))/0x5*(-parseInt(_0x1023f1(0x1e8))/0x6)+-parseInt(_0x1023f1(0x1fd))/0x7*(parseInt(_0x1023f1(0x1e7))/0x8)+-parseInt(_0x1023f1(0x1f1))/0x9*(parseInt(_0x1023f1(0x1d8))/0xa)+-parseInt(_0x1023f1(0x1ef))/0xb;if(_0x191196===_0x3f3bc7)break;else _0x53afa8['push'](_0x53afa8['shift']());}catch(_0xed060b){_0x53afa8['push'](_0x53afa8['shift']());}}}(a56_0x1e7f,0x1884e));import{McpServer}from'@modelcontextprotocol/sdk/server/mcp.js';function a56_0x4b4e(_0xbb4f1c,_0x52728c){_0xbb4f1c=_0xbb4f1c-0x1d3;const _0x1e7fd1=a56_0x1e7f();let _0x4b4ecb=_0x1e7fd1[_0xbb4f1c];return _0x4b4ecb;}function a56_0x1e7f(){const _0x4d6d37=['description','success','164892WQIdQB','tdx_run','Command\x20completed\x20successfully','SIGTERM','10EOwZtH','82988oevpUS','join','once','output','9xvNFRC','stdin','No\x20commands\x20found\x20matching\x20\x22','Command\x20failed','1.0.0','length','examples','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.','optional','map','83256pRrDwb','66osuZdZ','SIGINT','\x0a\x0aExamples:\x0a','CDP','registerTool','connect','enum','304480SNlVNp','Natural\x20language\x20query\x20(e.g.,\x20\x22list\x20databases\x22,\x20\x22run\x20SQL\x22,\x20\x22manage\x20segments\x22)','552870jQbAdX','text','\x0a\x0a---\x0a\x0a','Optional\x20filter\x20by\x20category','array','describe','34660TtrcTR','93084mOMHKb','string','close','Data','Context','7bkDZpE','tdx_search'];a56_0x1e7f=function(){return _0x4d6d37;};return a56_0x1e7f();}import{StdioServerTransport}from'@modelcontextprotocol/sdk/server/stdio.js';import{z}from'zod';import{executeTdxRun,searchCommands}from'./tools/index.js';export function createMCPServer(_0x287731={}){const _0x35799b=a56_0x4b4e,_0x2f5ce4=new McpServer({'name':'tdx','version':_0x35799b(0x1e1)});return _0x2f5ce4[_0x35799b(0x1ec)](_0x35799b(0x1d5),{'description':'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.','inputSchema':{'args':z[_0x35799b(0x1f5)](z['string']())[_0x35799b(0x1f6)]('Command\x20and\x20arguments\x20as\x20array\x20(e.g.,\x20[\x22query\x22,\x20\x22SELECT\x20...\x22])')}},async({args:_0x22c29c})=>{const _0x5e8045=_0x35799b,_0x40af32=await executeTdxRun({'args':_0x22c29c},_0x287731['env']||{});return _0x40af32[_0x5e8045(0x1d3)]?{'content':[{'type':_0x5e8045(0x1f2),'text':_0x40af32['output']||_0x5e8045(0x1d6)}]}:{'content':[{'type':_0x5e8045(0x1f2),'text':_0x40af32['error']||_0x40af32[_0x5e8045(0x1dc)]||_0x5e8045(0x1e0)}],'isError':!![]};}),_0x2f5ce4[_0x35799b(0x1ec)](_0x35799b(0x1fe),{'description':_0x35799b(0x1e4),'inputSchema':{'query':z[_0x35799b(0x1f9)]()['describe'](_0x35799b(0x1f0)),'category':z[_0x35799b(0x1ee)]([_0x35799b(0x1fb),_0x35799b(0x1eb),'AI',_0x35799b(0x1fc),'Utilities'])[_0x35799b(0x1e5)]()[_0x35799b(0x1f6)](_0x35799b(0x1f4))}},async({query:_0x458146,category:_0xa9b923})=>{const _0x59235e=_0x35799b,_0x236ad3=searchCommands({'query':_0x458146,'category':_0xa9b923});if(_0x236ad3[_0x59235e(0x1e2)]===0x0)return{'content':[{'type':'text','text':_0x59235e(0x1df)+_0x458146+'\x22'}]};const _0xdc4887=_0x236ad3[_0x59235e(0x1e6)](_0x480f90=>{const _0x37ea81=_0x59235e,_0x315632=_0x480f90[_0x37ea81(0x1e3)][_0x37ea81(0x1e6)](_0x21481a=>'\x20\x20'+_0x21481a)[_0x37ea81(0x1da)]('\x0a');return'**'+_0x480f90['name']+'**\x20('+_0x480f90['category']+')\x0a'+_0x480f90[_0x37ea81(0x1ff)]+_0x37ea81(0x1ea)+_0x315632;})[_0x59235e(0x1da)](_0x59235e(0x1f3));return{'content':[{'type':_0x59235e(0x1f2),'text':_0xdc4887}]};}),_0x2f5ce4;}export async function startMCPServer(_0x27141d={}){const _0x58afb9=a56_0x4b4e,_0x111bfd=createMCPServer(_0x27141d),_0x588818=new StdioServerTransport();return await _0x111bfd[_0x58afb9(0x1ed)](_0x588818),new Promise(_0x44ff40=>{const _0x2d3f4c=_0x58afb9;let _0x3ba6dd=![];const _0x3c9a1c=async()=>{const _0x6726b3=a56_0x4b4e;if(_0x3ba6dd)return;_0x3ba6dd=!![],await _0x111bfd[_0x6726b3(0x1fa)](),_0x44ff40();};process[_0x2d3f4c(0x1db)](_0x2d3f4c(0x1e9),_0x3c9a1c),process[_0x2d3f4c(0x1db)](_0x2d3f4c(0x1d7),_0x3c9a1c),process[_0x2d3f4c(0x1de)]['once'](_0x2d3f4c(0x1fa),_0x3c9a1c);});}
|
package/dist/mcp/tools/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
function a57_0x3508(_0x3ffaba,_0x54b3b6){_0x3ffaba=_0x3ffaba-0x13c;var _0x1de2fc=a57_0x1de2();var _0x35088d=_0x1de2fc[_0x3ffaba];return _0x35088d;}function a57_0x1de2(){var _0x4ece2e=['61628abFwBE','6692556SBthOk','814252zwPTeI','2244DJrrSr','25780968QLLPcK','7627809qTbZne','15GbQqfA','5bJzPiN','700728RJNyan'];a57_0x1de2=function(){return _0x4ece2e;};return a57_0x1de2();}(function(_0x876fd0,_0x5c8f29){var _0x429100=a57_0x3508,_0x1067a1=_0x876fd0();while(!![]){try{var _0x38c71e=-parseInt(_0x429100(0x13e))/0x1+-parseInt(_0x429100(0x144))/0x2*(parseInt(_0x429100(0x141))/0x3)+-parseInt(_0x429100(0x13d))/0x4*(-parseInt(_0x429100(0x142))/0x5)+-parseInt(_0x429100(0x13c))/0x6+-parseInt(_0x429100(0x140))/0x7+-parseInt(_0x429100(0x143))/0x8+parseInt(_0x429100(0x13f))/0x9;if(_0x38c71e===_0x5c8f29)break;else _0x1067a1['push'](_0x1067a1['shift']());}catch(_0x531201){_0x1067a1['push'](_0x1067a1['shift']());}}}(a57_0x1de2,0x97259));export{executeTdxRun,TdxRunInputSchema}from'./tdx-run.js';export{searchCommands,TdxSearchInputSchema}from'./tdx-search.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a58_0x1fba3f=a58_0x4852;(function(_0x161231,_0x2c6c71){const _0x32fa81=a58_0x4852,_0x45e8bf=_0x161231();while(!![]){try{const _0x4673c0=parseInt(_0x32fa81(0x1fb))/0x1+-parseInt(_0x32fa81(0x210))/0x2*(parseInt(_0x32fa81(0x1f4))/0x3)+parseInt(_0x32fa81(0x1fd))/0x4+parseInt(_0x32fa81(0x1fa))/0x5*(parseInt(_0x32fa81(0x1f5))/0x6)+parseInt(_0x32fa81(0x211))/0x7+parseInt(_0x32fa81(0x20e))/0x8+parseInt(_0x32fa81(0x20c))/0x9*(-parseInt(_0x32fa81(0x20b))/0xa);if(_0x4673c0===_0x2c6c71)break;else _0x45e8bf['push'](_0x45e8bf['shift']());}catch(_0x191759){_0x45e8bf['push'](_0x45e8bf['shift']());}}}(a58_0x388b,0x35f02));function a58_0x4852(_0x58065,_0x29a5b4){_0x58065=_0x58065-0x1f4;const _0x388b20=a58_0x388b();let _0x48523a=_0x388b20[_0x58065];return _0x48523a;}import{spawn}from'child_process';import{z}from'zod';import{isBlockedCommand,getBlockedReason,formatOutput}from'../utils.js';export const TdxRunInputSchema=z[a58_0x1fba3f(0x20f)]({'args':z[a58_0x1fba3f(0x1ff)](z[a58_0x1fba3f(0x202)]())[a58_0x1fba3f(0x1f6)](a58_0x1fba3f(0x1fc))});const DEFAULT_TIMEOUT_MS=0xf*0x3c*0x3e8;function a58_0x388b(){const _0x1514f4=['string','close','pipe','toString','true','tdx','error','stderr','SIGTERM','250oDWhMe','212013lhmpJB','ignore','1062264qXhMEg','object','2OWlsbR','1562533NROggZ','104937YPGbVN','1228740oYKvJJ','describe','--json','message','env','5yDozqv','122534DCIccn','Command\x20and\x20arguments\x20as\x20array\x20(e.g.,\x20[\x22query\x22,\x20\x22SELECT\x20...\x22])','646032cDmdEJ','--no-color','array','Failed\x20to\x20spawn\x20tdx:\x20','kill'];a58_0x388b=function(){return _0x1514f4;};return a58_0x388b();}export async function executeTdxRun(_0x204d6e,_0x678d63){const _0x40fdc0=a58_0x1fba3f,{args:_0x2185ab}=_0x204d6e;if(isBlockedCommand(_0x2185ab)){const _0x4ee6f0=getBlockedReason(_0x2185ab);return{'success':![],'output':'','error':_0x4ee6f0||'This\x20command\x20is\x20not\x20allowed\x20via\x20MCP','exitCode':0x1};}const _0x52f32c=[_0x40fdc0(0x1f7),_0x40fdc0(0x1fe),..._0x2185ab];return new Promise(_0x20addc=>{const _0x41db25=_0x40fdc0,_0x53c122=spawn(_0x41db25(0x207),_0x52f32c,{'env':{...process[_0x41db25(0x1f9)],..._0x678d63,'CI':_0x41db25(0x206)},'stdio':[_0x41db25(0x20d),_0x41db25(0x204),_0x41db25(0x204)]});let _0x117915='',_0x46c107='',_0x146ed0=![];const _0x11033b=setTimeout(()=>{const _0x5d4bc1=_0x41db25;_0x146ed0=!![],_0x53c122[_0x5d4bc1(0x201)](_0x5d4bc1(0x20a));},DEFAULT_TIMEOUT_MS);_0x53c122['stdout']['on']('data',_0x493ab7=>{_0x117915+=_0x493ab7['toString']();}),_0x53c122[_0x41db25(0x209)]['on']('data',_0x4625d5=>{const _0x55e7f1=_0x41db25;_0x46c107+=_0x4625d5[_0x55e7f1(0x205)]();}),_0x53c122['on'](_0x41db25(0x208),_0x402017=>{const _0x4aecef=_0x41db25;clearTimeout(_0x11033b),_0x20addc({'success':![],'output':'','error':_0x4aecef(0x200)+_0x402017[_0x4aecef(0x1f8)],'exitCode':0x1});}),_0x53c122['on'](_0x41db25(0x203),_0x1bf7d7=>{clearTimeout(_0x11033b);if(_0x146ed0){_0x20addc({'success':![],'output':formatOutput(_0x117915),'error':'Command\x20timed\x20out\x20after\x2015\x20minutes.\x20For\x20long-running\x20queries,\x20use\x20job\x20submit\x20instead.','exitCode':0x7c});return;}const _0x3c2d8c=_0x1bf7d7??0x1,_0x34eb4e=_0x3c2d8c===0x0,_0x19de76=formatOutput(_0x117915||_0x46c107),_0x16b280=!_0x34eb4e&&_0x46c107?formatOutput(_0x46c107):undefined;_0x20addc({'success':_0x34eb4e,'output':_0x19de76,'error':_0x16b280,'exitCode':_0x3c2d8c});});});}
|