Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 37 additions & 2 deletions veadk/cli/cli_frontend.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,8 +231,10 @@ def frontend(

# Agent introspection for the UI's agent picker (name, model, tools). Reuses
# ADK's AgentLoader, which caches each loaded `root_agent`.
from fastapi import HTTPException
from fastapi import HTTPException, Request
from fastapi.responses import Response
from google.adk.cli.utils.agent_loader import AgentLoader
import httpx

_agent_loader = AgentLoader(agents_dir)

Expand Down Expand Up @@ -350,6 +352,39 @@ async def _web_search(source: str, app_name: str, q: str):
]
return {"mounted": True, "results": results}

# ---- Skill Hub proxy: proxy /skillhub/* to skills.volces.com ----
SKILLHUB_TARGET = "https://skills.volces.com"

@app.api_route(
"/skillhub/{path:path}", methods=["GET", "POST", "PUT", "DELETE", "PATCH"]
)
async def _skillhub_proxy(request: Request, path: str):
"""Proxy requests to Volcengine Skill Hub API to avoid CORS issues."""
target_url = f"{SKILLHUB_TARGET}/{path}"
if request.url.query:
target_url += f"?{request.url.query}"

headers = dict(request.headers)
headers.pop("host", None)

try:
async with httpx.AsyncClient() as client:
response = await client.request(
method=request.method,
url=target_url,
headers=headers,
content=await request.body(),
timeout=30.0,
)
return Response(
content=response.content,
status_code=response.status_code,
headers=dict(response.headers),
)
except Exception as e:
logger.error(f"Skillhub proxy error: {e}")
raise HTTPException(status_code=502, detail=f"Proxy error: {str(e)}")

# ---- SSO (optional): VeIdentity user pool, or a generic provider via env ----
redirect_uri = oauth2_redirect_uri or f"http://{host}:{port}/oauth2/callback"
pool_ok = oauth2_user_pool or oauth2_user_pool_uid
Expand Down Expand Up @@ -406,7 +441,7 @@ async def _web_auth_config():
app,
oauth2_config,
exempt_paths={"/", "/index.html", "/favicon.ico", "/web/auth-config"},
exempt_prefixes={"/assets"},
exempt_prefixes={"/assets", "/skillhub"},
)
logger.info(
f"OAuth2 SSO enabled (provider={provider_id}, redirect_uri={redirect_uri})"
Expand Down
Loading