@treasuredata/tdx 0.14.2 → 0.14.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin.js +1 -1
- package/dist/build-info.json +3 -3
- package/dist/cli-categories.js +1 -1
- package/dist/cli.js +1 -1
- package/dist/commands/activations.js +1 -1
- package/dist/commands/agent-command.js +1 -1
- package/dist/commands/api-command.js +1 -1
- package/dist/commands/auth-command.d.ts.map +1 -1
- package/dist/commands/auth-command.js +1 -1
- package/dist/commands/auth-command.js.map +1 -1
- package/dist/commands/chat-command.js +1 -1
- package/dist/commands/claude-command.js +1 -1
- package/dist/commands/claude-statusline-command.js +1 -1
- package/dist/commands/claude-usage-command.js +1 -1
- package/dist/commands/command.js +1 -1
- package/dist/commands/connection-command.js +1 -1
- package/dist/commands/databases.js +1 -1
- package/dist/commands/describe.js +1 -1
- package/dist/commands/engage-command.js +1 -1
- package/dist/commands/job-command.js +1 -1
- package/dist/commands/journey-command.js +1 -1
- package/dist/commands/journey-validate-command.js +1 -1
- package/dist/commands/llm-command.js +1 -1
- package/dist/commands/llm-proxy.js +1 -1
- package/dist/commands/parent-segment-command.js +1 -1
- package/dist/commands/profile-command.js +1 -1
- package/dist/commands/profiles-command.js +1 -1
- package/dist/commands/query-command.js +1 -1
- package/dist/commands/segment-command.js +1 -1
- package/dist/commands/segment-create-command.js +1 -1
- package/dist/commands/segment-fields-command.js +1 -1
- package/dist/commands/segment-pull-command.js +1 -1
- package/dist/commands/segment-push-command.js +1 -1
- package/dist/commands/segment-update-command.js +1 -1
- package/dist/commands/segment-use-command.js +1 -1
- package/dist/commands/segment-validate-command.js +1 -1
- package/dist/commands/segments.js +1 -1
- package/dist/commands/show.js +1 -1
- package/dist/commands/tables.js +1 -1
- package/dist/commands/use-command.js +1 -1
- package/dist/commands/user-command.js +1 -1
- package/dist/commands/workflow-command.js +1 -1
- package/dist/core/auth.js +1 -1
- package/dist/core/command-output.js +1 -1
- package/dist/core/config.js +1 -1
- package/dist/core/connection-cache.js +1 -1
- package/dist/core/constants.js +1 -1
- package/dist/core/credential-cache.js +1 -1
- package/dist/core/global-context.js +1 -1
- package/dist/core/keychain.js +1 -1
- package/dist/core/profile.d.ts +15 -0
- package/dist/core/profile.d.ts.map +1 -1
- package/dist/core/profile.js +1 -1
- package/dist/core/profile.js.map +1 -1
- package/dist/core/project-config.js +1 -1
- package/dist/core/session.js +1 -1
- package/dist/core/user-cache.js +1 -1
- package/dist/core/version.js +1 -1
- package/dist/index.js +1 -1
- package/dist/proxy/anthropic-adapter.js +1 -1
- package/dist/proxy/claude-usage-tracker.js +1 -1
- package/dist/proxy/context-signature.js +1 -1
- package/dist/proxy/conversation-utils.js +1 -1
- package/dist/proxy/passthrough-server.d.ts +13 -2
- package/dist/proxy/passthrough-server.d.ts.map +1 -1
- package/dist/proxy/passthrough-server.js +1 -1
- package/dist/proxy/passthrough-server.js.map +1 -1
- package/dist/proxy/server.js +1 -1
- package/dist/proxy/session-cache.js +1 -1
- package/dist/proxy/sse-usage-parser.js +1 -1
- package/dist/sdk/agent/agent-config.js +1 -1
- package/dist/sdk/agent/agent-ref-parser.js +1 -1
- package/dist/sdk/agent/agent-yaml.js +1 -1
- package/dist/sdk/api.js +1 -1
- package/dist/sdk/client/cdp-api-client.js +1 -1
- package/dist/sdk/client/endpoints.js +1 -1
- package/dist/sdk/client/engage-api-client.js +1 -1
- package/dist/sdk/client/http-client.js +1 -1
- package/dist/sdk/client/llm-api-client.js +1 -1
- package/dist/sdk/client/rate-limiter.js +1 -1
- package/dist/sdk/client/td-api-client.js +1 -1
- package/dist/sdk/client/trino-api-client.js +1 -1
- package/dist/sdk/client/workflow-client.js +1 -1
- package/dist/sdk/connection-validator.js +1 -1
- package/dist/sdk/connection.js +1 -1
- package/dist/sdk/engage.js +1 -1
- package/dist/sdk/errors.js +1 -1
- package/dist/sdk/index.js +1 -1
- package/dist/sdk/io/index.js +1 -1
- package/dist/sdk/io/node-filesystem.js +1 -1
- package/dist/sdk/job.js +1 -1
- package/dist/sdk/journey.js +1 -1
- package/dist/sdk/llm/chat-cache.js +1 -1
- package/dist/sdk/llm/index.js +1 -1
- package/dist/sdk/llm/llm-backup-utils.js +1 -1
- package/dist/sdk/llm/model-aliases.js +1 -1
- package/dist/sdk/llm/model-factors.js +1 -1
- package/dist/sdk/query/index.js +1 -1
- package/dist/sdk/query/sql-parser.js +1 -1
- package/dist/sdk/segment/child-segment-yaml.js +1 -1
- package/dist/sdk/segment/fields-display.js +1 -1
- package/dist/sdk/segment/file-discovery.js +1 -1
- package/dist/sdk/segment/journey-utils.js +1 -1
- package/dist/sdk/segment/journey-yaml.js +1 -1
- package/dist/sdk/segment/parent-segment-preview.js +1 -1
- package/dist/sdk/segment/parent-segment-yaml.js +1 -1
- package/dist/sdk/segment/pull-workflow.js +1 -1
- package/dist/sdk/segment/push-workflow.js +1 -1
- package/dist/sdk/segment/resolution-context.js +1 -1
- package/dist/sdk/segment/segment-path-parser.js +1 -1
- package/dist/sdk/segment/segment-ref-parser.js +1 -1
- package/dist/sdk/segment/target-resolution.js +1 -1
- package/dist/sdk/segment/tdx-config.js +1 -1
- package/dist/sdk/segment/validate-files.js +1 -1
- package/dist/sdk/segment/yaml-validator.js +1 -1
- package/dist/sdk/segment.js +1 -1
- package/dist/sdk/types/index.js +1 -1
- package/dist/sdk/types/progress.js +1 -1
- package/dist/sdk/user.js +1 -1
- package/dist/sdk/util/format-detector.js +1 -1
- package/dist/sdk/util/formatters.js +1 -1
- package/dist/sdk/util/index.js +1 -1
- package/dist/sdk/util/tree-formatter.js +1 -1
- package/dist/sdk/workflow/clone-workflow.js +1 -1
- package/dist/sdk/workflow/index.js +1 -1
- package/dist/sdk/workflow/pull-workflow.js +1 -1
- package/dist/sdk/workflow/push-workflow.js +1 -1
- package/dist/sdk/workflow/tdx-config.js +1 -1
- package/dist/sdk/workflow/workflow-utils.js +1 -1
- package/dist/utils/async.js +1 -1
- package/dist/utils/colors.js +1 -1
- package/dist/utils/diff.js +1 -1
- package/dist/utils/file-permissions.js +1 -1
- package/dist/utils/json-loader.js +1 -1
- package/dist/utils/option-validation.js +1 -1
- package/dist/utils/port.js +1 -1
- package/dist/utils/process.js +1 -1
- package/dist/utils/prompt.js +1 -1
- package/dist/utils/spinner.js +1 -1
- package/dist/utils/sse-parser.js +1 -1
- package/dist/utils/string-utils.js +1 -1
- package/dist/utils/table-ref-parser.js +1 -1
- package/dist/utils/tdx-logger.js +1 -1
- package/dist/utils/version-check.js +1 -1
- package/package.json +1 -1
package/dist/sdk/llm/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const a86_0x7001ef=a86_0x1455;(function(_0x3aa136,_0x582dc3){const _0x31c557=a86_0x1455,_0x477a5e=_0x3aa136();while(!![]){try{const _0x4aae61=parseInt(_0x31c557(0x21f))/0x1*(-parseInt(_0x31c557(0x192))/0x2)+-parseInt(_0x31c557(0x1ae))/0x3+-parseInt(_0x31c557(0x172))/0x4*(parseInt(_0x31c557(0x1e5))/0x5)+parseInt(_0x31c557(0x1e8))/0x6+parseInt(_0x31c557(0x189))/0x7+-parseInt(_0x31c557(0x1d6))/0x8+parseInt(_0x31c557(0x163))/0x9;if(_0x4aae61===_0x582dc3)break;else _0x477a5e['push'](_0x477a5e['shift']());}catch(_0x1673cb){_0x477a5e['push'](_0x477a5e['shift']());}}}(a86_0x58f8,0xea7a5));import{LLMApiClient}from'../client/llm-api-client.js';import*as a86_0x5d09ce from'node:fs';import*as a86_0x417a93 from'node:path';import{HTTPClientError}from'../client/http-client.js';function a86_0x58f8(){const _0x7e8ff=['updateTextKnowledgeBase','add','Invalid\x20backup:\x20project.json\x20not\x20found\x20in\x20','join','PERMISSION_DENIED','createWebSearchTool','some','project.json','context','client','isDirectory','availableModelNames','continueChat','integrations.json','\x20in\x20project\x20','displayName','AGENT_NOT_FOUND','jsonSchemaHint','startChat','agent.yml\x20not\x20found\x20in\x20','Project\x20not\x20found:\x20','56207745IHcnKg','currentProjectId','\x20attempts\x20due\x20to\x20name\x20conflicts.','listImageGenerators','imageGenerators','projectName','tdx.json','isDir','error','llm_project','agent.yml','Multiple\x20agents\x20found\x20with\x20name\x20\x27','minimal','Use\x20format:\x20\x22agent-name\x22\x20or\x20\x22project-name/agent-name\x22','createAgent','92uWjJmB','dry-run-','already\x20exists','listChats','getUserSettings','listAgentsFull','resolveProjectName','signal','reasoningEffort','agents','toISOString','split','starter_message.md','createPrompt','pullProject','agents.json','status','dirname','Use\x20\x22tdx\x20llm\x20projects\x22\x20to\x20list\x20available\x20projects.','updateAgent','loadJsonFile','profile','Agent\x20not\x20found:\x20','4959556xfMmgH','listTextKnowledgeBases','Run\x20\x27tdx\x20agent\x20pull\x20<project>\x27\x20first\x20to\x20create\x20the\x20folder\x20structure.','cwd','errors','utf-8','map','textKnowledgeBases','\x27.\x20This\x20should\x20not\x20happen.','37546wTJFuB','Use\x20a\x20different\x20output\x20path\x20or\x20remove\x20the\x20existing\x20directory.','projects','text','mkdirSync','endsWith','medium','dryRun','keys','(dry-run)','listAgents','action','readFileSync','models','Ensure\x20the\x20backup\x20folder\x20path\x20is\x20correct.','cloneProject','restoreProject','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.','Unsupported\x20backup\x20version:\x20','systemPrompt','pullAgent','actions','unlinkSync','.llm','getOrCreateDefaultProject','LLM_PROJECT_NOT_FOUND','createImageGenerator','prompts','5579220gLRsqR','tools','slackMessageMode','knowledge_bases','prompt.md','Permission\x20denied.\x20Please\x20check\x20your\x20API\x20key\x20has\x20the\x20required\x20permissions\x20for\x20LLM\x20API\x20operations.','exportedFrom','createKnowledgeBase','setDefaultAgent','starterMessage','warn','chatInfo','Backup\x20folder\x20not\x20found:\x20','deleteAgent','getProject','message','type','listPrompts','updated','Available\x20agents:\x20','getChatInfo','includes','new','find','createIntegration','updateAgentResponse','tables','Unable\x20to\x20create\x20project\x20after\x20','createAgentResponse','knowledgeBases','agent','Failed\x20to\x20get\x20or\x20create\x20agent:\x20exceeded\x20maximum\x20attempts','unchanged','pushAgent','agentId\x20is\x20required\x20when\x20starting\x20a\x20new\x20chat','low','setCurrentProject','event','chatIgnoreManagedActions','Invalid\x20agent\x20reference\x20format:\x20','10710232tlIgWl','Authentication\x20failed.\x20Please\x20check\x20your\x20API\x20key\x20is\x20valid\x20and\x20not\x20expired.','This\x20backup\x20was\x20created\x20with\x20a\x20newer\x20version\x20of\x20tdx.','parse','template','NOT_FOUND','tdx_','existsSync','listKnowledgeBases','availableModels','clearDefaultAgent','image_gen','version','none','\x0a\x0a#\x20agent.yml\x0a','240010ViPWMd','isManaged','getCurrentProject','555648PdHCsa','push','resolveProjectId','listWebSearchTools','metadata','getOrCreateDefaultAgent','INVALID_ARGUMENT','prompts.json','\x22\x20already\x20exists','deleteProject','total','tdx_default_','Choose\x20a\x20different\x20name\x20or\x20delete\x20the\x20existing\x20project\x20first.','Ensure\x20the\x20path\x20points\x20to\x20a\x20valid\x20agent\x20directory.','.md','createProject','counts','filter','outputs','variables','stringify','Ensure\x20this\x20is\x20a\x20valid\x20LLM\x20project\x20backup\x20folder.','created','The\x20backup\x20contains\x20agents\x20with\x20circular\x20dependencies.','modelType','pushProject','chat','path','listProjects','INTERNAL','getBackupMetadata','logger','sort','Circular\x20dependency\x20detected\x20in\x20agents.\x20Cannot\x20restore.','integrations','site','starter_message','promptId','writeFileSync','set','attributes','chats','#\x20prompt.md\x0a','getDefaultProjectName','agentId','size','readdirSync','knowledgebases.json','name','target','getUniqueName','get','temperature','content','yaml','95XsdFFc','Use\x20\x22tdx\x20llm\x20agents\x22\x20to\x20list\x20available\x20agents\x20in\x20the\x20current\x20project.','webSearchTools','getAgent','duplicate','Agent\x20reference\x20not\x20found','createTextKnowledgeBase','UNAUTHENTICATED','.yml','high','resolveAgentId','serviceType','length','newProjectId','Project\x20\x22','ALREADY_EXISTS'];a86_0x58f8=function(){return _0x7e8ff;};return a86_0x58f8();}import{canCreateAgent,remapToolIds,remapVariableIds,isSupportedBackupVersion}from'./llm-backup-utils.js';import{SDKError,ErrorCode,errorContains}from'../errors.js';import{normalizeName,UniqueNameGenerator,migrateModelType,parseRef,agentResponseToDef,apiKnowledgeBaseToYaml,apiPromptToYaml,toAgentYamlString,toKnowledgeBaseYamlString,toTextKnowledgeBaseMd,toPromptYamlString,parseAgentYaml,parseKnowledgeBaseYaml,parseTextKnowledgeBaseMd,parsePromptYaml,agentDefToRequest,yamlKnowledgeBaseToApi,yamlTextKnowledgeBaseToApi,yamlPromptToApi,resolveAgentDependencies}from'../agent/agent-yaml.js';import{createAgentConfigContent,loadAgentConfig,findAgentConfig,isAgentDir,isAgentYamlPath,getAgentDirFromYamlPath,getKnowledgeBasesDir,getPromptsDir}from'../agent/agent-config.js';import{getSanitizedUsername,generateRandomHex}from'../../utils/string-utils.js';function a86_0x1455(_0x1ad2c5,_0x5aad3b){_0x1ad2c5=_0x1ad2c5-0x157;const _0x58f8c1=a86_0x58f8();let _0x1455a2=_0x58f8c1[_0x1ad2c5];return _0x1455a2;}import{generateDiff,formatDiffWithColors,hasChanges}from'../../utils/diff.js';import{readCachedLLMProject,writeCachedLLMProject,readCachedLLMAgent,writeCachedLLMAgent,clearCachedLLMAgent}from'../../core/config.js';export class LLMSDK{[a86_0x7001ef(0x164)];[a86_0x7001ef(0x157)];[a86_0x7001ef(0x237)];constructor(_0x372350){const _0x257d2f=a86_0x7001ef;this[_0x257d2f(0x157)]=new LLMApiClient(_0x372350,_0x372350[_0x257d2f(0x207)]),this['context']=_0x372350;}[a86_0x7001ef(0x213)](){const _0x4d1545=a86_0x7001ef,_0x206987=getSanitizedUsername();return _0x4d1545(0x1f3)+_0x206987;}async[a86_0x7001ef(0x1d2)](_0x5ee9d5){const _0x34ba13=a86_0x7001ef,{projectId:_0x539879}=await this[_0x34ba13(0x178)](_0x5ee9d5);this[_0x34ba13(0x164)]=_0x539879;}[a86_0x7001ef(0x1e7)](){return this['currentProjectId'];}async[a86_0x7001ef(0x1b6)](_0x25fe0c){const _0x1bf66a=a86_0x7001ef,_0x1444d8=this[_0x1bf66a(0x237)][_0x1bf66a(0x187)];let _0x585471,_0x14b3dc;if(_0x25fe0c['includes']('/')){const _0x529f6a=_0x25fe0c[_0x1bf66a(0x17d)]('/');if(_0x529f6a[_0x1bf66a(0x22b)]!==0x2)throw new SDKError(ErrorCode[_0x1bf66a(0x1ee)],_0x1bf66a(0x1d5)+_0x25fe0c,undefined,{'helpText':_0x1bf66a(0x170)});const [_0x508655,_0x49d50d]=_0x529f6a;_0x585471=await this[_0x1bf66a(0x1ea)](_0x508655),_0x14b3dc=_0x49d50d;}else _0x585471=this[_0x1bf66a(0x164)]||(await this[_0x1bf66a(0x1aa)]())['id'],_0x14b3dc=_0x25fe0c;const _0x45dc0f=await this[_0x1bf66a(0x229)](_0x14b3dc,_0x585471),_0x55b10c=await this[_0x1bf66a(0x157)][_0x1bf66a(0x222)](_0x45dc0f);writeCachedLLMAgent(_0x55b10c[_0x1bf66a(0x210)][_0x1bf66a(0x218)],_0x45dc0f,_0x585471,_0x1444d8);}['getDefaultAgent'](){const _0x41f1b=a86_0x7001ef,_0x3d8b5c=this[_0x41f1b(0x237)][_0x41f1b(0x187)];return readCachedLLMAgent(_0x3d8b5c)||undefined;}[a86_0x7001ef(0x1e0)](){const _0x17f0cd=a86_0x7001ef,_0x418b82=this[_0x17f0cd(0x237)][_0x17f0cd(0x187)];clearCachedLLMAgent(_0x418b82);}async[a86_0x7001ef(0x19f)](){const _0xa1893b=a86_0x7001ef,_0x598c3d=await this['client'][_0xa1893b(0x176)](),_0x20c719=[];for(const _0x3f0ce4 of _0x598c3d[_0xa1893b(0x159)]){const _0x206cf2=_0x598c3d[_0xa1893b(0x1df)][_0x3f0ce4];_0x206cf2&&_0x20c719[_0xa1893b(0x1e9)]({'name':_0x3f0ce4,'displayName':_0x206cf2[_0xa1893b(0x15d)]});}return _0x20c719;}async[a86_0x7001ef(0x1f7)](_0xce6ff4){const _0x12f7d2=a86_0x7001ef;return await this['client'][_0x12f7d2(0x1f7)](_0xce6ff4);}async[a86_0x7001ef(0x1f1)](_0x44320a){const _0x11649a=a86_0x7001ef,{projectId:_0x4b769c}=await this['resolveProjectName'](_0x44320a);await this[_0x11649a(0x157)]['deleteProject'](_0x4b769c);}async[a86_0x7001ef(0x194)](_0x321146=0x32){const _0x2778ff=a86_0x7001ef;return await this[_0x2778ff(0x157)]['listProjects'](_0x321146);}async['getOrCreateDefaultProject'](_0x5ea988){const _0x263f01=a86_0x7001ef,_0x544aaa=_0x5ea988||this[_0x263f01(0x213)](),_0x2dac6a=this[_0x263f01(0x237)]['profile'];if(!_0x5ea988){const _0x5f243f=readCachedLLMProject(_0x2dac6a);if(_0x5f243f&&_0x5f243f[_0x263f01(0x218)]===_0x544aaa)try{const _0xf4979c=await this['client'][_0x263f01(0x1bc)](_0x5f243f['id']);if(_0xf4979c['attributes'][_0x263f01(0x218)]===_0x544aaa)return _0xf4979c;}catch{}}const _0x3fb930=await this[_0x263f01(0x157)][_0x263f01(0x204)](),_0x26f920=_0x3fb930[_0x263f01(0x1c5)](_0x5cba43=>_0x5cba43['attributes']['name']===_0x544aaa);if(_0x26f920)return!_0x5ea988&&writeCachedLLMProject(_0x544aaa,_0x26f920['id'],_0x2dac6a),_0x26f920;const _0x1d63cd=await this['client'][_0x263f01(0x1f7)]({'name':_0x544aaa,'description':'Default\x20project\x20for\x20tdx\x20CLI\x20chat\x20(user:\x20'+getSanitizedUsername()+')'});return!_0x5ea988&&writeCachedLLMProject(_0x544aaa,_0x1d63cd['id'],_0x2dac6a),_0x1d63cd;}async[a86_0x7001ef(0x1ea)](_0x191f2d){const _0x148654=a86_0x7001ef,_0x555d10=await this['client'][_0x148654(0x204)](),_0x5221a8=_0x555d10[_0x148654(0x1f9)](_0x12c3c9=>_0x12c3c9[_0x148654(0x210)]['name']===_0x191f2d);if(_0x5221a8[_0x148654(0x22b)]===0x0)throw new SDKError(ErrorCode[_0x148654(0x1ab)],_0x148654(0x162)+_0x191f2d,undefined,{'helpText':_0x148654(0x184)});if(_0x5221a8['length']>0x1)throw new SDKError(ErrorCode['INTERNAL'],'Multiple\x20projects\x20found\x20with\x20name\x20\x27'+_0x191f2d+_0x148654(0x191));return _0x5221a8[0x0]['id'];}async[a86_0x7001ef(0x178)](_0x5b2186){const _0x9a6d48=a86_0x7001ef,_0x4d3e9a=await this[_0x9a6d48(0x157)]['listProjects'](),_0x3d73ba=_0x4d3e9a[_0x9a6d48(0x1c5)](_0x3bb799=>_0x3bb799[_0x9a6d48(0x210)][_0x9a6d48(0x218)]===_0x5b2186);if(_0x3d73ba)return{'projectId':_0x3d73ba['id'],'project':_0x3d73ba};throw new SDKError(ErrorCode[_0x9a6d48(0x1ab)],_0x9a6d48(0x162)+_0x5b2186,undefined,{'helpText':'Use\x20\x22tdx\x20llm\x20projects\x22\x20to\x20list\x20available\x20projects.'});}async[a86_0x7001ef(0x1ed)](_0x4237b4='claude-4.5-sonnet',_0x59b662=0x0,_0x2da8c6){const _0x4ff4de=a86_0x7001ef,_0x59cef3=0xa;let _0x275688=0x0,_0x270a68;while(_0x275688<_0x59cef3){try{const _0x5c4a7c=await this['getOrCreateDefaultProject'](_0x270a68),_0x359c0e=_0x5c4a7c['id'],_0x27d9c6=[_0x4ff4de(0x1e3),_0x4ff4de(0x16f),_0x4ff4de(0x1d1),_0x4ff4de(0x198),_0x4ff4de(0x228)],_0x5c3005=_0x59b662===0x0?_0x4ff4de(0x1dc)+_0x4237b4:_0x4ff4de(0x1dc)+_0x4237b4+'_reasoning_'+_0x27d9c6[_0x59b662],_0x161043=await this[_0x4ff4de(0x157)][_0x4ff4de(0x19c)](_0x359c0e),_0x1b39bc=_0x161043['find'](_0x5d3872=>_0x5d3872[_0x4ff4de(0x210)][_0x4ff4de(0x218)]===_0x5c3005);if(_0x1b39bc)return _0x1b39bc;const _0x158f9c=_0x59b662>0x0?0x1:_0x2da8c6;return await this[_0x4ff4de(0x157)][_0x4ff4de(0x171)]({'name':_0x5c3005,'projectId':_0x359c0e,'modelType':_0x4237b4,'systemPrompt':'','temperature':_0x158f9c,'reasoningEffort':_0x59b662>0x0?_0x59b662:undefined});}catch(_0x18502d){if(_0x18502d instanceof HTTPClientError){const _0x3acdec=_0x18502d[_0x4ff4de(0x182)];if(_0x3acdec>=0x190&&_0x3acdec<0x1f4){if(_0x3acdec===0x191)throw new SDKError(ErrorCode[_0x4ff4de(0x226)],_0x4ff4de(0x1d7),_0x18502d);else{if(_0x3acdec===0x193)throw new SDKError(ErrorCode[_0x4ff4de(0x233)],_0x4ff4de(0x1b3),_0x18502d);}throw _0x18502d;}}if(errorContains(_0x18502d,_0x4ff4de(0x174),_0x4ff4de(0x223),'conflict')){_0x275688++;if(_0x275688>=_0x59cef3)throw new SDKError(ErrorCode[_0x4ff4de(0x22e)],_0x4ff4de(0x1c9)+_0x59cef3+_0x4ff4de(0x165),_0x18502d);const _0x353fc6=this[_0x4ff4de(0x213)]();_0x270a68=_0x353fc6+'_'+generateRandomHex();continue;}throw _0x18502d;}}throw new SDKError(ErrorCode['INTERNAL'],_0x4ff4de(0x1cd));}async[a86_0x7001ef(0x229)](_0x25f12e,_0x4054e4){const _0x40e75d=a86_0x7001ef,_0x5b252b=_0x4054e4||this[_0x40e75d(0x164)],_0x347990=await this['client'][_0x40e75d(0x19c)](_0x5b252b),_0x44fce7=_0x347990[_0x40e75d(0x1f9)](_0x56c95b=>_0x56c95b[_0x40e75d(0x210)][_0x40e75d(0x218)]===_0x25f12e);if(_0x44fce7[_0x40e75d(0x22b)]===0x0){const _0x418d06=_0x5b252b?_0x40e75d(0x15c)+_0x5b252b:'';throw new SDKError(ErrorCode[_0x40e75d(0x15e)],_0x40e75d(0x188)+_0x25f12e+_0x418d06,undefined,{'helpText':_0x5b252b?_0x40e75d(0x220):_0x40e75d(0x1a3)});}if(_0x44fce7[_0x40e75d(0x22b)]>0x1)throw new SDKError(ErrorCode[_0x40e75d(0x205)],_0x40e75d(0x16e)+_0x25f12e+'\x27.\x20This\x20should\x20not\x20happen.');return _0x44fce7[0x0]['id'];}async['agents'](_0x5a90b4){const _0x4cd81e=a86_0x7001ef,_0x3465b9=_0x5a90b4||this[_0x4cd81e(0x164)];return await this[_0x4cd81e(0x157)][_0x4cd81e(0x19c)](_0x3465b9);}async[a86_0x7001ef(0x1cc)](_0x2d930f){const _0x9217a0=a86_0x7001ef;return await this[_0x9217a0(0x157)]['getAgent'](_0x2d930f);}async[a86_0x7001ef(0x171)](_0x35acf4){const _0x218c5b=a86_0x7001ef;return await this[_0x218c5b(0x157)]['createAgent'](_0x35acf4);}async[a86_0x7001ef(0x185)](_0x220376,_0x1ab41a){const _0x6ec9dd=a86_0x7001ef;return await this[_0x6ec9dd(0x157)][_0x6ec9dd(0x185)](_0x220376,_0x1ab41a);}async[a86_0x7001ef(0x1bb)](_0x362a67){const _0x4268a1=a86_0x7001ef;await this[_0x4268a1(0x157)][_0x4268a1(0x1bb)](_0x362a67);}async[a86_0x7001ef(0x160)](_0x21c8ba){const _0x448127=a86_0x7001ef;return await this['client'][_0x448127(0x160)]({'agentId':_0x21c8ba});}async*[a86_0x7001ef(0x202)](_0x405abc,_0x2888b6){const _0x123d42=a86_0x7001ef;let _0x17309e=_0x2888b6?.['chatId'];const _0x3ee0c3=_0x2888b6?.[_0x123d42(0x214)];if(!_0x17309e){if(!_0x3ee0c3)throw new Error(_0x123d42(0x1d0));const _0x326084=await this[_0x123d42(0x157)]['startChat']({'agentId':_0x3ee0c3});_0x17309e=_0x326084['id'],yield{'type':_0x123d42(0x1ec),'data':{'chatId':_0x17309e,'agentId':_0x3ee0c3}};}for await(const _0x357684 of this[_0x123d42(0x157)][_0x123d42(0x15a)](_0x17309e,_0x405abc,_0x2888b6?.[_0x123d42(0x179)])){yield{'type':_0x123d42(0x1d3),'data':_0x357684};}}async[a86_0x7001ef(0x211)](_0x55ff23=0x32){const _0x193b12=a86_0x7001ef;return await this[_0x193b12(0x157)][_0x193b12(0x175)](_0x55ff23);}async['history'](_0x344c19){const _0x52b067=a86_0x7001ef;return await this[_0x52b067(0x157)]['getChatHistory'](_0x344c19);}async[a86_0x7001ef(0x1b9)](_0x4cf5ec){const _0x43dcd7=a86_0x7001ef;return await this[_0x43dcd7(0x157)][_0x43dcd7(0x1c2)](_0x4cf5ec);}async['backupProject'](_0x5c301b,_0x21dfdc,_0x60d26c){const _0x577a38=a86_0x7001ef,_0x58552d=_0x60d26c?.[_0x577a38(0x199)]??![],{projectId:_0x300be2,project:_0x488805}=await this['resolveProjectName'](_0x5c301b),_0xd995d3=_0x488805[_0x577a38(0x210)][_0x577a38(0x218)],_0x27fb19=_0x21dfdc||_0xd995d3+_0x577a38(0x1a9);if(a86_0x5d09ce['existsSync'](_0x27fb19)&&!_0x58552d)throw new SDKError(ErrorCode[_0x577a38(0x22e)],'Output\x20directory\x20already\x20exists:\x20'+_0x27fb19,undefined,{'helpText':_0x577a38(0x193)});const _0x365599=await this['client'][_0x577a38(0x177)](_0x300be2),_0x3f3302=await this[_0x577a38(0x157)][_0x577a38(0x1de)](_0x300be2),_0x412580=await this[_0x577a38(0x157)][_0x577a38(0x1bf)](_0x300be2),_0x2f3345=await this['client']['listIntegrations'](_0x300be2);if(!_0x58552d){a86_0x5d09ce[_0x577a38(0x196)](_0x27fb19,{'recursive':!![]});const _0x34d202={'version':'1.0','exportedAt':new Date()[_0x577a38(0x17c)](),'exportedFrom':{'site':this[_0x577a38(0x237)]['site'],'projectId':_0x300be2,'projectName':_0xd995d3},'project':_0x488805};a86_0x5d09ce[_0x577a38(0x20e)](a86_0x417a93[_0x577a38(0x232)](_0x27fb19,'project.json'),JSON[_0x577a38(0x1fc)](_0x34d202,null,0x2)),a86_0x5d09ce[_0x577a38(0x20e)](a86_0x417a93[_0x577a38(0x232)](_0x27fb19,_0x577a38(0x181)),JSON[_0x577a38(0x1fc)](_0x365599,null,0x2)),a86_0x5d09ce[_0x577a38(0x20e)](a86_0x417a93[_0x577a38(0x232)](_0x27fb19,_0x577a38(0x217)),JSON[_0x577a38(0x1fc)](_0x3f3302,null,0x2)),a86_0x5d09ce[_0x577a38(0x20e)](a86_0x417a93['join'](_0x27fb19,_0x577a38(0x1ef)),JSON[_0x577a38(0x1fc)](_0x412580,null,0x2)),a86_0x5d09ce[_0x577a38(0x20e)](a86_0x417a93['join'](_0x27fb19,_0x577a38(0x15b)),JSON[_0x577a38(0x1fc)](_0x2f3345,null,0x2));}return{'projectName':_0xd995d3,'outputDir':_0x27fb19,'counts':{'agents':_0x365599['length'],'knowledgeBases':_0x3f3302[_0x577a38(0x22b)],'prompts':_0x412580[_0x577a38(0x22b)],'integrations':_0x2f3345['length']}};}async[a86_0x7001ef(0x1a2)](_0x285c1d,_0x4a4f18){const _0x402b3f=a86_0x7001ef,_0x2232a3=_0x4a4f18?.[_0x402b3f(0x199)]??![],_0x18c06e=this[_0x402b3f(0x206)](_0x285c1d),_0x39de46=_0x18c06e[_0x402b3f(0x1b4)]['site'],_0x2ebaae=this[_0x402b3f(0x237)][_0x402b3f(0x20b)],_0x55532c=_0x39de46!==_0x2ebaae?_0x39de46:undefined,_0xfc0004=this[_0x402b3f(0x186)](a86_0x417a93[_0x402b3f(0x232)](_0x285c1d,_0x402b3f(0x181)),[]),_0x26c756=this[_0x402b3f(0x186)](a86_0x417a93['join'](_0x285c1d,_0x402b3f(0x217)),[]),_0x4c0dac=this[_0x402b3f(0x186)](a86_0x417a93[_0x402b3f(0x232)](_0x285c1d,_0x402b3f(0x1ef)),[]),_0x2a7a0f=this['loadJsonFile'](a86_0x417a93[_0x402b3f(0x232)](_0x285c1d,'integrations.json'),[]),_0xd37603=_0x4a4f18?.[_0x402b3f(0x218)]||_0x18c06e[_0x402b3f(0x1b4)][_0x402b3f(0x168)];if(_0x2232a3){const _0x12a391=new Map(),_0x1241a0=[..._0xfc0004],_0xe85889=_0xfc0004['length']+0x1;let _0x305b79=0x0;while(_0x1241a0[_0x402b3f(0x22b)]>0x0&&_0x305b79<_0xe85889){_0x305b79++;const _0x3edc07=[];for(const _0x26f0df of _0x1241a0){canCreateAgent(_0x26f0df,_0x12a391)?_0x12a391['set'](_0x26f0df['id'],_0x402b3f(0x173)+_0x26f0df['id']):_0x3edc07[_0x402b3f(0x1e9)](_0x26f0df);}if(_0x3edc07[_0x402b3f(0x22b)]===_0x1241a0[_0x402b3f(0x22b)])throw new SDKError(ErrorCode[_0x402b3f(0x205)],_0x402b3f(0x209),undefined,{'helpText':_0x402b3f(0x1ff)});_0x1241a0[_0x402b3f(0x22b)]=0x0,_0x1241a0[_0x402b3f(0x1e9)](..._0x3edc07);}const _0x3652b7=_0x4c0dac['filter'](_0x5c8002=>_0x12a391['has'](_0x5c8002[_0x402b3f(0x210)]['agentId']))[_0x402b3f(0x22b)];return{'projectName':_0xd37603,'projectId':_0x402b3f(0x19b),'counts':{'agents':_0xfc0004[_0x402b3f(0x22b)],'knowledgeBases':_0x26c756[_0x402b3f(0x22b)],'prompts':_0x3652b7,'integrations':_0x2a7a0f[_0x402b3f(0x22b)]},'sourceSite':_0x55532c};}const _0xe9d57=await this[_0x402b3f(0x157)][_0x402b3f(0x1f7)]({'name':_0xd37603,'description':_0x18c06e['project'][_0x402b3f(0x210)]['description']}),_0x2d43bb=_0xe9d57['id'],_0x3f9182=new Map(),_0x5a926b=new Map(),_0x251b7c=new Map();for(const _0x58fa7e of _0x26c756){const _0x2c0d4b=await this['client'][_0x402b3f(0x1b5)]({'projectId':_0x2d43bb,'name':_0x58fa7e[_0x402b3f(0x210)]['name'],'tdDatabaseName':_0x58fa7e[_0x402b3f(0x210)]['tdDatabaseName'],'tables':_0x58fa7e[_0x402b3f(0x210)][_0x402b3f(0x1c8)]});_0x3f9182[_0x402b3f(0x20f)](_0x58fa7e['id'],_0x2c0d4b['id']);}const _0x4371bb=[..._0xfc0004],_0x52b218=_0xfc0004[_0x402b3f(0x22b)]+0x1;let _0x3b260d=0x0;while(_0x4371bb[_0x402b3f(0x22b)]>0x0&&_0x3b260d<_0x52b218){_0x3b260d++;const _0xf59e7a=[];for(const _0xa0c2cf of _0x4371bb){if(canCreateAgent(_0xa0c2cf,_0x5a926b)){const _0x10d265=remapToolIds(_0xa0c2cf['attributes'][_0x402b3f(0x1af)],_0x3f9182,_0x5a926b),_0x214d0f=remapVariableIds(_0xa0c2cf[_0x402b3f(0x210)][_0x402b3f(0x1fb)],_0x3f9182),_0x39912e=await this[_0x402b3f(0x157)][_0x402b3f(0x1ca)]({'name':_0xa0c2cf[_0x402b3f(0x210)][_0x402b3f(0x218)],'projectId':_0x2d43bb,'systemPrompt':_0xa0c2cf[_0x402b3f(0x210)][_0x402b3f(0x1a5)],'starterMessage':_0xa0c2cf['attributes'][_0x402b3f(0x1b7)],'modelType':migrateModelType(_0xa0c2cf[_0x402b3f(0x210)][_0x402b3f(0x200)]),'maxToolIterations':_0xa0c2cf[_0x402b3f(0x210)]['maxToolIterations'],'temperature':_0xa0c2cf[_0x402b3f(0x210)][_0x402b3f(0x21c)],'reasoningEffort':_0xa0c2cf[_0x402b3f(0x210)][_0x402b3f(0x17a)],'outputs':_0xa0c2cf[_0x402b3f(0x210)][_0x402b3f(0x1fa)],'tools':_0x10d265,'variables':_0x214d0f});_0x5a926b['set'](_0xa0c2cf['id'],_0x39912e['id']);}else _0xf59e7a[_0x402b3f(0x1e9)](_0xa0c2cf);}if(_0xf59e7a[_0x402b3f(0x22b)]===_0x4371bb[_0x402b3f(0x22b)])throw new SDKError(ErrorCode['INTERNAL'],'Circular\x20dependency\x20detected\x20in\x20agents.\x20Cannot\x20restore.',undefined,{'helpText':'The\x20backup\x20contains\x20agents\x20with\x20circular\x20dependencies.'});_0x4371bb[_0x402b3f(0x22b)]=0x0,_0x4371bb[_0x402b3f(0x1e9)](..._0xf59e7a);}for(const _0xe2a2b6 of _0x4c0dac){const _0x5a249e=_0x5a926b[_0x402b3f(0x21b)](_0xe2a2b6['attributes'][_0x402b3f(0x214)]);if(!_0x5a249e)continue;const _0x4ba195=await this['client'][_0x402b3f(0x17f)]({'projectId':_0x2d43bb,'agentId':_0x5a249e,'name':_0xe2a2b6['attributes'][_0x402b3f(0x218)],'systemPrompt':_0xe2a2b6[_0x402b3f(0x210)][_0x402b3f(0x1a5)],'template':_0xe2a2b6[_0x402b3f(0x210)][_0x402b3f(0x1da)],'jsonSchemaHint':_0xe2a2b6['attributes'][_0x402b3f(0x15f)]});_0x251b7c['set'](_0xe2a2b6['id'],_0x4ba195['id']);}for(const _0x356307 of _0x2a7a0f){const _0x4eb35e=_0x356307[_0x402b3f(0x210)][_0x402b3f(0x1a7)][_0x402b3f(0x18f)](_0xc3b27e=>({..._0xc3b27e,'promptId':_0x251b7c[_0x402b3f(0x21b)](_0xc3b27e[_0x402b3f(0x20d)])||_0xc3b27e[_0x402b3f(0x20d)]}));await this['client'][_0x402b3f(0x1c6)]({'projectId':_0x2d43bb,'serviceType':_0x356307['attributes'][_0x402b3f(0x22a)],'actions':_0x4eb35e,'slackMessageMode':_0x356307['attributes'][_0x402b3f(0x1b0)],'chatIgnoreManagedActions':_0x356307[_0x402b3f(0x210)][_0x402b3f(0x1d4)],'chatWelcomeMessage':_0x356307[_0x402b3f(0x210)]['chatWelcomeMessage'],'webhookCorsOrigins':_0x356307[_0x402b3f(0x210)]['webhookCorsOrigins']});}return{'projectName':_0xd37603,'projectId':_0x2d43bb,'counts':{'agents':_0x5a926b[_0x402b3f(0x215)],'knowledgeBases':_0x3f9182[_0x402b3f(0x215)],'prompts':_0x251b7c[_0x402b3f(0x215)],'integrations':_0x2a7a0f[_0x402b3f(0x22b)]},'sourceSite':_0x55532c};}['loadJsonFile'](_0x5a0769,_0x20b266){const _0xe28931=a86_0x7001ef;if(!a86_0x5d09ce[_0xe28931(0x1dd)](_0x5a0769))return _0x20b266;return JSON[_0xe28931(0x1d9)](a86_0x5d09ce['readFileSync'](_0x5a0769,_0xe28931(0x18e)));}[a86_0x7001ef(0x206)](_0x57f36e){const _0x378212=a86_0x7001ef;if(!a86_0x5d09ce[_0x378212(0x1dd)](_0x57f36e))throw new SDKError(ErrorCode[_0x378212(0x1db)],_0x378212(0x1ba)+_0x57f36e,undefined,{'helpText':_0x378212(0x1a0)});const _0x258977=a86_0x417a93[_0x378212(0x232)](_0x57f36e,_0x378212(0x236));if(!a86_0x5d09ce[_0x378212(0x1dd)](_0x258977))throw new SDKError(ErrorCode['INVALID_ARGUMENT'],_0x378212(0x231)+_0x57f36e,undefined,{'helpText':_0x378212(0x1fd)});const _0x305888=JSON[_0x378212(0x1d9)](a86_0x5d09ce[_0x378212(0x19e)](_0x258977,_0x378212(0x18e)));if(!isSupportedBackupVersion(_0x305888['version']))throw new SDKError(ErrorCode[_0x378212(0x1ee)],_0x378212(0x1a4)+_0x305888[_0x378212(0x1e2)],undefined,{'helpText':_0x378212(0x1d8)});return _0x305888;}async[a86_0x7001ef(0x180)](_0x1d98c3,_0x331c04,_0xd6368f){const _0x5afc8a=a86_0x7001ef,{projectId:_0x47822d,project:_0x12cb67}=await this[_0x5afc8a(0x178)](_0x1d98c3),_0x4c12e7=_0x12cb67[_0x5afc8a(0x210)][_0x5afc8a(0x218)],_0x34d60b=normalizeName(_0x4c12e7),_0xabe131=_0x331c04||a86_0x417a93[_0x5afc8a(0x232)](process[_0x5afc8a(0x18c)](),'agents',_0x34d60b),_0x575288=await this[_0x5afc8a(0x157)][_0x5afc8a(0x177)](_0x47822d),_0x179148=await this[_0x5afc8a(0x157)][_0x5afc8a(0x1de)](_0x47822d),_0x377ee3=await this['client'][_0x5afc8a(0x18a)](_0x47822d),_0x19c4e5=await this[_0x5afc8a(0x157)]['listImageGenerators'](_0x47822d),_0x511ecc=await this[_0x5afc8a(0x157)][_0x5afc8a(0x1eb)](_0x47822d),_0x3ed0b5=await this[_0x5afc8a(0x157)][_0x5afc8a(0x1bf)](_0x47822d),_0x1c85fb=new Map(),_0x526294=new Map(),_0x22d6c2=new Map(),_0xf357c=new Map(),_0x31be63=new Map(),_0x23de36=new Map();for(const _0x42290a of _0x575288){_0x1c85fb[_0x5afc8a(0x20f)](_0x42290a['id'],_0x42290a[_0x5afc8a(0x210)][_0x5afc8a(0x218)]);}for(const _0x31da81 of _0x179148){_0x526294[_0x5afc8a(0x20f)](_0x31da81['id'],_0x31da81[_0x5afc8a(0x210)]['name']);}for(const _0x7b0fc3 of _0x377ee3){_0x22d6c2[_0x5afc8a(0x20f)](_0x7b0fc3['id'],_0x7b0fc3[_0x5afc8a(0x210)][_0x5afc8a(0x218)]);}for(const _0x13c64c of _0x19c4e5){_0xf357c['set'](_0x13c64c['id'],_0x13c64c[_0x5afc8a(0x210)]['name']);}for(const _0x5ade93 of _0x511ecc){_0x31be63['set'](_0x5ade93['id'],_0x5ade93[_0x5afc8a(0x210)][_0x5afc8a(0x218)]);}for(const _0x35d38c of _0x3ed0b5){_0x23de36['set'](_0x35d38c['id'],_0x35d38c[_0x5afc8a(0x210)][_0x5afc8a(0x218)]);}const _0x3ad282={'resolveKnowledgeBaseName':async _0x68ca9c=>_0x526294['get'](_0x68ca9c),'resolveTextKnowledgeBaseName':async _0x1ecde6=>_0x22d6c2[_0x5afc8a(0x21b)](_0x1ecde6),'resolveAgentName':async _0x53a746=>_0x1c85fb[_0x5afc8a(0x21b)](_0x53a746),'resolveWebSearchToolName':async _0x2e42d5=>_0x31be63[_0x5afc8a(0x21b)](_0x2e42d5),'resolveImageGeneratorName':async _0x49847d=>_0xf357c[_0x5afc8a(0x21b)](_0x49847d),'resolvePromptName':async _0x753e67=>_0x23de36['get'](_0x753e67),'onWarning':_0xd33dbc=>this[_0x5afc8a(0x237)][_0x5afc8a(0x207)]?.[_0x5afc8a(0x1b8)](_0xd33dbc)},_0x128191={'projectName':_0x4c12e7,'outputDir':_0xabe131,'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}}},_0x31f68d=[],_0x573d5e=new UniqueNameGenerator(),_0x2976dd=new UniqueNameGenerator(),_0xb6db5b=new UniqueNameGenerator(),_0x120500=new UniqueNameGenerator();for(const _0x6089f0 of _0x575288){const _0x212795=_0x573d5e[_0x5afc8a(0x21a)](_0x6089f0[_0x5afc8a(0x210)][_0x5afc8a(0x218)]),_0x596d4c=a86_0x417a93[_0x5afc8a(0x232)](_0xabe131,_0x212795),_0xd2e5d0=a86_0x417a93['join'](_0x596d4c,_0x5afc8a(0x1b2)),_0x3837b4=a86_0x417a93[_0x5afc8a(0x232)](_0x596d4c,_0x5afc8a(0x16d)),_0x672a3d=a86_0x417a93[_0x5afc8a(0x232)](_0x596d4c,'starter_message.md'),{yaml:_0x2dbe93,systemPrompt:_0x328caa,starterMessage:_0x32fc0c}=await agentResponseToDef(_0x6089f0,_0x3ad282),_0x5c7c78=toAgentYamlString(_0x2dbe93),_0x292475=!a86_0x5d09ce[_0x5afc8a(0x1dd)](_0x3837b4);let _0x5938b6=_0x292475,_0x42df0a;if(!_0x292475){const _0x57d6d4=a86_0x5d09ce[_0x5afc8a(0x1dd)](_0xd2e5d0)?a86_0x5d09ce[_0x5afc8a(0x19e)](_0xd2e5d0,_0x5afc8a(0x18e)):'',_0x4062d5=a86_0x5d09ce[_0x5afc8a(0x19e)](_0x3837b4,_0x5afc8a(0x18e)),_0x1a5111=_0x5afc8a(0x212)+_0x57d6d4+_0x5afc8a(0x1e4)+_0x4062d5,_0x8915d4='#\x20prompt.md\x0a'+_0x328caa+'\x0a\x0a#\x20agent.yml\x0a'+_0x5c7c78,_0x5cd1c4=generateDiff(_0x1a5111,_0x8915d4);_0x5938b6=hasChanges(_0x5cd1c4),_0x5938b6&&(_0x42df0a=formatDiffWithColors(_0x5cd1c4));}_0x31f68d[_0x5afc8a(0x1e9)]({'path':_0x596d4c,'content':'','isDir':!![]}),_0x31f68d[_0x5afc8a(0x1e9)]({'path':_0xd2e5d0,'content':_0x328caa}),_0x31f68d[_0x5afc8a(0x1e9)]({'path':_0x3837b4,'content':_0x5c7c78});_0x32fc0c&&_0x32fc0c[_0x5afc8a(0x1c3)]('\x0a')&&_0x31f68d['push']({'path':_0x672a3d,'content':_0x32fc0c});_0x128191[_0x5afc8a(0x17b)][_0x5afc8a(0x1e9)]({'agentName':_0x6089f0[_0x5afc8a(0x210)][_0x5afc8a(0x218)],'outputPath':_0x596d4c,'isNew':_0x292475,'hasChanges':_0x5938b6,'diff':_0x42df0a}),_0x128191[_0x5afc8a(0x1f8)]['agents']['total']++;if(_0x292475)_0x128191[_0x5afc8a(0x1f8)][_0x5afc8a(0x17b)]['new']++;else{if(_0x5938b6)_0x128191[_0x5afc8a(0x1f8)]['agents'][_0x5afc8a(0x1c0)]++;else _0x128191[_0x5afc8a(0x1f8)][_0x5afc8a(0x17b)][_0x5afc8a(0x1ce)]++;}}for(const _0x30faec of _0x179148){if(_0x30faec[_0x5afc8a(0x210)][_0x5afc8a(0x1e6)])continue;const _0x26bfa1=_0x2976dd[_0x5afc8a(0x21a)](_0x30faec[_0x5afc8a(0x210)][_0x5afc8a(0x218)]),_0x45ae30=a86_0x417a93[_0x5afc8a(0x232)](getKnowledgeBasesDir(_0xabe131),_0x26bfa1+_0x5afc8a(0x227)),_0x36a8c0=apiKnowledgeBaseToYaml(_0x30faec),_0x4be4bd=toKnowledgeBaseYamlString(_0x36a8c0),_0x387f99=!a86_0x5d09ce[_0x5afc8a(0x1dd)](_0x45ae30);let _0x3f078a=_0x387f99,_0x45adaf;if(!_0x387f99){const _0x6ddb41=a86_0x5d09ce[_0x5afc8a(0x19e)](_0x45ae30,_0x5afc8a(0x18e)),_0x3cb96d=generateDiff(_0x6ddb41,_0x4be4bd);_0x3f078a=hasChanges(_0x3cb96d),_0x3f078a&&(_0x45adaf=formatDiffWithColors(_0x3cb96d));}_0x31f68d[_0x5afc8a(0x1e9)]({'path':_0x45ae30,'content':_0x4be4bd}),_0x128191[_0x5afc8a(0x1cb)][_0x5afc8a(0x1e9)]({'name':_0x30faec[_0x5afc8a(0x210)][_0x5afc8a(0x218)],'outputPath':_0x45ae30,'isNew':_0x387f99,'hasChanges':_0x3f078a,'diff':_0x45adaf}),_0x128191[_0x5afc8a(0x1f8)][_0x5afc8a(0x1cb)]['total']++;if(_0x387f99)_0x128191[_0x5afc8a(0x1f8)][_0x5afc8a(0x1cb)]['new']++;else{if(_0x3f078a)_0x128191['counts']['knowledgeBases'][_0x5afc8a(0x1c0)]++;else _0x128191[_0x5afc8a(0x1f8)]['knowledgeBases'][_0x5afc8a(0x1ce)]++;}}for(const _0x432fd9 of _0x377ee3){if(_0x432fd9[_0x5afc8a(0x210)][_0x5afc8a(0x1e6)])continue;const _0xe431d3=_0xb6db5b['getUniqueName'](_0x432fd9[_0x5afc8a(0x210)][_0x5afc8a(0x218)]),_0x558626=a86_0x417a93[_0x5afc8a(0x232)](getKnowledgeBasesDir(_0xabe131),_0xe431d3+'.md'),_0x107634=toTextKnowledgeBaseMd(_0x432fd9[_0x5afc8a(0x210)][_0x5afc8a(0x218)],_0x432fd9[_0x5afc8a(0x210)][_0x5afc8a(0x195)]),_0xf8849c=!a86_0x5d09ce[_0x5afc8a(0x1dd)](_0x558626);let _0xb1a354=_0xf8849c,_0x216f02;if(!_0xf8849c){const _0x4bed5d=a86_0x5d09ce['readFileSync'](_0x558626,_0x5afc8a(0x18e)),_0x2eac1a=generateDiff(_0x4bed5d,_0x107634);_0xb1a354=hasChanges(_0x2eac1a),_0xb1a354&&(_0x216f02=formatDiffWithColors(_0x2eac1a));}_0x31f68d[_0x5afc8a(0x1e9)]({'path':_0x558626,'content':_0x107634}),_0x128191[_0x5afc8a(0x190)][_0x5afc8a(0x1e9)]({'name':_0x432fd9[_0x5afc8a(0x210)][_0x5afc8a(0x218)],'outputPath':_0x558626,'isNew':_0xf8849c,'hasChanges':_0xb1a354,'diff':_0x216f02}),_0x128191[_0x5afc8a(0x1f8)][_0x5afc8a(0x190)][_0x5afc8a(0x1f2)]++;if(_0xf8849c)_0x128191[_0x5afc8a(0x1f8)][_0x5afc8a(0x190)][_0x5afc8a(0x1c4)]++;else{if(_0xb1a354)_0x128191[_0x5afc8a(0x1f8)][_0x5afc8a(0x190)][_0x5afc8a(0x1c0)]++;else _0x128191[_0x5afc8a(0x1f8)][_0x5afc8a(0x190)][_0x5afc8a(0x1ce)]++;}}for(const _0x405a4b of _0x3ed0b5){if(_0x405a4b[_0x5afc8a(0x210)][_0x5afc8a(0x1e6)])continue;const _0x55d01d=_0x120500[_0x5afc8a(0x21a)](_0x405a4b[_0x5afc8a(0x210)]['name']),_0x28fe92=a86_0x417a93['join'](getPromptsDir(_0xabe131),_0x55d01d+_0x5afc8a(0x227)),_0x4cea60=await apiPromptToYaml(_0x405a4b,_0x3ad282);if(!_0x4cea60)continue;const _0x21bc96=toPromptYamlString(_0x4cea60),_0xa465e3=!a86_0x5d09ce[_0x5afc8a(0x1dd)](_0x28fe92);let _0xc0fc23=_0xa465e3,_0x3a0983;if(!_0xa465e3){const _0x1d3741=a86_0x5d09ce['readFileSync'](_0x28fe92,_0x5afc8a(0x18e)),_0x813d8f=generateDiff(_0x1d3741,_0x21bc96);_0xc0fc23=hasChanges(_0x813d8f),_0xc0fc23&&(_0x3a0983=formatDiffWithColors(_0x813d8f));}_0x31f68d[_0x5afc8a(0x1e9)]({'path':_0x28fe92,'content':_0x21bc96}),_0x128191['prompts'][_0x5afc8a(0x1e9)]({'name':_0x405a4b['attributes'][_0x5afc8a(0x218)],'outputPath':_0x28fe92,'isNew':_0xa465e3,'hasChanges':_0xc0fc23,'diff':_0x3a0983}),_0x128191[_0x5afc8a(0x1f8)][_0x5afc8a(0x1ad)][_0x5afc8a(0x1f2)]++;if(_0xa465e3)_0x128191[_0x5afc8a(0x1f8)]['prompts'][_0x5afc8a(0x1c4)]++;else{if(_0xc0fc23)_0x128191[_0x5afc8a(0x1f8)]['prompts'][_0x5afc8a(0x1c0)]++;else _0x128191[_0x5afc8a(0x1f8)][_0x5afc8a(0x1ad)][_0x5afc8a(0x1ce)]++;}}if(_0xd6368f?.[_0x5afc8a(0x199)])return _0x128191;a86_0x5d09ce[_0x5afc8a(0x196)](_0xabe131,{'recursive':!![]}),a86_0x5d09ce[_0x5afc8a(0x196)](getKnowledgeBasesDir(_0xabe131),{'recursive':!![]}),a86_0x5d09ce[_0x5afc8a(0x196)](getPromptsDir(_0xabe131),{'recursive':!![]});const _0x292674=a86_0x417a93['join'](_0xabe131,'tdx.json');a86_0x5d09ce[_0x5afc8a(0x20e)](_0x292674,createAgentConfigContent(_0x4c12e7));for(const _0x102115 of _0x31f68d){if(_0x102115[_0x5afc8a(0x16a)])a86_0x5d09ce['mkdirSync'](_0x102115[_0x5afc8a(0x203)],{'recursive':!![]});else{const _0xb6c782=a86_0x417a93[_0x5afc8a(0x183)](_0x102115[_0x5afc8a(0x203)]);!a86_0x5d09ce['existsSync'](_0xb6c782)&&a86_0x5d09ce['mkdirSync'](_0xb6c782,{'recursive':!![]}),a86_0x5d09ce[_0x5afc8a(0x20e)](_0x102115[_0x5afc8a(0x203)],_0x102115[_0x5afc8a(0x21d)]);}}return _0x128191;}async[a86_0x7001ef(0x201)](_0x2db771,_0x554f1f){const _0x29d113=a86_0x7001ef,_0x868ea8=a86_0x417a93[_0x29d113(0x232)](_0x2db771,_0x29d113(0x169));if(!a86_0x5d09ce[_0x29d113(0x1dd)](_0x868ea8))throw new SDKError(ErrorCode[_0x29d113(0x1ee)],'No\x20tdx.json\x20found\x20in\x20'+_0x2db771,undefined,{'helpText':_0x29d113(0x18b)});const _0x42964f=loadAgentConfig(_0x868ea8),_0x3334b7=await this[_0x29d113(0x1ea)](_0x42964f[_0x29d113(0x16c)]),_0x3d0407=await this[_0x29d113(0x157)][_0x29d113(0x1bc)](_0x3334b7),_0x453503=_0x3d0407[_0x29d113(0x210)][_0x29d113(0x218)],_0xf2e68c={'projectName':_0x453503,'projectId':_0x3334b7,'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}}},_0xcf0857=[],_0x59ffc9=[],_0x137194=[],_0x3518e4=[],_0x329c8d=a86_0x5d09ce[_0x29d113(0x216)](_0x2db771,{'withFileTypes':!![]});for(const _0xeb79a3 of _0x329c8d){if(!_0xeb79a3[_0x29d113(0x158)]())continue;if(['knowledge_bases','prompts',_0x29d113(0x20a)][_0x29d113(0x1c3)](_0xeb79a3[_0x29d113(0x218)]))continue;const _0x2ab807=a86_0x417a93[_0x29d113(0x232)](_0x2db771,_0xeb79a3[_0x29d113(0x218)]);if(isAgentDir(_0x2ab807)){const _0x21409d=a86_0x417a93[_0x29d113(0x232)](_0x2ab807,'agent.yml'),_0x1620f1=a86_0x417a93[_0x29d113(0x232)](_0x2ab807,_0x29d113(0x1b2)),_0x3b269f=a86_0x417a93[_0x29d113(0x232)](_0x2ab807,'starter_message.md'),_0x58cb89=parseAgentYaml(a86_0x5d09ce[_0x29d113(0x19e)](_0x21409d,_0x29d113(0x18e)),_0x21409d),_0x1fa926=a86_0x5d09ce[_0x29d113(0x1dd)](_0x1620f1)?a86_0x5d09ce[_0x29d113(0x19e)](_0x1620f1,'utf-8'):'',_0x4c7052=a86_0x5d09ce['existsSync'](_0x3b269f)?a86_0x5d09ce['readFileSync'](_0x3b269f,_0x29d113(0x18e)):_0x58cb89[_0x29d113(0x20c)];_0xcf0857[_0x29d113(0x1e9)]({'name':_0x58cb89[_0x29d113(0x218)],'dir':_0x2ab807,'yaml':_0x58cb89,'systemPrompt':_0x1fa926,'starterMessage':_0x4c7052});}}const _0x2e5473=getKnowledgeBasesDir(_0x2db771);if(a86_0x5d09ce[_0x29d113(0x1dd)](_0x2e5473)){const _0x598403=a86_0x5d09ce[_0x29d113(0x216)](_0x2e5473);for(const _0x46c8dc of _0x598403){const _0x770372=a86_0x417a93[_0x29d113(0x232)](_0x2e5473,_0x46c8dc);if(_0x46c8dc[_0x29d113(0x197)](_0x29d113(0x227))){const _0x207055=parseKnowledgeBaseYaml(a86_0x5d09ce[_0x29d113(0x19e)](_0x770372,_0x29d113(0x18e)),_0x770372);_0x59ffc9[_0x29d113(0x1e9)]({'name':_0x207055[_0x29d113(0x218)],'path':_0x770372,'yaml':_0x207055});}else{if(_0x46c8dc['endsWith'](_0x29d113(0x1f6))){const _0x2e297c=a86_0x5d09ce['readFileSync'](_0x770372,'utf-8'),{name:_0x58674a,text:_0x57e8c4}=parseTextKnowledgeBaseMd(_0x2e297c,_0x46c8dc);_0x137194[_0x29d113(0x1e9)]({'name':_0x58674a,'path':_0x770372,'text':_0x57e8c4});}}}}const _0x4bb779=getPromptsDir(_0x2db771);if(a86_0x5d09ce['existsSync'](_0x4bb779)){const _0x516d47=a86_0x5d09ce[_0x29d113(0x216)](_0x4bb779)[_0x29d113(0x1f9)](_0x220484=>_0x220484[_0x29d113(0x197)]('.yml'));for(const _0xa1a4c1 of _0x516d47){const _0x248b3b=a86_0x417a93[_0x29d113(0x232)](_0x4bb779,_0xa1a4c1),_0x373208=parsePromptYaml(a86_0x5d09ce['readFileSync'](_0x248b3b,'utf-8'),_0x248b3b);_0x3518e4[_0x29d113(0x1e9)]({'name':_0x373208[_0x29d113(0x218)],'path':_0x248b3b,'yaml':_0x373208});}}const _0x5952a2=await this[_0x29d113(0x157)][_0x29d113(0x177)](_0x3334b7),_0x2ff0a6=await this[_0x29d113(0x157)][_0x29d113(0x1de)](_0x3334b7),_0xb71b88=await this[_0x29d113(0x157)]['listTextKnowledgeBases'](_0x3334b7),_0x11caf0=await this['client'][_0x29d113(0x166)](_0x3334b7),_0x34adda=await this[_0x29d113(0x157)]['listWebSearchTools'](_0x3334b7),_0x2fdb4=await this['client'][_0x29d113(0x1bf)](_0x3334b7),_0x5a70e2=new Map(),_0x4c6d75=new Map(),_0x5e566c=new Map(),_0x1532c3=new Map();for(const _0x53b95c of _0x5952a2){_0x5a70e2['set'](_0x53b95c[_0x29d113(0x210)]['name'],_0x53b95c);}for(const _0x32e56f of _0x2ff0a6){_0x4c6d75[_0x29d113(0x20f)](_0x32e56f[_0x29d113(0x210)][_0x29d113(0x218)],_0x32e56f);}for(const _0x591ce6 of _0xb71b88){_0x5e566c[_0x29d113(0x20f)](_0x591ce6[_0x29d113(0x210)][_0x29d113(0x218)],_0x591ce6);}for(const _0x552250 of _0x2fdb4){_0x1532c3['set'](_0x552250['attributes'][_0x29d113(0x218)],_0x552250);}const _0x519c67=new Map(),_0x46ad7a=new Map(),_0x2e8de1=new Map(),_0x32f993=new Map(),_0x3f2b34=new Map(),_0x2b8d18=new Map(),_0x463422=new Map(),_0x2fa17e=new Map(),_0x1ecce6=new Map(),_0x2587d8=new Map(),_0x512d81=new Map(),_0x17f621=new Map();for(const _0x2fa6bb of _0x2ff0a6){_0x519c67[_0x29d113(0x20f)](_0x2fa6bb[_0x29d113(0x210)][_0x29d113(0x218)],_0x2fa6bb['id']),_0x463422[_0x29d113(0x20f)](_0x2fa6bb['id'],_0x2fa6bb[_0x29d113(0x210)][_0x29d113(0x218)]);}for(const _0x404e43 of _0xb71b88){_0x46ad7a[_0x29d113(0x20f)](_0x404e43[_0x29d113(0x210)][_0x29d113(0x218)],_0x404e43['id']),_0x2fa17e[_0x29d113(0x20f)](_0x404e43['id'],_0x404e43[_0x29d113(0x210)]['name']);}for(const _0x30e187 of _0x5952a2){_0x2e8de1[_0x29d113(0x20f)](_0x30e187[_0x29d113(0x210)]['name'],_0x30e187['id']),_0x1ecce6[_0x29d113(0x20f)](_0x30e187['id'],_0x30e187[_0x29d113(0x210)][_0x29d113(0x218)]);}for(const _0x1c74de of _0x11caf0){_0x32f993[_0x29d113(0x20f)](_0x1c74de[_0x29d113(0x210)]['name'],_0x1c74de['id']),_0x2587d8['set'](_0x1c74de['id'],_0x1c74de[_0x29d113(0x210)][_0x29d113(0x218)]);}for(const _0x40e99b of _0x34adda){_0x3f2b34[_0x29d113(0x20f)](_0x40e99b['attributes']['name'],_0x40e99b['id']),_0x512d81[_0x29d113(0x20f)](_0x40e99b['id'],_0x40e99b[_0x29d113(0x210)][_0x29d113(0x218)]);}for(const _0x9bdd79 of _0x2fdb4){_0x2b8d18['set'](_0x9bdd79[_0x29d113(0x210)]['name'],_0x9bdd79['id']),_0x17f621[_0x29d113(0x20f)](_0x9bdd79['id'],_0x9bdd79[_0x29d113(0x210)][_0x29d113(0x218)]);}const _0x5a738e={'resolveKnowledgeBaseName':async _0x56ca79=>_0x463422[_0x29d113(0x21b)](_0x56ca79),'resolveTextKnowledgeBaseName':async _0x339427=>_0x2fa17e['get'](_0x339427),'resolveAgentName':async _0x4089c0=>_0x1ecce6[_0x29d113(0x21b)](_0x4089c0),'resolveWebSearchToolName':async _0x2a6235=>_0x512d81[_0x29d113(0x21b)](_0x2a6235),'resolveImageGeneratorName':async _0x18dcf7=>_0x2587d8[_0x29d113(0x21b)](_0x18dcf7),'resolvePromptName':async _0x317b19=>_0x17f621['get'](_0x317b19),'onWarning':_0x10f7be=>this['context'][_0x29d113(0x207)]?.[_0x29d113(0x1b8)](_0x10f7be)},_0x55814b={'projectId':_0x3334b7,'resolveKnowledgeBaseId':async _0x52b2af=>_0x519c67[_0x29d113(0x21b)](_0x52b2af),'resolveTextKnowledgeBaseId':async _0x253c42=>_0x46ad7a['get'](_0x253c42),'resolveAgentId':async _0xc05403=>_0x2e8de1[_0x29d113(0x21b)](_0xc05403),'resolveWebSearchToolId':async _0x54103e=>_0x3f2b34[_0x29d113(0x21b)](_0x54103e),'resolveImageGeneratorId':async _0x23af45=>_0x32f993[_0x29d113(0x21b)](_0x23af45),'resolvePromptId':async _0x5d9756=>_0x2b8d18[_0x29d113(0x21b)](_0x5d9756),'onWarning':_0x4f9106=>this[_0x29d113(0x237)][_0x29d113(0x207)]?.[_0x29d113(0x1b8)](_0x4f9106)},{resolved:_0x274233,unresolved:_0x5c2fff}=resolveAgentDependencies(_0xcf0857,new Set(_0x5a70e2[_0x29d113(0x19a)]()));for(const {agent:_0x31746f,missingDeps:_0x1c7349}of _0x5c2fff){_0xf2e68c['agents'][_0x29d113(0x1e9)]({'agentName':_0x31746f[_0x29d113(0x21e)][_0x29d113(0x218)],'action':_0x29d113(0x16b),'error':'Unresolved\x20dependencies:\x20'+_0x1c7349[_0x29d113(0x232)](',\x20')+'.\x20Check\x20for\x20circular\x20references\x20or\x20missing\x20agents.'}),_0xf2e68c['counts'][_0x29d113(0x17b)]['errors']++;}for(const _0x38c059 of _0x59ffc9){const _0x1ae577=_0x4c6d75[_0x29d113(0x21b)](_0x38c059['yaml']['name']),_0x1f78c2=a86_0x5d09ce['readFileSync'](_0x38c059[_0x29d113(0x203)],_0x29d113(0x18e));if(_0x1ae577){const _0x4304ba=apiKnowledgeBaseToYaml(_0x1ae577),_0x5c8d9b=toKnowledgeBaseYamlString(_0x4304ba),_0x4f02a9=generateDiff(_0x5c8d9b,_0x1f78c2),_0x45dcd8=hasChanges(_0x4f02a9);_0x45dcd8?(_0xf2e68c[_0x29d113(0x1cb)][_0x29d113(0x1e9)]({'name':_0x38c059[_0x29d113(0x21e)][_0x29d113(0x218)],'action':_0x29d113(0x1c0),'id':_0x1ae577['id'],'diff':formatDiffWithColors(_0x4f02a9)}),_0xf2e68c[_0x29d113(0x1f8)][_0x29d113(0x1cb)][_0x29d113(0x1c0)]++):(_0xf2e68c['knowledgeBases'][_0x29d113(0x1e9)]({'name':_0x38c059[_0x29d113(0x21e)]['name'],'action':'unchanged','id':_0x1ae577['id']}),_0xf2e68c[_0x29d113(0x1f8)][_0x29d113(0x1cb)][_0x29d113(0x1ce)]++);}else _0xf2e68c[_0x29d113(0x1cb)][_0x29d113(0x1e9)]({'name':_0x38c059[_0x29d113(0x21e)][_0x29d113(0x218)],'action':_0x29d113(0x1fe)}),_0xf2e68c[_0x29d113(0x1f8)]['knowledgeBases'][_0x29d113(0x1fe)]++;}for(const _0x4dc3fc of _0x137194){const _0x32309f=_0x5e566c['get'](_0x4dc3fc[_0x29d113(0x218)]),_0x340595=a86_0x5d09ce[_0x29d113(0x19e)](_0x4dc3fc['path'],_0x29d113(0x18e));if(_0x32309f){const _0xb501f4=toTextKnowledgeBaseMd(_0x32309f[_0x29d113(0x210)][_0x29d113(0x218)],_0x32309f[_0x29d113(0x210)]['text']),_0xc9a6e8=generateDiff(_0xb501f4,_0x340595),_0x228945=hasChanges(_0xc9a6e8);_0x228945?(_0xf2e68c['textKnowledgeBases']['push']({'name':_0x4dc3fc[_0x29d113(0x218)],'action':'updated','id':_0x32309f['id'],'diff':formatDiffWithColors(_0xc9a6e8)}),_0xf2e68c[_0x29d113(0x1f8)][_0x29d113(0x190)][_0x29d113(0x1c0)]++):(_0xf2e68c[_0x29d113(0x190)][_0x29d113(0x1e9)]({'name':_0x4dc3fc[_0x29d113(0x218)],'action':_0x29d113(0x1ce),'id':_0x32309f['id']}),_0xf2e68c['counts'][_0x29d113(0x190)][_0x29d113(0x1ce)]++);}else _0xf2e68c[_0x29d113(0x190)][_0x29d113(0x1e9)]({'name':_0x4dc3fc[_0x29d113(0x218)],'action':_0x29d113(0x1fe)}),_0xf2e68c[_0x29d113(0x1f8)][_0x29d113(0x190)][_0x29d113(0x1fe)]++;}for(const _0x310a62 of _0x274233){const _0x553b58=_0x5a70e2[_0x29d113(0x21b)](_0x310a62[_0x29d113(0x21e)]['name']),_0x3d5f71=a86_0x417a93[_0x29d113(0x232)](_0x310a62['dir'],'agent.yml'),_0x9184b6=a86_0x5d09ce[_0x29d113(0x19e)](_0x3d5f71,'utf-8'),_0x51a072=_0x310a62['systemPrompt'],_0x458b0e=_0x29d113(0x212)+_0x51a072+_0x29d113(0x1e4)+_0x9184b6;if(_0x553b58){const {yaml:_0x1c2daf,systemPrompt:_0x30dc8a}=await agentResponseToDef(_0x553b58,_0x5a738e),_0x536774=toAgentYamlString(_0x1c2daf),_0x2600eb=_0x29d113(0x212)+_0x30dc8a+_0x29d113(0x1e4)+_0x536774,_0x3ede91=generateDiff(_0x2600eb,_0x458b0e),_0x320e61=hasChanges(_0x3ede91);_0x320e61?(_0xf2e68c[_0x29d113(0x17b)]['push']({'agentName':_0x310a62[_0x29d113(0x21e)][_0x29d113(0x218)],'action':'updated','agentId':_0x553b58['id'],'diff':formatDiffWithColors(_0x3ede91)}),_0xf2e68c[_0x29d113(0x1f8)]['agents'][_0x29d113(0x1c0)]++):(_0xf2e68c['agents']['push']({'agentName':_0x310a62[_0x29d113(0x21e)][_0x29d113(0x218)],'action':_0x29d113(0x1ce),'agentId':_0x553b58['id']}),_0xf2e68c[_0x29d113(0x1f8)]['agents'][_0x29d113(0x1ce)]++);}else _0xf2e68c[_0x29d113(0x17b)][_0x29d113(0x1e9)]({'agentName':_0x310a62[_0x29d113(0x21e)][_0x29d113(0x218)],'action':_0x29d113(0x1fe)}),_0xf2e68c[_0x29d113(0x1f8)][_0x29d113(0x17b)][_0x29d113(0x1fe)]++;}for(const _0x4da158 of _0x3518e4){const _0x332a63=_0x1532c3[_0x29d113(0x21b)](_0x4da158['yaml'][_0x29d113(0x218)]),_0x43df73=a86_0x5d09ce[_0x29d113(0x19e)](_0x4da158[_0x29d113(0x203)],'utf-8');if(_0x332a63){const _0x30c999=await apiPromptToYaml(_0x332a63,_0x5a738e);if(!_0x30c999){_0xf2e68c['prompts'][_0x29d113(0x1e9)]({'name':_0x4da158[_0x29d113(0x21e)][_0x29d113(0x218)],'action':_0x29d113(0x1c0),'id':_0x332a63['id']}),_0xf2e68c[_0x29d113(0x1f8)][_0x29d113(0x1ad)][_0x29d113(0x1c0)]++;continue;}const _0x30a65c=toPromptYamlString(_0x30c999),_0x1ced28=generateDiff(_0x30a65c,_0x43df73),_0x8003b=hasChanges(_0x1ced28);_0x8003b?(_0xf2e68c[_0x29d113(0x1ad)][_0x29d113(0x1e9)]({'name':_0x4da158[_0x29d113(0x21e)][_0x29d113(0x218)],'action':_0x29d113(0x1c0),'id':_0x332a63['id'],'diff':formatDiffWithColors(_0x1ced28)}),_0xf2e68c[_0x29d113(0x1f8)][_0x29d113(0x1ad)]['updated']++):(_0xf2e68c['prompts'][_0x29d113(0x1e9)]({'name':_0x4da158[_0x29d113(0x21e)][_0x29d113(0x218)],'action':_0x29d113(0x1ce),'id':_0x332a63['id']}),_0xf2e68c[_0x29d113(0x1f8)][_0x29d113(0x1ad)][_0x29d113(0x1ce)]++);}else _0xf2e68c[_0x29d113(0x1ad)][_0x29d113(0x1e9)]({'name':_0x4da158['yaml'][_0x29d113(0x218)],'action':_0x29d113(0x1fe)}),_0xf2e68c[_0x29d113(0x1f8)]['prompts'][_0x29d113(0x1fe)]++;}if(_0x554f1f?.[_0x29d113(0x199)])return _0xf2e68c;_0xf2e68c[_0x29d113(0x1cb)]=[],_0xf2e68c[_0x29d113(0x190)]=[],_0xf2e68c[_0x29d113(0x1ad)]=[];const _0x746781=_0xf2e68c['agents'][_0x29d113(0x1f9)](_0x15f6fd=>_0x15f6fd[_0x29d113(0x19d)]==='error');_0xf2e68c[_0x29d113(0x17b)]=_0x746781,_0xf2e68c[_0x29d113(0x1f8)]={'agents':{'created':0x0,'updated':0x0,'unchanged':0x0,'errors':_0x746781[_0x29d113(0x22b)]},'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 _0x13b12e of _0x59ffc9){try{const _0x408ec5=_0x4c6d75[_0x29d113(0x21b)](_0x13b12e['yaml'][_0x29d113(0x218)]),_0x1289b5=yamlKnowledgeBaseToApi(_0x13b12e[_0x29d113(0x21e)],_0x3334b7);if(_0x408ec5)await this['client']['updateKnowledgeBase'](_0x408ec5['id'],_0x1289b5),_0x519c67['set'](_0x13b12e[_0x29d113(0x21e)][_0x29d113(0x218)],_0x408ec5['id']),_0xf2e68c[_0x29d113(0x1cb)][_0x29d113(0x1e9)]({'name':_0x13b12e[_0x29d113(0x21e)][_0x29d113(0x218)],'action':_0x29d113(0x1c0),'id':_0x408ec5['id']}),_0xf2e68c['counts'][_0x29d113(0x1cb)][_0x29d113(0x1c0)]++;else{const _0x1bac48=await this[_0x29d113(0x157)][_0x29d113(0x1b5)](_0x1289b5);_0x519c67[_0x29d113(0x20f)](_0x13b12e[_0x29d113(0x21e)]['name'],_0x1bac48['id']),_0xf2e68c[_0x29d113(0x1cb)]['push']({'name':_0x13b12e[_0x29d113(0x21e)][_0x29d113(0x218)],'action':_0x29d113(0x1fe),'id':_0x1bac48['id']}),_0xf2e68c['counts'][_0x29d113(0x1cb)][_0x29d113(0x1fe)]++;}}catch(_0x18c00f){_0xf2e68c['knowledgeBases'][_0x29d113(0x1e9)]({'name':_0x13b12e[_0x29d113(0x21e)][_0x29d113(0x218)],'action':_0x29d113(0x16b),'error':_0x18c00f[_0x29d113(0x1bd)]}),_0xf2e68c['counts'][_0x29d113(0x1cb)]['errors']++;}}for(const _0x497daa of _0x137194){try{const _0x5d5d0a=_0x5e566c['get'](_0x497daa['name']),_0x342ea3=yamlTextKnowledgeBaseToApi({'name':_0x497daa[_0x29d113(0x218)],'text':_0x497daa['text']},_0x3334b7);if(_0x5d5d0a)await this[_0x29d113(0x157)][_0x29d113(0x22f)](_0x5d5d0a['id'],_0x342ea3),_0x46ad7a[_0x29d113(0x20f)](_0x497daa[_0x29d113(0x218)],_0x5d5d0a['id']),_0xf2e68c[_0x29d113(0x190)]['push']({'name':_0x497daa[_0x29d113(0x218)],'action':_0x29d113(0x1c0),'id':_0x5d5d0a['id']}),_0xf2e68c['counts'][_0x29d113(0x190)][_0x29d113(0x1c0)]++;else{const _0x4ef938=await this[_0x29d113(0x157)][_0x29d113(0x225)](_0x342ea3);_0x46ad7a[_0x29d113(0x20f)](_0x497daa[_0x29d113(0x218)],_0x4ef938['id']),_0xf2e68c[_0x29d113(0x190)][_0x29d113(0x1e9)]({'name':_0x497daa[_0x29d113(0x218)],'action':_0x29d113(0x1fe),'id':_0x4ef938['id']}),_0xf2e68c[_0x29d113(0x1f8)][_0x29d113(0x190)]['created']++;}}catch(_0x15eebc){_0xf2e68c[_0x29d113(0x190)][_0x29d113(0x1e9)]({'name':_0x497daa['name'],'action':'error','error':_0x15eebc[_0x29d113(0x1bd)]}),_0xf2e68c[_0x29d113(0x1f8)][_0x29d113(0x190)][_0x29d113(0x18d)]++;}}for(const _0x551b84 of _0x274233){try{const _0x24ad7d=_0x5a70e2[_0x29d113(0x21b)](_0x551b84[_0x29d113(0x21e)][_0x29d113(0x218)]),_0x1e2042=await agentDefToRequest(_0x551b84[_0x29d113(0x21e)],_0x551b84[_0x29d113(0x1a5)],_0x551b84[_0x29d113(0x1b7)],_0x55814b);if(_0x24ad7d)await this[_0x29d113(0x157)][_0x29d113(0x1c7)](_0x24ad7d['id'],_0x1e2042),_0x2e8de1[_0x29d113(0x20f)](_0x551b84[_0x29d113(0x21e)][_0x29d113(0x218)],_0x24ad7d['id']),_0xf2e68c[_0x29d113(0x17b)][_0x29d113(0x1e9)]({'agentName':_0x551b84[_0x29d113(0x21e)][_0x29d113(0x218)],'action':'updated','agentId':_0x24ad7d['id']}),_0xf2e68c[_0x29d113(0x1f8)][_0x29d113(0x17b)][_0x29d113(0x1c0)]++;else{const _0x188c79=await this[_0x29d113(0x157)][_0x29d113(0x1ca)](_0x1e2042);_0x2e8de1[_0x29d113(0x20f)](_0x551b84[_0x29d113(0x21e)][_0x29d113(0x218)],_0x188c79['id']),_0xf2e68c[_0x29d113(0x17b)]['push']({'agentName':_0x551b84[_0x29d113(0x21e)]['name'],'action':'created','agentId':_0x188c79['id']}),_0xf2e68c[_0x29d113(0x1f8)]['agents'][_0x29d113(0x1fe)]++;}}catch(_0x16330f){_0xf2e68c['agents'][_0x29d113(0x1e9)]({'agentName':_0x551b84[_0x29d113(0x21e)]['name'],'action':_0x29d113(0x16b),'error':_0x16330f[_0x29d113(0x1bd)]}),_0xf2e68c[_0x29d113(0x1f8)][_0x29d113(0x17b)]['errors']++;}}for(const _0x48e835 of _0x3518e4){try{const _0x53a2ec=_0x1532c3[_0x29d113(0x21b)](_0x48e835[_0x29d113(0x21e)][_0x29d113(0x218)]),_0x4785a1=await yamlPromptToApi(_0x48e835['yaml'],_0x3334b7,_0x55814b);if(!_0x4785a1){_0xf2e68c[_0x29d113(0x1ad)]['push']({'name':_0x48e835[_0x29d113(0x21e)][_0x29d113(0x218)],'action':_0x29d113(0x16b),'error':_0x29d113(0x224)}),_0xf2e68c[_0x29d113(0x1f8)]['prompts'][_0x29d113(0x18d)]++;continue;}if(_0x53a2ec)await this[_0x29d113(0x157)]['updatePrompt'](_0x53a2ec['id'],_0x4785a1),_0x2b8d18[_0x29d113(0x20f)](_0x48e835[_0x29d113(0x21e)]['name'],_0x53a2ec['id']),_0xf2e68c[_0x29d113(0x1ad)]['push']({'name':_0x48e835[_0x29d113(0x21e)][_0x29d113(0x218)],'action':_0x29d113(0x1c0),'id':_0x53a2ec['id']}),_0xf2e68c['counts'][_0x29d113(0x1ad)][_0x29d113(0x1c0)]++;else{const _0x4b43a=await this['client']['createPrompt'](_0x4785a1);_0x2b8d18[_0x29d113(0x20f)](_0x48e835[_0x29d113(0x21e)]['name'],_0x4b43a['id']),_0xf2e68c['prompts'][_0x29d113(0x1e9)]({'name':_0x48e835[_0x29d113(0x21e)][_0x29d113(0x218)],'action':_0x29d113(0x1fe),'id':_0x4b43a['id']}),_0xf2e68c[_0x29d113(0x1f8)][_0x29d113(0x1ad)][_0x29d113(0x1fe)]++;}}catch(_0x488922){_0xf2e68c['prompts'][_0x29d113(0x1e9)]({'name':_0x48e835[_0x29d113(0x21e)][_0x29d113(0x218)],'action':'error','error':_0x488922[_0x29d113(0x1bd)]}),_0xf2e68c['counts'][_0x29d113(0x1ad)]['errors']++;}}return _0xf2e68c;}async[a86_0x7001ef(0x1a6)](_0x1320c2,_0x54a40a,_0xfd2a7f,_0x4d7ff5){const _0x274f32=a86_0x7001ef,{projectId:_0xe9d378,project:_0x5ca677}=await this['resolveProjectName'](_0x1320c2),_0x2a805c=_0x5ca677[_0x274f32(0x210)]['name'],_0x3a4f13=await this[_0x274f32(0x157)][_0x274f32(0x177)](_0xe9d378),_0x3ad597=_0x3a4f13[_0x274f32(0x1c5)](_0x4ed808=>_0x4ed808['attributes'][_0x274f32(0x218)]===_0x54a40a);if(!_0x3ad597)throw new SDKError(ErrorCode[_0x274f32(0x15e)],_0x274f32(0x188)+_0x54a40a,undefined,{'helpText':_0x274f32(0x1c1)+_0x3a4f13['map'](_0x1a061b=>_0x1a061b[_0x274f32(0x210)]['name'])['join'](',\x20')});const _0x4b10ce=normalizeName(_0x2a805c),_0x4fe67b=normalizeName(_0x54a40a),_0xc96124=_0xfd2a7f||a86_0x417a93[_0x274f32(0x232)](process[_0x274f32(0x18c)](),_0x274f32(0x17b),_0x4b10ce),_0x361d77=a86_0x417a93[_0x274f32(0x232)](_0xc96124,_0x4fe67b),_0x23d1b7=new Map(),_0x39bb97=new Map(),_0xd4407c=await this[_0x274f32(0x157)][_0x274f32(0x1de)](_0xe9d378),_0xb77e85=await this['client'][_0x274f32(0x18a)](_0xe9d378),_0x256822=new Map();for(const _0x280c9c of _0xd4407c){_0x23d1b7[_0x274f32(0x20f)](_0x280c9c['id'],_0x280c9c[_0x274f32(0x210)][_0x274f32(0x218)]);}for(const _0x3117f1 of _0xb77e85){_0x256822['set'](_0x3117f1['id'],_0x3117f1[_0x274f32(0x210)][_0x274f32(0x218)]);}for(const _0x990178 of _0x3a4f13){_0x39bb97[_0x274f32(0x20f)](_0x990178['id'],_0x990178[_0x274f32(0x210)][_0x274f32(0x218)]);}const _0x27333e={'resolveKnowledgeBaseName':async _0x4f4545=>_0x23d1b7[_0x274f32(0x21b)](_0x4f4545),'resolveTextKnowledgeBaseName':async _0x4ebfee=>_0x256822[_0x274f32(0x21b)](_0x4ebfee),'resolveAgentName':async _0x1f0809=>_0x39bb97[_0x274f32(0x21b)](_0x1f0809),'resolveWebSearchToolName':async()=>undefined,'resolveImageGeneratorName':async()=>undefined,'resolvePromptName':async()=>undefined,'onWarning':_0x4ac7a5=>this[_0x274f32(0x237)]['logger']?.[_0x274f32(0x1b8)](_0x4ac7a5)},_0x323c39=a86_0x417a93[_0x274f32(0x232)](_0x361d77,_0x274f32(0x1b2)),_0x4d6130=a86_0x417a93['join'](_0x361d77,'agent.yml'),_0x304248=a86_0x417a93[_0x274f32(0x232)](_0x361d77,_0x274f32(0x17e)),_0x23700b=!a86_0x5d09ce[_0x274f32(0x1dd)](_0x4d6130);if(_0x4d7ff5?.['dryRun'])return{'agentName':_0x54a40a,'outputPath':_0x361d77,'isNew':_0x23700b,'hasChanges':!![]};a86_0x5d09ce[_0x274f32(0x196)](_0xc96124,{'recursive':!![]}),a86_0x5d09ce[_0x274f32(0x196)](_0x361d77,{'recursive':!![]});const _0x3441f6=a86_0x417a93[_0x274f32(0x232)](_0xc96124,_0x274f32(0x169));!a86_0x5d09ce[_0x274f32(0x1dd)](_0x3441f6)&&a86_0x5d09ce[_0x274f32(0x20e)](_0x3441f6,createAgentConfigContent(_0x1320c2));const {yaml:_0x27647a,systemPrompt:_0x3432b9,starterMessage:_0x196aed}=await agentResponseToDef(_0x3ad597,_0x27333e);let _0x705c58=_0x23700b;if(!_0x23700b){const _0x62892b=a86_0x5d09ce[_0x274f32(0x1dd)](_0x323c39)?a86_0x5d09ce[_0x274f32(0x19e)](_0x323c39,'utf-8'):'',_0x2c7b20=a86_0x5d09ce[_0x274f32(0x19e)](_0x4d6130,_0x274f32(0x18e));_0x705c58=_0x62892b!==_0x3432b9||_0x2c7b20!==toAgentYamlString(_0x27647a);}a86_0x5d09ce['writeFileSync'](_0x323c39,_0x3432b9),a86_0x5d09ce[_0x274f32(0x20e)](_0x4d6130,toAgentYamlString(_0x27647a));if(_0x196aed&&_0x196aed[_0x274f32(0x1c3)]('\x0a'))a86_0x5d09ce['writeFileSync'](_0x304248,_0x196aed);else a86_0x5d09ce['existsSync'](_0x304248)&&a86_0x5d09ce[_0x274f32(0x1a8)](_0x304248);return{'agentName':_0x54a40a,'outputPath':_0x361d77,'isNew':_0x23700b,'hasChanges':_0x705c58};}async[a86_0x7001ef(0x1cf)](_0x5f3d02,_0x5437cd){const _0x55b271=a86_0x7001ef;let _0x21c245;isAgentYamlPath(_0x5f3d02)?_0x21c245=getAgentDirFromYamlPath(_0x5f3d02):_0x21c245=_0x5f3d02;const {config:_0x3d4c9b}=findAgentConfig(_0x21c245),_0x4f1ef1=await this[_0x55b271(0x1ea)](_0x3d4c9b[_0x55b271(0x16c)]),_0x26524e=a86_0x417a93[_0x55b271(0x232)](_0x21c245,_0x55b271(0x16d)),_0x42ca62=a86_0x417a93[_0x55b271(0x232)](_0x21c245,_0x55b271(0x1b2)),_0x2cb1b8=a86_0x417a93[_0x55b271(0x232)](_0x21c245,_0x55b271(0x17e));if(!a86_0x5d09ce['existsSync'](_0x26524e))throw new SDKError(ErrorCode[_0x55b271(0x1db)],_0x55b271(0x161)+_0x21c245,undefined,{'helpText':_0x55b271(0x1f5)});const _0x4ae63a=parseAgentYaml(a86_0x5d09ce[_0x55b271(0x19e)](_0x26524e,_0x55b271(0x18e)),_0x26524e),_0x576125=a86_0x5d09ce['existsSync'](_0x42ca62)?a86_0x5d09ce[_0x55b271(0x19e)](_0x42ca62,_0x55b271(0x18e)):'',_0x59f2cf=a86_0x5d09ce[_0x55b271(0x1dd)](_0x2cb1b8)?a86_0x5d09ce[_0x55b271(0x19e)](_0x2cb1b8,_0x55b271(0x18e)):_0x4ae63a[_0x55b271(0x20c)];if(_0x5437cd?.[_0x55b271(0x199)])return{'agentName':_0x4ae63a[_0x55b271(0x218)],'action':_0x55b271(0x1fe),'projectId':_0x4f1ef1};const _0x7ff2a1=await this[_0x55b271(0x157)][_0x55b271(0x177)](_0x4f1ef1),_0x4a534f=await this[_0x55b271(0x157)][_0x55b271(0x1de)](_0x4f1ef1),_0x3c8dd3=await this['client'][_0x55b271(0x18a)](_0x4f1ef1),_0x22f0e0=new Map(),_0x5d40b9=new Map(),_0x4091bf=new Map();for(const _0x566635 of _0x4a534f){_0x22f0e0[_0x55b271(0x20f)](_0x566635[_0x55b271(0x210)][_0x55b271(0x218)],_0x566635['id']);}for(const _0x134bb2 of _0x3c8dd3){_0x5d40b9[_0x55b271(0x20f)](_0x134bb2['attributes'][_0x55b271(0x218)],_0x134bb2['id']);}for(const _0x3a8cf9 of _0x7ff2a1){_0x4091bf[_0x55b271(0x20f)](_0x3a8cf9[_0x55b271(0x210)][_0x55b271(0x218)],_0x3a8cf9['id']);}const _0xea1e35={'projectId':_0x4f1ef1,'resolveKnowledgeBaseId':async _0x483a5c=>_0x22f0e0[_0x55b271(0x21b)](_0x483a5c),'resolveTextKnowledgeBaseId':async _0x28a86a=>_0x5d40b9[_0x55b271(0x21b)](_0x28a86a),'resolveAgentId':async _0x37bdd1=>_0x4091bf['get'](_0x37bdd1),'resolveWebSearchToolId':async()=>undefined,'resolveImageGeneratorId':async()=>undefined,'resolvePromptId':async()=>undefined,'onWarning':_0x35a80e=>this['context'][_0x55b271(0x207)]?.[_0x55b271(0x1b8)](_0x35a80e)};try{const _0x1e9ba7=_0x7ff2a1[_0x55b271(0x1c5)](_0x29ed4d=>_0x29ed4d[_0x55b271(0x210)][_0x55b271(0x218)]===_0x4ae63a[_0x55b271(0x218)]),_0x2bb0d8=await agentDefToRequest(_0x4ae63a,_0x576125,_0x59f2cf,_0xea1e35);if(_0x1e9ba7)return await this[_0x55b271(0x157)][_0x55b271(0x1c7)](_0x1e9ba7['id'],_0x2bb0d8),{'agentName':_0x4ae63a[_0x55b271(0x218)],'action':_0x55b271(0x1c0),'projectId':_0x4f1ef1,'agentId':_0x1e9ba7['id']};else{const _0x56c2e8=await this[_0x55b271(0x157)][_0x55b271(0x1ca)](_0x2bb0d8);return{'agentName':_0x4ae63a['name'],'action':'created','projectId':_0x4f1ef1,'agentId':_0x56c2e8['id']};}}catch(_0x3e4020){return{'agentName':_0x4ae63a['name'],'action':_0x55b271(0x16b),'projectId':_0x4f1ef1,'error':_0x3e4020['message']};}}async[a86_0x7001ef(0x1a1)](_0x2c3030,_0x836713,_0x3dfc12){const _0x2c3303=a86_0x7001ef,_0x3ff20c=a86_0x5d09ce[_0x2c3303(0x1dd)](_0x2c3030)&&a86_0x5d09ce[_0x2c3303(0x1dd)](a86_0x417a93['join'](_0x2c3030,_0x2c3303(0x169)));let _0x259733;const _0x41ef0d=[],_0x54ce7c=[],_0x155516=[],_0x24497c=[];if(_0x3ff20c){const _0x598855=loadAgentConfig(a86_0x417a93[_0x2c3303(0x232)](_0x2c3030,_0x2c3303(0x169)));_0x259733=_0x598855['llm_project'];const _0x3e3f0f=a86_0x5d09ce[_0x2c3303(0x216)](_0x2c3030,{'withFileTypes':!![]});for(const _0x298585 of _0x3e3f0f){if(!_0x298585[_0x2c3303(0x158)]())continue;if([_0x2c3303(0x1b1),_0x2c3303(0x1ad),_0x2c3303(0x20a)][_0x2c3303(0x1c3)](_0x298585[_0x2c3303(0x218)]))continue;const _0xae17b9=a86_0x417a93[_0x2c3303(0x232)](_0x2c3030,_0x298585['name']);if(isAgentDir(_0xae17b9)){const _0x3782a=a86_0x417a93[_0x2c3303(0x232)](_0xae17b9,_0x2c3303(0x16d)),_0x58414b=a86_0x417a93[_0x2c3303(0x232)](_0xae17b9,'prompt.md'),_0x37e941=a86_0x417a93[_0x2c3303(0x232)](_0xae17b9,'starter_message.md'),_0x5a5f96=parseAgentYaml(a86_0x5d09ce[_0x2c3303(0x19e)](_0x3782a,'utf-8'),_0x3782a),_0x2cd261=a86_0x5d09ce[_0x2c3303(0x1dd)](_0x58414b)?a86_0x5d09ce['readFileSync'](_0x58414b,_0x2c3303(0x18e)):'',_0x93757d=a86_0x5d09ce[_0x2c3303(0x1dd)](_0x37e941)?a86_0x5d09ce['readFileSync'](_0x37e941,_0x2c3303(0x18e)):_0x5a5f96['starter_message'];_0x41ef0d[_0x2c3303(0x1e9)]({'name':_0x5a5f96['name'],'dir':_0xae17b9,'yaml':_0x5a5f96,'systemPrompt':_0x2cd261,'starterMessage':_0x93757d});}}const _0x4ac5dd=getKnowledgeBasesDir(_0x2c3030);if(a86_0x5d09ce[_0x2c3303(0x1dd)](_0x4ac5dd)){const _0x215598=a86_0x5d09ce[_0x2c3303(0x216)](_0x4ac5dd);for(const _0xb96683 of _0x215598){const _0x16f9b3=a86_0x417a93[_0x2c3303(0x232)](_0x4ac5dd,_0xb96683);if(_0xb96683[_0x2c3303(0x197)](_0x2c3303(0x227))){const _0xaeacd0=parseKnowledgeBaseYaml(a86_0x5d09ce[_0x2c3303(0x19e)](_0x16f9b3,_0x2c3303(0x18e)),_0x16f9b3);_0x54ce7c[_0x2c3303(0x1e9)]({'name':_0xaeacd0[_0x2c3303(0x218)],'path':_0x16f9b3,'yaml':_0xaeacd0});}else{if(_0xb96683[_0x2c3303(0x197)](_0x2c3303(0x1f6))){const _0x41325c=a86_0x5d09ce[_0x2c3303(0x19e)](_0x16f9b3,'utf-8'),{name:_0x4dacbb,text:_0x25f24c}=parseTextKnowledgeBaseMd(_0x41325c,_0xb96683);_0x155516[_0x2c3303(0x1e9)]({'name':_0x4dacbb,'path':_0x16f9b3,'text':_0x25f24c});}}}}const _0x45a4c6=getPromptsDir(_0x2c3030);if(a86_0x5d09ce[_0x2c3303(0x1dd)](_0x45a4c6)){const _0x572e96=a86_0x5d09ce[_0x2c3303(0x216)](_0x45a4c6)[_0x2c3303(0x1f9)](_0x46c8fa=>_0x46c8fa[_0x2c3303(0x197)](_0x2c3303(0x227)));for(const _0x14d44d of _0x572e96){const _0x210451=a86_0x417a93['join'](_0x45a4c6,_0x14d44d),_0x57c086=parsePromptYaml(a86_0x5d09ce['readFileSync'](_0x210451,_0x2c3303(0x18e)),_0x210451);_0x24497c[_0x2c3303(0x1e9)]({'name':_0x57c086[_0x2c3303(0x218)],'path':_0x210451,'yaml':_0x57c086});}}}else{const _0x1c3ed2=await this[_0x2c3303(0x1ea)](_0x2c3030),_0x17b5e0=await this[_0x2c3303(0x157)][_0x2c3303(0x1bc)](_0x1c3ed2);_0x259733=_0x17b5e0['attributes']['name'];const _0x14318b=await this[_0x2c3303(0x157)][_0x2c3303(0x177)](_0x1c3ed2),_0x962d49=await this['client']['listKnowledgeBases'](_0x1c3ed2),_0x3a75ea=await this[_0x2c3303(0x157)][_0x2c3303(0x18a)](_0x1c3ed2),_0x4837e3=await this[_0x2c3303(0x157)][_0x2c3303(0x1bf)](_0x1c3ed2),_0x123169=new Map(),_0x4c39e4=new Map(),_0x7bb4c8=new Map(),_0x4dfc2d=new Map();for(const _0x326fb8 of _0x962d49){_0x123169[_0x2c3303(0x20f)](_0x326fb8['id'],_0x326fb8[_0x2c3303(0x210)]['name']);}for(const _0x33ef87 of _0x3a75ea){_0x4c39e4['set'](_0x33ef87['id'],_0x33ef87[_0x2c3303(0x210)][_0x2c3303(0x218)]);}for(const _0x430445 of _0x14318b){_0x7bb4c8[_0x2c3303(0x20f)](_0x430445['id'],_0x430445[_0x2c3303(0x210)][_0x2c3303(0x218)]);}for(const _0x2823ff of _0x4837e3){_0x4dfc2d[_0x2c3303(0x20f)](_0x2823ff['id'],_0x2823ff[_0x2c3303(0x210)][_0x2c3303(0x218)]);}const _0x484af2={'resolveKnowledgeBaseName':async _0x2a656f=>_0x123169[_0x2c3303(0x21b)](_0x2a656f),'resolveTextKnowledgeBaseName':async _0x32fee8=>_0x4c39e4[_0x2c3303(0x21b)](_0x32fee8),'resolveAgentName':async _0x5ae173=>_0x7bb4c8[_0x2c3303(0x21b)](_0x5ae173),'resolveWebSearchToolName':async()=>undefined,'resolveImageGeneratorName':async()=>undefined,'resolvePromptName':async _0x4cc87c=>_0x4dfc2d['get'](_0x4cc87c),'onWarning':_0x20c550=>this['context']['logger']?.[_0x2c3303(0x1b8)](_0x20c550)};for(const _0x196532 of _0x14318b){const _0x3705ad=await agentResponseToDef(_0x196532,_0x484af2),{yaml:_0x416d23,systemPrompt:_0x52f80,starterMessage:_0x339001}=_0x3705ad;_0x41ef0d[_0x2c3303(0x1e9)]({'name':_0x416d23[_0x2c3303(0x218)],'dir':'','yaml':_0x416d23,'systemPrompt':_0x52f80,'starterMessage':_0x339001});}for(const _0x41f174 of _0x962d49){const _0x3ce986=apiKnowledgeBaseToYaml(_0x41f174);_0x54ce7c[_0x2c3303(0x1e9)]({'name':_0x3ce986[_0x2c3303(0x218)],'path':'','yaml':_0x3ce986});}for(const _0x24b2e7 of _0x3a75ea){_0x155516[_0x2c3303(0x1e9)]({'name':_0x24b2e7[_0x2c3303(0x210)][_0x2c3303(0x218)],'path':'','text':_0x24b2e7['attributes'][_0x2c3303(0x195)]});}for(const _0x370386 of _0x4837e3){const _0x24908b=await apiPromptToYaml(_0x370386,_0x484af2);_0x24908b&&_0x24497c[_0x2c3303(0x1e9)]({'name':_0x24908b[_0x2c3303(0x218)],'path':'','yaml':_0x24908b});}}const _0x4e97ec={'sourceProjectName':_0x259733,'newProjectName':_0x836713,'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}}},_0x5dc4e8=await this['client']['listProjects'](),_0x507437=_0x5dc4e8['find'](_0x37ddd3=>_0x37ddd3['attributes'][_0x2c3303(0x218)]===_0x836713);if(_0x507437)throw new SDKError(ErrorCode['ALREADY_EXISTS'],_0x2c3303(0x22d)+_0x836713+_0x2c3303(0x1f0),undefined,{'helpText':_0x2c3303(0x1f4)});if(_0x3dfc12?.[_0x2c3303(0x199)])return _0x4e97ec[_0x2c3303(0x1f8)]['agents'][_0x2c3303(0x1fe)]=_0x41ef0d[_0x2c3303(0x22b)],_0x4e97ec[_0x2c3303(0x1f8)]['knowledgeBases'][_0x2c3303(0x1fe)]=_0x54ce7c['length'],_0x4e97ec['counts'][_0x2c3303(0x190)]['created']=_0x155516[_0x2c3303(0x22b)],_0x4e97ec[_0x2c3303(0x1f8)][_0x2c3303(0x1ad)][_0x2c3303(0x1fe)]=_0x24497c[_0x2c3303(0x22b)],_0x4e97ec;const _0x382de8=await this['client'][_0x2c3303(0x1f7)]({'name':_0x836713}),_0x566062=_0x382de8['id'];_0x4e97ec[_0x2c3303(0x22c)]=_0x566062;const _0x4a120b=new Map(),_0x1ddda8=new Map(),_0x48c138=new Map(),_0x1509ff=new Map(),_0x3360f6=new Map(),_0xd63123=new Map(),_0x2b20ba=new Set(),_0x5546bf=new Set();for(const _0x4b3f19 of _0x41ef0d){for(const _0x19fc3d of _0x4b3f19[_0x2c3303(0x21e)][_0x2c3303(0x1af)]||[]){if(_0x19fc3d[_0x2c3303(0x1be)]===_0x2c3303(0x1e1)){const _0x112122=parseRef(_0x19fc3d[_0x2c3303(0x219)]);if(_0x112122)_0x2b20ba[_0x2c3303(0x230)](_0x112122[_0x2c3303(0x218)]);}else{if(_0x19fc3d['type']==='web_search'){const _0x45567d=parseRef(_0x19fc3d[_0x2c3303(0x219)]);if(_0x45567d)_0x5546bf[_0x2c3303(0x230)](_0x45567d[_0x2c3303(0x218)]);}}}}for(const _0xc273bb of _0x2b20ba){try{const _0x4ec734=await this[_0x2c3303(0x157)][_0x2c3303(0x1ac)]({'projectId':_0x566062,'name':_0xc273bb});_0x3360f6[_0x2c3303(0x20f)](_0xc273bb,_0x4ec734['id']),_0x4e97ec['imageGenerators'][_0x2c3303(0x1e9)]({'name':_0xc273bb,'action':_0x2c3303(0x1fe),'id':_0x4ec734['id']}),_0x4e97ec[_0x2c3303(0x1f8)][_0x2c3303(0x167)][_0x2c3303(0x1fe)]++;}catch(_0x25d67d){_0x4e97ec[_0x2c3303(0x167)][_0x2c3303(0x1e9)]({'name':_0xc273bb,'action':'error','error':_0x25d67d['message']}),_0x4e97ec['counts'][_0x2c3303(0x167)][_0x2c3303(0x18d)]++;}}for(const _0x5f2a7a of _0x5546bf){try{const _0x457b11=await this['client'][_0x2c3303(0x234)]({'projectId':_0x566062,'name':_0x5f2a7a});_0xd63123[_0x2c3303(0x20f)](_0x5f2a7a,_0x457b11['id']),_0x4e97ec[_0x2c3303(0x221)][_0x2c3303(0x1e9)]({'name':_0x5f2a7a,'action':'created','id':_0x457b11['id']}),_0x4e97ec[_0x2c3303(0x1f8)]['webSearchTools']['created']++;}catch(_0x5d1152){_0x4e97ec['webSearchTools'][_0x2c3303(0x1e9)]({'name':_0x5f2a7a,'action':'error','error':_0x5d1152['message']}),_0x4e97ec[_0x2c3303(0x1f8)][_0x2c3303(0x221)][_0x2c3303(0x18d)]++;}}const _0x3b697e={'projectId':_0x566062,'resolveKnowledgeBaseId':async _0x5b2abe=>_0x4a120b[_0x2c3303(0x21b)](_0x5b2abe),'resolveTextKnowledgeBaseId':async _0x429286=>_0x1ddda8['get'](_0x429286),'resolveAgentId':async _0x468129=>_0x48c138['get'](_0x468129),'resolveWebSearchToolId':async _0x1bbfb6=>_0xd63123[_0x2c3303(0x21b)](_0x1bbfb6),'resolveImageGeneratorId':async _0x3099a7=>_0x3360f6[_0x2c3303(0x21b)](_0x3099a7),'resolvePromptId':async _0x4e370a=>_0x1509ff[_0x2c3303(0x21b)](_0x4e370a),'onWarning':_0x168ae7=>this[_0x2c3303(0x237)][_0x2c3303(0x207)]?.[_0x2c3303(0x1b8)](_0x168ae7)};for(const _0x49b74c of _0x54ce7c){try{const _0x322fde=yamlKnowledgeBaseToApi(_0x49b74c[_0x2c3303(0x21e)],_0x566062),_0x56e893=await this[_0x2c3303(0x157)][_0x2c3303(0x1b5)](_0x322fde);_0x4a120b[_0x2c3303(0x20f)](_0x49b74c[_0x2c3303(0x21e)][_0x2c3303(0x218)],_0x56e893['id']),_0x4e97ec[_0x2c3303(0x1cb)][_0x2c3303(0x1e9)]({'name':_0x49b74c[_0x2c3303(0x21e)][_0x2c3303(0x218)],'action':_0x2c3303(0x1fe),'id':_0x56e893['id']}),_0x4e97ec[_0x2c3303(0x1f8)][_0x2c3303(0x1cb)][_0x2c3303(0x1fe)]++;}catch(_0x221ce5){_0x4e97ec[_0x2c3303(0x1cb)]['push']({'name':_0x49b74c[_0x2c3303(0x21e)]['name'],'action':_0x2c3303(0x16b),'error':_0x221ce5[_0x2c3303(0x1bd)]}),_0x4e97ec[_0x2c3303(0x1f8)][_0x2c3303(0x1cb)]['errors']++;}}for(const _0x2c71aa of _0x155516){try{const _0x1a99d1=yamlTextKnowledgeBaseToApi({'name':_0x2c71aa['name'],'text':_0x2c71aa[_0x2c3303(0x195)]},_0x566062),_0x3bdd93=await this['client'][_0x2c3303(0x225)](_0x1a99d1);_0x1ddda8['set'](_0x2c71aa['name'],_0x3bdd93['id']),_0x4e97ec['textKnowledgeBases'][_0x2c3303(0x1e9)]({'name':_0x2c71aa[_0x2c3303(0x218)],'action':_0x2c3303(0x1fe),'id':_0x3bdd93['id']}),_0x4e97ec[_0x2c3303(0x1f8)][_0x2c3303(0x190)][_0x2c3303(0x1fe)]++;}catch(_0x40029a){_0x4e97ec['textKnowledgeBases']['push']({'name':_0x2c71aa[_0x2c3303(0x218)],'action':_0x2c3303(0x16b),'error':_0x40029a[_0x2c3303(0x1bd)]}),_0x4e97ec[_0x2c3303(0x1f8)][_0x2c3303(0x190)][_0x2c3303(0x18d)]++;}}const _0x2e0005=[..._0x41ef0d][_0x2c3303(0x208)]((_0x50881e,_0x31681a)=>{const _0x352e01=_0x2c3303,_0x1b00ed=_0x50881e['yaml'][_0x352e01(0x1af)]?.[_0x352e01(0x235)](_0x55a9cf=>_0x55a9cf['type']===_0x352e01(0x1cc))??![],_0x399172=_0x31681a['yaml'][_0x352e01(0x1af)]?.['some'](_0x5229ed=>_0x5229ed[_0x352e01(0x1be)]===_0x352e01(0x1cc))??![];if(_0x1b00ed&&!_0x399172)return 0x1;if(!_0x1b00ed&&_0x399172)return-0x1;return 0x0;});for(const _0x282e2b of _0x2e0005){try{const _0x3109eb=_0x282e2b['yaml'][_0x2c3303(0x1af)]?.['filter'](_0x545af2=>{const _0x604cbb=_0x2c3303;if(_0x545af2['type']===_0x604cbb(0x1cc)){const _0x3810c5=parseRef(_0x545af2['target']);return _0x3810c5?.[_0x604cbb(0x218)]===_0x282e2b[_0x604cbb(0x21e)][_0x604cbb(0x218)];}return![];})??[];_0x3109eb[_0x2c3303(0x22b)]>0x0&&this[_0x2c3303(0x237)][_0x2c3303(0x207)]?.[_0x2c3303(0x1b8)]('Agent\x20\x27'+_0x282e2b[_0x2c3303(0x21e)]['name']+'\x27\x20has\x20self-referencing\x20tool(s)\x20that\x20will\x20be\x20skipped\x20during\x20clone.\x20'+'Re-add\x20them\x20after\x20clone\x20using\x20\x27tdx\x20agent\x20push\x27.');const _0x90594a=await agentDefToRequest(_0x282e2b['yaml'],_0x282e2b[_0x2c3303(0x1a5)],_0x282e2b[_0x2c3303(0x1b7)],_0x3b697e),_0x3b81ac=await this[_0x2c3303(0x157)][_0x2c3303(0x1ca)](_0x90594a);_0x48c138[_0x2c3303(0x20f)](_0x282e2b['yaml'][_0x2c3303(0x218)],_0x3b81ac['id']),_0x4e97ec[_0x2c3303(0x17b)][_0x2c3303(0x1e9)]({'agentName':_0x282e2b[_0x2c3303(0x21e)][_0x2c3303(0x218)],'action':_0x2c3303(0x1fe),'agentId':_0x3b81ac['id']}),_0x4e97ec[_0x2c3303(0x1f8)][_0x2c3303(0x17b)][_0x2c3303(0x1fe)]++;}catch(_0x995678){_0x4e97ec['agents'][_0x2c3303(0x1e9)]({'agentName':_0x282e2b[_0x2c3303(0x21e)]['name'],'action':_0x2c3303(0x16b),'error':_0x995678[_0x2c3303(0x1bd)]}),_0x4e97ec[_0x2c3303(0x1f8)][_0x2c3303(0x17b)][_0x2c3303(0x18d)]++;}}for(const _0x1cfb7c of _0x24497c){try{const _0x2bd9bd=await yamlPromptToApi(_0x1cfb7c[_0x2c3303(0x21e)],_0x566062,_0x3b697e);if(!_0x2bd9bd){_0x4e97ec[_0x2c3303(0x1ad)][_0x2c3303(0x1e9)]({'name':_0x1cfb7c[_0x2c3303(0x21e)][_0x2c3303(0x218)],'action':_0x2c3303(0x16b),'error':'Agent\x20reference\x20not\x20found'}),_0x4e97ec[_0x2c3303(0x1f8)][_0x2c3303(0x1ad)][_0x2c3303(0x18d)]++;continue;}const _0x2cfb47=await this[_0x2c3303(0x157)][_0x2c3303(0x17f)](_0x2bd9bd);_0x1509ff['set'](_0x1cfb7c[_0x2c3303(0x21e)][_0x2c3303(0x218)],_0x2cfb47['id']),_0x4e97ec[_0x2c3303(0x1ad)][_0x2c3303(0x1e9)]({'name':_0x1cfb7c['yaml']['name'],'action':_0x2c3303(0x1fe),'id':_0x2cfb47['id']}),_0x4e97ec[_0x2c3303(0x1f8)]['prompts'][_0x2c3303(0x1fe)]++;}catch(_0x1e2c02){_0x4e97ec['prompts']['push']({'name':_0x1cfb7c[_0x2c3303(0x21e)]['name'],'action':_0x2c3303(0x16b),'error':_0x1e2c02[_0x2c3303(0x1bd)]}),_0x4e97ec[_0x2c3303(0x1f8)][_0x2c3303(0x1ad)][_0x2c3303(0x18d)]++;}}return _0x4e97ec;}}
|
|
1
|
+
const a86_0x2458fb=a86_0x20c6;(function(_0x2a2ace,_0x55d366){const _0x2618d7=a86_0x20c6,_0xbcc93=_0x2a2ace();while(!![]){try{const _0x1c9d3b=-parseInt(_0x2618d7(0x175))/0x1+parseInt(_0x2618d7(0x1f2))/0x2*(parseInt(_0x2618d7(0x222))/0x3)+-parseInt(_0x2618d7(0x15d))/0x4*(parseInt(_0x2618d7(0x192))/0x5)+parseInt(_0x2618d7(0x1b8))/0x6*(parseInt(_0x2618d7(0x16e))/0x7)+parseInt(_0x2618d7(0x1a3))/0x8*(parseInt(_0x2618d7(0x1bb))/0x9)+parseInt(_0x2618d7(0x196))/0xa+parseInt(_0x2618d7(0x19c))/0xb;if(_0x1c9d3b===_0x55d366)break;else _0xbcc93['push'](_0xbcc93['shift']());}catch(_0x21c0a9){_0xbcc93['push'](_0xbcc93['shift']());}}}(a86_0x2d1c,0xb5096));import{LLMApiClient}from'../client/llm-api-client.js';import*as a86_0x22a2ad from'node:fs';import*as a86_0x2c35ae from'node:path';import{HTTPClientError}from'../client/http-client.js';function a86_0x20c6(_0x50deba,_0x116a0e){_0x50deba=_0x50deba-0x155;const _0x2d1c49=a86_0x2d1c();let _0x20c6b7=_0x2d1c49[_0x50deba];return _0x20c6b7;}import{canCreateAgent,remapToolIds,remapVariableIds,isSupportedBackupVersion}from'./llm-backup-utils.js';function a86_0x2d1c(){const _0x2b21fe=['projects','Ensure\x20the\x20path\x20points\x20to\x20a\x20valid\x20agent\x20directory.','6KEUJhg','size','createProject','139437BbDTcK','createIntegration','Available\x20agents:\x20','type','systemPrompt','name','agent','modelType','#\x20prompt.md\x0a','Choose\x20a\x20different\x20name\x20or\x20delete\x20the\x20existing\x20project\x20first.','set','medium','agent.yml','resolveAgentId','serviceType','getOrCreateDefaultProject','created','agent.yml\x20not\x20found\x20in\x20','knowledgebases.json','restoreProject','listKnowledgeBases','web_search','length','\x20in\x20project\x20','getDefaultAgent','chatInfo','getBackupMetadata','listProjects','cwd','dryRun','currentProjectId','Re-add\x20them\x20after\x20clone\x20using\x20\x27tdx\x20agent\x20push\x27.','updateKnowledgeBase','dir','newProjectId','Use\x20\x22tdx\x20llm\x20projects\x22\x20to\x20list\x20available\x20projects.','.md','prompts','1.0','Invalid\x20backup:\x20project.json\x20not\x20found\x20in\x20','Backup\x20folder\x20not\x20found:\x20','profile','listAgents','utf-8','unchanged','dry-run-','error','readdirSync','integrations.json','createAgentResponse','webhookCorsOrigins','none','The\x20backup\x20contains\x20agents\x20with\x20circular\x20dependencies.','attributes','exportedFrom','442ObCAIH','No\x20tdx.json\x20found\x20in\x20','existsSync','updated','agents.json','parse','starterMessage','counts','site','createPrompt','tables','Ensure\x20the\x20backup\x20folder\x20path\x20is\x20correct.','Use\x20a\x20different\x20output\x20path\x20or\x20remove\x20the\x20existing\x20directory.','logger','availableModelNames','text','errors','listIntegrations','isManaged','INVALID_ARGUMENT','listPrompts','createImageGenerator','createTextKnowledgeBase','agentId\x20is\x20required\x20when\x20starting\x20a\x20new\x20chat','\x0a\x0a#\x20agent.yml\x0a','starter_message.md','INTERNAL','project','keys','yaml','version','pushAgent','.yml','getUniqueName','project.json','pullAgent','chats','mkdirSync','Project\x20\x22','listChats','updateAgentResponse','\x27.\x20This\x20should\x20not\x20happen.','map','updateTextKnowledgeBase','toISOString','prompt.md','llm_project','total','4143sdYzRw','Unable\x20to\x20create\x20project\x20after\x20','content','image_gen','isDirectory','writeFileSync','resolveProjectName','status','models','resolveProjectId','promptId','Authentication\x20failed.\x20Please\x20check\x20your\x20API\x20key\x20is\x20valid\x20and\x20not\x20expired.','continueChat','displayName','filter','createWebSearchTool','4FveOsi','\x22\x20already\x20exists','path','listTextKnowledgeBases','knowledgeBases','cloneProject','high','target','join','backupProject','find','PERMISSION_DENIED','message','deleteProject','stringify','deleteAgent','endsWith','59423FAIqUb','Circular\x20dependency\x20detected\x20in\x20agents.\x20Cannot\x20restore.','push','Use\x20format:\x20\x22agent-name\x22\x20or\x20\x22project-name/agent-name\x22','getAgent','tdx.json','new','625432vLmUnm','loadJsonFile','\x27\x20has\x20self-referencing\x20tool(s)\x20that\x20will\x20be\x20skipped\x20during\x20clone.\x20','integrations','actions','unlinkSync','.llm','AGENT_NOT_FOUND','warn','Default\x20project\x20for\x20tdx\x20CLI\x20chat\x20(user:\x20','tools','template','slackMessageMode','listAgentsFull','get','Project\x20not\x20found:\x20','getDefaultProjectName','getUserSettings','chatIgnoreManagedActions','agentId','getChatHistory','agents','Agent\x20not\x20found:\x20','getOrCreateDefaultAgent','tdDatabaseName','webSearchTools','maxToolIterations','createAgent','listImageGenerators','7092755xJIMNV','context','readFileSync','reasoningEffort','3365860gCdoHn','description','variables','listWebSearchTools','startChat','Use\x20\x22tdx\x20llm\x20agents\x22\x20to\x20list\x20available\x20agents\x20in\x20the\x20current\x20project.','11728376ykfrDx','isDir','knowledge_bases','add','LLM_PROJECT_NOT_FOUND','Permission\x20denied.\x20Please\x20check\x20your\x20API\x20key\x20has\x20the\x20required\x20permissions\x20for\x20LLM\x20API\x20operations.','imageGenerators','552LVqIHp','prompts.json','textKnowledgeBases','includes','ALREADY_EXISTS','history','_reasoning_','chatId','client','NOT_FOUND','Agent\x20reference\x20not\x20found','getProject','(dry-run)','\x20attempts\x20due\x20to\x20name\x20conflicts.','chatWelcomeMessage','starter_message','action','chat','updateAgent'];a86_0x2d1c=function(){return _0x2b21fe;};return a86_0x2d1c();}import{SDKError,ErrorCode,errorContains}from'../errors.js';import{normalizeName,UniqueNameGenerator,migrateModelType,parseRef,agentResponseToDef,apiKnowledgeBaseToYaml,apiPromptToYaml,toAgentYamlString,toKnowledgeBaseYamlString,toTextKnowledgeBaseMd,toPromptYamlString,parseAgentYaml,parseKnowledgeBaseYaml,parseTextKnowledgeBaseMd,parsePromptYaml,agentDefToRequest,yamlKnowledgeBaseToApi,yamlTextKnowledgeBaseToApi,yamlPromptToApi,resolveAgentDependencies}from'../agent/agent-yaml.js';import{createAgentConfigContent,loadAgentConfig,findAgentConfig,isAgentDir,isAgentYamlPath,getAgentDirFromYamlPath,getKnowledgeBasesDir,getPromptsDir}from'../agent/agent-config.js';import{getSanitizedUsername,generateRandomHex}from'../../utils/string-utils.js';import{generateDiff,formatDiffWithColors,hasChanges}from'../../utils/diff.js';import{readCachedLLMProject,writeCachedLLMProject,readCachedLLMAgent,writeCachedLLMAgent,clearCachedLLMAgent}from'../../core/config.js';export class LLMSDK{[a86_0x2458fb(0x1d9)];[a86_0x2458fb(0x1ab)];[a86_0x2458fb(0x193)];constructor(_0x5ba959){const _0x53a331=a86_0x2458fb;this[_0x53a331(0x1ab)]=new LLMApiClient(_0x5ba959,_0x5ba959[_0x53a331(0x1ff)]),this['context']=_0x5ba959;}[a86_0x2458fb(0x185)](){const _0x258bbd=getSanitizedUsername();return'tdx_default_'+_0x258bbd;}async['setCurrentProject'](_0xcbd31d){const _0x36dcca=a86_0x2458fb,{projectId:_0xe2d152}=await this[_0x36dcca(0x228)](_0xcbd31d);this['currentProjectId']=_0xe2d152;}['getCurrentProject'](){const _0x55160a=a86_0x2458fb;return this[_0x55160a(0x1d9)];}async['setDefaultAgent'](_0x585d17){const _0x32e6e8=a86_0x2458fb,_0x9e6650=this[_0x32e6e8(0x193)][_0x32e6e8(0x1e4)];let _0x54f647,_0x1652bb;if(_0x585d17[_0x32e6e8(0x1a6)]('/')){const _0x163041=_0x585d17['split']('/');if(_0x163041[_0x32e6e8(0x1d1)]!==0x2)throw new SDKError(ErrorCode['INVALID_ARGUMENT'],'Invalid\x20agent\x20reference\x20format:\x20'+_0x585d17,undefined,{'helpText':_0x32e6e8(0x171)});const [_0x1efa66,_0x50d2fe]=_0x163041;_0x54f647=await this[_0x32e6e8(0x156)](_0x1efa66),_0x1652bb=_0x50d2fe;}else _0x54f647=this['currentProjectId']||(await this['getOrCreateDefaultProject']())['id'],_0x1652bb=_0x585d17;const _0x423ba4=await this[_0x32e6e8(0x1c8)](_0x1652bb,_0x54f647),_0x57c518=await this[_0x32e6e8(0x1ab)][_0x32e6e8(0x172)](_0x423ba4);writeCachedLLMAgent(_0x57c518['attributes'][_0x32e6e8(0x1c0)],_0x423ba4,_0x54f647,_0x9e6650);}[a86_0x2458fb(0x1d3)](){const _0x25cf13=a86_0x2458fb,_0x285672=this[_0x25cf13(0x193)][_0x25cf13(0x1e4)];return readCachedLLMAgent(_0x285672)||undefined;}['clearDefaultAgent'](){const _0x9129be=this['context']['profile'];clearCachedLLMAgent(_0x9129be);}async[a86_0x2458fb(0x155)](){const _0x273ee3=a86_0x2458fb,_0x4ce5fc=await this[_0x273ee3(0x1ab)][_0x273ee3(0x186)](),_0x70110f=[];for(const _0x113558 of _0x4ce5fc[_0x273ee3(0x200)]){const _0x1158c5=_0x4ce5fc['availableModels'][_0x113558];_0x1158c5&&_0x70110f['push']({'name':_0x113558,'displayName':_0x1158c5[_0x273ee3(0x15a)]});}return _0x70110f;}async[a86_0x2458fb(0x1ba)](_0x4f795f){const _0x28c45a=a86_0x2458fb;return await this['client'][_0x28c45a(0x1ba)](_0x4f795f);}async[a86_0x2458fb(0x16a)](_0x4cd6d7){const _0x2f384c=a86_0x2458fb,{projectId:_0x526504}=await this[_0x2f384c(0x228)](_0x4cd6d7);await this[_0x2f384c(0x1ab)][_0x2f384c(0x16a)](_0x526504);}async[a86_0x2458fb(0x1b6)](_0x25ad66=0x32){const _0x2a4288=a86_0x2458fb;return await this[_0x2a4288(0x1ab)][_0x2a4288(0x1d6)](_0x25ad66);}async[a86_0x2458fb(0x1ca)](_0x32069b){const _0x4cdfcc=a86_0x2458fb,_0x37bf77=_0x32069b||this[_0x4cdfcc(0x185)](),_0x5a6c6e=this[_0x4cdfcc(0x193)]['profile'];if(!_0x32069b){const _0x2ab2ae=readCachedLLMProject(_0x5a6c6e);if(_0x2ab2ae&&_0x2ab2ae['name']===_0x37bf77)try{const _0x1ba0af=await this['client'][_0x4cdfcc(0x1ae)](_0x2ab2ae['id']);if(_0x1ba0af[_0x4cdfcc(0x1f0)][_0x4cdfcc(0x1c0)]===_0x37bf77)return _0x1ba0af;}catch{}}const _0x194424=await this[_0x4cdfcc(0x1ab)][_0x4cdfcc(0x1d6)](),_0x3f1908=_0x194424[_0x4cdfcc(0x167)](_0x385040=>_0x385040['attributes'][_0x4cdfcc(0x1c0)]===_0x37bf77);if(_0x3f1908)return!_0x32069b&&writeCachedLLMProject(_0x37bf77,_0x3f1908['id'],_0x5a6c6e),_0x3f1908;const _0x56e1aa=await this[_0x4cdfcc(0x1ab)]['createProject']({'name':_0x37bf77,'description':_0x4cdfcc(0x17e)+getSanitizedUsername()+')'});return!_0x32069b&&writeCachedLLMProject(_0x37bf77,_0x56e1aa['id'],_0x5a6c6e),_0x56e1aa;}async[a86_0x2458fb(0x156)](_0x2fc3e9){const _0xf22ab8=a86_0x2458fb,_0x1b2032=await this[_0xf22ab8(0x1ab)]['listProjects'](),_0x56f4f5=_0x1b2032['filter'](_0x237746=>_0x237746[_0xf22ab8(0x1f0)][_0xf22ab8(0x1c0)]===_0x2fc3e9);if(_0x56f4f5[_0xf22ab8(0x1d1)]===0x0)throw new SDKError(ErrorCode[_0xf22ab8(0x1a0)],_0xf22ab8(0x184)+_0x2fc3e9,undefined,{'helpText':_0xf22ab8(0x1de)});if(_0x56f4f5['length']>0x1)throw new SDKError(ErrorCode['INTERNAL'],'Multiple\x20projects\x20found\x20with\x20name\x20\x27'+_0x2fc3e9+_0xf22ab8(0x21b));return _0x56f4f5[0x0]['id'];}async['resolveProjectName'](_0x25dfab){const _0x42c5fb=a86_0x2458fb,_0x4f0813=await this[_0x42c5fb(0x1ab)][_0x42c5fb(0x1d6)](),_0x550613=_0x4f0813['find'](_0x297b0c=>_0x297b0c[_0x42c5fb(0x1f0)][_0x42c5fb(0x1c0)]===_0x25dfab);if(_0x550613)return{'projectId':_0x550613['id'],'project':_0x550613};throw new SDKError(ErrorCode[_0x42c5fb(0x1a0)],_0x42c5fb(0x184)+_0x25dfab,undefined,{'helpText':_0x42c5fb(0x1de)});}async[a86_0x2458fb(0x18c)](_0x9bdd40='claude-4.5-sonnet',_0x3a825d=0x0,_0x3e1d5b){const _0x22532d=a86_0x2458fb,_0x5e3f23=0xa;let _0x271ee0=0x0,_0x170022;while(_0x271ee0<_0x5e3f23){try{const _0x2c245b=await this[_0x22532d(0x1ca)](_0x170022),_0xa681d5=_0x2c245b['id'],_0x4dff6b=[_0x22532d(0x1ee),'minimal','low',_0x22532d(0x1c6),_0x22532d(0x163)],_0x222220=_0x3a825d===0x0?'tdx_'+_0x9bdd40:'tdx_'+_0x9bdd40+_0x22532d(0x1a9)+_0x4dff6b[_0x3a825d],_0x3506fe=await this[_0x22532d(0x1ab)]['listAgents'](_0xa681d5),_0x5ec33d=_0x3506fe[_0x22532d(0x167)](_0x48144a=>_0x48144a['attributes']['name']===_0x222220);if(_0x5ec33d)return _0x5ec33d;const _0x480475=_0x3a825d>0x0?0x1:_0x3e1d5b;return await this[_0x22532d(0x1ab)][_0x22532d(0x190)]({'name':_0x222220,'projectId':_0xa681d5,'modelType':_0x9bdd40,'systemPrompt':'','temperature':_0x480475,'reasoningEffort':_0x3a825d>0x0?_0x3a825d:undefined});}catch(_0x3fcb9a){if(_0x3fcb9a instanceof HTTPClientError){const _0x2a214d=_0x3fcb9a[_0x22532d(0x229)];if(_0x2a214d>=0x190&&_0x2a214d<0x1f4){if(_0x2a214d===0x191)throw new SDKError(ErrorCode['UNAUTHENTICATED'],_0x22532d(0x158),_0x3fcb9a);else{if(_0x2a214d===0x193)throw new SDKError(ErrorCode[_0x22532d(0x168)],_0x22532d(0x1a1),_0x3fcb9a);}throw _0x3fcb9a;}}if(errorContains(_0x3fcb9a,'already\x20exists','duplicate','conflict')){_0x271ee0++;if(_0x271ee0>=_0x5e3f23)throw new SDKError(ErrorCode['ALREADY_EXISTS'],_0x22532d(0x223)+_0x5e3f23+_0x22532d(0x1b0),_0x3fcb9a);const _0x16cfe3=this[_0x22532d(0x185)]();_0x170022=_0x16cfe3+'_'+generateRandomHex();continue;}throw _0x3fcb9a;}}throw new SDKError(ErrorCode[_0x22532d(0x20c)],'Failed\x20to\x20get\x20or\x20create\x20agent:\x20exceeded\x20maximum\x20attempts');}async[a86_0x2458fb(0x1c8)](_0x1b439f,_0x1528f7){const _0x42b201=a86_0x2458fb,_0x4e6e89=_0x1528f7||this[_0x42b201(0x1d9)],_0x4bed7f=await this[_0x42b201(0x1ab)][_0x42b201(0x1e5)](_0x4e6e89),_0xf6c6c3=_0x4bed7f[_0x42b201(0x15b)](_0x4d3aba=>_0x4d3aba['attributes'][_0x42b201(0x1c0)]===_0x1b439f);if(_0xf6c6c3[_0x42b201(0x1d1)]===0x0){const _0x2cad30=_0x4e6e89?_0x42b201(0x1d2)+_0x4e6e89:'';throw new SDKError(ErrorCode[_0x42b201(0x17c)],_0x42b201(0x18b)+_0x1b439f+_0x2cad30,undefined,{'helpText':_0x4e6e89?_0x42b201(0x19b):'Use\x20\x22tdx\x20llm\x20use\x20<project>\x22\x20to\x20set\x20a\x20project\x20context\x20first,\x20or\x20use\x20\x22tdx\x20llm\x20agents\x22\x20to\x20list\x20all\x20agents.'});}if(_0xf6c6c3[_0x42b201(0x1d1)]>0x1)throw new SDKError(ErrorCode[_0x42b201(0x20c)],'Multiple\x20agents\x20found\x20with\x20name\x20\x27'+_0x1b439f+_0x42b201(0x21b));return _0xf6c6c3[0x0]['id'];}async['agents'](_0x51c062){const _0xebb3c0=a86_0x2458fb,_0x44ca59=_0x51c062||this['currentProjectId'];return await this[_0xebb3c0(0x1ab)][_0xebb3c0(0x1e5)](_0x44ca59);}async[a86_0x2458fb(0x1c1)](_0xde54e7){const _0xb2c7=a86_0x2458fb;return await this[_0xb2c7(0x1ab)][_0xb2c7(0x172)](_0xde54e7);}async[a86_0x2458fb(0x190)](_0x32eb5c){const _0x1e85ed=a86_0x2458fb;return await this[_0x1e85ed(0x1ab)]['createAgent'](_0x32eb5c);}async['updateAgent'](_0x25b9bb,_0x5d0766){const _0x300b96=a86_0x2458fb;return await this[_0x300b96(0x1ab)][_0x300b96(0x1b5)](_0x25b9bb,_0x5d0766);}async[a86_0x2458fb(0x16c)](_0x52dc5a){const _0x3e13ce=a86_0x2458fb;await this[_0x3e13ce(0x1ab)][_0x3e13ce(0x16c)](_0x52dc5a);}async[a86_0x2458fb(0x19a)](_0x49ba94){const _0x4f914f=a86_0x2458fb;return await this[_0x4f914f(0x1ab)][_0x4f914f(0x19a)]({'agentId':_0x49ba94});}async*[a86_0x2458fb(0x1b4)](_0x155106,_0x2e522b){const _0x24dbed=a86_0x2458fb;let _0x2a0bd4=_0x2e522b?.[_0x24dbed(0x1aa)];const _0x1c9185=_0x2e522b?.['agentId'];if(!_0x2a0bd4){if(!_0x1c9185)throw new Error(_0x24dbed(0x209));const _0x42bc8a=await this[_0x24dbed(0x1ab)][_0x24dbed(0x19a)]({'agentId':_0x1c9185});_0x2a0bd4=_0x42bc8a['id'],yield{'type':'metadata','data':{'chatId':_0x2a0bd4,'agentId':_0x1c9185}};}for await(const _0x5159f4 of this[_0x24dbed(0x1ab)][_0x24dbed(0x159)](_0x2a0bd4,_0x155106,_0x2e522b?.['signal'])){yield{'type':'event','data':_0x5159f4};}}async[a86_0x2458fb(0x216)](_0x7a2699=0x32){const _0x2d1076=a86_0x2458fb;return await this[_0x2d1076(0x1ab)][_0x2d1076(0x219)](_0x7a2699);}async[a86_0x2458fb(0x1a8)](_0x3d506b){const _0x2ec08a=a86_0x2458fb;return await this[_0x2ec08a(0x1ab)][_0x2ec08a(0x189)](_0x3d506b);}async[a86_0x2458fb(0x1d4)](_0x55bc6b){const _0x1541fb=a86_0x2458fb;return await this[_0x1541fb(0x1ab)]['getChatInfo'](_0x55bc6b);}async[a86_0x2458fb(0x166)](_0x120b1b,_0x185b5e,_0x54a978){const _0x3202cd=a86_0x2458fb,_0x1f39aa=_0x54a978?.[_0x3202cd(0x1d8)]??![],{projectId:_0x21c6db,project:_0x1b2ac2}=await this['resolveProjectName'](_0x120b1b),_0x3801d4=_0x1b2ac2[_0x3202cd(0x1f0)]['name'],_0x874f97=_0x185b5e||_0x3801d4+_0x3202cd(0x17b);if(a86_0x22a2ad[_0x3202cd(0x1f4)](_0x874f97)&&!_0x1f39aa)throw new SDKError(ErrorCode[_0x3202cd(0x1a7)],'Output\x20directory\x20already\x20exists:\x20'+_0x874f97,undefined,{'helpText':_0x3202cd(0x1fe)});const _0x3a85be=await this['client']['listAgentsFull'](_0x21c6db),_0x1b62db=await this[_0x3202cd(0x1ab)]['listKnowledgeBases'](_0x21c6db),_0x167d97=await this[_0x3202cd(0x1ab)][_0x3202cd(0x206)](_0x21c6db),_0x33a69a=await this[_0x3202cd(0x1ab)][_0x3202cd(0x203)](_0x21c6db);if(!_0x1f39aa){a86_0x22a2ad['mkdirSync'](_0x874f97,{'recursive':!![]});const _0x35e32e={'version':_0x3202cd(0x1e1),'exportedAt':new Date()[_0x3202cd(0x21e)](),'exportedFrom':{'site':this[_0x3202cd(0x193)][_0x3202cd(0x1fa)],'projectId':_0x21c6db,'projectName':_0x3801d4},'project':_0x1b2ac2};a86_0x22a2ad[_0x3202cd(0x227)](a86_0x2c35ae[_0x3202cd(0x165)](_0x874f97,_0x3202cd(0x214)),JSON[_0x3202cd(0x16b)](_0x35e32e,null,0x2)),a86_0x22a2ad[_0x3202cd(0x227)](a86_0x2c35ae[_0x3202cd(0x165)](_0x874f97,'agents.json'),JSON[_0x3202cd(0x16b)](_0x3a85be,null,0x2)),a86_0x22a2ad[_0x3202cd(0x227)](a86_0x2c35ae[_0x3202cd(0x165)](_0x874f97,_0x3202cd(0x1cd)),JSON[_0x3202cd(0x16b)](_0x1b62db,null,0x2)),a86_0x22a2ad['writeFileSync'](a86_0x2c35ae[_0x3202cd(0x165)](_0x874f97,_0x3202cd(0x1a4)),JSON[_0x3202cd(0x16b)](_0x167d97,null,0x2)),a86_0x22a2ad['writeFileSync'](a86_0x2c35ae[_0x3202cd(0x165)](_0x874f97,_0x3202cd(0x1eb)),JSON[_0x3202cd(0x16b)](_0x33a69a,null,0x2));}return{'projectName':_0x3801d4,'outputDir':_0x874f97,'counts':{'agents':_0x3a85be[_0x3202cd(0x1d1)],'knowledgeBases':_0x1b62db[_0x3202cd(0x1d1)],'prompts':_0x167d97[_0x3202cd(0x1d1)],'integrations':_0x33a69a[_0x3202cd(0x1d1)]}};}async[a86_0x2458fb(0x1ce)](_0x809cbd,_0xc877f9){const _0x5468d3=a86_0x2458fb,_0x1f3cab=_0xc877f9?.[_0x5468d3(0x1d8)]??![],_0x33442c=this[_0x5468d3(0x1d5)](_0x809cbd),_0x5cdc2f=_0x33442c[_0x5468d3(0x1f1)][_0x5468d3(0x1fa)],_0x286bf7=this[_0x5468d3(0x193)][_0x5468d3(0x1fa)],_0x3a05c1=_0x5cdc2f!==_0x286bf7?_0x5cdc2f:undefined,_0x1faee4=this['loadJsonFile'](a86_0x2c35ae[_0x5468d3(0x165)](_0x809cbd,_0x5468d3(0x1f6)),[]),_0x471f0c=this[_0x5468d3(0x176)](a86_0x2c35ae[_0x5468d3(0x165)](_0x809cbd,'knowledgebases.json'),[]),_0x1a7589=this['loadJsonFile'](a86_0x2c35ae[_0x5468d3(0x165)](_0x809cbd,_0x5468d3(0x1a4)),[]),_0x5d84e8=this[_0x5468d3(0x176)](a86_0x2c35ae['join'](_0x809cbd,_0x5468d3(0x1eb)),[]),_0x5c55c6=_0xc877f9?.['name']||_0x33442c[_0x5468d3(0x1f1)]['projectName'];if(_0x1f3cab){const _0x286359=new Map(),_0xce4d26=[..._0x1faee4],_0x371a8e=_0x1faee4[_0x5468d3(0x1d1)]+0x1;let _0x558ccd=0x0;while(_0xce4d26['length']>0x0&&_0x558ccd<_0x371a8e){_0x558ccd++;const _0x47236c=[];for(const _0x5cd0d3 of _0xce4d26){canCreateAgent(_0x5cd0d3,_0x286359)?_0x286359[_0x5468d3(0x1c5)](_0x5cd0d3['id'],_0x5468d3(0x1e8)+_0x5cd0d3['id']):_0x47236c[_0x5468d3(0x170)](_0x5cd0d3);}if(_0x47236c[_0x5468d3(0x1d1)]===_0xce4d26[_0x5468d3(0x1d1)])throw new SDKError(ErrorCode[_0x5468d3(0x20c)],_0x5468d3(0x16f),undefined,{'helpText':_0x5468d3(0x1ef)});_0xce4d26[_0x5468d3(0x1d1)]=0x0,_0xce4d26[_0x5468d3(0x170)](..._0x47236c);}const _0x240c83=_0x1a7589[_0x5468d3(0x15b)](_0x45e327=>_0x286359['has'](_0x45e327[_0x5468d3(0x1f0)][_0x5468d3(0x188)]))[_0x5468d3(0x1d1)];return{'projectName':_0x5c55c6,'projectId':_0x5468d3(0x1af),'counts':{'agents':_0x1faee4['length'],'knowledgeBases':_0x471f0c['length'],'prompts':_0x240c83,'integrations':_0x5d84e8[_0x5468d3(0x1d1)]},'sourceSite':_0x3a05c1};}const _0x2212e9=await this['client'][_0x5468d3(0x1ba)]({'name':_0x5c55c6,'description':_0x33442c[_0x5468d3(0x20d)][_0x5468d3(0x1f0)][_0x5468d3(0x197)]}),_0x41970c=_0x2212e9['id'],_0x38d6a5=new Map(),_0xbeaa4a=new Map(),_0x26be38=new Map();for(const _0x6b661c of _0x471f0c){const _0x47ba99=await this[_0x5468d3(0x1ab)]['createKnowledgeBase']({'projectId':_0x41970c,'name':_0x6b661c[_0x5468d3(0x1f0)][_0x5468d3(0x1c0)],'tdDatabaseName':_0x6b661c[_0x5468d3(0x1f0)][_0x5468d3(0x18d)],'tables':_0x6b661c[_0x5468d3(0x1f0)][_0x5468d3(0x1fc)]});_0x38d6a5[_0x5468d3(0x1c5)](_0x6b661c['id'],_0x47ba99['id']);}const _0x47ac85=[..._0x1faee4],_0x14d852=_0x1faee4[_0x5468d3(0x1d1)]+0x1;let _0x31e0c3=0x0;while(_0x47ac85[_0x5468d3(0x1d1)]>0x0&&_0x31e0c3<_0x14d852){_0x31e0c3++;const _0x29365d=[];for(const _0x24f4a3 of _0x47ac85){if(canCreateAgent(_0x24f4a3,_0xbeaa4a)){const _0x85fab6=remapToolIds(_0x24f4a3[_0x5468d3(0x1f0)][_0x5468d3(0x17f)],_0x38d6a5,_0xbeaa4a),_0x507075=remapVariableIds(_0x24f4a3[_0x5468d3(0x1f0)][_0x5468d3(0x198)],_0x38d6a5),_0x1a3ae4=await this[_0x5468d3(0x1ab)][_0x5468d3(0x1ec)]({'name':_0x24f4a3[_0x5468d3(0x1f0)][_0x5468d3(0x1c0)],'projectId':_0x41970c,'systemPrompt':_0x24f4a3['attributes']['systemPrompt'],'starterMessage':_0x24f4a3[_0x5468d3(0x1f0)][_0x5468d3(0x1f8)],'modelType':migrateModelType(_0x24f4a3[_0x5468d3(0x1f0)][_0x5468d3(0x1c2)]),'maxToolIterations':_0x24f4a3[_0x5468d3(0x1f0)][_0x5468d3(0x18f)],'temperature':_0x24f4a3[_0x5468d3(0x1f0)]['temperature'],'reasoningEffort':_0x24f4a3['attributes'][_0x5468d3(0x195)],'outputs':_0x24f4a3[_0x5468d3(0x1f0)]['outputs'],'tools':_0x85fab6,'variables':_0x507075});_0xbeaa4a[_0x5468d3(0x1c5)](_0x24f4a3['id'],_0x1a3ae4['id']);}else _0x29365d[_0x5468d3(0x170)](_0x24f4a3);}if(_0x29365d[_0x5468d3(0x1d1)]===_0x47ac85[_0x5468d3(0x1d1)])throw new SDKError(ErrorCode['INTERNAL'],_0x5468d3(0x16f),undefined,{'helpText':'The\x20backup\x20contains\x20agents\x20with\x20circular\x20dependencies.'});_0x47ac85['length']=0x0,_0x47ac85['push'](..._0x29365d);}for(const _0x4e3c21 of _0x1a7589){const _0x3ff3e1=_0xbeaa4a[_0x5468d3(0x183)](_0x4e3c21[_0x5468d3(0x1f0)][_0x5468d3(0x188)]);if(!_0x3ff3e1)continue;const _0x389aca=await this[_0x5468d3(0x1ab)][_0x5468d3(0x1fb)]({'projectId':_0x41970c,'agentId':_0x3ff3e1,'name':_0x4e3c21['attributes'][_0x5468d3(0x1c0)],'systemPrompt':_0x4e3c21[_0x5468d3(0x1f0)]['systemPrompt'],'template':_0x4e3c21['attributes'][_0x5468d3(0x180)],'jsonSchemaHint':_0x4e3c21[_0x5468d3(0x1f0)]['jsonSchemaHint']});_0x26be38[_0x5468d3(0x1c5)](_0x4e3c21['id'],_0x389aca['id']);}for(const _0x293933 of _0x5d84e8){const _0x4d4374=_0x293933[_0x5468d3(0x1f0)][_0x5468d3(0x179)][_0x5468d3(0x21c)](_0x5238b0=>({..._0x5238b0,'promptId':_0x26be38[_0x5468d3(0x183)](_0x5238b0[_0x5468d3(0x157)])||_0x5238b0['promptId']}));await this[_0x5468d3(0x1ab)][_0x5468d3(0x1bc)]({'projectId':_0x41970c,'serviceType':_0x293933['attributes'][_0x5468d3(0x1c9)],'actions':_0x4d4374,'slackMessageMode':_0x293933[_0x5468d3(0x1f0)][_0x5468d3(0x181)],'chatIgnoreManagedActions':_0x293933[_0x5468d3(0x1f0)][_0x5468d3(0x187)],'chatWelcomeMessage':_0x293933[_0x5468d3(0x1f0)][_0x5468d3(0x1b1)],'webhookCorsOrigins':_0x293933['attributes'][_0x5468d3(0x1ed)]});}return{'projectName':_0x5c55c6,'projectId':_0x41970c,'counts':{'agents':_0xbeaa4a[_0x5468d3(0x1b9)],'knowledgeBases':_0x38d6a5[_0x5468d3(0x1b9)],'prompts':_0x26be38[_0x5468d3(0x1b9)],'integrations':_0x5d84e8['length']},'sourceSite':_0x3a05c1};}[a86_0x2458fb(0x176)](_0x3c16dc,_0x4a7ad7){const _0x4589cf=a86_0x2458fb;if(!a86_0x22a2ad[_0x4589cf(0x1f4)](_0x3c16dc))return _0x4a7ad7;return JSON[_0x4589cf(0x1f7)](a86_0x22a2ad['readFileSync'](_0x3c16dc,_0x4589cf(0x1e6)));}[a86_0x2458fb(0x1d5)](_0x5ddd53){const _0x51f9f9=a86_0x2458fb;if(!a86_0x22a2ad[_0x51f9f9(0x1f4)](_0x5ddd53))throw new SDKError(ErrorCode['NOT_FOUND'],_0x51f9f9(0x1e3)+_0x5ddd53,undefined,{'helpText':_0x51f9f9(0x1fd)});const _0x46379c=a86_0x2c35ae[_0x51f9f9(0x165)](_0x5ddd53,'project.json');if(!a86_0x22a2ad[_0x51f9f9(0x1f4)](_0x46379c))throw new SDKError(ErrorCode[_0x51f9f9(0x205)],_0x51f9f9(0x1e2)+_0x5ddd53,undefined,{'helpText':'Ensure\x20this\x20is\x20a\x20valid\x20LLM\x20project\x20backup\x20folder.'});const _0x16c022=JSON['parse'](a86_0x22a2ad[_0x51f9f9(0x194)](_0x46379c,_0x51f9f9(0x1e6)));if(!isSupportedBackupVersion(_0x16c022[_0x51f9f9(0x210)]))throw new SDKError(ErrorCode[_0x51f9f9(0x205)],'Unsupported\x20backup\x20version:\x20'+_0x16c022[_0x51f9f9(0x210)],undefined,{'helpText':'This\x20backup\x20was\x20created\x20with\x20a\x20newer\x20version\x20of\x20tdx.'});return _0x16c022;}async['pullProject'](_0x39f442,_0x16ae2b,_0x4bec6d){const _0x4cb494=a86_0x2458fb,{projectId:_0x2cf596,project:_0x46e369}=await this[_0x4cb494(0x228)](_0x39f442),_0x397f7d=_0x46e369[_0x4cb494(0x1f0)]['name'],_0x270959=normalizeName(_0x397f7d),_0xeb8902=_0x16ae2b||a86_0x2c35ae['join'](process['cwd'](),'agents',_0x270959),_0x16be1e=await this[_0x4cb494(0x1ab)][_0x4cb494(0x182)](_0x2cf596),_0x4ef36e=await this[_0x4cb494(0x1ab)][_0x4cb494(0x1cf)](_0x2cf596),_0x488e36=await this['client'][_0x4cb494(0x160)](_0x2cf596),_0x2186f2=await this[_0x4cb494(0x1ab)]['listImageGenerators'](_0x2cf596),_0x49c0e8=await this['client'][_0x4cb494(0x199)](_0x2cf596),_0x581714=await this['client'][_0x4cb494(0x206)](_0x2cf596),_0x53c1e8=new Map(),_0x500d7d=new Map(),_0x386288=new Map(),_0x3a24f4=new Map(),_0x7269fb=new Map(),_0x168188=new Map();for(const _0xdc2fa8 of _0x16be1e){_0x53c1e8[_0x4cb494(0x1c5)](_0xdc2fa8['id'],_0xdc2fa8['attributes'][_0x4cb494(0x1c0)]);}for(const _0x30491f of _0x4ef36e){_0x500d7d['set'](_0x30491f['id'],_0x30491f[_0x4cb494(0x1f0)]['name']);}for(const _0xcf1ac6 of _0x488e36){_0x386288[_0x4cb494(0x1c5)](_0xcf1ac6['id'],_0xcf1ac6[_0x4cb494(0x1f0)]['name']);}for(const _0x4623da of _0x2186f2){_0x3a24f4[_0x4cb494(0x1c5)](_0x4623da['id'],_0x4623da[_0x4cb494(0x1f0)][_0x4cb494(0x1c0)]);}for(const _0x1d7851 of _0x49c0e8){_0x7269fb[_0x4cb494(0x1c5)](_0x1d7851['id'],_0x1d7851['attributes'][_0x4cb494(0x1c0)]);}for(const _0x58bf31 of _0x581714){_0x168188['set'](_0x58bf31['id'],_0x58bf31['attributes']['name']);}const _0x178735={'resolveKnowledgeBaseName':async _0x2a6c6f=>_0x500d7d['get'](_0x2a6c6f),'resolveTextKnowledgeBaseName':async _0x16d7a4=>_0x386288[_0x4cb494(0x183)](_0x16d7a4),'resolveAgentName':async _0x346b73=>_0x53c1e8[_0x4cb494(0x183)](_0x346b73),'resolveWebSearchToolName':async _0x2b8a1a=>_0x7269fb[_0x4cb494(0x183)](_0x2b8a1a),'resolveImageGeneratorName':async _0x3e1a81=>_0x3a24f4[_0x4cb494(0x183)](_0x3e1a81),'resolvePromptName':async _0x5d2b22=>_0x168188['get'](_0x5d2b22),'onWarning':_0x5340be=>this['context'][_0x4cb494(0x1ff)]?.[_0x4cb494(0x17d)](_0x5340be)},_0x51eb5f={'projectName':_0x397f7d,'outputDir':_0xeb8902,'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}}},_0x853063=[],_0x1d3f0d=new UniqueNameGenerator(),_0x45d443=new UniqueNameGenerator(),_0x549764=new UniqueNameGenerator(),_0x3f4c9f=new UniqueNameGenerator();for(const _0x516887 of _0x16be1e){const _0x260144=_0x1d3f0d['getUniqueName'](_0x516887[_0x4cb494(0x1f0)][_0x4cb494(0x1c0)]),_0x2da624=a86_0x2c35ae[_0x4cb494(0x165)](_0xeb8902,_0x260144),_0x257f6b=a86_0x2c35ae[_0x4cb494(0x165)](_0x2da624,'prompt.md'),_0x355eab=a86_0x2c35ae[_0x4cb494(0x165)](_0x2da624,_0x4cb494(0x1c7)),_0x3e5ecf=a86_0x2c35ae[_0x4cb494(0x165)](_0x2da624,_0x4cb494(0x20b)),{yaml:_0x3fb597,systemPrompt:_0x300ba4,starterMessage:_0x26625e}=await agentResponseToDef(_0x516887,_0x178735),_0x5c38d6=toAgentYamlString(_0x3fb597),_0x225b8e=!a86_0x22a2ad[_0x4cb494(0x1f4)](_0x355eab);let _0x179276=_0x225b8e,_0x311caf;if(!_0x225b8e){const _0x430f76=a86_0x22a2ad[_0x4cb494(0x1f4)](_0x257f6b)?a86_0x22a2ad[_0x4cb494(0x194)](_0x257f6b,_0x4cb494(0x1e6)):'',_0x738ce3=a86_0x22a2ad[_0x4cb494(0x194)](_0x355eab,_0x4cb494(0x1e6)),_0x484a39='#\x20prompt.md\x0a'+_0x430f76+_0x4cb494(0x20a)+_0x738ce3,_0x31721f=_0x4cb494(0x1c3)+_0x300ba4+'\x0a\x0a#\x20agent.yml\x0a'+_0x5c38d6,_0x450992=generateDiff(_0x484a39,_0x31721f);_0x179276=hasChanges(_0x450992),_0x179276&&(_0x311caf=formatDiffWithColors(_0x450992));}_0x853063[_0x4cb494(0x170)]({'path':_0x2da624,'content':'','isDir':!![]}),_0x853063[_0x4cb494(0x170)]({'path':_0x257f6b,'content':_0x300ba4}),_0x853063[_0x4cb494(0x170)]({'path':_0x355eab,'content':_0x5c38d6});_0x26625e&&_0x26625e[_0x4cb494(0x1a6)]('\x0a')&&_0x853063[_0x4cb494(0x170)]({'path':_0x3e5ecf,'content':_0x26625e});_0x51eb5f[_0x4cb494(0x18a)][_0x4cb494(0x170)]({'agentName':_0x516887[_0x4cb494(0x1f0)][_0x4cb494(0x1c0)],'outputPath':_0x2da624,'isNew':_0x225b8e,'hasChanges':_0x179276,'diff':_0x311caf}),_0x51eb5f[_0x4cb494(0x1f9)]['agents'][_0x4cb494(0x221)]++;if(_0x225b8e)_0x51eb5f['counts']['agents'][_0x4cb494(0x174)]++;else{if(_0x179276)_0x51eb5f[_0x4cb494(0x1f9)][_0x4cb494(0x18a)][_0x4cb494(0x1f5)]++;else _0x51eb5f[_0x4cb494(0x1f9)][_0x4cb494(0x18a)][_0x4cb494(0x1e7)]++;}}for(const _0x1754a5 of _0x4ef36e){if(_0x1754a5[_0x4cb494(0x1f0)][_0x4cb494(0x204)])continue;const _0x255f0c=_0x45d443['getUniqueName'](_0x1754a5[_0x4cb494(0x1f0)][_0x4cb494(0x1c0)]),_0x2f8e24=a86_0x2c35ae[_0x4cb494(0x165)](getKnowledgeBasesDir(_0xeb8902),_0x255f0c+_0x4cb494(0x212)),_0x278c50=apiKnowledgeBaseToYaml(_0x1754a5),_0x539a7a=toKnowledgeBaseYamlString(_0x278c50),_0xd25fa8=!a86_0x22a2ad[_0x4cb494(0x1f4)](_0x2f8e24);let _0x2124a3=_0xd25fa8,_0x372e74;if(!_0xd25fa8){const _0x1fbad7=a86_0x22a2ad[_0x4cb494(0x194)](_0x2f8e24,_0x4cb494(0x1e6)),_0x626ebc=generateDiff(_0x1fbad7,_0x539a7a);_0x2124a3=hasChanges(_0x626ebc),_0x2124a3&&(_0x372e74=formatDiffWithColors(_0x626ebc));}_0x853063[_0x4cb494(0x170)]({'path':_0x2f8e24,'content':_0x539a7a}),_0x51eb5f[_0x4cb494(0x161)][_0x4cb494(0x170)]({'name':_0x1754a5['attributes'][_0x4cb494(0x1c0)],'outputPath':_0x2f8e24,'isNew':_0xd25fa8,'hasChanges':_0x2124a3,'diff':_0x372e74}),_0x51eb5f['counts'][_0x4cb494(0x161)][_0x4cb494(0x221)]++;if(_0xd25fa8)_0x51eb5f[_0x4cb494(0x1f9)][_0x4cb494(0x161)]['new']++;else{if(_0x2124a3)_0x51eb5f['counts'][_0x4cb494(0x161)]['updated']++;else _0x51eb5f[_0x4cb494(0x1f9)]['knowledgeBases']['unchanged']++;}}for(const _0x3f50da of _0x488e36){if(_0x3f50da[_0x4cb494(0x1f0)]['isManaged'])continue;const _0x3a14bd=_0x549764['getUniqueName'](_0x3f50da['attributes'][_0x4cb494(0x1c0)]),_0x5d71ec=a86_0x2c35ae['join'](getKnowledgeBasesDir(_0xeb8902),_0x3a14bd+'.md'),_0x267f6c=toTextKnowledgeBaseMd(_0x3f50da[_0x4cb494(0x1f0)][_0x4cb494(0x1c0)],_0x3f50da[_0x4cb494(0x1f0)][_0x4cb494(0x201)]),_0x4383e6=!a86_0x22a2ad['existsSync'](_0x5d71ec);let _0x43eddf=_0x4383e6,_0x2a4ea9;if(!_0x4383e6){const _0x2a9d45=a86_0x22a2ad[_0x4cb494(0x194)](_0x5d71ec,'utf-8'),_0x1f4e39=generateDiff(_0x2a9d45,_0x267f6c);_0x43eddf=hasChanges(_0x1f4e39),_0x43eddf&&(_0x2a4ea9=formatDiffWithColors(_0x1f4e39));}_0x853063[_0x4cb494(0x170)]({'path':_0x5d71ec,'content':_0x267f6c}),_0x51eb5f['textKnowledgeBases']['push']({'name':_0x3f50da[_0x4cb494(0x1f0)][_0x4cb494(0x1c0)],'outputPath':_0x5d71ec,'isNew':_0x4383e6,'hasChanges':_0x43eddf,'diff':_0x2a4ea9}),_0x51eb5f['counts']['textKnowledgeBases'][_0x4cb494(0x221)]++;if(_0x4383e6)_0x51eb5f[_0x4cb494(0x1f9)]['textKnowledgeBases'][_0x4cb494(0x174)]++;else{if(_0x43eddf)_0x51eb5f['counts']['textKnowledgeBases'][_0x4cb494(0x1f5)]++;else _0x51eb5f[_0x4cb494(0x1f9)][_0x4cb494(0x1a5)][_0x4cb494(0x1e7)]++;}}for(const _0x17726f of _0x581714){if(_0x17726f['attributes']['isManaged'])continue;const _0x4d3ee1=_0x3f4c9f[_0x4cb494(0x213)](_0x17726f[_0x4cb494(0x1f0)]['name']),_0x1c610d=a86_0x2c35ae[_0x4cb494(0x165)](getPromptsDir(_0xeb8902),_0x4d3ee1+_0x4cb494(0x212)),_0x4784a4=await apiPromptToYaml(_0x17726f,_0x178735);if(!_0x4784a4)continue;const _0x3b3bf7=toPromptYamlString(_0x4784a4),_0x401ecb=!a86_0x22a2ad[_0x4cb494(0x1f4)](_0x1c610d);let _0x397c2a=_0x401ecb,_0x33ecba;if(!_0x401ecb){const _0x4323c0=a86_0x22a2ad[_0x4cb494(0x194)](_0x1c610d,_0x4cb494(0x1e6)),_0x38e030=generateDiff(_0x4323c0,_0x3b3bf7);_0x397c2a=hasChanges(_0x38e030),_0x397c2a&&(_0x33ecba=formatDiffWithColors(_0x38e030));}_0x853063[_0x4cb494(0x170)]({'path':_0x1c610d,'content':_0x3b3bf7}),_0x51eb5f['prompts']['push']({'name':_0x17726f['attributes'][_0x4cb494(0x1c0)],'outputPath':_0x1c610d,'isNew':_0x401ecb,'hasChanges':_0x397c2a,'diff':_0x33ecba}),_0x51eb5f[_0x4cb494(0x1f9)][_0x4cb494(0x1e0)][_0x4cb494(0x221)]++;if(_0x401ecb)_0x51eb5f['counts'][_0x4cb494(0x1e0)]['new']++;else{if(_0x397c2a)_0x51eb5f[_0x4cb494(0x1f9)][_0x4cb494(0x1e0)]['updated']++;else _0x51eb5f[_0x4cb494(0x1f9)][_0x4cb494(0x1e0)][_0x4cb494(0x1e7)]++;}}if(_0x4bec6d?.['dryRun'])return _0x51eb5f;a86_0x22a2ad[_0x4cb494(0x217)](_0xeb8902,{'recursive':!![]}),a86_0x22a2ad[_0x4cb494(0x217)](getKnowledgeBasesDir(_0xeb8902),{'recursive':!![]}),a86_0x22a2ad[_0x4cb494(0x217)](getPromptsDir(_0xeb8902),{'recursive':!![]});const _0x1c3937=a86_0x2c35ae[_0x4cb494(0x165)](_0xeb8902,_0x4cb494(0x173));a86_0x22a2ad['writeFileSync'](_0x1c3937,createAgentConfigContent(_0x397f7d));for(const _0x39890a of _0x853063){if(_0x39890a[_0x4cb494(0x19d)])a86_0x22a2ad[_0x4cb494(0x217)](_0x39890a[_0x4cb494(0x15f)],{'recursive':!![]});else{const _0x44d6cc=a86_0x2c35ae['dirname'](_0x39890a[_0x4cb494(0x15f)]);!a86_0x22a2ad[_0x4cb494(0x1f4)](_0x44d6cc)&&a86_0x22a2ad['mkdirSync'](_0x44d6cc,{'recursive':!![]}),a86_0x22a2ad[_0x4cb494(0x227)](_0x39890a[_0x4cb494(0x15f)],_0x39890a[_0x4cb494(0x224)]);}}return _0x51eb5f;}async['pushProject'](_0x4215ca,_0x1b4f0f){const _0x4ac4e1=a86_0x2458fb,_0x9d894=a86_0x2c35ae[_0x4ac4e1(0x165)](_0x4215ca,_0x4ac4e1(0x173));if(!a86_0x22a2ad[_0x4ac4e1(0x1f4)](_0x9d894))throw new SDKError(ErrorCode['INVALID_ARGUMENT'],_0x4ac4e1(0x1f3)+_0x4215ca,undefined,{'helpText':'Run\x20\x27tdx\x20agent\x20pull\x20<project>\x27\x20first\x20to\x20create\x20the\x20folder\x20structure.'});const _0x423519=loadAgentConfig(_0x9d894),_0x1d031b=await this[_0x4ac4e1(0x156)](_0x423519[_0x4ac4e1(0x220)]),_0xa3feb0=await this[_0x4ac4e1(0x1ab)]['getProject'](_0x1d031b),_0x1504ee=_0xa3feb0['attributes'][_0x4ac4e1(0x1c0)],_0x5108cf={'projectName':_0x1504ee,'projectId':_0x1d031b,'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}}},_0x3a2b08=[],_0x24fda2=[],_0x18a7de=[],_0x16250=[],_0x4c4a60=a86_0x22a2ad[_0x4ac4e1(0x1ea)](_0x4215ca,{'withFileTypes':!![]});for(const _0x4f3659 of _0x4c4a60){if(!_0x4f3659[_0x4ac4e1(0x226)]())continue;if([_0x4ac4e1(0x19e),_0x4ac4e1(0x1e0),_0x4ac4e1(0x178)][_0x4ac4e1(0x1a6)](_0x4f3659[_0x4ac4e1(0x1c0)]))continue;const _0x2d2f9e=a86_0x2c35ae[_0x4ac4e1(0x165)](_0x4215ca,_0x4f3659['name']);if(isAgentDir(_0x2d2f9e)){const _0x433ab8=a86_0x2c35ae[_0x4ac4e1(0x165)](_0x2d2f9e,'agent.yml'),_0x33494e=a86_0x2c35ae[_0x4ac4e1(0x165)](_0x2d2f9e,_0x4ac4e1(0x21f)),_0x46109a=a86_0x2c35ae[_0x4ac4e1(0x165)](_0x2d2f9e,_0x4ac4e1(0x20b)),_0x3ff0b2=parseAgentYaml(a86_0x22a2ad[_0x4ac4e1(0x194)](_0x433ab8,_0x4ac4e1(0x1e6)),_0x433ab8),_0x503b31=a86_0x22a2ad[_0x4ac4e1(0x1f4)](_0x33494e)?a86_0x22a2ad[_0x4ac4e1(0x194)](_0x33494e,_0x4ac4e1(0x1e6)):'',_0x2b26a5=a86_0x22a2ad[_0x4ac4e1(0x1f4)](_0x46109a)?a86_0x22a2ad[_0x4ac4e1(0x194)](_0x46109a,_0x4ac4e1(0x1e6)):_0x3ff0b2[_0x4ac4e1(0x1b2)];_0x3a2b08[_0x4ac4e1(0x170)]({'name':_0x3ff0b2[_0x4ac4e1(0x1c0)],'dir':_0x2d2f9e,'yaml':_0x3ff0b2,'systemPrompt':_0x503b31,'starterMessage':_0x2b26a5});}}const _0x33688a=getKnowledgeBasesDir(_0x4215ca);if(a86_0x22a2ad['existsSync'](_0x33688a)){const _0x474b3a=a86_0x22a2ad[_0x4ac4e1(0x1ea)](_0x33688a);for(const _0x3f67d7 of _0x474b3a){const _0x308734=a86_0x2c35ae[_0x4ac4e1(0x165)](_0x33688a,_0x3f67d7);if(_0x3f67d7[_0x4ac4e1(0x16d)](_0x4ac4e1(0x212))){const _0x459f61=parseKnowledgeBaseYaml(a86_0x22a2ad['readFileSync'](_0x308734,'utf-8'),_0x308734);_0x24fda2[_0x4ac4e1(0x170)]({'name':_0x459f61[_0x4ac4e1(0x1c0)],'path':_0x308734,'yaml':_0x459f61});}else{if(_0x3f67d7[_0x4ac4e1(0x16d)](_0x4ac4e1(0x1df))){const _0x588f3d=a86_0x22a2ad[_0x4ac4e1(0x194)](_0x308734,_0x4ac4e1(0x1e6)),{name:_0x2eaf90,text:_0x38f361}=parseTextKnowledgeBaseMd(_0x588f3d,_0x3f67d7);_0x18a7de[_0x4ac4e1(0x170)]({'name':_0x2eaf90,'path':_0x308734,'text':_0x38f361});}}}}const _0x3997e9=getPromptsDir(_0x4215ca);if(a86_0x22a2ad[_0x4ac4e1(0x1f4)](_0x3997e9)){const _0x3fefd3=a86_0x22a2ad['readdirSync'](_0x3997e9)['filter'](_0x5e89c4=>_0x5e89c4['endsWith'](_0x4ac4e1(0x212)));for(const _0x4997d5 of _0x3fefd3){const _0x435d1e=a86_0x2c35ae[_0x4ac4e1(0x165)](_0x3997e9,_0x4997d5),_0x36528a=parsePromptYaml(a86_0x22a2ad[_0x4ac4e1(0x194)](_0x435d1e,_0x4ac4e1(0x1e6)),_0x435d1e);_0x16250[_0x4ac4e1(0x170)]({'name':_0x36528a['name'],'path':_0x435d1e,'yaml':_0x36528a});}}const _0x18e036=await this[_0x4ac4e1(0x1ab)][_0x4ac4e1(0x182)](_0x1d031b),_0x334625=await this[_0x4ac4e1(0x1ab)][_0x4ac4e1(0x1cf)](_0x1d031b),_0x1ee2cc=await this[_0x4ac4e1(0x1ab)][_0x4ac4e1(0x160)](_0x1d031b),_0x498b74=await this['client'][_0x4ac4e1(0x191)](_0x1d031b),_0x528516=await this['client'][_0x4ac4e1(0x199)](_0x1d031b),_0x16be68=await this[_0x4ac4e1(0x1ab)][_0x4ac4e1(0x206)](_0x1d031b),_0xc244df=new Map(),_0x4ec443=new Map(),_0xd08b36=new Map(),_0x506ca0=new Map();for(const _0x29009b of _0x18e036){_0xc244df[_0x4ac4e1(0x1c5)](_0x29009b[_0x4ac4e1(0x1f0)]['name'],_0x29009b);}for(const _0x5b2c8b of _0x334625){_0x4ec443[_0x4ac4e1(0x1c5)](_0x5b2c8b['attributes']['name'],_0x5b2c8b);}for(const _0x36cba7 of _0x1ee2cc){_0xd08b36[_0x4ac4e1(0x1c5)](_0x36cba7[_0x4ac4e1(0x1f0)][_0x4ac4e1(0x1c0)],_0x36cba7);}for(const _0x245a98 of _0x16be68){_0x506ca0[_0x4ac4e1(0x1c5)](_0x245a98[_0x4ac4e1(0x1f0)][_0x4ac4e1(0x1c0)],_0x245a98);}const _0x159179=new Map(),_0x21fb06=new Map(),_0x3f0f14=new Map(),_0x235ce8=new Map(),_0x12826b=new Map(),_0x339be2=new Map(),_0x2a7128=new Map(),_0x5be72d=new Map(),_0x2040c0=new Map(),_0x46beb7=new Map(),_0x3b8627=new Map(),_0x40a9e2=new Map();for(const _0x59e11a of _0x334625){_0x159179[_0x4ac4e1(0x1c5)](_0x59e11a['attributes'][_0x4ac4e1(0x1c0)],_0x59e11a['id']),_0x2a7128[_0x4ac4e1(0x1c5)](_0x59e11a['id'],_0x59e11a[_0x4ac4e1(0x1f0)][_0x4ac4e1(0x1c0)]);}for(const _0x341791 of _0x1ee2cc){_0x21fb06[_0x4ac4e1(0x1c5)](_0x341791[_0x4ac4e1(0x1f0)]['name'],_0x341791['id']),_0x5be72d[_0x4ac4e1(0x1c5)](_0x341791['id'],_0x341791[_0x4ac4e1(0x1f0)]['name']);}for(const _0x4f99e8 of _0x18e036){_0x3f0f14[_0x4ac4e1(0x1c5)](_0x4f99e8[_0x4ac4e1(0x1f0)][_0x4ac4e1(0x1c0)],_0x4f99e8['id']),_0x2040c0[_0x4ac4e1(0x1c5)](_0x4f99e8['id'],_0x4f99e8['attributes'][_0x4ac4e1(0x1c0)]);}for(const _0x14ef35 of _0x498b74){_0x235ce8[_0x4ac4e1(0x1c5)](_0x14ef35[_0x4ac4e1(0x1f0)][_0x4ac4e1(0x1c0)],_0x14ef35['id']),_0x46beb7[_0x4ac4e1(0x1c5)](_0x14ef35['id'],_0x14ef35[_0x4ac4e1(0x1f0)][_0x4ac4e1(0x1c0)]);}for(const _0x3f7a35 of _0x528516){_0x12826b['set'](_0x3f7a35[_0x4ac4e1(0x1f0)]['name'],_0x3f7a35['id']),_0x3b8627[_0x4ac4e1(0x1c5)](_0x3f7a35['id'],_0x3f7a35[_0x4ac4e1(0x1f0)]['name']);}for(const _0x1e1caa of _0x16be68){_0x339be2['set'](_0x1e1caa['attributes']['name'],_0x1e1caa['id']),_0x40a9e2['set'](_0x1e1caa['id'],_0x1e1caa[_0x4ac4e1(0x1f0)]['name']);}const _0x507968={'resolveKnowledgeBaseName':async _0x8349a2=>_0x2a7128['get'](_0x8349a2),'resolveTextKnowledgeBaseName':async _0x403579=>_0x5be72d['get'](_0x403579),'resolveAgentName':async _0x1dbbf9=>_0x2040c0[_0x4ac4e1(0x183)](_0x1dbbf9),'resolveWebSearchToolName':async _0x283ed9=>_0x3b8627[_0x4ac4e1(0x183)](_0x283ed9),'resolveImageGeneratorName':async _0x4657a5=>_0x46beb7[_0x4ac4e1(0x183)](_0x4657a5),'resolvePromptName':async _0x847771=>_0x40a9e2['get'](_0x847771),'onWarning':_0x1af06d=>this[_0x4ac4e1(0x193)][_0x4ac4e1(0x1ff)]?.[_0x4ac4e1(0x17d)](_0x1af06d)},_0x4897ac={'projectId':_0x1d031b,'resolveKnowledgeBaseId':async _0x14273c=>_0x159179[_0x4ac4e1(0x183)](_0x14273c),'resolveTextKnowledgeBaseId':async _0x41b141=>_0x21fb06[_0x4ac4e1(0x183)](_0x41b141),'resolveAgentId':async _0x51f3f3=>_0x3f0f14[_0x4ac4e1(0x183)](_0x51f3f3),'resolveWebSearchToolId':async _0x516da8=>_0x12826b[_0x4ac4e1(0x183)](_0x516da8),'resolveImageGeneratorId':async _0x2363e4=>_0x235ce8['get'](_0x2363e4),'resolvePromptId':async _0x22a02c=>_0x339be2[_0x4ac4e1(0x183)](_0x22a02c),'onWarning':_0x24e235=>this['context'][_0x4ac4e1(0x1ff)]?.[_0x4ac4e1(0x17d)](_0x24e235)},{resolved:_0x4190d1,unresolved:_0x39cbcf}=resolveAgentDependencies(_0x3a2b08,new Set(_0xc244df[_0x4ac4e1(0x20e)]()));for(const {agent:_0x206a40,missingDeps:_0xb38bec}of _0x39cbcf){_0x5108cf['agents']['push']({'agentName':_0x206a40['yaml'][_0x4ac4e1(0x1c0)],'action':_0x4ac4e1(0x1e9),'error':'Unresolved\x20dependencies:\x20'+_0xb38bec[_0x4ac4e1(0x165)](',\x20')+'.\x20Check\x20for\x20circular\x20references\x20or\x20missing\x20agents.'}),_0x5108cf[_0x4ac4e1(0x1f9)][_0x4ac4e1(0x18a)][_0x4ac4e1(0x202)]++;}for(const _0x4e4997 of _0x24fda2){const _0x48a2e4=_0x4ec443['get'](_0x4e4997['yaml'][_0x4ac4e1(0x1c0)]),_0x8481b=a86_0x22a2ad['readFileSync'](_0x4e4997[_0x4ac4e1(0x15f)],_0x4ac4e1(0x1e6));if(_0x48a2e4){const _0x37418b=apiKnowledgeBaseToYaml(_0x48a2e4),_0x34ef17=toKnowledgeBaseYamlString(_0x37418b),_0x27fac2=generateDiff(_0x34ef17,_0x8481b),_0x566192=hasChanges(_0x27fac2);_0x566192?(_0x5108cf[_0x4ac4e1(0x161)][_0x4ac4e1(0x170)]({'name':_0x4e4997['yaml'][_0x4ac4e1(0x1c0)],'action':_0x4ac4e1(0x1f5),'id':_0x48a2e4['id'],'diff':formatDiffWithColors(_0x27fac2)}),_0x5108cf[_0x4ac4e1(0x1f9)][_0x4ac4e1(0x161)]['updated']++):(_0x5108cf[_0x4ac4e1(0x161)][_0x4ac4e1(0x170)]({'name':_0x4e4997['yaml'][_0x4ac4e1(0x1c0)],'action':'unchanged','id':_0x48a2e4['id']}),_0x5108cf[_0x4ac4e1(0x1f9)][_0x4ac4e1(0x161)][_0x4ac4e1(0x1e7)]++);}else _0x5108cf[_0x4ac4e1(0x161)][_0x4ac4e1(0x170)]({'name':_0x4e4997[_0x4ac4e1(0x20f)][_0x4ac4e1(0x1c0)],'action':'created'}),_0x5108cf['counts']['knowledgeBases']['created']++;}for(const _0x837cae of _0x18a7de){const _0x33e95f=_0xd08b36['get'](_0x837cae[_0x4ac4e1(0x1c0)]),_0x10d82d=a86_0x22a2ad[_0x4ac4e1(0x194)](_0x837cae[_0x4ac4e1(0x15f)],_0x4ac4e1(0x1e6));if(_0x33e95f){const _0x31b583=toTextKnowledgeBaseMd(_0x33e95f['attributes'][_0x4ac4e1(0x1c0)],_0x33e95f[_0x4ac4e1(0x1f0)][_0x4ac4e1(0x201)]),_0x392138=generateDiff(_0x31b583,_0x10d82d),_0x27f9c5=hasChanges(_0x392138);_0x27f9c5?(_0x5108cf[_0x4ac4e1(0x1a5)][_0x4ac4e1(0x170)]({'name':_0x837cae[_0x4ac4e1(0x1c0)],'action':_0x4ac4e1(0x1f5),'id':_0x33e95f['id'],'diff':formatDiffWithColors(_0x392138)}),_0x5108cf['counts'][_0x4ac4e1(0x1a5)][_0x4ac4e1(0x1f5)]++):(_0x5108cf['textKnowledgeBases']['push']({'name':_0x837cae[_0x4ac4e1(0x1c0)],'action':_0x4ac4e1(0x1e7),'id':_0x33e95f['id']}),_0x5108cf['counts'][_0x4ac4e1(0x1a5)][_0x4ac4e1(0x1e7)]++);}else _0x5108cf[_0x4ac4e1(0x1a5)][_0x4ac4e1(0x170)]({'name':_0x837cae[_0x4ac4e1(0x1c0)],'action':_0x4ac4e1(0x1cb)}),_0x5108cf[_0x4ac4e1(0x1f9)]['textKnowledgeBases'][_0x4ac4e1(0x1cb)]++;}for(const _0x5d30a9 of _0x4190d1){const _0x26dc29=_0xc244df[_0x4ac4e1(0x183)](_0x5d30a9['yaml'][_0x4ac4e1(0x1c0)]),_0x2e07db=a86_0x2c35ae[_0x4ac4e1(0x165)](_0x5d30a9[_0x4ac4e1(0x1dc)],_0x4ac4e1(0x1c7)),_0xef6cde=a86_0x22a2ad[_0x4ac4e1(0x194)](_0x2e07db,'utf-8'),_0x4053d1=_0x5d30a9[_0x4ac4e1(0x1bf)],_0x50af06=_0x4ac4e1(0x1c3)+_0x4053d1+_0x4ac4e1(0x20a)+_0xef6cde;if(_0x26dc29){const {yaml:_0x4ab5d8,systemPrompt:_0x4b881a}=await agentResponseToDef(_0x26dc29,_0x507968),_0x47f921=toAgentYamlString(_0x4ab5d8),_0x54acd4=_0x4ac4e1(0x1c3)+_0x4b881a+'\x0a\x0a#\x20agent.yml\x0a'+_0x47f921,_0x4eb37d=generateDiff(_0x54acd4,_0x50af06),_0x1368f3=hasChanges(_0x4eb37d);_0x1368f3?(_0x5108cf[_0x4ac4e1(0x18a)][_0x4ac4e1(0x170)]({'agentName':_0x5d30a9[_0x4ac4e1(0x20f)]['name'],'action':_0x4ac4e1(0x1f5),'agentId':_0x26dc29['id'],'diff':formatDiffWithColors(_0x4eb37d)}),_0x5108cf['counts'][_0x4ac4e1(0x18a)][_0x4ac4e1(0x1f5)]++):(_0x5108cf['agents'][_0x4ac4e1(0x170)]({'agentName':_0x5d30a9[_0x4ac4e1(0x20f)]['name'],'action':_0x4ac4e1(0x1e7),'agentId':_0x26dc29['id']}),_0x5108cf[_0x4ac4e1(0x1f9)][_0x4ac4e1(0x18a)][_0x4ac4e1(0x1e7)]++);}else _0x5108cf[_0x4ac4e1(0x18a)][_0x4ac4e1(0x170)]({'agentName':_0x5d30a9[_0x4ac4e1(0x20f)][_0x4ac4e1(0x1c0)],'action':_0x4ac4e1(0x1cb)}),_0x5108cf[_0x4ac4e1(0x1f9)][_0x4ac4e1(0x18a)][_0x4ac4e1(0x1cb)]++;}for(const _0x1f03bb of _0x16250){const _0x3a608f=_0x506ca0[_0x4ac4e1(0x183)](_0x1f03bb[_0x4ac4e1(0x20f)][_0x4ac4e1(0x1c0)]),_0x4053fe=a86_0x22a2ad[_0x4ac4e1(0x194)](_0x1f03bb[_0x4ac4e1(0x15f)],_0x4ac4e1(0x1e6));if(_0x3a608f){const _0x14c68b=await apiPromptToYaml(_0x3a608f,_0x507968);if(!_0x14c68b){_0x5108cf[_0x4ac4e1(0x1e0)][_0x4ac4e1(0x170)]({'name':_0x1f03bb[_0x4ac4e1(0x20f)]['name'],'action':'updated','id':_0x3a608f['id']}),_0x5108cf[_0x4ac4e1(0x1f9)][_0x4ac4e1(0x1e0)][_0x4ac4e1(0x1f5)]++;continue;}const _0x3be472=toPromptYamlString(_0x14c68b),_0xf87800=generateDiff(_0x3be472,_0x4053fe),_0x47c7cb=hasChanges(_0xf87800);_0x47c7cb?(_0x5108cf[_0x4ac4e1(0x1e0)]['push']({'name':_0x1f03bb[_0x4ac4e1(0x20f)][_0x4ac4e1(0x1c0)],'action':'updated','id':_0x3a608f['id'],'diff':formatDiffWithColors(_0xf87800)}),_0x5108cf['counts'][_0x4ac4e1(0x1e0)][_0x4ac4e1(0x1f5)]++):(_0x5108cf['prompts']['push']({'name':_0x1f03bb[_0x4ac4e1(0x20f)]['name'],'action':_0x4ac4e1(0x1e7),'id':_0x3a608f['id']}),_0x5108cf['counts']['prompts'][_0x4ac4e1(0x1e7)]++);}else _0x5108cf[_0x4ac4e1(0x1e0)][_0x4ac4e1(0x170)]({'name':_0x1f03bb[_0x4ac4e1(0x20f)]['name'],'action':_0x4ac4e1(0x1cb)}),_0x5108cf[_0x4ac4e1(0x1f9)][_0x4ac4e1(0x1e0)][_0x4ac4e1(0x1cb)]++;}if(_0x1b4f0f?.['dryRun'])return _0x5108cf;_0x5108cf[_0x4ac4e1(0x161)]=[],_0x5108cf[_0x4ac4e1(0x1a5)]=[],_0x5108cf['prompts']=[];const _0x28a34c=_0x5108cf[_0x4ac4e1(0x18a)][_0x4ac4e1(0x15b)](_0xafe15=>_0xafe15[_0x4ac4e1(0x1b3)]===_0x4ac4e1(0x1e9));_0x5108cf['agents']=_0x28a34c,_0x5108cf[_0x4ac4e1(0x1f9)]={'agents':{'created':0x0,'updated':0x0,'unchanged':0x0,'errors':_0x28a34c['length']},'knowledgeBases':{'created':0x0,'updated':0x0,'unchanged':0x0,'errors':0x0},'textKnowledgeBases':{'created':0x0,'updated':0x0,'unchanged':0x0,'errors':0x0},'prompts':{'created':0x0,'updated':0x0,'unchanged':0x0,'errors':0x0}};for(const _0x37eca8 of _0x24fda2){try{const _0x54ad0f=_0x4ec443[_0x4ac4e1(0x183)](_0x37eca8[_0x4ac4e1(0x20f)][_0x4ac4e1(0x1c0)]),_0x4a153f=yamlKnowledgeBaseToApi(_0x37eca8[_0x4ac4e1(0x20f)],_0x1d031b);if(_0x54ad0f)await this[_0x4ac4e1(0x1ab)][_0x4ac4e1(0x1db)](_0x54ad0f['id'],_0x4a153f),_0x159179[_0x4ac4e1(0x1c5)](_0x37eca8[_0x4ac4e1(0x20f)]['name'],_0x54ad0f['id']),_0x5108cf[_0x4ac4e1(0x161)][_0x4ac4e1(0x170)]({'name':_0x37eca8[_0x4ac4e1(0x20f)]['name'],'action':_0x4ac4e1(0x1f5),'id':_0x54ad0f['id']}),_0x5108cf[_0x4ac4e1(0x1f9)][_0x4ac4e1(0x161)]['updated']++;else{const _0x28d513=await this[_0x4ac4e1(0x1ab)]['createKnowledgeBase'](_0x4a153f);_0x159179['set'](_0x37eca8[_0x4ac4e1(0x20f)][_0x4ac4e1(0x1c0)],_0x28d513['id']),_0x5108cf['knowledgeBases']['push']({'name':_0x37eca8[_0x4ac4e1(0x20f)][_0x4ac4e1(0x1c0)],'action':_0x4ac4e1(0x1cb),'id':_0x28d513['id']}),_0x5108cf[_0x4ac4e1(0x1f9)]['knowledgeBases'][_0x4ac4e1(0x1cb)]++;}}catch(_0xa87ed){_0x5108cf[_0x4ac4e1(0x161)]['push']({'name':_0x37eca8['yaml'][_0x4ac4e1(0x1c0)],'action':_0x4ac4e1(0x1e9),'error':_0xa87ed[_0x4ac4e1(0x169)]}),_0x5108cf[_0x4ac4e1(0x1f9)][_0x4ac4e1(0x161)][_0x4ac4e1(0x202)]++;}}for(const _0x509c76 of _0x18a7de){try{const _0x19919a=_0xd08b36['get'](_0x509c76[_0x4ac4e1(0x1c0)]),_0x8d58c1=yamlTextKnowledgeBaseToApi({'name':_0x509c76[_0x4ac4e1(0x1c0)],'text':_0x509c76['text']},_0x1d031b);if(_0x19919a)await this[_0x4ac4e1(0x1ab)][_0x4ac4e1(0x21d)](_0x19919a['id'],_0x8d58c1),_0x21fb06['set'](_0x509c76[_0x4ac4e1(0x1c0)],_0x19919a['id']),_0x5108cf[_0x4ac4e1(0x1a5)][_0x4ac4e1(0x170)]({'name':_0x509c76['name'],'action':_0x4ac4e1(0x1f5),'id':_0x19919a['id']}),_0x5108cf[_0x4ac4e1(0x1f9)]['textKnowledgeBases'][_0x4ac4e1(0x1f5)]++;else{const _0x4a6d47=await this[_0x4ac4e1(0x1ab)]['createTextKnowledgeBase'](_0x8d58c1);_0x21fb06[_0x4ac4e1(0x1c5)](_0x509c76['name'],_0x4a6d47['id']),_0x5108cf[_0x4ac4e1(0x1a5)]['push']({'name':_0x509c76[_0x4ac4e1(0x1c0)],'action':_0x4ac4e1(0x1cb),'id':_0x4a6d47['id']}),_0x5108cf['counts'][_0x4ac4e1(0x1a5)][_0x4ac4e1(0x1cb)]++;}}catch(_0x2d1af9){_0x5108cf[_0x4ac4e1(0x1a5)]['push']({'name':_0x509c76[_0x4ac4e1(0x1c0)],'action':'error','error':_0x2d1af9[_0x4ac4e1(0x169)]}),_0x5108cf['counts']['textKnowledgeBases']['errors']++;}}for(const _0x4e1c6a of _0x4190d1){try{const _0x502bc7=_0xc244df[_0x4ac4e1(0x183)](_0x4e1c6a[_0x4ac4e1(0x20f)]['name']),_0x135c6d=await agentDefToRequest(_0x4e1c6a[_0x4ac4e1(0x20f)],_0x4e1c6a[_0x4ac4e1(0x1bf)],_0x4e1c6a[_0x4ac4e1(0x1f8)],_0x4897ac);if(_0x502bc7)await this[_0x4ac4e1(0x1ab)][_0x4ac4e1(0x21a)](_0x502bc7['id'],_0x135c6d),_0x3f0f14[_0x4ac4e1(0x1c5)](_0x4e1c6a[_0x4ac4e1(0x20f)][_0x4ac4e1(0x1c0)],_0x502bc7['id']),_0x5108cf[_0x4ac4e1(0x18a)][_0x4ac4e1(0x170)]({'agentName':_0x4e1c6a[_0x4ac4e1(0x20f)][_0x4ac4e1(0x1c0)],'action':_0x4ac4e1(0x1f5),'agentId':_0x502bc7['id']}),_0x5108cf['counts']['agents']['updated']++;else{const _0x185739=await this['client'][_0x4ac4e1(0x1ec)](_0x135c6d);_0x3f0f14[_0x4ac4e1(0x1c5)](_0x4e1c6a[_0x4ac4e1(0x20f)]['name'],_0x185739['id']),_0x5108cf[_0x4ac4e1(0x18a)]['push']({'agentName':_0x4e1c6a['yaml'][_0x4ac4e1(0x1c0)],'action':_0x4ac4e1(0x1cb),'agentId':_0x185739['id']}),_0x5108cf['counts']['agents'][_0x4ac4e1(0x1cb)]++;}}catch(_0x46d5be){_0x5108cf['agents'][_0x4ac4e1(0x170)]({'agentName':_0x4e1c6a[_0x4ac4e1(0x20f)][_0x4ac4e1(0x1c0)],'action':_0x4ac4e1(0x1e9),'error':_0x46d5be[_0x4ac4e1(0x169)]}),_0x5108cf[_0x4ac4e1(0x1f9)][_0x4ac4e1(0x18a)][_0x4ac4e1(0x202)]++;}}for(const _0x3721cb of _0x16250){try{const _0x5f0ca8=_0x506ca0['get'](_0x3721cb[_0x4ac4e1(0x20f)][_0x4ac4e1(0x1c0)]),_0x86f7b2=await yamlPromptToApi(_0x3721cb[_0x4ac4e1(0x20f)],_0x1d031b,_0x4897ac);if(!_0x86f7b2){_0x5108cf['prompts'][_0x4ac4e1(0x170)]({'name':_0x3721cb[_0x4ac4e1(0x20f)][_0x4ac4e1(0x1c0)],'action':_0x4ac4e1(0x1e9),'error':_0x4ac4e1(0x1ad)}),_0x5108cf['counts'][_0x4ac4e1(0x1e0)][_0x4ac4e1(0x202)]++;continue;}if(_0x5f0ca8)await this[_0x4ac4e1(0x1ab)]['updatePrompt'](_0x5f0ca8['id'],_0x86f7b2),_0x339be2[_0x4ac4e1(0x1c5)](_0x3721cb['yaml'][_0x4ac4e1(0x1c0)],_0x5f0ca8['id']),_0x5108cf['prompts'][_0x4ac4e1(0x170)]({'name':_0x3721cb[_0x4ac4e1(0x20f)][_0x4ac4e1(0x1c0)],'action':'updated','id':_0x5f0ca8['id']}),_0x5108cf['counts']['prompts'][_0x4ac4e1(0x1f5)]++;else{const _0x2bfd47=await this['client']['createPrompt'](_0x86f7b2);_0x339be2[_0x4ac4e1(0x1c5)](_0x3721cb['yaml']['name'],_0x2bfd47['id']),_0x5108cf[_0x4ac4e1(0x1e0)][_0x4ac4e1(0x170)]({'name':_0x3721cb['yaml'][_0x4ac4e1(0x1c0)],'action':_0x4ac4e1(0x1cb),'id':_0x2bfd47['id']}),_0x5108cf[_0x4ac4e1(0x1f9)][_0x4ac4e1(0x1e0)][_0x4ac4e1(0x1cb)]++;}}catch(_0x59e85a){_0x5108cf[_0x4ac4e1(0x1e0)]['push']({'name':_0x3721cb[_0x4ac4e1(0x20f)][_0x4ac4e1(0x1c0)],'action':_0x4ac4e1(0x1e9),'error':_0x59e85a[_0x4ac4e1(0x169)]}),_0x5108cf[_0x4ac4e1(0x1f9)][_0x4ac4e1(0x1e0)]['errors']++;}}return _0x5108cf;}async[a86_0x2458fb(0x215)](_0x5db38b,_0x1408c0,_0x46832f,_0x595cd7){const _0x2ac517=a86_0x2458fb,{projectId:_0x34dc9b,project:_0x4eda56}=await this[_0x2ac517(0x228)](_0x5db38b),_0x670504=_0x4eda56[_0x2ac517(0x1f0)][_0x2ac517(0x1c0)],_0x4faf74=await this[_0x2ac517(0x1ab)][_0x2ac517(0x182)](_0x34dc9b),_0x8fce17=_0x4faf74['find'](_0x96b940=>_0x96b940[_0x2ac517(0x1f0)][_0x2ac517(0x1c0)]===_0x1408c0);if(!_0x8fce17)throw new SDKError(ErrorCode['AGENT_NOT_FOUND'],_0x2ac517(0x18b)+_0x1408c0,undefined,{'helpText':_0x2ac517(0x1bd)+_0x4faf74[_0x2ac517(0x21c)](_0x5b8287=>_0x5b8287[_0x2ac517(0x1f0)][_0x2ac517(0x1c0)])[_0x2ac517(0x165)](',\x20')});const _0x3331c0=normalizeName(_0x670504),_0x2e47c9=normalizeName(_0x1408c0),_0x366bba=_0x46832f||a86_0x2c35ae['join'](process[_0x2ac517(0x1d7)](),'agents',_0x3331c0),_0x56fcb5=a86_0x2c35ae['join'](_0x366bba,_0x2e47c9),_0x3e4dc1=new Map(),_0xab9974=new Map(),_0x1db4af=await this[_0x2ac517(0x1ab)][_0x2ac517(0x1cf)](_0x34dc9b),_0x41e76f=await this['client']['listTextKnowledgeBases'](_0x34dc9b),_0x48f865=new Map();for(const _0x285cb5 of _0x1db4af){_0x3e4dc1[_0x2ac517(0x1c5)](_0x285cb5['id'],_0x285cb5['attributes'][_0x2ac517(0x1c0)]);}for(const _0xdc56c6 of _0x41e76f){_0x48f865[_0x2ac517(0x1c5)](_0xdc56c6['id'],_0xdc56c6['attributes'][_0x2ac517(0x1c0)]);}for(const _0x20bff4 of _0x4faf74){_0xab9974[_0x2ac517(0x1c5)](_0x20bff4['id'],_0x20bff4[_0x2ac517(0x1f0)][_0x2ac517(0x1c0)]);}const _0x44bf15={'resolveKnowledgeBaseName':async _0x4a65dd=>_0x3e4dc1[_0x2ac517(0x183)](_0x4a65dd),'resolveTextKnowledgeBaseName':async _0xbd2f60=>_0x48f865[_0x2ac517(0x183)](_0xbd2f60),'resolveAgentName':async _0x4d2d17=>_0xab9974['get'](_0x4d2d17),'resolveWebSearchToolName':async()=>undefined,'resolveImageGeneratorName':async()=>undefined,'resolvePromptName':async()=>undefined,'onWarning':_0x2e7cc2=>this[_0x2ac517(0x193)]['logger']?.[_0x2ac517(0x17d)](_0x2e7cc2)},_0x5c0569=a86_0x2c35ae[_0x2ac517(0x165)](_0x56fcb5,_0x2ac517(0x21f)),_0x3a14ae=a86_0x2c35ae['join'](_0x56fcb5,_0x2ac517(0x1c7)),_0x197012=a86_0x2c35ae['join'](_0x56fcb5,_0x2ac517(0x20b)),_0x2b7570=!a86_0x22a2ad[_0x2ac517(0x1f4)](_0x3a14ae);if(_0x595cd7?.['dryRun'])return{'agentName':_0x1408c0,'outputPath':_0x56fcb5,'isNew':_0x2b7570,'hasChanges':!![]};a86_0x22a2ad[_0x2ac517(0x217)](_0x366bba,{'recursive':!![]}),a86_0x22a2ad['mkdirSync'](_0x56fcb5,{'recursive':!![]});const _0x51ba98=a86_0x2c35ae[_0x2ac517(0x165)](_0x366bba,'tdx.json');!a86_0x22a2ad[_0x2ac517(0x1f4)](_0x51ba98)&&a86_0x22a2ad[_0x2ac517(0x227)](_0x51ba98,createAgentConfigContent(_0x5db38b));const {yaml:_0x5c9e39,systemPrompt:_0x733bd6,starterMessage:_0x348aa4}=await agentResponseToDef(_0x8fce17,_0x44bf15);let _0x24adbb=_0x2b7570;if(!_0x2b7570){const _0x2f1a12=a86_0x22a2ad[_0x2ac517(0x1f4)](_0x5c0569)?a86_0x22a2ad[_0x2ac517(0x194)](_0x5c0569,_0x2ac517(0x1e6)):'',_0x2de682=a86_0x22a2ad[_0x2ac517(0x194)](_0x3a14ae,_0x2ac517(0x1e6));_0x24adbb=_0x2f1a12!==_0x733bd6||_0x2de682!==toAgentYamlString(_0x5c9e39);}a86_0x22a2ad[_0x2ac517(0x227)](_0x5c0569,_0x733bd6),a86_0x22a2ad['writeFileSync'](_0x3a14ae,toAgentYamlString(_0x5c9e39));if(_0x348aa4&&_0x348aa4[_0x2ac517(0x1a6)]('\x0a'))a86_0x22a2ad[_0x2ac517(0x227)](_0x197012,_0x348aa4);else a86_0x22a2ad[_0x2ac517(0x1f4)](_0x197012)&&a86_0x22a2ad[_0x2ac517(0x17a)](_0x197012);return{'agentName':_0x1408c0,'outputPath':_0x56fcb5,'isNew':_0x2b7570,'hasChanges':_0x24adbb};}async[a86_0x2458fb(0x211)](_0x29f8e0,_0x19b745){const _0x3cf76e=a86_0x2458fb;let _0xb6972a;isAgentYamlPath(_0x29f8e0)?_0xb6972a=getAgentDirFromYamlPath(_0x29f8e0):_0xb6972a=_0x29f8e0;const {config:_0x321316}=findAgentConfig(_0xb6972a),_0x3389d4=await this[_0x3cf76e(0x156)](_0x321316[_0x3cf76e(0x220)]),_0x875600=a86_0x2c35ae[_0x3cf76e(0x165)](_0xb6972a,_0x3cf76e(0x1c7)),_0xba0dc2=a86_0x2c35ae[_0x3cf76e(0x165)](_0xb6972a,_0x3cf76e(0x21f)),_0x2ad08c=a86_0x2c35ae[_0x3cf76e(0x165)](_0xb6972a,'starter_message.md');if(!a86_0x22a2ad['existsSync'](_0x875600))throw new SDKError(ErrorCode[_0x3cf76e(0x1ac)],_0x3cf76e(0x1cc)+_0xb6972a,undefined,{'helpText':_0x3cf76e(0x1b7)});const _0xcb75b4=parseAgentYaml(a86_0x22a2ad[_0x3cf76e(0x194)](_0x875600,_0x3cf76e(0x1e6)),_0x875600),_0x5839a7=a86_0x22a2ad[_0x3cf76e(0x1f4)](_0xba0dc2)?a86_0x22a2ad[_0x3cf76e(0x194)](_0xba0dc2,_0x3cf76e(0x1e6)):'',_0x50c6c2=a86_0x22a2ad[_0x3cf76e(0x1f4)](_0x2ad08c)?a86_0x22a2ad[_0x3cf76e(0x194)](_0x2ad08c,_0x3cf76e(0x1e6)):_0xcb75b4[_0x3cf76e(0x1b2)];if(_0x19b745?.['dryRun'])return{'agentName':_0xcb75b4[_0x3cf76e(0x1c0)],'action':_0x3cf76e(0x1cb),'projectId':_0x3389d4};const _0x5593b8=await this[_0x3cf76e(0x1ab)][_0x3cf76e(0x182)](_0x3389d4),_0x1c9ca6=await this[_0x3cf76e(0x1ab)][_0x3cf76e(0x1cf)](_0x3389d4),_0x34cd7c=await this['client']['listTextKnowledgeBases'](_0x3389d4),_0x1616ea=new Map(),_0x9b0cb6=new Map(),_0xf2d308=new Map();for(const _0x5a74be of _0x1c9ca6){_0x1616ea['set'](_0x5a74be['attributes'][_0x3cf76e(0x1c0)],_0x5a74be['id']);}for(const _0x39777e of _0x34cd7c){_0x9b0cb6[_0x3cf76e(0x1c5)](_0x39777e['attributes'][_0x3cf76e(0x1c0)],_0x39777e['id']);}for(const _0x16e499 of _0x5593b8){_0xf2d308[_0x3cf76e(0x1c5)](_0x16e499[_0x3cf76e(0x1f0)][_0x3cf76e(0x1c0)],_0x16e499['id']);}const _0x4cca20={'projectId':_0x3389d4,'resolveKnowledgeBaseId':async _0x4d406c=>_0x1616ea[_0x3cf76e(0x183)](_0x4d406c),'resolveTextKnowledgeBaseId':async _0x2106bc=>_0x9b0cb6[_0x3cf76e(0x183)](_0x2106bc),'resolveAgentId':async _0x2b89c3=>_0xf2d308['get'](_0x2b89c3),'resolveWebSearchToolId':async()=>undefined,'resolveImageGeneratorId':async()=>undefined,'resolvePromptId':async()=>undefined,'onWarning':_0x408a80=>this[_0x3cf76e(0x193)][_0x3cf76e(0x1ff)]?.['warn'](_0x408a80)};try{const _0x38ad72=_0x5593b8[_0x3cf76e(0x167)](_0x1c4712=>_0x1c4712[_0x3cf76e(0x1f0)][_0x3cf76e(0x1c0)]===_0xcb75b4[_0x3cf76e(0x1c0)]),_0x408753=await agentDefToRequest(_0xcb75b4,_0x5839a7,_0x50c6c2,_0x4cca20);if(_0x38ad72)return await this['client'][_0x3cf76e(0x21a)](_0x38ad72['id'],_0x408753),{'agentName':_0xcb75b4['name'],'action':_0x3cf76e(0x1f5),'projectId':_0x3389d4,'agentId':_0x38ad72['id']};else{const _0x359173=await this['client'][_0x3cf76e(0x1ec)](_0x408753);return{'agentName':_0xcb75b4[_0x3cf76e(0x1c0)],'action':_0x3cf76e(0x1cb),'projectId':_0x3389d4,'agentId':_0x359173['id']};}}catch(_0x173330){return{'agentName':_0xcb75b4[_0x3cf76e(0x1c0)],'action':_0x3cf76e(0x1e9),'projectId':_0x3389d4,'error':_0x173330[_0x3cf76e(0x169)]};}}async[a86_0x2458fb(0x162)](_0x232c12,_0x23b831,_0x4c1049){const _0x295f29=a86_0x2458fb,_0x445ef9=a86_0x22a2ad['existsSync'](_0x232c12)&&a86_0x22a2ad[_0x295f29(0x1f4)](a86_0x2c35ae['join'](_0x232c12,_0x295f29(0x173)));let _0x1a7707;const _0x16f372=[],_0x45d600=[],_0x1aa2b9=[],_0x3a2343=[];if(_0x445ef9){const _0x1ae03c=loadAgentConfig(a86_0x2c35ae[_0x295f29(0x165)](_0x232c12,_0x295f29(0x173)));_0x1a7707=_0x1ae03c[_0x295f29(0x220)];const _0x4d81cd=a86_0x22a2ad[_0x295f29(0x1ea)](_0x232c12,{'withFileTypes':!![]});for(const _0x5d4f51 of _0x4d81cd){if(!_0x5d4f51[_0x295f29(0x226)]())continue;if(['knowledge_bases',_0x295f29(0x1e0),_0x295f29(0x178)][_0x295f29(0x1a6)](_0x5d4f51[_0x295f29(0x1c0)]))continue;const _0x28b5eb=a86_0x2c35ae[_0x295f29(0x165)](_0x232c12,_0x5d4f51[_0x295f29(0x1c0)]);if(isAgentDir(_0x28b5eb)){const _0x4bb36b=a86_0x2c35ae[_0x295f29(0x165)](_0x28b5eb,'agent.yml'),_0x43b72f=a86_0x2c35ae['join'](_0x28b5eb,_0x295f29(0x21f)),_0x220b40=a86_0x2c35ae[_0x295f29(0x165)](_0x28b5eb,_0x295f29(0x20b)),_0x4bb564=parseAgentYaml(a86_0x22a2ad[_0x295f29(0x194)](_0x4bb36b,_0x295f29(0x1e6)),_0x4bb36b),_0x9dbc69=a86_0x22a2ad[_0x295f29(0x1f4)](_0x43b72f)?a86_0x22a2ad[_0x295f29(0x194)](_0x43b72f,_0x295f29(0x1e6)):'',_0x4a77f8=a86_0x22a2ad[_0x295f29(0x1f4)](_0x220b40)?a86_0x22a2ad[_0x295f29(0x194)](_0x220b40,_0x295f29(0x1e6)):_0x4bb564[_0x295f29(0x1b2)];_0x16f372[_0x295f29(0x170)]({'name':_0x4bb564['name'],'dir':_0x28b5eb,'yaml':_0x4bb564,'systemPrompt':_0x9dbc69,'starterMessage':_0x4a77f8});}}const _0x9d54ac=getKnowledgeBasesDir(_0x232c12);if(a86_0x22a2ad[_0x295f29(0x1f4)](_0x9d54ac)){const _0x538349=a86_0x22a2ad[_0x295f29(0x1ea)](_0x9d54ac);for(const _0x162a84 of _0x538349){const _0x532a3b=a86_0x2c35ae[_0x295f29(0x165)](_0x9d54ac,_0x162a84);if(_0x162a84[_0x295f29(0x16d)](_0x295f29(0x212))){const _0x5444ae=parseKnowledgeBaseYaml(a86_0x22a2ad[_0x295f29(0x194)](_0x532a3b,_0x295f29(0x1e6)),_0x532a3b);_0x45d600['push']({'name':_0x5444ae[_0x295f29(0x1c0)],'path':_0x532a3b,'yaml':_0x5444ae});}else{if(_0x162a84[_0x295f29(0x16d)]('.md')){const _0x2e64e6=a86_0x22a2ad['readFileSync'](_0x532a3b,_0x295f29(0x1e6)),{name:_0x32f91b,text:_0x473f72}=parseTextKnowledgeBaseMd(_0x2e64e6,_0x162a84);_0x1aa2b9['push']({'name':_0x32f91b,'path':_0x532a3b,'text':_0x473f72});}}}}const _0x3053a4=getPromptsDir(_0x232c12);if(a86_0x22a2ad[_0x295f29(0x1f4)](_0x3053a4)){const _0x531f83=a86_0x22a2ad[_0x295f29(0x1ea)](_0x3053a4)[_0x295f29(0x15b)](_0x46644e=>_0x46644e[_0x295f29(0x16d)]('.yml'));for(const _0x337305 of _0x531f83){const _0x485dc4=a86_0x2c35ae['join'](_0x3053a4,_0x337305),_0x25be6a=parsePromptYaml(a86_0x22a2ad['readFileSync'](_0x485dc4,_0x295f29(0x1e6)),_0x485dc4);_0x3a2343[_0x295f29(0x170)]({'name':_0x25be6a[_0x295f29(0x1c0)],'path':_0x485dc4,'yaml':_0x25be6a});}}}else{const _0x4efcab=await this[_0x295f29(0x156)](_0x232c12),_0x3c4913=await this[_0x295f29(0x1ab)][_0x295f29(0x1ae)](_0x4efcab);_0x1a7707=_0x3c4913[_0x295f29(0x1f0)][_0x295f29(0x1c0)];const _0x42bf17=await this[_0x295f29(0x1ab)][_0x295f29(0x182)](_0x4efcab),_0x28e7e1=await this[_0x295f29(0x1ab)][_0x295f29(0x1cf)](_0x4efcab),_0x8a3fde=await this['client'][_0x295f29(0x160)](_0x4efcab),_0x32dd9b=await this[_0x295f29(0x1ab)][_0x295f29(0x206)](_0x4efcab),_0x31f2db=new Map(),_0x2bdc1d=new Map(),_0x284bd4=new Map(),_0x161c72=new Map();for(const _0x1b3dac of _0x28e7e1){_0x31f2db[_0x295f29(0x1c5)](_0x1b3dac['id'],_0x1b3dac['attributes'][_0x295f29(0x1c0)]);}for(const _0x1722c2 of _0x8a3fde){_0x2bdc1d['set'](_0x1722c2['id'],_0x1722c2[_0x295f29(0x1f0)]['name']);}for(const _0x893f6c of _0x42bf17){_0x284bd4[_0x295f29(0x1c5)](_0x893f6c['id'],_0x893f6c['attributes'][_0x295f29(0x1c0)]);}for(const _0x1f6353 of _0x32dd9b){_0x161c72[_0x295f29(0x1c5)](_0x1f6353['id'],_0x1f6353[_0x295f29(0x1f0)][_0x295f29(0x1c0)]);}const _0x235265={'resolveKnowledgeBaseName':async _0x5b88ad=>_0x31f2db['get'](_0x5b88ad),'resolveTextKnowledgeBaseName':async _0x4f4689=>_0x2bdc1d[_0x295f29(0x183)](_0x4f4689),'resolveAgentName':async _0x442f1d=>_0x284bd4[_0x295f29(0x183)](_0x442f1d),'resolveWebSearchToolName':async()=>undefined,'resolveImageGeneratorName':async()=>undefined,'resolvePromptName':async _0x5fd40=>_0x161c72[_0x295f29(0x183)](_0x5fd40),'onWarning':_0x5de9b1=>this[_0x295f29(0x193)][_0x295f29(0x1ff)]?.[_0x295f29(0x17d)](_0x5de9b1)};for(const _0x43cdd4 of _0x42bf17){const _0x5d8ec1=await agentResponseToDef(_0x43cdd4,_0x235265),{yaml:_0x56d524,systemPrompt:_0x1ac75c,starterMessage:_0x4f0b90}=_0x5d8ec1;_0x16f372[_0x295f29(0x170)]({'name':_0x56d524[_0x295f29(0x1c0)],'dir':'','yaml':_0x56d524,'systemPrompt':_0x1ac75c,'starterMessage':_0x4f0b90});}for(const _0x45c2fd of _0x28e7e1){const _0x2b2017=apiKnowledgeBaseToYaml(_0x45c2fd);_0x45d600['push']({'name':_0x2b2017['name'],'path':'','yaml':_0x2b2017});}for(const _0x32674a of _0x8a3fde){_0x1aa2b9[_0x295f29(0x170)]({'name':_0x32674a['attributes'][_0x295f29(0x1c0)],'path':'','text':_0x32674a[_0x295f29(0x1f0)][_0x295f29(0x201)]});}for(const _0x22f5ba of _0x32dd9b){const _0x2e144f=await apiPromptToYaml(_0x22f5ba,_0x235265);_0x2e144f&&_0x3a2343[_0x295f29(0x170)]({'name':_0x2e144f[_0x295f29(0x1c0)],'path':'','yaml':_0x2e144f});}}const _0x17f3e8={'sourceProjectName':_0x1a7707,'newProjectName':_0x23b831,'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}}},_0x100e18=await this[_0x295f29(0x1ab)][_0x295f29(0x1d6)](),_0x1b7720=_0x100e18[_0x295f29(0x167)](_0x53c573=>_0x53c573[_0x295f29(0x1f0)]['name']===_0x23b831);if(_0x1b7720)throw new SDKError(ErrorCode[_0x295f29(0x1a7)],_0x295f29(0x218)+_0x23b831+_0x295f29(0x15e),undefined,{'helpText':_0x295f29(0x1c4)});if(_0x4c1049?.[_0x295f29(0x1d8)])return _0x17f3e8[_0x295f29(0x1f9)]['agents']['created']=_0x16f372[_0x295f29(0x1d1)],_0x17f3e8[_0x295f29(0x1f9)][_0x295f29(0x161)][_0x295f29(0x1cb)]=_0x45d600[_0x295f29(0x1d1)],_0x17f3e8[_0x295f29(0x1f9)][_0x295f29(0x1a5)][_0x295f29(0x1cb)]=_0x1aa2b9[_0x295f29(0x1d1)],_0x17f3e8[_0x295f29(0x1f9)][_0x295f29(0x1e0)]['created']=_0x3a2343['length'],_0x17f3e8;const _0x1e8129=await this[_0x295f29(0x1ab)][_0x295f29(0x1ba)]({'name':_0x23b831}),_0x124eca=_0x1e8129['id'];_0x17f3e8[_0x295f29(0x1dd)]=_0x124eca;const _0x22e758=new Map(),_0x108761=new Map(),_0x58a883=new Map(),_0x1b88ee=new Map(),_0x115d14=new Map(),_0x222960=new Map(),_0x131fef=new Set(),_0x2f7c9d=new Set();for(const _0x1955bc of _0x16f372){for(const _0x150167 of _0x1955bc[_0x295f29(0x20f)][_0x295f29(0x17f)]||[]){if(_0x150167[_0x295f29(0x1be)]===_0x295f29(0x225)){const _0x19be79=parseRef(_0x150167[_0x295f29(0x164)]);if(_0x19be79)_0x131fef[_0x295f29(0x19f)](_0x19be79[_0x295f29(0x1c0)]);}else{if(_0x150167[_0x295f29(0x1be)]===_0x295f29(0x1d0)){const _0xde82b=parseRef(_0x150167['target']);if(_0xde82b)_0x2f7c9d['add'](_0xde82b[_0x295f29(0x1c0)]);}}}}for(const _0x56c249 of _0x131fef){try{const _0xf08d58=await this[_0x295f29(0x1ab)][_0x295f29(0x207)]({'projectId':_0x124eca,'name':_0x56c249});_0x115d14[_0x295f29(0x1c5)](_0x56c249,_0xf08d58['id']),_0x17f3e8['imageGenerators'][_0x295f29(0x170)]({'name':_0x56c249,'action':_0x295f29(0x1cb),'id':_0xf08d58['id']}),_0x17f3e8['counts']['imageGenerators'][_0x295f29(0x1cb)]++;}catch(_0x5b8c37){_0x17f3e8[_0x295f29(0x1a2)][_0x295f29(0x170)]({'name':_0x56c249,'action':_0x295f29(0x1e9),'error':_0x5b8c37['message']}),_0x17f3e8[_0x295f29(0x1f9)][_0x295f29(0x1a2)]['errors']++;}}for(const _0x51ad71 of _0x2f7c9d){try{const _0x46c9fb=await this[_0x295f29(0x1ab)][_0x295f29(0x15c)]({'projectId':_0x124eca,'name':_0x51ad71});_0x222960[_0x295f29(0x1c5)](_0x51ad71,_0x46c9fb['id']),_0x17f3e8[_0x295f29(0x18e)][_0x295f29(0x170)]({'name':_0x51ad71,'action':_0x295f29(0x1cb),'id':_0x46c9fb['id']}),_0x17f3e8[_0x295f29(0x1f9)][_0x295f29(0x18e)][_0x295f29(0x1cb)]++;}catch(_0x5d8198){_0x17f3e8[_0x295f29(0x18e)][_0x295f29(0x170)]({'name':_0x51ad71,'action':_0x295f29(0x1e9),'error':_0x5d8198[_0x295f29(0x169)]}),_0x17f3e8[_0x295f29(0x1f9)][_0x295f29(0x18e)][_0x295f29(0x202)]++;}}const _0x43292d={'projectId':_0x124eca,'resolveKnowledgeBaseId':async _0x1bf2c8=>_0x22e758[_0x295f29(0x183)](_0x1bf2c8),'resolveTextKnowledgeBaseId':async _0x34fa79=>_0x108761[_0x295f29(0x183)](_0x34fa79),'resolveAgentId':async _0x594d48=>_0x58a883['get'](_0x594d48),'resolveWebSearchToolId':async _0x8501ec=>_0x222960[_0x295f29(0x183)](_0x8501ec),'resolveImageGeneratorId':async _0x1c1fe6=>_0x115d14[_0x295f29(0x183)](_0x1c1fe6),'resolvePromptId':async _0x223d27=>_0x1b88ee[_0x295f29(0x183)](_0x223d27),'onWarning':_0x398d95=>this[_0x295f29(0x193)][_0x295f29(0x1ff)]?.['warn'](_0x398d95)};for(const _0x42fbe2 of _0x45d600){try{const _0x637b65=yamlKnowledgeBaseToApi(_0x42fbe2['yaml'],_0x124eca),_0x55f496=await this[_0x295f29(0x1ab)]['createKnowledgeBase'](_0x637b65);_0x22e758[_0x295f29(0x1c5)](_0x42fbe2['yaml']['name'],_0x55f496['id']),_0x17f3e8[_0x295f29(0x161)][_0x295f29(0x170)]({'name':_0x42fbe2['yaml'][_0x295f29(0x1c0)],'action':'created','id':_0x55f496['id']}),_0x17f3e8[_0x295f29(0x1f9)][_0x295f29(0x161)]['created']++;}catch(_0x282c2c){_0x17f3e8[_0x295f29(0x161)][_0x295f29(0x170)]({'name':_0x42fbe2[_0x295f29(0x20f)][_0x295f29(0x1c0)],'action':_0x295f29(0x1e9),'error':_0x282c2c['message']}),_0x17f3e8[_0x295f29(0x1f9)]['knowledgeBases'][_0x295f29(0x202)]++;}}for(const _0x47d07b of _0x1aa2b9){try{const _0x2c56eb=yamlTextKnowledgeBaseToApi({'name':_0x47d07b[_0x295f29(0x1c0)],'text':_0x47d07b['text']},_0x124eca),_0x216f51=await this[_0x295f29(0x1ab)][_0x295f29(0x208)](_0x2c56eb);_0x108761['set'](_0x47d07b[_0x295f29(0x1c0)],_0x216f51['id']),_0x17f3e8['textKnowledgeBases'][_0x295f29(0x170)]({'name':_0x47d07b[_0x295f29(0x1c0)],'action':_0x295f29(0x1cb),'id':_0x216f51['id']}),_0x17f3e8[_0x295f29(0x1f9)][_0x295f29(0x1a5)]['created']++;}catch(_0x2ca6fe){_0x17f3e8['textKnowledgeBases'][_0x295f29(0x170)]({'name':_0x47d07b[_0x295f29(0x1c0)],'action':_0x295f29(0x1e9),'error':_0x2ca6fe[_0x295f29(0x169)]}),_0x17f3e8['counts'][_0x295f29(0x1a5)][_0x295f29(0x202)]++;}}const _0x2cb4a9=[..._0x16f372]['sort']((_0x4027d2,_0x49f50e)=>{const _0xaa6929=_0x295f29,_0x5b9f95=_0x4027d2[_0xaa6929(0x20f)]['tools']?.['some'](_0x376572=>_0x376572[_0xaa6929(0x1be)]===_0xaa6929(0x1c1))??![],_0x97fecc=_0x49f50e[_0xaa6929(0x20f)][_0xaa6929(0x17f)]?.['some'](_0x17923f=>_0x17923f[_0xaa6929(0x1be)]===_0xaa6929(0x1c1))??![];if(_0x5b9f95&&!_0x97fecc)return 0x1;if(!_0x5b9f95&&_0x97fecc)return-0x1;return 0x0;});for(const _0x4b2354 of _0x2cb4a9){try{const _0x396edc=_0x4b2354[_0x295f29(0x20f)]['tools']?.[_0x295f29(0x15b)](_0x145520=>{const _0x322d47=_0x295f29;if(_0x145520['type']===_0x322d47(0x1c1)){const _0x58fbe0=parseRef(_0x145520[_0x322d47(0x164)]);return _0x58fbe0?.['name']===_0x4b2354['yaml'][_0x322d47(0x1c0)];}return![];})??[];_0x396edc[_0x295f29(0x1d1)]>0x0&&this['context'][_0x295f29(0x1ff)]?.[_0x295f29(0x17d)]('Agent\x20\x27'+_0x4b2354[_0x295f29(0x20f)][_0x295f29(0x1c0)]+_0x295f29(0x177)+_0x295f29(0x1da));const _0x26b583=await agentDefToRequest(_0x4b2354['yaml'],_0x4b2354[_0x295f29(0x1bf)],_0x4b2354[_0x295f29(0x1f8)],_0x43292d),_0x54f212=await this[_0x295f29(0x1ab)][_0x295f29(0x1ec)](_0x26b583);_0x58a883[_0x295f29(0x1c5)](_0x4b2354[_0x295f29(0x20f)][_0x295f29(0x1c0)],_0x54f212['id']),_0x17f3e8[_0x295f29(0x18a)]['push']({'agentName':_0x4b2354[_0x295f29(0x20f)][_0x295f29(0x1c0)],'action':'created','agentId':_0x54f212['id']}),_0x17f3e8[_0x295f29(0x1f9)][_0x295f29(0x18a)]['created']++;}catch(_0x38bf1f){_0x17f3e8['agents'][_0x295f29(0x170)]({'agentName':_0x4b2354[_0x295f29(0x20f)][_0x295f29(0x1c0)],'action':_0x295f29(0x1e9),'error':_0x38bf1f[_0x295f29(0x169)]}),_0x17f3e8[_0x295f29(0x1f9)][_0x295f29(0x18a)][_0x295f29(0x202)]++;}}for(const _0x2fbfbe of _0x3a2343){try{const _0x37cda3=await yamlPromptToApi(_0x2fbfbe['yaml'],_0x124eca,_0x43292d);if(!_0x37cda3){_0x17f3e8['prompts']['push']({'name':_0x2fbfbe[_0x295f29(0x20f)][_0x295f29(0x1c0)],'action':_0x295f29(0x1e9),'error':'Agent\x20reference\x20not\x20found'}),_0x17f3e8['counts']['prompts'][_0x295f29(0x202)]++;continue;}const _0xdec147=await this[_0x295f29(0x1ab)][_0x295f29(0x1fb)](_0x37cda3);_0x1b88ee[_0x295f29(0x1c5)](_0x2fbfbe[_0x295f29(0x20f)][_0x295f29(0x1c0)],_0xdec147['id']),_0x17f3e8[_0x295f29(0x1e0)][_0x295f29(0x170)]({'name':_0x2fbfbe['yaml'][_0x295f29(0x1c0)],'action':_0x295f29(0x1cb),'id':_0xdec147['id']}),_0x17f3e8[_0x295f29(0x1f9)][_0x295f29(0x1e0)][_0x295f29(0x1cb)]++;}catch(_0xf2e05e){_0x17f3e8[_0x295f29(0x1e0)][_0x295f29(0x170)]({'name':_0x2fbfbe['yaml'][_0x295f29(0x1c0)],'action':_0x295f29(0x1e9),'error':_0xf2e05e[_0x295f29(0x169)]}),_0x17f3e8['counts'][_0x295f29(0x1e0)][_0x295f29(0x202)]++;}}return _0x17f3e8;}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(_0x340948,_0x1f3c66){const _0x463835=a87_0x42e1,_0x233b21=_0x340948();while(!![]){try{const _0x4ba594=parseInt(_0x463835(0xcf))/0x1+-parseInt(_0x463835(0xc8))/0x2*(parseInt(_0x463835(0xcd))/0x3)+parseInt(_0x463835(0xd3))/0x4+-parseInt(_0x463835(0xca))/0x5*(-parseInt(_0x463835(0xcb))/0x6)+-parseInt(_0x463835(0xc9))/0x7+parseInt(_0x463835(0xc6))/0x8*(-parseInt(_0x463835(0xc7))/0x9)+parseInt(_0x463835(0xcc))/0xa;if(_0x4ba594===_0x1f3c66)break;else _0x233b21['push'](_0x233b21['shift']());}catch(_0x48a225){_0x233b21['push'](_0x233b21['shift']());}}}(a87_0x898c,0x1973e));function a87_0x898c(){const _0x50b218=['map','8776akjRHw','targetKnowledgeBaseId','targetAgentId','12184iRwjbG','27vTrvwq','278yPHdkt','824376pBitgI','35uLbOAP','28614rtNgsg','2578900afRCch','1707OkLClU','get','12215zXDNhH','attributes','1.0'];a87_0x898c=function(){return _0x50b218;};return a87_0x898c();}function a87_0x42e1(_0x465fd0,_0x5a501a){_0x465fd0=_0x465fd0-0xc6;const _0x898c6=a87_0x898c();let _0x42e19d=_0x898c6[_0x465fd0];return _0x42e19d;}export function canCreateAgent(_0x793cfd,_0x483281){const _0x3b088b=a87_0x42e1;for(const _0x5274a8 of _0x793cfd[_0x3b088b(0xd0)]['tools']){if(_0x5274a8[_0x3b088b(0xd5)]&&!_0x483281['has'](_0x5274a8[_0x3b088b(0xd5)]))return![];}return!![];}export function remapToolIds(_0x4e3b67,_0x55776a,_0x3d289e){const _0x3e5c66=a87_0x42e1;return _0x4e3b67[_0x3e5c66(0xd2)](_0x509c18=>({..._0x509c18,'targetKnowledgeBaseId':_0x509c18[_0x3e5c66(0xd4)]?_0x55776a[_0x3e5c66(0xce)](_0x509c18[_0x3e5c66(0xd4)])||_0x509c18[_0x3e5c66(0xd4)]:undefined,'targetAgentId':_0x509c18[_0x3e5c66(0xd5)]?_0x3d289e['get'](_0x509c18[_0x3e5c66(0xd5)])||_0x509c18['targetAgentId']:undefined}));}export function remapVariableIds(_0x2cc790,_0x27a7b4){const _0x12eb2b=a87_0x42e1;return _0x2cc790['map'](_0x4e7702=>({..._0x4e7702,'targetKnowledgeBaseId':_0x27a7b4[_0x12eb2b(0xce)](_0x4e7702[_0x12eb2b(0xd4)])||_0x4e7702[_0x12eb2b(0xd4)]}));}export function isSupportedBackupVersion(_0x194c6a){const _0x5818fc=a87_0x42e1;return _0x194c6a===_0x5818fc(0xd1);}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a88_0x15f92f=a88_0xdd07;(function(_0x235670,_0x297a61){const _0xc5fd69=a88_0xdd07,_0x3b5d45=_0x235670();while(!![]){try{const _0x5360bb=-parseInt(_0xc5fd69(0x1f2))/0x1+parseInt(_0xc5fd69(0x1ef))/0x2+-parseInt(_0xc5fd69(0x1f6))/0x3*(parseInt(_0xc5fd69(0x1f1))/0x4)+-parseInt(_0xc5fd69(0x1f5))/0x5+parseInt(_0xc5fd69(0x1ed))/0x6*(parseInt(_0xc5fd69(0x1eb))/0x7)+-parseInt(_0xc5fd69(0x1ec))/0x8+parseInt(_0xc5fd69(0x1f3))/0x9;if(_0x5360bb===_0x297a61)break;else _0x3b5d45['push'](_0x3b5d45['shift']());}catch(_0x5a6985){_0x3b5d45['push'](_0x3b5d45['shift']());}}}(a88_0x4023,0x472e8));const MODEL_ALIASES={'haiku':a88_0x15f92f(0x1ee),'sonnet':a88_0x15f92f(0x1f4)};function a88_0x4023(){const _0x84e68f=['1558248kBFoCQ','claude-4.5-haiku','633058CTTjbE','match','149956GFFaYr','206545yzsSzd','7969752MBzqGv','claude-4.5-sonnet','2133070oWApxh','24MqzPEK','toLowerCase','14dFXuZi','3974736NhmPRc'];a88_0x4023=function(){return _0x84e68f;};return a88_0x4023();}function a88_0xdd07(_0x2d7126,_0xb7d223){_0x2d7126=_0x2d7126-0x1eb;const _0x402368=a88_0x4023();let _0xdd073d=_0x402368[_0x2d7126];return _0xdd073d;}export function extractModelAlias(_0x5162fd){const _0x13077e=a88_0x15f92f,_0xaf67cc=_0x5162fd[_0x13077e(0x1f0)](/^claude-(?:\d+-)?(?:\d+-?)?(sonnet|haiku|opus)/i);if(_0xaf67cc)return _0xaf67cc[0x1][_0x13077e(0x1f7)]();return _0x5162fd;}export function resolveModelAlias(_0x3f3dbd){const _0x3eb4f7=a88_0x15f92f;return MODEL_ALIASES[_0x3f3dbd[_0x3eb4f7(0x1f7)]()]||_0x3f3dbd;}export function getModelAliases(){return{...MODEL_ALIASES};}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(_0x23129c,_0x524922){const _0x348195=a89_0x5bf6,_0x3fd5c9=_0x23129c();while(!![]){try{const _0x5dfaa3=-parseInt(_0x348195(0xb3))/0x1*(-parseInt(_0x348195(0xb7))/0x2)+-parseInt(_0x348195(0xbb))/0x3+-parseInt(_0x348195(0xa7))/0x4+parseInt(_0x348195(0xa8))/0x5+parseInt(_0x348195(0xbe))/0x6+parseInt(_0x348195(0xa9))/0x7+-parseInt(_0x348195(0xb8))/0x8*(parseInt(_0x348195(0xae))/0x9);if(_0x5dfaa3===_0x524922)break;else _0x3fd5c9['push'](_0x3fd5c9['shift']());}catch(_0x3359cf){_0x3fd5c9['push'](_0x3fd5c9['shift']());}}}(a89_0x1ec2,0xc2c95));function a89_0x1ec2(){const _0x3566f2=['haiku','toLowerCase','sonnet','27CPMVSH','4.5','includes','opus','Sonnet\x204.5','5mLkhuh','Haiku\x204','4-5','Opus\x204.5','158072uRLIlX','1878040qDPjTX','Claude','toLocaleString','2103897aFATDv','default','Haiku\x204.5','4484586bmSlkm','en-US','round','3089244wngIXt','2882620qJbYBj','8796095oMXcFv','Opus\x204'];a89_0x1ec2=function(){return _0x3566f2;};return a89_0x1ec2();}export const MODEL_FACTORS={'sonnet':0xa,'claude-4.5-sonnet':0xa,'claude-sonnet-4':0xa,'haiku':3.4,'claude-4.5-haiku':3.4,'claude-haiku-4':3.4,'opus':0xf,'claude-4-opus':0xf,'claude-opus-4':0xf};export const CONTEXT_LIMITS={'sonnet':0x30d40,'haiku':0x30d40,'opus':0x30d40,'default':0x30d40};export function getModelFactor(_0xb5b5c7){const _0x117b0b=a89_0x5bf6,_0x2fd48b=_0xb5b5c7[_0x117b0b(0xac)]();if(MODEL_FACTORS[_0x2fd48b])return MODEL_FACTORS[_0x2fd48b];if(_0x2fd48b[_0x117b0b(0xb0)](_0x117b0b(0xad)))return MODEL_FACTORS[_0x117b0b(0xad)];if(_0x2fd48b[_0x117b0b(0xb0)](_0x117b0b(0xab)))return MODEL_FACTORS[_0x117b0b(0xab)];if(_0x2fd48b[_0x117b0b(0xb0)](_0x117b0b(0xb1)))return MODEL_FACTORS[_0x117b0b(0xb1)];return MODEL_FACTORS[_0x117b0b(0xad)];}export function getContextLimit(_0x513014){const _0x523d17=a89_0x5bf6,_0x375d09=_0x513014[_0x523d17(0xac)]();if(_0x375d09[_0x523d17(0xb0)](_0x523d17(0xad)))return CONTEXT_LIMITS[_0x523d17(0xad)];if(_0x375d09[_0x523d17(0xb0)](_0x523d17(0xab)))return CONTEXT_LIMITS[_0x523d17(0xab)];if(_0x375d09[_0x523d17(0xb0)](_0x523d17(0xb1)))return CONTEXT_LIMITS['opus'];return CONTEXT_LIMITS[_0x523d17(0xbc)];}export function calculateChatUnit(_0x376e3d,_0x215fdb,_0x6f0577){return(_0x376e3d+_0x215fdb)/0x1388*_0x6f0577;}export function calculateCredits(_0x5e54f4){return _0x5e54f4/0x2904;}export function getModelDisplayName(_0x2f134e){const _0xfd11ed=a89_0x5bf6,_0x3243e5=_0x2f134e[_0xfd11ed(0xac)]();if(_0x3243e5['includes'](_0xfd11ed(0xad))){if(_0x3243e5[_0xfd11ed(0xb0)](_0xfd11ed(0xb5))||_0x3243e5[_0xfd11ed(0xb0)]('4.5'))return _0xfd11ed(0xb2);return'Sonnet\x204';}if(_0x3243e5[_0xfd11ed(0xb0)]('haiku')){if(_0x3243e5[_0xfd11ed(0xb0)](_0xfd11ed(0xb5))||_0x3243e5[_0xfd11ed(0xb0)](_0xfd11ed(0xaf)))return _0xfd11ed(0xbd);return _0xfd11ed(0xb4);}if(_0x3243e5[_0xfd11ed(0xb0)](_0xfd11ed(0xb1))){if(_0x3243e5[_0xfd11ed(0xb0)]('4-5')||_0x3243e5[_0xfd11ed(0xb0)]('4.5'))return _0xfd11ed(0xb6);return _0xfd11ed(0xaa);}return _0xfd11ed(0xb9);}function a89_0x5bf6(_0x2111fa,_0x1085a6){_0x2111fa=_0x2111fa-0xa7;const _0x1ec214=a89_0x1ec2();let _0x5bf6ce=_0x1ec214[_0x2111fa];return _0x5bf6ce;}export function formatTokenCount(_0x5ab6b7){const _0x2f083c=a89_0x5bf6;return _0x5ab6b7[_0x2f083c(0xba)](_0x2f083c(0xbf));}export function calculateContextPercentage(_0x2befe1,_0x222ffe){const _0x5f5dde=a89_0x5bf6,_0x370205=getContextLimit(_0x222ffe);return Math[_0x5f5dde(0xc0)](_0x2befe1/_0x370205*0x64);}
|
package/dist/sdk/query/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a90_0x3a67c4=a90_0x598d;(function(_0x534b54,_0x555bb9){const _0x3c1097=a90_0x598d,_0x36209a=_0x534b54();while(!![]){try{const _0x5b3287=parseInt(_0x3c1097(0x18c))/0x1+parseInt(_0x3c1097(0x19b))/0x2+parseInt(_0x3c1097(0x196))/0x3+-parseInt(_0x3c1097(0x18f))/0x4*(-parseInt(_0x3c1097(0x19a))/0x5)+-parseInt(_0x3c1097(0x191))/0x6+parseInt(_0x3c1097(0x17d))/0x7*(-parseInt(_0x3c1097(0x17e))/0x8)+-parseInt(_0x3c1097(0x19e))/0x9*(-parseInt(_0x3c1097(0x195))/0xa);if(_0x5b3287===_0x555bb9)break;else _0x36209a['push'](_0x36209a['shift']());}catch(_0x1176d8){_0x36209a['push'](_0x36209a['shift']());}}}(a90_0x1a83,0x28ada));function a90_0x598d(_0x4db2d7,_0x3c2764){_0x4db2d7=_0x4db2d7-0x174;const _0x1a839d=a90_0x1a83();let _0x598df5=_0x1a839d[_0x4db2d7];return _0x598df5;}import{TrinoApiClient}from'../client/trino-api-client.js';import{escapeStringLiteral,buildLikePattern}from'../../utils/string-utils.js';import{SDKError,ErrorCode}from'../errors.js';function a90_0x1a83(){const _0x54b77c=['Limit\x20must\x20be\x20a\x20positive\x20number','\x0a\x20\x20\x20\x20\x20\x20','length','30zaWJoY','597435dJNguY','\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','Provide\x20SQL\x20via\x20argument\x20or\x20use\x20--file\x20option.','\x0aORDER\x20BY\x20database_name\x0aLIMIT\x20','369505sChldQ','311008CQUNRr','Provide\x20a\x20valid\x20glob\x20pattern\x20(e.g.,\x20\x22user_*\x22)\x20or\x20omit\x20to\x20list\x20all\x20tables.','data','503019iidhYy','SQL\x20query\x20is\x20required','\x0aORDER\x20BY\x20database_name,\x20table_name\x0aLIMIT\x20','\x0a\x20\x20\x20\x20\x20\x20ORDER\x20BY\x20ordinal_position\x0a\x20\x20\x20\x20','\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','Database\x20name\x20is\x20required','validateTable','Usage:\x20tdx\x20show\x20<database.table>','\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','\x0a\x20\x20\x20\x20\x20\x20\x20\x20AND\x20table_name\x20=\x20','trim','execute','slice','MISSING_ARGUMENT','trinoApiClient','Use\x20--limit\x20<number>\x20to\x20specify\x20row\x20limit\x20(must\x20be\x20positive).','\x0a\x20\x20AND\x20table_schema\x20LIKE\x20','executeQuery','\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','listTables','7qkypDy','2488504FsUUeU','Provide\x20a\x20valid\x20glob\x20pattern\x20(e.g.,\x20\x22prod_*\x22)\x20or\x20omit\x20the\x20pattern\x20to\x20list\x20all\x20databases.','\x0a\x20\x20\x20\x20','logger','INVALID_ARGUMENT','listDatabases','describeTable','\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\x20positive\x20number\x20for\x20limit\x20(e.g.,\x20100).','\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','Pattern\x20cannot\x20be\x20empty\x20or\x20whitespace-only','Provide\x20a\x20valid\x20database\x20name\x20or\x20omit\x20to\x20list\x20tables\x20from\x20all\x20databases.','\x0a\x20\x20AND\x20table_name\x20LIKE\x20','Limit\x20must\x20be\x20a\x20positive\x20integer','25236vmSNcb','\x0aORDER\x20BY\x20table_name\x0aLIMIT\x20','SELECT\x20*\x20FROM\x20','12hXKtlJ','\x20ESCAPE\x20\x27\x5c\x27','1749480iLkzNk'];a90_0x1a83=function(){return _0x54b77c;};return a90_0x1a83();}import{DEFAULT_LISTING_LIMIT}from'../../core/constants.js';export class QuerySDK{['trinoApiClient'];constructor(_0x4c87da){const _0x2f2697=a90_0x598d;this[_0x2f2697(0x177)]=new TrinoApiClient(_0x4c87da,_0x4c87da[_0x2f2697(0x181)]);}async[a90_0x3a67c4(0x174)](_0x2fd634,_0x1a1a0d){const _0x392197=a90_0x3a67c4;if(!_0x2fd634||_0x2fd634[_0x392197(0x1a8)]()[_0x392197(0x194)]===0x0)throw new SDKError(ErrorCode[_0x392197(0x176)],_0x392197(0x19f),undefined,{'helpText':_0x392197(0x198)});return await this[_0x392197(0x177)][_0x392197(0x17a)](_0x2fd634,_0x1a1a0d);}async[a90_0x3a67c4(0x183)](_0x461f80,_0x448d21=DEFAULT_LISTING_LIMIT){const _0x2ea664=a90_0x3a67c4;if(_0x461f80!==undefined&&_0x461f80[_0x2ea664(0x1a8)]()[_0x2ea664(0x194)]===0x0)throw new SDKError(ErrorCode['INVALID_ARGUMENT'],_0x2ea664(0x188),undefined,{'helpText':_0x2ea664(0x17f)});if(_0x448d21<=0x0)throw new SDKError(ErrorCode['INVALID_ARGUMENT'],'Limit\x20must\x20be\x20a\x20positive\x20number',undefined,{'helpText':_0x2ea664(0x186)});let _0x186040=_0x2ea664(0x187);_0x461f80&&(_0x186040+='\x0a\x20\x20AND\x20schema_name\x20LIKE\x20'+buildLikePattern(_0x461f80)+_0x2ea664(0x190));_0x186040+=_0x2ea664(0x199)+_0x448d21;const _0x20cbf6=await this['trinoApiClient'][_0x2ea664(0x17a)](_0x186040[_0x2ea664(0x1a8)]());return _0x20cbf6[_0x2ea664(0x19d)];}async[a90_0x3a67c4(0x17c)](_0x2f2e01,_0x1c666b,_0x5e112b,_0x2ff473=DEFAULT_LISTING_LIMIT){const _0x3c61df=a90_0x3a67c4;if(_0x2f2e01!==undefined&&_0x2f2e01[_0x3c61df(0x1a8)]()[_0x3c61df(0x194)]===0x0)throw new SDKError(ErrorCode[_0x3c61df(0x182)],'Database\x20name\x20cannot\x20be\x20empty\x20or\x20whitespace-only',undefined,{'helpText':_0x3c61df(0x189)});if(_0x1c666b!==undefined&&_0x1c666b[_0x3c61df(0x1a8)]()[_0x3c61df(0x194)]===0x0)throw new SDKError(ErrorCode[_0x3c61df(0x182)],_0x3c61df(0x188),undefined,{'helpText':_0x3c61df(0x19c)});if(_0x5e112b!==undefined&&_0x5e112b[_0x3c61df(0x1a8)]()[_0x3c61df(0x194)]===0x0)throw new SDKError(ErrorCode[_0x3c61df(0x182)],'Database\x20pattern\x20cannot\x20be\x20empty\x20or\x20whitespace-only',undefined,{'helpText':'Provide\x20a\x20valid\x20glob\x20pattern\x20(e.g.,\x20\x22prod_*\x22)\x20or\x20omit\x20to\x20search\x20all\x20databases.'});if(_0x2ff473<=0x0)throw new SDKError(ErrorCode['INVALID_ARGUMENT'],_0x3c61df(0x192),undefined,{'helpText':_0x3c61df(0x186)});let _0x211879;_0x2f2e01?(_0x211879=_0x3c61df(0x17b)+escapeStringLiteral(_0x2f2e01)+_0x3c61df(0x193),_0x1c666b&&(_0x211879+='\x0a\x20\x20AND\x20table_name\x20LIKE\x20'+buildLikePattern(_0x1c666b)+_0x3c61df(0x190)),_0x211879+=_0x3c61df(0x18d)+_0x2ff473):(_0x211879=_0x3c61df(0x197),_0x5e112b&&(_0x211879+=_0x3c61df(0x179)+buildLikePattern(_0x5e112b)+_0x3c61df(0x190)),_0x1c666b&&(_0x211879+=_0x3c61df(0x18a)+buildLikePattern(_0x1c666b)+_0x3c61df(0x190)),_0x211879+=_0x3c61df(0x1a0)+_0x2ff473);const _0x3c985b=await this['trinoApiClient'][_0x3c61df(0x17a)](_0x211879[_0x3c61df(0x1a8)]());return _0x3c985b[_0x3c61df(0x19d)];}async['validateDatabase'](_0x33b333){const _0x50c734=a90_0x3a67c4,_0x3936dc=(_0x50c734(0x1a6)+escapeStringLiteral(_0x33b333)+_0x50c734(0x180))[_0x50c734(0x1a8)](),_0x3baaf7=await this[_0x50c734(0x177)][_0x50c734(0x17a)](_0x3936dc);return _0x3baaf7[_0x50c734(0x19d)][_0x50c734(0x194)]>0x0;}async[a90_0x3a67c4(0x1a4)](_0x46c37c,_0x3b6491){const _0x5a3558=a90_0x3a67c4,_0x45d22e=(_0x5a3558(0x1a2)+escapeStringLiteral(_0x46c37c)+_0x5a3558(0x1a7)+escapeStringLiteral(_0x3b6491)+_0x5a3558(0x180))[_0x5a3558(0x1a8)](),_0x286433=await this[_0x5a3558(0x177)][_0x5a3558(0x17a)](_0x45d22e);return _0x286433[_0x5a3558(0x19d)][_0x5a3558(0x194)]>0x0;}async[a90_0x3a67c4(0x184)](_0x2360f0,_0x381751){const _0x4bb67b=a90_0x3a67c4;if(!_0x2360f0||_0x2360f0['trim']()['length']===0x0)throw new SDKError(ErrorCode[_0x4bb67b(0x176)],_0x4bb67b(0x1a3),undefined,{'helpText':'Usage:\x20tdx\x20describe\x20<database.table>'});if(!_0x381751||_0x381751['trim']()[_0x4bb67b(0x194)]===0x0)throw new SDKError(ErrorCode[_0x4bb67b(0x176)],'Table\x20name\x20is\x20required',undefined,{'helpText':'Usage:\x20tdx\x20describe\x20<database.table>'});const _0x42b46e=(_0x4bb67b(0x185)+escapeStringLiteral(_0x2360f0)+_0x4bb67b(0x1a7)+escapeStringLiteral(_0x381751)+_0x4bb67b(0x1a1))[_0x4bb67b(0x1a8)](),_0x58e3ab=await this[_0x4bb67b(0x177)]['executeQuery'](_0x42b46e);return _0x58e3ab[_0x4bb67b(0x19d)];}async['showTable'](_0x1a5d6c,_0x42bbac,_0x3f3e2d=0x28,_0x5b0657){const _0x24a891=a90_0x3a67c4;if(!_0x1a5d6c||_0x1a5d6c[_0x24a891(0x1a8)]()[_0x24a891(0x194)]===0x0)throw new SDKError(ErrorCode[_0x24a891(0x176)],_0x24a891(0x1a3),undefined,{'helpText':_0x24a891(0x1a5)});if(!_0x42bbac||_0x42bbac[_0x24a891(0x1a8)]()['length']===0x0)throw new SDKError(ErrorCode['MISSING_ARGUMENT'],'Table\x20name\x20is\x20required',undefined,{'helpText':_0x24a891(0x1a5)});if(!Number['isInteger'](_0x3f3e2d)||_0x3f3e2d<=0x0)throw new SDKError(ErrorCode[_0x24a891(0x182)],_0x24a891(0x18b),undefined,{'helpText':_0x24a891(0x178)});const _0x4b5340=escapeStringLiteral(_0x1a5d6c)[_0x24a891(0x175)](0x1,-0x1)+'.'+escapeStringLiteral(_0x42bbac)[_0x24a891(0x175)](0x1,-0x1),_0x3ed673=_0x24a891(0x18e)+_0x4b5340+'\x20LIMIT\x20'+_0x3f3e2d,_0x1817e2=await this['trinoApiClient']['executeQuery'](_0x3ed673,{'catalog':_0x5b0657,'schema':_0x1a5d6c});return _0x1817e2;}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(_0x4a4868,_0x3987ae){const _0x22ca0b=a91_0x54bc,_0x39aaa7=_0x4a4868();while(!![]){try{const _0x28d387=-parseInt(_0x22ca0b(0x14e))/0x1+parseInt(_0x22ca0b(0x149))/0x2+-parseInt(_0x22ca0b(0x134))/0x3*(-parseInt(_0x22ca0b(0x143))/0x4)+-parseInt(_0x22ca0b(0x148))/0x5*(parseInt(_0x22ca0b(0x139))/0x6)+-parseInt(_0x22ca0b(0x138))/0x7+-parseInt(_0x22ca0b(0x140))/0x8+parseInt(_0x22ca0b(0x135))/0x9;if(_0x28d387===_0x3987ae)break;else _0x39aaa7['push'](_0x39aaa7['shift']());}catch(_0x53504a){_0x39aaa7['push'](_0x39aaa7['shift']());}}}(a91_0x35f3,0x55233));import{readFileSync}from'fs';function a91_0x54bc(_0x16c113,_0x89b152){_0x16c113=_0x16c113-0x132;const _0x35f365=a91_0x35f3();let _0x54bc8f=_0x35f365[_0x16c113];return _0x54bc8f;}import{createInterface}from'readline';export function stripSqlComments(_0x545d29){const _0xbe0696=a91_0x54bc;let _0x2f3dda=_0x545d29['replace'](/\/\*(?:[^*]|\*(?!\/))*\*\//g,'');return _0x2f3dda=_0x2f3dda['replace'](/--.*$/gm,''),_0x2f3dda[_0xbe0696(0x14b)]();}function isEscaped(_0xae9f2c,_0xea15dd){let _0x4c962a=0x0;for(let _0x1e4cc6=_0xea15dd-0x1;_0x1e4cc6>=0x0&&_0xae9f2c[_0x1e4cc6]==='\x5c';_0x1e4cc6--){_0x4c962a++;}return _0x4c962a%0x2===0x1;}export function splitSqlStatements(_0x2fb225){const _0x5c19c2=a91_0x54bc,_0x513b5d=stripSqlComments(_0x2fb225);if(!_0x513b5d)throw new Error(_0x5c19c2(0x144));const _0x8d7fd3=[];let _0x5f5742='',_0x5dfd09=![],_0x120d77=![],_0x50231d=![];for(let _0x1661ff=0x0;_0x1661ff<_0x2fb225[_0x5c19c2(0x13a)];_0x1661ff++){const _0x5ab5cc=_0x2fb225[_0x1661ff];if(_0x5ab5cc==='\x27'&&!isEscaped(_0x2fb225,_0x1661ff)&&!_0x120d77&&!_0x50231d)_0x5dfd09=!_0x5dfd09;else{if(_0x5ab5cc==='\x22'&&!isEscaped(_0x2fb225,_0x1661ff)&&!_0x5dfd09&&!_0x50231d)_0x120d77=!_0x120d77;else _0x5ab5cc==='`'&&!isEscaped(_0x2fb225,_0x1661ff)&&!_0x5dfd09&&!_0x120d77&&(_0x50231d=!_0x50231d);}if(_0x5ab5cc===';'&&!_0x5dfd09&&!_0x120d77&&!_0x50231d){const _0x49d1f2=_0x5f5742['trim']();_0x49d1f2&&_0x8d7fd3[_0x5c19c2(0x14c)](_0x49d1f2),_0x5f5742='';}else _0x5f5742+=_0x5ab5cc;}const _0x499755=_0x5f5742[_0x5c19c2(0x14b)]();_0x499755&&_0x8d7fd3['push'](_0x499755);const _0x2e66f1=_0x8d7fd3['map'](_0x2ffd11=>_0x2ffd11[_0x5c19c2(0x14b)]())[_0x5c19c2(0x146)](_0x3a6d5b=>{const _0x2e89a2=_0x5c19c2,_0x3aaba1=stripSqlComments(_0x3a6d5b);return _0x3aaba1[_0x2e89a2(0x13a)]>0x0;});if(_0x2e66f1[_0x5c19c2(0x13a)]===0x0)throw new Error(_0x5c19c2(0x144));return _0x2e66f1;}export function readFileContent(_0x325685){const _0x311279=a91_0x54bc;try{return readFileSync(_0x325685,_0x311279(0x136));}catch(_0x164c23){const _0x6d310b=_0x164c23['code'];if(_0x6d310b===_0x311279(0x13e))throw new Error('File\x20\x27'+_0x325685+_0x311279(0x137));else{if(_0x6d310b===_0x311279(0x13c))throw new Error('Permission\x20denied\x20reading\x20file\x20\x27'+_0x325685+'\x27');else throw new Error(_0x311279(0x141)+_0x325685+_0x311279(0x145)+_0x164c23['message']);}}}export function readSqlStatementsFromFile(_0x5e9101){const _0x5921cf=a91_0x54bc,_0x1c818a=readFileContent(_0x5e9101);try{return splitSqlStatements(_0x1c818a);}catch(_0x5e99a2){throw new Error(_0x5921cf(0x14a)+_0x5e9101+'\x27\x20'+_0x5e99a2[_0x5921cf(0x150)][_0x5921cf(0x142)]());}}export async function readStdinContent(){const _0x320d18=a91_0x54bc;if(process[_0x320d18(0x13f)][_0x320d18(0x133)])throw new Error('No\x20input\x20provided.\x20Pipe\x20SQL\x20to\x20stdin\x20or\x20use\x20a\x20file.\x0aExample:\x20echo\x20\x22SELECT\x201\x22\x20|\x20tdx\x20query\x20-');return new Promise((_0x566a34,_0x526fb4)=>{const _0x7d6866=_0x320d18,_0x42cef3=[],_0x23a9dc=createInterface({'input':process['stdin'],'terminal':![]});_0x23a9dc['on'](_0x7d6866(0x13d),_0x4b88e6=>{const _0x4fca93=_0x7d6866;_0x42cef3[_0x4fca93(0x14c)](_0x4b88e6);}),_0x23a9dc['on'](_0x7d6866(0x147),()=>{const _0x1c204d=_0x7d6866;_0x566a34(_0x42cef3[_0x1c204d(0x132)]('\x0a'));}),_0x23a9dc['on'](_0x7d6866(0x14d),_0x5c3091=>{const _0x3e4afb=_0x7d6866;_0x23a9dc[_0x3e4afb(0x147)](),_0x526fb4(new Error(_0x3e4afb(0x13b)+_0x5c3091['message']));});});}function a91_0x35f3(){const _0x28df5a=['close','868090nszppw','227124rrYjsv','File\x20\x27','trim','push','error','236573EtJpen','stdin\x20','message','join','isTTY','3rHLhrn','12931524jbPQuq','utf-8','\x27\x20not\x20found','2722244QdzVfD','18JAdPsv','length','Error\x20reading\x20from\x20stdin:\x20','EACCES','line','ENOENT','stdin','2814232oTNVsu','Error\x20reading\x20file\x20\x27','toLowerCase','1185692TGgVVB','Content\x20contains\x20no\x20SQL\x20statements','\x27:\x20','filter'];a91_0x35f3=function(){return _0x28df5a;};return a91_0x35f3();}export async function readSqlStatementsFromStdin(){const _0x20bab2=a91_0x54bc,_0x33ae71=await readStdinContent();try{return splitSqlStatements(_0x33ae71);}catch(_0x13adec){throw new Error(_0x20bab2(0x14f)+_0x13adec[_0x20bab2(0x150)]['toLowerCase']());}}export function isSqlFilePath(_0x2d448e){return/\w\.sql$/['test'](_0x2d448e);}
|