@treasuredata/tdx 0.9.7 → 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 +36 -7
- 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.js +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_0x429fc8=a71_0x8a8a;(function(_0x4a9a15,_0xf57af3){const _0xe94c32=a71_0x8a8a,_0x529f28=_0x4a9a15();while(!![]){try{const _0x2ae849=-parseInt(_0xe94c32(0x12c))/0x1*(-parseInt(_0xe94c32(0x117))/0x2)+-parseInt(_0xe94c32(0x145))/0x3*(-parseInt(_0xe94c32(0xac))/0x4)+-parseInt(_0xe94c32(0xea))/0x5+parseInt(_0xe94c32(0x10f))/0x6+parseInt(_0xe94c32(0x11d))/0x7*(parseInt(_0xe94c32(0x7f))/0x8)+-parseInt(_0xe94c32(0xd7))/0x9*(-parseInt(_0xe94c32(0xe6))/0xa)+-parseInt(_0xe94c32(0x9c))/0xb;if(_0x2ae849===_0xf57af3)break;else _0x529f28['push'](_0x529f28['shift']());}catch(_0xbc0e89){_0x529f28['push'](_0x529f28['shift']());}}}(a71_0xf358,0x408c7));import{LLMApiClient}from'../client/llm-api-client.js';import*as a71_0x482401 from'node:fs';import*as a71_0x1b8025 from'node:path';import{HTTPClientError}from'../client/http-client.js';function a71_0xf358(){const _0x67c734=['new','chatInfo','version','deleteAgent','filter','text','createIntegration','createTextKnowledgeBase','push','listImageGenerators','agentId','getUniqueName','listTextKnowledgeBases','image_gen','chat','knowledge_bases','\x27.\x20This\x20should\x20not\x20happen.','currentProjectId','existsSync','\x0a\x0a#\x20agent.yml\x0a','yaml','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.','3541879zjtFDZ','createAgent','history','tdx.json','minimal','readdirSync','Re-add\x20them\x20after\x20clone\x20using\x20\x27tdx\x20agent\x20push\x27.','The\x20backup\x20contains\x20agents\x20with\x20circular\x20dependencies.','get','join','pullAgent','This\x20backup\x20was\x20created\x20with\x20a\x20newer\x20version\x20of\x20tdx.','agents','getDefaultProjectName','integrations.json','createImageGenerator','4daosGB','(dry-run)','Backup\x20folder\x20not\x20found:\x20','error','size','Agent\x20\x27','updateTextKnowledgeBase','textKnowledgeBases','knowledgebases.json','projects','createPrompt','length','action','availableModelNames','outputs','claude-4.5-sonnet','.llm','low','listIntegrations','agents.json','UNAUTHENTICATED','Multiple\x20agents\x20found\x20with\x20name\x20\x27','restoreProject','isDir','some','listPrompts','#\x20prompt.md\x0a','utf-8','total','.\x20Check\x20for\x20circular\x20references\x20or\x20missing\x20agents.','type','webSearchTools','.yml','INVALID_ARGUMENT','Agent\x20reference\x20not\x20found','startChat','web_search','split','signal','imageGenerators','project','starter_message.md','Invalid\x20backup:\x20project.json\x20not\x20found\x20in\x20','9yqFTLR','site','listChats','resolveProjectName','template','dryRun','updateKnowledgeBase','No\x20tdx.json\x20found\x20in\x20','logger','target','INTERNAL','client','newProjectId','.md','listAgentsFull','2032190FolSCA','Use\x20format:\x20\x22agent-name\x22\x20or\x20\x22project-name/agent-name\x22','Ensure\x20this\x20is\x20a\x20valid\x20LLM\x20project\x20backup\x20folder.','backupProject','2437055xPETHs','getCurrentProject','clearDefaultAgent','resolveProjectId','description','integrations','variables','deleteProject','displayName','chatIgnoreManagedActions','pullProject','name','knowledgeBases','event','find','temperature','already\x20exists','metadata','updated','jsonSchemaHint','systemPrompt','getAgent','duplicate','stringify','reasoningEffort','llm_project','errors','chatWelcomeMessage','actions','promptId','listWebSearchTools','dir','NOT_FOUND','Choose\x20a\x20different\x20name\x20or\x20delete\x20the\x20existing\x20project\x20first.','createAgentFull','updateAgentFull','listKnowledgeBases','1812828bDMYtF','getProject','modelType','createWebSearchTool','\x20attempts\x20due\x20to\x20name\x20conflicts.','project.json','Run\x20\x27tdx\x20agent\x20pull\x20<project>\x27\x20first\x20to\x20create\x20the\x20folder\x20structure.','agentId\x20is\x20required\x20when\x20starting\x20a\x20new\x20chat','2scAoYA','listAgents','Use\x20\x22tdx\x20llm\x20projects\x22\x20to\x20list\x20available\x20projects.','agent.yml','content','resolveAgentId','16779MrBKPX','availableModels','getBackupMetadata','Use\x20\x22tdx\x20llm\x20agents\x22\x20to\x20list\x20available\x20agents\x20in\x20the\x20current\x20project.','Project\x20not\x20found:\x20','prompt.md','updateAgent','loadJsonFile','Use\x20a\x20different\x20output\x20path\x20or\x20remove\x20the\x20existing\x20directory.','exportedFrom','createProject','tdx_','prompts','profile','parse','500231vyjWCH','prompts.json','createKnowledgeBase','Default\x20project\x20for\x20tdx\x20CLI\x20chat\x20(user:\x20','Unsupported\x20backup\x20version:\x20','listProjects','includes','tools','dirname','starter_message','warn','has','getOrCreateDefaultAgent','agent','created','LLM_PROJECT_NOT_FOUND','getChatInfo','counts','models','Agent\x20not\x20found:\x20','getOrCreateDefaultProject','\x27\x20has\x20self-referencing\x20tool(s)\x20that\x20will\x20be\x20skipped\x20during\x20clone.\x20','getDefaultAgent','starterMessage','toISOString','89553vznEzN','Failed\x20to\x20get\x20or\x20create\x20agent:\x20exceeded\x20maximum\x20attempts','context','readFileSync','status','unlinkSync','set','endsWith','attributes','Output\x20directory\x20already\x20exists:\x20','mkdirSync','ALREADY_EXISTS','message','isManaged','continueChat','path','pushAgent','none','AGENT_NOT_FOUND','chats','unchanged','isDirectory','tdx_default_','conflict','writeFileSync','getUserSettings','add','cwd','128KNtLod','keys','high','serviceType','Circular\x20dependency\x20detected\x20in\x20agents.\x20Cannot\x20restore.','Available\x20agents:\x20','Unable\x20to\x20create\x20project\x20after\x20'];a71_0xf358=function(){return _0x67c734;};return a71_0xf358();}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';function a71_0x8a8a(_0x2ee9f8,_0x586e32){_0x2ee9f8=_0x2ee9f8-0x6c;const _0xf35826=a71_0xf358();let _0x8a8acc=_0xf35826[_0x2ee9f8];return _0x8a8acc;}export class LLMSDK{[a71_0x429fc8(0x97)];[a71_0x429fc8(0xe2)];[a71_0x429fc8(0x147)];constructor(_0x414981){const _0x34b44f=a71_0x429fc8;this[_0x34b44f(0xe2)]=new LLMApiClient(_0x414981,_0x414981[_0x34b44f(0xdf)]),this['context']=_0x414981;}[a71_0x429fc8(0xa9)](){const _0x5693a2=a71_0x429fc8,_0x47991d=getSanitizedUsername();return _0x5693a2(0x79)+_0x47991d;}async['setCurrentProject'](_0x454198){const _0x138844=a71_0x429fc8,{projectId:_0x4cceea}=await this[_0x138844(0xda)](_0x454198);this[_0x138844(0x97)]=_0x4cceea;}[a71_0x429fc8(0xeb)](){return this['currentProjectId'];}async['setDefaultAgent'](_0x5ed604){const _0x55f870=a71_0x429fc8,_0x353a6c=this['context'][_0x55f870(0x12a)];let _0xac1c61,_0x4c3765;if(_0x5ed604[_0x55f870(0x132)]('/')){const _0x59530b=_0x5ed604[_0x55f870(0xd1)]('/');if(_0x59530b['length']!==0x2)throw new SDKError(ErrorCode[_0x55f870(0xcd)],'Invalid\x20agent\x20reference\x20format:\x20'+_0x5ed604,undefined,{'helpText':_0x55f870(0xe7)});const [_0x450b75,_0xfb9ce9]=_0x59530b;_0xac1c61=await this[_0x55f870(0xed)](_0x450b75),_0x4c3765=_0xfb9ce9;}else _0xac1c61=this['currentProjectId']||(await this['getOrCreateDefaultProject']())['id'],_0x4c3765=_0x5ed604;const _0x5996cc=await this[_0x55f870(0x11c)](_0x4c3765,_0xac1c61),_0x362e67=await this[_0x55f870(0xe2)][_0x55f870(0xff)](_0x5996cc);writeCachedLLMAgent(_0x362e67[_0x55f870(0x14d)][_0x55f870(0xf5)],_0x5996cc,_0xac1c61,_0x353a6c);}[a71_0x429fc8(0x142)](){const _0x4f5002=a71_0x429fc8,_0x520130=this['context'][_0x4f5002(0x12a)];return readCachedLLMAgent(_0x520130)||undefined;}[a71_0x429fc8(0xec)](){const _0x4fd4b1=a71_0x429fc8,_0x5104ea=this[_0x4fd4b1(0x147)]['profile'];clearCachedLLMAgent(_0x5104ea);}async[a71_0x429fc8(0x13e)](){const _0x56ebd4=a71_0x429fc8,_0x20bf9c=await this['client'][_0x56ebd4(0x7c)](),_0x5c1df9=[];for(const _0x5ea0ec of _0x20bf9c[_0x56ebd4(0xb9)]){const _0x2b146e=_0x20bf9c[_0x56ebd4(0x11e)][_0x5ea0ec];_0x2b146e&&_0x5c1df9[_0x56ebd4(0x8e)]({'name':_0x5ea0ec,'displayName':_0x2b146e[_0x56ebd4(0xf2)]});}return _0x5c1df9;}async['createProject'](_0x40ebe0){const _0x2cf998=a71_0x429fc8;return await this[_0x2cf998(0xe2)][_0x2cf998(0x127)](_0x40ebe0);}async['deleteProject'](_0x45e4eb){const _0xdb49d0=a71_0x429fc8,{projectId:_0x428521}=await this[_0xdb49d0(0xda)](_0x45e4eb);await this[_0xdb49d0(0xe2)][_0xdb49d0(0xf1)](_0x428521);}async[a71_0x429fc8(0xb5)](_0x3d341c=0x32){const _0x5e3368=a71_0x429fc8;return await this[_0x5e3368(0xe2)][_0x5e3368(0x131)](_0x3d341c);}async['getOrCreateDefaultProject'](_0x11bb5a){const _0x27d46e=a71_0x429fc8,_0x360b2a=_0x11bb5a||this['getDefaultProjectName'](),_0x53dd5b=this[_0x27d46e(0x147)][_0x27d46e(0x12a)];if(!_0x11bb5a){const _0x407bb3=readCachedLLMProject(_0x53dd5b);if(_0x407bb3&&_0x407bb3[_0x27d46e(0xf5)]===_0x360b2a)try{const _0x256323=await this[_0x27d46e(0xe2)][_0x27d46e(0x110)](_0x407bb3['id']);if(_0x256323[_0x27d46e(0x14d)][_0x27d46e(0xf5)]===_0x360b2a)return _0x256323;}catch{}}const _0x259154=await this[_0x27d46e(0xe2)][_0x27d46e(0x131)](),_0x45d56d=_0x259154[_0x27d46e(0xf8)](_0x38b4ea=>_0x38b4ea['attributes']['name']===_0x360b2a);if(_0x45d56d)return!_0x11bb5a&&writeCachedLLMProject(_0x360b2a,_0x45d56d['id'],_0x53dd5b),_0x45d56d;const _0x22e1b4=await this[_0x27d46e(0xe2)][_0x27d46e(0x127)]({'name':_0x360b2a,'description':_0x27d46e(0x12f)+getSanitizedUsername()+')'});return!_0x11bb5a&&writeCachedLLMProject(_0x360b2a,_0x22e1b4['id'],_0x53dd5b),_0x22e1b4;}async[a71_0x429fc8(0xed)](_0x315a0c){const _0x145d59=a71_0x429fc8,_0x345ebd=await this[_0x145d59(0xe2)][_0x145d59(0x131)](),_0x47360a=_0x345ebd[_0x145d59(0x8a)](_0x1e1032=>_0x1e1032[_0x145d59(0x14d)]['name']===_0x315a0c);if(_0x47360a[_0x145d59(0xb7)]===0x0)throw new SDKError(ErrorCode[_0x145d59(0x13b)],_0x145d59(0x121)+_0x315a0c,undefined,{'helpText':_0x145d59(0x119)});if(_0x47360a['length']>0x1)throw new SDKError(ErrorCode[_0x145d59(0xe1)],'Multiple\x20projects\x20found\x20with\x20name\x20\x27'+_0x315a0c+_0x145d59(0x96));return _0x47360a[0x0]['id'];}async['resolveProjectName'](_0x507f95){const _0x4b016c=a71_0x429fc8,_0x26730e=await this[_0x4b016c(0xe2)][_0x4b016c(0x131)](),_0x3ce993=_0x26730e['find'](_0x1f3685=>_0x1f3685[_0x4b016c(0x14d)][_0x4b016c(0xf5)]===_0x507f95);if(_0x3ce993)return{'projectId':_0x3ce993['id'],'project':_0x3ce993};throw new SDKError(ErrorCode[_0x4b016c(0x13b)],_0x4b016c(0x121)+_0x507f95,undefined,{'helpText':_0x4b016c(0x119)});}async[a71_0x429fc8(0x138)](_0x3da716=a71_0x429fc8(0xbb),_0x40b269=0x0,_0x13517a){const _0x5445af=a71_0x429fc8,_0x2e9906=0xa;let _0xd41bbe=0x0,_0x49a07c;while(_0xd41bbe<_0x2e9906){try{const _0x1dcfce=await this[_0x5445af(0x140)](_0x49a07c),_0x381367=_0x1dcfce['id'],_0xfda431=[_0x5445af(0x74),_0x5445af(0xa0),_0x5445af(0xbd),'medium',_0x5445af(0x81)],_0x4657f4=_0x40b269===0x0?_0x5445af(0x128)+_0x3da716:_0x5445af(0x128)+_0x3da716+'_reasoning_'+_0xfda431[_0x40b269],_0x3b2cd7=await this['client'][_0x5445af(0x118)](_0x381367),_0x4a7206=_0x3b2cd7[_0x5445af(0xf8)](_0x368292=>_0x368292[_0x5445af(0x14d)][_0x5445af(0xf5)]===_0x4657f4);if(_0x4a7206)return _0x4a7206;const _0x4a1a79=_0x40b269>0x0?0x1:_0x13517a;return await this[_0x5445af(0xe2)][_0x5445af(0x9d)]({'name':_0x4657f4,'projectId':_0x381367,'modelType':_0x3da716,'systemPrompt':'','temperature':_0x4a1a79,'reasoningEffort':_0x40b269>0x0?_0x40b269:undefined});}catch(_0x2507ad){if(_0x2507ad instanceof HTTPClientError){const _0x176e8a=_0x2507ad[_0x5445af(0x149)];if(_0x176e8a>=0x190&&_0x176e8a<0x1f4){if(_0x176e8a===0x191)throw new SDKError(ErrorCode[_0x5445af(0xc0)],'Authentication\x20failed.\x20Please\x20check\x20your\x20API\x20key\x20is\x20valid\x20and\x20not\x20expired.',_0x2507ad);else{if(_0x176e8a===0x193)throw new SDKError(ErrorCode['PERMISSION_DENIED'],'Permission\x20denied.\x20Please\x20check\x20your\x20API\x20key\x20has\x20the\x20required\x20permissions\x20for\x20LLM\x20API\x20operations.',_0x2507ad);}throw _0x2507ad;}}if(errorContains(_0x2507ad,_0x5445af(0xfa),_0x5445af(0x100),_0x5445af(0x7a))){_0xd41bbe++;if(_0xd41bbe>=_0x2e9906)throw new SDKError(ErrorCode[_0x5445af(0x6e)],_0x5445af(0x85)+_0x2e9906+_0x5445af(0x113),_0x2507ad);const _0x2e8536=this[_0x5445af(0xa9)]();_0x49a07c=_0x2e8536+'_'+generateRandomHex();continue;}throw _0x2507ad;}}throw new SDKError(ErrorCode[_0x5445af(0xe1)],_0x5445af(0x146));}async[a71_0x429fc8(0x11c)](_0x3fabba,_0x5ba375){const _0x506429=a71_0x429fc8,_0x1093a3=_0x5ba375||this[_0x506429(0x97)],_0x19a259=await this['client']['listAgents'](_0x1093a3),_0x351e14=_0x19a259[_0x506429(0x8a)](_0x885566=>_0x885566[_0x506429(0x14d)][_0x506429(0xf5)]===_0x3fabba);if(_0x351e14[_0x506429(0xb7)]===0x0){const _0x3fdae1=_0x1093a3?'\x20in\x20project\x20'+_0x1093a3:'';throw new SDKError(ErrorCode['AGENT_NOT_FOUND'],_0x506429(0x13f)+_0x3fabba+_0x3fdae1,undefined,{'helpText':_0x1093a3?_0x506429(0x120):_0x506429(0x9b)});}if(_0x351e14[_0x506429(0xb7)]>0x1)throw new SDKError(ErrorCode[_0x506429(0xe1)],_0x506429(0xc1)+_0x3fabba+_0x506429(0x96));return _0x351e14[0x0]['id'];}async[a71_0x429fc8(0xa8)](_0x28606e){const _0x3ceeff=_0x28606e||this['currentProjectId'];return await this['client']['listAgents'](_0x3ceeff);}async[a71_0x429fc8(0x139)](_0x277306){const _0xbdcf9e=a71_0x429fc8;return await this[_0xbdcf9e(0xe2)][_0xbdcf9e(0xff)](_0x277306);}async[a71_0x429fc8(0x9d)](_0x15b036){const _0x2be94d=a71_0x429fc8;return await this[_0x2be94d(0xe2)]['createAgent'](_0x15b036);}async['updateAgent'](_0x2ad896,_0x10f5c0){const _0x426642=a71_0x429fc8;return await this[_0x426642(0xe2)][_0x426642(0x123)](_0x2ad896,_0x10f5c0);}async[a71_0x429fc8(0x89)](_0x1a786b){const _0x267d4e=a71_0x429fc8;await this[_0x267d4e(0xe2)]['deleteAgent'](_0x1a786b);}async['startChat'](_0x3a732b){const _0x5e3820=a71_0x429fc8;return await this[_0x5e3820(0xe2)]['startChat']({'agentId':_0x3a732b});}async*[a71_0x429fc8(0x94)](_0x594918,_0x34c02e){const _0x44e11d=a71_0x429fc8;let _0x23f509=_0x34c02e?.['chatId'];const _0x1ea32b=_0x34c02e?.[_0x44e11d(0x90)];if(!_0x23f509){if(!_0x1ea32b)throw new Error(_0x44e11d(0x116));const _0x18bfc4=await this['client'][_0x44e11d(0xcf)]({'agentId':_0x1ea32b});_0x23f509=_0x18bfc4['id'],yield{'type':_0x44e11d(0xfb),'data':{'chatId':_0x23f509,'agentId':_0x1ea32b}};}for await(const _0x3b9d34 of this['client'][_0x44e11d(0x71)](_0x23f509,_0x594918,_0x34c02e?.[_0x44e11d(0xd2)])){yield{'type':_0x44e11d(0xf7),'data':_0x3b9d34};}}async[a71_0x429fc8(0x76)](_0x2c8e88=0x32){const _0x3507a4=a71_0x429fc8;return await this[_0x3507a4(0xe2)][_0x3507a4(0xd9)](_0x2c8e88);}async[a71_0x429fc8(0x9e)](_0x1a7903){const _0x5bbc9f=a71_0x429fc8;return await this[_0x5bbc9f(0xe2)]['getChatHistory'](_0x1a7903);}async[a71_0x429fc8(0x87)](_0x43177a){const _0x4fca39=a71_0x429fc8;return await this[_0x4fca39(0xe2)][_0x4fca39(0x13c)](_0x43177a);}async[a71_0x429fc8(0xe9)](_0x48721e,_0x485397,_0x485760){const _0x3233b6=a71_0x429fc8,_0x103468=_0x485760?.['dryRun']??![],{projectId:_0x3e0051,project:_0x41b985}=await this[_0x3233b6(0xda)](_0x48721e),_0x34fe8c=_0x41b985[_0x3233b6(0x14d)][_0x3233b6(0xf5)],_0x3f3492=_0x485397||_0x34fe8c+_0x3233b6(0xbc);if(a71_0x482401['existsSync'](_0x3f3492)&&!_0x103468)throw new SDKError(ErrorCode[_0x3233b6(0x6e)],_0x3233b6(0x6c)+_0x3f3492,undefined,{'helpText':_0x3233b6(0x125)});const _0x46fb23=await this[_0x3233b6(0xe2)][_0x3233b6(0xe5)](_0x3e0051),_0x54bdc8=await this[_0x3233b6(0xe2)]['listKnowledgeBases'](_0x3e0051),_0x7c64e3=await this[_0x3233b6(0xe2)][_0x3233b6(0xc5)](_0x3e0051),_0x253453=await this[_0x3233b6(0xe2)][_0x3233b6(0xbe)](_0x3e0051);if(!_0x103468){a71_0x482401[_0x3233b6(0x6d)](_0x3f3492,{'recursive':!![]});const _0x318108={'version':'1.0','exportedAt':new Date()[_0x3233b6(0x144)](),'exportedFrom':{'site':this[_0x3233b6(0x147)]['site'],'projectId':_0x3e0051,'projectName':_0x34fe8c},'project':_0x41b985};a71_0x482401[_0x3233b6(0x7b)](a71_0x1b8025['join'](_0x3f3492,'project.json'),JSON[_0x3233b6(0x101)](_0x318108,null,0x2)),a71_0x482401['writeFileSync'](a71_0x1b8025['join'](_0x3f3492,_0x3233b6(0xbf)),JSON[_0x3233b6(0x101)](_0x46fb23,null,0x2)),a71_0x482401[_0x3233b6(0x7b)](a71_0x1b8025[_0x3233b6(0xa5)](_0x3f3492,_0x3233b6(0xb4)),JSON[_0x3233b6(0x101)](_0x54bdc8,null,0x2)),a71_0x482401['writeFileSync'](a71_0x1b8025[_0x3233b6(0xa5)](_0x3f3492,_0x3233b6(0x12d)),JSON['stringify'](_0x7c64e3,null,0x2)),a71_0x482401[_0x3233b6(0x7b)](a71_0x1b8025[_0x3233b6(0xa5)](_0x3f3492,_0x3233b6(0xaa)),JSON[_0x3233b6(0x101)](_0x253453,null,0x2));}return{'projectName':_0x34fe8c,'outputDir':_0x3f3492,'counts':{'agents':_0x46fb23['length'],'knowledgeBases':_0x54bdc8[_0x3233b6(0xb7)],'prompts':_0x7c64e3[_0x3233b6(0xb7)],'integrations':_0x253453[_0x3233b6(0xb7)]}};}async[a71_0x429fc8(0xc2)](_0x21b5db,_0xaec9c4){const _0x1321d4=a71_0x429fc8,_0x14ca9f=_0xaec9c4?.['dryRun']??![],_0x4f9482=this['getBackupMetadata'](_0x21b5db),_0x4e873e=_0x4f9482[_0x1321d4(0x126)][_0x1321d4(0xd8)],_0x2b06cf=this[_0x1321d4(0x147)][_0x1321d4(0xd8)],_0x599b72=_0x4e873e!==_0x2b06cf?_0x4e873e:undefined,_0x2a82ac=this[_0x1321d4(0x124)](a71_0x1b8025[_0x1321d4(0xa5)](_0x21b5db,_0x1321d4(0xbf)),[]),_0x1b29d1=this[_0x1321d4(0x124)](a71_0x1b8025[_0x1321d4(0xa5)](_0x21b5db,_0x1321d4(0xb4)),[]),_0x52edb0=this[_0x1321d4(0x124)](a71_0x1b8025['join'](_0x21b5db,_0x1321d4(0x12d)),[]),_0x53e724=this['loadJsonFile'](a71_0x1b8025[_0x1321d4(0xa5)](_0x21b5db,_0x1321d4(0xaa)),[]),_0x826576=_0xaec9c4?.['name']||_0x4f9482['exportedFrom']['projectName'];if(_0x14ca9f){const _0x1aaed7=new Map(),_0x3577ee=[..._0x2a82ac],_0x2e515f=_0x2a82ac[_0x1321d4(0xb7)]+0x1;let _0x506c4c=0x0;while(_0x3577ee[_0x1321d4(0xb7)]>0x0&&_0x506c4c<_0x2e515f){_0x506c4c++;const _0x3ec94b=[];for(const _0x5b523a of _0x3577ee){canCreateAgent(_0x5b523a,_0x1aaed7)?_0x1aaed7[_0x1321d4(0x14b)](_0x5b523a['id'],'dry-run-'+_0x5b523a['id']):_0x3ec94b[_0x1321d4(0x8e)](_0x5b523a);}if(_0x3ec94b[_0x1321d4(0xb7)]===_0x3577ee[_0x1321d4(0xb7)])throw new SDKError(ErrorCode[_0x1321d4(0xe1)],_0x1321d4(0x83),undefined,{'helpText':_0x1321d4(0xa3)});_0x3577ee[_0x1321d4(0xb7)]=0x0,_0x3577ee[_0x1321d4(0x8e)](..._0x3ec94b);}const _0x3307e3=_0x52edb0[_0x1321d4(0x8a)](_0x202989=>_0x1aaed7[_0x1321d4(0x137)](_0x202989[_0x1321d4(0x14d)][_0x1321d4(0x90)]))[_0x1321d4(0xb7)];return{'projectName':_0x826576,'projectId':_0x1321d4(0xad),'counts':{'agents':_0x2a82ac[_0x1321d4(0xb7)],'knowledgeBases':_0x1b29d1[_0x1321d4(0xb7)],'prompts':_0x3307e3,'integrations':_0x53e724[_0x1321d4(0xb7)]},'sourceSite':_0x599b72};}const _0x18bfa3=await this['client']['createProject']({'name':_0x826576,'description':_0x4f9482[_0x1321d4(0xd4)][_0x1321d4(0x14d)][_0x1321d4(0xee)]}),_0x24aec1=_0x18bfa3['id'],_0x59c8da=new Map(),_0xbb37fc=new Map(),_0x4246c7=new Map();for(const _0x493115 of _0x1b29d1){const _0x4ce03f=await this[_0x1321d4(0xe2)][_0x1321d4(0x12e)]({'projectId':_0x24aec1,'name':_0x493115[_0x1321d4(0x14d)][_0x1321d4(0xf5)],'tdDatabaseName':_0x493115[_0x1321d4(0x14d)]['tdDatabaseName'],'tables':_0x493115[_0x1321d4(0x14d)]['tables']});_0x59c8da[_0x1321d4(0x14b)](_0x493115['id'],_0x4ce03f['id']);}const _0x352845=[..._0x2a82ac],_0x279f37=_0x2a82ac[_0x1321d4(0xb7)]+0x1;let _0x1d90fd=0x0;while(_0x352845['length']>0x0&&_0x1d90fd<_0x279f37){_0x1d90fd++;const _0x27a5b7=[];for(const _0x79e82b of _0x352845){if(canCreateAgent(_0x79e82b,_0xbb37fc)){const _0x5dadf8=remapToolIds(_0x79e82b[_0x1321d4(0x14d)][_0x1321d4(0x133)],_0x59c8da,_0xbb37fc),_0x3024d0=remapVariableIds(_0x79e82b['attributes'][_0x1321d4(0xf0)],_0x59c8da),_0xed24d5=await this[_0x1321d4(0xe2)][_0x1321d4(0x10c)]({'name':_0x79e82b[_0x1321d4(0x14d)][_0x1321d4(0xf5)],'projectId':_0x24aec1,'systemPrompt':_0x79e82b[_0x1321d4(0x14d)][_0x1321d4(0xfe)],'starterMessage':_0x79e82b['attributes'][_0x1321d4(0x143)],'modelType':migrateModelType(_0x79e82b[_0x1321d4(0x14d)][_0x1321d4(0x111)]),'maxToolIterations':_0x79e82b[_0x1321d4(0x14d)]['maxToolIterations'],'temperature':_0x79e82b[_0x1321d4(0x14d)][_0x1321d4(0xf9)],'reasoningEffort':_0x79e82b[_0x1321d4(0x14d)][_0x1321d4(0x102)],'outputs':_0x79e82b[_0x1321d4(0x14d)][_0x1321d4(0xba)],'tools':_0x5dadf8,'variables':_0x3024d0});_0xbb37fc[_0x1321d4(0x14b)](_0x79e82b['id'],_0xed24d5['id']);}else _0x27a5b7[_0x1321d4(0x8e)](_0x79e82b);}if(_0x27a5b7[_0x1321d4(0xb7)]===_0x352845[_0x1321d4(0xb7)])throw new SDKError(ErrorCode[_0x1321d4(0xe1)],_0x1321d4(0x83),undefined,{'helpText':_0x1321d4(0xa3)});_0x352845['length']=0x0,_0x352845[_0x1321d4(0x8e)](..._0x27a5b7);}for(const _0x5d88f3 of _0x52edb0){const _0x150b8a=_0xbb37fc[_0x1321d4(0xa4)](_0x5d88f3[_0x1321d4(0x14d)][_0x1321d4(0x90)]);if(!_0x150b8a)continue;const _0x49beff=await this[_0x1321d4(0xe2)][_0x1321d4(0xb6)]({'projectId':_0x24aec1,'agentId':_0x150b8a,'name':_0x5d88f3[_0x1321d4(0x14d)]['name'],'systemPrompt':_0x5d88f3[_0x1321d4(0x14d)]['systemPrompt'],'template':_0x5d88f3[_0x1321d4(0x14d)][_0x1321d4(0xdb)],'jsonSchemaHint':_0x5d88f3['attributes'][_0x1321d4(0xfd)]});_0x4246c7[_0x1321d4(0x14b)](_0x5d88f3['id'],_0x49beff['id']);}for(const _0x11c16b of _0x53e724){const _0x2181d9=_0x11c16b[_0x1321d4(0x14d)][_0x1321d4(0x106)]['map'](_0x4f5b4e=>({..._0x4f5b4e,'promptId':_0x4246c7[_0x1321d4(0xa4)](_0x4f5b4e[_0x1321d4(0x107)])||_0x4f5b4e['promptId']}));await this[_0x1321d4(0xe2)][_0x1321d4(0x8c)]({'projectId':_0x24aec1,'serviceType':_0x11c16b[_0x1321d4(0x14d)][_0x1321d4(0x82)],'actions':_0x2181d9,'slackMessageMode':_0x11c16b[_0x1321d4(0x14d)]['slackMessageMode'],'chatIgnoreManagedActions':_0x11c16b['attributes'][_0x1321d4(0xf3)],'chatWelcomeMessage':_0x11c16b[_0x1321d4(0x14d)][_0x1321d4(0x105)],'webhookCorsOrigins':_0x11c16b[_0x1321d4(0x14d)]['webhookCorsOrigins']});}return{'projectName':_0x826576,'projectId':_0x24aec1,'counts':{'agents':_0xbb37fc[_0x1321d4(0xb0)],'knowledgeBases':_0x59c8da[_0x1321d4(0xb0)],'prompts':_0x4246c7[_0x1321d4(0xb0)],'integrations':_0x53e724[_0x1321d4(0xb7)]},'sourceSite':_0x599b72};}[a71_0x429fc8(0x124)](_0x2cd02a,_0x1abaf9){const _0x29d878=a71_0x429fc8;if(!a71_0x482401[_0x29d878(0x98)](_0x2cd02a))return _0x1abaf9;return JSON[_0x29d878(0x12b)](a71_0x482401['readFileSync'](_0x2cd02a,_0x29d878(0xc7)));}[a71_0x429fc8(0x11f)](_0x4ee19c){const _0x3d972e=a71_0x429fc8;if(!a71_0x482401[_0x3d972e(0x98)](_0x4ee19c))throw new SDKError(ErrorCode[_0x3d972e(0x10a)],_0x3d972e(0xae)+_0x4ee19c,undefined,{'helpText':'Ensure\x20the\x20backup\x20folder\x20path\x20is\x20correct.'});const _0x5fae66=a71_0x1b8025[_0x3d972e(0xa5)](_0x4ee19c,_0x3d972e(0x114));if(!a71_0x482401[_0x3d972e(0x98)](_0x5fae66))throw new SDKError(ErrorCode[_0x3d972e(0xcd)],_0x3d972e(0xd6)+_0x4ee19c,undefined,{'helpText':_0x3d972e(0xe8)});const _0x4670aa=JSON[_0x3d972e(0x12b)](a71_0x482401[_0x3d972e(0x148)](_0x5fae66,_0x3d972e(0xc7)));if(!isSupportedBackupVersion(_0x4670aa[_0x3d972e(0x88)]))throw new SDKError(ErrorCode['INVALID_ARGUMENT'],_0x3d972e(0x130)+_0x4670aa[_0x3d972e(0x88)],undefined,{'helpText':_0x3d972e(0xa7)});return _0x4670aa;}async[a71_0x429fc8(0xf4)](_0x2dc30c,_0x3264fd,_0x1e2c90){const _0x30468f=a71_0x429fc8,{projectId:_0x3f8c19,project:_0xea036e}=await this['resolveProjectName'](_0x2dc30c),_0x4e31a4=_0xea036e[_0x30468f(0x14d)][_0x30468f(0xf5)],_0xa48580=normalizeName(_0x4e31a4),_0x112b4c=_0x3264fd||a71_0x1b8025[_0x30468f(0xa5)](process[_0x30468f(0x7e)](),_0x30468f(0xa8),_0xa48580),_0x374cbc=await this[_0x30468f(0xe2)][_0x30468f(0xe5)](_0x3f8c19),_0x3697ee=await this[_0x30468f(0xe2)][_0x30468f(0x10e)](_0x3f8c19),_0x14cdd4=await this[_0x30468f(0xe2)][_0x30468f(0x92)](_0x3f8c19),_0x1262b5=await this[_0x30468f(0xe2)][_0x30468f(0x8f)](_0x3f8c19),_0x3377c8=await this[_0x30468f(0xe2)][_0x30468f(0x108)](_0x3f8c19),_0xd7879c=await this[_0x30468f(0xe2)][_0x30468f(0xc5)](_0x3f8c19),_0x13f594=new Map(),_0x18c7c6=new Map(),_0x154645=new Map(),_0xcfd718=new Map(),_0x456265=new Map(),_0x766503=new Map();for(const _0x4c4905 of _0x374cbc){_0x13f594['set'](_0x4c4905['id'],_0x4c4905[_0x30468f(0x14d)]['name']);}for(const _0x4fe4b2 of _0x3697ee){_0x18c7c6[_0x30468f(0x14b)](_0x4fe4b2['id'],_0x4fe4b2[_0x30468f(0x14d)]['name']);}for(const _0x13a218 of _0x14cdd4){_0x154645[_0x30468f(0x14b)](_0x13a218['id'],_0x13a218[_0x30468f(0x14d)][_0x30468f(0xf5)]);}for(const _0x342ebb of _0x1262b5){_0xcfd718[_0x30468f(0x14b)](_0x342ebb['id'],_0x342ebb['attributes'][_0x30468f(0xf5)]);}for(const _0xd6b279 of _0x3377c8){_0x456265[_0x30468f(0x14b)](_0xd6b279['id'],_0xd6b279[_0x30468f(0x14d)]['name']);}for(const _0x254a1b of _0xd7879c){_0x766503['set'](_0x254a1b['id'],_0x254a1b['attributes'][_0x30468f(0xf5)]);}const _0x58e8b5={'resolveKnowledgeBaseName':async _0x3823de=>_0x18c7c6[_0x30468f(0xa4)](_0x3823de),'resolveTextKnowledgeBaseName':async _0x50dfc5=>_0x154645[_0x30468f(0xa4)](_0x50dfc5),'resolveAgentName':async _0x88c446=>_0x13f594['get'](_0x88c446),'resolveWebSearchToolName':async _0x37432f=>_0x456265[_0x30468f(0xa4)](_0x37432f),'resolveImageGeneratorName':async _0x165248=>_0xcfd718[_0x30468f(0xa4)](_0x165248),'resolvePromptName':async _0x52482f=>_0x766503[_0x30468f(0xa4)](_0x52482f),'onWarning':_0x99ea06=>this[_0x30468f(0x147)][_0x30468f(0xdf)]?.[_0x30468f(0x136)](_0x99ea06)},_0x49ebaa={'projectName':_0x4e31a4,'outputDir':_0x112b4c,'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}}},_0x3dcb63=[],_0x1c2025=new UniqueNameGenerator(),_0xd2fc0c=new UniqueNameGenerator(),_0x141026=new UniqueNameGenerator(),_0x4fe92f=new UniqueNameGenerator();for(const _0x21aa23 of _0x374cbc){const _0x4fbc72=_0x1c2025[_0x30468f(0x91)](_0x21aa23[_0x30468f(0x14d)][_0x30468f(0xf5)]),_0x215972=a71_0x1b8025[_0x30468f(0xa5)](_0x112b4c,_0x4fbc72),_0x29880e=a71_0x1b8025[_0x30468f(0xa5)](_0x215972,_0x30468f(0x122)),_0x2b6f83=a71_0x1b8025[_0x30468f(0xa5)](_0x215972,_0x30468f(0x11a)),_0x178f6d=a71_0x1b8025[_0x30468f(0xa5)](_0x215972,_0x30468f(0xd5)),{yaml:_0x83038,systemPrompt:_0x21e09f,starterMessage:_0x4b03f0}=await apiAgentToYaml(_0x21aa23,_0x58e8b5),_0x283f3d=toAgentYamlString(_0x83038),_0x450ed8=!a71_0x482401[_0x30468f(0x98)](_0x2b6f83);let _0x124373=_0x450ed8,_0x8d1115;if(!_0x450ed8){const _0x32c818=a71_0x482401[_0x30468f(0x98)](_0x29880e)?a71_0x482401[_0x30468f(0x148)](_0x29880e,_0x30468f(0xc7)):'',_0x125b0e=a71_0x482401[_0x30468f(0x148)](_0x2b6f83,_0x30468f(0xc7)),_0x241b92='#\x20prompt.md\x0a'+_0x32c818+_0x30468f(0x99)+_0x125b0e,_0xd46cf2='#\x20prompt.md\x0a'+_0x21e09f+_0x30468f(0x99)+_0x283f3d,_0x5407a8=generateDiff(_0x241b92,_0xd46cf2);_0x124373=hasChanges(_0x5407a8),_0x124373&&(_0x8d1115=formatDiffWithColors(_0x5407a8));}_0x3dcb63[_0x30468f(0x8e)]({'path':_0x215972,'content':'','isDir':!![]}),_0x3dcb63[_0x30468f(0x8e)]({'path':_0x29880e,'content':_0x21e09f}),_0x3dcb63[_0x30468f(0x8e)]({'path':_0x2b6f83,'content':_0x283f3d});_0x4b03f0&&_0x4b03f0[_0x30468f(0x132)]('\x0a')&&_0x3dcb63[_0x30468f(0x8e)]({'path':_0x178f6d,'content':_0x4b03f0});_0x49ebaa[_0x30468f(0xa8)][_0x30468f(0x8e)]({'agentName':_0x21aa23[_0x30468f(0x14d)]['name'],'outputPath':_0x215972,'isNew':_0x450ed8,'hasChanges':_0x124373,'diff':_0x8d1115}),_0x49ebaa[_0x30468f(0x13d)][_0x30468f(0xa8)][_0x30468f(0xc8)]++;if(_0x450ed8)_0x49ebaa[_0x30468f(0x13d)][_0x30468f(0xa8)][_0x30468f(0x86)]++;else{if(_0x124373)_0x49ebaa[_0x30468f(0x13d)][_0x30468f(0xa8)][_0x30468f(0xfc)]++;else _0x49ebaa[_0x30468f(0x13d)][_0x30468f(0xa8)][_0x30468f(0x77)]++;}}for(const _0x20bc4e of _0x3697ee){if(_0x20bc4e['attributes'][_0x30468f(0x70)])continue;const _0xef8f11=_0xd2fc0c['getUniqueName'](_0x20bc4e[_0x30468f(0x14d)]['name']),_0x12a785=a71_0x1b8025[_0x30468f(0xa5)](getKnowledgeBasesDir(_0x112b4c),_0xef8f11+_0x30468f(0xcc)),_0x1b2508=apiKnowledgeBaseToYaml(_0x20bc4e),_0x1050c4=toKnowledgeBaseYamlString(_0x1b2508),_0x426292=!a71_0x482401[_0x30468f(0x98)](_0x12a785);let _0x4946db=_0x426292,_0x4bd31c;if(!_0x426292){const _0x3de633=a71_0x482401[_0x30468f(0x148)](_0x12a785,'utf-8'),_0xba0216=generateDiff(_0x3de633,_0x1050c4);_0x4946db=hasChanges(_0xba0216),_0x4946db&&(_0x4bd31c=formatDiffWithColors(_0xba0216));}_0x3dcb63['push']({'path':_0x12a785,'content':_0x1050c4}),_0x49ebaa['knowledgeBases'][_0x30468f(0x8e)]({'name':_0x20bc4e[_0x30468f(0x14d)][_0x30468f(0xf5)],'outputPath':_0x12a785,'isNew':_0x426292,'hasChanges':_0x4946db,'diff':_0x4bd31c}),_0x49ebaa[_0x30468f(0x13d)][_0x30468f(0xf6)]['total']++;if(_0x426292)_0x49ebaa['counts'][_0x30468f(0xf6)]['new']++;else{if(_0x4946db)_0x49ebaa[_0x30468f(0x13d)][_0x30468f(0xf6)][_0x30468f(0xfc)]++;else _0x49ebaa['counts']['knowledgeBases'][_0x30468f(0x77)]++;}}for(const _0xbdc9c5 of _0x14cdd4){if(_0xbdc9c5[_0x30468f(0x14d)][_0x30468f(0x70)])continue;const _0x4fe1f7=_0x141026['getUniqueName'](_0xbdc9c5[_0x30468f(0x14d)][_0x30468f(0xf5)]),_0x1f5225=a71_0x1b8025[_0x30468f(0xa5)](getKnowledgeBasesDir(_0x112b4c),_0x4fe1f7+_0x30468f(0xe4)),_0x566658=toTextKnowledgeBaseMd(_0xbdc9c5[_0x30468f(0x14d)][_0x30468f(0xf5)],_0xbdc9c5[_0x30468f(0x14d)][_0x30468f(0x8b)]),_0x79dbf5=!a71_0x482401[_0x30468f(0x98)](_0x1f5225);let _0x5b15dd=_0x79dbf5,_0x1d2edb;if(!_0x79dbf5){const _0x48855c=a71_0x482401[_0x30468f(0x148)](_0x1f5225,'utf-8'),_0x34bc23=generateDiff(_0x48855c,_0x566658);_0x5b15dd=hasChanges(_0x34bc23),_0x5b15dd&&(_0x1d2edb=formatDiffWithColors(_0x34bc23));}_0x3dcb63[_0x30468f(0x8e)]({'path':_0x1f5225,'content':_0x566658}),_0x49ebaa[_0x30468f(0xb3)][_0x30468f(0x8e)]({'name':_0xbdc9c5['attributes']['name'],'outputPath':_0x1f5225,'isNew':_0x79dbf5,'hasChanges':_0x5b15dd,'diff':_0x1d2edb}),_0x49ebaa[_0x30468f(0x13d)][_0x30468f(0xb3)][_0x30468f(0xc8)]++;if(_0x79dbf5)_0x49ebaa[_0x30468f(0x13d)][_0x30468f(0xb3)][_0x30468f(0x86)]++;else{if(_0x5b15dd)_0x49ebaa[_0x30468f(0x13d)][_0x30468f(0xb3)]['updated']++;else _0x49ebaa['counts'][_0x30468f(0xb3)][_0x30468f(0x77)]++;}}for(const _0x13a5d5 of _0xd7879c){if(_0x13a5d5[_0x30468f(0x14d)][_0x30468f(0x70)])continue;const _0x3b86c4=_0x4fe92f[_0x30468f(0x91)](_0x13a5d5[_0x30468f(0x14d)][_0x30468f(0xf5)]),_0x1efd79=a71_0x1b8025['join'](getPromptsDir(_0x112b4c),_0x3b86c4+_0x30468f(0xcc)),_0x13ac2a=await apiPromptToYaml(_0x13a5d5,_0x58e8b5);if(!_0x13ac2a)continue;const _0x578143=toPromptYamlString(_0x13ac2a),_0x51cd41=!a71_0x482401[_0x30468f(0x98)](_0x1efd79);let _0x398477=_0x51cd41,_0x372d21;if(!_0x51cd41){const _0xd316b7=a71_0x482401['readFileSync'](_0x1efd79,_0x30468f(0xc7)),_0xbb6065=generateDiff(_0xd316b7,_0x578143);_0x398477=hasChanges(_0xbb6065),_0x398477&&(_0x372d21=formatDiffWithColors(_0xbb6065));}_0x3dcb63['push']({'path':_0x1efd79,'content':_0x578143}),_0x49ebaa[_0x30468f(0x129)][_0x30468f(0x8e)]({'name':_0x13a5d5[_0x30468f(0x14d)][_0x30468f(0xf5)],'outputPath':_0x1efd79,'isNew':_0x51cd41,'hasChanges':_0x398477,'diff':_0x372d21}),_0x49ebaa['counts'][_0x30468f(0x129)][_0x30468f(0xc8)]++;if(_0x51cd41)_0x49ebaa['counts'][_0x30468f(0x129)][_0x30468f(0x86)]++;else{if(_0x398477)_0x49ebaa[_0x30468f(0x13d)][_0x30468f(0x129)][_0x30468f(0xfc)]++;else _0x49ebaa[_0x30468f(0x13d)][_0x30468f(0x129)][_0x30468f(0x77)]++;}}if(_0x1e2c90?.[_0x30468f(0xdc)])return _0x49ebaa;a71_0x482401[_0x30468f(0x6d)](_0x112b4c,{'recursive':!![]}),a71_0x482401[_0x30468f(0x6d)](getKnowledgeBasesDir(_0x112b4c),{'recursive':!![]}),a71_0x482401[_0x30468f(0x6d)](getPromptsDir(_0x112b4c),{'recursive':!![]});const _0x3aa26e=a71_0x1b8025[_0x30468f(0xa5)](_0x112b4c,_0x30468f(0x9f));a71_0x482401[_0x30468f(0x7b)](_0x3aa26e,createAgentConfigContent(_0x4e31a4));for(const _0x4fc076 of _0x3dcb63){if(_0x4fc076[_0x30468f(0xc3)])a71_0x482401[_0x30468f(0x6d)](_0x4fc076['path'],{'recursive':!![]});else{const _0x5d8b49=a71_0x1b8025[_0x30468f(0x134)](_0x4fc076['path']);!a71_0x482401[_0x30468f(0x98)](_0x5d8b49)&&a71_0x482401['mkdirSync'](_0x5d8b49,{'recursive':!![]}),a71_0x482401['writeFileSync'](_0x4fc076[_0x30468f(0x72)],_0x4fc076[_0x30468f(0x11b)]);}}return _0x49ebaa;}async['pushProject'](_0x36eb99,_0x4d2f13){const _0x5c059c=a71_0x429fc8,_0x5b1736=a71_0x1b8025[_0x5c059c(0xa5)](_0x36eb99,_0x5c059c(0x9f));if(!a71_0x482401['existsSync'](_0x5b1736))throw new SDKError(ErrorCode[_0x5c059c(0xcd)],_0x5c059c(0xde)+_0x36eb99,undefined,{'helpText':_0x5c059c(0x115)});const _0x56bb8d=loadAgentConfig(_0x5b1736),_0x2d0591=await this[_0x5c059c(0xed)](_0x56bb8d[_0x5c059c(0x103)]),_0x126f98=await this[_0x5c059c(0xe2)][_0x5c059c(0x110)](_0x2d0591),_0x301fff=_0x126f98[_0x5c059c(0x14d)][_0x5c059c(0xf5)],_0x114899={'projectName':_0x301fff,'projectId':_0x2d0591,'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}}},_0xbaf231=[],_0x2bcca8=[],_0x16e000=[],_0x5664de=[],_0x5df6d8=a71_0x482401[_0x5c059c(0xa1)](_0x36eb99,{'withFileTypes':!![]});for(const _0x1d1cf7 of _0x5df6d8){if(!_0x1d1cf7[_0x5c059c(0x78)]())continue;if([_0x5c059c(0x95),'prompts','integrations']['includes'](_0x1d1cf7[_0x5c059c(0xf5)]))continue;const _0x20a025=a71_0x1b8025[_0x5c059c(0xa5)](_0x36eb99,_0x1d1cf7[_0x5c059c(0xf5)]);if(isAgentDir(_0x20a025)){const _0x494e97=a71_0x1b8025[_0x5c059c(0xa5)](_0x20a025,_0x5c059c(0x11a)),_0x260e1d=a71_0x1b8025['join'](_0x20a025,_0x5c059c(0x122)),_0x41f692=a71_0x1b8025['join'](_0x20a025,_0x5c059c(0xd5)),_0x26671a=parseAgentYaml(a71_0x482401[_0x5c059c(0x148)](_0x494e97,_0x5c059c(0xc7)),_0x494e97),_0x43dab8=a71_0x482401[_0x5c059c(0x98)](_0x260e1d)?a71_0x482401['readFileSync'](_0x260e1d,_0x5c059c(0xc7)):'',_0x150b93=a71_0x482401[_0x5c059c(0x98)](_0x41f692)?a71_0x482401[_0x5c059c(0x148)](_0x41f692,_0x5c059c(0xc7)):_0x26671a['starter_message'];_0xbaf231[_0x5c059c(0x8e)]({'name':_0x26671a['name'],'dir':_0x20a025,'yaml':_0x26671a,'systemPrompt':_0x43dab8,'starterMessage':_0x150b93});}}const _0x1259f7=getKnowledgeBasesDir(_0x36eb99);if(a71_0x482401['existsSync'](_0x1259f7)){const _0x24a820=a71_0x482401['readdirSync'](_0x1259f7);for(const _0x110968 of _0x24a820){const _0x381e0b=a71_0x1b8025[_0x5c059c(0xa5)](_0x1259f7,_0x110968);if(_0x110968[_0x5c059c(0x14c)]('.yml')){const _0x406bd6=parseKnowledgeBaseYaml(a71_0x482401[_0x5c059c(0x148)](_0x381e0b,_0x5c059c(0xc7)),_0x381e0b);_0x2bcca8[_0x5c059c(0x8e)]({'name':_0x406bd6[_0x5c059c(0xf5)],'path':_0x381e0b,'yaml':_0x406bd6});}else{if(_0x110968[_0x5c059c(0x14c)]('.md')){const _0x3352b9=a71_0x482401[_0x5c059c(0x148)](_0x381e0b,_0x5c059c(0xc7)),{name:_0x310510,text:_0x25f7d5}=parseTextKnowledgeBaseMd(_0x3352b9,_0x110968);_0x16e000[_0x5c059c(0x8e)]({'name':_0x310510,'path':_0x381e0b,'text':_0x25f7d5});}}}}const _0x45f46f=getPromptsDir(_0x36eb99);if(a71_0x482401['existsSync'](_0x45f46f)){const _0x4ba3b1=a71_0x482401['readdirSync'](_0x45f46f)[_0x5c059c(0x8a)](_0x402fd6=>_0x402fd6[_0x5c059c(0x14c)](_0x5c059c(0xcc)));for(const _0x51e9e8 of _0x4ba3b1){const _0x4e849f=a71_0x1b8025[_0x5c059c(0xa5)](_0x45f46f,_0x51e9e8),_0x3ada55=parsePromptYaml(a71_0x482401[_0x5c059c(0x148)](_0x4e849f,'utf-8'),_0x4e849f);_0x5664de[_0x5c059c(0x8e)]({'name':_0x3ada55['name'],'path':_0x4e849f,'yaml':_0x3ada55});}}const _0x478116=await this['client'][_0x5c059c(0xe5)](_0x2d0591),_0x2d3ca5=await this[_0x5c059c(0xe2)]['listKnowledgeBases'](_0x2d0591),_0xd5e10a=await this[_0x5c059c(0xe2)][_0x5c059c(0x92)](_0x2d0591),_0x17b8b4=await this[_0x5c059c(0xe2)][_0x5c059c(0x8f)](_0x2d0591),_0x17931a=await this[_0x5c059c(0xe2)][_0x5c059c(0x108)](_0x2d0591),_0x8983d9=await this[_0x5c059c(0xe2)][_0x5c059c(0xc5)](_0x2d0591),_0x5ce3b1=new Map(),_0xd3dd36=new Map(),_0xdfb48b=new Map(),_0x35c0b0=new Map();for(const _0x336329 of _0x478116){_0x5ce3b1[_0x5c059c(0x14b)](_0x336329[_0x5c059c(0x14d)][_0x5c059c(0xf5)],_0x336329);}for(const _0x2194b6 of _0x2d3ca5){_0xd3dd36[_0x5c059c(0x14b)](_0x2194b6[_0x5c059c(0x14d)]['name'],_0x2194b6);}for(const _0x1a07ca of _0xd5e10a){_0xdfb48b[_0x5c059c(0x14b)](_0x1a07ca[_0x5c059c(0x14d)]['name'],_0x1a07ca);}for(const _0x4e6fcb of _0x8983d9){_0x35c0b0['set'](_0x4e6fcb[_0x5c059c(0x14d)][_0x5c059c(0xf5)],_0x4e6fcb);}const _0x578a82=new Map(),_0x4c8fd6=new Map(),_0x33e1cf=new Map(),_0x30b165=new Map(),_0x25eaef=new Map(),_0x493b63=new Map(),_0x402727=new Map(),_0x50c8a4=new Map(),_0x149b81=new Map(),_0x3fc919=new Map(),_0xc2fc0d=new Map(),_0x13b3ca=new Map();for(const _0x2cfc2a of _0x2d3ca5){_0x578a82[_0x5c059c(0x14b)](_0x2cfc2a[_0x5c059c(0x14d)][_0x5c059c(0xf5)],_0x2cfc2a['id']),_0x402727['set'](_0x2cfc2a['id'],_0x2cfc2a[_0x5c059c(0x14d)]['name']);}for(const _0x1e0d6c of _0xd5e10a){_0x4c8fd6[_0x5c059c(0x14b)](_0x1e0d6c['attributes'][_0x5c059c(0xf5)],_0x1e0d6c['id']),_0x50c8a4[_0x5c059c(0x14b)](_0x1e0d6c['id'],_0x1e0d6c[_0x5c059c(0x14d)]['name']);}for(const _0x2a8f41 of _0x478116){_0x33e1cf['set'](_0x2a8f41[_0x5c059c(0x14d)]['name'],_0x2a8f41['id']),_0x149b81[_0x5c059c(0x14b)](_0x2a8f41['id'],_0x2a8f41[_0x5c059c(0x14d)][_0x5c059c(0xf5)]);}for(const _0xcf5b58 of _0x17b8b4){_0x30b165[_0x5c059c(0x14b)](_0xcf5b58[_0x5c059c(0x14d)]['name'],_0xcf5b58['id']),_0x3fc919['set'](_0xcf5b58['id'],_0xcf5b58[_0x5c059c(0x14d)][_0x5c059c(0xf5)]);}for(const _0x53b2a0 of _0x17931a){_0x25eaef[_0x5c059c(0x14b)](_0x53b2a0[_0x5c059c(0x14d)][_0x5c059c(0xf5)],_0x53b2a0['id']),_0xc2fc0d[_0x5c059c(0x14b)](_0x53b2a0['id'],_0x53b2a0[_0x5c059c(0x14d)][_0x5c059c(0xf5)]);}for(const _0x399edb of _0x8983d9){_0x493b63[_0x5c059c(0x14b)](_0x399edb[_0x5c059c(0x14d)]['name'],_0x399edb['id']),_0x13b3ca[_0x5c059c(0x14b)](_0x399edb['id'],_0x399edb[_0x5c059c(0x14d)][_0x5c059c(0xf5)]);}const _0xbbcbfa={'resolveKnowledgeBaseName':async _0x5b7722=>_0x402727[_0x5c059c(0xa4)](_0x5b7722),'resolveTextKnowledgeBaseName':async _0x2d23eb=>_0x50c8a4[_0x5c059c(0xa4)](_0x2d23eb),'resolveAgentName':async _0x2cbdda=>_0x149b81[_0x5c059c(0xa4)](_0x2cbdda),'resolveWebSearchToolName':async _0x53d36d=>_0xc2fc0d[_0x5c059c(0xa4)](_0x53d36d),'resolveImageGeneratorName':async _0x688999=>_0x3fc919[_0x5c059c(0xa4)](_0x688999),'resolvePromptName':async _0x5826b3=>_0x13b3ca[_0x5c059c(0xa4)](_0x5826b3),'onWarning':_0x55a4f1=>this[_0x5c059c(0x147)]['logger']?.[_0x5c059c(0x136)](_0x55a4f1)},_0x2fc34d={'projectId':_0x2d0591,'resolveKnowledgeBaseId':async _0x428e39=>_0x578a82['get'](_0x428e39),'resolveTextKnowledgeBaseId':async _0x48d0f8=>_0x4c8fd6['get'](_0x48d0f8),'resolveAgentId':async _0x394017=>_0x33e1cf['get'](_0x394017),'resolveWebSearchToolId':async _0x3c2c5a=>_0x25eaef['get'](_0x3c2c5a),'resolveImageGeneratorId':async _0x54f760=>_0x30b165[_0x5c059c(0xa4)](_0x54f760),'resolvePromptId':async _0x303abd=>_0x493b63[_0x5c059c(0xa4)](_0x303abd),'onWarning':_0x20e5f8=>this[_0x5c059c(0x147)][_0x5c059c(0xdf)]?.[_0x5c059c(0x136)](_0x20e5f8)},{resolved:_0x561410,unresolved:_0x369eb5}=resolveAgentDependencies(_0xbaf231,new Set(_0x5ce3b1[_0x5c059c(0x80)]()));for(const {agent:_0x7b6cbd,missingDeps:_0x5b2370}of _0x369eb5){_0x114899[_0x5c059c(0xa8)]['push']({'agentName':_0x7b6cbd['yaml'][_0x5c059c(0xf5)],'action':_0x5c059c(0xaf),'error':'Unresolved\x20dependencies:\x20'+_0x5b2370[_0x5c059c(0xa5)](',\x20')+_0x5c059c(0xc9)}),_0x114899[_0x5c059c(0x13d)][_0x5c059c(0xa8)][_0x5c059c(0x104)]++;}for(const _0x4d474a of _0x2bcca8){const _0x5c8574=_0xd3dd36[_0x5c059c(0xa4)](_0x4d474a['yaml']['name']),_0x4b4220=a71_0x482401[_0x5c059c(0x148)](_0x4d474a[_0x5c059c(0x72)],_0x5c059c(0xc7));if(_0x5c8574){const _0x4dacde=apiKnowledgeBaseToYaml(_0x5c8574),_0x1ccf69=toKnowledgeBaseYamlString(_0x4dacde),_0x1ec907=generateDiff(_0x1ccf69,_0x4b4220),_0x48873a=hasChanges(_0x1ec907);_0x48873a?(_0x114899[_0x5c059c(0xf6)][_0x5c059c(0x8e)]({'name':_0x4d474a['yaml']['name'],'action':_0x5c059c(0xfc),'id':_0x5c8574['id'],'diff':formatDiffWithColors(_0x1ec907)}),_0x114899['counts']['knowledgeBases'][_0x5c059c(0xfc)]++):(_0x114899[_0x5c059c(0xf6)][_0x5c059c(0x8e)]({'name':_0x4d474a['yaml'][_0x5c059c(0xf5)],'action':_0x5c059c(0x77),'id':_0x5c8574['id']}),_0x114899['counts'][_0x5c059c(0xf6)][_0x5c059c(0x77)]++);}else _0x114899['knowledgeBases'][_0x5c059c(0x8e)]({'name':_0x4d474a[_0x5c059c(0x9a)][_0x5c059c(0xf5)],'action':_0x5c059c(0x13a)}),_0x114899[_0x5c059c(0x13d)][_0x5c059c(0xf6)][_0x5c059c(0x13a)]++;}for(const _0x3c77c5 of _0x16e000){const _0x19672=_0xdfb48b[_0x5c059c(0xa4)](_0x3c77c5[_0x5c059c(0xf5)]),_0x4442d8=a71_0x482401[_0x5c059c(0x148)](_0x3c77c5[_0x5c059c(0x72)],_0x5c059c(0xc7));if(_0x19672){const _0x2be90f=toTextKnowledgeBaseMd(_0x19672[_0x5c059c(0x14d)][_0x5c059c(0xf5)],_0x19672[_0x5c059c(0x14d)][_0x5c059c(0x8b)]),_0x58ffd2=generateDiff(_0x2be90f,_0x4442d8),_0x483f38=hasChanges(_0x58ffd2);_0x483f38?(_0x114899[_0x5c059c(0xb3)][_0x5c059c(0x8e)]({'name':_0x3c77c5[_0x5c059c(0xf5)],'action':_0x5c059c(0xfc),'id':_0x19672['id'],'diff':formatDiffWithColors(_0x58ffd2)}),_0x114899[_0x5c059c(0x13d)][_0x5c059c(0xb3)][_0x5c059c(0xfc)]++):(_0x114899[_0x5c059c(0xb3)]['push']({'name':_0x3c77c5[_0x5c059c(0xf5)],'action':'unchanged','id':_0x19672['id']}),_0x114899[_0x5c059c(0x13d)][_0x5c059c(0xb3)]['unchanged']++);}else _0x114899['textKnowledgeBases'][_0x5c059c(0x8e)]({'name':_0x3c77c5[_0x5c059c(0xf5)],'action':_0x5c059c(0x13a)}),_0x114899[_0x5c059c(0x13d)]['textKnowledgeBases'][_0x5c059c(0x13a)]++;}for(const _0x52dfbe of _0x561410){const _0x39cb2c=_0x5ce3b1[_0x5c059c(0xa4)](_0x52dfbe[_0x5c059c(0x9a)][_0x5c059c(0xf5)]),_0x386e43=a71_0x1b8025[_0x5c059c(0xa5)](_0x52dfbe[_0x5c059c(0x109)],_0x5c059c(0x11a)),_0x2315bc=a71_0x482401['readFileSync'](_0x386e43,_0x5c059c(0xc7)),_0x200c67=_0x52dfbe[_0x5c059c(0xfe)],_0x56547e=_0x5c059c(0xc6)+_0x200c67+_0x5c059c(0x99)+_0x2315bc;if(_0x39cb2c){const {yaml:_0x44229a,systemPrompt:_0x30ac2a}=await apiAgentToYaml(_0x39cb2c,_0xbbcbfa),_0x1e133e=toAgentYamlString(_0x44229a),_0x325935='#\x20prompt.md\x0a'+_0x30ac2a+_0x5c059c(0x99)+_0x1e133e,_0x287017=generateDiff(_0x325935,_0x56547e),_0x146814=hasChanges(_0x287017);_0x146814?(_0x114899['agents']['push']({'agentName':_0x52dfbe['yaml'][_0x5c059c(0xf5)],'action':_0x5c059c(0xfc),'agentId':_0x39cb2c['id'],'diff':formatDiffWithColors(_0x287017)}),_0x114899[_0x5c059c(0x13d)][_0x5c059c(0xa8)][_0x5c059c(0xfc)]++):(_0x114899['agents'][_0x5c059c(0x8e)]({'agentName':_0x52dfbe[_0x5c059c(0x9a)][_0x5c059c(0xf5)],'action':_0x5c059c(0x77),'agentId':_0x39cb2c['id']}),_0x114899[_0x5c059c(0x13d)][_0x5c059c(0xa8)][_0x5c059c(0x77)]++);}else _0x114899['agents'][_0x5c059c(0x8e)]({'agentName':_0x52dfbe[_0x5c059c(0x9a)]['name'],'action':_0x5c059c(0x13a)}),_0x114899[_0x5c059c(0x13d)][_0x5c059c(0xa8)][_0x5c059c(0x13a)]++;}for(const _0x129388 of _0x5664de){const _0x1f6133=_0x35c0b0['get'](_0x129388[_0x5c059c(0x9a)]['name']),_0x23b3e6=a71_0x482401[_0x5c059c(0x148)](_0x129388[_0x5c059c(0x72)],_0x5c059c(0xc7));if(_0x1f6133){const _0x3bfc56=await apiPromptToYaml(_0x1f6133,_0xbbcbfa);if(!_0x3bfc56){_0x114899['prompts'][_0x5c059c(0x8e)]({'name':_0x129388[_0x5c059c(0x9a)][_0x5c059c(0xf5)],'action':_0x5c059c(0xfc),'id':_0x1f6133['id']}),_0x114899[_0x5c059c(0x13d)][_0x5c059c(0x129)][_0x5c059c(0xfc)]++;continue;}const _0x5aa66d=toPromptYamlString(_0x3bfc56),_0x4c9c1b=generateDiff(_0x5aa66d,_0x23b3e6),_0x491672=hasChanges(_0x4c9c1b);_0x491672?(_0x114899['prompts'][_0x5c059c(0x8e)]({'name':_0x129388['yaml'][_0x5c059c(0xf5)],'action':_0x5c059c(0xfc),'id':_0x1f6133['id'],'diff':formatDiffWithColors(_0x4c9c1b)}),_0x114899['counts']['prompts']['updated']++):(_0x114899[_0x5c059c(0x129)][_0x5c059c(0x8e)]({'name':_0x129388[_0x5c059c(0x9a)][_0x5c059c(0xf5)],'action':'unchanged','id':_0x1f6133['id']}),_0x114899[_0x5c059c(0x13d)][_0x5c059c(0x129)]['unchanged']++);}else _0x114899[_0x5c059c(0x129)][_0x5c059c(0x8e)]({'name':_0x129388[_0x5c059c(0x9a)]['name'],'action':'created'}),_0x114899['counts'][_0x5c059c(0x129)][_0x5c059c(0x13a)]++;}if(_0x4d2f13?.[_0x5c059c(0xdc)])return _0x114899;_0x114899[_0x5c059c(0xf6)]=[],_0x114899[_0x5c059c(0xb3)]=[],_0x114899[_0x5c059c(0x129)]=[];const _0x5a613e=_0x114899['agents'][_0x5c059c(0x8a)](_0x5c7b0c=>_0x5c7b0c[_0x5c059c(0xb8)]==='error');_0x114899['agents']=_0x5a613e,_0x114899[_0x5c059c(0x13d)]={'agents':{'created':0x0,'updated':0x0,'unchanged':0x0,'errors':_0x5a613e[_0x5c059c(0xb7)]},'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 _0x438118 of _0x2bcca8){try{const _0x3f30b9=_0xd3dd36[_0x5c059c(0xa4)](_0x438118['yaml'][_0x5c059c(0xf5)]),_0x44d4cf=yamlKnowledgeBaseToApi(_0x438118[_0x5c059c(0x9a)],_0x2d0591);if(_0x3f30b9)await this[_0x5c059c(0xe2)][_0x5c059c(0xdd)](_0x3f30b9['id'],_0x44d4cf),_0x578a82['set'](_0x438118[_0x5c059c(0x9a)][_0x5c059c(0xf5)],_0x3f30b9['id']),_0x114899[_0x5c059c(0xf6)]['push']({'name':_0x438118['yaml'][_0x5c059c(0xf5)],'action':_0x5c059c(0xfc),'id':_0x3f30b9['id']}),_0x114899[_0x5c059c(0x13d)][_0x5c059c(0xf6)][_0x5c059c(0xfc)]++;else{const _0x299751=await this[_0x5c059c(0xe2)][_0x5c059c(0x12e)](_0x44d4cf);_0x578a82[_0x5c059c(0x14b)](_0x438118['yaml'][_0x5c059c(0xf5)],_0x299751['id']),_0x114899[_0x5c059c(0xf6)][_0x5c059c(0x8e)]({'name':_0x438118[_0x5c059c(0x9a)][_0x5c059c(0xf5)],'action':'created','id':_0x299751['id']}),_0x114899[_0x5c059c(0x13d)][_0x5c059c(0xf6)][_0x5c059c(0x13a)]++;}}catch(_0x599f6e){_0x114899[_0x5c059c(0xf6)][_0x5c059c(0x8e)]({'name':_0x438118[_0x5c059c(0x9a)]['name'],'action':_0x5c059c(0xaf),'error':_0x599f6e[_0x5c059c(0x6f)]}),_0x114899[_0x5c059c(0x13d)][_0x5c059c(0xf6)][_0x5c059c(0x104)]++;}}for(const _0x349733 of _0x16e000){try{const _0x480568=_0xdfb48b[_0x5c059c(0xa4)](_0x349733[_0x5c059c(0xf5)]),_0x127fe8=yamlTextKnowledgeBaseToApi({'name':_0x349733[_0x5c059c(0xf5)],'text':_0x349733[_0x5c059c(0x8b)]},_0x2d0591);if(_0x480568)await this[_0x5c059c(0xe2)][_0x5c059c(0xb2)](_0x480568['id'],_0x127fe8),_0x4c8fd6[_0x5c059c(0x14b)](_0x349733[_0x5c059c(0xf5)],_0x480568['id']),_0x114899[_0x5c059c(0xb3)][_0x5c059c(0x8e)]({'name':_0x349733[_0x5c059c(0xf5)],'action':'updated','id':_0x480568['id']}),_0x114899[_0x5c059c(0x13d)][_0x5c059c(0xb3)][_0x5c059c(0xfc)]++;else{const _0x7e0a97=await this[_0x5c059c(0xe2)][_0x5c059c(0x8d)](_0x127fe8);_0x4c8fd6['set'](_0x349733[_0x5c059c(0xf5)],_0x7e0a97['id']),_0x114899[_0x5c059c(0xb3)][_0x5c059c(0x8e)]({'name':_0x349733[_0x5c059c(0xf5)],'action':_0x5c059c(0x13a),'id':_0x7e0a97['id']}),_0x114899[_0x5c059c(0x13d)][_0x5c059c(0xb3)][_0x5c059c(0x13a)]++;}}catch(_0x162145){_0x114899[_0x5c059c(0xb3)][_0x5c059c(0x8e)]({'name':_0x349733[_0x5c059c(0xf5)],'action':_0x5c059c(0xaf),'error':_0x162145['message']}),_0x114899['counts'][_0x5c059c(0xb3)]['errors']++;}}for(const _0x224bb4 of _0x561410){try{const _0x31b4f3=_0x5ce3b1['get'](_0x224bb4[_0x5c059c(0x9a)][_0x5c059c(0xf5)]),_0x5d6c71=await yamlAgentToApi(_0x224bb4[_0x5c059c(0x9a)],_0x224bb4[_0x5c059c(0xfe)],_0x224bb4[_0x5c059c(0x143)],_0x2fc34d);if(_0x31b4f3)await this[_0x5c059c(0xe2)][_0x5c059c(0x10d)](_0x31b4f3['id'],_0x5d6c71),_0x33e1cf[_0x5c059c(0x14b)](_0x224bb4[_0x5c059c(0x9a)]['name'],_0x31b4f3['id']),_0x114899[_0x5c059c(0xa8)][_0x5c059c(0x8e)]({'agentName':_0x224bb4[_0x5c059c(0x9a)][_0x5c059c(0xf5)],'action':_0x5c059c(0xfc),'agentId':_0x31b4f3['id']}),_0x114899['counts']['agents'][_0x5c059c(0xfc)]++;else{const _0x4a248d=await this['client'][_0x5c059c(0x10c)](_0x5d6c71);_0x33e1cf[_0x5c059c(0x14b)](_0x224bb4[_0x5c059c(0x9a)]['name'],_0x4a248d['id']),_0x114899[_0x5c059c(0xa8)][_0x5c059c(0x8e)]({'agentName':_0x224bb4[_0x5c059c(0x9a)][_0x5c059c(0xf5)],'action':_0x5c059c(0x13a),'agentId':_0x4a248d['id']}),_0x114899[_0x5c059c(0x13d)][_0x5c059c(0xa8)][_0x5c059c(0x13a)]++;}}catch(_0x3b2ccf){_0x114899[_0x5c059c(0xa8)][_0x5c059c(0x8e)]({'agentName':_0x224bb4[_0x5c059c(0x9a)][_0x5c059c(0xf5)],'action':_0x5c059c(0xaf),'error':_0x3b2ccf[_0x5c059c(0x6f)]}),_0x114899[_0x5c059c(0x13d)]['agents'][_0x5c059c(0x104)]++;}}for(const _0x33ddfe of _0x5664de){try{const _0x4af93f=_0x35c0b0[_0x5c059c(0xa4)](_0x33ddfe['yaml'][_0x5c059c(0xf5)]),_0x2a7aed=await yamlPromptToApi(_0x33ddfe[_0x5c059c(0x9a)],_0x2d0591,_0x2fc34d);if(!_0x2a7aed){_0x114899['prompts']['push']({'name':_0x33ddfe['yaml']['name'],'action':'error','error':_0x5c059c(0xce)}),_0x114899['counts'][_0x5c059c(0x129)][_0x5c059c(0x104)]++;continue;}if(_0x4af93f)await this[_0x5c059c(0xe2)]['updatePrompt'](_0x4af93f['id'],_0x2a7aed),_0x493b63['set'](_0x33ddfe[_0x5c059c(0x9a)]['name'],_0x4af93f['id']),_0x114899['prompts']['push']({'name':_0x33ddfe[_0x5c059c(0x9a)][_0x5c059c(0xf5)],'action':_0x5c059c(0xfc),'id':_0x4af93f['id']}),_0x114899['counts']['prompts']['updated']++;else{const _0x128b36=await this[_0x5c059c(0xe2)]['createPrompt'](_0x2a7aed);_0x493b63[_0x5c059c(0x14b)](_0x33ddfe[_0x5c059c(0x9a)][_0x5c059c(0xf5)],_0x128b36['id']),_0x114899[_0x5c059c(0x129)][_0x5c059c(0x8e)]({'name':_0x33ddfe[_0x5c059c(0x9a)][_0x5c059c(0xf5)],'action':_0x5c059c(0x13a),'id':_0x128b36['id']}),_0x114899['counts'][_0x5c059c(0x129)][_0x5c059c(0x13a)]++;}}catch(_0x3b70d0){_0x114899['prompts']['push']({'name':_0x33ddfe[_0x5c059c(0x9a)][_0x5c059c(0xf5)],'action':_0x5c059c(0xaf),'error':_0x3b70d0[_0x5c059c(0x6f)]}),_0x114899[_0x5c059c(0x13d)][_0x5c059c(0x129)]['errors']++;}}return _0x114899;}async[a71_0x429fc8(0xa6)](_0x14eece,_0x4968a0,_0x57893a,_0x2f8d3c){const _0x458aa2=a71_0x429fc8,{projectId:_0x15cbc5,project:_0x38eda4}=await this[_0x458aa2(0xda)](_0x14eece),_0x2ed208=_0x38eda4[_0x458aa2(0x14d)][_0x458aa2(0xf5)],_0x1291d8=await this[_0x458aa2(0xe2)][_0x458aa2(0xe5)](_0x15cbc5),_0x86447f=_0x1291d8[_0x458aa2(0xf8)](_0x1ed5ad=>_0x1ed5ad[_0x458aa2(0x14d)][_0x458aa2(0xf5)]===_0x4968a0);if(!_0x86447f)throw new SDKError(ErrorCode[_0x458aa2(0x75)],_0x458aa2(0x13f)+_0x4968a0,undefined,{'helpText':_0x458aa2(0x84)+_0x1291d8['map'](_0x16ef4a=>_0x16ef4a[_0x458aa2(0x14d)][_0x458aa2(0xf5)])['join'](',\x20')});const _0x296dd4=normalizeName(_0x2ed208),_0x54fb9e=normalizeName(_0x4968a0),_0x2186f1=_0x57893a||a71_0x1b8025['join'](process[_0x458aa2(0x7e)](),_0x458aa2(0xa8),_0x296dd4),_0x311318=a71_0x1b8025['join'](_0x2186f1,_0x54fb9e),_0x5b65a3=new Map(),_0x5a8d11=new Map(),_0x46e977=await this[_0x458aa2(0xe2)][_0x458aa2(0x10e)](_0x15cbc5),_0x5b451c=await this[_0x458aa2(0xe2)][_0x458aa2(0x92)](_0x15cbc5),_0x5a04f2=new Map();for(const _0x26acc1 of _0x46e977){_0x5b65a3[_0x458aa2(0x14b)](_0x26acc1['id'],_0x26acc1[_0x458aa2(0x14d)][_0x458aa2(0xf5)]);}for(const _0x1f4dca of _0x5b451c){_0x5a04f2['set'](_0x1f4dca['id'],_0x1f4dca[_0x458aa2(0x14d)][_0x458aa2(0xf5)]);}for(const _0x4f01d3 of _0x1291d8){_0x5a8d11[_0x458aa2(0x14b)](_0x4f01d3['id'],_0x4f01d3[_0x458aa2(0x14d)][_0x458aa2(0xf5)]);}const _0x1701c6={'resolveKnowledgeBaseName':async _0x2e4934=>_0x5b65a3['get'](_0x2e4934),'resolveTextKnowledgeBaseName':async _0x194211=>_0x5a04f2[_0x458aa2(0xa4)](_0x194211),'resolveAgentName':async _0x3e9f40=>_0x5a8d11[_0x458aa2(0xa4)](_0x3e9f40),'resolveWebSearchToolName':async()=>undefined,'resolveImageGeneratorName':async()=>undefined,'resolvePromptName':async()=>undefined,'onWarning':_0xe72bee=>this[_0x458aa2(0x147)][_0x458aa2(0xdf)]?.[_0x458aa2(0x136)](_0xe72bee)},_0x203016=a71_0x1b8025[_0x458aa2(0xa5)](_0x311318,_0x458aa2(0x122)),_0x108667=a71_0x1b8025[_0x458aa2(0xa5)](_0x311318,_0x458aa2(0x11a)),_0x4fe5a0=a71_0x1b8025[_0x458aa2(0xa5)](_0x311318,_0x458aa2(0xd5)),_0x331f1f=!a71_0x482401[_0x458aa2(0x98)](_0x108667);if(_0x2f8d3c?.['dryRun'])return{'agentName':_0x4968a0,'outputPath':_0x311318,'isNew':_0x331f1f,'hasChanges':!![]};a71_0x482401[_0x458aa2(0x6d)](_0x2186f1,{'recursive':!![]}),a71_0x482401['mkdirSync'](_0x311318,{'recursive':!![]});const _0x4d418e=a71_0x1b8025['join'](_0x2186f1,_0x458aa2(0x9f));!a71_0x482401[_0x458aa2(0x98)](_0x4d418e)&&a71_0x482401[_0x458aa2(0x7b)](_0x4d418e,createAgentConfigContent(_0x14eece));const {yaml:_0x648d68,systemPrompt:_0x20d9dd,starterMessage:_0x4787fe}=await apiAgentToYaml(_0x86447f,_0x1701c6);let _0xd7ada2=_0x331f1f;if(!_0x331f1f){const _0x16bf6c=a71_0x482401['existsSync'](_0x203016)?a71_0x482401[_0x458aa2(0x148)](_0x203016,_0x458aa2(0xc7)):'',_0x3164d1=a71_0x482401['readFileSync'](_0x108667,_0x458aa2(0xc7));_0xd7ada2=_0x16bf6c!==_0x20d9dd||_0x3164d1!==toAgentYamlString(_0x648d68);}a71_0x482401['writeFileSync'](_0x203016,_0x20d9dd),a71_0x482401['writeFileSync'](_0x108667,toAgentYamlString(_0x648d68));if(_0x4787fe&&_0x4787fe[_0x458aa2(0x132)]('\x0a'))a71_0x482401[_0x458aa2(0x7b)](_0x4fe5a0,_0x4787fe);else a71_0x482401[_0x458aa2(0x98)](_0x4fe5a0)&&a71_0x482401[_0x458aa2(0x14a)](_0x4fe5a0);return{'agentName':_0x4968a0,'outputPath':_0x311318,'isNew':_0x331f1f,'hasChanges':_0xd7ada2};}async[a71_0x429fc8(0x73)](_0x12c076,_0x54bc8e){const _0x196f21=a71_0x429fc8;let _0x60fb06;isAgentYamlPath(_0x12c076)?_0x60fb06=getAgentDirFromYamlPath(_0x12c076):_0x60fb06=_0x12c076;const {config:_0x310ddd}=findAgentConfig(_0x60fb06),_0x33714f=await this['resolveProjectId'](_0x310ddd['llm_project']),_0x10e7ce=a71_0x1b8025[_0x196f21(0xa5)](_0x60fb06,_0x196f21(0x11a)),_0x4c2b65=a71_0x1b8025[_0x196f21(0xa5)](_0x60fb06,_0x196f21(0x122)),_0x4dd338=a71_0x1b8025[_0x196f21(0xa5)](_0x60fb06,_0x196f21(0xd5));if(!a71_0x482401[_0x196f21(0x98)](_0x10e7ce))throw new SDKError(ErrorCode[_0x196f21(0x10a)],'agent.yml\x20not\x20found\x20in\x20'+_0x60fb06,undefined,{'helpText':'Ensure\x20the\x20path\x20points\x20to\x20a\x20valid\x20agent\x20directory.'});const _0x41de55=parseAgentYaml(a71_0x482401['readFileSync'](_0x10e7ce,_0x196f21(0xc7)),_0x10e7ce),_0x1f8513=a71_0x482401[_0x196f21(0x98)](_0x4c2b65)?a71_0x482401['readFileSync'](_0x4c2b65,_0x196f21(0xc7)):'',_0x18007e=a71_0x482401[_0x196f21(0x98)](_0x4dd338)?a71_0x482401[_0x196f21(0x148)](_0x4dd338,_0x196f21(0xc7)):_0x41de55[_0x196f21(0x135)];if(_0x54bc8e?.[_0x196f21(0xdc)])return{'agentName':_0x41de55['name'],'action':_0x196f21(0x13a),'projectId':_0x33714f};const _0x56f03d=await this['client'][_0x196f21(0xe5)](_0x33714f),_0x2034de=await this[_0x196f21(0xe2)][_0x196f21(0x10e)](_0x33714f),_0x137f5e=await this['client'][_0x196f21(0x92)](_0x33714f),_0x4526ec=new Map(),_0x4fd3bb=new Map(),_0x750f92=new Map();for(const _0x2e8283 of _0x2034de){_0x4526ec[_0x196f21(0x14b)](_0x2e8283[_0x196f21(0x14d)][_0x196f21(0xf5)],_0x2e8283['id']);}for(const _0xd2a812 of _0x137f5e){_0x4fd3bb[_0x196f21(0x14b)](_0xd2a812[_0x196f21(0x14d)][_0x196f21(0xf5)],_0xd2a812['id']);}for(const _0x833494 of _0x56f03d){_0x750f92['set'](_0x833494[_0x196f21(0x14d)]['name'],_0x833494['id']);}const _0x563277={'projectId':_0x33714f,'resolveKnowledgeBaseId':async _0x4c8295=>_0x4526ec['get'](_0x4c8295),'resolveTextKnowledgeBaseId':async _0x1f7edb=>_0x4fd3bb['get'](_0x1f7edb),'resolveAgentId':async _0x1b0f9b=>_0x750f92['get'](_0x1b0f9b),'resolveWebSearchToolId':async()=>undefined,'resolveImageGeneratorId':async()=>undefined,'resolvePromptId':async()=>undefined,'onWarning':_0x412a9c=>this[_0x196f21(0x147)][_0x196f21(0xdf)]?.[_0x196f21(0x136)](_0x412a9c)};try{const _0x4fc190=_0x56f03d[_0x196f21(0xf8)](_0x5002d=>_0x5002d[_0x196f21(0x14d)][_0x196f21(0xf5)]===_0x41de55[_0x196f21(0xf5)]),_0xe35ffd=await yamlAgentToApi(_0x41de55,_0x1f8513,_0x18007e,_0x563277);if(_0x4fc190)return await this[_0x196f21(0xe2)]['updateAgentFull'](_0x4fc190['id'],_0xe35ffd),{'agentName':_0x41de55[_0x196f21(0xf5)],'action':_0x196f21(0xfc),'projectId':_0x33714f,'agentId':_0x4fc190['id']};else{const _0x3b9991=await this['client']['createAgentFull'](_0xe35ffd);return{'agentName':_0x41de55[_0x196f21(0xf5)],'action':_0x196f21(0x13a),'projectId':_0x33714f,'agentId':_0x3b9991['id']};}}catch(_0x41804e){return{'agentName':_0x41de55[_0x196f21(0xf5)],'action':'error','projectId':_0x33714f,'error':_0x41804e[_0x196f21(0x6f)]};}}async['cloneProject'](_0x57b19f,_0x245745,_0x530c3f){const _0x3e3595=a71_0x429fc8,_0x2be4ba=a71_0x482401[_0x3e3595(0x98)](_0x57b19f)&&a71_0x482401[_0x3e3595(0x98)](a71_0x1b8025[_0x3e3595(0xa5)](_0x57b19f,'tdx.json'));let _0x5a2443;const _0x4b543d=[],_0x58f2cd=[],_0x1241a5=[],_0xa169ea=[];if(_0x2be4ba){const _0x360fbc=loadAgentConfig(a71_0x1b8025[_0x3e3595(0xa5)](_0x57b19f,'tdx.json'));_0x5a2443=_0x360fbc[_0x3e3595(0x103)];const _0x393417=a71_0x482401[_0x3e3595(0xa1)](_0x57b19f,{'withFileTypes':!![]});for(const _0x3d5008 of _0x393417){if(!_0x3d5008[_0x3e3595(0x78)]())continue;if([_0x3e3595(0x95),_0x3e3595(0x129),_0x3e3595(0xef)][_0x3e3595(0x132)](_0x3d5008[_0x3e3595(0xf5)]))continue;const _0x5509eb=a71_0x1b8025['join'](_0x57b19f,_0x3d5008[_0x3e3595(0xf5)]);if(isAgentDir(_0x5509eb)){const _0x39fa47=a71_0x1b8025[_0x3e3595(0xa5)](_0x5509eb,'agent.yml'),_0x167196=a71_0x1b8025['join'](_0x5509eb,_0x3e3595(0x122)),_0x41a907=a71_0x1b8025[_0x3e3595(0xa5)](_0x5509eb,'starter_message.md'),_0x2288eb=parseAgentYaml(a71_0x482401[_0x3e3595(0x148)](_0x39fa47,_0x3e3595(0xc7)),_0x39fa47),_0x317eb8=a71_0x482401[_0x3e3595(0x98)](_0x167196)?a71_0x482401[_0x3e3595(0x148)](_0x167196,_0x3e3595(0xc7)):'',_0x2861eb=a71_0x482401[_0x3e3595(0x98)](_0x41a907)?a71_0x482401['readFileSync'](_0x41a907,'utf-8'):_0x2288eb[_0x3e3595(0x135)];_0x4b543d[_0x3e3595(0x8e)]({'name':_0x2288eb['name'],'dir':_0x5509eb,'yaml':_0x2288eb,'systemPrompt':_0x317eb8,'starterMessage':_0x2861eb});}}const _0x2b5fe8=getKnowledgeBasesDir(_0x57b19f);if(a71_0x482401[_0x3e3595(0x98)](_0x2b5fe8)){const _0x8e16=a71_0x482401[_0x3e3595(0xa1)](_0x2b5fe8);for(const _0x238790 of _0x8e16){const _0x447d48=a71_0x1b8025['join'](_0x2b5fe8,_0x238790);if(_0x238790[_0x3e3595(0x14c)]('.yml')){const _0xc4243b=parseKnowledgeBaseYaml(a71_0x482401[_0x3e3595(0x148)](_0x447d48,'utf-8'),_0x447d48);_0x58f2cd[_0x3e3595(0x8e)]({'name':_0xc4243b[_0x3e3595(0xf5)],'path':_0x447d48,'yaml':_0xc4243b});}else{if(_0x238790[_0x3e3595(0x14c)](_0x3e3595(0xe4))){const _0x135142=a71_0x482401[_0x3e3595(0x148)](_0x447d48,_0x3e3595(0xc7)),{name:_0x34d84b,text:_0x57e29e}=parseTextKnowledgeBaseMd(_0x135142,_0x238790);_0x1241a5[_0x3e3595(0x8e)]({'name':_0x34d84b,'path':_0x447d48,'text':_0x57e29e});}}}}const _0x2b11a1=getPromptsDir(_0x57b19f);if(a71_0x482401[_0x3e3595(0x98)](_0x2b11a1)){const _0x5c574d=a71_0x482401[_0x3e3595(0xa1)](_0x2b11a1)['filter'](_0x2662a1=>_0x2662a1[_0x3e3595(0x14c)](_0x3e3595(0xcc)));for(const _0x5a6d9e of _0x5c574d){const _0x1e8224=a71_0x1b8025[_0x3e3595(0xa5)](_0x2b11a1,_0x5a6d9e),_0x3701d3=parsePromptYaml(a71_0x482401[_0x3e3595(0x148)](_0x1e8224,_0x3e3595(0xc7)),_0x1e8224);_0xa169ea['push']({'name':_0x3701d3['name'],'path':_0x1e8224,'yaml':_0x3701d3});}}}else{const _0x4b55bb=await this[_0x3e3595(0xed)](_0x57b19f),_0x3cf899=await this[_0x3e3595(0xe2)][_0x3e3595(0x110)](_0x4b55bb);_0x5a2443=_0x3cf899['attributes'][_0x3e3595(0xf5)];const _0x46d949=await this[_0x3e3595(0xe2)]['listAgentsFull'](_0x4b55bb),_0x1293ac=await this[_0x3e3595(0xe2)][_0x3e3595(0x10e)](_0x4b55bb),_0x213ab3=await this[_0x3e3595(0xe2)][_0x3e3595(0x92)](_0x4b55bb),_0x5251b1=await this[_0x3e3595(0xe2)][_0x3e3595(0xc5)](_0x4b55bb),_0x59e705=new Map(),_0x567efb=new Map(),_0xdaf240=new Map(),_0x17058f=new Map();for(const _0x406f9d of _0x1293ac){_0x59e705[_0x3e3595(0x14b)](_0x406f9d['id'],_0x406f9d[_0x3e3595(0x14d)]['name']);}for(const _0x350531 of _0x213ab3){_0x567efb['set'](_0x350531['id'],_0x350531[_0x3e3595(0x14d)]['name']);}for(const _0x581cce of _0x46d949){_0xdaf240[_0x3e3595(0x14b)](_0x581cce['id'],_0x581cce[_0x3e3595(0x14d)][_0x3e3595(0xf5)]);}for(const _0x3c4358 of _0x5251b1){_0x17058f[_0x3e3595(0x14b)](_0x3c4358['id'],_0x3c4358[_0x3e3595(0x14d)][_0x3e3595(0xf5)]);}const _0x49a262={'resolveKnowledgeBaseName':async _0x15871a=>_0x59e705['get'](_0x15871a),'resolveTextKnowledgeBaseName':async _0x2d63d6=>_0x567efb[_0x3e3595(0xa4)](_0x2d63d6),'resolveAgentName':async _0x18a535=>_0xdaf240[_0x3e3595(0xa4)](_0x18a535),'resolveWebSearchToolName':async()=>undefined,'resolveImageGeneratorName':async()=>undefined,'resolvePromptName':async _0xe383a4=>_0x17058f['get'](_0xe383a4),'onWarning':_0x36fbf3=>this[_0x3e3595(0x147)]['logger']?.[_0x3e3595(0x136)](_0x36fbf3)};for(const _0x51b075 of _0x46d949){const _0x44e6ac=await apiAgentToYaml(_0x51b075,_0x49a262),{yaml:_0x468a0d,systemPrompt:_0x5b1972,starterMessage:_0x23ce56}=_0x44e6ac;_0x4b543d[_0x3e3595(0x8e)]({'name':_0x468a0d[_0x3e3595(0xf5)],'dir':'','yaml':_0x468a0d,'systemPrompt':_0x5b1972,'starterMessage':_0x23ce56});}for(const _0x3b5748 of _0x1293ac){const _0x270adc=apiKnowledgeBaseToYaml(_0x3b5748);_0x58f2cd[_0x3e3595(0x8e)]({'name':_0x270adc['name'],'path':'','yaml':_0x270adc});}for(const _0xc0914f of _0x213ab3){_0x1241a5[_0x3e3595(0x8e)]({'name':_0xc0914f['attributes'][_0x3e3595(0xf5)],'path':'','text':_0xc0914f[_0x3e3595(0x14d)][_0x3e3595(0x8b)]});}for(const _0x320655 of _0x5251b1){const _0x44cf65=await apiPromptToYaml(_0x320655,_0x49a262);_0x44cf65&&_0xa169ea[_0x3e3595(0x8e)]({'name':_0x44cf65[_0x3e3595(0xf5)],'path':'','yaml':_0x44cf65});}}const _0x5040c2={'sourceProjectName':_0x5a2443,'newProjectName':_0x245745,'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}}},_0x555bd7=await this[_0x3e3595(0xe2)][_0x3e3595(0x131)](),_0x50c5ca=_0x555bd7[_0x3e3595(0xf8)](_0x46ab0d=>_0x46ab0d['attributes'][_0x3e3595(0xf5)]===_0x245745);if(_0x50c5ca)throw new SDKError(ErrorCode[_0x3e3595(0x6e)],'Project\x20\x22'+_0x245745+'\x22\x20already\x20exists',undefined,{'helpText':_0x3e3595(0x10b)});if(_0x530c3f?.[_0x3e3595(0xdc)])return _0x5040c2[_0x3e3595(0x13d)][_0x3e3595(0xa8)]['created']=_0x4b543d[_0x3e3595(0xb7)],_0x5040c2[_0x3e3595(0x13d)][_0x3e3595(0xf6)]['created']=_0x58f2cd[_0x3e3595(0xb7)],_0x5040c2[_0x3e3595(0x13d)][_0x3e3595(0xb3)][_0x3e3595(0x13a)]=_0x1241a5['length'],_0x5040c2[_0x3e3595(0x13d)]['prompts'][_0x3e3595(0x13a)]=_0xa169ea['length'],_0x5040c2;const _0x3967e6=await this[_0x3e3595(0xe2)][_0x3e3595(0x127)]({'name':_0x245745}),_0x296785=_0x3967e6['id'];_0x5040c2[_0x3e3595(0xe3)]=_0x296785;const _0x584b6e=new Map(),_0x2298d6=new Map(),_0x56278a=new Map(),_0xa6d2e3=new Map(),_0x16b5be=new Map(),_0x147df3=new Map(),_0x29f979=new Set(),_0x25cd81=new Set();for(const _0x150656 of _0x4b543d){for(const _0x583f4a of _0x150656['yaml'][_0x3e3595(0x133)]||[]){if(_0x583f4a['type']===_0x3e3595(0x93)){const _0x2a3fa6=parseRef(_0x583f4a[_0x3e3595(0xe0)]);if(_0x2a3fa6)_0x29f979[_0x3e3595(0x7d)](_0x2a3fa6[_0x3e3595(0xf5)]);}else{if(_0x583f4a[_0x3e3595(0xca)]===_0x3e3595(0xd0)){const _0x248164=parseRef(_0x583f4a[_0x3e3595(0xe0)]);if(_0x248164)_0x25cd81[_0x3e3595(0x7d)](_0x248164[_0x3e3595(0xf5)]);}}}}for(const _0x5d57cf of _0x29f979){try{const _0x48000b=await this[_0x3e3595(0xe2)][_0x3e3595(0xab)]({'projectId':_0x296785,'name':_0x5d57cf});_0x16b5be[_0x3e3595(0x14b)](_0x5d57cf,_0x48000b['id']),_0x5040c2['imageGenerators'][_0x3e3595(0x8e)]({'name':_0x5d57cf,'action':_0x3e3595(0x13a),'id':_0x48000b['id']}),_0x5040c2[_0x3e3595(0x13d)][_0x3e3595(0xd3)]['created']++;}catch(_0x2f9312){_0x5040c2[_0x3e3595(0xd3)][_0x3e3595(0x8e)]({'name':_0x5d57cf,'action':_0x3e3595(0xaf),'error':_0x2f9312[_0x3e3595(0x6f)]}),_0x5040c2['counts']['imageGenerators']['errors']++;}}for(const _0x596907 of _0x25cd81){try{const _0x2d8f44=await this[_0x3e3595(0xe2)][_0x3e3595(0x112)]({'projectId':_0x296785,'name':_0x596907});_0x147df3[_0x3e3595(0x14b)](_0x596907,_0x2d8f44['id']),_0x5040c2[_0x3e3595(0xcb)][_0x3e3595(0x8e)]({'name':_0x596907,'action':_0x3e3595(0x13a),'id':_0x2d8f44['id']}),_0x5040c2[_0x3e3595(0x13d)][_0x3e3595(0xcb)][_0x3e3595(0x13a)]++;}catch(_0x537a76){_0x5040c2[_0x3e3595(0xcb)][_0x3e3595(0x8e)]({'name':_0x596907,'action':'error','error':_0x537a76['message']}),_0x5040c2[_0x3e3595(0x13d)][_0x3e3595(0xcb)][_0x3e3595(0x104)]++;}}const _0x4a3696={'projectId':_0x296785,'resolveKnowledgeBaseId':async _0x1543e5=>_0x584b6e[_0x3e3595(0xa4)](_0x1543e5),'resolveTextKnowledgeBaseId':async _0x49c6f5=>_0x2298d6[_0x3e3595(0xa4)](_0x49c6f5),'resolveAgentId':async _0x438002=>_0x56278a[_0x3e3595(0xa4)](_0x438002),'resolveWebSearchToolId':async _0x5be39a=>_0x147df3['get'](_0x5be39a),'resolveImageGeneratorId':async _0x54a890=>_0x16b5be[_0x3e3595(0xa4)](_0x54a890),'resolvePromptId':async _0x24d227=>_0xa6d2e3[_0x3e3595(0xa4)](_0x24d227),'onWarning':_0x50616d=>this[_0x3e3595(0x147)][_0x3e3595(0xdf)]?.[_0x3e3595(0x136)](_0x50616d)};for(const _0x555f6a of _0x58f2cd){try{const _0x234f7f=yamlKnowledgeBaseToApi(_0x555f6a[_0x3e3595(0x9a)],_0x296785),_0x57d179=await this['client'][_0x3e3595(0x12e)](_0x234f7f);_0x584b6e[_0x3e3595(0x14b)](_0x555f6a[_0x3e3595(0x9a)][_0x3e3595(0xf5)],_0x57d179['id']),_0x5040c2['knowledgeBases'][_0x3e3595(0x8e)]({'name':_0x555f6a[_0x3e3595(0x9a)][_0x3e3595(0xf5)],'action':'created','id':_0x57d179['id']}),_0x5040c2[_0x3e3595(0x13d)][_0x3e3595(0xf6)][_0x3e3595(0x13a)]++;}catch(_0x529ec6){_0x5040c2[_0x3e3595(0xf6)][_0x3e3595(0x8e)]({'name':_0x555f6a[_0x3e3595(0x9a)][_0x3e3595(0xf5)],'action':_0x3e3595(0xaf),'error':_0x529ec6[_0x3e3595(0x6f)]}),_0x5040c2[_0x3e3595(0x13d)][_0x3e3595(0xf6)][_0x3e3595(0x104)]++;}}for(const _0x3df3c0 of _0x1241a5){try{const _0x3adda5=yamlTextKnowledgeBaseToApi({'name':_0x3df3c0[_0x3e3595(0xf5)],'text':_0x3df3c0[_0x3e3595(0x8b)]},_0x296785),_0x1c9bb0=await this[_0x3e3595(0xe2)][_0x3e3595(0x8d)](_0x3adda5);_0x2298d6[_0x3e3595(0x14b)](_0x3df3c0[_0x3e3595(0xf5)],_0x1c9bb0['id']),_0x5040c2[_0x3e3595(0xb3)][_0x3e3595(0x8e)]({'name':_0x3df3c0['name'],'action':_0x3e3595(0x13a),'id':_0x1c9bb0['id']}),_0x5040c2[_0x3e3595(0x13d)][_0x3e3595(0xb3)][_0x3e3595(0x13a)]++;}catch(_0xabe092){_0x5040c2[_0x3e3595(0xb3)][_0x3e3595(0x8e)]({'name':_0x3df3c0[_0x3e3595(0xf5)],'action':_0x3e3595(0xaf),'error':_0xabe092[_0x3e3595(0x6f)]}),_0x5040c2['counts'][_0x3e3595(0xb3)]['errors']++;}}const _0x152562=[..._0x4b543d]['sort']((_0x1ce47b,_0xc66a2a)=>{const _0x1a2fe2=_0x3e3595,_0x314425=_0x1ce47b[_0x1a2fe2(0x9a)][_0x1a2fe2(0x133)]?.[_0x1a2fe2(0xc4)](_0x3a791e=>_0x3a791e['type']==='agent')??![],_0x4f415a=_0xc66a2a[_0x1a2fe2(0x9a)][_0x1a2fe2(0x133)]?.[_0x1a2fe2(0xc4)](_0x1440d9=>_0x1440d9['type']==='agent')??![];if(_0x314425&&!_0x4f415a)return 0x1;if(!_0x314425&&_0x4f415a)return-0x1;return 0x0;});for(const _0x1513ee of _0x152562){try{const _0x4099c6=_0x1513ee[_0x3e3595(0x9a)][_0x3e3595(0x133)]?.['filter'](_0xdb7a01=>{const _0x52ccfd=_0x3e3595;if(_0xdb7a01[_0x52ccfd(0xca)]==='agent'){const _0x73588c=parseRef(_0xdb7a01[_0x52ccfd(0xe0)]);return _0x73588c?.['name']===_0x1513ee[_0x52ccfd(0x9a)][_0x52ccfd(0xf5)];}return![];})??[];_0x4099c6[_0x3e3595(0xb7)]>0x0&&this[_0x3e3595(0x147)]['logger']?.['warn'](_0x3e3595(0xb1)+_0x1513ee[_0x3e3595(0x9a)][_0x3e3595(0xf5)]+_0x3e3595(0x141)+_0x3e3595(0xa2));const _0x4c1486=await yamlAgentToApi(_0x1513ee['yaml'],_0x1513ee['systemPrompt'],_0x1513ee[_0x3e3595(0x143)],_0x4a3696),_0x218f6b=await this['client']['createAgentFull'](_0x4c1486);_0x56278a[_0x3e3595(0x14b)](_0x1513ee['yaml'][_0x3e3595(0xf5)],_0x218f6b['id']),_0x5040c2[_0x3e3595(0xa8)][_0x3e3595(0x8e)]({'agentName':_0x1513ee['yaml']['name'],'action':_0x3e3595(0x13a),'agentId':_0x218f6b['id']}),_0x5040c2['counts'][_0x3e3595(0xa8)][_0x3e3595(0x13a)]++;}catch(_0x34134a){_0x5040c2[_0x3e3595(0xa8)][_0x3e3595(0x8e)]({'agentName':_0x1513ee[_0x3e3595(0x9a)]['name'],'action':_0x3e3595(0xaf),'error':_0x34134a['message']}),_0x5040c2[_0x3e3595(0x13d)][_0x3e3595(0xa8)]['errors']++;}}for(const _0x564092 of _0xa169ea){try{const _0x5e17f2=await yamlPromptToApi(_0x564092[_0x3e3595(0x9a)],_0x296785,_0x4a3696);if(!_0x5e17f2){_0x5040c2['prompts'][_0x3e3595(0x8e)]({'name':_0x564092[_0x3e3595(0x9a)]['name'],'action':'error','error':_0x3e3595(0xce)}),_0x5040c2[_0x3e3595(0x13d)][_0x3e3595(0x129)][_0x3e3595(0x104)]++;continue;}const _0xced288=await this[_0x3e3595(0xe2)][_0x3e3595(0xb6)](_0x5e17f2);_0xa6d2e3[_0x3e3595(0x14b)](_0x564092[_0x3e3595(0x9a)][_0x3e3595(0xf5)],_0xced288['id']),_0x5040c2['prompts'][_0x3e3595(0x8e)]({'name':_0x564092[_0x3e3595(0x9a)][_0x3e3595(0xf5)],'action':_0x3e3595(0x13a),'id':_0xced288['id']}),_0x5040c2[_0x3e3595(0x13d)][_0x3e3595(0x129)]['created']++;}catch(_0x5a14e8){_0x5040c2[_0x3e3595(0x129)][_0x3e3595(0x8e)]({'name':_0x564092['yaml']['name'],'action':_0x3e3595(0xaf),'error':_0x5a14e8[_0x3e3595(0x6f)]}),_0x5040c2['counts']['prompts'][_0x3e3595(0x104)]++;}}return _0x5040c2;}}
|
|
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();}
|