AS AgentScopeAPI 手册 / API Reference
类class agentscope.app.hub

ClawSkillHub

class ClawSkillHub(SkillHubBase)
源码Source agentscope/app/hub/_skill/_claw_hub.py:75–651

Claw 技能中心,把智能体接入外部消息渠道与企业平台。位于 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.

参数Parameters
名称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 | Noneicon URL(类型 `str | None`)。The hub's icon, defaulting to the ClawHub favicon.
base_urlkw默认default DEFAULT_BASE_URLstrClawHub 注册表的基类 URL。The base URL of the ClawHub registry.
api_tokenkw默认default Nonestr | NoneAPI 令牌(类型 `str | None`)。The ClawHub Bearer token (`clh_...`). When provided, requests are authenticated and use the higher per-user rate limit bucket.
timeoutkw默认default 30.0float超时时间(类型 `float`)。The per-request timeout in seconds.
max_retrieskw默认default 3int最大重试次数(类型 `int`)。The maximum number of retries when a request is rate limited (HTTP `429`).
源码Source agentscope/app/hub/_skill/_claw_hub.py:86–127

方法详情Method Detail

__aenter__

async def __aenter__() -> 'ClawSkillHub'
async

进入异步上下文并返回自身。

Open the HTTP client shared by every request.

返回Returns 'ClawSkillHub'
返回'ClawSkillHub'。`ClawSkillHub`:
源码Source agentscope/app/hub/_skill/_claw_hub.py:129–139

__aexit__

async def __aexit__(*exc: Any) -> None
async

退出异步上下文并清理资源。

Close the shared HTTP client.

参数Parameters
名称Name类型Type说明Description
excAnyexc(类型 `Any`)。The exc.
返回Returns None
无返回值。No value is returned.
源码Source agentscope/app/hub/_skill/_claw_hub.py:141–145

download

async def download(user_id: str, card_id: str, version: str | None = None, tag: str | None = None, chunk_size: int = DEFAULT_CHUNK_SIZE) -> SkillArchive
async

执行下载相关操作。

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.

参数Parameters
名称Name类型Type说明Description
user_idstr用户标识(类型 `str`)。The user identifier the download is authorized against. Unused by the public ClawHub catalog, kept for interface compatibility.
card_idstr卡片标识(类型 `str`)。The :attr:`SkillCard.id`, either `owner/slug` or a bare slug.
version默认default Nonestr | None版本(类型 `str | None`)。A specific semver version to download. When omitted with `tag`, the latest version is used.
tag默认default Nonestr | None标签(类型 `str | None`)。A tag name (e.g. `"latest"`) to resolve the version.
chunk_size默认default DEFAULT_CHUNK_SIZEint分块大小(类型 `int`)。The number of bytes to yield per chunk.
返回Returns SkillArchive
返回SkillArchive。`SkillArchive`:
异常Raises
  • 可能抛出 `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.
源码Source agentscope/app/hub/_skill/_claw_hub.py:277–376

list_skills

async def list_skills(user_id: str, q: str | None = None, cursor: str | None = None, limit: int = 20) -> SkillHubPage
async

列出技能。

With q the search endpoint is used, which ranks by relevance but returns a single page — next_cursor is then always None.

参数Parameters
名称Name类型Type说明Description
user_idstr用户标识(类型 `str`)。The user identifier to query skill cards for. Unused by the public ClawHub catalog, kept for interface compatibility.
q默认default Nonestr | Noneq(类型 `str | None`)。A keyword filtering the cards.
cursor默认default Nonestr | None游标(类型 `str | None`)。The opaque cursor from a previous page. Ignored when `q` is given, since search is not paginated upstream.
limit默认default 20int数量上限(类型 `int`)。The maximum number of cards per page (1-200).
返回Returns SkillHubPage
返回SkillHubPage。`SkillHubPage`:
异常Raises
  • 可能抛出 `Exception`。`HubError`:
  • 可能抛出 `Exception`。When the API returns a non-success status code.
源码Source agentscope/app/hub/_skill/_claw_hub.py:541–595

get_skill

async def get_skill(user_id: str, card_id: str) -> SkillCard
async

获取技能。

Fetch one skill plus its SKILL.md body.

参数Parameters
名称Name类型Type说明Description
user_idstr用户标识(类型 `str`)。The user identifier to query the card for. Unused by the public ClawHub catalog, kept for interface compatibility.
card_idstr卡片标识(类型 `str`)。The :attr:`SkillCard.id`, either `owner/slug` or a bare slug.
返回Returns SkillCard
返回SkillCard。`SkillCard`:
异常Raises
  • 可能抛出 `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.
源码Source agentscope/app/hub/_skill/_claw_hub.py:597–651
基于官方固定版本源码静态生成Generated from pinned official sources · Python 2.0.11 · Java 2.0.4
签名与文档为静态抽取;如有疑问请以源码为准。Signatures and docs are extracted statically; verify against the source when in doubt.