Spaces:
Paused
Paused
Download src/api/imports.py from arimatch1/crewhub-api-2: direct link, hf CLI and curl.
- Browser
- Download file 1.48 kB
-
https://huggingface.co/spaces/arimatch1/crewhub-api-2/resolve/main/src/api/imports.py
- Command line
-
hf download hf://spaces/arimatch1/crewhub-api-2/src/api/imports.py
-
curl -L -o imports.py https://huggingface.co/spaces/arimatch1/crewhub-api-2/resolve/main/src/api/imports.py
1.48 kB
| # Copyright (c) 2026 CrewHub. All rights reserved. | |
| # Proprietary and confidential. See LICENSE for details. | |
| """External skill import endpoints.""" | |
| from uuid import UUID | |
| from fastapi import APIRouter, Depends | |
| from sqlalchemy.ext.asyncio import AsyncSession | |
| from src.core.auth import get_current_user | |
| from src.database import get_db | |
| from src.schemas.imports import OpenClawImportRequest, OpenClawImportResponse | |
| from src.services.openclaw_importer import OpenClawImporter | |
| router = APIRouter(prefix="/import", tags=["import"]) | |
| async def import_openclaw_skill( | |
| data: OpenClawImportRequest, | |
| db: AsyncSession = Depends(get_db), | |
| current_user: dict = Depends(get_current_user), | |
| ) -> OpenClawImportResponse: | |
| """Import an OpenClaw skill as a CrewHub agent. | |
| The imported agent starts as inactive and unverified. | |
| Requires authentication — the caller becomes the agent owner. | |
| """ | |
| importer = OpenClawImporter(db) | |
| agent = await importer.import_skill( | |
| skill_url=data.skill_url, | |
| pricing=data.pricing, | |
| category=data.category, | |
| tags=data.tags, | |
| owner_id=UUID(current_user["id"]), | |
| ) | |
| return OpenClawImportResponse( | |
| agent_id=str(agent.id), | |
| name=agent.name, | |
| status=agent.status.value if hasattr(agent.status, "value") else str(agent.status), | |
| source="openclaw", | |
| source_url=data.skill_url, | |
| ) | |