refactor: nuke legacy harness, drop sdk_ prefixes
The SDK harness is the only path now; legacy host-side code is gone. File names no longer carry the ``sdk_`` distinction. Deleted legacy host-side modules: - strix/agents/StrixAgent/ (template moved to strix/agents/prompts/) - strix/agents/base_agent.py, state.py - strix/llm/llm.py, config.py - strix/runtime/docker_runtime.py, runtime.py - strix/tools/executor.py, agents_graph/agents_graph_actions.py - strix/interface/sdk_dispatch.py + the env-flag dispatch in cli.py Renamed (drop ``sdk_`` prefix): - strix/sdk_entry.py → strix/entry.py - strix/agents/sdk_factory.py → strix/agents/factory.py - strix/agents/sdk_prompt.py → strix/agents/prompt.py - strix/tools/<x>/<x>_sdk_tool[s].py → strix/tools/<x>/tool[s].py - strix/tools/_legacy_adapter.py → strix/tools/_state_adapter.py - ``_legacy`` aliases inside the wrappers → ``_impl`` CLI + TUI now call ``run_strix_scan`` directly — they build the sandbox image / sources_path locally and rely on ``session_manager.cleanup`` (called inside ``run_strix_scan``'s finally) for teardown. Three TUI handlers that reached into legacy multi-agent globals (``_agent_instances``, ``send_user_message_to_agent``, ``stop_agent``) are now no-ops with a TODO; reconnecting them to the ``AgentMessageBus`` is a follow-up. Tracer.get_total_llm_stats no longer reaches into the deleted ``agents_graph_actions`` globals — the orchestration hooks now feed the tracer via ``Tracer.record_llm_usage`` (live + completed buckets). finish_scan's ``_check_active_agents`` and load_skill's runtime ``_agent_instances`` reach-in are no-op stubs; the ``AgentMessageBus`` is the source of truth post-migration. llm/utils.py rewritten to keep only the streaming-parser helpers (``normalize_tool_format``, ``parse_tool_invocations``, ``fix_incomplete_tool_call``, ``format_tool_call``, ``clean_content``). ``STRIX_MODEL_MAP`` moved to ``llm/multi_provider_setup.py`` (its only remaining caller). Per-file ruff ignores added for legacy interface modules (TUI / main / CLI / utils / streaming_parser / tool_components) and tracer.py — pre-existing PLC0415/BLE001/PLR0915 patterns are out of scope. Tests: 287/287 passing. Renamed test files to drop ``sdk_`` prefix. ``test_tracer.py::test_get_total_llm_stats_aggregates_live_and_completed`` rewritten to feed ``Tracer.record_llm_usage`` instead of legacy globals. Test file annotations added so pre-commit's strict mypy passes. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,109 @@
|
||||
"""SDK function-tool wrappers for the legacy ``file_edit`` tools.
|
||||
|
||||
These three tools (``str_replace_editor``, ``list_files``, ``search_files``)
|
||||
operate on files inside the sandbox container's ``/workspace`` filesystem.
|
||||
The legacy harness marks them ``sandbox_execution=True`` (default) so the
|
||||
executor POSTs them to the in-container tool server.
|
||||
|
||||
The host-side SDK wrappers therefore delegate to ``post_to_sandbox`` —
|
||||
the legacy implementations live in the container image and we don't
|
||||
import them on the host (they pull in ``openhands_aci``, which is a
|
||||
sandbox-only dependency).
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
from typing import Any
|
||||
|
||||
from agents import RunContextWrapper
|
||||
|
||||
from strix.tools._decorator import strix_tool
|
||||
from strix.tools._sandbox_dispatch import post_to_sandbox
|
||||
|
||||
|
||||
def _dump(result: dict[str, Any]) -> str:
|
||||
return json.dumps(result, ensure_ascii=False, default=str)
|
||||
|
||||
|
||||
@strix_tool(timeout=180)
|
||||
async def str_replace_editor(
|
||||
ctx: RunContextWrapper,
|
||||
command: str,
|
||||
path: str,
|
||||
file_text: str | None = None,
|
||||
view_range: list[int] | None = None,
|
||||
old_str: str | None = None,
|
||||
new_str: str | None = None,
|
||||
insert_line: int | None = None,
|
||||
) -> str:
|
||||
"""View, create, or edit a file in the sandbox.
|
||||
|
||||
Args:
|
||||
command: One of ``"view" | "create" | "str_replace" | "insert" |
|
||||
"undo_edit"``.
|
||||
path: File path. Relative paths are anchored at ``/workspace``.
|
||||
file_text: Required for ``create``.
|
||||
view_range: Optional ``[start, end]`` line range for ``view``.
|
||||
old_str / new_str: Required for ``str_replace``.
|
||||
insert_line: Required for ``insert``.
|
||||
"""
|
||||
return _dump(
|
||||
await post_to_sandbox(
|
||||
ctx,
|
||||
"str_replace_editor",
|
||||
{
|
||||
"command": command,
|
||||
"path": path,
|
||||
"file_text": file_text,
|
||||
"view_range": view_range,
|
||||
"old_str": old_str,
|
||||
"new_str": new_str,
|
||||
"insert_line": insert_line,
|
||||
},
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
@strix_tool(timeout=120)
|
||||
async def list_files(
|
||||
ctx: RunContextWrapper,
|
||||
path: str,
|
||||
recursive: bool = False,
|
||||
) -> str:
|
||||
"""List files and directories under a sandbox path.
|
||||
|
||||
Args:
|
||||
path: Directory path, relative paths anchored at ``/workspace``.
|
||||
recursive: When True, walks subdirectories (capped at 500 entries).
|
||||
"""
|
||||
return _dump(
|
||||
await post_to_sandbox(
|
||||
ctx,
|
||||
"list_files",
|
||||
{"path": path, "recursive": recursive},
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
@strix_tool(timeout=120)
|
||||
async def search_files(
|
||||
ctx: RunContextWrapper,
|
||||
path: str,
|
||||
regex: str,
|
||||
file_pattern: str = "*",
|
||||
) -> str:
|
||||
"""Recursively grep files in the sandbox using ripgrep.
|
||||
|
||||
Args:
|
||||
path: Root path to search; relative paths anchored at ``/workspace``.
|
||||
regex: Pattern to match (passed straight to ``rg``).
|
||||
file_pattern: Glob filter (e.g. ``"*.py"``). Defaults to all files.
|
||||
"""
|
||||
return _dump(
|
||||
await post_to_sandbox(
|
||||
ctx,
|
||||
"search_files",
|
||||
{"path": path, "regex": regex, "file_pattern": file_pattern},
|
||||
),
|
||||
)
|
||||
Reference in New Issue
Block a user