From 6cdb12c43f1c48b092af292327e135044cb12e34 Mon Sep 17 00:00:00 2001 From: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Date: Thu, 17 Sep 2026 21:06:26 +0000 Subject: [PATCH 1/5] feat(proxy): serve stored skill archives to authenticated keys Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> --- litellm/proxy/_types.py | 1 + .../agent_skills_endpoints.py | 29 ++++++-- .../litellm_proxy/test_skills_ownership.py | 21 ++++++ .../test_agent_skills_endpoints.py | 71 ++++++++++++++++++- 4 files changed, 114 insertions(+), 8 deletions(-) diff --git a/litellm/proxy/_types.py b/litellm/proxy/_types.py index 680c63393e8..59b41676ca1 100644 --- a/litellm/proxy/_types.py +++ b/litellm/proxy/_types.py @@ -507,6 +507,7 @@ class LiteLLMRoutes(enum.Enum): "/v1/messages/count_tokens", "/v1/skills", "/v1/skills/{skill_id}", + "/v1/skills/{skill_id}/archive", "/claude-code/marketplace.json", "/claude-code/plugins", "/claude-code/plugins/{plugin_name}", diff --git a/litellm/proxy/discovery_endpoints/agent_skills_endpoints.py b/litellm/proxy/discovery_endpoints/agent_skills_endpoints.py index 3084cbfd84f..639e80ce1ae 100644 --- a/litellm/proxy/discovery_endpoints/agent_skills_endpoints.py +++ b/litellm/proxy/discovery_endpoints/agent_skills_endpoints.py @@ -1,9 +1,11 @@ """Serve skills stored on the proxy as an Agent Skills well-known discovery index. ``npx skills add -a `` reads ``/.well-known/agent-skills/index.json`` -and downloads each entry's archive. Discovery clients send no credentials, so both -routes are unauthenticated and stay off until ``litellm_settings.public_skills_index`` +and downloads each entry's archive. Discovery clients send no credentials, so the +index routes are unauthenticated and stay off until ``litellm_settings.public_skills_index`` is enabled, which publishes every stored skill to anyone who can reach the proxy. +The archive route stays anonymous while the index is public; with the index off it +requires a LiteLLM key and stays scoped to the skill's owner. """ import asyncio @@ -20,6 +22,7 @@ import litellm from litellm._logging import verbose_proxy_logger from litellm.caching.in_memory_cache import InMemoryCache from litellm.models.skills import LiteLLM_SkillsTable +from litellm.proxy._types import UserAPIKeyAuth from litellm.proxy.discovery_endpoints.agent_skills_archive import SkillArchive, build_skill_archive from litellm.types.proxy.discovery_endpoints.agent_skills_endpoints import ( MAX_SKILL_DESCRIPTION_LENGTH, @@ -62,11 +65,22 @@ async def stored_skills() -> Sequence[LiteLLM_SkillsTable]: return await LiteLLMSkillsHandler.list_skills(limit=MAX_INDEXED_SKILLS) -async def stored_skill(skill_id: str) -> LiteLLM_SkillsTable | None: +async def archive_caller(request: Request) -> UserAPIKeyAuth | None: + if litellm.public_skills_index is True: + return None + from litellm.proxy.auth.user_api_key_auth import user_api_key_auth + + return await user_api_key_auth(request=request, api_key=request.headers.get("Authorization", "")) + + +async def stored_skill( + skill_id: str, + caller: UserAPIKeyAuth | None = Depends(archive_caller), +) -> LiteLLM_SkillsTable | None: from litellm.llms.litellm_proxy.skills.handler import LiteLLMSkillsHandler try: - return await LiteLLMSkillsHandler.get_skill(skill_id) + return await LiteLLMSkillsHandler.get_skill(skill_id, user_api_key_dict=caller) except ValueError: return None @@ -111,14 +125,17 @@ async def agent_skills_index( @router.get( "/v1/skills/{skill_id}/archive", - dependencies=(Depends(ensure_index_enabled),), response_class=ZipArchiveResponse, ) async def agent_skills_archive( skill_id: str, skill: LiteLLM_SkillsTable | None = Depends(stored_skill), ) -> ZipArchiveResponse: - """Stored skill upload, repacked so SKILL.md sits at the archive root.""" + """Stored skill upload, repacked so SKILL.md sits at the archive root. + + Anonymous while the public index is on; otherwise needs a LiteLLM key + with access to the skill's owner scope. + """ archive: Final = await _archive_for(skill) if skill is not None else None if archive is None: raise HTTPException(status_code=404, detail=f"No installable skill archive for: {skill_id}") diff --git a/tests/test_litellm/llms/litellm_proxy/test_skills_ownership.py b/tests/test_litellm/llms/litellm_proxy/test_skills_ownership.py index e538c50cde8..7f2feefb0bf 100644 --- a/tests/test_litellm/llms/litellm_proxy/test_skills_ownership.py +++ b/tests/test_litellm/llms/litellm_proxy/test_skills_ownership.py @@ -336,6 +336,27 @@ async def test_should_hide_skill_from_different_owner(monkeypatch): ) +@pytest.mark.asyncio +async def test_should_return_skill_to_its_owner(monkeypatch): + table = AsyncMock() + table.find_unique.return_value = _skill("litellm_skill_mine", "user-1") + prisma_client = type( + "Prisma", (), {"db": type("DB", (), {"litellm_skillstable": table})()} + )() + monkeypatch.setattr( + LiteLLMSkillsHandler, + "_get_prisma_client", + AsyncMock(return_value=prisma_client), + ) + + skill = await LiteLLMSkillsHandler.get_skill( + "litellm_skill_mine", + user_api_key_dict=UserAPIKeyAuth(user_id="user-1"), + ) + + assert skill.skill_id == "litellm_skill_mine" + + @pytest.mark.asyncio async def test_should_hide_unowned_skill_by_default(monkeypatch): table = AsyncMock() diff --git a/tests/test_litellm/proxy/discovery_endpoints/test_agent_skills_endpoints.py b/tests/test_litellm/proxy/discovery_endpoints/test_agent_skills_endpoints.py index ea889e75ae8..47af4bcefb8 100644 --- a/tests/test_litellm/proxy/discovery_endpoints/test_agent_skills_endpoints.py +++ b/tests/test_litellm/proxy/discovery_endpoints/test_agent_skills_endpoints.py @@ -4,12 +4,14 @@ import zipfile from datetime import datetime, timezone import pytest -from fastapi import FastAPI +from fastapi import Depends, FastAPI from fastapi.testclient import TestClient import litellm from litellm.models.skills import LiteLLM_SkillsTable +from litellm.proxy._types import UserAPIKeyAuth from litellm.proxy.discovery_endpoints.agent_skills_endpoints import ( + archive_caller, router, stored_skill, stored_skills, @@ -80,7 +82,6 @@ def test_discovery_is_absent_until_public_skills_index_is_enabled(monkeypatch): for path in WELL_KNOWN_PATHS: assert client.get(path).status_code == 404 - assert client.get("/v1/skills/litellm_skill_1/archive").status_code == 404 @pytest.mark.parametrize("path", WELL_KNOWN_PATHS) @@ -167,6 +168,72 @@ def test_archive_route_404s_for_a_skill_that_does_not_exist(index_enabled): assert client.get("/v1/skills/litellm_skill_missing/archive").status_code == 404 +def authenticated_client_for( + *skills: LiteLLM_SkillsTable, caller: UserAPIKeyAuth | None = None +) -> tuple[TestClient, list[UserAPIKeyAuth | None]]: + from litellm.proxy._types import ProxyException + + app = FastAPI() + + @app.exception_handler(ProxyException) + async def _proxy_exception(request, exc: ProxyException): + from fastapi.responses import JSONResponse + + return JSONResponse(status_code=int(exc.code), content={"error": exc.to_dict()}) + + app.include_router(router) + + seen: list[UserAPIKeyAuth | None] = [] + + def _skill( + skill_id: str, + resolved: UserAPIKeyAuth | None = Depends(archive_caller), + ) -> LiteLLM_SkillsTable | None: + seen.append(resolved) + return next((candidate for candidate in skills if candidate.skill_id == skill_id), None) + + app.dependency_overrides[stored_skill] = _skill + if caller is not None: + app.dependency_overrides[archive_caller] = lambda: caller + return TestClient(app), seen + + +def test_archive_route_rejects_keyless_requests_when_the_index_is_private(monkeypatch): + monkeypatch.setattr(litellm, "public_skills_index", False) + from litellm.proxy import proxy_server + + monkeypatch.setattr(proxy_server, "master_key", "sk-master") + client, seen = authenticated_client_for(skill("litellm_skill_1")) + + assert client.get("/v1/skills/litellm_skill_1/archive").status_code == 401 + assert seen == [] + + +def test_archive_route_serves_an_authenticated_key_when_the_index_is_private(monkeypatch): + monkeypatch.setattr(litellm, "public_skills_index", False) + client, seen = authenticated_client_for(skill("litellm_skill_1"), caller=UserAPIKeyAuth(user_id="user-1")) + + downloaded = client.get( + "/v1/skills/litellm_skill_1/archive", + headers={"Authorization": "Bearer sk-test"}, + ) + + assert downloaded.status_code == 200 + assert downloaded.headers["content-type"] == "application/zip" + assert seen[0] is not None and seen[0].user_id == "user-1" + with zipfile.ZipFile(io.BytesIO(downloaded.content)) as archive: + assert "SKILL.md" in archive.namelist() + + +def test_archive_route_stays_anonymous_while_the_index_is_public(index_enabled): + client, seen = authenticated_client_for(skill("litellm_skill_1")) + + downloaded = client.get("/v1/skills/litellm_skill_1/archive") + + assert downloaded.status_code == 200 + assert seen == [None] + + def test_a_stored_skill_is_repacked_once_per_version(index_enabled): stamp = datetime(2026, 9, 6, 9, 0, tzinfo=timezone.utc) first = client_for(skill("litellm_skill_cached", files={"s/SKILL.md": MANIFEST}, updated_at=stamp)) From 07a7a235229ebd8f382782bffd927c518803e36d Mon Sep 17 00:00:00 2001 From: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Date: Thu, 17 Sep 2026 21:12:18 +0000 Subject: [PATCH 2/5] chore(proxy): noqa B008 on FastAPI dependency default Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> --- litellm/proxy/discovery_endpoints/agent_skills_endpoints.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/litellm/proxy/discovery_endpoints/agent_skills_endpoints.py b/litellm/proxy/discovery_endpoints/agent_skills_endpoints.py index 639e80ce1ae..b346f8d624f 100644 --- a/litellm/proxy/discovery_endpoints/agent_skills_endpoints.py +++ b/litellm/proxy/discovery_endpoints/agent_skills_endpoints.py @@ -75,7 +75,7 @@ async def archive_caller(request: Request) -> UserAPIKeyAuth | None: async def stored_skill( skill_id: str, - caller: UserAPIKeyAuth | None = Depends(archive_caller), + caller: UserAPIKeyAuth | None = Depends(archive_caller), # noqa: B008 # FastAPI dependency injection ) -> LiteLLM_SkillsTable | None: from litellm.llms.litellm_proxy.skills.handler import LiteLLMSkillsHandler From 844ac21f2bcc6ec553d9fc12d82362a82da6efe8 Mon Sep 17 00:00:00 2001 From: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Date: Thu, 17 Sep 2026 21:25:17 +0000 Subject: [PATCH 3/5] chore(proxy): regen lazy openapi snapshot for archive route description Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> --- litellm/proxy/_lazy_openapi_snapshot.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/litellm/proxy/_lazy_openapi_snapshot.json b/litellm/proxy/_lazy_openapi_snapshot.json index 74f38b3ca6d..735ac1bb9d1 100644 --- a/litellm/proxy/_lazy_openapi_snapshot.json +++ b/litellm/proxy/_lazy_openapi_snapshot.json @@ -5168,7 +5168,7 @@ }, "/v1/skills/{skill_id}/archive": { "get": { - "description": "Stored skill upload, repacked so SKILL.md sits at the archive root.", + "description": "Stored skill upload, repacked so SKILL.md sits at the archive root.\n\nAnonymous while the public index is on; otherwise needs a LiteLLM key\nwith access to the skill's owner scope.", "operationId": "agent_skills_archive_v1_skills__skill_id__archive_get", "parameters": [ { From eafb8c180559a6ddc260e9bff2dcce5f4339784e Mon Sep 17 00:00:00 2001 From: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Date: Thu, 17 Sep 2026 21:36:58 +0000 Subject: [PATCH 4/5] chore(ui): regen dashboard api types for archive route description Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> --- ui/litellm-dashboard/src/lib/http/schema.d.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ui/litellm-dashboard/src/lib/http/schema.d.ts b/ui/litellm-dashboard/src/lib/http/schema.d.ts index 872875cc535..254cfe4848c 100644 --- a/ui/litellm-dashboard/src/lib/http/schema.d.ts +++ b/ui/litellm-dashboard/src/lib/http/schema.d.ts @@ -20245,6 +20245,9 @@ export interface paths { /** * Agent Skills Archive * @description Stored skill upload, repacked so SKILL.md sits at the archive root. + * + * Anonymous while the public index is on; otherwise needs a LiteLLM key + * with access to the skill's owner scope. */ get: operations["agent_skills_archive_v1_skills__skill_id__archive_get"]; put?: never; From d93cdec5bff42ebc4bebdf112c91d4c24a7653b3 Mon Sep 17 00:00:00 2001 From: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Date: Thu, 17 Sep 2026 21:49:20 +0000 Subject: [PATCH 5/5] fix(proxy): accept all supported credential headers on the archive route Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> --- .../discovery_endpoints/agent_skills_endpoints.py | 12 ++++++++++-- .../test_agent_skills_endpoints.py | 2 +- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/litellm/proxy/discovery_endpoints/agent_skills_endpoints.py b/litellm/proxy/discovery_endpoints/agent_skills_endpoints.py index b346f8d624f..b7cd5268a47 100644 --- a/litellm/proxy/discovery_endpoints/agent_skills_endpoints.py +++ b/litellm/proxy/discovery_endpoints/agent_skills_endpoints.py @@ -22,7 +22,7 @@ import litellm from litellm._logging import verbose_proxy_logger from litellm.caching.in_memory_cache import InMemoryCache from litellm.models.skills import LiteLLM_SkillsTable -from litellm.proxy._types import UserAPIKeyAuth +from litellm.proxy._types import SpecialHeaders, UserAPIKeyAuth from litellm.proxy.discovery_endpoints.agent_skills_archive import SkillArchive, build_skill_archive from litellm.types.proxy.discovery_endpoints.agent_skills_endpoints import ( MAX_SKILL_DESCRIPTION_LENGTH, @@ -70,7 +70,15 @@ async def archive_caller(request: Request) -> UserAPIKeyAuth | None: return None from litellm.proxy.auth.user_api_key_auth import user_api_key_auth - return await user_api_key_auth(request=request, api_key=request.headers.get("Authorization", "")) + return await user_api_key_auth( + request=request, + api_key=request.headers.get(SpecialHeaders.openai_authorization.value, ""), + azure_api_key_header=request.headers.get(SpecialHeaders.azure_authorization.value), + anthropic_api_key_header=request.headers.get(SpecialHeaders.anthropic_authorization.value), + google_ai_studio_api_key_header=request.headers.get(SpecialHeaders.google_ai_studio_authorization.value), + azure_apim_header=request.headers.get(SpecialHeaders.azure_apim_authorization.value), + custom_litellm_key_header=request.headers.get(SpecialHeaders.custom_litellm_api_key.value), + ) async def stored_skill( diff --git a/tests/test_litellm/proxy/discovery_endpoints/test_agent_skills_endpoints.py b/tests/test_litellm/proxy/discovery_endpoints/test_agent_skills_endpoints.py index 47af4bcefb8..420302360f4 100644 --- a/tests/test_litellm/proxy/discovery_endpoints/test_agent_skills_endpoints.py +++ b/tests/test_litellm/proxy/discovery_endpoints/test_agent_skills_endpoints.py @@ -183,7 +183,7 @@ def authenticated_client_for( app.include_router(router) - seen: list[UserAPIKeyAuth | None] = [] + seen: list[UserAPIKeyAuth | None] = [] # mutable-ok: test spy recording the resolved caller def _skill( skill_id: str,