@treasuredata/tdx 0.25.8 → 0.26.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin.js +1 -1
- package/dist/build-info.json +3 -3
- package/dist/cli-categories.js +1 -1
- package/dist/cli.js +1 -1
- package/dist/commands/activations.js +1 -1
- package/dist/commands/agent-command.js +1 -1
- package/dist/commands/agent-test-command.js +1 -1
- package/dist/commands/api-command.js +1 -1
- package/dist/commands/auth-command.js +1 -1
- package/dist/commands/chat-command.js +1 -1
- package/dist/commands/claude-command.js +1 -1
- package/dist/commands/claude-statusline-command.js +1 -1
- package/dist/commands/claude-usage-command.js +1 -1
- package/dist/commands/command.js +1 -1
- package/dist/commands/connection-command.js +1 -1
- package/dist/commands/databases.js +1 -1
- package/dist/commands/describe.js +1 -1
- package/dist/commands/engage-command.js +1 -1
- package/dist/commands/job-command.js +1 -1
- package/dist/commands/journey-command.js +1 -1
- package/dist/commands/journey-validate-command.js +1 -1
- package/dist/commands/llm-command.js +1 -1
- package/dist/commands/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/schedule-command.js +1 -1
- package/dist/commands/segment-command.js +1 -1
- package/dist/commands/segment-create-command.js +1 -1
- package/dist/commands/segment-fields-command.js +1 -1
- package/dist/commands/segment-pull-command.js +1 -1
- package/dist/commands/segment-push-command.js +1 -1
- package/dist/commands/segment-update-command.js +1 -1
- package/dist/commands/segment-use-command.js +1 -1
- package/dist/commands/segment-validate-command.js +1 -1
- package/dist/commands/segments.js +1 -1
- package/dist/commands/show.js +1 -1
- package/dist/commands/status-command.js +1 -1
- package/dist/commands/tables.js +1 -1
- package/dist/commands/unset-command.js +1 -1
- package/dist/commands/use-command.js +1 -1
- package/dist/commands/user-command.js +1 -1
- package/dist/commands/workflow-command.js +1 -1
- package/dist/core/auth.js +1 -1
- package/dist/core/command-output.js +1 -1
- package/dist/core/config.js +1 -1
- package/dist/core/connection-cache.js +1 -1
- package/dist/core/constants.js +1 -1
- package/dist/core/credential-cache.js +1 -1
- package/dist/core/global-context.js +1 -1
- package/dist/core/keychain.js +1 -1
- package/dist/core/profile.js +1 -1
- package/dist/core/project-config.js +1 -1
- package/dist/core/session.js +1 -1
- package/dist/core/user-cache.js +1 -1
- package/dist/core/version.js +1 -1
- package/dist/index.js +1 -1
- package/dist/mcp/server.js +1 -1
- package/dist/mcp/tools/index.js +1 -1
- package/dist/mcp/tools/tdx-run.js +1 -1
- package/dist/mcp/tools/tdx-search.js +1 -1
- package/dist/mcp/utils.js +1 -1
- package/dist/proxy/claude-usage-tracker.js +1 -1
- package/dist/proxy/passthrough-server.js +1 -1
- package/dist/proxy/sse-usage-parser.js +1 -1
- package/dist/sdk/agent/agent-config.js +1 -1
- package/dist/sdk/agent/agent-ref-parser.js +1 -1
- package/dist/sdk/agent/agent-yaml.js +1 -1
- package/dist/sdk/agent/test/evaluator.js +1 -1
- package/dist/sdk/agent/test/executor.js +1 -1
- package/dist/sdk/agent/test/index.js +1 -1
- package/dist/sdk/agent/test/output.js +1 -1
- package/dist/sdk/agent/test/parser.js +1 -1
- package/dist/sdk/api.js +1 -1
- package/dist/sdk/client/cdp-api-client.js +1 -1
- package/dist/sdk/client/endpoints.js +1 -1
- package/dist/sdk/client/engage-api-client.js +1 -1
- package/dist/sdk/client/http-client.js +1 -1
- package/dist/sdk/client/llm-api-client.js +1 -1
- package/dist/sdk/client/rate-limiter.js +1 -1
- package/dist/sdk/client/td-api-client.js +1 -1
- package/dist/sdk/client/trino-api-client.js +1 -1
- package/dist/sdk/client/workflow-client.js +1 -1
- package/dist/sdk/connection-validator.js +1 -1
- package/dist/sdk/connection.js +1 -1
- package/dist/sdk/engage.js +1 -1
- package/dist/sdk/errors.js +1 -1
- package/dist/sdk/index.js +1 -1
- package/dist/sdk/io/index.js +1 -1
- package/dist/sdk/io/node-filesystem.js +1 -1
- package/dist/sdk/job.js +1 -1
- package/dist/sdk/journey.js +1 -1
- package/dist/sdk/llm/chat-cache.js +1 -1
- package/dist/sdk/llm/index.js +1 -1
- package/dist/sdk/llm/llm-backup-utils.js +1 -1
- package/dist/sdk/llm/model-factors.js +1 -1
- package/dist/sdk/personalization.js +1 -1
- package/dist/sdk/query/index.js +1 -1
- package/dist/sdk/query/sql-parser.js +1 -1
- package/dist/sdk/realtime.js +1 -1
- package/dist/sdk/schedule.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-validator.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-recovery.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/archive-validation.js +1 -1
- package/dist/sdk/workflow/clone-workflow.js +1 -1
- package/dist/sdk/workflow/index.js +1 -1
- package/dist/sdk/workflow/pull-workflow.js +1 -1
- package/dist/sdk/workflow/push-workflow.js +1 -1
- package/dist/sdk/workflow/tdx-config.js +1 -1
- package/dist/sdk/workflow/workflow-utils.js +1 -1
- package/dist/test-utils/command-runner.js +1 -1
- package/dist/test-utils/factories.js +1 -1
- package/dist/test-utils/fixtures.js +1 -1
- package/dist/test-utils/http-mock.js +1 -1
- package/dist/test-utils/index.js +1 -1
- package/dist/utils/async.js +1 -1
- package/dist/utils/colors.js +1 -1
- package/dist/utils/diff.js +1 -1
- package/dist/utils/file-permissions.js +1 -1
- package/dist/utils/global-cache.js +1 -1
- package/dist/utils/json-loader.js +1 -1
- package/dist/utils/local-cache.js +1 -1
- package/dist/utils/logger/formatters/default-formatter.js +1 -1
- package/dist/utils/logger/formatters/index.js +1 -1
- package/dist/utils/logger/handlers/console-handler.js +1 -1
- package/dist/utils/logger/handlers/file-handler.js +1 -1
- package/dist/utils/logger/handlers/index.js +1 -1
- package/dist/utils/logger/handlers/null-handler.js +1 -1
- package/dist/utils/logger/index.js +1 -1
- package/dist/utils/logger/logger.js +1 -1
- package/dist/utils/logger/types.js +1 -1
- package/dist/utils/option-validation.js +1 -1
- package/dist/utils/port.js +1 -1
- package/dist/utils/process.js +1 -1
- package/dist/utils/prompt.js +1 -1
- package/dist/utils/spinner.js +1 -1
- package/dist/utils/sse-parser.js +1 -1
- package/dist/utils/string-utils.js +1 -1
- package/dist/utils/table-ref-parser.js +1 -1
- package/dist/utils/tdx-logger.js +1 -1
- package/dist/utils/version-check.js +1 -1
- package/package.json +1 -1
package/dist/core/config.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const a45_0x2f0edf=a45_0x225e;(function(_0x27cc6e,_0x5aff2a){const _0x471809=a45_0x225e,_0x3bef7f=_0x27cc6e();while(!![]){try{const _0x430834=-parseInt(_0x471809(0xa2))/0x1+-parseInt(_0x471809(0x91))/0x2+parseInt(_0x471809(0x94))/0x3*(-parseInt(_0x471809(0xc2))/0x4)+-parseInt(_0x471809(0xb2))/0x5*(-parseInt(_0x471809(0x7f))/0x6)+-parseInt(_0x471809(0xb3))/0x7+-parseInt(_0x471809(0x88))/0x8+parseInt(_0x471809(0xbc))/0x9;if(_0x430834===_0x5aff2a)break;else _0x3bef7f['push'](_0x3bef7f['shift']());}catch(_0x5e5964){_0x3bef7f['push'](_0x3bef7f['shift']());}}}(a45_0x871c,0x447cc));import{homedir}from'os';import{join}from'path';import{existsSync,readFileSync,writeFileSync,mkdirSync,unlinkSync}from'fs';import*as a45_0x1e358c from'node:fs';function a45_0x871c(){const _0x76ed48=['apiKeys','\x27,\x20defaulting\x20to\x20us01','some','keychain','toUpperCase','TDX_API_KEY_','llm_default_agent','5jyHWMd','1246014qhlsbb','TD_API_KEY_','site','string','Warning:\x20Failed\x20to\x20read\x20','replace','read','.json','warn','12781152nMBfGn','⚠\x20Cleaned\x20up\x20API\x20keys\x20from\x20legacy\x20.env\x20file','stable','ap03','stg-us01','.env.','4raeDbh','startsWith','1881588VKqaUY','TD_API_KEY','parse','config/account-info','tdx','keychain\x20(profile:\x20','us01','write','release_channel','4048992UpAAkF','stg-jp01','dev-eu01','join','readFileSync','utf-8','stg-ap03','existsSync','proxy','55886DzhMWF','ap02','slice','1523499syOesd','next','yellow','profile','tdx.json','dev-us01','split','stringify','eu01','TDX_API_KEY\x20env\x20var','entries','trim','clear','filter','233300NwPMoQ','jp01','Warning:\x20Unknown\x20site\x20\x27','accountId','config/llm-project','number','llm_default_project','name','.config'];a45_0x871c=function(){return _0x76ed48;};return a45_0x871c();}import*as a45_0x517fbc from'node:path';import{SITE_ALIASES}from'../sdk/types/index.js';import{getKeychainAPIKey,saveKeychainAPIKey}from'./keychain.js';import{getCachedCredential,setCachedCredential}from'./credential-cache.js';import a45_0x3ce216 from'chalk';import{getGlobalCacheDir,createOptionalProfileCache}from'../utils/global-cache.js';export function getConfigDir(){const _0x4266d2=a45_0x225e;return process.env.TDX_CONFIG_DIR||join(homedir(),_0x4266d2(0xaa),_0x4266d2(0x83));}export function getConfigFile(){return join(getConfigDir(),'.env');}export function getConfigFilePath(_0x421faa){const _0x46ef4a=a45_0x225e,_0xd52f31=getConfigDir();return _0x421faa?a45_0x517fbc[_0x46ef4a(0x8b)](_0xd52f31,_0x46ef4a(0xc1)+_0x421faa):getConfigFile();}export function getCacheDir(){return getGlobalCacheDir();}const llmProjectCache=createOptionalProfileCache(a45_0x2f0edf(0xa8),a45_0x2f0edf(0xa6));export function getLLMProjectCacheFile(_0x1a7eed){return llmProjectCache['path'](_0x1a7eed);}export function readCachedLLMProject(_0x4436ef){const _0x48222c=a45_0x2f0edf,_0x49bfc6=llmProjectCache[_0x48222c(0xb9)](_0x4436ef);if(_0x49bfc6&&typeof _0x49bfc6['id']===_0x48222c(0xb6)&&typeof _0x49bfc6[_0x48222c(0xa9)]===_0x48222c(0xb6))return _0x49bfc6;return null;}export function writeCachedLLMProject(_0x20e31f,_0x4d23bd,_0x37a73b){try{llmProjectCache['write']({'name':_0x20e31f,'id':_0x4d23bd},_0x37a73b);}catch{}}const llmAgentCache=createOptionalProfileCache(a45_0x2f0edf(0xb1),'config/llm-agent');export function getLLMAgentCacheFile(_0x45e266){return llmAgentCache['path'](_0x45e266);}export function readCachedLLMAgent(_0x2e03de){const _0x34aef3=a45_0x2f0edf,_0x77c92f=llmAgentCache['read'](_0x2e03de);if(_0x77c92f&&typeof _0x77c92f['id']===_0x34aef3(0xb6)&&typeof _0x77c92f['name']===_0x34aef3(0xb6)&&typeof _0x77c92f['projectId']===_0x34aef3(0xb6))return _0x77c92f;return null;}export function writeCachedLLMAgent(_0x24837d,_0x1e3829,_0x5b59f5,_0x1c794b){const _0x17fb6b=a45_0x2f0edf;try{llmAgentCache[_0x17fb6b(0x86)]({'name':_0x24837d,'id':_0x1e3829,'projectId':_0x5b59f5},_0x1c794b);}catch{}}export function clearCachedLLMAgent(_0x3e1d5e){const _0x2f4f7d=a45_0x2f0edf;try{llmAgentCache[_0x2f4f7d(0xa0)](_0x3e1d5e);}catch{}}const accountInfoCache=createOptionalProfileCache('account_info',a45_0x2f0edf(0x82),{'suffix':a45_0x2f0edf(0xba)});export function getAccountInfoCacheFile(_0x8cb6ef){return accountInfoCache['path'](_0x8cb6ef);}export function readCachedAccountInfo(_0x3c166f){const _0x4117d1=a45_0x2f0edf,_0x151c7f=accountInfoCache[_0x4117d1(0xb9)](_0x3c166f);if(_0x151c7f&&typeof _0x151c7f[_0x4117d1(0xb5)]===_0x4117d1(0xb6)&&typeof _0x151c7f[_0x4117d1(0xa5)]===_0x4117d1(0xa7))return _0x151c7f;return null;}export function writeCachedAccountInfo(_0x54d032,_0x27bafc,_0x2eb5b3){const _0x35c6d1=a45_0x2f0edf;try{accountInfoCache[_0x35c6d1(0x86)]({'site':_0x54d032,'accountId':_0x27bafc,'cachedAt':new Date()['toISOString']()},_0x2eb5b3);}catch{}}export function parseEnvFile(_0x44e186){const _0x4f246f=a45_0x2f0edf,_0x57e0eb={};for(const _0x4a3e24 of _0x44e186[_0x4f246f(0x9a)]('\x0a')){const _0x5492e9=_0x4a3e24[_0x4f246f(0x9f)]();if(!_0x5492e9||_0x5492e9[_0x4f246f(0x7e)]('#'))continue;const _0x5c8bf6=_0x5492e9['match'](/^([^=]+)=(.*)$/);if(_0x5c8bf6){const _0x25dd87=_0x5c8bf6[0x1]['trim']();let _0x52fd9c=_0x5c8bf6[0x2][_0x4f246f(0x9f)]();(_0x52fd9c[_0x4f246f(0x7e)]('\x22')&&_0x52fd9c['endsWith']('\x22')||_0x52fd9c[_0x4f246f(0x7e)]('\x27')&&_0x52fd9c['endsWith']('\x27'))&&(_0x52fd9c=_0x52fd9c[_0x4f246f(0x93)](0x1,-0x1)),_0x57e0eb[_0x25dd87]=_0x52fd9c;}}return _0x57e0eb;}export function readUserConfig(){const _0x55e2fc=a45_0x2f0edf,_0xfd415d=getConfigFile();if(!existsSync(_0xfd415d))return{};try{const _0x367481=readFileSync(_0xfd415d,'utf-8');return parseEnvFile(_0x367481);}catch(_0x28845f){return console[_0x55e2fc(0xbb)]('Warning:\x20Failed\x20to\x20read\x20config\x20file\x20'+_0xfd415d+':',_0x28845f),{};}}export function resolveSite(_0x1d3bff){const _0x40f183=a45_0x2f0edf,_0x628e88=[_0x40f183(0x85),_0x40f183(0xa3),_0x40f183(0x9c),_0x40f183(0x92),_0x40f183(0xbf),_0x40f183(0x99),_0x40f183(0x8a),_0x40f183(0xc0),'stg-jp01',_0x40f183(0x8e)];if(_0x628e88['includes'](_0x1d3bff))return _0x1d3bff;if(_0x1d3bff in SITE_ALIASES)return SITE_ALIASES[_0x1d3bff];return console[_0x40f183(0xbb)](_0x40f183(0xa4)+_0x1d3bff+_0x40f183(0xac)),_0x40f183(0x85);}let cachedUserConfig=null;export function loadUserConfigOnce(){return cachedUserConfig===null&&(cachedUserConfig=readUserConfig()),cachedUserConfig;}export function clearConfigCache(){cachedUserConfig=null;}export function getAPIKey(_0x2bee3c){const _0x3d4949=a45_0x2f0edf,_0x425bb1=_0x2bee3c||getActiveProfileName();if(_0x425bb1){const _0x2e159b=_0x3d4949(0xb0)+normalizeProfileForEnvVar(_0x425bb1);if(process.env[_0x2e159b])return process.env[_0x2e159b];}if(process.env.TDX_API_KEY)return process.env.TDX_API_KEY;return undefined;}export function normalizeProfileForEnvVar(_0x1034b1){const _0x8df61a=a45_0x2f0edf;return _0x1034b1[_0x8df61a(0xaf)]()[_0x8df61a(0xb8)](/[^A-Z0-9]/g,'_');}function a45_0x225e(_0x2c298a,_0x579d38){_0x2c298a=_0x2c298a-0x7e;const _0x871c27=a45_0x871c();let _0x225ef6=_0x871c27[_0x2c298a];return _0x225ef6;}export async function resolveAPIKeyAsync(_0x327374,_0x9b9d7e){const _0x113c51=a45_0x2f0edf,_0x1bbc72=_0x9b9d7e||getActiveProfileName()||undefined;if(_0x1bbc72){const _0x556c34=_0x113c51(0xb0)+normalizeProfileForEnvVar(_0x1bbc72);if(process.env[_0x556c34])return{'apiKey':process.env[_0x556c34],'source':_0x556c34+'\x20env\x20var','isDeprecated':![]};const _0x2f1d9f=getCachedCredential(_0x327374,_0x1bbc72);if(_0x2f1d9f)return{'apiKey':_0x2f1d9f,'source':_0x113c51(0x84)+_0x1bbc72+')','isDeprecated':![]};const _0x5e6562=await getKeychainAPIKey(_0x1bbc72);if(_0x5e6562)return setCachedCredential(_0x5e6562,_0x327374,_0x1bbc72),{'apiKey':_0x5e6562,'source':_0x113c51(0x84)+_0x1bbc72+')','isDeprecated':![]};}if(process.env.TDX_API_KEY)return{'apiKey':process.env.TDX_API_KEY,'source':_0x113c51(0x9d),'isDeprecated':![]};if(!_0x1bbc72){const _0x24d911=getCachedCredential(_0x327374,undefined);if(_0x24d911)return{'apiKey':_0x24d911,'source':_0x113c51(0xae),'isDeprecated':![]};const _0x4b88b9=await getKeychainAPIKey(undefined);if(_0x4b88b9)return setCachedCredential(_0x4b88b9,_0x327374,undefined),{'apiKey':_0x4b88b9,'source':_0x113c51(0xae),'isDeprecated':![]};}return null;}export async function getAPIKeyAsync(_0x38f961,_0x457aab){const _0x4afb5c=await resolveAPIKeyAsync(_0x38f961,_0x457aab);return _0x4afb5c?.['apiKey'];}function cleanupLegacyEnvFile(_0x2da7fd){const _0x1d963c=a45_0x2f0edf;if(!existsSync(_0x2da7fd))return![];try{const _0x2cf3d7=readFileSync(_0x2da7fd,_0x1d963c(0x8d)),_0x215941=_0x2cf3d7['split']('\x0a'),_0x2b5869=_0x215941[_0x1d963c(0xa1)](_0x33e9c3=>{const _0x5b396e=_0x1d963c,_0x33a12e=_0x33e9c3['trim']();if(!_0x33a12e||_0x33a12e[_0x5b396e(0x7e)]('#'))return!![];const [_0xc8789f]=_0x33a12e['split']('=');return!_0xc8789f[_0x5b396e(0x7e)](_0x5b396e(0x80));}),_0x21eec6=_0x2b5869[_0x1d963c(0xad)](_0xea4eb4=>{const _0xb9297e=_0x1d963c,_0x4630a8=_0xea4eb4[_0xb9297e(0x9f)]();return _0x4630a8&&!_0x4630a8[_0xb9297e(0x7e)]('#');});if(!_0x21eec6)return unlinkSync(_0x2da7fd),!![];return writeFileSync(_0x2da7fd,_0x2b5869['join']('\x0a'),{'mode':0x180}),!![];}catch{return![];}}function getActiveProfileName(){const _0x457e4a=a45_0x2f0edf;if(process.env.TDX_PROFILE)return process.env.TDX_PROFILE;const _0x6894ea=a45_0x517fbc[_0x457e4a(0x8b)](getConfigDir(),_0x457e4a(0x98));if(!a45_0x1e358c[_0x457e4a(0x8f)](_0x6894ea))return null;try{const _0x4116a3=a45_0x1e358c[_0x457e4a(0x8c)](_0x6894ea,_0x457e4a(0x8d)),_0x12fbb6=JSON[_0x457e4a(0x81)](_0x4116a3);return _0x12fbb6[_0x457e4a(0x97)]||null;}catch{return null;}}export function saveAPIKey(_0x32c878,_0x43457d,_0x474c6e){const _0x16b5df=a45_0x2f0edf,_0x4e5284=getConfigDir(),_0x1a6232=getConfigFilePath(_0x474c6e);!existsSync(_0x4e5284)&&mkdirSync(_0x4e5284,{'recursive':!![],'mode':0x1c0});let _0xdf8c9c={};if(existsSync(_0x1a6232))try{const _0x127e38=readFileSync(_0x1a6232,_0x16b5df(0x8d));_0xdf8c9c=parseEnvFile(_0x127e38);}catch(_0x4149b){console[_0x16b5df(0xbb)](_0x16b5df(0xb7)+_0x1a6232+':',_0x4149b);}const _0x39e7fc=_0x32c878[_0x16b5df(0xaf)]()['replace'](/-/g,'_');_0xdf8c9c[_0x16b5df(0xb4)+_0x39e7fc]=_0x43457d;const _0xcc5c20=Object[_0x16b5df(0x9e)](_0xdf8c9c)['map'](([_0x1b0a9e,_0x123dce])=>_0x1b0a9e+'='+_0x123dce);writeFileSync(_0x1a6232,_0xcc5c20[_0x16b5df(0x8b)]('\x0a')+'\x0a',{'mode':0x180});}export async function saveAPIKeyAsync(_0x3e8239,_0x323ffe,_0x184f55){const _0x505e57=a45_0x2f0edf;await saveKeychainAPIKey(_0x3e8239,_0x184f55),setCachedCredential(_0x3e8239,_0x323ffe,_0x184f55);const _0x3537d6=getConfigFilePath(_0x184f55);cleanupLegacyEnvFile(_0x3537d6)&&console[_0x505e57(0xbb)](a45_0x3ce216[_0x505e57(0x96)](_0x505e57(0xbd)));}export function loadConfig(){const _0x3890cc=a45_0x2f0edf,_0x321611={'apiKeys':{},'defaultSite':'us01'},_0x93622f=['us01','jp01',_0x3890cc(0x9c),_0x3890cc(0x92),_0x3890cc(0xbf),_0x3890cc(0x99),_0x3890cc(0x8a),_0x3890cc(0xc0),_0x3890cc(0x89),_0x3890cc(0x8e)],_0x4a5eb8=getAPIKey();if(_0x4a5eb8)for(const _0x369204 of _0x93622f){_0x321611[_0x3890cc(0xab)][_0x369204]=_0x4a5eb8;}return _0x321611;}export function isExperimentalAvailable(){return!!process.env.TDX_EXPERIMENTAL;}export function loadGlobalProxy(){const _0x24a937=a45_0x2f0edf,_0x42f435=a45_0x517fbc['join'](getConfigDir(),'tdx.json');if(!a45_0x1e358c[_0x24a937(0x8f)](_0x42f435))return undefined;try{const _0x283197=a45_0x1e358c['readFileSync'](_0x42f435,'utf-8'),_0xb1ea12=JSON[_0x24a937(0x81)](_0x283197);return typeof _0xb1ea12['proxy']==='string'?_0xb1ea12[_0x24a937(0x90)]:undefined;}catch{return undefined;}}export function loadReleaseChannel(){const _0x12c9cb=a45_0x2f0edf,_0xd7b928=process.env.TDX_RELEASE_CHANNEL;if(_0xd7b928===_0x12c9cb(0x95)||_0xd7b928==='stable')return _0xd7b928;const _0xb1bedc=a45_0x517fbc['join'](getConfigDir(),'tdx.json');if(!a45_0x1e358c[_0x12c9cb(0x8f)](_0xb1bedc))return _0x12c9cb(0xbe);try{const _0x1c6f7e=a45_0x1e358c[_0x12c9cb(0x8c)](_0xb1bedc,'utf-8'),_0x3f82c3=JSON[_0x12c9cb(0x81)](_0x1c6f7e);if(_0x3f82c3['release_channel']===_0x12c9cb(0x95))return _0x12c9cb(0x95);}catch{}return _0x12c9cb(0xbe);}export function saveReleaseChannel(_0x47554c){const _0x22cab3=a45_0x2f0edf,_0x358b3a=getConfigDir(),_0xb4ad1b=a45_0x517fbc[_0x22cab3(0x8b)](_0x358b3a,_0x22cab3(0x98));!existsSync(_0x358b3a)&&mkdirSync(_0x358b3a,{'recursive':!![],'mode':0x1c0});let _0x5618dd={};if(existsSync(_0xb4ad1b))try{const _0x40f290=readFileSync(_0xb4ad1b,_0x22cab3(0x8d));_0x5618dd=JSON[_0x22cab3(0x81)](_0x40f290);}catch{}_0x5618dd[_0x22cab3(0x87)]=_0x47554c,writeFileSync(_0xb4ad1b,JSON[_0x22cab3(0x9b)](_0x5618dd,null,0x2),{'mode':0x180});}
|
|
1
|
+
const a45_0x389ae9=a45_0x403a;(function(_0x462de3,_0x2d2cb4){const _0x1c86f2=a45_0x403a,_0x3937a6=_0x462de3();while(!![]){try{const _0x449181=parseInt(_0x1c86f2(0x16b))/0x1*(parseInt(_0x1c86f2(0x169))/0x2)+-parseInt(_0x1c86f2(0x149))/0x3*(parseInt(_0x1c86f2(0x178))/0x4)+parseInt(_0x1c86f2(0x174))/0x5*(parseInt(_0x1c86f2(0x18a))/0x6)+-parseInt(_0x1c86f2(0x17b))/0x7+parseInt(_0x1c86f2(0x15f))/0x8*(parseInt(_0x1c86f2(0x167))/0x9)+parseInt(_0x1c86f2(0x17e))/0xa*(-parseInt(_0x1c86f2(0x166))/0xb)+parseInt(_0x1c86f2(0x163))/0xc*(-parseInt(_0x1c86f2(0x17d))/0xd);if(_0x449181===_0x2d2cb4)break;else _0x3937a6['push'](_0x3937a6['shift']());}catch(_0x29b3d8){_0x3937a6['push'](_0x3937a6['shift']());}}}(a45_0x2bb3,0x6c9f5));import{homedir}from'os';import{join}from'path';import{existsSync,readFileSync,writeFileSync,mkdirSync,unlinkSync}from'fs';import*as a45_0x27cb27 from'node:fs';import*as a45_0x1cb021 from'node:path';import{SITE_ALIASES}from'../sdk/types/index.js';import{getKeychainAPIKey,saveKeychainAPIKey}from'./keychain.js';import{getCachedCredential,setCachedCredential}from'./credential-cache.js';function a45_0x2bb3(){const _0x16d069=['string','account_info','llm_default_agent','116835syLLnA','startsWith','slice','eu01','dev-us01','stringify','site','config/llm-project','replace','next','path','readFileSync','parse','name','split','entries','number','release_channel','dev-eu01','profile','.config','accountId','2224uoSocE','stg-ap03','⚠\x20Cleaned\x20up\x20API\x20keys\x20from\x20legacy\x20.env\x20file','ap02','12VMpMAs','stg-jp01','projectId','229031UsyLeq','25299obAnIP','us01','826gSiKiT','tdx.json','941PSNcLo','ap03','jp01','Warning:\x20Unknown\x20site\x20\x27','endsWith','TDX_API_KEY\x20env\x20var','config/account-info','toUpperCase','proxy','176140aCPMGJ','toISOString','.json','write','4pnjcTd','join','\x20env\x20var','2286410YyJykh','.env.','2467075YAsQoG','200aJWHym','config/llm-agent','keychain','read','tdx','yellow','utf-8','TD_API_KEY','existsSync','stable','clear','trim','42EXWIMb','warn','\x27,\x20defaulting\x20to\x20us01'];a45_0x2bb3=function(){return _0x16d069;};return a45_0x2bb3();}import a45_0x44be1d from'chalk';import{getGlobalCacheDir,createOptionalProfileCache}from'../utils/global-cache.js';export function getConfigDir(){const _0x38b798=a45_0x403a;return process.env.TDX_CONFIG_DIR||join(homedir(),_0x38b798(0x15d),_0x38b798(0x182));}export function getConfigFile(){return join(getConfigDir(),'.env');}export function getConfigFilePath(_0x3ebf6a){const _0x5448c5=a45_0x403a,_0x4b4665=getConfigDir();return _0x3ebf6a?a45_0x1cb021[_0x5448c5(0x179)](_0x4b4665,_0x5448c5(0x17c)+_0x3ebf6a):getConfigFile();}export function getCacheDir(){return getGlobalCacheDir();}const llmProjectCache=createOptionalProfileCache('llm_default_project',a45_0x389ae9(0x150));export function getLLMProjectCacheFile(_0x359576){const _0x175b81=a45_0x389ae9;return llmProjectCache[_0x175b81(0x153)](_0x359576);}export function readCachedLLMProject(_0x566329){const _0x3e7202=a45_0x389ae9,_0x266817=llmProjectCache[_0x3e7202(0x181)](_0x566329);if(_0x266817&&typeof _0x266817['id']===_0x3e7202(0x146)&&typeof _0x266817[_0x3e7202(0x156)]===_0x3e7202(0x146))return _0x266817;return null;}export function writeCachedLLMProject(_0xbf66f8,_0x1ec56e,_0xbce00f){try{llmProjectCache['write']({'name':_0xbf66f8,'id':_0x1ec56e},_0xbce00f);}catch{}}const llmAgentCache=createOptionalProfileCache(a45_0x389ae9(0x148),a45_0x389ae9(0x17f));export function getLLMAgentCacheFile(_0x778dc6){return llmAgentCache['path'](_0x778dc6);}export function readCachedLLMAgent(_0x51a3bc){const _0x19e502=a45_0x389ae9,_0xe76f65=llmAgentCache[_0x19e502(0x181)](_0x51a3bc);if(_0xe76f65&&typeof _0xe76f65['id']==='string'&&typeof _0xe76f65['name']===_0x19e502(0x146)&&typeof _0xe76f65[_0x19e502(0x165)]===_0x19e502(0x146))return _0xe76f65;return null;}export function writeCachedLLMAgent(_0x2774dd,_0xdbfbea,_0x455f39,_0x24b27d){try{llmAgentCache['write']({'name':_0x2774dd,'id':_0xdbfbea,'projectId':_0x455f39},_0x24b27d);}catch{}}export function clearCachedLLMAgent(_0x1a7399){const _0x34ba02=a45_0x389ae9;try{llmAgentCache[_0x34ba02(0x188)](_0x1a7399);}catch{}}const accountInfoCache=createOptionalProfileCache(a45_0x389ae9(0x147),a45_0x389ae9(0x171),{'suffix':a45_0x389ae9(0x176)});export function getAccountInfoCacheFile(_0xf927ef){const _0x11103c=a45_0x389ae9;return accountInfoCache[_0x11103c(0x153)](_0xf927ef);}function a45_0x403a(_0x2189a2,_0x1f7665){_0x2189a2=_0x2189a2-0x144;const _0x2bb3b4=a45_0x2bb3();let _0x403a14=_0x2bb3b4[_0x2189a2];return _0x403a14;}export function readCachedAccountInfo(_0x107b69){const _0x37a773=a45_0x389ae9,_0x2b0fa3=accountInfoCache[_0x37a773(0x181)](_0x107b69);if(_0x2b0fa3&&typeof _0x2b0fa3[_0x37a773(0x14f)]===_0x37a773(0x146)&&typeof _0x2b0fa3[_0x37a773(0x15e)]===_0x37a773(0x159))return _0x2b0fa3;return null;}export function writeCachedAccountInfo(_0x50ce1b,_0x79cc6e,_0x5f5183){const _0xcccd4a=a45_0x389ae9;try{accountInfoCache[_0xcccd4a(0x177)]({'site':_0x50ce1b,'accountId':_0x79cc6e,'cachedAt':new Date()[_0xcccd4a(0x175)]()},_0x5f5183);}catch{}}export function parseEnvFile(_0x18831b){const _0x36f35a=a45_0x389ae9,_0x13b9c5={};for(const _0x1e05f9 of _0x18831b[_0x36f35a(0x157)]('\x0a')){const _0x2657f5=_0x1e05f9['trim']();if(!_0x2657f5||_0x2657f5[_0x36f35a(0x14a)]('#'))continue;const _0xa282ff=_0x2657f5['match'](/^([^=]+)=(.*)$/);if(_0xa282ff){const _0x36dc5d=_0xa282ff[0x1]['trim']();let _0x389e43=_0xa282ff[0x2][_0x36f35a(0x189)]();(_0x389e43[_0x36f35a(0x14a)]('\x22')&&_0x389e43[_0x36f35a(0x16f)]('\x22')||_0x389e43['startsWith']('\x27')&&_0x389e43['endsWith']('\x27'))&&(_0x389e43=_0x389e43[_0x36f35a(0x14b)](0x1,-0x1)),_0x13b9c5[_0x36dc5d]=_0x389e43;}}return _0x13b9c5;}export function readUserConfig(){const _0x382d44=a45_0x389ae9,_0x9f56d1=getConfigFile();if(!existsSync(_0x9f56d1))return{};try{const _0x158060=readFileSync(_0x9f56d1,_0x382d44(0x184));return parseEnvFile(_0x158060);}catch(_0x2e3dbe){return console[_0x382d44(0x144)]('Warning:\x20Failed\x20to\x20read\x20config\x20file\x20'+_0x9f56d1+':',_0x2e3dbe),{};}}export function resolveSite(_0x52422e){const _0x21fbe0=a45_0x389ae9,_0x1f5318=[_0x21fbe0(0x168),_0x21fbe0(0x16d),_0x21fbe0(0x14c),_0x21fbe0(0x162),_0x21fbe0(0x16c),_0x21fbe0(0x14d),_0x21fbe0(0x15b),'stg-us01',_0x21fbe0(0x164),'stg-ap03'];if(_0x1f5318['includes'](_0x52422e))return _0x52422e;if(_0x52422e in SITE_ALIASES)return SITE_ALIASES[_0x52422e];return console['warn'](_0x21fbe0(0x16e)+_0x52422e+_0x21fbe0(0x145)),_0x21fbe0(0x168);}let cachedUserConfig=null;export function loadUserConfigOnce(){return cachedUserConfig===null&&(cachedUserConfig=readUserConfig()),cachedUserConfig;}export function clearConfigCache(){cachedUserConfig=null;}export function getAPIKey(_0x17f600){const _0xd29442=_0x17f600||getActiveProfileName();if(_0xd29442){const _0x2039ce='TDX_API_KEY_'+normalizeProfileForEnvVar(_0xd29442);if(process.env[_0x2039ce])return process.env[_0x2039ce];}if(process.env.TDX_API_KEY)return process.env.TDX_API_KEY;return undefined;}export function normalizeProfileForEnvVar(_0x52b2f3){const _0x4dc907=a45_0x389ae9;return _0x52b2f3['toUpperCase']()[_0x4dc907(0x151)](/[^A-Z0-9]/g,'_');}export async function resolveAPIKeyAsync(_0xfb8034,_0x525790){const _0x19ab4a=a45_0x389ae9,_0x297f69=_0x525790||getActiveProfileName()||undefined;if(_0x297f69){const _0x31f14e='TDX_API_KEY_'+normalizeProfileForEnvVar(_0x297f69);if(process.env[_0x31f14e])return{'apiKey':process.env[_0x31f14e],'source':_0x31f14e+_0x19ab4a(0x17a),'isDeprecated':![]};const _0x2210c8=getCachedCredential(_0xfb8034,_0x297f69);if(_0x2210c8)return{'apiKey':_0x2210c8,'source':'keychain\x20(profile:\x20'+_0x297f69+')','isDeprecated':![]};const _0x145a11=await getKeychainAPIKey(_0x297f69);if(_0x145a11)return setCachedCredential(_0x145a11,_0xfb8034,_0x297f69),{'apiKey':_0x145a11,'source':'keychain\x20(profile:\x20'+_0x297f69+')','isDeprecated':![]};}if(process.env.TDX_API_KEY)return{'apiKey':process.env.TDX_API_KEY,'source':_0x19ab4a(0x170),'isDeprecated':![]};if(!_0x297f69){const _0x3b91e7=getCachedCredential(_0xfb8034,undefined);if(_0x3b91e7)return{'apiKey':_0x3b91e7,'source':_0x19ab4a(0x180),'isDeprecated':![]};const _0x51aed5=await getKeychainAPIKey(undefined);if(_0x51aed5)return setCachedCredential(_0x51aed5,_0xfb8034,undefined),{'apiKey':_0x51aed5,'source':'keychain','isDeprecated':![]};}return null;}export async function getAPIKeyAsync(_0x20a40d,_0x44509b){const _0x1aabf1=await resolveAPIKeyAsync(_0x20a40d,_0x44509b);return _0x1aabf1?.['apiKey'];}function cleanupLegacyEnvFile(_0x213404){const _0x691816=a45_0x389ae9;if(!existsSync(_0x213404))return![];try{const _0x4c0bf8=readFileSync(_0x213404,_0x691816(0x184)),_0x12dfc8=_0x4c0bf8[_0x691816(0x157)]('\x0a'),_0x19bf66=_0x12dfc8['filter'](_0x38e401=>{const _0x251585=_0x691816,_0x379bcf=_0x38e401[_0x251585(0x189)]();if(!_0x379bcf||_0x379bcf['startsWith']('#'))return!![];const [_0x25eb1d]=_0x379bcf[_0x251585(0x157)]('=');return!_0x25eb1d[_0x251585(0x14a)](_0x251585(0x185));}),_0x54739e=_0x19bf66['some'](_0x14d5c1=>{const _0x506ca9=_0x691816,_0x4c2e72=_0x14d5c1[_0x506ca9(0x189)]();return _0x4c2e72&&!_0x4c2e72[_0x506ca9(0x14a)]('#');});if(!_0x54739e)return unlinkSync(_0x213404),!![];return writeFileSync(_0x213404,_0x19bf66[_0x691816(0x179)]('\x0a'),{'mode':0x180}),!![];}catch{return![];}}function getActiveProfileName(){const _0x44d5cd=a45_0x389ae9;if(process.env.TDX_PROFILE)return process.env.TDX_PROFILE;const _0x39817d=a45_0x1cb021[_0x44d5cd(0x179)](getConfigDir(),'tdx.json');if(!a45_0x27cb27[_0x44d5cd(0x186)](_0x39817d))return null;try{const _0x27514d=a45_0x27cb27['readFileSync'](_0x39817d,_0x44d5cd(0x184)),_0x404411=JSON[_0x44d5cd(0x155)](_0x27514d);return _0x404411[_0x44d5cd(0x15c)]||null;}catch{return null;}}export function saveAPIKey(_0x1af5e3,_0x5c6bbc,_0x225f2b){const _0x3012f0=a45_0x389ae9,_0x37e97b=getConfigDir(),_0x485097=getConfigFilePath(_0x225f2b);!existsSync(_0x37e97b)&&mkdirSync(_0x37e97b,{'recursive':!![],'mode':0x1c0});let _0x47edf9={};if(existsSync(_0x485097))try{const _0x5575b3=readFileSync(_0x485097,_0x3012f0(0x184));_0x47edf9=parseEnvFile(_0x5575b3);}catch(_0x7b268a){console[_0x3012f0(0x144)]('Warning:\x20Failed\x20to\x20read\x20'+_0x485097+':',_0x7b268a);}const _0x8c1057=_0x1af5e3[_0x3012f0(0x172)]()[_0x3012f0(0x151)](/-/g,'_');_0x47edf9['TD_API_KEY_'+_0x8c1057]=_0x5c6bbc;const _0x55fe00=Object[_0x3012f0(0x158)](_0x47edf9)['map'](([_0x577c3d,_0xd33e9e])=>_0x577c3d+'='+_0xd33e9e);writeFileSync(_0x485097,_0x55fe00['join']('\x0a')+'\x0a',{'mode':0x180});}export async function saveAPIKeyAsync(_0x582a4d,_0x50d525,_0x4e6aab){const _0x2ebf70=a45_0x389ae9;await saveKeychainAPIKey(_0x582a4d,_0x4e6aab),setCachedCredential(_0x582a4d,_0x50d525,_0x4e6aab);const _0x3a117e=getConfigFilePath(_0x4e6aab);cleanupLegacyEnvFile(_0x3a117e)&&console['warn'](a45_0x44be1d[_0x2ebf70(0x183)](_0x2ebf70(0x161)));}export function loadConfig(){const _0x112e6c=a45_0x389ae9,_0x4d50b3={'apiKeys':{},'defaultSite':_0x112e6c(0x168)},_0x4d9be4=[_0x112e6c(0x168),_0x112e6c(0x16d),_0x112e6c(0x14c),_0x112e6c(0x162),_0x112e6c(0x16c),'dev-us01',_0x112e6c(0x15b),'stg-us01',_0x112e6c(0x164),_0x112e6c(0x160)],_0x3b997a=getAPIKey();if(_0x3b997a)for(const _0x435264 of _0x4d9be4){_0x4d50b3['apiKeys'][_0x435264]=_0x3b997a;}return _0x4d50b3;}export function isExperimentalAvailable(){return!!process.env.TDX_EXPERIMENTAL;}export function loadGlobalProxy(){const _0xec9be1=a45_0x389ae9,_0x2a751a=a45_0x1cb021['join'](getConfigDir(),_0xec9be1(0x16a));if(!a45_0x27cb27['existsSync'](_0x2a751a))return undefined;try{const _0x2a9bc3=a45_0x27cb27[_0xec9be1(0x154)](_0x2a751a,'utf-8'),_0x5c693f=JSON[_0xec9be1(0x155)](_0x2a9bc3);return typeof _0x5c693f[_0xec9be1(0x173)]===_0xec9be1(0x146)?_0x5c693f[_0xec9be1(0x173)]:undefined;}catch{return undefined;}}export function loadReleaseChannel(){const _0x236186=a45_0x389ae9,_0xae753e=process.env.TDX_RELEASE_CHANNEL;if(_0xae753e==='next'||_0xae753e===_0x236186(0x187))return _0xae753e;const _0x222546=a45_0x1cb021[_0x236186(0x179)](getConfigDir(),_0x236186(0x16a));if(!a45_0x27cb27[_0x236186(0x186)](_0x222546))return'stable';try{const _0x45bb75=a45_0x27cb27[_0x236186(0x154)](_0x222546,_0x236186(0x184)),_0x4f8b53=JSON[_0x236186(0x155)](_0x45bb75);if(_0x4f8b53[_0x236186(0x15a)]===_0x236186(0x152))return _0x236186(0x152);}catch{}return _0x236186(0x187);}export function saveReleaseChannel(_0x32c4d5){const _0x17c74b=a45_0x389ae9,_0x197b2d=getConfigDir(),_0x11af78=a45_0x1cb021[_0x17c74b(0x179)](_0x197b2d,'tdx.json');!existsSync(_0x197b2d)&&mkdirSync(_0x197b2d,{'recursive':!![],'mode':0x1c0});let _0x72785f={};if(existsSync(_0x11af78))try{const _0x5d7855=readFileSync(_0x11af78,_0x17c74b(0x184));_0x72785f=JSON['parse'](_0x5d7855);}catch{}_0x72785f[_0x17c74b(0x15a)]=_0x32c4d5,writeFileSync(_0x11af78,JSON[_0x17c74b(0x14e)](_0x72785f,null,0x2),{'mode':0x180});}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
const a46_0x48f1dc=a46_0x19c8;(function(_0x305b27,_0x2639f3){const _0x3ff1e4=a46_0x19c8,_0x262fa0=_0x305b27();while(!![]){try{const _0x4670d8=-parseInt(_0x3ff1e4(0xf0))/0x1*(parseInt(_0x3ff1e4(0x102))/0x2)+-parseInt(_0x3ff1e4(0xf5))/0x3+parseInt(_0x3ff1e4(0x101))/0x4*(-parseInt(_0x3ff1e4(0xf9))/0x5)+-parseInt(_0x3ff1e4(0xf4))/0x6*(-parseInt(_0x3ff1e4(0xf6))/0x7)+parseInt(_0x3ff1e4(0x100))/0x8*(parseInt(_0x3ff1e4(0xfd))/0x9)+parseInt(_0x3ff1e4(0xff))/0xa*(-parseInt(_0x3ff1e4(0xfb))/0xb)+parseInt(_0x3ff1e4(0xf3))/0xc*(parseInt(_0x3ff1e4(0xfe))/0xd);if(_0x4670d8===_0x2639f3)break;else _0x262fa0['push'](_0x262fa0['shift']());}catch(_0x3e4b87){_0x262fa0['push'](_0x262fa0['shift']());}}}(a46_0xf0a7,0x85a24));import{createProfileCache}from'../utils/global-cache.js';function a46_0xf0a7(){const _0x948c95=['28964652gATSeU','840DhKhWW','2691345Rsiahq','13027YKKNds','connections','now','5rGqjpg','core/connection-cache','231UisAiJ','write','198WXtQpy','13BGLqtT','395570jWDEwj','397752BuMckr','1953664DBXdcH','2XpgxxF','1004487ihFpdw','read','connections-{profile}.json'];a46_0xf0a7=function(){return _0x948c95;};return a46_0xf0a7();}const connectionCache=createProfileCache(a46_0x48f1dc(0xf2),a46_0x48f1dc(0xfa));function a46_0x19c8(_0x1e0a1a,_0x190b5f){_0x1e0a1a=_0x1e0a1a-0xf0;const _0xf0a790=a46_0xf0a7();let _0x19c80b=_0xf0a790[_0x1e0a1a];return _0x19c80b;}export function loadCachedConnections(_0x47aed3){const _0x1d7b01=a46_0x48f1dc,_0x2f8be4=connectionCache[_0x1d7b01(0xf1)](_0x47aed3);return _0x2f8be4?.[_0x1d7b01(0xf7)]??null;}export function saveCachedConnections(_0x563d35,_0x43a3e6){const _0x5a402f=a46_0x48f1dc;connectionCache[_0x5a402f(0xfc)](_0x563d35,{'connections':_0x43a3e6,'cachedAt':Date[_0x5a402f(0xf8)]()});}export function clearConnectionCache(_0x28db8c){connectionCache['clear'](_0x28db8c);}
|
package/dist/core/constants.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a47_0x157690=a47_0x2144;(function(_0x3c89e2,_0x5a9c21){const _0x34826f=a47_0x2144,_0x32b579=_0x3c89e2();while(!![]){try{const _0x319b40=parseInt(_0x34826f(0x152))/0x1+parseInt(_0x34826f(0x14a))/0x2+parseInt(_0x34826f(0x153))/0x3+parseInt(_0x34826f(0x143))/0x4+-parseInt(_0x34826f(0x151))/0x5*(parseInt(_0x34826f(0x154))/0x6)+parseInt(_0x34826f(0x147))/0x7+-parseInt(_0x34826f(0x144))/0x8*(parseInt(_0x34826f(0x14b))/0x9);if(_0x319b40===_0x5a9c21)break;else _0x32b579['push'](_0x32b579['shift']());}catch(_0x49163c){_0x32b579['push'](_0x32b579['shift']());}}}(a47_0xdee5,0x6bbdb));export const DEFAULT_DISPLAY_LIMIT=0x28;export const DEFAULT_LISTING_LIMIT=0x2710;function a47_0x2144(_0x3a3f60,_0x3618b3){_0x3a3f60=_0x3a3f60-0x140;const _0xdee59=a47_0xdee5();let _0x214454=_0xdee59[_0x3a3f60];return _0x214454;}export const DEFAULT_LLM_LIMIT=0x32;function a47_0xdee5(){const _0x5dbd79=['jp\x20\x20\x20-\x20Japan','us\x20\x20\x20-\x20United\x20States','ap02\x20-\x20Korea','us01','eu\x20\x20\x20-\x20Europe','5gDWjdo','660246oaoxhs','1324581QTyHYh','5094198QVebtv','ap02','value','jp01','Enter\x20custom\x20site','3323456xExBoU','12138976lUNERx','findIndex','eu01','3915002rRiVAS','number','push','631578pwwRoU','9oORbEB'];a47_0xdee5=function(){return _0x5dbd79;};return a47_0xdee5();}export function resolveLimit(_0x12f000,_0x522f47){const _0x4e50e2=a47_0x2144;if(_0x12f000===undefined)return _0x522f47;if(typeof _0x12f000===_0x4e50e2(0x148))return _0x12f000;return parseInt(_0x12f000,0xa);}export const STANDARD_SITE_CHOICES=[{'title':a47_0x157690(0x14d),'value':a47_0x157690(0x14f)},{'title':a47_0x157690(0x14c),'value':a47_0x157690(0x141)},{'title':a47_0x157690(0x150),'value':a47_0x157690(0x146)},{'title':a47_0x157690(0x14e),'value':a47_0x157690(0x155)}];export function buildSiteChoices(_0x35a5b4){const _0x3597a7=a47_0x157690,_0x4db290=[...STANDARD_SITE_CHOICES];let _0x5ae175=_0x4db290[_0x3597a7(0x145)](_0x5e0f29=>_0x5e0f29[_0x3597a7(0x140)]===_0x35a5b4);return _0x5ae175===-0x1&&_0x35a5b4!==_0x3597a7(0x14f)&&(_0x4db290['push']({'title':_0x35a5b4,'value':_0x35a5b4}),_0x5ae175=_0x4db290['length']-0x1),_0x4db290[_0x3597a7(0x149)]({'title':_0x3597a7(0x142),'value':'other'}),{'choices':_0x4db290,'initialIndex':_0x5ae175>=0x0?_0x5ae175:0x0};}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(_0x10914b,_0x48ad9e){const _0x1e1794=a48_0x5a4b,_0x4627e1=_0x10914b();while(!![]){try{const _0x27d99a=-parseInt(_0x1e1794(0x1fa))/0x1+parseInt(_0x1e1794(0x1f0))/0x2*(-parseInt(_0x1e1794(0x1f7))/0x3)+parseInt(_0x1e1794(0x1f6))/0x4*(parseInt(_0x1e1794(0x1fc))/0x5)+parseInt(_0x1e1794(0x1fb))/0x6+parseInt(_0x1e1794(0x1ef))/0x7*(-parseInt(_0x1e1794(0x1f5))/0x8)+parseInt(_0x1e1794(0x1f2))/0x9+parseInt(_0x1e1794(0x1f8))/0xa;if(_0x27d99a===_0x48ad9e)break;else _0x4627e1['push'](_0x4627e1['shift']());}catch(_0x38af53){_0x4627e1['push'](_0x4627e1['shift']());}}}(a48_0x5a77,0x5df9f));const cache=new Map(),CACHE_TTL_MS=0x5*0x3c*0x3e8;function getCacheKey(_0x3d32f1,_0xbdad50){const _0x1f6cfb=a48_0x5a4b,_0x4fa964=_0x3d32f1||_0x1f6cfb(0x1fe),_0x58390b=_0xbdad50||_0x1f6cfb(0x1fd);return _0x4fa964+':'+_0x58390b;}export function getCachedCredential(_0x223d57,_0x496ef2){const _0x23e486=a48_0x5a4b,_0x244eec=getCacheKey(_0x223d57,_0x496ef2),_0x409092=cache[_0x23e486(0x1ff)](_0x244eec);if(!_0x409092)return null;if(Date[_0x23e486(0x1ed)]()-_0x409092[_0x23e486(0x1f3)]>CACHE_TTL_MS)return cache[_0x23e486(0x1f4)](_0x244eec),null;return _0x409092[_0x23e486(0x1f1)];}export function setCachedCredential(_0x28fa9d,_0x1894ab,_0x41e1f5){const _0x441c5e=a48_0x5a4b,_0x4aba5b=getCacheKey(_0x1894ab,_0x41e1f5);cache[_0x441c5e(0x1ee)](_0x4aba5b,{'apiKey':_0x28fa9d,'loadedAt':Date[_0x441c5e(0x1ed)]()});}export function clearCredentialCache(){const _0x58e5c1=a48_0x5a4b;cache[_0x58e5c1(0x1f9)]();}function a48_0x5a4b(_0x4987cc,_0x4513fb){_0x4987cc=_0x4987cc-0x1ed;const _0x5a7799=a48_0x5a77();let _0x5a4bb4=_0x5a7799[_0x4987cc];return _0x5a4bb4;}export function clearCachedCredential(_0x4964f6,_0x4173b1){const _0x477f63=getCacheKey(_0x4964f6,_0x4173b1);cache['delete'](_0x477f63);}function a48_0x5a77(){const _0x1fcecb=['__default_profile__','__default_site__','get','now','set','4499516QwkvTx','241726nFDutJ','apiKey','2412279SmjVIy','loadedAt','delete','8mlVJlV','84HfYlJW','18LoDQUB','15491420fGpaeB','clear','512911TwzTbE','2645040OfKFhP','1855htTfDE'];a48_0x5a77=function(){return _0x1fcecb;};return a48_0x5a77();}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const a49_0x63ff33=a49_0x590e;function a49_0x590e(_0x1be8d2,_0x145808){_0x1be8d2=_0x1be8d2-0x113;const _0x36a294=a49_0x36a2();let _0x590ebe=_0x36a294[_0x1be8d2];return _0x590ebe;}(function(_0x4f96e9,_0x21ed58){const _0x3d2bd6=a49_0x590e,_0x32a228=_0x4f96e9();while(!![]){try{const _0x433888=parseInt(_0x3d2bd6(0x13e))/0x1+parseInt(_0x3d2bd6(0x145))/0x2*(parseInt(_0x3d2bd6(0x11a))/0x3)+parseInt(_0x3d2bd6(0x12b))/0x4+-parseInt(_0x3d2bd6(0x140))/0x5+-parseInt(_0x3d2bd6(0x149))/0x6*(-parseInt(_0x3d2bd6(0x15c))/0x7)+-parseInt(_0x3d2bd6(0x14e))/0x8+-parseInt(_0x3d2bd6(0x11d))/0x9;if(_0x433888===_0x21ed58)break;else _0x32a228['push'](_0x32a228['shift']());}catch(_0x121ffe){_0x32a228['push'](_0x32a228['shift']());}}}(a49_0x36a2,0x69992));import{resolveSite,getAPIKey,getAPIKeyAsync,getConfigDir}from'./config.js';import{loadSessionContext,getSessionID}from'./session.js';import{loadProjectConfig,findProjectConfigPath}from'./project-config.js';import{loadProfile}from'./profile.js';import{LogLevel}from'../utils/logger/index.js';function a49_0x36a2(){const _0x10963c=['sessionId','parse','resolveAPIKeyAsync','none','(active)','injectIntoOptions','14yaQebG','session','getParameters','join','green','logLevel','.json','parent_segment','8163tUHfkA','project','bold','4483962TTrylF','config','CLI\x20flag:\x20--','existsSync','profile:\x20','tdx.json','[configuration\x20files]','llmProject','site','profileCredentials','entries','segmentPath','profileSource','activeProfile','680856NPUjDM','getSource','env','Profile','Session','(session:\x20','default','verbose','llm_project','configFiles','Project','database','string','workflow_project','us01','log','profile','Global','global','98881aauvIj','[context]','1346435RINrCx','proxy','cliFlags','apiKey','.env','454eXPajV','loadGlobalConfig','Profile\x20Credentials','cyan','2014134yoynuQ','llm_agent','utf-8','displayWithSources','cli','2864840SSHzzQ','segment_path','llmAgent','dim','profiles','parentSegment','layers','not\x20set'];a49_0x36a2=function(){return _0x10963c;};return a49_0x36a2();}import*as a49_0x58c11e from'node:fs';import*as a49_0xa1eb3d from'node:path';import a49_0x540c98 from'chalk';export class GlobalContext{['site'];[a49_0x63ff33(0x136)];['parent_segment'];['segment_path'];[a49_0x63ff33(0x133)];[a49_0x63ff33(0x14a)];['workflow_project'];['apiKey'];[a49_0x63ff33(0x141)];[a49_0x63ff33(0x132)];['logLevel'];[a49_0x63ff33(0x13b)];['profileSource']=null;[a49_0x63ff33(0x154)];[a49_0x63ff33(0x12a)];[a49_0x63ff33(0x156)];['configFiles'];constructor(_0x4865c1){const _0x1a12e5=a49_0x63ff33;this[_0x1a12e5(0x156)]=getSessionID(_0x4865c1['session']);const _0x7eb4a0=loadSessionContext(_0x4865c1[_0x1a12e5(0x113)]),_0x1694ac=loadProjectConfig(),_0x3a8870=this[_0x1a12e5(0x146)]();if(_0x4865c1['profile'])this[_0x1a12e5(0x12a)]=_0x4865c1[_0x1a12e5(0x13b)],this['profileSource']=_0x1a12e5(0x14d);else{if(_0x7eb4a0?.[_0x1a12e5(0x13b)])this['activeProfile']=_0x7eb4a0[_0x1a12e5(0x13b)],this[_0x1a12e5(0x129)]='session';else{if(_0x3a8870['profile'])this[_0x1a12e5(0x12a)]=_0x3a8870[_0x1a12e5(0x13b)],this[_0x1a12e5(0x129)]=_0x1a12e5(0x11e);else process.env.TDX_PROFILE?(this[_0x1a12e5(0x12a)]=process.env.TDX_PROFILE,this[_0x1a12e5(0x129)]=_0x1a12e5(0x12d)):(this[_0x1a12e5(0x12a)]=null,this[_0x1a12e5(0x129)]=null);}}const _0x230784=this[_0x1a12e5(0x12a)]?loadProfile(this['activeProfile']):null,_0x36935a=_0x4f39a8=>{const _0x584a84=_0x1a12e5;if(!_0x4f39a8)return{};const _0x27c394=_0x4f39a8,_0x195782={};for(const [_0x5e05b2,_0x2ee3b7]of Object[_0x584a84(0x127)](_0x27c394)){typeof _0x2ee3b7===_0x584a84(0x137)&&(_0x195782[_0x5e05b2]=_0x2ee3b7);}return _0x195782;},_0x61e3d4={},_0x3670f3=(_0x5f2977,_0x4eddbb,_0x54950a)=>{if(!_0x5f2977)return![];if(_0x54950a&&_0x5f2977===_0x54950a)return![];const _0x59c66e=_0x7eb4a0,_0x593f53=_0x1694ac,_0x3135d9=_0x230784?.['config'],_0x45d230=_0x3a8870,_0x2ff360=_0x59c66e?.[_0x4eddbb],_0x43ae38=_0x593f53?.[_0x4eddbb],_0x253c3f=_0x3135d9?.[_0x4eddbb],_0x19caa7=_0x45d230[_0x4eddbb];return _0x5f2977!==_0x2ff360&&_0x5f2977!==_0x43ae38&&_0x5f2977!==_0x253c3f&&_0x5f2977!==_0x19caa7;},_0x3abc5d=[{'optionKey':_0x1a12e5(0x125),'contextKey':'site','defaultValue':_0x1a12e5(0x139)},{'optionKey':_0x1a12e5(0x136),'contextKey':_0x1a12e5(0x136)},{'optionKey':_0x1a12e5(0x153),'contextKey':_0x1a12e5(0x119)},{'optionKey':_0x1a12e5(0x124),'contextKey':_0x1a12e5(0x133)},{'optionKey':'llmAgent','contextKey':_0x1a12e5(0x14a)},{'optionKey':'profile','contextKey':_0x1a12e5(0x13b)}];for(const {optionKey:_0x1ca238,contextKey:_0x5e2499,defaultValue:_0x3a9e7a}of _0x3abc5d){const _0x17ab40=_0x4865c1[_0x1ca238];_0x3670f3(_0x17ab40,_0x5e2499,_0x3a9e7a)&&(_0x61e3d4[_0x5e2499]=_0x17ab40);}this['layers']={'cliFlags':_0x61e3d4,'session':_0x36935a(_0x7eb4a0),'project':_0x36935a(_0x1694ac),'profile':_0x36935a(_0x230784?.['config']),'global':_0x36935a(_0x3a8870)};const _0x3fdd4c={...this['layers'][_0x1a12e5(0x13d)],...this[_0x1a12e5(0x154)][_0x1a12e5(0x13b)],...this[_0x1a12e5(0x154)][_0x1a12e5(0x11b)]};process.env.TDX_SITE&&!this[_0x1a12e5(0x154)]['session'][_0x1a12e5(0x125)]&&!this[_0x1a12e5(0x154)][_0x1a12e5(0x142)][_0x1a12e5(0x125)]&&(_0x3fdd4c['site']=process.env.TDX_SITE);Object['assign'](_0x3fdd4c,this[_0x1a12e5(0x154)][_0x1a12e5(0x113)]),Object['assign'](_0x3fdd4c,this[_0x1a12e5(0x154)][_0x1a12e5(0x142)]);const _0x3cbdd8=_0x3fdd4c[_0x1a12e5(0x125)]||_0x1a12e5(0x139);this[_0x1a12e5(0x125)]=resolveSite(_0x3cbdd8),this['database']=_0x3fdd4c['database'],this[_0x1a12e5(0x119)]=_0x3fdd4c[_0x1a12e5(0x119)],this[_0x1a12e5(0x14f)]=_0x3fdd4c[_0x1a12e5(0x14f)],this[_0x1a12e5(0x133)]=_0x3fdd4c[_0x1a12e5(0x133)],this[_0x1a12e5(0x14a)]=_0x3fdd4c['llm_agent'],this[_0x1a12e5(0x138)]=_0x3fdd4c[_0x1a12e5(0x138)],this[_0x1a12e5(0x132)]=_0x4865c1[_0x1a12e5(0x132)]||![],this[_0x1a12e5(0x117)]=_0x4865c1['logLevel']??LogLevel['INFO'],this[_0x1a12e5(0x13b)]=this[_0x1a12e5(0x12a)]||undefined,this['apiKey']=getAPIKey(this[_0x1a12e5(0x12a)]||undefined);const _0x1bc9e2=typeof _0x3a8870[_0x1a12e5(0x141)]===_0x1a12e5(0x137)?_0x3a8870[_0x1a12e5(0x141)]:undefined;this[_0x1a12e5(0x141)]=_0x1bc9e2||process.env.HTTPS_PROXY||process.env.HTTP_PROXY;const _0x4ab559=getConfigDir(),_0x553f8c=a49_0xa1eb3d[_0x1a12e5(0x115)](_0x4ab559,'sessions',this[_0x1a12e5(0x156)]+_0x1a12e5(0x118)),_0x1c5956=findProjectConfigPath(),_0x5e3052=a49_0xa1eb3d[_0x1a12e5(0x115)](_0x4ab559,'tdx.json'),_0x2d16ab=a49_0xa1eb3d[_0x1a12e5(0x115)](_0x4ab559,_0x1a12e5(0x144));let _0x2309e0=null,_0x54ed58=null;this[_0x1a12e5(0x12a)]&&(_0x2309e0=a49_0xa1eb3d['join'](_0x4ab559,_0x1a12e5(0x152),this[_0x1a12e5(0x12a)],_0x1a12e5(0x122)),_0x54ed58=a49_0xa1eb3d['join'](_0x4ab559,'profiles',this['activeProfile'],_0x1a12e5(0x144))),this['configFiles']={'session':a49_0x58c11e[_0x1a12e5(0x120)](_0x553f8c)?_0x553f8c:null,'project':_0x1c5956,'profile':_0x2309e0&&a49_0x58c11e[_0x1a12e5(0x120)](_0x2309e0)?_0x2309e0:null,'profileCredentials':_0x54ed58&&a49_0x58c11e[_0x1a12e5(0x120)](_0x54ed58)?_0x54ed58:null,'global':a49_0x58c11e[_0x1a12e5(0x120)](_0x5e3052)?_0x5e3052:null,'globalCredentials':a49_0x58c11e[_0x1a12e5(0x120)](_0x2d16ab)?_0x2d16ab:null};}[a49_0x63ff33(0x12c)](_0x40be8a,_0x23b1b6){const _0x2e225e=a49_0x63ff33;if(!_0x23b1b6)return _0x2e225e(0x155);const _0x5dcad0=_0x23b1b6;if(this['layers'][_0x2e225e(0x142)][_0x40be8a]===_0x5dcad0){if(_0x40be8a===_0x2e225e(0x125)&&_0x5dcad0===_0x2e225e(0x139)&&!this['layers'][_0x2e225e(0x113)]['site']&&!this['layers'][_0x2e225e(0x11b)][_0x2e225e(0x125)]&&!this[_0x2e225e(0x154)][_0x2e225e(0x13b)][_0x2e225e(0x125)]&&!this[_0x2e225e(0x154)][_0x2e225e(0x13d)][_0x2e225e(0x125)])return'default';return _0x2e225e(0x11f)+_0x40be8a['replace'](/_/g,'-');}if(this[_0x2e225e(0x154)][_0x2e225e(0x113)][_0x40be8a]===_0x5dcad0)return _0x2e225e(0x113);if(this['layers'][_0x2e225e(0x11b)][_0x40be8a]===_0x5dcad0)return _0x2e225e(0x11b);if(this[_0x2e225e(0x154)][_0x2e225e(0x13b)][_0x40be8a]===_0x5dcad0)return _0x2e225e(0x121)+this[_0x2e225e(0x12a)];if(this[_0x2e225e(0x154)][_0x2e225e(0x13d)][_0x40be8a]===_0x5dcad0)return'global';return _0x2e225e(0x131);}[a49_0x63ff33(0x146)](){const _0x5d3e81=a49_0x63ff33,_0x4c4021=a49_0xa1eb3d[_0x5d3e81(0x115)](getConfigDir(),'tdx.json');if(!a49_0x58c11e[_0x5d3e81(0x120)](_0x4c4021))return{};try{const _0x1aa052=a49_0x58c11e['readFileSync'](_0x4c4021,_0x5d3e81(0x14b));return JSON[_0x5d3e81(0x157)](_0x1aa052);}catch{return{};}}[a49_0x63ff33(0x15b)](_0x324ad6){const _0x2b79a1=a49_0x63ff33;_0x324ad6['site']=this[_0x2b79a1(0x125)],!_0x324ad6[_0x2b79a1(0x136)]&&this[_0x2b79a1(0x136)]&&(_0x324ad6[_0x2b79a1(0x136)]=this[_0x2b79a1(0x136)]),!_0x324ad6[_0x2b79a1(0x153)]&&this['parent_segment']&&(_0x324ad6[_0x2b79a1(0x153)]=this[_0x2b79a1(0x119)]),!_0x324ad6[_0x2b79a1(0x128)]&&this[_0x2b79a1(0x14f)]&&(_0x324ad6[_0x2b79a1(0x128)]=this[_0x2b79a1(0x14f)]),!_0x324ad6[_0x2b79a1(0x124)]&&this['llm_project']&&(_0x324ad6[_0x2b79a1(0x124)]=this[_0x2b79a1(0x133)]),!_0x324ad6[_0x2b79a1(0x150)]&&this[_0x2b79a1(0x14a)]&&(_0x324ad6['llmAgent']=this[_0x2b79a1(0x14a)]),!_0x324ad6['workflowProject']&&this['workflow_project']&&(_0x324ad6['workflowProject']=this[_0x2b79a1(0x138)]);}['getParameters'](){const _0x23a957=a49_0x63ff33;return[{'key':_0x23a957(0x125),'value':this['site']},{'key':'database','value':this[_0x23a957(0x136)]},{'key':_0x23a957(0x119),'value':this[_0x23a957(0x119)]},{'key':'segment_path','value':this[_0x23a957(0x14f)]},{'key':'llm_project','value':this[_0x23a957(0x133)]},{'key':_0x23a957(0x14a),'value':this['llm_agent']},{'key':_0x23a957(0x138),'value':this['workflow_project']},{'key':'profile','value':this['activeProfile']||undefined}];}['display'](){const _0x1585b1=a49_0x63ff33;console[_0x1585b1(0x13a)](a49_0x540c98[_0x1585b1(0x11c)](_0x1585b1(0x13f)));for(const {key:_0xc49352,value:_0x1208dc}of this[_0x1585b1(0x114)]()){_0x1208dc&&console[_0x1585b1(0x13a)](a49_0x540c98[_0x1585b1(0x148)](_0xc49352)+':\x20'+_0x1208dc);}}[a49_0x63ff33(0x14c)](){const _0x39117a=a49_0x63ff33;console[_0x39117a(0x13a)](a49_0x540c98[_0x39117a(0x11c)]('[context]'));for(const {key:_0x35696c,value:_0x5122c7}of this[_0x39117a(0x114)]()){if(_0x5122c7){const _0x3d682c=_0x35696c===_0x39117a(0x13b)?_0x39117a(0x15a):'('+this['getSource'](_0x35696c,_0x5122c7)+')';console['log'](a49_0x540c98['cyan'](_0x35696c)+':\x20'+_0x5122c7+'\x20'+a49_0x540c98['dim'](_0x3d682c));}}console[_0x39117a(0x13a)]('\x0a'+a49_0x540c98[_0x39117a(0x11c)](_0x39117a(0x123)));const _0x33a737=[{'label':_0x39117a(0x12f),'path':this[_0x39117a(0x134)][_0x39117a(0x113)],'extra':_0x39117a(0x130)+this[_0x39117a(0x156)]+')'},{'label':_0x39117a(0x135),'path':this['configFiles'][_0x39117a(0x11b)]},{'label':_0x39117a(0x12e),'path':this[_0x39117a(0x134)][_0x39117a(0x13b)]},{'label':_0x39117a(0x147),'path':this[_0x39117a(0x134)][_0x39117a(0x126)]},{'label':_0x39117a(0x13c),'path':this[_0x39117a(0x134)][_0x39117a(0x13d)]},{'label':'Global\x20Credentials','path':this[_0x39117a(0x134)]['globalCredentials']}];for(const {label:_0x5e2be4,path:_0x261112,extra:_0x3ead3f}of _0x33a737){if(_0x261112)console['log'](a49_0x540c98[_0x39117a(0x148)](_0x5e2be4)+':\x20'+_0x261112+'\x20'+a49_0x540c98[_0x39117a(0x116)]('✓')+(_0x3ead3f?'\x20'+a49_0x540c98[_0x39117a(0x151)](_0x3ead3f):''));else{if(_0x5e2be4===_0x39117a(0x12f))console[_0x39117a(0x13a)](a49_0x540c98[_0x39117a(0x148)](_0x5e2be4)+':\x20'+a49_0x540c98[_0x39117a(0x151)]('none')+'\x20'+a49_0x540c98[_0x39117a(0x151)]('(using\x20session:\x20'+this[_0x39117a(0x156)]+')'));else(_0x5e2be4===_0x39117a(0x135)||_0x5e2be4===_0x39117a(0x13c))&&console[_0x39117a(0x13a)](a49_0x540c98['cyan'](_0x5e2be4)+':\x20'+a49_0x540c98[_0x39117a(0x151)](_0x39117a(0x159)));}}}async['resolveAPIKeyAsync'](){const _0x87cb6a=a49_0x63ff33;return this[_0x87cb6a(0x143)]=await getAPIKeyAsync(this[_0x87cb6a(0x125)],this[_0x87cb6a(0x12a)]||undefined),this[_0x87cb6a(0x143)];}static async['createAsync'](_0x1b8ad0){const _0x467239=a49_0x63ff33,_0x2688ec=new GlobalContext(_0x1b8ad0);return await _0x2688ec[_0x467239(0x158)](),_0x2688ec;}}
|
|
1
|
+
const a49_0x3098be=a49_0x4abf;function a49_0x4abf(_0x195d58,_0x3be49f){_0x195d58=_0x195d58-0x69;const _0x57c3a0=a49_0x57c3();let _0x4abf5a=_0x57c3a0[_0x195d58];return _0x4abf5a;}(function(_0xf18a4e,_0x274af1){const _0x574378=a49_0x4abf,_0xd6af7d=_0xf18a4e();while(!![]){try{const _0x5c59e7=-parseInt(_0x574378(0x9c))/0x1*(-parseInt(_0x574378(0xb6))/0x2)+parseInt(_0x574378(0x8b))/0x3*(parseInt(_0x574378(0xa4))/0x4)+parseInt(_0x574378(0x7e))/0x5*(parseInt(_0x574378(0x7d))/0x6)+parseInt(_0x574378(0xa7))/0x7+parseInt(_0x574378(0x8a))/0x8+-parseInt(_0x574378(0xaf))/0x9*(parseInt(_0x574378(0x89))/0xa)+-parseInt(_0x574378(0xad))/0xb;if(_0x5c59e7===_0x274af1)break;else _0xd6af7d['push'](_0xd6af7d['shift']());}catch(_0x46d867){_0xd6af7d['push'](_0xd6af7d['shift']());}}}(a49_0x57c3,0x3a48a));import{resolveSite,getAPIKey,getAPIKeyAsync,getConfigDir}from'./config.js';import{loadSessionContext,getSessionID}from'./session.js';import{loadProjectConfig,findProjectConfigPath}from'./project-config.js';import{loadProfile}from'./profile.js';import{LogLevel}from'../utils/logger/index.js';import*as a49_0x3d3c61 from'node:fs';import*as a49_0x25ee06 from'node:path';function a49_0x57c3(){const _0x383b8b=['parentSegment','INFO','env','dim','7169701IckGdB','join','171BvlEPT','cyan','segmentPath','CLI\x20flag:\x20--','config','log','[configuration\x20files]','48458znfRGI','(session:\x20','existsSync','llm_project','readFileSync','createAsync','llmAgent','global','logLevel','project','llm_agent','cliFlags','green','profile:\x20','workflowProject','parent_segment','workflow_project','tdx.json','assign','Session','apiKey','proxy','us01','1428xzQGmS','1895LGkNiM','activeProfile','Profile','verbose','profiles','Global','getSource','layers','Project','llmProject','session','130430xtKHml','1051288xnpQLS','24qcmEhI','bold','sessionId','replace','not\x20set','[context]','site','displayWithSources','.env','configFiles','(using\x20session:\x20','default','Global\x20Credentials','sessions','loadGlobalConfig','profileSource','globalCredentials','15XDskSM','profileCredentials','segment_path','.json','none','Profile\x20Credentials','profile','getParameters','222524hsIXyj','database','resolveAPIKeyAsync','757694tkbmpu','string'];a49_0x57c3=function(){return _0x383b8b;};return a49_0x57c3();}import a49_0x561fe6 from'chalk';export class GlobalContext{[a49_0x3098be(0x91)];[a49_0x3098be(0xa5)];[a49_0x3098be(0x75)];[a49_0x3098be(0x9e)];[a49_0x3098be(0x69)];[a49_0x3098be(0x70)];['workflow_project'];[a49_0x3098be(0x7a)];[a49_0x3098be(0x7b)];[a49_0x3098be(0x81)];['logLevel'];['profile'];[a49_0x3098be(0x9a)]=null;[a49_0x3098be(0x85)];['activeProfile'];[a49_0x3098be(0x8d)];[a49_0x3098be(0x94)];constructor(_0x4ef0da){const _0x10de59=a49_0x3098be;this[_0x10de59(0x8d)]=getSessionID(_0x4ef0da[_0x10de59(0x88)]);const _0xd4d1a2=loadSessionContext(_0x4ef0da['session']),_0x4c60c8=loadProjectConfig(),_0x514d6e=this[_0x10de59(0x99)]();if(_0x4ef0da['profile'])this['activeProfile']=_0x4ef0da[_0x10de59(0xa2)],this['profileSource']='cli';else{if(_0xd4d1a2?.[_0x10de59(0xa2)])this[_0x10de59(0x7f)]=_0xd4d1a2[_0x10de59(0xa2)],this['profileSource']='session';else{if(_0x514d6e[_0x10de59(0xa2)])this[_0x10de59(0x7f)]=_0x514d6e[_0x10de59(0xa2)],this['profileSource']=_0x10de59(0xb3);else process.env.TDX_PROFILE?(this[_0x10de59(0x7f)]=process.env.TDX_PROFILE,this[_0x10de59(0x9a)]=_0x10de59(0xab)):(this['activeProfile']=null,this[_0x10de59(0x9a)]=null);}}const _0x6326cd=this['activeProfile']?loadProfile(this[_0x10de59(0x7f)]):null,_0x236388=_0x4fd720=>{const _0x16ac65=_0x10de59;if(!_0x4fd720)return{};const _0x2dc29d=_0x4fd720,_0xb0a13a={};for(const [_0x50c793,_0x4f20da]of Object['entries'](_0x2dc29d)){typeof _0x4f20da===_0x16ac65(0xa8)&&(_0xb0a13a[_0x50c793]=_0x4f20da);}return _0xb0a13a;},_0x4d6476={},_0x3fdee8=(_0x16dad4,_0x14feeb,_0x455f4f)=>{if(!_0x16dad4)return![];if(_0x455f4f&&_0x16dad4===_0x455f4f)return![];const _0x1ce92b=_0xd4d1a2,_0xa5369a=_0x4c60c8,_0x436b27=_0x6326cd?.['config'],_0x22a0c8=_0x514d6e,_0x9d142e=_0x1ce92b?.[_0x14feeb],_0x1e5987=_0xa5369a?.[_0x14feeb],_0xc57f9a=_0x436b27?.[_0x14feeb],_0x35a642=_0x22a0c8[_0x14feeb];return _0x16dad4!==_0x9d142e&&_0x16dad4!==_0x1e5987&&_0x16dad4!==_0xc57f9a&&_0x16dad4!==_0x35a642;},_0x372c7f=[{'optionKey':'site','contextKey':'site','defaultValue':'us01'},{'optionKey':_0x10de59(0xa5),'contextKey':'database'},{'optionKey':_0x10de59(0xa9),'contextKey':_0x10de59(0x75)},{'optionKey':_0x10de59(0x87),'contextKey':_0x10de59(0x69)},{'optionKey':'llmAgent','contextKey':_0x10de59(0x70)},{'optionKey':'profile','contextKey':_0x10de59(0xa2)}];for(const {optionKey:_0x40a71e,contextKey:_0x3838fe,defaultValue:_0x3a0c81}of _0x372c7f){const _0x40e900=_0x4ef0da[_0x40a71e];_0x3fdee8(_0x40e900,_0x3838fe,_0x3a0c81)&&(_0x4d6476[_0x3838fe]=_0x40e900);}this['layers']={'cliFlags':_0x4d6476,'session':_0x236388(_0xd4d1a2),'project':_0x236388(_0x4c60c8),'profile':_0x236388(_0x6326cd?.[_0x10de59(0xb3)]),'global':_0x236388(_0x514d6e)};const _0x29e8e5={...this[_0x10de59(0x85)]['global'],...this[_0x10de59(0x85)][_0x10de59(0xa2)],...this[_0x10de59(0x85)]['project']};process.env.TDX_SITE&&!this[_0x10de59(0x85)][_0x10de59(0x88)][_0x10de59(0x91)]&&!this[_0x10de59(0x85)][_0x10de59(0x71)][_0x10de59(0x91)]&&(_0x29e8e5[_0x10de59(0x91)]=process.env.TDX_SITE);Object[_0x10de59(0x78)](_0x29e8e5,this[_0x10de59(0x85)][_0x10de59(0x88)]),Object['assign'](_0x29e8e5,this[_0x10de59(0x85)][_0x10de59(0x71)]);const _0x2acca6=_0x29e8e5[_0x10de59(0x91)]||_0x10de59(0x7c);this['site']=resolveSite(_0x2acca6),this[_0x10de59(0xa5)]=_0x29e8e5[_0x10de59(0xa5)],this[_0x10de59(0x75)]=_0x29e8e5[_0x10de59(0x75)],this['segment_path']=_0x29e8e5[_0x10de59(0x9e)],this[_0x10de59(0x69)]=_0x29e8e5['llm_project'],this[_0x10de59(0x70)]=_0x29e8e5[_0x10de59(0x70)],this[_0x10de59(0x76)]=_0x29e8e5[_0x10de59(0x76)],this['verbose']=_0x4ef0da[_0x10de59(0x81)]||![],this[_0x10de59(0x6e)]=_0x4ef0da[_0x10de59(0x6e)]??LogLevel[_0x10de59(0xaa)],this['profile']=this['activeProfile']||undefined,this[_0x10de59(0x7a)]=getAPIKey(this[_0x10de59(0x7f)]||undefined);const _0x594030=typeof _0x514d6e[_0x10de59(0x7b)]==='string'?_0x514d6e[_0x10de59(0x7b)]:undefined;this[_0x10de59(0x7b)]=_0x594030||process.env.HTTPS_PROXY||process.env.HTTP_PROXY;const _0x2772fa=getConfigDir(),_0x28c23a=a49_0x25ee06[_0x10de59(0xae)](_0x2772fa,_0x10de59(0x98),this[_0x10de59(0x8d)]+_0x10de59(0x9f)),_0x24c29e=findProjectConfigPath(),_0x18a47f=a49_0x25ee06[_0x10de59(0xae)](_0x2772fa,_0x10de59(0x77)),_0x1e4106=a49_0x25ee06[_0x10de59(0xae)](_0x2772fa,_0x10de59(0x93));let _0x37d007=null,_0x2f68b0=null;this[_0x10de59(0x7f)]&&(_0x37d007=a49_0x25ee06[_0x10de59(0xae)](_0x2772fa,_0x10de59(0x82),this[_0x10de59(0x7f)],_0x10de59(0x77)),_0x2f68b0=a49_0x25ee06[_0x10de59(0xae)](_0x2772fa,_0x10de59(0x82),this[_0x10de59(0x7f)],_0x10de59(0x93))),this[_0x10de59(0x94)]={'session':a49_0x3d3c61[_0x10de59(0xb8)](_0x28c23a)?_0x28c23a:null,'project':_0x24c29e,'profile':_0x37d007&&a49_0x3d3c61[_0x10de59(0xb8)](_0x37d007)?_0x37d007:null,'profileCredentials':_0x2f68b0&&a49_0x3d3c61[_0x10de59(0xb8)](_0x2f68b0)?_0x2f68b0:null,'global':a49_0x3d3c61[_0x10de59(0xb8)](_0x18a47f)?_0x18a47f:null,'globalCredentials':a49_0x3d3c61['existsSync'](_0x1e4106)?_0x1e4106:null};}[a49_0x3098be(0x84)](_0x3ba4f2,_0x12d74c){const _0x237e05=a49_0x3098be;if(!_0x12d74c)return _0x237e05(0x8f);const _0x4bd1ad=_0x12d74c;if(this['layers'][_0x237e05(0x71)][_0x3ba4f2]===_0x4bd1ad){if(_0x3ba4f2==='site'&&_0x4bd1ad===_0x237e05(0x7c)&&!this[_0x237e05(0x85)][_0x237e05(0x88)][_0x237e05(0x91)]&&!this[_0x237e05(0x85)][_0x237e05(0x6f)][_0x237e05(0x91)]&&!this['layers'][_0x237e05(0xa2)][_0x237e05(0x91)]&&!this[_0x237e05(0x85)]['global'][_0x237e05(0x91)])return _0x237e05(0x96);return _0x237e05(0xb2)+_0x3ba4f2[_0x237e05(0x8e)](/_/g,'-');}if(this[_0x237e05(0x85)][_0x237e05(0x88)][_0x3ba4f2]===_0x4bd1ad)return _0x237e05(0x88);if(this[_0x237e05(0x85)][_0x237e05(0x6f)][_0x3ba4f2]===_0x4bd1ad)return'project';if(this['layers'][_0x237e05(0xa2)][_0x3ba4f2]===_0x4bd1ad)return _0x237e05(0x73)+this[_0x237e05(0x7f)];if(this[_0x237e05(0x85)][_0x237e05(0x6d)][_0x3ba4f2]===_0x4bd1ad)return _0x237e05(0x6d);return _0x237e05(0x96);}[a49_0x3098be(0x99)](){const _0x11d2fc=a49_0x3098be,_0x11edc0=a49_0x25ee06['join'](getConfigDir(),_0x11d2fc(0x77));if(!a49_0x3d3c61[_0x11d2fc(0xb8)](_0x11edc0))return{};try{const _0x3290ee=a49_0x3d3c61[_0x11d2fc(0x6a)](_0x11edc0,'utf-8');return JSON['parse'](_0x3290ee);}catch{return{};}}['injectIntoOptions'](_0x5b0c18){const _0x8f68a2=a49_0x3098be;_0x5b0c18[_0x8f68a2(0x91)]=this[_0x8f68a2(0x91)],!_0x5b0c18[_0x8f68a2(0xa5)]&&this[_0x8f68a2(0xa5)]&&(_0x5b0c18[_0x8f68a2(0xa5)]=this[_0x8f68a2(0xa5)]),!_0x5b0c18[_0x8f68a2(0xa9)]&&this[_0x8f68a2(0x75)]&&(_0x5b0c18[_0x8f68a2(0xa9)]=this[_0x8f68a2(0x75)]),!_0x5b0c18[_0x8f68a2(0xb1)]&&this[_0x8f68a2(0x9e)]&&(_0x5b0c18[_0x8f68a2(0xb1)]=this['segment_path']),!_0x5b0c18[_0x8f68a2(0x87)]&&this[_0x8f68a2(0x69)]&&(_0x5b0c18['llmProject']=this['llm_project']),!_0x5b0c18[_0x8f68a2(0x6c)]&&this[_0x8f68a2(0x70)]&&(_0x5b0c18[_0x8f68a2(0x6c)]=this[_0x8f68a2(0x70)]),!_0x5b0c18[_0x8f68a2(0x74)]&&this[_0x8f68a2(0x76)]&&(_0x5b0c18[_0x8f68a2(0x74)]=this[_0x8f68a2(0x76)]);}['getParameters'](){const _0x493e63=a49_0x3098be;return[{'key':_0x493e63(0x91),'value':this[_0x493e63(0x91)]},{'key':_0x493e63(0xa5),'value':this[_0x493e63(0xa5)]},{'key':_0x493e63(0x75),'value':this[_0x493e63(0x75)]},{'key':_0x493e63(0x9e),'value':this[_0x493e63(0x9e)]},{'key':_0x493e63(0x69),'value':this[_0x493e63(0x69)]},{'key':_0x493e63(0x70),'value':this['llm_agent']},{'key':_0x493e63(0x76),'value':this[_0x493e63(0x76)]},{'key':_0x493e63(0xa2),'value':this[_0x493e63(0x7f)]||undefined}];}['display'](){const _0x16cae8=a49_0x3098be;console[_0x16cae8(0xb4)](a49_0x561fe6[_0x16cae8(0x8c)](_0x16cae8(0x90)));for(const {key:_0x29c9d5,value:_0x47c0f6}of this[_0x16cae8(0xa3)]()){_0x47c0f6&&console[_0x16cae8(0xb4)](a49_0x561fe6[_0x16cae8(0xb0)](_0x29c9d5)+':\x20'+_0x47c0f6);}}[a49_0x3098be(0x92)](){const _0x5bf4b6=a49_0x3098be;console['log'](a49_0x561fe6[_0x5bf4b6(0x8c)](_0x5bf4b6(0x90)));for(const {key:_0x5e017e,value:_0x4f982c}of this[_0x5bf4b6(0xa3)]()){if(_0x4f982c){const _0x4d44bf=_0x5e017e==='profile'?'(active)':'('+this[_0x5bf4b6(0x84)](_0x5e017e,_0x4f982c)+')';console[_0x5bf4b6(0xb4)](a49_0x561fe6[_0x5bf4b6(0xb0)](_0x5e017e)+':\x20'+_0x4f982c+'\x20'+a49_0x561fe6[_0x5bf4b6(0xac)](_0x4d44bf));}}console[_0x5bf4b6(0xb4)]('\x0a'+a49_0x561fe6['bold'](_0x5bf4b6(0xb5)));const _0x3630a7=[{'label':_0x5bf4b6(0x79),'path':this[_0x5bf4b6(0x94)][_0x5bf4b6(0x88)],'extra':_0x5bf4b6(0xb7)+this[_0x5bf4b6(0x8d)]+')'},{'label':_0x5bf4b6(0x86),'path':this['configFiles'][_0x5bf4b6(0x6f)]},{'label':_0x5bf4b6(0x80),'path':this[_0x5bf4b6(0x94)]['profile']},{'label':_0x5bf4b6(0xa1),'path':this[_0x5bf4b6(0x94)][_0x5bf4b6(0x9d)]},{'label':_0x5bf4b6(0x83),'path':this[_0x5bf4b6(0x94)][_0x5bf4b6(0x6d)]},{'label':_0x5bf4b6(0x97),'path':this[_0x5bf4b6(0x94)][_0x5bf4b6(0x9b)]}];for(const {label:_0x2d0303,path:_0x3a0dbc,extra:_0x4d2f14}of _0x3630a7){if(_0x3a0dbc)console['log'](a49_0x561fe6[_0x5bf4b6(0xb0)](_0x2d0303)+':\x20'+_0x3a0dbc+'\x20'+a49_0x561fe6[_0x5bf4b6(0x72)]('✓')+(_0x4d2f14?'\x20'+a49_0x561fe6[_0x5bf4b6(0xac)](_0x4d2f14):''));else{if(_0x2d0303==='Session')console[_0x5bf4b6(0xb4)](a49_0x561fe6[_0x5bf4b6(0xb0)](_0x2d0303)+':\x20'+a49_0x561fe6[_0x5bf4b6(0xac)](_0x5bf4b6(0xa0))+'\x20'+a49_0x561fe6[_0x5bf4b6(0xac)](_0x5bf4b6(0x95)+this['sessionId']+')'));else(_0x2d0303===_0x5bf4b6(0x86)||_0x2d0303===_0x5bf4b6(0x83))&&console[_0x5bf4b6(0xb4)](a49_0x561fe6[_0x5bf4b6(0xb0)](_0x2d0303)+':\x20'+a49_0x561fe6[_0x5bf4b6(0xac)](_0x5bf4b6(0xa0)));}}}async[a49_0x3098be(0xa6)](){const _0x3a1272=a49_0x3098be;return this[_0x3a1272(0x7a)]=await getAPIKeyAsync(this[_0x3a1272(0x91)],this[_0x3a1272(0x7f)]||undefined),this[_0x3a1272(0x7a)];}static async[a49_0x3098be(0x6b)](_0x1205c0){const _0x13221a=a49_0x3098be,_0xd2f2bf=new GlobalContext(_0x1205c0);return await _0xd2f2bf[_0x13221a(0xa6)](),_0xd2f2bf;}}
|
package/dist/core/keychain.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a50_0x4f0f4d=a50_0x2518;(function(_0x12d9bb,_0x418621){const _0x5e317b=a50_0x2518,_0x4bd809=_0x12d9bb();while(!![]){try{const _0x138624=parseInt(_0x5e317b(0x155))/0x1+-parseInt(_0x5e317b(0x156))/0x2+-parseInt(_0x5e317b(0x16f))/0x3+-parseInt(_0x5e317b(0x15a))/0x4+parseInt(_0x5e317b(0x16a))/0x5+parseInt(_0x5e317b(0x154))/0x6+parseInt(_0x5e317b(0x16c))/0x7;if(_0x138624===_0x418621)break;else _0x4bd809['push'](_0x4bd809['shift']());}catch(_0x405f32){_0x4bd809['push'](_0x4bd809['shift']());}}}(a50_0x4b72,0xd78a1));const SERVICE_NAME=a50_0x4f0f4d(0x159);function a50_0x4b72(){const _0x12aad5=['619421cwckjh','2928216zeJzwf','-25300','no\x20matching\x20entry','tdx','3726752TDbVOc','not\x20supported','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.','reason','not\x20available','System\x20keychain\x20is\x20not\x20available','-25293','deleteCredential','unavailable','not_found','Entry','not\x20found','access','profile:','includes','Warning:\x20','5442900PiUPMa','could\x20not\x20be\x20found','12605775tFGjTv','error','success','5184762nmxChJ','message','@napi-rs/keyring','value','cannot\x20find','restricted','toLowerCase','8988438pasbwb'];a50_0x4b72=function(){return _0x12aad5;};return a50_0x4b72();}let EntryClass=null,keyringLoadError=null;async function getEntryClass(){const _0x5e0214=a50_0x4f0f4d;if(EntryClass!==null)return EntryClass;if(keyringLoadError!==null)return null;try{const _0x414e46=await import(_0x5e0214(0x14f));return EntryClass=_0x414e46[_0x5e0214(0x164)],EntryClass;}catch(_0x2867d8){return keyringLoadError=_0x2867d8 instanceof Error?_0x2867d8:new Error(String(_0x2867d8)),null;}}function getAccountName(_0x4ef253){const _0x5dfb20=a50_0x4f0f4d,_0x5d7603=_0x4ef253||'';return _0x5dfb20(0x167)+_0x5d7603+':api_key';}function a50_0x2518(_0x30f728,_0x3e3deb){_0x30f728=_0x30f728-0x14e;const _0x4b72d2=a50_0x4b72();let _0x2518cd=_0x4b72d2[_0x30f728];return _0x2518cd;}export async function getKeychainAPIKey(_0x45560c){const _0x78e7e0=a50_0x4f0f4d,_0x343f8c=await getKeychainAPIKeyWithStatus(_0x45560c);if(_0x343f8c[_0x78e7e0(0x16e)])return _0x343f8c[_0x78e7e0(0x150)];return _0x343f8c[_0x78e7e0(0x15d)]==='access_denied'&&console[_0x78e7e0(0x16d)](_0x78e7e0(0x169)+_0x343f8c[_0x78e7e0(0x14e)]),null;}export async function getKeychainAPIKeyWithStatus(_0xb6f8c4){const _0xe18ce9=a50_0x4f0f4d;try{const _0x22dfba=await getEntryClass();if(!_0x22dfba)return{'success':![],'reason':'unavailable'};const _0x175626=getAccountName(_0xb6f8c4),_0x1509f8=new _0x22dfba(SERVICE_NAME,_0x175626),_0x463ec9=_0x1509f8['getPassword']();if(_0x463ec9)return{'success':!![],'value':_0x463ec9};return{'success':![],'reason':_0xe18ce9(0x163)};}catch(_0x51cf06){const _0x8370d4=_0x51cf06 instanceof Error?_0x51cf06[_0xe18ce9(0x14e)]:String(_0x51cf06);if(_0x8370d4[_0xe18ce9(0x168)](_0xe18ce9(0x157))||_0x8370d4[_0xe18ce9(0x153)]()[_0xe18ce9(0x168)](_0xe18ce9(0x16b))||_0x8370d4[_0xe18ce9(0x153)]()[_0xe18ce9(0x168)](_0xe18ce9(0x165))||_0x8370d4[_0xe18ce9(0x153)]()['includes'](_0xe18ce9(0x158)))return{'success':![],'reason':'not_found'};if(_0x8370d4[_0xe18ce9(0x168)](_0xe18ce9(0x160))||_0x8370d4[_0xe18ce9(0x153)]()['includes'](_0xe18ce9(0x152))||_0x8370d4[_0xe18ce9(0x153)]()['includes'](_0xe18ce9(0x166)))return{'success':![],'reason':'access_denied','message':_0xe18ce9(0x15c)};return{'success':![],'reason':_0xe18ce9(0x162),'message':_0x8370d4};}}export async function saveKeychainAPIKey(_0x229b14,_0x5080c2){const _0x33233e=a50_0x4f0f4d,_0x107a5a=await getEntryClass();if(!_0x107a5a)throw new Error(_0x33233e(0x15f));const _0x519691=getAccountName(_0x5080c2),_0xb34f2d=new _0x107a5a(SERVICE_NAME,_0x519691);_0xb34f2d['setPassword'](_0x229b14);}export async function deleteKeychainAPIKey(_0x553f1f){const _0x492fc4=a50_0x4f0f4d;try{const _0x3d5795=await getEntryClass();if(!_0x3d5795)return![];const _0x9af747=getAccountName(_0x553f1f),_0x1241cf=new _0x3d5795(SERVICE_NAME,_0x9af747);return _0x1241cf[_0x492fc4(0x161)](),!![];}catch{return![];}}export async function isKeychainAvailable(){const _0x1f39d3=a50_0x4f0f4d;try{const _0x12f099=await getEntryClass();if(!_0x12f099)return![];const _0xb470aa=new _0x12f099(SERVICE_NAME,'__keychain_test__');return _0xb470aa['getPassword'](),!![];}catch(_0x446346){const _0x5eed16=_0x446346 instanceof Error?_0x446346[_0x1f39d3(0x14e)]['toLowerCase']():'';if(_0x5eed16[_0x1f39d3(0x168)](_0x1f39d3(0x15e))||_0x5eed16['includes'](_0x1f39d3(0x15b))||_0x5eed16[_0x1f39d3(0x168)](_0x1f39d3(0x151)))return![];return!![];}}
|
package/dist/core/profile.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const a51_0x260232=a51_0x442b;(function(_0x855d53,_0x3ed649){const _0x3c760e=a51_0x442b,_0x1f8ec1=_0x855d53();while(!![]){try{const _0x228798=-parseInt(_0x3c760e(0x1a7))/0x1+parseInt(_0x3c760e(0x191))/0x2+-parseInt(_0x3c760e(0x187))/0x3*(parseInt(_0x3c760e(0x17d))/0x4)+parseInt(_0x3c760e(0x174))/0x5+parseInt(_0x3c760e(0x1a3))/0x6*(-parseInt(_0x3c760e(0x197))/0x7)+-parseInt(_0x3c760e(0x184))/0x8*(-parseInt(_0x3c760e(0x1ad))/0x9)+-parseInt(_0x3c760e(0x189))/0xa;if(_0x228798===_0x3ed649)break;else _0x1f8ec1['push'](_0x1f8ec1['shift']());}catch(_0x11c903){_0x1f8ec1['push'](_0x1f8ec1['shift']());}}}(a51_0x1e3c,0x51a13));import*as a51_0x27a1 from'node:fs';import*as a51_0x18bffb from'node:path';import{SDKError,ErrorCode}from'../sdk/errors.js';import{getConfigDir}from'./config.js';import{createSecureDirectory,writeSecureFile}from'../utils/file-permissions.js';import{findProjectConfigPath}from'./project-config.js';import{loadSessionContext}from'./session.js';export const STUDIO_PROFILE_NAME=a51_0x260232(0x19d);export function getProfileParams(_0x911ac){const _0x1902c7=a51_0x260232,_0x3e4a2d={};if(!_0x911ac)return _0x3e4a2d;for(const [_0x47cf3a,_0x32f6a4]of Object[_0x1902c7(0x188)](_0x911ac)){_0x47cf3a!==_0x1902c7(0x17e)&&_0x32f6a4!==undefined&&(_0x3e4a2d[_0x47cf3a]=_0x32f6a4);}return _0x3e4a2d;}export function getProfilesDir(){const _0x51d155=a51_0x260232;return a51_0x18bffb['join'](getConfigDir(),_0x51d155(0x17b));}function getProfileDir(_0x56a49){const _0x5ef1de=a51_0x260232;return a51_0x18bffb[_0x5ef1de(0x199)](getProfilesDir(),_0x56a49);}function getProfileConfigPath(_0x1c5e32){const _0x5ab336=a51_0x260232;return a51_0x18bffb[_0x5ab336(0x199)](getProfileDir(_0x1c5e32),_0x5ab336(0x1b6));}function getProfileEnvPath(_0x53bdba){const _0x34ad9c=a51_0x260232;return a51_0x18bffb[_0x34ad9c(0x199)](getProfileDir(_0x53bdba),_0x34ad9c(0x1a5));}function a51_0x1e3c(){const _0x4bd5f5=['\x27:\x20\x27description\x27\x20must\x20be\x20a\x20string','148HjyYDB','description','string','existsSync','\x27:\x20\x27database\x27\x20must\x20be\x20a\x20string','Warning:\x20Profile\x20\x27','\x22\x20\x22','2463672BBRvlT','\x27:\x20\x27llm_agent\x27\x20must\x20be\x20a\x20string','readdirSync','4581dOStKh','entries','4913990VJsXqT','rmSync','filter','\x0aWarning:\x20Failed\x20to\x20load\x20profiles\x20from\x20','Failed\x20to\x20parse\x20','\x20does\x20not\x20exist','Profile\x20\x27','map','244918UIycpB','toISOString','INVALID_PROFILE_CONFIG','directory','Warning:\x20Failed\x20to\x20parse\x20','\x0aWarning:\x20Skipping\x20invalid\x20profile\x20in\x20','83118naMVqz','llm_agent','join','\x27:\x20config\x20must\x20be\x20an\x20object','user_info','Error:\x20','@tdx-studio','Profile\x20','values','warn','parse','message','174VjBNXi','\x27:\x20\x27parent_segment\x27\x20must\x20be\x20a\x20string','.env','test','155763QUvnWh','profile','keys','from','Then\x20define\x20profiles\x20in\x20~/.config/tdx/tdx.json\x0a','local','18spKbiw',',\x20creating\x20new\x20file','.\x20Must\x20contain\x20only\x20alphanumeric\x20characters,\x20dash,\x20underscore,\x20and\x20optional\x20@\x20prefix\x20for\x20reserved\x20profiles.','\x20\x202.\x20Add\x20profiles\x20under\x20a\x20\x22profiles\x22\x20key\x20(see\x20\x27tdx\x20profiles\x27\x20for\x20current\x20config)','database','readFileSync','has','name','includes','tdx.json','\x20\x203.\x20Move\x20credentials:\x20mv\x20~/.config/tdx/profiles/<name>/.env\x20~/.config/tdx/.env.<name>\x0a','\x20already\x20exists','utf-8','\x27\x20not\x20found\x20in\x20user\x20configuration','\x27\x20will\x20be\x20ignored','isDirectory','\x0aWarning:\x20Using\x20deprecated\x20credential\x20location\x20for\x20profile\x20\x27','length','\x27:\x20\x27llm_project\x27\x20must\x20be\x20a\x20string','some','user','.env.','object','site','push','3219925iKuyLl','sort','\x20\x20mv\x20\x22','llm_project','Invalid\x20profile\x20name:\x20','stringify','find','profiles'];a51_0x1e3c=function(){return _0x4bd5f5;};return a51_0x1e3c();}function getGlobalConfigPath(){const _0x8da469=a51_0x260232;return a51_0x18bffb[_0x8da469(0x199)](getConfigDir(),_0x8da469(0x1b6));}function validateProfileName(_0x10232c){const _0x3fbc3b=a51_0x260232;if(/^@?[a-zA-Z0-9_-]+$/[_0x3fbc3b(0x1a6)](_0x10232c))return;if(/^@tdx-studio:[a-zA-Z0-9_-]+:\d+$/[_0x3fbc3b(0x1a6)](_0x10232c))return;throw new Error(_0x3fbc3b(0x178)+_0x10232c+_0x3fbc3b(0x1af));}function validateProfileConfig(_0x1b6559,_0xf51634){const _0x330397=a51_0x260232;if(typeof _0x1b6559!==_0x330397(0x171)||_0x1b6559===null)throw new SDKError(ErrorCode[_0x330397(0x193)],'Profile\x20\x27'+_0xf51634+_0x330397(0x19a));const _0x21e7e9=[_0x330397(0x17e),_0x330397(0x172),_0x330397(0x1b1),'parent_segment',_0x330397(0x177),_0x330397(0x198),_0x330397(0x19b)],_0x537b52=_0x1b6559;for(const _0x105f28 of Object[_0x330397(0x1a9)](_0x537b52)){!_0x21e7e9[_0x330397(0x1b5)](_0x105f28)&&console[_0x330397(0x1a0)](_0x330397(0x182)+_0xf51634+'\x27:\x20unknown\x20config\x20key\x20\x27'+_0x105f28+_0x330397(0x169));}if(_0x537b52[_0x330397(0x17e)]!==undefined&&typeof _0x537b52[_0x330397(0x17e)]!==_0x330397(0x17f))throw new SDKError(ErrorCode['INVALID_PROFILE_CONFIG'],_0x330397(0x18f)+_0xf51634+_0x330397(0x17c));if(_0x537b52['site']!==undefined&&typeof _0x537b52[_0x330397(0x172)]!==_0x330397(0x17f))throw new SDKError(ErrorCode['INVALID_PROFILE_CONFIG'],'Profile\x20\x27'+_0xf51634+'\x27:\x20\x27site\x27\x20must\x20be\x20a\x20string');if(_0x537b52[_0x330397(0x1b1)]!==undefined&&typeof _0x537b52['database']!==_0x330397(0x17f))throw new SDKError(ErrorCode[_0x330397(0x193)],_0x330397(0x18f)+_0xf51634+_0x330397(0x181));if(_0x537b52['parent_segment']!==undefined&&typeof _0x537b52['parent_segment']!==_0x330397(0x17f))throw new SDKError(ErrorCode[_0x330397(0x193)],'Profile\x20\x27'+_0xf51634+_0x330397(0x1a4));if(_0x537b52['llm_project']!==undefined&&typeof _0x537b52['llm_project']!=='string')throw new SDKError(ErrorCode[_0x330397(0x193)],'Profile\x20\x27'+_0xf51634+_0x330397(0x16d));if(_0x537b52[_0x330397(0x198)]!==undefined&&typeof _0x537b52[_0x330397(0x198)]!=='string')throw new SDKError(ErrorCode['INVALID_PROFILE_CONFIG'],_0x330397(0x18f)+_0xf51634+_0x330397(0x185));return!![];}function loadProfilesFromTdxJson(_0xb467aa,_0x1537ec){const _0x153fae=a51_0x260232;if(!a51_0x27a1['existsSync'](_0xb467aa))return[];try{const _0x17aae2=a51_0x27a1[_0x153fae(0x1b2)](_0xb467aa,_0x153fae(0x167)),_0x3981a4=JSON[_0x153fae(0x1a1)](_0x17aae2);if(!_0x3981a4[_0x153fae(0x17b)]||typeof _0x3981a4[_0x153fae(0x17b)]!=='object')return[];const _0xb970b8=[];for(const [_0x2c4868,_0x4144e6]of Object[_0x153fae(0x188)](_0x3981a4[_0x153fae(0x17b)])){try{validateProfileConfig(_0x4144e6,_0x2c4868);const _0x47f236=getNewCredentialPath(_0x2c4868),_0x2a1eee=getOldCredentialPath(_0x2c4868),_0x202f20=a51_0x27a1[_0x153fae(0x180)](_0x47f236)||a51_0x27a1[_0x153fae(0x180)](_0x2a1eee);_0xb970b8[_0x153fae(0x173)]({'name':_0x2c4868,'config':_0x4144e6,'metadata':{'name':_0x2c4868,'createdAt':new Date()['toISOString']()},'hasCredentials':_0x202f20,'scope':_0x1537ec});}catch(_0x32eb7a){_0x32eb7a instanceof Error&&(console[_0x153fae(0x1a0)](_0x153fae(0x196)+_0xb467aa+':'),console[_0x153fae(0x1a0)]('\x20\x20'+_0x32eb7a[_0x153fae(0x1a2)]+'\x0a'));}}return _0xb970b8;}catch(_0x515e2c){return _0x515e2c instanceof SyntaxError?(console[_0x153fae(0x1a0)]('\x0aWarning:\x20Failed\x20to\x20parse\x20'+_0xb467aa+':\x20Invalid\x20JSON\x20syntax'),console['warn'](_0x153fae(0x19c)+_0x515e2c[_0x153fae(0x1a2)]+'\x0a')):console[_0x153fae(0x1a0)](_0x153fae(0x18c)+_0xb467aa+':\x20'+_0x515e2c+'\x0a'),[];}}export function getNewCredentialPath(_0x3cc549){const _0x33635a=a51_0x260232;return a51_0x18bffb[_0x33635a(0x199)](getConfigDir(),_0x33635a(0x170)+_0x3cc549);}function getOldCredentialPath(_0x33e6dc){const _0x503a74=a51_0x260232;return a51_0x18bffb[_0x503a74(0x199)](getProfilesDir(),_0x33e6dc,_0x503a74(0x1a5));}function loadProfilesFromTdxJsonFiles(){const _0x403162=a51_0x260232,_0xadbb40=[],_0x4cbe9e=findProjectConfigPath();_0x4cbe9e&&_0xadbb40[_0x403162(0x173)](...loadProfilesFromTdxJson(_0x4cbe9e,_0x403162(0x1ac)));const _0x1ff4b9=a51_0x18bffb[_0x403162(0x199)](getConfigDir(),_0x403162(0x1b6));return _0xadbb40[_0x403162(0x173)](...loadProfilesFromTdxJson(_0x1ff4b9,_0x403162(0x16f))),_0xadbb40;}function loadProfilesFromDirectories(){const _0x446f39=a51_0x260232,_0x5de25d=getProfilesDir();if(!a51_0x27a1['existsSync'](_0x5de25d))return[];try{return a51_0x27a1[_0x446f39(0x186)](_0x5de25d,{'withFileTypes':!![]})[_0x446f39(0x18b)](_0x15f100=>_0x15f100[_0x446f39(0x16a)]())[_0x446f39(0x190)](_0x4b944a=>_0x4b944a[_0x446f39(0x1b4)])[_0x446f39(0x18b)](_0x1a5dc1=>{const _0x1d536c=_0x446f39,_0x24f70c=getProfileConfigPath(_0x1a5dc1),_0x90bb34=getProfileEnvPath(_0x1a5dc1);return a51_0x27a1[_0x1d536c(0x180)](_0x24f70c)||a51_0x27a1['existsSync'](_0x90bb34);})[_0x446f39(0x190)](_0x176c7a=>{const _0x224f55=_0x446f39,_0x545ebb=loadProfileFromDirectory(_0x176c7a);if(_0x545ebb)return{..._0x545ebb,'scope':_0x224f55(0x194)};return null;})[_0x446f39(0x18b)](_0x6fd054=>_0x6fd054!==null);}catch{return[];}}function loadProfileFromDirectory(_0x102a8e){const _0x4bdd63=a51_0x260232,_0x1c51ed=getProfileConfigPath(_0x102a8e),_0x4a3552=getOldCredentialPath(_0x102a8e);if(!a51_0x27a1['existsSync'](_0x1c51ed)&&!a51_0x27a1[_0x4bdd63(0x180)](_0x4a3552))return null;let _0x207836={},_0x3d9948={'name':_0x102a8e,'createdAt':new Date()[_0x4bdd63(0x192)]()};if(a51_0x27a1[_0x4bdd63(0x180)](_0x1c51ed))try{const _0x147fbe=a51_0x27a1[_0x4bdd63(0x1b2)](_0x1c51ed,_0x4bdd63(0x167)),_0x179dbe=JSON[_0x4bdd63(0x1a1)](_0x147fbe),{metadata:_0x11ac33,..._0x56ece0}=_0x179dbe;_0x207836=_0x56ece0,_0x11ac33&&(_0x3d9948=_0x11ac33);}catch{}return{'name':_0x102a8e,'config':_0x207836,'metadata':_0x3d9948,'hasCredentials':a51_0x27a1[_0x4bdd63(0x180)](_0x4a3552),'scope':_0x4bdd63(0x194)};}export function listProfiles(){const _0x188966=a51_0x260232,_0x311843=loadProfilesFromTdxJsonFiles(),_0x518a9c=loadProfilesFromDirectories();if(_0x518a9c[_0x188966(0x16c)]>0x0){const _0x22ffd6=_0x518a9c[_0x188966(0x190)](_0x268287=>_0x268287[_0x188966(0x1b4)])[_0x188966(0x199)](',\x20'),_0x20f076=getConfigDir();console[_0x188966(0x1a0)]('\x0aWarning:\x20Profiles\x20in\x20directories\x20are\x20deprecated:\x20'+_0x22ffd6),console[_0x188966(0x1a0)]('Please\x20migrate\x20to\x20~/.config/tdx/tdx.json:'),console[_0x188966(0x1a0)]('\x20\x201.\x20Edit:\x20'+a51_0x18bffb['join'](_0x20f076,_0x188966(0x1b6))),console[_0x188966(0x1a0)](_0x188966(0x1b0)),console[_0x188966(0x1a0)](_0x188966(0x165));}const _0x60e6be=[..._0x311843,..._0x518a9c],_0x4dfd03=new Map();for(const _0x1b680e of _0x60e6be){!_0x4dfd03[_0x188966(0x1b3)](_0x1b680e[_0x188966(0x1b4)])&&_0x4dfd03['set'](_0x1b680e['name'],_0x1b680e);}return Array[_0x188966(0x1aa)](_0x4dfd03[_0x188966(0x19f)]())[_0x188966(0x175)]((_0x2c23e8,_0x49f6d6)=>_0x2c23e8[_0x188966(0x1b4)]['localeCompare'](_0x49f6d6[_0x188966(0x1b4)]));}export function profileExists(_0x3087bb){const _0x3c9eee=a51_0x260232,_0xd04275=listProfiles();return _0xd04275[_0x3c9eee(0x16e)](_0x4f49c8=>_0x4f49c8[_0x3c9eee(0x1b4)]===_0x3087bb);}function a51_0x442b(_0x30fc7e,_0x12112f){_0x30fc7e=_0x30fc7e-0x165;const _0x1e3c19=a51_0x1e3c();let _0x442ba0=_0x1e3c19[_0x30fc7e];return _0x442ba0;}export function loadProfile(_0xb83a2a){const _0x4bbb88=a51_0x260232;validateProfileName(_0xb83a2a);const _0x231853=listProfiles(),_0x385b72=_0x231853[_0x4bbb88(0x17a)](_0x5f1e93=>_0x5f1e93['name']===_0xb83a2a);return _0x385b72||null;}export function saveProfile(_0xa2d874,_0x434dc9,_0x2f2f35=![]){saveProfileToUserConfig(_0xa2d874,_0x434dc9);}export function deleteProfile(_0x514496){const _0x5f2228=a51_0x260232;validateProfileName(_0x514496);const _0x2898ad=getProfileDir(_0x514496);if(!a51_0x27a1[_0x5f2228(0x180)](_0x2898ad))throw new Error(_0x5f2228(0x19e)+_0x514496+_0x5f2228(0x18e));a51_0x27a1[_0x5f2228(0x18a)](_0x2898ad,{'recursive':!![],'force':!![]});}export function saveProfileToUserConfig(_0x716b6b,_0x478b86){const _0x15a856=a51_0x260232;validateProfileName(_0x716b6b);const _0x37edb5=getGlobalConfigPath(),_0x43b79d=getConfigDir();!a51_0x27a1[_0x15a856(0x180)](_0x43b79d)&&createSecureDirectory(_0x43b79d);let _0x313200={};if(a51_0x27a1[_0x15a856(0x180)](_0x37edb5))try{const _0x2716fd=a51_0x27a1['readFileSync'](_0x37edb5,_0x15a856(0x167));_0x313200=JSON[_0x15a856(0x1a1)](_0x2716fd);}catch{console[_0x15a856(0x1a0)](_0x15a856(0x195)+_0x37edb5+_0x15a856(0x1ae));}!_0x313200[_0x15a856(0x17b)]&&(_0x313200[_0x15a856(0x17b)]={}),_0x313200['profiles'][_0x716b6b]=_0x478b86,writeSecureFile(_0x37edb5,JSON[_0x15a856(0x179)](_0x313200,null,0x2));}export function removeProfileFromUserConfig(_0x2af2fa){const _0x44d603=a51_0x260232;validateProfileName(_0x2af2fa);const _0x307db8=getGlobalConfigPath();if(!a51_0x27a1[_0x44d603(0x180)](_0x307db8))throw new Error(_0x44d603(0x18f)+_0x2af2fa+_0x44d603(0x168));let _0x10172a={};try{const _0x2764f6=a51_0x27a1[_0x44d603(0x1b2)](_0x307db8,_0x44d603(0x167));_0x10172a=JSON[_0x44d603(0x1a1)](_0x2764f6);}catch{throw new Error(_0x44d603(0x18d)+_0x307db8);}if(!_0x10172a[_0x44d603(0x17b)]||!_0x10172a[_0x44d603(0x17b)][_0x2af2fa])throw new Error('Profile\x20\x27'+_0x2af2fa+_0x44d603(0x168));delete _0x10172a[_0x44d603(0x17b)][_0x2af2fa],_0x10172a[_0x44d603(0x1a8)]===_0x2af2fa&&delete _0x10172a['profile'],writeSecureFile(_0x307db8,JSON[_0x44d603(0x179)](_0x10172a,null,0x2));}export function getActiveProfile(){const _0x13062e=a51_0x260232,_0x55421e=loadSessionContext();if(_0x55421e?.[_0x13062e(0x1a8)])return _0x55421e[_0x13062e(0x1a8)];if(process.env.TDX_PROFILE)return process.env.TDX_PROFILE;const _0x17aeb8=getGlobalConfigPath();if(!a51_0x27a1[_0x13062e(0x180)](_0x17aeb8))return null;try{const _0x579850=a51_0x27a1[_0x13062e(0x1b2)](_0x17aeb8,'utf-8'),_0x2e455a=JSON[_0x13062e(0x1a1)](_0x579850);return _0x2e455a[_0x13062e(0x1a8)]||null;}catch{return null;}}export function saveDefaultSiteToUserConfig(_0x34866f){const _0x259e80=a51_0x260232,_0x54739e=getGlobalConfigPath(),_0x498c83=getConfigDir();!a51_0x27a1[_0x259e80(0x180)](_0x498c83)&&createSecureDirectory(_0x498c83);let _0x401998={};if(a51_0x27a1[_0x259e80(0x180)](_0x54739e))try{const _0x5e1a00=a51_0x27a1[_0x259e80(0x1b2)](_0x54739e,_0x259e80(0x167));_0x401998=JSON[_0x259e80(0x1a1)](_0x5e1a00);}catch{console[_0x259e80(0x1a0)](_0x259e80(0x195)+_0x54739e+_0x259e80(0x1ae));}_0x401998[_0x259e80(0x172)]=_0x34866f,writeSecureFile(_0x54739e,JSON[_0x259e80(0x179)](_0x401998,null,0x2));}export function saveActiveProfileToUserConfig(_0x100c70){const _0x22d7b7=a51_0x260232;validateProfileName(_0x100c70);const _0x2cf957=getGlobalConfigPath(),_0x3f17b4=getConfigDir();!a51_0x27a1[_0x22d7b7(0x180)](_0x3f17b4)&&createSecureDirectory(_0x3f17b4);let _0xbec650={};if(a51_0x27a1[_0x22d7b7(0x180)](_0x2cf957))try{const _0x46444e=a51_0x27a1[_0x22d7b7(0x1b2)](_0x2cf957,'utf-8');_0xbec650=JSON[_0x22d7b7(0x1a1)](_0x46444e);}catch{console[_0x22d7b7(0x1a0)](_0x22d7b7(0x195)+_0x2cf957+',\x20creating\x20new\x20file');}_0xbec650[_0x22d7b7(0x1a8)]=_0x100c70,writeSecureFile(_0x2cf957,JSON[_0x22d7b7(0x179)](_0xbec650,null,0x2));}function clearFieldFromUserConfig(_0x2ff44d){const _0x28ad10=a51_0x260232,_0x3c8636=getGlobalConfigPath();if(!a51_0x27a1[_0x28ad10(0x180)](_0x3c8636))return;let _0x367fac={};try{const _0x4d5ddb=a51_0x27a1[_0x28ad10(0x1b2)](_0x3c8636,_0x28ad10(0x167));_0x367fac=JSON[_0x28ad10(0x1a1)](_0x4d5ddb);}catch{return;}delete _0x367fac[_0x2ff44d],writeSecureFile(_0x3c8636,JSON['stringify'](_0x367fac,null,0x2));}export function clearDefaultSiteFromUserConfig(){const _0xcaed6f=a51_0x260232;clearFieldFromUserConfig(_0xcaed6f(0x172));}export function clearActiveProfileFromUserConfig(){const _0x11a4e5=a51_0x260232;clearFieldFromUserConfig(_0x11a4e5(0x1a8));}export function createProfile(_0x280144,_0x5c9da5){const _0x151b61=a51_0x260232;validateProfileName(_0x280144);if(profileExists(_0x280144))throw new Error(_0x151b61(0x19e)+_0x280144+_0x151b61(0x166));saveProfile(_0x280144,_0x5c9da5);}export function saveProfileCredentials(_0x509c10,_0x533f38){const _0x3e27aa=a51_0x260232;validateProfileName(_0x509c10);if(!profileExists(_0x509c10))throw new Error(_0x3e27aa(0x19e)+_0x509c10+'\x20does\x20not\x20exist');const _0x5da533=getNewCredentialPath(_0x509c10);writeSecureFile(_0x5da533,_0x533f38);}export function loadProfileCredentials(_0xa40f7c){const _0x5f1ec1=a51_0x260232;validateProfileName(_0xa40f7c);const _0x4c23ec=getNewCredentialPath(_0xa40f7c);if(a51_0x27a1[_0x5f1ec1(0x180)](_0x4c23ec))try{return a51_0x27a1[_0x5f1ec1(0x1b2)](_0x4c23ec,_0x5f1ec1(0x167));}catch{}const _0x4dd7c5=getOldCredentialPath(_0xa40f7c);if(a51_0x27a1[_0x5f1ec1(0x180)](_0x4dd7c5)){console[_0x5f1ec1(0x1a0)](_0x5f1ec1(0x16b)+_0xa40f7c+'\x27'),console[_0x5f1ec1(0x1a0)]('To\x20migrate:'),console['warn'](_0x5f1ec1(0x176)+_0x4dd7c5+_0x5f1ec1(0x183)+_0x4c23ec+'\x22'),console[_0x5f1ec1(0x1a0)](_0x5f1ec1(0x1ab));try{return a51_0x27a1[_0x5f1ec1(0x1b2)](_0x4dd7c5,_0x5f1ec1(0x167));}catch{return null;}}return null;}
|
|
1
|
+
(function(_0x269e1e,_0x2cdd5c){const _0x425570=a51_0x51cc,_0x4fd78a=_0x269e1e();while(!![]){try{const _0x2412ac=-parseInt(_0x425570(0x107))/0x1*(-parseInt(_0x425570(0xfb))/0x2)+-parseInt(_0x425570(0x126))/0x3+parseInt(_0x425570(0xfd))/0x4+parseInt(_0x425570(0x12e))/0x5*(parseInt(_0x425570(0xf8))/0x6)+parseInt(_0x425570(0x13e))/0x7+parseInt(_0x425570(0x12b))/0x8*(parseInt(_0x425570(0x115))/0x9)+parseInt(_0x425570(0xfc))/0xa*(-parseInt(_0x425570(0x130))/0xb);if(_0x2412ac===_0x2cdd5c)break;else _0x4fd78a['push'](_0x4fd78a['shift']());}catch(_0x4a51fe){_0x4fd78a['push'](_0x4fd78a['shift']());}}}(a51_0xeaa5,0x2a5a2));import*as a51_0x1b9441 from'node:fs';import*as a51_0x377fe3 from'node:path';import{SDKError,ErrorCode}from'../sdk/errors.js';import{getConfigDir}from'./config.js';import{createSecureDirectory,writeSecureFile}from'../utils/file-permissions.js';import{findProjectConfigPath}from'./project-config.js';function a51_0x51cc(_0x55d001,_0x4bc011){_0x55d001=_0x55d001-0xf4;const _0xeaa5c0=a51_0xeaa5();let _0x51ccbe=_0xeaa5c0[_0x55d001];return _0x51ccbe;}import{loadSessionContext}from'./session.js';export const STUDIO_PROFILE_NAME='@tdx-studio';export function getProfileParams(_0x372061){const _0x1720c3=a51_0x51cc,_0x576646={};if(!_0x372061)return _0x576646;for(const [_0x44987a,_0x5c0c2f]of Object[_0x1720c3(0x10b)](_0x372061)){_0x44987a!==_0x1720c3(0x136)&&_0x5c0c2f!==undefined&&(_0x576646[_0x44987a]=_0x5c0c2f);}return _0x576646;}export function getProfilesDir(){const _0x577f8b=a51_0x51cc;return a51_0x377fe3['join'](getConfigDir(),_0x577f8b(0x140));}function getProfileDir(_0x1071c9){const _0x32c7bd=a51_0x51cc;return a51_0x377fe3[_0x32c7bd(0x11b)](getProfilesDir(),_0x1071c9);}function getProfileConfigPath(_0x2345e1){const _0x5a8283=a51_0x51cc;return a51_0x377fe3[_0x5a8283(0x11b)](getProfileDir(_0x2345e1),_0x5a8283(0x12f));}function getProfileEnvPath(_0x83667){const _0x261cb6=a51_0x51cc;return a51_0x377fe3[_0x261cb6(0x11b)](getProfileDir(_0x83667),_0x261cb6(0x124));}function getGlobalConfigPath(){return a51_0x377fe3['join'](getConfigDir(),'tdx.json');}function validateProfileName(_0x2793e7){const _0x419e98=a51_0x51cc;if(/^@?[a-zA-Z0-9_-]+$/[_0x419e98(0x129)](_0x2793e7))return;if(/^@tdx-studio:[a-zA-Z0-9_-]+:\d+$/[_0x419e98(0x129)](_0x2793e7))return;throw new Error(_0x419e98(0xff)+_0x2793e7+_0x419e98(0x13a));}function validateProfileConfig(_0x1f8eea,_0x552e94){const _0x1bfff2=a51_0x51cc;if(typeof _0x1f8eea!==_0x1bfff2(0x121)||_0x1f8eea===null)throw new SDKError(ErrorCode[_0x1bfff2(0x142)],_0x1bfff2(0x10c)+_0x552e94+'\x27:\x20config\x20must\x20be\x20an\x20object');const _0x15a7e5=['description','site',_0x1bfff2(0x123),_0x1bfff2(0x128),_0x1bfff2(0x13c),_0x1bfff2(0x10e),_0x1bfff2(0x102)],_0x3164f5=_0x1f8eea;for(const _0x3d1ef9 of Object[_0x1bfff2(0x144)](_0x3164f5)){!_0x15a7e5['includes'](_0x3d1ef9)&&console['warn'](_0x1bfff2(0x10d)+_0x552e94+_0x1bfff2(0x10a)+_0x3d1ef9+_0x1bfff2(0x145));}if(_0x3164f5[_0x1bfff2(0x136)]!==undefined&&typeof _0x3164f5[_0x1bfff2(0x136)]!=='string')throw new SDKError(ErrorCode['INVALID_PROFILE_CONFIG'],_0x1bfff2(0x10c)+_0x552e94+_0x1bfff2(0x11f));if(_0x3164f5[_0x1bfff2(0x120)]!==undefined&&typeof _0x3164f5[_0x1bfff2(0x120)]!==_0x1bfff2(0x11e))throw new SDKError(ErrorCode[_0x1bfff2(0x142)],_0x1bfff2(0x10c)+_0x552e94+_0x1bfff2(0x13f));if(_0x3164f5['database']!==undefined&&typeof _0x3164f5['database']!==_0x1bfff2(0x11e))throw new SDKError(ErrorCode['INVALID_PROFILE_CONFIG'],_0x1bfff2(0x10c)+_0x552e94+_0x1bfff2(0x10f));if(_0x3164f5[_0x1bfff2(0x128)]!==undefined&&typeof _0x3164f5['parent_segment']!==_0x1bfff2(0x11e))throw new SDKError(ErrorCode[_0x1bfff2(0x142)],'Profile\x20\x27'+_0x552e94+'\x27:\x20\x27parent_segment\x27\x20must\x20be\x20a\x20string');if(_0x3164f5[_0x1bfff2(0x13c)]!==undefined&&typeof _0x3164f5['llm_project']!==_0x1bfff2(0x11e))throw new SDKError(ErrorCode[_0x1bfff2(0x142)],_0x1bfff2(0x10c)+_0x552e94+_0x1bfff2(0xfa));if(_0x3164f5['llm_agent']!==undefined&&typeof _0x3164f5['llm_agent']!=='string')throw new SDKError(ErrorCode[_0x1bfff2(0x142)],_0x1bfff2(0x10c)+_0x552e94+_0x1bfff2(0x109));return!![];}function loadProfilesFromTdxJson(_0x2679b3,_0x2e0cbe){const _0x4b082b=a51_0x51cc;if(!a51_0x1b9441[_0x4b082b(0x116)](_0x2679b3))return[];try{const _0x2333e2=a51_0x1b9441[_0x4b082b(0x108)](_0x2679b3,_0x4b082b(0x141)),_0x18e621=JSON[_0x4b082b(0x139)](_0x2333e2);if(!_0x18e621[_0x4b082b(0x140)]||typeof _0x18e621[_0x4b082b(0x140)]!==_0x4b082b(0x121))return[];const _0x41afa9=[];for(const [_0x4f4922,_0x266dc1]of Object[_0x4b082b(0x10b)](_0x18e621['profiles'])){try{validateProfileConfig(_0x266dc1,_0x4f4922);const _0x365fee=getNewCredentialPath(_0x4f4922),_0x362903=getOldCredentialPath(_0x4f4922),_0x13fb5a=a51_0x1b9441[_0x4b082b(0x116)](_0x365fee)||a51_0x1b9441['existsSync'](_0x362903);_0x41afa9[_0x4b082b(0x111)]({'name':_0x4f4922,'config':_0x266dc1,'metadata':{'name':_0x4f4922,'createdAt':new Date()['toISOString']()},'hasCredentials':_0x13fb5a,'scope':_0x2e0cbe});}catch(_0x19efa7){_0x19efa7 instanceof Error&&(console[_0x4b082b(0x146)](_0x4b082b(0x112)+_0x2679b3+':'),console['warn']('\x20\x20'+_0x19efa7['message']+'\x0a'));}}return _0x41afa9;}catch(_0x2270ee){return _0x2270ee instanceof SyntaxError?(console[_0x4b082b(0x146)](_0x4b082b(0xf6)+_0x2679b3+_0x4b082b(0x13d)),console[_0x4b082b(0x146)](_0x4b082b(0x105)+_0x2270ee[_0x4b082b(0x114)]+'\x0a')):console['warn'](_0x4b082b(0x138)+_0x2679b3+':\x20'+_0x2270ee+'\x0a'),[];}}export function getNewCredentialPath(_0x582982){const _0x28fc5c=a51_0x51cc;return a51_0x377fe3[_0x28fc5c(0x11b)](getConfigDir(),_0x28fc5c(0x110)+_0x582982);}function getOldCredentialPath(_0x29d9ae){const _0x1fe173=a51_0x51cc;return a51_0x377fe3[_0x1fe173(0x11b)](getProfilesDir(),_0x29d9ae,'.env');}function loadProfilesFromTdxJsonFiles(){const _0x3a3835=a51_0x51cc,_0x552088=[],_0x1f1237=findProjectConfigPath();_0x1f1237&&_0x552088[_0x3a3835(0x111)](...loadProfilesFromTdxJson(_0x1f1237,_0x3a3835(0x122)));const _0x22ada2=a51_0x377fe3[_0x3a3835(0x11b)](getConfigDir(),'tdx.json');return _0x552088[_0x3a3835(0x111)](...loadProfilesFromTdxJson(_0x22ada2,'user')),_0x552088;}function loadProfilesFromDirectories(){const _0x3b764f=a51_0x51cc,_0x2ae548=getProfilesDir();if(!a51_0x1b9441['existsSync'](_0x2ae548))return[];try{return a51_0x1b9441[_0x3b764f(0x11c)](_0x2ae548,{'withFileTypes':!![]})[_0x3b764f(0x113)](_0x5538ee=>_0x5538ee[_0x3b764f(0xf5)]())[_0x3b764f(0x117)](_0x1d1189=>_0x1d1189[_0x3b764f(0x125)])[_0x3b764f(0x113)](_0x33d335=>{const _0x490c3a=_0x3b764f,_0x2abf3e=getProfileConfigPath(_0x33d335),_0x1b844b=getProfileEnvPath(_0x33d335);return a51_0x1b9441[_0x490c3a(0x116)](_0x2abf3e)||a51_0x1b9441['existsSync'](_0x1b844b);})[_0x3b764f(0x117)](_0x58f453=>{const _0x47b853=_0x3b764f,_0x350c14=loadProfileFromDirectory(_0x58f453);if(_0x350c14)return{..._0x350c14,'scope':_0x47b853(0x119)};return null;})[_0x3b764f(0x113)](_0x51e534=>_0x51e534!==null);}catch{return[];}}function loadProfileFromDirectory(_0x115de2){const _0x1634dc=a51_0x51cc,_0x2057b1=getProfileConfigPath(_0x115de2),_0x2904cd=getOldCredentialPath(_0x115de2);if(!a51_0x1b9441[_0x1634dc(0x116)](_0x2057b1)&&!a51_0x1b9441[_0x1634dc(0x116)](_0x2904cd))return null;let _0x3de844={},_0x17b788={'name':_0x115de2,'createdAt':new Date()['toISOString']()};if(a51_0x1b9441[_0x1634dc(0x116)](_0x2057b1))try{const _0x2d357a=a51_0x1b9441['readFileSync'](_0x2057b1,'utf-8'),_0xb29874=JSON[_0x1634dc(0x139)](_0x2d357a),{metadata:_0x2eece6,..._0xba0708}=_0xb29874;_0x3de844=_0xba0708,_0x2eece6&&(_0x17b788=_0x2eece6);}catch{}return{'name':_0x115de2,'config':_0x3de844,'metadata':_0x17b788,'hasCredentials':a51_0x1b9441['existsSync'](_0x2904cd),'scope':_0x1634dc(0x119)};}export function listProfiles(){const _0x39f4ba=a51_0x51cc,_0x325286=loadProfilesFromTdxJsonFiles(),_0x2cb574=loadProfilesFromDirectories();if(_0x2cb574[_0x39f4ba(0xf7)]>0x0){const _0x53b70d=_0x2cb574['map'](_0x675f63=>_0x675f63[_0x39f4ba(0x125)])[_0x39f4ba(0x11b)](',\x20'),_0x1cf609=getConfigDir();console[_0x39f4ba(0x146)](_0x39f4ba(0x13b)+_0x53b70d),console[_0x39f4ba(0x146)]('Please\x20migrate\x20to\x20~/.config/tdx/tdx.json:'),console[_0x39f4ba(0x146)](_0x39f4ba(0x132)+a51_0x377fe3[_0x39f4ba(0x11b)](_0x1cf609,_0x39f4ba(0x12f))),console[_0x39f4ba(0x146)](_0x39f4ba(0xf9)),console[_0x39f4ba(0x146)](_0x39f4ba(0x131));}const _0x103346=[..._0x325286,..._0x2cb574],_0x2bed1a=new Map();for(const _0x3c461d of _0x103346){!_0x2bed1a[_0x39f4ba(0x12d)](_0x3c461d['name'])&&_0x2bed1a[_0x39f4ba(0x12a)](_0x3c461d[_0x39f4ba(0x125)],_0x3c461d);}return Array[_0x39f4ba(0x100)](_0x2bed1a[_0x39f4ba(0x106)]())[_0x39f4ba(0x137)]((_0x334690,_0x320edd)=>_0x334690[_0x39f4ba(0x125)][_0x39f4ba(0x11d)](_0x320edd[_0x39f4ba(0x125)]));}export function profileExists(_0x4e4f19){const _0x54cf62=a51_0x51cc,_0xe8f438=listProfiles();return _0xe8f438[_0x54cf62(0x133)](_0x216815=>_0x216815['name']===_0x4e4f19);}export function loadProfile(_0xef9ed0){validateProfileName(_0xef9ed0);const _0x378da5=listProfiles(),_0x4520a7=_0x378da5['find'](_0x3d152e=>_0x3d152e['name']===_0xef9ed0);return _0x4520a7||null;}export function saveProfile(_0x7a50e0,_0x33a61d,_0xdedfe3=![]){saveProfileToUserConfig(_0x7a50e0,_0x33a61d);}export function deleteProfile(_0x22dd7f){const _0x55ecb7=a51_0x51cc;validateProfileName(_0x22dd7f);const _0x3a7d50=getProfileDir(_0x22dd7f);if(!a51_0x1b9441[_0x55ecb7(0x116)](_0x3a7d50))throw new Error(_0x55ecb7(0x11a)+_0x22dd7f+'\x20does\x20not\x20exist');a51_0x1b9441[_0x55ecb7(0x143)](_0x3a7d50,{'recursive':!![],'force':!![]});}export function saveProfileToUserConfig(_0x42c6b0,_0x5a2f9c){const _0x216821=a51_0x51cc;validateProfileName(_0x42c6b0);const _0x291a3a=getGlobalConfigPath(),_0x1daaea=getConfigDir();!a51_0x1b9441[_0x216821(0x116)](_0x1daaea)&&createSecureDirectory(_0x1daaea);let _0x19330b={};if(a51_0x1b9441['existsSync'](_0x291a3a))try{const _0x2751fe=a51_0x1b9441[_0x216821(0x108)](_0x291a3a,_0x216821(0x141));_0x19330b=JSON[_0x216821(0x139)](_0x2751fe);}catch{console[_0x216821(0x146)](_0x216821(0x135)+_0x291a3a+_0x216821(0x134));}!_0x19330b['profiles']&&(_0x19330b[_0x216821(0x140)]={}),_0x19330b[_0x216821(0x140)][_0x42c6b0]=_0x5a2f9c,writeSecureFile(_0x291a3a,JSON[_0x216821(0x12c)](_0x19330b,null,0x2));}export function removeProfileFromUserConfig(_0x57485a){const _0x36b4ea=a51_0x51cc;validateProfileName(_0x57485a);const _0x5f148e=getGlobalConfigPath();if(!a51_0x1b9441['existsSync'](_0x5f148e))throw new Error('Profile\x20\x27'+_0x57485a+_0x36b4ea(0x104));let _0x19a3cb={};try{const _0x5d7694=a51_0x1b9441['readFileSync'](_0x5f148e,_0x36b4ea(0x141));_0x19a3cb=JSON['parse'](_0x5d7694);}catch{throw new Error('Failed\x20to\x20parse\x20'+_0x5f148e);}if(!_0x19a3cb[_0x36b4ea(0x140)]||!_0x19a3cb['profiles'][_0x57485a])throw new Error(_0x36b4ea(0x10c)+_0x57485a+_0x36b4ea(0x104));delete _0x19a3cb[_0x36b4ea(0x140)][_0x57485a],_0x19a3cb[_0x36b4ea(0x103)]===_0x57485a&&delete _0x19a3cb[_0x36b4ea(0x103)],writeSecureFile(_0x5f148e,JSON[_0x36b4ea(0x12c)](_0x19a3cb,null,0x2));}function a51_0xeaa5(){const _0xa46d4a=['Invalid\x20profile\x20name:\x20','from','\x0aWarning:\x20Using\x20deprecated\x20credential\x20location\x20for\x20profile\x20\x27','user_info','profile','\x27\x20not\x20found\x20in\x20user\x20configuration','Error:\x20','values','171284bvHgeR','readFileSync','\x27:\x20\x27llm_agent\x27\x20must\x20be\x20a\x20string','\x27:\x20unknown\x20config\x20key\x20\x27','entries','Profile\x20\x27','Warning:\x20Profile\x20\x27','llm_agent','\x27:\x20\x27database\x27\x20must\x20be\x20a\x20string','.env.','push','\x0aWarning:\x20Skipping\x20invalid\x20profile\x20in\x20','filter','message','72KfnOFK','existsSync','map','To\x20migrate:','directory','Profile\x20','join','readdirSync','localeCompare','string','\x27:\x20\x27description\x27\x20must\x20be\x20a\x20string','site','object','local','database','.env','name','597681YZxLVM','Then\x20define\x20profiles\x20in\x20~/.config/tdx/tdx.json\x0a','parent_segment','test','set','44984SeTdXO','stringify','has','5vDhEwA','tdx.json','1474cZzohe','\x20\x203.\x20Move\x20credentials:\x20mv\x20~/.config/tdx/profiles/<name>/.env\x20~/.config/tdx/.env.<name>\x0a','\x20\x201.\x20Edit:\x20','some',',\x20creating\x20new\x20file','Warning:\x20Failed\x20to\x20parse\x20','description','sort','\x0aWarning:\x20Failed\x20to\x20load\x20profiles\x20from\x20','parse','.\x20Must\x20contain\x20only\x20alphanumeric\x20characters,\x20dash,\x20underscore,\x20and\x20optional\x20@\x20prefix\x20for\x20reserved\x20profiles.','\x0aWarning:\x20Profiles\x20in\x20directories\x20are\x20deprecated:\x20','llm_project',':\x20Invalid\x20JSON\x20syntax','2356340HunVkN','\x27:\x20\x27site\x27\x20must\x20be\x20a\x20string','profiles','utf-8','INVALID_PROFILE_CONFIG','rmSync','keys','\x27\x20will\x20be\x20ignored','warn','\x20already\x20exists','isDirectory','\x0aWarning:\x20Failed\x20to\x20parse\x20','length','1795092DStMmB','\x20\x202.\x20Add\x20profiles\x20under\x20a\x20\x22profiles\x22\x20key\x20(see\x20\x27tdx\x20profiles\x27\x20for\x20current\x20config)','\x27:\x20\x27llm_project\x27\x20must\x20be\x20a\x20string','4uonUPN','64430jrkgMx','850836txGiLb','\x20\x20mv\x20\x22'];a51_0xeaa5=function(){return _0xa46d4a;};return a51_0xeaa5();}export function getActiveProfile(){const _0x3a6ccd=a51_0x51cc,_0x2e6ccf=loadSessionContext();if(_0x2e6ccf?.['profile'])return _0x2e6ccf['profile'];if(process.env.TDX_PROFILE)return process.env.TDX_PROFILE;const _0x588430=getGlobalConfigPath();if(!a51_0x1b9441[_0x3a6ccd(0x116)](_0x588430))return null;try{const _0x189ad4=a51_0x1b9441[_0x3a6ccd(0x108)](_0x588430,_0x3a6ccd(0x141)),_0x5c4268=JSON[_0x3a6ccd(0x139)](_0x189ad4);return _0x5c4268[_0x3a6ccd(0x103)]||null;}catch{return null;}}export function saveDefaultSiteToUserConfig(_0x2464e0){const _0x34b2dc=a51_0x51cc,_0xe7f72f=getGlobalConfigPath(),_0x1286c8=getConfigDir();!a51_0x1b9441[_0x34b2dc(0x116)](_0x1286c8)&&createSecureDirectory(_0x1286c8);let _0x4f8b20={};if(a51_0x1b9441[_0x34b2dc(0x116)](_0xe7f72f))try{const _0x1ef16d=a51_0x1b9441[_0x34b2dc(0x108)](_0xe7f72f,_0x34b2dc(0x141));_0x4f8b20=JSON[_0x34b2dc(0x139)](_0x1ef16d);}catch{console['warn'](_0x34b2dc(0x135)+_0xe7f72f+',\x20creating\x20new\x20file');}_0x4f8b20[_0x34b2dc(0x120)]=_0x2464e0,writeSecureFile(_0xe7f72f,JSON[_0x34b2dc(0x12c)](_0x4f8b20,null,0x2));}export function saveActiveProfileToUserConfig(_0x35e471){const _0x30a1ef=a51_0x51cc;validateProfileName(_0x35e471);const _0x1187d0=getGlobalConfigPath(),_0x70de60=getConfigDir();!a51_0x1b9441[_0x30a1ef(0x116)](_0x70de60)&&createSecureDirectory(_0x70de60);let _0x2eb4a3={};if(a51_0x1b9441[_0x30a1ef(0x116)](_0x1187d0))try{const _0x5bbeb4=a51_0x1b9441[_0x30a1ef(0x108)](_0x1187d0,_0x30a1ef(0x141));_0x2eb4a3=JSON[_0x30a1ef(0x139)](_0x5bbeb4);}catch{console['warn'](_0x30a1ef(0x135)+_0x1187d0+_0x30a1ef(0x134));}_0x2eb4a3['profile']=_0x35e471,writeSecureFile(_0x1187d0,JSON[_0x30a1ef(0x12c)](_0x2eb4a3,null,0x2));}function clearFieldFromUserConfig(_0x57995f){const _0x42184e=a51_0x51cc,_0x23e711=getGlobalConfigPath();if(!a51_0x1b9441[_0x42184e(0x116)](_0x23e711))return;let _0x42ef01={};try{const _0x3508b6=a51_0x1b9441['readFileSync'](_0x23e711,_0x42184e(0x141));_0x42ef01=JSON[_0x42184e(0x139)](_0x3508b6);}catch{return;}delete _0x42ef01[_0x57995f],writeSecureFile(_0x23e711,JSON[_0x42184e(0x12c)](_0x42ef01,null,0x2));}export function clearDefaultSiteFromUserConfig(){clearFieldFromUserConfig('site');}export function clearActiveProfileFromUserConfig(){clearFieldFromUserConfig('profile');}export function createProfile(_0xac7c3e,_0x1937d6){const _0x3c9c21=a51_0x51cc;validateProfileName(_0xac7c3e);if(profileExists(_0xac7c3e))throw new Error(_0x3c9c21(0x11a)+_0xac7c3e+_0x3c9c21(0xf4));saveProfile(_0xac7c3e,_0x1937d6);}export function saveProfileCredentials(_0x30108b,_0x383e54){const _0xb9cd6c=a51_0x51cc;validateProfileName(_0x30108b);if(!profileExists(_0x30108b))throw new Error(_0xb9cd6c(0x11a)+_0x30108b+'\x20does\x20not\x20exist');const _0x3af760=getNewCredentialPath(_0x30108b);writeSecureFile(_0x3af760,_0x383e54);}export function loadProfileCredentials(_0x337ab7){const _0x5b0599=a51_0x51cc;validateProfileName(_0x337ab7);const _0x34bdaa=getNewCredentialPath(_0x337ab7);if(a51_0x1b9441['existsSync'](_0x34bdaa))try{return a51_0x1b9441['readFileSync'](_0x34bdaa,_0x5b0599(0x141));}catch{}const _0x3dfc63=getOldCredentialPath(_0x337ab7);if(a51_0x1b9441[_0x5b0599(0x116)](_0x3dfc63)){console[_0x5b0599(0x146)](_0x5b0599(0x101)+_0x337ab7+'\x27'),console['warn'](_0x5b0599(0x118)),console[_0x5b0599(0x146)](_0x5b0599(0xfe)+_0x3dfc63+'\x22\x20\x22'+_0x34bdaa+'\x22'),console[_0x5b0599(0x146)](_0x5b0599(0x127));try{return a51_0x1b9441[_0x5b0599(0x108)](_0x3dfc63,_0x5b0599(0x141));}catch{return null;}}return null;}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(_0x399b77,_0x88643e){const _0x2b03a2=a52_0x1737,_0x3fb414=_0x399b77();while(!![]){try{const _0x4d3a01=parseInt(_0x2b03a2(0x8c))/0x1*(parseInt(_0x2b03a2(0x9b))/0x2)+-parseInt(_0x2b03a2(0x9a))/0x3*(parseInt(_0x2b03a2(0x8f))/0x4)+-parseInt(_0x2b03a2(0x95))/0x5+-parseInt(_0x2b03a2(0x94))/0x6*(parseInt(_0x2b03a2(0x96))/0x7)+parseInt(_0x2b03a2(0x8b))/0x8+parseInt(_0x2b03a2(0xa6))/0x9+-parseInt(_0x2b03a2(0x98))/0xa*(-parseInt(_0x2b03a2(0x97))/0xb);if(_0x4d3a01===_0x88643e)break;else _0x3fb414['push'](_0x3fb414['shift']());}catch(_0x3d686d){_0x3fb414['push'](_0x3fb414['shift']());}}}(a52_0x209c,0x9191d));import*as a52_0x3900e5 from'node:fs';function a52_0x1737(_0x142002,_0x7a1b53){_0x142002=_0x142002-0x89;const _0x209c75=a52_0x209c();let _0x173732=_0x209c75[_0x142002];return _0x173732;}import*as a52_0xd1f96a from'node:path';const PROJECT_CONFIG_FILENAME='tdx.json';export function findProjectConfigPath(_0xd2b8c){const _0x9dbec1=a52_0x1737;let _0x2a41ed=_0xd2b8c||process[_0x9dbec1(0xa5)]();while(!![]){const _0xb9893=a52_0xd1f96a[_0x9dbec1(0xa4)](_0x2a41ed,PROJECT_CONFIG_FILENAME);if(a52_0x3900e5[_0x9dbec1(0xa3)](_0xb9893))return _0xb9893;const _0x15cf34=a52_0xd1f96a['dirname'](_0x2a41ed);if(_0x15cf34===_0x2a41ed)return null;_0x2a41ed=_0x15cf34;}}export function loadProjectConfig(_0x53f22e){const _0x6b21cc=a52_0x1737,_0xcb257a=findProjectConfigPath(_0x53f22e);if(!_0xcb257a)return null;try{const _0x1a0ec5=a52_0x3900e5['readFileSync'](_0xcb257a,_0x6b21cc(0x8e)),_0x179a79=JSON['parse'](_0x1a0ec5),_0x540bd1=JSON[_0x6b21cc(0x90)](_0x179a79);if(_0x540bd1[_0x6b21cc(0x8a)]('TD_API_KEY')||_0x540bd1['includes']('apiKey')||_0x540bd1[_0x6b21cc(0x8a)](_0x6b21cc(0x89)))throw new Error(_0x6b21cc(0xa0)+_0xcb257a+_0x6b21cc(0x9f)+'Use\x20~/.config/tdx/.env\x20or\x20profile\x20.env\x20files\x20instead.');const {metadata:_0x54fbf1,profile:_0x5b5680,..._0x5bd749}=_0x179a79;return _0x5b5680&&console[_0x6b21cc(0x9d)](_0x6b21cc(0xa1)+_0xcb257a+'\x20is\x20ignored.\x20'+_0x6b21cc(0x9c)),_0x5bd749;}catch(_0x13c1e1){if(_0x13c1e1 instanceof Error&&_0x6b21cc(0x99)in _0x13c1e1&&_0x13c1e1[_0x6b21cc(0x99)]==='ENOENT')return null;throw new Error(_0x6b21cc(0x91)+_0xcb257a+':\x20'+_0x13c1e1);}}export function saveProjectConfig(_0x5a2f82,_0x137280){const _0x3c5af3=a52_0x1737,_0x5c0a3c=_0x137280||process['cwd'](),_0x3ecdc9=a52_0xd1f96a['join'](_0x5c0a3c,PROJECT_CONFIG_FILENAME),_0x59aee5=JSON['stringify'](_0x5a2f82);if(_0x59aee5[_0x3c5af3(0x8a)]('TD_API_KEY')||_0x59aee5[_0x3c5af3(0x8a)](_0x3c5af3(0xa7))||_0x59aee5[_0x3c5af3(0x8a)]('api_key'))throw new Error(_0x3c5af3(0x8d));if(_0x3c5af3(0x93)in _0x5a2f82)throw new Error(_0x3c5af3(0x9e));a52_0x3900e5[_0x3c5af3(0xa2)](_0x3ecdc9,JSON['stringify'](_0x5a2f82,null,0x2));}function a52_0x209c(){const _0x7644b4=['dirname','profile','54eqvRfE','3160345vrqkZY','907347HdKmxr','484ZUmmaj','315030orguhV','code','3IIEpeO','2bwfLRm','Active\x20profile\x20is\x20set\x20in\x20~/.config/tdx/tdx.json','warn','\x27profile\x27\x20should\x20not\x20be\x20set\x20in\x20project\x20config.\x20Use\x20\x27tdx\x20profile\x20use\x27\x20instead.',').\x20','Security\x20error:\x20API\x20keys\x20must\x20not\x20be\x20stored\x20in\x20project\x20config\x20(','Warning:\x20\x27profile\x27\x20field\x20in\x20','writeFileSync','existsSync','join','cwd','10688895JofpBl','apiKey','api_key','includes','4587640vAdqNA','379061ZGbJYi','API\x20keys\x20must\x20not\x20be\x20stored\x20in\x20project\x20configuration.\x20Use\x20.env\x20files\x20instead.','utf-8','4525568QjxEia','stringify','Failed\x20to\x20load\x20project\x20config\x20from\x20'];a52_0x209c=function(){return _0x7644b4;};return a52_0x209c();}export function hasProjectConfig(_0x3ce57f){return findProjectConfigPath(_0x3ce57f)!==null;}export function getProjectRoot(_0x114fcd){const _0x556cd1=a52_0x1737,_0x5e2531=findProjectConfigPath(_0x114fcd);return _0x5e2531?a52_0xd1f96a[_0x556cd1(0x92)](_0x5e2531):null;}
|
package/dist/core/session.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(_0x9cb7db,_0x183180){const _0x3dc78b=a53_0x25cc,_0x5021f4=_0x9cb7db();while(!![]){try{const _0x2cb275=-parseInt(_0x3dc78b(0x8e))/0x1+-parseInt(_0x3dc78b(0x99))/0x2*(-parseInt(_0x3dc78b(0x8b))/0x3)+parseInt(_0x3dc78b(0x7f))/0x4*(-parseInt(_0x3dc78b(0x80))/0x5)+parseInt(_0x3dc78b(0x7e))/0x6*(parseInt(_0x3dc78b(0x79))/0x7)+-parseInt(_0x3dc78b(0x86))/0x8+parseInt(_0x3dc78b(0x84))/0x9*(parseInt(_0x3dc78b(0x91))/0xa)+parseInt(_0x3dc78b(0x8f))/0xb;if(_0x2cb275===_0x183180)break;else _0x5021f4['push'](_0x5021f4['shift']());}catch(_0x48c2af){_0x5021f4['push'](_0x5021f4['shift']());}}}(a53_0x16bc,0x7086c));import*as a53_0x352bdc from'node:fs';import*as a53_0x6d1522 from'node:path';import*as a53_0x166d93 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 a53_0x25cc(_0x13e7d5,_0x51a1e4){_0x13e7d5=_0x13e7d5-0x73;const _0x16bca5=a53_0x16bc();let _0x25cc07=_0x16bca5[_0x13e7d5];return _0x25cc07;}function getSessionsDir(){const _0x12b85f=a53_0x25cc,_0x49962b=process.env.TDX_CONFIG_DIR||a53_0x6d1522[_0x12b85f(0x74)](a53_0x166d93[_0x12b85f(0x96)](),_0x12b85f(0x7d),_0x12b85f(0x93));return a53_0x6d1522[_0x12b85f(0x74)](_0x49962b,_0x12b85f(0x75));}function a53_0x16bc(){const _0x26f410=['existsSync','740400ApDtYL','6791961rMvGuz','toISOString','1510360fonbpZ','utf-8','tdx','includes','API\x20keys\x20must\x20not\x20be\x20stored\x20in\x20session\x20context.\x20Use\x20.env\x20files\x20instead.','homedir','Warning:\x20API\x20keys\x20found\x20in\x20session\x20file\x20','.json','2XxHvav','toString','api_key','join','sessions','apiKey','unlinkSync','sort','7XVhMcG','readFileSync','test','parse','.config','1542768fRnyJS','2951464RcrRxt','5IhWSEP','replace','now','TD_API_KEY','45NTUGif','createdAt','3441592fzjdCD','stringify','warn','getTime','readdirSync','2218842aqxgrv','endsWith'];a53_0x16bc=function(){return _0x26f410;};return a53_0x16bc();}function getSessionPath(_0x5821b8){const _0x3a7d3d=a53_0x25cc;return a53_0x6d1522[_0x3a7d3d(0x74)](getSessionsDir(),_0x5821b8+_0x3a7d3d(0x98));}export function getCurrentSessionPID(){return getPPID();}export function getSessionID(_0x311e8d){const _0x4764e9=a53_0x25cc;if(_0x311e8d)return _0x311e8d;if(process.env.TDX_SESSION)return process.env.TDX_SESSION;return getCurrentSessionPID()[_0x4764e9(0x9a)]();}export function loadSessionContext(_0x5b1454){const _0x3f2bae=a53_0x25cc,_0x1f1198=getSessionID(_0x5b1454),_0x8926c9=/^\d+$/[_0x3f2bae(0x7b)](_0x1f1198)?parseInt(_0x1f1198,0xa):null;return _0x8926c9!==null?loadSessionContextByPID(_0x8926c9):loadSessionContextByString(_0x1f1198);}export function loadSessionContextByPID(_0x15fee8){const _0x48e2b0=a53_0x25cc,_0x291145=getSessionPath(_0x15fee8);if(!a53_0x352bdc[_0x48e2b0(0x8d)](_0x291145))return null;try{const _0x258183=a53_0x352bdc[_0x48e2b0(0x7a)](_0x291145,_0x48e2b0(0x92)),_0x17ee41=JSON[_0x48e2b0(0x7c)](_0x258183),_0x2344d2=new Date(_0x17ee41[_0x48e2b0(0x85)])['getTime'](),_0x349b5c=Date['now']();if(_0x349b5c-_0x2344d2>SESSION_EXPIRATION_MS)return a53_0x352bdc[_0x48e2b0(0x77)](_0x291145),null;const _0x41840e=JSON[_0x48e2b0(0x87)](_0x17ee41);if(_0x41840e['includes'](_0x48e2b0(0x83))||_0x41840e[_0x48e2b0(0x94)](_0x48e2b0(0x76))||_0x41840e[_0x48e2b0(0x94)](_0x48e2b0(0x73)))return console[_0x48e2b0(0x88)]('Warning:\x20API\x20keys\x20found\x20in\x20session\x20file\x20'+_0x291145+'.\x20This\x20is\x20insecure.\x20Removing\x20session.'),a53_0x352bdc[_0x48e2b0(0x77)](_0x291145),null;return _0x17ee41;}catch{try{a53_0x352bdc[_0x48e2b0(0x77)](_0x291145);}catch{}return null;}}function loadSessionContextByString(_0x4fc0de){const _0x46407c=a53_0x25cc,_0x28902a=a53_0x6d1522[_0x46407c(0x74)](getSessionsDir(),_0x4fc0de+_0x46407c(0x98));if(!a53_0x352bdc[_0x46407c(0x8d)](_0x28902a))return null;try{const _0x25529d=a53_0x352bdc[_0x46407c(0x7a)](_0x28902a,_0x46407c(0x92)),_0x13962a=JSON[_0x46407c(0x7c)](_0x25529d),_0xfcc08a=new Date(_0x13962a[_0x46407c(0x85)])[_0x46407c(0x89)](),_0x374a31=Date[_0x46407c(0x82)]();if(_0x374a31-_0xfcc08a>SESSION_EXPIRATION_MS)return a53_0x352bdc[_0x46407c(0x77)](_0x28902a),null;const _0x33306e=JSON[_0x46407c(0x87)](_0x13962a);if(_0x33306e[_0x46407c(0x94)](_0x46407c(0x83))||_0x33306e[_0x46407c(0x94)](_0x46407c(0x76))||_0x33306e['includes']('api_key'))return console[_0x46407c(0x88)](_0x46407c(0x97)+_0x28902a+'.\x20This\x20is\x20insecure.\x20Removing\x20session.'),a53_0x352bdc[_0x46407c(0x77)](_0x28902a),null;return _0x13962a;}catch{try{a53_0x352bdc['unlinkSync'](_0x28902a);}catch{}return null;}}export function saveSessionContext(_0x418346,_0x325239){const _0x48cd20=a53_0x25cc,_0x390ebf=getSessionID(_0x325239),_0x37d9ac=/^\d+$/[_0x48cd20(0x7b)](_0x390ebf)?parseInt(_0x390ebf,0xa):getCurrentSessionPID(),_0x4392f4=a53_0x6d1522['join'](getSessionsDir(),_0x390ebf+'.json'),_0x409ddb=getSessionsDir();createSecureDirectory(_0x409ddb);const _0x4240d5=JSON[_0x48cd20(0x87)](_0x418346);if(_0x4240d5[_0x48cd20(0x94)](_0x48cd20(0x83))||_0x4240d5[_0x48cd20(0x94)](_0x48cd20(0x76))||_0x4240d5[_0x48cd20(0x94)](_0x48cd20(0x73)))throw new Error(_0x48cd20(0x95));let _0x16598a;const _0x13ed84=/^\d+$/['test'](_0x390ebf)?loadSessionContextByPID(parseInt(_0x390ebf,0xa)):loadSessionContextByString(_0x390ebf);_0x13ed84?_0x16598a={..._0x13ed84,..._0x418346,'pid':_0x37d9ac,'sessionId':_0x390ebf!==_0x37d9ac[_0x48cd20(0x9a)]()?_0x390ebf:undefined,'updatedAt':new Date()[_0x48cd20(0x90)]()}:_0x16598a={'pid':_0x37d9ac,'sessionId':_0x390ebf!==_0x37d9ac[_0x48cd20(0x9a)]()?_0x390ebf:undefined,..._0x418346,'createdAt':new Date()[_0x48cd20(0x90)](),'updatedAt':new Date()[_0x48cd20(0x90)]()},a53_0x352bdc['writeFileSync'](_0x4392f4,JSON[_0x48cd20(0x87)](_0x16598a,null,0x2));}export function clearSessionContext(_0x283967){const _0x202b86=a53_0x25cc,_0x593ea7=getSessionID(_0x283967),_0x29417b=a53_0x6d1522[_0x202b86(0x74)](getSessionsDir(),_0x593ea7+_0x202b86(0x98));a53_0x352bdc['existsSync'](_0x29417b)&&a53_0x352bdc['unlinkSync'](_0x29417b);}export function clearSessionContextField(_0x5b4887,_0x4338f5){const _0x239812=a53_0x25cc,_0x3571dd=getSessionID(_0x4338f5),_0x20dff3=a53_0x6d1522[_0x239812(0x74)](getSessionsDir(),_0x3571dd+_0x239812(0x98));if(!a53_0x352bdc[_0x239812(0x8d)](_0x20dff3))return;try{const _0x383845=a53_0x352bdc[_0x239812(0x7a)](_0x20dff3,_0x239812(0x92)),_0x1c0b53=JSON[_0x239812(0x7c)](_0x383845);delete _0x1c0b53[_0x5b4887],a53_0x352bdc['writeFileSync'](_0x20dff3,JSON[_0x239812(0x87)](_0x1c0b53,null,0x2));}catch{}}export function cleanExpiredSessions(){const _0x40fd47=a53_0x25cc,_0x5d6a33=getSessionsDir();if(!a53_0x352bdc[_0x40fd47(0x8d)](_0x5d6a33))return 0x0;let _0xed7895=0x0;const _0x598e01=Date[_0x40fd47(0x82)]();try{const _0x542f5b=a53_0x352bdc[_0x40fd47(0x8a)](_0x5d6a33);for(const _0x2ee45d of _0x542f5b){if(!_0x2ee45d[_0x40fd47(0x8c)]('.json'))continue;const _0xb12fd8=a53_0x6d1522[_0x40fd47(0x74)](_0x5d6a33,_0x2ee45d),_0xd19f4e=_0x2ee45d[_0x40fd47(0x81)](_0x40fd47(0x98),''),_0x1139d1=parseInt(_0xd19f4e,0xa),_0x2f83f8=!isNaN(_0x1139d1);if(_0x2f83f8){if(!isProcessRunning(_0x1139d1)){a53_0x352bdc[_0x40fd47(0x77)](_0xb12fd8),_0xed7895++;continue;}}try{const _0xd3933e=a53_0x352bdc[_0x40fd47(0x7a)](_0xb12fd8,_0x40fd47(0x92)),_0x160fd9=JSON[_0x40fd47(0x7c)](_0xd3933e),_0x46a221=new Date(_0x160fd9[_0x40fd47(0x85)])[_0x40fd47(0x89)]();_0x598e01-_0x46a221>SESSION_EXPIRATION_MS&&(a53_0x352bdc[_0x40fd47(0x77)](_0xb12fd8),_0xed7895++);}catch{a53_0x352bdc[_0x40fd47(0x77)](_0xb12fd8),_0xed7895++;}}}catch{}return _0xed7895;}export function listActiveSessions(){const _0x326036=a53_0x25cc,_0x558b2a=getSessionsDir();if(!a53_0x352bdc[_0x326036(0x8d)](_0x558b2a))return[];try{const _0x471e69=a53_0x352bdc['readdirSync'](_0x558b2a),_0x16c1d0=[];for(const _0x46f1df of _0x471e69){if(!_0x46f1df[_0x326036(0x8c)](_0x326036(0x98)))continue;const _0x409a9d=_0x46f1df['replace']('.json',''),_0x532501=parseInt(_0x409a9d,0xa);!isNaN(_0x532501)&&isProcessRunning(_0x532501)&&_0x16c1d0['push'](_0x532501);}return _0x16c1d0[_0x326036(0x78)]((_0x526964,_0x8cfca7)=>_0x526964-_0x8cfca7);}catch{return[];}}
|
package/dist/core/user-cache.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
function a54_0x39e1(_0x42cde,_0x5320aa){_0x42cde=_0x42cde-0xac;const _0x222c3d=a54_0x222c();let _0x39e18f=_0x222c3d[_0x42cde];return _0x39e18f;}const a54_0x20956c=a54_0x39e1;(function(_0x220b14,_0x567ca9){const _0x295628=a54_0x39e1,_0x55dec5=_0x220b14();while(!![]){try{const _0x331840=-parseInt(_0x295628(0xb9))/0x1*(-parseInt(_0x295628(0xae))/0x2)+parseInt(_0x295628(0xb7))/0x3+-parseInt(_0x295628(0xb2))/0x4+-parseInt(_0x295628(0xb1))/0x5+parseInt(_0x295628(0xac))/0x6+parseInt(_0x295628(0xb3))/0x7*(parseInt(_0x295628(0xb4))/0x8)+-parseInt(_0x295628(0xb8))/0x9;if(_0x331840===_0x567ca9)break;else _0x55dec5['push'](_0x55dec5['shift']());}catch(_0x1fee1e){_0x55dec5['push'](_0x55dec5['shift']());}}}(a54_0x222c,0x19808));import{createProfileCache}from'../utils/global-cache.js';const userCache=createProfileCache(a54_0x20956c(0xb5),'core/user-cache');function a54_0x222c(){const _0x154626=['users','read','68745YpwIQZ','145292UjRXXN','749FyEBvM','10984bvnRIs','users-{profile}.json','write','375516inWHWN','2418075NyJloP','474yeBkju','now','428928uHuRvf','clear','336UlZKHu'];a54_0x222c=function(){return _0x154626;};return a54_0x222c();}export function loadCachedUsers(_0x287d46){const _0x319b1c=a54_0x20956c,_0x354284=userCache[_0x319b1c(0xb0)](_0x287d46);return _0x354284?.[_0x319b1c(0xaf)]??null;}export function saveCachedUsers(_0x2470fe,_0x5ada73){const _0x5b4bf8=a54_0x20956c;userCache[_0x5b4bf8(0xb6)](_0x2470fe,{'users':_0x5ada73,'cachedAt':Date[_0x5b4bf8(0xba)]()});}export function clearUserCache(_0xb4844){const _0xdeda0b=a54_0x20956c;userCache[_0xdeda0b(0xad)](_0xb4844);}
|
package/dist/core/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(_0x3bad47,_0xf93ec9){const _0x5dd5e9=a55_0x4e35,_0x158178=_0x3bad47();while(!![]){try{const _0x303b1c=parseInt(_0x5dd5e9(0x1a0))/0x1*(-parseInt(_0x5dd5e9(0x193))/0x2)+-parseInt(_0x5dd5e9(0x1a5))/0x3*(parseInt(_0x5dd5e9(0x19e))/0x4)+parseInt(_0x5dd5e9(0x19a))/0x5+-parseInt(_0x5dd5e9(0x19c))/0x6*(-parseInt(_0x5dd5e9(0x1a6))/0x7)+parseInt(_0x5dd5e9(0x194))/0x8*(-parseInt(_0x5dd5e9(0x197))/0x9)+parseInt(_0x5dd5e9(0x198))/0xa+parseInt(_0x5dd5e9(0x19f))/0xb*(parseInt(_0x5dd5e9(0x196))/0xc);if(_0x303b1c===_0xf93ec9)break;else _0x158178['push'](_0x158178['shift']());}catch(_0x1593b2){_0x158178['push'](_0x158178['shift']());}}}(a55_0x4fec,0xe014a));import{readFileSync}from'fs';import{fileURLToPath}from'url';import{dirname,join}from'path';function a55_0x4e35(_0x11d5fd,_0x450c30){_0x11d5fd=_0x11d5fd-0x193;const _0x4feca8=a55_0x4fec();let _0x4e35b0=_0x4feca8[_0x11d5fd];return _0x4e35b0;}let cachedBuildInfo=null,cachedVersion=null;export function getBuildInfo(){const _0x14aba5=a55_0x4e35;if(cachedBuildInfo!==null)return cachedBuildInfo;const _0x2bc8d4=fileURLToPath(import.meta.url),_0x29cd36=dirname(_0x2bc8d4);try{const _0x32e88f=join(_0x29cd36,_0x14aba5(0x195));cachedBuildInfo=JSON[_0x14aba5(0x199)](readFileSync(_0x32e88f,_0x14aba5(0x1a2)));}catch{cachedBuildInfo={};}return cachedBuildInfo;}function a55_0x4fec(){const _0x100fba=['5PFMSxl','0.0.0','utf-8','version','includes','6AdkdKi','2912VYnPmo','520172TCsZdz','997368vxQUzZ','../build-info.json','96ndGVyV','27XzOGqh','285990fCnLvI','parse','6626660ZQFwlg','../../package.json','13908HaLAAX','.dev','2708764Muymcj','2239105atFgrt'];a55_0x4fec=function(){return _0x100fba;};return a55_0x4fec();}export function getVersion(){const _0x1e72da=a55_0x4e35;if(cachedVersion!==null)return cachedVersion;const _0x2dfc41=fileURLToPath(import.meta.url),_0x14e067=dirname(_0x2dfc41),_0x1be31f=getBuildInfo();if(_0x1be31f[_0x1e72da(0x1a3)])return cachedVersion=_0x1be31f[_0x1e72da(0x1a3)],cachedVersion;try{const _0x33a5bf=join(_0x14e067,_0x1e72da(0x19b)),_0x3828a7=JSON['parse'](readFileSync(_0x33a5bf,_0x1e72da(0x1a2)));cachedVersion=_0x3828a7['version'];}catch{cachedVersion=_0x1e72da(0x1a1);}return cachedVersion;}export function isDevVersion(){const _0x316867=a55_0x4e35,_0x47d321=getVersion();return _0x47d321[_0x316867(0x1a4)](_0x316867(0x19d))||_0x47d321[_0x316867(0x1a4)]('-');}
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(_0x49c4cb,_0x29a6ba){var _0x31d339=a56_0xc1f9,_0x1b4fc7=_0x49c4cb();while(!![]){try{var _0x311483=-parseInt(_0x31d339(0x1cf))/0x1*(parseInt(_0x31d339(0x1ca))/0x2)+parseInt(_0x31d339(0x1cc))/0x3*(parseInt(_0x31d339(0x1c7))/0x4)+parseInt(_0x31d339(0x1ce))/0x5+-parseInt(_0x31d339(0x1c9))/0x6*(parseInt(_0x31d339(0x1d1))/0x7)+-parseInt(_0x31d339(0x1cb))/0x8+-parseInt(_0x31d339(0x1d2))/0x9*(-parseInt(_0x31d339(0x1c8))/0xa)+-parseInt(_0x31d339(0x1cd))/0xb*(-parseInt(_0x31d339(0x1d0))/0xc);if(_0x311483===_0x29a6ba)break;else _0x1b4fc7['push'](_0x1b4fc7['shift']());}catch(_0x57c00f){_0x1b4fc7['push'](_0x1b4fc7['shift']());}}}(a56_0x7a72,0xa264d));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';function a56_0x7a72(){var _0x2bb44b=['707vfrYnZ','4652451nHfyGS','431492PxTBel','20UImVLh','66996RYvSyw','30872ikWrRY','7278752VMOIYW','15GcATdx','5264105jhoCCI','1093650jQZUqw','3fXgNNf','24NkLCXA'];a56_0x7a72=function(){return _0x2bb44b;};return a56_0x7a72();}export*from'./sdk/types/trino.js';export*from'./commands/command.js';export*from'./commands/query-command.js';export*from'./commands/databases.js';export*from'./commands/tables.js';export*from'./commands/segments.js';export*from'./commands/activations.js';function a56_0xc1f9(_0x39ef59,_0x43cdf2){_0x39ef59=_0x39ef59-0x1c7;var _0x7a7226=a56_0x7a72();var _0xc1f9d1=_0x7a7226[_0x39ef59];return _0xc1f9d1;}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(_0x40f7fb,_0x3e45cb){const _0x3369c1=a57_0x1187,_0x53ab8c=_0x40f7fb();while(!![]){try{const _0x4874cb=parseInt(_0x3369c1(0x1f5))/0x1+-parseInt(_0x3369c1(0x20b))/0x2*(parseInt(_0x3369c1(0x1ef))/0x3)+parseInt(_0x3369c1(0x1ee))/0x4+parseInt(_0x3369c1(0x1ec))/0x5+-parseInt(_0x3369c1(0x1f9))/0x6+parseInt(_0x3369c1(0x1f3))/0x7+-parseInt(_0x3369c1(0x1e5))/0x8*(parseInt(_0x3369c1(0x1e4))/0x9);if(_0x4874cb===_0x3e45cb)break;else _0x53ab8c['push'](_0x53ab8c['shift']());}catch(_0x2f036a){_0x53ab8c['push'](_0x53ab8c['shift']());}}}(a57_0x4f49,0xccf14));import{McpServer}from'@modelcontextprotocol/sdk/server/mcp.js';import{StdioServerTransport}from'@modelcontextprotocol/sdk/server/stdio.js';import{z}from'zod';function a57_0x1187(_0x3a96bc,_0x4ad221){_0x3a96bc=_0x3a96bc-0x1e3;const _0x4f49d2=a57_0x4f49();let _0x1187d8=_0x4f49d2[_0x3a96bc];return _0x1187d8;}import{executeTdxRun,searchCommands}from'./tools/index.js';export function createMCPServer(_0x52aade={}){const _0x31fa8b=a57_0x1187,_0x358ba4=new McpServer({'name':_0x31fa8b(0x1e7),'version':_0x31fa8b(0x209)});return _0x358ba4['registerTool'](_0x31fa8b(0x1e3),{'description':_0x31fa8b(0x202),'inputSchema':{'args':z[_0x31fa8b(0x1fd)](z['string']())[_0x31fa8b(0x1e6)]('Command\x20and\x20arguments\x20as\x20array\x20(e.g.,\x20[\x22query\x22,\x20\x22SELECT\x20...\x22])')}},async({args:_0x5e44f2})=>{const _0x792634=_0x31fa8b,_0x3fbd2e=await executeTdxRun({'args':_0x5e44f2},_0x52aade['env']||{});return _0x3fbd2e[_0x792634(0x1fb)]?{'content':[{'type':_0x792634(0x1eb),'text':_0x3fbd2e[_0x792634(0x1ea)]||_0x792634(0x1ff)}]}:{'content':[{'type':_0x792634(0x1eb),'text':_0x3fbd2e['error']||_0x3fbd2e['output']||_0x792634(0x1f8)}],'isError':!![]};}),_0x358ba4['registerTool']('tdx_search',{'description':_0x31fa8b(0x1f4),'inputSchema':{'query':z['string']()[_0x31fa8b(0x1e6)](_0x31fa8b(0x1ed)),'category':z[_0x31fa8b(0x20a)]([_0x31fa8b(0x1f6),'CDP','AI','Context',_0x31fa8b(0x1fc)])[_0x31fa8b(0x1f1)]()[_0x31fa8b(0x1e6)](_0x31fa8b(0x206))}},async({query:_0x7f9060,category:_0x20a4ec})=>{const _0x5571da=_0x31fa8b,_0x597b4e=searchCommands({'query':_0x7f9060,'category':_0x20a4ec});if(_0x597b4e[_0x5571da(0x1fa)]===0x0)return{'content':[{'type':_0x5571da(0x1eb),'text':_0x5571da(0x207)+_0x7f9060+'\x22'}]};const _0x550d10=_0x597b4e['map'](_0x1e3cd6=>{const _0x40f3a4=_0x5571da,_0xf357cc=_0x1e3cd6[_0x40f3a4(0x203)][_0x40f3a4(0x1f0)](_0x1f88ab=>'\x20\x20'+_0x1f88ab)['join']('\x0a');return'**'+_0x1e3cd6['name']+_0x40f3a4(0x1fe)+_0x1e3cd6[_0x40f3a4(0x208)]+')\x0a'+_0x1e3cd6[_0x40f3a4(0x1f2)]+_0x40f3a4(0x1e8)+_0xf357cc;})['join'](_0x5571da(0x205));return{'content':[{'type':'text','text':_0x550d10}]};}),_0x358ba4;}export async function startMCPServer(_0x42bcc0={}){const _0x371b81=a57_0x1187,_0x28416a=createMCPServer(_0x42bcc0),_0x5d8f8e=new StdioServerTransport();return await _0x28416a[_0x371b81(0x201)](_0x5d8f8e),new Promise(_0x2696cb=>{const _0x3c8877=_0x371b81;let _0x592a9e=![];const _0x29355d=async()=>{const _0x409ecc=a57_0x1187;if(_0x592a9e)return;_0x592a9e=!![],await _0x28416a[_0x409ecc(0x200)](),_0x2696cb();};process[_0x3c8877(0x1e9)](_0x3c8877(0x204),_0x29355d),process[_0x3c8877(0x1e9)](_0x3c8877(0x1f7),_0x29355d),process['stdin']['once']('close',_0x29355d);});}function a57_0x4f49(){const _0x1e3501=['examples','SIGINT','\x0a\x0a---\x0a\x0a','Optional\x20filter\x20by\x20category','No\x20commands\x20found\x20matching\x20\x22','category','1.0.0','enum','22BMqjef','tdx_run','9RCTGKw','2129560vQtNrd','describe','tdx','\x0a\x0aExamples:\x0a','once','output','text','4935735PKSNfC','Natural\x20language\x20query\x20(e.g.,\x20\x22list\x20databases\x22,\x20\x22run\x20SQL\x22,\x20\x22manage\x20segments\x22)','2029856WvDLTr','137331lNrBKd','map','optional','description','1784447WMsNZw','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.','313129LITSIb','Data','SIGTERM','Command\x20failed','2720850HuDwKM','length','success','Utilities','array','**\x20(','Command\x20completed\x20successfully','close','connect','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.'];a57_0x4f49=function(){return _0x1e3501;};return a57_0x4f49();}
|
package/dist/mcp/tools/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
function a58_0x152f(){var _0x30b418=['3141584dglXLI','6PRPqkx','165QpKPIt','243250fgmFSl','1166780XxRDdw','5956659dXRKHK','440041PCESSq','43636FtTruu','45802rXMPOp'];a58_0x152f=function(){return _0x30b418;};return a58_0x152f();}(function(_0x15d1dd,_0x5d23da){var _0x5ab3e4=a58_0xee7a,_0x3f5b9f=_0x15d1dd();while(!![]){try{var _0x4e6d0d=-parseInt(_0x5ab3e4(0xf3))/0x1+-parseInt(_0x5ab3e4(0xf8))/0x2+-parseInt(_0x5ab3e4(0xfb))/0x3*(parseInt(_0x5ab3e4(0xf7))/0x4)+parseInt(_0x5ab3e4(0xf4))/0x5+-parseInt(_0x5ab3e4(0xfa))/0x6*(parseInt(_0x5ab3e4(0xf6))/0x7)+parseInt(_0x5ab3e4(0xf9))/0x8+parseInt(_0x5ab3e4(0xf5))/0x9;if(_0x4e6d0d===_0x5d23da)break;else _0x3f5b9f['push'](_0x3f5b9f['shift']());}catch(_0x4af997){_0x3f5b9f['push'](_0x3f5b9f['shift']());}}}(a58_0x152f,0x579f0));function a58_0xee7a(_0x2793ee,_0x24c2a4){_0x2793ee=_0x2793ee-0xf3;var _0x152f99=a58_0x152f();var _0xee7a00=_0x152f99[_0x2793ee];return _0xee7a00;}export{executeTdxRun,TdxRunInputSchema}from'./tdx-run.js';export{searchCommands,TdxSearchInputSchema}from'./tdx-search.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
const a59_0x2ea461=a59_0x1ee2;(function(_0x109531,_0x50353a){const _0x9fa993=a59_0x1ee2,_0x2e84a0=_0x109531();while(!![]){try{const _0x161030=-parseInt(_0x9fa993(0x7e))/0x1*(parseInt(_0x9fa993(0x8d))/0x2)+-parseInt(_0x9fa993(0x7f))/0x3+-parseInt(_0x9fa993(0x86))/0x4+parseInt(_0x9fa993(0x83))/0x5+parseInt(_0x9fa993(0x93))/0x6+parseInt(_0x9fa993(0x84))/0x7+parseInt(_0x9fa993(0x8b))/0x8;if(_0x161030===_0x50353a)break;else _0x2e84a0['push'](_0x2e84a0['shift']());}catch(_0xc7589c){_0x2e84a0['push'](_0x2e84a0['shift']());}}}(a59_0x49fb,0x82ed9));import{spawn}from'child_process';import{dirname,join}from'path';import{existsSync}from'fs';import{z}from'zod';import{isBlockedCommand,getBlockedReason,formatOutput}from'../utils.js';export const TdxRunInputSchema=z[a59_0x2ea461(0x91)]({'args':z[a59_0x2ea461(0x89)](z[a59_0x2ea461(0x8e)]())[a59_0x2ea461(0x9a)]('Command\x20and\x20arguments\x20as\x20array\x20(e.g.,\x20[\x22query\x22,\x20\x22SELECT\x20...\x22])')});const DEFAULT_TIMEOUT_MS=0xf*0x3c*0x3e8;function a59_0x1ee2(_0x1a7dda,_0x4720ea){_0x1a7dda=_0x1a7dda-0x7d;const _0x49fbc5=a59_0x49fb();let _0x1ee2c9=_0x49fbc5[_0x1a7dda];return _0x1ee2c9;}function getNodeBinDir(){const _0x3e3651=a59_0x2ea461,_0x1a7697=process[_0x3e3651(0x87)];if(_0x1a7697){const _0x51aa4d=join(_0x1a7697,_0x3e3651(0x90)),_0xfd65e3=process[_0x3e3651(0x94)]===_0x3e3651(0x80)?_0x3e3651(0x8a):_0x3e3651(0x90);if(existsSync(join(_0x51aa4d,_0xfd65e3)))return _0x51aa4d;}return dirname(process[_0x3e3651(0x98)]);}function a59_0x49fb(){const _0x1a3c6c=['object','pipe','4345320xckCjZ','platform','close','error','stderr','execPath','Command\x20timed\x20out\x20after\x2015\x20minutes.\x20For\x20long-running\x20queries,\x20use\x20job\x20submit\x20instead.','describe','--no-color','185GccXep','2052870FDoJIy','win32','true','data','441385OJvwZf','4315024occBhD','Failed\x20to\x20spawn\x20tdx:\x20','1091396MNcYks','resourcesPath','ignore','array','node.exe','7587368NOAxPz','kill','9556CojUtC','string','toString','node'];a59_0x49fb=function(){return _0x1a3c6c;};return a59_0x49fb();}export async function executeTdxRun(_0x1bc04d,_0x9290de){const _0x5225a3=a59_0x2ea461,{args:_0x436068}=_0x1bc04d;if(isBlockedCommand(_0x436068)){const _0x5ce2c4=getBlockedReason(_0x436068);return{'success':![],'output':'','error':_0x5ce2c4||'This\x20command\x20is\x20not\x20allowed\x20via\x20MCP','exitCode':0x1};}const _0x2d759a=['--json',_0x5225a3(0x7d),..._0x436068],_0x34fb1e=getNodeBinDir(),_0x1e2617=process['platform']===_0x5225a3(0x80)?';':':',_0xa087d6=_0x9290de['PATH']??process.env.PATH??'',_0x39ff46=''+_0x34fb1e+_0x1e2617+_0xa087d6;return new Promise(_0x377bc3=>{const _0x475518=_0x5225a3,_0x3f950e=spawn('tdx',_0x2d759a,{'env':{...process.env,..._0x9290de,'PATH':_0x39ff46,'CI':_0x475518(0x81)},'stdio':[_0x475518(0x88),_0x475518(0x92),_0x475518(0x92)]});let _0x43b00b='',_0x2150e4='',_0x35b052=![];const _0x25e50e=setTimeout(()=>{const _0x34e063=_0x475518;_0x35b052=!![],_0x3f950e[_0x34e063(0x8c)]('SIGTERM');},DEFAULT_TIMEOUT_MS);_0x3f950e['stdout']['on'](_0x475518(0x82),_0x1bdcd5=>{_0x43b00b+=_0x1bdcd5['toString']();}),_0x3f950e[_0x475518(0x97)]['on'](_0x475518(0x82),_0x2f259d=>{const _0x1b9862=_0x475518;_0x2150e4+=_0x2f259d[_0x1b9862(0x8f)]();}),_0x3f950e['on'](_0x475518(0x96),_0x4ed2fe=>{const _0x31fb5d=_0x475518;clearTimeout(_0x25e50e),_0x377bc3({'success':![],'output':'','error':_0x31fb5d(0x85)+_0x4ed2fe['message'],'exitCode':0x1});}),_0x3f950e['on'](_0x475518(0x95),_0x3dd192=>{const _0x59517a=_0x475518;clearTimeout(_0x25e50e);if(_0x35b052){_0x377bc3({'success':![],'output':formatOutput(_0x43b00b),'error':_0x59517a(0x99),'exitCode':0x7c});return;}const _0x2b2f90=_0x3dd192??0x1,_0x4f71d3=_0x2b2f90===0x0,_0x2ec38f=formatOutput(_0x43b00b||_0x2150e4),_0xfd2db0=!_0x4f71d3&&_0x2150e4?formatOutput(_0x2150e4):undefined;_0x377bc3({'success':_0x4f71d3,'output':_0x2ec38f,'error':_0xfd2db0,'exitCode':_0x2b2f90});});});}
|