refactor(computer): improve type safety and error handling

bwrap.py:
- Improve property accessors with better error handling
- Add RuntimeError checks for unavailable components before boot

shipyard.py & shipyard_neo.py:
- Add type annotations and improve code quality

browser.py, fs.py, neo_skills.py, python.py:
- Improve type annotations

computer_tool_provider.py:
- Add type annotations
This commit is contained in:
LIghtJUNction
2026-03-31 20:17:26 +08:00
parent 7b16068a04
commit 5357a29ff2
10 changed files with 54 additions and 47 deletions

View File

@@ -67,7 +67,7 @@ class PythonTool(FunctionTool):
description: str = f"Run codes in an IPython shell. Current OS: {_OS_NAME}."
parameters: dict = field(default_factory=lambda: param_schema)
async def call( # type: ignore[invalid-method-override]
async def call(
self, context: ContextWrapper[AstrAgentContext], code: str, silent: bool = False
) -> ToolExecResult:
if permission_error := check_admin_permission(context, "Python execution"):
@@ -93,7 +93,7 @@ class LocalPythonTool(FunctionTool):
parameters: dict = field(default_factory=lambda: param_schema)
async def call( # type: ignore[invalid-method-override]
async def call(
self, context: ContextWrapper[AstrAgentContext], code: str, silent: bool = False
) -> ToolExecResult:
if permission_error := check_admin_permission(context, "Python execution"):