feat(settings): bind internal/external knowledge bases from the UI

Routing targets move from env-only to a UI-managed binding (migration
000034 routing_kb_bindings, single active row):
- GET/PUT /api/v1/routing-bindings + /options: env defaults act as the
  bootstrap fallback; a UI binding wins and takes effect immediately
  (per-request resolution, no restart), and clearing falls back to env
- PUT validates against the connected WeKnora instance (real knowledge
  base list via the scoped API key) and rejects same-KB bindings;
  saves require the admin role
- route/catalog capabilities now resolve through the binding so both
  annotation paths share one source of truth
- system settings > 服务配置 gains a 知识库绑定 panel: dropdown picker
  (or raw ID when WeKnora is unreachable) showing bound name, origin
  (UI vs env default) and last author
- contract tests: OpenAPI, handler matrix (fallback, validation,
  same-KB rejection, capability resolution), frontend fetch/save layer
This commit is contained in:
姚章浩
2026-09-14 14:45:35 +08:00
parent 4c86c5e659
commit 021e91eae4
17 changed files with 676 additions and 13 deletions
+68
View File
@@ -1127,6 +1127,74 @@
}
}
},
"/api/v1/routing-bindings": {
"get": {
"tags": [
"Settings"
],
"operationId": "getRoutingBindings",
"summary": "读取对内/对外知识库绑定",
"responses": {
"200": {
"$ref": "#/components/responses/Envelope"
},
"400": {
"$ref": "#/components/responses/BadRequest"
},
"500": {
"$ref": "#/components/responses/InternalError"
}
}
},
"put": {
"tags": [
"Settings"
],
"operationId": "saveRoutingBindings",
"summary": "绑定对内/对外知识库(管理员)",
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"type": "object"
}
}
}
},
"responses": {
"200": {
"$ref": "#/components/responses/Envelope"
},
"400": {
"$ref": "#/components/responses/BadRequest"
},
"500": {
"$ref": "#/components/responses/InternalError"
}
}
}
},
"/api/v1/routing-bindings/options": {
"get": {
"tags": [
"Settings"
],
"operationId": "listRoutingBindingOptions",
"summary": "列出可绑定的 WeKnora 知识库",
"responses": {
"200": {
"$ref": "#/components/responses/Envelope"
},
"400": {
"$ref": "#/components/responses/BadRequest"
},
"500": {
"$ref": "#/components/responses/InternalError"
}
}
}
},
"/api/v1/ui-settings": {
"get": {
"tags": [