Skip to content

Agent Zero AI framework

refactor: move get_config from file_ops.py to text_editor.py to keep file_ops pure

linuztx2827b57b8692
diff --git a/plugins/text_editor/helpers/file_ops.py b/plugins/text_editor/helpers/file_ops.py
index ff0a3c5cb..6bfdd8634 100644
--- a/plugins/text_editor/helpers/file_ops.py
+++ b/plugins/text_editor/helpers/file_ops.py
@@ -8,29 +8,12 @@ import os
import shutil
import tempfile
from dataclasses import dataclass
-from typing import TYPE_CHECKING
-from python.helpers import plugins, tokens
-
-if TYPE_CHECKING:
- from agent import Agent
+from python.helpers import tokens
_BINARY_PEEK = 8192
-# ------------------------------------------------------------------
-# Config
-# ------------------------------------------------------------------
-
-def get_config(agent: "Agent") -> dict:
- config = plugins.get_plugin_config("text_editor", agent=agent) or {}
- return {
- "max_line_tokens": int(config.get("max_line_tokens", 500)),
- "default_line_count": int(config.get("default_line_count", 100)),
- "max_total_read_tokens": int(config.get("max_total_read_tokens", 4000)),
- }
-
-
# ------------------------------------------------------------------
# Binary detection
# ------------------------------------------------------------------
diff --git a/plugins/text_editor/tools/text_editor.py b/plugins/text_editor/tools/text_editor.py
index ccb039f93..e6dc932fb 100644
--- a/plugins/text_editor/tools/text_editor.py
+++ b/plugins/text_editor/tools/text_editor.py
@@ -2,8 +2,8 @@ import os
from python.helpers.tool import Tool, Response
from python.helpers.extension import call_extensions
+from python.helpers import plugins
from plugins.text_editor.helpers.file_ops import (
- get_config,
read_file,
write_file,
validate_edits,
@@ -32,7 +32,7 @@ class TextEditor(Tool):
if not path:
return self._error("read", path, "path is required")
- cfg = get_config(self.agent)
+ cfg = _get_config(self.agent)
line_from = int(kwargs.get("line_from", 1))
raw_to = kwargs.get("line_to")
line_to = int(raw_to) if raw_to is not None else None
@@ -143,4 +143,16 @@ class TextEditor(Tool):
f"fw.text_editor.{action}_error.md", path=path, error=error
)
return Response(message=msg, break_loop=False)
-
\ No newline at end of file
+
+# ------------------------------------------------------------------
+# Config
+# ------------------------------------------------------------------
+
+def _get_config(agent) -> dict:
+ config = plugins.get_plugin_config("text_editor", agent=agent) or {}
+ return {
+ "max_line_tokens": int(config.get("max_line_tokens", 500)),
+ "default_line_count": int(config.get("default_line_count", 100)),
+ "max_total_read_tokens": int(config.get("max_total_read_tokens", 4000)),
+ }
+
\ No newline at end of file