Skip to content
4 changes: 3 additions & 1 deletion astrbot/core/computer/computer_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -507,7 +507,9 @@ async def _sync_skills_to_sandbox(booter: ComputerBooter) -> None:
remote_zip = Path(SANDBOX_SKILLS_ROOT) / "skills.zip"
logger.info("Uploading skills bundle to sandbox...")
await booter.shell.exec(f"mkdir -p {SANDBOX_SKILLS_ROOT}")
upload_result = await booter.upload_file(str(zip_path), str(remote_zip))
upload_result = await booter.upload_file(
str(zip_path), remote_zip.as_posix()
)
if not upload_result.get("success", False):
raise RuntimeError("Failed to upload skills bundle to sandbox.")
else:
Expand Down
4 changes: 2 additions & 2 deletions astrbot/core/provider/sources/openai_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,12 +270,12 @@ def _file_uri_to_path(file_uri: str) -> str:
netloc = unquote(parsed.netloc or "")
path = unquote(parsed.path or "")
if re.fullmatch(r"[A-Za-z]:", netloc):
return str(Path(f"{netloc}{path}"))
return Path(f"{netloc}{path}").as_posix()
if re.match(r"^/[A-Za-z]:/", path):
path = path[1:]
if netloc and netloc != "localhost":
path = f"//{netloc}{path}"
return str(Path(path))
return Path(path).as_posix()
Comment thread
sourcery-ai[bot] marked this conversation as resolved.

async def _image_ref_to_data_url(
self,
Expand Down
2 changes: 1 addition & 1 deletion astrbot/core/skills/skill_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ def _build_skill_read_command_example(path: str) -> str:
return f"cat {path}"
if _is_windows_prompt_path(path):
command = "type"
path_arg = f'"{os.path.normpath(path)}"'
path_arg = f'"{path.replace(chr(92), "/")}"'
Comment thread
lingyun14beta marked this conversation as resolved.
Comment thread
sourcery-ai[bot] marked this conversation as resolved.
else:
command = "cat"
path_arg = shlex.quote(path)
Expand Down
1 change: 1 addition & 0 deletions astrbot/core/utils/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

6 changes: 3 additions & 3 deletions tests/test_computer_fs_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ async def test_restricted_local_member_can_read_plugin_provided_skill(
path=str(plugin_skill),
)

assert result == "# Demo Skill\n\nRead plugin docs."
assert result.replace("\r\n", "\n") == "# Demo Skill\n\nRead plugin docs."


@pytest.mark.asyncio
Expand All @@ -237,7 +237,7 @@ async def test_restricted_local_member_can_read_plugin_skill_inventory_even_if_p
path=str(plugin_skill),
)

assert result == "# Demo Skill\n"
assert result.replace("\r\n", "\n") == "# Demo Skill\n"


@pytest.mark.asyncio
Expand Down Expand Up @@ -314,7 +314,7 @@ async def test_file_read_tool_allows_partial_read_for_large_text_file(
limit=3,
)

assert result == "".join(lines[1000:1003])
assert result.replace("\r\n", "\n") == "".join(lines[1000:1003])


@pytest.mark.asyncio
Expand Down
5 changes: 4 additions & 1 deletion tests/test_openai_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -1063,7 +1063,10 @@ async def test_prepare_chat_payload_materializes_context_localhost_file_uri_imag
image_path = tmp_path / "quoted-image.png"
PILImage.new("RGBA", (1, 1), (255, 0, 0, 255)).save(image_path)

localhost_uri = f"file://localhost{image_path.as_posix()}"
posix_path = image_path.as_posix()
if not posix_path.startswith("/"):
posix_path = "/" + posix_path
localhost_uri = f"file://localhost{posix_path}"
Comment thread
sourcery-ai[bot] marked this conversation as resolved.
payloads, _ = await provider._prepare_chat_payload(
prompt=None,
contexts=[
Expand Down
3 changes: 2 additions & 1 deletion tests/test_pip_helper_modules.py
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,8 @@ def test_get_core_constraints_logs_resolution_step_context(monkeypatch):
assert any("解析核心分发名称失败" in log for log in warning_logs)


def test_iter_requirements_supports_direct_line_input():
def test_iter_requirements_supports_direct_line_input(monkeypatch):
monkeypatch.setattr("sys.platform", "linux")
Comment on lines +445 to +446

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion (testing): Clarify platform-dependent expectations and consider adding a complementary Windows-case test

Since sys.platform is forced to "linux" here for determinism, please also add a test that sets sys.platform to "win32" and asserts the expected inclusion/exclusion of the Windows-only requirement. This will exercise both branches of the marker logic independent of the CI OS.

parsed = list(
requirements_utils.iter_requirements(
lines=["demo-package>=1.0", 'other-package; sys_platform == "win32"']
Expand Down
1 change: 1 addition & 0 deletions tests/test_pip_installer.py
Original file line number Diff line number Diff line change
Expand Up @@ -788,6 +788,7 @@ def test_find_missing_requirements_honors_version_specifiers(monkeypatch, tmp_pa


def test_find_missing_requirements_skips_unmatched_markers(monkeypatch, tmp_path):
monkeypatch.setattr("sys.platform", "linux")
requirements_path = tmp_path / "requirements.txt"
requirements_path.write_text(
'demo-package; sys_platform == "win32"\n',
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/test_computer.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ async def test_exec_simple_code(self):
"""Test executing simple Python code."""
python = LocalPythonComponent()
result = await python.exec("print('hello')")
assert result["data"]["output"]["text"] == "hello\n"
assert result["data"]["output"]["text"].replace("\r\n", "\n") == "hello\n"

@pytest.mark.asyncio
async def test_exec_with_error(self):
Expand Down
Loading