Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions astrbot/core/star/plugin_categories.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
"""Recommended plugin categories that plugins may declare in ``metadata.yaml``.

A category is an optional, free-form hint. The values below are the ones the
plugin market, the WebUI and the runtime know how to label and order, and a
plugin may declare something else: the declared value is normalized to a slug
either way, so one typo or one niche category cannot block a plugin from loading,
installing or updating. Display code derives labels from the slug and falls back
to the words of the slug itself.
"""

from __future__ import annotations

import re

RECOMMENDED_PLUGIN_CATEGORIES: tuple[str, ...] = (
"utility",
"ai_context",
"entertainment",
"game",
"media",
"productivity",
"integration",
"platform_adapter",
"provider_adapter",
"other",
)
"""Recommended ``metadata.yaml`` ``category`` values, in display order."""


def normalize_plugin_category(value: object) -> str | None:
"""Normalize the optional category declared by plugin metadata.

Any value is accepted. A value outside ``RECOMMENDED_PLUGIN_CATEGORIES`` is
kept as declared instead of being rejected or rewritten, because the
vocabulary is a recommendation for plugin authors rather than a constraint
the runtime enforces.

Args:
value: Raw ``category`` value read from ``metadata.yaml``.

Returns:
The normalized slug, or ``None`` when the plugin declares no category or
declares something that is not a string.
"""
if not isinstance(value, str):
return None

# Collapse separator runs so that "AI - Context", "ai-context" and
# "ai_context" reach the WebUI as one slug.
slug = re.sub(r"[\s-]+", "_", value.strip().lower())
return slug or None
9 changes: 9 additions & 0 deletions astrbot/core/star/star.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,15 @@ class StarMetadata:
views: list[ViewSpec] = field(default_factory=list)
"""插件注册的 Views 元数据。"""

# Appended last on purpose: StarMetadata is constructed positionally by
# external consumers, so new fields must not shift existing ones.
category: str | None = None
"""Optional marketplace category declared in metadata, normalized to a slug.

Any declared value is kept as-is, so this is not limited to the recommended
vocabulary; ``None`` means the plugin declares no category.
"""

@property
def plugin_id(self) -> str:
p_name = (self.name or "unknown").lower().replace("/", "_")
Expand Down
5 changes: 5 additions & 0 deletions astrbot/core/star/star_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
from .context import Context
from .error_messages import format_plugin_error
from .filter.permission import COMMAND_PERMISSION_TYPES, PermissionTypeFilter
from .plugin_categories import normalize_plugin_category
from .star import star_map, star_registry
from .star_handler import EventType, star_handlers_registry
from .updater import PLUGIN_METADATA_FILENAMES, _PluginUpdater
Expand Down Expand Up @@ -561,6 +562,9 @@ def _load_plugin_metadata(plugin_path: str, plugin_obj=None) -> StarMetadata | N
if isinstance(metadata.get("astrbot_version"), str)
else None
),
# The category is an optional, free-form hint. Declaring an
# unknown value is normalized but never rejected.
category=normalize_plugin_category(metadata.get("category")),
views=views,
i18n=PluginManager._load_plugin_i18n(plugin_path),
)
Expand Down Expand Up @@ -1202,6 +1206,7 @@ async def load(
metadata.display_name = metadata_yaml.display_name
metadata.support_platforms = metadata_yaml.support_platforms
metadata.astrbot_version = metadata_yaml.astrbot_version
metadata.category = metadata_yaml.category
metadata.views = metadata_yaml.views
metadata.i18n = metadata_yaml.i18n
except Exception as e:
Expand Down
6 changes: 5 additions & 1 deletion astrbot/dashboard/api/plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from astrbot.api.web import PluginRequest, bind_request_context
from astrbot.core import logger
from astrbot.core.log import LogManager
from astrbot.core.star.plugin_categories import RECOMMENDED_PLUGIN_CATEGORIES
from astrbot.dashboard.asgi_runtime import (
DashboardRequestState,
call_request_view,
Expand Down Expand Up @@ -623,7 +624,10 @@ async def list_plugin_market(
async def list_plugin_market_categories(
_auth: AuthContext = Depends(require_plugin_scope),
):
return ok({"categories": []})
# Slugs only: display labels stay in the dashboard i18n bundles. This is the
# recommended vocabulary used to order the filter and to keep shared labels;
# plugins may declare any other category and the WebUI shows it as declared.
return ok({"categories": list(RECOMMENDED_PLUGIN_CATEGORIES)})


@router.get("/plugin-sources")
Expand Down
1 change: 1 addition & 0 deletions astrbot/dashboard/services/plugin_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -660,6 +660,7 @@ def serialize_plugin_base(
"logo": logo_url,
"support_platforms": plugin.support_platforms,
"astrbot_version": plugin.astrbot_version,
"category": plugin.category,
"installed_at": installed_at,
"i18n": plugin.i18n,
"root_dir_name": plugin.root_dir_name,
Expand Down
1 change: 1 addition & 0 deletions changelogs/unreleased.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Unreleased

- QQ Official: failed image uploads no longer log base64 payloads, avoiding dashboard freezes from oversized log entries. Retry attempts decrease from five to three, with one summary warning.
- Plugin market: plugins can now declare an optional marketplace category in `metadata.yaml`. The plugin API serves a ten-value recommended vocabulary (`utility`, `ai_context`, `entertainment`, `game`, `media`, `productivity`, `integration`, `platform_adapter`, `provider_adapter`, `other`) that orders the filter and supplies translated labels, but any other value is accepted as written: nothing warns, nothing is rewritten, and installation and updates are never blocked. The WebUI category filter also moved from the toolbar dropdown to a chip row above the plugin list (old entry: Extensions → Plugin Market → toolbar "Category" dropdown; new entry: Extensions → Plugin Market → category row above the list).

- 「插件 → 管理行为 → 函数工具」现在只列出插件工具。Agent 运行时工具由配置文件的 AI 功能设置控制,MCP 工具可在「插件 → MCP」查看。
- Extensions → Handlers → Function Tools now lists plugin tools. Configure Agent runtime tools in the profile's AI capability settings and view MCP tools under Extensions → MCP Servers.
Expand Down
5 changes: 5 additions & 0 deletions dashboard/src/api/v1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1398,6 +1398,11 @@ export const pluginApi = {
sources() {
return typed<any>(openApiV1.listPluginSources());
},
marketCategories() {
return typed<{ categories: string[] }>(
openApiV1.listPluginMarketCategories(),
);
},
replaceSources(sources: OpenConfig[]) {
return typed<OpenConfig>(
openApiV1.replacePluginSources({ body: { sources: sources as any } }),
Expand Down
15 changes: 10 additions & 5 deletions dashboard/src/i18n/locales/en-US/features/extension.json
Original file line number Diff line number Diff line change
Expand Up @@ -142,15 +142,20 @@
},
"market": {
"recommended": "🥳 Recommended",
"allPlugins": "📦 All Extensions",
"category": "Category",
"expandCategories": "Show all categories",
"collapseCategories": "Collapse categories",
"refresh": "Refresh",
"categories": {
"all": "All",
"ai_tools": "AI Tools",
"utility": "Utility",
"ai_context": "AI Conversation",
"entertainment": "Entertainment",
"game": "Game",
"media": "Media",
"productivity": "Productivity",
"integrations": "Integrations",
"utilities": "Utilities",
"integration": "Integration",
"platform_adapter": "Platform Adapter",
"provider_adapter": "Provider Adapter",
"other": "Other"
},
"showFullName": "Full Name",
Expand Down
15 changes: 10 additions & 5 deletions dashboard/src/i18n/locales/ja-JP/features/extension.json
Original file line number Diff line number Diff line change
Expand Up @@ -142,15 +142,20 @@
},
"market": {
"recommended": "🥳 おすすめ",
"allPlugins": "📦 すべてのプラグイン",
"category": "カテゴリ",
"expandCategories": "すべてのカテゴリを表示",
"collapseCategories": "カテゴリを折りたたむ",
"refresh": "更新",
"categories": {
"all": "すべて",
"ai_tools": "AI ツール",
"utility": "ユーティリティ",
"ai_context": "AI 会話",
"entertainment": "エンターテインメント",
"game": "ゲーム",
"media": "メディア",
"productivity": "生産性",
"integrations": "外部連携",
"utilities": "ユーティリティ",
"integration": "外部連携",
"platform_adapter": "プラットフォームアダプター",
"provider_adapter": "プロバイダーアダプター",
"other": "その他"
},
"showFullName": "正式名称",
Expand Down
17 changes: 11 additions & 6 deletions dashboard/src/i18n/locales/ru-RU/features/extension.json
Original file line number Diff line number Diff line change
Expand Up @@ -142,15 +142,20 @@
},
"market": {
"recommended": "🥳 Рекомендуем",
"allPlugins": "📦 Все плагины",
"category": "Категория",
"categories": {
"expandCategories": "Показать все категории",
"collapseCategories": "Свернуть категории",
"refresh": "Обновить",
"categories": {
"all": "Все",
"ai_tools": "AI Tools",
"utility": "Утилиты",
"ai_context": "AI-диалог",
"entertainment": "Развлечения",
"game": "Игры",
"media": "Медиа",
"productivity": "Продуктивность",
"integrations": "Интеграции",
"utilities": "Утилиты",
"integration": "Интеграции",
"platform_adapter": "Адаптер платформы",
"provider_adapter": "Адаптер провайдера",
"other": "Другое"
},
"showFullName": "Полное имя",
Expand Down
15 changes: 10 additions & 5 deletions dashboard/src/i18n/locales/zh-CN/features/extension.json
Original file line number Diff line number Diff line change
Expand Up @@ -142,15 +142,20 @@
},
"market": {
"recommended": "🥳 推荐",
"allPlugins": "📦 全部插件",
"category": "分类",
"expandCategories": "展开全部分类",
"collapseCategories": "收起分类",
"refresh": "刷新",
"categories": {
"all": "全部",
"ai_tools": "AI 增强",
"utility": "实用工具",
"ai_context": "AI 对话",
"entertainment": "娱乐",
"game": "游戏",
"media": "媒体",
"productivity": "效率",
"integrations": "外部集成",
"utilities": "生活实用",
"integration": "外部集成",
"platform_adapter": "平台适配器",
"provider_adapter": "提供商适配器",
"other": "其他"
},
"showFullName": "完整名称",
Expand Down
Loading
Loading