@treasuredata/tdx 0.14.7 → 0.14.8
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/api-command.js +1 -1
- package/dist/commands/auth-command.js +1 -1
- package/dist/commands/chat-command.js +1 -1
- package/dist/commands/claude-command.js +1 -1
- package/dist/commands/claude-statusline-command.js +1 -1
- package/dist/commands/claude-usage-command.js +1 -1
- package/dist/commands/command.js +1 -1
- package/dist/commands/connection-command.js +1 -1
- package/dist/commands/databases.js +1 -1
- package/dist/commands/describe.js +1 -1
- package/dist/commands/engage-command.js +1 -1
- package/dist/commands/job-command.js +1 -1
- package/dist/commands/journey-command.js +1 -1
- package/dist/commands/journey-validate-command.js +1 -1
- package/dist/commands/llm-command.js +1 -1
- package/dist/commands/llm-proxy.js +1 -1
- package/dist/commands/parent-segment-command.js +1 -1
- package/dist/commands/profile-command.js +1 -1
- package/dist/commands/profiles-command.js +1 -1
- package/dist/commands/query-command.js +1 -1
- package/dist/commands/segment-command.js +1 -1
- package/dist/commands/segment-create-command.js +1 -1
- package/dist/commands/segment-fields-command.js +1 -1
- package/dist/commands/segment-pull-command.js +1 -1
- package/dist/commands/segment-push-command.js +1 -1
- package/dist/commands/segment-update-command.js +1 -1
- package/dist/commands/segment-use-command.js +1 -1
- package/dist/commands/segment-validate-command.js +1 -1
- package/dist/commands/segments.js +1 -1
- package/dist/commands/show.js +1 -1
- package/dist/commands/tables.js +1 -1
- package/dist/commands/unset-command.js +1 -1
- package/dist/commands/use-command.js +1 -1
- package/dist/commands/user-command.js +1 -1
- package/dist/commands/workflow-command.js +1 -1
- package/dist/core/auth.js +1 -1
- package/dist/core/command-output.js +1 -1
- package/dist/core/config.js +1 -1
- package/dist/core/connection-cache.js +1 -1
- package/dist/core/constants.js +1 -1
- package/dist/core/credential-cache.js +1 -1
- package/dist/core/global-context.js +1 -1
- package/dist/core/keychain.js +1 -1
- package/dist/core/profile.js +1 -1
- package/dist/core/project-config.js +1 -1
- package/dist/core/session.js +1 -1
- package/dist/core/user-cache.js +1 -1
- package/dist/core/version.js +1 -1
- package/dist/index.js +1 -1
- package/dist/proxy/anthropic-adapter.js +1 -1
- package/dist/proxy/claude-usage-tracker.js +1 -1
- package/dist/proxy/context-signature.js +1 -1
- package/dist/proxy/conversation-utils.js +1 -1
- package/dist/proxy/passthrough-server.js +1 -1
- package/dist/proxy/server.js +1 -1
- package/dist/proxy/session-cache.js +1 -1
- package/dist/proxy/sse-usage-parser.js +1 -1
- package/dist/sdk/agent/agent-config.js +1 -1
- package/dist/sdk/agent/agent-ref-parser.js +1 -1
- package/dist/sdk/agent/agent-yaml.js +1 -1
- package/dist/sdk/api.js +1 -1
- package/dist/sdk/client/cdp-api-client.js +1 -1
- package/dist/sdk/client/endpoints.js +1 -1
- package/dist/sdk/client/engage-api-client.js +1 -1
- package/dist/sdk/client/http-client.js +1 -1
- package/dist/sdk/client/llm-api-client.js +1 -1
- package/dist/sdk/client/rate-limiter.js +1 -1
- package/dist/sdk/client/td-api-client.js +1 -1
- package/dist/sdk/client/trino-api-client.js +1 -1
- package/dist/sdk/client/workflow-client.js +1 -1
- package/dist/sdk/connection-validator.js +1 -1
- package/dist/sdk/connection.js +1 -1
- package/dist/sdk/engage.js +1 -1
- package/dist/sdk/errors.js +1 -1
- package/dist/sdk/index.js +1 -1
- package/dist/sdk/io/index.js +1 -1
- package/dist/sdk/io/node-filesystem.js +1 -1
- package/dist/sdk/job.js +1 -1
- package/dist/sdk/journey.js +1 -1
- package/dist/sdk/llm/chat-cache.js +1 -1
- package/dist/sdk/llm/index.js +1 -1
- package/dist/sdk/llm/llm-backup-utils.js +1 -1
- package/dist/sdk/llm/model-aliases.js +1 -1
- package/dist/sdk/llm/model-factors.js +1 -1
- package/dist/sdk/query/index.js +1 -1
- package/dist/sdk/query/sql-parser.js +1 -1
- package/dist/sdk/segment/child-segment-yaml.js +1 -1
- package/dist/sdk/segment/fields-display.js +1 -1
- package/dist/sdk/segment/file-discovery.js +1 -1
- package/dist/sdk/segment/journey-utils.js +1 -1
- package/dist/sdk/segment/journey-yaml.js +1 -1
- package/dist/sdk/segment/parent-segment-preview.js +1 -1
- package/dist/sdk/segment/parent-segment-yaml.js +1 -1
- package/dist/sdk/segment/pull-workflow.js +1 -1
- package/dist/sdk/segment/push-workflow.js +1 -1
- package/dist/sdk/segment/resolution-context.js +1 -1
- package/dist/sdk/segment/segment-path-parser.js +1 -1
- package/dist/sdk/segment/segment-ref-parser.js +1 -1
- package/dist/sdk/segment/target-resolution.js +1 -1
- package/dist/sdk/segment/tdx-config.js +1 -1
- package/dist/sdk/segment/validate-files.js +1 -1
- package/dist/sdk/segment/yaml-validator.js +1 -1
- package/dist/sdk/segment.js +1 -1
- package/dist/sdk/types/index.js +1 -1
- package/dist/sdk/types/progress.js +1 -1
- package/dist/sdk/user.js +1 -1
- package/dist/sdk/util/format-detector.js +1 -1
- package/dist/sdk/util/formatters.js +1 -1
- package/dist/sdk/util/index.js +1 -1
- package/dist/sdk/util/tree-formatter.js +1 -1
- package/dist/sdk/workflow/clone-workflow.js +1 -1
- package/dist/sdk/workflow/index.js +1 -1
- package/dist/sdk/workflow/pull-workflow.js +1 -1
- package/dist/sdk/workflow/push-workflow.js +1 -1
- package/dist/sdk/workflow/tdx-config.js +1 -1
- package/dist/sdk/workflow/workflow-utils.js +1 -1
- package/dist/tdx +10 -0
- 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/json-loader.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 +2 -2
package/dist/sdk/llm/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
function a87_0x222f(){const _0x32d5b4=['listWebSearchTools','INTERNAL','AGENT_NOT_FOUND','attributes','.\x20Check\x20for\x20circular\x20references\x20or\x20missing\x20agents.','resolveProjectId','#\x20prompt.md\x0a','chatWelcomeMessage','high','models','Output\x20directory\x20already\x20exists:\x20','updated','getAgent','signal','1.0','availableModels','Unsupported\x20backup\x20version:\x20','tdx.json','.llm','status','updateAgent','text','getOrCreateDefaultAgent','projectName','modelType','path','Choose\x20a\x20different\x20name\x20or\x20delete\x20the\x20existing\x20project\x20first.','getChatInfo','unchanged','listKnowledgeBases','tdDatabaseName','endsWith','createImageGenerator','has','tdx_','createTextKnowledgeBase','getOrCreateDefaultProject','INVALID_ARGUMENT','description','push','agents','\x27\x20has\x20self-referencing\x20tool(s)\x20that\x20will\x20be\x20skipped\x20during\x20clone.\x20','loadJsonFile','conflict','7JCLAQO','listTextKnowledgeBases','deleteProject','listProjects','client','resolveAgentId','getUserSettings','Ensure\x20this\x20is\x20a\x20valid\x20LLM\x20project\x20backup\x20folder.','isManaged','prompts.json','dryRun','Use\x20\x22tdx\x20llm\x20projects\x22\x20to\x20list\x20available\x20projects.','isDirectory','543936PqbVCg','minimal','errors','createAgentResponse','\x27.\x20This\x20should\x20not\x20happen.','currentProjectId','total','listChats','includes','maxToolIterations','slackMessageMode','imageGenerators','Authentication\x20failed.\x20Please\x20check\x20your\x20API\x20key\x20is\x20valid\x20and\x20not\x20expired.','isDir','starter_message.md','agent.yml\x20not\x20found\x20in\x20','createKnowledgeBase','action','some','Failed\x20to\x20get\x20or\x20create\x20agent:\x20exceeded\x20maximum\x20attempts','Permission\x20denied.\x20Please\x20check\x20your\x20API\x20key\x20has\x20the\x20required\x20permissions\x20for\x20LLM\x20API\x20operations.','pullAgent','Ensure\x20the\x20path\x20points\x20to\x20a\x20valid\x20agent\x20directory.','createProject','existsSync','pushAgent','readFileSync','restoreProject','name','Ensure\x20the\x20backup\x20folder\x20path\x20is\x20correct.','agents.json','Use\x20\x22tdx\x20llm\x20agents\x22\x20to\x20list\x20available\x20agents\x20in\x20the\x20current\x20project.','agentId\x20is\x20required\x20when\x20starting\x20a\x20new\x20chat','createIntegration','metadata','agent.yml','logger','Invalid\x20backup:\x20project.json\x20not\x20found\x20in\x20','listAgentsFull','createAgent','medium','Multiple\x20agents\x20found\x20with\x20name\x20\x27','listImageGenerators','mkdirSync','Use\x20\x22tdx\x20llm\x20use\x20<project>\x22\x20to\x20set\x20a\x20project\x20context\x20first,\x20or\x20use\x20\x22tdx\x20llm\x20agents\x22\x20to\x20list\x20all\x20agents.','counts','low','availableModelNames','add','listIntegrations','knowledgeBases','message','UNAUTHENTICATED','filter','stringify','getUniqueName','displayName','4coBwUl','actions','dry-run-','serviceType','ALREADY_EXISTS','variables','PERMISSION_DENIED','starterMessage','\x20in\x20project\x20','projects','setCurrentProject','getDefaultProjectName','Backup\x20folder\x20not\x20found:\x20','agentId','warn','integrations.json','.yml','created','updateKnowledgeBase','tools','listPrompts','tables','Circular\x20dependency\x20detected\x20in\x20agents.\x20Cannot\x20restore.','chatInfo','error','get','createPrompt','map','project','423501vdDgDV','dirname','temperature','createWebSearchTool','LLM_PROJECT_NOT_FOUND','Re-add\x20them\x20after\x20clone\x20using\x20\x27tdx\x20agent\x20push\x27.','deleteAgent','set','textKnowledgeBases','length','newProjectId','Default\x20project\x20for\x20tdx\x20CLI\x20chat\x20(user:\x20','knowledgebases.json','pullProject','starter_message','readdirSync','utf-8','project.json','Available\x20agents:\x20','This\x20backup\x20was\x20created\x20with\x20a\x20newer\x20version\x20of\x20tdx.','event','Agent\x20not\x20found:\x20','chat','listAgents','78929zhKjks','prompt.md','find','_reasoning_','getProject','duplicate','none','webSearchTools','NOT_FOUND','Use\x20a\x20different\x20output\x20path\x20or\x20remove\x20the\x20existing\x20directory.','unlinkSync','4820442WpFkXC','getBackupMetadata','type','profile','cwd','getCurrentProject','setDefaultAgent','split','.md','pushProject','history','size','(dry-run)','reasoningEffort','toISOString','llm_project','\x0a\x0a#\x20agent.yml\x0a','template','new','knowledge_bases','Project\x20not\x20found:\x20','491715kirwCD','2760245ZTVkry','parse','tdx_default_','1863846VrLyun','systemPrompt','context','site','startChat','\x22\x20already\x20exists','prompts','The\x20backup\x20contains\x20agents\x20with\x20circular\x20dependencies.','integrations','target','promptId','Run\x20\x27tdx\x20agent\x20pull\x20<project>\x27\x20first\x20to\x20create\x20the\x20folder\x20structure.','exportedFrom','writeFileSync','updateAgentResponse','Agent\x20reference\x20not\x20found','yaml','updatePrompt','outputs','Invalid\x20agent\x20reference\x20format:\x20','agent','resolveProjectName','join'];a87_0x222f=function(){return _0x32d5b4;};return a87_0x222f();}const a87_0x13fc72=a87_0x25d1;(function(_0x5bd8a7,_0x132116){const _0x4f1e31=a87_0x25d1,_0x1c9070=_0x5bd8a7();while(!![]){try{const _0x1a934e=-parseInt(_0x4f1e31(0x143))/0x1+parseInt(_0x4f1e31(0x167))/0x2+parseInt(_0x4f1e31(0x12b))/0x3*(-parseInt(_0x4f1e31(0x1f0))/0x4)+parseInt(_0x4f1e31(0x164))/0x5+parseInt(_0x4f1e31(0x14e))/0x6*(-parseInt(_0x4f1e31(0x1aa))/0x7)+parseInt(_0x4f1e31(0x1b7))/0x8+-parseInt(_0x4f1e31(0x163))/0x9;if(_0x1a934e===_0x132116)break;else _0x1c9070['push'](_0x1c9070['shift']());}catch(_0x2b0c5a){_0x1c9070['push'](_0x1c9070['shift']());}}}(a87_0x222f,0x73ae2));import{LLMApiClient}from'../client/llm-api-client.js';import*as a87_0x4028a9 from'node:fs';function a87_0x25d1(_0x20b8af,_0x14c089){_0x20b8af=_0x20b8af-0x11c;const _0x222f8c=a87_0x222f();let _0x25d1b6=_0x222f8c[_0x20b8af];return _0x25d1b6;}import*as a87_0x1a4aec from'node:path';import{HTTPClientError}from'../client/http-client.js';import{canCreateAgent,remapToolIds,remapVariableIds,isSupportedBackupVersion}from'./llm-backup-utils.js';import{SDKError,ErrorCode,errorContains}from'../errors.js';import{normalizeName,UniqueNameGenerator,migrateModelType,parseRef,agentResponseToDef,apiKnowledgeBaseToYaml,apiPromptToYaml,toAgentYamlString,toKnowledgeBaseYamlString,toTextKnowledgeBaseMd,toPromptYamlString,parseAgentYaml,parseKnowledgeBaseYaml,parseTextKnowledgeBaseMd,parsePromptYaml,agentDefToRequest,yamlKnowledgeBaseToApi,yamlTextKnowledgeBaseToApi,yamlPromptToApi,resolveAgentDependencies}from'../agent/agent-yaml.js';import{createAgentConfigContent,loadAgentConfig,findAgentConfig,isAgentDir,isAgentYamlPath,getAgentDirFromYamlPath,getKnowledgeBasesDir,getPromptsDir}from'../agent/agent-config.js';import{getSanitizedUsername,generateRandomHex}from'../../utils/string-utils.js';import{generateDiff,formatDiffWithColors,hasChanges}from'../../utils/diff.js';import{readCachedLLMProject,writeCachedLLMProject,readCachedLLMAgent,writeCachedLLMAgent,clearCachedLLMAgent}from'../../core/config.js';export class LLMSDK{[a87_0x13fc72(0x1bc)];[a87_0x13fc72(0x1ae)];[a87_0x13fc72(0x169)];constructor(_0x4268ee){const _0x640673=a87_0x13fc72;this['client']=new LLMApiClient(_0x4268ee,_0x4268ee[_0x640673(0x1db)]),this['context']=_0x4268ee;}['getDefaultProjectName'](){const _0x19f247=a87_0x13fc72,_0x1e4f75=getSanitizedUsername();return _0x19f247(0x166)+_0x1e4f75;}async[a87_0x13fc72(0x1fa)](_0x2b4b79){const _0x3008e5=a87_0x13fc72,{projectId:_0x135c36}=await this[_0x3008e5(0x17c)](_0x2b4b79);this['currentProjectId']=_0x135c36;}[a87_0x13fc72(0x153)](){const _0x3bcb4a=a87_0x13fc72;return this[_0x3bcb4a(0x1bc)];}async[a87_0x13fc72(0x154)](_0x1d8b46){const _0x454045=a87_0x13fc72,_0x454a63=this['context']['profile'];let _0x138da6,_0x3968ab;if(_0x1d8b46[_0x454045(0x1bf)]('/')){const _0x2557a0=_0x1d8b46[_0x454045(0x155)]('/');if(_0x2557a0['length']!==0x2)throw new SDKError(ErrorCode['INVALID_ARGUMENT'],_0x454045(0x17a)+_0x1d8b46,undefined,{'helpText':'Use\x20format:\x20\x22agent-name\x22\x20or\x20\x22project-name/agent-name\x22'});const [_0x461b6f,_0x26f8e8]=_0x2557a0;_0x138da6=await this['resolveProjectId'](_0x461b6f),_0x3968ab=_0x26f8e8;}else _0x138da6=this[_0x454045(0x1bc)]||(await this[_0x454045(0x1a2)]())['id'],_0x3968ab=_0x1d8b46;const _0x522327=await this[_0x454045(0x1af)](_0x3968ab,_0x138da6),_0x3bfe15=await this[_0x454045(0x1ae)][_0x454045(0x18a)](_0x522327);writeCachedLLMAgent(_0x3bfe15[_0x454045(0x181)][_0x454045(0x1d3)],_0x522327,_0x138da6,_0x454a63);}['getDefaultAgent'](){const _0x1beae8=a87_0x13fc72,_0x2befec=this[_0x1beae8(0x169)][_0x1beae8(0x151)];return readCachedLLMAgent(_0x2befec)||undefined;}['clearDefaultAgent'](){const _0xaddee9=a87_0x13fc72,_0x4cbcc1=this[_0xaddee9(0x169)]['profile'];clearCachedLLMAgent(_0x4cbcc1);}async[a87_0x13fc72(0x187)](){const _0x5dd271=a87_0x13fc72,_0x35aa9b=await this[_0x5dd271(0x1ae)][_0x5dd271(0x1b0)](),_0x3fb8fa=[];for(const _0x483706 of _0x35aa9b[_0x5dd271(0x1e6)]){const _0x2e3157=_0x35aa9b[_0x5dd271(0x18d)][_0x483706];_0x2e3157&&_0x3fb8fa[_0x5dd271(0x1a5)]({'name':_0x483706,'displayName':_0x2e3157[_0x5dd271(0x1ef)]});}return _0x3fb8fa;}async[a87_0x13fc72(0x1ce)](_0x106020){const _0x222187=a87_0x13fc72;return await this[_0x222187(0x1ae)][_0x222187(0x1ce)](_0x106020);}async[a87_0x13fc72(0x1ac)](_0x3e0989){const _0x70ef90=a87_0x13fc72,{projectId:_0x28fae8}=await this[_0x70ef90(0x17c)](_0x3e0989);await this['client'][_0x70ef90(0x1ac)](_0x28fae8);}async[a87_0x13fc72(0x1f9)](_0x5c7f9b=0x32){const _0x32e89f=a87_0x13fc72;return await this[_0x32e89f(0x1ae)][_0x32e89f(0x1ad)](_0x5c7f9b);}async['getOrCreateDefaultProject'](_0x323574){const _0x51842d=a87_0x13fc72,_0x12dfe8=_0x323574||this[_0x51842d(0x1fb)](),_0x4633c8=this[_0x51842d(0x169)][_0x51842d(0x151)];if(!_0x323574){const _0x289f7c=readCachedLLMProject(_0x4633c8);if(_0x289f7c&&_0x289f7c[_0x51842d(0x1d3)]===_0x12dfe8)try{const _0x26c2a9=await this[_0x51842d(0x1ae)][_0x51842d(0x147)](_0x289f7c['id']);if(_0x26c2a9[_0x51842d(0x181)][_0x51842d(0x1d3)]===_0x12dfe8)return _0x26c2a9;}catch{}}const _0x3fb034=await this[_0x51842d(0x1ae)]['listProjects'](),_0x87b128=_0x3fb034[_0x51842d(0x145)](_0x455cf3=>_0x455cf3['attributes'][_0x51842d(0x1d3)]===_0x12dfe8);if(_0x87b128)return!_0x323574&&writeCachedLLMProject(_0x12dfe8,_0x87b128['id'],_0x4633c8),_0x87b128;const _0x1e8741=await this[_0x51842d(0x1ae)][_0x51842d(0x1ce)]({'name':_0x12dfe8,'description':_0x51842d(0x136)+getSanitizedUsername()+')'});return!_0x323574&&writeCachedLLMProject(_0x12dfe8,_0x1e8741['id'],_0x4633c8),_0x1e8741;}async['resolveProjectId'](_0x1308db){const _0x48a8cd=a87_0x13fc72,_0x111d5f=await this[_0x48a8cd(0x1ae)][_0x48a8cd(0x1ad)](),_0x454eff=_0x111d5f['filter'](_0x3429ca=>_0x3429ca['attributes'][_0x48a8cd(0x1d3)]===_0x1308db);if(_0x454eff[_0x48a8cd(0x134)]===0x0)throw new SDKError(ErrorCode['LLM_PROJECT_NOT_FOUND'],_0x48a8cd(0x162)+_0x1308db,undefined,{'helpText':_0x48a8cd(0x1b5)});if(_0x454eff[_0x48a8cd(0x134)]>0x1)throw new SDKError(ErrorCode[_0x48a8cd(0x17f)],'Multiple\x20projects\x20found\x20with\x20name\x20\x27'+_0x1308db+_0x48a8cd(0x1bb));return _0x454eff[0x0]['id'];}async['resolveProjectName'](_0x35d0c9){const _0x5e8671=a87_0x13fc72,_0x3b0d54=await this[_0x5e8671(0x1ae)][_0x5e8671(0x1ad)](),_0x2b69d4=_0x3b0d54['find'](_0x46483a=>_0x46483a[_0x5e8671(0x181)]['name']===_0x35d0c9);if(_0x2b69d4)return{'projectId':_0x2b69d4['id'],'project':_0x2b69d4};throw new SDKError(ErrorCode[_0x5e8671(0x12f)],_0x5e8671(0x162)+_0x35d0c9,undefined,{'helpText':_0x5e8671(0x1b5)});}async[a87_0x13fc72(0x194)](_0x40a5b4='claude-4.5-sonnet',_0x1c9371=0x0,_0x14404e){const _0x813c93=a87_0x13fc72,_0xb57ccf=0xa;let _0x2ca85b=0x0,_0x2f4b4f;while(_0x2ca85b<_0xb57ccf){try{const _0x4967b6=await this['getOrCreateDefaultProject'](_0x2f4b4f),_0xa98306=_0x4967b6['id'],_0x3ccd66=[_0x813c93(0x149),_0x813c93(0x1b8),_0x813c93(0x1e5),_0x813c93(0x1df),_0x813c93(0x186)],_0x459d70=_0x1c9371===0x0?_0x813c93(0x1a0)+_0x40a5b4:_0x813c93(0x1a0)+_0x40a5b4+_0x813c93(0x146)+_0x3ccd66[_0x1c9371],_0x1e2579=await this[_0x813c93(0x1ae)][_0x813c93(0x142)](_0xa98306),_0x108143=_0x1e2579['find'](_0x50507a=>_0x50507a[_0x813c93(0x181)][_0x813c93(0x1d3)]===_0x459d70);if(_0x108143)return _0x108143;const _0xb53d52=_0x1c9371>0x0?0x1:_0x14404e;return await this[_0x813c93(0x1ae)][_0x813c93(0x1de)]({'name':_0x459d70,'projectId':_0xa98306,'modelType':_0x40a5b4,'systemPrompt':'','temperature':_0xb53d52,'reasoningEffort':_0x1c9371>0x0?_0x1c9371:undefined});}catch(_0x51e327){if(_0x51e327 instanceof HTTPClientError){const _0xadabde=_0x51e327[_0x813c93(0x191)];if(_0xadabde>=0x190&&_0xadabde<0x1f4){if(_0xadabde===0x191)throw new SDKError(ErrorCode[_0x813c93(0x1eb)],_0x813c93(0x1c3),_0x51e327);else{if(_0xadabde===0x193)throw new SDKError(ErrorCode[_0x813c93(0x1f6)],_0x813c93(0x1cb),_0x51e327);}throw _0x51e327;}}if(errorContains(_0x51e327,'already\x20exists',_0x813c93(0x148),_0x813c93(0x1a9))){_0x2ca85b++;if(_0x2ca85b>=_0xb57ccf)throw new SDKError(ErrorCode[_0x813c93(0x1f4)],'Unable\x20to\x20create\x20project\x20after\x20'+_0xb57ccf+'\x20attempts\x20due\x20to\x20name\x20conflicts.',_0x51e327);const _0x2f07c5=this[_0x813c93(0x1fb)]();_0x2f4b4f=_0x2f07c5+'_'+generateRandomHex();continue;}throw _0x51e327;}}throw new SDKError(ErrorCode[_0x813c93(0x17f)],_0x813c93(0x1ca));}async['resolveAgentId'](_0x41d32c,_0x4b80aa){const _0x35a790=a87_0x13fc72,_0x18c87b=_0x4b80aa||this[_0x35a790(0x1bc)],_0x409112=await this[_0x35a790(0x1ae)][_0x35a790(0x142)](_0x18c87b),_0x445e00=_0x409112[_0x35a790(0x1ec)](_0xde0a3d=>_0xde0a3d['attributes'][_0x35a790(0x1d3)]===_0x41d32c);if(_0x445e00['length']===0x0){const _0xd77c70=_0x18c87b?_0x35a790(0x1f8)+_0x18c87b:'';throw new SDKError(ErrorCode['AGENT_NOT_FOUND'],'Agent\x20not\x20found:\x20'+_0x41d32c+_0xd77c70,undefined,{'helpText':_0x18c87b?_0x35a790(0x1d6):_0x35a790(0x1e3)});}if(_0x445e00[_0x35a790(0x134)]>0x1)throw new SDKError(ErrorCode['INTERNAL'],_0x35a790(0x1e0)+_0x41d32c+_0x35a790(0x1bb));return _0x445e00[0x0]['id'];}async[a87_0x13fc72(0x1a6)](_0x239737){const _0x3f34dd=a87_0x13fc72,_0x3539b7=_0x239737||this[_0x3f34dd(0x1bc)];return await this[_0x3f34dd(0x1ae)][_0x3f34dd(0x142)](_0x3539b7);}async[a87_0x13fc72(0x17b)](_0x521c0d){const _0x5454fc=a87_0x13fc72;return await this[_0x5454fc(0x1ae)]['getAgent'](_0x521c0d);}async[a87_0x13fc72(0x1de)](_0xd31c67){const _0x78542a=a87_0x13fc72;return await this[_0x78542a(0x1ae)][_0x78542a(0x1de)](_0xd31c67);}async[a87_0x13fc72(0x192)](_0x2f4f9e,_0x3abe46){const _0x29b48b=a87_0x13fc72;return await this[_0x29b48b(0x1ae)]['updateAgent'](_0x2f4f9e,_0x3abe46);}async[a87_0x13fc72(0x131)](_0x9f3e95){const _0x557c20=a87_0x13fc72;await this[_0x557c20(0x1ae)]['deleteAgent'](_0x9f3e95);}async[a87_0x13fc72(0x16b)](_0xee5fbf){const _0x4ab0fe=a87_0x13fc72;return await this[_0x4ab0fe(0x1ae)]['startChat']({'agentId':_0xee5fbf});}async*[a87_0x13fc72(0x141)](_0x56c121,_0x3f05fd){const _0x124636=a87_0x13fc72;let _0x4118f8=_0x3f05fd?.['chatId'];const _0xe5f72e=_0x3f05fd?.[_0x124636(0x1fd)];if(!_0x4118f8){if(!_0xe5f72e)throw new Error(_0x124636(0x1d7));const _0x12ee2b=await this[_0x124636(0x1ae)][_0x124636(0x16b)]({'agentId':_0xe5f72e});_0x4118f8=_0x12ee2b['id'],yield{'type':_0x124636(0x1d9),'data':{'chatId':_0x4118f8,'agentId':_0xe5f72e}};}for await(const _0x10e64a of this['client']['continueChat'](_0x4118f8,_0x56c121,_0x3f05fd?.[_0x124636(0x18b)])){yield{'type':_0x124636(0x13f),'data':_0x10e64a};}}async['chats'](_0x506b6d=0x32){const _0x529018=a87_0x13fc72;return await this[_0x529018(0x1ae)][_0x529018(0x1be)](_0x506b6d);}async[a87_0x13fc72(0x158)](_0x47ad02){const _0x498b83=a87_0x13fc72;return await this[_0x498b83(0x1ae)]['getChatHistory'](_0x47ad02);}async[a87_0x13fc72(0x125)](_0x2fb92d){const _0x3ae959=a87_0x13fc72;return await this[_0x3ae959(0x1ae)][_0x3ae959(0x199)](_0x2fb92d);}async['backupProject'](_0x7f7cbc,_0xd3c1cf,_0x911ed6){const _0x55974c=a87_0x13fc72,_0x1e8574=_0x911ed6?.[_0x55974c(0x1b4)]??![],{projectId:_0x5f2beb,project:_0x38da9e}=await this['resolveProjectName'](_0x7f7cbc),_0x642e7b=_0x38da9e[_0x55974c(0x181)][_0x55974c(0x1d3)],_0xe0f5ea=_0xd3c1cf||_0x642e7b+_0x55974c(0x190);if(a87_0x4028a9[_0x55974c(0x1cf)](_0xe0f5ea)&&!_0x1e8574)throw new SDKError(ErrorCode[_0x55974c(0x1f4)],_0x55974c(0x188)+_0xe0f5ea,undefined,{'helpText':_0x55974c(0x14c)});const _0x4683b5=await this[_0x55974c(0x1ae)][_0x55974c(0x1dd)](_0x5f2beb),_0x165e96=await this[_0x55974c(0x1ae)][_0x55974c(0x19b)](_0x5f2beb),_0x5891ea=await this[_0x55974c(0x1ae)][_0x55974c(0x122)](_0x5f2beb),_0x5ab7b6=await this[_0x55974c(0x1ae)][_0x55974c(0x1e8)](_0x5f2beb);if(!_0x1e8574){a87_0x4028a9[_0x55974c(0x1e2)](_0xe0f5ea,{'recursive':!![]});const _0x5391c8={'version':_0x55974c(0x18c),'exportedAt':new Date()[_0x55974c(0x15c)](),'exportedFrom':{'site':this[_0x55974c(0x169)]['site'],'projectId':_0x5f2beb,'projectName':_0x642e7b},'project':_0x38da9e};a87_0x4028a9[_0x55974c(0x174)](a87_0x1a4aec[_0x55974c(0x17d)](_0xe0f5ea,'project.json'),JSON[_0x55974c(0x1ed)](_0x5391c8,null,0x2)),a87_0x4028a9[_0x55974c(0x174)](a87_0x1a4aec[_0x55974c(0x17d)](_0xe0f5ea,_0x55974c(0x1d5)),JSON[_0x55974c(0x1ed)](_0x4683b5,null,0x2)),a87_0x4028a9['writeFileSync'](a87_0x1a4aec[_0x55974c(0x17d)](_0xe0f5ea,'knowledgebases.json'),JSON[_0x55974c(0x1ed)](_0x165e96,null,0x2)),a87_0x4028a9[_0x55974c(0x174)](a87_0x1a4aec[_0x55974c(0x17d)](_0xe0f5ea,_0x55974c(0x1b3)),JSON['stringify'](_0x5891ea,null,0x2)),a87_0x4028a9[_0x55974c(0x174)](a87_0x1a4aec['join'](_0xe0f5ea,_0x55974c(0x11d)),JSON['stringify'](_0x5ab7b6,null,0x2));}return{'projectName':_0x642e7b,'outputDir':_0xe0f5ea,'counts':{'agents':_0x4683b5['length'],'knowledgeBases':_0x165e96[_0x55974c(0x134)],'prompts':_0x5891ea['length'],'integrations':_0x5ab7b6[_0x55974c(0x134)]}};}async[a87_0x13fc72(0x1d2)](_0x5ed5fc,_0x16b9b5){const _0x3b99a8=a87_0x13fc72,_0x46b8f1=_0x16b9b5?.['dryRun']??![],_0x39c2c0=this[_0x3b99a8(0x14f)](_0x5ed5fc),_0x3450c0=_0x39c2c0[_0x3b99a8(0x173)][_0x3b99a8(0x16a)],_0x200179=this[_0x3b99a8(0x169)][_0x3b99a8(0x16a)],_0x1341d6=_0x3450c0!==_0x200179?_0x3450c0:undefined,_0x168ec0=this[_0x3b99a8(0x1a8)](a87_0x1a4aec[_0x3b99a8(0x17d)](_0x5ed5fc,_0x3b99a8(0x1d5)),[]),_0x494ef3=this[_0x3b99a8(0x1a8)](a87_0x1a4aec[_0x3b99a8(0x17d)](_0x5ed5fc,_0x3b99a8(0x137)),[]),_0x40fd0e=this['loadJsonFile'](a87_0x1a4aec[_0x3b99a8(0x17d)](_0x5ed5fc,_0x3b99a8(0x1b3)),[]),_0x133d60=this[_0x3b99a8(0x1a8)](a87_0x1a4aec[_0x3b99a8(0x17d)](_0x5ed5fc,_0x3b99a8(0x11d)),[]),_0xaf018c=_0x16b9b5?.[_0x3b99a8(0x1d3)]||_0x39c2c0['exportedFrom'][_0x3b99a8(0x195)];if(_0x46b8f1){const _0x472678=new Map(),_0x33fd36=[..._0x168ec0],_0x46bd52=_0x168ec0[_0x3b99a8(0x134)]+0x1;let _0x52237c=0x0;while(_0x33fd36[_0x3b99a8(0x134)]>0x0&&_0x52237c<_0x46bd52){_0x52237c++;const _0x41939c=[];for(const _0x3e8d44 of _0x33fd36){canCreateAgent(_0x3e8d44,_0x472678)?_0x472678[_0x3b99a8(0x132)](_0x3e8d44['id'],_0x3b99a8(0x1f2)+_0x3e8d44['id']):_0x41939c[_0x3b99a8(0x1a5)](_0x3e8d44);}if(_0x41939c[_0x3b99a8(0x134)]===_0x33fd36['length'])throw new SDKError(ErrorCode[_0x3b99a8(0x17f)],'Circular\x20dependency\x20detected\x20in\x20agents.\x20Cannot\x20restore.',undefined,{'helpText':_0x3b99a8(0x16e)});_0x33fd36[_0x3b99a8(0x134)]=0x0,_0x33fd36[_0x3b99a8(0x1a5)](..._0x41939c);}const _0x357f3b=_0x40fd0e[_0x3b99a8(0x1ec)](_0x5e3a71=>_0x472678[_0x3b99a8(0x19f)](_0x5e3a71[_0x3b99a8(0x181)][_0x3b99a8(0x1fd)]))[_0x3b99a8(0x134)];return{'projectName':_0xaf018c,'projectId':_0x3b99a8(0x15a),'counts':{'agents':_0x168ec0[_0x3b99a8(0x134)],'knowledgeBases':_0x494ef3[_0x3b99a8(0x134)],'prompts':_0x357f3b,'integrations':_0x133d60['length']},'sourceSite':_0x1341d6};}const _0x13f99d=await this[_0x3b99a8(0x1ae)][_0x3b99a8(0x1ce)]({'name':_0xaf018c,'description':_0x39c2c0[_0x3b99a8(0x12a)][_0x3b99a8(0x181)][_0x3b99a8(0x1a4)]}),_0x39beaa=_0x13f99d['id'],_0x450572=new Map(),_0x25eb9c=new Map(),_0x53a20f=new Map();for(const _0x5ab6b7 of _0x494ef3){const _0x198170=await this['client'][_0x3b99a8(0x1c7)]({'projectId':_0x39beaa,'name':_0x5ab6b7['attributes'][_0x3b99a8(0x1d3)],'tdDatabaseName':_0x5ab6b7[_0x3b99a8(0x181)][_0x3b99a8(0x19c)],'tables':_0x5ab6b7[_0x3b99a8(0x181)][_0x3b99a8(0x123)]});_0x450572[_0x3b99a8(0x132)](_0x5ab6b7['id'],_0x198170['id']);}const _0x3d1ab0=[..._0x168ec0],_0x175371=_0x168ec0[_0x3b99a8(0x134)]+0x1;let _0x2b8437=0x0;while(_0x3d1ab0['length']>0x0&&_0x2b8437<_0x175371){_0x2b8437++;const _0x188e26=[];for(const _0x5b415a of _0x3d1ab0){if(canCreateAgent(_0x5b415a,_0x25eb9c)){const _0x2a912f=remapToolIds(_0x5b415a['attributes'][_0x3b99a8(0x121)],_0x450572,_0x25eb9c),_0x1eb064=remapVariableIds(_0x5b415a['attributes'][_0x3b99a8(0x1f5)],_0x450572),_0x5725de=await this['client'][_0x3b99a8(0x1ba)]({'name':_0x5b415a[_0x3b99a8(0x181)]['name'],'projectId':_0x39beaa,'systemPrompt':_0x5b415a['attributes'][_0x3b99a8(0x168)],'starterMessage':_0x5b415a['attributes'][_0x3b99a8(0x1f7)],'modelType':migrateModelType(_0x5b415a[_0x3b99a8(0x181)][_0x3b99a8(0x196)]),'maxToolIterations':_0x5b415a[_0x3b99a8(0x181)][_0x3b99a8(0x1c0)],'temperature':_0x5b415a[_0x3b99a8(0x181)][_0x3b99a8(0x12d)],'reasoningEffort':_0x5b415a[_0x3b99a8(0x181)][_0x3b99a8(0x15b)],'outputs':_0x5b415a[_0x3b99a8(0x181)][_0x3b99a8(0x179)],'tools':_0x2a912f,'variables':_0x1eb064});_0x25eb9c['set'](_0x5b415a['id'],_0x5725de['id']);}else _0x188e26['push'](_0x5b415a);}if(_0x188e26[_0x3b99a8(0x134)]===_0x3d1ab0[_0x3b99a8(0x134)])throw new SDKError(ErrorCode['INTERNAL'],_0x3b99a8(0x124),undefined,{'helpText':_0x3b99a8(0x16e)});_0x3d1ab0[_0x3b99a8(0x134)]=0x0,_0x3d1ab0['push'](..._0x188e26);}for(const _0x4dcecd of _0x40fd0e){const _0x3dc3f8=_0x25eb9c[_0x3b99a8(0x127)](_0x4dcecd[_0x3b99a8(0x181)]['agentId']);if(!_0x3dc3f8)continue;const _0x4ccddc=await this[_0x3b99a8(0x1ae)][_0x3b99a8(0x128)]({'projectId':_0x39beaa,'agentId':_0x3dc3f8,'name':_0x4dcecd[_0x3b99a8(0x181)][_0x3b99a8(0x1d3)],'systemPrompt':_0x4dcecd['attributes'][_0x3b99a8(0x168)],'template':_0x4dcecd[_0x3b99a8(0x181)][_0x3b99a8(0x15f)],'jsonSchemaHint':_0x4dcecd[_0x3b99a8(0x181)]['jsonSchemaHint']});_0x53a20f['set'](_0x4dcecd['id'],_0x4ccddc['id']);}for(const _0x133b3f of _0x133d60){const _0x4ec7e1=_0x133b3f[_0x3b99a8(0x181)][_0x3b99a8(0x1f1)][_0x3b99a8(0x129)](_0x14344d=>({..._0x14344d,'promptId':_0x53a20f['get'](_0x14344d[_0x3b99a8(0x171)])||_0x14344d[_0x3b99a8(0x171)]}));await this[_0x3b99a8(0x1ae)][_0x3b99a8(0x1d8)]({'projectId':_0x39beaa,'serviceType':_0x133b3f[_0x3b99a8(0x181)][_0x3b99a8(0x1f3)],'actions':_0x4ec7e1,'slackMessageMode':_0x133b3f[_0x3b99a8(0x181)][_0x3b99a8(0x1c1)],'chatIgnoreManagedActions':_0x133b3f['attributes']['chatIgnoreManagedActions'],'chatWelcomeMessage':_0x133b3f['attributes'][_0x3b99a8(0x185)],'webhookCorsOrigins':_0x133b3f[_0x3b99a8(0x181)]['webhookCorsOrigins']});}return{'projectName':_0xaf018c,'projectId':_0x39beaa,'counts':{'agents':_0x25eb9c['size'],'knowledgeBases':_0x450572[_0x3b99a8(0x159)],'prompts':_0x53a20f[_0x3b99a8(0x159)],'integrations':_0x133d60[_0x3b99a8(0x134)]},'sourceSite':_0x1341d6};}[a87_0x13fc72(0x1a8)](_0x30bd82,_0x314611){const _0xf58da9=a87_0x13fc72;if(!a87_0x4028a9[_0xf58da9(0x1cf)](_0x30bd82))return _0x314611;return JSON[_0xf58da9(0x165)](a87_0x4028a9['readFileSync'](_0x30bd82,'utf-8'));}['getBackupMetadata'](_0x271d24){const _0x111683=a87_0x13fc72;if(!a87_0x4028a9[_0x111683(0x1cf)](_0x271d24))throw new SDKError(ErrorCode[_0x111683(0x14b)],_0x111683(0x1fc)+_0x271d24,undefined,{'helpText':_0x111683(0x1d4)});const _0x384ff9=a87_0x1a4aec[_0x111683(0x17d)](_0x271d24,_0x111683(0x13c));if(!a87_0x4028a9[_0x111683(0x1cf)](_0x384ff9))throw new SDKError(ErrorCode[_0x111683(0x1a3)],_0x111683(0x1dc)+_0x271d24,undefined,{'helpText':_0x111683(0x1b1)});const _0xc6ab3b=JSON[_0x111683(0x165)](a87_0x4028a9[_0x111683(0x1d1)](_0x384ff9,_0x111683(0x13b)));if(!isSupportedBackupVersion(_0xc6ab3b['version']))throw new SDKError(ErrorCode[_0x111683(0x1a3)],_0x111683(0x18e)+_0xc6ab3b['version'],undefined,{'helpText':_0x111683(0x13e)});return _0xc6ab3b;}async[a87_0x13fc72(0x138)](_0x28f4c4,_0x22f50c,_0x9006c1){const _0x16c888=a87_0x13fc72,{projectId:_0x2a9d56,project:_0x21e250}=await this[_0x16c888(0x17c)](_0x28f4c4),_0x1e7f61=_0x21e250[_0x16c888(0x181)][_0x16c888(0x1d3)],_0x4e59a6=normalizeName(_0x1e7f61),_0x5d8fbb=_0x22f50c||a87_0x1a4aec[_0x16c888(0x17d)](process[_0x16c888(0x152)](),'agents',_0x4e59a6),_0x231223=await this[_0x16c888(0x1ae)][_0x16c888(0x1dd)](_0x2a9d56),_0x5bbcea=await this[_0x16c888(0x1ae)][_0x16c888(0x19b)](_0x2a9d56),_0x311676=await this['client']['listTextKnowledgeBases'](_0x2a9d56),_0x2726ae=await this[_0x16c888(0x1ae)][_0x16c888(0x1e1)](_0x2a9d56),_0x1ab91b=await this['client']['listWebSearchTools'](_0x2a9d56),_0x1197dd=await this[_0x16c888(0x1ae)][_0x16c888(0x122)](_0x2a9d56),_0x58a8c5=new Map(),_0x149317=new Map(),_0x3a6d39=new Map(),_0x1ce7fb=new Map(),_0x184a2b=new Map(),_0xe32093=new Map();for(const _0x41e409 of _0x231223){_0x58a8c5[_0x16c888(0x132)](_0x41e409['id'],_0x41e409['attributes']['name']);}for(const _0x124ce3 of _0x5bbcea){_0x149317['set'](_0x124ce3['id'],_0x124ce3[_0x16c888(0x181)][_0x16c888(0x1d3)]);}for(const _0x3ce95e of _0x311676){_0x3a6d39[_0x16c888(0x132)](_0x3ce95e['id'],_0x3ce95e['attributes'][_0x16c888(0x1d3)]);}for(const _0x1e25d3 of _0x2726ae){_0x1ce7fb[_0x16c888(0x132)](_0x1e25d3['id'],_0x1e25d3[_0x16c888(0x181)][_0x16c888(0x1d3)]);}for(const _0x4c30a3 of _0x1ab91b){_0x184a2b['set'](_0x4c30a3['id'],_0x4c30a3['attributes'][_0x16c888(0x1d3)]);}for(const _0x32716c of _0x1197dd){_0xe32093[_0x16c888(0x132)](_0x32716c['id'],_0x32716c[_0x16c888(0x181)][_0x16c888(0x1d3)]);}const _0x3240fe={'resolveKnowledgeBaseName':async _0x1b7189=>_0x149317['get'](_0x1b7189),'resolveTextKnowledgeBaseName':async _0x391693=>_0x3a6d39[_0x16c888(0x127)](_0x391693),'resolveAgentName':async _0x3700c3=>_0x58a8c5[_0x16c888(0x127)](_0x3700c3),'resolveWebSearchToolName':async _0x1f2539=>_0x184a2b[_0x16c888(0x127)](_0x1f2539),'resolveImageGeneratorName':async _0x715140=>_0x1ce7fb[_0x16c888(0x127)](_0x715140),'resolvePromptName':async _0x1aa87c=>_0xe32093[_0x16c888(0x127)](_0x1aa87c),'onWarning':_0x4111b3=>this['context'][_0x16c888(0x1db)]?.[_0x16c888(0x11c)](_0x4111b3)},_0x1134c1={'projectName':_0x1e7f61,'outputDir':_0x5d8fbb,'agents':[],'knowledgeBases':[],'textKnowledgeBases':[],'prompts':[],'counts':{'agents':{'total':0x0,'new':0x0,'updated':0x0,'unchanged':0x0},'knowledgeBases':{'total':0x0,'new':0x0,'updated':0x0,'unchanged':0x0},'textKnowledgeBases':{'total':0x0,'new':0x0,'updated':0x0,'unchanged':0x0},'prompts':{'total':0x0,'new':0x0,'updated':0x0,'unchanged':0x0}}},_0x315b46=[],_0x95a21e=new UniqueNameGenerator(),_0x362cd5=new UniqueNameGenerator(),_0xdb1924=new UniqueNameGenerator(),_0x314e77=new UniqueNameGenerator();for(const _0x5250ff of _0x231223){const _0xdec84d=_0x95a21e['getUniqueName'](_0x5250ff[_0x16c888(0x181)][_0x16c888(0x1d3)]),_0x255f98=a87_0x1a4aec[_0x16c888(0x17d)](_0x5d8fbb,_0xdec84d),_0x3b35af=a87_0x1a4aec[_0x16c888(0x17d)](_0x255f98,_0x16c888(0x144)),_0x3aabb3=a87_0x1a4aec[_0x16c888(0x17d)](_0x255f98,_0x16c888(0x1da)),_0x1dd8e6=a87_0x1a4aec[_0x16c888(0x17d)](_0x255f98,_0x16c888(0x1c5)),{yaml:_0x1c55fe,systemPrompt:_0x32ca8f,starterMessage:_0x216075}=await agentResponseToDef(_0x5250ff,_0x3240fe),_0x374c34=toAgentYamlString(_0x1c55fe),_0x3f69f7=!a87_0x4028a9[_0x16c888(0x1cf)](_0x3aabb3);let _0x17bd03=_0x3f69f7,_0x24f2a2;if(!_0x3f69f7){const _0x1f38fc=a87_0x4028a9[_0x16c888(0x1cf)](_0x3b35af)?a87_0x4028a9[_0x16c888(0x1d1)](_0x3b35af,_0x16c888(0x13b)):'',_0x3c9368=a87_0x4028a9[_0x16c888(0x1d1)](_0x3aabb3,'utf-8'),_0x4f4ebf=_0x16c888(0x184)+_0x1f38fc+_0x16c888(0x15e)+_0x3c9368,_0xdc8570=_0x16c888(0x184)+_0x32ca8f+_0x16c888(0x15e)+_0x374c34,_0x271e29=generateDiff(_0x4f4ebf,_0xdc8570);_0x17bd03=hasChanges(_0x271e29),_0x17bd03&&(_0x24f2a2=formatDiffWithColors(_0x271e29));}_0x315b46[_0x16c888(0x1a5)]({'path':_0x255f98,'content':'','isDir':!![]}),_0x315b46[_0x16c888(0x1a5)]({'path':_0x3b35af,'content':_0x32ca8f}),_0x315b46[_0x16c888(0x1a5)]({'path':_0x3aabb3,'content':_0x374c34});_0x216075&&_0x216075['includes']('\x0a')&&_0x315b46[_0x16c888(0x1a5)]({'path':_0x1dd8e6,'content':_0x216075});_0x1134c1['agents'][_0x16c888(0x1a5)]({'agentName':_0x5250ff[_0x16c888(0x181)][_0x16c888(0x1d3)],'outputPath':_0x255f98,'isNew':_0x3f69f7,'hasChanges':_0x17bd03,'diff':_0x24f2a2}),_0x1134c1['counts']['agents']['total']++;if(_0x3f69f7)_0x1134c1[_0x16c888(0x1e4)]['agents'][_0x16c888(0x160)]++;else{if(_0x17bd03)_0x1134c1[_0x16c888(0x1e4)][_0x16c888(0x1a6)][_0x16c888(0x189)]++;else _0x1134c1[_0x16c888(0x1e4)][_0x16c888(0x1a6)]['unchanged']++;}}for(const _0x1bb5aa of _0x5bbcea){if(_0x1bb5aa[_0x16c888(0x181)][_0x16c888(0x1b2)])continue;const _0x3796b1=_0x362cd5['getUniqueName'](_0x1bb5aa[_0x16c888(0x181)][_0x16c888(0x1d3)]),_0x32bb07=a87_0x1a4aec[_0x16c888(0x17d)](getKnowledgeBasesDir(_0x5d8fbb),_0x3796b1+'.yml'),_0xee3bf1=apiKnowledgeBaseToYaml(_0x1bb5aa),_0x554cec=toKnowledgeBaseYamlString(_0xee3bf1),_0x18642f=!a87_0x4028a9[_0x16c888(0x1cf)](_0x32bb07);let _0x348cc3=_0x18642f,_0x39e2ae;if(!_0x18642f){const _0x4622ad=a87_0x4028a9['readFileSync'](_0x32bb07,_0x16c888(0x13b)),_0x3b0cf4=generateDiff(_0x4622ad,_0x554cec);_0x348cc3=hasChanges(_0x3b0cf4),_0x348cc3&&(_0x39e2ae=formatDiffWithColors(_0x3b0cf4));}_0x315b46[_0x16c888(0x1a5)]({'path':_0x32bb07,'content':_0x554cec}),_0x1134c1[_0x16c888(0x1e9)][_0x16c888(0x1a5)]({'name':_0x1bb5aa[_0x16c888(0x181)][_0x16c888(0x1d3)],'outputPath':_0x32bb07,'isNew':_0x18642f,'hasChanges':_0x348cc3,'diff':_0x39e2ae}),_0x1134c1[_0x16c888(0x1e4)]['knowledgeBases'][_0x16c888(0x1bd)]++;if(_0x18642f)_0x1134c1[_0x16c888(0x1e4)]['knowledgeBases'][_0x16c888(0x160)]++;else{if(_0x348cc3)_0x1134c1[_0x16c888(0x1e4)][_0x16c888(0x1e9)][_0x16c888(0x189)]++;else _0x1134c1['counts'][_0x16c888(0x1e9)][_0x16c888(0x19a)]++;}}for(const _0x971d5 of _0x311676){if(_0x971d5[_0x16c888(0x181)][_0x16c888(0x1b2)])continue;const _0x51021a=_0xdb1924['getUniqueName'](_0x971d5['attributes'][_0x16c888(0x1d3)]),_0x2b7734=a87_0x1a4aec[_0x16c888(0x17d)](getKnowledgeBasesDir(_0x5d8fbb),_0x51021a+'.md'),_0x30f67c=toTextKnowledgeBaseMd(_0x971d5[_0x16c888(0x181)][_0x16c888(0x1d3)],_0x971d5[_0x16c888(0x181)][_0x16c888(0x193)]),_0x5c10e5=!a87_0x4028a9[_0x16c888(0x1cf)](_0x2b7734);let _0x39bb65=_0x5c10e5,_0x47b09b;if(!_0x5c10e5){const _0x27303d=a87_0x4028a9[_0x16c888(0x1d1)](_0x2b7734,_0x16c888(0x13b)),_0x135068=generateDiff(_0x27303d,_0x30f67c);_0x39bb65=hasChanges(_0x135068),_0x39bb65&&(_0x47b09b=formatDiffWithColors(_0x135068));}_0x315b46[_0x16c888(0x1a5)]({'path':_0x2b7734,'content':_0x30f67c}),_0x1134c1['textKnowledgeBases']['push']({'name':_0x971d5[_0x16c888(0x181)][_0x16c888(0x1d3)],'outputPath':_0x2b7734,'isNew':_0x5c10e5,'hasChanges':_0x39bb65,'diff':_0x47b09b}),_0x1134c1[_0x16c888(0x1e4)][_0x16c888(0x133)][_0x16c888(0x1bd)]++;if(_0x5c10e5)_0x1134c1[_0x16c888(0x1e4)][_0x16c888(0x133)]['new']++;else{if(_0x39bb65)_0x1134c1[_0x16c888(0x1e4)][_0x16c888(0x133)][_0x16c888(0x189)]++;else _0x1134c1['counts'][_0x16c888(0x133)][_0x16c888(0x19a)]++;}}for(const _0x24b09a of _0x1197dd){if(_0x24b09a[_0x16c888(0x181)][_0x16c888(0x1b2)])continue;const _0x27b660=_0x314e77[_0x16c888(0x1ee)](_0x24b09a[_0x16c888(0x181)][_0x16c888(0x1d3)]),_0x2c4516=a87_0x1a4aec[_0x16c888(0x17d)](getPromptsDir(_0x5d8fbb),_0x27b660+_0x16c888(0x11e)),_0x502767=await apiPromptToYaml(_0x24b09a,_0x3240fe);if(!_0x502767)continue;const _0x3a0cde=toPromptYamlString(_0x502767),_0x22449e=!a87_0x4028a9[_0x16c888(0x1cf)](_0x2c4516);let _0x5682a8=_0x22449e,_0x5636cf;if(!_0x22449e){const _0x5cb9f6=a87_0x4028a9[_0x16c888(0x1d1)](_0x2c4516,_0x16c888(0x13b)),_0x3748a3=generateDiff(_0x5cb9f6,_0x3a0cde);_0x5682a8=hasChanges(_0x3748a3),_0x5682a8&&(_0x5636cf=formatDiffWithColors(_0x3748a3));}_0x315b46[_0x16c888(0x1a5)]({'path':_0x2c4516,'content':_0x3a0cde}),_0x1134c1['prompts'][_0x16c888(0x1a5)]({'name':_0x24b09a[_0x16c888(0x181)]['name'],'outputPath':_0x2c4516,'isNew':_0x22449e,'hasChanges':_0x5682a8,'diff':_0x5636cf}),_0x1134c1[_0x16c888(0x1e4)][_0x16c888(0x16d)][_0x16c888(0x1bd)]++;if(_0x22449e)_0x1134c1[_0x16c888(0x1e4)][_0x16c888(0x16d)]['new']++;else{if(_0x5682a8)_0x1134c1[_0x16c888(0x1e4)][_0x16c888(0x16d)]['updated']++;else _0x1134c1[_0x16c888(0x1e4)]['prompts'][_0x16c888(0x19a)]++;}}if(_0x9006c1?.['dryRun'])return _0x1134c1;a87_0x4028a9[_0x16c888(0x1e2)](_0x5d8fbb,{'recursive':!![]}),a87_0x4028a9[_0x16c888(0x1e2)](getKnowledgeBasesDir(_0x5d8fbb),{'recursive':!![]}),a87_0x4028a9[_0x16c888(0x1e2)](getPromptsDir(_0x5d8fbb),{'recursive':!![]});const _0x30100b=a87_0x1a4aec[_0x16c888(0x17d)](_0x5d8fbb,_0x16c888(0x18f));a87_0x4028a9[_0x16c888(0x174)](_0x30100b,createAgentConfigContent(_0x1e7f61));for(const _0x27406b of _0x315b46){if(_0x27406b[_0x16c888(0x1c4)])a87_0x4028a9[_0x16c888(0x1e2)](_0x27406b['path'],{'recursive':!![]});else{const _0x1258c9=a87_0x1a4aec[_0x16c888(0x12c)](_0x27406b['path']);!a87_0x4028a9['existsSync'](_0x1258c9)&&a87_0x4028a9['mkdirSync'](_0x1258c9,{'recursive':!![]}),a87_0x4028a9[_0x16c888(0x174)](_0x27406b[_0x16c888(0x197)],_0x27406b['content']);}}return _0x1134c1;}async[a87_0x13fc72(0x157)](_0x571a7a,_0x3b815f){const _0x3576ff=a87_0x13fc72,_0x43a953=a87_0x1a4aec['join'](_0x571a7a,'tdx.json');if(!a87_0x4028a9[_0x3576ff(0x1cf)](_0x43a953))throw new SDKError(ErrorCode[_0x3576ff(0x1a3)],'No\x20tdx.json\x20found\x20in\x20'+_0x571a7a,undefined,{'helpText':_0x3576ff(0x172)});const _0x4d3b9d=loadAgentConfig(_0x43a953),_0x554118=await this[_0x3576ff(0x183)](_0x4d3b9d[_0x3576ff(0x15d)]),_0x9998d9=await this[_0x3576ff(0x1ae)][_0x3576ff(0x147)](_0x554118),_0x446252=_0x9998d9['attributes'][_0x3576ff(0x1d3)],_0x150c2c={'projectName':_0x446252,'projectId':_0x554118,'agents':[],'knowledgeBases':[],'textKnowledgeBases':[],'prompts':[],'counts':{'agents':{'created':0x0,'updated':0x0,'unchanged':0x0,'errors':0x0},'knowledgeBases':{'created':0x0,'updated':0x0,'unchanged':0x0,'errors':0x0},'textKnowledgeBases':{'created':0x0,'updated':0x0,'unchanged':0x0,'errors':0x0},'prompts':{'created':0x0,'updated':0x0,'unchanged':0x0,'errors':0x0}}},_0x2df561=[],_0x433aff=[],_0x5c0f75=[],_0xd77351=[],_0x4a9b4d=a87_0x4028a9['readdirSync'](_0x571a7a,{'withFileTypes':!![]});for(const _0x523dec of _0x4a9b4d){if(!_0x523dec['isDirectory']())continue;if([_0x3576ff(0x161),'prompts',_0x3576ff(0x16f)][_0x3576ff(0x1bf)](_0x523dec['name']))continue;const _0x5badc1=a87_0x1a4aec['join'](_0x571a7a,_0x523dec[_0x3576ff(0x1d3)]);if(isAgentDir(_0x5badc1)){const _0x1d55de=a87_0x1a4aec['join'](_0x5badc1,'agent.yml'),_0x4b452a=a87_0x1a4aec['join'](_0x5badc1,_0x3576ff(0x144)),_0x2a37d5=a87_0x1a4aec[_0x3576ff(0x17d)](_0x5badc1,'starter_message.md'),_0x477d61=parseAgentYaml(a87_0x4028a9[_0x3576ff(0x1d1)](_0x1d55de,_0x3576ff(0x13b)),_0x1d55de),_0x5b19dc=a87_0x4028a9[_0x3576ff(0x1cf)](_0x4b452a)?a87_0x4028a9[_0x3576ff(0x1d1)](_0x4b452a,_0x3576ff(0x13b)):'',_0x2130b6=a87_0x4028a9[_0x3576ff(0x1cf)](_0x2a37d5)?a87_0x4028a9[_0x3576ff(0x1d1)](_0x2a37d5,'utf-8'):_0x477d61[_0x3576ff(0x139)];_0x2df561[_0x3576ff(0x1a5)]({'name':_0x477d61[_0x3576ff(0x1d3)],'dir':_0x5badc1,'yaml':_0x477d61,'systemPrompt':_0x5b19dc,'starterMessage':_0x2130b6});}}const _0x5d208d=getKnowledgeBasesDir(_0x571a7a);if(a87_0x4028a9[_0x3576ff(0x1cf)](_0x5d208d)){const _0x5eb1c9=a87_0x4028a9['readdirSync'](_0x5d208d);for(const _0xcce177 of _0x5eb1c9){const _0x284f46=a87_0x1a4aec[_0x3576ff(0x17d)](_0x5d208d,_0xcce177);if(_0xcce177['endsWith'](_0x3576ff(0x11e))){const _0x5a45ac=parseKnowledgeBaseYaml(a87_0x4028a9[_0x3576ff(0x1d1)](_0x284f46,_0x3576ff(0x13b)),_0x284f46);_0x433aff[_0x3576ff(0x1a5)]({'name':_0x5a45ac[_0x3576ff(0x1d3)],'path':_0x284f46,'yaml':_0x5a45ac});}else{if(_0xcce177[_0x3576ff(0x19d)](_0x3576ff(0x156))){const _0x11e3ac=a87_0x4028a9[_0x3576ff(0x1d1)](_0x284f46,_0x3576ff(0x13b)),{name:_0x270396,text:_0x1f4cc9}=parseTextKnowledgeBaseMd(_0x11e3ac,_0xcce177);_0x5c0f75['push']({'name':_0x270396,'path':_0x284f46,'text':_0x1f4cc9});}}}}const _0x152df2=getPromptsDir(_0x571a7a);if(a87_0x4028a9['existsSync'](_0x152df2)){const _0x4902e0=a87_0x4028a9[_0x3576ff(0x13a)](_0x152df2)[_0x3576ff(0x1ec)](_0x1a714c=>_0x1a714c[_0x3576ff(0x19d)]('.yml'));for(const _0x38b948 of _0x4902e0){const _0x58f068=a87_0x1a4aec['join'](_0x152df2,_0x38b948),_0x52324d=parsePromptYaml(a87_0x4028a9['readFileSync'](_0x58f068,'utf-8'),_0x58f068);_0xd77351['push']({'name':_0x52324d[_0x3576ff(0x1d3)],'path':_0x58f068,'yaml':_0x52324d});}}const _0x5da371=await this[_0x3576ff(0x1ae)][_0x3576ff(0x1dd)](_0x554118),_0x5e44eb=await this[_0x3576ff(0x1ae)][_0x3576ff(0x19b)](_0x554118),_0x2b5718=await this[_0x3576ff(0x1ae)][_0x3576ff(0x1ab)](_0x554118),_0x2eb160=await this['client'][_0x3576ff(0x1e1)](_0x554118),_0x20217d=await this['client'][_0x3576ff(0x17e)](_0x554118),_0x50d45d=await this[_0x3576ff(0x1ae)][_0x3576ff(0x122)](_0x554118),_0x16efd4=new Map(),_0x59996b=new Map(),_0x4259d4=new Map(),_0x130bb6=new Map();for(const _0x5e2bb7 of _0x5da371){_0x16efd4[_0x3576ff(0x132)](_0x5e2bb7[_0x3576ff(0x181)]['name'],_0x5e2bb7);}for(const _0x22cb42 of _0x5e44eb){_0x59996b[_0x3576ff(0x132)](_0x22cb42[_0x3576ff(0x181)][_0x3576ff(0x1d3)],_0x22cb42);}for(const _0x35dd1c of _0x2b5718){_0x4259d4[_0x3576ff(0x132)](_0x35dd1c[_0x3576ff(0x181)]['name'],_0x35dd1c);}for(const _0x24782a of _0x50d45d){_0x130bb6['set'](_0x24782a[_0x3576ff(0x181)]['name'],_0x24782a);}const _0x33cc36=new Map(),_0x3fce32=new Map(),_0x146431=new Map(),_0x1dcf40=new Map(),_0x17e914=new Map(),_0x577133=new Map(),_0x34e3b8=new Map(),_0x410e97=new Map(),_0x524702=new Map(),_0x3c68a8=new Map(),_0x177a9f=new Map(),_0x499205=new Map();for(const _0x318f17 of _0x5e44eb){_0x33cc36[_0x3576ff(0x132)](_0x318f17[_0x3576ff(0x181)]['name'],_0x318f17['id']),_0x34e3b8[_0x3576ff(0x132)](_0x318f17['id'],_0x318f17['attributes'][_0x3576ff(0x1d3)]);}for(const _0x65b836 of _0x2b5718){_0x3fce32[_0x3576ff(0x132)](_0x65b836[_0x3576ff(0x181)]['name'],_0x65b836['id']),_0x410e97[_0x3576ff(0x132)](_0x65b836['id'],_0x65b836[_0x3576ff(0x181)][_0x3576ff(0x1d3)]);}for(const _0x51b25b of _0x5da371){_0x146431[_0x3576ff(0x132)](_0x51b25b[_0x3576ff(0x181)][_0x3576ff(0x1d3)],_0x51b25b['id']),_0x524702[_0x3576ff(0x132)](_0x51b25b['id'],_0x51b25b[_0x3576ff(0x181)][_0x3576ff(0x1d3)]);}for(const _0x2ec0fe of _0x2eb160){_0x1dcf40[_0x3576ff(0x132)](_0x2ec0fe[_0x3576ff(0x181)]['name'],_0x2ec0fe['id']),_0x3c68a8[_0x3576ff(0x132)](_0x2ec0fe['id'],_0x2ec0fe['attributes'][_0x3576ff(0x1d3)]);}for(const _0x538c63 of _0x20217d){_0x17e914[_0x3576ff(0x132)](_0x538c63['attributes']['name'],_0x538c63['id']),_0x177a9f['set'](_0x538c63['id'],_0x538c63[_0x3576ff(0x181)]['name']);}for(const _0x3f3c27 of _0x50d45d){_0x577133['set'](_0x3f3c27[_0x3576ff(0x181)][_0x3576ff(0x1d3)],_0x3f3c27['id']),_0x499205['set'](_0x3f3c27['id'],_0x3f3c27[_0x3576ff(0x181)]['name']);}const _0x4c977a={'resolveKnowledgeBaseName':async _0x4727e4=>_0x34e3b8[_0x3576ff(0x127)](_0x4727e4),'resolveTextKnowledgeBaseName':async _0x471f2c=>_0x410e97[_0x3576ff(0x127)](_0x471f2c),'resolveAgentName':async _0x43e036=>_0x524702['get'](_0x43e036),'resolveWebSearchToolName':async _0x27fa71=>_0x177a9f['get'](_0x27fa71),'resolveImageGeneratorName':async _0x5f5dac=>_0x3c68a8['get'](_0x5f5dac),'resolvePromptName':async _0x529506=>_0x499205[_0x3576ff(0x127)](_0x529506),'onWarning':_0x2e37e7=>this[_0x3576ff(0x169)][_0x3576ff(0x1db)]?.[_0x3576ff(0x11c)](_0x2e37e7)},_0x3fce6f={'projectId':_0x554118,'resolveKnowledgeBaseId':async _0x343982=>_0x33cc36[_0x3576ff(0x127)](_0x343982),'resolveTextKnowledgeBaseId':async _0xdbaf4a=>_0x3fce32['get'](_0xdbaf4a),'resolveAgentId':async _0x4c3773=>_0x146431[_0x3576ff(0x127)](_0x4c3773),'resolveWebSearchToolId':async _0x2576a6=>_0x17e914[_0x3576ff(0x127)](_0x2576a6),'resolveImageGeneratorId':async _0x58ce4a=>_0x1dcf40[_0x3576ff(0x127)](_0x58ce4a),'resolvePromptId':async _0x34bbb3=>_0x577133[_0x3576ff(0x127)](_0x34bbb3),'onWarning':_0x421453=>this[_0x3576ff(0x169)][_0x3576ff(0x1db)]?.['warn'](_0x421453)},{resolved:_0x2cdf13,unresolved:_0x3c738f}=resolveAgentDependencies(_0x2df561,new Set(_0x16efd4['keys']()));for(const {agent:_0x201fd0,missingDeps:_0x5a6b0e}of _0x3c738f){_0x150c2c[_0x3576ff(0x1a6)][_0x3576ff(0x1a5)]({'agentName':_0x201fd0[_0x3576ff(0x177)][_0x3576ff(0x1d3)],'action':_0x3576ff(0x126),'error':'Unresolved\x20dependencies:\x20'+_0x5a6b0e[_0x3576ff(0x17d)](',\x20')+_0x3576ff(0x182)}),_0x150c2c[_0x3576ff(0x1e4)]['agents'][_0x3576ff(0x1b9)]++;}for(const _0x450e8a of _0x433aff){const _0x3314ae=_0x59996b[_0x3576ff(0x127)](_0x450e8a[_0x3576ff(0x177)][_0x3576ff(0x1d3)]),_0x4bce2d=a87_0x4028a9[_0x3576ff(0x1d1)](_0x450e8a[_0x3576ff(0x197)],_0x3576ff(0x13b));if(_0x3314ae){const _0x331497=apiKnowledgeBaseToYaml(_0x3314ae),_0x4bc502=toKnowledgeBaseYamlString(_0x331497),_0x590bcc=generateDiff(_0x4bc502,_0x4bce2d),_0x377e0e=hasChanges(_0x590bcc);_0x377e0e?(_0x150c2c[_0x3576ff(0x1e9)][_0x3576ff(0x1a5)]({'name':_0x450e8a[_0x3576ff(0x177)]['name'],'action':_0x3576ff(0x189),'id':_0x3314ae['id'],'diff':formatDiffWithColors(_0x590bcc)}),_0x150c2c[_0x3576ff(0x1e4)][_0x3576ff(0x1e9)]['updated']++):(_0x150c2c[_0x3576ff(0x1e9)][_0x3576ff(0x1a5)]({'name':_0x450e8a[_0x3576ff(0x177)][_0x3576ff(0x1d3)],'action':_0x3576ff(0x19a),'id':_0x3314ae['id']}),_0x150c2c['counts'][_0x3576ff(0x1e9)][_0x3576ff(0x19a)]++);}else _0x150c2c[_0x3576ff(0x1e9)][_0x3576ff(0x1a5)]({'name':_0x450e8a[_0x3576ff(0x177)][_0x3576ff(0x1d3)],'action':_0x3576ff(0x11f)}),_0x150c2c[_0x3576ff(0x1e4)]['knowledgeBases'][_0x3576ff(0x11f)]++;}for(const _0x26010d of _0x5c0f75){const _0x2c6e18=_0x4259d4[_0x3576ff(0x127)](_0x26010d[_0x3576ff(0x1d3)]),_0xbe4a4d=a87_0x4028a9[_0x3576ff(0x1d1)](_0x26010d[_0x3576ff(0x197)],'utf-8');if(_0x2c6e18){const _0x297e5c=toTextKnowledgeBaseMd(_0x2c6e18[_0x3576ff(0x181)][_0x3576ff(0x1d3)],_0x2c6e18[_0x3576ff(0x181)][_0x3576ff(0x193)]),_0x4b9f1c=generateDiff(_0x297e5c,_0xbe4a4d),_0x35b780=hasChanges(_0x4b9f1c);_0x35b780?(_0x150c2c['textKnowledgeBases'][_0x3576ff(0x1a5)]({'name':_0x26010d[_0x3576ff(0x1d3)],'action':_0x3576ff(0x189),'id':_0x2c6e18['id'],'diff':formatDiffWithColors(_0x4b9f1c)}),_0x150c2c[_0x3576ff(0x1e4)][_0x3576ff(0x133)][_0x3576ff(0x189)]++):(_0x150c2c['textKnowledgeBases'][_0x3576ff(0x1a5)]({'name':_0x26010d[_0x3576ff(0x1d3)],'action':_0x3576ff(0x19a),'id':_0x2c6e18['id']}),_0x150c2c[_0x3576ff(0x1e4)][_0x3576ff(0x133)][_0x3576ff(0x19a)]++);}else _0x150c2c['textKnowledgeBases']['push']({'name':_0x26010d[_0x3576ff(0x1d3)],'action':_0x3576ff(0x11f)}),_0x150c2c['counts'][_0x3576ff(0x133)][_0x3576ff(0x11f)]++;}for(const _0x3ea796 of _0x2cdf13){const _0x4be928=_0x16efd4[_0x3576ff(0x127)](_0x3ea796[_0x3576ff(0x177)][_0x3576ff(0x1d3)]),_0x3bcdc4=a87_0x1a4aec[_0x3576ff(0x17d)](_0x3ea796['dir'],_0x3576ff(0x1da)),_0x322f27=a87_0x4028a9['readFileSync'](_0x3bcdc4,_0x3576ff(0x13b)),_0x2e32d7=_0x3ea796[_0x3576ff(0x168)],_0x5eacae=_0x3576ff(0x184)+_0x2e32d7+'\x0a\x0a#\x20agent.yml\x0a'+_0x322f27;if(_0x4be928){const {yaml:_0x2b11b6,systemPrompt:_0x2eaecb}=await agentResponseToDef(_0x4be928,_0x4c977a),_0x212625=toAgentYamlString(_0x2b11b6),_0x5a3aae=_0x3576ff(0x184)+_0x2eaecb+'\x0a\x0a#\x20agent.yml\x0a'+_0x212625,_0x53eaaa=generateDiff(_0x5a3aae,_0x5eacae),_0x583574=hasChanges(_0x53eaaa);_0x583574?(_0x150c2c[_0x3576ff(0x1a6)][_0x3576ff(0x1a5)]({'agentName':_0x3ea796[_0x3576ff(0x177)][_0x3576ff(0x1d3)],'action':_0x3576ff(0x189),'agentId':_0x4be928['id'],'diff':formatDiffWithColors(_0x53eaaa)}),_0x150c2c[_0x3576ff(0x1e4)][_0x3576ff(0x1a6)][_0x3576ff(0x189)]++):(_0x150c2c[_0x3576ff(0x1a6)][_0x3576ff(0x1a5)]({'agentName':_0x3ea796['yaml'][_0x3576ff(0x1d3)],'action':_0x3576ff(0x19a),'agentId':_0x4be928['id']}),_0x150c2c[_0x3576ff(0x1e4)][_0x3576ff(0x1a6)][_0x3576ff(0x19a)]++);}else _0x150c2c[_0x3576ff(0x1a6)][_0x3576ff(0x1a5)]({'agentName':_0x3ea796[_0x3576ff(0x177)]['name'],'action':_0x3576ff(0x11f)}),_0x150c2c[_0x3576ff(0x1e4)][_0x3576ff(0x1a6)][_0x3576ff(0x11f)]++;}for(const _0x393f9a of _0xd77351){const _0x2cc0c0=_0x130bb6['get'](_0x393f9a['yaml']['name']),_0x53cf8c=a87_0x4028a9['readFileSync'](_0x393f9a['path'],_0x3576ff(0x13b));if(_0x2cc0c0){const _0x4603cb=await apiPromptToYaml(_0x2cc0c0,_0x4c977a);if(!_0x4603cb){_0x150c2c[_0x3576ff(0x16d)][_0x3576ff(0x1a5)]({'name':_0x393f9a[_0x3576ff(0x177)]['name'],'action':'updated','id':_0x2cc0c0['id']}),_0x150c2c['counts']['prompts'][_0x3576ff(0x189)]++;continue;}const _0x819eb9=toPromptYamlString(_0x4603cb),_0x3a7945=generateDiff(_0x819eb9,_0x53cf8c),_0x54e237=hasChanges(_0x3a7945);_0x54e237?(_0x150c2c[_0x3576ff(0x16d)][_0x3576ff(0x1a5)]({'name':_0x393f9a[_0x3576ff(0x177)][_0x3576ff(0x1d3)],'action':_0x3576ff(0x189),'id':_0x2cc0c0['id'],'diff':formatDiffWithColors(_0x3a7945)}),_0x150c2c[_0x3576ff(0x1e4)][_0x3576ff(0x16d)]['updated']++):(_0x150c2c['prompts'][_0x3576ff(0x1a5)]({'name':_0x393f9a[_0x3576ff(0x177)][_0x3576ff(0x1d3)],'action':_0x3576ff(0x19a),'id':_0x2cc0c0['id']}),_0x150c2c[_0x3576ff(0x1e4)]['prompts'][_0x3576ff(0x19a)]++);}else _0x150c2c['prompts'][_0x3576ff(0x1a5)]({'name':_0x393f9a[_0x3576ff(0x177)][_0x3576ff(0x1d3)],'action':'created'}),_0x150c2c[_0x3576ff(0x1e4)][_0x3576ff(0x16d)][_0x3576ff(0x11f)]++;}if(_0x3b815f?.['dryRun'])return _0x150c2c;_0x150c2c[_0x3576ff(0x1e9)]=[],_0x150c2c[_0x3576ff(0x133)]=[],_0x150c2c[_0x3576ff(0x16d)]=[];const _0x31bacd=_0x150c2c[_0x3576ff(0x1a6)]['filter'](_0x3122bb=>_0x3122bb[_0x3576ff(0x1c8)]===_0x3576ff(0x126));_0x150c2c[_0x3576ff(0x1a6)]=_0x31bacd,_0x150c2c['counts']={'agents':{'created':0x0,'updated':0x0,'unchanged':0x0,'errors':_0x31bacd[_0x3576ff(0x134)]},'knowledgeBases':{'created':0x0,'updated':0x0,'unchanged':0x0,'errors':0x0},'textKnowledgeBases':{'created':0x0,'updated':0x0,'unchanged':0x0,'errors':0x0},'prompts':{'created':0x0,'updated':0x0,'unchanged':0x0,'errors':0x0}};for(const _0x8a7c27 of _0x433aff){try{const _0x1bad1d=_0x59996b[_0x3576ff(0x127)](_0x8a7c27[_0x3576ff(0x177)][_0x3576ff(0x1d3)]),_0x37e0ee=yamlKnowledgeBaseToApi(_0x8a7c27[_0x3576ff(0x177)],_0x554118);if(_0x1bad1d)await this['client'][_0x3576ff(0x120)](_0x1bad1d['id'],_0x37e0ee),_0x33cc36['set'](_0x8a7c27[_0x3576ff(0x177)]['name'],_0x1bad1d['id']),_0x150c2c[_0x3576ff(0x1e9)][_0x3576ff(0x1a5)]({'name':_0x8a7c27[_0x3576ff(0x177)][_0x3576ff(0x1d3)],'action':_0x3576ff(0x189),'id':_0x1bad1d['id']}),_0x150c2c[_0x3576ff(0x1e4)][_0x3576ff(0x1e9)][_0x3576ff(0x189)]++;else{const _0x290386=await this[_0x3576ff(0x1ae)][_0x3576ff(0x1c7)](_0x37e0ee);_0x33cc36[_0x3576ff(0x132)](_0x8a7c27[_0x3576ff(0x177)][_0x3576ff(0x1d3)],_0x290386['id']),_0x150c2c[_0x3576ff(0x1e9)][_0x3576ff(0x1a5)]({'name':_0x8a7c27['yaml'][_0x3576ff(0x1d3)],'action':_0x3576ff(0x11f),'id':_0x290386['id']}),_0x150c2c['counts'][_0x3576ff(0x1e9)][_0x3576ff(0x11f)]++;}}catch(_0x32b112){_0x150c2c[_0x3576ff(0x1e9)][_0x3576ff(0x1a5)]({'name':_0x8a7c27[_0x3576ff(0x177)][_0x3576ff(0x1d3)],'action':_0x3576ff(0x126),'error':_0x32b112[_0x3576ff(0x1ea)]}),_0x150c2c['counts'][_0x3576ff(0x1e9)][_0x3576ff(0x1b9)]++;}}for(const _0x5ba594 of _0x5c0f75){try{const _0x203e78=_0x4259d4['get'](_0x5ba594[_0x3576ff(0x1d3)]),_0x4d3e7e=yamlTextKnowledgeBaseToApi({'name':_0x5ba594[_0x3576ff(0x1d3)],'text':_0x5ba594[_0x3576ff(0x193)]},_0x554118);if(_0x203e78)await this[_0x3576ff(0x1ae)]['updateTextKnowledgeBase'](_0x203e78['id'],_0x4d3e7e),_0x3fce32[_0x3576ff(0x132)](_0x5ba594[_0x3576ff(0x1d3)],_0x203e78['id']),_0x150c2c[_0x3576ff(0x133)][_0x3576ff(0x1a5)]({'name':_0x5ba594[_0x3576ff(0x1d3)],'action':_0x3576ff(0x189),'id':_0x203e78['id']}),_0x150c2c[_0x3576ff(0x1e4)][_0x3576ff(0x133)][_0x3576ff(0x189)]++;else{const _0x47adae=await this['client'][_0x3576ff(0x1a1)](_0x4d3e7e);_0x3fce32[_0x3576ff(0x132)](_0x5ba594[_0x3576ff(0x1d3)],_0x47adae['id']),_0x150c2c[_0x3576ff(0x133)][_0x3576ff(0x1a5)]({'name':_0x5ba594[_0x3576ff(0x1d3)],'action':'created','id':_0x47adae['id']}),_0x150c2c[_0x3576ff(0x1e4)]['textKnowledgeBases'][_0x3576ff(0x11f)]++;}}catch(_0x133752){_0x150c2c[_0x3576ff(0x133)][_0x3576ff(0x1a5)]({'name':_0x5ba594['name'],'action':'error','error':_0x133752[_0x3576ff(0x1ea)]}),_0x150c2c[_0x3576ff(0x1e4)][_0x3576ff(0x133)][_0x3576ff(0x1b9)]++;}}for(const _0x2eb401 of _0x2cdf13){try{const _0x1145e4=_0x16efd4['get'](_0x2eb401[_0x3576ff(0x177)]['name']),_0x2d4d2e=await agentDefToRequest(_0x2eb401[_0x3576ff(0x177)],_0x2eb401[_0x3576ff(0x168)],_0x2eb401[_0x3576ff(0x1f7)],_0x3fce6f);if(_0x1145e4)await this[_0x3576ff(0x1ae)][_0x3576ff(0x175)](_0x1145e4['id'],_0x2d4d2e),_0x146431[_0x3576ff(0x132)](_0x2eb401['yaml'][_0x3576ff(0x1d3)],_0x1145e4['id']),_0x150c2c['agents'][_0x3576ff(0x1a5)]({'agentName':_0x2eb401[_0x3576ff(0x177)][_0x3576ff(0x1d3)],'action':_0x3576ff(0x189),'agentId':_0x1145e4['id']}),_0x150c2c[_0x3576ff(0x1e4)][_0x3576ff(0x1a6)][_0x3576ff(0x189)]++;else{const _0x269848=await this[_0x3576ff(0x1ae)][_0x3576ff(0x1ba)](_0x2d4d2e);_0x146431[_0x3576ff(0x132)](_0x2eb401[_0x3576ff(0x177)][_0x3576ff(0x1d3)],_0x269848['id']),_0x150c2c[_0x3576ff(0x1a6)][_0x3576ff(0x1a5)]({'agentName':_0x2eb401[_0x3576ff(0x177)][_0x3576ff(0x1d3)],'action':_0x3576ff(0x11f),'agentId':_0x269848['id']}),_0x150c2c['counts'][_0x3576ff(0x1a6)][_0x3576ff(0x11f)]++;}}catch(_0xe26487){_0x150c2c['agents'][_0x3576ff(0x1a5)]({'agentName':_0x2eb401[_0x3576ff(0x177)][_0x3576ff(0x1d3)],'action':'error','error':_0xe26487[_0x3576ff(0x1ea)]}),_0x150c2c[_0x3576ff(0x1e4)][_0x3576ff(0x1a6)][_0x3576ff(0x1b9)]++;}}for(const _0x113bd7 of _0xd77351){try{const _0x481a2a=_0x130bb6[_0x3576ff(0x127)](_0x113bd7[_0x3576ff(0x177)]['name']),_0x1c539f=await yamlPromptToApi(_0x113bd7[_0x3576ff(0x177)],_0x554118,_0x3fce6f);if(!_0x1c539f){_0x150c2c[_0x3576ff(0x16d)][_0x3576ff(0x1a5)]({'name':_0x113bd7[_0x3576ff(0x177)][_0x3576ff(0x1d3)],'action':_0x3576ff(0x126),'error':_0x3576ff(0x176)}),_0x150c2c[_0x3576ff(0x1e4)]['prompts'][_0x3576ff(0x1b9)]++;continue;}if(_0x481a2a)await this['client'][_0x3576ff(0x178)](_0x481a2a['id'],_0x1c539f),_0x577133[_0x3576ff(0x132)](_0x113bd7[_0x3576ff(0x177)][_0x3576ff(0x1d3)],_0x481a2a['id']),_0x150c2c['prompts'][_0x3576ff(0x1a5)]({'name':_0x113bd7[_0x3576ff(0x177)][_0x3576ff(0x1d3)],'action':_0x3576ff(0x189),'id':_0x481a2a['id']}),_0x150c2c['counts'][_0x3576ff(0x16d)][_0x3576ff(0x189)]++;else{const _0x1ddd3b=await this[_0x3576ff(0x1ae)][_0x3576ff(0x128)](_0x1c539f);_0x577133[_0x3576ff(0x132)](_0x113bd7[_0x3576ff(0x177)][_0x3576ff(0x1d3)],_0x1ddd3b['id']),_0x150c2c[_0x3576ff(0x16d)][_0x3576ff(0x1a5)]({'name':_0x113bd7[_0x3576ff(0x177)][_0x3576ff(0x1d3)],'action':'created','id':_0x1ddd3b['id']}),_0x150c2c[_0x3576ff(0x1e4)]['prompts'][_0x3576ff(0x11f)]++;}}catch(_0x668e1b){_0x150c2c['prompts'][_0x3576ff(0x1a5)]({'name':_0x113bd7[_0x3576ff(0x177)][_0x3576ff(0x1d3)],'action':_0x3576ff(0x126),'error':_0x668e1b[_0x3576ff(0x1ea)]}),_0x150c2c['counts']['prompts'][_0x3576ff(0x1b9)]++;}}return _0x150c2c;}async[a87_0x13fc72(0x1cc)](_0x1bcbfb,_0x17f119,_0x1a4861,_0x1d09a8){const _0x3c6720=a87_0x13fc72,{projectId:_0x53d5e9,project:_0x30b36b}=await this[_0x3c6720(0x17c)](_0x1bcbfb),_0x47fbc3=_0x30b36b[_0x3c6720(0x181)][_0x3c6720(0x1d3)],_0x150700=await this[_0x3c6720(0x1ae)][_0x3c6720(0x1dd)](_0x53d5e9),_0x4e15a4=_0x150700['find'](_0x56e0be=>_0x56e0be[_0x3c6720(0x181)][_0x3c6720(0x1d3)]===_0x17f119);if(!_0x4e15a4)throw new SDKError(ErrorCode[_0x3c6720(0x180)],_0x3c6720(0x140)+_0x17f119,undefined,{'helpText':_0x3c6720(0x13d)+_0x150700['map'](_0x3b46c0=>_0x3b46c0['attributes'][_0x3c6720(0x1d3)])[_0x3c6720(0x17d)](',\x20')});const _0x56eeca=normalizeName(_0x47fbc3),_0x35d6d9=normalizeName(_0x17f119),_0x378992=_0x1a4861||a87_0x1a4aec[_0x3c6720(0x17d)](process[_0x3c6720(0x152)](),_0x3c6720(0x1a6),_0x56eeca),_0x3dce3d=a87_0x1a4aec[_0x3c6720(0x17d)](_0x378992,_0x35d6d9),_0x50347e=new Map(),_0x380a48=new Map(),_0x5ebdcd=await this[_0x3c6720(0x1ae)][_0x3c6720(0x19b)](_0x53d5e9),_0x318341=await this['client']['listTextKnowledgeBases'](_0x53d5e9),_0x295a86=new Map();for(const _0x33e218 of _0x5ebdcd){_0x50347e[_0x3c6720(0x132)](_0x33e218['id'],_0x33e218[_0x3c6720(0x181)][_0x3c6720(0x1d3)]);}for(const _0x189161 of _0x318341){_0x295a86[_0x3c6720(0x132)](_0x189161['id'],_0x189161[_0x3c6720(0x181)]['name']);}for(const _0x2b54c1 of _0x150700){_0x380a48[_0x3c6720(0x132)](_0x2b54c1['id'],_0x2b54c1[_0x3c6720(0x181)][_0x3c6720(0x1d3)]);}const _0x1ba620={'resolveKnowledgeBaseName':async _0x4451c7=>_0x50347e[_0x3c6720(0x127)](_0x4451c7),'resolveTextKnowledgeBaseName':async _0x37df35=>_0x295a86[_0x3c6720(0x127)](_0x37df35),'resolveAgentName':async _0x5d96b8=>_0x380a48[_0x3c6720(0x127)](_0x5d96b8),'resolveWebSearchToolName':async()=>undefined,'resolveImageGeneratorName':async()=>undefined,'resolvePromptName':async()=>undefined,'onWarning':_0xe5c0f9=>this[_0x3c6720(0x169)][_0x3c6720(0x1db)]?.[_0x3c6720(0x11c)](_0xe5c0f9)},_0x12342e=a87_0x1a4aec[_0x3c6720(0x17d)](_0x3dce3d,'prompt.md'),_0x109e01=a87_0x1a4aec['join'](_0x3dce3d,'agent.yml'),_0x473b75=a87_0x1a4aec['join'](_0x3dce3d,'starter_message.md'),_0x45d10f=!a87_0x4028a9[_0x3c6720(0x1cf)](_0x109e01);if(_0x1d09a8?.['dryRun'])return{'agentName':_0x17f119,'outputPath':_0x3dce3d,'isNew':_0x45d10f,'hasChanges':!![]};a87_0x4028a9[_0x3c6720(0x1e2)](_0x378992,{'recursive':!![]}),a87_0x4028a9['mkdirSync'](_0x3dce3d,{'recursive':!![]});const _0xaf8a97=a87_0x1a4aec['join'](_0x378992,_0x3c6720(0x18f));!a87_0x4028a9['existsSync'](_0xaf8a97)&&a87_0x4028a9[_0x3c6720(0x174)](_0xaf8a97,createAgentConfigContent(_0x1bcbfb));const {yaml:_0x57d838,systemPrompt:_0x4ad3a0,starterMessage:_0x23b169}=await agentResponseToDef(_0x4e15a4,_0x1ba620);let _0x4db405=_0x45d10f;if(!_0x45d10f){const _0x2f3ecb=a87_0x4028a9[_0x3c6720(0x1cf)](_0x12342e)?a87_0x4028a9[_0x3c6720(0x1d1)](_0x12342e,_0x3c6720(0x13b)):'',_0xdd247e=a87_0x4028a9[_0x3c6720(0x1d1)](_0x109e01,'utf-8');_0x4db405=_0x2f3ecb!==_0x4ad3a0||_0xdd247e!==toAgentYamlString(_0x57d838);}a87_0x4028a9['writeFileSync'](_0x12342e,_0x4ad3a0),a87_0x4028a9[_0x3c6720(0x174)](_0x109e01,toAgentYamlString(_0x57d838));if(_0x23b169&&_0x23b169[_0x3c6720(0x1bf)]('\x0a'))a87_0x4028a9['writeFileSync'](_0x473b75,_0x23b169);else a87_0x4028a9[_0x3c6720(0x1cf)](_0x473b75)&&a87_0x4028a9[_0x3c6720(0x14d)](_0x473b75);return{'agentName':_0x17f119,'outputPath':_0x3dce3d,'isNew':_0x45d10f,'hasChanges':_0x4db405};}async[a87_0x13fc72(0x1d0)](_0x53d4ff,_0x405947){const _0x4c8e72=a87_0x13fc72;let _0x18b0cf;isAgentYamlPath(_0x53d4ff)?_0x18b0cf=getAgentDirFromYamlPath(_0x53d4ff):_0x18b0cf=_0x53d4ff;const {config:_0x15e3ae}=findAgentConfig(_0x18b0cf),_0x949dfc=await this[_0x4c8e72(0x183)](_0x15e3ae['llm_project']),_0x1bc8a8=a87_0x1a4aec[_0x4c8e72(0x17d)](_0x18b0cf,_0x4c8e72(0x1da)),_0x50d04c=a87_0x1a4aec[_0x4c8e72(0x17d)](_0x18b0cf,_0x4c8e72(0x144)),_0x618bb7=a87_0x1a4aec[_0x4c8e72(0x17d)](_0x18b0cf,_0x4c8e72(0x1c5));if(!a87_0x4028a9['existsSync'](_0x1bc8a8))throw new SDKError(ErrorCode[_0x4c8e72(0x14b)],_0x4c8e72(0x1c6)+_0x18b0cf,undefined,{'helpText':_0x4c8e72(0x1cd)});const _0x57602e=parseAgentYaml(a87_0x4028a9[_0x4c8e72(0x1d1)](_0x1bc8a8,_0x4c8e72(0x13b)),_0x1bc8a8),_0x30bfeb=a87_0x4028a9['existsSync'](_0x50d04c)?a87_0x4028a9['readFileSync'](_0x50d04c,_0x4c8e72(0x13b)):'',_0xd99a35=a87_0x4028a9['existsSync'](_0x618bb7)?a87_0x4028a9[_0x4c8e72(0x1d1)](_0x618bb7,_0x4c8e72(0x13b)):_0x57602e[_0x4c8e72(0x139)];if(_0x405947?.[_0x4c8e72(0x1b4)])return{'agentName':_0x57602e[_0x4c8e72(0x1d3)],'action':_0x4c8e72(0x11f),'projectId':_0x949dfc};const _0x48ca91=await this[_0x4c8e72(0x1ae)][_0x4c8e72(0x1dd)](_0x949dfc),_0x32505c=await this[_0x4c8e72(0x1ae)][_0x4c8e72(0x19b)](_0x949dfc),_0x47e874=await this[_0x4c8e72(0x1ae)][_0x4c8e72(0x1ab)](_0x949dfc),_0x2a344e=new Map(),_0x4ec6f7=new Map(),_0x1f8c89=new Map();for(const _0x2274c2 of _0x32505c){_0x2a344e[_0x4c8e72(0x132)](_0x2274c2[_0x4c8e72(0x181)]['name'],_0x2274c2['id']);}for(const _0x3fdc48 of _0x47e874){_0x4ec6f7['set'](_0x3fdc48['attributes']['name'],_0x3fdc48['id']);}for(const _0x5cbf6c of _0x48ca91){_0x1f8c89[_0x4c8e72(0x132)](_0x5cbf6c[_0x4c8e72(0x181)][_0x4c8e72(0x1d3)],_0x5cbf6c['id']);}const _0x421f80={'projectId':_0x949dfc,'resolveKnowledgeBaseId':async _0x2ceb8c=>_0x2a344e[_0x4c8e72(0x127)](_0x2ceb8c),'resolveTextKnowledgeBaseId':async _0x357347=>_0x4ec6f7[_0x4c8e72(0x127)](_0x357347),'resolveAgentId':async _0x48cbe8=>_0x1f8c89[_0x4c8e72(0x127)](_0x48cbe8),'resolveWebSearchToolId':async()=>undefined,'resolveImageGeneratorId':async()=>undefined,'resolvePromptId':async()=>undefined,'onWarning':_0x5c9d6c=>this[_0x4c8e72(0x169)][_0x4c8e72(0x1db)]?.[_0x4c8e72(0x11c)](_0x5c9d6c)};try{const _0x27b2c7=_0x48ca91['find'](_0x20684b=>_0x20684b[_0x4c8e72(0x181)][_0x4c8e72(0x1d3)]===_0x57602e[_0x4c8e72(0x1d3)]),_0x3c27a8=await agentDefToRequest(_0x57602e,_0x30bfeb,_0xd99a35,_0x421f80);if(_0x27b2c7)return await this[_0x4c8e72(0x1ae)][_0x4c8e72(0x175)](_0x27b2c7['id'],_0x3c27a8),{'agentName':_0x57602e['name'],'action':_0x4c8e72(0x189),'projectId':_0x949dfc,'agentId':_0x27b2c7['id']};else{const _0x43dcce=await this[_0x4c8e72(0x1ae)][_0x4c8e72(0x1ba)](_0x3c27a8);return{'agentName':_0x57602e[_0x4c8e72(0x1d3)],'action':_0x4c8e72(0x11f),'projectId':_0x949dfc,'agentId':_0x43dcce['id']};}}catch(_0x5e8dbe){return{'agentName':_0x57602e[_0x4c8e72(0x1d3)],'action':_0x4c8e72(0x126),'projectId':_0x949dfc,'error':_0x5e8dbe[_0x4c8e72(0x1ea)]};}}async['cloneProject'](_0x2725e7,_0x164426,_0x5ee67d){const _0x17ad40=a87_0x13fc72,_0x1b92b8=a87_0x4028a9[_0x17ad40(0x1cf)](_0x2725e7)&&a87_0x4028a9[_0x17ad40(0x1cf)](a87_0x1a4aec[_0x17ad40(0x17d)](_0x2725e7,'tdx.json'));let _0x221303;const _0x19cfb7=[],_0x2f1cec=[],_0x3fc00f=[],_0x4b7f1f=[];if(_0x1b92b8){const _0x3ce93e=loadAgentConfig(a87_0x1a4aec[_0x17ad40(0x17d)](_0x2725e7,_0x17ad40(0x18f)));_0x221303=_0x3ce93e[_0x17ad40(0x15d)];const _0x5874e4=a87_0x4028a9[_0x17ad40(0x13a)](_0x2725e7,{'withFileTypes':!![]});for(const _0xd2585 of _0x5874e4){if(!_0xd2585[_0x17ad40(0x1b6)]())continue;if([_0x17ad40(0x161),'prompts',_0x17ad40(0x16f)][_0x17ad40(0x1bf)](_0xd2585['name']))continue;const _0x290066=a87_0x1a4aec[_0x17ad40(0x17d)](_0x2725e7,_0xd2585[_0x17ad40(0x1d3)]);if(isAgentDir(_0x290066)){const _0x315623=a87_0x1a4aec[_0x17ad40(0x17d)](_0x290066,_0x17ad40(0x1da)),_0x46f946=a87_0x1a4aec[_0x17ad40(0x17d)](_0x290066,_0x17ad40(0x144)),_0x288d21=a87_0x1a4aec[_0x17ad40(0x17d)](_0x290066,'starter_message.md'),_0x45bd7c=parseAgentYaml(a87_0x4028a9[_0x17ad40(0x1d1)](_0x315623,_0x17ad40(0x13b)),_0x315623),_0x247f06=a87_0x4028a9[_0x17ad40(0x1cf)](_0x46f946)?a87_0x4028a9[_0x17ad40(0x1d1)](_0x46f946,_0x17ad40(0x13b)):'',_0x28328f=a87_0x4028a9[_0x17ad40(0x1cf)](_0x288d21)?a87_0x4028a9[_0x17ad40(0x1d1)](_0x288d21,_0x17ad40(0x13b)):_0x45bd7c['starter_message'];_0x19cfb7[_0x17ad40(0x1a5)]({'name':_0x45bd7c['name'],'dir':_0x290066,'yaml':_0x45bd7c,'systemPrompt':_0x247f06,'starterMessage':_0x28328f});}}const _0x305ea9=getKnowledgeBasesDir(_0x2725e7);if(a87_0x4028a9[_0x17ad40(0x1cf)](_0x305ea9)){const _0x27ba38=a87_0x4028a9['readdirSync'](_0x305ea9);for(const _0x5977ca of _0x27ba38){const _0x3d4beb=a87_0x1a4aec[_0x17ad40(0x17d)](_0x305ea9,_0x5977ca);if(_0x5977ca[_0x17ad40(0x19d)](_0x17ad40(0x11e))){const _0x4a5d9b=parseKnowledgeBaseYaml(a87_0x4028a9['readFileSync'](_0x3d4beb,_0x17ad40(0x13b)),_0x3d4beb);_0x2f1cec[_0x17ad40(0x1a5)]({'name':_0x4a5d9b[_0x17ad40(0x1d3)],'path':_0x3d4beb,'yaml':_0x4a5d9b});}else{if(_0x5977ca['endsWith']('.md')){const _0x3e6b8f=a87_0x4028a9[_0x17ad40(0x1d1)](_0x3d4beb,_0x17ad40(0x13b)),{name:_0x409195,text:_0x1b7195}=parseTextKnowledgeBaseMd(_0x3e6b8f,_0x5977ca);_0x3fc00f[_0x17ad40(0x1a5)]({'name':_0x409195,'path':_0x3d4beb,'text':_0x1b7195});}}}}const _0x2919ce=getPromptsDir(_0x2725e7);if(a87_0x4028a9['existsSync'](_0x2919ce)){const _0x35f6b9=a87_0x4028a9[_0x17ad40(0x13a)](_0x2919ce)[_0x17ad40(0x1ec)](_0x46c92e=>_0x46c92e[_0x17ad40(0x19d)](_0x17ad40(0x11e)));for(const _0x13381b of _0x35f6b9){const _0x30e1c2=a87_0x1a4aec[_0x17ad40(0x17d)](_0x2919ce,_0x13381b),_0x145d72=parsePromptYaml(a87_0x4028a9[_0x17ad40(0x1d1)](_0x30e1c2,_0x17ad40(0x13b)),_0x30e1c2);_0x4b7f1f[_0x17ad40(0x1a5)]({'name':_0x145d72[_0x17ad40(0x1d3)],'path':_0x30e1c2,'yaml':_0x145d72});}}}else{const _0x287b57=await this['resolveProjectId'](_0x2725e7),_0x24782c=await this[_0x17ad40(0x1ae)]['getProject'](_0x287b57);_0x221303=_0x24782c[_0x17ad40(0x181)]['name'];const _0x5ca7e=await this['client'][_0x17ad40(0x1dd)](_0x287b57),_0x5bbfb3=await this[_0x17ad40(0x1ae)]['listKnowledgeBases'](_0x287b57),_0x336a3d=await this[_0x17ad40(0x1ae)][_0x17ad40(0x1ab)](_0x287b57),_0x447964=await this['client']['listPrompts'](_0x287b57),_0x17df2d=new Map(),_0x1900f8=new Map(),_0x7f46bc=new Map(),_0x5b2187=new Map();for(const _0x452070 of _0x5bbfb3){_0x17df2d[_0x17ad40(0x132)](_0x452070['id'],_0x452070['attributes'][_0x17ad40(0x1d3)]);}for(const _0x5c41fd of _0x336a3d){_0x1900f8['set'](_0x5c41fd['id'],_0x5c41fd[_0x17ad40(0x181)][_0x17ad40(0x1d3)]);}for(const _0x4c599c of _0x5ca7e){_0x7f46bc[_0x17ad40(0x132)](_0x4c599c['id'],_0x4c599c[_0x17ad40(0x181)][_0x17ad40(0x1d3)]);}for(const _0x339eb5 of _0x447964){_0x5b2187[_0x17ad40(0x132)](_0x339eb5['id'],_0x339eb5['attributes'][_0x17ad40(0x1d3)]);}const _0x5adb21={'resolveKnowledgeBaseName':async _0x3c4b2b=>_0x17df2d['get'](_0x3c4b2b),'resolveTextKnowledgeBaseName':async _0xdefb9e=>_0x1900f8[_0x17ad40(0x127)](_0xdefb9e),'resolveAgentName':async _0x261998=>_0x7f46bc['get'](_0x261998),'resolveWebSearchToolName':async()=>undefined,'resolveImageGeneratorName':async()=>undefined,'resolvePromptName':async _0x4fe983=>_0x5b2187[_0x17ad40(0x127)](_0x4fe983),'onWarning':_0x497fdf=>this[_0x17ad40(0x169)][_0x17ad40(0x1db)]?.[_0x17ad40(0x11c)](_0x497fdf)};for(const _0x521d8f of _0x5ca7e){const _0x2ab505=await agentResponseToDef(_0x521d8f,_0x5adb21),{yaml:_0x5e3948,systemPrompt:_0x46d77c,starterMessage:_0x5a81ba}=_0x2ab505;_0x19cfb7[_0x17ad40(0x1a5)]({'name':_0x5e3948['name'],'dir':'','yaml':_0x5e3948,'systemPrompt':_0x46d77c,'starterMessage':_0x5a81ba});}for(const _0x2db5c0 of _0x5bbfb3){const _0x13615b=apiKnowledgeBaseToYaml(_0x2db5c0);_0x2f1cec[_0x17ad40(0x1a5)]({'name':_0x13615b[_0x17ad40(0x1d3)],'path':'','yaml':_0x13615b});}for(const _0x23b9c1 of _0x336a3d){_0x3fc00f[_0x17ad40(0x1a5)]({'name':_0x23b9c1[_0x17ad40(0x181)]['name'],'path':'','text':_0x23b9c1[_0x17ad40(0x181)][_0x17ad40(0x193)]});}for(const _0x591f32 of _0x447964){const _0x4ef91b=await apiPromptToYaml(_0x591f32,_0x5adb21);_0x4ef91b&&_0x4b7f1f[_0x17ad40(0x1a5)]({'name':_0x4ef91b[_0x17ad40(0x1d3)],'path':'','yaml':_0x4ef91b});}}const _0x550ab9={'sourceProjectName':_0x221303,'newProjectName':_0x164426,'newProjectId':'','agents':[],'knowledgeBases':[],'textKnowledgeBases':[],'imageGenerators':[],'webSearchTools':[],'prompts':[],'counts':{'agents':{'created':0x0,'updated':0x0,'unchanged':0x0,'errors':0x0},'knowledgeBases':{'created':0x0,'updated':0x0,'unchanged':0x0,'errors':0x0},'textKnowledgeBases':{'created':0x0,'updated':0x0,'unchanged':0x0,'errors':0x0},'imageGenerators':{'created':0x0,'errors':0x0},'webSearchTools':{'created':0x0,'errors':0x0},'prompts':{'created':0x0,'updated':0x0,'unchanged':0x0,'errors':0x0}}},_0x3f6a3a=await this[_0x17ad40(0x1ae)][_0x17ad40(0x1ad)](),_0x543eb1=_0x3f6a3a[_0x17ad40(0x145)](_0x1034f4=>_0x1034f4[_0x17ad40(0x181)][_0x17ad40(0x1d3)]===_0x164426);if(_0x543eb1)throw new SDKError(ErrorCode[_0x17ad40(0x1f4)],'Project\x20\x22'+_0x164426+_0x17ad40(0x16c),undefined,{'helpText':_0x17ad40(0x198)});if(_0x5ee67d?.[_0x17ad40(0x1b4)])return _0x550ab9[_0x17ad40(0x1e4)][_0x17ad40(0x1a6)][_0x17ad40(0x11f)]=_0x19cfb7[_0x17ad40(0x134)],_0x550ab9[_0x17ad40(0x1e4)][_0x17ad40(0x1e9)][_0x17ad40(0x11f)]=_0x2f1cec['length'],_0x550ab9[_0x17ad40(0x1e4)][_0x17ad40(0x133)][_0x17ad40(0x11f)]=_0x3fc00f[_0x17ad40(0x134)],_0x550ab9[_0x17ad40(0x1e4)]['prompts']['created']=_0x4b7f1f[_0x17ad40(0x134)],_0x550ab9;const _0xd22f11=await this[_0x17ad40(0x1ae)]['createProject']({'name':_0x164426}),_0x293177=_0xd22f11['id'];_0x550ab9[_0x17ad40(0x135)]=_0x293177;const _0x3d92cb=new Map(),_0x47decb=new Map(),_0x587e46=new Map(),_0x53ead7=new Map(),_0x15be22=new Map(),_0x43379f=new Map(),_0x2321d2=new Set(),_0x92d26a=new Set();for(const _0x51aaad of _0x19cfb7){for(const _0x54062a of _0x51aaad['yaml'][_0x17ad40(0x121)]||[]){if(_0x54062a[_0x17ad40(0x150)]==='image_gen'){const _0xd88837=parseRef(_0x54062a[_0x17ad40(0x170)]);if(_0xd88837)_0x2321d2['add'](_0xd88837[_0x17ad40(0x1d3)]);}else{if(_0x54062a[_0x17ad40(0x150)]==='web_search'){const _0x8e80f=parseRef(_0x54062a[_0x17ad40(0x170)]);if(_0x8e80f)_0x92d26a[_0x17ad40(0x1e7)](_0x8e80f[_0x17ad40(0x1d3)]);}}}}for(const _0x13353a of _0x2321d2){try{const _0x1b676c=await this[_0x17ad40(0x1ae)][_0x17ad40(0x19e)]({'projectId':_0x293177,'name':_0x13353a});_0x15be22[_0x17ad40(0x132)](_0x13353a,_0x1b676c['id']),_0x550ab9['imageGenerators']['push']({'name':_0x13353a,'action':'created','id':_0x1b676c['id']}),_0x550ab9[_0x17ad40(0x1e4)][_0x17ad40(0x1c2)][_0x17ad40(0x11f)]++;}catch(_0x1ae981){_0x550ab9[_0x17ad40(0x1c2)]['push']({'name':_0x13353a,'action':_0x17ad40(0x126),'error':_0x1ae981['message']}),_0x550ab9[_0x17ad40(0x1e4)][_0x17ad40(0x1c2)][_0x17ad40(0x1b9)]++;}}for(const _0x23af2d of _0x92d26a){try{const _0xd05c42=await this[_0x17ad40(0x1ae)][_0x17ad40(0x12e)]({'projectId':_0x293177,'name':_0x23af2d});_0x43379f['set'](_0x23af2d,_0xd05c42['id']),_0x550ab9[_0x17ad40(0x14a)][_0x17ad40(0x1a5)]({'name':_0x23af2d,'action':'created','id':_0xd05c42['id']}),_0x550ab9[_0x17ad40(0x1e4)]['webSearchTools']['created']++;}catch(_0x12bf1a){_0x550ab9[_0x17ad40(0x14a)][_0x17ad40(0x1a5)]({'name':_0x23af2d,'action':_0x17ad40(0x126),'error':_0x12bf1a[_0x17ad40(0x1ea)]}),_0x550ab9[_0x17ad40(0x1e4)]['webSearchTools'][_0x17ad40(0x1b9)]++;}}const _0x30bc14={'projectId':_0x293177,'resolveKnowledgeBaseId':async _0x390972=>_0x3d92cb[_0x17ad40(0x127)](_0x390972),'resolveTextKnowledgeBaseId':async _0x48ea70=>_0x47decb[_0x17ad40(0x127)](_0x48ea70),'resolveAgentId':async _0x6a5c46=>_0x587e46[_0x17ad40(0x127)](_0x6a5c46),'resolveWebSearchToolId':async _0x144452=>_0x43379f[_0x17ad40(0x127)](_0x144452),'resolveImageGeneratorId':async _0x26bc73=>_0x15be22['get'](_0x26bc73),'resolvePromptId':async _0x573290=>_0x53ead7[_0x17ad40(0x127)](_0x573290),'onWarning':_0x3599c7=>this[_0x17ad40(0x169)][_0x17ad40(0x1db)]?.[_0x17ad40(0x11c)](_0x3599c7)};for(const _0x4b47c6 of _0x2f1cec){try{const _0x423048=yamlKnowledgeBaseToApi(_0x4b47c6['yaml'],_0x293177),_0x15496d=await this['client'][_0x17ad40(0x1c7)](_0x423048);_0x3d92cb[_0x17ad40(0x132)](_0x4b47c6['yaml'][_0x17ad40(0x1d3)],_0x15496d['id']),_0x550ab9[_0x17ad40(0x1e9)][_0x17ad40(0x1a5)]({'name':_0x4b47c6[_0x17ad40(0x177)][_0x17ad40(0x1d3)],'action':_0x17ad40(0x11f),'id':_0x15496d['id']}),_0x550ab9[_0x17ad40(0x1e4)]['knowledgeBases'][_0x17ad40(0x11f)]++;}catch(_0x158afd){_0x550ab9[_0x17ad40(0x1e9)][_0x17ad40(0x1a5)]({'name':_0x4b47c6[_0x17ad40(0x177)][_0x17ad40(0x1d3)],'action':_0x17ad40(0x126),'error':_0x158afd[_0x17ad40(0x1ea)]}),_0x550ab9[_0x17ad40(0x1e4)][_0x17ad40(0x1e9)][_0x17ad40(0x1b9)]++;}}for(const _0x4b6d69 of _0x3fc00f){try{const _0xe435e7=yamlTextKnowledgeBaseToApi({'name':_0x4b6d69[_0x17ad40(0x1d3)],'text':_0x4b6d69[_0x17ad40(0x193)]},_0x293177),_0x47bb53=await this['client'][_0x17ad40(0x1a1)](_0xe435e7);_0x47decb[_0x17ad40(0x132)](_0x4b6d69[_0x17ad40(0x1d3)],_0x47bb53['id']),_0x550ab9[_0x17ad40(0x133)][_0x17ad40(0x1a5)]({'name':_0x4b6d69[_0x17ad40(0x1d3)],'action':_0x17ad40(0x11f),'id':_0x47bb53['id']}),_0x550ab9['counts'][_0x17ad40(0x133)][_0x17ad40(0x11f)]++;}catch(_0x221997){_0x550ab9[_0x17ad40(0x133)][_0x17ad40(0x1a5)]({'name':_0x4b6d69[_0x17ad40(0x1d3)],'action':'error','error':_0x221997['message']}),_0x550ab9[_0x17ad40(0x1e4)][_0x17ad40(0x133)][_0x17ad40(0x1b9)]++;}}const _0x2eb288=[..._0x19cfb7]['sort']((_0x4ae1c6,_0x358e7f)=>{const _0x3d6817=_0x17ad40,_0x2d0803=_0x4ae1c6[_0x3d6817(0x177)][_0x3d6817(0x121)]?.['some'](_0x148ec8=>_0x148ec8['type']==='agent')??![],_0x1e4dd4=_0x358e7f[_0x3d6817(0x177)][_0x3d6817(0x121)]?.[_0x3d6817(0x1c9)](_0x478f4e=>_0x478f4e[_0x3d6817(0x150)]===_0x3d6817(0x17b))??![];if(_0x2d0803&&!_0x1e4dd4)return 0x1;if(!_0x2d0803&&_0x1e4dd4)return-0x1;return 0x0;});for(const _0x4a7c51 of _0x2eb288){try{const _0x18bca3=_0x4a7c51[_0x17ad40(0x177)]['tools']?.[_0x17ad40(0x1ec)](_0x1ce2d3=>{const _0x1249b3=_0x17ad40;if(_0x1ce2d3[_0x1249b3(0x150)]===_0x1249b3(0x17b)){const _0x2f6c4b=parseRef(_0x1ce2d3[_0x1249b3(0x170)]);return _0x2f6c4b?.['name']===_0x4a7c51['yaml']['name'];}return![];})??[];_0x18bca3[_0x17ad40(0x134)]>0x0&&this[_0x17ad40(0x169)][_0x17ad40(0x1db)]?.[_0x17ad40(0x11c)]('Agent\x20\x27'+_0x4a7c51['yaml'][_0x17ad40(0x1d3)]+_0x17ad40(0x1a7)+_0x17ad40(0x130));const _0x3d54a8=await agentDefToRequest(_0x4a7c51['yaml'],_0x4a7c51['systemPrompt'],_0x4a7c51[_0x17ad40(0x1f7)],_0x30bc14),_0x3ed50b=await this['client'][_0x17ad40(0x1ba)](_0x3d54a8);_0x587e46[_0x17ad40(0x132)](_0x4a7c51[_0x17ad40(0x177)]['name'],_0x3ed50b['id']),_0x550ab9[_0x17ad40(0x1a6)][_0x17ad40(0x1a5)]({'agentName':_0x4a7c51[_0x17ad40(0x177)][_0x17ad40(0x1d3)],'action':_0x17ad40(0x11f),'agentId':_0x3ed50b['id']}),_0x550ab9[_0x17ad40(0x1e4)][_0x17ad40(0x1a6)][_0x17ad40(0x11f)]++;}catch(_0x1e6d2f){_0x550ab9[_0x17ad40(0x1a6)]['push']({'agentName':_0x4a7c51[_0x17ad40(0x177)]['name'],'action':_0x17ad40(0x126),'error':_0x1e6d2f[_0x17ad40(0x1ea)]}),_0x550ab9['counts']['agents'][_0x17ad40(0x1b9)]++;}}for(const _0x3e1834 of _0x4b7f1f){try{const _0xa21d0=await yamlPromptToApi(_0x3e1834['yaml'],_0x293177,_0x30bc14);if(!_0xa21d0){_0x550ab9['prompts'][_0x17ad40(0x1a5)]({'name':_0x3e1834[_0x17ad40(0x177)]['name'],'action':_0x17ad40(0x126),'error':_0x17ad40(0x176)}),_0x550ab9[_0x17ad40(0x1e4)][_0x17ad40(0x16d)]['errors']++;continue;}const _0x4283c0=await this['client'][_0x17ad40(0x128)](_0xa21d0);_0x53ead7[_0x17ad40(0x132)](_0x3e1834[_0x17ad40(0x177)][_0x17ad40(0x1d3)],_0x4283c0['id']),_0x550ab9[_0x17ad40(0x16d)][_0x17ad40(0x1a5)]({'name':_0x3e1834['yaml'][_0x17ad40(0x1d3)],'action':_0x17ad40(0x11f),'id':_0x4283c0['id']}),_0x550ab9[_0x17ad40(0x1e4)][_0x17ad40(0x16d)][_0x17ad40(0x11f)]++;}catch(_0x2f1749){_0x550ab9[_0x17ad40(0x16d)]['push']({'name':_0x3e1834[_0x17ad40(0x177)][_0x17ad40(0x1d3)],'action':_0x17ad40(0x126),'error':_0x2f1749['message']}),_0x550ab9[_0x17ad40(0x1e4)][_0x17ad40(0x16d)][_0x17ad40(0x1b9)]++;}}return _0x550ab9;}}
|
|
1
|
+
const a87_0x523c07=a87_0x3a53;(function(_0x515010,_0x22ce88){const _0x1f53c5=a87_0x3a53,_0x135635=_0x515010();while(!![]){try{const _0x1ff094=-parseInt(_0x1f53c5(0x271))/0x1+parseInt(_0x1f53c5(0x1fb))/0x2+parseInt(_0x1f53c5(0x256))/0x3*(parseInt(_0x1f53c5(0x21b))/0x4)+parseInt(_0x1f53c5(0x29c))/0x5*(parseInt(_0x1f53c5(0x290))/0x6)+parseInt(_0x1f53c5(0x2a4))/0x7*(parseInt(_0x1f53c5(0x2a8))/0x8)+parseInt(_0x1f53c5(0x23d))/0x9+-parseInt(_0x1f53c5(0x1e8))/0xa*(parseInt(_0x1f53c5(0x25c))/0xb);if(_0x1ff094===_0x22ce88)break;else _0x135635['push'](_0x135635['shift']());}catch(_0x1eef84){_0x135635['push'](_0x135635['shift']());}}}(a87_0x1cde,0x1ced8));import{LLMApiClient}from'../client/llm-api-client.js';import*as a87_0x4b9004 from'node:fs';import*as a87_0x445c58 from'node:path';import{HTTPClientError}from'../client/http-client.js';import{canCreateAgent,remapToolIds,remapVariableIds,isSupportedBackupVersion}from'./llm-backup-utils.js';import{SDKError,ErrorCode,errorContains}from'../errors.js';import{normalizeName,UniqueNameGenerator,migrateModelType,parseRef,agentResponseToDef,apiKnowledgeBaseToYaml,apiPromptToYaml,toAgentYamlString,toKnowledgeBaseYamlString,toTextKnowledgeBaseMd,toPromptYamlString,parseAgentYaml,parseKnowledgeBaseYaml,parseTextKnowledgeBaseMd,parsePromptYaml,agentDefToRequest,yamlKnowledgeBaseToApi,yamlTextKnowledgeBaseToApi,yamlPromptToApi,resolveAgentDependencies}from'../agent/agent-yaml.js';function a87_0x3a53(_0x6944e6,_0x5498b0){_0x6944e6=_0x6944e6-0x1e2;const _0x1cde63=a87_0x1cde();let _0x3a5302=_0x1cde63[_0x6944e6];return _0x3a5302;}import{createAgentConfigContent,loadAgentConfig,findAgentConfig,isAgentDir,isAgentYamlPath,getAgentDirFromYamlPath,getKnowledgeBasesDir,getPromptsDir}from'../agent/agent-config.js';import{getSanitizedUsername,generateRandomHex}from'../../utils/string-utils.js';function a87_0x1cde(){const _0x483ba4=['chats','createAgent','textKnowledgeBases','327026ILaQoW','integrations','systemPrompt','isManaged','8dcZBcB','createTextKnowledgeBase','version','starterMessage','Project\x20not\x20found:\x20','UNAUTHENTICATED','projects','Use\x20\x22tdx\x20llm\x20projects\x22\x20to\x20list\x20available\x20projects.','total','agentId','INVALID_ARGUMENT','chatIgnoreManagedActions','created','unchanged','tdx_','pushProject','new','error','getProject','description','prompt.md','find','.\x20Check\x20for\x20circular\x20references\x20or\x20missing\x20agents.','getChatInfo','writeFileSync','getAgent','already\x20exists','80RfAFSw','tools','updateTextKnowledgeBase','Ensure\x20the\x20backup\x20folder\x20path\x20is\x20correct.','existsSync','getDefaultAgent','ALREADY_EXISTS','path','conflict','project','tdx.json','updateAgent','listWebSearchTools','Backup\x20folder\x20not\x20found:\x20','isDirectory','deleteProject','createPrompt','updateKnowledgeBase','getCurrentProject','133846GhvxNT','.yml','push','listAgentsFull','createWebSearchTool','getUniqueName','medium','getDefaultProjectName','prompts.json','message','The\x20backup\x20contains\x20agents\x20with\x20circular\x20dependencies.','dirname','duplicate','warn','updatePrompt','cwd','agents','createProject','\x27\x20has\x20self-referencing\x20tool(s)\x20that\x20will\x20be\x20skipped\x20during\x20clone.\x20','isDir','history','Invalid\x20agent\x20reference\x20format:\x20','resolveAgentId','stringify','projectName','variables','starter_message','pullProject','metadata','\x20in\x20project\x20','parse','site','116deoJIR','claude-4.5-sonnet','modelType','name','counts','chatInfo','temperature','\x20attempts\x20due\x20to\x20name\x20conflicts.','includes','keys','restoreProject','readdirSync','context','agent','Multiple\x20projects\x20found\x20with\x20name\x20\x27','agents.json','filter','agentId\x20is\x20required\x20when\x20starting\x20a\x20new\x20chat','action','listImageGenerators','getUserSettings','prompts','deleteAgent','Ensure\x20the\x20path\x20points\x20to\x20a\x20valid\x20agent\x20directory.','serviceType','backupProject','listAgents','actions','displayName','exportedFrom','\x27.\x20This\x20should\x20not\x20happen.','unlinkSync','set','length','531288dMHeEQ','resolveProjectName','_reasoning_','join','setCurrentProject','agent.yml\x20not\x20found\x20in\x20','Available\x20agents:\x20','Use\x20a\x20different\x20output\x20path\x20or\x20remove\x20the\x20existing\x20directory.','starter_message.md','text','Default\x20project\x20for\x20tdx\x20CLI\x20chat\x20(user:\x20','utf-8','listChats','project.json','getChatHistory','endsWith','mkdirSync','resolveProjectId','Run\x20\x27tdx\x20agent\x20pull\x20<project>\x27\x20first\x20to\x20create\x20the\x20folder\x20structure.','updateAgentResponse','This\x20backup\x20was\x20created\x20with\x20a\x20newer\x20version\x20of\x20tdx.','knowledge_bases','createImageGenerator','currentProjectId','listPrompts','9447BreDuS','chat','\x0a\x0a#\x20agent.yml\x0a','createAgentResponse','listKnowledgeBases','getOrCreateDefaultAgent','331463rbzQfs','Failed\x20to\x20get\x20or\x20create\x20agent:\x20exceeded\x20maximum\x20attempts','event','split','continueChat','logger','getOrCreateDefaultProject','low','setDefaultAgent','client','updated','tables','.md','listIntegrations','Authentication\x20failed.\x20Please\x20check\x20your\x20API\x20key\x20is\x20valid\x20and\x20not\x20expired.','content','#\x20prompt.md\x0a','chatWelcomeMessage','LLM_PROJECT_NOT_FOUND','map','\x22\x20already\x20exists','1050CUsXIv','Unable\x20to\x20create\x20project\x20after\x20','NOT_FOUND','loadJsonFile','tdx_default_','chatId','webSearchTools','Agent\x20not\x20found:\x20','readFileSync','listProjects','PERMISSION_DENIED','newProjectId','dry-run-','add','knowledgebases.json','attributes','webhookCorsOrigins','getBackupMetadata','Project\x20\x22','profile','type','Multiple\x20agents\x20found\x20with\x20name\x20\x27','Unresolved\x20dependencies:\x20','llm_project','startChat','knowledgeBases','pushAgent','errors','some','yaml','No\x20tdx.json\x20found\x20in\x20','579648uOAnJp','listTextKnowledgeBases','none','dryRun','Choose\x20a\x20different\x20name\x20or\x20delete\x20the\x20existing\x20project\x20first.','Agent\x20reference\x20not\x20found','createKnowledgeBase','size','imageGenerators','createIntegration','Unsupported\x20backup\x20version:\x20','AGENT_NOT_FOUND','5OePwTJ','INTERNAL','agent.yml','get','target'];a87_0x1cde=function(){return _0x483ba4;};return a87_0x1cde();}import{generateDiff,formatDiffWithColors,hasChanges}from'../../utils/diff.js';import{readCachedLLMProject,writeCachedLLMProject,readCachedLLMAgent,writeCachedLLMAgent,clearCachedLLMAgent}from'../../core/config.js';export class LLMSDK{[a87_0x523c07(0x254)];[a87_0x523c07(0x265)];['context'];constructor(_0xc58b10){const _0xc7a8f3=a87_0x523c07;this[_0xc7a8f3(0x265)]=new LLMApiClient(_0xc58b10,_0xc58b10['logger']),this[_0xc7a8f3(0x227)]=_0xc58b10;}[a87_0x523c07(0x202)](){const _0x1ca060=a87_0x523c07,_0x5bd307=getSanitizedUsername();return _0x1ca060(0x275)+_0x5bd307;}async[a87_0x523c07(0x241)](_0x4cbf9e){const _0x32c547=a87_0x523c07,{projectId:_0x23b0d6}=await this['resolveProjectName'](_0x4cbf9e);this[_0x32c547(0x254)]=_0x23b0d6;}[a87_0x523c07(0x1fa)](){const _0x4743aa=a87_0x523c07;return this[_0x4743aa(0x254)];}async[a87_0x523c07(0x264)](_0x5d8344){const _0x446cf8=a87_0x523c07,_0x243d35=this[_0x446cf8(0x227)][_0x446cf8(0x284)];let _0x2ec8a5,_0x5e893b;if(_0x5d8344[_0x446cf8(0x223)]('/')){const _0x47c989=_0x5d8344[_0x446cf8(0x25f)]('/');if(_0x47c989[_0x446cf8(0x23c)]!==0x2)throw new SDKError(ErrorCode[_0x446cf8(0x2b2)],_0x446cf8(0x210)+_0x5d8344,undefined,{'helpText':'Use\x20format:\x20\x22agent-name\x22\x20or\x20\x22project-name/agent-name\x22'});const [_0x530db6,_0x362ccb]=_0x47c989;_0x2ec8a5=await this['resolveProjectId'](_0x530db6),_0x5e893b=_0x362ccb;}else _0x2ec8a5=this[_0x446cf8(0x254)]||(await this['getOrCreateDefaultProject']())['id'],_0x5e893b=_0x5d8344;const _0x1fe3ca=await this[_0x446cf8(0x211)](_0x5e893b,_0x2ec8a5),_0x4db743=await this[_0x446cf8(0x265)][_0x446cf8(0x1e6)](_0x1fe3ca);writeCachedLLMAgent(_0x4db743['attributes'][_0x446cf8(0x21e)],_0x1fe3ca,_0x2ec8a5,_0x243d35);}[a87_0x523c07(0x1ed)](){const _0x41f603=a87_0x523c07,_0x8c850a=this[_0x41f603(0x227)][_0x41f603(0x284)];return readCachedLLMAgent(_0x8c850a)||undefined;}['clearDefaultAgent'](){const _0x3b98e0=a87_0x523c07,_0x4ef531=this[_0x3b98e0(0x227)]['profile'];clearCachedLLMAgent(_0x4ef531);}async['models'](){const _0x1917f9=a87_0x523c07,_0x59c6ec=await this[_0x1917f9(0x265)][_0x1917f9(0x22f)](),_0x2336d4=[];for(const _0x5d6420 of _0x59c6ec['availableModelNames']){const _0x4de71a=_0x59c6ec['availableModels'][_0x5d6420];_0x4de71a&&_0x2336d4[_0x1917f9(0x1fd)]({'name':_0x5d6420,'displayName':_0x4de71a[_0x1917f9(0x237)]});}return _0x2336d4;}async[a87_0x523c07(0x20c)](_0x5962de){const _0x331c7b=a87_0x523c07;return await this[_0x331c7b(0x265)][_0x331c7b(0x20c)](_0x5962de);}async[a87_0x523c07(0x1f7)](_0x5178f7){const _0x37b52d=a87_0x523c07,{projectId:_0x4c4e0f}=await this[_0x37b52d(0x23e)](_0x5178f7);await this['client']['deleteProject'](_0x4c4e0f);}async[a87_0x523c07(0x2ae)](_0x2687a8=0x32){const _0x381152=a87_0x523c07;return await this[_0x381152(0x265)]['listProjects'](_0x2687a8);}async[a87_0x523c07(0x262)](_0x2e244f){const _0x326702=a87_0x523c07,_0x5a300e=_0x2e244f||this[_0x326702(0x202)](),_0x4c2baa=this['context'][_0x326702(0x284)];if(!_0x2e244f){const _0x367339=readCachedLLMProject(_0x4c2baa);if(_0x367339&&_0x367339[_0x326702(0x21e)]===_0x5a300e)try{const _0x5f5752=await this[_0x326702(0x265)][_0x326702(0x2ba)](_0x367339['id']);if(_0x5f5752['attributes'][_0x326702(0x21e)]===_0x5a300e)return _0x5f5752;}catch{}}const _0x4ed6c1=await this['client']['listProjects'](),_0x3ade77=_0x4ed6c1[_0x326702(0x1e2)](_0x50f1b2=>_0x50f1b2[_0x326702(0x280)][_0x326702(0x21e)]===_0x5a300e);if(_0x3ade77)return!_0x2e244f&&writeCachedLLMProject(_0x5a300e,_0x3ade77['id'],_0x4c2baa),_0x3ade77;const _0x1d112a=await this[_0x326702(0x265)][_0x326702(0x20c)]({'name':_0x5a300e,'description':_0x326702(0x247)+getSanitizedUsername()+')'});return!_0x2e244f&&writeCachedLLMProject(_0x5a300e,_0x1d112a['id'],_0x4c2baa),_0x1d112a;}async['resolveProjectId'](_0x2af2e8){const _0x33b604=a87_0x523c07,_0x1d8e81=await this[_0x33b604(0x265)][_0x33b604(0x27a)](),_0x34791c=_0x1d8e81['filter'](_0x18e55b=>_0x18e55b['attributes'][_0x33b604(0x21e)]===_0x2af2e8);if(_0x34791c['length']===0x0)throw new SDKError(ErrorCode[_0x33b604(0x26e)],_0x33b604(0x2ac)+_0x2af2e8,undefined,{'helpText':_0x33b604(0x2af)});if(_0x34791c['length']>0x1)throw new SDKError(ErrorCode['INTERNAL'],_0x33b604(0x229)+_0x2af2e8+_0x33b604(0x239));return _0x34791c[0x0]['id'];}async[a87_0x523c07(0x23e)](_0x2d77a5){const _0x222f6f=a87_0x523c07,_0x333151=await this[_0x222f6f(0x265)][_0x222f6f(0x27a)](),_0x5c50b8=_0x333151[_0x222f6f(0x1e2)](_0x1a3df7=>_0x1a3df7[_0x222f6f(0x280)][_0x222f6f(0x21e)]===_0x2d77a5);if(_0x5c50b8)return{'projectId':_0x5c50b8['id'],'project':_0x5c50b8};throw new SDKError(ErrorCode[_0x222f6f(0x26e)],_0x222f6f(0x2ac)+_0x2d77a5,undefined,{'helpText':_0x222f6f(0x2af)});}async[a87_0x523c07(0x25b)](_0x4541b7=a87_0x523c07(0x21c),_0x5191e3=0x0,_0x458ec7){const _0x5bf172=a87_0x523c07,_0x3b250e=0xa;let _0xb71410=0x0,_0x4cdb5a;while(_0xb71410<_0x3b250e){try{const _0x18998b=await this[_0x5bf172(0x262)](_0x4cdb5a),_0x3cfca1=_0x18998b['id'],_0x1e99fd=[_0x5bf172(0x292),'minimal',_0x5bf172(0x263),_0x5bf172(0x201),'high'],_0xbc844f=_0x5191e3===0x0?'tdx_'+_0x4541b7:_0x5bf172(0x2b6)+_0x4541b7+_0x5bf172(0x23f)+_0x1e99fd[_0x5191e3],_0xcbc954=await this[_0x5bf172(0x265)][_0x5bf172(0x235)](_0x3cfca1),_0x5f715=_0xcbc954[_0x5bf172(0x1e2)](_0x2c0737=>_0x2c0737[_0x5bf172(0x280)][_0x5bf172(0x21e)]===_0xbc844f);if(_0x5f715)return _0x5f715;const _0xaed405=_0x5191e3>0x0?0x1:_0x458ec7;return await this['client'][_0x5bf172(0x2a2)]({'name':_0xbc844f,'projectId':_0x3cfca1,'modelType':_0x4541b7,'systemPrompt':'','temperature':_0xaed405,'reasoningEffort':_0x5191e3>0x0?_0x5191e3:undefined});}catch(_0x3c760b){if(_0x3c760b instanceof HTTPClientError){const _0x24ae9c=_0x3c760b['status'];if(_0x24ae9c>=0x190&&_0x24ae9c<0x1f4){if(_0x24ae9c===0x191)throw new SDKError(ErrorCode[_0x5bf172(0x2ad)],_0x5bf172(0x26a),_0x3c760b);else{if(_0x24ae9c===0x193)throw new SDKError(ErrorCode[_0x5bf172(0x27b)],'Permission\x20denied.\x20Please\x20check\x20your\x20API\x20key\x20has\x20the\x20required\x20permissions\x20for\x20LLM\x20API\x20operations.',_0x3c760b);}throw _0x3c760b;}}if(errorContains(_0x3c760b,_0x5bf172(0x1e7),_0x5bf172(0x207),_0x5bf172(0x1f0))){_0xb71410++;if(_0xb71410>=_0x3b250e)throw new SDKError(ErrorCode[_0x5bf172(0x1ee)],_0x5bf172(0x272)+_0x3b250e+_0x5bf172(0x222),_0x3c760b);const _0x5d1776=this[_0x5bf172(0x202)]();_0x4cdb5a=_0x5d1776+'_'+generateRandomHex();continue;}throw _0x3c760b;}}throw new SDKError(ErrorCode['INTERNAL'],_0x5bf172(0x25d));}async[a87_0x523c07(0x211)](_0x2287ab,_0x46d8e1){const _0x4cd118=a87_0x523c07,_0x3517ca=_0x46d8e1||this[_0x4cd118(0x254)],_0x3d1dad=await this['client']['listAgents'](_0x3517ca),_0x19497b=_0x3d1dad['filter'](_0x33611b=>_0x33611b[_0x4cd118(0x280)][_0x4cd118(0x21e)]===_0x2287ab);if(_0x19497b['length']===0x0){const _0x5d67df=_0x3517ca?_0x4cd118(0x218)+_0x3517ca:'';throw new SDKError(ErrorCode[_0x4cd118(0x29b)],_0x4cd118(0x278)+_0x2287ab+_0x5d67df,undefined,{'helpText':_0x3517ca?'Use\x20\x22tdx\x20llm\x20agents\x22\x20to\x20list\x20available\x20agents\x20in\x20the\x20current\x20project.':'Use\x20\x22tdx\x20llm\x20use\x20<project>\x22\x20to\x20set\x20a\x20project\x20context\x20first,\x20or\x20use\x20\x22tdx\x20llm\x20agents\x22\x20to\x20list\x20all\x20agents.'});}if(_0x19497b[_0x4cd118(0x23c)]>0x1)throw new SDKError(ErrorCode[_0x4cd118(0x29d)],_0x4cd118(0x286)+_0x2287ab+'\x27.\x20This\x20should\x20not\x20happen.');return _0x19497b[0x0]['id'];}async[a87_0x523c07(0x20b)](_0x5b84de){const _0x5f8cad=a87_0x523c07,_0x5618b1=_0x5b84de||this['currentProjectId'];return await this[_0x5f8cad(0x265)][_0x5f8cad(0x235)](_0x5618b1);}async[a87_0x523c07(0x228)](_0x1513c0){return await this['client']['getAgent'](_0x1513c0);}async[a87_0x523c07(0x2a2)](_0x27d2fb){const _0x4e32cf=a87_0x523c07;return await this[_0x4e32cf(0x265)][_0x4e32cf(0x2a2)](_0x27d2fb);}async['updateAgent'](_0x3fb7b8,_0x3ce0fa){const _0x42c585=a87_0x523c07;return await this[_0x42c585(0x265)][_0x42c585(0x1f3)](_0x3fb7b8,_0x3ce0fa);}async['deleteAgent'](_0x5a4847){const _0x4e5462=a87_0x523c07;await this['client'][_0x4e5462(0x231)](_0x5a4847);}async[a87_0x523c07(0x289)](_0x14e07f){const _0x3bed09=a87_0x523c07;return await this['client'][_0x3bed09(0x289)]({'agentId':_0x14e07f});}async*[a87_0x523c07(0x257)](_0x38a551,_0x4a6653){const _0xebe94e=a87_0x523c07;let _0x5d3ee0=_0x4a6653?.[_0xebe94e(0x276)];const _0x223199=_0x4a6653?.[_0xebe94e(0x2b1)];if(!_0x5d3ee0){if(!_0x223199)throw new Error(_0xebe94e(0x22c));const _0x38c9f7=await this['client'][_0xebe94e(0x289)]({'agentId':_0x223199});_0x5d3ee0=_0x38c9f7['id'],yield{'type':_0xebe94e(0x217),'data':{'chatId':_0x5d3ee0,'agentId':_0x223199}};}for await(const _0x316038 of this[_0xebe94e(0x265)][_0xebe94e(0x260)](_0x5d3ee0,_0x38a551,_0x4a6653?.['signal'])){yield{'type':_0xebe94e(0x25e),'data':_0x316038};}}async[a87_0x523c07(0x2a1)](_0x58070a=0x32){const _0x4f1dd9=a87_0x523c07;return await this[_0x4f1dd9(0x265)][_0x4f1dd9(0x249)](_0x58070a);}async[a87_0x523c07(0x20f)](_0x377add){const _0x4b2d15=a87_0x523c07;return await this[_0x4b2d15(0x265)][_0x4b2d15(0x24b)](_0x377add);}async[a87_0x523c07(0x220)](_0x1bef66){const _0x1297a4=a87_0x523c07;return await this[_0x1297a4(0x265)][_0x1297a4(0x1e4)](_0x1bef66);}async[a87_0x523c07(0x234)](_0x38e87a,_0x386563,_0x487555){const _0x3e49f5=a87_0x523c07,_0x25d526=_0x487555?.[_0x3e49f5(0x293)]??![],{projectId:_0x14d7dd,project:_0x2df2d3}=await this[_0x3e49f5(0x23e)](_0x38e87a),_0x464a6a=_0x2df2d3['attributes'][_0x3e49f5(0x21e)],_0x5cc150=_0x386563||_0x464a6a+'.llm';if(a87_0x4b9004['existsSync'](_0x5cc150)&&!_0x25d526)throw new SDKError(ErrorCode[_0x3e49f5(0x1ee)],'Output\x20directory\x20already\x20exists:\x20'+_0x5cc150,undefined,{'helpText':_0x3e49f5(0x244)});const _0x4ca605=await this[_0x3e49f5(0x265)]['listAgentsFull'](_0x14d7dd),_0x4e2492=await this[_0x3e49f5(0x265)][_0x3e49f5(0x25a)](_0x14d7dd),_0x44608f=await this[_0x3e49f5(0x265)]['listPrompts'](_0x14d7dd),_0x335f61=await this[_0x3e49f5(0x265)][_0x3e49f5(0x269)](_0x14d7dd);if(!_0x25d526){a87_0x4b9004[_0x3e49f5(0x24d)](_0x5cc150,{'recursive':!![]});const _0x2fceeb={'version':'1.0','exportedAt':new Date()['toISOString'](),'exportedFrom':{'site':this['context'][_0x3e49f5(0x21a)],'projectId':_0x14d7dd,'projectName':_0x464a6a},'project':_0x2df2d3};a87_0x4b9004[_0x3e49f5(0x1e5)](a87_0x445c58['join'](_0x5cc150,_0x3e49f5(0x24a)),JSON[_0x3e49f5(0x212)](_0x2fceeb,null,0x2)),a87_0x4b9004[_0x3e49f5(0x1e5)](a87_0x445c58['join'](_0x5cc150,_0x3e49f5(0x22a)),JSON[_0x3e49f5(0x212)](_0x4ca605,null,0x2)),a87_0x4b9004[_0x3e49f5(0x1e5)](a87_0x445c58['join'](_0x5cc150,_0x3e49f5(0x27f)),JSON['stringify'](_0x4e2492,null,0x2)),a87_0x4b9004[_0x3e49f5(0x1e5)](a87_0x445c58['join'](_0x5cc150,_0x3e49f5(0x203)),JSON['stringify'](_0x44608f,null,0x2)),a87_0x4b9004['writeFileSync'](a87_0x445c58[_0x3e49f5(0x240)](_0x5cc150,'integrations.json'),JSON[_0x3e49f5(0x212)](_0x335f61,null,0x2));}return{'projectName':_0x464a6a,'outputDir':_0x5cc150,'counts':{'agents':_0x4ca605['length'],'knowledgeBases':_0x4e2492[_0x3e49f5(0x23c)],'prompts':_0x44608f['length'],'integrations':_0x335f61[_0x3e49f5(0x23c)]}};}async[a87_0x523c07(0x225)](_0x15ef10,_0x575ad3){const _0x56b7d8=a87_0x523c07,_0x354e84=_0x575ad3?.[_0x56b7d8(0x293)]??![],_0x41122f=this[_0x56b7d8(0x282)](_0x15ef10),_0x262002=_0x41122f[_0x56b7d8(0x238)][_0x56b7d8(0x21a)],_0x1f4920=this[_0x56b7d8(0x227)][_0x56b7d8(0x21a)],_0x19be44=_0x262002!==_0x1f4920?_0x262002:undefined,_0x441036=this[_0x56b7d8(0x274)](a87_0x445c58[_0x56b7d8(0x240)](_0x15ef10,_0x56b7d8(0x22a)),[]),_0x7ce341=this[_0x56b7d8(0x274)](a87_0x445c58['join'](_0x15ef10,_0x56b7d8(0x27f)),[]),_0x5b6c06=this[_0x56b7d8(0x274)](a87_0x445c58[_0x56b7d8(0x240)](_0x15ef10,_0x56b7d8(0x203)),[]),_0x2feab9=this[_0x56b7d8(0x274)](a87_0x445c58['join'](_0x15ef10,'integrations.json'),[]),_0x267450=_0x575ad3?.[_0x56b7d8(0x21e)]||_0x41122f[_0x56b7d8(0x238)][_0x56b7d8(0x213)];if(_0x354e84){const _0x1948f6=new Map(),_0x26ffd8=[..._0x441036],_0x5652ea=_0x441036[_0x56b7d8(0x23c)]+0x1;let _0x214253=0x0;while(_0x26ffd8['length']>0x0&&_0x214253<_0x5652ea){_0x214253++;const _0x432736=[];for(const _0x5f4ff7 of _0x26ffd8){canCreateAgent(_0x5f4ff7,_0x1948f6)?_0x1948f6[_0x56b7d8(0x23b)](_0x5f4ff7['id'],_0x56b7d8(0x27d)+_0x5f4ff7['id']):_0x432736[_0x56b7d8(0x1fd)](_0x5f4ff7);}if(_0x432736['length']===_0x26ffd8['length'])throw new SDKError(ErrorCode[_0x56b7d8(0x29d)],'Circular\x20dependency\x20detected\x20in\x20agents.\x20Cannot\x20restore.',undefined,{'helpText':_0x56b7d8(0x205)});_0x26ffd8[_0x56b7d8(0x23c)]=0x0,_0x26ffd8[_0x56b7d8(0x1fd)](..._0x432736);}const _0xb9b27d=_0x5b6c06[_0x56b7d8(0x22b)](_0x49bdb4=>_0x1948f6['has'](_0x49bdb4[_0x56b7d8(0x280)][_0x56b7d8(0x2b1)]))[_0x56b7d8(0x23c)];return{'projectName':_0x267450,'projectId':'(dry-run)','counts':{'agents':_0x441036[_0x56b7d8(0x23c)],'knowledgeBases':_0x7ce341['length'],'prompts':_0xb9b27d,'integrations':_0x2feab9['length']},'sourceSite':_0x19be44};}const _0xb079f0=await this[_0x56b7d8(0x265)][_0x56b7d8(0x20c)]({'name':_0x267450,'description':_0x41122f[_0x56b7d8(0x1f1)][_0x56b7d8(0x280)][_0x56b7d8(0x2bb)]}),_0x489c62=_0xb079f0['id'],_0x187f39=new Map(),_0x42a00a=new Map(),_0x1dfaa0=new Map();for(const _0x2b3d95 of _0x7ce341){const _0x2b152e=await this[_0x56b7d8(0x265)]['createKnowledgeBase']({'projectId':_0x489c62,'name':_0x2b3d95[_0x56b7d8(0x280)][_0x56b7d8(0x21e)],'tdDatabaseName':_0x2b3d95['attributes']['tdDatabaseName'],'tables':_0x2b3d95[_0x56b7d8(0x280)][_0x56b7d8(0x267)]});_0x187f39[_0x56b7d8(0x23b)](_0x2b3d95['id'],_0x2b152e['id']);}const _0x525ac9=[..._0x441036],_0x494f57=_0x441036[_0x56b7d8(0x23c)]+0x1;let _0x46759a=0x0;while(_0x525ac9[_0x56b7d8(0x23c)]>0x0&&_0x46759a<_0x494f57){_0x46759a++;const _0x408615=[];for(const _0x3f8ff4 of _0x525ac9){if(canCreateAgent(_0x3f8ff4,_0x42a00a)){const _0x40b4a8=remapToolIds(_0x3f8ff4[_0x56b7d8(0x280)][_0x56b7d8(0x1e9)],_0x187f39,_0x42a00a),_0x15244e=remapVariableIds(_0x3f8ff4[_0x56b7d8(0x280)][_0x56b7d8(0x214)],_0x187f39),_0x161012=await this['client'][_0x56b7d8(0x259)]({'name':_0x3f8ff4['attributes'][_0x56b7d8(0x21e)],'projectId':_0x489c62,'systemPrompt':_0x3f8ff4[_0x56b7d8(0x280)][_0x56b7d8(0x2a6)],'starterMessage':_0x3f8ff4[_0x56b7d8(0x280)][_0x56b7d8(0x2ab)],'modelType':migrateModelType(_0x3f8ff4[_0x56b7d8(0x280)][_0x56b7d8(0x21d)]),'maxToolIterations':_0x3f8ff4['attributes']['maxToolIterations'],'temperature':_0x3f8ff4[_0x56b7d8(0x280)][_0x56b7d8(0x221)],'reasoningEffort':_0x3f8ff4[_0x56b7d8(0x280)]['reasoningEffort'],'outputs':_0x3f8ff4[_0x56b7d8(0x280)]['outputs'],'tools':_0x40b4a8,'variables':_0x15244e});_0x42a00a[_0x56b7d8(0x23b)](_0x3f8ff4['id'],_0x161012['id']);}else _0x408615[_0x56b7d8(0x1fd)](_0x3f8ff4);}if(_0x408615[_0x56b7d8(0x23c)]===_0x525ac9[_0x56b7d8(0x23c)])throw new SDKError(ErrorCode[_0x56b7d8(0x29d)],'Circular\x20dependency\x20detected\x20in\x20agents.\x20Cannot\x20restore.',undefined,{'helpText':'The\x20backup\x20contains\x20agents\x20with\x20circular\x20dependencies.'});_0x525ac9[_0x56b7d8(0x23c)]=0x0,_0x525ac9['push'](..._0x408615);}for(const _0x30376b of _0x5b6c06){const _0x5ddc8e=_0x42a00a[_0x56b7d8(0x29f)](_0x30376b[_0x56b7d8(0x280)]['agentId']);if(!_0x5ddc8e)continue;const _0x408774=await this[_0x56b7d8(0x265)]['createPrompt']({'projectId':_0x489c62,'agentId':_0x5ddc8e,'name':_0x30376b[_0x56b7d8(0x280)][_0x56b7d8(0x21e)],'systemPrompt':_0x30376b[_0x56b7d8(0x280)][_0x56b7d8(0x2a6)],'template':_0x30376b[_0x56b7d8(0x280)]['template'],'jsonSchemaHint':_0x30376b[_0x56b7d8(0x280)]['jsonSchemaHint']});_0x1dfaa0['set'](_0x30376b['id'],_0x408774['id']);}for(const _0x3b794d of _0x2feab9){const _0x10fb5f=_0x3b794d[_0x56b7d8(0x280)][_0x56b7d8(0x236)][_0x56b7d8(0x26f)](_0x7d1b78=>({..._0x7d1b78,'promptId':_0x1dfaa0[_0x56b7d8(0x29f)](_0x7d1b78['promptId'])||_0x7d1b78['promptId']}));await this['client'][_0x56b7d8(0x299)]({'projectId':_0x489c62,'serviceType':_0x3b794d['attributes'][_0x56b7d8(0x233)],'actions':_0x10fb5f,'slackMessageMode':_0x3b794d['attributes']['slackMessageMode'],'chatIgnoreManagedActions':_0x3b794d['attributes'][_0x56b7d8(0x2b3)],'chatWelcomeMessage':_0x3b794d[_0x56b7d8(0x280)][_0x56b7d8(0x26d)],'webhookCorsOrigins':_0x3b794d[_0x56b7d8(0x280)][_0x56b7d8(0x281)]});}return{'projectName':_0x267450,'projectId':_0x489c62,'counts':{'agents':_0x42a00a[_0x56b7d8(0x297)],'knowledgeBases':_0x187f39[_0x56b7d8(0x297)],'prompts':_0x1dfaa0[_0x56b7d8(0x297)],'integrations':_0x2feab9['length']},'sourceSite':_0x19be44};}[a87_0x523c07(0x274)](_0x2708b5,_0x46edcc){const _0x2b4f11=a87_0x523c07;if(!a87_0x4b9004[_0x2b4f11(0x1ec)](_0x2708b5))return _0x46edcc;return JSON[_0x2b4f11(0x219)](a87_0x4b9004['readFileSync'](_0x2708b5,_0x2b4f11(0x248)));}['getBackupMetadata'](_0x4f6227){const _0x45269b=a87_0x523c07;if(!a87_0x4b9004[_0x45269b(0x1ec)](_0x4f6227))throw new SDKError(ErrorCode[_0x45269b(0x273)],_0x45269b(0x1f5)+_0x4f6227,undefined,{'helpText':_0x45269b(0x1eb)});const _0x186721=a87_0x445c58[_0x45269b(0x240)](_0x4f6227,_0x45269b(0x24a));if(!a87_0x4b9004['existsSync'](_0x186721))throw new SDKError(ErrorCode[_0x45269b(0x2b2)],'Invalid\x20backup:\x20project.json\x20not\x20found\x20in\x20'+_0x4f6227,undefined,{'helpText':'Ensure\x20this\x20is\x20a\x20valid\x20LLM\x20project\x20backup\x20folder.'});const _0x367722=JSON[_0x45269b(0x219)](a87_0x4b9004[_0x45269b(0x279)](_0x186721,'utf-8'));if(!isSupportedBackupVersion(_0x367722[_0x45269b(0x2aa)]))throw new SDKError(ErrorCode[_0x45269b(0x2b2)],_0x45269b(0x29a)+_0x367722[_0x45269b(0x2aa)],undefined,{'helpText':_0x45269b(0x251)});return _0x367722;}async[a87_0x523c07(0x216)](_0xb4cb15,_0x549eff,_0x463fc4){const _0x5cd6b8=a87_0x523c07,{projectId:_0x4db5ad,project:_0x29fad9}=await this[_0x5cd6b8(0x23e)](_0xb4cb15),_0x9c6036=_0x29fad9[_0x5cd6b8(0x280)][_0x5cd6b8(0x21e)],_0x4f538f=normalizeName(_0x9c6036),_0x39b278=_0x549eff||a87_0x445c58['join'](process[_0x5cd6b8(0x20a)](),_0x5cd6b8(0x20b),_0x4f538f),_0x4fb9b1=await this[_0x5cd6b8(0x265)][_0x5cd6b8(0x1fe)](_0x4db5ad),_0x812067=await this[_0x5cd6b8(0x265)][_0x5cd6b8(0x25a)](_0x4db5ad),_0x1afe52=await this['client']['listTextKnowledgeBases'](_0x4db5ad),_0x4d3d27=await this[_0x5cd6b8(0x265)][_0x5cd6b8(0x22e)](_0x4db5ad),_0x2ad54f=await this[_0x5cd6b8(0x265)][_0x5cd6b8(0x1f4)](_0x4db5ad),_0x4cfa27=await this[_0x5cd6b8(0x265)][_0x5cd6b8(0x255)](_0x4db5ad),_0x2f39dc=new Map(),_0x498a11=new Map(),_0x22c1eb=new Map(),_0x37e0fa=new Map(),_0x4b50c=new Map(),_0x154696=new Map();for(const _0x2d4f5e of _0x4fb9b1){_0x2f39dc[_0x5cd6b8(0x23b)](_0x2d4f5e['id'],_0x2d4f5e[_0x5cd6b8(0x280)][_0x5cd6b8(0x21e)]);}for(const _0x1c8906 of _0x812067){_0x498a11[_0x5cd6b8(0x23b)](_0x1c8906['id'],_0x1c8906[_0x5cd6b8(0x280)][_0x5cd6b8(0x21e)]);}for(const _0x26853a of _0x1afe52){_0x22c1eb[_0x5cd6b8(0x23b)](_0x26853a['id'],_0x26853a['attributes']['name']);}for(const _0x5f55e8 of _0x4d3d27){_0x37e0fa['set'](_0x5f55e8['id'],_0x5f55e8[_0x5cd6b8(0x280)][_0x5cd6b8(0x21e)]);}for(const _0x11e505 of _0x2ad54f){_0x4b50c['set'](_0x11e505['id'],_0x11e505[_0x5cd6b8(0x280)]['name']);}for(const _0x321700 of _0x4cfa27){_0x154696['set'](_0x321700['id'],_0x321700[_0x5cd6b8(0x280)][_0x5cd6b8(0x21e)]);}const _0x167767={'resolveKnowledgeBaseName':async _0x1c450f=>_0x498a11['get'](_0x1c450f),'resolveTextKnowledgeBaseName':async _0x4fbe26=>_0x22c1eb['get'](_0x4fbe26),'resolveAgentName':async _0x12945b=>_0x2f39dc[_0x5cd6b8(0x29f)](_0x12945b),'resolveWebSearchToolName':async _0x260328=>_0x4b50c['get'](_0x260328),'resolveImageGeneratorName':async _0x45ff5f=>_0x37e0fa[_0x5cd6b8(0x29f)](_0x45ff5f),'resolvePromptName':async _0x43776d=>_0x154696['get'](_0x43776d),'onWarning':_0x45a2a4=>this[_0x5cd6b8(0x227)][_0x5cd6b8(0x261)]?.[_0x5cd6b8(0x208)](_0x45a2a4)},_0x5aab3e={'projectName':_0x9c6036,'outputDir':_0x39b278,'agents':[],'knowledgeBases':[],'textKnowledgeBases':[],'prompts':[],'counts':{'agents':{'total':0x0,'new':0x0,'updated':0x0,'unchanged':0x0},'knowledgeBases':{'total':0x0,'new':0x0,'updated':0x0,'unchanged':0x0},'textKnowledgeBases':{'total':0x0,'new':0x0,'updated':0x0,'unchanged':0x0},'prompts':{'total':0x0,'new':0x0,'updated':0x0,'unchanged':0x0}}},_0x41e03c=[],_0x3faa6d=new UniqueNameGenerator(),_0xceda20=new UniqueNameGenerator(),_0x3f1b4a=new UniqueNameGenerator(),_0x1cd7b3=new UniqueNameGenerator();for(const _0xd2dd03 of _0x4fb9b1){const _0x41e8b7=_0x3faa6d[_0x5cd6b8(0x200)](_0xd2dd03[_0x5cd6b8(0x280)]['name']),_0x18ce03=a87_0x445c58[_0x5cd6b8(0x240)](_0x39b278,_0x41e8b7),_0x415d03=a87_0x445c58[_0x5cd6b8(0x240)](_0x18ce03,_0x5cd6b8(0x2bc)),_0x340819=a87_0x445c58[_0x5cd6b8(0x240)](_0x18ce03,_0x5cd6b8(0x29e)),_0x51b645=a87_0x445c58[_0x5cd6b8(0x240)](_0x18ce03,_0x5cd6b8(0x245)),{yaml:_0x3e3ef3,systemPrompt:_0x448e0c,starterMessage:_0x4e14d7}=await agentResponseToDef(_0xd2dd03,_0x167767),_0x35c470=toAgentYamlString(_0x3e3ef3),_0x312c27=!a87_0x4b9004['existsSync'](_0x340819);let _0x434df2=_0x312c27,_0x2105d5;if(!_0x312c27){const _0x490cb0=a87_0x4b9004['existsSync'](_0x415d03)?a87_0x4b9004[_0x5cd6b8(0x279)](_0x415d03,'utf-8'):'',_0x458ac7=a87_0x4b9004[_0x5cd6b8(0x279)](_0x340819,'utf-8'),_0x1ed46f=_0x5cd6b8(0x26c)+_0x490cb0+'\x0a\x0a#\x20agent.yml\x0a'+_0x458ac7,_0x191861=_0x5cd6b8(0x26c)+_0x448e0c+_0x5cd6b8(0x258)+_0x35c470,_0x4337e7=generateDiff(_0x1ed46f,_0x191861);_0x434df2=hasChanges(_0x4337e7),_0x434df2&&(_0x2105d5=formatDiffWithColors(_0x4337e7));}_0x41e03c[_0x5cd6b8(0x1fd)]({'path':_0x18ce03,'content':'','isDir':!![]}),_0x41e03c[_0x5cd6b8(0x1fd)]({'path':_0x415d03,'content':_0x448e0c}),_0x41e03c['push']({'path':_0x340819,'content':_0x35c470});_0x4e14d7&&_0x4e14d7['includes']('\x0a')&&_0x41e03c[_0x5cd6b8(0x1fd)]({'path':_0x51b645,'content':_0x4e14d7});_0x5aab3e[_0x5cd6b8(0x20b)][_0x5cd6b8(0x1fd)]({'agentName':_0xd2dd03[_0x5cd6b8(0x280)]['name'],'outputPath':_0x18ce03,'isNew':_0x312c27,'hasChanges':_0x434df2,'diff':_0x2105d5}),_0x5aab3e[_0x5cd6b8(0x21f)]['agents'][_0x5cd6b8(0x2b0)]++;if(_0x312c27)_0x5aab3e[_0x5cd6b8(0x21f)][_0x5cd6b8(0x20b)][_0x5cd6b8(0x2b8)]++;else{if(_0x434df2)_0x5aab3e[_0x5cd6b8(0x21f)][_0x5cd6b8(0x20b)][_0x5cd6b8(0x266)]++;else _0x5aab3e[_0x5cd6b8(0x21f)][_0x5cd6b8(0x20b)]['unchanged']++;}}for(const _0x3d67ba of _0x812067){if(_0x3d67ba[_0x5cd6b8(0x280)][_0x5cd6b8(0x2a7)])continue;const _0x21c107=_0xceda20[_0x5cd6b8(0x200)](_0x3d67ba['attributes'][_0x5cd6b8(0x21e)]),_0xdb0346=a87_0x445c58[_0x5cd6b8(0x240)](getKnowledgeBasesDir(_0x39b278),_0x21c107+_0x5cd6b8(0x1fc)),_0xcab4f=apiKnowledgeBaseToYaml(_0x3d67ba),_0x43e20d=toKnowledgeBaseYamlString(_0xcab4f),_0x393dc1=!a87_0x4b9004[_0x5cd6b8(0x1ec)](_0xdb0346);let _0x32a9ce=_0x393dc1,_0x1e8b9f;if(!_0x393dc1){const _0x489c36=a87_0x4b9004[_0x5cd6b8(0x279)](_0xdb0346,'utf-8'),_0x1b2fbd=generateDiff(_0x489c36,_0x43e20d);_0x32a9ce=hasChanges(_0x1b2fbd),_0x32a9ce&&(_0x1e8b9f=formatDiffWithColors(_0x1b2fbd));}_0x41e03c['push']({'path':_0xdb0346,'content':_0x43e20d}),_0x5aab3e[_0x5cd6b8(0x28a)][_0x5cd6b8(0x1fd)]({'name':_0x3d67ba[_0x5cd6b8(0x280)][_0x5cd6b8(0x21e)],'outputPath':_0xdb0346,'isNew':_0x393dc1,'hasChanges':_0x32a9ce,'diff':_0x1e8b9f}),_0x5aab3e[_0x5cd6b8(0x21f)][_0x5cd6b8(0x28a)][_0x5cd6b8(0x2b0)]++;if(_0x393dc1)_0x5aab3e[_0x5cd6b8(0x21f)]['knowledgeBases'][_0x5cd6b8(0x2b8)]++;else{if(_0x32a9ce)_0x5aab3e['counts'][_0x5cd6b8(0x28a)][_0x5cd6b8(0x266)]++;else _0x5aab3e[_0x5cd6b8(0x21f)][_0x5cd6b8(0x28a)]['unchanged']++;}}for(const _0x5e4185 of _0x1afe52){if(_0x5e4185[_0x5cd6b8(0x280)][_0x5cd6b8(0x2a7)])continue;const _0x24e736=_0x3f1b4a[_0x5cd6b8(0x200)](_0x5e4185[_0x5cd6b8(0x280)][_0x5cd6b8(0x21e)]),_0x566904=a87_0x445c58[_0x5cd6b8(0x240)](getKnowledgeBasesDir(_0x39b278),_0x24e736+_0x5cd6b8(0x268)),_0x297d41=toTextKnowledgeBaseMd(_0x5e4185[_0x5cd6b8(0x280)][_0x5cd6b8(0x21e)],_0x5e4185[_0x5cd6b8(0x280)][_0x5cd6b8(0x246)]),_0x15e502=!a87_0x4b9004[_0x5cd6b8(0x1ec)](_0x566904);let _0x2f1f4d=_0x15e502,_0x51f989;if(!_0x15e502){const _0x3e3e85=a87_0x4b9004[_0x5cd6b8(0x279)](_0x566904,_0x5cd6b8(0x248)),_0xd2accd=generateDiff(_0x3e3e85,_0x297d41);_0x2f1f4d=hasChanges(_0xd2accd),_0x2f1f4d&&(_0x51f989=formatDiffWithColors(_0xd2accd));}_0x41e03c[_0x5cd6b8(0x1fd)]({'path':_0x566904,'content':_0x297d41}),_0x5aab3e[_0x5cd6b8(0x2a3)][_0x5cd6b8(0x1fd)]({'name':_0x5e4185[_0x5cd6b8(0x280)][_0x5cd6b8(0x21e)],'outputPath':_0x566904,'isNew':_0x15e502,'hasChanges':_0x2f1f4d,'diff':_0x51f989}),_0x5aab3e[_0x5cd6b8(0x21f)][_0x5cd6b8(0x2a3)][_0x5cd6b8(0x2b0)]++;if(_0x15e502)_0x5aab3e[_0x5cd6b8(0x21f)]['textKnowledgeBases'][_0x5cd6b8(0x2b8)]++;else{if(_0x2f1f4d)_0x5aab3e[_0x5cd6b8(0x21f)][_0x5cd6b8(0x2a3)][_0x5cd6b8(0x266)]++;else _0x5aab3e['counts'][_0x5cd6b8(0x2a3)][_0x5cd6b8(0x2b5)]++;}}for(const _0x40124a of _0x4cfa27){if(_0x40124a[_0x5cd6b8(0x280)][_0x5cd6b8(0x2a7)])continue;const _0x2f7fea=_0x1cd7b3[_0x5cd6b8(0x200)](_0x40124a[_0x5cd6b8(0x280)]['name']),_0x14384f=a87_0x445c58[_0x5cd6b8(0x240)](getPromptsDir(_0x39b278),_0x2f7fea+_0x5cd6b8(0x1fc)),_0x47c9dc=await apiPromptToYaml(_0x40124a,_0x167767);if(!_0x47c9dc)continue;const _0x21556d=toPromptYamlString(_0x47c9dc),_0x374e76=!a87_0x4b9004[_0x5cd6b8(0x1ec)](_0x14384f);let _0x162548=_0x374e76,_0x3ccd04;if(!_0x374e76){const _0x29f256=a87_0x4b9004[_0x5cd6b8(0x279)](_0x14384f,_0x5cd6b8(0x248)),_0x5f31e5=generateDiff(_0x29f256,_0x21556d);_0x162548=hasChanges(_0x5f31e5),_0x162548&&(_0x3ccd04=formatDiffWithColors(_0x5f31e5));}_0x41e03c[_0x5cd6b8(0x1fd)]({'path':_0x14384f,'content':_0x21556d}),_0x5aab3e['prompts'][_0x5cd6b8(0x1fd)]({'name':_0x40124a[_0x5cd6b8(0x280)][_0x5cd6b8(0x21e)],'outputPath':_0x14384f,'isNew':_0x374e76,'hasChanges':_0x162548,'diff':_0x3ccd04}),_0x5aab3e['counts'][_0x5cd6b8(0x230)][_0x5cd6b8(0x2b0)]++;if(_0x374e76)_0x5aab3e['counts'][_0x5cd6b8(0x230)][_0x5cd6b8(0x2b8)]++;else{if(_0x162548)_0x5aab3e[_0x5cd6b8(0x21f)]['prompts']['updated']++;else _0x5aab3e[_0x5cd6b8(0x21f)]['prompts'][_0x5cd6b8(0x2b5)]++;}}if(_0x463fc4?.[_0x5cd6b8(0x293)])return _0x5aab3e;a87_0x4b9004[_0x5cd6b8(0x24d)](_0x39b278,{'recursive':!![]}),a87_0x4b9004['mkdirSync'](getKnowledgeBasesDir(_0x39b278),{'recursive':!![]}),a87_0x4b9004[_0x5cd6b8(0x24d)](getPromptsDir(_0x39b278),{'recursive':!![]});const _0x21c954=a87_0x445c58[_0x5cd6b8(0x240)](_0x39b278,_0x5cd6b8(0x1f2));a87_0x4b9004[_0x5cd6b8(0x1e5)](_0x21c954,createAgentConfigContent(_0x9c6036));for(const _0x343f44 of _0x41e03c){if(_0x343f44[_0x5cd6b8(0x20e)])a87_0x4b9004[_0x5cd6b8(0x24d)](_0x343f44['path'],{'recursive':!![]});else{const _0x1e5384=a87_0x445c58[_0x5cd6b8(0x206)](_0x343f44[_0x5cd6b8(0x1ef)]);!a87_0x4b9004[_0x5cd6b8(0x1ec)](_0x1e5384)&&a87_0x4b9004[_0x5cd6b8(0x24d)](_0x1e5384,{'recursive':!![]}),a87_0x4b9004[_0x5cd6b8(0x1e5)](_0x343f44[_0x5cd6b8(0x1ef)],_0x343f44[_0x5cd6b8(0x26b)]);}}return _0x5aab3e;}async[a87_0x523c07(0x2b7)](_0x2ada83,_0x5bc8d7){const _0x4e7b23=a87_0x523c07,_0x1d6330=a87_0x445c58[_0x4e7b23(0x240)](_0x2ada83,_0x4e7b23(0x1f2));if(!a87_0x4b9004['existsSync'](_0x1d6330))throw new SDKError(ErrorCode[_0x4e7b23(0x2b2)],_0x4e7b23(0x28f)+_0x2ada83,undefined,{'helpText':_0x4e7b23(0x24f)});const _0xd5d94d=loadAgentConfig(_0x1d6330),_0x1332ce=await this[_0x4e7b23(0x24e)](_0xd5d94d[_0x4e7b23(0x288)]),_0x303359=await this[_0x4e7b23(0x265)][_0x4e7b23(0x2ba)](_0x1332ce),_0x17b8b3=_0x303359[_0x4e7b23(0x280)][_0x4e7b23(0x21e)],_0x373f87={'projectName':_0x17b8b3,'projectId':_0x1332ce,'agents':[],'knowledgeBases':[],'textKnowledgeBases':[],'prompts':[],'counts':{'agents':{'created':0x0,'updated':0x0,'unchanged':0x0,'errors':0x0},'knowledgeBases':{'created':0x0,'updated':0x0,'unchanged':0x0,'errors':0x0},'textKnowledgeBases':{'created':0x0,'updated':0x0,'unchanged':0x0,'errors':0x0},'prompts':{'created':0x0,'updated':0x0,'unchanged':0x0,'errors':0x0}}},_0x5c5cf6=[],_0x24e223=[],_0x3b274d=[],_0x7b3352=[],_0xbab173=a87_0x4b9004[_0x4e7b23(0x226)](_0x2ada83,{'withFileTypes':!![]});for(const _0x14286d of _0xbab173){if(!_0x14286d[_0x4e7b23(0x1f6)]())continue;if([_0x4e7b23(0x252),_0x4e7b23(0x230),_0x4e7b23(0x2a5)][_0x4e7b23(0x223)](_0x14286d[_0x4e7b23(0x21e)]))continue;const _0x2a2d33=a87_0x445c58[_0x4e7b23(0x240)](_0x2ada83,_0x14286d[_0x4e7b23(0x21e)]);if(isAgentDir(_0x2a2d33)){const _0x28fc47=a87_0x445c58['join'](_0x2a2d33,_0x4e7b23(0x29e)),_0x452208=a87_0x445c58[_0x4e7b23(0x240)](_0x2a2d33,_0x4e7b23(0x2bc)),_0x25ccc4=a87_0x445c58[_0x4e7b23(0x240)](_0x2a2d33,_0x4e7b23(0x245)),_0x1e5b74=parseAgentYaml(a87_0x4b9004['readFileSync'](_0x28fc47,'utf-8'),_0x28fc47),_0x53d902=a87_0x4b9004[_0x4e7b23(0x1ec)](_0x452208)?a87_0x4b9004['readFileSync'](_0x452208,_0x4e7b23(0x248)):'',_0x5ca82a=a87_0x4b9004[_0x4e7b23(0x1ec)](_0x25ccc4)?a87_0x4b9004[_0x4e7b23(0x279)](_0x25ccc4,_0x4e7b23(0x248)):_0x1e5b74[_0x4e7b23(0x215)];_0x5c5cf6[_0x4e7b23(0x1fd)]({'name':_0x1e5b74[_0x4e7b23(0x21e)],'dir':_0x2a2d33,'yaml':_0x1e5b74,'systemPrompt':_0x53d902,'starterMessage':_0x5ca82a});}}const _0x35d9c0=getKnowledgeBasesDir(_0x2ada83);if(a87_0x4b9004['existsSync'](_0x35d9c0)){const _0x3b3c3c=a87_0x4b9004['readdirSync'](_0x35d9c0);for(const _0x3464d5 of _0x3b3c3c){const _0x2d44b2=a87_0x445c58['join'](_0x35d9c0,_0x3464d5);if(_0x3464d5[_0x4e7b23(0x24c)]('.yml')){const _0xed9fdd=parseKnowledgeBaseYaml(a87_0x4b9004[_0x4e7b23(0x279)](_0x2d44b2,_0x4e7b23(0x248)),_0x2d44b2);_0x24e223[_0x4e7b23(0x1fd)]({'name':_0xed9fdd['name'],'path':_0x2d44b2,'yaml':_0xed9fdd});}else{if(_0x3464d5[_0x4e7b23(0x24c)]('.md')){const _0x577f54=a87_0x4b9004[_0x4e7b23(0x279)](_0x2d44b2,'utf-8'),{name:_0x664c5b,text:_0x28831c}=parseTextKnowledgeBaseMd(_0x577f54,_0x3464d5);_0x3b274d[_0x4e7b23(0x1fd)]({'name':_0x664c5b,'path':_0x2d44b2,'text':_0x28831c});}}}}const _0x1c82a7=getPromptsDir(_0x2ada83);if(a87_0x4b9004[_0x4e7b23(0x1ec)](_0x1c82a7)){const _0x158b35=a87_0x4b9004[_0x4e7b23(0x226)](_0x1c82a7)[_0x4e7b23(0x22b)](_0x31eddd=>_0x31eddd['endsWith'](_0x4e7b23(0x1fc)));for(const _0x2376a9 of _0x158b35){const _0x160686=a87_0x445c58['join'](_0x1c82a7,_0x2376a9),_0x2b3668=parsePromptYaml(a87_0x4b9004['readFileSync'](_0x160686,'utf-8'),_0x160686);_0x7b3352[_0x4e7b23(0x1fd)]({'name':_0x2b3668[_0x4e7b23(0x21e)],'path':_0x160686,'yaml':_0x2b3668});}}const _0x5a751b=await this[_0x4e7b23(0x265)][_0x4e7b23(0x1fe)](_0x1332ce),_0x34b9f5=await this['client'][_0x4e7b23(0x25a)](_0x1332ce),_0x2c9061=await this[_0x4e7b23(0x265)][_0x4e7b23(0x291)](_0x1332ce),_0x41c57e=await this[_0x4e7b23(0x265)][_0x4e7b23(0x22e)](_0x1332ce),_0xbdad4f=await this[_0x4e7b23(0x265)][_0x4e7b23(0x1f4)](_0x1332ce),_0x4435c9=await this['client']['listPrompts'](_0x1332ce),_0x2ffe55=new Map(),_0x1f98ff=new Map(),_0x29a8b9=new Map(),_0x289452=new Map();for(const _0x40c454 of _0x5a751b){_0x2ffe55[_0x4e7b23(0x23b)](_0x40c454[_0x4e7b23(0x280)][_0x4e7b23(0x21e)],_0x40c454);}for(const _0x6819e4 of _0x34b9f5){_0x1f98ff[_0x4e7b23(0x23b)](_0x6819e4['attributes'][_0x4e7b23(0x21e)],_0x6819e4);}for(const _0x44dc16 of _0x2c9061){_0x29a8b9[_0x4e7b23(0x23b)](_0x44dc16[_0x4e7b23(0x280)][_0x4e7b23(0x21e)],_0x44dc16);}for(const _0x128f9c of _0x4435c9){_0x289452['set'](_0x128f9c[_0x4e7b23(0x280)][_0x4e7b23(0x21e)],_0x128f9c);}const _0x215b70=new Map(),_0x1893cb=new Map(),_0x111c32=new Map(),_0x304252=new Map(),_0x5ea928=new Map(),_0x4b0b19=new Map(),_0x313d01=new Map(),_0x2b936c=new Map(),_0x8b99b5=new Map(),_0x1a92dd=new Map(),_0x446194=new Map(),_0x109bcb=new Map();for(const _0x5535f6 of _0x34b9f5){_0x215b70[_0x4e7b23(0x23b)](_0x5535f6[_0x4e7b23(0x280)][_0x4e7b23(0x21e)],_0x5535f6['id']),_0x313d01['set'](_0x5535f6['id'],_0x5535f6[_0x4e7b23(0x280)]['name']);}for(const _0x27bd1c of _0x2c9061){_0x1893cb[_0x4e7b23(0x23b)](_0x27bd1c[_0x4e7b23(0x280)][_0x4e7b23(0x21e)],_0x27bd1c['id']),_0x2b936c[_0x4e7b23(0x23b)](_0x27bd1c['id'],_0x27bd1c[_0x4e7b23(0x280)][_0x4e7b23(0x21e)]);}for(const _0x37f841 of _0x5a751b){_0x111c32[_0x4e7b23(0x23b)](_0x37f841[_0x4e7b23(0x280)][_0x4e7b23(0x21e)],_0x37f841['id']),_0x8b99b5[_0x4e7b23(0x23b)](_0x37f841['id'],_0x37f841['attributes']['name']);}for(const _0x249855 of _0x41c57e){_0x304252['set'](_0x249855[_0x4e7b23(0x280)][_0x4e7b23(0x21e)],_0x249855['id']),_0x1a92dd['set'](_0x249855['id'],_0x249855[_0x4e7b23(0x280)][_0x4e7b23(0x21e)]);}for(const _0x3c2e53 of _0xbdad4f){_0x5ea928[_0x4e7b23(0x23b)](_0x3c2e53['attributes'][_0x4e7b23(0x21e)],_0x3c2e53['id']),_0x446194[_0x4e7b23(0x23b)](_0x3c2e53['id'],_0x3c2e53['attributes'][_0x4e7b23(0x21e)]);}for(const _0x5dadda of _0x4435c9){_0x4b0b19[_0x4e7b23(0x23b)](_0x5dadda['attributes'][_0x4e7b23(0x21e)],_0x5dadda['id']),_0x109bcb[_0x4e7b23(0x23b)](_0x5dadda['id'],_0x5dadda[_0x4e7b23(0x280)]['name']);}const _0x20d1f1={'resolveKnowledgeBaseName':async _0x183c9c=>_0x313d01[_0x4e7b23(0x29f)](_0x183c9c),'resolveTextKnowledgeBaseName':async _0xc70ef8=>_0x2b936c[_0x4e7b23(0x29f)](_0xc70ef8),'resolveAgentName':async _0x4d4437=>_0x8b99b5[_0x4e7b23(0x29f)](_0x4d4437),'resolveWebSearchToolName':async _0x56ba88=>_0x446194['get'](_0x56ba88),'resolveImageGeneratorName':async _0x43c244=>_0x1a92dd[_0x4e7b23(0x29f)](_0x43c244),'resolvePromptName':async _0x213953=>_0x109bcb[_0x4e7b23(0x29f)](_0x213953),'onWarning':_0x4e10f4=>this[_0x4e7b23(0x227)][_0x4e7b23(0x261)]?.[_0x4e7b23(0x208)](_0x4e10f4)},_0x4ed7c2={'projectId':_0x1332ce,'resolveKnowledgeBaseId':async _0x55405a=>_0x215b70[_0x4e7b23(0x29f)](_0x55405a),'resolveTextKnowledgeBaseId':async _0x1db68d=>_0x1893cb[_0x4e7b23(0x29f)](_0x1db68d),'resolveAgentId':async _0x247009=>_0x111c32[_0x4e7b23(0x29f)](_0x247009),'resolveWebSearchToolId':async _0x5c9373=>_0x5ea928[_0x4e7b23(0x29f)](_0x5c9373),'resolveImageGeneratorId':async _0x166463=>_0x304252['get'](_0x166463),'resolvePromptId':async _0x442cd6=>_0x4b0b19[_0x4e7b23(0x29f)](_0x442cd6),'onWarning':_0x460f79=>this['context'][_0x4e7b23(0x261)]?.[_0x4e7b23(0x208)](_0x460f79)},{resolved:_0x1ed6d8,unresolved:_0x12b275}=resolveAgentDependencies(_0x5c5cf6,new Set(_0x2ffe55[_0x4e7b23(0x224)]()));for(const {agent:_0x4ac37b,missingDeps:_0x6310f9}of _0x12b275){_0x373f87[_0x4e7b23(0x20b)]['push']({'agentName':_0x4ac37b[_0x4e7b23(0x28e)][_0x4e7b23(0x21e)],'action':_0x4e7b23(0x2b9),'error':_0x4e7b23(0x287)+_0x6310f9[_0x4e7b23(0x240)](',\x20')+_0x4e7b23(0x1e3)}),_0x373f87[_0x4e7b23(0x21f)][_0x4e7b23(0x20b)][_0x4e7b23(0x28c)]++;}for(const _0x4ad9a5 of _0x24e223){const _0x67a371=_0x1f98ff[_0x4e7b23(0x29f)](_0x4ad9a5[_0x4e7b23(0x28e)][_0x4e7b23(0x21e)]),_0x17c99c=a87_0x4b9004[_0x4e7b23(0x279)](_0x4ad9a5['path'],_0x4e7b23(0x248));if(_0x67a371){const _0xa13068=apiKnowledgeBaseToYaml(_0x67a371),_0x10dd2f=toKnowledgeBaseYamlString(_0xa13068),_0x4a54be=generateDiff(_0x10dd2f,_0x17c99c),_0x21def4=hasChanges(_0x4a54be);_0x21def4?(_0x373f87['knowledgeBases'][_0x4e7b23(0x1fd)]({'name':_0x4ad9a5['yaml'][_0x4e7b23(0x21e)],'action':_0x4e7b23(0x266),'id':_0x67a371['id'],'diff':formatDiffWithColors(_0x4a54be)}),_0x373f87[_0x4e7b23(0x21f)]['knowledgeBases']['updated']++):(_0x373f87[_0x4e7b23(0x28a)][_0x4e7b23(0x1fd)]({'name':_0x4ad9a5[_0x4e7b23(0x28e)]['name'],'action':_0x4e7b23(0x2b5),'id':_0x67a371['id']}),_0x373f87[_0x4e7b23(0x21f)][_0x4e7b23(0x28a)][_0x4e7b23(0x2b5)]++);}else _0x373f87[_0x4e7b23(0x28a)]['push']({'name':_0x4ad9a5[_0x4e7b23(0x28e)][_0x4e7b23(0x21e)],'action':'created'}),_0x373f87[_0x4e7b23(0x21f)][_0x4e7b23(0x28a)][_0x4e7b23(0x2b4)]++;}for(const _0x51f7bf of _0x3b274d){const _0x4052bd=_0x29a8b9[_0x4e7b23(0x29f)](_0x51f7bf[_0x4e7b23(0x21e)]),_0x16735c=a87_0x4b9004[_0x4e7b23(0x279)](_0x51f7bf[_0x4e7b23(0x1ef)],_0x4e7b23(0x248));if(_0x4052bd){const _0x23122d=toTextKnowledgeBaseMd(_0x4052bd['attributes'][_0x4e7b23(0x21e)],_0x4052bd[_0x4e7b23(0x280)][_0x4e7b23(0x246)]),_0x2450a7=generateDiff(_0x23122d,_0x16735c),_0x10ef9c=hasChanges(_0x2450a7);_0x10ef9c?(_0x373f87[_0x4e7b23(0x2a3)][_0x4e7b23(0x1fd)]({'name':_0x51f7bf['name'],'action':_0x4e7b23(0x266),'id':_0x4052bd['id'],'diff':formatDiffWithColors(_0x2450a7)}),_0x373f87[_0x4e7b23(0x21f)][_0x4e7b23(0x2a3)][_0x4e7b23(0x266)]++):(_0x373f87['textKnowledgeBases']['push']({'name':_0x51f7bf['name'],'action':'unchanged','id':_0x4052bd['id']}),_0x373f87[_0x4e7b23(0x21f)][_0x4e7b23(0x2a3)][_0x4e7b23(0x2b5)]++);}else _0x373f87['textKnowledgeBases'][_0x4e7b23(0x1fd)]({'name':_0x51f7bf[_0x4e7b23(0x21e)],'action':_0x4e7b23(0x2b4)}),_0x373f87[_0x4e7b23(0x21f)]['textKnowledgeBases'][_0x4e7b23(0x2b4)]++;}for(const _0x121d16 of _0x1ed6d8){const _0x37d558=_0x2ffe55[_0x4e7b23(0x29f)](_0x121d16[_0x4e7b23(0x28e)][_0x4e7b23(0x21e)]),_0x32bb59=a87_0x445c58['join'](_0x121d16['dir'],'agent.yml'),_0x51ccf7=a87_0x4b9004[_0x4e7b23(0x279)](_0x32bb59,'utf-8'),_0x397568=_0x121d16[_0x4e7b23(0x2a6)],_0x1d4a41=_0x4e7b23(0x26c)+_0x397568+'\x0a\x0a#\x20agent.yml\x0a'+_0x51ccf7;if(_0x37d558){const {yaml:_0x53eb7b,systemPrompt:_0x55603d}=await agentResponseToDef(_0x37d558,_0x20d1f1),_0x5a0172=toAgentYamlString(_0x53eb7b),_0x230cb2=_0x4e7b23(0x26c)+_0x55603d+_0x4e7b23(0x258)+_0x5a0172,_0x2fe2f9=generateDiff(_0x230cb2,_0x1d4a41),_0x13291c=hasChanges(_0x2fe2f9);_0x13291c?(_0x373f87[_0x4e7b23(0x20b)][_0x4e7b23(0x1fd)]({'agentName':_0x121d16[_0x4e7b23(0x28e)][_0x4e7b23(0x21e)],'action':_0x4e7b23(0x266),'agentId':_0x37d558['id'],'diff':formatDiffWithColors(_0x2fe2f9)}),_0x373f87[_0x4e7b23(0x21f)][_0x4e7b23(0x20b)][_0x4e7b23(0x266)]++):(_0x373f87['agents'][_0x4e7b23(0x1fd)]({'agentName':_0x121d16[_0x4e7b23(0x28e)]['name'],'action':_0x4e7b23(0x2b5),'agentId':_0x37d558['id']}),_0x373f87['counts'][_0x4e7b23(0x20b)][_0x4e7b23(0x2b5)]++);}else _0x373f87[_0x4e7b23(0x20b)][_0x4e7b23(0x1fd)]({'agentName':_0x121d16[_0x4e7b23(0x28e)][_0x4e7b23(0x21e)],'action':_0x4e7b23(0x2b4)}),_0x373f87[_0x4e7b23(0x21f)]['agents'][_0x4e7b23(0x2b4)]++;}for(const _0x2df88e of _0x7b3352){const _0x163637=_0x289452[_0x4e7b23(0x29f)](_0x2df88e[_0x4e7b23(0x28e)][_0x4e7b23(0x21e)]),_0x1ed0d3=a87_0x4b9004['readFileSync'](_0x2df88e[_0x4e7b23(0x1ef)],_0x4e7b23(0x248));if(_0x163637){const _0x2c1bdb=await apiPromptToYaml(_0x163637,_0x20d1f1);if(!_0x2c1bdb){_0x373f87[_0x4e7b23(0x230)][_0x4e7b23(0x1fd)]({'name':_0x2df88e[_0x4e7b23(0x28e)][_0x4e7b23(0x21e)],'action':'updated','id':_0x163637['id']}),_0x373f87['counts'][_0x4e7b23(0x230)]['updated']++;continue;}const _0x506a89=toPromptYamlString(_0x2c1bdb),_0x1a9642=generateDiff(_0x506a89,_0x1ed0d3),_0x3e9c7=hasChanges(_0x1a9642);_0x3e9c7?(_0x373f87[_0x4e7b23(0x230)][_0x4e7b23(0x1fd)]({'name':_0x2df88e['yaml'][_0x4e7b23(0x21e)],'action':_0x4e7b23(0x266),'id':_0x163637['id'],'diff':formatDiffWithColors(_0x1a9642)}),_0x373f87[_0x4e7b23(0x21f)][_0x4e7b23(0x230)]['updated']++):(_0x373f87[_0x4e7b23(0x230)][_0x4e7b23(0x1fd)]({'name':_0x2df88e[_0x4e7b23(0x28e)][_0x4e7b23(0x21e)],'action':_0x4e7b23(0x2b5),'id':_0x163637['id']}),_0x373f87['counts'][_0x4e7b23(0x230)]['unchanged']++);}else _0x373f87[_0x4e7b23(0x230)][_0x4e7b23(0x1fd)]({'name':_0x2df88e[_0x4e7b23(0x28e)][_0x4e7b23(0x21e)],'action':_0x4e7b23(0x2b4)}),_0x373f87[_0x4e7b23(0x21f)][_0x4e7b23(0x230)][_0x4e7b23(0x2b4)]++;}if(_0x5bc8d7?.[_0x4e7b23(0x293)])return _0x373f87;_0x373f87[_0x4e7b23(0x28a)]=[],_0x373f87[_0x4e7b23(0x2a3)]=[],_0x373f87['prompts']=[];const _0x379c60=_0x373f87['agents'][_0x4e7b23(0x22b)](_0x587e1b=>_0x587e1b[_0x4e7b23(0x22d)]==='error');_0x373f87[_0x4e7b23(0x20b)]=_0x379c60,_0x373f87[_0x4e7b23(0x21f)]={'agents':{'created':0x0,'updated':0x0,'unchanged':0x0,'errors':_0x379c60[_0x4e7b23(0x23c)]},'knowledgeBases':{'created':0x0,'updated':0x0,'unchanged':0x0,'errors':0x0},'textKnowledgeBases':{'created':0x0,'updated':0x0,'unchanged':0x0,'errors':0x0},'prompts':{'created':0x0,'updated':0x0,'unchanged':0x0,'errors':0x0}};for(const _0x19e8e4 of _0x24e223){try{const _0x44962f=_0x1f98ff[_0x4e7b23(0x29f)](_0x19e8e4[_0x4e7b23(0x28e)][_0x4e7b23(0x21e)]),_0x7d1b2d=yamlKnowledgeBaseToApi(_0x19e8e4['yaml'],_0x1332ce);if(_0x44962f)await this[_0x4e7b23(0x265)][_0x4e7b23(0x1f9)](_0x44962f['id'],_0x7d1b2d),_0x215b70['set'](_0x19e8e4[_0x4e7b23(0x28e)][_0x4e7b23(0x21e)],_0x44962f['id']),_0x373f87[_0x4e7b23(0x28a)][_0x4e7b23(0x1fd)]({'name':_0x19e8e4[_0x4e7b23(0x28e)][_0x4e7b23(0x21e)],'action':_0x4e7b23(0x266),'id':_0x44962f['id']}),_0x373f87['counts'][_0x4e7b23(0x28a)][_0x4e7b23(0x266)]++;else{const _0x19d9db=await this[_0x4e7b23(0x265)][_0x4e7b23(0x296)](_0x7d1b2d);_0x215b70[_0x4e7b23(0x23b)](_0x19e8e4[_0x4e7b23(0x28e)]['name'],_0x19d9db['id']),_0x373f87[_0x4e7b23(0x28a)][_0x4e7b23(0x1fd)]({'name':_0x19e8e4[_0x4e7b23(0x28e)][_0x4e7b23(0x21e)],'action':_0x4e7b23(0x2b4),'id':_0x19d9db['id']}),_0x373f87[_0x4e7b23(0x21f)]['knowledgeBases'][_0x4e7b23(0x2b4)]++;}}catch(_0x35b57c){_0x373f87[_0x4e7b23(0x28a)]['push']({'name':_0x19e8e4[_0x4e7b23(0x28e)][_0x4e7b23(0x21e)],'action':_0x4e7b23(0x2b9),'error':_0x35b57c[_0x4e7b23(0x204)]}),_0x373f87[_0x4e7b23(0x21f)]['knowledgeBases'][_0x4e7b23(0x28c)]++;}}for(const _0x5db209 of _0x3b274d){try{const _0x24508e=_0x29a8b9[_0x4e7b23(0x29f)](_0x5db209['name']),_0x348e97=yamlTextKnowledgeBaseToApi({'name':_0x5db209[_0x4e7b23(0x21e)],'text':_0x5db209[_0x4e7b23(0x246)]},_0x1332ce);if(_0x24508e)await this['client'][_0x4e7b23(0x1ea)](_0x24508e['id'],_0x348e97),_0x1893cb['set'](_0x5db209['name'],_0x24508e['id']),_0x373f87['textKnowledgeBases'][_0x4e7b23(0x1fd)]({'name':_0x5db209[_0x4e7b23(0x21e)],'action':_0x4e7b23(0x266),'id':_0x24508e['id']}),_0x373f87[_0x4e7b23(0x21f)][_0x4e7b23(0x2a3)][_0x4e7b23(0x266)]++;else{const _0x4c3026=await this['client'][_0x4e7b23(0x2a9)](_0x348e97);_0x1893cb[_0x4e7b23(0x23b)](_0x5db209['name'],_0x4c3026['id']),_0x373f87[_0x4e7b23(0x2a3)][_0x4e7b23(0x1fd)]({'name':_0x5db209[_0x4e7b23(0x21e)],'action':_0x4e7b23(0x2b4),'id':_0x4c3026['id']}),_0x373f87[_0x4e7b23(0x21f)]['textKnowledgeBases'][_0x4e7b23(0x2b4)]++;}}catch(_0x4ea000){_0x373f87['textKnowledgeBases'][_0x4e7b23(0x1fd)]({'name':_0x5db209['name'],'action':_0x4e7b23(0x2b9),'error':_0x4ea000['message']}),_0x373f87[_0x4e7b23(0x21f)][_0x4e7b23(0x2a3)][_0x4e7b23(0x28c)]++;}}for(const _0x30baf3 of _0x1ed6d8){try{const _0x3d3434=_0x2ffe55[_0x4e7b23(0x29f)](_0x30baf3['yaml'][_0x4e7b23(0x21e)]),_0x6c87a8=await agentDefToRequest(_0x30baf3[_0x4e7b23(0x28e)],_0x30baf3[_0x4e7b23(0x2a6)],_0x30baf3[_0x4e7b23(0x2ab)],_0x4ed7c2);if(_0x3d3434)await this['client'][_0x4e7b23(0x250)](_0x3d3434['id'],_0x6c87a8),_0x111c32[_0x4e7b23(0x23b)](_0x30baf3[_0x4e7b23(0x28e)][_0x4e7b23(0x21e)],_0x3d3434['id']),_0x373f87[_0x4e7b23(0x20b)][_0x4e7b23(0x1fd)]({'agentName':_0x30baf3[_0x4e7b23(0x28e)][_0x4e7b23(0x21e)],'action':_0x4e7b23(0x266),'agentId':_0x3d3434['id']}),_0x373f87[_0x4e7b23(0x21f)][_0x4e7b23(0x20b)]['updated']++;else{const _0x1278a8=await this[_0x4e7b23(0x265)][_0x4e7b23(0x259)](_0x6c87a8);_0x111c32['set'](_0x30baf3[_0x4e7b23(0x28e)]['name'],_0x1278a8['id']),_0x373f87[_0x4e7b23(0x20b)]['push']({'agentName':_0x30baf3[_0x4e7b23(0x28e)][_0x4e7b23(0x21e)],'action':_0x4e7b23(0x2b4),'agentId':_0x1278a8['id']}),_0x373f87['counts']['agents']['created']++;}}catch(_0x2ec793){_0x373f87[_0x4e7b23(0x20b)]['push']({'agentName':_0x30baf3[_0x4e7b23(0x28e)]['name'],'action':'error','error':_0x2ec793['message']}),_0x373f87[_0x4e7b23(0x21f)]['agents'][_0x4e7b23(0x28c)]++;}}for(const _0x1950e4 of _0x7b3352){try{const _0x1eea33=_0x289452[_0x4e7b23(0x29f)](_0x1950e4['yaml']['name']),_0x2d19bd=await yamlPromptToApi(_0x1950e4[_0x4e7b23(0x28e)],_0x1332ce,_0x4ed7c2);if(!_0x2d19bd){_0x373f87[_0x4e7b23(0x230)][_0x4e7b23(0x1fd)]({'name':_0x1950e4[_0x4e7b23(0x28e)][_0x4e7b23(0x21e)],'action':_0x4e7b23(0x2b9),'error':'Agent\x20reference\x20not\x20found'}),_0x373f87[_0x4e7b23(0x21f)][_0x4e7b23(0x230)]['errors']++;continue;}if(_0x1eea33)await this[_0x4e7b23(0x265)][_0x4e7b23(0x209)](_0x1eea33['id'],_0x2d19bd),_0x4b0b19[_0x4e7b23(0x23b)](_0x1950e4['yaml'][_0x4e7b23(0x21e)],_0x1eea33['id']),_0x373f87[_0x4e7b23(0x230)]['push']({'name':_0x1950e4[_0x4e7b23(0x28e)][_0x4e7b23(0x21e)],'action':'updated','id':_0x1eea33['id']}),_0x373f87['counts'][_0x4e7b23(0x230)][_0x4e7b23(0x266)]++;else{const _0x44f1db=await this[_0x4e7b23(0x265)][_0x4e7b23(0x1f8)](_0x2d19bd);_0x4b0b19[_0x4e7b23(0x23b)](_0x1950e4[_0x4e7b23(0x28e)][_0x4e7b23(0x21e)],_0x44f1db['id']),_0x373f87[_0x4e7b23(0x230)][_0x4e7b23(0x1fd)]({'name':_0x1950e4['yaml'][_0x4e7b23(0x21e)],'action':_0x4e7b23(0x2b4),'id':_0x44f1db['id']}),_0x373f87[_0x4e7b23(0x21f)][_0x4e7b23(0x230)][_0x4e7b23(0x2b4)]++;}}catch(_0x5b0ea8){_0x373f87[_0x4e7b23(0x230)][_0x4e7b23(0x1fd)]({'name':_0x1950e4[_0x4e7b23(0x28e)]['name'],'action':_0x4e7b23(0x2b9),'error':_0x5b0ea8[_0x4e7b23(0x204)]}),_0x373f87['counts'][_0x4e7b23(0x230)][_0x4e7b23(0x28c)]++;}}return _0x373f87;}async['pullAgent'](_0x46ba90,_0x3f4cb0,_0x52e085,_0x2eccc9){const _0x30a597=a87_0x523c07,{projectId:_0x5c4783,project:_0x30e605}=await this['resolveProjectName'](_0x46ba90),_0x8189a=_0x30e605[_0x30a597(0x280)][_0x30a597(0x21e)],_0x62fb4e=await this['client'][_0x30a597(0x1fe)](_0x5c4783),_0x5e20d3=_0x62fb4e[_0x30a597(0x1e2)](_0x36a092=>_0x36a092['attributes'][_0x30a597(0x21e)]===_0x3f4cb0);if(!_0x5e20d3)throw new SDKError(ErrorCode[_0x30a597(0x29b)],_0x30a597(0x278)+_0x3f4cb0,undefined,{'helpText':_0x30a597(0x243)+_0x62fb4e[_0x30a597(0x26f)](_0x3d978e=>_0x3d978e['attributes']['name'])[_0x30a597(0x240)](',\x20')});const _0xfce492=normalizeName(_0x8189a),_0x1e0478=normalizeName(_0x3f4cb0),_0x15f583=_0x52e085||a87_0x445c58[_0x30a597(0x240)](process[_0x30a597(0x20a)](),'agents',_0xfce492),_0x587eb6=a87_0x445c58[_0x30a597(0x240)](_0x15f583,_0x1e0478),_0x5d2c11=new Map(),_0x1b5cf8=new Map(),_0x28f646=await this[_0x30a597(0x265)][_0x30a597(0x25a)](_0x5c4783),_0x5e221b=await this[_0x30a597(0x265)][_0x30a597(0x291)](_0x5c4783),_0x1c0acb=new Map();for(const _0x57f72d of _0x28f646){_0x5d2c11[_0x30a597(0x23b)](_0x57f72d['id'],_0x57f72d[_0x30a597(0x280)][_0x30a597(0x21e)]);}for(const _0x5c7c38 of _0x5e221b){_0x1c0acb[_0x30a597(0x23b)](_0x5c7c38['id'],_0x5c7c38[_0x30a597(0x280)][_0x30a597(0x21e)]);}for(const _0xb49fff of _0x62fb4e){_0x1b5cf8[_0x30a597(0x23b)](_0xb49fff['id'],_0xb49fff[_0x30a597(0x280)]['name']);}const _0x38bc33={'resolveKnowledgeBaseName':async _0x4c849b=>_0x5d2c11[_0x30a597(0x29f)](_0x4c849b),'resolveTextKnowledgeBaseName':async _0x329420=>_0x1c0acb[_0x30a597(0x29f)](_0x329420),'resolveAgentName':async _0x5344ab=>_0x1b5cf8[_0x30a597(0x29f)](_0x5344ab),'resolveWebSearchToolName':async()=>undefined,'resolveImageGeneratorName':async()=>undefined,'resolvePromptName':async()=>undefined,'onWarning':_0x30743c=>this[_0x30a597(0x227)]['logger']?.[_0x30a597(0x208)](_0x30743c)},_0x311fe7=a87_0x445c58[_0x30a597(0x240)](_0x587eb6,_0x30a597(0x2bc)),_0x2be186=a87_0x445c58[_0x30a597(0x240)](_0x587eb6,_0x30a597(0x29e)),_0x3be108=a87_0x445c58['join'](_0x587eb6,_0x30a597(0x245)),_0x4aa133=!a87_0x4b9004['existsSync'](_0x2be186);if(_0x2eccc9?.[_0x30a597(0x293)])return{'agentName':_0x3f4cb0,'outputPath':_0x587eb6,'isNew':_0x4aa133,'hasChanges':!![]};a87_0x4b9004[_0x30a597(0x24d)](_0x15f583,{'recursive':!![]}),a87_0x4b9004[_0x30a597(0x24d)](_0x587eb6,{'recursive':!![]});const _0xc3276=a87_0x445c58[_0x30a597(0x240)](_0x15f583,_0x30a597(0x1f2));!a87_0x4b9004['existsSync'](_0xc3276)&&a87_0x4b9004['writeFileSync'](_0xc3276,createAgentConfigContent(_0x46ba90));const {yaml:_0x22fae4,systemPrompt:_0x36ac49,starterMessage:_0x25d5ee}=await agentResponseToDef(_0x5e20d3,_0x38bc33);let _0xea78f9=_0x4aa133;if(!_0x4aa133){const _0xc51fd9=a87_0x4b9004[_0x30a597(0x1ec)](_0x311fe7)?a87_0x4b9004[_0x30a597(0x279)](_0x311fe7,_0x30a597(0x248)):'',_0x527dda=a87_0x4b9004[_0x30a597(0x279)](_0x2be186,_0x30a597(0x248));_0xea78f9=_0xc51fd9!==_0x36ac49||_0x527dda!==toAgentYamlString(_0x22fae4);}a87_0x4b9004[_0x30a597(0x1e5)](_0x311fe7,_0x36ac49),a87_0x4b9004[_0x30a597(0x1e5)](_0x2be186,toAgentYamlString(_0x22fae4));if(_0x25d5ee&&_0x25d5ee[_0x30a597(0x223)]('\x0a'))a87_0x4b9004[_0x30a597(0x1e5)](_0x3be108,_0x25d5ee);else a87_0x4b9004[_0x30a597(0x1ec)](_0x3be108)&&a87_0x4b9004[_0x30a597(0x23a)](_0x3be108);return{'agentName':_0x3f4cb0,'outputPath':_0x587eb6,'isNew':_0x4aa133,'hasChanges':_0xea78f9};}async[a87_0x523c07(0x28b)](_0x53998b,_0x138d50){const _0x51bf80=a87_0x523c07;let _0x24e65a;isAgentYamlPath(_0x53998b)?_0x24e65a=getAgentDirFromYamlPath(_0x53998b):_0x24e65a=_0x53998b;const {config:_0x4fec8a}=findAgentConfig(_0x24e65a),_0x18bfe8=await this[_0x51bf80(0x24e)](_0x4fec8a[_0x51bf80(0x288)]),_0x4852ce=a87_0x445c58['join'](_0x24e65a,_0x51bf80(0x29e)),_0x422f73=a87_0x445c58[_0x51bf80(0x240)](_0x24e65a,_0x51bf80(0x2bc)),_0x415c6f=a87_0x445c58[_0x51bf80(0x240)](_0x24e65a,_0x51bf80(0x245));if(!a87_0x4b9004[_0x51bf80(0x1ec)](_0x4852ce))throw new SDKError(ErrorCode[_0x51bf80(0x273)],_0x51bf80(0x242)+_0x24e65a,undefined,{'helpText':_0x51bf80(0x232)});const _0x287e08=parseAgentYaml(a87_0x4b9004['readFileSync'](_0x4852ce,_0x51bf80(0x248)),_0x4852ce),_0x4b6045=a87_0x4b9004['existsSync'](_0x422f73)?a87_0x4b9004['readFileSync'](_0x422f73,'utf-8'):'',_0x578e99=a87_0x4b9004['existsSync'](_0x415c6f)?a87_0x4b9004[_0x51bf80(0x279)](_0x415c6f,_0x51bf80(0x248)):_0x287e08['starter_message'];if(_0x138d50?.[_0x51bf80(0x293)])return{'agentName':_0x287e08[_0x51bf80(0x21e)],'action':_0x51bf80(0x2b4),'projectId':_0x18bfe8};const _0x59d057=await this[_0x51bf80(0x265)]['listAgentsFull'](_0x18bfe8),_0x39c4d7=await this[_0x51bf80(0x265)][_0x51bf80(0x25a)](_0x18bfe8),_0x22e5f7=await this[_0x51bf80(0x265)]['listTextKnowledgeBases'](_0x18bfe8),_0x380a7=new Map(),_0x267d96=new Map(),_0x35c6e8=new Map();for(const _0x4a31cb of _0x39c4d7){_0x380a7[_0x51bf80(0x23b)](_0x4a31cb[_0x51bf80(0x280)][_0x51bf80(0x21e)],_0x4a31cb['id']);}for(const _0x33d5f5 of _0x22e5f7){_0x267d96[_0x51bf80(0x23b)](_0x33d5f5[_0x51bf80(0x280)][_0x51bf80(0x21e)],_0x33d5f5['id']);}for(const _0x23ab78 of _0x59d057){_0x35c6e8['set'](_0x23ab78[_0x51bf80(0x280)][_0x51bf80(0x21e)],_0x23ab78['id']);}const _0x356275={'projectId':_0x18bfe8,'resolveKnowledgeBaseId':async _0x3bf2b3=>_0x380a7['get'](_0x3bf2b3),'resolveTextKnowledgeBaseId':async _0x5db6ff=>_0x267d96[_0x51bf80(0x29f)](_0x5db6ff),'resolveAgentId':async _0x44417a=>_0x35c6e8['get'](_0x44417a),'resolveWebSearchToolId':async()=>undefined,'resolveImageGeneratorId':async()=>undefined,'resolvePromptId':async()=>undefined,'onWarning':_0x27b4e6=>this[_0x51bf80(0x227)][_0x51bf80(0x261)]?.[_0x51bf80(0x208)](_0x27b4e6)};try{const _0x5b5016=_0x59d057[_0x51bf80(0x1e2)](_0x4dbe92=>_0x4dbe92[_0x51bf80(0x280)][_0x51bf80(0x21e)]===_0x287e08[_0x51bf80(0x21e)]),_0x490b19=await agentDefToRequest(_0x287e08,_0x4b6045,_0x578e99,_0x356275);if(_0x5b5016)return await this[_0x51bf80(0x265)][_0x51bf80(0x250)](_0x5b5016['id'],_0x490b19),{'agentName':_0x287e08[_0x51bf80(0x21e)],'action':_0x51bf80(0x266),'projectId':_0x18bfe8,'agentId':_0x5b5016['id']};else{const _0x5cc892=await this[_0x51bf80(0x265)][_0x51bf80(0x259)](_0x490b19);return{'agentName':_0x287e08['name'],'action':'created','projectId':_0x18bfe8,'agentId':_0x5cc892['id']};}}catch(_0x16ae10){return{'agentName':_0x287e08[_0x51bf80(0x21e)],'action':_0x51bf80(0x2b9),'projectId':_0x18bfe8,'error':_0x16ae10[_0x51bf80(0x204)]};}}async['cloneProject'](_0xb42f99,_0x54ab0a,_0x4b9128){const _0x46a3e8=a87_0x523c07,_0x45bd8c=a87_0x4b9004['existsSync'](_0xb42f99)&&a87_0x4b9004[_0x46a3e8(0x1ec)](a87_0x445c58[_0x46a3e8(0x240)](_0xb42f99,_0x46a3e8(0x1f2)));let _0x197ac4;const _0xcac724=[],_0x7c51d5=[],_0x3c4108=[],_0x50a476=[];if(_0x45bd8c){const _0x2c4056=loadAgentConfig(a87_0x445c58[_0x46a3e8(0x240)](_0xb42f99,'tdx.json'));_0x197ac4=_0x2c4056[_0x46a3e8(0x288)];const _0xda7ed5=a87_0x4b9004[_0x46a3e8(0x226)](_0xb42f99,{'withFileTypes':!![]});for(const _0x23790c of _0xda7ed5){if(!_0x23790c[_0x46a3e8(0x1f6)]())continue;if(['knowledge_bases',_0x46a3e8(0x230),_0x46a3e8(0x2a5)][_0x46a3e8(0x223)](_0x23790c[_0x46a3e8(0x21e)]))continue;const _0x53b21a=a87_0x445c58['join'](_0xb42f99,_0x23790c[_0x46a3e8(0x21e)]);if(isAgentDir(_0x53b21a)){const _0x4073ae=a87_0x445c58[_0x46a3e8(0x240)](_0x53b21a,_0x46a3e8(0x29e)),_0x13a9cf=a87_0x445c58[_0x46a3e8(0x240)](_0x53b21a,_0x46a3e8(0x2bc)),_0x5a91ce=a87_0x445c58[_0x46a3e8(0x240)](_0x53b21a,_0x46a3e8(0x245)),_0x3b91cc=parseAgentYaml(a87_0x4b9004[_0x46a3e8(0x279)](_0x4073ae,'utf-8'),_0x4073ae),_0x29a4d4=a87_0x4b9004['existsSync'](_0x13a9cf)?a87_0x4b9004[_0x46a3e8(0x279)](_0x13a9cf,_0x46a3e8(0x248)):'',_0x2547bb=a87_0x4b9004[_0x46a3e8(0x1ec)](_0x5a91ce)?a87_0x4b9004[_0x46a3e8(0x279)](_0x5a91ce,_0x46a3e8(0x248)):_0x3b91cc[_0x46a3e8(0x215)];_0xcac724[_0x46a3e8(0x1fd)]({'name':_0x3b91cc['name'],'dir':_0x53b21a,'yaml':_0x3b91cc,'systemPrompt':_0x29a4d4,'starterMessage':_0x2547bb});}}const _0x3177cd=getKnowledgeBasesDir(_0xb42f99);if(a87_0x4b9004[_0x46a3e8(0x1ec)](_0x3177cd)){const _0x774895=a87_0x4b9004['readdirSync'](_0x3177cd);for(const _0x4ac722 of _0x774895){const _0x24fe3f=a87_0x445c58[_0x46a3e8(0x240)](_0x3177cd,_0x4ac722);if(_0x4ac722[_0x46a3e8(0x24c)](_0x46a3e8(0x1fc))){const _0x16d619=parseKnowledgeBaseYaml(a87_0x4b9004['readFileSync'](_0x24fe3f,'utf-8'),_0x24fe3f);_0x7c51d5['push']({'name':_0x16d619[_0x46a3e8(0x21e)],'path':_0x24fe3f,'yaml':_0x16d619});}else{if(_0x4ac722[_0x46a3e8(0x24c)]('.md')){const _0x304a40=a87_0x4b9004[_0x46a3e8(0x279)](_0x24fe3f,_0x46a3e8(0x248)),{name:_0x5988c5,text:_0x418a6a}=parseTextKnowledgeBaseMd(_0x304a40,_0x4ac722);_0x3c4108[_0x46a3e8(0x1fd)]({'name':_0x5988c5,'path':_0x24fe3f,'text':_0x418a6a});}}}}const _0x30998d=getPromptsDir(_0xb42f99);if(a87_0x4b9004[_0x46a3e8(0x1ec)](_0x30998d)){const _0x4be658=a87_0x4b9004[_0x46a3e8(0x226)](_0x30998d)[_0x46a3e8(0x22b)](_0x504aa3=>_0x504aa3[_0x46a3e8(0x24c)]('.yml'));for(const _0x49bc3b of _0x4be658){const _0x28ac3a=a87_0x445c58[_0x46a3e8(0x240)](_0x30998d,_0x49bc3b),_0x16a663=parsePromptYaml(a87_0x4b9004[_0x46a3e8(0x279)](_0x28ac3a,'utf-8'),_0x28ac3a);_0x50a476[_0x46a3e8(0x1fd)]({'name':_0x16a663['name'],'path':_0x28ac3a,'yaml':_0x16a663});}}}else{const _0x93489b=await this[_0x46a3e8(0x24e)](_0xb42f99),_0x37c136=await this['client'][_0x46a3e8(0x2ba)](_0x93489b);_0x197ac4=_0x37c136['attributes'][_0x46a3e8(0x21e)];const _0x51dcf2=await this[_0x46a3e8(0x265)][_0x46a3e8(0x1fe)](_0x93489b),_0x1ddaf3=await this[_0x46a3e8(0x265)]['listKnowledgeBases'](_0x93489b),_0x4bc720=await this['client'][_0x46a3e8(0x291)](_0x93489b),_0x21cc10=await this['client']['listPrompts'](_0x93489b),_0x231b2c=new Map(),_0x58dc85=new Map(),_0x4d428c=new Map(),_0x247463=new Map();for(const _0x2a404e of _0x1ddaf3){_0x231b2c['set'](_0x2a404e['id'],_0x2a404e[_0x46a3e8(0x280)]['name']);}for(const _0x37f6b8 of _0x4bc720){_0x58dc85['set'](_0x37f6b8['id'],_0x37f6b8[_0x46a3e8(0x280)][_0x46a3e8(0x21e)]);}for(const _0x2af0e2 of _0x51dcf2){_0x4d428c[_0x46a3e8(0x23b)](_0x2af0e2['id'],_0x2af0e2[_0x46a3e8(0x280)][_0x46a3e8(0x21e)]);}for(const _0x45b78e of _0x21cc10){_0x247463[_0x46a3e8(0x23b)](_0x45b78e['id'],_0x45b78e[_0x46a3e8(0x280)]['name']);}const _0x9b4fd={'resolveKnowledgeBaseName':async _0x1e636f=>_0x231b2c[_0x46a3e8(0x29f)](_0x1e636f),'resolveTextKnowledgeBaseName':async _0x5c3177=>_0x58dc85[_0x46a3e8(0x29f)](_0x5c3177),'resolveAgentName':async _0xe9decf=>_0x4d428c[_0x46a3e8(0x29f)](_0xe9decf),'resolveWebSearchToolName':async()=>undefined,'resolveImageGeneratorName':async()=>undefined,'resolvePromptName':async _0x188d2a=>_0x247463[_0x46a3e8(0x29f)](_0x188d2a),'onWarning':_0x127fdd=>this[_0x46a3e8(0x227)][_0x46a3e8(0x261)]?.['warn'](_0x127fdd)};for(const _0x31c367 of _0x51dcf2){const _0x45bb9c=await agentResponseToDef(_0x31c367,_0x9b4fd),{yaml:_0x43905f,systemPrompt:_0x30fcbd,starterMessage:_0x11e858}=_0x45bb9c;_0xcac724[_0x46a3e8(0x1fd)]({'name':_0x43905f['name'],'dir':'','yaml':_0x43905f,'systemPrompt':_0x30fcbd,'starterMessage':_0x11e858});}for(const _0xd091da of _0x1ddaf3){const _0x4a196d=apiKnowledgeBaseToYaml(_0xd091da);_0x7c51d5['push']({'name':_0x4a196d[_0x46a3e8(0x21e)],'path':'','yaml':_0x4a196d});}for(const _0x138978 of _0x4bc720){_0x3c4108['push']({'name':_0x138978['attributes'][_0x46a3e8(0x21e)],'path':'','text':_0x138978[_0x46a3e8(0x280)][_0x46a3e8(0x246)]});}for(const _0x3f3d38 of _0x21cc10){const _0x5cc1f2=await apiPromptToYaml(_0x3f3d38,_0x9b4fd);_0x5cc1f2&&_0x50a476[_0x46a3e8(0x1fd)]({'name':_0x5cc1f2[_0x46a3e8(0x21e)],'path':'','yaml':_0x5cc1f2});}}const _0x17f2d0={'sourceProjectName':_0x197ac4,'newProjectName':_0x54ab0a,'newProjectId':'','agents':[],'knowledgeBases':[],'textKnowledgeBases':[],'imageGenerators':[],'webSearchTools':[],'prompts':[],'counts':{'agents':{'created':0x0,'updated':0x0,'unchanged':0x0,'errors':0x0},'knowledgeBases':{'created':0x0,'updated':0x0,'unchanged':0x0,'errors':0x0},'textKnowledgeBases':{'created':0x0,'updated':0x0,'unchanged':0x0,'errors':0x0},'imageGenerators':{'created':0x0,'errors':0x0},'webSearchTools':{'created':0x0,'errors':0x0},'prompts':{'created':0x0,'updated':0x0,'unchanged':0x0,'errors':0x0}}},_0x1b7400=await this['client'][_0x46a3e8(0x27a)](),_0x22d34f=_0x1b7400[_0x46a3e8(0x1e2)](_0x395388=>_0x395388[_0x46a3e8(0x280)][_0x46a3e8(0x21e)]===_0x54ab0a);if(_0x22d34f)throw new SDKError(ErrorCode[_0x46a3e8(0x1ee)],_0x46a3e8(0x283)+_0x54ab0a+_0x46a3e8(0x270),undefined,{'helpText':_0x46a3e8(0x294)});if(_0x4b9128?.[_0x46a3e8(0x293)])return _0x17f2d0[_0x46a3e8(0x21f)][_0x46a3e8(0x20b)][_0x46a3e8(0x2b4)]=_0xcac724['length'],_0x17f2d0[_0x46a3e8(0x21f)][_0x46a3e8(0x28a)][_0x46a3e8(0x2b4)]=_0x7c51d5[_0x46a3e8(0x23c)],_0x17f2d0[_0x46a3e8(0x21f)][_0x46a3e8(0x2a3)][_0x46a3e8(0x2b4)]=_0x3c4108[_0x46a3e8(0x23c)],_0x17f2d0[_0x46a3e8(0x21f)][_0x46a3e8(0x230)][_0x46a3e8(0x2b4)]=_0x50a476['length'],_0x17f2d0;const _0x1cbd32=await this[_0x46a3e8(0x265)][_0x46a3e8(0x20c)]({'name':_0x54ab0a}),_0x3f6b41=_0x1cbd32['id'];_0x17f2d0[_0x46a3e8(0x27c)]=_0x3f6b41;const _0x17323a=new Map(),_0x2970e9=new Map(),_0x33d5e4=new Map(),_0x58ec2b=new Map(),_0x1416f7=new Map(),_0x19361e=new Map(),_0x584d94=new Set(),_0x1d1f92=new Set();for(const _0xbcf71b of _0xcac724){for(const _0x5d4b17 of _0xbcf71b[_0x46a3e8(0x28e)]['tools']||[]){if(_0x5d4b17[_0x46a3e8(0x285)]==='image_gen'){const _0x4add5f=parseRef(_0x5d4b17[_0x46a3e8(0x2a0)]);if(_0x4add5f)_0x584d94[_0x46a3e8(0x27e)](_0x4add5f[_0x46a3e8(0x21e)]);}else{if(_0x5d4b17[_0x46a3e8(0x285)]==='web_search'){const _0x3546b5=parseRef(_0x5d4b17['target']);if(_0x3546b5)_0x1d1f92['add'](_0x3546b5[_0x46a3e8(0x21e)]);}}}}for(const _0xab2ac6 of _0x584d94){try{const _0x4020a7=await this[_0x46a3e8(0x265)][_0x46a3e8(0x253)]({'projectId':_0x3f6b41,'name':_0xab2ac6});_0x1416f7[_0x46a3e8(0x23b)](_0xab2ac6,_0x4020a7['id']),_0x17f2d0[_0x46a3e8(0x298)][_0x46a3e8(0x1fd)]({'name':_0xab2ac6,'action':_0x46a3e8(0x2b4),'id':_0x4020a7['id']}),_0x17f2d0[_0x46a3e8(0x21f)][_0x46a3e8(0x298)][_0x46a3e8(0x2b4)]++;}catch(_0x4d53b8){_0x17f2d0[_0x46a3e8(0x298)][_0x46a3e8(0x1fd)]({'name':_0xab2ac6,'action':_0x46a3e8(0x2b9),'error':_0x4d53b8['message']}),_0x17f2d0[_0x46a3e8(0x21f)][_0x46a3e8(0x298)][_0x46a3e8(0x28c)]++;}}for(const _0x5e8b96 of _0x1d1f92){try{const _0x188772=await this[_0x46a3e8(0x265)][_0x46a3e8(0x1ff)]({'projectId':_0x3f6b41,'name':_0x5e8b96});_0x19361e[_0x46a3e8(0x23b)](_0x5e8b96,_0x188772['id']),_0x17f2d0['webSearchTools']['push']({'name':_0x5e8b96,'action':'created','id':_0x188772['id']}),_0x17f2d0[_0x46a3e8(0x21f)][_0x46a3e8(0x277)]['created']++;}catch(_0xe2ff86){_0x17f2d0['webSearchTools'][_0x46a3e8(0x1fd)]({'name':_0x5e8b96,'action':_0x46a3e8(0x2b9),'error':_0xe2ff86['message']}),_0x17f2d0['counts']['webSearchTools'][_0x46a3e8(0x28c)]++;}}const _0x3b69e1={'projectId':_0x3f6b41,'resolveKnowledgeBaseId':async _0x2d86d2=>_0x17323a['get'](_0x2d86d2),'resolveTextKnowledgeBaseId':async _0x57252b=>_0x2970e9[_0x46a3e8(0x29f)](_0x57252b),'resolveAgentId':async _0x3f17f1=>_0x33d5e4[_0x46a3e8(0x29f)](_0x3f17f1),'resolveWebSearchToolId':async _0xadad40=>_0x19361e[_0x46a3e8(0x29f)](_0xadad40),'resolveImageGeneratorId':async _0x31cafa=>_0x1416f7[_0x46a3e8(0x29f)](_0x31cafa),'resolvePromptId':async _0x5487ad=>_0x58ec2b[_0x46a3e8(0x29f)](_0x5487ad),'onWarning':_0x1c00c1=>this[_0x46a3e8(0x227)]['logger']?.[_0x46a3e8(0x208)](_0x1c00c1)};for(const _0x555574 of _0x7c51d5){try{const _0x40ff75=yamlKnowledgeBaseToApi(_0x555574[_0x46a3e8(0x28e)],_0x3f6b41),_0x29db46=await this[_0x46a3e8(0x265)][_0x46a3e8(0x296)](_0x40ff75);_0x17323a[_0x46a3e8(0x23b)](_0x555574[_0x46a3e8(0x28e)][_0x46a3e8(0x21e)],_0x29db46['id']),_0x17f2d0[_0x46a3e8(0x28a)][_0x46a3e8(0x1fd)]({'name':_0x555574[_0x46a3e8(0x28e)][_0x46a3e8(0x21e)],'action':_0x46a3e8(0x2b4),'id':_0x29db46['id']}),_0x17f2d0[_0x46a3e8(0x21f)][_0x46a3e8(0x28a)][_0x46a3e8(0x2b4)]++;}catch(_0x4503b5){_0x17f2d0['knowledgeBases'][_0x46a3e8(0x1fd)]({'name':_0x555574['yaml'][_0x46a3e8(0x21e)],'action':_0x46a3e8(0x2b9),'error':_0x4503b5[_0x46a3e8(0x204)]}),_0x17f2d0[_0x46a3e8(0x21f)]['knowledgeBases']['errors']++;}}for(const _0x5ca359 of _0x3c4108){try{const _0x539710=yamlTextKnowledgeBaseToApi({'name':_0x5ca359[_0x46a3e8(0x21e)],'text':_0x5ca359[_0x46a3e8(0x246)]},_0x3f6b41),_0x2dc32b=await this[_0x46a3e8(0x265)]['createTextKnowledgeBase'](_0x539710);_0x2970e9['set'](_0x5ca359[_0x46a3e8(0x21e)],_0x2dc32b['id']),_0x17f2d0[_0x46a3e8(0x2a3)][_0x46a3e8(0x1fd)]({'name':_0x5ca359[_0x46a3e8(0x21e)],'action':_0x46a3e8(0x2b4),'id':_0x2dc32b['id']}),_0x17f2d0[_0x46a3e8(0x21f)][_0x46a3e8(0x2a3)]['created']++;}catch(_0x20ba27){_0x17f2d0['textKnowledgeBases'][_0x46a3e8(0x1fd)]({'name':_0x5ca359[_0x46a3e8(0x21e)],'action':_0x46a3e8(0x2b9),'error':_0x20ba27[_0x46a3e8(0x204)]}),_0x17f2d0['counts'][_0x46a3e8(0x2a3)][_0x46a3e8(0x28c)]++;}}const _0x5fe35=[..._0xcac724]['sort']((_0xfb71d,_0x513992)=>{const _0x3ed472=_0x46a3e8,_0x39be28=_0xfb71d[_0x3ed472(0x28e)][_0x3ed472(0x1e9)]?.['some'](_0x2dbdd1=>_0x2dbdd1['type']===_0x3ed472(0x228))??![],_0x3a959e=_0x513992['yaml']['tools']?.[_0x3ed472(0x28d)](_0x103285=>_0x103285['type']===_0x3ed472(0x228))??![];if(_0x39be28&&!_0x3a959e)return 0x1;if(!_0x39be28&&_0x3a959e)return-0x1;return 0x0;});for(const _0x5d0076 of _0x5fe35){try{const _0x14a5af=_0x5d0076[_0x46a3e8(0x28e)]['tools']?.[_0x46a3e8(0x22b)](_0xe4eeb6=>{const _0x527fc0=_0x46a3e8;if(_0xe4eeb6['type']===_0x527fc0(0x228)){const _0x12525c=parseRef(_0xe4eeb6[_0x527fc0(0x2a0)]);return _0x12525c?.['name']===_0x5d0076[_0x527fc0(0x28e)][_0x527fc0(0x21e)];}return![];})??[];_0x14a5af[_0x46a3e8(0x23c)]>0x0&&this[_0x46a3e8(0x227)]['logger']?.['warn']('Agent\x20\x27'+_0x5d0076[_0x46a3e8(0x28e)][_0x46a3e8(0x21e)]+_0x46a3e8(0x20d)+'Re-add\x20them\x20after\x20clone\x20using\x20\x27tdx\x20agent\x20push\x27.');const _0x4aeedc=await agentDefToRequest(_0x5d0076['yaml'],_0x5d0076[_0x46a3e8(0x2a6)],_0x5d0076[_0x46a3e8(0x2ab)],_0x3b69e1),_0x1b6746=await this['client']['createAgentResponse'](_0x4aeedc);_0x33d5e4[_0x46a3e8(0x23b)](_0x5d0076['yaml'][_0x46a3e8(0x21e)],_0x1b6746['id']),_0x17f2d0[_0x46a3e8(0x20b)]['push']({'agentName':_0x5d0076[_0x46a3e8(0x28e)]['name'],'action':'created','agentId':_0x1b6746['id']}),_0x17f2d0[_0x46a3e8(0x21f)][_0x46a3e8(0x20b)][_0x46a3e8(0x2b4)]++;}catch(_0x461015){_0x17f2d0[_0x46a3e8(0x20b)][_0x46a3e8(0x1fd)]({'agentName':_0x5d0076['yaml']['name'],'action':'error','error':_0x461015['message']}),_0x17f2d0[_0x46a3e8(0x21f)][_0x46a3e8(0x20b)][_0x46a3e8(0x28c)]++;}}for(const _0x4de356 of _0x50a476){try{const _0x5a1738=await yamlPromptToApi(_0x4de356[_0x46a3e8(0x28e)],_0x3f6b41,_0x3b69e1);if(!_0x5a1738){_0x17f2d0[_0x46a3e8(0x230)][_0x46a3e8(0x1fd)]({'name':_0x4de356[_0x46a3e8(0x28e)]['name'],'action':_0x46a3e8(0x2b9),'error':_0x46a3e8(0x295)}),_0x17f2d0[_0x46a3e8(0x21f)][_0x46a3e8(0x230)][_0x46a3e8(0x28c)]++;continue;}const _0x45051f=await this[_0x46a3e8(0x265)][_0x46a3e8(0x1f8)](_0x5a1738);_0x58ec2b[_0x46a3e8(0x23b)](_0x4de356[_0x46a3e8(0x28e)][_0x46a3e8(0x21e)],_0x45051f['id']),_0x17f2d0[_0x46a3e8(0x230)][_0x46a3e8(0x1fd)]({'name':_0x4de356['yaml'][_0x46a3e8(0x21e)],'action':_0x46a3e8(0x2b4),'id':_0x45051f['id']}),_0x17f2d0[_0x46a3e8(0x21f)][_0x46a3e8(0x230)][_0x46a3e8(0x2b4)]++;}catch(_0x47643a){_0x17f2d0[_0x46a3e8(0x230)][_0x46a3e8(0x1fd)]({'name':_0x4de356['yaml'][_0x46a3e8(0x21e)],'action':'error','error':_0x47643a['message']}),_0x17f2d0[_0x46a3e8(0x21f)][_0x46a3e8(0x230)][_0x46a3e8(0x28c)]++;}}return _0x17f2d0;}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
function a88_0xd4df(_0x430d46,_0x5aa041){_0x430d46=_0x430d46-0x160;const _0x4d0ac9=a88_0x4d0a();let _0xd4dfbb=_0x4d0ac9[_0x430d46];return _0xd4dfbb;}function a88_0x4d0a(){const _0xbe9e6f=['4oiAHaj','470NKqwai','862372sHJyVN','get','5IWKbAU','targetKnowledgeBaseId','1.0','12ncKqsr','201705uEkEjv','map','17813235aJgpgq','702006MplCFH','targetAgentId','295734swNBsC','has','1054635tgdpbL','attributes','94644qbfkvi','56CAwmSO'];a88_0x4d0a=function(){return _0xbe9e6f;};return a88_0x4d0a();}(function(_0x5e0826,_0x4e2cb3){const _0x528ffe=a88_0xd4df,_0x15be86=_0x5e0826();while(!![]){try{const _0x30c831=-parseInt(_0x528ffe(0x164))/0x1+parseInt(_0x528ffe(0x169))/0x2+parseInt(_0x528ffe(0x16b))/0x3*(parseInt(_0x528ffe(0x16f))/0x4)+-parseInt(_0x528ffe(0x160))/0x5*(parseInt(_0x528ffe(0x167))/0x6)+-parseInt(_0x528ffe(0x171))/0x7*(parseInt(_0x528ffe(0x16e))/0x8)+parseInt(_0x528ffe(0x16d))/0x9*(-parseInt(_0x528ffe(0x170))/0xa)+parseInt(_0x528ffe(0x166))/0xb*(parseInt(_0x528ffe(0x163))/0xc);if(_0x30c831===_0x4e2cb3)break;else _0x15be86['push'](_0x15be86['shift']());}catch(_0x3120bb){_0x15be86['push'](_0x15be86['shift']());}}}(a88_0x4d0a,0x6c44b));export function canCreateAgent(_0x522ece,_0x53c3fe){const _0xadc129=a88_0xd4df;for(const _0x5bfe72 of _0x522ece[_0xadc129(0x16c)]['tools']){if(_0x5bfe72['targetAgentId']&&!_0x53c3fe[_0xadc129(0x16a)](_0x5bfe72[_0xadc129(0x168)]))return![];}return!![];}export function remapToolIds(_0x1e6fd7,_0x5d73ba,_0x1437ea){const _0x4d5520=a88_0xd4df;return _0x1e6fd7[_0x4d5520(0x165)](_0x486910=>({..._0x486910,'targetKnowledgeBaseId':_0x486910[_0x4d5520(0x161)]?_0x5d73ba[_0x4d5520(0x172)](_0x486910[_0x4d5520(0x161)])||_0x486910[_0x4d5520(0x161)]:undefined,'targetAgentId':_0x486910[_0x4d5520(0x168)]?_0x1437ea[_0x4d5520(0x172)](_0x486910['targetAgentId'])||_0x486910[_0x4d5520(0x168)]:undefined}));}export function remapVariableIds(_0x262923,_0x4db47e){const _0x56157d=a88_0xd4df;return _0x262923['map'](_0x3394c8=>({..._0x3394c8,'targetKnowledgeBaseId':_0x4db47e[_0x56157d(0x172)](_0x3394c8[_0x56157d(0x161)])||_0x3394c8[_0x56157d(0x161)]}));}export function isSupportedBackupVersion(_0x4c3425){const _0xded42c=a88_0xd4df;return _0x4c3425===_0xded42c(0x162);}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
const a89_0x4698b5=a89_0x4c18;(function(_0x44b40e,_0x266550){const _0x2eb414=a89_0x4c18,_0x14916d=_0x44b40e();while(!![]){try{const _0x3356cb=parseInt(_0x2eb414(0x123))/0x1+parseInt(_0x2eb414(0x120))/0x2+parseInt(_0x2eb414(0x11f))/0x3*(parseInt(_0x2eb414(0x11b))/0x4)+parseInt(_0x2eb414(0x11d))/0x5*(-parseInt(_0x2eb414(0x11e))/0x6)+parseInt(_0x2eb414(0x121))/0x7+-parseInt(_0x2eb414(0x118))/0x8*(-parseInt(_0x2eb414(0x119))/0x9)+parseInt(_0x2eb414(0x116))/0xa*(-parseInt(_0x2eb414(0x122))/0xb);if(_0x3356cb===_0x266550)break;else _0x14916d['push'](_0x14916d['shift']());}catch(_0x59888e){_0x14916d['push'](_0x14916d['shift']());}}}(a89_0xbe30,0xf2f7b));function a89_0x4c18(_0x30334c,_0x3d5e04){_0x30334c=_0x30334c-0x116;const _0xbe30b1=a89_0xbe30();let _0x4c1840=_0xbe30b1[_0x30334c];return _0x4c1840;}const MODEL_ALIASES={'haiku':a89_0x4698b5(0x11c),'sonnet':a89_0x4698b5(0x124)};export function extractModelAlias(_0x41b48c){const _0x2ec935=a89_0x4698b5,_0x355dee=_0x41b48c[_0x2ec935(0x11a)](/^claude-(?:\d+-)?(?:\d+-?)?(sonnet|haiku|opus)/i);if(_0x355dee)return _0x355dee[0x1][_0x2ec935(0x117)]();return _0x41b48c;}export function resolveModelAlias(_0x4afea4){const _0x254be5=a89_0x4698b5;return MODEL_ALIASES[_0x4afea4[_0x254be5(0x117)]()]||_0x4afea4;}function a89_0xbe30(){const _0x1b51aa=['match','4tniLMH','claude-4.5-haiku','25iVKSSR','1229214gkfiHB','5602611smZHnF','926168uVYvsm','5218367OrAOzf','814KLSANz','758268miAAjD','claude-4.5-sonnet','353930vSbuQy','toLowerCase','8osiypl','7238268qKrwjk'];a89_0xbe30=function(){return _0x1b51aa;};return a89_0xbe30();}export function getModelAliases(){return{...MODEL_ALIASES};}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(_0x2754db,_0xb6e6d4){const _0x1b1a1c=a90_0x4667,_0x2ea96e=_0x2754db();while(!![]){try{const _0x478a70=-parseInt(_0x1b1a1c(0xee))/0x1+-parseInt(_0x1b1a1c(0xf8))/0x2*(parseInt(_0x1b1a1c(0xfd))/0x3)+parseInt(_0x1b1a1c(0xf5))/0x4+-parseInt(_0x1b1a1c(0xfc))/0x5+parseInt(_0x1b1a1c(0x100))/0x6+-parseInt(_0x1b1a1c(0xfb))/0x7*(parseInt(_0x1b1a1c(0xf2))/0x8)+parseInt(_0x1b1a1c(0xfa))/0x9;if(_0x478a70===_0xb6e6d4)break;else _0x2ea96e['push'](_0x2ea96e['shift']());}catch(_0x1decb0){_0x2ea96e['push'](_0x2ea96e['shift']());}}}(a90_0x29c7,0x42456));export const MODEL_FACTORS={'sonnet':0xa,'claude-4.5-sonnet':0xa,'claude-sonnet-4':0xa,'haiku':3.4,'claude-4.5-haiku':3.4,'claude-haiku-4':3.4,'opus':0xf,'claude-4-opus':0xf,'claude-opus-4':0xf};export const CONTEXT_LIMITS={'sonnet':0x30d40,'haiku':0x30d40,'opus':0x30d40,'default':0x30d40};export function getModelFactor(_0x1f8f98){const _0x38ef52=a90_0x4667,_0xa985d3=_0x1f8f98[_0x38ef52(0xfe)]();if(MODEL_FACTORS[_0xa985d3])return MODEL_FACTORS[_0xa985d3];if(_0xa985d3['includes'](_0x38ef52(0xea)))return MODEL_FACTORS[_0x38ef52(0xea)];if(_0xa985d3[_0x38ef52(0xf4)](_0x38ef52(0xef)))return MODEL_FACTORS['haiku'];if(_0xa985d3[_0x38ef52(0xf4)]('opus'))return MODEL_FACTORS[_0x38ef52(0xed)];return MODEL_FACTORS['sonnet'];}export function getContextLimit(_0x13fe2f){const _0x11dcd0=a90_0x4667,_0x6ff557=_0x13fe2f[_0x11dcd0(0xfe)]();if(_0x6ff557['includes'](_0x11dcd0(0xea)))return CONTEXT_LIMITS['sonnet'];if(_0x6ff557['includes']('haiku'))return CONTEXT_LIMITS[_0x11dcd0(0xef)];if(_0x6ff557[_0x11dcd0(0xf4)](_0x11dcd0(0xed)))return CONTEXT_LIMITS[_0x11dcd0(0xed)];return CONTEXT_LIMITS[_0x11dcd0(0xf9)];}export function calculateChatUnit(_0x4f3326,_0x3cebdf,_0x531473){return(_0x4f3326+_0x3cebdf)/0x1388*_0x531473;}export function calculateCredits(_0x47d26b){return _0x47d26b/0x2904;}export function getModelDisplayName(_0x3b3d43){const _0x20639e=a90_0x4667,_0x3bcc39=_0x3b3d43[_0x20639e(0xfe)]();if(_0x3bcc39[_0x20639e(0xf4)](_0x20639e(0xea))){if(_0x3bcc39[_0x20639e(0xf4)](_0x20639e(0xf7))||_0x3bcc39[_0x20639e(0xf4)]('4.5'))return'Sonnet\x204.5';return'Sonnet\x204';}if(_0x3bcc39['includes'](_0x20639e(0xef))){if(_0x3bcc39[_0x20639e(0xf4)](_0x20639e(0xf7))||_0x3bcc39[_0x20639e(0xf4)](_0x20639e(0xec)))return _0x20639e(0xf6);return _0x20639e(0xeb);}if(_0x3bcc39[_0x20639e(0xf4)](_0x20639e(0xed))){if(_0x3bcc39[_0x20639e(0xf4)](_0x20639e(0xf7))||_0x3bcc39[_0x20639e(0xf4)](_0x20639e(0xec)))return _0x20639e(0xf1);return'Opus\x204';}return'Claude';}function a90_0x29c7(){const _0x558cac=['4-5','714062YsDZTa','default','2749617JSVCcD','689017DBBIdD','2195375WJsNuh','3YnUSdO','toLowerCase','toLocaleString','2980710NipHmH','sonnet','Haiku\x204','4.5','opus','59816smcovv','haiku','round','Opus\x204.5','8STTFUx','en-US','includes','1694004GeRrZW','Haiku\x204.5'];a90_0x29c7=function(){return _0x558cac;};return a90_0x29c7();}function a90_0x4667(_0x4234ca,_0x5e468d){_0x4234ca=_0x4234ca-0xea;const _0x29c70c=a90_0x29c7();let _0x4667b0=_0x29c70c[_0x4234ca];return _0x4667b0;}export function formatTokenCount(_0x4ae947){const _0x36405c=a90_0x4667;return _0x4ae947[_0x36405c(0xff)](_0x36405c(0xf3));}export function calculateContextPercentage(_0x1839ec,_0x25f351){const _0x530096=a90_0x4667,_0x526b96=getContextLimit(_0x25f351);return Math[_0x530096(0xf0)](_0x1839ec/_0x526b96*0x64);}
|
package/dist/sdk/query/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
function a91_0xfa30(){const _0x2d8308=['listTables','99314aZiCre','\x0a\x20\x20AND\x20table_schema\x20LIKE\x20','MISSING_ARGUMENT','\x20ESCAPE\x20\x27\x5c\x27','Database\x20pattern\x20cannot\x20be\x20empty\x20or\x20whitespace-only','Provide\x20SQL\x20via\x20argument\x20or\x20use\x20--file\x20option.','trim','34720BEvUtc','Pattern\x20cannot\x20be\x20empty\x20or\x20whitespace-only','data','describeTable','\x0a\x20\x20\x20\x20\x20\x20ORDER\x20BY\x20ordinal_position\x0a\x20\x20\x20\x20','900519aLeBov','validateDatabase','504525RifroV','\x20LIMIT\x20','\x0a\x20\x20\x20\x20\x20\x20\x20\x20AND\x20table_name\x20=\x20','\x0a\x20\x20\x20\x20\x20\x20SELECT\x0a\x20\x20\x20\x20\x20\x20\x20\x20column_name,\x0a\x20\x20\x20\x20\x20\x20\x20\x20data_type,\x0a\x20\x20\x20\x20\x20\x20\x20\x20is_nullable\x0a\x20\x20\x20\x20\x20\x20FROM\x20td.information_schema.columns\x0a\x20\x20\x20\x20\x20\x20WHERE\x20table_catalog\x20=\x20\x27td\x27\x0a\x20\x20\x20\x20\x20\x20\x20\x20AND\x20table_schema\x20=\x20','Use\x20--limit\x20<number>\x20to\x20specify\x20row\x20limit\x20(must\x20be\x20positive).','\x0a\x20\x20AND\x20table_name\x20LIKE\x20','Table\x20name\x20is\x20required','SQL\x20query\x20is\x20required','INVALID_ARGUMENT','Usage:\x20tdx\x20describe\x20<database.table>','listDatabases','1740588WucMRX','SELECT\x20*\x20FROM\x20','\x0a\x20\x20\x20\x20','\x0a\x20\x20\x20\x20\x20\x20SELECT\x201\x0a\x20\x20\x20\x20\x20\x20FROM\x20td.information_schema.schemata\x0a\x20\x20\x20\x20\x20\x20WHERE\x20catalog_name\x20=\x20\x27td\x27\x0a\x20\x20\x20\x20\x20\x20\x20\x20AND\x20schema_name\x20=\x20','slice','1956280EjmCpa','isInteger','\x0aORDER\x20BY\x20database_name,\x20table_name\x0aLIMIT\x20','\x0a\x20\x20\x20\x20\x20\x20\x20\x20SELECT\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20table_schema\x20AS\x20database_name,\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20table_name\x0a\x20\x20\x20\x20\x20\x20\x20\x20FROM\x20td.information_schema.tables\x0a\x20\x20\x20\x20\x20\x20\x20\x20WHERE\x20table_catalog\x20=\x20\x27td\x27\x0a\x20\x20\x20\x20\x20\x20','\x0a\x20\x20\x20\x20\x20\x20','Provide\x20a\x20positive\x20number\x20for\x20limit\x20(e.g.,\x20100).','180378ldHluV','\x0a\x20\x20\x20\x20\x20\x20SELECT\x20schema_name\x20AS\x20database_name\x0a\x20\x20\x20\x20\x20\x20FROM\x20td.information_schema.schemata\x0a\x20\x20\x20\x20\x20\x20WHERE\x20catalog_name\x20=\x20\x27td\x27\x0a\x20\x20\x20\x20','Database\x20name\x20is\x20required','length','executeQuery','\x0aORDER\x20BY\x20database_name\x0aLIMIT\x20','showTable','5LvMsDk','\x0a\x20\x20\x20\x20\x20\x20\x20\x20SELECT\x20table_name\x0a\x20\x20\x20\x20\x20\x20\x20\x20FROM\x20td.information_schema.tables\x0a\x20\x20\x20\x20\x20\x20\x20\x20WHERE\x20table_catalog\x20=\x20\x27td\x27\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20AND\x20table_schema\x20=\x20','logger','Usage:\x20tdx\x20show\x20<database.table>','\x0a\x20\x20AND\x20schema_name\x20LIKE\x20','trinoApiClient','Provide\x20a\x20valid\x20database\x20name\x20or\x20omit\x20to\x20list\x20tables\x20from\x20all\x20databases.','9QinUTc','\x0aORDER\x20BY\x20table_name\x0aLIMIT\x20'];a91_0xfa30=function(){return _0x2d8308;};return a91_0xfa30();}const a91_0x134947=a91_0x1668;(function(_0x1e14d9,_0x202f42){const _0x2f5e81=a91_0x1668,_0x698f0e=_0x1e14d9();while(!![]){try{const _0x4a88fb=-parseInt(_0x2f5e81(0x1f2))/0x1+parseInt(_0x2f5e81(0x1ce))/0x2+parseInt(_0x2f5e81(0x1da))/0x3+parseInt(_0x2f5e81(0x1d5))/0x4*(parseInt(_0x2f5e81(0x1c4))/0x5)+parseInt(_0x2f5e81(0x1e7))/0x6+-parseInt(_0x2f5e81(0x1dc))/0x7+parseInt(_0x2f5e81(0x1ec))/0x8*(-parseInt(_0x2f5e81(0x1cb))/0x9);if(_0x4a88fb===_0x202f42)break;else _0x698f0e['push'](_0x698f0e['shift']());}catch(_0x828cb9){_0x698f0e['push'](_0x698f0e['shift']());}}}(a91_0xfa30,0x25044));import{TrinoApiClient}from'../client/trino-api-client.js';import{escapeStringLiteral,buildLikePattern}from'../../utils/string-utils.js';import{SDKError,ErrorCode}from'../errors.js';function a91_0x1668(_0x57a433,_0x4b576b){_0x57a433=_0x57a433-0x1bf;const _0xfa30c1=a91_0xfa30();let _0x166880=_0xfa30c1[_0x57a433];return _0x166880;}import{DEFAULT_LISTING_LIMIT}from'../../core/constants.js';export class QuerySDK{[a91_0x134947(0x1c9)];constructor(_0x4b061a){const _0xd0a986=a91_0x134947;this[_0xd0a986(0x1c9)]=new TrinoApiClient(_0x4b061a,_0x4b061a[_0xd0a986(0x1c6)]);}async['execute'](_0x293a0e,_0xbedc1){const _0x5d3c1a=a91_0x134947;if(!_0x293a0e||_0x293a0e['trim']()[_0x5d3c1a(0x1c0)]===0x0)throw new SDKError(ErrorCode[_0x5d3c1a(0x1d0)],_0x5d3c1a(0x1e3),undefined,{'helpText':_0x5d3c1a(0x1d3)});return await this[_0x5d3c1a(0x1c9)][_0x5d3c1a(0x1c1)](_0x293a0e,_0xbedc1);}async[a91_0x134947(0x1e6)](_0xe0d75,_0x4daeef=DEFAULT_LISTING_LIMIT){const _0x112884=a91_0x134947;if(_0xe0d75!==undefined&&_0xe0d75[_0x112884(0x1d4)]()[_0x112884(0x1c0)]===0x0)throw new SDKError(ErrorCode[_0x112884(0x1e4)],_0x112884(0x1d6),undefined,{'helpText':'Provide\x20a\x20valid\x20glob\x20pattern\x20(e.g.,\x20\x22prod_*\x22)\x20or\x20omit\x20the\x20pattern\x20to\x20list\x20all\x20databases.'});if(_0x4daeef<=0x0)throw new SDKError(ErrorCode['INVALID_ARGUMENT'],'Limit\x20must\x20be\x20a\x20positive\x20number',undefined,{'helpText':'Provide\x20a\x20positive\x20number\x20for\x20limit\x20(e.g.,\x20100).'});let _0xaf37d9=_0x112884(0x1f3);_0xe0d75&&(_0xaf37d9+=_0x112884(0x1c8)+buildLikePattern(_0xe0d75)+_0x112884(0x1d1));_0xaf37d9+=_0x112884(0x1c2)+_0x4daeef;const _0x861502=await this[_0x112884(0x1c9)][_0x112884(0x1c1)](_0xaf37d9[_0x112884(0x1d4)]());return _0x861502[_0x112884(0x1d7)];}async[a91_0x134947(0x1cd)](_0xa4f980,_0x308601,_0x15ca81,_0x2c82d7=DEFAULT_LISTING_LIMIT){const _0x4afad2=a91_0x134947;if(_0xa4f980!==undefined&&_0xa4f980[_0x4afad2(0x1d4)]()[_0x4afad2(0x1c0)]===0x0)throw new SDKError(ErrorCode[_0x4afad2(0x1e4)],'Database\x20name\x20cannot\x20be\x20empty\x20or\x20whitespace-only',undefined,{'helpText':_0x4afad2(0x1ca)});if(_0x308601!==undefined&&_0x308601[_0x4afad2(0x1d4)]()[_0x4afad2(0x1c0)]===0x0)throw new SDKError(ErrorCode['INVALID_ARGUMENT'],_0x4afad2(0x1d6),undefined,{'helpText':'Provide\x20a\x20valid\x20glob\x20pattern\x20(e.g.,\x20\x22user_*\x22)\x20or\x20omit\x20to\x20list\x20all\x20tables.'});if(_0x15ca81!==undefined&&_0x15ca81[_0x4afad2(0x1d4)]()['length']===0x0)throw new SDKError(ErrorCode[_0x4afad2(0x1e4)],_0x4afad2(0x1d2),undefined,{'helpText':'Provide\x20a\x20valid\x20glob\x20pattern\x20(e.g.,\x20\x22prod_*\x22)\x20or\x20omit\x20to\x20search\x20all\x20databases.'});if(_0x2c82d7<=0x0)throw new SDKError(ErrorCode[_0x4afad2(0x1e4)],'Limit\x20must\x20be\x20a\x20positive\x20number',undefined,{'helpText':_0x4afad2(0x1f1)});let _0x3cdcb3;_0xa4f980?(_0x3cdcb3=_0x4afad2(0x1c5)+escapeStringLiteral(_0xa4f980)+_0x4afad2(0x1f0),_0x308601&&(_0x3cdcb3+=_0x4afad2(0x1e1)+buildLikePattern(_0x308601)+'\x20ESCAPE\x20\x27\x5c\x27'),_0x3cdcb3+=_0x4afad2(0x1cc)+_0x2c82d7):(_0x3cdcb3=_0x4afad2(0x1ef),_0x15ca81&&(_0x3cdcb3+=_0x4afad2(0x1cf)+buildLikePattern(_0x15ca81)+_0x4afad2(0x1d1)),_0x308601&&(_0x3cdcb3+=_0x4afad2(0x1e1)+buildLikePattern(_0x308601)+'\x20ESCAPE\x20\x27\x5c\x27'),_0x3cdcb3+=_0x4afad2(0x1ee)+_0x2c82d7);const _0x1406f9=await this[_0x4afad2(0x1c9)][_0x4afad2(0x1c1)](_0x3cdcb3[_0x4afad2(0x1d4)]());return _0x1406f9[_0x4afad2(0x1d7)];}async[a91_0x134947(0x1db)](_0x359e7d){const _0x360ec2=a91_0x134947,_0xf8bcef=(_0x360ec2(0x1ea)+escapeStringLiteral(_0x359e7d)+_0x360ec2(0x1e9))[_0x360ec2(0x1d4)](),_0x3d2d5e=await this['trinoApiClient']['executeQuery'](_0xf8bcef);return _0x3d2d5e[_0x360ec2(0x1d7)][_0x360ec2(0x1c0)]>0x0;}async['validateTable'](_0xb726a2,_0x1c719c){const _0x4a4335=a91_0x134947,_0x58250b=('\x0a\x20\x20\x20\x20\x20\x20SELECT\x201\x0a\x20\x20\x20\x20\x20\x20FROM\x20td.information_schema.tables\x0a\x20\x20\x20\x20\x20\x20WHERE\x20table_catalog\x20=\x20\x27td\x27\x0a\x20\x20\x20\x20\x20\x20\x20\x20AND\x20table_schema\x20=\x20'+escapeStringLiteral(_0xb726a2)+_0x4a4335(0x1de)+escapeStringLiteral(_0x1c719c)+'\x0a\x20\x20\x20\x20')[_0x4a4335(0x1d4)](),_0x1865e1=await this[_0x4a4335(0x1c9)][_0x4a4335(0x1c1)](_0x58250b);return _0x1865e1['data'][_0x4a4335(0x1c0)]>0x0;}async[a91_0x134947(0x1d8)](_0x3e118b,_0x4c523d){const _0x3da396=a91_0x134947;if(!_0x3e118b||_0x3e118b[_0x3da396(0x1d4)]()['length']===0x0)throw new SDKError(ErrorCode[_0x3da396(0x1d0)],_0x3da396(0x1bf),undefined,{'helpText':_0x3da396(0x1e5)});if(!_0x4c523d||_0x4c523d['trim']()[_0x3da396(0x1c0)]===0x0)throw new SDKError(ErrorCode['MISSING_ARGUMENT'],_0x3da396(0x1e2),undefined,{'helpText':_0x3da396(0x1e5)});const _0x4d767f=(_0x3da396(0x1df)+escapeStringLiteral(_0x3e118b)+_0x3da396(0x1de)+escapeStringLiteral(_0x4c523d)+_0x3da396(0x1d9))[_0x3da396(0x1d4)](),_0x1b91eb=await this[_0x3da396(0x1c9)][_0x3da396(0x1c1)](_0x4d767f);return _0x1b91eb[_0x3da396(0x1d7)];}async[a91_0x134947(0x1c3)](_0x52f4f9,_0x5244c4,_0x2562df=0x28,_0x4cdc3d){const _0x441a3f=a91_0x134947;if(!_0x52f4f9||_0x52f4f9[_0x441a3f(0x1d4)]()[_0x441a3f(0x1c0)]===0x0)throw new SDKError(ErrorCode[_0x441a3f(0x1d0)],_0x441a3f(0x1bf),undefined,{'helpText':_0x441a3f(0x1c7)});if(!_0x5244c4||_0x5244c4[_0x441a3f(0x1d4)]()['length']===0x0)throw new SDKError(ErrorCode['MISSING_ARGUMENT'],'Table\x20name\x20is\x20required',undefined,{'helpText':_0x441a3f(0x1c7)});if(!Number[_0x441a3f(0x1ed)](_0x2562df)||_0x2562df<=0x0)throw new SDKError(ErrorCode[_0x441a3f(0x1e4)],'Limit\x20must\x20be\x20a\x20positive\x20integer',undefined,{'helpText':_0x441a3f(0x1e0)});const _0x4b307c=escapeStringLiteral(_0x52f4f9)[_0x441a3f(0x1eb)](0x1,-0x1)+'.'+escapeStringLiteral(_0x5244c4)[_0x441a3f(0x1eb)](0x1,-0x1),_0x44dfa1=_0x441a3f(0x1e8)+_0x4b307c+_0x441a3f(0x1dd)+_0x2562df,_0x31f9cb=await this[_0x441a3f(0x1c9)]['executeQuery'](_0x44dfa1,{'catalog':_0x4cdc3d,'schema':_0x52f4f9});return _0x31f9cb;}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
(function(_0x213308,_0x298751){const _0x51f5ff=a92_0x284e,_0x3ee916=_0x213308();while(!![]){try{const _0x5f16e7=-parseInt(_0x51f5ff(0xdf))/0x1+-parseInt(_0x51f5ff(0xd4))/0x2+-parseInt(_0x51f5ff(0xc9))/0x3+parseInt(_0x51f5ff(0xd9))/0x4*(parseInt(_0x51f5ff(0xcb))/0x5)+parseInt(_0x51f5ff(0xbd))/0x6*(parseInt(_0x51f5ff(0xbc))/0x7)+parseInt(_0x51f5ff(0xdc))/0x8*(-parseInt(_0x51f5ff(0xc6))/0x9)+-parseInt(_0x51f5ff(0xce))/0xa*(-parseInt(_0x51f5ff(0xde))/0xb);if(_0x5f16e7===_0x298751)break;else _0x3ee916['push'](_0x3ee916['shift']());}catch(_0x115330){_0x3ee916['push'](_0x3ee916['shift']());}}}(a92_0x10a5,0xc93b0));import{readFileSync}from'fs';import{createInterface}from'readline';export function stripSqlComments(_0x4ba7b4){const _0x4e7afc=a92_0x284e;let _0x5cb307=_0x4ba7b4[_0x4e7afc(0xd1)](/\/\*(?:[^*]|\*(?!\/))*\*\//g,'');return _0x5cb307=_0x5cb307['replace'](/--.*$/gm,''),_0x5cb307[_0x4e7afc(0xda)]();}function isEscaped(_0x1b59f8,_0x33b76e){let _0x2eed49=0x0;for(let _0x3c6925=_0x33b76e-0x1;_0x3c6925>=0x0&&_0x1b59f8[_0x3c6925]==='\x5c';_0x3c6925--){_0x2eed49++;}return _0x2eed49%0x2===0x1;}export function splitSqlStatements(_0x2c6e63){const _0x371646=a92_0x284e,_0x56729f=stripSqlComments(_0x2c6e63);if(!_0x56729f)throw new Error(_0x371646(0xc1));const _0x39ed92=[];let _0x3ba81f='',_0x5bd561=![],_0x507e2c=![],_0x213390=![];for(let _0x688e7c=0x0;_0x688e7c<_0x2c6e63[_0x371646(0xcf)];_0x688e7c++){const _0x191d49=_0x2c6e63[_0x688e7c];if(_0x191d49==='\x27'&&!isEscaped(_0x2c6e63,_0x688e7c)&&!_0x507e2c&&!_0x213390)_0x5bd561=!_0x5bd561;else{if(_0x191d49==='\x22'&&!isEscaped(_0x2c6e63,_0x688e7c)&&!_0x5bd561&&!_0x213390)_0x507e2c=!_0x507e2c;else _0x191d49==='`'&&!isEscaped(_0x2c6e63,_0x688e7c)&&!_0x5bd561&&!_0x507e2c&&(_0x213390=!_0x213390);}if(_0x191d49===';'&&!_0x5bd561&&!_0x507e2c&&!_0x213390){const _0x1ecf9c=_0x3ba81f[_0x371646(0xda)]();_0x1ecf9c&&_0x39ed92[_0x371646(0xbb)](_0x1ecf9c),_0x3ba81f='';}else _0x3ba81f+=_0x191d49;}const _0x475152=_0x3ba81f['trim']();_0x475152&&_0x39ed92[_0x371646(0xbb)](_0x475152);const _0x2056aa=_0x39ed92[_0x371646(0xd0)](_0x28e877=>_0x28e877[_0x371646(0xda)]())[_0x371646(0xbe)](_0x22d06c=>{const _0x46e9fb=stripSqlComments(_0x22d06c);return _0x46e9fb['length']>0x0;});if(_0x2056aa['length']===0x0)throw new Error(_0x371646(0xc1));return _0x2056aa;}function a92_0x10a5(){const _0xccfffb=['ENOENT','Content\x20contains\x20no\x20SQL\x20statements','join','No\x20input\x20provided.\x20Pipe\x20SQL\x20to\x20stdin\x20or\x20use\x20a\x20file.\x0aExample:\x20echo\x20\x22SELECT\x201\x22\x20|\x20tdx\x20query\x20-','message','error','1953729ffQsyZ','line','close','3688299ytNtUz','\x27\x20not\x20found','5SuvWOZ','toLowerCase','EACCES','100izpjJm','length','map','replace','isTTY','code','1551978iBJlxP','stdin','test','File\x20\x27','utf-8','3672452eySAvT','trim','Error\x20reading\x20from\x20stdin:\x20','8pQuXIC','Error\x20reading\x20file\x20\x27','2734534GbJZiM','695561chKWBU','push','2367757QLeRGt','6WuGTTt','filter','stdin\x20'];a92_0x10a5=function(){return _0xccfffb;};return a92_0x10a5();}export function readFileContent(_0x2ad076){const _0x2a208b=a92_0x284e;try{return readFileSync(_0x2ad076,_0x2a208b(0xd8));}catch(_0xa69139){const _0x56ec18=_0xa69139[_0x2a208b(0xd3)];if(_0x56ec18===_0x2a208b(0xc0))throw new Error(_0x2a208b(0xd7)+_0x2ad076+_0x2a208b(0xca));else{if(_0x56ec18===_0x2a208b(0xcd))throw new Error('Permission\x20denied\x20reading\x20file\x20\x27'+_0x2ad076+'\x27');else throw new Error(_0x2a208b(0xdd)+_0x2ad076+'\x27:\x20'+_0xa69139[_0x2a208b(0xc4)]);}}}export function readSqlStatementsFromFile(_0x4c4598){const _0x153478=a92_0x284e,_0x45f318=readFileContent(_0x4c4598);try{return splitSqlStatements(_0x45f318);}catch(_0x29f09f){throw new Error('File\x20\x27'+_0x4c4598+'\x27\x20'+_0x29f09f[_0x153478(0xc4)][_0x153478(0xcc)]());}}function a92_0x284e(_0x24a488,_0x5792d6){_0x24a488=_0x24a488-0xbb;const _0x10a5d1=a92_0x10a5();let _0x284e9a=_0x10a5d1[_0x24a488];return _0x284e9a;}export async function readStdinContent(){const _0x4ca2e5=a92_0x284e;if(process[_0x4ca2e5(0xd5)][_0x4ca2e5(0xd2)])throw new Error(_0x4ca2e5(0xc3));return new Promise((_0x8587ed,_0x2001ca)=>{const _0x44e621=_0x4ca2e5,_0x1bd3d4=[],_0xb0ca06=createInterface({'input':process[_0x44e621(0xd5)],'terminal':![]});_0xb0ca06['on'](_0x44e621(0xc7),_0x27217c=>{const _0x555459=_0x44e621;_0x1bd3d4[_0x555459(0xbb)](_0x27217c);}),_0xb0ca06['on'](_0x44e621(0xc8),()=>{const _0x4f64b1=_0x44e621;_0x8587ed(_0x1bd3d4[_0x4f64b1(0xc2)]('\x0a'));}),_0xb0ca06['on'](_0x44e621(0xc5),_0x3f2000=>{const _0x2a0f4f=_0x44e621;_0xb0ca06['close'](),_0x2001ca(new Error(_0x2a0f4f(0xdb)+_0x3f2000[_0x2a0f4f(0xc4)]));});});}export async function readSqlStatementsFromStdin(){const _0x2bf015=a92_0x284e,_0x1b5c77=await readStdinContent();try{return splitSqlStatements(_0x1b5c77);}catch(_0x30d2ab){throw new Error(_0x2bf015(0xbf)+_0x30d2ab[_0x2bf015(0xc4)][_0x2bf015(0xcc)]());}}export function isSqlFilePath(_0x2b05f9){const _0xf391cd=a92_0x284e;return/\w\.sql$/[_0xf391cd(0xd6)](_0x2b05f9);}
|