agentscope.app.hubClawSkillHub
class ClawSkillHub(SkillHubBase)
agentscope/app/hub/_skill/_claw_hub.py:75–651Claw 技能中心,把智能体接入外部消息渠道与企业平台。位于 agentscope.app.hub 包,继承自 SkillHubBase。核心成员包括 download、list_skills、get_skill。
A skill hub backed by the ClawHub registry. Declared in agentscope.app.hub. Extends SkillHubBase.
示例Example
hub = ClawSkillHub(api_token="clh_xxx")
page = await hub.list_skills(user_id="alice", q="git")
async for chunk in hub.download("gifgrep"):
... # stream-write into a sandbox
构造器摘要Constructor Summary
| 构造器Constructor | 说明Description |
|---|---|
def __init__(hub_id: str = 'clawhub', display_name: str = 'ClawHub', description: str = 'The ClawHub public skill regis… | 初始化 `ClawSkillHub` 实例。 Initialize the ClawHub skill provider. |
方法摘要Method Summary
| 方法Method | 说明Description |
|---|---|
async def __aenter__() -> 'ClawSkillHub'async | 进入异步上下文并返回自身。 Open the HTTP client shared by every request. |
async def __aexit__(*exc: Any) -> Noneasync | 退出异步上下文并清理资源。 Close the shared HTTP client. |
async def download(user_id: str, card_id: str, version: str | None = None, tag: str | None = None, chunk_size: int = DE…async | 执行下载相关操作。 Open a skill archive via ``GET /api/v1/download``. |
async def list_skills(user_id: str, q: str | None = None, cursor: str | None = None, limit: int = 20) -> SkillHubPageasync | 列出技能。 Browse or search the ClawHub registry in one request. |
async def get_skill(user_id: str, card_id: str) -> SkillCardasync | 获取技能。 Fetch one skill plus its ``SKILL.md`` body. |
构造器详情Constructor Detail
ClawSkillHub
def __init__(hub_id: str = 'clawhub', display_name: str = 'ClawHub', description: str = 'The ClawHub public skill registry.', icon_url: str | None = 'https://openclaw.ai/favicon.svg', *, base_url: str = DEFAULT_BASE_URL, api_token: str | None = None, timeout: float = 30.0, max_retries: int = 3) -> None
初始化 ClawSkillHub 实例。
Initialize the ClawHub skill provider.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
hub_id默认default 'clawhub' | str | 中心标识(类型 `str`)。The stable identifier addressing this hub in the API routes. |
display_name默认default 'ClawHub' | str | 展示名称(类型 `str`)。The user-facing hub name. |
description默认default 'The ClawHub public skill registry.' | str | 描述(类型 `str`)。The user-facing hub description. |
icon_url默认default 'https://openclaw.ai/favicon.svg' | str | None | icon URL(类型 `str | None`)。The hub's icon, defaulting to the ClawHub favicon. |
base_urlkw默认default DEFAULT_BASE_URL | str | ClawHub 注册表的基类 URL。The base URL of the ClawHub registry. |
api_tokenkw默认default None | str | None | API 令牌(类型 `str | None`)。The ClawHub Bearer token (`clh_...`). When provided, requests are authenticated and use the higher per-user rate limit bucket. |
timeoutkw默认default 30.0 | float | 超时时间(类型 `float`)。The per-request timeout in seconds. |
max_retrieskw默认default 3 | int | 最大重试次数(类型 `int`)。The maximum number of retries when a request is rate limited (HTTP `429`). |
agentscope/app/hub/_skill/_claw_hub.py:86–127方法详情Method Detail
__aenter__
async def __aenter__() -> 'ClawSkillHub'
进入异步上下文并返回自身。
Open the HTTP client shared by every request.
agentscope/app/hub/_skill/_claw_hub.py:129–139__aexit__
async def __aexit__(*exc: Any) -> None
退出异步上下文并清理资源。
Close the shared HTTP client.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
exc | Any | exc(类型 `Any`)。The exc. |
agentscope/app/hub/_skill/_claw_hub.py:141–145download
async def download(user_id: str, card_id: str, version: str | None = None, tag: str | None = None, chunk_size: int = DEFAULT_CHUNK_SIZE) -> SkillArchive
执行下载相关操作。
The response headers are awaited here — so a missing skill or an exhausted rate limit raises before the caller commits to an install — while the body stays lazy, letting the archive be piped into a sandbox without ever being held whole.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
user_id | str | 用户标识(类型 `str`)。The user identifier the download is authorized against. Unused by the public ClawHub catalog, kept for interface compatibility. |
card_id | str | 卡片标识(类型 `str`)。The :attr:`SkillCard.id`, either `owner/slug` or a bare slug. |
version默认default None | str | None | 版本(类型 `str | None`)。A specific semver version to download. When omitted with `tag`, the latest version is used. |
tag默认default None | str | None | 标签(类型 `str | None`)。A tag name (e.g. `"latest"`) to resolve the version. |
chunk_size默认default DEFAULT_CHUNK_SIZE | int | 分块大小(类型 `int`)。The number of bytes to yield per chunk. |
- 可能抛出 `Exception`。`KeyError`:
- 可能抛出 `Exception`。When the registry has no skill under `card_id`.
- 可能抛出 `Exception`。`HubError`:
- 可能抛出 `Exception`。When the API returns any other non-success status code.
agentscope/app/hub/_skill/_claw_hub.py:277–376list_skills
async def list_skills(user_id: str, q: str | None = None, cursor: str | None = None, limit: int = 20) -> SkillHubPage
列出技能。
With q the search endpoint is used, which ranks by relevance but returns a single page — next_cursor is then always None.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
user_id | str | 用户标识(类型 `str`)。The user identifier to query skill cards for. Unused by the public ClawHub catalog, kept for interface compatibility. |
q默认default None | str | None | q(类型 `str | None`)。A keyword filtering the cards. |
cursor默认default None | str | None | 游标(类型 `str | None`)。The opaque cursor from a previous page. Ignored when `q` is given, since search is not paginated upstream. |
limit默认default 20 | int | 数量上限(类型 `int`)。The maximum number of cards per page (1-200). |
- 可能抛出 `Exception`。`HubError`:
- 可能抛出 `Exception`。When the API returns a non-success status code.
agentscope/app/hub/_skill/_claw_hub.py:541–595get_skill
async def get_skill(user_id: str, card_id: str) -> SkillCard
获取技能。
Fetch one skill plus its SKILL.md body.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
user_id | str | 用户标识(类型 `str`)。The user identifier to query the card for. Unused by the public ClawHub catalog, kept for interface compatibility. |
card_id | str | 卡片标识(类型 `str`)。The :attr:`SkillCard.id`, either `owner/slug` or a bare slug. |
- 可能抛出 `Exception`。`KeyError`:
- 可能抛出 `Exception`。When the registry has no skill under `card_id`.
- 可能抛出 `Exception`。`HubError`:
- 可能抛出 `Exception`。When the API returns any other non-success status code.
agentscope/app/hub/_skill/_claw_hub.py:597–651