Skip to content

JiuwenSwarm is an intelligent AI Agent built on openJiuwen. It extends the powerful capabilities of large language models directly to your fingertips through various communication apps you use daily.

Python

fix:用户上传的文件目录改为可删除

wangxinbf40def7675f
diff --git a/jiuwenswarm/channels/web/frontend/src/components/WorkspacePanel/index.tsx b/jiuwenswarm/channels/web/frontend/src/components/WorkspacePanel/index.tsx
index 892d6d0069..956b0dd167 100644
--- a/jiuwenswarm/channels/web/frontend/src/components/WorkspacePanel/index.tsx
+++ b/jiuwenswarm/channels/web/frontend/src/components/WorkspacePanel/index.tsx
@@ -37,6 +37,7 @@ const DELETABLE_ZONE_ROOTS = [
'agent/jiuwenclaw_workspace/todo',
'agent/jiuwenclaw_workspace/prompt_attachment',
'agent/jiuwenclaw_workspace/received_files',
+ 'agent/jiuwenclaw_workspace/uploads',
] as const;
/** 打开「仅可删除」时预展开并拉取的路径(含中间祖先)。 */
diff --git a/jiuwenswarm/common/workspace/zones.py b/jiuwenswarm/common/workspace/zones.py
index 9b83bb9573..06c05f3344 100644
--- a/jiuwenswarm/common/workspace/zones.py
+++ b/jiuwenswarm/common/workspace/zones.py
@@ -51,6 +51,7 @@ _PREFIX_RULES: Final[tuple[tuple[str, WorkspaceZone], ...]] = (
("agent/jiuwenclaw_workspace/messages/", WorkspaceZone.RUNTIME),
("agent/jiuwenclaw_workspace/prompt_attachment/", WorkspaceZone.ARTIFACT),
("agent/jiuwenclaw_workspace/received_files/", WorkspaceZone.ARTIFACT),
+ ("agent/jiuwenclaw_workspace/uploads/", WorkspaceZone.ARTIFACT),
)
diff --git a/tests/unit_tests/common/test_workspace_path_delete.py b/tests/unit_tests/common/test_workspace_path_delete.py
index 478561daf5..7e3f08bbd7 100644
--- a/tests/unit_tests/common/test_workspace_path_delete.py
+++ b/tests/unit_tests/common/test_workspace_path_delete.py
@@ -9,9 +9,15 @@ from pathlib import Path
import pytest
from jiuwenswarm.common.workspace.service import WorkspaceService
-from jiuwenswarm.common.workspace.zones import normalize_relative_path
+from jiuwenswarm.common.workspace.zones import (
+ WorkspaceZone,
+ classify_zone,
+ is_deletable,
+ normalize_relative_path,
+)
_DELETABLE_PREFIX = "agent/jiuwenclaw_workspace/projects"
+_UPLOADS_PREFIX = "agent/jiuwenclaw_workspace/uploads"
def test_normalize_relative_path_accepts_relative() -> None:
@@ -118,3 +124,39 @@ def test_delete_rejects_path_traversal(tmp_path: Path) -> None:
result = svc.delete_entries(["../outside"])
assert result["results"][0]["ok"] is False
assert result["results"][0]["error"] == "bad_path"
+
+
+ ("relative_path", "zone", "deletable"),
+ [
+ (f"{_UPLOADS_PREFIX}/note.txt", WorkspaceZone.ARTIFACT, True),
+ (f"{_UPLOADS_PREFIX}", WorkspaceZone.ARTIFACT, True),
+ ("agent/jiuwenclaw_workspace/prompt_attachment/a.md", WorkspaceZone.ARTIFACT, True),
+ ("agent/jiuwenclaw_workspace/received_files/b.bin", WorkspaceZone.ARTIFACT, True),
+ ("agent/jiuwenclaw_workspace/skills/SKILL.md", WorkspaceZone.SKILLS, False),
+ ],
+)
+def test_uploads_classified_as_deletable_artifact(
+ relative_path: str,
+ zone: WorkspaceZone,
+ deletable: bool,
+) -> None:
+ assert classify_zone(relative_path) == zone
+ assert is_deletable(relative_path) is deletable
+
+
+def test_delete_enterprise_upload_attachment(tmp_path: Path) -> None:
+ tenant = tmp_path / "tenant"
+ uploads = tenant / "agent" / "jiuwenclaw_workspace" / "uploads"
+ uploads.mkdir(parents=True)
+ target = uploads / "note.txt"
+ target.write_text("hello", encoding="utf-8")
+
+ svc = WorkspaceService(tenant_root=tenant)
+ rel = f"{_UPLOADS_PREFIX}/note.txt"
+ result = svc.delete_entries([rel])
+
+ assert result["results"] == [
+ {"relative_path": rel, "ok": True, "error": None, "freed_bytes": 5}
+ ]
+ assert not target.exists()