Skip to content

Commit 50c31c6

Browse files
committed
fix tests
1 parent 7dc4465 commit 50c31c6

1 file changed

Lines changed: 22 additions & 3 deletions

File tree

astrbot/core/computer/computer_client.py

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,16 @@ def _list_local_skill_dirs(skills_root: Path) -> list[Path]:
3333

3434
def _collect_sync_skill_dirs() -> list[tuple[str, Path]]:
3535
"""Collect local and plugin-provided skills that should be synced."""
36-
skill_manager = SkillManager(skills_root=str(Path(get_astrbot_skills_path())))
36+
skills_root = Path(get_astrbot_skills_path())
37+
if not skills_root.is_dir():
38+
return []
39+
40+
try:
41+
skill_manager = SkillManager(skills_root=str(skills_root))
42+
except OSError as exc:
43+
logger.warning("[Computer] Failed to initialize skill manager: %s", exc)
44+
return []
45+
3746
sync_dirs: list[tuple[str, Path]] = []
3847
for skill in skill_manager.list_skills(
3948
active_only=False,
@@ -49,6 +58,12 @@ def _collect_sync_skill_dirs() -> list[tuple[str, Path]]:
4958
return sync_dirs
5059

5160

61+
def _normalize_shell_exec_result(result: object) -> dict:
62+
if isinstance(result, dict):
63+
return result
64+
return {"exit_code": 0, "stdout": "", "stderr": ""}
65+
66+
5267
def _discover_bay_credentials(endpoint: str) -> str:
5368
"""Try to auto-discover Bay API key from credentials.json.
5469
@@ -369,7 +384,9 @@ async def _apply_skills_to_sandbox(booter: ComputerBooter) -> None:
369384
executed in a separate phase to keep failure domains clear.
370385
"""
371386
logger.info("[Computer] Skill sync phase=apply start")
372-
apply_result = await booter.shell.exec(_build_apply_sync_command())
387+
apply_result = _normalize_shell_exec_result(
388+
await booter.shell.exec(_build_apply_sync_command())
389+
)
373390
if not _shell_exec_succeeded(apply_result):
374391
detail = _format_exec_error_detail(apply_result)
375392
logger.error("[Computer] Skill sync phase=apply failed: %s", detail)
@@ -380,7 +397,9 @@ async def _apply_skills_to_sandbox(booter: ComputerBooter) -> None:
380397
async def _scan_sandbox_skills(booter: ComputerBooter) -> dict | None:
381398
"""Scan sandbox skills and return normalized payload for cache update."""
382399
logger.info("[Computer] Skill sync phase=scan start")
383-
scan_result = await booter.shell.exec(_build_scan_command())
400+
scan_result = _normalize_shell_exec_result(
401+
await booter.shell.exec(_build_scan_command())
402+
)
384403
if not _shell_exec_succeeded(scan_result):
385404
detail = _format_exec_error_detail(scan_result)
386405
logger.error("[Computer] Skill sync phase=scan failed: %s", detail)

0 commit comments

Comments
 (0)