From 838111c0fe5243ca85e829c25e3e70615c308d68 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=B1=E6=BD=AE?= Date: Mon, 15 Jun 2026 15:11:03 +0800 Subject: [PATCH] onrepm static hosting --- skills/onprem/static-hosting/SKILL.md | 30 +++++++++++++++++++ .../onprem/static-hosting/scripts/get_url.py | 25 ++++++++++++++++ 2 files changed, 55 insertions(+) create mode 100644 skills/onprem/static-hosting/SKILL.md create mode 100644 skills/onprem/static-hosting/scripts/get_url.py diff --git a/skills/onprem/static-hosting/SKILL.md b/skills/onprem/static-hosting/SKILL.md new file mode 100644 index 0000000..4058cf1 --- /dev/null +++ b/skills/onprem/static-hosting/SKILL.md @@ -0,0 +1,30 @@ +--- +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. +category: Web Services +--- + +# 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 +``` + +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 diff --git a/skills/onprem/static-hosting/scripts/get_url.py b/skills/onprem/static-hosting/scripts/get_url.py new file mode 100644 index 0000000..9def77b --- /dev/null +++ b/skills/onprem/static-hosting/scripts/get_url.py @@ -0,0 +1,25 @@ +import os +import sys + +BACKEND_HOST = os.getenv("BACKEND_HOST", "https://onprem-dev.gbase.ai/api") +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]} ") + 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}")