diff --git a/litellm/proxy/_lazy_openapi_snapshot.json b/litellm/proxy/_lazy_openapi_snapshot.json
index eee6beb83c7..2482cba3351 100644
--- a/litellm/proxy/_lazy_openapi_snapshot.json
+++ b/litellm/proxy/_lazy_openapi_snapshot.json
@@ -59731,7 +59731,7 @@
},
"file": {
"contentMediaType": "application/octet-stream",
- "description": "Replacement Agent Skills ZIP with the same declared skill name",
+ "description": "Replacement ZIP retaining the registered and declared skill names",
"title": "File",
"type": "string"
},
@@ -59744,6 +59744,7 @@
"type": "null"
}
],
+ "description": "Explicit SemVer, or omit/send empty for automatic versioning on approval",
"title": "Version"
}
},
@@ -59770,7 +59771,7 @@
},
"file": {
"contentMediaType": "application/octet-stream",
- "description": "Replacement Agent Skills ZIP with the same declared skill name",
+ "description": "Replacement ZIP retaining the registered and declared skill names",
"title": "File",
"type": "string"
},
@@ -59800,6 +59801,22 @@
"title": "File",
"type": "string"
},
+ "metadata": {
+ "anyOf": [
+ {
+ "contentMediaType": "application/json",
+ "contentSchema": {
+ "$ref": "#/components/schemas/SkillHubUpload"
+ },
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "description": "Optional JSON registry metadata",
+ "title": "Metadata"
+ },
"version": {
"anyOf": [
{
@@ -59832,7 +59849,19 @@
"type": "object"
},
"ImportSkillRequest": {
+ "additionalProperties": false,
"properties": {
+ "metadata": {
+ "anyOf": [
+ {
+ "$ref": "#/components/schemas/SkillHubUpload"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "description": "Optional registry name and metadata overrides"
+ },
"path": {
"anyOf": [
{
@@ -59887,6 +59916,33 @@
"title": "ImportSkillRequest",
"type": "object"
},
+ "PluginAuthor": {
+ "description": "Plugin author information.",
+ "properties": {
+ "email": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "description": "Author email",
+ "title": "Email"
+ },
+ "name": {
+ "description": "Author name",
+ "title": "Name",
+ "type": "string"
+ }
+ },
+ "required": [
+ "name"
+ ],
+ "title": "PluginAuthor",
+ "type": "object"
+ },
"PluginDownloadEvent": {
"properties": {
"authenticated": {
@@ -60102,86 +60158,6 @@
"title": "SkillHubList",
"type": "object"
},
- "SkillHubMetadata": {
- "additionalProperties": false,
- "properties": {
- "description": {
- "anyOf": [
- {
- "maxLength": 1024,
- "type": "string"
- },
- {
- "type": "null"
- }
- ],
- "title": "Description"
- },
- "domain": {
- "anyOf": [
- {
- "type": "string"
- },
- {
- "type": "null"
- }
- ],
- "title": "Domain"
- },
- "expected_updated_at": {
- "anyOf": [
- {
- "format": "date-time",
- "type": "string"
- },
- {
- "type": "null"
- }
- ],
- "description": "Published updated_at read by the editor. A stale value returns 409",
- "title": "Expected Updated At"
- },
- "keywords": {
- "anyOf": [
- {
- "items": {
- "type": "string"
- },
- "type": "array"
- },
- {
- "type": "null"
- }
- ],
- "title": "Keywords"
- },
- "namespace": {
- "anyOf": [
- {
- "type": "string"
- },
- {
- "type": "null"
- }
- ],
- "title": "Namespace"
- },
- "version": {
- "anyOf": [
- {
- "type": "string"
- },
- {
- "type": "null"
- }
- ],
- "description": "Explicit higher SemVer, or omit/null for an automatic patch bump",
- "title": "Version"
- }
- },
- "title": "SkillHubMetadata",
- "type": "object"
- },
"SkillHubPendingSkill": {
"properties": {
"action": {
@@ -60223,6 +60199,27 @@
}
]
},
+ "author": {
+ "anyOf": [
+ {
+ "$ref": "#/components/schemas/PluginAuthor"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "category": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "title": "Category"
+ },
"description": {
"anyOf": [
{
@@ -60245,6 +60242,17 @@
],
"title": "Domain"
},
+ "homepage": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "title": "Homepage"
+ },
"keywords": {
"anyOf": [
{
@@ -60308,6 +60316,123 @@
"title": "SkillHubPublication",
"type": "object"
},
+ "SkillHubRegistration": {
+ "additionalProperties": false,
+ "properties": {
+ "author": {
+ "anyOf": [
+ {
+ "$ref": "#/components/schemas/PluginAuthor"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "category": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "title": "Category"
+ },
+ "description": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "title": "Description"
+ },
+ "domain": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "title": "Domain"
+ },
+ "homepage": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "title": "Homepage"
+ },
+ "keywords": {
+ "anyOf": [
+ {
+ "items": {
+ "type": "string"
+ },
+ "type": "array"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "title": "Keywords"
+ },
+ "name": {
+ "description": "Registry skill name",
+ "pattern": "^[a-z0-9-]+$",
+ "title": "Name",
+ "type": "string"
+ },
+ "namespace": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "title": "Namespace"
+ },
+ "source": {
+ "additionalProperties": {
+ "type": "string"
+ },
+ "description": "Repository or HTTPS archive source reference",
+ "title": "Source",
+ "type": "object"
+ },
+ "version": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "default": "1.0.0",
+ "description": "Semantic version, defaults to 1.0.0 on creation",
+ "title": "Version"
+ }
+ },
+ "required": [
+ "name",
+ "source"
+ ],
+ "title": "SkillHubRegistration",
+ "type": "object"
+ },
"SkillHubRejection": {
"additionalProperties": false,
"properties": {
@@ -60431,6 +60556,27 @@
],
"title": "Approved By"
},
+ "author": {
+ "anyOf": [
+ {
+ "$ref": "#/components/schemas/PluginAuthor"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "category": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "title": "Category"
+ },
"content_url": {
"anyOf": [
{
@@ -60510,6 +60656,17 @@
],
"title": "Download Url"
},
+ "homepage": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "title": "Homepage"
+ },
"id": {
"title": "Id",
"type": "string"
@@ -60766,16 +60923,39 @@
"SkillHubSubmissionEdit": {
"additionalProperties": false,
"properties": {
- "description": {
+ "author": {
+ "anyOf": [
+ {
+ "$ref": "#/components/schemas/PluginAuthor"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "description": "Omit to preserve, null to clear"
+ },
+ "category": {
"anyOf": [
{
- "maxLength": 1024,
"type": "string"
},
{
"type": "null"
}
],
+ "description": "Omit to preserve, null to clear",
+ "title": "Category"
+ },
+ "description": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "description": "Omit to preserve, null to clear the registry description",
"title": "Description"
},
"domain": {
@@ -60787,6 +60967,7 @@
"type": "null"
}
],
+ "description": "Omit to preserve, null to clear",
"title": "Domain"
},
"expected_revision": {
@@ -60808,6 +60989,18 @@
"description": "Published updated_at read by the editor. A stale value returns 409",
"title": "Expected Updated At"
},
+ "homepage": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "description": "Omit to preserve, null to clear",
+ "title": "Homepage"
+ },
"keywords": {
"anyOf": [
{
@@ -60820,6 +61013,7 @@
"type": "null"
}
],
+ "description": "Omit to preserve, null or an empty list to clear",
"title": "Keywords"
},
"namespace": {
@@ -60831,6 +61025,7 @@
"type": "null"
}
],
+ "description": "Omit to preserve, null to clear",
"title": "Namespace"
},
"version": {
@@ -60842,7 +61037,7 @@
"type": "null"
}
],
- "description": "Explicit higher SemVer, or omit/null for an automatic patch bump",
+ "description": "Explicit SemVer, or omit/null for automatic versioning on approval",
"title": "Version"
}
},
@@ -60894,6 +61089,247 @@
"title": "SkillHubSubmissionRevision",
"type": "object"
},
+ "SkillHubUpdate": {
+ "additionalProperties": false,
+ "properties": {
+ "author": {
+ "anyOf": [
+ {
+ "$ref": "#/components/schemas/PluginAuthor"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "description": "Omit to preserve, null to clear"
+ },
+ "category": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "description": "Omit to preserve, null to clear",
+ "title": "Category"
+ },
+ "description": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "description": "Omit to preserve, null to clear the registry description",
+ "title": "Description"
+ },
+ "domain": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "description": "Omit to preserve, null to clear",
+ "title": "Domain"
+ },
+ "expected_updated_at": {
+ "anyOf": [
+ {
+ "format": "date-time",
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "description": "Published updated_at read by the editor. A stale value returns 409",
+ "title": "Expected Updated At"
+ },
+ "homepage": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "description": "Omit to preserve, null to clear",
+ "title": "Homepage"
+ },
+ "keywords": {
+ "anyOf": [
+ {
+ "items": {
+ "type": "string"
+ },
+ "type": "array"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "description": "Omit to preserve, null or an empty list to clear",
+ "title": "Keywords"
+ },
+ "namespace": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "description": "Omit to preserve, null to clear",
+ "title": "Namespace"
+ },
+ "source": {
+ "anyOf": [
+ {
+ "additionalProperties": {
+ "type": "string"
+ },
+ "type": "object"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "description": "Explicit replacement source reference. Omit/null to preserve the stored source and archive",
+ "title": "Source"
+ },
+ "version": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "description": "Explicit higher SemVer, or omit/null for an automatic patch bump",
+ "title": "Version"
+ }
+ },
+ "title": "SkillHubUpdate",
+ "type": "object"
+ },
+ "SkillHubUpload": {
+ "additionalProperties": false,
+ "properties": {
+ "author": {
+ "anyOf": [
+ {
+ "$ref": "#/components/schemas/PluginAuthor"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "category": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "title": "Category"
+ },
+ "description": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "title": "Description"
+ },
+ "domain": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "title": "Domain"
+ },
+ "homepage": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "title": "Homepage"
+ },
+ "keywords": {
+ "anyOf": [
+ {
+ "items": {
+ "type": "string"
+ },
+ "type": "array"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "title": "Keywords"
+ },
+ "name": {
+ "description": "Registry skill name",
+ "pattern": "^[a-z0-9-]+$",
+ "title": "Name",
+ "type": "string"
+ },
+ "namespace": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "title": "Namespace"
+ },
+ "version": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "default": "1.0.0",
+ "description": "Semantic version, defaults to 1.0.0 on creation",
+ "title": "Version"
+ }
+ },
+ "required": [
+ "name"
+ ],
+ "title": "SkillHubUpload",
+ "type": "object"
+ },
"SkillHubVersion": {
"properties": {
"content_kind": {
@@ -61393,6 +61829,16 @@
"title": "Sort Order",
"type": "string"
}
+ },
+ {
+ "in": "query",
+ "name": "enabled_only",
+ "required": false,
+ "schema": {
+ "default": false,
+ "title": "Enabled Only",
+ "type": "boolean"
+ }
}
],
"responses": {
@@ -61430,13 +61876,21 @@
},
"/skill-hub/skills/import": {
"post": {
- "description": "Import a public skills.sh or GitHub skill as a portable snapshot.",
+ "description": "Register a source reference, or import a public skills.sh/GitHub URL as a portable snapshot.",
"operationId": "import_skill_skill_hub_skills_import_post",
"requestBody": {
"content": {
"application/json": {
"schema": {
- "$ref": "#/components/schemas/ImportSkillRequest"
+ "anyOf": [
+ {
+ "$ref": "#/components/schemas/SkillHubRegistration"
+ },
+ {
+ "$ref": "#/components/schemas/ImportSkillRequest"
+ }
+ ],
+ "title": "Body"
}
}
},
@@ -61625,7 +62079,7 @@
]
},
"put": {
- "description": "Replace registry metadata, preserving files. Members submit an immutable proposal for admin review.",
+ "description": "Update supplied registry fields. Omitted metadata is retained, null clears it, and version defaults to a bump.",
"operationId": "replace_skill_metadata_skill_hub_skills__name__put",
"parameters": [
{
@@ -61642,7 +62096,7 @@
"content": {
"application/json": {
"schema": {
- "$ref": "#/components/schemas/SkillHubMetadata"
+ "$ref": "#/components/schemas/SkillHubUpdate"
}
}
},
@@ -61920,7 +62374,7 @@
},
"/skill-hub/skills/{name}/upload": {
"put": {
- "description": "Replace skill files, retaining registry fields. Members propose an update against the original editor timestamp.",
+ "description": "Replace files and refresh their inherited description, retaining registry overrides and other metadata.",
"operationId": "replace_skill_archive_skill_hub_skills__name__upload_put",
"parameters": [
{
@@ -62114,7 +62568,7 @@
},
"/skill-hub/skills/{name}/versions/{version_id}/archive": {
"get": {
- "description": "Download a retained publication as a portable ZIP with SKILL.md at its root.",
+ "description": "Download a retained skill ZIP, preserving legacy packages without portable frontmatter.",
"operationId": "download_skill_version_skill_hub_skills__name__versions__version_id__archive_get",
"parameters": [
{
@@ -62450,7 +62904,7 @@
]
},
"put": {
- "description": "Replace a pending proposal's metadata, preserving files. Only its original submitting user may edit.",
+ "description": "Update supplied proposal metadata. Omit/null version uses automatic versioning on approval.",
"operationId": "edit_submission_skill_hub_submissions__submission_id__put",
"parameters": [
{
@@ -62573,7 +63027,7 @@
},
"/skill-hub/submissions/{submission_id}/archive": {
"get": {
- "description": "Download an owned proposal as a private portable ZIP. Legacy nonportable archives return 404.",
+ "description": "Download an owned proposal as a private ZIP, preserving legacy packages without portable frontmatter.",
"operationId": "download_submission_skill_hub_submissions__submission_id__archive_get",
"parameters": [
{
diff --git a/litellm/proxy/anthropic_endpoints/claude_code_endpoints/claude_code_marketplace.py b/litellm/proxy/anthropic_endpoints/claude_code_endpoints/claude_code_marketplace.py
index 3534dd167de..7ba58677bef 100644
--- a/litellm/proxy/anthropic_endpoints/claude_code_endpoints/claude_code_marketplace.py
+++ b/litellm/proxy/anthropic_endpoints/claude_code_endpoints/claude_code_marketplace.py
@@ -29,7 +29,7 @@ from typing import Annotated, Final, Protocol, TypedDict, get_args
from fastapi import APIRouter, Depends, File, Form, HTTPException, Query, Request, UploadFile
from fastapi.responses import JSONResponse, Response
-from pydantic import Json, TypeAdapter
+from pydantic import Json, TypeAdapter, ValidationError
from typing_extensions import ReadOnly, assert_never
from litellm._logging import verbose_proxy_logger
@@ -66,6 +66,7 @@ from litellm.types.proxy.auth.special_headers import SpecialHeaders
from litellm.types.proxy.claude_code_endpoints import (
InstallationPreference,
ListPluginsResponse,
+ PluginAuthor,
PluginListItem,
PluginResponse,
PluginSpec,
@@ -109,6 +110,15 @@ MANIFEST_FIELDS: Final = TypeAdapter(dict[str, object])
_SELF_INSTALLING_PREFERENCES: Final[frozenset[InstallationPreference]] = frozenset({"auto_install", "required"})
+def read_plugin_author(value: object) -> PluginAuthor | None:
+ if value is None:
+ return None
+ try:
+ return PluginAuthor.model_validate({"name": value} if isinstance(value, str) else value)
+ except ValidationError:
+ return None
+
+
def get_installation_preference(manifest: Mapping[str, object]) -> InstallationPreference | None:
value: Final = manifest.get("installation_preference")
if value is None or value in _INSTALLATION_PREFERENCES:
@@ -216,13 +226,13 @@ async def upload_plugin(
"sha256": digest,
}
spec: Final = RegisterPluginRequest.model_validate({**metadata.model_dump(), "source": source})
- _validate_installation_preference(spec)
+ validate_plugin_installation_preference(spec)
published: Final = await uploads.publish(
PluginPublication(
name=spec.name,
version=spec.version,
description=spec.description,
- manifest=_build_plugin_manifest(spec.name, spec),
+ manifest=build_plugin_manifest(spec.name, spec),
content=archive,
created_by=user_api_key_dict.user_id,
)
@@ -445,7 +455,7 @@ _VALID_GIT_SUBDIR_PATH_RE: Final = re.compile(r"^[a-zA-Z0-9][a-zA-Z0-9._-]*(/[a-
_VALID_SHA256_RE: Final = re.compile(r"^[0-9a-fA-F]{64}$")
-def _validate_plugin_source(source: Mapping[str, str]) -> None:
+def validate_plugin_source(source: Mapping[str, str]) -> None:
"""Validate plugin source format, raising HTTPException on invalid input."""
source_type: Final = source.get("source")
if source_type == "github":
@@ -501,7 +511,7 @@ def _validate_plugin_source(source: Mapping[str, str]) -> None:
)
-def _validate_installation_preference(spec: PluginSpec) -> None:
+def validate_plugin_installation_preference(spec: PluginSpec) -> None:
if spec.installation_preference is None:
return
if spec.source.get("source") != "archive":
@@ -522,7 +532,7 @@ def _validate_installation_preference(spec: PluginSpec) -> None:
)
-def _build_plugin_manifest(name: str, spec: PluginSpec) -> Mapping[str, object]:
+def build_plugin_manifest(name: str, spec: PluginSpec) -> Mapping[str, object]:
"""Build the stored manifest dict shared by plugin create and update."""
dumped: Final[Mapping[str, object]] = MappingProxyType(spec.model_dump(exclude_none=True))
return {"name": name, **{key: value for key, value in dumped.items() if value and key != "name"}}
@@ -617,10 +627,10 @@ async def register_plugin(
detail={"error": "Plugin name must be kebab-case (lowercase letters, numbers, hyphens)"},
)
- _validate_plugin_source(request.source)
- _validate_installation_preference(request)
+ validate_plugin_source(request.source)
+ validate_plugin_installation_preference(request)
- manifest: Final[Mapping[str, object]] = _build_plugin_manifest(request.name, request)
+ manifest: Final[Mapping[str, object]] = build_plugin_manifest(request.name, request)
plugin: Final = await uploads.publish(
PluginPublication(
@@ -719,7 +729,7 @@ async def list_visible_plugins(enabled_only: bool, user_api_key_dict: UserAPIKey
description=p.description,
source=manifest.get("source", {}),
has_agent_skill_metadata=has_agent_skill_metadata(MANIFEST_FIELDS.validate_python(manifest)),
- author=manifest.get("author"),
+ author=read_plugin_author(manifest.get("author")),
homepage=manifest.get("homepage"),
keywords=manifest.get("keywords"),
category=manifest.get("category"),
@@ -887,11 +897,11 @@ async def update_plugin(
current_manifest: Final = MANIFEST_FIELDS.validate_json(existing.manifest_json or "{}")
if request.source != current_manifest.get("source"):
- _validate_plugin_source(request.source)
- _validate_installation_preference(request)
+ validate_plugin_source(request.source)
+ validate_plugin_installation_preference(request)
manifest: Final[Mapping[str, object]] = {
- **_build_plugin_manifest(plugin_name, request),
+ **build_plugin_manifest(plugin_name, request),
**(
{"agent_skill": current_manifest["agent_skill"]}
if "agent_skill" in current_manifest and request.source == current_manifest.get("source")
diff --git a/litellm/proxy/discovery_endpoints/skill_hub_endpoints.py b/litellm/proxy/discovery_endpoints/skill_hub_endpoints.py
index 8cbcf6d52ea..bceaecf7fca 100644
--- a/litellm/proxy/discovery_endpoints/skill_hub_endpoints.py
+++ b/litellm/proxy/discovery_endpoints/skill_hub_endpoints.py
@@ -9,6 +9,7 @@ from urllib.parse import quote
import httpx
from fastapi import APIRouter, Depends, File, Form, HTTPException, Query, Request, Response, UploadFile
+from pydantic import Json
import litellm
from litellm.llms.custom_httpx.http_handler import (
@@ -27,20 +28,25 @@ from litellm.models.plugin_upload import (
PublishedPlugin,
has_agent_skill_metadata,
)
-from litellm.models.skill_submission import SkillSubmission, SkillSubmissionStore
+from litellm.models.skill_submission import SkillProposal, SkillSubmission, SkillSubmissionStore
from litellm.proxy._types import UserAPIKeyAuth
from litellm.proxy.anthropic_endpoints.claude_code_endpoints.claude_code_marketplace import (
MANIFEST_FIELDS,
+ build_plugin_manifest,
delete_plugin,
disable_plugin,
enable_plugin,
+ get_installation_preference,
get_plugin_downloads,
header_key_caller,
list_visible_plugins,
plugin_archive_source_matches,
plugin_archive_url,
plugin_downloader,
+ read_plugin_author,
require_download_recorded,
+ validate_plugin_installation_preference,
+ validate_plugin_source,
)
from litellm.proxy.anthropic_endpoints.claude_code_endpoints.claude_code_skill_access import resolve_skill_visibility
from litellm.proxy.anthropic_endpoints.claude_code_endpoints.skill_upload_archive import build_uploaded_skill_archive
@@ -54,6 +60,7 @@ from litellm.proxy.deps.repositories import PluginUploadRepositoryDep, SkillSubm
from litellm.proxy.discovery_endpoints.agent_skills_archive import (
SkillArchive,
build_agent_skill_archive,
+ read_skill_archive_members,
)
from litellm.proxy.discovery_endpoints.skill_hub_mutations import (
SkillMutationError,
@@ -70,25 +77,32 @@ from litellm.proxy.discovery_endpoints.skill_import import (
select_imported_skill,
)
from litellm.repositories.plugin_publication import read_plugin_publisher, read_plugin_review
-from litellm.types.proxy.claude_code_endpoints import PluginListItem
+from litellm.types.proxy.claude_code_endpoints import (
+ PluginListItem,
+ PluginSpec,
+ RegisterPluginRequest,
+)
from litellm.types.proxy.discovery_endpoints.agent_skills_endpoints import AgentSkillsIndexEntry
from litellm.types.proxy.skill_hub import (
ImportSkillRequest,
+ SkillHubAgentSkill,
SkillHubList,
SkillHubMetadata,
SkillHubMutationResponse,
SkillHubPendingSkill,
SkillHubProposal,
SkillHubPublication,
+ SkillHubRegistration,
SkillHubRestore,
SkillHubSkill,
+ SkillHubUpdate,
+ SkillHubUpload,
SkillHubVersion,
SkillHubVersions,
SkillSortField,
)
router: Final = APIRouter(prefix="/skill-hub/skills", tags=["Skills Hub"])
-_EDITABLE_METADATA: Final = frozenset(SkillHubMetadata.model_fields)
router.add_api_route(
"/{plugin_name}/downloads", get_plugin_downloads, methods=["GET"], response_model=PluginDownloadsResponse
)
@@ -111,6 +125,10 @@ def _download_url(request: Request, name: str) -> str:
return _url(request, f"skill-hub/skills/{quote(name, safe='')}/archive")
+def _portable_source(request: Request, name: str) -> Mapping[str, str]:
+ return {"source": "archive", "url": _download_url(request, name)}
+
+
def _skill_response(request: Request, plugin: PluginListItem, download_count: int | None = None) -> SkillHubSkill:
local_archive: Final = plugin_archive_source_matches(
request,
@@ -119,6 +137,7 @@ def _skill_response(request: Request, plugin: PluginListItem, download_count: in
plugin.source.get("sha256", ""),
has_agent_skill_metadata=plugin.has_agent_skill_metadata,
)
+ portable: Final = local_archive and plugin.has_agent_skill_metadata
return SkillHubSkill(
id=plugin.id,
name=plugin.name,
@@ -127,6 +146,9 @@ def _skill_response(request: Request, plugin: PluginListItem, download_count: in
domain=plugin.domain,
namespace=plugin.namespace,
keywords=None if plugin.keywords is None else tuple(plugin.keywords),
+ author=plugin.author,
+ category=plugin.category,
+ homepage=plugin.homepage,
updated_at=None if plugin.updated_at is None else datetime.fromisoformat(plugin.updated_at),
created_at=None if plugin.created_at is None else datetime.fromisoformat(plugin.created_at),
created_by=plugin.created_by,
@@ -134,9 +156,11 @@ def _skill_response(request: Request, plugin: PluginListItem, download_count: in
published_by=plugin.published_by,
security_scan_passed=plugin.security_scan_passed,
visibility="public" if plugin.enabled else "private",
- source={"source": "archive", "url": _download_url(request, plugin.name)} if local_archive else plugin.source,
- download_url=_download_url(request, plugin.name) if local_archive else None,
- content_url=_url(request, f"skill-hub/skills/{quote(plugin.name, safe='')}/content") if local_archive else None,
+ source=_portable_source(request, plugin.name) if portable else plugin.source,
+ download_url=(
+ _download_url(request, plugin.name) if portable else plugin.source.get("url") if local_archive else None
+ ),
+ content_url=_url(request, f"skill-hub/skills/{quote(plugin.name, safe='')}/content") if portable else None,
download_count=download_count,
)
@@ -153,9 +177,10 @@ async def list_skills(
security_scan_passed: bool | None = None,
sort_by: SkillSortField = "name",
sort_order: Literal["asc", "desc"] = "asc",
+ enabled_only: bool = False,
) -> SkillHubList:
"""Browse the caller's public and granted private skills."""
- catalog: Final = await list_visible_plugins(enabled_only=False, user_api_key_dict=caller)
+ catalog: Final = await list_visible_plugins(enabled_only=enabled_only, user_api_key_dict=caller)
needle: Final = query.strip().casefold()
selected_tag: Final = tag.strip().casefold()
matched: Final = tuple(
@@ -255,6 +280,9 @@ def skill_metadata_response(request: Request, metadata: PluginArchiveMetadata) -
"domain": manifest.get("domain"),
"namespace": manifest.get("namespace"),
"keywords": manifest.get("keywords"),
+ "author": read_plugin_author(manifest.get("author")),
+ "category": manifest.get("category"),
+ "homepage": manifest.get("homepage"),
}
),
)
@@ -275,12 +303,12 @@ def _require_admin(caller: UserAPIKeyAuth) -> None:
async def replace_skill_metadata(
request: Request,
name: str,
- body: SkillHubMetadata,
+ body: SkillHubUpdate,
uploads: PluginUploadRepositoryDep,
submissions: SkillSubmissionRepositoryDep,
caller: Annotated[UserAPIKeyAuth, Depends(user_api_key_auth)],
) -> SkillHubMutationResponse:
- """Replace registry metadata, preserving files. Members submit an immutable proposal for admin review."""
+ """Update supplied registry fields. Omitted metadata is retained, null clears it, and version defaults to a bump."""
existing: Final = await write_target(name, True, uploads, caller, body.expected_updated_at)
if isinstance(existing, SkillMutationError):
raise HTTPException(existing.status, existing.message)
@@ -289,17 +317,47 @@ async def replace_skill_metadata(
publication: Final = PluginPublication(
name=name,
version=body.version,
- description=body.description,
- manifest={
- **{key: value for key, value in existing.manifest.items() if key not in _EDITABLE_METADATA},
- **body.model_dump(exclude_none=True),
- "name": name,
- },
+ description=body.description if "description" in body.model_fields_set else existing.description,
+ manifest=updated_skill_manifest(request, name, existing.manifest, body),
created_by=caller.user_id,
)
return await _mutate(request, publication, existing, _require_store(uploads), submissions, caller)
+def updated_skill_manifest(
+ request: Request, name: str, manifest: Mapping[str, object], body: SkillHubMetadata
+) -> Mapping[str, object]:
+ replaced: Final = body.model_fields_set | {"version"}
+ source: Final = body.source if isinstance(body, SkillHubUpdate) else None
+ original: Final = PluginSpec.model_validate({"source": manifest.get("source", {})}).source
+ displayed: Final = (
+ source == _portable_source(request, name)
+ and has_agent_skill_metadata(manifest)
+ and plugin_archive_source_matches(
+ request, name, original, original.get("sha256", ""), has_agent_skill_metadata=True
+ )
+ )
+ changed: Final = source is not None and source != original and not displayed
+ if changed and source is not None:
+ validate_plugin_source(source)
+ updated: Final = {
+ **{
+ key: value
+ for key, value in manifest.items()
+ if key not in replaced and not (changed and key == "agent_skill")
+ },
+ **body.model_dump(exclude={"source", "expected_revision"}, exclude_none=True, exclude_unset=True),
+ "name": name,
+ "source": source if changed else original,
+ }
+ validate_plugin_installation_preference(
+ PluginSpec.model_validate(
+ {"source": updated["source"], "installation_preference": get_installation_preference(updated)}
+ )
+ )
+ return updated
+
+
@router.post("/{name}/publish", response_model=SkillHubSkill)
async def publish_skill(
request: Request,
@@ -344,6 +402,7 @@ async def upload_skill(
caller: Annotated[UserAPIKeyAuth, Depends(archive_writer)],
file: Annotated[UploadFile, File(description="Agent Skills ZIP with SKILL.md and optional supporting files")],
version: Annotated[str | None, Form()] = None,
+ metadata: Annotated[Json[SkillHubUpload] | None, Form(description="Optional JSON registry metadata")] = None,
) -> SkillHubMutationResponse:
"""Publish a portable skill while retaining Claude marketplace compatibility."""
store: Final = _require_store(uploads)
@@ -352,8 +411,72 @@ async def upload_skill(
raise HTTPException(413, "Skill ZIP must be 10 MiB or smaller")
archive: Final = await asyncio.to_thread(build_agent_skill_archive, content)
if archive is None:
+ if metadata is not None:
+ return await _publish_legacy_upload(request, store, submissions, caller, content, metadata, version)
raise HTTPException(422, "Upload a valid Agent Skill with name and description in SKILL.md")
- return await _publish(request, store, submissions, caller, archive, version, None)
+ return await _publish(request, store, submissions, caller, archive, version, None, metadata)
+
+
+def _creation_version(version: str | None, metadata: SkillHubUpload | None) -> str | None:
+ if metadata is None or "version" not in metadata.model_fields_set:
+ return version
+ if version is not None and metadata.version is not None and version != metadata.version:
+ raise HTTPException(400, "Send matching versions or specify version in only one place")
+ return version if version is not None else metadata.version
+
+
+async def _publish_legacy_upload(
+ request: Request,
+ store: PluginUploadStore,
+ submissions: SkillSubmissionStore | None,
+ caller: UserAPIKeyAuth,
+ content: bytes,
+ metadata: SkillHubUpload,
+ version: str | None,
+) -> SkillHubMutationResponse:
+ existing: Final = await write_target(metadata.name, False, store, caller)
+ if isinstance(existing, SkillMutationError):
+ raise HTTPException(existing.status, existing.message)
+ publication: Final = await _prepare_legacy_upload(request, content, metadata, version, caller.user_id)
+ return await _mutate(request, publication, existing, store, submissions, caller)
+
+
+async def _prepare_legacy_upload(
+ request: Request,
+ content: bytes,
+ metadata: SkillHubUpload,
+ version: str | None,
+ created_by: str | None,
+) -> PluginPublication:
+ archive: Final = await asyncio.to_thread(build_uploaded_skill_archive, content, metadata.name)
+ if (
+ archive is None
+ or await asyncio.to_thread(
+ read_skill_archive_members, archive, for_upload=True, skill_path=f"skills/{metadata.name}"
+ )
+ is None
+ ):
+ raise HTTPException(422, "Upload a valid ZIP with SKILL.md and safe supporting files")
+ digest: Final = hashlib.sha256(archive).hexdigest()
+ spec: Final = RegisterPluginRequest.model_validate(
+ {
+ **metadata.model_dump(),
+ "version": _creation_version(version, metadata),
+ "source": {
+ "source": "archive",
+ "url": plugin_archive_url(request, metadata.name, digest),
+ "sha256": digest,
+ },
+ }
+ )
+ return PluginPublication(
+ name=spec.name,
+ version=spec.version,
+ description=spec.description,
+ manifest=build_plugin_manifest(spec.name, spec),
+ content=archive,
+ created_by=created_by,
+ )
def import_http_client() -> httpx.AsyncClient:
@@ -363,13 +486,21 @@ def import_http_client() -> httpx.AsyncClient:
@router.post("/import", response_model=SkillHubMutationResponse)
async def import_skill(
request: Request,
- body: ImportSkillRequest,
+ body: SkillHubRegistration | ImportSkillRequest,
uploads: PluginUploadRepositoryDep,
submissions: SkillSubmissionRepositoryDep,
caller: Annotated[UserAPIKeyAuth, Depends(archive_writer)],
client: Annotated[httpx.AsyncClient, Depends(import_http_client)],
) -> SkillHubMutationResponse:
- """Import a public skills.sh or GitHub skill as a portable snapshot."""
+ """Register a source reference, or import a public skills.sh/GitHub URL as a portable snapshot."""
+ if isinstance(body, SkillHubRegistration):
+ return await _register_reference(
+ request,
+ _require_store(uploads),
+ submissions,
+ caller,
+ RegisterPluginRequest.model_validate(body.model_dump()),
+ )
store: Final = _require_store(uploads)
source: Final = parse_skill_source(body.url, skill=body.skill, ref=body.ref, path=body.path)
if isinstance(source, SkillImportError):
@@ -380,7 +511,28 @@ async def import_skill(
archive: Final = await asyncio.to_thread(select_imported_skill, content, source)
if isinstance(archive, SkillImportError):
raise HTTPException(archive.status, archive.message)
- return await _publish(request, store, submissions, caller, archive, body.version, body.url)
+ return await _publish(request, store, submissions, caller, archive, body.version, body.url, body.metadata)
+
+
+async def _register_reference(
+ request: Request,
+ store: PluginUploadStore,
+ submissions: SkillSubmissionStore | None,
+ caller: UserAPIKeyAuth,
+ body: RegisterPluginRequest,
+) -> SkillHubMutationResponse:
+ validate_plugin_source(body.source)
+ existing: Final = await write_target(body.name, False, store, caller)
+ if isinstance(existing, SkillMutationError):
+ raise HTTPException(existing.status, existing.message)
+ publication: Final = PluginPublication(
+ name=body.name,
+ version=body.version,
+ description=body.description,
+ manifest=build_plugin_manifest(body.name, body),
+ created_by=caller.user_id,
+ )
+ return await _mutate(request, publication, existing, store, submissions, caller)
async def _publish(
@@ -391,11 +543,16 @@ async def _publish(
archive: SkillArchive,
version: str | None,
origin: str | None,
+ metadata: SkillHubUpload | None = None,
) -> SkillHubMutationResponse:
- existing: Final = await write_target(archive.declared_name or "", False, store, caller)
+ existing: Final = await write_target(
+ metadata.name if metadata else archive.declared_name or "", False, store, caller
+ )
if isinstance(existing, SkillMutationError):
raise HTTPException(existing.status, existing.message)
- publication: Final = await prepare_skill_publication(request, archive, version, origin, caller.user_id)
+ publication: Final = await prepare_skill_publication(
+ request, archive, _creation_version(version, metadata), origin, caller.user_id, metadata
+ )
return await _mutate(request, publication, existing, store, submissions, caller)
@@ -423,6 +580,7 @@ def skill_proposal_response(request: Request, submission: SkillSubmission) -> Sk
"name": proposal.name,
"description": proposal.description,
"version": proposal.version,
+ "author": read_plugin_author(proposal.manifest.get("author")),
**(
{
"source": {
@@ -444,11 +602,11 @@ async def replace_skill_archive(
uploads: PluginUploadRepositoryDep,
submissions: SkillSubmissionRepositoryDep,
caller: Annotated[UserAPIKeyAuth, Depends(archive_writer)],
- file: Annotated[UploadFile, File(description="Replacement Agent Skills ZIP with the same declared skill name")],
+ file: Annotated[UploadFile, File(description="Replacement ZIP retaining the registered and declared skill names")],
version: Annotated[str | None, Form()] = None,
expected_updated_at: Annotated[datetime | None, Form()] = None,
) -> SkillHubMutationResponse:
- """Replace skill files, retaining registry fields. Members propose an update against the original editor timestamp."""
+ """Replace files and refresh their inherited description, retaining registry overrides and other metadata."""
existing: Final = await write_target(name, True, uploads, caller, expected_updated_at)
if isinstance(existing, SkillMutationError):
raise HTTPException(existing.status, existing.message)
@@ -457,14 +615,50 @@ async def replace_skill_archive(
content: Final = await file.read(MAX_IMPORT_BYTES + 1)
if len(content) > MAX_IMPORT_BYTES:
raise HTTPException(413, "Skill ZIP must be 10 MiB or smaller")
- archive: Final = await asyncio.to_thread(build_agent_skill_archive, content)
- if archive is None or archive.declared_name != name:
- raise HTTPException(422, "Replacement SKILL.md must declare the existing skill name and a description")
- prepared: Final = await prepare_skill_publication(request, archive, version, None, caller.user_id)
- publication: Final = replace(prepared, manifest={**existing.manifest, **prepared.manifest})
+ publication: Final = await prepare_skill_replacement(request, content, existing, version, caller.user_id)
return await _mutate(request, publication, existing, _require_store(uploads), submissions, caller)
+async def prepare_skill_replacement(
+ request: Request,
+ content: bytes,
+ existing: PluginSnapshot | SkillProposal,
+ version: str | None,
+ created_by: str | None,
+) -> PluginPublication:
+ archive: Final = await asyncio.to_thread(build_agent_skill_archive, content)
+ declared: Final = (
+ SkillHubAgentSkill.model_validate(existing.manifest["agent_skill"])
+ if has_agent_skill_metadata(existing.manifest)
+ else None
+ )
+ if declared is not None and (archive is None or archive.declared_name != declared.name):
+ raise HTTPException(422, "Replacement SKILL.md must declare the existing skill name and a description")
+ metadata: Final = SkillHubUpload.model_validate(
+ {
+ "name": existing.name,
+ "version": version,
+ **(
+ {"description": existing.description}
+ if declared is None or existing.description != declared.description
+ else {}
+ ),
+ }
+ )
+ prepared: Final = (
+ await _prepare_legacy_upload(request, content, metadata, version, created_by)
+ if archive is None
+ else await prepare_skill_publication(request, archive, version, None, created_by, metadata)
+ )
+ return replace(
+ prepared,
+ manifest={
+ **{key: value for key, value in existing.manifest.items() if key != "description"},
+ **prepared.manifest,
+ },
+ )
+
+
def skill_publication_response(
request: Request, publication: PluginPublication, published: PublishedPlugin
) -> SkillHubSkill:
@@ -488,6 +682,9 @@ def skill_publication_response(
"domain": publication.manifest.get("domain"),
"namespace": publication.manifest.get("namespace"),
"keywords": publication.manifest.get("keywords"),
+ "author": read_plugin_author(publication.manifest.get("author")),
+ "category": publication.manifest.get("category"),
+ "homepage": publication.manifest.get("homepage"),
}
),
)
@@ -499,8 +696,9 @@ async def prepare_skill_publication(
version: str | None,
origin: str | None,
created_by: str | None,
+ metadata: SkillHubUpload | None = None,
) -> PluginPublication:
- name: Final = archive.declared_name
+ name: Final = metadata.name if metadata is not None else archive.declared_name
if name is None:
raise HTTPException(422, "SKILL.md must declare a skill name")
plugin: Final = await asyncio.to_thread(build_uploaded_skill_archive, archive.content, name)
@@ -515,13 +713,24 @@ async def prepare_skill_publication(
"url": plugin_archive_url(request, name, digest),
"sha256": digest,
}
- manifest: Final = {
- "name": name,
- "description": archive.declared_description,
- "version": version,
- "source": source,
- "agent_skill": {
+ description: Final = (
+ metadata.description
+ if metadata is not None and "description" in metadata.model_fields_set
+ else archive.declared_description
+ )
+ spec: Final = RegisterPluginRequest.model_validate(
+ {
+ **(metadata.model_dump() if metadata else {}),
"name": name,
+ "description": description,
+ "version": version,
+ "source": source,
+ }
+ )
+ manifest: Final = {
+ **build_plugin_manifest(name, spec),
+ "agent_skill": {
+ "name": archive.declared_name,
"description": archive.declared_description,
"digest": archive.digest,
"origin": origin,
@@ -530,7 +739,7 @@ async def prepare_skill_publication(
return PluginPublication(
name=name,
version=version,
- description=archive.declared_description,
+ description=description,
manifest=manifest,
content=plugin,
created_by=created_by,
@@ -608,37 +817,41 @@ async def download_skill_version(
uploads: PluginUploadRepositoryDep,
caller: Annotated[UserAPIKeyAuth, Depends(user_api_key_auth)],
) -> Response:
- """Download a retained publication as a portable ZIP with SKILL.md at its root."""
+ """Download a retained skill ZIP, preserving legacy packages without portable frontmatter."""
store: Final = _require_store(uploads)
metadata: Final = await _version_metadata(name, store, caller)
version: Final = await store.version(metadata, version_id)
if version is None:
raise HTTPException(404, "Skill version not found")
content: Final = await store.version_content(metadata, version_id)
- archive: Final = (
- await asyncio.to_thread(build_agent_skill_archive, content, plugin_name=name) if content is not None else None
- )
- if archive is None:
- raise HTTPException(404, "This version has no retained Agent Skills archive")
+ if content is None:
+ raise HTTPException(404, "This version has no retained skill archive")
+ payload: Final = await skill_archive_payload(content, name)
+ digest: Final = hashlib.sha256(payload).hexdigest()
require_download_recorded(
await store.record_download(
replace(metadata, version=version.version),
- archive.digest.removeprefix("sha256:"),
+ digest,
plugin_downloader(caller),
)
)
return Response(
- archive.content,
+ payload,
media_type="application/zip",
headers={
"Content-Disposition": f'attachment; filename="{name}.zip"',
"Cache-Control": "private, no-store",
"X-Content-Type-Options": "nosniff",
- "ETag": f'"{archive.digest}"',
+ "ETag": f'"sha256:{digest}"',
},
)
+async def skill_archive_payload(content: bytes, name: str) -> bytes:
+ archive: Final = await asyncio.to_thread(build_agent_skill_archive, content, plugin_name=name)
+ return archive.content if archive is not None else content
+
+
@router.post("/{name}/versions/{version_id}/restore", response_model=SkillHubSkill)
async def restore_skill_version(
request: Request,
diff --git a/litellm/proxy/discovery_endpoints/skill_hub_submissions.py b/litellm/proxy/discovery_endpoints/skill_hub_submissions.py
index 884e15e72a0..48cafd4a63e 100644
--- a/litellm/proxy/discovery_endpoints/skill_hub_submissions.py
+++ b/litellm/proxy/discovery_endpoints/skill_hub_submissions.py
@@ -1,5 +1,4 @@
-import asyncio
-from dataclasses import replace
+import hashlib
from typing import Annotated, Final
from fastapi import APIRouter, Depends, File, Form, HTTPException, Query, Request, Response, UploadFile
@@ -17,12 +16,13 @@ from litellm.proxy._types import UserAPIKeyAuth
from litellm.proxy.anthropic_endpoints.claude_code_endpoints.claude_code_skill_access import resolve_skill_visibility
from litellm.proxy.auth.user_api_key_auth import user_api_key_auth
from litellm.proxy.deps.repositories import PluginUploadRepositoryDep, SkillSubmissionRepositoryDep
-from litellm.proxy.discovery_endpoints.agent_skills_archive import build_agent_skill_archive
from litellm.proxy.discovery_endpoints.skill_hub_endpoints import (
- prepare_skill_publication,
+ prepare_skill_replacement,
+ skill_archive_payload,
skill_metadata_response,
skill_proposal_response,
skill_publication_response,
+ updated_skill_manifest,
)
from litellm.proxy.discovery_endpoints.skill_hub_mutations import (
SkillMutationError,
@@ -36,7 +36,6 @@ from litellm.proxy.discovery_endpoints.skill_hub_mutations import (
from litellm.proxy.discovery_endpoints.skill_import import MAX_IMPORT_BYTES
from litellm.repositories.plugin_publication import resolve_plugin_version
from litellm.types.proxy.skill_hub import (
- SkillHubMetadata,
SkillHubRejection,
SkillHubReviewResponse,
SkillHubSubmission,
@@ -134,28 +133,24 @@ async def download_submission(
submissions: SkillSubmissionRepositoryDep,
caller: Annotated[UserAPIKeyAuth, Depends(user_api_key_auth)],
) -> Response:
- """Download an owned proposal as a private portable ZIP. Legacy nonportable archives return 404."""
+ """Download an owned proposal as a private ZIP, preserving legacy packages without portable frontmatter."""
owner: Final = _owner(caller)
store: Final = _store(submissions)
submission: Final = await store.get(submission_id, owner)
if submission is None:
raise HTTPException(404, "Skill submission not found")
content: Final = await store.get_archive(submission_id, owner)
- archive: Final = (
- await asyncio.to_thread(build_agent_skill_archive, content, plugin_name=submission.plugin_name)
- if content is not None
- else None
- )
- if archive is None:
- raise HTTPException(404, "This submission has no portable Agent Skills archive")
+ if content is None:
+ raise HTTPException(404, "This submission has no stored archive")
+ payload: Final = await skill_archive_payload(content, submission.plugin_name)
return Response(
- archive.content,
+ payload,
media_type="application/zip",
headers={
"Content-Disposition": f'attachment; filename="{submission.plugin_name}.zip"',
"Cache-Control": "private, no-store",
"X-Content-Type-Options": "nosniff",
- "ETag": f'"{archive.digest}"',
+ "ETag": f'"sha256:{hashlib.sha256(payload).hexdigest()}"',
},
)
@@ -284,7 +279,7 @@ async def edit_submission(
uploads: PluginUploadRepositoryDep,
caller: Annotated[UserAPIKeyAuth, Depends(user_api_key_auth)],
) -> SkillHubSubmission:
- """Replace a pending proposal's metadata, preserving files. Only its original submitting user may edit."""
+ """Update supplied proposal metadata. Omit/null version uses automatic versioning on approval."""
owner: Final = _editor(caller)
store: Final = _store(submissions)
submission: Final = await _editable(
@@ -293,15 +288,8 @@ async def edit_submission(
publication: Final = PluginPublication(
name=submission.plugin_name,
version=body.version,
- description=body.description,
- manifest={
- **{
- key: value
- for key, value in submission.proposal.manifest.items()
- if key not in SkillHubMetadata.model_fields
- },
- **body.model_dump(exclude={"expected_revision"}, exclude_none=True),
- },
+ description=body.description if "description" in body.model_fields_set else submission.proposal.description,
+ manifest=updated_skill_manifest(request, submission.plugin_name, submission.proposal.manifest, body),
created_by=owner,
)
result: Final = await store.edit(submission_id, owner, body.expected_revision, publication)
@@ -315,9 +303,12 @@ async def edit_submission_archive(
submissions: SkillSubmissionRepositoryDep,
uploads: PluginUploadRepositoryDep,
caller: Annotated[UserAPIKeyAuth, Depends(archive_writer)],
- file: Annotated[UploadFile, File(description="Replacement Agent Skills ZIP with the same declared skill name")],
+ file: Annotated[UploadFile, File(description="Replacement ZIP retaining the registered and declared skill names")],
expected_revision: Annotated[int, Form(ge=0)],
- version: Annotated[str | None, Form()] = None,
+ version: Annotated[
+ str | None,
+ Form(description="Explicit SemVer, or omit/send empty for automatic versioning on approval"),
+ ] = None,
) -> SkillHubSubmission:
"""Replace a pending proposal's files using the upload limits. Only its original submitting user may edit."""
owner: Final = _editor(caller)
@@ -326,11 +317,7 @@ async def edit_submission_archive(
content: Final = await file.read(MAX_IMPORT_BYTES + 1)
if len(content) > MAX_IMPORT_BYTES:
raise HTTPException(413, "Skill ZIP must be 10 MiB or smaller")
- archive: Final = await asyncio.to_thread(build_agent_skill_archive, content)
- if archive is None or archive.declared_name != submission.plugin_name:
- raise HTTPException(422, "Replacement SKILL.md must declare the existing skill name and a description")
- prepared: Final = await prepare_skill_publication(request, archive, version, None, owner)
- publication: Final = replace(prepared, manifest={**submission.proposal.manifest, **prepared.manifest})
+ publication: Final = await prepare_skill_replacement(request, content, submission.proposal, version, owner)
result: Final = await store.edit(submission_id, owner, expected_revision, publication)
return _response(request, _changed(result), caller)
diff --git a/litellm/proxy/discovery_endpoints/skill_import.py b/litellm/proxy/discovery_endpoints/skill_import.py
index a74e3abef10..f62049ab5b6 100644
--- a/litellm/proxy/discovery_endpoints/skill_import.py
+++ b/litellm/proxy/discovery_endpoints/skill_import.py
@@ -60,9 +60,12 @@ def parse_skill_source(
return GitHubSkillSource(parts[0], parts[1], ref, parts[2], path)
if len(parts) == 2:
return GitHubSkillSource(parts[0], parts[1].removesuffix(".git"), ref, skill, path)
- if len(parts) < 5 or parts[2] != "tree" or path is not None or ref != "HEAD":
- return SkillImportError(400, "Use a repository URL with ref and path, or a GitHub tree URL")
- return GitHubSkillSource(parts[0], parts[1], parts[3], skill, "/".join(parts[4:]))
+ if len(parts) < 5 or parts[2] not in ("tree", "blob") or path is not None or ref != "HEAD":
+ return SkillImportError(400, "Use a repository URL with ref and path, or a GitHub tree or SKILL.md blob URL")
+ if parts[2] == "blob" and parts[-1] != "SKILL.md":
+ return SkillImportError(400, "GitHub blob URLs must identify a SKILL.md file")
+ directory: Final = parts[4:-1] if parts[2] == "blob" else parts[4:]
+ return GitHubSkillSource(parts[0], parts[1], parts[3], skill, "/".join(directory))
async def fetch_skill_source(source: GitHubSkillSource, client: httpx.AsyncClient) -> bytes | SkillImportError:
diff --git a/litellm/proxy/discovery_endpoints/skill_scanner_adapter/README.md b/litellm/proxy/discovery_endpoints/skill_scanner_adapter/README.md
index 0e3ad5a726f..4605718a72c 100644
--- a/litellm/proxy/discovery_endpoints/skill_scanner_adapter/README.md
+++ b/litellm/proxy/discovery_endpoints/skill_scanner_adapter/README.md
@@ -26,7 +26,7 @@ The endpoint must be reachable from the gateway. A customer's laptop works while
Open Skills, Submissions, and Review as a proxy admin. Click **Scan for threats**, inspect the report, then independently approve or reject the proposal. Scanning is optional and never changes approval permissions or blocks publication. The report shows findings, locations, remediation, risk score, scanner version and whether semantic analysis actually ran. Incomplete reports do not establish safety
-Uploaded ZIPs are sent privately to the scanner with their exact stored bytes. Metadata-only edits reuse the matching stored archive. If that archive is missing or changed, submit a new ZIP before scanning. The displayed SHA-256 identifies that archive, and the scan examines its files rather than proposed catalog metadata. Remote URL reports describe the source at scan time and do not freeze its contents. GitHub branch/tag refs and explicit-ref subdirectories are supported. Other ref/subdirectory combinations require a ZIP so the adapter does not silently scan the wrong revision
+Uploaded ZIPs are sent privately to the scanner with their exact stored bytes. Metadata-only edits reuse the matching stored archive. If that archive is missing or changed, submit a new ZIP before scanning. The displayed SHA-256 identifies that archive, and the scan examines its files rather than proposed catalog metadata. Remote URL reports describe the source at scan time and do not freeze its contents. GitHub branch/tag refs and explicit-ref subdirectories are supported. Commit-pinned sources and other ref/subdirectory combinations require a ZIP so the adapter does not silently scan the wrong revision
The latest scan result is retained with the submission. Running scans have a deadline. If a gateway restarts or the scanner becomes unavailable, the attempt expires and an admin can retry. Retries replace the latest report. Approving or rejecting during a scan does not cancel it or change the decision
diff --git a/litellm/proxy/discovery_endpoints/skill_scanner_adapter/server.py b/litellm/proxy/discovery_endpoints/skill_scanner_adapter/server.py
index 44a1cecb00f..1b06cf7678a 100644
--- a/litellm/proxy/discovery_endpoints/skill_scanner_adapter/server.py
+++ b/litellm/proxy/discovery_endpoints/skill_scanner_adapter/server.py
@@ -37,6 +37,8 @@ def authenticate(credentials: Annotated[HTTPAuthorizationCredentials, Depends(HT
def source_target(source: dict[str, str]) -> str:
+ if source.get("sha"):
+ raise HTTPException(400, "Upload a ZIP to scan this source's exact commit")
target: Final = (
"https://github.com/" + source.get("repo", "") if source.get("source") == "github" else source.get("url", "")
)
diff --git a/litellm/types/proxy/skill_hub.py b/litellm/types/proxy/skill_hub.py
index e045914ead2..6ebbd1e25d1 100644
--- a/litellm/types/proxy/skill_hub.py
+++ b/litellm/types/proxy/skill_hub.py
@@ -6,6 +6,7 @@ from pydantic import ConfigDict, Field
from litellm.models.skill_submission import SubmissionOperation, SubmissionStatus
from litellm.types.llms.base import LiteLLMBaseModel
+from litellm.types.proxy.claude_code_endpoints import PluginAuthor
SkillSortField: TypeAlias = Literal[
"name",
@@ -39,6 +40,9 @@ class SkillHubSkill(LiteLLMBaseModel):
domain: str | None = None
namespace: str | None = None
keywords: tuple[str, ...] | None = None
+ author: PluginAuthor | None = None
+ category: str | None = None
+ homepage: str | None = None
download_count: int | None = Field(None, description="Gateway ZIP downloads, including repeat downloads")
@@ -51,27 +55,56 @@ class SkillHubList(LiteLLMBaseModel):
next_offset: int | None
+class SkillHubUpload(LiteLLMBaseModel):
+ model_config = ConfigDict(frozen=True, extra="forbid")
+
+ name: str = Field(..., pattern=r"^[a-z0-9-]+$", description="Registry skill name")
+ version: str | None = Field("1.0.0", description="Semantic version, defaults to 1.0.0 on creation")
+ description: str | None = None
+ author: PluginAuthor | None = None
+ homepage: str | None = None
+ keywords: tuple[str, ...] | None = None
+ category: str | None = None
+ domain: str | None = None
+ namespace: str | None = None
+
+
+class SkillHubRegistration(SkillHubUpload):
+ source: Mapping[str, str] = Field(description="Repository or HTTPS archive source reference")
+
+
class ImportSkillRequest(LiteLLMBaseModel):
- model_config = ConfigDict(frozen=True)
+ model_config = ConfigDict(frozen=True, extra="forbid")
url: str = Field(description="Public skills.sh skill URL or GitHub repository URL")
skill: str | None = Field(None, description="Skill name to select when a repository contains several skills")
ref: str = Field("HEAD", description="Git commit, tag or branch to import")
path: str | None = Field(None, description="Repository-relative skill directory")
version: str | None = Field(None, description="Semantic version, or omit/null to start at 1.0.0")
+ metadata: SkillHubUpload | None = Field(None, description="Optional registry name and metadata overrides")
class SkillHubMetadata(LiteLLMBaseModel):
model_config = ConfigDict(frozen=True, extra="forbid")
- description: str | None = Field(None, max_length=1024)
+ description: str | None = Field(None, description="Omit to preserve, null to clear the registry description")
version: str | None = Field(None, description="Explicit higher SemVer, or omit/null for an automatic patch bump")
expected_updated_at: datetime | None = Field(
None, description="Published updated_at read by the editor. A stale value returns 409", exclude=True
)
- domain: str | None = None
- namespace: str | None = None
- keywords: tuple[str, ...] | None = None
+ domain: str | None = Field(None, description="Omit to preserve, null to clear")
+ namespace: str | None = Field(None, description="Omit to preserve, null to clear")
+ keywords: tuple[str, ...] | None = Field(None, description="Omit to preserve, null or an empty list to clear")
+ author: PluginAuthor | None = Field(None, description="Omit to preserve, null to clear")
+ category: str | None = Field(None, description="Omit to preserve, null to clear")
+ homepage: str | None = Field(None, description="Omit to preserve, null to clear")
+
+
+class SkillHubUpdate(SkillHubMetadata):
+ source: Mapping[str, str] | None = Field(
+ None,
+ description="Explicit replacement source reference. Omit/null to preserve the stored source and archive",
+ )
class SkillHubPublication(LiteLLMBaseModel):
@@ -124,6 +157,9 @@ class SkillHubProposal(LiteLLMBaseModel):
domain: str | None = None
namespace: str | None = None
keywords: tuple[str, ...] | None = None
+ author: PluginAuthor | None = None
+ category: str | None = None
+ homepage: str | None = None
source: Mapping[str, str]
agent_skill: SkillHubAgentSkill | None = None
@@ -183,6 +219,7 @@ class SkillHubSubmissionRevision(LiteLLMBaseModel):
class SkillHubSubmissionEdit(SkillHubMetadata):
expected_revision: int = Field(ge=0, description="Revision read from the submission detail")
+ version: str | None = Field(None, description="Explicit SemVer, or omit/null for automatic versioning on approval")
class SkillHubReviewResponse(LiteLLMBaseModel):
diff --git a/litellm/ui/litellm-dashboard/src/app/(dashboard)/hooks/users/useUsers.test.ts b/litellm/ui/litellm-dashboard/src/app/(dashboard)/hooks/users/useUsers.test.ts
index 36f49615317..d71f291e25d 100644
--- a/litellm/ui/litellm-dashboard/src/app/(dashboard)/hooks/users/useUsers.test.ts
+++ b/litellm/ui/litellm-dashboard/src/app/(dashboard)/hooks/users/useUsers.test.ts
@@ -1,11 +1,18 @@
-import { describe, it, expect, vi, beforeEach } from "vitest";
+import { describe, it, expect, vi, beforeEach, afterEach } from "vitest";
import { renderHook, waitFor } from "@testing-library/react";
-import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
+import { keepPreviousData, QueryClient, QueryClientProvider } from "@tanstack/react-query";
import React, { ReactNode } from "react";
-import { useInfiniteUsers, useUserEmailLookup, useUserLookup } from "./useUsers";
+import {
+ useInfiniteUsers,
+ useUserEmailLookup,
+ useUserLookup,
+ useUserIdentityLookup,
+ userIdentityLabel,
+} from "./useUsers";
import { userGetInfoV2, userListCall } from "@/components/networking";
import type { UserInfoV2Response, UserListResponse } from "@/components/networking";
import { ApiError } from "@/lib/http/client";
+import type { CurrentUser } from "../currentUser/useCurrentUser";
vi.mock("@/components/networking", () => ({
userGetInfoV2: vi.fn(),
@@ -27,6 +34,11 @@ vi.mock("@/app/(dashboard)/hooks/useAuthorized", () => ({
default: () => mockUseAuthorized(),
}));
+const mockUseCurrentUser = vi.fn<(accessToken: string | null) => { data?: CurrentUser; isPlaceholderData?: boolean }>();
+vi.mock("../currentUser/useCurrentUser", () => ({
+ useCurrentUser: (accessToken: string | null) => mockUseCurrentUser(accessToken),
+}));
+
const DEFAULT_AUTH = {
accessToken: "test-access-token",
userId: "test-user-id",
@@ -48,6 +60,12 @@ const buildUserListResponse = (page: number, totalPages: number, userCount = 2):
user_email: `user-${page}-${i}@example.com`,
user_alias: null,
user_role: "Internal User",
+ allowed_cache_controls: [],
+ model_max_budget: {},
+ model_spend: {},
+ models: [],
+ policies: [],
+ teams: [],
spend: 0,
max_budget: null,
key_count: 0,
@@ -448,3 +466,128 @@ describe("useUserEmailLookup", () => {
expect(userListCall).not.toHaveBeenCalled();
});
});
+
+describe("useUserIdentityLookup", () => {
+ let queryClient: QueryClient;
+ const adminScope = { accessToken: "admin-token", userRole: "Admin" };
+ const admin: CurrentUser = { user_id: "admin-id", user_email: "admin@example.com", user_role: "proxy_admin" };
+ const member: CurrentUser = { user_id: "member-id", user_email: "member@example.com", user_role: "internal_user" };
+ const wrapper = ({ children }: { children: ReactNode }) =>
+ React.createElement(QueryClientProvider, { client: queryClient }, children);
+ const lookup = (
+ ids: Parameters[0],
+ scope: Parameters[1] = adminScope,
+ ) => renderHook(() => useUserIdentityLookup(ids, scope), { wrapper });
+
+ beforeEach(() => {
+ queryClient = new QueryClient({ defaultOptions: { queries: { retry: false, placeholderData: keepPreviousData } } });
+ vi.clearAllMocks();
+ mockUseCurrentUser.mockReturnValue({ data: admin });
+ vi.mocked(userGetInfoV2).mockRejectedValue(new ApiError("Not Found", 404, {}));
+ vi.mocked(userListCall).mockRejectedValue(new ApiError("Forbidden", 403, {}));
+ });
+
+ afterEach(() => queryClient.clear());
+
+ it.each([
+ [" alice@example.com ", "Alice", "alice@example.com"],
+ [null, " Alice ", "Alice"],
+ [" ", " ", "id"],
+ ])("labels by email, alias, then id", (user_email, user_alias, expected) => {
+ expect(userIdentityLabel("id", { id: { user_email, user_alias } })).toBe(expected);
+ });
+
+ it("matches singleton by exact id, never email", async () => {
+ vi.mocked(userGetInfoV2).mockResolvedValue(buildUserInfoV2Response("different-id"));
+ const { result } = lookup(["alice@example.com"]);
+ await waitFor(() => expect(queryClient.isFetching()).toBe(0));
+ expect(result.current).toEqual({});
+ expect(userGetInfoV2).toHaveBeenCalledExactlyOnceWith("admin-token", "alice@example.com");
+ });
+
+ it.each([undefined, 403, 404])("resolves exact ids across batches, retaining successes after %s", async (status) => {
+ const ids = Array.from({ length: 201 }, (_, index) => `user-${String(index).padStart(3, "0")}`);
+ const template = buildUserListResponse(1, 1, 1);
+ vi.mocked(userListCall).mockImplementation(async (_token, batch) => ({
+ ...template,
+ users: [...(batch ?? []), "unrequested-id"].map((user_id) => ({ ...template.users[0], user_id })),
+ }));
+ if (status) vi.mocked(userListCall).mockRejectedValueOnce(new ApiError("Unavailable", status, {}));
+ vi.mocked(userGetInfoV2).mockResolvedValue(buildUserInfoV2Response(ids[200]));
+ const { result } = lookup([...ids, ids[0]]);
+ await waitFor(() => expect(queryClient.isFetching()).toBe(0));
+ expect(Object.keys(result.current)).toEqual(status ? ids.slice(100) : ids);
+ expect(userIdentityLabel(ids[0], result.current)).toBe(status ? ids[0] : template.users[0].user_email);
+ expect(userListCall).toHaveBeenCalledTimes(2);
+ expect(userListCall).toHaveBeenNthCalledWith(1, "admin-token", ids.slice(0, 100), 1, 100);
+ expect(userListCall).toHaveBeenNthCalledWith(2, "admin-token", ids.slice(100, 200), 1, 100);
+ expect(userGetInfoV2).toHaveBeenCalledExactlyOnceWith("admin-token", ids[200]);
+ });
+
+ it.each([200, 403])("enriches only self, keeping authenticated email after status %s", async (status) => {
+ mockUseCurrentUser.mockReturnValue({ data: member });
+ if (status === 200) vi.mocked(userGetInfoV2).mockResolvedValue(buildUserInfoV2Response("member-id"));
+ const { result } = lookup(["member-id", "other-id"], { accessToken: "member-token" });
+ expect(userIdentityLabel("member-id", result.current)).toBe(member.user_email);
+ await waitFor(() => expect(queryClient.isFetching()).toBe(0));
+ expect(result.current).toEqual({
+ "member-id": { user_email: member.user_email, user_alias: status === 200 ? "Alice" : null },
+ });
+ expect(userGetInfoV2).toHaveBeenCalledExactlyOnceWith("member-token", "member-id");
+ expect(userListCall).not.toHaveBeenCalled();
+ });
+
+ it.each([
+ { ...adminScope, userRole: "Internal User", ids: ["other-id"] },
+ { accessToken: "member-token", userRole: undefined, ids: ["member@example.com", "other-id"] },
+ { ...adminScope, ids: [null, undefined, ""] },
+ { ...adminScope, accessToken: null, ids: ["admin-id", "other-id"] },
+ ])("does not query outside scope $accessToken / $userRole / $ids", ({ ids, ...scope }) => {
+ if (scope.accessToken === "member-token") mockUseCurrentUser.mockReturnValue({ data: member });
+ const { result } = lookup(ids, scope);
+ expect(result.current).toEqual({});
+ expect(mockUseCurrentUser).toHaveBeenCalledWith(scope.accessToken);
+ expect(mockUseAuthorized).not.toHaveBeenCalled();
+ expect(userListCall).not.toHaveBeenCalled();
+ expect(userGetInfoV2).not.toHaveBeenCalled();
+ });
+
+ it.each(["supplied-role", "server-role", "read-only", "ids", "account", "logout"])(
+ "clears privileged data immediately after a %s transition, including placeholders",
+ async (change) => {
+ const id = change === "account" ? "admin-id" : "other-id";
+ vi.mocked(userGetInfoV2).mockResolvedValue(buildUserInfoV2Response(id));
+ const initialProps: Parameters[1] & { ids: string[] } = {
+ ...adminScope,
+ userRole: change === "account" ? undefined : adminScope.userRole,
+ isViewOnly: false,
+ ids: [id],
+ };
+ const { result, rerender } = renderHook(({ ids, ...scope }) => useUserIdentityLookup(ids, scope), {
+ wrapper,
+ initialProps,
+ });
+ await waitFor(() => expect(queryClient.isFetching()).toBe(0));
+ expect(userIdentityLabel(id, result.current)).toBe(change === "account" ? admin.user_email : "alice@example.com");
+ vi.mocked(userGetInfoV2).mockRejectedValue(new ApiError("Forbidden", 403, {}));
+ if (change === "server-role")
+ mockUseCurrentUser.mockReturnValue({ data: { ...admin, user_role: "internal_user" } });
+ if (change === "account") mockUseCurrentUser.mockReturnValue({ data: admin, isPlaceholderData: true });
+ const nextToken = change === "account" ? "member-token" : initialProps.accessToken;
+ const nextProps = {
+ accessToken: change === "logout" ? null : nextToken,
+ userRole: change === "supplied-role" ? "Internal User" : initialProps.userRole,
+ isViewOnly: change === "read-only",
+ ids: change === "ids" ? ["new-id"] : initialProps.ids,
+ };
+ rerender(nextProps);
+ expect(result.current).toEqual({});
+ await waitFor(() => expect(queryClient.isFetching()).toBe(0));
+ mockUseCurrentUser.mockReturnValue({ data: member });
+ rerender(nextProps);
+ expect(result.current).toEqual({});
+ expect(userListCall).not.toHaveBeenCalled();
+ if (change === "logout") expect(userGetInfoV2).toHaveBeenCalledTimes(1);
+ },
+ );
+});
diff --git a/litellm/ui/litellm-dashboard/src/app/(dashboard)/hooks/users/useUsers.ts b/litellm/ui/litellm-dashboard/src/app/(dashboard)/hooks/users/useUsers.ts
index 20df7388ca1..68d1f023a6f 100644
--- a/litellm/ui/litellm-dashboard/src/app/(dashboard)/hooks/users/useUsers.ts
+++ b/litellm/ui/litellm-dashboard/src/app/(dashboard)/hooks/users/useUsers.ts
@@ -5,6 +5,7 @@ import { createQueryKeys } from "../common/queryKeysFactory";
import { canListUsers } from "@/utils/roles";
import useAuthorized from "@/app/(dashboard)/hooks/useAuthorized";
import { ApiError } from "@/lib/http/client";
+import { useCurrentUser } from "../currentUser/useCurrentUser";
const infiniteUsersKeys = createQueryKeys("infiniteUsers");
const userLookupKeys = createQueryKeys("userLookup");
@@ -42,6 +43,73 @@ export const useInfiniteUsers = (pageSize: number = DEFAULT_PAGE_SIZE, searchEma
const USER_LIST_MAX_PAGE_SIZE = 100;
+export type UserIdentityLookup = Readonly<
+ Record>>
+>;
+
+export const userIdentityLabel = (id: string | null | undefined, identities: UserIdentityLookup): string => {
+ if (!id) return "";
+ return identities[id]?.user_email?.trim() || identities[id]?.user_alias?.trim() || id;
+};
+
+export const useUserIdentityLookup = (
+ userIds: readonly (string | null | undefined)[],
+ scope: { accessToken: string | null; userRole?: string; isViewOnly?: boolean },
+): UserIdentityLookup => {
+ const { accessToken, userRole, isViewOnly = false } = scope;
+ const currentUser = useCurrentUser(accessToken);
+ const me = currentUser.isPlaceholderData ? undefined : currentUser.data;
+ const effectiveRole = userRole ?? me?.user_role ?? "";
+ const canLookupOthers = canListUsers(effectiveRole);
+ const ids = Array.from(new Set(userIds.filter((id): id is string => typeof id === "string" && id !== ""))).sort();
+ const lookupIds = canLookupOthers ? ids : ids.filter((id) => id === me?.user_id);
+ const { data, isPlaceholderData } = useQuery({
+ queryKey: [
+ "userIdentityLookup",
+ { accessToken, effectiveRole, isViewOnly, currentUserRole: me?.user_role, currentUserId: me?.user_id, ids },
+ ],
+ queryFn: async () => {
+ if (!accessToken) return {};
+ const batches = Array.from({ length: Math.ceil(lookupIds.length / USER_LIST_MAX_PAGE_SIZE) }, (_, index) =>
+ lookupIds.slice(index * USER_LIST_MAX_PAGE_SIZE, (index + 1) * USER_LIST_MAX_PAGE_SIZE),
+ );
+ const users = await Promise.all(
+ batches.map(async (batch) => {
+ try {
+ if (batch.length === 1) {
+ const user = await userGetInfoV2(accessToken, batch[0]);
+ return user.user_id === batch[0] ? [user] : [];
+ }
+ const response = await userListCall(accessToken, batch, 1, batch.length);
+ return response.users.filter((user) => batch.includes(user.user_id));
+ } catch (error) {
+ if (error instanceof ApiError && (error.status === 403 || error.status === 404)) return [];
+ throw error;
+ }
+ }),
+ );
+ return Object.fromEntries(
+ users
+ .flat()
+ .map((user) => [user.user_id, { user_email: user.user_email ?? null, user_alias: user.user_alias ?? null }]),
+ );
+ },
+ enabled: Boolean(accessToken) && lookupIds.length > 0,
+ });
+
+ if (!accessToken) return {};
+ const identities = isPlaceholderData ? {} : data ?? {};
+ if (!me || !ids.includes(me.user_id)) return identities;
+ const self = identities[me.user_id] ?? { user_email: null, user_alias: null };
+ return {
+ ...identities,
+ [me.user_id]: {
+ ...self,
+ user_email: me.user_email?.trim() || self.user_email,
+ },
+ };
+};
+
export const useUserEmailLookup = (userIds: readonly string[]) => {
const { accessToken, userRole } = useAuthorized();
const distinctIds = Array.from(new Set(userIds.filter((id) => id !== ""))).sort();
diff --git a/litellm/ui/litellm-dashboard/src/app/(dashboard)/skills/_components/ClaudeCodePluginsPanel.integration.test.tsx b/litellm/ui/litellm-dashboard/src/app/(dashboard)/skills/_components/ClaudeCodePluginsPanel.integration.test.tsx
index 60faedee8f9..8a0ba8834a5 100644
--- a/litellm/ui/litellm-dashboard/src/app/(dashboard)/skills/_components/ClaudeCodePluginsPanel.integration.test.tsx
+++ b/litellm/ui/litellm-dashboard/src/app/(dashboard)/skills/_components/ClaudeCodePluginsPanel.integration.test.tsx
@@ -27,6 +27,7 @@ const published: SkillHubSkill = {
content_url: "/skill-hub/skills/shared-skill/content",
updated_at: "2026-10-20T00:00:00Z",
download_count: 0,
+ security_scan_passed: false,
};
const pending: SkillSubmission = {
@@ -61,6 +62,20 @@ const pending: SkillSubmission = {
rejection_reason: null,
};
+const creator = { user_id: "creator-uuid", user_email: "creator@example.test", user_alias: "Creator" };
+const authoredMetadata = {
+ author: { name: "Original Maintainer", email: "maintainer@example.test" },
+ category: "Review",
+ homepage: "https://example.test/skill",
+};
+
+const ownedSubmission: SkillSubmission = {
+ ...pending,
+ can_edit: true,
+ revision: 3,
+ proposal: { ...pending.proposal, version: "3.0.0" },
+};
+
const fetchMock = vi.fn();
const queryDefaults = testQueryClient.getDefaultOptions();
let catalog: SkillHubSkill[];
@@ -70,6 +85,7 @@ let pageRequests: { limit: number; offset: number }[];
let writes: { path: string; method: string; body: RequestInit["body"] }[];
let reviewFailure: string | null;
let directPublication: boolean;
+let identities: { user_id: string; user_email: string; user_alias: string }[];
const respondToWrite = (path: string, body: RequestInit["body"]) => {
if (reviewFailure && path.startsWith("/skill-hub/submissions/"))
@@ -91,12 +107,13 @@ const respondToWrite = (path: string, body: RequestInit["body"]) => {
};
return Response.json(result);
}
- if (path === `/skill-hub/submissions/${pending.id}`) {
+ if (path === `/skill-hub/submissions/${pending.id}` || path === `/skill-hub/submissions/${pending.id}/upload`) {
const metadata = typeof body === "string" ? JSON.parse(body) : {};
+ const version = body instanceof FormData ? body.get("version") : null;
submissions = submissions.map((item) => ({
...item,
revision: (item.revision ?? 0) + 1,
- proposal: { ...item.proposal, ...metadata },
+ proposal: { ...item.proposal, ...metadata, ...(typeof version === "string" ? { version: version || null } : {}) },
}));
return Response.json(submissions[0]);
}
@@ -105,7 +122,7 @@ const respondToWrite = (path: string, body: RequestInit["body"]) => {
return Response.json(submissions[0]);
}
if (directPublication) {
- catalog = [{ ...published, version: "3.0.0", description: "Admin-published instructions" }];
+ catalog = [{ ...catalog[0], version: "3.0.0", description: "Admin-published instructions" }];
return Response.json(catalog[0]);
}
submissions = [pending];
@@ -173,6 +190,27 @@ function scanResponse(method: string) {
});
}
+const respondToIdentity = (url: URL, headers: Headers): Response | undefined => {
+ const path = url.pathname;
+ if (path === "/management/v1/users/me") {
+ const member = headers.get("Authorization") === "Bearer member-token";
+ return Response.json({
+ user_id: member ? "member@example.org" : "admin",
+ user_email: member ? "member@example.org" : null,
+ user_role: member ? "internal_user" : "proxy_admin",
+ });
+ }
+ if (path === "/user/list") {
+ const ids = url.searchParams.get("user_ids")?.split(",") ?? [];
+ return Response.json({ users: identities.filter((user) => ids.includes(user.user_id)) });
+ }
+ if (path === "/v2/user/info") {
+ const user = identities.find((user) => user.user_id === url.searchParams.get("user_id"));
+ return user ? Response.json(user) : Response.json({ detail: "Not found" }, { status: 404 });
+ }
+ if (path === "/.well-known/litellm-ui-config") return Response.json({ claude_code_marketplace_auth_required: true });
+};
+
beforeEach(() => {
scanFailure = false;
scanRequested = false;
@@ -185,16 +223,19 @@ beforeEach(() => {
writes = [];
reviewFailure = null;
directPublication = false;
- fetchMock.mockReset().mockImplementation(async (input, options) => {
+ identities = [];
+ fetchMock.mockReset().mockImplementation(async (input, options = {}) => {
const request = input instanceof Request ? input : null;
const url = new URL(request?.url ?? String(input), "http://localhost");
const path = url.pathname;
- const method = request?.method ?? options?.method ?? "GET";
+ const { method = "GET", headers } = request ?? options;
+ const identityResponse = respondToIdentity(url, new Headers(headers));
+ if (identityResponse) return identityResponse;
if (path === `/skill-hub/submissions/${pending.id}/scan`) {
return scanResponse(method);
}
if (method !== "GET") {
- const body = request ? await request.text() : options?.body;
+ const body = request ? await request.text() : options.body;
writes.push({ path, method, body });
return respondToWrite(path, body);
}
@@ -233,8 +274,6 @@ beforeEach(() => {
if (path.endsWith("/archive")) return new Response("zip-bytes", { headers: { "Content-Type": "application/zip" } });
if (path === `/skill-hub/submissions/${pending.id}`)
return Response.json({ submission: submissions[0], current_skill: catalog[0] });
- if (path === "/.well-known/litellm-ui-config")
- return Response.json({ claude_code_marketplace_auth_required: true });
return Response.json({ detail: "Unexpected request" }, { status: 404 });
});
vi.stubGlobal("fetch", fetchMock);
@@ -262,7 +301,7 @@ it("refreshes published counts after a retained download", async () => {
URL.createObjectURL = vi.fn(() => "blob:skill-download");
renderWithProviders();
expect(await screen.findByRole("cell", { name: "0" }, { timeout: 5000 })).toBeInTheDocument();
- expect(fetchMock).toHaveBeenCalledOnce();
+ expect(catalogRequests).toHaveLength(1);
fireEvent.click(screen.getByText(published.name));
await screen.findByRole("button", { name: "Edit Skill" });
fireEvent.click(screen.getByRole("tab", { name: "Version history" }));
@@ -306,7 +345,7 @@ it("paginates the neutral catalog and refreshes detail for a recreated skill", a
await waitFor(() => expect(screen.getByRole("button", { name: "Previous" })).toBeDisabled());
});
-it.each(["descriptor", "archive"])("requires a portable %s for a submitted ZIP preview", async (missing) => {
+it.each(["descriptor", "archive"])("previews stored ZIPs with missing %s", async (missing) => {
submissions = [
{
...pending,
@@ -317,7 +356,8 @@ it.each(["descriptor", "archive"])("requires a portable %s for a submitted ZIP p
renderSubmissions();
fireEvent.click(await screen.findByRole("button", { name: "Review" }));
expect(await screen.findByText("Currently published")).toBeInTheDocument();
- expect(screen.queryByRole("button", { name: "Download submitted ZIP" })).not.toBeInTheDocument();
+ if (missing === "descriptor") expect(screen.getByRole("button", { name: "Download submitted ZIP" })).toBeEnabled();
+ else expect(screen.queryByRole("button", { name: "Download submitted ZIP" })).not.toBeInTheDocument();
expect(screen.getByRole("button", { name: "Approve and publish" })).toBeEnabled();
});
@@ -415,10 +455,21 @@ it("allows a member submission, explains approval and refreshes their pending li
expect(screen.getByRole("tab", { name: "Published skills" })).toHaveAttribute("aria-selected", "true"),
);
fireEvent.click(screen.getByRole("button", { name: "+ Register your skill" }));
- fireEvent.click(screen.getByRole("radio", { name: "Import URL" }));
+ fireEvent.click(screen.getByRole("radio", { name: "Add from URL" }));
fireEvent.change(screen.getByRole("textbox", { name: "Source URL" }), {
target: { value: "https://github.com/example/new-skill" },
});
+ fireEvent.click(screen.getByRole("radio", { name: "Store a copy in LiteLLM" }));
+ fireEvent.change(screen.getByLabelText("Registry name (optional)"), { target: { value: "review-alias" } });
+ fireEvent.click(screen.getByText("Advanced metadata (optional)"));
+ for (const [label, value] of [
+ ["Author Name (Optional)", authoredMetadata.author.name],
+ ["Author Email (Optional)", authoredMetadata.author.email],
+ ["Category (Optional)", authoredMetadata.category],
+ ["Homepage (Optional)", authoredMetadata.homepage],
+ ]) {
+ fireEvent.change(screen.getByLabelText(label), { target: { value } });
+ }
fireEvent.click(screen.getByRole("button", { name: "Submit for approval" }));
await waitFor(() =>
expect(toast.success).toHaveBeenCalledWith("Submitted for admin approval. The published skill is unchanged"),
@@ -429,6 +480,7 @@ it("allows a member submission, explains approval and refreshes their pending li
path: "/skill-hub/skills/import",
method: "POST",
});
+ expect(JSON.parse(String(writes[0].body)).metadata).toEqual({ name: "review-alias", ...authoredMetadata });
fireEvent.click(screen.getByRole("tab", { name: "My submissions" }));
expect(await screen.findByText("Pending review")).toBeInTheDocument();
fireEvent.click(screen.getByRole("button", { name: "View details" }));
@@ -453,7 +505,7 @@ it("retries failed detail loading before enabling edits", async () => {
expect(await screen.findByRole("button", { name: "Edit Skill" })).toBeInTheDocument();
});
-it("edits the loaded detail with automatic version intent and preserves the approved skill while review is pending", async () => {
+it("replaces an existing source without publishing the member's proposal", async () => {
const loaded = { ...published, updated_at: "2026-10-21T12:00:00Z" };
const fetchStub = fetchMock.getMockImplementation()!;
fetchMock.mockImplementation((input, options) =>
@@ -469,21 +521,24 @@ it("edits the loaded detail with automatic version intent and preserves the appr
const form = screen.getByRole("dialog");
expect(within(form).getByLabelText("Version override (optional)")).toHaveValue("");
expect(within(form).getByLabelText("Namespace (optional)")).toHaveValue(published.namespace);
+ fireEvent.click(within(form).getByRole("radio", { name: "Replace source" }));
+ const source = { source: "url", url: "https://gitlab.com/example/skills" };
+ fireEvent.change(within(form).getByLabelText("Source URL"), { target: { value: source.url } });
fireEvent.change(within(form).getByLabelText("Description (Optional)"), {
target: { value: "Proposed instructions" },
});
+ fireEvent.change(within(form).getByLabelText("Namespace (optional)"), { target: { value: "" } });
fireEvent.click(within(form).getByRole("button", { name: "Submit for approval" }));
await waitFor(() => expect(screen.queryByRole("dialog")).not.toBeInTheDocument());
expect(writes[0]).toMatchObject({ path: "/skill-hub/skills/shared-skill", method: "PUT" });
const expectedMetadata = {
version: null,
expected_updated_at: loaded.updated_at,
- domain: published.domain,
- namespace: published.namespace,
- keywords: published.keywords,
description: "Proposed instructions",
+ namespace: null,
+ source,
};
- expect(JSON.parse(String(writes[0].body))).toMatchObject(expectedMetadata);
+ expect(JSON.parse(String(writes[0].body))).toEqual(expectedMetadata);
expect(await screen.findByText("Recorded release")).toBeInTheDocument();
expect(screen.queryByText("Proposed instructions")).not.toBeInTheDocument();
});
@@ -509,7 +564,11 @@ it.each(["metadata", "upload"])(
"keeps direct admin %s publication and wires an explicit version override",
async (sourceType) => {
directPublication = true;
+ identities = [creator];
+ catalog = [{ ...published, ...authoredMetadata, created_by: creator.user_id }];
renderWithProviders();
+ expect(await screen.findByText(creator.user_email)).toBeInTheDocument();
+ expect(screen.getByTitle(creator.user_id)).toHaveTextContent(creator.user_email);
const form = await openEdit();
fireEvent.change(within(form).getByLabelText("Version override (optional)"), { target: { value: "3.0.0" } });
fireEvent.change(within(form).getByLabelText("Description (Optional)"), {
@@ -526,6 +585,8 @@ it.each(["metadata", "upload"])(
expect(await screen.findByText("Admin-published instructions")).toBeInTheDocument();
expect(toast.success).toHaveBeenCalledWith("Skill updated successfully");
expect(screen.queryByText("Submitted for admin approval")).not.toBeInTheDocument();
+ expect(screen.getByText(authoredMetadata.author.name)).toBeInTheDocument();
+ expect(screen.getByRole("row", { name: `Created by ${creator.user_email}` })).toBeInTheDocument();
const body = writes[0].body;
if (body instanceof FormData) {
expect(body.get("version")).toBe("3.0.0");
@@ -537,6 +598,8 @@ it.each(["metadata", "upload"])(
);
it("lets an admin inspect full proposed values, download the private ZIP, approve and see refreshed published details", async () => {
+ identities = [creator];
+ submissions = [{ ...pending, submitted_by: creator.user_id, proposal: { ...pending.proposal, ...authoredMetadata } }];
const click = vi.spyOn(HTMLAnchorElement.prototype, "click").mockImplementation(() => {});
vi.stubGlobal(
"URL",
@@ -544,9 +607,14 @@ it("lets an admin inspect full proposed values, download the private ZIP, approv
);
setGlobalLitellmHeaderName("X-LiteLLM-Key");
renderSubmissions();
+ await screen.findByText(`Submitted by ${creator.user_email}`, { exact: false });
fireEvent.click(await screen.findByRole("button", { name: "Review" }));
expect(await screen.findByText("Currently published")).toBeInTheDocument();
const dialog = within(screen.getByRole("dialog"));
+ expect(await dialog.findByText(`Submitted by ${creator.user_email}`)).toBeInTheDocument();
+ expect(dialog.getByText(authoredMetadata.author.name, { exact: false })).toHaveTextContent(
+ authoredMetadata.author.email,
+ );
expect(dialog.getByText("Approved instructions")).toBeInTheDocument();
expect(dialog.getByText("Proposed instructions")).toBeInTheDocument();
expect(dialog.getByText("Next patch version on approval")).toBeInTheDocument();
@@ -596,20 +664,33 @@ it("saves an admin rejection reason for the author and keeps the published metad
expect(await screen.findByRole("cell", { name: "Approved instructions" })).toBeInTheDocument();
});
-it("refreshes detail after a review conflict and removes actions when another reviewer has already acted", async () => {
- renderSubmissions();
- fireEvent.click(await screen.findByRole("button", { name: "Review" }));
- await screen.findByRole("button", { name: "Approve and publish" });
- reviewFailure = "Submission has already been reviewed";
- submissions = [{ ...pending, status: "rejected", rejection_reason: "Already reviewed elsewhere" }];
- fireEvent.click(screen.getByRole("button", { name: "Approve and publish" }));
- expect(await screen.findByRole("alert")).toHaveTextContent(reviewFailure);
- await waitFor(() => expect(screen.queryByRole("button", { name: "Approve and publish" })).not.toBeInTheDocument());
- expect(screen.queryByRole("button", { name: "Reject" })).not.toBeInTheDocument();
- expect(
- within(screen.getByRole("dialog")).getByText("Rejection reason: Already reviewed elsewhere"),
- ).toBeInTheDocument();
-});
+it.each(["approved", "rejected"] as const)(
+ "refreshes detail after another reviewer has %s the submission",
+ async (status) => {
+ identities = [creator];
+ renderSubmissions();
+ fireEvent.click(await screen.findByRole("button", { name: "Review" }));
+ await screen.findByRole("button", { name: "Approve and publish" });
+ reviewFailure = "Submission has already been reviewed";
+ submissions = [
+ {
+ ...pending,
+ status,
+ rejection_reason: status === "rejected" ? "Already reviewed elsewhere" : null,
+ reviewed_by: creator.user_id,
+ reviewed_at: pending.created_at,
+ },
+ ];
+ fireEvent.click(screen.getByRole("button", { name: "Approve and publish" }));
+ expect(await screen.findByRole("alert")).toHaveTextContent(reviewFailure);
+ await waitFor(() => expect(screen.queryByRole("button", { name: "Approve and publish" })).not.toBeInTheDocument());
+ expect(screen.queryByRole("button", { name: "Reject" })).not.toBeInTheDocument();
+ const dialog = within(screen.getByRole("dialog"));
+ await dialog.findByText(`${status === "approved" ? "Approved" : "Rejected"} by ${creator.user_email}`, {
+ exact: false,
+ });
+ },
+);
it("keeps an effective Admin viewer read-only while allowing full submission inspection", async () => {
renderWithProviders();
@@ -807,8 +888,8 @@ it("applies tag and scan filters across the catalog and resets pagination when s
expect(catalogRequests.at(-1)?.searchParams.get("security_scan_passed")).toBe("true");
});
-it("lets an owner edit the viewed proposal and withdraw it with its current revision", async () => {
- submissions = [{ ...pending, can_edit: true, revision: 3, proposal: { ...pending.proposal, version: "3.0.0" } }];
+it.each([false, true])("edits and withdraws the owner's proposal with version reset %s", async (resetVersion) => {
+ submissions = [ownedSubmission];
renderWithProviders(, {
searchParams: "tab=submissions",
});
@@ -823,12 +904,15 @@ it("lets an owner edit the viewed proposal and withdraw it with its current revi
fireEvent.change(await screen.findByLabelText("Description (Optional)"), {
target: { value: "Owner revised instructions" },
});
+ if (resetVersion) fireEvent.change(screen.getByLabelText("Version override (optional)"), { target: { value: "" } });
fireEvent.click(screen.getByRole("button", { name: "Save submission" }));
expect(await screen.findByRole("cell", { name: "Owner revised instructions" })).toBeInTheDocument();
- expect(JSON.parse(String(writes[0].body))).toMatchObject({
+ const expectedMetadata = {
expected_revision: 3,
description: "Owner revised instructions",
- });
+ version: resetVersion ? null : "3.0.0",
+ };
+ expect(JSON.parse(String(writes[0].body))).toEqual(expectedMetadata);
expect(catalog).toEqual([published]);
fireEvent.click(screen.getByRole("button", { name: "Withdraw submission" }));
expect(writes).toHaveLength(1);
@@ -843,6 +927,39 @@ it("lets an owner edit the viewed proposal and withdraw it with its current revi
expect(screen.queryByRole("button", { name: "Withdraw submission" })).not.toBeInTheDocument();
});
+it.each([
+ { action: "untouched", input: null, expectedVersion: "3.0.0" },
+ { action: "cleared", input: "", expectedVersion: null },
+ { action: "overridden", input: " 4.0.0 ", expectedVersion: "4.0.0" },
+])("saves a pending ZIP with its version $action", async ({ input, expectedVersion }) => {
+ submissions = [ownedSubmission];
+ renderWithProviders(, {
+ searchParams: "tab=submissions",
+ });
+ fireEvent.click(await screen.findByRole("button", { name: "View details" }));
+ fireEvent.click(await screen.findByRole("button", { name: "Edit submission" }));
+ fireEvent.click(screen.getByRole("radio", { name: "Upload ZIP" }));
+ expect(screen.getByLabelText("Version override (optional)")).toHaveValue("3.0.0");
+ const file = new File(["replacement"], "skill.zip", { type: "application/zip" });
+ fireEvent.change(screen.getByLabelText("Skill ZIP file"), { target: { files: [file] } });
+ if (input !== null) {
+ fireEvent.change(screen.getByLabelText("Version override (optional)"), { target: { value: input } });
+ }
+ fireEvent.click(screen.getByRole("button", { name: "Save submission" }));
+ expect(
+ await screen.findByRole("cell", { name: expectedVersion ?? "Next patch version on approval" }),
+ ).toBeInTheDocument();
+ expect(writes).toHaveLength(1);
+ expect(writes[0]).toMatchObject({ path: `/skill-hub/submissions/${pending.id}/upload`, method: "PUT" });
+ expect(Object.fromEntries(writes[0].body as FormData)).toEqual({
+ file,
+ expected_revision: "3",
+ version: expectedVersion ?? "",
+ });
+ fireEvent.click(screen.getByRole("button", { name: "Edit submission" }));
+ expect(screen.getByLabelText("Version override (optional)")).toHaveValue(expectedVersion ?? "");
+});
+
it("keeps admin review separate from ownership and sends the displayed revision", async () => {
submissions = [{ ...pending, revision: 7, can_edit: false }];
renderSubmissions();
@@ -884,6 +1001,7 @@ it.each(["metadata", "upload"])(
expect(screen.getByLabelText("Description (Optional)")).toHaveValue("Latest edit");
fireEvent.click(screen.getByRole("button", { name: "Save submission" }));
await waitFor(() => expect(writes).toHaveLength(2));
- expect(JSON.parse(String(writes[1].body))).toMatchObject({ expected_revision: 1, description: "Latest edit" });
+ expect(JSON.parse(String(writes[1].body))).toEqual({ expected_revision: 1, version: null });
+ expect(await screen.findByRole("cell", { name: "Latest edit" })).toBeInTheDocument();
},
);
diff --git a/litellm/ui/litellm-dashboard/src/app/(dashboard)/skills/_components/ClaudeCodePluginsPanel.tsx b/litellm/ui/litellm-dashboard/src/app/(dashboard)/skills/_components/ClaudeCodePluginsPanel.tsx
index c17246fbe2e..3bbca25b514 100644
--- a/litellm/ui/litellm-dashboard/src/app/(dashboard)/skills/_components/ClaudeCodePluginsPanel.tsx
+++ b/litellm/ui/litellm-dashboard/src/app/(dashboard)/skills/_components/ClaudeCodePluginsPanel.tsx
@@ -24,6 +24,7 @@ import { toast } from "@/lib/toast";
import { isPendingSkill, type SkillHubSkill, type SkillMutationResponse } from "@/components/claude_code_plugins/types";
import { useUrlTab } from "@/hooks/useUrlTab";
import SkillSubmissions from "./SkillSubmissions";
+import { useUserIdentityLookup } from "@/app/(dashboard)/hooks/users/useUsers";
interface ClaudeCodePluginsPanelProps {
accessToken: string | null;
@@ -48,6 +49,8 @@ function skillPermissions(accessToken: string | null, userRole: string, isViewOn
}
interface CatalogSkillDetailProps {
+ userRole: string;
+ isViewOnly: boolean;
skill: SkillHubSkill;
accessToken: string | null;
queryScope: QueryKey;
@@ -58,6 +61,8 @@ interface CatalogSkillDetailProps {
}
function CatalogSkillDetail({
+ userRole,
+ isViewOnly,
skill,
accessToken,
queryScope,
@@ -74,6 +79,12 @@ function CatalogSkillDetail({
queryFn: () => getSkillHubSkill(accessToken!, skill.name),
enabled: Boolean(accessToken),
});
+ const displayedSkill = detail.data ?? skill;
+ const users = useUserIdentityLookup([displayedSkill.created_by, displayedSkill.approved_by], {
+ accessToken,
+ userRole,
+ isViewOnly,
+ });
return (
<>
{detail.isError && (
@@ -85,7 +96,8 @@ function CatalogSkillDetail({
)}
= ({
enabled: Boolean(accessToken),
});
const pluginsList = plugins.data?.skills ?? [];
+ const users = useUserIdentityLookup(
+ pluginsList.flatMap((skill) => [skill.created_by, skill.approved_by]),
+ { accessToken, userRole, isViewOnly: readOnly },
+ );
const selectedSkill = pluginsList.find((plugin) => plugin.id === selectedSkillId);
const refreshSkills = async () => {
await Promise.all([
@@ -172,6 +188,8 @@ const SkillsPanelContent: React.FC = ({
{selectedSkill ? (
= ({
)}
= ({
{accessToken && (
;
@@ -39,6 +41,7 @@ function EmptyState({ filtered }: { filtered: boolean }) {
}
const PluginTable: React.FC = ({
+ users,
pluginsList,
sorting,
onSortingChange,
@@ -50,10 +53,10 @@ const PluginTable: React.FC = ({
}) => {
const { t } = useTranslation();
- const columns = useMemo(
- () => getPluginTableColumns({ isAdmin, onPluginClick, onDeleteClick }),
- [isAdmin, onPluginClick, onDeleteClick],
- );
+ const columns = useMemo(() => {
+ const dependencies = { isAdmin, onPluginClick, onDeleteClick, users };
+ return getPluginTableColumns(dependencies);
+ }, [isAdmin, onPluginClick, onDeleteClick, users]);
return (
void;
onDeleteClick: (pluginName: string, displayName: string) => void;
}
export const getPluginTableColumns = ({
+ users,
isAdmin,
onPluginClick,
onDeleteClick,
@@ -145,7 +148,7 @@ export const getPluginTableColumns = ({
/>
),
},
- ...getSkillMetadataColumns(),
+ ...getSkillMetadataColumns(users),
{
id: "actions",
meta: { className: "text-right", headerClassName: "text-right" },
diff --git a/litellm/ui/litellm-dashboard/src/app/(dashboard)/skills/_components/SkillSubmissions.tsx b/litellm/ui/litellm-dashboard/src/app/(dashboard)/skills/_components/SkillSubmissions.tsx
index 9865610db4c..1f09a145e8a 100644
--- a/litellm/ui/litellm-dashboard/src/app/(dashboard)/skills/_components/SkillSubmissions.tsx
+++ b/litellm/ui/litellm-dashboard/src/app/(dashboard)/skills/_components/SkillSubmissions.tsx
@@ -18,6 +18,7 @@ import { useUrlTableState, type UrlTableStateOptions } from "@/components/shared
import SkillScanPanel from "./SkillScanPanel";
import { toast } from "@/lib/toast";
import AddPluginForm from "./add_plugin_form";
+import { useUserIdentityLookup, userIdentityLabel } from "@/app/(dashboard)/hooks/users/useUsers";
import {
AlertDialog,
AlertDialogCancel,
@@ -28,7 +29,18 @@ import {
AlertDialogTitle,
} from "@/components/ui/alert-dialog";
-const METADATA_FIELDS = ["name", "version", "description", "source", "keywords", "domain", "namespace"] as const;
+const METADATA_FIELDS = [
+ "name",
+ "version",
+ "description",
+ "source",
+ "author",
+ "category",
+ "homepage",
+ "keywords",
+ "domain",
+ "namespace",
+] as const;
const displayValue = (value: unknown): string => {
if (value === null || value === undefined || value === "") return "";
@@ -60,15 +72,23 @@ function SubmissionStatus({ status }: { status: SkillSubmission["status"] }) {
);
}
-function SubmissionSummary({ submission }: { submission: SkillSubmission }) {
+function SubmissionSummary({
+ submission,
+ scope,
+}: {
+ submission: SkillSubmission;
+ scope: Pick;
+}) {
const { t } = useTranslation();
+ const users = useUserIdentityLookup([submission.submitted_by, submission.reviewed_by], scope);
+ const reviewed = submission.status === "approved" || submission.status === "rejected";
return (
<>
{t(`skills.submissions.operation.${submission.operation}`)}
-
- {t("skills.submissions.submittedBy", { name: submission.submitted_by })}
+
+ {t("skills.submissions.submittedBy", { name: userIdentityLabel(submission.submitted_by, users) })}
{submission.status === "pending_review" && (
@@ -79,10 +99,10 @@ function SubmissionSummary({ submission }: { submission: SkillSubmission }) {
{t("skills.submissions.rejectionReason", { reason: submission.rejection_reason })}
)}
- {submission.reviewed_at && (
-
- {t("skills.submissions.reviewedBy", {
- name: submission.reviewed_by,
+ {submission.reviewed_at && reviewed && (
+
+ {t(submission.status === "approved" ? "skills.submissions.approvedBy" : "skills.submissions.rejectedBy", {
+ name: userIdentityLabel(submission.reviewed_by, users),
date: new Date(submission.reviewed_at).toLocaleString(),
})}
@@ -145,7 +165,7 @@ function SubmissionComparison({
- {submission.has_archive && submission.proposal.agent_skill && (
+ {submission.has_archive && (
@@ -155,6 +175,8 @@ function SubmissionComparison({
}
interface SubmissionReviewProps {
+ userRole: string;
+ isViewOnly: boolean;
id: string;
accessToken: string;
queryScope: QueryKey;
@@ -165,6 +187,8 @@ interface SubmissionReviewProps {
}
function SubmissionReview({
+ userRole,
+ isViewOnly,
id,
accessToken,
queryScope,
@@ -257,7 +281,7 @@ function SubmissionReview({
)}
{submission && (
<>
-
+
listSkillSubmissions(accessToken, { limit: pageSize, offset: pageIndex * pageSize }),
});
+ const users = useUserIdentityLookup(
+ submissions.data?.submissions.flatMap((submission) => [submission.submitted_by, submission.reviewed_by]) ?? [],
+ { accessToken, userRole, isViewOnly },
+ );
const isEmpty = submissions.isSuccess && submissions.data.submissions.length === 0;
const changePage = (page: number) => {
setSelectedId(null);
@@ -409,8 +441,8 @@ export default function SkillSubmissions({
{submission.proposal.description}
-
- {t("skills.submissions.submittedBy", { name: submission.submitted_by })} ·{" "}
+
+ {t("skills.submissions.submittedBy", { name: userIdentityLabel(submission.submitted_by, users) })} ·{" "}
{new Date(submission.created_at).toLocaleString()}
{submission.rejection_reason && (
@@ -448,6 +480,8 @@ export default function SkillSubmissions({
{selectedId && (
fireEvent.change(screen.getByLabelText("Skill ZIP file"), { target: { files: [selected] } });
const change = (label: string, value: string) => fireEvent.change(screen.getByLabelText(label), { target: { value } });
const submit = () => fireEvent.click(screen.getByRole("button", { name: "Register skill" }));
-const openImport = () => {
+const openImport = (url = "https://github.com/example/skills") => {
renderWithProviders();
- fireEvent.click(screen.getByRole("radio", { name: "Import URL" }));
+ fireEvent.click(screen.getByRole("radio", { name: "Add from URL" }));
+ change("Source URL", url);
+ if (!url.startsWith("https://skills.sh/")) {
+ fireEvent.click(screen.getByRole("radio", { name: "Store a copy in LiteLLM" }));
+ }
};
describe("AddPluginForm", () => {
beforeEach(() => vi.clearAllMocks());
- it("starts with a portable ZIP and offers host-agnostic imports without guessing metadata", () => {
+ it("offers ZIP or URL, with managed copies available for supported URL hosts", () => {
renderWithProviders();
expect(screen.getByRole("radio", { name: "Upload ZIP" })).toBeChecked();
expect(screen.getByText(/frontmatter supplies the skill name and description/)).toBeInTheDocument();
- fireEvent.click(screen.getByRole("radio", { name: "Import URL" }));
+ fireEvent.click(screen.getByRole("radio", { name: "Add from URL" }));
expect(screen.getByLabelText("Source URL")).toBeInTheDocument();
expect(screen.getByLabelText("Path (optional)")).toBeEnabled();
- expect(screen.queryByLabelText("Skill Name")).not.toBeInTheDocument();
+ expect(screen.getByRole("radio", { name: "Use the external source" })).toBeChecked();
+ expect(screen.getByRole("radio", { name: "Store a copy in LiteLLM" })).toHaveAttribute("aria-disabled", "true");
+ change("Source URL", " HTTPS://www.GitHub.com/example/skills ");
+ fireEvent.click(screen.getByRole("radio", { name: "Store a copy in LiteLLM" }));
+ expect(screen.getByLabelText("Registry name (optional)")).toHaveValue("");
+ expect(screen.getByRole("radio", { name: "Add from URL" })).toBeChecked();
+ change("Skill selector (optional)", "previous-draft");
+ change("Source URL", " www.Skills.sh/example/skills/review ");
+ expect(screen.getByLabelText("Skill selector (optional)")).toBeDisabled();
+ expect(screen.getByLabelText("Skill selector (optional)")).toHaveValue("review");
+ expect(screen.getByRole("radio", { name: "Use the external source" })).toHaveAttribute("aria-disabled", "true");
+ fireEvent.click(screen.getByRole("radio", { name: "Upload ZIP" }));
+ fireEvent.click(screen.getByRole("radio", { name: "Add from URL" }));
+ expect(screen.getByRole("radio", { name: "Store a copy in LiteLLM" })).toBeChecked();
+ change("Source URL", "GitHub.com/example/skills");
+ expect(screen.getByLabelText("Skill selector (optional)")).toBeEnabled();
+ expect(screen.getByLabelText("Skill selector (optional)")).toHaveValue("previous-draft");
});
- it.each([
- "https://github.com/anthropics/claude-code",
- "https://github.com/anthropics/claude-code/tree/main/plugins/my-skill",
- "https://gitlab.com/group/repo",
- "https://skills-bucket.s3.us-east-1.amazonaws.com/plugins/s3-skill-1.0.0.zip",
- ])("submits the original source URL %s", async (url) => {
+ it.each(["https://github.com/anthropics/claude-code", "https://skills.sh/example/skills/review"])(
+ "submits the canonical source URL %s",
+ async (url) => {
+ openImport();
+ change(
+ "Source URL",
+ ` ${url.replace("https://", "HTTPS://www.").replace(".com", ".COM").replace(".sh", ".SH")} `,
+ );
+ submit();
+ await waitFor(() => expect(importSkill).toHaveBeenCalledWith("sk-test", { url }));
+ expect(props.onSuccess).toHaveBeenCalledOnce();
+ },
+ );
+
+ it.each(["tree/release/v2/skills/review", "blob/release/v2/skills/review/SKILL.md"])(
+ "imports one canonical selection from %s after changing sources",
+ async (location) => {
+ openImport();
+ change("Skill selector (optional)", "review");
+ change("Git ref", "release/v2");
+ const url = "https://github.com/example/other-skills";
+ change("Source URL", `${url}/tree/release/v2`);
+ expect(screen.getByLabelText("Path (optional)")).toBeEnabled();
+ change("Path (optional)", "previous-draft");
+ change("Version (Optional)", "3.0.0");
+ change("Source URL", `${url}/${location}`);
+ expect(screen.getByLabelText("Path (optional)")).toBeDisabled();
+ expect(screen.getByLabelText("Path (optional)")).toHaveValue("skills/review");
+ expect(screen.getByLabelText("Skill selector (optional)")).toHaveAccessibleDescription(/both must match/);
+ submit();
+ const expected = { url, skill: "review", ref: "release/v2", path: "skills/review", version: "3.0.0" };
+ await waitFor(() => expect(importSkill).toHaveBeenCalledWith("sk-test", expected));
+ },
+ );
+
+ it("switches unsupported import hosts to references and preserves source drafts", async () => {
openImport();
- change("Source URL", url);
+ change("Registry name (optional)", "review");
+ const repository = "https://gitlab.com/team/repo";
+ const archive = "https://artifacts.example.test/skill.zip";
+ change("Source URL", repository);
+ expect(screen.getByRole("radio", { name: "Use the external source" })).toBeChecked();
+ expect(screen.getByRole("radio", { name: "Store a copy in LiteLLM" })).toHaveAttribute("aria-disabled", "true");
+ expect(screen.queryByLabelText("Skill selector (optional)")).not.toBeInTheDocument();
+ change("Path (optional)", "plugins/review");
+ change("Source URL", archive);
+ expect(screen.getByLabelText("Path (optional)")).toBeDisabled();
+ expect(screen.getByLabelText("Path (optional)")).toHaveValue("");
+ expect(screen.queryByLabelText("Git ref")).not.toBeInTheDocument();
+ change("Source URL", repository);
+ expect(screen.getByLabelText("Path (optional)")).toBeEnabled();
+ expect(screen.getByLabelText("Path (optional)")).toHaveValue("plugins/review");
+ change("Git ref", "release/v2");
+ change("Source URL", archive);
submit();
- await waitFor(() => expect(importSkill).toHaveBeenCalledWith("sk-test", { url }));
- expect(props.onSuccess).toHaveBeenCalledOnce();
+ await waitFor(() =>
+ expect(importSkill).toHaveBeenCalledWith("sk-test", {
+ name: "review",
+ source: { source: "archive", url: archive },
+ }),
+ );
});
- it("keeps explicit selector, ref and path choices when a source URL changes", async () => {
- openImport();
- change("Source URL", "https://gitlab.com/group/repo");
- change("Skill selector (optional)", "review");
- change("Git ref (optional)", "release/v2");
- change("Path (optional)", "skills/review");
- change("Version (Optional)", "3.0.0");
- const url = "https://github.com/example/skills/tree/release/v2";
- change("Source URL", url);
+ it("shows the GitLab browser directory and sends its clone URL, full ref and path", async () => {
+ renderWithProviders();
+ fireEvent.click(screen.getByRole("radio", { name: "Add from URL" }));
+ change("Registry name", "review");
+ change("Source URL", "https://gitlab.com/team/repo");
+ change("Path (optional)", "previous-draft");
+ change("Source URL", "https://gitlab.com/team/subgroup/repo/-/blob/release/v2/plugins/review/SKILL.md");
+ expect(screen.getByLabelText("Git ref")).not.toHaveAttribute("placeholder");
+ expect(screen.getByLabelText("Git ref")).toHaveAccessibleDescription(/Enter the full Git ref from this URL/);
+ expect(screen.getByLabelText("Path (optional)")).toBeDisabled();
+ expect(screen.getByLabelText("Path (optional)")).toHaveValue("");
+ expect(screen.queryByText(/^Detected:/)).not.toBeInTheDocument();
submit();
- const expected = { url, skill: "review", ref: "release/v2", path: "skills/review", version: "3.0.0" };
+ expect(await screen.findByRole("alert")).toHaveTextContent("Enter the full Git ref from this URL");
+ expect(importSkill).not.toHaveBeenCalled();
+ change("Git ref", "release/v2");
+ expect(screen.getByLabelText("Path (optional)")).toBeDisabled();
+ expect(screen.getByLabelText("Path (optional)")).toHaveValue("plugins/review");
+ expect(screen.getByText(/^Detected:/)).toHaveTextContent("plugins/review (release/v2)");
+ submit();
+ const expected = {
+ name: "review",
+ source: {
+ source: "git-subdir",
+ url: "https://gitlab.com/team/subgroup/repo",
+ ref: "release/v2",
+ path: "plugins/review",
+ },
+ };
await waitFor(() => expect(importSkill).toHaveBeenCalledWith("sk-test", expected));
});
@@ -88,7 +176,7 @@ describe("AddPluginForm", () => {
expect(props.onSuccess).not.toHaveBeenCalled();
submit();
await waitFor(() => expect(props.onSuccess).toHaveBeenCalledOnce());
- expect(uploadSkill).toHaveBeenLastCalledWith("sk-test", file, "2.0.0", undefined);
+ expect(uploadSkill).toHaveBeenLastCalledWith("sk-test", file, "2.0.0", { skill: undefined, metadata: undefined });
expect(importSkill).not.toHaveBeenCalled();
expect(props.onClose).toHaveBeenCalledOnce();
});
@@ -107,15 +195,18 @@ describe("AddPluginForm", () => {
it("clears a file on mode change, allows reselection and restores source validation", async () => {
renderWithProviders();
chooseFile();
- fireEvent.click(screen.getByRole("radio", { name: "Import URL" }));
+ fireEvent.click(screen.getByRole("radio", { name: "Add from URL" }));
+ change("Registry name", "review");
submit();
- expect(await screen.findByRole("alert")).toHaveTextContent("Please enter a repository or zip archive URL");
+ expect(await screen.findByRole("alert")).toHaveTextContent("Please enter a valid repository or zip archive URL");
fireEvent.click(screen.getByRole("radio", { name: "Upload ZIP" }));
submit();
expect(await screen.findByRole("alert")).toHaveTextContent("Please choose a .zip file");
chooseFile();
submit();
- await waitFor(() => expect(uploadSkill).toHaveBeenCalledWith("sk-test", file, "", undefined));
+ await waitFor(() =>
+ expect(uploadSkill).toHaveBeenCalledWith("sk-test", file, "", { skill: undefined, metadata: { name: "review" } }),
+ );
});
it("blocks an invalid version and cancels without publishing", async () => {
diff --git a/litellm/ui/litellm-dashboard/src/app/(dashboard)/skills/_components/add_plugin_form.tsx b/litellm/ui/litellm-dashboard/src/app/(dashboard)/skills/_components/add_plugin_form.tsx
index 6e537ad589e..34aa684c5fc 100644
--- a/litellm/ui/litellm-dashboard/src/app/(dashboard)/skills/_components/add_plugin_form.tsx
+++ b/litellm/ui/litellm-dashboard/src/app/(dashboard)/skills/_components/add_plugin_form.tsx
@@ -1,7 +1,6 @@
import { useState } from "react";
+import type { UseFormReturn } from "react-hook-form";
import { useTranslation } from "react-i18next";
-import { z } from "zod";
-import i18n from "@/i18n/i18n";
import { toast } from "@/lib/toast";
import { ApiError } from "@/lib/http/client";
import {
@@ -19,17 +18,43 @@ import { Input } from "@/components/ui/input";
import { RadioGroup, RadioGroupItem } from "@/components/ui/radio-group";
import { Textarea } from "@/components/ui/textarea";
import { useZodForm } from "@/lib/forms/useZodForm";
-import { isValidSemanticVersion } from "@/components/claude_code_plugins/helpers";
+import {
+ availableSkillUrlModes,
+ parseSkillImportSource,
+ parseSkillSource,
+ requiresBrowserRefConfirmation,
+} from "@/components/claude_code_plugins/helpers";
import {
isPendingSkill,
type SkillHubSkill,
type SkillMutationResponse,
type SkillSubmission,
} from "@/components/claude_code_plugins/types";
-import { buildSkillImport, buildSkillMetadata, skillFormValues } from "@/components/claude_code_plugins/skillForm";
+import {
+ buildSkillImport,
+ buildSkillMetadata,
+ buildSkillRegistration,
+ buildSkillUpdate,
+ buildSkillUploadMetadata,
+ skillFormSchema,
+ skillFormValues,
+ type SkillFormValues,
+} from "@/components/claude_code_plugins/skillForm";
-const EDIT_SKILL_SOURCES = ["metadata", "upload"] as const;
-const NEW_SKILL_SOURCES = ["upload", "import"] as const;
+const EDIT_SKILL_SOURCES = ["metadata", "upload", "replace"] as const;
+const SUBMISSION_SOURCES = ["metadata", "upload"] as const;
+const NEW_SKILL_SOURCES = ["upload", "register"] as const;
+const URL_SKILL_SOURCES = ["register", "import"] as const;
+
+const ADVANCED_FIELDS = [
+ "authorName",
+ "authorEmail",
+ "category",
+ "domain",
+ "namespace",
+ "keywords",
+ "homepage",
+] as const;
interface AddPluginFormProps {
visible: boolean;
@@ -41,43 +66,6 @@ interface AddPluginFormProps {
requiresApproval?: boolean;
}
-const skillShape = {
- mode: z.enum(["upload", "import", "metadata"]),
- archiveFile: z
- .file()
- .refine((file) => file.name.toLowerCase().endsWith(".zip"), {
- error: () => i18n.t("skills.addForm.errors.zipRequired"),
- })
- .max(10 * 1024 * 1024, { error: () => i18n.t("skills.addForm.errors.zipTooLarge") })
- .nullable(),
- url: z.string(),
- skill: z.string(),
- ref: z.string(),
- path: z.string(),
- domain: z.string(),
- namespace: z.string(),
- description: z.string(),
- keywords: z.string(),
- version: z.string().refine((value) => !value.trim() || isValidSemanticVersion(value.trim()), {
- error: () => i18n.t("skills.addForm.toasts.invalidVersion"),
- }),
-};
-const skillSchema = z.object(skillShape).superRefine((values, context) => {
- if (values.mode === "upload" && !values.archiveFile) {
- context.addIssue({ code: "custom", path: ["archiveFile"], message: i18n.t("skills.addForm.errors.zipRequired") });
- }
- if (values.mode === "import" && !values.url.trim()) {
- context.addIssue({ code: "custom", path: ["url"], message: i18n.t("skills.addForm.errors.urlRequired") });
- }
- if (values.mode === "metadata" && values.description.length > 1024) {
- context.addIssue({
- code: "custom",
- path: ["description"],
- message: i18n.t("skills.addForm.errors.descriptionTooLong"),
- });
- }
-});
-
function formLabels(editing: boolean, submission: boolean, requiresApproval: boolean) {
if (submission) return { title: "skills.submissions.edit", submit: "skills.submissions.save" } as const;
const directSubmit = editing ? "skills.addForm.save" : "skills.addForm.submit";
@@ -87,6 +75,221 @@ function formLabels(editing: boolean, submission: boolean, requiresApproval: boo
} as const;
}
+interface SkillFormFieldsProps {
+ form: UseFormReturn;
+ skill?: SkillHubSkill;
+}
+
+interface SkillSourceSelectorsProps {
+ form: UseFormReturn;
+ mode: "register" | "import" | "replace";
+}
+
+function SkillSourceSelectors({ form, mode }: SkillSourceSelectorsProps) {
+ const { t } = useTranslation();
+ const sourceUrl = form.watch("url");
+ const sourcePath = form.watch("path");
+ const sourceRef = form.watch("ref");
+ const source =
+ mode === "import"
+ ? parseSkillImportSource(sourceUrl, sourcePath, sourceRef)
+ : { preview: parseSkillSource(sourceUrl, sourcePath, sourceRef), skillFromUrl: undefined };
+ const sourcePreview = source?.preview;
+ const needsRef = requiresBrowserRefConfirmation(sourcePreview, sourceRef);
+ const displayPreview = needsRef ? null : sourcePreview;
+ const isArchive = sourcePreview?.parsed.source === "archive";
+ const archivePathLock = isArchive ? "archive" : undefined;
+ const pathLock = sourcePreview?.pathFromUrl ? "gitSubdir" : archivePathLock;
+ const referenceFields = isArchive ? (["path"] as const) : (["ref", "path"] as const);
+ const sourceFields = mode === "import" ? (["skill", "ref", "path"] as const) : referenceFields;
+ const lockedValues: Partial> = {
+ ...(pathLock ? { path: displayPreview?.parsed.path ?? "" } : {}),
+ ...(source?.skillFromUrl ? { skill: source.skillFromUrl } : {}),
+ };
+ const sourceDescriptions: Partial> = {
+ skill: t(source?.skillFromUrl ? "skills.addForm.hints.skillFromUrl" : "skills.addForm.hints.skill"),
+ path: t(pathLock ? `skills.addForm.subPathLock.${pathLock}` : "skills.addForm.hints.subPath"),
+ ref: t(needsRef ? "skills.addForm.errors.browserRefRequired" : "skills.addForm.hints.ref"),
+ };
+ return (
+ <>
+ {sourceFields.map((name) => (
+
+ {(field) => (
+
+ )}
+
+ ))}
+ {t(`skills.addForm.${mode}Hint`)}
+ {displayPreview && (
+
+ {t("skills.addForm.detected", { source: displayPreview.label })}
+
+ )}
+ >
+ );
+}
+
+function SkillSourceFields({
+ form,
+ skill,
+ changeMode,
+}: SkillFormFieldsProps & { changeMode: (value: string) => void }) {
+ const { t } = useTranslation();
+ const mode = form.watch("mode");
+ const sourceUrl = form.watch("url");
+ const urlModes = availableSkillUrlModes(sourceUrl);
+ const changeSourceMode = (url: string) => {
+ if (skill) return;
+ const available = availableSkillUrlModes(url);
+ if (available.length === 1 && available[0] !== mode) changeMode(available[0]);
+ };
+ if (mode === "metadata") return null;
+ if (mode === "upload") {
+ return (
+
+ {({ value, onChange, ...field }) => (
+ onChange(event.target.files?.[0] ?? null)}
+ />
+ )}
+
+ );
+ }
+ return (
+ <>
+
+ {(field) => (
+ {
+ field.onChange(event);
+ changeSourceMode(event.target.value);
+ }}
+ />
+ )}
+
+ {!skill && (
+
+ {({ value }) => (
+
+ {URL_SKILL_SOURCES.map((option) => (
+
+ ))}
+
+ )}
+
+ )}
+
+ >
+ );
+}
+
+function SkillMetadataFields({ form, skill }: SkillFormFieldsProps) {
+ const { t } = useTranslation();
+ const mode = form.watch("mode");
+ const sourceUrl = form.watch("url");
+ const sourcePath = form.watch("path");
+ const sourceRef = form.watch("ref");
+ if (skill && mode === "upload") return null;
+ const referenceMode = mode === "register" || mode === "replace";
+ const sourcePreview = referenceMode ? parseSkillSource(sourceUrl, sourcePath, sourceRef) : null;
+ const hasAdvancedErrors =
+ ADVANCED_FIELDS.some((field) => form.formState.errors[field]) || Boolean(form.formState.errors.sha256);
+ return (
+ <>
+ {!skill && (
+
+ {(field) => }
+
+ )}
+
+ {(field) => }
+
+
+ {t("skills.addForm.advancedMetadata")}
+ {t("skills.addForm.authorOverrideHint")}
+
+ {ADVANCED_FIELDS.map((name) => (
+
+ {(field) => }
+
+ ))}
+ {sourcePreview?.parsed.source === "archive" && (
+
+ {(field) => }
+
+ )}
+
+
+ >
+ );
+}
+
+function SkillVersionField({ form, skill, submission }: SkillFormFieldsProps & Pick) {
+ const { t } = useTranslation();
+ const version = submission ? submission.publishedVersion : skill?.version;
+ return (
+
+ {(field) => }
+
+ );
+}
+
export default function AddPluginForm({
visible,
onClose,
@@ -97,17 +300,16 @@ export default function AddPluginForm({
requiresApproval = false,
}: AddPluginFormProps) {
const { t } = useTranslation();
- const form = useZodForm(skillSchema, {
+ const form = useZodForm(skillFormSchema(skill), {
defaultValues: {
...skillFormValues(skill),
...(submission ? { version: submission.value.proposal.version ?? "" } : {}),
},
});
- const mode = form.watch("mode");
const [error, setError] = useState(null);
const conflictedSubmission = error instanceof ApiError && error.status === 409 ? submission : undefined;
const isSubmitting = form.formState.isSubmitting;
- const submit = async (values: z.infer) => {
+ const submit = async (values: SkillFormValues) => {
if (!accessToken) return;
setError(null);
try {
@@ -127,12 +329,22 @@ export default function AddPluginForm({
}
const write = () => {
if (values.mode === "upload" && values.archiveFile) {
- return uploadSkillHubSkill(accessToken, values.archiveFile, values.version, skill);
+ return uploadSkillHubSkill(accessToken, values.archiveFile, values.version, {
+ skill,
+ metadata: skill ? undefined : buildSkillUploadMetadata(values),
+ });
}
- if (skill) return updateSkillHubSkill(accessToken, skill.name, buildSkillMetadata(values, skill));
- return importSkillHubSkill(accessToken, buildSkillImport(values));
+ if (skill) return updateSkillHubSkill(accessToken, skill.name, buildSkillUpdate(values, skill));
+ if (values.mode === "register") {
+ const registration = buildSkillRegistration(values);
+ if (!registration) return;
+ return importSkillHubSkill(accessToken, registration);
+ }
+ const imported = buildSkillImport(values);
+ if (imported) return importSkillHubSkill(accessToken, imported);
};
const response = await write();
+ if (!response) return;
const publishedMessage = skill ? "skills.addForm.toasts.updated" : "skills.addForm.toasts.registered";
toast.success(t(isPendingSkill(response) ? "skills.addForm.toasts.submitted" : publishedMessage));
onSuccess?.(response);
@@ -142,15 +354,16 @@ export default function AddPluginForm({
}
};
const changeMode = (value: string) => {
- if (value !== "upload" && value !== "import" && value !== "metadata") return;
- form.setValue("mode", value);
+ const nextMode = [...EDIT_SKILL_SOURCES, ...URL_SKILL_SOURCES].find((option) => option === value);
+ if (!nextMode) return;
+ form.setValue("mode", nextMode === "register" ? availableSkillUrlModes(form.getValues("url"))[0] : nextMode);
form.setValue("archiveFile", null);
form.clearErrors();
setError(null);
};
const labels = formLabels(Boolean(skill), Boolean(submission), requiresApproval);
- const fields =
- mode === "import" ? (["url", "skill", "ref", "path"] as const) : (["domain", "namespace", "keywords"] as const);
+ const editSources = submission ? SUBMISSION_SOURCES : EDIT_SKILL_SOURCES;
+ const sources = skill ? editSources : NEW_SKILL_SOURCES;
return (