@treasuredata/tdx 0.9.6 → 0.9.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 +2 -2
- package/dist/cli-categories.js +1 -1
- package/dist/cli.js +1 -1
- package/dist/client/cdp-api-client.js +1 -1
- package/dist/client/engage-api-client.js +1 -1
- package/dist/client/http-client.js +1 -1
- package/dist/client/llm-api-client.js +1 -1
- package/dist/client/rate-limiter.js +1 -1
- package/dist/client/td-api-client.js +1 -1
- package/dist/client/trino-api-client.js +1 -1
- package/dist/client/workflow-client.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/context-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/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/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/segments.js +1 -1
- package/dist/commands/show.js +1 -1
- package/dist/commands/tables.js +1 -1
- package/dist/commands/use-command.js +1 -1
- package/dist/commands/user-command.js +1 -1
- package/dist/commands/workflow-command.js +1 -1
- package/dist/core/auth.js +1 -1
- package/dist/core/config.js +1 -1
- package/dist/core/connection-cache.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/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/server.js +1 -1
- package/dist/proxy/session-cache.js +1 -1
- package/dist/sdk/agent/agent-yaml.js +1 -1
- package/dist/sdk/api.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/job.js +1 -1
- package/dist/sdk/journey.js +1 -1
- package/dist/sdk/llm.js +1 -1
- package/dist/sdk/query.js +1 -1
- package/dist/sdk/segment/child-segment-yaml.js +1 -1
- package/dist/sdk/segment/journey-yaml.d.ts +53 -18
- package/dist/sdk/segment/journey-yaml.d.ts.map +1 -1
- package/dist/sdk/segment/journey-yaml.js +1 -1
- package/dist/sdk/segment/journey-yaml.js.map +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.js +1 -1
- package/dist/sdk/user.js +1 -1
- package/dist/sdk/workflow.js +1 -1
- package/dist/types/endpoints.js +1 -1
- package/dist/types/index.js +1 -1
- package/dist/utils/agent-config.js +1 -1
- package/dist/utils/agent-ref-parser.js +1 -1
- package/dist/utils/async.js +1 -1
- package/dist/utils/chat-cache.js +1 -1
- package/dist/utils/colors.js +1 -1
- package/dist/utils/command-output.js +1 -1
- package/dist/utils/constants.js +1 -1
- package/dist/utils/diff.js +1 -1
- package/dist/utils/fields-display.js +1 -1
- package/dist/utils/file-permissions.js +1 -1
- package/dist/utils/format-detector.js +1 -1
- package/dist/utils/formatters.js +1 -1
- package/dist/utils/journey-utils.d.ts +30 -0
- package/dist/utils/journey-utils.d.ts.map +1 -1
- package/dist/utils/journey-utils.js +1 -1
- package/dist/utils/journey-utils.js.map +1 -1
- package/dist/utils/json-loader.js +1 -1
- package/dist/utils/llm-backup-utils.js +1 -1
- package/dist/utils/model-aliases.js +1 -1
- package/dist/utils/model-factors.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/segment-path-parser.js +1 -1
- package/dist/utils/segment-ref-parser.js +1 -1
- package/dist/utils/spinner.js +1 -1
- package/dist/utils/sql-parser.js +1 -1
- package/dist/utils/sse-parser.js +1 -1
- package/dist/utils/string-utils.js +1 -1
- package/dist/utils/table-ref-parser.js +1 -1
- package/dist/utils/tdx-config.js +1 -1
- package/dist/utils/tdx-logger.js +1 -1
- package/dist/utils/tree-formatter.js +1 -1
- package/dist/utils/version-check.js +1 -1
- package/dist/utils/workflow-utils.js +1 -1
- package/package.json +1 -1
package/dist/sdk/llm.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const a71_0x4d6f2d=a71_0x8b3c;(function(_0x25fe6c,_0x43f03c){const _0x25d86a=a71_0x8b3c,_0x4c6726=_0x25fe6c();while(!![]){try{const _0x95473c=parseInt(_0x25d86a(0x1a8))/0x1+-parseInt(_0x25d86a(0x1c9))/0x2+parseInt(_0x25d86a(0x1cd))/0x3+parseInt(_0x25d86a(0x17a))/0x4+-parseInt(_0x25d86a(0x1e7))/0x5+parseInt(_0x25d86a(0x21e))/0x6+-parseInt(_0x25d86a(0x220))/0x7*(parseInt(_0x25d86a(0x1aa))/0x8);if(_0x95473c===_0x43f03c)break;else _0x4c6726['push'](_0x4c6726['shift']());}catch(_0x211b26){_0x4c6726['push'](_0x4c6726['shift']());}}}(a71_0x2ccc,0x707bc));import{LLMApiClient}from'../client/llm-api-client.js';import*as a71_0x20c894 from'node:fs';function a71_0x8b3c(_0x44c110,_0x217a9f){_0x44c110=_0x44c110-0x14f;const _0x2ccc7c=a71_0x2ccc();let _0x8b3c64=_0x2ccc7c[_0x44c110];return _0x8b3c64;}import*as a71_0x3e1183 from'node:path';import{HTTPClientError}from'../client/http-client.js';import{canCreateAgent,remapToolIds,remapVariableIds,isSupportedBackupVersion}from'../utils/llm-backup-utils.js';import{SDKError,ErrorCode,errorContains}from'./errors.js';function a71_0x2ccc(){const _0x5b8427=['The\x20backup\x20contains\x20agents\x20with\x20circular\x20dependencies.','Backup\x20folder\x20not\x20found:\x20','#\x20prompt.md\x0a','site','push','setDefaultAgent','client','imageGenerators','clearDefaultAgent','outputs','systemPrompt','some','Available\x20agents:\x20','llm_project','updateAgentFull','Ensure\x20this\x20is\x20a\x20valid\x20LLM\x20project\x20backup\x20folder.','isDirectory','has','tdx.json','loadJsonFile','integrations','context','availableModelNames','Ensure\x20the\x20backup\x20folder\x20path\x20is\x20correct.','text','getAgent','keys','deleteProject','3537360ftOCVN','total','89929hptrQn','starter_message','content','No\x20tdx.json\x20found\x20in\x20','tdDatabaseName','.yml','Project\x20\x22','high','endsWith','getDefaultProjectName','promptId','counts','NOT_FOUND','getChatInfo','starterMessage','Multiple\x20agents\x20found\x20with\x20name\x20\x27','stringify','Invalid\x20agent\x20reference\x20format:\x20','filter','\x27\x20has\x20self-referencing\x20tool(s)\x20that\x20will\x20be\x20skipped\x20during\x20clone.\x20','createAgent','existsSync','createKnowledgeBase','cwd','Agent\x20reference\x20not\x20found','length','listProjects','status','pullProject','knowledge_bases','conflict','listTextKnowledgeBases','restoreProject','jsonSchemaHint','LLM_PROJECT_NOT_FOUND','chatId','updateTextKnowledgeBase','PERMISSION_DENIED','Run\x20\x27tdx\x20agent\x20pull\x20<project>\x27\x20first\x20to\x20create\x20the\x20folder\x20structure.','path','getBackupMetadata','listImageGenerators','dir','Circular\x20dependency\x20detected\x20in\x20agents.\x20Cannot\x20restore.','INTERNAL','.md','listKnowledgeBases','chatIgnoreManagedActions','name','textKnowledgeBases','listAgents','event','minimal','listPrompts','sort','actions','ALREADY_EXISTS','2299120hlkIbI','getOrCreateDefaultAgent','yaml','agentId\x20is\x20required\x20when\x20starting\x20a\x20new\x20chat','attributes','This\x20backup\x20was\x20created\x20with\x20a\x20newer\x20version\x20of\x20tdx.','toISOString','Failed\x20to\x20get\x20or\x20create\x20agent:\x20exceeded\x20maximum\x20attempts','size','warn','claude-4.5-sonnet','dry-run-','split','Unable\x20to\x20create\x20project\x20after\x20','agentId','resolveProjectName','UNAUTHENTICATED','setCurrentProject','created','readdirSync','temperature','\x27.\x20This\x20should\x20not\x20happen.','starter_message.md','new','set','map','\x20attempts\x20due\x20to\x20name\x20conflicts.','getChatHistory','Choose\x20a\x20different\x20name\x20or\x20delete\x20the\x20existing\x20project\x20first.','tools','getOrCreateDefaultProject','serviceType','Re-add\x20them\x20after\x20clone\x20using\x20\x27tdx\x20agent\x20push\x27.','isDir','Output\x20directory\x20already\x20exists:\x20','Authentication\x20failed.\x20Please\x20check\x20your\x20API\x20key\x20is\x20valid\x20and\x20not\x20expired.','Default\x20project\x20for\x20tdx\x20CLI\x20chat\x20(user:\x20','updateKnowledgeBase','Unsupported\x20backup\x20version:\x20','profile','find','startChat','resolveAgentId','listWebSearchTools','utf-8','Project\x20not\x20found:\x20','189722obxwaY','prompt.md','160ofvokk','.llm','createPrompt','parse','slackMessageMode','Use\x20a\x20different\x20output\x20path\x20or\x20remove\x20the\x20existing\x20directory.','projects','variables','getProject','history','INVALID_ARGUMENT','currentProjectId','readFileSync','errors','agents','\x0a\x0a#\x20agent.yml\x0a','type','agents.json','deleteAgent','Agent\x20not\x20found:\x20','unchanged','error','target','action','prompts','knowledgeBases','getUniqueName','unlinkSync','displayName','(dry-run)','updateAgent','54156kMkFdy','\x22\x20already\x20exists','prompts.json','pushProject','873942slBxfb','dirname','Ensure\x20the\x20path\x20points\x20to\x20a\x20valid\x20agent\x20directory.','createProject','project.json','pullAgent','resolveProjectId','getUserSettings','models','\x20in\x20project\x20','createWebSearchTool','pushAgent','get','createAgentFull','modelType','web_search','getDefaultAgent','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.','Unresolved\x20dependencies:\x20','template','agent.yml\x20not\x20found\x20in\x20','Use\x20format:\x20\x22agent-name\x22\x20or\x20\x22project-name/agent-name\x22','agent','chat','medium','listAgentsFull','4503130nzjtbY','listChats','webSearchTools','updated','isManaged','logger','mkdirSync','dryRun','signal','Permission\x20denied.\x20Please\x20check\x20your\x20API\x20key\x20has\x20the\x20required\x20permissions\x20for\x20LLM\x20API\x20operations.','Invalid\x20backup:\x20project.json\x20not\x20found\x20in\x20','Agent\x20\x27','exportedFrom','writeFileSync','message','agent.yml','backupProject','tdx_','knowledgebases.json','includes','newProjectId','project','webhookCorsOrigins','createTextKnowledgeBase','listIntegrations','version','join'];a71_0x2ccc=function(){return _0x5b8427;};return a71_0x2ccc();}import{normalizeName,UniqueNameGenerator,migrateModelType,parseRef,apiAgentToYaml,apiKnowledgeBaseToYaml,apiPromptToYaml,toAgentYamlString,toKnowledgeBaseYamlString,toTextKnowledgeBaseMd,toPromptYamlString,parseAgentYaml,parseKnowledgeBaseYaml,parseTextKnowledgeBaseMd,parsePromptYaml,yamlAgentToApi,yamlKnowledgeBaseToApi,yamlTextKnowledgeBaseToApi,yamlPromptToApi,resolveAgentDependencies}from'./agent/agent-yaml.js';import{createAgentConfigContent,loadAgentConfig,findAgentConfig,isAgentDir,isAgentYamlPath,getAgentDirFromYamlPath,getKnowledgeBasesDir,getPromptsDir}from'../utils/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{[a71_0x4d6f2d(0x1b5)];[a71_0x4d6f2d(0x208)];[a71_0x4d6f2d(0x217)];constructor(_0x17d1cd){const _0x28a0ed=a71_0x4d6f2d;this[_0x28a0ed(0x208)]=new LLMApiClient(_0x17d1cd,_0x17d1cd[_0x28a0ed(0x1ec)]),this[_0x28a0ed(0x217)]=_0x17d1cd;}[a71_0x4d6f2d(0x229)](){const _0x2f5f4a=getSanitizedUsername();return'tdx_default_'+_0x2f5f4a;}async[a71_0x4d6f2d(0x18b)](_0x4b3144){const _0xaa1a6=a71_0x4d6f2d,{projectId:_0x216f78}=await this[_0xaa1a6(0x189)](_0x4b3144);this[_0xaa1a6(0x1b5)]=_0x216f78;}['getCurrentProject'](){const _0x5e2249=a71_0x4d6f2d;return this[_0x5e2249(0x1b5)];}async[a71_0x4d6f2d(0x207)](_0x3c9aa2){const _0xaa951b=a71_0x4d6f2d,_0x5c8a20=this[_0xaa951b(0x217)][_0xaa951b(0x1a1)];let _0x8e209e,_0x3923b9;if(_0x3c9aa2['includes']('/')){const _0x2689dc=_0x3c9aa2[_0xaa951b(0x186)]('/');if(_0x2689dc[_0xaa951b(0x15a)]!==0x2)throw new SDKError(ErrorCode[_0xaa951b(0x1b4)],_0xaa951b(0x152)+_0x3c9aa2,undefined,{'helpText':_0xaa951b(0x1e2)});const [_0x49f962,_0x38a242]=_0x2689dc;_0x8e209e=await this[_0xaa951b(0x1d3)](_0x49f962),_0x3923b9=_0x38a242;}else _0x8e209e=this['currentProjectId']||(await this['getOrCreateDefaultProject']())['id'],_0x3923b9=_0x3c9aa2;const _0x313bc4=await this[_0xaa951b(0x1a4)](_0x3923b9,_0x8e209e),_0x1041e0=await this[_0xaa951b(0x208)][_0xaa951b(0x21b)](_0x313bc4);writeCachedLLMAgent(_0x1041e0[_0xaa951b(0x17e)]['name'],_0x313bc4,_0x8e209e,_0x5c8a20);}[a71_0x4d6f2d(0x1dd)](){const _0x3ec7db=a71_0x4d6f2d,_0xf0a55=this['context'][_0x3ec7db(0x1a1)];return readCachedLLMAgent(_0xf0a55)||undefined;}[a71_0x4d6f2d(0x20a)](){const _0x2721ca=a71_0x4d6f2d,_0x41f4fc=this[_0x2721ca(0x217)][_0x2721ca(0x1a1)];clearCachedLLMAgent(_0x41f4fc);}async[a71_0x4d6f2d(0x1d5)](){const _0x26c0ef=a71_0x4d6f2d,_0x27ef82=await this[_0x26c0ef(0x208)][_0x26c0ef(0x1d4)](),_0x13a142=[];for(const _0x155844 of _0x27ef82[_0x26c0ef(0x218)]){const _0x4932e5=_0x27ef82['availableModels'][_0x155844];_0x4932e5&&_0x13a142['push']({'name':_0x155844,'displayName':_0x4932e5[_0x26c0ef(0x1c6)]});}return _0x13a142;}async[a71_0x4d6f2d(0x1d0)](_0x3adee3){const _0x34d863=a71_0x4d6f2d;return await this[_0x34d863(0x208)]['createProject'](_0x3adee3);}async[a71_0x4d6f2d(0x21d)](_0x5516c6){const _0x112ba1=a71_0x4d6f2d,{projectId:_0x1d3e90}=await this[_0x112ba1(0x189)](_0x5516c6);await this['client']['deleteProject'](_0x1d3e90);}async[a71_0x4d6f2d(0x1b0)](_0x11f685=0x32){const _0x43403d=a71_0x4d6f2d;return await this[_0x43403d(0x208)][_0x43403d(0x15b)](_0x11f685);}async[a71_0x4d6f2d(0x198)](_0x519f48){const _0x4e711f=a71_0x4d6f2d,_0x1e3222=_0x519f48||this[_0x4e711f(0x229)](),_0x4b5670=this[_0x4e711f(0x217)][_0x4e711f(0x1a1)];if(!_0x519f48){const _0x3ac3b4=readCachedLLMProject(_0x4b5670);if(_0x3ac3b4&&_0x3ac3b4['name']===_0x1e3222)try{const _0x50c900=await this['client'][_0x4e711f(0x1b2)](_0x3ac3b4['id']);if(_0x50c900[_0x4e711f(0x17e)][_0x4e711f(0x171)]===_0x1e3222)return _0x50c900;}catch{}}const _0x1d1234=await this[_0x4e711f(0x208)]['listProjects'](),_0x154972=_0x1d1234['find'](_0x29a166=>_0x29a166[_0x4e711f(0x17e)][_0x4e711f(0x171)]===_0x1e3222);if(_0x154972)return!_0x519f48&&writeCachedLLMProject(_0x1e3222,_0x154972['id'],_0x4b5670),_0x154972;const _0x3b6aa5=await this[_0x4e711f(0x208)][_0x4e711f(0x1d0)]({'name':_0x1e3222,'description':_0x4e711f(0x19e)+getSanitizedUsername()+')'});return!_0x519f48&&writeCachedLLMProject(_0x1e3222,_0x3b6aa5['id'],_0x4b5670),_0x3b6aa5;}async['resolveProjectId'](_0x20a1df){const _0x3e908d=a71_0x4d6f2d,_0x46ea1f=await this[_0x3e908d(0x208)][_0x3e908d(0x15b)](),_0x3f098a=_0x46ea1f[_0x3e908d(0x153)](_0x3c1c9d=>_0x3c1c9d[_0x3e908d(0x17e)][_0x3e908d(0x171)]===_0x20a1df);if(_0x3f098a[_0x3e908d(0x15a)]===0x0)throw new SDKError(ErrorCode[_0x3e908d(0x163)],'Project\x20not\x20found:\x20'+_0x20a1df,undefined,{'helpText':'Use\x20\x22tdx\x20llm\x20projects\x22\x20to\x20list\x20available\x20projects.'});if(_0x3f098a[_0x3e908d(0x15a)]>0x1)throw new SDKError(ErrorCode[_0x3e908d(0x16d)],'Multiple\x20projects\x20found\x20with\x20name\x20\x27'+_0x20a1df+_0x3e908d(0x18f));return _0x3f098a[0x0]['id'];}async[a71_0x4d6f2d(0x189)](_0x201a8e){const _0x472e75=a71_0x4d6f2d,_0x5112d1=await this['client'][_0x472e75(0x15b)](),_0x91b6fe=_0x5112d1['find'](_0x223128=>_0x223128[_0x472e75(0x17e)]['name']===_0x201a8e);if(_0x91b6fe)return{'projectId':_0x91b6fe['id'],'project':_0x91b6fe};throw new SDKError(ErrorCode[_0x472e75(0x163)],_0x472e75(0x1a7)+_0x201a8e,undefined,{'helpText':'Use\x20\x22tdx\x20llm\x20projects\x22\x20to\x20list\x20available\x20projects.'});}async[a71_0x4d6f2d(0x17b)](_0x1993ca=a71_0x4d6f2d(0x184),_0x36ad27=0x0,_0x3f0d3d){const _0x351760=a71_0x4d6f2d,_0x32849a=0xa;let _0x5ace1f=0x0,_0x46f788;while(_0x5ace1f<_0x32849a){try{const _0x1d9536=await this[_0x351760(0x198)](_0x46f788),_0x58566e=_0x1d9536['id'],_0x2dfe6c=['none',_0x351760(0x175),'low',_0x351760(0x1e5),_0x351760(0x227)],_0x2d8f6d=_0x36ad27===0x0?_0x351760(0x1f8)+_0x1993ca:_0x351760(0x1f8)+_0x1993ca+'_reasoning_'+_0x2dfe6c[_0x36ad27],_0x215280=await this[_0x351760(0x208)][_0x351760(0x173)](_0x58566e),_0x274198=_0x215280['find'](_0x495f90=>_0x495f90[_0x351760(0x17e)][_0x351760(0x171)]===_0x2d8f6d);if(_0x274198)return _0x274198;const _0xa4ba17=_0x36ad27>0x0?0x1:_0x3f0d3d;return await this[_0x351760(0x208)][_0x351760(0x155)]({'name':_0x2d8f6d,'projectId':_0x58566e,'modelType':_0x1993ca,'systemPrompt':'','temperature':_0xa4ba17,'reasoningEffort':_0x36ad27>0x0?_0x36ad27:undefined});}catch(_0x247b09){if(_0x247b09 instanceof HTTPClientError){const _0x1e5d04=_0x247b09[_0x351760(0x15c)];if(_0x1e5d04>=0x190&&_0x1e5d04<0x1f4){if(_0x1e5d04===0x191)throw new SDKError(ErrorCode[_0x351760(0x18a)],_0x351760(0x19d),_0x247b09);else{if(_0x1e5d04===0x193)throw new SDKError(ErrorCode[_0x351760(0x166)],_0x351760(0x1f0),_0x247b09);}throw _0x247b09;}}if(errorContains(_0x247b09,'already\x20exists','duplicate',_0x351760(0x15f))){_0x5ace1f++;if(_0x5ace1f>=_0x32849a)throw new SDKError(ErrorCode[_0x351760(0x179)],_0x351760(0x187)+_0x32849a+_0x351760(0x194),_0x247b09);const _0x1a88f0=this[_0x351760(0x229)]();_0x46f788=_0x1a88f0+'_'+generateRandomHex();continue;}throw _0x247b09;}}throw new SDKError(ErrorCode[_0x351760(0x16d)],_0x351760(0x181));}async['resolveAgentId'](_0x3d2e2d,_0x104262){const _0x4bddde=a71_0x4d6f2d,_0x621de6=_0x104262||this['currentProjectId'],_0x3d5c35=await this[_0x4bddde(0x208)][_0x4bddde(0x173)](_0x621de6),_0x4ad4f5=_0x3d5c35[_0x4bddde(0x153)](_0x233ecc=>_0x233ecc[_0x4bddde(0x17e)]['name']===_0x3d2e2d);if(_0x4ad4f5[_0x4bddde(0x15a)]===0x0){const _0x1e187c=_0x621de6?_0x4bddde(0x1d6)+_0x621de6:'';throw new SDKError(ErrorCode['AGENT_NOT_FOUND'],_0x4bddde(0x1bd)+_0x3d2e2d+_0x1e187c,undefined,{'helpText':_0x621de6?'Use\x20\x22tdx\x20llm\x20agents\x22\x20to\x20list\x20available\x20agents\x20in\x20the\x20current\x20project.':_0x4bddde(0x1de)});}if(_0x4ad4f5[_0x4bddde(0x15a)]>0x1)throw new SDKError(ErrorCode[_0x4bddde(0x16d)],_0x4bddde(0x150)+_0x3d2e2d+_0x4bddde(0x18f));return _0x4ad4f5[0x0]['id'];}async[a71_0x4d6f2d(0x1b8)](_0x572000){const _0xa387b9=a71_0x4d6f2d,_0x119fb9=_0x572000||this[_0xa387b9(0x1b5)];return await this[_0xa387b9(0x208)][_0xa387b9(0x173)](_0x119fb9);}async[a71_0x4d6f2d(0x1e3)](_0x53c7a2){const _0x18b9ce=a71_0x4d6f2d;return await this['client'][_0x18b9ce(0x21b)](_0x53c7a2);}async[a71_0x4d6f2d(0x155)](_0x3ea2a5){const _0x1ec371=a71_0x4d6f2d;return await this['client'][_0x1ec371(0x155)](_0x3ea2a5);}async[a71_0x4d6f2d(0x1c8)](_0x264d7,_0x1b97e1){const _0x496761=a71_0x4d6f2d;return await this[_0x496761(0x208)]['updateAgent'](_0x264d7,_0x1b97e1);}async[a71_0x4d6f2d(0x1bc)](_0x39b4a4){const _0x33f00b=a71_0x4d6f2d;await this['client'][_0x33f00b(0x1bc)](_0x39b4a4);}async[a71_0x4d6f2d(0x1a3)](_0x59f5f6){const _0x57c5d1=a71_0x4d6f2d;return await this[_0x57c5d1(0x208)][_0x57c5d1(0x1a3)]({'agentId':_0x59f5f6});}async*[a71_0x4d6f2d(0x1e4)](_0x201251,_0x45c2d4){const _0x48e5a5=a71_0x4d6f2d;let _0x523fd1=_0x45c2d4?.[_0x48e5a5(0x164)];const _0x114362=_0x45c2d4?.['agentId'];if(!_0x523fd1){if(!_0x114362)throw new Error(_0x48e5a5(0x17d));const _0x4d87ef=await this['client']['startChat']({'agentId':_0x114362});_0x523fd1=_0x4d87ef['id'],yield{'type':'metadata','data':{'chatId':_0x523fd1,'agentId':_0x114362}};}for await(const _0x11f6fe of this[_0x48e5a5(0x208)]['continueChat'](_0x523fd1,_0x201251,_0x45c2d4?.[_0x48e5a5(0x1ef)])){yield{'type':_0x48e5a5(0x174),'data':_0x11f6fe};}}async['chats'](_0x4dde64=0x32){const _0x208fe9=a71_0x4d6f2d;return await this[_0x208fe9(0x208)][_0x208fe9(0x1e8)](_0x4dde64);}async[a71_0x4d6f2d(0x1b3)](_0x4e8bb3){const _0x37cb8a=a71_0x4d6f2d;return await this[_0x37cb8a(0x208)][_0x37cb8a(0x195)](_0x4e8bb3);}async['chatInfo'](_0x309400){const _0x570b89=a71_0x4d6f2d;return await this['client'][_0x570b89(0x22d)](_0x309400);}async[a71_0x4d6f2d(0x1f7)](_0x510292,_0x1fbaf9,_0xb6b016){const _0xb27b64=a71_0x4d6f2d,_0x222061=_0xb6b016?.[_0xb27b64(0x1ee)]??![],{projectId:_0xbeb285,project:_0x434499}=await this[_0xb27b64(0x189)](_0x510292),_0x3f36a4=_0x434499['attributes']['name'],_0xac4e7c=_0x1fbaf9||_0x3f36a4+_0xb27b64(0x1ab);if(a71_0x20c894['existsSync'](_0xac4e7c)&&!_0x222061)throw new SDKError(ErrorCode[_0xb27b64(0x179)],_0xb27b64(0x19c)+_0xac4e7c,undefined,{'helpText':_0xb27b64(0x1af)});const _0x9ab6e6=await this[_0xb27b64(0x208)]['listAgentsFull'](_0xbeb285),_0x130cce=await this[_0xb27b64(0x208)][_0xb27b64(0x16f)](_0xbeb285),_0x4c9793=await this[_0xb27b64(0x208)][_0xb27b64(0x176)](_0xbeb285),_0x2a6e5b=await this[_0xb27b64(0x208)][_0xb27b64(0x1ff)](_0xbeb285);if(!_0x222061){a71_0x20c894[_0xb27b64(0x1ed)](_0xac4e7c,{'recursive':!![]});const _0x2a765d={'version':'1.0','exportedAt':new Date()[_0xb27b64(0x180)](),'exportedFrom':{'site':this[_0xb27b64(0x217)][_0xb27b64(0x205)],'projectId':_0xbeb285,'projectName':_0x3f36a4},'project':_0x434499};a71_0x20c894['writeFileSync'](a71_0x3e1183['join'](_0xac4e7c,_0xb27b64(0x1d1)),JSON[_0xb27b64(0x151)](_0x2a765d,null,0x2)),a71_0x20c894[_0xb27b64(0x1f4)](a71_0x3e1183[_0xb27b64(0x201)](_0xac4e7c,_0xb27b64(0x1bb)),JSON[_0xb27b64(0x151)](_0x9ab6e6,null,0x2)),a71_0x20c894[_0xb27b64(0x1f4)](a71_0x3e1183['join'](_0xac4e7c,_0xb27b64(0x1f9)),JSON['stringify'](_0x130cce,null,0x2)),a71_0x20c894['writeFileSync'](a71_0x3e1183[_0xb27b64(0x201)](_0xac4e7c,_0xb27b64(0x1cb)),JSON['stringify'](_0x4c9793,null,0x2)),a71_0x20c894[_0xb27b64(0x1f4)](a71_0x3e1183['join'](_0xac4e7c,'integrations.json'),JSON[_0xb27b64(0x151)](_0x2a6e5b,null,0x2));}return{'projectName':_0x3f36a4,'outputDir':_0xac4e7c,'counts':{'agents':_0x9ab6e6[_0xb27b64(0x15a)],'knowledgeBases':_0x130cce['length'],'prompts':_0x4c9793['length'],'integrations':_0x2a6e5b[_0xb27b64(0x15a)]}};}async[a71_0x4d6f2d(0x161)](_0x295562,_0x21910b){const _0x31e976=a71_0x4d6f2d,_0x31005d=_0x21910b?.[_0x31e976(0x1ee)]??![],_0x3ffb9f=this[_0x31e976(0x169)](_0x295562),_0x1e822e=_0x3ffb9f[_0x31e976(0x1f3)]['site'],_0x38f60e=this[_0x31e976(0x217)][_0x31e976(0x205)],_0x23b032=_0x1e822e!==_0x38f60e?_0x1e822e:undefined,_0x295634=this[_0x31e976(0x215)](a71_0x3e1183[_0x31e976(0x201)](_0x295562,'agents.json'),[]),_0x5d670c=this['loadJsonFile'](a71_0x3e1183[_0x31e976(0x201)](_0x295562,'knowledgebases.json'),[]),_0xb683f0=this[_0x31e976(0x215)](a71_0x3e1183[_0x31e976(0x201)](_0x295562,_0x31e976(0x1cb)),[]),_0x2f4738=this['loadJsonFile'](a71_0x3e1183[_0x31e976(0x201)](_0x295562,'integrations.json'),[]),_0x415493=_0x21910b?.[_0x31e976(0x171)]||_0x3ffb9f[_0x31e976(0x1f3)]['projectName'];if(_0x31005d){const _0x2c1bd9=new Map(),_0x218476=[..._0x295634],_0x58b2cc=_0x295634[_0x31e976(0x15a)]+0x1;let _0x2d5cb8=0x0;while(_0x218476[_0x31e976(0x15a)]>0x0&&_0x2d5cb8<_0x58b2cc){_0x2d5cb8++;const _0x431ff7=[];for(const _0x2da87e of _0x218476){canCreateAgent(_0x2da87e,_0x2c1bd9)?_0x2c1bd9[_0x31e976(0x192)](_0x2da87e['id'],_0x31e976(0x185)+_0x2da87e['id']):_0x431ff7[_0x31e976(0x206)](_0x2da87e);}if(_0x431ff7[_0x31e976(0x15a)]===_0x218476[_0x31e976(0x15a)])throw new SDKError(ErrorCode[_0x31e976(0x16d)],_0x31e976(0x16c),undefined,{'helpText':_0x31e976(0x202)});_0x218476['length']=0x0,_0x218476['push'](..._0x431ff7);}const _0x294b31=_0xb683f0[_0x31e976(0x153)](_0xee4c38=>_0x2c1bd9[_0x31e976(0x213)](_0xee4c38[_0x31e976(0x17e)][_0x31e976(0x188)]))[_0x31e976(0x15a)];return{'projectName':_0x415493,'projectId':_0x31e976(0x1c7),'counts':{'agents':_0x295634[_0x31e976(0x15a)],'knowledgeBases':_0x5d670c[_0x31e976(0x15a)],'prompts':_0x294b31,'integrations':_0x2f4738[_0x31e976(0x15a)]},'sourceSite':_0x23b032};}const _0x52bc15=await this[_0x31e976(0x208)][_0x31e976(0x1d0)]({'name':_0x415493,'description':_0x3ffb9f[_0x31e976(0x1fc)]['attributes']['description']}),_0x358c69=_0x52bc15['id'],_0x585f99=new Map(),_0x299782=new Map(),_0x50259a=new Map();for(const _0x1ede45 of _0x5d670c){const _0x5d3f99=await this['client'][_0x31e976(0x157)]({'projectId':_0x358c69,'name':_0x1ede45[_0x31e976(0x17e)][_0x31e976(0x171)],'tdDatabaseName':_0x1ede45[_0x31e976(0x17e)][_0x31e976(0x224)],'tables':_0x1ede45[_0x31e976(0x17e)]['tables']});_0x585f99['set'](_0x1ede45['id'],_0x5d3f99['id']);}const _0x2deeae=[..._0x295634],_0x5bff70=_0x295634[_0x31e976(0x15a)]+0x1;let _0x2e7f46=0x0;while(_0x2deeae['length']>0x0&&_0x2e7f46<_0x5bff70){_0x2e7f46++;const _0x2616cb=[];for(const _0x325863 of _0x2deeae){if(canCreateAgent(_0x325863,_0x299782)){const _0x33b5aa=remapToolIds(_0x325863[_0x31e976(0x17e)]['tools'],_0x585f99,_0x299782),_0x553b76=remapVariableIds(_0x325863[_0x31e976(0x17e)][_0x31e976(0x1b1)],_0x585f99),_0x933b03=await this[_0x31e976(0x208)][_0x31e976(0x1da)]({'name':_0x325863[_0x31e976(0x17e)]['name'],'projectId':_0x358c69,'systemPrompt':_0x325863[_0x31e976(0x17e)][_0x31e976(0x20c)],'starterMessage':_0x325863['attributes'][_0x31e976(0x14f)],'modelType':migrateModelType(_0x325863['attributes'][_0x31e976(0x1db)]),'maxToolIterations':_0x325863['attributes']['maxToolIterations'],'temperature':_0x325863[_0x31e976(0x17e)][_0x31e976(0x18e)],'reasoningEffort':_0x325863[_0x31e976(0x17e)]['reasoningEffort'],'outputs':_0x325863[_0x31e976(0x17e)][_0x31e976(0x20b)],'tools':_0x33b5aa,'variables':_0x553b76});_0x299782[_0x31e976(0x192)](_0x325863['id'],_0x933b03['id']);}else _0x2616cb[_0x31e976(0x206)](_0x325863);}if(_0x2616cb[_0x31e976(0x15a)]===_0x2deeae['length'])throw new SDKError(ErrorCode[_0x31e976(0x16d)],_0x31e976(0x16c),undefined,{'helpText':'The\x20backup\x20contains\x20agents\x20with\x20circular\x20dependencies.'});_0x2deeae[_0x31e976(0x15a)]=0x0,_0x2deeae[_0x31e976(0x206)](..._0x2616cb);}for(const _0x1d5cf2 of _0xb683f0){const _0x1ce77e=_0x299782[_0x31e976(0x1d9)](_0x1d5cf2['attributes'][_0x31e976(0x188)]);if(!_0x1ce77e)continue;const _0x19cc5b=await this['client']['createPrompt']({'projectId':_0x358c69,'agentId':_0x1ce77e,'name':_0x1d5cf2['attributes'][_0x31e976(0x171)],'systemPrompt':_0x1d5cf2[_0x31e976(0x17e)]['systemPrompt'],'template':_0x1d5cf2[_0x31e976(0x17e)][_0x31e976(0x1e0)],'jsonSchemaHint':_0x1d5cf2[_0x31e976(0x17e)][_0x31e976(0x162)]});_0x50259a[_0x31e976(0x192)](_0x1d5cf2['id'],_0x19cc5b['id']);}for(const _0x23c926 of _0x2f4738){const _0x5c05b6=_0x23c926[_0x31e976(0x17e)][_0x31e976(0x178)]['map'](_0x4f4772=>({..._0x4f4772,'promptId':_0x50259a[_0x31e976(0x1d9)](_0x4f4772[_0x31e976(0x22a)])||_0x4f4772[_0x31e976(0x22a)]}));await this[_0x31e976(0x208)]['createIntegration']({'projectId':_0x358c69,'serviceType':_0x23c926[_0x31e976(0x17e)][_0x31e976(0x199)],'actions':_0x5c05b6,'slackMessageMode':_0x23c926['attributes'][_0x31e976(0x1ae)],'chatIgnoreManagedActions':_0x23c926['attributes'][_0x31e976(0x170)],'chatWelcomeMessage':_0x23c926[_0x31e976(0x17e)]['chatWelcomeMessage'],'webhookCorsOrigins':_0x23c926[_0x31e976(0x17e)][_0x31e976(0x1fd)]});}return{'projectName':_0x415493,'projectId':_0x358c69,'counts':{'agents':_0x299782[_0x31e976(0x182)],'knowledgeBases':_0x585f99['size'],'prompts':_0x50259a[_0x31e976(0x182)],'integrations':_0x2f4738[_0x31e976(0x15a)]},'sourceSite':_0x23b032};}[a71_0x4d6f2d(0x215)](_0x340821,_0x780e25){const _0x535bac=a71_0x4d6f2d;if(!a71_0x20c894['existsSync'](_0x340821))return _0x780e25;return JSON['parse'](a71_0x20c894[_0x535bac(0x1b6)](_0x340821,_0x535bac(0x1a6)));}['getBackupMetadata'](_0x439674){const _0x20fb4e=a71_0x4d6f2d;if(!a71_0x20c894[_0x20fb4e(0x156)](_0x439674))throw new SDKError(ErrorCode[_0x20fb4e(0x22c)],_0x20fb4e(0x203)+_0x439674,undefined,{'helpText':_0x20fb4e(0x219)});const _0x2f91d1=a71_0x3e1183[_0x20fb4e(0x201)](_0x439674,'project.json');if(!a71_0x20c894[_0x20fb4e(0x156)](_0x2f91d1))throw new SDKError(ErrorCode[_0x20fb4e(0x1b4)],_0x20fb4e(0x1f1)+_0x439674,undefined,{'helpText':_0x20fb4e(0x211)});const _0x2eb7dc=JSON[_0x20fb4e(0x1ad)](a71_0x20c894[_0x20fb4e(0x1b6)](_0x2f91d1,_0x20fb4e(0x1a6)));if(!isSupportedBackupVersion(_0x2eb7dc[_0x20fb4e(0x200)]))throw new SDKError(ErrorCode[_0x20fb4e(0x1b4)],_0x20fb4e(0x1a0)+_0x2eb7dc[_0x20fb4e(0x200)],undefined,{'helpText':_0x20fb4e(0x17f)});return _0x2eb7dc;}async[a71_0x4d6f2d(0x15d)](_0x1d850f,_0x171cd8,_0x42a10){const _0x14cb3e=a71_0x4d6f2d,{projectId:_0x4095d8,project:_0x423e32}=await this[_0x14cb3e(0x189)](_0x1d850f),_0x27de89=_0x423e32[_0x14cb3e(0x17e)][_0x14cb3e(0x171)],_0xb41905=normalizeName(_0x27de89),_0x23e463=_0x171cd8||a71_0x3e1183[_0x14cb3e(0x201)](process[_0x14cb3e(0x158)](),'agents',_0xb41905),_0x49cd70=await this[_0x14cb3e(0x208)][_0x14cb3e(0x1e6)](_0x4095d8),_0x38b0e3=await this['client'][_0x14cb3e(0x16f)](_0x4095d8),_0x2bc64c=await this[_0x14cb3e(0x208)]['listTextKnowledgeBases'](_0x4095d8),_0x1e6d86=await this['client'][_0x14cb3e(0x16a)](_0x4095d8),_0x352ef0=await this[_0x14cb3e(0x208)][_0x14cb3e(0x1a5)](_0x4095d8),_0x30d543=await this[_0x14cb3e(0x208)]['listPrompts'](_0x4095d8),_0x426ac5=new Map(),_0x4734e1=new Map(),_0x5c74fe=new Map(),_0x11c6b6=new Map(),_0xb47ad1=new Map(),_0x22fb93=new Map();for(const _0x5668fd of _0x49cd70){_0x426ac5[_0x14cb3e(0x192)](_0x5668fd['id'],_0x5668fd[_0x14cb3e(0x17e)]['name']);}for(const _0x509c04 of _0x38b0e3){_0x4734e1['set'](_0x509c04['id'],_0x509c04[_0x14cb3e(0x17e)][_0x14cb3e(0x171)]);}for(const _0x32a52d of _0x2bc64c){_0x5c74fe[_0x14cb3e(0x192)](_0x32a52d['id'],_0x32a52d[_0x14cb3e(0x17e)][_0x14cb3e(0x171)]);}for(const _0x43dde0 of _0x1e6d86){_0x11c6b6[_0x14cb3e(0x192)](_0x43dde0['id'],_0x43dde0[_0x14cb3e(0x17e)][_0x14cb3e(0x171)]);}for(const _0x1e7220 of _0x352ef0){_0xb47ad1[_0x14cb3e(0x192)](_0x1e7220['id'],_0x1e7220[_0x14cb3e(0x17e)][_0x14cb3e(0x171)]);}for(const _0x4f4849 of _0x30d543){_0x22fb93['set'](_0x4f4849['id'],_0x4f4849[_0x14cb3e(0x17e)][_0x14cb3e(0x171)]);}const _0x194c36={'resolveKnowledgeBaseName':async _0x486424=>_0x4734e1['get'](_0x486424),'resolveTextKnowledgeBaseName':async _0xcf0c70=>_0x5c74fe[_0x14cb3e(0x1d9)](_0xcf0c70),'resolveAgentName':async _0x4c09d7=>_0x426ac5[_0x14cb3e(0x1d9)](_0x4c09d7),'resolveWebSearchToolName':async _0x509ae3=>_0xb47ad1[_0x14cb3e(0x1d9)](_0x509ae3),'resolveImageGeneratorName':async _0x578b1b=>_0x11c6b6[_0x14cb3e(0x1d9)](_0x578b1b),'resolvePromptName':async _0x540696=>_0x22fb93['get'](_0x540696),'onWarning':_0x5f45fb=>this['context'][_0x14cb3e(0x1ec)]?.[_0x14cb3e(0x183)](_0x5f45fb)},_0x8d336c={'projectName':_0x27de89,'outputDir':_0x23e463,'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}}},_0x1bb93f=[],_0x3f62d4=new UniqueNameGenerator(),_0x6b6dc4=new UniqueNameGenerator(),_0x4e6240=new UniqueNameGenerator(),_0x374c12=new UniqueNameGenerator();for(const _0x4d363c of _0x49cd70){const _0x3fd46e=_0x3f62d4[_0x14cb3e(0x1c4)](_0x4d363c[_0x14cb3e(0x17e)]['name']),_0x15e798=a71_0x3e1183[_0x14cb3e(0x201)](_0x23e463,_0x3fd46e),_0x336a6c=a71_0x3e1183[_0x14cb3e(0x201)](_0x15e798,_0x14cb3e(0x1a9)),_0x5b3ac6=a71_0x3e1183['join'](_0x15e798,_0x14cb3e(0x1f6)),_0x76c7bf=a71_0x3e1183[_0x14cb3e(0x201)](_0x15e798,_0x14cb3e(0x190)),{yaml:_0xa81947,systemPrompt:_0x1ddd4b,starterMessage:_0x240245}=await apiAgentToYaml(_0x4d363c,_0x194c36),_0x5c792f=toAgentYamlString(_0xa81947),_0x527b38=!a71_0x20c894[_0x14cb3e(0x156)](_0x5b3ac6);let _0x14302d=_0x527b38,_0xcd9c87;if(!_0x527b38){const _0x28b165=a71_0x20c894[_0x14cb3e(0x156)](_0x336a6c)?a71_0x20c894[_0x14cb3e(0x1b6)](_0x336a6c,_0x14cb3e(0x1a6)):'',_0x19b600=a71_0x20c894[_0x14cb3e(0x1b6)](_0x5b3ac6,_0x14cb3e(0x1a6)),_0x1f52f1=_0x14cb3e(0x204)+_0x28b165+_0x14cb3e(0x1b9)+_0x19b600,_0x58232b='#\x20prompt.md\x0a'+_0x1ddd4b+_0x14cb3e(0x1b9)+_0x5c792f,_0x2e6c27=generateDiff(_0x1f52f1,_0x58232b);_0x14302d=hasChanges(_0x2e6c27),_0x14302d&&(_0xcd9c87=formatDiffWithColors(_0x2e6c27));}_0x1bb93f[_0x14cb3e(0x206)]({'path':_0x15e798,'content':'','isDir':!![]}),_0x1bb93f[_0x14cb3e(0x206)]({'path':_0x336a6c,'content':_0x1ddd4b}),_0x1bb93f[_0x14cb3e(0x206)]({'path':_0x5b3ac6,'content':_0x5c792f});_0x240245&&_0x240245[_0x14cb3e(0x1fa)]('\x0a')&&_0x1bb93f['push']({'path':_0x76c7bf,'content':_0x240245});_0x8d336c[_0x14cb3e(0x1b8)][_0x14cb3e(0x206)]({'agentName':_0x4d363c[_0x14cb3e(0x17e)][_0x14cb3e(0x171)],'outputPath':_0x15e798,'isNew':_0x527b38,'hasChanges':_0x14302d,'diff':_0xcd9c87}),_0x8d336c[_0x14cb3e(0x22b)]['agents'][_0x14cb3e(0x21f)]++;if(_0x527b38)_0x8d336c[_0x14cb3e(0x22b)]['agents'][_0x14cb3e(0x191)]++;else{if(_0x14302d)_0x8d336c['counts']['agents'][_0x14cb3e(0x1ea)]++;else _0x8d336c[_0x14cb3e(0x22b)][_0x14cb3e(0x1b8)]['unchanged']++;}}for(const _0x26e056 of _0x38b0e3){if(_0x26e056[_0x14cb3e(0x17e)]['isManaged'])continue;const _0x19f292=_0x6b6dc4[_0x14cb3e(0x1c4)](_0x26e056[_0x14cb3e(0x17e)][_0x14cb3e(0x171)]),_0xd6517=a71_0x3e1183[_0x14cb3e(0x201)](getKnowledgeBasesDir(_0x23e463),_0x19f292+'.yml'),_0x22ae60=apiKnowledgeBaseToYaml(_0x26e056),_0x189aa7=toKnowledgeBaseYamlString(_0x22ae60),_0x2baf55=!a71_0x20c894['existsSync'](_0xd6517);let _0x1a4eb0=_0x2baf55,_0x1b14eb;if(!_0x2baf55){const _0x17c016=a71_0x20c894[_0x14cb3e(0x1b6)](_0xd6517,_0x14cb3e(0x1a6)),_0x1b4327=generateDiff(_0x17c016,_0x189aa7);_0x1a4eb0=hasChanges(_0x1b4327),_0x1a4eb0&&(_0x1b14eb=formatDiffWithColors(_0x1b4327));}_0x1bb93f['push']({'path':_0xd6517,'content':_0x189aa7}),_0x8d336c['knowledgeBases'][_0x14cb3e(0x206)]({'name':_0x26e056[_0x14cb3e(0x17e)][_0x14cb3e(0x171)],'outputPath':_0xd6517,'isNew':_0x2baf55,'hasChanges':_0x1a4eb0,'diff':_0x1b14eb}),_0x8d336c[_0x14cb3e(0x22b)]['knowledgeBases']['total']++;if(_0x2baf55)_0x8d336c[_0x14cb3e(0x22b)][_0x14cb3e(0x1c3)][_0x14cb3e(0x191)]++;else{if(_0x1a4eb0)_0x8d336c[_0x14cb3e(0x22b)][_0x14cb3e(0x1c3)][_0x14cb3e(0x1ea)]++;else _0x8d336c['counts'][_0x14cb3e(0x1c3)]['unchanged']++;}}for(const _0x1462e4 of _0x2bc64c){if(_0x1462e4[_0x14cb3e(0x17e)][_0x14cb3e(0x1eb)])continue;const _0x3da3f7=_0x4e6240[_0x14cb3e(0x1c4)](_0x1462e4[_0x14cb3e(0x17e)][_0x14cb3e(0x171)]),_0x7cd1cf=a71_0x3e1183[_0x14cb3e(0x201)](getKnowledgeBasesDir(_0x23e463),_0x3da3f7+_0x14cb3e(0x16e)),_0x1b98b1=toTextKnowledgeBaseMd(_0x1462e4[_0x14cb3e(0x17e)][_0x14cb3e(0x171)],_0x1462e4['attributes'][_0x14cb3e(0x21a)]),_0x77e78b=!a71_0x20c894['existsSync'](_0x7cd1cf);let _0x2bcb2f=_0x77e78b,_0x3b7acc;if(!_0x77e78b){const _0xcab376=a71_0x20c894[_0x14cb3e(0x1b6)](_0x7cd1cf,_0x14cb3e(0x1a6)),_0xc30c33=generateDiff(_0xcab376,_0x1b98b1);_0x2bcb2f=hasChanges(_0xc30c33),_0x2bcb2f&&(_0x3b7acc=formatDiffWithColors(_0xc30c33));}_0x1bb93f['push']({'path':_0x7cd1cf,'content':_0x1b98b1}),_0x8d336c['textKnowledgeBases']['push']({'name':_0x1462e4[_0x14cb3e(0x17e)]['name'],'outputPath':_0x7cd1cf,'isNew':_0x77e78b,'hasChanges':_0x2bcb2f,'diff':_0x3b7acc}),_0x8d336c['counts'][_0x14cb3e(0x172)][_0x14cb3e(0x21f)]++;if(_0x77e78b)_0x8d336c[_0x14cb3e(0x22b)]['textKnowledgeBases']['new']++;else{if(_0x2bcb2f)_0x8d336c[_0x14cb3e(0x22b)][_0x14cb3e(0x172)]['updated']++;else _0x8d336c[_0x14cb3e(0x22b)][_0x14cb3e(0x172)]['unchanged']++;}}for(const _0x5f3ed0 of _0x30d543){if(_0x5f3ed0[_0x14cb3e(0x17e)][_0x14cb3e(0x1eb)])continue;const _0x344f39=_0x374c12['getUniqueName'](_0x5f3ed0['attributes'][_0x14cb3e(0x171)]),_0x438572=a71_0x3e1183[_0x14cb3e(0x201)](getPromptsDir(_0x23e463),_0x344f39+_0x14cb3e(0x225)),_0x5c933b=await apiPromptToYaml(_0x5f3ed0,_0x194c36);if(!_0x5c933b)continue;const _0x574b3f=toPromptYamlString(_0x5c933b),_0x3fb558=!a71_0x20c894[_0x14cb3e(0x156)](_0x438572);let _0x24c8ce=_0x3fb558,_0x378cf2;if(!_0x3fb558){const _0x3dfc21=a71_0x20c894[_0x14cb3e(0x1b6)](_0x438572,'utf-8'),_0x4c2edd=generateDiff(_0x3dfc21,_0x574b3f);_0x24c8ce=hasChanges(_0x4c2edd),_0x24c8ce&&(_0x378cf2=formatDiffWithColors(_0x4c2edd));}_0x1bb93f['push']({'path':_0x438572,'content':_0x574b3f}),_0x8d336c['prompts']['push']({'name':_0x5f3ed0[_0x14cb3e(0x17e)][_0x14cb3e(0x171)],'outputPath':_0x438572,'isNew':_0x3fb558,'hasChanges':_0x24c8ce,'diff':_0x378cf2}),_0x8d336c['counts']['prompts'][_0x14cb3e(0x21f)]++;if(_0x3fb558)_0x8d336c[_0x14cb3e(0x22b)][_0x14cb3e(0x1c2)]['new']++;else{if(_0x24c8ce)_0x8d336c['counts']['prompts'][_0x14cb3e(0x1ea)]++;else _0x8d336c[_0x14cb3e(0x22b)][_0x14cb3e(0x1c2)][_0x14cb3e(0x1be)]++;}}if(_0x42a10?.[_0x14cb3e(0x1ee)])return _0x8d336c;a71_0x20c894[_0x14cb3e(0x1ed)](_0x23e463,{'recursive':!![]}),a71_0x20c894[_0x14cb3e(0x1ed)](getKnowledgeBasesDir(_0x23e463),{'recursive':!![]}),a71_0x20c894['mkdirSync'](getPromptsDir(_0x23e463),{'recursive':!![]});const _0x36308b=a71_0x3e1183['join'](_0x23e463,_0x14cb3e(0x214));a71_0x20c894[_0x14cb3e(0x1f4)](_0x36308b,createAgentConfigContent(_0x27de89));for(const _0x5e5b8d of _0x1bb93f){if(_0x5e5b8d[_0x14cb3e(0x19b)])a71_0x20c894[_0x14cb3e(0x1ed)](_0x5e5b8d['path'],{'recursive':!![]});else{const _0x40f401=a71_0x3e1183[_0x14cb3e(0x1ce)](_0x5e5b8d[_0x14cb3e(0x168)]);!a71_0x20c894['existsSync'](_0x40f401)&&a71_0x20c894[_0x14cb3e(0x1ed)](_0x40f401,{'recursive':!![]}),a71_0x20c894[_0x14cb3e(0x1f4)](_0x5e5b8d[_0x14cb3e(0x168)],_0x5e5b8d[_0x14cb3e(0x222)]);}}return _0x8d336c;}async[a71_0x4d6f2d(0x1cc)](_0x4f01d1,_0x392457){const _0x591447=a71_0x4d6f2d,_0x3bcb11=a71_0x3e1183['join'](_0x4f01d1,_0x591447(0x214));if(!a71_0x20c894[_0x591447(0x156)](_0x3bcb11))throw new SDKError(ErrorCode['INVALID_ARGUMENT'],_0x591447(0x223)+_0x4f01d1,undefined,{'helpText':_0x591447(0x167)});const _0x444ef4=loadAgentConfig(_0x3bcb11),_0x40cc72=await this[_0x591447(0x1d3)](_0x444ef4['llm_project']),_0x51d4dd=await this[_0x591447(0x208)]['getProject'](_0x40cc72),_0x5dc194=_0x51d4dd['attributes'][_0x591447(0x171)],_0x213c5f={'projectName':_0x5dc194,'projectId':_0x40cc72,'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}}},_0x5edcab=[],_0x317122=[],_0x13050a=[],_0x4cbb9d=[],_0x1c64dc=a71_0x20c894[_0x591447(0x18d)](_0x4f01d1,{'withFileTypes':!![]});for(const _0x3b7290 of _0x1c64dc){if(!_0x3b7290['isDirectory']())continue;if(['knowledge_bases',_0x591447(0x1c2),_0x591447(0x216)][_0x591447(0x1fa)](_0x3b7290[_0x591447(0x171)]))continue;const _0x23e3e7=a71_0x3e1183[_0x591447(0x201)](_0x4f01d1,_0x3b7290['name']);if(isAgentDir(_0x23e3e7)){const _0x3fdf28=a71_0x3e1183[_0x591447(0x201)](_0x23e3e7,_0x591447(0x1f6)),_0x3178cb=a71_0x3e1183[_0x591447(0x201)](_0x23e3e7,'prompt.md'),_0xdf9d79=a71_0x3e1183[_0x591447(0x201)](_0x23e3e7,_0x591447(0x190)),_0xee20a1=parseAgentYaml(a71_0x20c894[_0x591447(0x1b6)](_0x3fdf28,_0x591447(0x1a6)),_0x3fdf28),_0x24b468=a71_0x20c894['existsSync'](_0x3178cb)?a71_0x20c894[_0x591447(0x1b6)](_0x3178cb,_0x591447(0x1a6)):'',_0x22df9c=a71_0x20c894[_0x591447(0x156)](_0xdf9d79)?a71_0x20c894[_0x591447(0x1b6)](_0xdf9d79,_0x591447(0x1a6)):_0xee20a1[_0x591447(0x221)];_0x5edcab[_0x591447(0x206)]({'name':_0xee20a1[_0x591447(0x171)],'dir':_0x23e3e7,'yaml':_0xee20a1,'systemPrompt':_0x24b468,'starterMessage':_0x22df9c});}}const _0x5be4b4=getKnowledgeBasesDir(_0x4f01d1);if(a71_0x20c894[_0x591447(0x156)](_0x5be4b4)){const _0x29a5c9=a71_0x20c894['readdirSync'](_0x5be4b4);for(const _0x11708e of _0x29a5c9){const _0x1fd3de=a71_0x3e1183[_0x591447(0x201)](_0x5be4b4,_0x11708e);if(_0x11708e[_0x591447(0x228)]('.yml')){const _0x4ca74b=parseKnowledgeBaseYaml(a71_0x20c894[_0x591447(0x1b6)](_0x1fd3de,'utf-8'),_0x1fd3de);_0x317122['push']({'name':_0x4ca74b[_0x591447(0x171)],'path':_0x1fd3de,'yaml':_0x4ca74b});}else{if(_0x11708e['endsWith'](_0x591447(0x16e))){const _0x37aff4=a71_0x20c894['readFileSync'](_0x1fd3de,_0x591447(0x1a6)),{name:_0x3e80e4,text:_0x135d87}=parseTextKnowledgeBaseMd(_0x37aff4,_0x11708e);_0x13050a[_0x591447(0x206)]({'name':_0x3e80e4,'path':_0x1fd3de,'text':_0x135d87});}}}}const _0x4908fc=getPromptsDir(_0x4f01d1);if(a71_0x20c894[_0x591447(0x156)](_0x4908fc)){const _0x3909ef=a71_0x20c894[_0x591447(0x18d)](_0x4908fc)['filter'](_0x181d43=>_0x181d43['endsWith'](_0x591447(0x225)));for(const _0x443e68 of _0x3909ef){const _0x10ec78=a71_0x3e1183[_0x591447(0x201)](_0x4908fc,_0x443e68),_0x2f67cc=parsePromptYaml(a71_0x20c894[_0x591447(0x1b6)](_0x10ec78,_0x591447(0x1a6)),_0x10ec78);_0x4cbb9d[_0x591447(0x206)]({'name':_0x2f67cc['name'],'path':_0x10ec78,'yaml':_0x2f67cc});}}const _0x2676c9=await this[_0x591447(0x208)]['listAgentsFull'](_0x40cc72),_0x10263a=await this['client'][_0x591447(0x16f)](_0x40cc72),_0x57729e=await this[_0x591447(0x208)][_0x591447(0x160)](_0x40cc72),_0x134b08=await this[_0x591447(0x208)][_0x591447(0x16a)](_0x40cc72),_0x64ad75=await this['client'][_0x591447(0x1a5)](_0x40cc72),_0x390bdb=await this[_0x591447(0x208)][_0x591447(0x176)](_0x40cc72),_0x4c9257=new Map(),_0x53c395=new Map(),_0x278cd0=new Map(),_0x4e3dba=new Map();for(const _0x196d90 of _0x2676c9){_0x4c9257['set'](_0x196d90[_0x591447(0x17e)][_0x591447(0x171)],_0x196d90);}for(const _0x37ccae of _0x10263a){_0x53c395[_0x591447(0x192)](_0x37ccae[_0x591447(0x17e)][_0x591447(0x171)],_0x37ccae);}for(const _0x49bba0 of _0x57729e){_0x278cd0[_0x591447(0x192)](_0x49bba0['attributes'][_0x591447(0x171)],_0x49bba0);}for(const _0x14be55 of _0x390bdb){_0x4e3dba[_0x591447(0x192)](_0x14be55[_0x591447(0x17e)][_0x591447(0x171)],_0x14be55);}const _0xde2ce8=new Map(),_0x261559=new Map(),_0x1ed54b=new Map(),_0x3d6e30=new Map(),_0x52afb9=new Map(),_0x4eb526=new Map(),_0x3d8076=new Map(),_0xa8035=new Map(),_0x30b61f=new Map(),_0x58f09e=new Map(),_0x572b57=new Map(),_0x11e6ec=new Map();for(const _0x41d6cd of _0x10263a){_0xde2ce8['set'](_0x41d6cd[_0x591447(0x17e)][_0x591447(0x171)],_0x41d6cd['id']),_0x3d8076['set'](_0x41d6cd['id'],_0x41d6cd['attributes'][_0x591447(0x171)]);}for(const _0x5ee4b7 of _0x57729e){_0x261559['set'](_0x5ee4b7[_0x591447(0x17e)]['name'],_0x5ee4b7['id']),_0xa8035[_0x591447(0x192)](_0x5ee4b7['id'],_0x5ee4b7[_0x591447(0x17e)][_0x591447(0x171)]);}for(const _0x25560b of _0x2676c9){_0x1ed54b[_0x591447(0x192)](_0x25560b[_0x591447(0x17e)]['name'],_0x25560b['id']),_0x30b61f[_0x591447(0x192)](_0x25560b['id'],_0x25560b['attributes'][_0x591447(0x171)]);}for(const _0x2387ba of _0x134b08){_0x3d6e30[_0x591447(0x192)](_0x2387ba['attributes']['name'],_0x2387ba['id']),_0x58f09e[_0x591447(0x192)](_0x2387ba['id'],_0x2387ba[_0x591447(0x17e)][_0x591447(0x171)]);}for(const _0x29c485 of _0x64ad75){_0x52afb9[_0x591447(0x192)](_0x29c485[_0x591447(0x17e)]['name'],_0x29c485['id']),_0x572b57[_0x591447(0x192)](_0x29c485['id'],_0x29c485[_0x591447(0x17e)][_0x591447(0x171)]);}for(const _0x3f5701 of _0x390bdb){_0x4eb526[_0x591447(0x192)](_0x3f5701[_0x591447(0x17e)][_0x591447(0x171)],_0x3f5701['id']),_0x11e6ec[_0x591447(0x192)](_0x3f5701['id'],_0x3f5701[_0x591447(0x17e)][_0x591447(0x171)]);}const _0x56c24b={'resolveKnowledgeBaseName':async _0x3b4438=>_0x3d8076[_0x591447(0x1d9)](_0x3b4438),'resolveTextKnowledgeBaseName':async _0x111b43=>_0xa8035['get'](_0x111b43),'resolveAgentName':async _0x5ed7ba=>_0x30b61f[_0x591447(0x1d9)](_0x5ed7ba),'resolveWebSearchToolName':async _0x44f10c=>_0x572b57['get'](_0x44f10c),'resolveImageGeneratorName':async _0xcba761=>_0x58f09e['get'](_0xcba761),'resolvePromptName':async _0x1da4dd=>_0x11e6ec[_0x591447(0x1d9)](_0x1da4dd),'onWarning':_0x468069=>this[_0x591447(0x217)]['logger']?.['warn'](_0x468069)},_0x44ee64={'projectId':_0x40cc72,'resolveKnowledgeBaseId':async _0x6b43d8=>_0xde2ce8['get'](_0x6b43d8),'resolveTextKnowledgeBaseId':async _0x487efb=>_0x261559[_0x591447(0x1d9)](_0x487efb),'resolveAgentId':async _0x3bed79=>_0x1ed54b[_0x591447(0x1d9)](_0x3bed79),'resolveWebSearchToolId':async _0x5c33a1=>_0x52afb9[_0x591447(0x1d9)](_0x5c33a1),'resolveImageGeneratorId':async _0x2e27ee=>_0x3d6e30[_0x591447(0x1d9)](_0x2e27ee),'resolvePromptId':async _0x13d85d=>_0x4eb526[_0x591447(0x1d9)](_0x13d85d),'onWarning':_0x46ff8f=>this[_0x591447(0x217)]['logger']?.[_0x591447(0x183)](_0x46ff8f)},{resolved:_0x25a464,unresolved:_0x21a60f}=resolveAgentDependencies(_0x5edcab,new Set(_0x4c9257[_0x591447(0x21c)]()));for(const {agent:_0x74d39f,missingDeps:_0x57a10c}of _0x21a60f){_0x213c5f[_0x591447(0x1b8)][_0x591447(0x206)]({'agentName':_0x74d39f[_0x591447(0x17c)][_0x591447(0x171)],'action':'error','error':_0x591447(0x1df)+_0x57a10c[_0x591447(0x201)](',\x20')+'.\x20Check\x20for\x20circular\x20references\x20or\x20missing\x20agents.'}),_0x213c5f[_0x591447(0x22b)]['agents'][_0x591447(0x1b7)]++;}for(const _0x455e50 of _0x317122){const _0x504fc3=_0x53c395[_0x591447(0x1d9)](_0x455e50[_0x591447(0x17c)][_0x591447(0x171)]),_0x45ae60=a71_0x20c894['readFileSync'](_0x455e50[_0x591447(0x168)],'utf-8');if(_0x504fc3){const _0x167eb2=apiKnowledgeBaseToYaml(_0x504fc3),_0x26534d=toKnowledgeBaseYamlString(_0x167eb2),_0x5a7cb0=generateDiff(_0x26534d,_0x45ae60),_0x4fc7ef=hasChanges(_0x5a7cb0);_0x4fc7ef?(_0x213c5f[_0x591447(0x1c3)][_0x591447(0x206)]({'name':_0x455e50[_0x591447(0x17c)][_0x591447(0x171)],'action':_0x591447(0x1ea),'id':_0x504fc3['id'],'diff':formatDiffWithColors(_0x5a7cb0)}),_0x213c5f['counts']['knowledgeBases']['updated']++):(_0x213c5f['knowledgeBases'][_0x591447(0x206)]({'name':_0x455e50[_0x591447(0x17c)][_0x591447(0x171)],'action':'unchanged','id':_0x504fc3['id']}),_0x213c5f[_0x591447(0x22b)][_0x591447(0x1c3)][_0x591447(0x1be)]++);}else _0x213c5f[_0x591447(0x1c3)]['push']({'name':_0x455e50[_0x591447(0x17c)][_0x591447(0x171)],'action':'created'}),_0x213c5f[_0x591447(0x22b)][_0x591447(0x1c3)]['created']++;}for(const _0x5a8f86 of _0x13050a){const _0x1bba8b=_0x278cd0[_0x591447(0x1d9)](_0x5a8f86[_0x591447(0x171)]),_0x45fe25=a71_0x20c894['readFileSync'](_0x5a8f86[_0x591447(0x168)],_0x591447(0x1a6));if(_0x1bba8b){const _0xb844c7=toTextKnowledgeBaseMd(_0x1bba8b[_0x591447(0x17e)][_0x591447(0x171)],_0x1bba8b['attributes'][_0x591447(0x21a)]),_0x45c171=generateDiff(_0xb844c7,_0x45fe25),_0x4868ff=hasChanges(_0x45c171);_0x4868ff?(_0x213c5f[_0x591447(0x172)][_0x591447(0x206)]({'name':_0x5a8f86[_0x591447(0x171)],'action':'updated','id':_0x1bba8b['id'],'diff':formatDiffWithColors(_0x45c171)}),_0x213c5f[_0x591447(0x22b)][_0x591447(0x172)]['updated']++):(_0x213c5f[_0x591447(0x172)]['push']({'name':_0x5a8f86['name'],'action':_0x591447(0x1be),'id':_0x1bba8b['id']}),_0x213c5f[_0x591447(0x22b)][_0x591447(0x172)][_0x591447(0x1be)]++);}else _0x213c5f[_0x591447(0x172)]['push']({'name':_0x5a8f86['name'],'action':_0x591447(0x18c)}),_0x213c5f[_0x591447(0x22b)]['textKnowledgeBases']['created']++;}for(const _0x337cb3 of _0x25a464){const _0x524e6d=_0x4c9257[_0x591447(0x1d9)](_0x337cb3[_0x591447(0x17c)][_0x591447(0x171)]),_0x5d7f6e=a71_0x3e1183['join'](_0x337cb3[_0x591447(0x16b)],_0x591447(0x1f6)),_0x1c64cd=a71_0x20c894[_0x591447(0x1b6)](_0x5d7f6e,_0x591447(0x1a6)),_0x88a67=_0x337cb3[_0x591447(0x20c)],_0x3b3f50=_0x591447(0x204)+_0x88a67+_0x591447(0x1b9)+_0x1c64cd;if(_0x524e6d){const {yaml:_0x13f850,systemPrompt:_0x2c689a}=await apiAgentToYaml(_0x524e6d,_0x56c24b),_0x2d85b6=toAgentYamlString(_0x13f850),_0x267826='#\x20prompt.md\x0a'+_0x2c689a+_0x591447(0x1b9)+_0x2d85b6,_0x3a2392=generateDiff(_0x267826,_0x3b3f50),_0x4e88be=hasChanges(_0x3a2392);_0x4e88be?(_0x213c5f[_0x591447(0x1b8)]['push']({'agentName':_0x337cb3[_0x591447(0x17c)][_0x591447(0x171)],'action':_0x591447(0x1ea),'agentId':_0x524e6d['id'],'diff':formatDiffWithColors(_0x3a2392)}),_0x213c5f[_0x591447(0x22b)]['agents'][_0x591447(0x1ea)]++):(_0x213c5f[_0x591447(0x1b8)][_0x591447(0x206)]({'agentName':_0x337cb3['yaml'][_0x591447(0x171)],'action':_0x591447(0x1be),'agentId':_0x524e6d['id']}),_0x213c5f[_0x591447(0x22b)][_0x591447(0x1b8)][_0x591447(0x1be)]++);}else _0x213c5f[_0x591447(0x1b8)][_0x591447(0x206)]({'agentName':_0x337cb3[_0x591447(0x17c)][_0x591447(0x171)],'action':_0x591447(0x18c)}),_0x213c5f[_0x591447(0x22b)][_0x591447(0x1b8)][_0x591447(0x18c)]++;}for(const _0x322d43 of _0x4cbb9d){const _0x24114e=_0x4e3dba[_0x591447(0x1d9)](_0x322d43[_0x591447(0x17c)][_0x591447(0x171)]),_0x3a3466=a71_0x20c894['readFileSync'](_0x322d43[_0x591447(0x168)],_0x591447(0x1a6));if(_0x24114e){const _0x111b83=await apiPromptToYaml(_0x24114e,_0x56c24b);if(!_0x111b83){_0x213c5f[_0x591447(0x1c2)]['push']({'name':_0x322d43[_0x591447(0x17c)]['name'],'action':'updated','id':_0x24114e['id']}),_0x213c5f[_0x591447(0x22b)]['prompts']['updated']++;continue;}const _0x5c28d2=toPromptYamlString(_0x111b83),_0x56bc21=generateDiff(_0x5c28d2,_0x3a3466),_0x161e9b=hasChanges(_0x56bc21);_0x161e9b?(_0x213c5f['prompts']['push']({'name':_0x322d43['yaml'][_0x591447(0x171)],'action':_0x591447(0x1ea),'id':_0x24114e['id'],'diff':formatDiffWithColors(_0x56bc21)}),_0x213c5f[_0x591447(0x22b)]['prompts'][_0x591447(0x1ea)]++):(_0x213c5f[_0x591447(0x1c2)][_0x591447(0x206)]({'name':_0x322d43['yaml'][_0x591447(0x171)],'action':_0x591447(0x1be),'id':_0x24114e['id']}),_0x213c5f[_0x591447(0x22b)][_0x591447(0x1c2)][_0x591447(0x1be)]++);}else _0x213c5f[_0x591447(0x1c2)][_0x591447(0x206)]({'name':_0x322d43[_0x591447(0x17c)][_0x591447(0x171)],'action':_0x591447(0x18c)}),_0x213c5f[_0x591447(0x22b)]['prompts'][_0x591447(0x18c)]++;}if(_0x392457?.[_0x591447(0x1ee)])return _0x213c5f;_0x213c5f[_0x591447(0x1c3)]=[],_0x213c5f[_0x591447(0x172)]=[],_0x213c5f[_0x591447(0x1c2)]=[];const _0x568337=_0x213c5f[_0x591447(0x1b8)]['filter'](_0x18858e=>_0x18858e[_0x591447(0x1c1)]==='error');_0x213c5f[_0x591447(0x1b8)]=_0x568337,_0x213c5f[_0x591447(0x22b)]={'agents':{'created':0x0,'updated':0x0,'unchanged':0x0,'errors':_0x568337['length']},'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 _0x9f00a4 of _0x317122){try{const _0x512113=_0x53c395[_0x591447(0x1d9)](_0x9f00a4[_0x591447(0x17c)][_0x591447(0x171)]),_0x3762aa=yamlKnowledgeBaseToApi(_0x9f00a4['yaml'],_0x40cc72);if(_0x512113)await this[_0x591447(0x208)][_0x591447(0x19f)](_0x512113['id'],_0x3762aa),_0xde2ce8['set'](_0x9f00a4['yaml'][_0x591447(0x171)],_0x512113['id']),_0x213c5f[_0x591447(0x1c3)]['push']({'name':_0x9f00a4[_0x591447(0x17c)][_0x591447(0x171)],'action':_0x591447(0x1ea),'id':_0x512113['id']}),_0x213c5f['counts']['knowledgeBases']['updated']++;else{const _0x63764e=await this['client']['createKnowledgeBase'](_0x3762aa);_0xde2ce8[_0x591447(0x192)](_0x9f00a4[_0x591447(0x17c)][_0x591447(0x171)],_0x63764e['id']),_0x213c5f['knowledgeBases'][_0x591447(0x206)]({'name':_0x9f00a4['yaml'][_0x591447(0x171)],'action':_0x591447(0x18c),'id':_0x63764e['id']}),_0x213c5f['counts'][_0x591447(0x1c3)][_0x591447(0x18c)]++;}}catch(_0x4ec454){_0x213c5f[_0x591447(0x1c3)][_0x591447(0x206)]({'name':_0x9f00a4[_0x591447(0x17c)][_0x591447(0x171)],'action':_0x591447(0x1bf),'error':_0x4ec454[_0x591447(0x1f5)]}),_0x213c5f[_0x591447(0x22b)][_0x591447(0x1c3)][_0x591447(0x1b7)]++;}}for(const _0x31824f of _0x13050a){try{const _0xa3d6e=_0x278cd0[_0x591447(0x1d9)](_0x31824f[_0x591447(0x171)]),_0x44632b=yamlTextKnowledgeBaseToApi({'name':_0x31824f['name'],'text':_0x31824f[_0x591447(0x21a)]},_0x40cc72);if(_0xa3d6e)await this[_0x591447(0x208)][_0x591447(0x165)](_0xa3d6e['id'],_0x44632b),_0x261559[_0x591447(0x192)](_0x31824f[_0x591447(0x171)],_0xa3d6e['id']),_0x213c5f[_0x591447(0x172)][_0x591447(0x206)]({'name':_0x31824f[_0x591447(0x171)],'action':_0x591447(0x1ea),'id':_0xa3d6e['id']}),_0x213c5f[_0x591447(0x22b)][_0x591447(0x172)]['updated']++;else{const _0x145ffe=await this['client']['createTextKnowledgeBase'](_0x44632b);_0x261559[_0x591447(0x192)](_0x31824f[_0x591447(0x171)],_0x145ffe['id']),_0x213c5f['textKnowledgeBases'][_0x591447(0x206)]({'name':_0x31824f[_0x591447(0x171)],'action':'created','id':_0x145ffe['id']}),_0x213c5f['counts'][_0x591447(0x172)][_0x591447(0x18c)]++;}}catch(_0x312e55){_0x213c5f['textKnowledgeBases'][_0x591447(0x206)]({'name':_0x31824f['name'],'action':_0x591447(0x1bf),'error':_0x312e55[_0x591447(0x1f5)]}),_0x213c5f[_0x591447(0x22b)]['textKnowledgeBases'][_0x591447(0x1b7)]++;}}for(const _0x1a911f of _0x25a464){try{const _0x1cd6af=_0x4c9257['get'](_0x1a911f[_0x591447(0x17c)][_0x591447(0x171)]),_0x187e06=await yamlAgentToApi(_0x1a911f[_0x591447(0x17c)],_0x1a911f[_0x591447(0x20c)],_0x1a911f[_0x591447(0x14f)],_0x44ee64);if(_0x1cd6af)await this[_0x591447(0x208)][_0x591447(0x210)](_0x1cd6af['id'],_0x187e06),_0x1ed54b[_0x591447(0x192)](_0x1a911f[_0x591447(0x17c)][_0x591447(0x171)],_0x1cd6af['id']),_0x213c5f[_0x591447(0x1b8)][_0x591447(0x206)]({'agentName':_0x1a911f['yaml'][_0x591447(0x171)],'action':'updated','agentId':_0x1cd6af['id']}),_0x213c5f[_0x591447(0x22b)]['agents']['updated']++;else{const _0x10ce8d=await this['client']['createAgentFull'](_0x187e06);_0x1ed54b[_0x591447(0x192)](_0x1a911f['yaml'][_0x591447(0x171)],_0x10ce8d['id']),_0x213c5f['agents'][_0x591447(0x206)]({'agentName':_0x1a911f[_0x591447(0x17c)][_0x591447(0x171)],'action':_0x591447(0x18c),'agentId':_0x10ce8d['id']}),_0x213c5f['counts'][_0x591447(0x1b8)][_0x591447(0x18c)]++;}}catch(_0x22f9e3){_0x213c5f['agents'][_0x591447(0x206)]({'agentName':_0x1a911f[_0x591447(0x17c)][_0x591447(0x171)],'action':'error','error':_0x22f9e3[_0x591447(0x1f5)]}),_0x213c5f[_0x591447(0x22b)][_0x591447(0x1b8)]['errors']++;}}for(const _0x3935f0 of _0x4cbb9d){try{const _0x489dc5=_0x4e3dba['get'](_0x3935f0[_0x591447(0x17c)]['name']),_0x5813ec=await yamlPromptToApi(_0x3935f0[_0x591447(0x17c)],_0x40cc72,_0x44ee64);if(!_0x5813ec){_0x213c5f[_0x591447(0x1c2)][_0x591447(0x206)]({'name':_0x3935f0[_0x591447(0x17c)]['name'],'action':_0x591447(0x1bf),'error':_0x591447(0x159)}),_0x213c5f[_0x591447(0x22b)][_0x591447(0x1c2)][_0x591447(0x1b7)]++;continue;}if(_0x489dc5)await this[_0x591447(0x208)]['updatePrompt'](_0x489dc5['id'],_0x5813ec),_0x4eb526[_0x591447(0x192)](_0x3935f0[_0x591447(0x17c)][_0x591447(0x171)],_0x489dc5['id']),_0x213c5f['prompts'][_0x591447(0x206)]({'name':_0x3935f0[_0x591447(0x17c)]['name'],'action':_0x591447(0x1ea),'id':_0x489dc5['id']}),_0x213c5f[_0x591447(0x22b)]['prompts']['updated']++;else{const _0x56c689=await this[_0x591447(0x208)][_0x591447(0x1ac)](_0x5813ec);_0x4eb526[_0x591447(0x192)](_0x3935f0[_0x591447(0x17c)]['name'],_0x56c689['id']),_0x213c5f['prompts'][_0x591447(0x206)]({'name':_0x3935f0[_0x591447(0x17c)][_0x591447(0x171)],'action':_0x591447(0x18c),'id':_0x56c689['id']}),_0x213c5f['counts']['prompts'][_0x591447(0x18c)]++;}}catch(_0x15a949){_0x213c5f['prompts'][_0x591447(0x206)]({'name':_0x3935f0[_0x591447(0x17c)][_0x591447(0x171)],'action':_0x591447(0x1bf),'error':_0x15a949[_0x591447(0x1f5)]}),_0x213c5f[_0x591447(0x22b)]['prompts'][_0x591447(0x1b7)]++;}}return _0x213c5f;}async[a71_0x4d6f2d(0x1d2)](_0x2da5be,_0x4cc86f,_0x34ff79,_0x119b3a){const _0x26b8ed=a71_0x4d6f2d,{projectId:_0x4f80f2,project:_0x575566}=await this[_0x26b8ed(0x189)](_0x2da5be),_0x5e1a3b=_0x575566['attributes'][_0x26b8ed(0x171)],_0x12e8a4=await this[_0x26b8ed(0x208)]['listAgentsFull'](_0x4f80f2),_0x43a4b1=_0x12e8a4['find'](_0x11c810=>_0x11c810[_0x26b8ed(0x17e)][_0x26b8ed(0x171)]===_0x4cc86f);if(!_0x43a4b1)throw new SDKError(ErrorCode['AGENT_NOT_FOUND'],_0x26b8ed(0x1bd)+_0x4cc86f,undefined,{'helpText':_0x26b8ed(0x20e)+_0x12e8a4[_0x26b8ed(0x193)](_0x49d869=>_0x49d869[_0x26b8ed(0x17e)][_0x26b8ed(0x171)])[_0x26b8ed(0x201)](',\x20')});const _0x5d0a89=normalizeName(_0x5e1a3b),_0x23a338=normalizeName(_0x4cc86f),_0x1f11e7=_0x34ff79||a71_0x3e1183[_0x26b8ed(0x201)](process[_0x26b8ed(0x158)](),_0x26b8ed(0x1b8),_0x5d0a89),_0x147599=a71_0x3e1183[_0x26b8ed(0x201)](_0x1f11e7,_0x23a338),_0x5aeda2=new Map(),_0x328224=new Map(),_0x18138b=await this[_0x26b8ed(0x208)][_0x26b8ed(0x16f)](_0x4f80f2),_0x33f064=await this['client'][_0x26b8ed(0x160)](_0x4f80f2),_0x159ac3=new Map();for(const _0x21973b of _0x18138b){_0x5aeda2['set'](_0x21973b['id'],_0x21973b[_0x26b8ed(0x17e)][_0x26b8ed(0x171)]);}for(const _0x4e7779 of _0x33f064){_0x159ac3[_0x26b8ed(0x192)](_0x4e7779['id'],_0x4e7779['attributes']['name']);}for(const _0x227c4d of _0x12e8a4){_0x328224[_0x26b8ed(0x192)](_0x227c4d['id'],_0x227c4d['attributes'][_0x26b8ed(0x171)]);}const _0x4d2a5c={'resolveKnowledgeBaseName':async _0x540596=>_0x5aeda2[_0x26b8ed(0x1d9)](_0x540596),'resolveTextKnowledgeBaseName':async _0x43413d=>_0x159ac3['get'](_0x43413d),'resolveAgentName':async _0xabe0b7=>_0x328224[_0x26b8ed(0x1d9)](_0xabe0b7),'resolveWebSearchToolName':async()=>undefined,'resolveImageGeneratorName':async()=>undefined,'resolvePromptName':async()=>undefined,'onWarning':_0x398b82=>this['context'][_0x26b8ed(0x1ec)]?.[_0x26b8ed(0x183)](_0x398b82)},_0x8c0a0b=a71_0x3e1183[_0x26b8ed(0x201)](_0x147599,_0x26b8ed(0x1a9)),_0x35f076=a71_0x3e1183[_0x26b8ed(0x201)](_0x147599,_0x26b8ed(0x1f6)),_0x13aa9a=a71_0x3e1183['join'](_0x147599,'starter_message.md'),_0x40df3f=!a71_0x20c894['existsSync'](_0x35f076);if(_0x119b3a?.[_0x26b8ed(0x1ee)])return{'agentName':_0x4cc86f,'outputPath':_0x147599,'isNew':_0x40df3f,'hasChanges':!![]};a71_0x20c894[_0x26b8ed(0x1ed)](_0x1f11e7,{'recursive':!![]}),a71_0x20c894[_0x26b8ed(0x1ed)](_0x147599,{'recursive':!![]});const _0x247f2c=a71_0x3e1183[_0x26b8ed(0x201)](_0x1f11e7,_0x26b8ed(0x214));!a71_0x20c894['existsSync'](_0x247f2c)&&a71_0x20c894[_0x26b8ed(0x1f4)](_0x247f2c,createAgentConfigContent(_0x2da5be));const {yaml:_0x3d5423,systemPrompt:_0x351cb0,starterMessage:_0x5a601b}=await apiAgentToYaml(_0x43a4b1,_0x4d2a5c);let _0xa47588=_0x40df3f;if(!_0x40df3f){const _0x2e41ee=a71_0x20c894[_0x26b8ed(0x156)](_0x8c0a0b)?a71_0x20c894[_0x26b8ed(0x1b6)](_0x8c0a0b,_0x26b8ed(0x1a6)):'',_0x2b9c0b=a71_0x20c894[_0x26b8ed(0x1b6)](_0x35f076,_0x26b8ed(0x1a6));_0xa47588=_0x2e41ee!==_0x351cb0||_0x2b9c0b!==toAgentYamlString(_0x3d5423);}a71_0x20c894[_0x26b8ed(0x1f4)](_0x8c0a0b,_0x351cb0),a71_0x20c894['writeFileSync'](_0x35f076,toAgentYamlString(_0x3d5423));if(_0x5a601b&&_0x5a601b['includes']('\x0a'))a71_0x20c894[_0x26b8ed(0x1f4)](_0x13aa9a,_0x5a601b);else a71_0x20c894[_0x26b8ed(0x156)](_0x13aa9a)&&a71_0x20c894[_0x26b8ed(0x1c5)](_0x13aa9a);return{'agentName':_0x4cc86f,'outputPath':_0x147599,'isNew':_0x40df3f,'hasChanges':_0xa47588};}async[a71_0x4d6f2d(0x1d8)](_0x5af0f0,_0x585562){const _0x58b38a=a71_0x4d6f2d;let _0x4565d1;isAgentYamlPath(_0x5af0f0)?_0x4565d1=getAgentDirFromYamlPath(_0x5af0f0):_0x4565d1=_0x5af0f0;const {config:_0x2f6cc9}=findAgentConfig(_0x4565d1),_0x5477b8=await this[_0x58b38a(0x1d3)](_0x2f6cc9[_0x58b38a(0x20f)]),_0x325d5b=a71_0x3e1183[_0x58b38a(0x201)](_0x4565d1,'agent.yml'),_0x2cf94c=a71_0x3e1183[_0x58b38a(0x201)](_0x4565d1,_0x58b38a(0x1a9)),_0xa5437a=a71_0x3e1183['join'](_0x4565d1,'starter_message.md');if(!a71_0x20c894[_0x58b38a(0x156)](_0x325d5b))throw new SDKError(ErrorCode[_0x58b38a(0x22c)],_0x58b38a(0x1e1)+_0x4565d1,undefined,{'helpText':_0x58b38a(0x1cf)});const _0x2ecaa3=parseAgentYaml(a71_0x20c894[_0x58b38a(0x1b6)](_0x325d5b,'utf-8'),_0x325d5b),_0x476f3f=a71_0x20c894[_0x58b38a(0x156)](_0x2cf94c)?a71_0x20c894[_0x58b38a(0x1b6)](_0x2cf94c,_0x58b38a(0x1a6)):'',_0x41b438=a71_0x20c894['existsSync'](_0xa5437a)?a71_0x20c894[_0x58b38a(0x1b6)](_0xa5437a,_0x58b38a(0x1a6)):_0x2ecaa3[_0x58b38a(0x221)];if(_0x585562?.[_0x58b38a(0x1ee)])return{'agentName':_0x2ecaa3[_0x58b38a(0x171)],'action':'created','projectId':_0x5477b8};const _0x32db51=await this[_0x58b38a(0x208)][_0x58b38a(0x1e6)](_0x5477b8),_0x1a5966=await this['client'][_0x58b38a(0x16f)](_0x5477b8),_0x1b3480=await this[_0x58b38a(0x208)]['listTextKnowledgeBases'](_0x5477b8),_0x2c2017=new Map(),_0x28655a=new Map(),_0x4a2a71=new Map();for(const _0x35385c of _0x1a5966){_0x2c2017[_0x58b38a(0x192)](_0x35385c['attributes'][_0x58b38a(0x171)],_0x35385c['id']);}for(const _0x267dd0 of _0x1b3480){_0x28655a[_0x58b38a(0x192)](_0x267dd0[_0x58b38a(0x17e)][_0x58b38a(0x171)],_0x267dd0['id']);}for(const _0x4c7b6e of _0x32db51){_0x4a2a71[_0x58b38a(0x192)](_0x4c7b6e['attributes'][_0x58b38a(0x171)],_0x4c7b6e['id']);}const _0x7182dc={'projectId':_0x5477b8,'resolveKnowledgeBaseId':async _0x420a31=>_0x2c2017[_0x58b38a(0x1d9)](_0x420a31),'resolveTextKnowledgeBaseId':async _0x59d7a0=>_0x28655a[_0x58b38a(0x1d9)](_0x59d7a0),'resolveAgentId':async _0x40e6f1=>_0x4a2a71[_0x58b38a(0x1d9)](_0x40e6f1),'resolveWebSearchToolId':async()=>undefined,'resolveImageGeneratorId':async()=>undefined,'resolvePromptId':async()=>undefined,'onWarning':_0x49bc77=>this[_0x58b38a(0x217)][_0x58b38a(0x1ec)]?.['warn'](_0x49bc77)};try{const _0x224b7f=_0x32db51[_0x58b38a(0x1a2)](_0x2b202f=>_0x2b202f['attributes'][_0x58b38a(0x171)]===_0x2ecaa3['name']),_0x3771b7=await yamlAgentToApi(_0x2ecaa3,_0x476f3f,_0x41b438,_0x7182dc);if(_0x224b7f)return await this['client'][_0x58b38a(0x210)](_0x224b7f['id'],_0x3771b7),{'agentName':_0x2ecaa3[_0x58b38a(0x171)],'action':_0x58b38a(0x1ea),'projectId':_0x5477b8,'agentId':_0x224b7f['id']};else{const _0x2bb483=await this[_0x58b38a(0x208)][_0x58b38a(0x1da)](_0x3771b7);return{'agentName':_0x2ecaa3[_0x58b38a(0x171)],'action':_0x58b38a(0x18c),'projectId':_0x5477b8,'agentId':_0x2bb483['id']};}}catch(_0x516ba9){return{'agentName':_0x2ecaa3[_0x58b38a(0x171)],'action':_0x58b38a(0x1bf),'projectId':_0x5477b8,'error':_0x516ba9[_0x58b38a(0x1f5)]};}}async['cloneProject'](_0x381789,_0x131d8c,_0x20a913){const _0x11cc41=a71_0x4d6f2d,_0x394b31=a71_0x20c894[_0x11cc41(0x156)](_0x381789)&&a71_0x20c894[_0x11cc41(0x156)](a71_0x3e1183[_0x11cc41(0x201)](_0x381789,'tdx.json'));let _0x30b998;const _0x574ff3=[],_0x301479=[],_0x44a875=[],_0x13d3d6=[];if(_0x394b31){const _0x173ea9=loadAgentConfig(a71_0x3e1183[_0x11cc41(0x201)](_0x381789,'tdx.json'));_0x30b998=_0x173ea9[_0x11cc41(0x20f)];const _0x2476b0=a71_0x20c894[_0x11cc41(0x18d)](_0x381789,{'withFileTypes':!![]});for(const _0xdec104 of _0x2476b0){if(!_0xdec104[_0x11cc41(0x212)]())continue;if([_0x11cc41(0x15e),'prompts',_0x11cc41(0x216)]['includes'](_0xdec104[_0x11cc41(0x171)]))continue;const _0x5483db=a71_0x3e1183['join'](_0x381789,_0xdec104[_0x11cc41(0x171)]);if(isAgentDir(_0x5483db)){const _0x1c9858=a71_0x3e1183['join'](_0x5483db,'agent.yml'),_0x1b9a8b=a71_0x3e1183[_0x11cc41(0x201)](_0x5483db,_0x11cc41(0x1a9)),_0x42e192=a71_0x3e1183[_0x11cc41(0x201)](_0x5483db,_0x11cc41(0x190)),_0x537f63=parseAgentYaml(a71_0x20c894[_0x11cc41(0x1b6)](_0x1c9858,'utf-8'),_0x1c9858),_0x464d5a=a71_0x20c894[_0x11cc41(0x156)](_0x1b9a8b)?a71_0x20c894[_0x11cc41(0x1b6)](_0x1b9a8b,_0x11cc41(0x1a6)):'',_0x1b4d40=a71_0x20c894[_0x11cc41(0x156)](_0x42e192)?a71_0x20c894[_0x11cc41(0x1b6)](_0x42e192,_0x11cc41(0x1a6)):_0x537f63[_0x11cc41(0x221)];_0x574ff3[_0x11cc41(0x206)]({'name':_0x537f63[_0x11cc41(0x171)],'dir':_0x5483db,'yaml':_0x537f63,'systemPrompt':_0x464d5a,'starterMessage':_0x1b4d40});}}const _0x4004fe=getKnowledgeBasesDir(_0x381789);if(a71_0x20c894[_0x11cc41(0x156)](_0x4004fe)){const _0x5b8b36=a71_0x20c894['readdirSync'](_0x4004fe);for(const _0x39cf0c of _0x5b8b36){const _0x159c4e=a71_0x3e1183[_0x11cc41(0x201)](_0x4004fe,_0x39cf0c);if(_0x39cf0c[_0x11cc41(0x228)](_0x11cc41(0x225))){const _0x2ed21b=parseKnowledgeBaseYaml(a71_0x20c894[_0x11cc41(0x1b6)](_0x159c4e,_0x11cc41(0x1a6)),_0x159c4e);_0x301479['push']({'name':_0x2ed21b[_0x11cc41(0x171)],'path':_0x159c4e,'yaml':_0x2ed21b});}else{if(_0x39cf0c[_0x11cc41(0x228)](_0x11cc41(0x16e))){const _0x5d113a=a71_0x20c894[_0x11cc41(0x1b6)](_0x159c4e,_0x11cc41(0x1a6)),{name:_0x5b587f,text:_0x1df2ea}=parseTextKnowledgeBaseMd(_0x5d113a,_0x39cf0c);_0x44a875[_0x11cc41(0x206)]({'name':_0x5b587f,'path':_0x159c4e,'text':_0x1df2ea});}}}}const _0x1abd32=getPromptsDir(_0x381789);if(a71_0x20c894[_0x11cc41(0x156)](_0x1abd32)){const _0x5778c1=a71_0x20c894['readdirSync'](_0x1abd32)['filter'](_0x3a5ffc=>_0x3a5ffc[_0x11cc41(0x228)]('.yml'));for(const _0x343264 of _0x5778c1){const _0x422632=a71_0x3e1183[_0x11cc41(0x201)](_0x1abd32,_0x343264),_0x5c74c8=parsePromptYaml(a71_0x20c894[_0x11cc41(0x1b6)](_0x422632,'utf-8'),_0x422632);_0x13d3d6[_0x11cc41(0x206)]({'name':_0x5c74c8[_0x11cc41(0x171)],'path':_0x422632,'yaml':_0x5c74c8});}}}else{const _0x96288=await this[_0x11cc41(0x1d3)](_0x381789),_0x2042db=await this['client'][_0x11cc41(0x1b2)](_0x96288);_0x30b998=_0x2042db['attributes'][_0x11cc41(0x171)];const _0x140ad1=await this[_0x11cc41(0x208)][_0x11cc41(0x1e6)](_0x96288),_0x2ec7a3=await this[_0x11cc41(0x208)][_0x11cc41(0x16f)](_0x96288),_0x51927c=await this[_0x11cc41(0x208)][_0x11cc41(0x160)](_0x96288),_0x3b376d=await this[_0x11cc41(0x208)][_0x11cc41(0x176)](_0x96288),_0x436f43=new Map(),_0x1c0bfa=new Map(),_0x18d193=new Map(),_0x2675ed=new Map();for(const _0x3cbf5a of _0x2ec7a3){_0x436f43[_0x11cc41(0x192)](_0x3cbf5a['id'],_0x3cbf5a[_0x11cc41(0x17e)][_0x11cc41(0x171)]);}for(const _0x2c9eab of _0x51927c){_0x1c0bfa['set'](_0x2c9eab['id'],_0x2c9eab[_0x11cc41(0x17e)]['name']);}for(const _0x1820b4 of _0x140ad1){_0x18d193[_0x11cc41(0x192)](_0x1820b4['id'],_0x1820b4['attributes']['name']);}for(const _0x400057 of _0x3b376d){_0x2675ed['set'](_0x400057['id'],_0x400057['attributes'][_0x11cc41(0x171)]);}const _0x248116={'resolveKnowledgeBaseName':async _0x250027=>_0x436f43[_0x11cc41(0x1d9)](_0x250027),'resolveTextKnowledgeBaseName':async _0x7a7563=>_0x1c0bfa[_0x11cc41(0x1d9)](_0x7a7563),'resolveAgentName':async _0xdea23b=>_0x18d193[_0x11cc41(0x1d9)](_0xdea23b),'resolveWebSearchToolName':async()=>undefined,'resolveImageGeneratorName':async()=>undefined,'resolvePromptName':async _0x301eb8=>_0x2675ed[_0x11cc41(0x1d9)](_0x301eb8),'onWarning':_0x3972e0=>this['context'][_0x11cc41(0x1ec)]?.[_0x11cc41(0x183)](_0x3972e0)};for(const _0x39a345 of _0x140ad1){const _0x5c8c80=await apiAgentToYaml(_0x39a345,_0x248116),{yaml:_0x24c0c0,systemPrompt:_0x3423a6,starterMessage:_0x54df2e}=_0x5c8c80;_0x574ff3['push']({'name':_0x24c0c0[_0x11cc41(0x171)],'dir':'','yaml':_0x24c0c0,'systemPrompt':_0x3423a6,'starterMessage':_0x54df2e});}for(const _0xb514fd of _0x2ec7a3){const _0x1dcf0f=apiKnowledgeBaseToYaml(_0xb514fd);_0x301479[_0x11cc41(0x206)]({'name':_0x1dcf0f[_0x11cc41(0x171)],'path':'','yaml':_0x1dcf0f});}for(const _0x533e8a of _0x51927c){_0x44a875['push']({'name':_0x533e8a['attributes'][_0x11cc41(0x171)],'path':'','text':_0x533e8a[_0x11cc41(0x17e)][_0x11cc41(0x21a)]});}for(const _0x6b7ecb of _0x3b376d){const _0x16d60e=await apiPromptToYaml(_0x6b7ecb,_0x248116);_0x16d60e&&_0x13d3d6[_0x11cc41(0x206)]({'name':_0x16d60e[_0x11cc41(0x171)],'path':'','yaml':_0x16d60e});}}const _0x31140c={'sourceProjectName':_0x30b998,'newProjectName':_0x131d8c,'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}}},_0x1d33af=await this[_0x11cc41(0x208)]['listProjects'](),_0x5365fe=_0x1d33af[_0x11cc41(0x1a2)](_0x337a29=>_0x337a29[_0x11cc41(0x17e)]['name']===_0x131d8c);if(_0x5365fe)throw new SDKError(ErrorCode[_0x11cc41(0x179)],_0x11cc41(0x226)+_0x131d8c+_0x11cc41(0x1ca),undefined,{'helpText':_0x11cc41(0x196)});if(_0x20a913?.[_0x11cc41(0x1ee)])return _0x31140c[_0x11cc41(0x22b)][_0x11cc41(0x1b8)][_0x11cc41(0x18c)]=_0x574ff3[_0x11cc41(0x15a)],_0x31140c[_0x11cc41(0x22b)][_0x11cc41(0x1c3)][_0x11cc41(0x18c)]=_0x301479[_0x11cc41(0x15a)],_0x31140c[_0x11cc41(0x22b)][_0x11cc41(0x172)][_0x11cc41(0x18c)]=_0x44a875[_0x11cc41(0x15a)],_0x31140c[_0x11cc41(0x22b)][_0x11cc41(0x1c2)][_0x11cc41(0x18c)]=_0x13d3d6[_0x11cc41(0x15a)],_0x31140c;const _0x52cb18=await this[_0x11cc41(0x208)]['createProject']({'name':_0x131d8c}),_0x5c0c7a=_0x52cb18['id'];_0x31140c[_0x11cc41(0x1fb)]=_0x5c0c7a;const _0x5eb7f5=new Map(),_0x26f52d=new Map(),_0xfe209d=new Map(),_0x59e9f4=new Map(),_0x438e5e=new Map(),_0x5406f6=new Map(),_0x57c919=new Set(),_0x1fa843=new Set();for(const _0x25038f of _0x574ff3){for(const _0x587703 of _0x25038f[_0x11cc41(0x17c)][_0x11cc41(0x197)]||[]){if(_0x587703[_0x11cc41(0x1ba)]==='image_gen'){const _0x21c23f=parseRef(_0x587703[_0x11cc41(0x1c0)]);if(_0x21c23f)_0x57c919['add'](_0x21c23f[_0x11cc41(0x171)]);}else{if(_0x587703[_0x11cc41(0x1ba)]===_0x11cc41(0x1dc)){const _0x468d35=parseRef(_0x587703[_0x11cc41(0x1c0)]);if(_0x468d35)_0x1fa843['add'](_0x468d35['name']);}}}}for(const _0x43a778 of _0x57c919){try{const _0xc50c17=await this[_0x11cc41(0x208)]['createImageGenerator']({'projectId':_0x5c0c7a,'name':_0x43a778});_0x438e5e[_0x11cc41(0x192)](_0x43a778,_0xc50c17['id']),_0x31140c[_0x11cc41(0x209)]['push']({'name':_0x43a778,'action':'created','id':_0xc50c17['id']}),_0x31140c[_0x11cc41(0x22b)][_0x11cc41(0x209)][_0x11cc41(0x18c)]++;}catch(_0x4b8c6c){_0x31140c[_0x11cc41(0x209)][_0x11cc41(0x206)]({'name':_0x43a778,'action':_0x11cc41(0x1bf),'error':_0x4b8c6c['message']}),_0x31140c[_0x11cc41(0x22b)][_0x11cc41(0x209)][_0x11cc41(0x1b7)]++;}}for(const _0x1f4f4d of _0x1fa843){try{const _0x3bc1d9=await this[_0x11cc41(0x208)][_0x11cc41(0x1d7)]({'projectId':_0x5c0c7a,'name':_0x1f4f4d});_0x5406f6[_0x11cc41(0x192)](_0x1f4f4d,_0x3bc1d9['id']),_0x31140c['webSearchTools'][_0x11cc41(0x206)]({'name':_0x1f4f4d,'action':'created','id':_0x3bc1d9['id']}),_0x31140c[_0x11cc41(0x22b)][_0x11cc41(0x1e9)]['created']++;}catch(_0x47bfd3){_0x31140c['webSearchTools'][_0x11cc41(0x206)]({'name':_0x1f4f4d,'action':_0x11cc41(0x1bf),'error':_0x47bfd3[_0x11cc41(0x1f5)]}),_0x31140c[_0x11cc41(0x22b)][_0x11cc41(0x1e9)][_0x11cc41(0x1b7)]++;}}const _0x3d6fff={'projectId':_0x5c0c7a,'resolveKnowledgeBaseId':async _0x1e4213=>_0x5eb7f5[_0x11cc41(0x1d9)](_0x1e4213),'resolveTextKnowledgeBaseId':async _0x2b2a00=>_0x26f52d['get'](_0x2b2a00),'resolveAgentId':async _0xacfdaa=>_0xfe209d[_0x11cc41(0x1d9)](_0xacfdaa),'resolveWebSearchToolId':async _0x389c24=>_0x5406f6['get'](_0x389c24),'resolveImageGeneratorId':async _0x38e6b8=>_0x438e5e['get'](_0x38e6b8),'resolvePromptId':async _0x506aa5=>_0x59e9f4['get'](_0x506aa5),'onWarning':_0xdfef2f=>this[_0x11cc41(0x217)][_0x11cc41(0x1ec)]?.[_0x11cc41(0x183)](_0xdfef2f)};for(const _0x210369 of _0x301479){try{const _0x407830=yamlKnowledgeBaseToApi(_0x210369[_0x11cc41(0x17c)],_0x5c0c7a),_0x30b66f=await this[_0x11cc41(0x208)][_0x11cc41(0x157)](_0x407830);_0x5eb7f5[_0x11cc41(0x192)](_0x210369[_0x11cc41(0x17c)]['name'],_0x30b66f['id']),_0x31140c['knowledgeBases'][_0x11cc41(0x206)]({'name':_0x210369[_0x11cc41(0x17c)][_0x11cc41(0x171)],'action':_0x11cc41(0x18c),'id':_0x30b66f['id']}),_0x31140c[_0x11cc41(0x22b)][_0x11cc41(0x1c3)][_0x11cc41(0x18c)]++;}catch(_0x2d7353){_0x31140c['knowledgeBases']['push']({'name':_0x210369[_0x11cc41(0x17c)][_0x11cc41(0x171)],'action':'error','error':_0x2d7353[_0x11cc41(0x1f5)]}),_0x31140c[_0x11cc41(0x22b)][_0x11cc41(0x1c3)][_0x11cc41(0x1b7)]++;}}for(const _0x4cf2b7 of _0x44a875){try{const _0x1516ad=yamlTextKnowledgeBaseToApi({'name':_0x4cf2b7['name'],'text':_0x4cf2b7[_0x11cc41(0x21a)]},_0x5c0c7a),_0x24beda=await this[_0x11cc41(0x208)][_0x11cc41(0x1fe)](_0x1516ad);_0x26f52d[_0x11cc41(0x192)](_0x4cf2b7[_0x11cc41(0x171)],_0x24beda['id']),_0x31140c[_0x11cc41(0x172)][_0x11cc41(0x206)]({'name':_0x4cf2b7[_0x11cc41(0x171)],'action':_0x11cc41(0x18c),'id':_0x24beda['id']}),_0x31140c[_0x11cc41(0x22b)]['textKnowledgeBases'][_0x11cc41(0x18c)]++;}catch(_0x2980f8){_0x31140c[_0x11cc41(0x172)]['push']({'name':_0x4cf2b7[_0x11cc41(0x171)],'action':'error','error':_0x2980f8[_0x11cc41(0x1f5)]}),_0x31140c[_0x11cc41(0x22b)][_0x11cc41(0x172)][_0x11cc41(0x1b7)]++;}}const _0x3334ef=[..._0x574ff3][_0x11cc41(0x177)]((_0x987896,_0x403b87)=>{const _0x2294ed=_0x11cc41,_0x27b7d8=_0x987896[_0x2294ed(0x17c)]['tools']?.['some'](_0x11c664=>_0x11c664[_0x2294ed(0x1ba)]===_0x2294ed(0x1e3))??![],_0xa37e20=_0x403b87[_0x2294ed(0x17c)][_0x2294ed(0x197)]?.[_0x2294ed(0x20d)](_0x577a6c=>_0x577a6c[_0x2294ed(0x1ba)]===_0x2294ed(0x1e3))??![];if(_0x27b7d8&&!_0xa37e20)return 0x1;if(!_0x27b7d8&&_0xa37e20)return-0x1;return 0x0;});for(const _0x5a0335 of _0x3334ef){try{const _0x2fda42=_0x5a0335[_0x11cc41(0x17c)]['tools']?.[_0x11cc41(0x153)](_0x1b4d48=>{const _0x7d4082=_0x11cc41;if(_0x1b4d48[_0x7d4082(0x1ba)]===_0x7d4082(0x1e3)){const _0x1fb179=parseRef(_0x1b4d48[_0x7d4082(0x1c0)]);return _0x1fb179?.['name']===_0x5a0335[_0x7d4082(0x17c)][_0x7d4082(0x171)];}return![];})??[];_0x2fda42[_0x11cc41(0x15a)]>0x0&&this['context'][_0x11cc41(0x1ec)]?.[_0x11cc41(0x183)](_0x11cc41(0x1f2)+_0x5a0335[_0x11cc41(0x17c)][_0x11cc41(0x171)]+_0x11cc41(0x154)+_0x11cc41(0x19a));const _0x32eb79=await yamlAgentToApi(_0x5a0335['yaml'],_0x5a0335[_0x11cc41(0x20c)],_0x5a0335[_0x11cc41(0x14f)],_0x3d6fff),_0x494a86=await this[_0x11cc41(0x208)]['createAgentFull'](_0x32eb79);_0xfe209d[_0x11cc41(0x192)](_0x5a0335[_0x11cc41(0x17c)][_0x11cc41(0x171)],_0x494a86['id']),_0x31140c[_0x11cc41(0x1b8)]['push']({'agentName':_0x5a0335[_0x11cc41(0x17c)][_0x11cc41(0x171)],'action':_0x11cc41(0x18c),'agentId':_0x494a86['id']}),_0x31140c[_0x11cc41(0x22b)][_0x11cc41(0x1b8)][_0x11cc41(0x18c)]++;}catch(_0x1bf143){_0x31140c[_0x11cc41(0x1b8)][_0x11cc41(0x206)]({'agentName':_0x5a0335[_0x11cc41(0x17c)][_0x11cc41(0x171)],'action':'error','error':_0x1bf143[_0x11cc41(0x1f5)]}),_0x31140c['counts'][_0x11cc41(0x1b8)]['errors']++;}}for(const _0x2a50ef of _0x13d3d6){try{const _0x2e49db=await yamlPromptToApi(_0x2a50ef[_0x11cc41(0x17c)],_0x5c0c7a,_0x3d6fff);if(!_0x2e49db){_0x31140c[_0x11cc41(0x1c2)][_0x11cc41(0x206)]({'name':_0x2a50ef[_0x11cc41(0x17c)][_0x11cc41(0x171)],'action':_0x11cc41(0x1bf),'error':'Agent\x20reference\x20not\x20found'}),_0x31140c[_0x11cc41(0x22b)]['prompts'][_0x11cc41(0x1b7)]++;continue;}const _0x3547d0=await this['client'][_0x11cc41(0x1ac)](_0x2e49db);_0x59e9f4['set'](_0x2a50ef[_0x11cc41(0x17c)]['name'],_0x3547d0['id']),_0x31140c['prompts'][_0x11cc41(0x206)]({'name':_0x2a50ef[_0x11cc41(0x17c)]['name'],'action':_0x11cc41(0x18c),'id':_0x3547d0['id']}),_0x31140c['counts'][_0x11cc41(0x1c2)][_0x11cc41(0x18c)]++;}catch(_0x3a9824){_0x31140c['prompts'][_0x11cc41(0x206)]({'name':_0x2a50ef[_0x11cc41(0x17c)][_0x11cc41(0x171)],'action':_0x11cc41(0x1bf),'error':_0x3a9824[_0x11cc41(0x1f5)]}),_0x31140c[_0x11cc41(0x22b)]['prompts'][_0x11cc41(0x1b7)]++;}}return _0x31140c;}}
|
|
1
|
+
const a71_0x49d5c4=a71_0x2db5;(function(_0x21d0c4,_0x512c55){const _0x5ec589=a71_0x2db5,_0x57431d=_0x21d0c4();while(!![]){try{const _0xee20c3=parseInt(_0x5ec589(0x184))/0x1+-parseInt(_0x5ec589(0x1dd))/0x2*(parseInt(_0x5ec589(0x1d7))/0x3)+-parseInt(_0x5ec589(0x173))/0x4+-parseInt(_0x5ec589(0x13d))/0x5+-parseInt(_0x5ec589(0x1b8))/0x6*(-parseInt(_0x5ec589(0x1f2))/0x7)+parseInt(_0x5ec589(0x142))/0x8*(-parseInt(_0x5ec589(0x15a))/0x9)+-parseInt(_0x5ec589(0x12b))/0xa*(parseInt(_0x5ec589(0x1ad))/0xb);if(_0xee20c3===_0x512c55)break;else _0x57431d['push'](_0x57431d['shift']());}catch(_0x2e895a){_0x57431d['push'](_0x57431d['shift']());}}}(a71_0x352d,0xd60a9));import{LLMApiClient}from'../client/llm-api-client.js';import*as a71_0x2553dc from'node:fs';import*as a71_0x5c63df from'node:path';import{HTTPClientError}from'../client/http-client.js';function a71_0x352d(){const _0x25b48e=['agent.yml','Ensure\x20the\x20backup\x20folder\x20path\x20is\x20correct.','getBackupMetadata','Output\x20directory\x20already\x20exists:\x20','21763mVEtoG','maxToolIterations','new','existsSync','displayName','imageGenerators','listWebSearchTools','getAgent','reasoningEffort','target','Invalid\x20agent\x20reference\x20format:\x20','template','Multiple\x20projects\x20found\x20with\x20name\x20\x27','logger','listAgentsFull','\x0a\x0a#\x20agent.yml\x0a','clearDefaultAgent','(dry-run)','\x20attempts\x20due\x20to\x20name\x20conflicts.','models','Use\x20format:\x20\x22agent-name\x22\x20or\x20\x22project-name/agent-name\x22','starter_message.md','content','Use\x20a\x20different\x20output\x20path\x20or\x20remove\x20the\x20existing\x20directory.','medium','keys','Available\x20agents:\x20','NOT_FOUND','systemPrompt','10LKUrnB','readFileSync','getUniqueName','starter_message','projects','starterMessage','backupProject','UNAUTHENTICATED','listAgents','prompt.md','listIntegrations','message','counts','createPrompt','tdx_','pushAgent','tdDatabaseName','Project\x20\x22','1050180KpQNIP','chats','currentProjectId','getOrCreateDefaultProject','mkdirSync','64CmMmAP','version','total','updateTextKnowledgeBase','action','webSearchTools','updateAgent','The\x20backup\x20contains\x20agents\x20with\x20circular\x20dependencies.','Choose\x20a\x20different\x20name\x20or\x20delete\x20the\x20existing\x20project\x20first.','webhookCorsOrigins','context','knowledge_bases','unchanged','setDefaultAgent','readdirSync','temperature','agents','textKnowledgeBases','continueChat','attributes','chatId','serviceType','setCurrentProject','client','585486qUuuOr','type','resolveProjectName','signal','\x22\x20already\x20exists','toISOString','sort','listKnowledgeBases','promptId','resolveProjectId','Unresolved\x20dependencies:\x20','\x20in\x20project\x20','find','getProject','includes','already\x20exists','updatePrompt','Agent\x20\x27','endsWith','agentId','Invalid\x20backup:\x20project.json\x20not\x20found\x20in\x20','.llm','history','listImageGenerators','chatWelcomeMessage','1758844sImJgR','get','writeFileSync','PERMISSION_DENIED','map','agent.yml\x20not\x20found\x20in\x20','project','getChatHistory','knowledgeBases','dirname','utf-8','event','chatIgnoreManagedActions','exportedFrom','yaml','createImageGenerator','Project\x20not\x20found:\x20','488203DjSUuL','conflict','INVALID_ARGUMENT','low','status','llm_project','Agent\x20reference\x20not\x20found','\x27\x20has\x20self-referencing\x20tool(s)\x20that\x20will\x20be\x20skipped\x20during\x20clone.\x20','#\x20prompt.md\x0a','getDefaultProjectName','Unable\x20to\x20create\x20project\x20after\x20','createAgent','createTextKnowledgeBase','join','agents.json','created','variables','availableModelNames','listPrompts','set','listProjects','chat','getUserSettings','createAgentFull','AGENT_NOT_FOUND','errors','prompts','length','.md','text','startChat','tdx_default_','Use\x20\x22tdx\x20llm\x20agents\x22\x20to\x20list\x20available\x20agents\x20in\x20the\x20current\x20project.','high','.\x20Check\x20for\x20circular\x20references\x20or\x20missing\x20agents.','site','dry-run-','loadJsonFile','updated','dryRun','has','936848UYcEfo','listTextKnowledgeBases','agent','Re-add\x20them\x20after\x20clone\x20using\x20\x27tdx\x20agent\x20push\x27.','filter','cwd','image_gen','isDirectory','knowledgebases.json','.yml','1.0','3210JhRFYy','name','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.','pushProject','Run\x20\x27tdx\x20agent\x20pull\x20<project>\x27\x20first\x20to\x20create\x20the\x20folder\x20structure.','profile','updateAgentFull','updateKnowledgeBase','Agent\x20not\x20found:\x20','No\x20tdx.json\x20found\x20in\x20','Default\x20project\x20for\x20tdx\x20CLI\x20chat\x20(user:\x20','stringify','integrations.json','cloneProject','push','add','Ensure\x20this\x20is\x20a\x20valid\x20LLM\x20project\x20backup\x20folder.','tdx.json','slackMessageMode','tools','isDir','resolveAgentId','getDefaultAgent','some','This\x20backup\x20was\x20created\x20with\x20a\x20newer\x20version\x20of\x20tdx.','getOrCreateDefaultAgent','deleteProject','Authentication\x20failed.\x20Please\x20check\x20your\x20API\x20key\x20is\x20valid\x20and\x20not\x20expired.','prompts.json','projectName','warn','9729sCtohY','integrations','error','ALREADY_EXISTS','deleteAgent','getChatInfo','12ARCnAS','minimal','createKnowledgeBase','pullProject','Unsupported\x20backup\x20version:\x20','LLM_PROJECT_NOT_FOUND','createWebSearchTool','createIntegration','availableModels','Backup\x20folder\x20not\x20found:\x20','createProject','agentId\x20is\x20required\x20when\x20starting\x20a\x20new\x20chat','INTERNAL','parse','duplicate','path','isManaged'];a71_0x352d=function(){return _0x25b48e;};return a71_0x352d();}function a71_0x2db5(_0x368d54,_0x284334){_0x368d54=_0x368d54-0x11b;const _0x352d2b=a71_0x352d();let _0x2db50c=_0x352d2b[_0x368d54];return _0x2db50c;}import{canCreateAgent,remapToolIds,remapVariableIds,isSupportedBackupVersion}from'../utils/llm-backup-utils.js';import{SDKError,ErrorCode,errorContains}from'./errors.js';import{normalizeName,UniqueNameGenerator,migrateModelType,parseRef,apiAgentToYaml,apiKnowledgeBaseToYaml,apiPromptToYaml,toAgentYamlString,toKnowledgeBaseYamlString,toTextKnowledgeBaseMd,toPromptYamlString,parseAgentYaml,parseKnowledgeBaseYaml,parseTextKnowledgeBaseMd,parsePromptYaml,yamlAgentToApi,yamlKnowledgeBaseToApi,yamlTextKnowledgeBaseToApi,yamlPromptToApi,resolveAgentDependencies}from'./agent/agent-yaml.js';import{createAgentConfigContent,loadAgentConfig,findAgentConfig,isAgentDir,isAgentYamlPath,getAgentDirFromYamlPath,getKnowledgeBasesDir,getPromptsDir}from'../utils/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{[a71_0x49d5c4(0x13f)];[a71_0x49d5c4(0x159)];['context'];constructor(_0x240fa7){const _0x474ffd=a71_0x49d5c4;this['client']=new LLMApiClient(_0x240fa7,_0x240fa7['logger']),this[_0x474ffd(0x14c)]=_0x240fa7;}[a71_0x49d5c4(0x18d)](){const _0x5061f9=a71_0x49d5c4,_0x1ca537=getSanitizedUsername();return _0x5061f9(0x1a3)+_0x1ca537;}async[a71_0x49d5c4(0x158)](_0x58052c){const _0x5542f1=a71_0x49d5c4,{projectId:_0x2b1e5a}=await this[_0x5542f1(0x15c)](_0x58052c);this[_0x5542f1(0x13f)]=_0x2b1e5a;}['getCurrentProject'](){const _0x569cfd=a71_0x49d5c4;return this[_0x569cfd(0x13f)];}async[a71_0x49d5c4(0x14f)](_0x801d8e){const _0x23ab8f=a71_0x49d5c4,_0x280e01=this[_0x23ab8f(0x14c)][_0x23ab8f(0x1bd)];let _0x2e7196,_0x4b0f90;if(_0x801d8e[_0x23ab8f(0x168)]('/')){const _0x2338cc=_0x801d8e['split']('/');if(_0x2338cc['length']!==0x2)throw new SDKError(ErrorCode[_0x23ab8f(0x186)],_0x23ab8f(0x1fc)+_0x801d8e,undefined,{'helpText':_0x23ab8f(0x122)});const [_0x5bec6f,_0x1dd61d]=_0x2338cc;_0x2e7196=await this[_0x23ab8f(0x163)](_0x5bec6f),_0x4b0f90=_0x1dd61d;}else _0x2e7196=this[_0x23ab8f(0x13f)]||(await this[_0x23ab8f(0x140)]())['id'],_0x4b0f90=_0x801d8e;const _0x4d5209=await this[_0x23ab8f(0x1cd)](_0x4b0f90,_0x2e7196),_0x2d7f49=await this[_0x23ab8f(0x159)]['getAgent'](_0x4d5209);writeCachedLLMAgent(_0x2d7f49['attributes'][_0x23ab8f(0x1b9)],_0x4d5209,_0x2e7196,_0x280e01);}[a71_0x49d5c4(0x1ce)](){const _0x3f8271=a71_0x49d5c4,_0x20edb2=this[_0x3f8271(0x14c)][_0x3f8271(0x1bd)];return readCachedLLMAgent(_0x20edb2)||undefined;}[a71_0x49d5c4(0x11e)](){const _0x4ea8a7=a71_0x49d5c4,_0x487999=this[_0x4ea8a7(0x14c)][_0x4ea8a7(0x1bd)];clearCachedLLMAgent(_0x487999);}async[a71_0x49d5c4(0x121)](){const _0x1085ac=a71_0x49d5c4,_0x2ac39c=await this[_0x1085ac(0x159)][_0x1085ac(0x19a)](),_0x583f00=[];for(const _0x19f954 of _0x2ac39c[_0x1085ac(0x195)]){const _0xdbc862=_0x2ac39c[_0x1085ac(0x1e5)][_0x19f954];_0xdbc862&&_0x583f00[_0x1085ac(0x1c6)]({'name':_0x19f954,'displayName':_0xdbc862[_0x1085ac(0x1f6)]});}return _0x583f00;}async['createProject'](_0x3eed05){const _0x336d5a=a71_0x49d5c4;return await this[_0x336d5a(0x159)][_0x336d5a(0x1e7)](_0x3eed05);}async[a71_0x49d5c4(0x1d2)](_0x7b26dc){const _0x8fae9=a71_0x49d5c4,{projectId:_0x35a8ef}=await this[_0x8fae9(0x15c)](_0x7b26dc);await this[_0x8fae9(0x159)][_0x8fae9(0x1d2)](_0x35a8ef);}async[a71_0x49d5c4(0x12f)](_0x2302b9=0x32){const _0x49d237=a71_0x49d5c4;return await this['client'][_0x49d237(0x198)](_0x2302b9);}async[a71_0x49d5c4(0x140)](_0x2544c5){const _0x186a73=a71_0x49d5c4,_0x553327=_0x2544c5||this[_0x186a73(0x18d)](),_0x54715b=this[_0x186a73(0x14c)][_0x186a73(0x1bd)];if(!_0x2544c5){const _0x31720c=readCachedLLMProject(_0x54715b);if(_0x31720c&&_0x31720c[_0x186a73(0x1b9)]===_0x553327)try{const _0x6d94ea=await this[_0x186a73(0x159)][_0x186a73(0x167)](_0x31720c['id']);if(_0x6d94ea[_0x186a73(0x155)][_0x186a73(0x1b9)]===_0x553327)return _0x6d94ea;}catch{}}const _0x4d0ed7=await this[_0x186a73(0x159)][_0x186a73(0x198)](),_0x3096c6=_0x4d0ed7['find'](_0x2151ea=>_0x2151ea['attributes'][_0x186a73(0x1b9)]===_0x553327);if(_0x3096c6)return!_0x2544c5&&writeCachedLLMProject(_0x553327,_0x3096c6['id'],_0x54715b),_0x3096c6;const _0x3ac4b1=await this[_0x186a73(0x159)]['createProject']({'name':_0x553327,'description':_0x186a73(0x1c2)+getSanitizedUsername()+')'});return!_0x2544c5&&writeCachedLLMProject(_0x553327,_0x3ac4b1['id'],_0x54715b),_0x3ac4b1;}async['resolveProjectId'](_0x260626){const _0x1cc10f=a71_0x49d5c4,_0x1a2958=await this[_0x1cc10f(0x159)][_0x1cc10f(0x198)](),_0x3140d0=_0x1a2958[_0x1cc10f(0x1b1)](_0x2b52a1=>_0x2b52a1['attributes'][_0x1cc10f(0x1b9)]===_0x260626);if(_0x3140d0[_0x1cc10f(0x19f)]===0x0)throw new SDKError(ErrorCode[_0x1cc10f(0x1e2)],_0x1cc10f(0x183)+_0x260626,undefined,{'helpText':'Use\x20\x22tdx\x20llm\x20projects\x22\x20to\x20list\x20available\x20projects.'});if(_0x3140d0['length']>0x1)throw new SDKError(ErrorCode['INTERNAL'],_0x1cc10f(0x1fe)+_0x260626+'\x27.\x20This\x20should\x20not\x20happen.');return _0x3140d0[0x0]['id'];}async['resolveProjectName'](_0x3f6f1b){const _0x51770a=a71_0x49d5c4,_0xa0e359=await this[_0x51770a(0x159)]['listProjects'](),_0x2a9c42=_0xa0e359['find'](_0x51f7d6=>_0x51f7d6[_0x51770a(0x155)][_0x51770a(0x1b9)]===_0x3f6f1b);if(_0x2a9c42)return{'projectId':_0x2a9c42['id'],'project':_0x2a9c42};throw new SDKError(ErrorCode[_0x51770a(0x1e2)],_0x51770a(0x183)+_0x3f6f1b,undefined,{'helpText':'Use\x20\x22tdx\x20llm\x20projects\x22\x20to\x20list\x20available\x20projects.'});}async[a71_0x49d5c4(0x1d1)](_0x341b32='claude-4.5-sonnet',_0x121bbb=0x0,_0x4f448a){const _0x308f16=a71_0x49d5c4,_0x28c87b=0xa;let _0x14124f=0x0,_0x433289;while(_0x14124f<_0x28c87b){try{const _0x3e79b6=await this[_0x308f16(0x140)](_0x433289),_0x344b8f=_0x3e79b6['id'],_0x54e690=['none',_0x308f16(0x1de),_0x308f16(0x187),_0x308f16(0x126),_0x308f16(0x1a5)],_0x30a3c7=_0x121bbb===0x0?_0x308f16(0x139)+_0x341b32:_0x308f16(0x139)+_0x341b32+'_reasoning_'+_0x54e690[_0x121bbb],_0x5e019d=await this[_0x308f16(0x159)][_0x308f16(0x133)](_0x344b8f),_0x535530=_0x5e019d[_0x308f16(0x166)](_0x465f15=>_0x465f15[_0x308f16(0x155)][_0x308f16(0x1b9)]===_0x30a3c7);if(_0x535530)return _0x535530;const _0xf06c75=_0x121bbb>0x0?0x1:_0x4f448a;return await this['client'][_0x308f16(0x18f)]({'name':_0x30a3c7,'projectId':_0x344b8f,'modelType':_0x341b32,'systemPrompt':'','temperature':_0xf06c75,'reasoningEffort':_0x121bbb>0x0?_0x121bbb:undefined});}catch(_0x2effc0){if(_0x2effc0 instanceof HTTPClientError){const _0x47d70e=_0x2effc0[_0x308f16(0x188)];if(_0x47d70e>=0x190&&_0x47d70e<0x1f4){if(_0x47d70e===0x191)throw new SDKError(ErrorCode[_0x308f16(0x132)],_0x308f16(0x1d3),_0x2effc0);else{if(_0x47d70e===0x193)throw new SDKError(ErrorCode[_0x308f16(0x176)],'Permission\x20denied.\x20Please\x20check\x20your\x20API\x20key\x20has\x20the\x20required\x20permissions\x20for\x20LLM\x20API\x20operations.',_0x2effc0);}throw _0x2effc0;}}if(errorContains(_0x2effc0,_0x308f16(0x169),_0x308f16(0x1eb),_0x308f16(0x185))){_0x14124f++;if(_0x14124f>=_0x28c87b)throw new SDKError(ErrorCode[_0x308f16(0x1da)],_0x308f16(0x18e)+_0x28c87b+_0x308f16(0x120),_0x2effc0);const _0x45dccd=this['getDefaultProjectName']();_0x433289=_0x45dccd+'_'+generateRandomHex();continue;}throw _0x2effc0;}}throw new SDKError(ErrorCode['INTERNAL'],'Failed\x20to\x20get\x20or\x20create\x20agent:\x20exceeded\x20maximum\x20attempts');}async[a71_0x49d5c4(0x1cd)](_0x1221a7,_0x3e7964){const _0x594b91=a71_0x49d5c4,_0x27c268=_0x3e7964||this[_0x594b91(0x13f)],_0x28e6cc=await this[_0x594b91(0x159)][_0x594b91(0x133)](_0x27c268),_0x5b59ea=_0x28e6cc['filter'](_0x310eb4=>_0x310eb4[_0x594b91(0x155)][_0x594b91(0x1b9)]===_0x1221a7);if(_0x5b59ea['length']===0x0){const _0x2986d3=_0x27c268?_0x594b91(0x165)+_0x27c268:'';throw new SDKError(ErrorCode[_0x594b91(0x19c)],_0x594b91(0x1c0)+_0x1221a7+_0x2986d3,undefined,{'helpText':_0x27c268?_0x594b91(0x1a4):_0x594b91(0x1ba)});}if(_0x5b59ea[_0x594b91(0x19f)]>0x1)throw new SDKError(ErrorCode['INTERNAL'],'Multiple\x20agents\x20found\x20with\x20name\x20\x27'+_0x1221a7+'\x27.\x20This\x20should\x20not\x20happen.');return _0x5b59ea[0x0]['id'];}async[a71_0x49d5c4(0x152)](_0x21a778){const _0x452e29=a71_0x49d5c4,_0xa45bc5=_0x21a778||this['currentProjectId'];return await this[_0x452e29(0x159)][_0x452e29(0x133)](_0xa45bc5);}async[a71_0x49d5c4(0x1af)](_0x20ec11){const _0x556995=a71_0x49d5c4;return await this[_0x556995(0x159)][_0x556995(0x1f9)](_0x20ec11);}async[a71_0x49d5c4(0x18f)](_0x39f022){return await this['client']['createAgent'](_0x39f022);}async[a71_0x49d5c4(0x148)](_0x333bb9,_0x5cbbd1){return await this['client']['updateAgent'](_0x333bb9,_0x5cbbd1);}async['deleteAgent'](_0x21086d){const _0x4e98c8=a71_0x49d5c4;await this[_0x4e98c8(0x159)][_0x4e98c8(0x1db)](_0x21086d);}async[a71_0x49d5c4(0x1a2)](_0x385c11){const _0x4615b4=a71_0x49d5c4;return await this[_0x4615b4(0x159)][_0x4615b4(0x1a2)]({'agentId':_0x385c11});}async*[a71_0x49d5c4(0x199)](_0x2a9a69,_0x3410e1){const _0x11475b=a71_0x49d5c4;let _0x50c1a4=_0x3410e1?.[_0x11475b(0x156)];const _0x221a0f=_0x3410e1?.[_0x11475b(0x16d)];if(!_0x50c1a4){if(!_0x221a0f)throw new Error(_0x11475b(0x1e8));const _0x15ea8a=await this[_0x11475b(0x159)][_0x11475b(0x1a2)]({'agentId':_0x221a0f});_0x50c1a4=_0x15ea8a['id'],yield{'type':'metadata','data':{'chatId':_0x50c1a4,'agentId':_0x221a0f}};}for await(const _0xbd5ef4 of this[_0x11475b(0x159)][_0x11475b(0x154)](_0x50c1a4,_0x2a9a69,_0x3410e1?.[_0x11475b(0x15d)])){yield{'type':_0x11475b(0x17e),'data':_0xbd5ef4};}}async[a71_0x49d5c4(0x13e)](_0x44e1e1=0x32){const _0x351363=a71_0x49d5c4;return await this[_0x351363(0x159)]['listChats'](_0x44e1e1);}async[a71_0x49d5c4(0x170)](_0x255d87){const _0x459276=a71_0x49d5c4;return await this[_0x459276(0x159)][_0x459276(0x17a)](_0x255d87);}async['chatInfo'](_0x21059d){const _0x36bdf0=a71_0x49d5c4;return await this[_0x36bdf0(0x159)][_0x36bdf0(0x1dc)](_0x21059d);}async[a71_0x49d5c4(0x131)](_0x192e15,_0x3243a1,_0x5d2a60){const _0x65ca16=a71_0x49d5c4,_0x437272=_0x5d2a60?.[_0x65ca16(0x1ab)]??![],{projectId:_0x4bf625,project:_0x5585e9}=await this['resolveProjectName'](_0x192e15),_0x42c05a=_0x5585e9[_0x65ca16(0x155)]['name'],_0x185805=_0x3243a1||_0x42c05a+_0x65ca16(0x16f);if(a71_0x2553dc[_0x65ca16(0x1f5)](_0x185805)&&!_0x437272)throw new SDKError(ErrorCode[_0x65ca16(0x1da)],_0x65ca16(0x1f1)+_0x185805,undefined,{'helpText':_0x65ca16(0x125)});const _0x2e7441=await this[_0x65ca16(0x159)][_0x65ca16(0x11c)](_0x4bf625),_0x2e51a9=await this['client'][_0x65ca16(0x161)](_0x4bf625),_0x1a0dd1=await this[_0x65ca16(0x159)][_0x65ca16(0x196)](_0x4bf625),_0x570bf4=await this[_0x65ca16(0x159)][_0x65ca16(0x135)](_0x4bf625);if(!_0x437272){a71_0x2553dc[_0x65ca16(0x141)](_0x185805,{'recursive':!![]});const _0x1d3909={'version':_0x65ca16(0x1b7),'exportedAt':new Date()[_0x65ca16(0x15f)](),'exportedFrom':{'site':this[_0x65ca16(0x14c)][_0x65ca16(0x1a7)],'projectId':_0x4bf625,'projectName':_0x42c05a},'project':_0x5585e9};a71_0x2553dc[_0x65ca16(0x175)](a71_0x5c63df[_0x65ca16(0x191)](_0x185805,'project.json'),JSON[_0x65ca16(0x1c3)](_0x1d3909,null,0x2)),a71_0x2553dc['writeFileSync'](a71_0x5c63df[_0x65ca16(0x191)](_0x185805,_0x65ca16(0x192)),JSON[_0x65ca16(0x1c3)](_0x2e7441,null,0x2)),a71_0x2553dc[_0x65ca16(0x175)](a71_0x5c63df[_0x65ca16(0x191)](_0x185805,_0x65ca16(0x1b5)),JSON[_0x65ca16(0x1c3)](_0x2e51a9,null,0x2)),a71_0x2553dc[_0x65ca16(0x175)](a71_0x5c63df[_0x65ca16(0x191)](_0x185805,_0x65ca16(0x1d4)),JSON[_0x65ca16(0x1c3)](_0x1a0dd1,null,0x2)),a71_0x2553dc[_0x65ca16(0x175)](a71_0x5c63df['join'](_0x185805,'integrations.json'),JSON[_0x65ca16(0x1c3)](_0x570bf4,null,0x2));}return{'projectName':_0x42c05a,'outputDir':_0x185805,'counts':{'agents':_0x2e7441[_0x65ca16(0x19f)],'knowledgeBases':_0x2e51a9['length'],'prompts':_0x1a0dd1[_0x65ca16(0x19f)],'integrations':_0x570bf4[_0x65ca16(0x19f)]}};}async['restoreProject'](_0x41b9bd,_0x11fbc2){const _0x308dc6=a71_0x49d5c4,_0x23d825=_0x11fbc2?.[_0x308dc6(0x1ab)]??![],_0x10e74b=this['getBackupMetadata'](_0x41b9bd),_0x5d1e83=_0x10e74b[_0x308dc6(0x180)][_0x308dc6(0x1a7)],_0x4799f9=this[_0x308dc6(0x14c)][_0x308dc6(0x1a7)],_0xf00b01=_0x5d1e83!==_0x4799f9?_0x5d1e83:undefined,_0x2cb99d=this[_0x308dc6(0x1a9)](a71_0x5c63df[_0x308dc6(0x191)](_0x41b9bd,_0x308dc6(0x192)),[]),_0x5141d4=this[_0x308dc6(0x1a9)](a71_0x5c63df[_0x308dc6(0x191)](_0x41b9bd,_0x308dc6(0x1b5)),[]),_0x2902db=this['loadJsonFile'](a71_0x5c63df[_0x308dc6(0x191)](_0x41b9bd,_0x308dc6(0x1d4)),[]),_0x3c5bb9=this[_0x308dc6(0x1a9)](a71_0x5c63df[_0x308dc6(0x191)](_0x41b9bd,_0x308dc6(0x1c4)),[]),_0x3eb775=_0x11fbc2?.[_0x308dc6(0x1b9)]||_0x10e74b[_0x308dc6(0x180)][_0x308dc6(0x1d5)];if(_0x23d825){const _0x52a985=new Map(),_0x272a9d=[..._0x2cb99d],_0x2ce329=_0x2cb99d[_0x308dc6(0x19f)]+0x1;let _0x78b0ac=0x0;while(_0x272a9d[_0x308dc6(0x19f)]>0x0&&_0x78b0ac<_0x2ce329){_0x78b0ac++;const _0x5ba009=[];for(const _0x5b9674 of _0x272a9d){canCreateAgent(_0x5b9674,_0x52a985)?_0x52a985[_0x308dc6(0x197)](_0x5b9674['id'],_0x308dc6(0x1a8)+_0x5b9674['id']):_0x5ba009['push'](_0x5b9674);}if(_0x5ba009['length']===_0x272a9d['length'])throw new SDKError(ErrorCode[_0x308dc6(0x1e9)],'Circular\x20dependency\x20detected\x20in\x20agents.\x20Cannot\x20restore.',undefined,{'helpText':_0x308dc6(0x149)});_0x272a9d[_0x308dc6(0x19f)]=0x0,_0x272a9d[_0x308dc6(0x1c6)](..._0x5ba009);}const _0x1f8020=_0x2902db[_0x308dc6(0x1b1)](_0x3fe978=>_0x52a985[_0x308dc6(0x1ac)](_0x3fe978['attributes'][_0x308dc6(0x16d)]))['length'];return{'projectName':_0x3eb775,'projectId':_0x308dc6(0x11f),'counts':{'agents':_0x2cb99d[_0x308dc6(0x19f)],'knowledgeBases':_0x5141d4[_0x308dc6(0x19f)],'prompts':_0x1f8020,'integrations':_0x3c5bb9[_0x308dc6(0x19f)]},'sourceSite':_0xf00b01};}const _0x3eb905=await this['client'][_0x308dc6(0x1e7)]({'name':_0x3eb775,'description':_0x10e74b[_0x308dc6(0x179)]['attributes']['description']}),_0x9f0e3f=_0x3eb905['id'],_0x26960d=new Map(),_0xdcc5f6=new Map(),_0x417d87=new Map();for(const _0x2891dd of _0x5141d4){const _0x5ae64d=await this[_0x308dc6(0x159)][_0x308dc6(0x1df)]({'projectId':_0x9f0e3f,'name':_0x2891dd[_0x308dc6(0x155)][_0x308dc6(0x1b9)],'tdDatabaseName':_0x2891dd[_0x308dc6(0x155)][_0x308dc6(0x13b)],'tables':_0x2891dd[_0x308dc6(0x155)]['tables']});_0x26960d[_0x308dc6(0x197)](_0x2891dd['id'],_0x5ae64d['id']);}const _0x44ed8e=[..._0x2cb99d],_0x34c267=_0x2cb99d['length']+0x1;let _0x73c526=0x0;while(_0x44ed8e[_0x308dc6(0x19f)]>0x0&&_0x73c526<_0x34c267){_0x73c526++;const _0x162ab7=[];for(const _0xfab573 of _0x44ed8e){if(canCreateAgent(_0xfab573,_0xdcc5f6)){const _0x52f653=remapToolIds(_0xfab573[_0x308dc6(0x155)]['tools'],_0x26960d,_0xdcc5f6),_0x230bfb=remapVariableIds(_0xfab573[_0x308dc6(0x155)][_0x308dc6(0x194)],_0x26960d),_0x4307bc=await this[_0x308dc6(0x159)][_0x308dc6(0x19b)]({'name':_0xfab573[_0x308dc6(0x155)][_0x308dc6(0x1b9)],'projectId':_0x9f0e3f,'systemPrompt':_0xfab573[_0x308dc6(0x155)][_0x308dc6(0x12a)],'starterMessage':_0xfab573[_0x308dc6(0x155)][_0x308dc6(0x130)],'modelType':migrateModelType(_0xfab573[_0x308dc6(0x155)]['modelType']),'maxToolIterations':_0xfab573['attributes'][_0x308dc6(0x1f3)],'temperature':_0xfab573['attributes'][_0x308dc6(0x151)],'reasoningEffort':_0xfab573[_0x308dc6(0x155)][_0x308dc6(0x1fa)],'outputs':_0xfab573[_0x308dc6(0x155)]['outputs'],'tools':_0x52f653,'variables':_0x230bfb});_0xdcc5f6['set'](_0xfab573['id'],_0x4307bc['id']);}else _0x162ab7[_0x308dc6(0x1c6)](_0xfab573);}if(_0x162ab7[_0x308dc6(0x19f)]===_0x44ed8e['length'])throw new SDKError(ErrorCode[_0x308dc6(0x1e9)],'Circular\x20dependency\x20detected\x20in\x20agents.\x20Cannot\x20restore.',undefined,{'helpText':_0x308dc6(0x149)});_0x44ed8e['length']=0x0,_0x44ed8e['push'](..._0x162ab7);}for(const _0x5b789e of _0x2902db){const _0x49e45a=_0xdcc5f6[_0x308dc6(0x174)](_0x5b789e['attributes'][_0x308dc6(0x16d)]);if(!_0x49e45a)continue;const _0x38a152=await this[_0x308dc6(0x159)][_0x308dc6(0x138)]({'projectId':_0x9f0e3f,'agentId':_0x49e45a,'name':_0x5b789e['attributes'][_0x308dc6(0x1b9)],'systemPrompt':_0x5b789e[_0x308dc6(0x155)][_0x308dc6(0x12a)],'template':_0x5b789e[_0x308dc6(0x155)][_0x308dc6(0x1fd)],'jsonSchemaHint':_0x5b789e[_0x308dc6(0x155)]['jsonSchemaHint']});_0x417d87[_0x308dc6(0x197)](_0x5b789e['id'],_0x38a152['id']);}for(const _0x20e455 of _0x3c5bb9){const _0x2b6459=_0x20e455[_0x308dc6(0x155)]['actions'][_0x308dc6(0x177)](_0x416f3a=>({..._0x416f3a,'promptId':_0x417d87[_0x308dc6(0x174)](_0x416f3a[_0x308dc6(0x162)])||_0x416f3a['promptId']}));await this[_0x308dc6(0x159)][_0x308dc6(0x1e4)]({'projectId':_0x9f0e3f,'serviceType':_0x20e455[_0x308dc6(0x155)][_0x308dc6(0x157)],'actions':_0x2b6459,'slackMessageMode':_0x20e455[_0x308dc6(0x155)][_0x308dc6(0x1ca)],'chatIgnoreManagedActions':_0x20e455['attributes'][_0x308dc6(0x17f)],'chatWelcomeMessage':_0x20e455[_0x308dc6(0x155)][_0x308dc6(0x172)],'webhookCorsOrigins':_0x20e455['attributes'][_0x308dc6(0x14b)]});}return{'projectName':_0x3eb775,'projectId':_0x9f0e3f,'counts':{'agents':_0xdcc5f6['size'],'knowledgeBases':_0x26960d['size'],'prompts':_0x417d87['size'],'integrations':_0x3c5bb9[_0x308dc6(0x19f)]},'sourceSite':_0xf00b01};}['loadJsonFile'](_0x160e6f,_0x3ee639){const _0x385cd6=a71_0x49d5c4;if(!a71_0x2553dc[_0x385cd6(0x1f5)](_0x160e6f))return _0x3ee639;return JSON[_0x385cd6(0x1ea)](a71_0x2553dc[_0x385cd6(0x12c)](_0x160e6f,_0x385cd6(0x17d)));}[a71_0x49d5c4(0x1f0)](_0x3225b4){const _0x307c6b=a71_0x49d5c4;if(!a71_0x2553dc[_0x307c6b(0x1f5)](_0x3225b4))throw new SDKError(ErrorCode['NOT_FOUND'],_0x307c6b(0x1e6)+_0x3225b4,undefined,{'helpText':_0x307c6b(0x1ef)});const _0x2afd5b=a71_0x5c63df[_0x307c6b(0x191)](_0x3225b4,'project.json');if(!a71_0x2553dc[_0x307c6b(0x1f5)](_0x2afd5b))throw new SDKError(ErrorCode[_0x307c6b(0x186)],_0x307c6b(0x16e)+_0x3225b4,undefined,{'helpText':_0x307c6b(0x1c8)});const _0x1b4b32=JSON[_0x307c6b(0x1ea)](a71_0x2553dc[_0x307c6b(0x12c)](_0x2afd5b,'utf-8'));if(!isSupportedBackupVersion(_0x1b4b32[_0x307c6b(0x143)]))throw new SDKError(ErrorCode[_0x307c6b(0x186)],_0x307c6b(0x1e1)+_0x1b4b32['version'],undefined,{'helpText':_0x307c6b(0x1d0)});return _0x1b4b32;}async[a71_0x49d5c4(0x1e0)](_0xeabb41,_0x5aeb50,_0x882d08){const _0x5a6947=a71_0x49d5c4,{projectId:_0x149b81,project:_0xa9cad5}=await this[_0x5a6947(0x15c)](_0xeabb41),_0x56079e=_0xa9cad5[_0x5a6947(0x155)][_0x5a6947(0x1b9)],_0x4a4862=normalizeName(_0x56079e),_0x8b8d0=_0x5aeb50||a71_0x5c63df[_0x5a6947(0x191)](process[_0x5a6947(0x1b2)](),_0x5a6947(0x152),_0x4a4862),_0x24a324=await this[_0x5a6947(0x159)][_0x5a6947(0x11c)](_0x149b81),_0x106366=await this[_0x5a6947(0x159)][_0x5a6947(0x161)](_0x149b81),_0x1205f5=await this[_0x5a6947(0x159)][_0x5a6947(0x1ae)](_0x149b81),_0x41e0c8=await this['client']['listImageGenerators'](_0x149b81),_0x32c554=await this[_0x5a6947(0x159)][_0x5a6947(0x1f8)](_0x149b81),_0x5b7b58=await this[_0x5a6947(0x159)][_0x5a6947(0x196)](_0x149b81),_0x2ff4be=new Map(),_0x563331=new Map(),_0x274a01=new Map(),_0x2bed0c=new Map(),_0x13b15=new Map(),_0x5453d1=new Map();for(const _0x3251f5 of _0x24a324){_0x2ff4be[_0x5a6947(0x197)](_0x3251f5['id'],_0x3251f5[_0x5a6947(0x155)][_0x5a6947(0x1b9)]);}for(const _0x4b1ddf of _0x106366){_0x563331[_0x5a6947(0x197)](_0x4b1ddf['id'],_0x4b1ddf[_0x5a6947(0x155)]['name']);}for(const _0x1d0592 of _0x1205f5){_0x274a01[_0x5a6947(0x197)](_0x1d0592['id'],_0x1d0592[_0x5a6947(0x155)][_0x5a6947(0x1b9)]);}for(const _0x3f8a5f of _0x41e0c8){_0x2bed0c[_0x5a6947(0x197)](_0x3f8a5f['id'],_0x3f8a5f[_0x5a6947(0x155)]['name']);}for(const _0x325d06 of _0x32c554){_0x13b15[_0x5a6947(0x197)](_0x325d06['id'],_0x325d06[_0x5a6947(0x155)][_0x5a6947(0x1b9)]);}for(const _0x319921 of _0x5b7b58){_0x5453d1[_0x5a6947(0x197)](_0x319921['id'],_0x319921[_0x5a6947(0x155)]['name']);}const _0x4385d5={'resolveKnowledgeBaseName':async _0x2a67a6=>_0x563331[_0x5a6947(0x174)](_0x2a67a6),'resolveTextKnowledgeBaseName':async _0x16b42d=>_0x274a01[_0x5a6947(0x174)](_0x16b42d),'resolveAgentName':async _0x4a33a6=>_0x2ff4be[_0x5a6947(0x174)](_0x4a33a6),'resolveWebSearchToolName':async _0x1ef6c9=>_0x13b15[_0x5a6947(0x174)](_0x1ef6c9),'resolveImageGeneratorName':async _0x1f8ae5=>_0x2bed0c[_0x5a6947(0x174)](_0x1f8ae5),'resolvePromptName':async _0x1b0bd1=>_0x5453d1[_0x5a6947(0x174)](_0x1b0bd1),'onWarning':_0xe190b3=>this[_0x5a6947(0x14c)][_0x5a6947(0x11b)]?.[_0x5a6947(0x1d6)](_0xe190b3)},_0x35f6ef={'projectName':_0x56079e,'outputDir':_0x8b8d0,'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}}},_0xc81216=[],_0x45fc54=new UniqueNameGenerator(),_0x57c0dc=new UniqueNameGenerator(),_0xbba9d4=new UniqueNameGenerator(),_0x1661cf=new UniqueNameGenerator();for(const _0x209373 of _0x24a324){const _0x11b9ba=_0x45fc54['getUniqueName'](_0x209373[_0x5a6947(0x155)][_0x5a6947(0x1b9)]),_0x491386=a71_0x5c63df[_0x5a6947(0x191)](_0x8b8d0,_0x11b9ba),_0x46a5f0=a71_0x5c63df[_0x5a6947(0x191)](_0x491386,'prompt.md'),_0x1245e9=a71_0x5c63df[_0x5a6947(0x191)](_0x491386,'agent.yml'),_0x54344d=a71_0x5c63df[_0x5a6947(0x191)](_0x491386,_0x5a6947(0x123)),{yaml:_0x457780,systemPrompt:_0x10efa6,starterMessage:_0x3e34bb}=await apiAgentToYaml(_0x209373,_0x4385d5),_0xaa1ed8=toAgentYamlString(_0x457780),_0x1e0a2d=!a71_0x2553dc[_0x5a6947(0x1f5)](_0x1245e9);let _0x15d85a=_0x1e0a2d,_0x499047;if(!_0x1e0a2d){const _0x218c0d=a71_0x2553dc['existsSync'](_0x46a5f0)?a71_0x2553dc[_0x5a6947(0x12c)](_0x46a5f0,_0x5a6947(0x17d)):'',_0x35f10d=a71_0x2553dc['readFileSync'](_0x1245e9,_0x5a6947(0x17d)),_0x276223=_0x5a6947(0x18c)+_0x218c0d+_0x5a6947(0x11d)+_0x35f10d,_0x29b75b=_0x5a6947(0x18c)+_0x10efa6+_0x5a6947(0x11d)+_0xaa1ed8,_0x35ae2d=generateDiff(_0x276223,_0x29b75b);_0x15d85a=hasChanges(_0x35ae2d),_0x15d85a&&(_0x499047=formatDiffWithColors(_0x35ae2d));}_0xc81216['push']({'path':_0x491386,'content':'','isDir':!![]}),_0xc81216[_0x5a6947(0x1c6)]({'path':_0x46a5f0,'content':_0x10efa6}),_0xc81216[_0x5a6947(0x1c6)]({'path':_0x1245e9,'content':_0xaa1ed8});_0x3e34bb&&_0x3e34bb[_0x5a6947(0x168)]('\x0a')&&_0xc81216[_0x5a6947(0x1c6)]({'path':_0x54344d,'content':_0x3e34bb});_0x35f6ef[_0x5a6947(0x152)][_0x5a6947(0x1c6)]({'agentName':_0x209373['attributes'][_0x5a6947(0x1b9)],'outputPath':_0x491386,'isNew':_0x1e0a2d,'hasChanges':_0x15d85a,'diff':_0x499047}),_0x35f6ef[_0x5a6947(0x137)][_0x5a6947(0x152)]['total']++;if(_0x1e0a2d)_0x35f6ef[_0x5a6947(0x137)][_0x5a6947(0x152)][_0x5a6947(0x1f4)]++;else{if(_0x15d85a)_0x35f6ef[_0x5a6947(0x137)][_0x5a6947(0x152)][_0x5a6947(0x1aa)]++;else _0x35f6ef['counts'][_0x5a6947(0x152)][_0x5a6947(0x14e)]++;}}for(const _0x55e84e of _0x106366){if(_0x55e84e['attributes'][_0x5a6947(0x1ed)])continue;const _0x17b96e=_0x57c0dc[_0x5a6947(0x12d)](_0x55e84e['attributes'][_0x5a6947(0x1b9)]),_0x4fc716=a71_0x5c63df[_0x5a6947(0x191)](getKnowledgeBasesDir(_0x8b8d0),_0x17b96e+_0x5a6947(0x1b6)),_0x40ae95=apiKnowledgeBaseToYaml(_0x55e84e),_0x48f567=toKnowledgeBaseYamlString(_0x40ae95),_0x3806f5=!a71_0x2553dc['existsSync'](_0x4fc716);let _0x16b19a=_0x3806f5,_0x291516;if(!_0x3806f5){const _0x45335f=a71_0x2553dc[_0x5a6947(0x12c)](_0x4fc716,_0x5a6947(0x17d)),_0x266c96=generateDiff(_0x45335f,_0x48f567);_0x16b19a=hasChanges(_0x266c96),_0x16b19a&&(_0x291516=formatDiffWithColors(_0x266c96));}_0xc81216[_0x5a6947(0x1c6)]({'path':_0x4fc716,'content':_0x48f567}),_0x35f6ef[_0x5a6947(0x17b)]['push']({'name':_0x55e84e[_0x5a6947(0x155)][_0x5a6947(0x1b9)],'outputPath':_0x4fc716,'isNew':_0x3806f5,'hasChanges':_0x16b19a,'diff':_0x291516}),_0x35f6ef[_0x5a6947(0x137)]['knowledgeBases'][_0x5a6947(0x144)]++;if(_0x3806f5)_0x35f6ef[_0x5a6947(0x137)][_0x5a6947(0x17b)][_0x5a6947(0x1f4)]++;else{if(_0x16b19a)_0x35f6ef[_0x5a6947(0x137)][_0x5a6947(0x17b)]['updated']++;else _0x35f6ef[_0x5a6947(0x137)][_0x5a6947(0x17b)][_0x5a6947(0x14e)]++;}}for(const _0x1dc071 of _0x1205f5){if(_0x1dc071['attributes'][_0x5a6947(0x1ed)])continue;const _0x312ee9=_0xbba9d4[_0x5a6947(0x12d)](_0x1dc071[_0x5a6947(0x155)][_0x5a6947(0x1b9)]),_0x53208a=a71_0x5c63df[_0x5a6947(0x191)](getKnowledgeBasesDir(_0x8b8d0),_0x312ee9+_0x5a6947(0x1a0)),_0x2b7f20=toTextKnowledgeBaseMd(_0x1dc071[_0x5a6947(0x155)][_0x5a6947(0x1b9)],_0x1dc071[_0x5a6947(0x155)][_0x5a6947(0x1a1)]),_0x54e728=!a71_0x2553dc[_0x5a6947(0x1f5)](_0x53208a);let _0xbc9616=_0x54e728,_0x4272f3;if(!_0x54e728){const _0xfdb8dd=a71_0x2553dc[_0x5a6947(0x12c)](_0x53208a,_0x5a6947(0x17d)),_0x37802b=generateDiff(_0xfdb8dd,_0x2b7f20);_0xbc9616=hasChanges(_0x37802b),_0xbc9616&&(_0x4272f3=formatDiffWithColors(_0x37802b));}_0xc81216[_0x5a6947(0x1c6)]({'path':_0x53208a,'content':_0x2b7f20}),_0x35f6ef['textKnowledgeBases'][_0x5a6947(0x1c6)]({'name':_0x1dc071[_0x5a6947(0x155)][_0x5a6947(0x1b9)],'outputPath':_0x53208a,'isNew':_0x54e728,'hasChanges':_0xbc9616,'diff':_0x4272f3}),_0x35f6ef[_0x5a6947(0x137)][_0x5a6947(0x153)]['total']++;if(_0x54e728)_0x35f6ef['counts'][_0x5a6947(0x153)][_0x5a6947(0x1f4)]++;else{if(_0xbc9616)_0x35f6ef[_0x5a6947(0x137)]['textKnowledgeBases'][_0x5a6947(0x1aa)]++;else _0x35f6ef[_0x5a6947(0x137)]['textKnowledgeBases'][_0x5a6947(0x14e)]++;}}for(const _0x871737 of _0x5b7b58){if(_0x871737[_0x5a6947(0x155)][_0x5a6947(0x1ed)])continue;const _0x62c556=_0x1661cf[_0x5a6947(0x12d)](_0x871737['attributes'][_0x5a6947(0x1b9)]),_0xa3d062=a71_0x5c63df[_0x5a6947(0x191)](getPromptsDir(_0x8b8d0),_0x62c556+'.yml'),_0x22fff6=await apiPromptToYaml(_0x871737,_0x4385d5);if(!_0x22fff6)continue;const _0x46221d=toPromptYamlString(_0x22fff6),_0x3e2904=!a71_0x2553dc[_0x5a6947(0x1f5)](_0xa3d062);let _0x28d5e9=_0x3e2904,_0x40fd06;if(!_0x3e2904){const _0x3f932f=a71_0x2553dc['readFileSync'](_0xa3d062,_0x5a6947(0x17d)),_0x28d075=generateDiff(_0x3f932f,_0x46221d);_0x28d5e9=hasChanges(_0x28d075),_0x28d5e9&&(_0x40fd06=formatDiffWithColors(_0x28d075));}_0xc81216[_0x5a6947(0x1c6)]({'path':_0xa3d062,'content':_0x46221d}),_0x35f6ef[_0x5a6947(0x19e)]['push']({'name':_0x871737[_0x5a6947(0x155)][_0x5a6947(0x1b9)],'outputPath':_0xa3d062,'isNew':_0x3e2904,'hasChanges':_0x28d5e9,'diff':_0x40fd06}),_0x35f6ef[_0x5a6947(0x137)][_0x5a6947(0x19e)][_0x5a6947(0x144)]++;if(_0x3e2904)_0x35f6ef[_0x5a6947(0x137)][_0x5a6947(0x19e)][_0x5a6947(0x1f4)]++;else{if(_0x28d5e9)_0x35f6ef[_0x5a6947(0x137)][_0x5a6947(0x19e)][_0x5a6947(0x1aa)]++;else _0x35f6ef['counts'][_0x5a6947(0x19e)][_0x5a6947(0x14e)]++;}}if(_0x882d08?.[_0x5a6947(0x1ab)])return _0x35f6ef;a71_0x2553dc[_0x5a6947(0x141)](_0x8b8d0,{'recursive':!![]}),a71_0x2553dc['mkdirSync'](getKnowledgeBasesDir(_0x8b8d0),{'recursive':!![]}),a71_0x2553dc[_0x5a6947(0x141)](getPromptsDir(_0x8b8d0),{'recursive':!![]});const _0x960d57=a71_0x5c63df[_0x5a6947(0x191)](_0x8b8d0,'tdx.json');a71_0x2553dc[_0x5a6947(0x175)](_0x960d57,createAgentConfigContent(_0x56079e));for(const _0x302f3e of _0xc81216){if(_0x302f3e[_0x5a6947(0x1cc)])a71_0x2553dc[_0x5a6947(0x141)](_0x302f3e[_0x5a6947(0x1ec)],{'recursive':!![]});else{const _0x57281b=a71_0x5c63df[_0x5a6947(0x17c)](_0x302f3e[_0x5a6947(0x1ec)]);!a71_0x2553dc[_0x5a6947(0x1f5)](_0x57281b)&&a71_0x2553dc[_0x5a6947(0x141)](_0x57281b,{'recursive':!![]}),a71_0x2553dc[_0x5a6947(0x175)](_0x302f3e[_0x5a6947(0x1ec)],_0x302f3e[_0x5a6947(0x124)]);}}return _0x35f6ef;}async[a71_0x49d5c4(0x1bb)](_0x133681,_0x2ef705){const _0x4eb516=a71_0x49d5c4,_0x7c792=a71_0x5c63df['join'](_0x133681,_0x4eb516(0x1c9));if(!a71_0x2553dc['existsSync'](_0x7c792))throw new SDKError(ErrorCode[_0x4eb516(0x186)],_0x4eb516(0x1c1)+_0x133681,undefined,{'helpText':_0x4eb516(0x1bc)});const _0x462313=loadAgentConfig(_0x7c792),_0x338133=await this[_0x4eb516(0x163)](_0x462313['llm_project']),_0x5be2b7=await this['client'][_0x4eb516(0x167)](_0x338133),_0x5044f3=_0x5be2b7[_0x4eb516(0x155)]['name'],_0x38d3b1={'projectName':_0x5044f3,'projectId':_0x338133,'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}}},_0x50dcf2=[],_0x171668=[],_0x4bf20a=[],_0x4c5f5a=[],_0x5ba2ca=a71_0x2553dc[_0x4eb516(0x150)](_0x133681,{'withFileTypes':!![]});for(const _0x50a9b4 of _0x5ba2ca){if(!_0x50a9b4[_0x4eb516(0x1b4)]())continue;if([_0x4eb516(0x14d),_0x4eb516(0x19e),_0x4eb516(0x1d8)]['includes'](_0x50a9b4[_0x4eb516(0x1b9)]))continue;const _0x1106e6=a71_0x5c63df['join'](_0x133681,_0x50a9b4[_0x4eb516(0x1b9)]);if(isAgentDir(_0x1106e6)){const _0x312ebf=a71_0x5c63df[_0x4eb516(0x191)](_0x1106e6,_0x4eb516(0x1ee)),_0x44abc4=a71_0x5c63df[_0x4eb516(0x191)](_0x1106e6,_0x4eb516(0x134)),_0x13b3b3=a71_0x5c63df[_0x4eb516(0x191)](_0x1106e6,_0x4eb516(0x123)),_0x5a8326=parseAgentYaml(a71_0x2553dc[_0x4eb516(0x12c)](_0x312ebf,_0x4eb516(0x17d)),_0x312ebf),_0x3be74e=a71_0x2553dc[_0x4eb516(0x1f5)](_0x44abc4)?a71_0x2553dc['readFileSync'](_0x44abc4,'utf-8'):'',_0x305d86=a71_0x2553dc['existsSync'](_0x13b3b3)?a71_0x2553dc[_0x4eb516(0x12c)](_0x13b3b3,'utf-8'):_0x5a8326[_0x4eb516(0x12e)];_0x50dcf2[_0x4eb516(0x1c6)]({'name':_0x5a8326[_0x4eb516(0x1b9)],'dir':_0x1106e6,'yaml':_0x5a8326,'systemPrompt':_0x3be74e,'starterMessage':_0x305d86});}}const _0x26e0d9=getKnowledgeBasesDir(_0x133681);if(a71_0x2553dc[_0x4eb516(0x1f5)](_0x26e0d9)){const _0x361834=a71_0x2553dc[_0x4eb516(0x150)](_0x26e0d9);for(const _0x2ef566 of _0x361834){const _0x4dabad=a71_0x5c63df[_0x4eb516(0x191)](_0x26e0d9,_0x2ef566);if(_0x2ef566[_0x4eb516(0x16c)](_0x4eb516(0x1b6))){const _0x5a0d98=parseKnowledgeBaseYaml(a71_0x2553dc[_0x4eb516(0x12c)](_0x4dabad,_0x4eb516(0x17d)),_0x4dabad);_0x171668[_0x4eb516(0x1c6)]({'name':_0x5a0d98[_0x4eb516(0x1b9)],'path':_0x4dabad,'yaml':_0x5a0d98});}else{if(_0x2ef566['endsWith']('.md')){const _0x217dcc=a71_0x2553dc['readFileSync'](_0x4dabad,_0x4eb516(0x17d)),{name:_0x19d68e,text:_0x4b7337}=parseTextKnowledgeBaseMd(_0x217dcc,_0x2ef566);_0x4bf20a[_0x4eb516(0x1c6)]({'name':_0x19d68e,'path':_0x4dabad,'text':_0x4b7337});}}}}const _0x21876c=getPromptsDir(_0x133681);if(a71_0x2553dc[_0x4eb516(0x1f5)](_0x21876c)){const _0x52a5a0=a71_0x2553dc['readdirSync'](_0x21876c)[_0x4eb516(0x1b1)](_0x19f5d5=>_0x19f5d5[_0x4eb516(0x16c)](_0x4eb516(0x1b6)));for(const _0x58abd9 of _0x52a5a0){const _0x5b63c1=a71_0x5c63df[_0x4eb516(0x191)](_0x21876c,_0x58abd9),_0x1050a1=parsePromptYaml(a71_0x2553dc['readFileSync'](_0x5b63c1,_0x4eb516(0x17d)),_0x5b63c1);_0x4c5f5a[_0x4eb516(0x1c6)]({'name':_0x1050a1['name'],'path':_0x5b63c1,'yaml':_0x1050a1});}}const _0x307fb4=await this['client'][_0x4eb516(0x11c)](_0x338133),_0x609f55=await this['client'][_0x4eb516(0x161)](_0x338133),_0x365087=await this[_0x4eb516(0x159)][_0x4eb516(0x1ae)](_0x338133),_0xc22daf=await this[_0x4eb516(0x159)][_0x4eb516(0x171)](_0x338133),_0x545a31=await this[_0x4eb516(0x159)]['listWebSearchTools'](_0x338133),_0x4fea15=await this[_0x4eb516(0x159)]['listPrompts'](_0x338133),_0x3c2749=new Map(),_0x51cb80=new Map(),_0x5639b6=new Map(),_0x2423e0=new Map();for(const _0xa97de3 of _0x307fb4){_0x3c2749['set'](_0xa97de3[_0x4eb516(0x155)][_0x4eb516(0x1b9)],_0xa97de3);}for(const _0x3c73f9 of _0x609f55){_0x51cb80[_0x4eb516(0x197)](_0x3c73f9[_0x4eb516(0x155)]['name'],_0x3c73f9);}for(const _0xa1da2 of _0x365087){_0x5639b6['set'](_0xa1da2[_0x4eb516(0x155)][_0x4eb516(0x1b9)],_0xa1da2);}for(const _0x2ceed6 of _0x4fea15){_0x2423e0['set'](_0x2ceed6[_0x4eb516(0x155)][_0x4eb516(0x1b9)],_0x2ceed6);}const _0x29835c=new Map(),_0x21428b=new Map(),_0x37b80e=new Map(),_0x3daabe=new Map(),_0x21fa68=new Map(),_0x2c872a=new Map(),_0x50c6ef=new Map(),_0x35b93e=new Map(),_0x3aa641=new Map(),_0x54ca04=new Map(),_0x5676dd=new Map(),_0x4d38d5=new Map();for(const _0x37ce63 of _0x609f55){_0x29835c[_0x4eb516(0x197)](_0x37ce63[_0x4eb516(0x155)][_0x4eb516(0x1b9)],_0x37ce63['id']),_0x50c6ef[_0x4eb516(0x197)](_0x37ce63['id'],_0x37ce63[_0x4eb516(0x155)]['name']);}for(const _0x47e834 of _0x365087){_0x21428b[_0x4eb516(0x197)](_0x47e834[_0x4eb516(0x155)]['name'],_0x47e834['id']),_0x35b93e[_0x4eb516(0x197)](_0x47e834['id'],_0x47e834['attributes'][_0x4eb516(0x1b9)]);}for(const _0x576b20 of _0x307fb4){_0x37b80e[_0x4eb516(0x197)](_0x576b20['attributes'][_0x4eb516(0x1b9)],_0x576b20['id']),_0x3aa641[_0x4eb516(0x197)](_0x576b20['id'],_0x576b20[_0x4eb516(0x155)]['name']);}for(const _0x5d6475 of _0xc22daf){_0x3daabe[_0x4eb516(0x197)](_0x5d6475['attributes'][_0x4eb516(0x1b9)],_0x5d6475['id']),_0x54ca04[_0x4eb516(0x197)](_0x5d6475['id'],_0x5d6475[_0x4eb516(0x155)][_0x4eb516(0x1b9)]);}for(const _0xa92e32 of _0x545a31){_0x21fa68[_0x4eb516(0x197)](_0xa92e32[_0x4eb516(0x155)]['name'],_0xa92e32['id']),_0x5676dd[_0x4eb516(0x197)](_0xa92e32['id'],_0xa92e32[_0x4eb516(0x155)][_0x4eb516(0x1b9)]);}for(const _0x5a38df of _0x4fea15){_0x2c872a['set'](_0x5a38df[_0x4eb516(0x155)]['name'],_0x5a38df['id']),_0x4d38d5['set'](_0x5a38df['id'],_0x5a38df[_0x4eb516(0x155)]['name']);}const _0xc66f0a={'resolveKnowledgeBaseName':async _0x1ca3f8=>_0x50c6ef['get'](_0x1ca3f8),'resolveTextKnowledgeBaseName':async _0x3cc6c7=>_0x35b93e[_0x4eb516(0x174)](_0x3cc6c7),'resolveAgentName':async _0xb15adc=>_0x3aa641[_0x4eb516(0x174)](_0xb15adc),'resolveWebSearchToolName':async _0x4b45f4=>_0x5676dd[_0x4eb516(0x174)](_0x4b45f4),'resolveImageGeneratorName':async _0x478bbb=>_0x54ca04[_0x4eb516(0x174)](_0x478bbb),'resolvePromptName':async _0xa74ef0=>_0x4d38d5[_0x4eb516(0x174)](_0xa74ef0),'onWarning':_0x59007d=>this[_0x4eb516(0x14c)]['logger']?.['warn'](_0x59007d)},_0x5cf98f={'projectId':_0x338133,'resolveKnowledgeBaseId':async _0x4c4e75=>_0x29835c[_0x4eb516(0x174)](_0x4c4e75),'resolveTextKnowledgeBaseId':async _0x504b4f=>_0x21428b[_0x4eb516(0x174)](_0x504b4f),'resolveAgentId':async _0x58a616=>_0x37b80e[_0x4eb516(0x174)](_0x58a616),'resolveWebSearchToolId':async _0x2fe71d=>_0x21fa68[_0x4eb516(0x174)](_0x2fe71d),'resolveImageGeneratorId':async _0x54934d=>_0x3daabe[_0x4eb516(0x174)](_0x54934d),'resolvePromptId':async _0x2e56e8=>_0x2c872a[_0x4eb516(0x174)](_0x2e56e8),'onWarning':_0x41d2ef=>this['context'][_0x4eb516(0x11b)]?.[_0x4eb516(0x1d6)](_0x41d2ef)},{resolved:_0x578d7e,unresolved:_0x596b42}=resolveAgentDependencies(_0x50dcf2,new Set(_0x3c2749[_0x4eb516(0x127)]()));for(const {agent:_0x59faac,missingDeps:_0x45c6e2}of _0x596b42){_0x38d3b1[_0x4eb516(0x152)][_0x4eb516(0x1c6)]({'agentName':_0x59faac[_0x4eb516(0x181)][_0x4eb516(0x1b9)],'action':_0x4eb516(0x1d9),'error':_0x4eb516(0x164)+_0x45c6e2[_0x4eb516(0x191)](',\x20')+_0x4eb516(0x1a6)}),_0x38d3b1['counts'][_0x4eb516(0x152)]['errors']++;}for(const _0x3e82c7 of _0x171668){const _0x19b395=_0x51cb80[_0x4eb516(0x174)](_0x3e82c7[_0x4eb516(0x181)][_0x4eb516(0x1b9)]),_0x5108a8=a71_0x2553dc[_0x4eb516(0x12c)](_0x3e82c7[_0x4eb516(0x1ec)],_0x4eb516(0x17d));if(_0x19b395){const _0x513779=apiKnowledgeBaseToYaml(_0x19b395),_0x412376=toKnowledgeBaseYamlString(_0x513779),_0x2b1cf4=generateDiff(_0x412376,_0x5108a8),_0x44ebc2=hasChanges(_0x2b1cf4);_0x44ebc2?(_0x38d3b1[_0x4eb516(0x17b)][_0x4eb516(0x1c6)]({'name':_0x3e82c7[_0x4eb516(0x181)][_0x4eb516(0x1b9)],'action':_0x4eb516(0x1aa),'id':_0x19b395['id'],'diff':formatDiffWithColors(_0x2b1cf4)}),_0x38d3b1[_0x4eb516(0x137)]['knowledgeBases'][_0x4eb516(0x1aa)]++):(_0x38d3b1[_0x4eb516(0x17b)][_0x4eb516(0x1c6)]({'name':_0x3e82c7['yaml'][_0x4eb516(0x1b9)],'action':_0x4eb516(0x14e),'id':_0x19b395['id']}),_0x38d3b1[_0x4eb516(0x137)][_0x4eb516(0x17b)]['unchanged']++);}else _0x38d3b1[_0x4eb516(0x17b)]['push']({'name':_0x3e82c7[_0x4eb516(0x181)][_0x4eb516(0x1b9)],'action':_0x4eb516(0x193)}),_0x38d3b1['counts'][_0x4eb516(0x17b)][_0x4eb516(0x193)]++;}for(const _0x3ff462 of _0x4bf20a){const _0x41526a=_0x5639b6['get'](_0x3ff462[_0x4eb516(0x1b9)]),_0x298dd3=a71_0x2553dc['readFileSync'](_0x3ff462[_0x4eb516(0x1ec)],_0x4eb516(0x17d));if(_0x41526a){const _0x7c34bd=toTextKnowledgeBaseMd(_0x41526a['attributes'][_0x4eb516(0x1b9)],_0x41526a[_0x4eb516(0x155)][_0x4eb516(0x1a1)]),_0x4f9fa8=generateDiff(_0x7c34bd,_0x298dd3),_0x462572=hasChanges(_0x4f9fa8);_0x462572?(_0x38d3b1[_0x4eb516(0x153)][_0x4eb516(0x1c6)]({'name':_0x3ff462[_0x4eb516(0x1b9)],'action':'updated','id':_0x41526a['id'],'diff':formatDiffWithColors(_0x4f9fa8)}),_0x38d3b1[_0x4eb516(0x137)][_0x4eb516(0x153)]['updated']++):(_0x38d3b1[_0x4eb516(0x153)]['push']({'name':_0x3ff462[_0x4eb516(0x1b9)],'action':_0x4eb516(0x14e),'id':_0x41526a['id']}),_0x38d3b1[_0x4eb516(0x137)]['textKnowledgeBases']['unchanged']++);}else _0x38d3b1[_0x4eb516(0x153)][_0x4eb516(0x1c6)]({'name':_0x3ff462[_0x4eb516(0x1b9)],'action':_0x4eb516(0x193)}),_0x38d3b1[_0x4eb516(0x137)]['textKnowledgeBases'][_0x4eb516(0x193)]++;}for(const _0x5e706d of _0x578d7e){const _0x36d1d3=_0x3c2749[_0x4eb516(0x174)](_0x5e706d[_0x4eb516(0x181)][_0x4eb516(0x1b9)]),_0x5d56b7=a71_0x5c63df[_0x4eb516(0x191)](_0x5e706d['dir'],'agent.yml'),_0x32f078=a71_0x2553dc[_0x4eb516(0x12c)](_0x5d56b7,_0x4eb516(0x17d)),_0x5a19dc=_0x5e706d[_0x4eb516(0x12a)],_0x3494c2=_0x4eb516(0x18c)+_0x5a19dc+_0x4eb516(0x11d)+_0x32f078;if(_0x36d1d3){const {yaml:_0x32c4f1,systemPrompt:_0x821994}=await apiAgentToYaml(_0x36d1d3,_0xc66f0a),_0x9b88e3=toAgentYamlString(_0x32c4f1),_0x3a0b27=_0x4eb516(0x18c)+_0x821994+'\x0a\x0a#\x20agent.yml\x0a'+_0x9b88e3,_0x498d61=generateDiff(_0x3a0b27,_0x3494c2),_0x2a3f09=hasChanges(_0x498d61);_0x2a3f09?(_0x38d3b1[_0x4eb516(0x152)][_0x4eb516(0x1c6)]({'agentName':_0x5e706d[_0x4eb516(0x181)][_0x4eb516(0x1b9)],'action':_0x4eb516(0x1aa),'agentId':_0x36d1d3['id'],'diff':formatDiffWithColors(_0x498d61)}),_0x38d3b1[_0x4eb516(0x137)][_0x4eb516(0x152)]['updated']++):(_0x38d3b1[_0x4eb516(0x152)][_0x4eb516(0x1c6)]({'agentName':_0x5e706d[_0x4eb516(0x181)][_0x4eb516(0x1b9)],'action':'unchanged','agentId':_0x36d1d3['id']}),_0x38d3b1[_0x4eb516(0x137)][_0x4eb516(0x152)]['unchanged']++);}else _0x38d3b1[_0x4eb516(0x152)][_0x4eb516(0x1c6)]({'agentName':_0x5e706d[_0x4eb516(0x181)][_0x4eb516(0x1b9)],'action':_0x4eb516(0x193)}),_0x38d3b1[_0x4eb516(0x137)]['agents'][_0x4eb516(0x193)]++;}for(const _0x663c5a of _0x4c5f5a){const _0x59fece=_0x2423e0[_0x4eb516(0x174)](_0x663c5a[_0x4eb516(0x181)][_0x4eb516(0x1b9)]),_0x202516=a71_0x2553dc[_0x4eb516(0x12c)](_0x663c5a['path'],_0x4eb516(0x17d));if(_0x59fece){const _0x36f6bb=await apiPromptToYaml(_0x59fece,_0xc66f0a);if(!_0x36f6bb){_0x38d3b1['prompts'][_0x4eb516(0x1c6)]({'name':_0x663c5a[_0x4eb516(0x181)]['name'],'action':_0x4eb516(0x1aa),'id':_0x59fece['id']}),_0x38d3b1['counts']['prompts']['updated']++;continue;}const _0x45c8f8=toPromptYamlString(_0x36f6bb),_0x403af9=generateDiff(_0x45c8f8,_0x202516),_0x562674=hasChanges(_0x403af9);_0x562674?(_0x38d3b1[_0x4eb516(0x19e)][_0x4eb516(0x1c6)]({'name':_0x663c5a[_0x4eb516(0x181)][_0x4eb516(0x1b9)],'action':_0x4eb516(0x1aa),'id':_0x59fece['id'],'diff':formatDiffWithColors(_0x403af9)}),_0x38d3b1[_0x4eb516(0x137)]['prompts']['updated']++):(_0x38d3b1['prompts'][_0x4eb516(0x1c6)]({'name':_0x663c5a[_0x4eb516(0x181)][_0x4eb516(0x1b9)],'action':_0x4eb516(0x14e),'id':_0x59fece['id']}),_0x38d3b1['counts']['prompts'][_0x4eb516(0x14e)]++);}else _0x38d3b1[_0x4eb516(0x19e)][_0x4eb516(0x1c6)]({'name':_0x663c5a[_0x4eb516(0x181)][_0x4eb516(0x1b9)],'action':_0x4eb516(0x193)}),_0x38d3b1['counts'][_0x4eb516(0x19e)][_0x4eb516(0x193)]++;}if(_0x2ef705?.[_0x4eb516(0x1ab)])return _0x38d3b1;_0x38d3b1[_0x4eb516(0x17b)]=[],_0x38d3b1['textKnowledgeBases']=[],_0x38d3b1[_0x4eb516(0x19e)]=[];const _0x1eb249=_0x38d3b1[_0x4eb516(0x152)][_0x4eb516(0x1b1)](_0x355ab5=>_0x355ab5[_0x4eb516(0x146)]==='error');_0x38d3b1[_0x4eb516(0x152)]=_0x1eb249,_0x38d3b1[_0x4eb516(0x137)]={'agents':{'created':0x0,'updated':0x0,'unchanged':0x0,'errors':_0x1eb249[_0x4eb516(0x19f)]},'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 _0x262dec of _0x171668){try{const _0xb29ac2=_0x51cb80['get'](_0x262dec[_0x4eb516(0x181)][_0x4eb516(0x1b9)]),_0x281b79=yamlKnowledgeBaseToApi(_0x262dec['yaml'],_0x338133);if(_0xb29ac2)await this[_0x4eb516(0x159)][_0x4eb516(0x1bf)](_0xb29ac2['id'],_0x281b79),_0x29835c[_0x4eb516(0x197)](_0x262dec[_0x4eb516(0x181)][_0x4eb516(0x1b9)],_0xb29ac2['id']),_0x38d3b1[_0x4eb516(0x17b)]['push']({'name':_0x262dec[_0x4eb516(0x181)][_0x4eb516(0x1b9)],'action':_0x4eb516(0x1aa),'id':_0xb29ac2['id']}),_0x38d3b1[_0x4eb516(0x137)][_0x4eb516(0x17b)][_0x4eb516(0x1aa)]++;else{const _0x4426c1=await this[_0x4eb516(0x159)][_0x4eb516(0x1df)](_0x281b79);_0x29835c[_0x4eb516(0x197)](_0x262dec[_0x4eb516(0x181)][_0x4eb516(0x1b9)],_0x4426c1['id']),_0x38d3b1[_0x4eb516(0x17b)][_0x4eb516(0x1c6)]({'name':_0x262dec['yaml'][_0x4eb516(0x1b9)],'action':'created','id':_0x4426c1['id']}),_0x38d3b1[_0x4eb516(0x137)][_0x4eb516(0x17b)]['created']++;}}catch(_0xf5c71a){_0x38d3b1['knowledgeBases'][_0x4eb516(0x1c6)]({'name':_0x262dec[_0x4eb516(0x181)][_0x4eb516(0x1b9)],'action':_0x4eb516(0x1d9),'error':_0xf5c71a['message']}),_0x38d3b1[_0x4eb516(0x137)][_0x4eb516(0x17b)]['errors']++;}}for(const _0x5c9a32 of _0x4bf20a){try{const _0x4cfbbe=_0x5639b6[_0x4eb516(0x174)](_0x5c9a32['name']),_0x5d77d6=yamlTextKnowledgeBaseToApi({'name':_0x5c9a32['name'],'text':_0x5c9a32[_0x4eb516(0x1a1)]},_0x338133);if(_0x4cfbbe)await this[_0x4eb516(0x159)][_0x4eb516(0x145)](_0x4cfbbe['id'],_0x5d77d6),_0x21428b[_0x4eb516(0x197)](_0x5c9a32[_0x4eb516(0x1b9)],_0x4cfbbe['id']),_0x38d3b1['textKnowledgeBases'][_0x4eb516(0x1c6)]({'name':_0x5c9a32[_0x4eb516(0x1b9)],'action':_0x4eb516(0x1aa),'id':_0x4cfbbe['id']}),_0x38d3b1['counts']['textKnowledgeBases'][_0x4eb516(0x1aa)]++;else{const _0x2eee05=await this[_0x4eb516(0x159)]['createTextKnowledgeBase'](_0x5d77d6);_0x21428b[_0x4eb516(0x197)](_0x5c9a32[_0x4eb516(0x1b9)],_0x2eee05['id']),_0x38d3b1[_0x4eb516(0x153)][_0x4eb516(0x1c6)]({'name':_0x5c9a32[_0x4eb516(0x1b9)],'action':_0x4eb516(0x193),'id':_0x2eee05['id']}),_0x38d3b1[_0x4eb516(0x137)][_0x4eb516(0x153)]['created']++;}}catch(_0x2a4870){_0x38d3b1[_0x4eb516(0x153)][_0x4eb516(0x1c6)]({'name':_0x5c9a32[_0x4eb516(0x1b9)],'action':_0x4eb516(0x1d9),'error':_0x2a4870[_0x4eb516(0x136)]}),_0x38d3b1[_0x4eb516(0x137)]['textKnowledgeBases'][_0x4eb516(0x19d)]++;}}for(const _0x16fa78 of _0x578d7e){try{const _0x1e5f84=_0x3c2749[_0x4eb516(0x174)](_0x16fa78[_0x4eb516(0x181)]['name']),_0x2fbe87=await yamlAgentToApi(_0x16fa78['yaml'],_0x16fa78[_0x4eb516(0x12a)],_0x16fa78[_0x4eb516(0x130)],_0x5cf98f);if(_0x1e5f84)await this[_0x4eb516(0x159)][_0x4eb516(0x1be)](_0x1e5f84['id'],_0x2fbe87),_0x37b80e[_0x4eb516(0x197)](_0x16fa78[_0x4eb516(0x181)]['name'],_0x1e5f84['id']),_0x38d3b1[_0x4eb516(0x152)]['push']({'agentName':_0x16fa78[_0x4eb516(0x181)][_0x4eb516(0x1b9)],'action':_0x4eb516(0x1aa),'agentId':_0x1e5f84['id']}),_0x38d3b1[_0x4eb516(0x137)][_0x4eb516(0x152)][_0x4eb516(0x1aa)]++;else{const _0x4675e7=await this['client'][_0x4eb516(0x19b)](_0x2fbe87);_0x37b80e[_0x4eb516(0x197)](_0x16fa78[_0x4eb516(0x181)][_0x4eb516(0x1b9)],_0x4675e7['id']),_0x38d3b1['agents']['push']({'agentName':_0x16fa78[_0x4eb516(0x181)][_0x4eb516(0x1b9)],'action':'created','agentId':_0x4675e7['id']}),_0x38d3b1[_0x4eb516(0x137)][_0x4eb516(0x152)][_0x4eb516(0x193)]++;}}catch(_0x1f64ad){_0x38d3b1['agents'][_0x4eb516(0x1c6)]({'agentName':_0x16fa78['yaml'][_0x4eb516(0x1b9)],'action':_0x4eb516(0x1d9),'error':_0x1f64ad[_0x4eb516(0x136)]}),_0x38d3b1[_0x4eb516(0x137)][_0x4eb516(0x152)]['errors']++;}}for(const _0x5677ea of _0x4c5f5a){try{const _0x4cd88f=_0x2423e0[_0x4eb516(0x174)](_0x5677ea[_0x4eb516(0x181)][_0x4eb516(0x1b9)]),_0x572568=await yamlPromptToApi(_0x5677ea[_0x4eb516(0x181)],_0x338133,_0x5cf98f);if(!_0x572568){_0x38d3b1['prompts'][_0x4eb516(0x1c6)]({'name':_0x5677ea[_0x4eb516(0x181)]['name'],'action':_0x4eb516(0x1d9),'error':'Agent\x20reference\x20not\x20found'}),_0x38d3b1[_0x4eb516(0x137)][_0x4eb516(0x19e)][_0x4eb516(0x19d)]++;continue;}if(_0x4cd88f)await this['client'][_0x4eb516(0x16a)](_0x4cd88f['id'],_0x572568),_0x2c872a['set'](_0x5677ea[_0x4eb516(0x181)][_0x4eb516(0x1b9)],_0x4cd88f['id']),_0x38d3b1[_0x4eb516(0x19e)]['push']({'name':_0x5677ea[_0x4eb516(0x181)][_0x4eb516(0x1b9)],'action':_0x4eb516(0x1aa),'id':_0x4cd88f['id']}),_0x38d3b1[_0x4eb516(0x137)][_0x4eb516(0x19e)][_0x4eb516(0x1aa)]++;else{const _0x1c82be=await this[_0x4eb516(0x159)][_0x4eb516(0x138)](_0x572568);_0x2c872a['set'](_0x5677ea[_0x4eb516(0x181)][_0x4eb516(0x1b9)],_0x1c82be['id']),_0x38d3b1[_0x4eb516(0x19e)][_0x4eb516(0x1c6)]({'name':_0x5677ea[_0x4eb516(0x181)][_0x4eb516(0x1b9)],'action':_0x4eb516(0x193),'id':_0x1c82be['id']}),_0x38d3b1[_0x4eb516(0x137)]['prompts'][_0x4eb516(0x193)]++;}}catch(_0x502d4e){_0x38d3b1[_0x4eb516(0x19e)][_0x4eb516(0x1c6)]({'name':_0x5677ea['yaml'][_0x4eb516(0x1b9)],'action':_0x4eb516(0x1d9),'error':_0x502d4e[_0x4eb516(0x136)]}),_0x38d3b1[_0x4eb516(0x137)][_0x4eb516(0x19e)][_0x4eb516(0x19d)]++;}}return _0x38d3b1;}async['pullAgent'](_0x549f00,_0x5c313f,_0x1c27de,_0x16438d){const _0x14ad13=a71_0x49d5c4,{projectId:_0xc14996,project:_0x651f2}=await this['resolveProjectName'](_0x549f00),_0x47c9ea=_0x651f2['attributes'][_0x14ad13(0x1b9)],_0x301f99=await this[_0x14ad13(0x159)][_0x14ad13(0x11c)](_0xc14996),_0x232c96=_0x301f99[_0x14ad13(0x166)](_0x3e41d0=>_0x3e41d0[_0x14ad13(0x155)][_0x14ad13(0x1b9)]===_0x5c313f);if(!_0x232c96)throw new SDKError(ErrorCode['AGENT_NOT_FOUND'],_0x14ad13(0x1c0)+_0x5c313f,undefined,{'helpText':_0x14ad13(0x128)+_0x301f99[_0x14ad13(0x177)](_0x49729c=>_0x49729c['attributes'][_0x14ad13(0x1b9)])[_0x14ad13(0x191)](',\x20')});const _0x48e997=normalizeName(_0x47c9ea),_0x48d405=normalizeName(_0x5c313f),_0x5c238c=_0x1c27de||a71_0x5c63df[_0x14ad13(0x191)](process['cwd'](),_0x14ad13(0x152),_0x48e997),_0x29bf33=a71_0x5c63df[_0x14ad13(0x191)](_0x5c238c,_0x48d405),_0x4f4fb4=new Map(),_0x2f5dba=new Map(),_0x8813b3=await this['client']['listKnowledgeBases'](_0xc14996),_0x56a788=await this[_0x14ad13(0x159)][_0x14ad13(0x1ae)](_0xc14996),_0x36d886=new Map();for(const _0x4f455b of _0x8813b3){_0x4f4fb4[_0x14ad13(0x197)](_0x4f455b['id'],_0x4f455b[_0x14ad13(0x155)][_0x14ad13(0x1b9)]);}for(const _0x2cb6ee of _0x56a788){_0x36d886[_0x14ad13(0x197)](_0x2cb6ee['id'],_0x2cb6ee[_0x14ad13(0x155)][_0x14ad13(0x1b9)]);}for(const _0x520883 of _0x301f99){_0x2f5dba[_0x14ad13(0x197)](_0x520883['id'],_0x520883[_0x14ad13(0x155)][_0x14ad13(0x1b9)]);}const _0x35fc2c={'resolveKnowledgeBaseName':async _0x153965=>_0x4f4fb4['get'](_0x153965),'resolveTextKnowledgeBaseName':async _0x1c6a6c=>_0x36d886[_0x14ad13(0x174)](_0x1c6a6c),'resolveAgentName':async _0x3b959e=>_0x2f5dba[_0x14ad13(0x174)](_0x3b959e),'resolveWebSearchToolName':async()=>undefined,'resolveImageGeneratorName':async()=>undefined,'resolvePromptName':async()=>undefined,'onWarning':_0x8a37bf=>this[_0x14ad13(0x14c)]['logger']?.[_0x14ad13(0x1d6)](_0x8a37bf)},_0x4c6f4a=a71_0x5c63df['join'](_0x29bf33,_0x14ad13(0x134)),_0x4d87e6=a71_0x5c63df[_0x14ad13(0x191)](_0x29bf33,_0x14ad13(0x1ee)),_0x28b5eb=a71_0x5c63df[_0x14ad13(0x191)](_0x29bf33,'starter_message.md'),_0x25fe3e=!a71_0x2553dc[_0x14ad13(0x1f5)](_0x4d87e6);if(_0x16438d?.[_0x14ad13(0x1ab)])return{'agentName':_0x5c313f,'outputPath':_0x29bf33,'isNew':_0x25fe3e,'hasChanges':!![]};a71_0x2553dc['mkdirSync'](_0x5c238c,{'recursive':!![]}),a71_0x2553dc[_0x14ad13(0x141)](_0x29bf33,{'recursive':!![]});const _0x254918=a71_0x5c63df[_0x14ad13(0x191)](_0x5c238c,_0x14ad13(0x1c9));!a71_0x2553dc[_0x14ad13(0x1f5)](_0x254918)&&a71_0x2553dc[_0x14ad13(0x175)](_0x254918,createAgentConfigContent(_0x549f00));const {yaml:_0x1019d6,systemPrompt:_0x9c6495,starterMessage:_0x4e7232}=await apiAgentToYaml(_0x232c96,_0x35fc2c);let _0x35ca9b=_0x25fe3e;if(!_0x25fe3e){const _0x3ca090=a71_0x2553dc[_0x14ad13(0x1f5)](_0x4c6f4a)?a71_0x2553dc[_0x14ad13(0x12c)](_0x4c6f4a,'utf-8'):'',_0x1a76eb=a71_0x2553dc[_0x14ad13(0x12c)](_0x4d87e6,_0x14ad13(0x17d));_0x35ca9b=_0x3ca090!==_0x9c6495||_0x1a76eb!==toAgentYamlString(_0x1019d6);}a71_0x2553dc[_0x14ad13(0x175)](_0x4c6f4a,_0x9c6495),a71_0x2553dc['writeFileSync'](_0x4d87e6,toAgentYamlString(_0x1019d6));if(_0x4e7232&&_0x4e7232[_0x14ad13(0x168)]('\x0a'))a71_0x2553dc[_0x14ad13(0x175)](_0x28b5eb,_0x4e7232);else a71_0x2553dc[_0x14ad13(0x1f5)](_0x28b5eb)&&a71_0x2553dc['unlinkSync'](_0x28b5eb);return{'agentName':_0x5c313f,'outputPath':_0x29bf33,'isNew':_0x25fe3e,'hasChanges':_0x35ca9b};}async[a71_0x49d5c4(0x13a)](_0x13502e,_0x501422){const _0x456bab=a71_0x49d5c4;let _0xd587ce;isAgentYamlPath(_0x13502e)?_0xd587ce=getAgentDirFromYamlPath(_0x13502e):_0xd587ce=_0x13502e;const {config:_0x436b74}=findAgentConfig(_0xd587ce),_0x3e8de5=await this[_0x456bab(0x163)](_0x436b74['llm_project']),_0x83c622=a71_0x5c63df[_0x456bab(0x191)](_0xd587ce,_0x456bab(0x1ee)),_0x3cebca=a71_0x5c63df[_0x456bab(0x191)](_0xd587ce,'prompt.md'),_0x2d2560=a71_0x5c63df[_0x456bab(0x191)](_0xd587ce,_0x456bab(0x123));if(!a71_0x2553dc['existsSync'](_0x83c622))throw new SDKError(ErrorCode[_0x456bab(0x129)],_0x456bab(0x178)+_0xd587ce,undefined,{'helpText':'Ensure\x20the\x20path\x20points\x20to\x20a\x20valid\x20agent\x20directory.'});const _0x4a9f80=parseAgentYaml(a71_0x2553dc[_0x456bab(0x12c)](_0x83c622,_0x456bab(0x17d)),_0x83c622),_0x4d29ba=a71_0x2553dc['existsSync'](_0x3cebca)?a71_0x2553dc[_0x456bab(0x12c)](_0x3cebca,'utf-8'):'',_0x4f2085=a71_0x2553dc[_0x456bab(0x1f5)](_0x2d2560)?a71_0x2553dc[_0x456bab(0x12c)](_0x2d2560,'utf-8'):_0x4a9f80[_0x456bab(0x12e)];if(_0x501422?.[_0x456bab(0x1ab)])return{'agentName':_0x4a9f80['name'],'action':_0x456bab(0x193),'projectId':_0x3e8de5};const _0x2f1f86=await this['client']['listAgentsFull'](_0x3e8de5),_0x174745=await this[_0x456bab(0x159)][_0x456bab(0x161)](_0x3e8de5),_0x18ed36=await this[_0x456bab(0x159)]['listTextKnowledgeBases'](_0x3e8de5),_0x5660b9=new Map(),_0x2cf19b=new Map(),_0x568684=new Map();for(const _0xe9643a of _0x174745){_0x5660b9[_0x456bab(0x197)](_0xe9643a[_0x456bab(0x155)][_0x456bab(0x1b9)],_0xe9643a['id']);}for(const _0x6a953d of _0x18ed36){_0x2cf19b[_0x456bab(0x197)](_0x6a953d[_0x456bab(0x155)]['name'],_0x6a953d['id']);}for(const _0x6104ff of _0x2f1f86){_0x568684[_0x456bab(0x197)](_0x6104ff[_0x456bab(0x155)][_0x456bab(0x1b9)],_0x6104ff['id']);}const _0x27d5cf={'projectId':_0x3e8de5,'resolveKnowledgeBaseId':async _0x553d5a=>_0x5660b9[_0x456bab(0x174)](_0x553d5a),'resolveTextKnowledgeBaseId':async _0x1e137c=>_0x2cf19b[_0x456bab(0x174)](_0x1e137c),'resolveAgentId':async _0x3ab671=>_0x568684[_0x456bab(0x174)](_0x3ab671),'resolveWebSearchToolId':async()=>undefined,'resolveImageGeneratorId':async()=>undefined,'resolvePromptId':async()=>undefined,'onWarning':_0x2f7e02=>this[_0x456bab(0x14c)][_0x456bab(0x11b)]?.[_0x456bab(0x1d6)](_0x2f7e02)};try{const _0x4823aa=_0x2f1f86[_0x456bab(0x166)](_0x258a3b=>_0x258a3b[_0x456bab(0x155)]['name']===_0x4a9f80[_0x456bab(0x1b9)]),_0x2a031b=await yamlAgentToApi(_0x4a9f80,_0x4d29ba,_0x4f2085,_0x27d5cf);if(_0x4823aa)return await this[_0x456bab(0x159)][_0x456bab(0x1be)](_0x4823aa['id'],_0x2a031b),{'agentName':_0x4a9f80[_0x456bab(0x1b9)],'action':'updated','projectId':_0x3e8de5,'agentId':_0x4823aa['id']};else{const _0x4186b2=await this[_0x456bab(0x159)][_0x456bab(0x19b)](_0x2a031b);return{'agentName':_0x4a9f80[_0x456bab(0x1b9)],'action':_0x456bab(0x193),'projectId':_0x3e8de5,'agentId':_0x4186b2['id']};}}catch(_0x112e62){return{'agentName':_0x4a9f80[_0x456bab(0x1b9)],'action':_0x456bab(0x1d9),'projectId':_0x3e8de5,'error':_0x112e62[_0x456bab(0x136)]};}}async[a71_0x49d5c4(0x1c5)](_0x547f71,_0x13b89e,_0x501a57){const _0x302281=a71_0x49d5c4,_0xcd744b=a71_0x2553dc['existsSync'](_0x547f71)&&a71_0x2553dc[_0x302281(0x1f5)](a71_0x5c63df[_0x302281(0x191)](_0x547f71,_0x302281(0x1c9)));let _0x33b77c;const _0x42df3f=[],_0x1dd760=[],_0x4d6b46=[],_0x318af6=[];if(_0xcd744b){const _0x42c8c3=loadAgentConfig(a71_0x5c63df[_0x302281(0x191)](_0x547f71,_0x302281(0x1c9)));_0x33b77c=_0x42c8c3[_0x302281(0x189)];const _0x275c27=a71_0x2553dc[_0x302281(0x150)](_0x547f71,{'withFileTypes':!![]});for(const _0x4a275d of _0x275c27){if(!_0x4a275d['isDirectory']())continue;if([_0x302281(0x14d),_0x302281(0x19e),'integrations'][_0x302281(0x168)](_0x4a275d['name']))continue;const _0x13308a=a71_0x5c63df[_0x302281(0x191)](_0x547f71,_0x4a275d['name']);if(isAgentDir(_0x13308a)){const _0x58e594=a71_0x5c63df['join'](_0x13308a,_0x302281(0x1ee)),_0x3c00eb=a71_0x5c63df['join'](_0x13308a,'prompt.md'),_0x8e4b6f=a71_0x5c63df[_0x302281(0x191)](_0x13308a,_0x302281(0x123)),_0x5cf3af=parseAgentYaml(a71_0x2553dc[_0x302281(0x12c)](_0x58e594,_0x302281(0x17d)),_0x58e594),_0x338850=a71_0x2553dc[_0x302281(0x1f5)](_0x3c00eb)?a71_0x2553dc[_0x302281(0x12c)](_0x3c00eb,_0x302281(0x17d)):'',_0x2fb9fc=a71_0x2553dc['existsSync'](_0x8e4b6f)?a71_0x2553dc[_0x302281(0x12c)](_0x8e4b6f,_0x302281(0x17d)):_0x5cf3af['starter_message'];_0x42df3f[_0x302281(0x1c6)]({'name':_0x5cf3af['name'],'dir':_0x13308a,'yaml':_0x5cf3af,'systemPrompt':_0x338850,'starterMessage':_0x2fb9fc});}}const _0x21dcaa=getKnowledgeBasesDir(_0x547f71);if(a71_0x2553dc['existsSync'](_0x21dcaa)){const _0x38ecfb=a71_0x2553dc[_0x302281(0x150)](_0x21dcaa);for(const _0x5b4b29 of _0x38ecfb){const _0x11f8de=a71_0x5c63df[_0x302281(0x191)](_0x21dcaa,_0x5b4b29);if(_0x5b4b29[_0x302281(0x16c)](_0x302281(0x1b6))){const _0x2ba607=parseKnowledgeBaseYaml(a71_0x2553dc[_0x302281(0x12c)](_0x11f8de,_0x302281(0x17d)),_0x11f8de);_0x1dd760[_0x302281(0x1c6)]({'name':_0x2ba607[_0x302281(0x1b9)],'path':_0x11f8de,'yaml':_0x2ba607});}else{if(_0x5b4b29['endsWith'](_0x302281(0x1a0))){const _0x5e3504=a71_0x2553dc[_0x302281(0x12c)](_0x11f8de,_0x302281(0x17d)),{name:_0x546882,text:_0x46aec4}=parseTextKnowledgeBaseMd(_0x5e3504,_0x5b4b29);_0x4d6b46[_0x302281(0x1c6)]({'name':_0x546882,'path':_0x11f8de,'text':_0x46aec4});}}}}const _0x1a1477=getPromptsDir(_0x547f71);if(a71_0x2553dc[_0x302281(0x1f5)](_0x1a1477)){const _0xa3b26d=a71_0x2553dc[_0x302281(0x150)](_0x1a1477)['filter'](_0x2f58ce=>_0x2f58ce[_0x302281(0x16c)]('.yml'));for(const _0x330ab7 of _0xa3b26d){const _0x6aaeb4=a71_0x5c63df[_0x302281(0x191)](_0x1a1477,_0x330ab7),_0x3cb54b=parsePromptYaml(a71_0x2553dc[_0x302281(0x12c)](_0x6aaeb4,_0x302281(0x17d)),_0x6aaeb4);_0x318af6[_0x302281(0x1c6)]({'name':_0x3cb54b[_0x302281(0x1b9)],'path':_0x6aaeb4,'yaml':_0x3cb54b});}}}else{const _0x1046b2=await this[_0x302281(0x163)](_0x547f71),_0x4900f6=await this[_0x302281(0x159)][_0x302281(0x167)](_0x1046b2);_0x33b77c=_0x4900f6[_0x302281(0x155)]['name'];const _0x5324c0=await this[_0x302281(0x159)][_0x302281(0x11c)](_0x1046b2),_0x325ec8=await this['client'][_0x302281(0x161)](_0x1046b2),_0x24c522=await this['client'][_0x302281(0x1ae)](_0x1046b2),_0x21e59b=await this[_0x302281(0x159)][_0x302281(0x196)](_0x1046b2),_0x4f5ea2=new Map(),_0x3b86ad=new Map(),_0x4fe0eb=new Map(),_0x21232a=new Map();for(const _0x33ed39 of _0x325ec8){_0x4f5ea2['set'](_0x33ed39['id'],_0x33ed39['attributes']['name']);}for(const _0x20df2e of _0x24c522){_0x3b86ad['set'](_0x20df2e['id'],_0x20df2e[_0x302281(0x155)][_0x302281(0x1b9)]);}for(const _0x4351cf of _0x5324c0){_0x4fe0eb[_0x302281(0x197)](_0x4351cf['id'],_0x4351cf['attributes'][_0x302281(0x1b9)]);}for(const _0x1c8fcd of _0x21e59b){_0x21232a[_0x302281(0x197)](_0x1c8fcd['id'],_0x1c8fcd[_0x302281(0x155)][_0x302281(0x1b9)]);}const _0x3ec5c3={'resolveKnowledgeBaseName':async _0x3fd4d7=>_0x4f5ea2[_0x302281(0x174)](_0x3fd4d7),'resolveTextKnowledgeBaseName':async _0x34ddaa=>_0x3b86ad[_0x302281(0x174)](_0x34ddaa),'resolveAgentName':async _0x37bf56=>_0x4fe0eb[_0x302281(0x174)](_0x37bf56),'resolveWebSearchToolName':async()=>undefined,'resolveImageGeneratorName':async()=>undefined,'resolvePromptName':async _0x1b1987=>_0x21232a[_0x302281(0x174)](_0x1b1987),'onWarning':_0x53ea24=>this[_0x302281(0x14c)][_0x302281(0x11b)]?.[_0x302281(0x1d6)](_0x53ea24)};for(const _0x17cf68 of _0x5324c0){const _0x55ac59=await apiAgentToYaml(_0x17cf68,_0x3ec5c3),{yaml:_0x1e0c8d,systemPrompt:_0x5b1c47,starterMessage:_0x18b50b}=_0x55ac59;_0x42df3f[_0x302281(0x1c6)]({'name':_0x1e0c8d[_0x302281(0x1b9)],'dir':'','yaml':_0x1e0c8d,'systemPrompt':_0x5b1c47,'starterMessage':_0x18b50b});}for(const _0x3ee0b9 of _0x325ec8){const _0x471d29=apiKnowledgeBaseToYaml(_0x3ee0b9);_0x1dd760[_0x302281(0x1c6)]({'name':_0x471d29[_0x302281(0x1b9)],'path':'','yaml':_0x471d29});}for(const _0x54657d of _0x24c522){_0x4d6b46[_0x302281(0x1c6)]({'name':_0x54657d[_0x302281(0x155)]['name'],'path':'','text':_0x54657d[_0x302281(0x155)][_0x302281(0x1a1)]});}for(const _0x4a2eef of _0x21e59b){const _0x92ac6b=await apiPromptToYaml(_0x4a2eef,_0x3ec5c3);_0x92ac6b&&_0x318af6['push']({'name':_0x92ac6b['name'],'path':'','yaml':_0x92ac6b});}}const _0x4c8a87={'sourceProjectName':_0x33b77c,'newProjectName':_0x13b89e,'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}}},_0x246c47=await this[_0x302281(0x159)][_0x302281(0x198)](),_0x245ce1=_0x246c47[_0x302281(0x166)](_0x11aaf6=>_0x11aaf6['attributes'][_0x302281(0x1b9)]===_0x13b89e);if(_0x245ce1)throw new SDKError(ErrorCode[_0x302281(0x1da)],_0x302281(0x13c)+_0x13b89e+_0x302281(0x15e),undefined,{'helpText':_0x302281(0x14a)});if(_0x501a57?.[_0x302281(0x1ab)])return _0x4c8a87['counts'][_0x302281(0x152)][_0x302281(0x193)]=_0x42df3f[_0x302281(0x19f)],_0x4c8a87[_0x302281(0x137)][_0x302281(0x17b)][_0x302281(0x193)]=_0x1dd760[_0x302281(0x19f)],_0x4c8a87['counts']['textKnowledgeBases'][_0x302281(0x193)]=_0x4d6b46[_0x302281(0x19f)],_0x4c8a87['counts']['prompts'][_0x302281(0x193)]=_0x318af6[_0x302281(0x19f)],_0x4c8a87;const _0x121087=await this['client'][_0x302281(0x1e7)]({'name':_0x13b89e}),_0x5d544c=_0x121087['id'];_0x4c8a87['newProjectId']=_0x5d544c;const _0x537258=new Map(),_0x2fd5f4=new Map(),_0xecaaee=new Map(),_0x5c6721=new Map(),_0x1afaf4=new Map(),_0x7bc03b=new Map(),_0x30a773=new Set(),_0x381d73=new Set();for(const _0x82ef62 of _0x42df3f){for(const _0x2bed1f of _0x82ef62[_0x302281(0x181)][_0x302281(0x1cb)]||[]){if(_0x2bed1f[_0x302281(0x15b)]===_0x302281(0x1b3)){const _0x3af365=parseRef(_0x2bed1f[_0x302281(0x1fb)]);if(_0x3af365)_0x30a773['add'](_0x3af365[_0x302281(0x1b9)]);}else{if(_0x2bed1f[_0x302281(0x15b)]==='web_search'){const _0x5d166f=parseRef(_0x2bed1f[_0x302281(0x1fb)]);if(_0x5d166f)_0x381d73[_0x302281(0x1c7)](_0x5d166f[_0x302281(0x1b9)]);}}}}for(const _0x4c288d of _0x30a773){try{const _0x16601c=await this[_0x302281(0x159)][_0x302281(0x182)]({'projectId':_0x5d544c,'name':_0x4c288d});_0x1afaf4[_0x302281(0x197)](_0x4c288d,_0x16601c['id']),_0x4c8a87['imageGenerators'][_0x302281(0x1c6)]({'name':_0x4c288d,'action':_0x302281(0x193),'id':_0x16601c['id']}),_0x4c8a87[_0x302281(0x137)][_0x302281(0x1f7)][_0x302281(0x193)]++;}catch(_0x5d3400){_0x4c8a87[_0x302281(0x1f7)][_0x302281(0x1c6)]({'name':_0x4c288d,'action':_0x302281(0x1d9),'error':_0x5d3400[_0x302281(0x136)]}),_0x4c8a87[_0x302281(0x137)][_0x302281(0x1f7)]['errors']++;}}for(const _0x2736c6 of _0x381d73){try{const _0x3e31d6=await this[_0x302281(0x159)][_0x302281(0x1e3)]({'projectId':_0x5d544c,'name':_0x2736c6});_0x7bc03b[_0x302281(0x197)](_0x2736c6,_0x3e31d6['id']),_0x4c8a87[_0x302281(0x147)]['push']({'name':_0x2736c6,'action':_0x302281(0x193),'id':_0x3e31d6['id']}),_0x4c8a87[_0x302281(0x137)]['webSearchTools'][_0x302281(0x193)]++;}catch(_0x4e8e31){_0x4c8a87[_0x302281(0x147)]['push']({'name':_0x2736c6,'action':'error','error':_0x4e8e31[_0x302281(0x136)]}),_0x4c8a87[_0x302281(0x137)][_0x302281(0x147)][_0x302281(0x19d)]++;}}const _0x4efbda={'projectId':_0x5d544c,'resolveKnowledgeBaseId':async _0x1a4c50=>_0x537258[_0x302281(0x174)](_0x1a4c50),'resolveTextKnowledgeBaseId':async _0x4d2c7f=>_0x2fd5f4[_0x302281(0x174)](_0x4d2c7f),'resolveAgentId':async _0x4eb451=>_0xecaaee[_0x302281(0x174)](_0x4eb451),'resolveWebSearchToolId':async _0x1066f9=>_0x7bc03b[_0x302281(0x174)](_0x1066f9),'resolveImageGeneratorId':async _0xa5a755=>_0x1afaf4[_0x302281(0x174)](_0xa5a755),'resolvePromptId':async _0x21b2d4=>_0x5c6721[_0x302281(0x174)](_0x21b2d4),'onWarning':_0x1718de=>this[_0x302281(0x14c)][_0x302281(0x11b)]?.[_0x302281(0x1d6)](_0x1718de)};for(const _0x3d1556 of _0x1dd760){try{const _0x15e707=yamlKnowledgeBaseToApi(_0x3d1556[_0x302281(0x181)],_0x5d544c),_0x17b27f=await this[_0x302281(0x159)][_0x302281(0x1df)](_0x15e707);_0x537258[_0x302281(0x197)](_0x3d1556[_0x302281(0x181)]['name'],_0x17b27f['id']),_0x4c8a87[_0x302281(0x17b)][_0x302281(0x1c6)]({'name':_0x3d1556['yaml'][_0x302281(0x1b9)],'action':'created','id':_0x17b27f['id']}),_0x4c8a87[_0x302281(0x137)][_0x302281(0x17b)][_0x302281(0x193)]++;}catch(_0x58fff0){_0x4c8a87['knowledgeBases'][_0x302281(0x1c6)]({'name':_0x3d1556[_0x302281(0x181)][_0x302281(0x1b9)],'action':_0x302281(0x1d9),'error':_0x58fff0[_0x302281(0x136)]}),_0x4c8a87[_0x302281(0x137)]['knowledgeBases'][_0x302281(0x19d)]++;}}for(const _0x365303 of _0x4d6b46){try{const _0x4df7ed=yamlTextKnowledgeBaseToApi({'name':_0x365303[_0x302281(0x1b9)],'text':_0x365303[_0x302281(0x1a1)]},_0x5d544c),_0x4924ae=await this[_0x302281(0x159)][_0x302281(0x190)](_0x4df7ed);_0x2fd5f4['set'](_0x365303['name'],_0x4924ae['id']),_0x4c8a87[_0x302281(0x153)][_0x302281(0x1c6)]({'name':_0x365303[_0x302281(0x1b9)],'action':_0x302281(0x193),'id':_0x4924ae['id']}),_0x4c8a87[_0x302281(0x137)][_0x302281(0x153)][_0x302281(0x193)]++;}catch(_0x432cd3){_0x4c8a87[_0x302281(0x153)][_0x302281(0x1c6)]({'name':_0x365303[_0x302281(0x1b9)],'action':'error','error':_0x432cd3['message']}),_0x4c8a87[_0x302281(0x137)]['textKnowledgeBases'][_0x302281(0x19d)]++;}}const _0x5ae474=[..._0x42df3f][_0x302281(0x160)]((_0x486586,_0x11949a)=>{const _0xe343d1=_0x302281,_0x3733ec=_0x486586[_0xe343d1(0x181)]['tools']?.[_0xe343d1(0x1cf)](_0x44087=>_0x44087['type']===_0xe343d1(0x1af))??![],_0x6c237c=_0x11949a['yaml'][_0xe343d1(0x1cb)]?.[_0xe343d1(0x1cf)](_0x124400=>_0x124400[_0xe343d1(0x15b)]===_0xe343d1(0x1af))??![];if(_0x3733ec&&!_0x6c237c)return 0x1;if(!_0x3733ec&&_0x6c237c)return-0x1;return 0x0;});for(const _0x275497 of _0x5ae474){try{const _0x4ad957=_0x275497['yaml'][_0x302281(0x1cb)]?.[_0x302281(0x1b1)](_0x4b2d45=>{const _0xf03e81=_0x302281;if(_0x4b2d45['type']==='agent'){const _0x103f47=parseRef(_0x4b2d45['target']);return _0x103f47?.['name']===_0x275497['yaml'][_0xf03e81(0x1b9)];}return![];})??[];_0x4ad957[_0x302281(0x19f)]>0x0&&this[_0x302281(0x14c)]['logger']?.[_0x302281(0x1d6)](_0x302281(0x16b)+_0x275497[_0x302281(0x181)][_0x302281(0x1b9)]+_0x302281(0x18b)+_0x302281(0x1b0));const _0x5508f9=await yamlAgentToApi(_0x275497[_0x302281(0x181)],_0x275497[_0x302281(0x12a)],_0x275497['starterMessage'],_0x4efbda),_0x440c2d=await this[_0x302281(0x159)]['createAgentFull'](_0x5508f9);_0xecaaee[_0x302281(0x197)](_0x275497[_0x302281(0x181)]['name'],_0x440c2d['id']),_0x4c8a87['agents'][_0x302281(0x1c6)]({'agentName':_0x275497[_0x302281(0x181)][_0x302281(0x1b9)],'action':_0x302281(0x193),'agentId':_0x440c2d['id']}),_0x4c8a87[_0x302281(0x137)][_0x302281(0x152)]['created']++;}catch(_0x66994a){_0x4c8a87[_0x302281(0x152)][_0x302281(0x1c6)]({'agentName':_0x275497[_0x302281(0x181)]['name'],'action':_0x302281(0x1d9),'error':_0x66994a[_0x302281(0x136)]}),_0x4c8a87[_0x302281(0x137)][_0x302281(0x152)][_0x302281(0x19d)]++;}}for(const _0x5abd7c of _0x318af6){try{const _0x3854d2=await yamlPromptToApi(_0x5abd7c[_0x302281(0x181)],_0x5d544c,_0x4efbda);if(!_0x3854d2){_0x4c8a87['prompts'][_0x302281(0x1c6)]({'name':_0x5abd7c[_0x302281(0x181)][_0x302281(0x1b9)],'action':_0x302281(0x1d9),'error':_0x302281(0x18a)}),_0x4c8a87[_0x302281(0x137)]['prompts'][_0x302281(0x19d)]++;continue;}const _0x59f420=await this[_0x302281(0x159)][_0x302281(0x138)](_0x3854d2);_0x5c6721[_0x302281(0x197)](_0x5abd7c['yaml'][_0x302281(0x1b9)],_0x59f420['id']),_0x4c8a87['prompts']['push']({'name':_0x5abd7c[_0x302281(0x181)][_0x302281(0x1b9)],'action':'created','id':_0x59f420['id']}),_0x4c8a87[_0x302281(0x137)][_0x302281(0x19e)][_0x302281(0x193)]++;}catch(_0x2b1b38){_0x4c8a87[_0x302281(0x19e)][_0x302281(0x1c6)]({'name':_0x5abd7c[_0x302281(0x181)][_0x302281(0x1b9)],'action':'error','error':_0x2b1b38[_0x302281(0x136)]}),_0x4c8a87[_0x302281(0x137)][_0x302281(0x19e)][_0x302281(0x19d)]++;}}return _0x4c8a87;}}
|
package/dist/sdk/query.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a72_0x4c88bb=a72_0x2f15;(function(_0x44dbf2,_0x529988){const _0x28888f=a72_0x2f15,_0x33fa87=_0x44dbf2();while(!![]){try{const _0x2c9468=-parseInt(_0x28888f(0x158))/0x1*(-parseInt(_0x28888f(0x156))/0x2)+parseInt(_0x28888f(0x14f))/0x3*(parseInt(_0x28888f(0x12f))/0x4)+-parseInt(_0x28888f(0x155))/0x5*(parseInt(_0x28888f(0x134))/0x6)+-parseInt(_0x28888f(0x133))/0x7+parseInt(_0x28888f(0x140))/0x8+-parseInt(_0x28888f(0x138))/0x9*(-parseInt(_0x28888f(0x15f))/0xa)+-parseInt(_0x28888f(0x137))/0xb*(parseInt(_0x28888f(0x13a))/0xc);if(_0x2c9468===_0x529988)break;else _0x33fa87['push'](_0x33fa87['shift']());}catch(_0x337ff7){_0x33fa87['push'](_0x33fa87['shift']());}}}(a72_0x2c60,0x4f60f));import{TrinoApiClient}from'../client/trino-api-client.js';import{escapeStringLiteral,buildLikePattern}from'../utils/string-utils.js';import{SDKError,ErrorCode}from'./errors.js';import{DEFAULT_LISTING_LIMIT}from'../utils/constants.js';export class QuerySDK{[a72_0x4c88bb(0x148)];constructor(_0x20d2d7){this['trinoApiClient']=new TrinoApiClient(_0x20d2d7,_0x20d2d7['logger']);}async[a72_0x4c88bb(0x13e)](_0x2aea81,_0x1ce7ba){const _0x2f517a=a72_0x4c88bb;if(!_0x2aea81||_0x2aea81[_0x2f517a(0x149)]()[_0x2f517a(0x154)]===0x0)throw new SDKError(ErrorCode[_0x2f517a(0x129)],_0x2f517a(0x159),undefined,{'helpText':'Provide\x20SQL\x20via\x20argument\x20or\x20use\x20--file\x20option.'});return await this[_0x2f517a(0x148)][_0x2f517a(0x142)](_0x2aea81,_0x1ce7ba);}async[a72_0x4c88bb(0x14c)](_0x3617d7,_0x5990ef=DEFAULT_LISTING_LIMIT){const _0x4ffec9=a72_0x4c88bb;if(_0x3617d7!==undefined&&_0x3617d7[_0x4ffec9(0x149)]()[_0x4ffec9(0x154)]===0x0)throw new SDKError(ErrorCode[_0x4ffec9(0x15e)],_0x4ffec9(0x152),undefined,{'helpText':_0x4ffec9(0x145)});if(_0x5990ef<=0x0)throw new SDKError(ErrorCode[_0x4ffec9(0x15e)],_0x4ffec9(0x14a),undefined,{'helpText':_0x4ffec9(0x15d)});let _0x463a67='\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';_0x3617d7&&(_0x463a67+=_0x4ffec9(0x141)+buildLikePattern(_0x3617d7)+_0x4ffec9(0x12a));_0x463a67+='\x0aORDER\x20BY\x20database_name\x0aLIMIT\x20'+_0x5990ef;const _0xe26310=await this[_0x4ffec9(0x148)][_0x4ffec9(0x142)](_0x463a67[_0x4ffec9(0x149)]());return _0xe26310[_0x4ffec9(0x13d)];}async['listTables'](_0x38cd7e,_0xac75db,_0x2226da,_0x487e5d=DEFAULT_LISTING_LIMIT){const _0xa81a4e=a72_0x4c88bb;if(_0x38cd7e!==undefined&&_0x38cd7e[_0xa81a4e(0x149)]()[_0xa81a4e(0x154)]===0x0)throw new SDKError(ErrorCode[_0xa81a4e(0x15e)],_0xa81a4e(0x130),undefined,{'helpText':_0xa81a4e(0x13c)});if(_0xac75db!==undefined&&_0xac75db[_0xa81a4e(0x149)]()[_0xa81a4e(0x154)]===0x0)throw new SDKError(ErrorCode[_0xa81a4e(0x15e)],_0xa81a4e(0x152),undefined,{'helpText':_0xa81a4e(0x15c)});if(_0x2226da!==undefined&&_0x2226da[_0xa81a4e(0x149)]()[_0xa81a4e(0x154)]===0x0)throw new SDKError(ErrorCode[_0xa81a4e(0x15e)],_0xa81a4e(0x13f),undefined,{'helpText':_0xa81a4e(0x131)});if(_0x487e5d<=0x0)throw new SDKError(ErrorCode[_0xa81a4e(0x15e)],_0xa81a4e(0x14a),undefined,{'helpText':_0xa81a4e(0x15d)});let _0x108b03;_0x38cd7e?(_0x108b03=_0xa81a4e(0x15a)+escapeStringLiteral(_0x38cd7e)+'\x0a\x20\x20\x20\x20\x20\x20',_0xac75db&&(_0x108b03+='\x0a\x20\x20AND\x20table_name\x20LIKE\x20'+buildLikePattern(_0xac75db)+'\x20ESCAPE\x20\x27\x5c\x27'),_0x108b03+=_0xa81a4e(0x136)+_0x487e5d):(_0x108b03=_0xa81a4e(0x146),_0x2226da&&(_0x108b03+=_0xa81a4e(0x13b)+buildLikePattern(_0x2226da)+_0xa81a4e(0x12a)),_0xac75db&&(_0x108b03+='\x0a\x20\x20AND\x20table_name\x20LIKE\x20'+buildLikePattern(_0xac75db)+_0xa81a4e(0x12a)),_0x108b03+=_0xa81a4e(0x150)+_0x487e5d);const _0x400d6c=await this[_0xa81a4e(0x148)][_0xa81a4e(0x142)](_0x108b03[_0xa81a4e(0x149)]());return _0x400d6c[_0xa81a4e(0x13d)];}async[a72_0x4c88bb(0x153)](_0x5bc6ca){const _0x315ff1=a72_0x4c88bb,_0x22eca4=('\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'+escapeStringLiteral(_0x5bc6ca)+_0x315ff1(0x151))[_0x315ff1(0x149)](),_0x49d84a=await this[_0x315ff1(0x148)][_0x315ff1(0x142)](_0x22eca4);return _0x49d84a['data'][_0x315ff1(0x154)]>0x0;}async[a72_0x4c88bb(0x157)](_0x2df966,_0xc0dab7){const _0x14aec3=a72_0x4c88bb,_0x30dc01=(_0x14aec3(0x160)+escapeStringLiteral(_0x2df966)+_0x14aec3(0x135)+escapeStringLiteral(_0xc0dab7)+_0x14aec3(0x151))[_0x14aec3(0x149)](),_0x5850fd=await this[_0x14aec3(0x148)][_0x14aec3(0x142)](_0x30dc01);return _0x5850fd['data'][_0x14aec3(0x154)]>0x0;}async[a72_0x4c88bb(0x139)](_0x5cfd9a,_0x32b989){const _0x4fd9d7=a72_0x4c88bb;if(!_0x5cfd9a||_0x5cfd9a[_0x4fd9d7(0x149)]()[_0x4fd9d7(0x154)]===0x0)throw new SDKError(ErrorCode[_0x4fd9d7(0x129)],_0x4fd9d7(0x12d),undefined,{'helpText':_0x4fd9d7(0x12e)});if(!_0x32b989||_0x32b989['trim']()[_0x4fd9d7(0x154)]===0x0)throw new SDKError(ErrorCode[_0x4fd9d7(0x129)],'Table\x20name\x20is\x20required',undefined,{'helpText':_0x4fd9d7(0x12e)});const _0x4b13a0=(_0x4fd9d7(0x144)+escapeStringLiteral(_0x5cfd9a)+_0x4fd9d7(0x135)+escapeStringLiteral(_0x32b989)+_0x4fd9d7(0x14d))[_0x4fd9d7(0x149)](),_0x3423f5=await this['trinoApiClient'][_0x4fd9d7(0x142)](_0x4b13a0);return _0x3423f5[_0x4fd9d7(0x13d)];}async[a72_0x4c88bb(0x14b)](_0xa15dbc,_0x3e5df7,_0x125d01=0x28,_0xbe2856){const _0xe3ddde=a72_0x4c88bb;if(!_0xa15dbc||_0xa15dbc[_0xe3ddde(0x149)]()['length']===0x0)throw new SDKError(ErrorCode[_0xe3ddde(0x129)],_0xe3ddde(0x12d),undefined,{'helpText':'Usage:\x20tdx\x20show\x20<database.table>'});if(!_0x3e5df7||_0x3e5df7['trim']()[_0xe3ddde(0x154)]===0x0)throw new SDKError(ErrorCode['MISSING_ARGUMENT'],_0xe3ddde(0x14e),undefined,{'helpText':'Usage:\x20tdx\x20show\x20<database.table>'});if(!Number[_0xe3ddde(0x132)](_0x125d01)||_0x125d01<=0x0)throw new SDKError(ErrorCode[_0xe3ddde(0x15e)],_0xe3ddde(0x12b),undefined,{'helpText':_0xe3ddde(0x15b)});const _0xea48b9=escapeStringLiteral(_0xa15dbc)[_0xe3ddde(0x147)](0x1,-0x1)+'.'+escapeStringLiteral(_0x3e5df7)[_0xe3ddde(0x147)](0x1,-0x1),_0x6d40bf=_0xe3ddde(0x12c)+_0xea48b9+_0xe3ddde(0x143)+_0x125d01,_0x610a4c=await this[_0xe3ddde(0x148)][_0xe3ddde(0x142)](_0x6d40bf,{'catalog':_0xbe2856,'schema':_0xa15dbc});return _0x610a4c;}}function a72_0x2f15(_0x24f3f7,_0x5eecc9){_0x24f3f7=_0x24f3f7-0x129;const _0x2c6007=a72_0x2c60();let _0x2f1599=_0x2c6007[_0x24f3f7];return _0x2f1599;}function a72_0x2c60(){const _0x5553c1=['Database\x20name\x20is\x20required','Usage:\x20tdx\x20describe\x20<database.table>','4dmiSuV','Database\x20name\x20cannot\x20be\x20empty\x20or\x20whitespace-only','Provide\x20a\x20valid\x20glob\x20pattern\x20(e.g.,\x20\x22prod_*\x22)\x20or\x20omit\x20to\x20search\x20all\x20databases.','isInteger','1083453QRQUCu','537834IBkbrx','\x0a\x20\x20\x20\x20\x20\x20\x20\x20AND\x20table_name\x20=\x20','\x0aORDER\x20BY\x20table_name\x0aLIMIT\x20','1138313dreJVs','2812581seVVkL','describeTable','156WORTYH','\x0a\x20\x20AND\x20table_schema\x20LIKE\x20','Provide\x20a\x20valid\x20database\x20name\x20or\x20omit\x20to\x20list\x20tables\x20from\x20all\x20databases.','data','execute','Database\x20pattern\x20cannot\x20be\x20empty\x20or\x20whitespace-only','1703584YkrZzf','\x0a\x20\x20AND\x20schema_name\x20LIKE\x20','executeQuery','\x20LIMIT\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','Provide\x20a\x20valid\x20glob\x20pattern\x20(e.g.,\x20\x22prod_*\x22)\x20or\x20omit\x20the\x20pattern\x20to\x20list\x20all\x20databases.','\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','slice','trinoApiClient','trim','Limit\x20must\x20be\x20a\x20positive\x20number','showTable','listDatabases','\x0a\x20\x20\x20\x20\x20\x20ORDER\x20BY\x20ordinal_position\x0a\x20\x20\x20\x20','Table\x20name\x20is\x20required','1537287bVeFtb','\x0aORDER\x20BY\x20database_name,\x20table_name\x0aLIMIT\x20','\x0a\x20\x20\x20\x20','Pattern\x20cannot\x20be\x20empty\x20or\x20whitespace-only','validateDatabase','length','5iXDxsJ','2cqfquf','validateTable','564437tvCBYf','SQL\x20query\x20is\x20required','\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','Use\x20--limit\x20<number>\x20to\x20specify\x20row\x20limit\x20(must\x20be\x20positive).','Provide\x20a\x20valid\x20glob\x20pattern\x20(e.g.,\x20\x22user_*\x22)\x20or\x20omit\x20to\x20list\x20all\x20tables.','Provide\x20a\x20positive\x20number\x20for\x20limit\x20(e.g.,\x20100).','INVALID_ARGUMENT','20MuBxeP','\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','MISSING_ARGUMENT','\x20ESCAPE\x20\x27\x5c\x27','Limit\x20must\x20be\x20a\x20positive\x20integer','SELECT\x20*\x20FROM\x20'];a72_0x2c60=function(){return _0x5553c1;};return a72_0x2c60();}
|