/ tools / REPLTool / constants.ts
constants.ts
 1  import { isEnvDefinedFalsy, isEnvTruthy } from '../../utils/envUtils.js'
 2  import { AGENT_TOOL_NAME } from '../AgentTool/constants.js'
 3  import { BASH_TOOL_NAME } from '../BashTool/toolName.js'
 4  import { FILE_EDIT_TOOL_NAME } from '../FileEditTool/constants.js'
 5  import { FILE_READ_TOOL_NAME } from '../FileReadTool/prompt.js'
 6  import { FILE_WRITE_TOOL_NAME } from '../FileWriteTool/prompt.js'
 7  import { GLOB_TOOL_NAME } from '../GlobTool/prompt.js'
 8  import { GREP_TOOL_NAME } from '../GrepTool/prompt.js'
 9  import { NOTEBOOK_EDIT_TOOL_NAME } from '../NotebookEditTool/constants.js'
10  
11  export const REPL_TOOL_NAME = 'REPL'
12  
13  /**
14   * REPL mode is default-on for ants in the interactive CLI (opt out with
15   * CLAUDE_CODE_REPL=0). The legacy CLAUDE_REPL_MODE=1 also forces it on.
16   *
17   * SDK entrypoints (sdk-ts, sdk-py, sdk-cli) are NOT defaulted on — SDK
18   * consumers script direct tool calls (Bash, Read, etc.) and REPL mode
19   * hides those tools. USER_TYPE is a build-time --define, so the ant-native
20   * binary would otherwise force REPL mode on every SDK subprocess regardless
21   * of the env the caller passes.
22   */
23  export function isReplModeEnabled(): boolean {
24    if (isEnvDefinedFalsy(process.env.CLAUDE_CODE_REPL)) return false
25    if (isEnvTruthy(process.env.CLAUDE_REPL_MODE)) return true
26    return (
27      process.env.USER_TYPE === 'ant' &&
28      process.env.CLAUDE_CODE_ENTRYPOINT === 'cli'
29    )
30  }
31  
32  /**
33   * Tools that are only accessible via REPL when REPL mode is enabled.
34   * When REPL mode is on, these tools are hidden from Claude's direct use,
35   * forcing Claude to use REPL for batch operations.
36   */
37  export const REPL_ONLY_TOOLS = new Set([
38    FILE_READ_TOOL_NAME,
39    FILE_WRITE_TOOL_NAME,
40    FILE_EDIT_TOOL_NAME,
41    GLOB_TOOL_NAME,
42    GREP_TOOL_NAME,
43    BASH_TOOL_NAME,
44    NOTEBOOK_EDIT_TOOL_NAME,
45    AGENT_TOOL_NAME,
46  ])