@smythos/sre 1.5.0 → 1.5.2
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/CHANGELOG +62 -0
- package/LICENSE +18 -0
- package/package.json +127 -115
- package/src/Components/APICall/APICall.class.ts +155 -0
- package/src/Components/APICall/AccessTokenManager.ts +130 -0
- package/src/Components/APICall/ArrayBufferResponse.helper.ts +58 -0
- package/src/Components/APICall/OAuth.helper.ts +294 -0
- package/src/Components/APICall/mimeTypeCategories.ts +46 -0
- package/src/Components/APICall/parseData.ts +167 -0
- package/src/Components/APICall/parseHeaders.ts +41 -0
- package/src/Components/APICall/parseProxy.ts +68 -0
- package/src/Components/APICall/parseUrl.ts +91 -0
- package/src/Components/APIEndpoint.class.ts +234 -0
- package/src/Components/APIOutput.class.ts +58 -0
- package/src/Components/AgentPlugin.class.ts +102 -0
- package/src/Components/Async.class.ts +155 -0
- package/src/Components/Await.class.ts +90 -0
- package/src/Components/Classifier.class.ts +158 -0
- package/src/Components/Component.class.ts +94 -0
- package/src/Components/ComponentHost.class.ts +38 -0
- package/src/Components/DataSourceCleaner.class.ts +92 -0
- package/src/Components/DataSourceIndexer.class.ts +181 -0
- package/src/Components/DataSourceLookup.class.ts +141 -0
- package/src/Components/FEncDec.class.ts +29 -0
- package/src/Components/FHash.class.ts +33 -0
- package/src/Components/FSign.class.ts +80 -0
- package/src/Components/FSleep.class.ts +25 -0
- package/src/Components/FTimestamp.class.ts +25 -0
- package/src/Components/FileStore.class.ts +75 -0
- package/src/Components/ForEach.class.ts +97 -0
- package/src/Components/GPTPlugin.class.ts +70 -0
- package/src/Components/GenAILLM.class.ts +395 -0
- package/src/Components/HuggingFace.class.ts +314 -0
- package/src/Components/Image/imageSettings.config.ts +70 -0
- package/src/Components/ImageGenerator.class.ts +407 -0
- package/src/Components/JSONFilter.class.ts +54 -0
- package/src/Components/LLMAssistant.class.ts +213 -0
- package/src/Components/LogicAND.class.ts +28 -0
- package/src/Components/LogicAtLeast.class.ts +85 -0
- package/src/Components/LogicAtMost.class.ts +86 -0
- package/src/Components/LogicOR.class.ts +29 -0
- package/src/Components/LogicXOR.class.ts +34 -0
- package/src/Components/MCPClient.class.ts +112 -0
- package/src/Components/PromptGenerator.class.ts +122 -0
- package/src/Components/ScrapflyWebScrape.class.ts +159 -0
- package/src/Components/TavilyWebSearch.class.ts +98 -0
- package/src/Components/index.ts +77 -0
- package/src/Core/AgentProcess.helper.ts +240 -0
- package/src/Core/Connector.class.ts +123 -0
- package/src/Core/ConnectorsService.ts +192 -0
- package/src/Core/DummyConnector.ts +49 -0
- package/src/Core/HookService.ts +105 -0
- package/src/Core/SmythRuntime.class.ts +292 -0
- package/src/Core/SystemEvents.ts +15 -0
- package/src/Core/boot.ts +55 -0
- package/src/config.ts +15 -0
- package/src/constants.ts +125 -0
- package/src/data/hugging-face.params.json +580 -0
- package/src/helpers/BinaryInput.helper.ts +324 -0
- package/src/helpers/Conversation.helper.ts +1094 -0
- package/src/helpers/JsonContent.helper.ts +97 -0
- package/src/helpers/LocalCache.helper.ts +97 -0
- package/src/helpers/Log.helper.ts +234 -0
- package/src/helpers/OpenApiParser.helper.ts +150 -0
- package/src/helpers/S3Cache.helper.ts +129 -0
- package/src/helpers/SmythURI.helper.ts +5 -0
- package/src/helpers/TemplateString.helper.ts +243 -0
- package/src/helpers/TypeChecker.helper.ts +329 -0
- package/src/index.ts +179 -0
- package/src/index.ts.bak +179 -0
- package/src/subsystems/AgentManager/Agent.class.ts +1108 -0
- package/src/subsystems/AgentManager/Agent.helper.ts +3 -0
- package/src/subsystems/AgentManager/AgentData.service/AgentDataConnector.ts +230 -0
- package/src/subsystems/AgentManager/AgentData.service/connectors/CLIAgentDataConnector.class.ts +66 -0
- package/src/subsystems/AgentManager/AgentData.service/connectors/LocalAgentDataConnector.class.ts +142 -0
- package/src/subsystems/AgentManager/AgentData.service/connectors/NullAgentData.class.ts +39 -0
- package/src/subsystems/AgentManager/AgentData.service/index.ts +18 -0
- package/src/subsystems/AgentManager/AgentLogger.class.ts +297 -0
- package/src/subsystems/AgentManager/AgentRequest.class.ts +51 -0
- package/src/subsystems/AgentManager/AgentRuntime.class.ts +559 -0
- package/src/subsystems/AgentManager/AgentSSE.class.ts +101 -0
- package/src/subsystems/AgentManager/AgentSettings.class.ts +52 -0
- package/src/subsystems/AgentManager/Component.service/ComponentConnector.ts +32 -0
- package/src/subsystems/AgentManager/Component.service/connectors/LocalComponentConnector.class.ts +59 -0
- package/src/subsystems/AgentManager/Component.service/index.ts +11 -0
- package/src/subsystems/AgentManager/EmbodimentSettings.class.ts +47 -0
- package/src/subsystems/AgentManager/ForkedAgent.class.ts +153 -0
- package/src/subsystems/AgentManager/OSResourceMonitor.ts +77 -0
- package/src/subsystems/ComputeManager/Code.service/CodeConnector.ts +99 -0
- package/src/subsystems/ComputeManager/Code.service/connectors/AWSLambdaCode.class.ts +63 -0
- package/src/subsystems/ComputeManager/Code.service/index.ts +11 -0
- package/src/subsystems/IO/CLI.service/CLIConnector.ts +47 -0
- package/src/subsystems/IO/CLI.service/index.ts +9 -0
- package/src/subsystems/IO/Log.service/LogConnector.ts +32 -0
- package/src/subsystems/IO/Log.service/connectors/ConsoleLog.class.ts +28 -0
- package/src/subsystems/IO/Log.service/index.ts +13 -0
- package/src/subsystems/IO/NKV.service/NKVConnector.ts +41 -0
- package/src/subsystems/IO/NKV.service/connectors/NKVRAM.class.ts +204 -0
- package/src/subsystems/IO/NKV.service/connectors/NKVRedis.class.ts +182 -0
- package/src/subsystems/IO/NKV.service/index.ts +12 -0
- package/src/subsystems/IO/Router.service/RouterConnector.ts +21 -0
- package/src/subsystems/IO/Router.service/connectors/ExpressRouter.class.ts +48 -0
- package/src/subsystems/IO/Router.service/connectors/NullRouter.class.ts +40 -0
- package/src/subsystems/IO/Router.service/index.ts +11 -0
- package/src/subsystems/IO/Storage.service/SmythFS.class.ts +472 -0
- package/src/subsystems/IO/Storage.service/StorageConnector.ts +66 -0
- package/src/subsystems/IO/Storage.service/connectors/LocalStorage.class.ts +305 -0
- package/src/subsystems/IO/Storage.service/connectors/S3Storage.class.ts +418 -0
- package/src/subsystems/IO/Storage.service/index.ts +13 -0
- package/src/subsystems/IO/VectorDB.service/VectorDBConnector.ts +108 -0
- package/src/subsystems/IO/VectorDB.service/connectors/MilvusVectorDB.class.ts +450 -0
- package/src/subsystems/IO/VectorDB.service/connectors/PineconeVectorDB.class.ts +373 -0
- package/src/subsystems/IO/VectorDB.service/connectors/RAMVecrtorDB.class.ts +420 -0
- package/src/subsystems/IO/VectorDB.service/embed/BaseEmbedding.ts +106 -0
- package/src/subsystems/IO/VectorDB.service/embed/OpenAIEmbedding.ts +109 -0
- package/src/subsystems/IO/VectorDB.service/embed/index.ts +21 -0
- package/src/subsystems/IO/VectorDB.service/index.ts +14 -0
- package/src/subsystems/LLMManager/LLM.helper.ts +221 -0
- package/src/subsystems/LLMManager/LLM.inference.ts +335 -0
- package/src/subsystems/LLMManager/LLM.service/LLMConnector.ts +374 -0
- package/src/subsystems/LLMManager/LLM.service/LLMCredentials.helper.ts +145 -0
- package/src/subsystems/LLMManager/LLM.service/connectors/Anthropic.class.ts +632 -0
- package/src/subsystems/LLMManager/LLM.service/connectors/Bedrock.class.ts +405 -0
- package/src/subsystems/LLMManager/LLM.service/connectors/Echo.class.ts +81 -0
- package/src/subsystems/LLMManager/LLM.service/connectors/GoogleAI.class.ts +689 -0
- package/src/subsystems/LLMManager/LLM.service/connectors/Groq.class.ts +257 -0
- package/src/subsystems/LLMManager/LLM.service/connectors/OpenAI.class.ts +848 -0
- package/src/subsystems/LLMManager/LLM.service/connectors/Perplexity.class.ts +255 -0
- package/src/subsystems/LLMManager/LLM.service/connectors/VertexAI.class.ts +193 -0
- package/src/subsystems/LLMManager/LLM.service/index.ts +43 -0
- package/src/subsystems/LLMManager/ModelsProvider.service/ModelsProviderConnector.ts +281 -0
- package/src/subsystems/LLMManager/ModelsProvider.service/connectors/SmythModelsProvider.class.ts +229 -0
- package/src/subsystems/LLMManager/ModelsProvider.service/index.ts +11 -0
- package/src/subsystems/LLMManager/custom-models.ts +854 -0
- package/src/subsystems/LLMManager/models.ts +2539 -0
- package/src/subsystems/LLMManager/paramMappings.ts +69 -0
- package/src/subsystems/MemoryManager/Cache.service/CacheConnector.ts +86 -0
- package/src/subsystems/MemoryManager/Cache.service/connectors/LocalStorageCache.class.ts +297 -0
- package/src/subsystems/MemoryManager/Cache.service/connectors/RAMCache.class.ts +201 -0
- package/src/subsystems/MemoryManager/Cache.service/connectors/RedisCache.class.ts +252 -0
- package/src/subsystems/MemoryManager/Cache.service/connectors/S3Cache.class.ts +373 -0
- package/src/subsystems/MemoryManager/Cache.service/index.ts +15 -0
- package/src/subsystems/MemoryManager/LLMCache.ts +72 -0
- package/src/subsystems/MemoryManager/LLMContext.ts +125 -0
- package/src/subsystems/MemoryManager/RuntimeContext.ts +249 -0
- package/src/subsystems/Security/AccessControl/ACL.class.ts +208 -0
- package/src/subsystems/Security/AccessControl/AccessCandidate.class.ts +76 -0
- package/src/subsystems/Security/AccessControl/AccessRequest.class.ts +52 -0
- package/src/subsystems/Security/Account.service/AccountConnector.ts +41 -0
- package/src/subsystems/Security/Account.service/connectors/AWSAccount.class.ts +76 -0
- package/src/subsystems/Security/Account.service/connectors/DummyAccount.class.ts +130 -0
- package/src/subsystems/Security/Account.service/connectors/JSONFileAccount.class.ts +159 -0
- package/src/subsystems/Security/Account.service/index.ts +14 -0
- package/src/subsystems/Security/Credentials.helper.ts +62 -0
- package/src/subsystems/Security/ManagedVault.service/ManagedVaultConnector.ts +34 -0
- package/src/subsystems/Security/ManagedVault.service/connectors/NullManagedVault.class.ts +57 -0
- package/src/subsystems/Security/ManagedVault.service/connectors/SecretManagerManagedVault.ts +154 -0
- package/src/subsystems/Security/ManagedVault.service/index.ts +12 -0
- package/src/subsystems/Security/SecureConnector.class.ts +110 -0
- package/src/subsystems/Security/Vault.service/Vault.helper.ts +30 -0
- package/src/subsystems/Security/Vault.service/VaultConnector.ts +26 -0
- package/src/subsystems/Security/Vault.service/connectors/HashicorpVault.class.ts +46 -0
- package/src/subsystems/Security/Vault.service/connectors/JSONFileVault.class.ts +166 -0
- package/src/subsystems/Security/Vault.service/connectors/NullVault.class.ts +54 -0
- package/src/subsystems/Security/Vault.service/connectors/SecretsManager.class.ts +140 -0
- package/src/subsystems/Security/Vault.service/index.ts +12 -0
- package/src/types/ACL.types.ts +104 -0
- package/src/types/AWS.types.ts +9 -0
- package/src/types/Agent.types.ts +61 -0
- package/src/types/AgentLogger.types.ts +17 -0
- package/src/types/Cache.types.ts +1 -0
- package/src/types/Common.types.ts +3 -0
- package/src/types/LLM.types.ts +419 -0
- package/src/types/Redis.types.ts +8 -0
- package/src/types/SRE.types.ts +64 -0
- package/src/types/Security.types.ts +18 -0
- package/src/types/Storage.types.ts +5 -0
- package/src/types/VectorDB.types.ts +78 -0
- package/src/utils/base64.utils.ts +275 -0
- package/src/utils/cli.utils.ts +68 -0
- package/src/utils/data.utils.ts +263 -0
- package/src/utils/date-time.utils.ts +22 -0
- package/src/utils/general.utils.ts +238 -0
- package/src/utils/index.ts +12 -0
- package/src/utils/numbers.utils.ts +13 -0
- package/src/utils/oauth.utils.ts +35 -0
- package/src/utils/string.utils.ts +414 -0
- package/src/utils/url.utils.ts +19 -0
- package/src/utils/validation.utils.ts +74 -0
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { IAgent as Agent } from '@sre/types/Agent.types';
|
|
2
|
+
import { Component } from './Component.class';
|
|
3
|
+
import axios from 'axios';
|
|
4
|
+
import Joi from 'joi';
|
|
5
|
+
import { Async } from './Async.class';
|
|
6
|
+
|
|
7
|
+
export class Await extends Component {
|
|
8
|
+
static WAITS = {};
|
|
9
|
+
|
|
10
|
+
protected configSchema = Joi.object({
|
|
11
|
+
jobs_count: Joi.number().min(1).max(100).default(1).label('Jobs Count'),
|
|
12
|
+
max_time: Joi.number().min(1).max(21600).default(1).label('Max time'),
|
|
13
|
+
});
|
|
14
|
+
constructor() {
|
|
15
|
+
super();
|
|
16
|
+
}
|
|
17
|
+
init() {}
|
|
18
|
+
async process(input, config, agent: Agent) {
|
|
19
|
+
await super.process(input, config, agent);
|
|
20
|
+
|
|
21
|
+
const logger = this.createComponentLogger(agent, config);
|
|
22
|
+
try {
|
|
23
|
+
let Results: any = {};
|
|
24
|
+
const _error = null;
|
|
25
|
+
let jobs_count = parseInt(config.data.jobs_count || 1);
|
|
26
|
+
let max_time = parseInt(config.data.max_time || 1);
|
|
27
|
+
|
|
28
|
+
const jobs = Array.isArray(input.Jobs) ? input.Jobs : [input.Jobs];
|
|
29
|
+
|
|
30
|
+
if (!Await.WAITS[agent.id]) Await.WAITS[agent.id] = {};
|
|
31
|
+
if (!Await.WAITS[agent.id][config.id]) Await.WAITS[agent.id][config.id] = {};
|
|
32
|
+
if (!Await.WAITS[agent.id][config.id][agent.agentRuntime.workflowReqId])
|
|
33
|
+
Await.WAITS[agent.id][config.id][agent.agentRuntime.workflowReqId] = [];
|
|
34
|
+
|
|
35
|
+
//add jobs to the list
|
|
36
|
+
for (let jobID of jobs) Await.WAITS[agent.id][config.id][agent.agentRuntime.workflowReqId].push(jobID);
|
|
37
|
+
|
|
38
|
+
logger.debug('Jobs', jobs);
|
|
39
|
+
logger.debug('Waiting for jobs to finish');
|
|
40
|
+
|
|
41
|
+
let promise = new Promise((resolve, reject) => {
|
|
42
|
+
let interval = setInterval(() => {
|
|
43
|
+
if (max_time < 0) {
|
|
44
|
+
clearInterval(interval);
|
|
45
|
+
return resolve(true);
|
|
46
|
+
}
|
|
47
|
+
let done = true;
|
|
48
|
+
let completed = 0;
|
|
49
|
+
for (let jobID of jobs) {
|
|
50
|
+
if (Async.JOBS?.[agent.id]?.[jobID]?.status == 'pending') {
|
|
51
|
+
done = false;
|
|
52
|
+
break;
|
|
53
|
+
} else {
|
|
54
|
+
completed++;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
if (completed >= jobs_count) {
|
|
58
|
+
done = true;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
if (done) {
|
|
62
|
+
clearInterval(interval);
|
|
63
|
+
return resolve(true);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
max_time -= 1;
|
|
67
|
+
}, 1000);
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
await promise;
|
|
71
|
+
logger.debug('Jobs finished, collecting results');
|
|
72
|
+
for (let jobID of jobs) {
|
|
73
|
+
Results[jobID] = {
|
|
74
|
+
output: Async.JOBS?.[agent.id]?.[jobID]?.result,
|
|
75
|
+
status: Async.JOBS?.[agent.id]?.[jobID]?.status || 'unknown_job',
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
delete Await.WAITS[agent.id][config.id][agent.agentRuntime.workflowReqId];
|
|
79
|
+
|
|
80
|
+
logger.debug('Results', Results);
|
|
81
|
+
return { Results, _error, _debug: logger.output, _debug_time: logger.elapsedTime };
|
|
82
|
+
} catch (err: any) {
|
|
83
|
+
const _error = err?.response?.data || err?.message || err.toString();
|
|
84
|
+
logger.error(` Error running code \n${_error}\n`);
|
|
85
|
+
delete Await.WAITS[agent.id][config.id][agent.agentRuntime.workflowReqId];
|
|
86
|
+
|
|
87
|
+
return { Output: undefined, _error, _debug: logger.output, _debug_time: logger.elapsedTime };
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
import Joi from 'joi';
|
|
2
|
+
|
|
3
|
+
import { JSONContentHelper } from '@sre/helpers/JsonContent.helper';
|
|
4
|
+
import { Component } from './Component.class';
|
|
5
|
+
import { IAgent as Agent } from '@sre/types/Agent.types';
|
|
6
|
+
import { TemplateString } from '@sre/helpers/TemplateString.helper';
|
|
7
|
+
import { LLMInference } from '@sre/LLMManager/LLM.inference';
|
|
8
|
+
import { AccessCandidate } from '@sre/Security/AccessControl/AccessCandidate.class';
|
|
9
|
+
|
|
10
|
+
export class Classifier extends Component {
|
|
11
|
+
protected schema = {
|
|
12
|
+
name: 'Classifier',
|
|
13
|
+
settings: {
|
|
14
|
+
model: {
|
|
15
|
+
type: 'string',
|
|
16
|
+
max: 200,
|
|
17
|
+
required: true,
|
|
18
|
+
},
|
|
19
|
+
prompt: {
|
|
20
|
+
type: 'string',
|
|
21
|
+
max: 30000,
|
|
22
|
+
allow: '',
|
|
23
|
+
label: 'Prompt',
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
|
|
27
|
+
inputs: {
|
|
28
|
+
Input: {
|
|
29
|
+
type: 'Any',
|
|
30
|
+
default: true,
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
};
|
|
34
|
+
protected configSchema = Joi.object({
|
|
35
|
+
model: Joi.string().max(200).required(),
|
|
36
|
+
prompt: Joi.string().max(30000).allow('').label('Prompt'),
|
|
37
|
+
});
|
|
38
|
+
constructor() {
|
|
39
|
+
super();
|
|
40
|
+
}
|
|
41
|
+
init() {}
|
|
42
|
+
escapeJSONString(str: string) {
|
|
43
|
+
return str.replace(/\{/g, '<[<(').replace(/\}/g, ')>]>').replace(/"/g, '`');
|
|
44
|
+
}
|
|
45
|
+
unescapeJSONString(str: string) {
|
|
46
|
+
return str
|
|
47
|
+
.replace(/<\[<\(/g, '{')
|
|
48
|
+
.replace(/\)>]>/g, '}')
|
|
49
|
+
.replace(/`/g, '"');
|
|
50
|
+
}
|
|
51
|
+
async process(input, config, agent: Agent) {
|
|
52
|
+
await super.process(input, config, agent);
|
|
53
|
+
//let debugLog = agent.agentRuntime?.debug ? [] : undefined;
|
|
54
|
+
const logger = this.createComponentLogger(agent, config);
|
|
55
|
+
|
|
56
|
+
const inputCopy = JSON.parse(JSON.stringify(input));
|
|
57
|
+
for (let key in inputCopy) {
|
|
58
|
+
if (typeof inputCopy[key] === 'string') {
|
|
59
|
+
inputCopy[key] = this.escapeJSONString(inputCopy[key]);
|
|
60
|
+
} else if (typeof inputCopy[key] === 'object') {
|
|
61
|
+
inputCopy[key] = JSON.stringify(inputCopy[key]);
|
|
62
|
+
inputCopy[key] = this.escapeJSONString(inputCopy[key]);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
const _input = typeof input === 'string' ? input : JSON.stringify(inputCopy, null, 2);
|
|
67
|
+
//const categories = config.outputs.map((output) => (output.name[0] != '[' ? output.name : null)).filter((e) => e);
|
|
68
|
+
const categories = {};
|
|
69
|
+
for (let con of config.outputs) categories[con.name] = con.description || '';
|
|
70
|
+
|
|
71
|
+
const outputs = {};
|
|
72
|
+
for (let con of config.outputs) {
|
|
73
|
+
outputs[con.name] = '<Boolean|String>';
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
const model: string = config.data.model;
|
|
77
|
+
const modelId = await agent.modelsProvider.getModelId(model);
|
|
78
|
+
//const isStandardLLM = await agent.modelsProvider.isStandardLLM(model);
|
|
79
|
+
|
|
80
|
+
logger.log(` Selected model : ${modelId || model}`);
|
|
81
|
+
|
|
82
|
+
let prompt = '';
|
|
83
|
+
const excludedKeys = ['_debug', '_error'];
|
|
84
|
+
const outputKeys = Object.keys(outputs).filter((key) => !excludedKeys.includes(key));
|
|
85
|
+
|
|
86
|
+
if (outputKeys.length > 0) {
|
|
87
|
+
const outputFormat = {};
|
|
88
|
+
outputKeys.forEach((key) => (outputFormat[key] = outputs[key]));
|
|
89
|
+
|
|
90
|
+
prompt = `${config.data.prompt}
|
|
91
|
+
${_input}
|
|
92
|
+
|
|
93
|
+
---
|
|
94
|
+
Categories:
|
|
95
|
+
${JSON.stringify(categories, null, 2)}`;
|
|
96
|
+
|
|
97
|
+
prompt = TemplateString(prompt).parse(input).result;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
logger.log(` Enhanced prompt \n${prompt}\n`);
|
|
101
|
+
|
|
102
|
+
if (!prompt) {
|
|
103
|
+
logger.error(` Missing information, Cannot run classifier`);
|
|
104
|
+
|
|
105
|
+
return { _error: 'Missing information, Cannot run classifier', _debug: logger.output };
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
const llmInference: LLMInference = await LLMInference.getInstance(model || 'echo', AccessCandidate.agent(agent.id));
|
|
109
|
+
if (!llmInference.connector) {
|
|
110
|
+
return {
|
|
111
|
+
_error: `The model '${model}' is not available. Please try a different one.`,
|
|
112
|
+
_debug: logger.output,
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
try {
|
|
117
|
+
let response = await llmInference
|
|
118
|
+
.prompt({ query: prompt, params: { ...config, agentId: agent.id } })
|
|
119
|
+
.catch((error) => ({ error: error }));
|
|
120
|
+
|
|
121
|
+
if (response?.error) {
|
|
122
|
+
const error = response?.error + ' ' + (response?.details || '');
|
|
123
|
+
logger.error(` LLM Error=`, error);
|
|
124
|
+
|
|
125
|
+
return { _error: error, _debug: logger.output };
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
// let parsed = parseJson(response);
|
|
129
|
+
let parsed = typeof response === 'string' ? JSONContentHelper.create(response).tryParse() : response;
|
|
130
|
+
|
|
131
|
+
for (let entry in parsed) {
|
|
132
|
+
if (!parsed[entry]) delete parsed[entry];
|
|
133
|
+
else {
|
|
134
|
+
if (typeof parsed[entry] === 'string') {
|
|
135
|
+
parsed[entry] = this.unescapeJSONString(parsed[entry]);
|
|
136
|
+
// const parsedValue = parseJson(parsed[entry]);
|
|
137
|
+
const parsedValue = JSONContentHelper.create(parsed[entry]).tryParse();
|
|
138
|
+
if (typeof parsedValue === 'object' && !parsedValue.error) parsed[entry] = parsedValue;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
if (parsed.error) {
|
|
144
|
+
parsed._error = parsed.error;
|
|
145
|
+
logger.warn(` Post process error=${parsed.error}`);
|
|
146
|
+
delete parsed.error;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
logger.log(' Classifier result\n', parsed);
|
|
150
|
+
|
|
151
|
+
parsed['_debug'] = logger.output;
|
|
152
|
+
|
|
153
|
+
return parsed;
|
|
154
|
+
} catch (error) {
|
|
155
|
+
return { _error: error.message, _debug: logger.output };
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import Joi from 'joi';
|
|
2
|
+
import { IAgent as Agent } from '@sre/types/Agent.types';
|
|
3
|
+
import { Logger } from '@sre/helpers/Log.helper';
|
|
4
|
+
import { performTypeInference } from '@sre/helpers/TypeChecker.helper';
|
|
5
|
+
import { hookAsync } from '@sre/Core/HookService';
|
|
6
|
+
|
|
7
|
+
export type ComponentSchema = {
|
|
8
|
+
name: string;
|
|
9
|
+
settings?: Record<string, any>;
|
|
10
|
+
inputs?: Record<string, any>;
|
|
11
|
+
outputs?: Record<string, any>;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export class Component {
|
|
15
|
+
public hasReadOutput = false;
|
|
16
|
+
public hasPostProcess = true;
|
|
17
|
+
public alwaysActive = false; //for components like readable memories
|
|
18
|
+
public exclusive = false; //for components like writable memories : when exclusive components are active, they are processed in a run cycle bofore other components
|
|
19
|
+
protected schema: ComponentSchema = {
|
|
20
|
+
name: 'Component',
|
|
21
|
+
settings: {},
|
|
22
|
+
inputs: {},
|
|
23
|
+
//outputs: {},
|
|
24
|
+
};
|
|
25
|
+
protected configSchema;
|
|
26
|
+
constructor() {}
|
|
27
|
+
init() {}
|
|
28
|
+
|
|
29
|
+
createComponentLogger(agent: Agent, configuration: any) {
|
|
30
|
+
const logger = Logger(configuration.name || this.constructor.name, agent?.agentRuntime?.debug);
|
|
31
|
+
|
|
32
|
+
logger.on('logged', (info: { level: string; message: string }) => {
|
|
33
|
+
if (agent.sse && configuration.eventId) {
|
|
34
|
+
agent.sse.send('component', {
|
|
35
|
+
eventId: configuration.eventId,
|
|
36
|
+
action: 'log',
|
|
37
|
+
name: configuration.name || this.constructor.name,
|
|
38
|
+
title: configuration.title,
|
|
39
|
+
logs: [{ level: info.level, message: info.message }],
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
return logger;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
async validateConfig(config) {
|
|
47
|
+
if (!this.configSchema) return {};
|
|
48
|
+
if (config.data._templateVars) {
|
|
49
|
+
//Accept dynamically added template data
|
|
50
|
+
for (let tplVar in config.data._templateVars) {
|
|
51
|
+
this.configSchema = this.configSchema.append({ [tplVar]: Joi.any() });
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
const valid = await this.configSchema.validate(config.data);
|
|
55
|
+
if (valid.error) {
|
|
56
|
+
return {
|
|
57
|
+
id: config.id,
|
|
58
|
+
name: config.name,
|
|
59
|
+
_error: `Schema Validation error: ${valid?.error?.message} on component ${config.displayName}:${config.title}`,
|
|
60
|
+
_debug: `Schema Validation error: ${valid?.error?.message} on component ${config.displayName}:${config.title}`,
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
return {};
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
@hookAsync('Component.process')
|
|
68
|
+
async process(input, config, agent: Agent): Promise<any> {
|
|
69
|
+
if (agent.isKilled()) {
|
|
70
|
+
throw new Error('Agent killed');
|
|
71
|
+
}
|
|
72
|
+
const _input = await performTypeInference(input, config?.inputs, agent);
|
|
73
|
+
|
|
74
|
+
// modify the input object for component's process method
|
|
75
|
+
for (const [key, value] of Object.entries(_input)) {
|
|
76
|
+
input[key] = value;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
async postProcess(output, config, agent: Agent): Promise<any> {
|
|
80
|
+
if (output?.result) {
|
|
81
|
+
delete output?.result?._debug;
|
|
82
|
+
if (!output?.result?._error) delete output?.result?._error;
|
|
83
|
+
}
|
|
84
|
+
return output;
|
|
85
|
+
}
|
|
86
|
+
async enable(config, agent: Agent): Promise<any> {}
|
|
87
|
+
async disable(config, agent: Agent): Promise<any> {}
|
|
88
|
+
readOutput(id, config, agent: Agent): any {
|
|
89
|
+
return null;
|
|
90
|
+
}
|
|
91
|
+
hasOutput(id, config, agent: Agent): any {
|
|
92
|
+
return false;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { Component } from './Component.class';
|
|
2
|
+
import { IAgent as Agent } from '@sre/types/Agent.types';
|
|
3
|
+
import { ConnectorService } from '@sre/Core/ConnectorsService';
|
|
4
|
+
import { AccessCandidate } from '@sre/Security/AccessControl/AccessCandidate.class';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* This component allows running components that are not natively shiped with SRE
|
|
8
|
+
* it can be used to extend SRE components by registering custom component using ComponentService
|
|
9
|
+
*/
|
|
10
|
+
export class ComponentHost extends Component {
|
|
11
|
+
protected configSchema = null;
|
|
12
|
+
constructor() {
|
|
13
|
+
super();
|
|
14
|
+
}
|
|
15
|
+
init() {}
|
|
16
|
+
|
|
17
|
+
async process(input, config, agent: Agent) {
|
|
18
|
+
await super.process(input, config, agent);
|
|
19
|
+
//let debugLog = agent.agentRuntime?.debug ? [] : undefined;
|
|
20
|
+
const logger = this.createComponentLogger(agent, config);
|
|
21
|
+
|
|
22
|
+
try {
|
|
23
|
+
const componentName = config.data._component;
|
|
24
|
+
const componentConnector = ConnectorService.getComponentConnector();
|
|
25
|
+
|
|
26
|
+
const component = await componentConnector.requester(AccessCandidate.agent(agent.id)).get(componentName);
|
|
27
|
+
|
|
28
|
+
if (!component) {
|
|
29
|
+
logger.debug(`Component ${componentName} not found`);
|
|
30
|
+
return { _error: `Component ${componentName} not found`, _debug: logger.output };
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
return await component.process(input, config, agent);
|
|
34
|
+
} catch (error) {
|
|
35
|
+
return { _error: error.message, _debug: logger.output };
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { IAgent as Agent } from '@sre/types/Agent.types';
|
|
2
|
+
import { Component } from './Component.class';
|
|
3
|
+
import { TemplateString } from '@sre/helpers/TemplateString.helper';
|
|
4
|
+
import Joi from 'joi';
|
|
5
|
+
import { validateCharacterSet } from '../utils';
|
|
6
|
+
import { ConnectorService } from '@sre/Core/ConnectorsService';
|
|
7
|
+
import { AccessCandidate } from '@sre/Security/AccessControl/AccessCandidate.class';
|
|
8
|
+
|
|
9
|
+
import { DataSourceIndexer } from './DataSourceIndexer.class';
|
|
10
|
+
|
|
11
|
+
export class DataSourceCleaner extends Component {
|
|
12
|
+
protected configSchema = Joi.object({
|
|
13
|
+
namespaceId: Joi.string().max(50).allow('').label('namespace'),
|
|
14
|
+
id: Joi.string().custom(validateCharacterSet, 'custom validation characterSet').allow('').label('source identifier'),
|
|
15
|
+
});
|
|
16
|
+
constructor() {
|
|
17
|
+
super();
|
|
18
|
+
}
|
|
19
|
+
init() {}
|
|
20
|
+
async process(input, config, agent: Agent) {
|
|
21
|
+
await super.process(input, config, agent);
|
|
22
|
+
const teamId = agent.teamId;
|
|
23
|
+
const agentId = agent.id;
|
|
24
|
+
let debugOutput = agent.agentRuntime?.debug ? '== Source Indexer Log ==\n' : null;
|
|
25
|
+
|
|
26
|
+
try {
|
|
27
|
+
const configSchema = this.validateConfigData(config.data);
|
|
28
|
+
if (configSchema.error) {
|
|
29
|
+
throw new Error(`Config data validation error: ${configSchema.error}\n EXITING...`);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const outputs = {};
|
|
33
|
+
for (let con of config.outputs) {
|
|
34
|
+
if (con.default) continue;
|
|
35
|
+
outputs[con.name] = con?.description ? `<${con?.description}>` : '';
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const inputSchema = this.validateInput(input);
|
|
39
|
+
if (inputSchema.error) {
|
|
40
|
+
throw new Error(`Input validation error: ${inputSchema.error}\n EXITING...`);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const namespaceId = configSchema.value.namespaceId.split('_')?.slice(1).join('_') || configSchema.value.namespaceId;
|
|
44
|
+
|
|
45
|
+
let vectorDbConnector = ConnectorService.getVectorDBConnector();
|
|
46
|
+
|
|
47
|
+
let existingnamespace = await vectorDbConnector.requester(AccessCandidate.team(teamId)).namespaceExists(namespaceId);
|
|
48
|
+
if (!existingnamespace) {
|
|
49
|
+
throw new Error(`Namespace ${namespaceId} does not exist`);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const providedId = TemplateString(config.data.id).parse(input).result;
|
|
53
|
+
const idRegex = /^[a-zA-Z0-9\-\_\.]+$/;
|
|
54
|
+
if (!idRegex.test(providedId)) {
|
|
55
|
+
throw new Error(`Invalid id. Accepted characters: 'a-z', 'A-Z', '0-9', '-', '_', '.'`);
|
|
56
|
+
}
|
|
57
|
+
debugOutput += `Searching for data source with id: ${providedId}\n`;
|
|
58
|
+
|
|
59
|
+
const dsId = DataSourceIndexer.genDsId(providedId, teamId, namespaceId);
|
|
60
|
+
|
|
61
|
+
await vectorDbConnector.requester(AccessCandidate.team(teamId)).deleteDatasource(namespaceId, dsId);
|
|
62
|
+
|
|
63
|
+
debugOutput += `Deleted data source with id: ${providedId}\n`;
|
|
64
|
+
|
|
65
|
+
return {
|
|
66
|
+
_debug: debugOutput,
|
|
67
|
+
Success: true,
|
|
68
|
+
// _error,
|
|
69
|
+
};
|
|
70
|
+
} catch (err: any) {
|
|
71
|
+
debugOutput += `Failed to delete data source: \n Error: ${err?.message}\n`;
|
|
72
|
+
|
|
73
|
+
return {
|
|
74
|
+
_debug: debugOutput,
|
|
75
|
+
_error: err?.message || "Couldn't delete data source",
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
validateInput(input: any) {
|
|
81
|
+
return Joi.object({}).unknown(true).validate(input);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
validateConfigData(data: any) {
|
|
85
|
+
return Joi.object({
|
|
86
|
+
namespaceId: Joi.string().required(),
|
|
87
|
+
id: Joi.string().optional().allow('').allow(null),
|
|
88
|
+
})
|
|
89
|
+
.unknown(true)
|
|
90
|
+
.validate(data);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
import { IAgent as Agent } from '@sre/types/Agent.types';
|
|
2
|
+
import { Component } from './Component.class';
|
|
3
|
+
import Joi from 'joi';
|
|
4
|
+
import { validateCharacterSet } from '@sre/utils/validation.utils';
|
|
5
|
+
import { TemplateString } from '@sre/helpers/TemplateString.helper';
|
|
6
|
+
import { isUrl, detectURLSourceType } from '../utils';
|
|
7
|
+
import { SmythFS } from '@sre/IO/Storage.service/SmythFS.class';
|
|
8
|
+
import { ConnectorService } from '@sre/Core/ConnectorsService';
|
|
9
|
+
|
|
10
|
+
import { AccessCandidate } from '@sre/Security/AccessControl/AccessCandidate.class';
|
|
11
|
+
|
|
12
|
+
export class DataSourceIndexer extends Component {
|
|
13
|
+
private MAX_ALLOWED_URLS_PER_INPUT = 20;
|
|
14
|
+
protected configSchema = Joi.object({
|
|
15
|
+
namespace: Joi.string().max(50).allow(''),
|
|
16
|
+
id: Joi.string().custom(validateCharacterSet, 'id custom validation').allow('').label('source identifier'),
|
|
17
|
+
name: Joi.string().max(50).allow('').label('label'),
|
|
18
|
+
metadata: Joi.string().allow(null).allow('').max(10000).label('metadata'),
|
|
19
|
+
});
|
|
20
|
+
constructor() {
|
|
21
|
+
super();
|
|
22
|
+
}
|
|
23
|
+
init() {}
|
|
24
|
+
async process(input, config, agent: Agent) {
|
|
25
|
+
await super.process(input, config, agent);
|
|
26
|
+
const teamId = agent.teamId;
|
|
27
|
+
const agentId = agent.id;
|
|
28
|
+
let debugOutput = agent.agentRuntime?.debug ? '== Source Indexer Log ==\n' : null;
|
|
29
|
+
|
|
30
|
+
try {
|
|
31
|
+
const _config = {
|
|
32
|
+
...config.data,
|
|
33
|
+
name: TemplateString(config.data.name).parse(input).result,
|
|
34
|
+
id: TemplateString(config.data.id).parse(input).result,
|
|
35
|
+
metadata: TemplateString(config.data.metadata).parse(input).result,
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
const outputs = {};
|
|
39
|
+
for (let con of config.outputs) {
|
|
40
|
+
if (con.default) continue;
|
|
41
|
+
outputs[con.name] = con?.description ? `<${con?.description}>` : '';
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const namespaceId = _config.namespace.split('_').slice(1).join('_') || _config.namespace;
|
|
45
|
+
debugOutput += `[Selected namespace id] \n${namespaceId}\n\n`;
|
|
46
|
+
|
|
47
|
+
const vectorDbConnector =
|
|
48
|
+
// (await vectorDBHelper.getTeamConnector(teamId)) ||
|
|
49
|
+
ConnectorService.getVectorDBConnector();
|
|
50
|
+
const nsExists = await vectorDbConnector.requester(AccessCandidate.team(teamId)).namespaceExists(namespaceId);
|
|
51
|
+
|
|
52
|
+
if (!nsExists) {
|
|
53
|
+
const newNs = await vectorDbConnector.requester(AccessCandidate.team(teamId)).createNamespace(namespaceId);
|
|
54
|
+
debugOutput += `[Created namespace] \n${newNs}\n\n`;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const inputSchema = this.validateInput(input);
|
|
58
|
+
if (inputSchema.error) {
|
|
59
|
+
throw new Error(`Input validation error: ${inputSchema.error}\n EXITING...`);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
const providedId = _config.id;
|
|
63
|
+
// const isAutoId = _config.isAutoId;
|
|
64
|
+
const idRegex = /^[a-zA-Z0-9\-\_\.]+$/;
|
|
65
|
+
|
|
66
|
+
if (!providedId) {
|
|
67
|
+
// Assign a new ID if it's set to auto-generate or not provided
|
|
68
|
+
// _config.id = crypto.randomBytes(16).toString('hex');
|
|
69
|
+
throw new Error(`Id is required`);
|
|
70
|
+
} else if (!idRegex.test(providedId)) {
|
|
71
|
+
// Validate the provided ID if it's not auto-generated
|
|
72
|
+
throw new Error(`Invalid id. Accepted characters: 'a-z', 'A-Z', '0-9', '-', '_', '.'`);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
// check if the datasource already exists with the same id
|
|
76
|
+
// await this.checkForRecordDuplicate(dsId, token);
|
|
77
|
+
|
|
78
|
+
let indexRes: any = null;
|
|
79
|
+
let parsedUrlArray: string[] | null = null;
|
|
80
|
+
|
|
81
|
+
//! DISABLE URL ARRAY PARSING FOR NOW UNTIL WE HAVE A GOOD WAY TO HANDLE BULK INDEXING
|
|
82
|
+
// if ((parsedUrlArray = parseUrlArray(inputSchema.value.Source))) {
|
|
83
|
+
// debugOutput += `STEP: Parsing input as url array\n\n`;
|
|
84
|
+
// if (parsedUrlArray.length > this.MAX_ALLOWED_URLS_PER_INPUT) {
|
|
85
|
+
// throw new Error(`Too many urls in input. Max allowed: ${this.MAX_ALLOWED_URLS_PER_INPUT}`);
|
|
86
|
+
// }
|
|
87
|
+
|
|
88
|
+
// for (let url of parsedUrlArray) {
|
|
89
|
+
// indexRes = await this.addDSFromUrl({
|
|
90
|
+
// teamId,
|
|
91
|
+
// namespaceId,
|
|
92
|
+
// dsId, // WILL OVERRIDE EACH OTHER
|
|
93
|
+
// type: detectURLSourceType(url),
|
|
94
|
+
// url,
|
|
95
|
+
// name: _config.name || 'Untitled',
|
|
96
|
+
// });
|
|
97
|
+
|
|
98
|
+
// debugOutput += `STEP: Created datasource for url: ${url}\n\n`;
|
|
99
|
+
// }
|
|
100
|
+
// } else
|
|
101
|
+
|
|
102
|
+
const dsId = DataSourceIndexer.genDsId(providedId, teamId, namespaceId);
|
|
103
|
+
|
|
104
|
+
if (isUrl(inputSchema.value.Source)) {
|
|
105
|
+
debugOutput += `STEP: Parsing input as url\n\n`;
|
|
106
|
+
throw new Error('URLs are not supported yet');
|
|
107
|
+
// indexRes = await this.addDSFromUrl({
|
|
108
|
+
// teamId,
|
|
109
|
+
// namespaceId,
|
|
110
|
+
// dsId,
|
|
111
|
+
// type: detectURLSourceType(inputSchema.value.Source),
|
|
112
|
+
// url: inputSchema.value.Source,
|
|
113
|
+
// name: _config.name || 'Untitled',
|
|
114
|
+
// metadata: _config.metadata || null,
|
|
115
|
+
// });
|
|
116
|
+
} else {
|
|
117
|
+
debugOutput += `STEP: Parsing input as text\n\n`;
|
|
118
|
+
indexRes = await this.addDSFromText({
|
|
119
|
+
teamId,
|
|
120
|
+
namespaceId: namespaceId,
|
|
121
|
+
text: inputSchema.value.Source,
|
|
122
|
+
name: _config.name || 'Untitled',
|
|
123
|
+
metadata: _config.metadata || null,
|
|
124
|
+
sourceId: dsId,
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
debugOutput += `Created datasource successfully\n\n`;
|
|
129
|
+
|
|
130
|
+
return {
|
|
131
|
+
_debug: debugOutput,
|
|
132
|
+
Success: {
|
|
133
|
+
result: indexRes?.data?.dataSource || true,
|
|
134
|
+
id: _config.id,
|
|
135
|
+
},
|
|
136
|
+
// _error,
|
|
137
|
+
};
|
|
138
|
+
} catch (err: any) {
|
|
139
|
+
debugOutput += `Error: ${err?.message || "Couldn't index data source"}\n\n`;
|
|
140
|
+
return {
|
|
141
|
+
_debug: debugOutput,
|
|
142
|
+
_error: err?.message || "Couldn't index data source",
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
validateInput(input: any) {
|
|
148
|
+
return Joi.object({
|
|
149
|
+
Source: Joi.any().required(),
|
|
150
|
+
})
|
|
151
|
+
.unknown(true)
|
|
152
|
+
.validate(input);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
private async addDSFromText({ teamId, sourceId, namespaceId, text, name, metadata }) {
|
|
156
|
+
let vectorDbConnector = ConnectorService.getVectorDBConnector();
|
|
157
|
+
// const isOnCustomStorage = await vectorDBHelper.isNamespaceOnCustomStorage(teamId, namespaceId);
|
|
158
|
+
// if (isOnCustomStorage) {
|
|
159
|
+
// const customTeamConnector = await vectorDBHelper.getTeamConnector(teamId);
|
|
160
|
+
// if (customTeamConnector) {
|
|
161
|
+
// vectorDbConnector = customTeamConnector;
|
|
162
|
+
// }
|
|
163
|
+
// }
|
|
164
|
+
const id = await vectorDbConnector.requester(AccessCandidate.team(teamId)).createDatasource(namespaceId, {
|
|
165
|
+
text,
|
|
166
|
+
metadata,
|
|
167
|
+
id: sourceId,
|
|
168
|
+
label: name,
|
|
169
|
+
});
|
|
170
|
+
|
|
171
|
+
return id;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
public static genDsId(providedId: string, teamId: string, namespaceId: string) {
|
|
175
|
+
return `${teamId}::${namespaceId}::${providedId}`;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
private async addDSFromUrl({ teamId, namespaceId, dsId, type, url, name, metadata }) {
|
|
179
|
+
throw new Error('URLs are not supported yet');
|
|
180
|
+
}
|
|
181
|
+
}
|