Agent Zero AI framework
Share editor log presentation across local and remote tools
Alessandro6f0f036feacb
diff --git a/plugins/_a0_connector/AGENTS.md b/plugins/_a0_connector/AGENTS.mdindex 124b607ef..a11f8568c 100644--- a/plugins/_a0_connector/AGENTS.md+++ b/plugins/_a0_connector/AGENTS.md@@ -15,6 +15,7 @@## Local Contracts- `tools/text_editor_remote.py` logs `type="text_editor"` through a `get_log_object()` override so the WebUI routes its messages through the `_text_editor` plugin's `get_message_handler` JS extension; keep remote edits visually consistent with local edits.+- Remote text editing reuses the shipped `_text_editor` patch and log helpers. Disabling local editor discovery does not remove these Python modules; removing the bundled dependency is unsupported.- Preserve session-auth and `auth.handlers` activation assumptions.- Keep remote tool prompts synchronized with remote tool behavior and disclosethem only from connected CLI metadata: no connected CLI hides all remote tooldiff --git a/plugins/_a0_connector/tools/text_editor_remote.py b/plugins/_a0_connector/tools/text_editor_remote.pyindex d764f491d..9ef60f93f 100644--- a/plugins/_a0_connector/tools/text_editor_remote.py+++ b/plugins/_a0_connector/tools/text_editor_remote.py@@ -23,6 +23,7 @@ from plugins._a0_connector.helpers.ws_runtime import (select_remote_file_target_sid,store_pending_file_op,)+from plugins._text_editor.helpers.log import create_editor_logfrom plugins._text_editor.helpers.patch_request import (exact_replace_to_patch_text,parse_patch_request,@@ -41,22 +42,7 @@ class TextEditorRemote(Tool):"""Send file-editing operations to the connected CLI machine."""def get_log_object(self):- action = str(self.args.get("action") or "")- path = str(self.args.get("path") or "")- verb = {"read": "Reading", "write": "Writing", "patch": "Patching"}.get(action)- heading = (- f"icon://construction {verb} {path} (remote)".strip()- if verb and path- else f"icon://construction {self.agent.agent_name}: Using tool '{self.name}' (remote)"- )- return self.agent.context.log.log(- type="text_editor",- heading=heading,- content="",- kvps=self.args,- _tool_name=self.name,- id=str(uuid.uuid4()),- )+ return create_editor_log(self, remote=True)async def execute(self, **kwargs: Any) -> Response:op = (diff --git a/plugins/_text_editor/AGENTS.md b/plugins/_text_editor/AGENTS.mdindex 1e0e7688e..fdd43cdd6 100644--- a/plugins/_text_editor/AGENTS.md+++ b/plugins/_text_editor/AGENTS.md@@ -7,13 +7,14 @@## Ownership- `tools/text_editor.py` owns method dispatch and agent-facing tool behavior.-- `helpers/` owns file operations, patch requests, context patching, stale-read tracking, and patch state.+- `helpers/` owns file operations, patch requests, context patching, stale-read tracking, and patch state. `helpers/log.py` owns the shared local/remote editor log factory.- `prompts/` owns read/write/patch success and error messages.- `default_config.yaml`, `plugin.yaml`, `README.md`, `extensions/`, and `webui/` own defaults, metadata, docs, hooks, and config UI.## Local Contracts- `tools/text_editor.py` logs `type="text_editor"` through a `get_log_object()` override so the WebUI `get_message_handler` hook routes messages to `_text_editor/extensions/webui/get_message_handler/_10_text_editor_handler.js` instead of the default `drawMessageTool` handler.+- The remote editor reuses shipped patch and log helpers even when this plugin is disabled; activation still controls local tool discovery and custom WebUI rendering. Removing bundled helper files is not a supported independent-plugin configuration.- Preserve stale-read protection before patch operations.- Validate patch structures before applying edits.- Read back changed regions after writes or patches where the tool contract requires confirmation.diff --git a/plugins/_text_editor/helpers/log.py b/plugins/_text_editor/helpers/log.pynew file mode 100644index 000000000..415d78ad5--- /dev/null+++ b/plugins/_text_editor/helpers/log.py@@ -0,0 +1,23 @@+"""Shared local and remote editor log presentation."""++import uuid+++def create_editor_log(tool, *, remote: bool = False):+ action = str(tool.args.get("action") or "")+ path = str(tool.args.get("path") or "")+ verb = {"read": "Reading", "write": "Writing", "patch": "Patching"}.get(action)+ suffix = " (remote)" if remote else ""+ heading = (+ f"icon://construction {verb} {path}{suffix}".strip()+ if verb and path+ else f"icon://construction {tool.agent.agent_name}: Using tool '{tool.name}'{suffix}"+ )+ return tool.agent.context.log.log(+ type="text_editor",+ heading=heading,+ content="",+ kvps=tool.args,+ _tool_name=tool.name,+ id=str(uuid.uuid4()),+ )diff --git a/plugins/_text_editor/tools/text_editor.py b/plugins/_text_editor/tools/text_editor.pyindex 56ac05e3a..fa7db79b8 100644--- a/plugins/_text_editor/tools/text_editor.py+++ b/plugins/_text_editor/tools/text_editor.py@@ -1,4 +1,3 @@-import uuidfrom pathlib import Pathfrom helpers.tool import Tool, Response@@ -14,6 +13,7 @@ from plugins._text_editor.helpers.file_ops import (apply_exact_replace_file,file_info,)+from plugins._text_editor.helpers.log import create_editor_logfrom plugins._text_editor.helpers.patch_request import parse_patch_requestfrom plugins._text_editor.helpers.patch_state import (LOCAL_FRESHNESS_KEY,@@ -32,22 +32,7 @@ _MTIME_KEY = LOCAL_FRESHNESS_KEYclass TextEditor(Tool):def get_log_object(self):- action = str(self.args.get("action") or "")- path = str(self.args.get("path") or "")- verb = {"read": "Reading", "write": "Writing", "patch": "Patching"}.get(action)- heading = (- f"icon://construction {verb} {path}".strip()- if verb and path- else f"icon://construction {self.agent.agent_name}: Using tool '{self.name}'"- )- return self.agent.context.log.log(- type="text_editor",- heading=heading,- content="",- kvps=self.args,- _tool_name=self.name,- id=str(uuid.uuid4()),- )+ return create_editor_log(self)async def execute(self, **kwargs):action = _current_action(self, kwargs)diff --git a/tools/AGENTS.md b/tools/AGENTS.mdindex 5c1a0da54..d6d51d035 100644--- a/tools/AGENTS.md+++ b/tools/AGENTS.md@@ -22,7 +22,7 @@- The `*.py.dox.md` file owns tool purpose, tool arguments/concepts, output and `break_loop` behavior, side effects, important helper dependencies, prompt-contract notes, and verification guidance.- When a tool module is added, removed, renamed, or behaviorally changed, update its matching `*.py.dox.md` in the same change.- Do not leave stale file-level DOX after tool deletion or rename.-- Plugin tools may duplicate `get_log_object()` implementations across independently installable plugins; a shared helper cannot be used because plugins can be disabled independently. Tool headings must not include an `A0:` prefix; heading shape is per-tool.+- Tool headings and log types are owned by each tool or its shared presentation helper. Bundled plugins may reuse shipped Python helpers when disabled; activation governs discovery/hooks, not installation. Preserve explicit dependency boundaries and per-tool heading shapes.## Work Guidance