MCPcopy Create free account
hub / github.com/bytedance/trae-agent / _str_replace_handler

Method _str_replace_handler

trae_agent/tools/edit_tool_cli.py:376–389  ·  view source on GitHub ↗
(self, arguments: ToolCallArguments, _path: Path)

Source from the content-addressed store, hash-verified

374 return ToolExecResult(output=f"File created successfully at: {_path}")
375
376 def _str_replace_handler(self, arguments: ToolCallArguments, _path: Path) -> ToolExecResult:
377 old_str = arguments.get("old_str") if "old_str" in arguments else None
378 if not isinstance(old_str, str):
379 return ToolExecResult(
380 error="Parameter `old_str` is required and should be a string for command: str_replace",
381 error_code=-1,
382 )
383 new_str = arguments.get("new_str") if "new_str" in arguments else None
384 if not (new_str is None or isinstance(new_str, str)):
385 return ToolExecResult(
386 error="Parameter `new_str` should be a string or null for command: str_replace",
387 error_code=-1,
388 )
389 return self.str_replace(_path, old_str, new_str)
390
391 def _insert_handler(self, arguments: ToolCallArguments, _path: Path) -> ToolExecResult:
392 insert_line = arguments.get("insert_line") if "insert_line" in arguments else None

Callers 2

executeMethod · 0.95
mainFunction · 0.95

Calls 2

str_replaceMethod · 0.95
ToolExecResultClass · 0.70

Tested by

no test coverage detected