3.9 KiB
Enterprise Gateway — LobeChat Plugin Manifest
This directory holds two flavours of a LobeChat plugin manifest:
- Static
manifest.json— a hard-coded four-tool view. Good as a fallback / first look, but does not reflect the caller's real gateway capabilities. - Dynamic (recommended) — served by the gateway at
GET http://gateway:3001/api/lobechat/manifest. Theapi[]list is computed from/api/capabilitiesfor the caller (identity viaX-Dev-Useror future Casdoor session), so different users see different tools.
Both flavours funnel tool calls to
POST http://gateway:3001/api/lobechat/tool-gateway which preserves the gateway's
RBAC / identity-map / data-scope / field-masking / audit pipeline.
Dynamic manifest details
api[i].nameuses__as the separator because LobeChat's plugin spec rejects dots inname(e.g.kb__search,gongdan__search_tickets). The gateway translates this back to its real tool key.- Calls go to
POST /api/lobechat/tool-gatewaywith body{"name":"kb__search","arguments":{...}}(OpenAI-plugin shape) or the simpler{"tool":"kb.search","params":{...}}. Both are accepted. - A 403 response means the caller is not authorized for that tool; agents should not retry.
What it exposes
All four entries call POST http://gateway:3001/api/tools/call with a { tool, params } body:
Manifest name |
Gateway tool key |
|---|---|
kb_search |
kb.search |
ai_search_web |
ai_search.web |
gongdan_create_ticket |
gongdan.create_ticket |
xiaoshou_search_customers |
xiaoshou.search_customers |
This is a minimum-viable bridge. The Gateway enforces RBAC, identity-map, data-scope, and field-masking — this manifest does not relax any of that. A real plugin build will also need to translate the manifest
name→ gatewaytoolkey, inject the caller's identity header (X-Dev-Userin dev, Casdoor JWT in prod), and stream results back to LobeChat's tool-call channel. Today the gateway URL is reachable only from inside the compose network.
How to register it in LobeChat
- Start the stack:
docker compose up -d. - Open http://localhost:3010 and sign in.
- Settings → Plugins → Custom Plugin → Install from URL.
- Paste one of:
- Dynamic (recommended):
http://gateway:3001/api/lobechat/manifest— served per-user, so the tool list always matches the caller's real grants. LobeChat must sendX-Dev-User: <username>on the manifest fetch (configure via the plugin's custom-headers field) or be behind a gateway-side proxy that injects the Casdoor identity. - Static: paste the contents of
manifest.json.
- Dynamic (recommended):
- Enable the plugin for an agent.
Server-mode auto-registration
LobeChat's server-mode stores installed plugins in its own DB. We do not
seed a row there from this repo because the LobeChat server-mode schema is
owned by the lobehub/lobe-chat-database image (we pull it as a released
container and do not control its migrations). Registration is manual (step 4
above). If/when we self-host the LobeChat server image we can add a seed
migration that pre-registers http://gateway:3001/api/lobechat/manifest for
all users.
Known limitations
- No auth header is injected yet — the gateway is running in
AUTH_MODE=dev, so calls withoutX-Dev-Userget 401. Replace this with a server-side proxy that adds the authenticated user's identity before forwarding. - Only 4 tools out of the full gateway catalog (
/api/capabilities) are mirrored here. Extendmanifest.jsonas needed. - The
urluses the internal Docker hostnamegateway. If LobeChat fetches the plugin from outside the compose network, change it tohttp://localhost:3001and adjust CORS (GATEWAY_CORS_ORIGINS).