refactor: remove unused runtime and WebUI helpers (#5999)
* refactor: remove unused runtime and WebUI helpers * fix: preserve exported agent helper methods
This commit is contained in:
1 parent
d3d70f2065
commit
6ecb74aea9
17 files changed
+26
-143
No files matched your search
@@ -249,9 +249,8 @@ class MemoryStore:
|
||||
def write_user(self, content: str) -> None:
|
||||
self.user_file.write_text(content, encoding="utf-8")
|
||||
|
||||
# -- context injection (used by context.py) ------------------------------
|
||||
|
||||
def get_memory_context(self) -> str:
|
||||
"""Return long-term memory formatted for context injection."""
|
||||
long_term = self.read_memory()
|
||||
return f"## Long-term Memory\n{long_term}" if long_term else ""
|
||||
|
||||
|
||||
@@ -166,7 +166,7 @@ class SubagentManager:
|
||||
self._session_tasks: dict[str, set[str]] = {} # session_key -> {task_id, ...}
|
||||
|
||||
def runtime_statuses(self) -> Mapping[str, SubagentStatus]:
|
||||
"""Return the observable task statuses used by runtime-control snapshots."""
|
||||
"""Return the observable statuses of all active tasks."""
|
||||
return self._task_statuses
|
||||
|
||||
def statuses_for_session(self, session_key: str | None) -> Mapping[str, SubagentStatus]:
|
||||
|
||||
@@ -877,10 +877,6 @@ class WebSocketChannel(BaseChannel):
|
||||
return
|
||||
await self._commands.dispatch(connection, client_id, envelope)
|
||||
|
||||
def _prune_webui_request_operations(self) -> None:
|
||||
"""Compatibility hook for request-cache boundary tests."""
|
||||
self._commands.prune_request_operations()
|
||||
|
||||
# -- Outbound WebSocket events -----------------------------------------
|
||||
|
||||
async def stop(self) -> None:
|
||||
|
||||
@@ -1360,7 +1360,7 @@ def test_webui_request_cache_prunes_expired_completed_but_keeps_pending(
|
||||
)
|
||||
operations["fresh"] = SimpleNamespace(completed_at=now - 1)
|
||||
|
||||
channel._prune_webui_request_operations()
|
||||
channel._commands.prune_request_operations()
|
||||
|
||||
assert "pending" in operations
|
||||
assert "expired" not in operations
|
||||
@@ -1383,7 +1383,7 @@ def test_webui_request_cache_prunes_oldest_completed_at_capacity(
|
||||
completed_at=now - 1 + index / 1_000
|
||||
)
|
||||
|
||||
channel._prune_webui_request_operations()
|
||||
channel._commands.prune_request_operations()
|
||||
|
||||
assert "pending" in operations
|
||||
assert "completed-0" not in operations
|
||||
|
||||
@@ -677,23 +677,6 @@ class WeixinChannel(BaseChannel):
|
||||
return WeixinChannel._is_retryable_http_status(status_code)
|
||||
return False
|
||||
|
||||
async def _api_get(
|
||||
self,
|
||||
endpoint: str,
|
||||
params: dict[str, Any] | None = None,
|
||||
*,
|
||||
auth: bool = True,
|
||||
extra_headers: dict[str, str] | None = None,
|
||||
) -> dict[str, Any]:
|
||||
assert self._client is not None
|
||||
url = f"{self.config.base_url}/{endpoint}"
|
||||
hdrs = self._make_headers(auth=auth)
|
||||
if extra_headers:
|
||||
hdrs.update(extra_headers)
|
||||
return await self._request_json(
|
||||
"GET", url, endpoint=endpoint, params=params, headers=hdrs,
|
||||
)
|
||||
|
||||
async def _api_get_with_base(
|
||||
self,
|
||||
*,
|
||||
|
||||
@@ -895,7 +895,6 @@ async def test_qr_login_switches_polling_base_url_on_redirect_status(
|
||||
"ilink_user_id": "wx-user",
|
||||
},
|
||||
]
|
||||
channel._api_get = AsyncMock(side_effect=list(status_side_effect))
|
||||
channel._api_get_with_base = AsyncMock(side_effect=list(status_side_effect))
|
||||
|
||||
ok = await channel._qr_login()
|
||||
@@ -929,7 +928,6 @@ async def test_qr_login_redirect_without_host_keeps_current_polling_base_url(
|
||||
"ilink_user_id": "wx-user",
|
||||
},
|
||||
]
|
||||
channel._api_get = AsyncMock(side_effect=list(status_side_effect))
|
||||
channel._api_get_with_base = AsyncMock(side_effect=list(status_side_effect))
|
||||
|
||||
ok = await channel._qr_login()
|
||||
|
||||
@@ -179,14 +179,6 @@ def read_file_snapshot(path: Path, *, max_bytes: int = _MAX_SNAPSHOT_BYTES) -> F
|
||||
return FileSnapshot(path=path, exists=True, text=text.replace("\r\n", "\n"))
|
||||
|
||||
|
||||
def line_diff_stats(before: str | None, after: str | None) -> tuple[int, int]:
|
||||
"""Return ``(added, deleted)`` for a UTF-8 text line-level diff."""
|
||||
if before is None or after is None:
|
||||
return 0, 0
|
||||
diff = FileDiff.from_text(before, after)
|
||||
return diff.added, diff.deleted
|
||||
|
||||
|
||||
def build_unified_diff_payload(
|
||||
before: str | None,
|
||||
after: str | None,
|
||||
|
||||
@@ -583,40 +583,6 @@ class WebUISettingsRouter:
|
||||
)
|
||||
)
|
||||
|
||||
_coerce_channel_value = staticmethod(system_domain.coerce_channel_value)
|
||||
_assign_channel_config_value = staticmethod(
|
||||
system_domain.assign_channel_config_value
|
||||
)
|
||||
|
||||
def _nanobot_features_payload(self) -> dict[str, Any]:
|
||||
return nanobot_features_payload(config_path=self.settings.config.path)
|
||||
|
||||
def _nanobot_features_action(
|
||||
self,
|
||||
action: str,
|
||||
query: QueryParams,
|
||||
*,
|
||||
allow_install: bool = True,
|
||||
) -> dict[str, Any]:
|
||||
return self.settings.mutate(
|
||||
nanobot_features_action,
|
||||
action,
|
||||
query,
|
||||
allow_install=allow_install,
|
||||
)
|
||||
|
||||
def _allow_feature_package_install(
|
||||
self,
|
||||
connection: Any,
|
||||
request: WsRequest,
|
||||
) -> bool:
|
||||
domain_request = self._domain_request(
|
||||
connection,
|
||||
request,
|
||||
needs_local_browser=True,
|
||||
)
|
||||
return self._system.allow_feature_package_install(domain_request)
|
||||
|
||||
async def _handle_mcp_oauth_start(self, request: WsRequest) -> Response:
|
||||
if not self._authorized(request):
|
||||
return self._unauthorized()
|
||||
|
||||
Reference in new issue
Block a user