-
Notifications
You must be signed in to change notification settings - Fork 373
Expand file tree
/
Copy pathSubagentTools.kt
More file actions
43 lines (37 loc) · 1.69 KB
/
SubagentTools.kt
File metadata and controls
43 lines (37 loc) · 1.69 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
package ee.carlrobert.codegpt.agent
enum class SubagentTool(val id: String, val displayName: String, val isWrite: Boolean) {
READ("read", "Read", false),
TODO_WRITE("todowrite", "TodoWrite", false),
INTELLIJ_SEARCH("intellijsearch", "IntelliJSearch", false),
DIAGNOSTICS("diagnostics", "Diagnostics", false),
WEB_SEARCH("websearch", "WebSearch", false),
WEB_FETCH("webfetch", "WebFetch", false),
MCP("MCP", "MCP", false),
RESOLVE_LIBRARY_ID("resolvelibraryid", "ResolveLibraryId", false),
GET_LIBRARY_DOCS("getlibrarydocs", "GetLibraryDocs", false),
LOAD_SKILL("loadskill", "LoadSkill", false),
BASH_OUTPUT("bashoutput", "BashOutput", false),
KILL_SHELL("killshell", "KillShell", false),
EDIT("edit", "Edit", true),
WRITE("write", "Write", true),
BASH("bash", "Bash", true),
EXIT("exit", "Exit", false);
companion object {
val readOnly: List<SubagentTool> = entries.filterNot { it.isWrite }
val write: List<SubagentTool> = entries.filter { it.isWrite }
fun parse(values: Collection<String>): Set<SubagentTool> {
return values.mapNotNull { fromString(it) }.toSet()
}
fun toStoredValues(tools: Collection<SubagentTool>): List<String> {
val selected = tools.toSet()
return entries.filter { it in selected }.map { it.id }
}
fun fromString(value: String): SubagentTool? {
val key = normalize(value)
return entries.firstOrNull { normalize(it.id) == key || normalize(it.displayName) == key }
}
private fun normalize(value: String): String {
return value.lowercase().filter { it.isLetterOrDigit() }
}
}
}