Build and run agents you can see, understand and trust.
Python agentchatbotlarge-language-modelsllmllm-agentmcpmulti-agentmulti-modalreact-agentrealtime-agentvoice-agentvoice-assistant
fix(app): remove server-path skill import endpoint (#3536)
qbc3a0e73fa767d
diff --git a/examples/web_ui/frontend/src/api/types.ts b/examples/web_ui/frontend/src/api/types.tsindex 95f032262..f95ecca0b 100644--- a/examples/web_ui/frontend/src/api/types.ts+++ b/examples/web_ui/frontend/src/api/types.ts@@ -545,15 +545,6 @@ export interface Skill {updated_at: number;}-/**- * @deprecated The path is resolved on the server, which only means- * anything for a single-host deployment. Upload a folder or install- * from the library instead.- */-export interface AddSkillRequest {- skill_path: string;-}-// ─── Hub ──────────────────────────────────────────────────────────────────────/** One registered hub, as shown in the hub picker. */diff --git a/examples/web_ui/frontend/src/api/workspace.ts b/examples/web_ui/frontend/src/api/workspace.tsindex 5379a8427..d1b92ff0b 100644--- a/examples/web_ui/frontend/src/api/workspace.ts+++ b/examples/web_ui/frontend/src/api/workspace.ts@@ -2,7 +2,6 @@ import { ApiError, client, getBaseUrl, getUserId } from './client';import type { UploadProgress } from './knowledgeBase';import type {AddFromLibraryResponse,- AddSkillRequest,DirectoryListing,WorkspaceStatus,MCPClient,@@ -163,16 +162,6 @@ export const workspaceApi = {list: (agentId: string, sessionId: string) =>client.get<Skill[]>('/workspace/skill', { agent_id: agentId, session_id: sessionId }),- /**- * @deprecated The path is resolved on the server. Use `upload`- * for a local folder or `addFromLibrary` for an installed skill.- */- add: (agentId: string, sessionId: string, body: AddSkillRequest) =>- client.post<void>('/workspace/skill', body, {- agent_id: agentId,- session_id: sessionId,- }),-/** Uploads a picked folder as a skill, reporting send progress. */upload: (agentId: string, sessionId: string, files: File[], options: UploadOptions = {}) =>uploadSkillXhr(agentId, sessionId, files, options),diff --git a/src/agentscope/app/_router/_schema/__init__.py b/src/agentscope/app/_router/_schema/__init__.pyindex 084f150a1..6510a64c4 100644--- a/src/agentscope/app/_router/_schema/__init__.py+++ b/src/agentscope/app/_router/_schema/__init__.py@@ -19,7 +19,6 @@ from ._hub_skill import SkillViewfrom ._workspace import (AddFromLibraryRequest,AddFromLibraryResponse,- AddSkillRequest,AddSkillsFromLibraryRequest,DirectoryEntry,DirectoryListing,@@ -119,7 +118,6 @@ __all__ = [# Workspace"AddFromLibraryRequest","AddFromLibraryResponse",- "AddSkillRequest","AddSkillsFromLibraryRequest","DirectoryEntry","DirectoryListing",diff --git a/src/agentscope/app/_router/_schema/_workspace.py b/src/agentscope/app/_router/_schema/_workspace.pyindex 455e78f6b..2b2866260 100644--- a/src/agentscope/app/_router/_schema/_workspace.py+++ b/src/agentscope/app/_router/_schema/_workspace.py@@ -5,12 +5,6 @@ from pydantic import BaseModel, Fieldfrom ....mcp import MCPClient-class AddSkillRequest(BaseModel):- """The request to add skill."""-- skill_path: str--class AddFromLibraryRequest(BaseModel):"""The request to put library MCPs into a workspace."""diff --git a/src/agentscope/app/_router/_workspace.py b/src/agentscope/app/_router/_workspace.pyindex 6e3b43f6f..a40b31527 100644--- a/src/agentscope/app/_router/_workspace.py+++ b/src/agentscope/app/_router/_workspace.py@@ -32,7 +32,6 @@ from ...skill import Skillfrom ._schema import (AddFromLibraryRequest,AddFromLibraryResponse,- AddSkillRequest,AddSkillsFromLibraryRequest,DirectoryEntry,DirectoryListing,@@ -237,33 +236,6 @@ async def list_skills(return await workspace.list_skills(agent_id=agent_id)-@workspace_router.post(- "/skill",- status_code=status.HTTP_201_CREATED,- deprecated=True,-)-async def add_skill(- body: AddSkillRequest,- agent_id: str = Query(...),- session_id: str = Query(...),- user_id: str = Depends(get_current_user_id),- workspace_service: WorkspaceService = Depends(get_workspace_service),-) -> None:- """Add a skill to the session's workspace from the given path.-- Deprecated: the path is resolved on the server, which only means- anything for a single-host deployment. Use ``POST /skill/upload``- to send a folder, or ``POST /skill/from-library`` to install one- the user already has.- """- workspace = await workspace_service.resolve(- user_id,- agent_id,- session_id,- )- await workspace.add_skill(body.skill_path, agent_id=agent_id)--@workspace_router.post("/skill/upload",status_code=status.HTTP_201_CREATED,diff --git a/tests/hub_router_test.py b/tests/hub_router_test.pyindex a0e074666..a5d0a8828 100644--- a/tests/hub_router_test.py+++ b/tests/hub_router_test.py@@ -5,6 +5,7 @@ import ioimport jsonimport tempfileimport zipfile+from pathlib import Pathfrom typing import Any, AsyncIteratorfrom urllib.parse import quotefrom unittest import IsolatedAsyncioTestCase@@ -17,6 +18,7 @@ from agentscope.app.hub import (MCPCard,MCPHubBase,MCPHubPage,+ SkillArchive,SkillCard,SkillHubBase,SkillHubPage,@@ -193,9 +195,16 @@ class FakeSkillHub(SkillHubBase):user_id: str,card_id: str,version: str | None = None,+ ) -> SkillArchive:+ """Return the format and stream required by the hub contract."""+ self.download_users.append(user_id)+ return SkillArchive("zip", self._download_stream(card_id))++ async def _download_stream(+ self,+ card_id: str,) -> AsyncIterator[bytes]:"""Yield an in-memory ZIP, or raise for an unknown card."""- self.download_users.append(user_id)if card_id == "nozip":yield b"not a zip at all"return@@ -699,6 +708,84 @@ class HubRouterTest(IsolatedAsyncioTestCase):# ── install: skill ────────────────────────────────────────────+ def test_server_path_skill_import_is_disabled(self) -> None:+ """Reject a valid host skill without copying it into a workspace."""+ with tempfile.TemporaryDirectory() as source:+ Path(source, "SKILL.md").write_text(SKILL_MD, encoding="utf-8")+ Path(source, "secret.txt").write_text(+ "sentinel secret",+ encoding="utf-8",+ )+ for headers in ({}, HEADERS):+ with self.subTest(headers=headers):+ response = self._client.post(+ "/workspace/skill",+ params=self._scope,+ json={"skill_path": source},+ headers=headers,+ )+ self.assertEqual(response.status_code, 405)+ self.assertEqual(+ response.json(),+ {"detail": "Method Not Allowed"},+ )++ listed = self._client.get(+ "/workspace/skill",+ params=self._scope,+ headers=HEADERS,+ )+ self.assertEqual(listed.status_code, 200)+ self.assertEqual(listed.json(), [])+ schema = self._client.get("/openapi.json").json()+ self.assertNotIn("post", schema["paths"]["/workspace/skill"])+ self.assertNotIn("AddSkillRequest", schema["components"]["schemas"])++ def test_workspace_skill_upload_still_installs(self) -> None:+ """Uploading client-provided bytes remains available."""+ content = SKILL_MD.encode("utf-8")+ response = self._client.post(+ "/workspace/skill/upload",+ params=self._scope,+ headers=HEADERS,+ data={+ "manifest": json.dumps(+ {+ "entries": [+ {"path": "pack/SKILL.md", "size": len(content)},+ ],+ },+ ),+ },+ files=[("files", ("SKILL.md", content, "text/markdown"))],+ )+ self.assertEqual(response.status_code, 201)+ self.assertEqual(response.json(), None)+ listed = self._client.get(+ "/workspace/skill",+ params=self._scope,+ headers=HEADERS,+ ).json()+ self.assertEqual([skill["name"] for skill in listed], ["gifgrep"])++ def test_workspace_skill_library_install_still_works(self) -> None:+ """Installing a library skill still downloads its archive."""+ skill_id = self._install_skill("gifgrep").json()["id"]+ response = self._client.post(+ "/workspace/skill/from-library",+ params=self._scope,+ headers=HEADERS,+ json={"skill_ids": [skill_id]},+ )+ self.assertEqual(response.status_code, 201)+ self.assertEqual(response.json(), {"added": ["gifgrep"], "failed": {}})+ listed = self._client.get(+ "/workspace/skill",+ params=self._scope,+ headers=HEADERS,+ ).json()+ self.assertEqual([skill["name"] for skill in listed], ["gifgrep"])+def _install_skill(self, card_id: str, **params: str) -> Any:"""POST a skill install. User-level, like the MCP one."""return self._client.post(