πŸ“„ File detail

tools/REPLTool/primitiveTools.ts

🧩 .tsπŸ“ 40 linesπŸ’Ύ 1,532 bytesπŸ“ text
← Back to All Files

🎯 Use case

This module implements the β€œREPLTool” tool (R E P L) β€” something the model can call at runtime alongside other agent tools. On the API surface it exposes getReplPrimitiveTools β€” mainly functions, hooks, or classes. It composes internal code from Tool, AgentTool, BashTool, FileEditTool, and FileReadTool (relative imports).

Generated from folder role, exports, dependency roots, and inline comments β€” not hand-reviewed for every path.

🧠 Inline summary

import type { Tool } from '../../Tool.js' import { AgentTool } from '../AgentTool/AgentTool.js' import { BashTool } from '../BashTool/BashTool.js' import { FileEditTool } from '../FileEditTool/FileEditTool.js' import { FileReadTool } from '../FileReadTool/FileReadTool.js'

πŸ“€ Exports (heuristic)

  • getReplPrimitiveTools

πŸ–₯️ Source preview

import type { Tool } from '../../Tool.js'
import { AgentTool } from '../AgentTool/AgentTool.js'
import { BashTool } from '../BashTool/BashTool.js'
import { FileEditTool } from '../FileEditTool/FileEditTool.js'
import { FileReadTool } from '../FileReadTool/FileReadTool.js'
import { FileWriteTool } from '../FileWriteTool/FileWriteTool.js'
import { GlobTool } from '../GlobTool/GlobTool.js'
import { GrepTool } from '../GrepTool/GrepTool.js'
import { NotebookEditTool } from '../NotebookEditTool/NotebookEditTool.js'

let _primitiveTools: readonly Tool[] | undefined

/**
 * Primitive tools hidden from direct model use when REPL mode is on
 * (REPL_ONLY_TOOLS) but still accessible inside the REPL VM context.
 * Exported so display-side code (collapseReadSearch, renderers) can
 * classify/render virtual messages for these tools even when they're
 * absent from the filtered execution tools list.
 *
 * Lazy getter β€” the import chain collapseReadSearch.ts β†’ primitiveTools.ts
 * β†’ FileReadTool.tsx β†’ ... loops back through the tool registry, so a
 * top-level const hits "Cannot access before initialization". Deferring
 * to call time avoids the TDZ.
 *
 * Referenced directly rather than via getAllBaseTools() because that
 * excludes Glob/Grep when hasEmbeddedSearchTools() is true.
 */
export function getReplPrimitiveTools(): readonly Tool[] {
  return (_primitiveTools ??= [
    FileReadTool,
    FileWriteTool,
    FileEditTool,
    GlobTool,
    GrepTool,
    BashTool,
    NotebookEditTool,
    AgentTool,
  ])
}