source dump of claude code
at main 39 lines 1.5 kB view raw
1import type { Tool } from '../../Tool.js' 2import { AgentTool } from '../AgentTool/AgentTool.js' 3import { BashTool } from '../BashTool/BashTool.js' 4import { FileEditTool } from '../FileEditTool/FileEditTool.js' 5import { FileReadTool } from '../FileReadTool/FileReadTool.js' 6import { FileWriteTool } from '../FileWriteTool/FileWriteTool.js' 7import { GlobTool } from '../GlobTool/GlobTool.js' 8import { GrepTool } from '../GrepTool/GrepTool.js' 9import { NotebookEditTool } from '../NotebookEditTool/NotebookEditTool.js' 10 11let _primitiveTools: readonly Tool[] | undefined 12 13/** 14 * Primitive tools hidden from direct model use when REPL mode is on 15 * (REPL_ONLY_TOOLS) but still accessible inside the REPL VM context. 16 * Exported so display-side code (collapseReadSearch, renderers) can 17 * classify/render virtual messages for these tools even when they're 18 * absent from the filtered execution tools list. 19 * 20 * Lazy getter — the import chain collapseReadSearch.ts → primitiveTools.ts 21 * → FileReadTool.tsx → ... loops back through the tool registry, so a 22 * top-level const hits "Cannot access before initialization". Deferring 23 * to call time avoids the TDZ. 24 * 25 * Referenced directly rather than via getAllBaseTools() because that 26 * excludes Glob/Grep when hasEmbeddedSearchTools() is true. 27 */ 28export function getReplPrimitiveTools(): readonly Tool[] { 29 return (_primitiveTools ??= [ 30 FileReadTool, 31 FileWriteTool, 32 FileEditTool, 33 GlobTool, 34 GrepTool, 35 BashTool, 36 NotebookEditTool, 37 AgentTool, 38 ]) 39}