-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Expand file tree
/
Copy pathtools.ts
More file actions
59 lines (53 loc) · 2.22 KB
/
tools.ts
File metadata and controls
59 lines (53 loc) · 2.22 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
import { Tool } from './Tool.js'
import { AgentTool } from './tools/AgentTool/AgentTool.js'
import { ArchitectTool } from './tools/ArchitectTool/ArchitectTool.js'
import { BashTool } from './tools/BashTool/BashTool.js'
import { FileEditTool } from './tools/FileEditTool/FileEditTool.js'
import { FileReadTool } from './tools/FileReadTool/FileReadTool.js'
import { FileWriteTool } from './tools/FileWriteTool/FileWriteTool.js'
import { GlobTool } from './tools/GlobTool/GlobTool.js'
import { GrepTool } from './tools/GrepTool/GrepTool.js'
import { LSTool } from './tools/lsTool/lsTool.js'
import { MemoryReadTool } from './tools/MemoryReadTool/MemoryReadTool.js'
import { MemoryWriteTool } from './tools/MemoryWriteTool/MemoryWriteTool.js'
import { NotebookEditTool } from './tools/NotebookEditTool/NotebookEditTool.js'
import { NotebookReadTool } from './tools/NotebookReadTool/NotebookReadTool.js'
import { StickerRequestTool } from './tools/StickerRequestTool/StickerRequestTool.js'
import { ThinkTool } from './tools/ThinkTool/ThinkTool.js'
import { getMCPTools } from './services/mcpClient.js'
import { memoize } from 'lodash-es'
const ANT_ONLY_TOOLS = [MemoryReadTool, MemoryWriteTool]
// Function to avoid circular dependencies that break bun
export const getAllTools = (): Tool[] => {
return [
AgentTool,
BashTool,
GlobTool,
GrepTool,
LSTool,
FileReadTool,
FileEditTool,
FileWriteTool,
NotebookReadTool,
NotebookEditTool,
StickerRequestTool,
ThinkTool,
...(process.env.USER_TYPE === 'ant' ? ANT_ONLY_TOOLS : []),
]
}
export const getTools = memoize(
async (enableArchitect?: boolean): Promise<Tool[]> => {
const tools = [...getAllTools(), ...(await getMCPTools())]
// Only include Architect tool if enabled via config or CLI flag
if (enableArchitect) {
tools.push(ArchitectTool)
}
const isEnabled = await Promise.all(tools.map(tool => tool.isEnabled()))
return tools.filter((_, i) => isEnabled[i])
},
)
export const getReadOnlyTools = memoize(async (): Promise<Tool[]> => {
const tools = getAllTools().filter(tool => tool.isReadOnly())
const isEnabled = await Promise.all(tools.map(tool => tool.isEnabled()))
return tools.filter((_, index) => isEnabled[index])
})