-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy pathSystemDefaultEngines.java
More file actions
204 lines (177 loc) · 8.15 KB
/
Copy pathSystemDefaultEngines.java
File metadata and controls
204 lines (177 loc) · 8.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
/*******************************************************************************
* Copyright 2015 Defense Health Agency (DHA)
*
* If your use of this software does not include any GPLv2 components:
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* ----------------------------------------------------------------------------
* If your use of this software includes any GPLv2 components:
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*******************************************************************************/
package prerna.util;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Set;
public class SystemDefaultEngines {
private static final Set<String> SYSTEM_ENGINE_IDS = Set.of(Constants.SECURITY_DB, Constants.LOCAL_MASTER_DB,
Constants.SCHEDULER_DB, Constants.THEMING_DB, Constants.USER_TRACKING_DB, Constants.PROMPT_DB,
Constants.NOTIFICATION_DB, Constants.COLLABORATION_DB, Constants.AUDIT_LOGS_DB,
Constants.MODEL_INFERENCE_LOGS_DB);
private static final List<String> IGNORE_DATABASE_OWL = Collections
.unmodifiableList(new ArrayList<>(SYSTEM_ENGINE_IDS));
private static final List<String> DATABASE_GENERATED_OWL = Collections
.unmodifiableList(new ArrayList<>(SYSTEM_ENGINE_IDS));
private static final List<String> DATABASE_IGNORE_LOCALMASTER = Collections
.unmodifiableList(new ArrayList<>(SYSTEM_ENGINE_IDS));
private static final List<String> DATABASE_IGNORE_SECURITY = Collections
.unmodifiableList(new ArrayList<>(SYSTEM_ENGINE_IDS));
private static final List<String> SYSTEM_APPS = List.of(Constants.APP_REACT_TEMPLATE);
private static final List<String> APP_BUILDER_SKILLS = List.of(Constants.SKILL_AGENT_RUN,
Constants.SKILL_APP_BOOTSTRAP, Constants.SKILL_APP_DATA, Constants.SKILL_BUILD_AND_PUBLISH,
Constants.SKILL_DATABASE, Constants.SKILL_EXPORTS, Constants.SKILL_FILE_UPLOADS,
Constants.SKILL_FRONTEND_DESIGN, Constants.SKILL_FUNCTIONS, Constants.SKILL_MCP, Constants.SKILL_MODEL,
Constants.SKILL_PAGINATION, Constants.SKILL_PERMISSIONS, Constants.SKILL_PYTHON, Constants.SKILL_ROOM,
Constants.SKILL_STORAGE, Constants.SKILL_USER, Constants.SKILL_VECTOR);
private static final List<String> SYSTEM_SKILLS = List.of(Constants.SKILL_AGENT_RUN, Constants.SKILL_APP_BOOTSTRAP,
Constants.SKILL_APP_DATA, Constants.SKILL_BUILD_AND_PUBLISH, Constants.SKILL_COLLABORATION,
Constants.SKILL_DATABASE,
Constants.SKILL_EXPORTS, Constants.SKILL_FILE_UPLOADS, Constants.SKILL_FRONTEND_DESIGN,
Constants.SKILL_FUNCTIONS, Constants.SKILL_MCP, Constants.SKILL_MODEL, Constants.SKILL_PAGINATION,
Constants.SKILL_PERMISSIONS, Constants.SKILL_PPTX, Constants.SKILL_PYTHON, Constants.SKILL_ROOM,
Constants.SKILL_STORAGE, Constants.SKILL_USER, Constants.SKILL_VECTOR, Constants.SKILL_WORKFLOW_AUTOMATION);
private static final List<String> COLLABORATION_SKILLS = List.of(Constants.SKILL_COLLABORATION,
Constants.SKILL_PYTHON);
/**
* Platform MCPs cataloged at boot by {@code ProjectWatcher.init()}. Every entry
* must have a matching {@code project/platform__<id>} folder.
*/
private static final List<String> SYSTEM_MCPS = List.of(Constants.MCP_APP_FILESYSTEM,
Constants.MCP_BROWSER_AUTOMATION, Constants.MCP_DATABASE_MAKER, Constants.MCP_NODE_BUILDER,
Constants.MCP_PIXABAY, Constants.MCP_REACTOR_HELP, Constants.MCP_ROOM_FILESYSTEM);
/**
* Subset of {@link #SYSTEM_MCPS} seeded onto system agent workspaces. This is
* deliberately narrower than the cataloged list: UI-driven MCPs (whose tools
* open a sidebar app and wait on a user) are not useful to a headless agent, so
* they are cataloged and invokable without being attached to every system
* agent.
*/
private static final List<String> APP_BUILDER_MCPS = List.of(Constants.MCP_DATABASE_MAKER,
Constants.MCP_NODE_BUILDER, Constants.MCP_REACTOR_HELP);
private static final List<String> SYSTEM_AGENTS = List.of(Constants.AGENT_APP_BUILDER,
Constants.AGENT_DATABASE_EXPLORER, Constants.AGENT_NOTEBOOK_ANALYST, Constants.AGENT_PPTX,
Constants.AGENT_PPTX_REVIEWER, Constants.AGENT_WORKFLOW_AUTOMATION_BUILDER);
public static List<String> getIgnoreDatabaseOwlList() {
return IGNORE_DATABASE_OWL;
}
public static List<String> getDatabasesWithGeneratedOwl() {
return DATABASE_GENERATED_OWL;
}
public static List<String> getDatabaseIgnoreLocalMaster() {
return DATABASE_IGNORE_LOCALMASTER;
}
public static List<String> getDatabaseIgnoreSecurity() {
return DATABASE_IGNORE_SECURITY;
}
public static List<String> getSystemApps() {
return SYSTEM_APPS;
}
public static List<String> getSystemSkills() {
return SYSTEM_SKILLS;
}
/** Skills available in every collaboration room, independently of its agent. */
public static List<String> getCollaborationSkills() {
return COLLABORATION_SKILLS;
}
public static List<String> getSystemMCPs() {
return SYSTEM_MCPS;
}
/**
* Returns the platform MCP projects seeded onto one system agent.
*
* @param agentId system agent identifier
* @return immutable MCP project identifiers for the agent
*/
public static List<String> getSystemAgentMCPs(String agentId) {
if (Constants.AGENT_APP_BUILDER.equals(agentId)) {
return APP_BUILDER_MCPS;
}
if (Constants.AGENT_DATABASE_EXPLORER.equals(agentId) || Constants.AGENT_NOTEBOOK_ANALYST.equals(agentId)) {
return List.of(Constants.MCP_REACTOR_HELP);
}
if (Constants.AGENT_PPTX.equals(agentId)) {
return List.of(Constants.MCP_PIXABAY);
}
return List.of();
}
/**
* Returns the platform skills seeded onto one system agent.
*
* @param agentId system agent identifier
* @return immutable skill project identifiers for the agent
*/
public static List<String> getSystemAgentSkills(String agentId) {
if (Constants.AGENT_APP_BUILDER.equals(agentId)) {
return APP_BUILDER_SKILLS;
}
if (Constants.AGENT_DATABASE_EXPLORER.equals(agentId)) {
return List.of(Constants.SKILL_DATABASE, Constants.SKILL_PYTHON, Constants.SKILL_PAGINATION,
Constants.SKILL_EXPORTS);
}
if (Constants.AGENT_NOTEBOOK_ANALYST.equals(agentId)) {
return List.of(Constants.SKILL_PYTHON, Constants.SKILL_DATABASE, Constants.SKILL_FILE_UPLOADS,
Constants.SKILL_STORAGE, Constants.SKILL_EXPORTS);
}
if (Constants.AGENT_WORKFLOW_AUTOMATION_BUILDER.equals(agentId)) {
return List.of(Constants.SKILL_WORKFLOW_AUTOMATION);
}
if (Constants.AGENT_PPTX.equals(agentId)) {
return List.of(Constants.SKILL_PPTX);
}
return List.of();
}
public static List<String> getSystemAgents() {
return SYSTEM_AGENTS;
}
/**
* Identifies projects seeded and managed by the instance. Use the registered
* IDs rather than editable tags, display names, or a missing creator field.
*/
public static boolean isSystemProject(String projectId) {
return projectId != null && (SYSTEM_APPS.contains(projectId) || SYSTEM_SKILLS.contains(projectId)
|| SYSTEM_MCPS.contains(projectId) || SYSTEM_AGENTS.contains(projectId));
}
/**
* Check if a string starts with any value within a collection
*
* @param strValue
* @param collection
* @return
*/
public static boolean valueStartsWith(String strValue, Collection<String> collection) {
for (String c : collection) {
if (strValue.startsWith(c)) {
return true;
}
}
return false;
}
}