Merge branch 'feature/mcp-ui' into dev

This commit is contained in:
朱潮 2026-05-21 18:33:57 +08:00
commit 3ebd006b6e
2 changed files with 54 additions and 0 deletions

View File

@ -0,0 +1,29 @@
---
name: static-hosting
description: Serve static HTML/CSS/JS/images from robot project directories via the built-in FastAPI static file server. Use when generating web pages, reports, or interactive content for a bot.
---
# Static Hosting
Host static files (HTML, CSS, JS, images, fonts, etc.) under `/workspace/` and get public URLs.
## Usage
Write files to `/workspace/`, then run the script to get the public URL:
```bash
python3 {SKILL_DIR}/scripts/get_url.py <absolute_path>
```
Example:
```bash
python3 {SKILL_DIR}/scripts/get_url.py /workspace/index.html
# => https://api-dev.gptbase.ai/robot-assets/[bot-id]/index.html
```
## Notes
- Inside HTML, use **relative paths** to reference other assets (e.g. `href="css/style.css"`)
- `/workspace/index.html` is auto-served at the directory URL
- All files under `/robot-assets/` are publicly accessible, no authentication

View File

@ -0,0 +1,25 @@
import os
import sys
BACKEND_HOST = os.getenv("BACKEND_HOST", "https://api-dev.gptbase.ai")
ASSISTANT_ID = os.getenv("ASSISTANT_ID", "")
if not ASSISTANT_ID:
print("Error: ASSISTANT_ID environment variable is not set")
sys.exit(1)
if len(sys.argv) < 2:
print(f"Usage: python3 {sys.argv[0]} <file_path>")
print(f"Example: python3 {sys.argv[0]} /workspace/index.html")
sys.exit(1)
file_path = os.path.abspath(sys.argv[1])
workspace_root = "/workspace"
if not file_path.startswith(workspace_root):
print(f"Error: path must be under {workspace_root}, got: {file_path}")
sys.exit(1)
relative_path = file_path[len(workspace_root):] # e.g. "/css/style.css"
base_url = f"{BACKEND_HOST.rstrip('/')}/robot-assets/{ASSISTANT_ID}"
print(f"{base_url}{relative_path}")