WeKnora/website-docs/04-api/02-api-faq-wiki.md

502 lines
19 KiB
Markdown
Raw Normal View History

# API 参考:FAQ 与 Wiki
管理知识库中的 FAQ 条目与 Wiki 页面,支持导入、检索、编辑和版本恢复。
两组均为 KB 内容子资源:读为 Viewer+ 且 KB read(API key `retrieve`/full);写为“KB 创建者 OR Admin+”且 KB write(API key `ingest`/full),并受 KB 白名单约束。跨库 Wiki 搜索 `POST /wiki-search` 无路径 KB,Viewer+ 且 API key `retrieve`/full,handler 内校验每个目标库的 allow-list 与共享库 Viewer 权限。
## FAQ(/api/v1/knowledge-bases/:id/faq)
### GET /api/v1/knowledge-bases/:id/faq/entries
用途:FAQ 条目列表。
| 查询参数 | 类型 | 必填 | 说明 |
| --- | --- | --- | --- |
| `page` / `page_size` | int | 否 | 分页 |
| `tag_id` | int | 否 | 旧版单标签 seq_id |
| `tag_ids` | string | 否 | 逗号分隔标签 UUID |
| `keyword` | string | 否 | 关键字 |
| `search_field` | string | 否 | `standard_question`/`similar_questions`/`answers`(默认全字段) |
| `sort_order` | string | 否 | `asc`(默认按更新时间倒序) |
docs: sync website-docs, homepage and changelog for v0.8.2 (#3632) * docs: sync website-docs with changes since v0.8.0 Audit every change between v0.8.0 and the v0.8.2 release against the documentation site, adding what users and operators need and correcting statements that no longer match the code. - Add local browser (BrowserSkill), built-in MCP Server endpoints, the toolbox, conversation steer/fork/rewind and reasoning effort, the artifacts library, sandbox terminal and desktop, the Lite host sandbox, the rebuilt model catalog (including a protocol-compat field reference), Confluence and DingTalk Docs sources, Bocha/Serply search, per-channel IM locale, whitelist-only outbound, admin user creation, new configuration variables and migrations 000091-000110. - Fix wrong API examples and parameters (model type values, knowledge search params, FAQ match_count cap, Notion credentials), tenant deletion semantics, default timeouts, parser engine claims, removed tables and commands, stale navigation paths, and route locations after the router split into routes_*.go. - Add screenshots for the new pages and refresh outdated ones. * fix(frontend): link the protocol-compat field to its documentation The model editor told users to read catalog/compat.go on the backend, a path that no longer exists after the model catalog refactor. The hint now says when the override is needed and links to the field reference in website-docs/03-features/06-models.md; the config examples and the API type comment point to the same place. * feat(website): showcase v0.8.2 on the homepage - Add a v0.8.2 section for the local browser (BrowserSkill), the built-in MCP Server and conversation control, and turn the v0.8.0 release block into a standing skills & sandbox topic with the sandbox desktop and terminal. - Replace the three-up galleries with a feature list beside one large screenshot: every item's text stays visible, clicking an item or one of its views switches the image with a cross-fade, and the list plays itself while on screen until the visitor picks something. - Add Confluence, DingTalk, BrowserSkill and more model vendors to the integrations, bump the header badge to v0.8.2 and link the changelog. - check-site reports missing docs screenshots as pending instead of failing, since the Screenshot component renders a placeholder for them. * docs(changelog): add v0.8.2 release notes * docs(website): add per-version release notes pages Add a "版本发布" docs section with one page per release, starting with v0.8.2 and a backfilled v0.8.0. Each page walks through the highlights with the existing product screenshots, the other improvements and fixes, and an upgrade checklist with the actions each breaking change needs. The sidebar orders these pages by version, newest first; the docs header gains a 版本 entry, and the homepage's v0.8.2 section now links to the release notes page instead of the raw CHANGELOG. * feat(website): let the site image listen on a configurable port The Docker image hard-coded `listen 80`, so running it with host networking or on a platform that assigns the container port required editing the Nginx config and rebuilding. The image now renders its config from the official nginx template directory at startup and reads the listen port from `PORT` (default 80); deploy/nginx.conf stays a plain config for static deployments. test-docker starts a second container with PORT=8080 and checks the rendered config and that the site answers on that port; the README documents the variable. * fix(website): namespace the nginx listen port variable * fix(website): support bash-wrapped container startup * fix(website): align nginx startup with frontend entrypoint * fix(website): pin nginx runtime for older host compatibility * fix(website): bake the configured nginx port into the image
2026-09-24 03:26:34 +00:00
| `is_enabled` | bool | 否 | 按启用状态筛选:`true` 仅启用、`false` 仅停用,不传返回全部;其他取值返回 400 |
响应:200 `{"success":true,"data":{分页 FAQEntry 列表}}`
```bash
docs: sync website-docs, homepage and changelog for v0.8.2 (#3632) * docs: sync website-docs with changes since v0.8.0 Audit every change between v0.8.0 and the v0.8.2 release against the documentation site, adding what users and operators need and correcting statements that no longer match the code. - Add local browser (BrowserSkill), built-in MCP Server endpoints, the toolbox, conversation steer/fork/rewind and reasoning effort, the artifacts library, sandbox terminal and desktop, the Lite host sandbox, the rebuilt model catalog (including a protocol-compat field reference), Confluence and DingTalk Docs sources, Bocha/Serply search, per-channel IM locale, whitelist-only outbound, admin user creation, new configuration variables and migrations 000091-000110. - Fix wrong API examples and parameters (model type values, knowledge search params, FAQ match_count cap, Notion credentials), tenant deletion semantics, default timeouts, parser engine claims, removed tables and commands, stale navigation paths, and route locations after the router split into routes_*.go. - Add screenshots for the new pages and refresh outdated ones. * fix(frontend): link the protocol-compat field to its documentation The model editor told users to read catalog/compat.go on the backend, a path that no longer exists after the model catalog refactor. The hint now says when the override is needed and links to the field reference in website-docs/03-features/06-models.md; the config examples and the API type comment point to the same place. * feat(website): showcase v0.8.2 on the homepage - Add a v0.8.2 section for the local browser (BrowserSkill), the built-in MCP Server and conversation control, and turn the v0.8.0 release block into a standing skills & sandbox topic with the sandbox desktop and terminal. - Replace the three-up galleries with a feature list beside one large screenshot: every item's text stays visible, clicking an item or one of its views switches the image with a cross-fade, and the list plays itself while on screen until the visitor picks something. - Add Confluence, DingTalk, BrowserSkill and more model vendors to the integrations, bump the header badge to v0.8.2 and link the changelog. - check-site reports missing docs screenshots as pending instead of failing, since the Screenshot component renders a placeholder for them. * docs(changelog): add v0.8.2 release notes * docs(website): add per-version release notes pages Add a "版本发布" docs section with one page per release, starting with v0.8.2 and a backfilled v0.8.0. Each page walks through the highlights with the existing product screenshots, the other improvements and fixes, and an upgrade checklist with the actions each breaking change needs. The sidebar orders these pages by version, newest first; the docs header gains a 版本 entry, and the homepage's v0.8.2 section now links to the release notes page instead of the raw CHANGELOG. * feat(website): let the site image listen on a configurable port The Docker image hard-coded `listen 80`, so running it with host networking or on a platform that assigns the container port required editing the Nginx config and rebuilding. The image now renders its config from the official nginx template directory at startup and reads the listen port from `PORT` (default 80); deploy/nginx.conf stays a plain config for static deployments. test-docker starts a second container with PORT=8080 and checks the rendered config and that the site answers on that port; the README documents the variable. * fix(website): namespace the nginx listen port variable * fix(website): support bash-wrapped container startup * fix(website): align nginx startup with frontend entrypoint * fix(website): pin nginx runtime for older host compatibility * fix(website): bake the configured nginx port into the image
2026-09-24 03:26:34 +00:00
curl "$BASE/api/v1/knowledge-bases/kb-1/faq/entries?page=1&is_enabled=false" -H "Authorization: Bearer $TOKEN"
```
### GET /api/v1/knowledge-bases/:id/faq/entries/export
用途:导出 FAQ。查询参数:`format`(`csv` 默认 / `json`)。
响应:200 文件下载(`text/csv` 或 `application/json`)。
```bash
curl -OJ "$BASE/api/v1/knowledge-bases/kb-1/faq/entries/export?format=csv" -H "Authorization: Bearer $TOKEN"
```
### GET /api/v1/knowledge-bases/:id/faq/entries/:entry_id
用途:FAQ 条目详情(`entry_id` 为整数 seq_id)。
响应:200 `{"success":true,"data":{FAQEntry}}`
```bash
curl $BASE/api/v1/knowledge-bases/kb-1/faq/entries/12 -H "Authorization: Bearer $TOKEN"
```
### POST /api/v1/knowledge-bases/:id/faq/entries
用途:批量 upsert / 导入(异步任务)。Handler 方法 `UpsertEntries`。
| 字段 | 类型 | 必填 | 说明 |
| --- | --- | --- | --- |
| `entries` | []FAQEntryPayload | 是(`binding:"required"`) | 批量条目 |
| `mode` | string | 是(`binding:"oneof=append replace"`) | 追加或替换 |
| `knowledge_id` | string | 否 | FAQ 知识实体 ID |
docs: sync website-docs, homepage and changelog for v0.8.2 (#3632) * docs: sync website-docs with changes since v0.8.0 Audit every change between v0.8.0 and the v0.8.2 release against the documentation site, adding what users and operators need and correcting statements that no longer match the code. - Add local browser (BrowserSkill), built-in MCP Server endpoints, the toolbox, conversation steer/fork/rewind and reasoning effort, the artifacts library, sandbox terminal and desktop, the Lite host sandbox, the rebuilt model catalog (including a protocol-compat field reference), Confluence and DingTalk Docs sources, Bocha/Serply search, per-channel IM locale, whitelist-only outbound, admin user creation, new configuration variables and migrations 000091-000110. - Fix wrong API examples and parameters (model type values, knowledge search params, FAQ match_count cap, Notion credentials), tenant deletion semantics, default timeouts, parser engine claims, removed tables and commands, stale navigation paths, and route locations after the router split into routes_*.go. - Add screenshots for the new pages and refresh outdated ones. * fix(frontend): link the protocol-compat field to its documentation The model editor told users to read catalog/compat.go on the backend, a path that no longer exists after the model catalog refactor. The hint now says when the override is needed and links to the field reference in website-docs/03-features/06-models.md; the config examples and the API type comment point to the same place. * feat(website): showcase v0.8.2 on the homepage - Add a v0.8.2 section for the local browser (BrowserSkill), the built-in MCP Server and conversation control, and turn the v0.8.0 release block into a standing skills & sandbox topic with the sandbox desktop and terminal. - Replace the three-up galleries with a feature list beside one large screenshot: every item's text stays visible, clicking an item or one of its views switches the image with a cross-fade, and the list plays itself while on screen until the visitor picks something. - Add Confluence, DingTalk, BrowserSkill and more model vendors to the integrations, bump the header badge to v0.8.2 and link the changelog. - check-site reports missing docs screenshots as pending instead of failing, since the Screenshot component renders a placeholder for them. * docs(changelog): add v0.8.2 release notes * docs(website): add per-version release notes pages Add a "版本发布" docs section with one page per release, starting with v0.8.2 and a backfilled v0.8.0. Each page walks through the highlights with the existing product screenshots, the other improvements and fixes, and an upgrade checklist with the actions each breaking change needs. The sidebar orders these pages by version, newest first; the docs header gains a 版本 entry, and the homepage's v0.8.2 section now links to the release notes page instead of the raw CHANGELOG. * feat(website): let the site image listen on a configurable port The Docker image hard-coded `listen 80`, so running it with host networking or on a platform that assigns the container port required editing the Nginx config and rebuilding. The image now renders its config from the official nginx template directory at startup and reads the listen port from `PORT` (default 80); deploy/nginx.conf stays a plain config for static deployments. test-docker starts a second container with PORT=8080 and checks the rendered config and that the site answers on that port; the README documents the variable. * fix(website): namespace the nginx listen port variable * fix(website): support bash-wrapped container startup * fix(website): align nginx startup with frontend entrypoint * fix(website): pin nginx runtime for older host compatibility * fix(website): bake the configured nginx port into the image
2026-09-24 03:26:34 +00:00
| `task_id` | string | 否 | 自定义任务 ID,仅允许字母、数字、`_`、`-`,最长 128 字符,否则返回 400 |
| `dry_run` | bool | 否 | 仅校验不落库 |
响应:200 `{"success":true,"data":{"task_id"}}`
```bash
curl -X POST $BASE/api/v1/knowledge-bases/kb-1/faq/entries -H "X-API-Key: $API_KEY" \
-H 'Content-Type: application/json' \
-d '{"mode":"append","entries":[{"standard_question":"如何退款?","answers":["联系客服"]}]}'
```
### POST /api/v1/knowledge-bases/:id/faq/entry
用途:创建单条 FAQ。请求体(`types.FAQEntryPayload`):
| 字段 | 类型 | 必填 | 说明 |
| --- | --- | --- | --- |
| `standard_question` | string | 是(`binding:"required"`) | 标准问 |
| `similar_questions` | []string | 否 | 相似问 |
| `negative_questions` | []string | 否 | 负样例问 |
| `answers` | []string | 否 | 答案列表 |
| `answer_strategy` | string | 否 | `all` / `random` |
| `tag_id` | int64 | 否 | 标签 seq_id |
| `tag_name` | string | 否 | 标签名 |
| `is_enabled` / `is_recommended` | *bool | 否 | 启用/推荐 |
响应:200 `{"success":true,"data":{FAQEntry}}`
```bash
curl -X POST $BASE/api/v1/knowledge-bases/kb-1/faq/entry -H "Authorization: Bearer $TOKEN" \
-H 'Content-Type: application/json' -d '{"standard_question":"如何退款?","answers":["7 天内可退"]}'
```
### PUT /api/v1/knowledge-bases/:id/faq/entries/:entry_id
用途:更新单条 FAQ(请求体同创建)。
响应:200 `{"success":true,"data":{FAQEntry}}`
```bash
curl -X PUT $BASE/api/v1/knowledge-bases/kb-1/faq/entries/12 -H "Authorization: Bearer $TOKEN" \
-H 'Content-Type: application/json' -d '{"standard_question":"如何退款?","answers":["30 天内可退"]}'
```
### POST /api/v1/knowledge-bases/:id/faq/entries/:entry_id/similar-questions
用途:追加相似问。请求体:`{"similar_questions":["..."]}`(`binding:"required,min=1"`)。
响应:200 `{"success":true,"data":{FAQEntry}}`
```bash
curl -X POST $BASE/api/v1/knowledge-bases/kb-1/faq/entries/12/similar-questions \
-H "Authorization: Bearer $TOKEN" -H 'Content-Type: application/json' \
-d '{"similar_questions":["退款怎么操作"]}'
```
### PUT /api/v1/knowledge-bases/:id/faq/entries/fields
用途:批量更新条目字段(`is_enabled`/`is_recommended`/`tag_id`)。
| 字段 | 类型 | 必填 | 说明 |
| --- | --- | --- | --- |
| `by_id` | map[int64]object | 否 | 按条目 seq_id 更新 |
| `by_tag` | map[int64]object | 否 | 按标签批量更新 |
| `exclude_ids` | []int64 | 否 | `by_tag` 时排除的条目 |
响应:200 `{"success":true}`
```bash
curl -X PUT $BASE/api/v1/knowledge-bases/kb-1/faq/entries/fields -H "Authorization: Bearer $TOKEN" \
-H 'Content-Type: application/json' -d '{"by_id":{"12":{"is_enabled":false}}}'
```
### PUT /api/v1/knowledge-bases/:id/faq/entries/tags
用途:批量改条目标签。请求体:`{"updates":{"<entry_id>":<tag_id|null>}}`(`binding:"required,min=1"`;null 移除标签)。
响应:200 `{"success":true}`
```bash
curl -X PUT $BASE/api/v1/knowledge-bases/kb-1/faq/entries/tags -H "Authorization: Bearer $TOKEN" \
-H 'Content-Type: application/json' -d '{"updates":{"12":3}}'
```
### DELETE /api/v1/knowledge-bases/:id/faq/entries
用途:批量删除条目。请求体:`{"ids":[int64]}`(`binding:"required,min=1"`)。
响应:200 `{"success":true}`
```bash
curl -X DELETE $BASE/api/v1/knowledge-bases/kb-1/faq/entries -H "Authorization: Bearer $TOKEN" \
-H 'Content-Type: application/json' -d '{"ids":[12,13]}'
```
### POST /api/v1/knowledge-bases/:id/faq/search
用途:FAQ 检索(只读语义,scoped key 用 `retrieve` 亦可调用)。
| 字段 | 类型 | 必填 | 说明 |
| --- | --- | --- | --- |
| `query_text` | string | 是(`binding:"required"`) | 查询 |
docs: sync website-docs, homepage and changelog for v0.8.2 (#3632) * docs: sync website-docs with changes since v0.8.0 Audit every change between v0.8.0 and the v0.8.2 release against the documentation site, adding what users and operators need and correcting statements that no longer match the code. - Add local browser (BrowserSkill), built-in MCP Server endpoints, the toolbox, conversation steer/fork/rewind and reasoning effort, the artifacts library, sandbox terminal and desktop, the Lite host sandbox, the rebuilt model catalog (including a protocol-compat field reference), Confluence and DingTalk Docs sources, Bocha/Serply search, per-channel IM locale, whitelist-only outbound, admin user creation, new configuration variables and migrations 000091-000110. - Fix wrong API examples and parameters (model type values, knowledge search params, FAQ match_count cap, Notion credentials), tenant deletion semantics, default timeouts, parser engine claims, removed tables and commands, stale navigation paths, and route locations after the router split into routes_*.go. - Add screenshots for the new pages and refresh outdated ones. * fix(frontend): link the protocol-compat field to its documentation The model editor told users to read catalog/compat.go on the backend, a path that no longer exists after the model catalog refactor. The hint now says when the override is needed and links to the field reference in website-docs/03-features/06-models.md; the config examples and the API type comment point to the same place. * feat(website): showcase v0.8.2 on the homepage - Add a v0.8.2 section for the local browser (BrowserSkill), the built-in MCP Server and conversation control, and turn the v0.8.0 release block into a standing skills & sandbox topic with the sandbox desktop and terminal. - Replace the three-up galleries with a feature list beside one large screenshot: every item's text stays visible, clicking an item or one of its views switches the image with a cross-fade, and the list plays itself while on screen until the visitor picks something. - Add Confluence, DingTalk, BrowserSkill and more model vendors to the integrations, bump the header badge to v0.8.2 and link the changelog. - check-site reports missing docs screenshots as pending instead of failing, since the Screenshot component renders a placeholder for them. * docs(changelog): add v0.8.2 release notes * docs(website): add per-version release notes pages Add a "版本发布" docs section with one page per release, starting with v0.8.2 and a backfilled v0.8.0. Each page walks through the highlights with the existing product screenshots, the other improvements and fixes, and an upgrade checklist with the actions each breaking change needs. The sidebar orders these pages by version, newest first; the docs header gains a 版本 entry, and the homepage's v0.8.2 section now links to the release notes page instead of the raw CHANGELOG. * feat(website): let the site image listen on a configurable port The Docker image hard-coded `listen 80`, so running it with host networking or on a platform that assigns the container port required editing the Nginx config and rebuilding. The image now renders its config from the official nginx template directory at startup and reads the listen port from `PORT` (default 80); deploy/nginx.conf stays a plain config for static deployments. test-docker starts a second container with PORT=8080 and checks the rendered config and that the site answers on that port; the README documents the variable. * fix(website): namespace the nginx listen port variable * fix(website): support bash-wrapped container startup * fix(website): align nginx startup with frontend entrypoint * fix(website): pin nginx runtime for older host compatibility * fix(website): bake the configured nginx port into the image
2026-09-24 03:26:34 +00:00
| `vector_threshold` | float64 | 否 | 向量阈值,默认 0.7 |
| `match_count` | int | 否 | 默认 10,上限 50 |
| `first_priority_tag_ids` / `second_priority_tag_ids` | []int64 | 否 | 标签优先级过滤 |
| `only_recommended` | bool | 否 | 仅推荐条目 |
响应:200 `{"success":true,"data":[FAQEntry(含 match_type/score)]}`
```bash
curl -X POST $BASE/api/v1/knowledge-bases/kb-1/faq/search -H "X-API-Key: $API_KEY" \
-H 'Content-Type: application/json' -d '{"query_text":"退款"}'
```
### PUT /api/v1/knowledge-bases/:id/faq/import/last-result/display
用途:设置最近一次导入结果面板的显示状态。请求体:`{"display_status":"open|close"}`(`binding:"required,oneof=open close"`)。
响应:200 `{"success":true}`
```bash
curl -X PUT $BASE/api/v1/knowledge-bases/kb-1/faq/import/last-result/display \
-H "Authorization: Bearer $TOKEN" -H 'Content-Type: application/json' -d '{"display_status":"close"}'
```
### GET /api/v1/faq/import/progress/:task_id
用途:查询 FAQ 导入/dry-run 进度(任务按空间隔离)。权限:Viewer+;API key `retrieve`/`ingest`/full。
响应:200 `{"success":true,"data":{status,progress,failed_entries,...}}`
```bash
curl $BASE/api/v1/faq/import/progress/task-1 -H "X-API-Key: $API_KEY"
```
## Wiki(/api/v1/knowledgebase/:kb_id/wiki)
注意此组前缀为 `/knowledgebase/:kb_id/wiki`(单数,无连字符)。Handler: `internal/handler/wiki_page.go`。本组响应多为**原始对象**(不带 `success` 包装)。
### GET /api/v1/knowledgebase/:kb_id/wiki/pages
用途:Wiki 页面列表。
| 查询参数 | 类型 | 必填 | 说明 |
| --- | --- | --- | --- |
| `page_type` | string | 否 | 逗号分隔类型 |
| `status` | string | 否 | 页面状态 |
| `query` | string | 否 | 全文搜索 |
| `category_path` | string | 否 | `/` 分隔路径过滤 |
| `folder_id` | string | 否 | 精确目录过滤(空串=根) |
| `category_depth` | int | 否 | 目录深度 |
| `page` / `page_size` | int | 否 | 分页(默认 1/20) |
docs: sync website-docs, homepage and changelog for v0.8.2 (#3632) * docs: sync website-docs with changes since v0.8.0 Audit every change between v0.8.0 and the v0.8.2 release against the documentation site, adding what users and operators need and correcting statements that no longer match the code. - Add local browser (BrowserSkill), built-in MCP Server endpoints, the toolbox, conversation steer/fork/rewind and reasoning effort, the artifacts library, sandbox terminal and desktop, the Lite host sandbox, the rebuilt model catalog (including a protocol-compat field reference), Confluence and DingTalk Docs sources, Bocha/Serply search, per-channel IM locale, whitelist-only outbound, admin user creation, new configuration variables and migrations 000091-000110. - Fix wrong API examples and parameters (model type values, knowledge search params, FAQ match_count cap, Notion credentials), tenant deletion semantics, default timeouts, parser engine claims, removed tables and commands, stale navigation paths, and route locations after the router split into routes_*.go. - Add screenshots for the new pages and refresh outdated ones. * fix(frontend): link the protocol-compat field to its documentation The model editor told users to read catalog/compat.go on the backend, a path that no longer exists after the model catalog refactor. The hint now says when the override is needed and links to the field reference in website-docs/03-features/06-models.md; the config examples and the API type comment point to the same place. * feat(website): showcase v0.8.2 on the homepage - Add a v0.8.2 section for the local browser (BrowserSkill), the built-in MCP Server and conversation control, and turn the v0.8.0 release block into a standing skills & sandbox topic with the sandbox desktop and terminal. - Replace the three-up galleries with a feature list beside one large screenshot: every item's text stays visible, clicking an item or one of its views switches the image with a cross-fade, and the list plays itself while on screen until the visitor picks something. - Add Confluence, DingTalk, BrowserSkill and more model vendors to the integrations, bump the header badge to v0.8.2 and link the changelog. - check-site reports missing docs screenshots as pending instead of failing, since the Screenshot component renders a placeholder for them. * docs(changelog): add v0.8.2 release notes * docs(website): add per-version release notes pages Add a "版本发布" docs section with one page per release, starting with v0.8.2 and a backfilled v0.8.0. Each page walks through the highlights with the existing product screenshots, the other improvements and fixes, and an upgrade checklist with the actions each breaking change needs. The sidebar orders these pages by version, newest first; the docs header gains a 版本 entry, and the homepage's v0.8.2 section now links to the release notes page instead of the raw CHANGELOG. * feat(website): let the site image listen on a configurable port The Docker image hard-coded `listen 80`, so running it with host networking or on a platform that assigns the container port required editing the Nginx config and rebuilding. The image now renders its config from the official nginx template directory at startup and reads the listen port from `PORT` (default 80); deploy/nginx.conf stays a plain config for static deployments. test-docker starts a second container with PORT=8080 and checks the rendered config and that the site answers on that port; the README documents the variable. * fix(website): namespace the nginx listen port variable * fix(website): support bash-wrapped container startup * fix(website): align nginx startup with frontend entrypoint * fix(website): pin nginx runtime for older host compatibility * fix(website): bake the configured nginx port into the image
2026-09-24 03:26:34 +00:00
| `sort_by` / `sort_order` | string | 否 | 排序字段:`title`、`created_at`、`updated_at`、`page_type`、`wiki_path`、`sort_order`、`depth`,其他值按 `updated_at`;默认 `updated_at` desc |
响应:200 `WikiPageListResponse`
```bash
curl "$BASE/api/v1/knowledgebase/kb-1/wiki/pages?page=1" -H "Authorization: Bearer $TOKEN"
```
### POST /api/v1/knowledgebase/:kb_id/wiki/pages
用途:创建页面。请求体(`types.WikiPage`):`slug`、`title`、`content`、`folder_id`、`page_type` 等(均可选,slug 缺省自动生成)。
响应:201 `WikiPage`
```bash
curl -X POST $BASE/api/v1/knowledgebase/kb-1/wiki/pages -H "Authorization: Bearer $TOKEN" \
-H 'Content-Type: application/json' -d '{"title":"架构概览","content":"# 概览"}'
```
### PUT /api/v1/knowledgebase/:kb_id/wiki/move-page
用途:移动页面到目录。请求体:`{"slug":"<页面slug>","folder_id":"<目录ID|空=根>"}`(slug 必填)。
响应:200 `WikiPage`
```bash
curl -X PUT $BASE/api/v1/knowledgebase/kb-1/wiki/move-page -H "Authorization: Bearer $TOKEN" \
-H 'Content-Type: application/json' -d '{"slug":"overview","folder_id":"f-1"}'
```
### GET /api/v1/knowledgebase/:kb_id/wiki/pages/*slug
用途:获取页面(`*slug` 为通配路径)。
响应:200 `WikiPage`
```bash
curl $BASE/api/v1/knowledgebase/kb-1/wiki/pages/overview -H "Authorization: Bearer $TOKEN"
```
### PUT /api/v1/knowledgebase/:kb_id/wiki/pages/*slug
用途:更新页面(请求体同创建)。旧版本会先整份快照进 `wiki_page_revisions`,`version` 递增,`last_edit_source` 记为 `user`(Agent 工具写入时为 `agent`)。
响应:200 `WikiPage`
```bash
curl -X PUT $BASE/api/v1/knowledgebase/kb-1/wiki/pages/overview -H "Authorization: Bearer $TOKEN" \
-H 'Content-Type: application/json' -d '{"content":"# 更新后的概览"}'
```
### GET /api/v1/knowledgebase/:kb_id/wiki/revisions/*slug
用途:页面版本历史(migration `000075`)。权限:Viewer+ + KBAccessRead。
| 查询参数 | 类型 | 必填 | 说明 |
| --- | --- | --- | --- |
docs: sync website-docs, homepage and changelog for v0.8.2 (#3632) * docs: sync website-docs with changes since v0.8.0 Audit every change between v0.8.0 and the v0.8.2 release against the documentation site, adding what users and operators need and correcting statements that no longer match the code. - Add local browser (BrowserSkill), built-in MCP Server endpoints, the toolbox, conversation steer/fork/rewind and reasoning effort, the artifacts library, sandbox terminal and desktop, the Lite host sandbox, the rebuilt model catalog (including a protocol-compat field reference), Confluence and DingTalk Docs sources, Bocha/Serply search, per-channel IM locale, whitelist-only outbound, admin user creation, new configuration variables and migrations 000091-000110. - Fix wrong API examples and parameters (model type values, knowledge search params, FAQ match_count cap, Notion credentials), tenant deletion semantics, default timeouts, parser engine claims, removed tables and commands, stale navigation paths, and route locations after the router split into routes_*.go. - Add screenshots for the new pages and refresh outdated ones. * fix(frontend): link the protocol-compat field to its documentation The model editor told users to read catalog/compat.go on the backend, a path that no longer exists after the model catalog refactor. The hint now says when the override is needed and links to the field reference in website-docs/03-features/06-models.md; the config examples and the API type comment point to the same place. * feat(website): showcase v0.8.2 on the homepage - Add a v0.8.2 section for the local browser (BrowserSkill), the built-in MCP Server and conversation control, and turn the v0.8.0 release block into a standing skills & sandbox topic with the sandbox desktop and terminal. - Replace the three-up galleries with a feature list beside one large screenshot: every item's text stays visible, clicking an item or one of its views switches the image with a cross-fade, and the list plays itself while on screen until the visitor picks something. - Add Confluence, DingTalk, BrowserSkill and more model vendors to the integrations, bump the header badge to v0.8.2 and link the changelog. - check-site reports missing docs screenshots as pending instead of failing, since the Screenshot component renders a placeholder for them. * docs(changelog): add v0.8.2 release notes * docs(website): add per-version release notes pages Add a "版本发布" docs section with one page per release, starting with v0.8.2 and a backfilled v0.8.0. Each page walks through the highlights with the existing product screenshots, the other improvements and fixes, and an upgrade checklist with the actions each breaking change needs. The sidebar orders these pages by version, newest first; the docs header gains a 版本 entry, and the homepage's v0.8.2 section now links to the release notes page instead of the raw CHANGELOG. * feat(website): let the site image listen on a configurable port The Docker image hard-coded `listen 80`, so running it with host networking or on a platform that assigns the container port required editing the Nginx config and rebuilding. The image now renders its config from the official nginx template directory at startup and reads the listen port from `PORT` (default 80); deploy/nginx.conf stays a plain config for static deployments. test-docker starts a second container with PORT=8080 and checks the rendered config and that the site answers on that port; the README documents the variable. * fix(website): namespace the nginx listen port variable * fix(website): support bash-wrapped container startup * fix(website): align nginx startup with frontend entrypoint * fix(website): pin nginx runtime for older host compatibility * fix(website): bake the configured nginx port into the image
2026-09-24 03:26:34 +00:00
| `version` | int | 否 | 传入时返回**该版本全文**(用于 diff),无效或 < 1 返回 400,找不到返回 404(升级前写入的版本或已被保留策略清理的快照都没有全文,属正常情况) |
| `limit` | int | 否 | 默认 50,上限 200;仅列表模式生效 |
| `offset` | int | 否 | 分页偏移 |
不带 `version` 时返回历史列表(版本号倒序、**不含正文**)加上页面当前版本号;每条含 `edit_source`(`pipeline` / `agent` / `user` / `revert`)、`editor_id`、`edited_at`。
历史保留是两级上限:软上限 50 版只裁剪 `pipeline` 与空来源的快照,硬上限 200 版对所有来源生效,因此人工编辑不会被管道刷掉。
```bash
# 历史列表
curl $BASE/api/v1/knowledgebase/kb-1/wiki/revisions/entity/acme-corp -H "Authorization: Bearer $TOKEN"
# 取第 3 版全文
curl "$BASE/api/v1/knowledgebase/kb-1/wiki/revisions/entity/acme-corp?version=3" -H "Authorization: Bearer $TOKEN"
```
### POST /api/v1/knowledgebase/:kb_id/wiki/revert
用途:把页面回滚到某个历史版本。权限:KB owner 或 Admin+ + KBAccessWrite。
| 字段 | 类型 | 必填 | 说明 |
| --- | --- | --- | --- |
| `slug` | string | 是 | 目标页面 |
| `version` | int | 是 | 目标版本号(≥ 1) |
回滚**不会把版本号退回去**:目标版本的内容会作为一个新版本写入,`last_edit_source` 记为 `revert`,所以回滚也能被回滚。回滚到当前版本返回 400(一般是前端历史列表过期)。
响应:200 `WikiPage`
```bash
curl -X POST $BASE/api/v1/knowledgebase/kb-1/wiki/revert -H "Authorization: Bearer $TOKEN" \
-H 'Content-Type: application/json' -d '{"slug":"entity/acme-corp","version":3}'
```
### DELETE /api/v1/knowledgebase/:kb_id/wiki/pages/*slug
用途:删除页面。
响应:204 No Content
```bash
curl -X DELETE $BASE/api/v1/knowledgebase/kb-1/wiki/pages/overview -H "Authorization: Bearer $TOKEN"
```
### GET /api/v1/knowledgebase/:kb_id/wiki/folders
用途:目录列表。查询参数:`parent_id`(空=根)、`page_types`(逗号分隔)。
响应:200 `WikiFolderListResponse`
```bash
curl $BASE/api/v1/knowledgebase/kb-1/wiki/folders -H "Authorization: Bearer $TOKEN"
```
### POST /api/v1/knowledgebase/:kb_id/wiki/folders
用途:创建目录。
| 字段 | 类型 | 必填 | 说明 |
| --- | --- | --- | --- |
| `name` | string | 是 | 目录名 |
| `parent_id` | string | 否 | 父目录 |
响应:201 `WikiFolder`
```bash
curl -X POST $BASE/api/v1/knowledgebase/kb-1/wiki/folders -H "Authorization: Bearer $TOKEN" \
-H 'Content-Type: application/json' -d '{"name":"设计文档"}'
```
### PUT /api/v1/knowledgebase/:kb_id/wiki/folders/:folder_id
用途:重命名/移动目录。请求体:`name`、`parent_id`、`move_parent`(bool),均可选。
响应:200 `WikiFolder`
```bash
curl -X PUT $BASE/api/v1/knowledgebase/kb-1/wiki/folders/f-1 -H "Authorization: Bearer $TOKEN" \
-H 'Content-Type: application/json' -d '{"name":"架构设计"}'
```
### DELETE /api/v1/knowledgebase/:kb_id/wiki/folders/:folder_id
用途:删除目录。
响应:204 No Content
```bash
curl -X DELETE $BASE/api/v1/knowledgebase/kb-1/wiki/folders/f-1 -H "Authorization: Bearer $TOKEN"
```
### GET /api/v1/knowledgebase/:kb_id/wiki/index
用途:Wiki 索引页(按类型分组窗口)。查询参数:`types`(逗号分隔)、`limit`(1-200,默认 50)、`cursor`(游标)。
响应:200 `WikiIndexResponse`
```bash
curl $BASE/api/v1/knowledgebase/kb-1/wiki/index -H "Authorization: Bearer $TOKEN"
```
::: warning 已移除
`GET /api/v1/knowledgebase/:kb_id/wiki/log`(Wiki 变更日志)已随 migration `000077_remove_wiki_log` 一并下线,`wiki_log_entries` 表被删除。Wiki 变更现在统一投影到知识库活动流,改用 `GET /api/v1/knowledge-bases/:id/activity`。
:::
### GET /api/v1/knowledgebase/:kb_id/wiki/graph
用途:页面关系图。
| 查询参数 | 类型 | 必填 | 说明 |
| --- | --- | --- | --- |
| `mode` | string | 否 | `overview`(默认)/ `ego` |
| `center` | string | 否 | ego 模式中心 slug(ego 时必填) |
| `depth` | int | 否 | 1-3,默认 1 |
| `types` | string | 否 | page_type 过滤 |
| `limit` | int | 否 | 默认 500,上限 2000 |
响应:200 `WikiGraphData`
```bash
curl "$BASE/api/v1/knowledgebase/kb-1/wiki/graph?mode=overview" -H "Authorization: Bearer $TOKEN"
```
### GET /api/v1/knowledgebase/:kb_id/wiki/stats
用途:Wiki 统计。
响应:200 `WikiStats`
```bash
curl $BASE/api/v1/knowledgebase/kb-1/wiki/stats -H "Authorization: Bearer $TOKEN"
```
### GET /api/v1/knowledgebase/:kb_id/wiki/search
用途:页面搜索。查询参数:`q`(必填)、`limit`(默认 10)。
匹配语义随存储方言变化:
- Postgres:`q` 按 POSIX 正则(`~*`,大小写不敏感)匹配。
- SQLite / Lite:按 `LIKE` 字面子串匹配;`%` / `_` 会转义,不当通配符。
响应:200 `{"pages":[WikiPage]}`
```bash
curl "$BASE/api/v1/knowledgebase/kb-1/wiki/search?q=部署" -H "Authorization: Bearer $TOKEN"
```
### POST /api/v1/wiki-search
用途:跨知识库 Wiki 页面搜索(无会话、非混合检索)。Handler: `internal/handler/wiki_page.go` 的 `SearchPagesAcross`。算法与单库 `GET .../wiki/search` 相同(标题 > slug > summary > 正文),对多个库做一次查询后按 `match_rank` 全局截断。API key:`retrieve`/full。
| 字段 | 类型 | 必填 | 说明 |
| --- | --- | --- | --- |
| `query` | string | 是(`binding:"required"`) | 与单库 `q` 相同:Postgres 为 POSIX 正则(大小写不敏感);SQLite / Lite 为字面 `LIKE` 子串 |
| `knowledge_base_ids` | []string | 条件必填 | 多库;与 `knowledge_base_id` 至少提供一个,最多 32 个 |
| `knowledge_base_id` | string | 否 | 单库兼容字段,合并进 ids |
| `limit` | int | 否 | 全局 top-N,默认 10,最大 50 |
任一目标库未开启 wiki → 400。库不存在或无读权限 → 404。API Key 白名单越权 → 403。非法正则(Postgres)→ 400。
响应:200 `{"success":true,"data":[WikiSearchHit]}`。命中只含导航字段 + `match_snippet`,不含正文;全文用 `GET /knowledgebase/:kb_id/wiki/pages/{slug}`。
| 响应字段 | 类型 | 说明 |
| --- | --- | --- |
| `id` | string | 页面 ID |
| `knowledge_base_id` | string | 来源库,跨库时用来拼读页 URL |
| `slug` | string | 页面 slug |
| `title` | string | 标题 |
| `page_type` | string | 页面类型 |
| `aliases` | []string | 别名 |
| `summary` | string | 摘要 |
| `match_snippet` | string | 正文中首次命中附近约 60+命中+60 字;无正文命中时省略。snippet 仍用 Go 正则编译 `query`;SQLite 下 `query` 含正则元字符时库内可命中、snippet 可能为空 |
`content`、树/链接/元数据、时间戳不在搜索结果里。单库 `GET .../wiki/search` 仍返回完整 `WikiPage`。
```bash
curl -X POST $BASE/api/v1/wiki-search -H "X-API-Key: $API_KEY" \
-H 'Content-Type: application/json' \
-d '{"query":"部署|发布","knowledge_base_ids":["kb-1","kb-2"],"limit":10}'
```
### POST /api/v1/knowledgebase/:kb_id/wiki/rebuild-links
用途:重建页面互链。写权限。无请求体。
响应:200 `{"message":"Links rebuilt successfully"}`
```bash
curl -X POST $BASE/api/v1/knowledgebase/kb-1/wiki/rebuild-links -H "Authorization: Bearer $TOKEN"
```
### GET /api/v1/knowledgebase/:kb_id/wiki/lint
用途:Wiki 一致性检查报告。
响应:200 `WikiLintReport`
```bash
curl $BASE/api/v1/knowledgebase/kb-1/wiki/lint -H "Authorization: Bearer $TOKEN"
```
### POST /api/v1/knowledgebase/:kb_id/wiki/auto-fix
用途:自动修复 lint 问题。写权限。无请求体。
响应:200 `{"fixed":N,"message":"Auto-fixed N issues"}`
```bash
curl -X POST $BASE/api/v1/knowledgebase/kb-1/wiki/auto-fix -H "Authorization: Bearer $TOKEN"
```
### GET /api/v1/knowledgebase/:kb_id/wiki/issues
用途:问题列表。查询参数:`slug`(按页面过滤)、`status`(`pending/ignored/resolved`)。
响应:200 `[WikiPageIssue]`
```bash
curl $BASE/api/v1/knowledgebase/kb-1/wiki/issues -H "Authorization: Bearer $TOKEN"
```
### PUT /api/v1/knowledgebase/:kb_id/wiki/issues/:issue_id/status
fix(security): close the low-severity shared-space findings (#3416) * fix(security): close the low-severity shared-space findings Verified and fixed from the shared-space permission review: - Embed channels kept knowledge_ids, tag_ids, mentioned_items, skill_names and summary_model_id from anonymous visitors. Mentions are only scoped for shared agents, so a visitor could query any KB (and pick any model) of the channel workspace by ID. The payload now drops them; the widget never sends them. - PUT /knowledgebase/:kb_id/wiki/issues/:issue_id/status updated any issue by ID. The update is now scoped to the path's KB (404 otherwise). - A direct org invite let the inviter attach any user of the target workspace (or any user by ID) as its representative, whose username and email the roster then showed to all members. Direct adds attach no representative, and the roster returns emails only for the caller's own workspace. - COS and KS3 dropped the bucket (and COS the region) segment when turning a path into an object key, while the tenant check scans every segment: cos://42/<region>/prefix/7/... passed as tenant 42 and read tenant 7's object from a shared bucket. Both must now match the service's config. - Shared agent listings returned the full agent to receivers. Prompts and the creator's user ID are withheld; capabilities and scope stay visible. - Temporary document uploads let the caller pick the parser engine (and its credentials) of a shared agent's workspace; only the agent's rules choose one there now. - Suggested questions used request / message-snapshot knowledge_ids without a permission check. Each document is now resolved to its KB and checked like KB IDs, including a shared agent's scope. - IM channels accepted any knowledge_base_id (and any agent ID on create). Both must belong to the channel's workspace, the KB also to a restricted API key's allow-list. - KB-restricted API keys could list org-shared KBs outside their allow-list in the organization views; those listings are now filtered. - With enable_rbac=false, RequireKBAccess let cross-workspace denials through. That switch is for roles inside a workspace; the guard now always denies another workspace's KB, since handlers behind it load by ID without a tenant filter. - The org member limit was counted before and enforced apart from the insert; it is now checked in the insert's transaction with the organization row locked (SQLite serializes writers instead). - The UpdateOrganization route comment and API doc said owner-only; the service and UI allow org admins. Comment and doc corrected. Documented, not changed: issued /r/ and presigned links stay valid until they expire after a share is revoked. * fix(security): address review of the low-severity shared-space fixes - Embed payloads also drop question_origin. It selects a KB like an @mention for agents that retrieve only when mentioned, and the widget never sends it; the selection stays inside the agent's scope, but an anonymous visitor should not pick among its KBs. suggestion_attribution is kept (the widget sends it and it is validated). - The receiver view of a shared agent also withholds the follow-up suggestion instruction, a prompt like the others. Starter questions are shown to receivers anyway, and the sharer's name is displayed by design. - Follow-up suggestion generation moves into the agent's workspace with types.WithExecutionTenant instead of a bare tenant rewrite, so the caller is pinned before the document permission check runs. The auth middleware and the shared run already pinned it; this removes the dependency on that. - KS3 CopyFile copies only from the service's own bucket (as COS and S3 do); another bucket's path is a cross-backend copy. Tests cover the dropped question_origin, the follow-up instruction and the /shared-agents listing, a follow-up context with the tenant switched, a repeated wiki issue status update, and the KS3 copy source.
2026-09-18 14:58:46 +00:00
用途:更新问题状态。写权限。请求体:`{"status":"pending|ignored|resolved"}`(`binding:"required"`)。`issue_id` 必须属于路径中的知识库,否则 404。
响应:200 `{"message":"Issue status updated successfully"}`
```bash
curl -X PUT $BASE/api/v1/knowledgebase/kb-1/wiki/issues/i-1/status -H "Authorization: Bearer $TOKEN" \
-H 'Content-Type: application/json' -d '{"status":"resolved"}'
```
## 实现参考
docs: sync website-docs, homepage and changelog for v0.8.2 (#3632) * docs: sync website-docs with changes since v0.8.0 Audit every change between v0.8.0 and the v0.8.2 release against the documentation site, adding what users and operators need and correcting statements that no longer match the code. - Add local browser (BrowserSkill), built-in MCP Server endpoints, the toolbox, conversation steer/fork/rewind and reasoning effort, the artifacts library, sandbox terminal and desktop, the Lite host sandbox, the rebuilt model catalog (including a protocol-compat field reference), Confluence and DingTalk Docs sources, Bocha/Serply search, per-channel IM locale, whitelist-only outbound, admin user creation, new configuration variables and migrations 000091-000110. - Fix wrong API examples and parameters (model type values, knowledge search params, FAQ match_count cap, Notion credentials), tenant deletion semantics, default timeouts, parser engine claims, removed tables and commands, stale navigation paths, and route locations after the router split into routes_*.go. - Add screenshots for the new pages and refresh outdated ones. * fix(frontend): link the protocol-compat field to its documentation The model editor told users to read catalog/compat.go on the backend, a path that no longer exists after the model catalog refactor. The hint now says when the override is needed and links to the field reference in website-docs/03-features/06-models.md; the config examples and the API type comment point to the same place. * feat(website): showcase v0.8.2 on the homepage - Add a v0.8.2 section for the local browser (BrowserSkill), the built-in MCP Server and conversation control, and turn the v0.8.0 release block into a standing skills & sandbox topic with the sandbox desktop and terminal. - Replace the three-up galleries with a feature list beside one large screenshot: every item's text stays visible, clicking an item or one of its views switches the image with a cross-fade, and the list plays itself while on screen until the visitor picks something. - Add Confluence, DingTalk, BrowserSkill and more model vendors to the integrations, bump the header badge to v0.8.2 and link the changelog. - check-site reports missing docs screenshots as pending instead of failing, since the Screenshot component renders a placeholder for them. * docs(changelog): add v0.8.2 release notes * docs(website): add per-version release notes pages Add a "版本发布" docs section with one page per release, starting with v0.8.2 and a backfilled v0.8.0. Each page walks through the highlights with the existing product screenshots, the other improvements and fixes, and an upgrade checklist with the actions each breaking change needs. The sidebar orders these pages by version, newest first; the docs header gains a 版本 entry, and the homepage's v0.8.2 section now links to the release notes page instead of the raw CHANGELOG. * feat(website): let the site image listen on a configurable port The Docker image hard-coded `listen 80`, so running it with host networking or on a platform that assigns the container port required editing the Nginx config and rebuilding. The image now renders its config from the official nginx template directory at startup and reads the listen port from `PORT` (default 80); deploy/nginx.conf stays a plain config for static deployments. test-docker starts a second container with PORT=8080 and checks the rendered config and that the site answers on that port; the README documents the variable. * fix(website): namespace the nginx listen port variable * fix(website): support bash-wrapped container startup * fix(website): align nginx startup with frontend entrypoint * fix(website): pin nginx runtime for older host compatibility * fix(website): bake the configured nginx port into the image
2026-09-24 03:26:34 +00:00
路由注册:`internal/router/routes_knowledge.go` 的 `RegisterFAQRoutes` 与 `RegisterWikiPageRoutes`。Handler:`internal/handler/faq.go`、`internal/handler/wiki_page.go`。