diff --git a/client/README.md b/client/README.md index d832a35a..cd9ac297 100644 --- a/client/README.md +++ b/client/README.md @@ -391,7 +391,7 @@ if err != nil { ```go skillID, err := apiClient.InstallSandboxSkillFromSource( - context.Background(), sandboxConfigID, "@owner/slug", "") + context.Background(), sandboxConfigID, "@owner/slug") if err != nil { // 处理错误 } diff --git a/client/README_EN.md b/client/README_EN.md index 63700654..6c676018 100644 --- a/client/README_EN.md +++ b/client/README_EN.md @@ -204,7 +204,7 @@ if err != nil { ```go skillID, err := apiClient.InstallSandboxSkillFromSource( - context.Background(), sandboxConfigID, "@owner/slug", "") + context.Background(), sandboxConfigID, "@owner/slug") if err != nil { // Handle error } diff --git a/client/skill.go b/client/skill.go index 2d180bdf..d2f93e5a 100644 --- a/client/skill.go +++ b/client/skill.go @@ -53,17 +53,15 @@ func (c *Client) ListSkills(ctx context.Context, sandboxConfigID string) ([]Skil // InstallSandboxSkillFromSource installs a skill onto a sandbox config from a // ClawHub / SkillHub / skills.sh / GitHub / GitLab locator or a direct archive -// URL. The call is accepted asynchronously; follow progress on the skill ID. +// URL. The source must be readable anonymously. The call is accepted +// asynchronously; follow progress on the skill ID. func (c *Client) InstallSandboxSkillFromSource( - ctx context.Context, configID, source, token string, + ctx context.Context, configID, source string, ) (string, error) { if configID == "" { return "", fmt.Errorf("sandbox config ID is required") } body := map[string]string{"source": source} - if token != "" { - body["token"] = token - } path := "/api/v1/sandbox-configs/" + url.PathEscape(configID) + "/skills" resp, err := c.doRequest(ctx, http.MethodPost, path, body, nil) if err != nil { diff --git a/docs/agent-skills.md b/docs/agent-skills.md index 52e6722c..8ba484bb 100644 --- a/docs/agent-skills.md +++ b/docs/agent-skills.md @@ -164,7 +164,7 @@ Docker、Local、CubeSandbox、E2B 均通过同一套空间配置 CRUD、连接 - skills.sh、GitHub、GitLab 仓库或目录链接 - 直接的 zip / `SKILL.md` URL -私有 SkillHub 可在同一次请求里带 Token,仅用于下载、不会落库。安装仍走原有镜像快照流程。 +来源必须可匿名读取,服务端下载时不携带任何凭据;私有仓库请先导出 zip 再上传。安装仍走原有镜像快照流程。 **有沙箱在跑时改不了身份字段。** 身份字段分两组,成因不同但后果都足够严重: diff --git a/docs/api/skill.md b/docs/api/skill.md index 3e172e34..8d83f491 100644 --- a/docs/api/skill.md +++ b/docs/api/skill.md @@ -75,7 +75,7 @@ curl --location 'http://localhost:8080/api/v1/sandbox-configs/{id}/skills' \ - skills.sh / GitHub / GitLab 仓库或目录链接 - 直接的 zip / `SKILL.md` URL -私有 SkillHub 可带 `token`,仅用于本次下载,服务端不保存。 +来源必须可匿名读取:服务端不会为这次下载附带任何凭据,因此私有仓库/私有 registry 需要先自行导出 zip 再上传。 ```curl curl --location 'http://localhost:8080/api/v1/sandbox-configs/{id}/skills' \ diff --git a/docs/docs.go b/docs/docs.go index de2725d1..e51e472b 100644 --- a/docs/docs.go +++ b/docs/docs.go @@ -6122,6 +6122,66 @@ const docTemplate = `{ } } }, + "/knowledge-search": { + "post": { + "security": [ + { + "Bearer": [] + }, + { + "ApiKeyAuth": [] + } + ], + "description": "在知识库中搜索(不使用LLM总结)", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "问答" + ], + "summary": "知识搜索", + "parameters": [ + { + "description": "搜索请求", + "name": "request", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/internal_handler_session.SearchKnowledgeRequest" + } + }, + { + "enum": [ + "handle", + "public" + ], + "type": "string", + "default": "handle", + "description": "文件引用形式,public 返回可加载直链", + "name": "resource_urls", + "in": "query" + } + ], + "responses": { + "200": { + "description": "搜索结果", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "400": { + "description": "请求参数错误", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + } + } + } + }, "/knowledge/batch": { "get": { "security": [ @@ -6594,14 +6654,17 @@ const docTemplate = `{ "in": "query" }, { + "minimum": 0, "type": "integer", - "description": "Offset for pagination", + "description": "Offset for pagination (minimum 0)", "name": "offset", "in": "query" }, { + "maximum": 100, + "minimum": 1, "type": "integer", - "description": "Limit for pagination (default 20)", + "description": "Limit for pagination (default 20, maximum 100)", "name": "limit", "in": "query" }, @@ -6751,7 +6814,7 @@ const docTemplate = `{ "ApiKeyAuth": [] } ], - "description": "更新知识条目信息", + "description": "部分更新知识条目(标题/描述/自定义元数据);未传字段保持不变,显式传空 description 可清空摘要", "consumes": [ "application/json" ], @@ -6771,12 +6834,12 @@ const docTemplate = `{ "required": true }, { - "description": "知识信息", + "description": "更新字段(均可选)", "name": "request", "in": "body", "required": true, "schema": { - "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_types.Knowledge" + "$ref": "#/definitions/internal_handler.UpdateKnowledgeRequest" } } ], @@ -9051,6 +9114,574 @@ const docTemplate = `{ } } }, + "/memory/consolidate": { + "post": { + "security": [ + { + "Bearer": [] + } + ], + "description": "合并意思接近的条目、归档到期事项,不等待每日后台整理", + "produces": [ + "application/json" + ], + "tags": [ + "长期记忆" + ], + "summary": "立刻整理我的记忆", + "responses": { + "200": { + "description": "整理结果", + "schema": { + "type": "object", + "additionalProperties": true + } + } + } + } + }, + "/memory/documents": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "description": "返回当前用户回答里反复引用的文档,次数未达习惯门槛的不展示", + "produces": [ + "application/json" + ], + "tags": [ + "长期记忆" + ], + "summary": "列出常用资料", + "parameters": [ + { + "type": "integer", + "default": 50, + "description": "每页条数", + "name": "limit", + "in": "query" + }, + { + "type": "integer", + "description": "偏移量", + "name": "offset", + "in": "query" + } + ], + "responses": { + "200": { + "description": "文档列表", + "schema": { + "type": "object", + "additionalProperties": true + } + } + } + } + }, + "/memory/documents/{id}": { + "delete": { + "security": [ + { + "Bearer": [] + } + ], + "description": "删除一条文档亲和度计数,之后检索不再因为这份文档而加权", + "produces": [ + "application/json" + ], + "tags": [ + "长期记忆" + ], + "summary": "停止用某份文档做个性化检索", + "parameters": [ + { + "type": "string", + "description": "亲和度 ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "删除成功", + "schema": { + "type": "object", + "additionalProperties": true + } + } + } + } + }, + "/memory/export": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "description": "以 JSON 导出当前用户的全部记忆", + "produces": [ + "application/json" + ], + "tags": [ + "长期记忆" + ], + "summary": "导出我的记忆", + "responses": { + "200": { + "description": "记忆导出", + "schema": { + "type": "object", + "additionalProperties": true + } + } + } + } + }, + "/memory/items": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "description": "分页返回当前用户的记忆条目,可按状态过滤", + "produces": [ + "application/json" + ], + "tags": [ + "长期记忆" + ], + "summary": "列出我的记忆", + "parameters": [ + { + "enum": [ + "active", + "superseded", + "archived", + "pending" + ], + "type": "string", + "description": "状态过滤", + "name": "status", + "in": "query" + }, + { + "type": "integer", + "default": 50, + "description": "每页条数", + "name": "limit", + "in": "query" + }, + { + "type": "integer", + "description": "偏移量", + "name": "offset", + "in": "query" + } + ], + "responses": { + "200": { + "description": "记忆列表", + "schema": { + "type": "object", + "additionalProperties": true + } + } + } + }, + "post": { + "security": [ + { + "Bearer": [] + } + ], + "description": "手动添加一条长期记忆", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "长期记忆" + ], + "summary": "新增一条记忆", + "parameters": [ + { + "description": "记忆内容", + "name": "request", + "in": "body", + "required": true, + "schema": { + "type": "object" + } + } + ], + "responses": { + "200": { + "description": "新增的记忆", + "schema": { + "type": "object", + "additionalProperties": true + } + } + } + }, + "delete": { + "security": [ + { + "Bearer": [] + } + ], + "description": "永久删除当前用户的全部记忆", + "produces": [ + "application/json" + ], + "tags": [ + "长期记忆" + ], + "summary": "清空我的记忆", + "responses": { + "200": { + "description": "清空成功", + "schema": { + "type": "object", + "additionalProperties": true + } + } + } + } + }, + "/memory/items/{id}": { + "put": { + "security": [ + { + "Bearer": [] + } + ], + "description": "修改记忆内容与重要度,修改后该条记忆不会被后台抽取覆盖", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "长期记忆" + ], + "summary": "修改一条记忆", + "parameters": [ + { + "type": "string", + "description": "记忆ID", + "name": "id", + "in": "path", + "required": true + }, + { + "description": "记忆内容", + "name": "request", + "in": "body", + "required": true, + "schema": { + "type": "object" + } + } + ], + "responses": { + "200": { + "description": "更新后的记忆", + "schema": { + "type": "object", + "additionalProperties": true + } + } + } + }, + "delete": { + "security": [ + { + "Bearer": [] + } + ], + "description": "永久删除一条记忆", + "produces": [ + "application/json" + ], + "tags": [ + "长期记忆" + ], + "summary": "删除一条记忆", + "parameters": [ + { + "type": "string", + "description": "记忆ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "删除成功", + "schema": { + "type": "object", + "additionalProperties": true + } + } + } + } + }, + "/memory/items/{id}/confirm": { + "post": { + "security": [ + { + "Bearer": [] + } + ], + "description": "接受系统推断的记忆,使其开始生效", + "produces": [ + "application/json" + ], + "tags": [ + "长期记忆" + ], + "summary": "确认一条推断出的记忆", + "parameters": [ + { + "type": "string", + "description": "记忆 ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "确认成功", + "schema": { + "type": "object", + "additionalProperties": true + } + } + } + } + }, + "/memory/items/{id}/reject": { + "post": { + "security": [ + { + "Bearer": [] + } + ], + "description": "拒绝系统推断的记忆,并记住这次拒绝", + "produces": [ + "application/json" + ], + "tags": [ + "长期记忆" + ], + "summary": "否决一条推断出的记忆", + "parameters": [ + { + "type": "string", + "description": "记忆 ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "否决成功", + "schema": { + "type": "object", + "additionalProperties": true + } + } + } + } + }, + "/memory/settings": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "description": "返回合并后的记忆开关状态(空间级 + 个人级)与记忆条数", + "produces": [ + "application/json" + ], + "tags": [ + "长期记忆" + ], + "summary": "获取我的记忆设置", + "responses": { + "200": { + "description": "记忆设置", + "schema": { + "type": "object", + "additionalProperties": true + } + } + } + }, + "put": { + "security": [ + { + "Bearer": [] + } + ], + "description": "开启或关闭当前用户自己的长期记忆", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "长期记忆" + ], + "summary": "更新我的记忆设置", + "parameters": [ + { + "description": "设置", + "name": "request", + "in": "body", + "required": true, + "schema": { + "type": "object" + } + } + ], + "responses": { + "200": { + "description": "更新后的设置", + "schema": { + "type": "object", + "additionalProperties": true + } + } + } + } + }, + "/memory/topics": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "description": "返回已计数、尚未提升为长期关注的主题,以及距离阈值还差几次", + "produces": [ + "application/json" + ], + "tags": [ + "长期记忆" + ], + "summary": "列出正在观察的主题", + "parameters": [ + { + "type": "integer", + "default": 50, + "description": "每页条数", + "name": "limit", + "in": "query" + }, + { + "type": "integer", + "description": "偏移量", + "name": "offset", + "in": "query" + } + ], + "responses": { + "200": { + "description": "主题列表", + "schema": { + "type": "object", + "additionalProperties": true + } + } + } + } + }, + "/memory/topics/{id}": { + "delete": { + "security": [ + { + "Bearer": [] + } + ], + "description": "删除尚未提升的主题计数,并记住这次拒绝,之后不会再自动记为长期关注", + "produces": [ + "application/json" + ], + "tags": [ + "长期记忆" + ], + "summary": "停止跟踪一个主题", + "parameters": [ + { + "type": "string", + "description": "主题 ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "删除成功", + "schema": { + "type": "object", + "additionalProperties": true + } + } + } + } + }, + "/memory/topics/{id}/promote": { + "post": { + "security": [ + { + "Bearer": [] + } + ], + "description": "不等待剩余次数,把正在观察的主题提升为一条长期关注记忆", + "produces": [ + "application/json" + ], + "tags": [ + "长期记忆" + ], + "summary": "立即记为长期关注", + "parameters": [ + { + "type": "string", + "description": "主题 ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "新增的记忆", + "schema": { + "type": "object", + "additionalProperties": true + } + } + } + } + }, "/messages/chat-history-stats": { "get": { "security": [ @@ -10942,6 +11573,432 @@ const docTemplate = `{ } } }, + "/sandbox-configs/{id}/skills": { + "get": { + "security": [ + { + "Bearer": [] + }, + { + "ApiKeyAuth": [] + } + ], + "description": "List the agent skills installed onto one sandbox config's image.", + "produces": [ + "application/json" + ], + "tags": [ + "SandboxConfig" + ], + "summary": "List installed skills", + "parameters": [ + { + "type": "string", + "description": "Sandbox config ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "Installed skills", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "404": { + "description": "Sandbox config not found", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + } + } + }, + "post": { + "security": [ + { + "Bearer": [] + }, + { + "ApiKeyAuth": [] + } + ], + "description": "Install a skill onto this sandbox config's image. Send a zip\nas multipart form field \"file\", or JSON {\"source\":\"...\"} to\npull from ClawHub, SkillHub, skills.sh, GitHub, GitLab, or a\ndirect archive URL. The source must be readable anonymously.\nThe install boots a sandbox and runs for minutes, so the\nrequest is only accepted; follow it via the install-events\nstream.", + "consumes": [ + "application/json", + "multipart/form-data" + ], + "produces": [ + "application/json" + ], + "tags": [ + "SandboxConfig" + ], + "summary": "Install a skill", + "parameters": [ + { + "type": "string", + "description": "Sandbox config ID", + "name": "id", + "in": "path", + "required": true + }, + { + "type": "file", + "description": "Skill bundle (zip)", + "name": "file", + "in": "formData" + }, + { + "description": "Install from a registry, git host, or archive URL", + "name": "request", + "in": "body", + "schema": { + "$ref": "#/definitions/internal_handler.skillSourceRequest" + } + } + ], + "responses": { + "202": { + "description": "Install accepted", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "400": { + "description": "Missing, oversized or invalid bundle or source", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "404": { + "description": "Sandbox config not found", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + } + } + } + }, + "/sandbox-configs/{id}/skills/{skillId}": { + "get": { + "security": [ + { + "Bearer": [] + }, + { + "ApiKeyAuth": [] + } + ], + "description": "Retrieve one installed skill of a sandbox config.", + "produces": [ + "application/json" + ], + "tags": [ + "SandboxConfig" + ], + "summary": "Get an installed skill", + "parameters": [ + { + "type": "string", + "description": "Sandbox config ID", + "name": "id", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Skill ID", + "name": "skillId", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "Installed skill", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "404": { + "description": "Skill not found", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + } + } + }, + "delete": { + "security": [ + { + "Bearer": [] + }, + { + "ApiKeyAuth": [] + } + ], + "description": "Remove a skill from the config's image. The removal rebuilds\nthe image and runs for minutes, so it is only accepted; follow\nit via the install-events stream.", + "produces": [ + "application/json" + ], + "tags": [ + "SandboxConfig" + ], + "summary": "Remove an installed skill", + "parameters": [ + { + "type": "string", + "description": "Sandbox config ID", + "name": "id", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Skill ID", + "name": "skillId", + "in": "path", + "required": true + } + ], + "responses": { + "202": { + "description": "Removal accepted", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "404": { + "description": "Skill not found", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + } + } + }, + "patch": { + "security": [ + { + "Bearer": [] + }, + { + "ApiKeyAuth": [] + } + ], + "description": "Show or hide an installed skill. The files stay in the image either way; removal is a separate flow.", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "SandboxConfig" + ], + "summary": "Update an installed skill", + "parameters": [ + { + "type": "string", + "description": "Sandbox config ID", + "name": "id", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Skill ID", + "name": "skillId", + "in": "path", + "required": true + }, + { + "description": "Fields to update", + "name": "request", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/internal_handler.skillPatchRequest" + } + } + ], + "responses": { + "200": { + "description": "Updated skill", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "400": { + "description": "Invalid request", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "404": { + "description": "Skill not found", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + } + } + } + }, + "/sandbox-configs/{id}/skills/{skillId}/install-events": { + "get": { + "security": [ + { + "Bearer": [] + }, + { + "ApiKeyAuth": [] + } + ], + "description": "Server-sent progress for one install or removal. The stream\nalways terminates: with the run's own terminal event, with one\nderived from the durable status, or with a \"detached\" frame\nwhen it stops following a run that is still going.", + "produces": [ + "text/event-stream" + ], + "tags": [ + "SandboxConfig" + ], + "summary": "Follow an install or removal", + "parameters": [ + { + "type": "string", + "description": "Sandbox config ID", + "name": "id", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Skill ID", + "name": "skillId", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "SSE stream of progress events", + "schema": { + "type": "string" + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "404": { + "description": "Skill not found", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + } + } + } + }, + "/sandbox-configs/{id}/skills/{skillId}/transcript": { + "get": { + "security": [ + { + "Bearer": [] + }, + { + "ApiKeyAuth": [] + } + ], + "description": "Server-sent replay of everything the installer agent did — the\nprompt it was given, its thinking, the commands it ran and\ntheir output — followed live while the install is still\nrunning. Frames are the same shape the chat stream uses, so a\nconsole renders an install with the components it renders a\nchat turn with. 404 once the event log has expired; the\ndurable message history is the fallback.", + "produces": [ + "text/event-stream" + ], + "tags": [ + "SandboxConfig" + ], + "summary": "Follow an install's agent transcript", + "parameters": [ + { + "type": "string", + "description": "Sandbox config ID", + "name": "id", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Skill ID", + "name": "skillId", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "SSE stream of transcript events", + "schema": { + "type": "string" + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "404": { + "description": "Skill or transcript not found", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + } + } + } + }, "/sessions": { "get": { "security": [ @@ -11173,66 +12230,6 @@ const docTemplate = `{ } } }, - "/knowledge-search": { - "post": { - "security": [ - { - "Bearer": [] - }, - { - "ApiKeyAuth": [] - } - ], - "description": "在知识库中搜索(不使用LLM总结)", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "问答" - ], - "summary": "知识搜索", - "parameters": [ - { - "description": "搜索请求", - "name": "request", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/internal_handler_session.SearchKnowledgeRequest" - } - }, - { - "enum": [ - "handle", - "public" - ], - "type": "string", - "default": "handle", - "description": "文件引用形式,public 返回可加载直链", - "name": "resource_urls", - "in": "query" - } - ], - "responses": { - "200": { - "description": "搜索结果", - "schema": { - "type": "object", - "additionalProperties": true - } - }, - "400": { - "description": "请求参数错误", - "schema": { - "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" - } - } - } - } - }, "/sessions/{id}": { "get": { "security": [ @@ -11902,7 +12899,7 @@ const docTemplate = `{ "ApiKeyAuth": [] } ], - "description": "获取所有预装的Agent Skills元数据", + "description": "返回指定沙盒配置镜像内、智能体实际能调用的已安装技能(ready 且启用)。不传 sandbox_config_id 时列表为空。", "consumes": [ "application/json" ], @@ -11912,7 +12909,15 @@ const docTemplate = `{ "tags": [ "Skills" ], - "summary": "获取预装Skills列表", + "summary": "获取当前沙盒配置上可执行的 Skills", + "parameters": [ + { + "type": "string", + "description": "Sandbox config ID", + "name": "sandbox_config_id", + "in": "query" + } + ], "responses": { "200": { "description": "Skills列表", @@ -11920,12 +12925,6 @@ const docTemplate = `{ "type": "object", "additionalProperties": true } - }, - "500": { - "description": "服务器错误", - "schema": { - "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" - } } } } @@ -13028,6 +14027,74 @@ const docTemplate = `{ } } }, + "/system/admin/users/create": { + "post": { + "description": "Provision a new local user account (SystemAdmin only).\nWhen ` + "`" + `password` + "`" + ` is omitted or null, a cryptographically random\npassword is generated (OIDC-style crypto/rand + base64url)\nand returned once in the response body. Any provided value,\nincluding empty string, is policy-checked. Tenant provisioning\nfollows the shared auth.default_tenant_mode policy.", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "System Admin" + ], + "summary": "Create a new user (SystemAdmin)", + "parameters": [ + { + "description": "User creation request", + "name": "request", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_types.AdminCreateUserRequest" + } + } + ], + "responses": { + "200": { + "description": "Identity already exists, returns the existing user", + "schema": { + "$ref": "#/definitions/internal_handler.CreateSystemUserResponse" + } + }, + "201": { + "description": "User created successfully", + "schema": { + "$ref": "#/definitions/internal_handler.CreateSystemUserResponse" + } + }, + "400": { + "description": "Invalid request or weak password", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "403": { + "description": "Forbidden: not a system admin", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "409": { + "description": "Email and username refer to conflicting identities", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "500": { + "description": "Internal error", + "schema": { + "type": "object", + "additionalProperties": true + } + } + } + } + }, "/system/admin/users/reset-password": { "post": { "description": "Replace another user's local password and revoke all of their existing sessions (SystemAdmin only).\nA system administrator cannot reset their own password through this endpoint; self-service password change still requires the old password.", @@ -15713,6 +16780,26 @@ const docTemplate = `{ } } }, + "github_com_Tencent_WeKnora_internal_types.AdminCreateUserRequest": { + "type": "object", + "required": [ + "email", + "username" + ], + "properties": { + "email": { + "type": "string" + }, + "password": { + "type": "string" + }, + "username": { + "type": "string", + "maxLength": 50, + "minLength": 2 + } + } + }, "github_com_Tencent_WeKnora_internal_types.AgentStep": { "type": "object", "properties": { @@ -15775,6 +16862,7 @@ const docTemplate = `{ "system.admin_promoted", "system.admin_revoked", "system.user_password_reset", + "system.user_created", "system.api_key_created", "system.api_key_revoked", "system.queue_task_retried", @@ -15838,6 +16926,7 @@ const docTemplate = `{ "AuditActionSystemAdminPromoted", "AuditActionSystemAdminRevoked", "AuditActionSystemUserPasswordReset", + "AuditActionSystemUserCreated", "AuditActionSystemAPIKeyCreated", "AuditActionSystemAPIKeyRevoked", "AuditActionSystemQueueTaskRetried", @@ -16392,6 +17481,10 @@ const docTemplate = `{ "type": "string" } }, + "memory_enabled": { + "description": "Whether this agent may read the user's long-term memory. Nil inherits\nthe workspace setting; false opts a single agent out of memory even when\nthe workspace has it on. There is no \"on\" that overrides the workspace.", + "type": "boolean" + }, "model_id": { "description": "===== Model Settings =====\nModel ID to use for conversations", "type": "string" @@ -16617,8 +17710,44 @@ const docTemplate = `{ "github_com_Tencent_WeKnora_internal_types.DockerSandboxConfig": { "type": "object", "properties": { + "cpu_limit": { + "description": "CPULimit is the number of CPU cores one sandbox may use. 0 uses the\nbuilt-in default.", + "type": "number" + }, + "host": { + "description": "Host is the daemon endpoint in DOCKER_HOST form. Empty means the local\nunix socket.", + "type": "string" + }, + "http_timeout_sec": { + "description": "HTTPTimeoutSec bounds each Engine API call. 0 uses the built-in default.", + "type": "integer" + }, + "idle_ttl_seconds": { + "description": "IdleTTLSeconds is how long a session container may go unused before it\nis reclaimed. The daemon has no idle timeout of its own, so this is what\nstops an abandoned session from pinning host memory indefinitely.", + "type": "integer" + }, "image": { "type": "string" + }, + "memory_limit_mb": { + "description": "MemoryLimitMB caps one sandbox's memory. 0 uses the built-in default.", + "type": "integer" + }, + "network_mode": { + "description": "NetworkMode is the Docker network sandboxes join: \"bridge\" (default) or\n\"none\" for no egress. Nothing else is accepted — host and container:\nmodes share another namespace outright, and a named network is usually\nthe deployment's own compose network, which would put the sandbox next\nto Postgres and Redis.", + "type": "string" + }, + "pids_limit": { + "description": "PidsLimit caps how many processes one sandbox may run. 0 uses the\nbuilt-in default.", + "type": "integer" + }, + "runtime": { + "description": "Runtime selects an alternative OCI runtime such as \"runsc\" (gVisor).\nEmpty uses the daemon default.", + "type": "string" + }, + "tls_cert_path": { + "description": "TLSCertPath is a directory on the WeKnora host containing ca.pem,\ncert.pem and key.pem. Required when Host is a TCP endpoint.", + "type": "string" } } }, @@ -17163,147 +18292,6 @@ const docTemplate = `{ } } }, - "github_com_Tencent_WeKnora_internal_types.Knowledge": { - "type": "object", - "properties": { - "channel": { - "description": "Channel indicates through which channel the knowledge was ingested (web, api, browser_extension, wechat, etc.)", - "type": "string" - }, - "created_at": { - "description": "Creation time of the knowledge", - "type": "string" - }, - "custom_metadata": { - "description": "CustomMetadata is user-authored descriptive metadata. It is deliberately\nseparate from Metadata, which contains internal ingestion state and IDs.", - "type": "array", - "items": { - "type": "integer" - } - }, - "deleted_at": { - "description": "Deletion time of the knowledge", - "allOf": [ - { - "$ref": "#/definitions/gorm.DeletedAt" - } - ] - }, - "description": { - "description": "Description of the knowledge", - "type": "string" - }, - "embedding_model_id": { - "description": "ID of the embedding model", - "type": "string" - }, - "enable_status": { - "description": "Enable status of the knowledge", - "type": "string" - }, - "error_message": { - "description": "Error message of the knowledge", - "type": "string" - }, - "file_hash": { - "description": "File hash of the knowledge", - "type": "string" - }, - "file_name": { - "description": "File name of the knowledge", - "type": "string" - }, - "file_path": { - "description": "File path of the knowledge", - "type": "string" - }, - "file_size": { - "description": "File size of the knowledge", - "type": "integer" - }, - "file_type": { - "description": "File type of the knowledge", - "type": "string" - }, - "folder_path": { - "description": "FolderPath is the canonical relative directory this entry belongs to\ninside the knowledge base, e.g. \"docs/spec\" for a folder upload of\n\"docs/spec/design.md\". Empty means the knowledge base root. It is a\ndisplay/navigation concern only: it never affects where the file is\nphysically stored (see FilePath).", - "type": "string" - }, - "id": { - "description": "Unique identifier of the knowledge", - "type": "string" - }, - "knowledge_base_id": { - "description": "ID of the knowledge base", - "type": "string" - }, - "knowledge_base_name": { - "description": "Knowledge base name (not stored in database, populated on query)", - "type": "string" - }, - "last_faq_import_result": { - "description": "Last FAQ import result (for FAQ type knowledge only)", - "type": "array", - "items": { - "type": "integer" - } - }, - "metadata": { - "description": "Metadata of the knowledge", - "type": "array", - "items": { - "type": "integer" - } - }, - "parse_status": { - "description": "Parse status of the knowledge", - "type": "string" - }, - "pending_subtasks_count": { - "description": "PendingSubtasksCount is the outstanding enrichment subtask count\n(summary + question + graph chunks). Only meaningful while\nParseStatus == \"finalizing\"; defaults to 0 in any terminal state.", - "type": "integer" - }, - "processed_at": { - "description": "Processed time of the knowledge", - "type": "string" - }, - "source": { - "description": "Source of the knowledge (e.g. URL address for url type, \"manual\" for manual type)", - "type": "string" - }, - "storage_size": { - "description": "Storage size of the knowledge", - "type": "integer" - }, - "summary_status": { - "description": "Summary status for async summary generation", - "type": "string" - }, - "tags": { - "description": "Tags holds the tags associated with this knowledge (populated on query, not persisted directly).", - "type": "array", - "items": { - "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_types.KnowledgeTag" - } - }, - "tenant_id": { - "description": "Workspace ID", - "type": "integer" - }, - "title": { - "description": "Title of the knowledge", - "type": "string" - }, - "type": { - "description": "Type of the knowledge", - "type": "string" - }, - "updated_at": { - "description": "Last updated time of the knowledge", - "type": "string" - } - } - }, "github_com_Tencent_WeKnora_internal_types.KnowledgeBase": { "type": "object", "properties": { @@ -17694,47 +18682,6 @@ const docTemplate = `{ } } }, - "github_com_Tencent_WeKnora_internal_types.KnowledgeTag": { - "type": "object", - "properties": { - "color": { - "description": "Optional display color", - "type": "string" - }, - "created_at": { - "description": "Creation time", - "type": "string" - }, - "id": { - "description": "Unique identifier of the tag (UUID)", - "type": "string" - }, - "knowledge_base_id": { - "description": "Knowledge base ID that this tag belongs to", - "type": "string" - }, - "name": { - "description": "Tag name, unique within the same knowledge base", - "type": "string" - }, - "seq_id": { - "description": "SeqID is an auto-increment integer ID for external API usage", - "type": "integer" - }, - "sort_order": { - "description": "Sort order within the same knowledge base", - "type": "integer" - }, - "tenant_id": { - "description": "Workspace ID", - "type": "integer" - }, - "updated_at": { - "description": "Last updated time", - "type": "string" - } - } - }, "github_com_Tencent_WeKnora_internal_types.ListMembersResponse": { "type": "object", "properties": { @@ -18118,6 +19065,55 @@ const docTemplate = `{ } } }, + "github_com_Tencent_WeKnora_internal_types.MemoryConfig": { + "type": "object", + "properties": { + "embedding_model_id": { + "description": "EmbeddingModelID is the single model used to score memory against a\nquestion. It is pinned per workspace: knowledge bases each have their\nown embedding model, and grabbing whichever one happens to be listed\nfirst would mix incomparable vector spaces. Blank means semantic recall\nis off and matching stays lexical.", + "type": "string" + }, + "enabled": { + "description": "Enabled defaults to false. Memory retains user statements across\nsessions, so a workspace admin has to turn it on deliberately.", + "type": "boolean" + }, + "extract_delay_seconds": { + "description": "ExtractDelaySeconds is how long a finished turn waits before\ndistillation runs. Waiting lets one model call cover the several\nmessages a user usually sends in a row. 0 means the default.", + "type": "integer" + }, + "extract_instructions": { + "description": "ExtractInstructions are workspace-specific rules appended to the\ndistillation prompt, for policies the product cannot guess (\"never record\ncustomer names\", \"always note the environment a question is about\").", + "type": "string" + }, + "extract_min_interval_seconds": { + "description": "ExtractMinIntervalSeconds is the floor between two distillation runs for\nthe same person, and exists purely to bound cost. It never drops a turn:\na turn arriving inside the interval is queued and picked up by the next\nrun. 0 means the default.", + "type": "integer" + }, + "extract_model_id": { + "description": "ExtractModelID is the model used by the background extraction task.\nEmpty means \"use the model the conversation itself used\", which is what\nthe settings UI promises, so the extraction task must never fail merely\nbecause this is blank.", + "type": "string" + }, + "interest_threshold": { + "description": "InterestThreshold is how many separate conversations must touch a topic\nbefore it becomes a stored interest. 0 means the default. Setting it to 1\nrecords every topic on first sight, which is usually too noisy.", + "type": "integer" + }, + "max_items": { + "description": "MaxItems caps active items per subject. 0 means DefaultMemoryMaxItems.", + "type": "integer" + }, + "retrieval_conditioning": { + "description": "RetrievalConditioning lets memory shape retrieval — query rewriting and\nper-document ranking — rather than only being appended to the answer\nprompt. This is where memory earns its keep in a knowledge-base product.", + "type": "boolean" + }, + "vector_recall": { + "description": "VectorRecall adds semantic similarity to memory recall. Nil means on\nwhen an embedding model is reachable.\n\nLexical matching alone cannot find a memory the user has re-worded, which\nis most of them: \"回答直接给结论\" and \"别铺垫那么多\" share no tokens. The\ncost is one embedding call per turn, bounded and degraded to lexical on\nfailure, so the feature never becomes a reason a chat is slow.", + "type": "boolean" + }, + "write_mode": { + "description": "WriteMode is MemoryWriteExplicitOnly or MemoryWriteAuto.", + "type": "string" + } + } + }, "github_com_Tencent_WeKnora_internal_types.MentionedItem": { "type": "object", "properties": { @@ -18261,6 +19257,21 @@ const docTemplate = `{ "updated_at": { "description": "Last update timestamp", "type": "string" + }, + "usage": { + "description": "LLM token usage aggregated across every round of the turn that produced this\nassistant message. Persisted so history reads can attribute cost after the\nlive stream is gone; NULL (nil) for user messages and pre-feature rows.", + "allOf": [ + { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_types.TokenUsage" + } + ] + }, + "used_memories": { + "description": "UsedMemories records which long-term memories were injected into this\nanswer, so the chat UI can show them and let the user delete one on the\nspot. Persisted rather than only streamed so reopening a conversation\nstill explains what the answer saw.", + "type": "array", + "items": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_types.UsedMemory" + } } } }, @@ -18884,6 +19895,21 @@ const docTemplate = `{ } } }, + "github_com_Tencent_WeKnora_internal_types.PromptCacheStatus": { + "type": "string", + "enum": [ + "unsupported", + "unreported", + "miss", + "hit" + ], + "x-enum-varnames": [ + "PromptCacheStatusUnsupported", + "PromptCacheStatusUnreported", + "PromptCacheStatusMiss", + "PromptCacheStatusHit" + ] + }, "github_com_Tencent_WeKnora_internal_types.QuestionGenerationConfig": { "type": "object", "properties": { @@ -19691,6 +20717,31 @@ const docTemplate = `{ } } }, + "github_com_Tencent_WeKnora_internal_types.SkillImageConfig": { + "type": "object", + "properties": { + "base_template_id": { + "description": "BaseTemplateID is the template this chain was originally built from;\nthe rebuild path starts over from it.", + "type": "string" + }, + "built_at": { + "description": "BuiltAt records when this generation was produced.", + "type": "string" + }, + "generation": { + "description": "Generation increments on every successful install/remove, for naming\nand troubleshooting.", + "type": "integer" + }, + "owner_fingerprint": { + "description": "OwnerFingerprint identifies the provider account that owns the snapshot.\nSnapshots are invisible across accounts, so a mismatch means \"fall back\nto the base template\" rather than \"fail\".", + "type": "string" + }, + "snapshot_id": { + "description": "SnapshotID is the currently effective snapshot; empty = base template.", + "type": "string" + } + } + }, "github_com_Tencent_WeKnora_internal_types.StarterSuggestionConfig": { "type": "object", "properties": { @@ -20090,6 +21141,14 @@ const docTemplate = `{ "description": "ID", "type": "integer" }, + "memory_config": { + "description": "Memory config: workspace switch for cross-session long-term memory", + "allOf": [ + { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_types.MemoryConfig" + } + ] + }, "name": { "description": "Name", "type": "string" @@ -20198,6 +21257,18 @@ const docTemplate = `{ "description": "SandboxType selects the sandbox backend. Named configs may use \"cube\",\n\"e2b\", \"docker\", or \"local\". \"disabled\" is reserved for the hidden\nworkspace policy row.", "type": "string" }, + "skill_image": { + "description": "SkillImage points at the snapshot that carries this config's installed\nskills. Empty means \"use the base template\". Written only by the skill\ninstall/remove path: MergeSandboxConfigForUpdate ignores client values\nso a settings-form save cannot wipe or plant the pointer.", + "allOf": [ + { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_types.SkillImageConfig" + } + ] + }, + "skill_rollout": { + "description": "SkillRollout decides whether sessions that already hold a sandbox of\nthis config rebuild after a skill install or removal. Empty and\nSkillRolloutNextTurn rebuild on the next chat turn. SkillRolloutNewSession\nleaves those sandboxes on the previous image; only sessions that start\nafterwards boot the new snapshot.", + "type": "string" + }, "volume_mount": { "description": "VolumeMount configures an optional shared volume mounted into every\nsandbox created for this tenant. Currently used for tenant-installed\nskills, but the configuration itself is skill-agnostic and can serve\nany volume-mount use case (shared datasets, pre-installed toolchains,\netc.).", "allOf": [ @@ -20208,6 +21279,39 @@ const docTemplate = `{ } } }, + "github_com_Tencent_WeKnora_internal_types.TokenUsage": { + "type": "object", + "properties": { + "cache_miss_tokens": { + "type": "integer" + }, + "cache_read_tokens": { + "type": "integer" + }, + "cache_reported": { + "type": "boolean" + }, + "cache_status": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_types.PromptCacheStatus" + }, + "cache_write_tokens": { + "type": "integer" + }, + "cached_tokens": { + "description": "CachedTokens is the legacy alias for CacheReadTokens. It remains on the\nwire for compatibility with existing API consumers.", + "type": "integer" + }, + "completion_tokens": { + "type": "integer" + }, + "prompt_tokens": { + "type": "integer" + }, + "total_tokens": { + "type": "integer" + } + } + }, "github_com_Tencent_WeKnora_internal_types.ToolCall": { "type": "object", "properties": { @@ -20344,6 +21448,20 @@ const docTemplate = `{ } } }, + "github_com_Tencent_WeKnora_internal_types.UsedMemory": { + "type": "object", + "properties": { + "content": { + "type": "string" + }, + "id": { + "type": "string" + }, + "kind": { + "type": "string" + } + } + }, "github_com_Tencent_WeKnora_internal_types.User": { "type": "object", "properties": { @@ -20922,6 +22040,10 @@ const docTemplate = `{ "description": "populated in ego mode", "type": "integer" }, + "familiar_count": { + "description": "FamiliarCount is how many returned nodes are lit up for this person.", + "type": "integer" + }, "mode": { "type": "string" }, @@ -20942,6 +22064,10 @@ const docTemplate = `{ "github_com_Tencent_WeKnora_internal_types.WikiGraphNode": { "type": "object", "properties": { + "familiar": { + "description": "Familiar is true when this page was built from a document this person\nkeeps citing in answers. It is a personal overlay, not a property of\nthe page: two people looking at the same wiki see different highlights.", + "type": "boolean" + }, "link_count": { "description": "Number of inbound + outbound links", "type": "integer" @@ -21535,6 +22661,18 @@ const docTemplate = `{ } } }, + "internal_handler.CreateSystemUserResponse": { + "type": "object", + "properties": { + "generated_password": { + "description": "GeneratedPassword is the plaintext password when the server\nauto-generated one. Absent when the caller supplied the password.", + "type": "string" + }, + "user": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_types.UserInfo" + } + } + }, "internal_handler.DeleteTagRequest": { "type": "object", "properties": { @@ -22760,6 +23898,23 @@ const docTemplate = `{ } } }, + "internal_handler.UpdateKnowledgeRequest": { + "type": "object", + "properties": { + "custom_metadata": { + "type": "array", + "items": { + "type": "integer" + } + }, + "description": { + "type": "string" + }, + "title": { + "type": "string" + } + } + }, "internal_handler.UpdateModelRequest": { "type": "object", "properties": { @@ -23075,6 +24230,24 @@ const docTemplate = `{ } } }, + "internal_handler.skillPatchRequest": { + "type": "object", + "properties": { + "enabled": { + "description": "Enabled is a pointer because its absence is a bad request rather than a\nrequest to disable the skill.", + "type": "boolean" + } + } + }, + "internal_handler.skillSourceRequest": { + "type": "object", + "properties": { + "source": { + "description": "Source is a ClawHub/SkillHub slug or page URL, a skills.sh / GitHub /\nGitLab locator, or a direct zip/SKILL.md URL. It must be readable\nanonymously: the fetch carries no credential of any kind.", + "type": "string" + } + } + }, "internal_handler.storageBackendRequest": { "type": "object", "required": [ diff --git a/docs/swagger.json b/docs/swagger.json index 7e83a153..fd115ee3 100644 --- a/docs/swagger.json +++ b/docs/swagger.json @@ -6115,6 +6115,66 @@ } } }, + "/knowledge-search": { + "post": { + "security": [ + { + "Bearer": [] + }, + { + "ApiKeyAuth": [] + } + ], + "description": "在知识库中搜索(不使用LLM总结)", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "问答" + ], + "summary": "知识搜索", + "parameters": [ + { + "description": "搜索请求", + "name": "request", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/internal_handler_session.SearchKnowledgeRequest" + } + }, + { + "enum": [ + "handle", + "public" + ], + "type": "string", + "default": "handle", + "description": "文件引用形式,public 返回可加载直链", + "name": "resource_urls", + "in": "query" + } + ], + "responses": { + "200": { + "description": "搜索结果", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "400": { + "description": "请求参数错误", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + } + } + } + }, "/knowledge/batch": { "get": { "security": [ @@ -6587,14 +6647,17 @@ "in": "query" }, { + "minimum": 0, "type": "integer", - "description": "Offset for pagination", + "description": "Offset for pagination (minimum 0)", "name": "offset", "in": "query" }, { + "maximum": 100, + "minimum": 1, "type": "integer", - "description": "Limit for pagination (default 20)", + "description": "Limit for pagination (default 20, maximum 100)", "name": "limit", "in": "query" }, @@ -6744,7 +6807,7 @@ "ApiKeyAuth": [] } ], - "description": "更新知识条目信息", + "description": "部分更新知识条目(标题/描述/自定义元数据);未传字段保持不变,显式传空 description 可清空摘要", "consumes": [ "application/json" ], @@ -6764,12 +6827,12 @@ "required": true }, { - "description": "知识信息", + "description": "更新字段(均可选)", "name": "request", "in": "body", "required": true, "schema": { - "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_types.Knowledge" + "$ref": "#/definitions/internal_handler.UpdateKnowledgeRequest" } } ], @@ -9044,6 +9107,574 @@ } } }, + "/memory/consolidate": { + "post": { + "security": [ + { + "Bearer": [] + } + ], + "description": "合并意思接近的条目、归档到期事项,不等待每日后台整理", + "produces": [ + "application/json" + ], + "tags": [ + "长期记忆" + ], + "summary": "立刻整理我的记忆", + "responses": { + "200": { + "description": "整理结果", + "schema": { + "type": "object", + "additionalProperties": true + } + } + } + } + }, + "/memory/documents": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "description": "返回当前用户回答里反复引用的文档,次数未达习惯门槛的不展示", + "produces": [ + "application/json" + ], + "tags": [ + "长期记忆" + ], + "summary": "列出常用资料", + "parameters": [ + { + "type": "integer", + "default": 50, + "description": "每页条数", + "name": "limit", + "in": "query" + }, + { + "type": "integer", + "description": "偏移量", + "name": "offset", + "in": "query" + } + ], + "responses": { + "200": { + "description": "文档列表", + "schema": { + "type": "object", + "additionalProperties": true + } + } + } + } + }, + "/memory/documents/{id}": { + "delete": { + "security": [ + { + "Bearer": [] + } + ], + "description": "删除一条文档亲和度计数,之后检索不再因为这份文档而加权", + "produces": [ + "application/json" + ], + "tags": [ + "长期记忆" + ], + "summary": "停止用某份文档做个性化检索", + "parameters": [ + { + "type": "string", + "description": "亲和度 ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "删除成功", + "schema": { + "type": "object", + "additionalProperties": true + } + } + } + } + }, + "/memory/export": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "description": "以 JSON 导出当前用户的全部记忆", + "produces": [ + "application/json" + ], + "tags": [ + "长期记忆" + ], + "summary": "导出我的记忆", + "responses": { + "200": { + "description": "记忆导出", + "schema": { + "type": "object", + "additionalProperties": true + } + } + } + } + }, + "/memory/items": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "description": "分页返回当前用户的记忆条目,可按状态过滤", + "produces": [ + "application/json" + ], + "tags": [ + "长期记忆" + ], + "summary": "列出我的记忆", + "parameters": [ + { + "enum": [ + "active", + "superseded", + "archived", + "pending" + ], + "type": "string", + "description": "状态过滤", + "name": "status", + "in": "query" + }, + { + "type": "integer", + "default": 50, + "description": "每页条数", + "name": "limit", + "in": "query" + }, + { + "type": "integer", + "description": "偏移量", + "name": "offset", + "in": "query" + } + ], + "responses": { + "200": { + "description": "记忆列表", + "schema": { + "type": "object", + "additionalProperties": true + } + } + } + }, + "post": { + "security": [ + { + "Bearer": [] + } + ], + "description": "手动添加一条长期记忆", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "长期记忆" + ], + "summary": "新增一条记忆", + "parameters": [ + { + "description": "记忆内容", + "name": "request", + "in": "body", + "required": true, + "schema": { + "type": "object" + } + } + ], + "responses": { + "200": { + "description": "新增的记忆", + "schema": { + "type": "object", + "additionalProperties": true + } + } + } + }, + "delete": { + "security": [ + { + "Bearer": [] + } + ], + "description": "永久删除当前用户的全部记忆", + "produces": [ + "application/json" + ], + "tags": [ + "长期记忆" + ], + "summary": "清空我的记忆", + "responses": { + "200": { + "description": "清空成功", + "schema": { + "type": "object", + "additionalProperties": true + } + } + } + } + }, + "/memory/items/{id}": { + "put": { + "security": [ + { + "Bearer": [] + } + ], + "description": "修改记忆内容与重要度,修改后该条记忆不会被后台抽取覆盖", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "长期记忆" + ], + "summary": "修改一条记忆", + "parameters": [ + { + "type": "string", + "description": "记忆ID", + "name": "id", + "in": "path", + "required": true + }, + { + "description": "记忆内容", + "name": "request", + "in": "body", + "required": true, + "schema": { + "type": "object" + } + } + ], + "responses": { + "200": { + "description": "更新后的记忆", + "schema": { + "type": "object", + "additionalProperties": true + } + } + } + }, + "delete": { + "security": [ + { + "Bearer": [] + } + ], + "description": "永久删除一条记忆", + "produces": [ + "application/json" + ], + "tags": [ + "长期记忆" + ], + "summary": "删除一条记忆", + "parameters": [ + { + "type": "string", + "description": "记忆ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "删除成功", + "schema": { + "type": "object", + "additionalProperties": true + } + } + } + } + }, + "/memory/items/{id}/confirm": { + "post": { + "security": [ + { + "Bearer": [] + } + ], + "description": "接受系统推断的记忆,使其开始生效", + "produces": [ + "application/json" + ], + "tags": [ + "长期记忆" + ], + "summary": "确认一条推断出的记忆", + "parameters": [ + { + "type": "string", + "description": "记忆 ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "确认成功", + "schema": { + "type": "object", + "additionalProperties": true + } + } + } + } + }, + "/memory/items/{id}/reject": { + "post": { + "security": [ + { + "Bearer": [] + } + ], + "description": "拒绝系统推断的记忆,并记住这次拒绝", + "produces": [ + "application/json" + ], + "tags": [ + "长期记忆" + ], + "summary": "否决一条推断出的记忆", + "parameters": [ + { + "type": "string", + "description": "记忆 ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "否决成功", + "schema": { + "type": "object", + "additionalProperties": true + } + } + } + } + }, + "/memory/settings": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "description": "返回合并后的记忆开关状态(空间级 + 个人级)与记忆条数", + "produces": [ + "application/json" + ], + "tags": [ + "长期记忆" + ], + "summary": "获取我的记忆设置", + "responses": { + "200": { + "description": "记忆设置", + "schema": { + "type": "object", + "additionalProperties": true + } + } + } + }, + "put": { + "security": [ + { + "Bearer": [] + } + ], + "description": "开启或关闭当前用户自己的长期记忆", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "长期记忆" + ], + "summary": "更新我的记忆设置", + "parameters": [ + { + "description": "设置", + "name": "request", + "in": "body", + "required": true, + "schema": { + "type": "object" + } + } + ], + "responses": { + "200": { + "description": "更新后的设置", + "schema": { + "type": "object", + "additionalProperties": true + } + } + } + } + }, + "/memory/topics": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "description": "返回已计数、尚未提升为长期关注的主题,以及距离阈值还差几次", + "produces": [ + "application/json" + ], + "tags": [ + "长期记忆" + ], + "summary": "列出正在观察的主题", + "parameters": [ + { + "type": "integer", + "default": 50, + "description": "每页条数", + "name": "limit", + "in": "query" + }, + { + "type": "integer", + "description": "偏移量", + "name": "offset", + "in": "query" + } + ], + "responses": { + "200": { + "description": "主题列表", + "schema": { + "type": "object", + "additionalProperties": true + } + } + } + } + }, + "/memory/topics/{id}": { + "delete": { + "security": [ + { + "Bearer": [] + } + ], + "description": "删除尚未提升的主题计数,并记住这次拒绝,之后不会再自动记为长期关注", + "produces": [ + "application/json" + ], + "tags": [ + "长期记忆" + ], + "summary": "停止跟踪一个主题", + "parameters": [ + { + "type": "string", + "description": "主题 ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "删除成功", + "schema": { + "type": "object", + "additionalProperties": true + } + } + } + } + }, + "/memory/topics/{id}/promote": { + "post": { + "security": [ + { + "Bearer": [] + } + ], + "description": "不等待剩余次数,把正在观察的主题提升为一条长期关注记忆", + "produces": [ + "application/json" + ], + "tags": [ + "长期记忆" + ], + "summary": "立即记为长期关注", + "parameters": [ + { + "type": "string", + "description": "主题 ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "新增的记忆", + "schema": { + "type": "object", + "additionalProperties": true + } + } + } + } + }, "/messages/chat-history-stats": { "get": { "security": [ @@ -10935,6 +11566,432 @@ } } }, + "/sandbox-configs/{id}/skills": { + "get": { + "security": [ + { + "Bearer": [] + }, + { + "ApiKeyAuth": [] + } + ], + "description": "List the agent skills installed onto one sandbox config's image.", + "produces": [ + "application/json" + ], + "tags": [ + "SandboxConfig" + ], + "summary": "List installed skills", + "parameters": [ + { + "type": "string", + "description": "Sandbox config ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "Installed skills", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "404": { + "description": "Sandbox config not found", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + } + } + }, + "post": { + "security": [ + { + "Bearer": [] + }, + { + "ApiKeyAuth": [] + } + ], + "description": "Install a skill onto this sandbox config's image. Send a zip\nas multipart form field \"file\", or JSON {\"source\":\"...\"} to\npull from ClawHub, SkillHub, skills.sh, GitHub, GitLab, or a\ndirect archive URL. The source must be readable anonymously.\nThe install boots a sandbox and runs for minutes, so the\nrequest is only accepted; follow it via the install-events\nstream.", + "consumes": [ + "application/json", + "multipart/form-data" + ], + "produces": [ + "application/json" + ], + "tags": [ + "SandboxConfig" + ], + "summary": "Install a skill", + "parameters": [ + { + "type": "string", + "description": "Sandbox config ID", + "name": "id", + "in": "path", + "required": true + }, + { + "type": "file", + "description": "Skill bundle (zip)", + "name": "file", + "in": "formData" + }, + { + "description": "Install from a registry, git host, or archive URL", + "name": "request", + "in": "body", + "schema": { + "$ref": "#/definitions/internal_handler.skillSourceRequest" + } + } + ], + "responses": { + "202": { + "description": "Install accepted", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "400": { + "description": "Missing, oversized or invalid bundle or source", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "404": { + "description": "Sandbox config not found", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + } + } + } + }, + "/sandbox-configs/{id}/skills/{skillId}": { + "get": { + "security": [ + { + "Bearer": [] + }, + { + "ApiKeyAuth": [] + } + ], + "description": "Retrieve one installed skill of a sandbox config.", + "produces": [ + "application/json" + ], + "tags": [ + "SandboxConfig" + ], + "summary": "Get an installed skill", + "parameters": [ + { + "type": "string", + "description": "Sandbox config ID", + "name": "id", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Skill ID", + "name": "skillId", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "Installed skill", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "404": { + "description": "Skill not found", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + } + } + }, + "delete": { + "security": [ + { + "Bearer": [] + }, + { + "ApiKeyAuth": [] + } + ], + "description": "Remove a skill from the config's image. The removal rebuilds\nthe image and runs for minutes, so it is only accepted; follow\nit via the install-events stream.", + "produces": [ + "application/json" + ], + "tags": [ + "SandboxConfig" + ], + "summary": "Remove an installed skill", + "parameters": [ + { + "type": "string", + "description": "Sandbox config ID", + "name": "id", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Skill ID", + "name": "skillId", + "in": "path", + "required": true + } + ], + "responses": { + "202": { + "description": "Removal accepted", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "404": { + "description": "Skill not found", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + } + } + }, + "patch": { + "security": [ + { + "Bearer": [] + }, + { + "ApiKeyAuth": [] + } + ], + "description": "Show or hide an installed skill. The files stay in the image either way; removal is a separate flow.", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "SandboxConfig" + ], + "summary": "Update an installed skill", + "parameters": [ + { + "type": "string", + "description": "Sandbox config ID", + "name": "id", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Skill ID", + "name": "skillId", + "in": "path", + "required": true + }, + { + "description": "Fields to update", + "name": "request", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/internal_handler.skillPatchRequest" + } + } + ], + "responses": { + "200": { + "description": "Updated skill", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "400": { + "description": "Invalid request", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "404": { + "description": "Skill not found", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + } + } + } + }, + "/sandbox-configs/{id}/skills/{skillId}/install-events": { + "get": { + "security": [ + { + "Bearer": [] + }, + { + "ApiKeyAuth": [] + } + ], + "description": "Server-sent progress for one install or removal. The stream\nalways terminates: with the run's own terminal event, with one\nderived from the durable status, or with a \"detached\" frame\nwhen it stops following a run that is still going.", + "produces": [ + "text/event-stream" + ], + "tags": [ + "SandboxConfig" + ], + "summary": "Follow an install or removal", + "parameters": [ + { + "type": "string", + "description": "Sandbox config ID", + "name": "id", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Skill ID", + "name": "skillId", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "SSE stream of progress events", + "schema": { + "type": "string" + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "404": { + "description": "Skill not found", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + } + } + } + }, + "/sandbox-configs/{id}/skills/{skillId}/transcript": { + "get": { + "security": [ + { + "Bearer": [] + }, + { + "ApiKeyAuth": [] + } + ], + "description": "Server-sent replay of everything the installer agent did — the\nprompt it was given, its thinking, the commands it ran and\ntheir output — followed live while the install is still\nrunning. Frames are the same shape the chat stream uses, so a\nconsole renders an install with the components it renders a\nchat turn with. 404 once the event log has expired; the\ndurable message history is the fallback.", + "produces": [ + "text/event-stream" + ], + "tags": [ + "SandboxConfig" + ], + "summary": "Follow an install's agent transcript", + "parameters": [ + { + "type": "string", + "description": "Sandbox config ID", + "name": "id", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Skill ID", + "name": "skillId", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "SSE stream of transcript events", + "schema": { + "type": "string" + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "404": { + "description": "Skill or transcript not found", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + } + } + } + }, "/sessions": { "get": { "security": [ @@ -11166,66 +12223,6 @@ } } }, - "/knowledge-search": { - "post": { - "security": [ - { - "Bearer": [] - }, - { - "ApiKeyAuth": [] - } - ], - "description": "在知识库中搜索(不使用LLM总结)", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "问答" - ], - "summary": "知识搜索", - "parameters": [ - { - "description": "搜索请求", - "name": "request", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/internal_handler_session.SearchKnowledgeRequest" - } - }, - { - "enum": [ - "handle", - "public" - ], - "type": "string", - "default": "handle", - "description": "文件引用形式,public 返回可加载直链", - "name": "resource_urls", - "in": "query" - } - ], - "responses": { - "200": { - "description": "搜索结果", - "schema": { - "type": "object", - "additionalProperties": true - } - }, - "400": { - "description": "请求参数错误", - "schema": { - "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" - } - } - } - } - }, "/sessions/{id}": { "get": { "security": [ @@ -11895,7 +12892,7 @@ "ApiKeyAuth": [] } ], - "description": "获取所有预装的Agent Skills元数据", + "description": "返回指定沙盒配置镜像内、智能体实际能调用的已安装技能(ready 且启用)。不传 sandbox_config_id 时列表为空。", "consumes": [ "application/json" ], @@ -11905,7 +12902,15 @@ "tags": [ "Skills" ], - "summary": "获取预装Skills列表", + "summary": "获取当前沙盒配置上可执行的 Skills", + "parameters": [ + { + "type": "string", + "description": "Sandbox config ID", + "name": "sandbox_config_id", + "in": "query" + } + ], "responses": { "200": { "description": "Skills列表", @@ -11913,12 +12918,6 @@ "type": "object", "additionalProperties": true } - }, - "500": { - "description": "服务器错误", - "schema": { - "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" - } } } } @@ -13021,6 +14020,74 @@ } } }, + "/system/admin/users/create": { + "post": { + "description": "Provision a new local user account (SystemAdmin only).\nWhen `password` is omitted or null, a cryptographically random\npassword is generated (OIDC-style crypto/rand + base64url)\nand returned once in the response body. Any provided value,\nincluding empty string, is policy-checked. Tenant provisioning\nfollows the shared auth.default_tenant_mode policy.", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "System Admin" + ], + "summary": "Create a new user (SystemAdmin)", + "parameters": [ + { + "description": "User creation request", + "name": "request", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_types.AdminCreateUserRequest" + } + } + ], + "responses": { + "200": { + "description": "Identity already exists, returns the existing user", + "schema": { + "$ref": "#/definitions/internal_handler.CreateSystemUserResponse" + } + }, + "201": { + "description": "User created successfully", + "schema": { + "$ref": "#/definitions/internal_handler.CreateSystemUserResponse" + } + }, + "400": { + "description": "Invalid request or weak password", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "403": { + "description": "Forbidden: not a system admin", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "409": { + "description": "Email and username refer to conflicting identities", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "500": { + "description": "Internal error", + "schema": { + "type": "object", + "additionalProperties": true + } + } + } + } + }, "/system/admin/users/reset-password": { "post": { "description": "Replace another user's local password and revoke all of their existing sessions (SystemAdmin only).\nA system administrator cannot reset their own password through this endpoint; self-service password change still requires the old password.", @@ -15706,6 +16773,26 @@ } } }, + "github_com_Tencent_WeKnora_internal_types.AdminCreateUserRequest": { + "type": "object", + "required": [ + "email", + "username" + ], + "properties": { + "email": { + "type": "string" + }, + "password": { + "type": "string" + }, + "username": { + "type": "string", + "maxLength": 50, + "minLength": 2 + } + } + }, "github_com_Tencent_WeKnora_internal_types.AgentStep": { "type": "object", "properties": { @@ -15768,6 +16855,7 @@ "system.admin_promoted", "system.admin_revoked", "system.user_password_reset", + "system.user_created", "system.api_key_created", "system.api_key_revoked", "system.queue_task_retried", @@ -15831,6 +16919,7 @@ "AuditActionSystemAdminPromoted", "AuditActionSystemAdminRevoked", "AuditActionSystemUserPasswordReset", + "AuditActionSystemUserCreated", "AuditActionSystemAPIKeyCreated", "AuditActionSystemAPIKeyRevoked", "AuditActionSystemQueueTaskRetried", @@ -16385,6 +17474,10 @@ "type": "string" } }, + "memory_enabled": { + "description": "Whether this agent may read the user's long-term memory. Nil inherits\nthe workspace setting; false opts a single agent out of memory even when\nthe workspace has it on. There is no \"on\" that overrides the workspace.", + "type": "boolean" + }, "model_id": { "description": "===== Model Settings =====\nModel ID to use for conversations", "type": "string" @@ -16610,8 +17703,44 @@ "github_com_Tencent_WeKnora_internal_types.DockerSandboxConfig": { "type": "object", "properties": { + "cpu_limit": { + "description": "CPULimit is the number of CPU cores one sandbox may use. 0 uses the\nbuilt-in default.", + "type": "number" + }, + "host": { + "description": "Host is the daemon endpoint in DOCKER_HOST form. Empty means the local\nunix socket.", + "type": "string" + }, + "http_timeout_sec": { + "description": "HTTPTimeoutSec bounds each Engine API call. 0 uses the built-in default.", + "type": "integer" + }, + "idle_ttl_seconds": { + "description": "IdleTTLSeconds is how long a session container may go unused before it\nis reclaimed. The daemon has no idle timeout of its own, so this is what\nstops an abandoned session from pinning host memory indefinitely.", + "type": "integer" + }, "image": { "type": "string" + }, + "memory_limit_mb": { + "description": "MemoryLimitMB caps one sandbox's memory. 0 uses the built-in default.", + "type": "integer" + }, + "network_mode": { + "description": "NetworkMode is the Docker network sandboxes join: \"bridge\" (default) or\n\"none\" for no egress. Nothing else is accepted — host and container:\nmodes share another namespace outright, and a named network is usually\nthe deployment's own compose network, which would put the sandbox next\nto Postgres and Redis.", + "type": "string" + }, + "pids_limit": { + "description": "PidsLimit caps how many processes one sandbox may run. 0 uses the\nbuilt-in default.", + "type": "integer" + }, + "runtime": { + "description": "Runtime selects an alternative OCI runtime such as \"runsc\" (gVisor).\nEmpty uses the daemon default.", + "type": "string" + }, + "tls_cert_path": { + "description": "TLSCertPath is a directory on the WeKnora host containing ca.pem,\ncert.pem and key.pem. Required when Host is a TCP endpoint.", + "type": "string" } } }, @@ -17156,147 +18285,6 @@ } } }, - "github_com_Tencent_WeKnora_internal_types.Knowledge": { - "type": "object", - "properties": { - "channel": { - "description": "Channel indicates through which channel the knowledge was ingested (web, api, browser_extension, wechat, etc.)", - "type": "string" - }, - "created_at": { - "description": "Creation time of the knowledge", - "type": "string" - }, - "custom_metadata": { - "description": "CustomMetadata is user-authored descriptive metadata. It is deliberately\nseparate from Metadata, which contains internal ingestion state and IDs.", - "type": "array", - "items": { - "type": "integer" - } - }, - "deleted_at": { - "description": "Deletion time of the knowledge", - "allOf": [ - { - "$ref": "#/definitions/gorm.DeletedAt" - } - ] - }, - "description": { - "description": "Description of the knowledge", - "type": "string" - }, - "embedding_model_id": { - "description": "ID of the embedding model", - "type": "string" - }, - "enable_status": { - "description": "Enable status of the knowledge", - "type": "string" - }, - "error_message": { - "description": "Error message of the knowledge", - "type": "string" - }, - "file_hash": { - "description": "File hash of the knowledge", - "type": "string" - }, - "file_name": { - "description": "File name of the knowledge", - "type": "string" - }, - "file_path": { - "description": "File path of the knowledge", - "type": "string" - }, - "file_size": { - "description": "File size of the knowledge", - "type": "integer" - }, - "file_type": { - "description": "File type of the knowledge", - "type": "string" - }, - "folder_path": { - "description": "FolderPath is the canonical relative directory this entry belongs to\ninside the knowledge base, e.g. \"docs/spec\" for a folder upload of\n\"docs/spec/design.md\". Empty means the knowledge base root. It is a\ndisplay/navigation concern only: it never affects where the file is\nphysically stored (see FilePath).", - "type": "string" - }, - "id": { - "description": "Unique identifier of the knowledge", - "type": "string" - }, - "knowledge_base_id": { - "description": "ID of the knowledge base", - "type": "string" - }, - "knowledge_base_name": { - "description": "Knowledge base name (not stored in database, populated on query)", - "type": "string" - }, - "last_faq_import_result": { - "description": "Last FAQ import result (for FAQ type knowledge only)", - "type": "array", - "items": { - "type": "integer" - } - }, - "metadata": { - "description": "Metadata of the knowledge", - "type": "array", - "items": { - "type": "integer" - } - }, - "parse_status": { - "description": "Parse status of the knowledge", - "type": "string" - }, - "pending_subtasks_count": { - "description": "PendingSubtasksCount is the outstanding enrichment subtask count\n(summary + question + graph chunks). Only meaningful while\nParseStatus == \"finalizing\"; defaults to 0 in any terminal state.", - "type": "integer" - }, - "processed_at": { - "description": "Processed time of the knowledge", - "type": "string" - }, - "source": { - "description": "Source of the knowledge (e.g. URL address for url type, \"manual\" for manual type)", - "type": "string" - }, - "storage_size": { - "description": "Storage size of the knowledge", - "type": "integer" - }, - "summary_status": { - "description": "Summary status for async summary generation", - "type": "string" - }, - "tags": { - "description": "Tags holds the tags associated with this knowledge (populated on query, not persisted directly).", - "type": "array", - "items": { - "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_types.KnowledgeTag" - } - }, - "tenant_id": { - "description": "Workspace ID", - "type": "integer" - }, - "title": { - "description": "Title of the knowledge", - "type": "string" - }, - "type": { - "description": "Type of the knowledge", - "type": "string" - }, - "updated_at": { - "description": "Last updated time of the knowledge", - "type": "string" - } - } - }, "github_com_Tencent_WeKnora_internal_types.KnowledgeBase": { "type": "object", "properties": { @@ -17687,47 +18675,6 @@ } } }, - "github_com_Tencent_WeKnora_internal_types.KnowledgeTag": { - "type": "object", - "properties": { - "color": { - "description": "Optional display color", - "type": "string" - }, - "created_at": { - "description": "Creation time", - "type": "string" - }, - "id": { - "description": "Unique identifier of the tag (UUID)", - "type": "string" - }, - "knowledge_base_id": { - "description": "Knowledge base ID that this tag belongs to", - "type": "string" - }, - "name": { - "description": "Tag name, unique within the same knowledge base", - "type": "string" - }, - "seq_id": { - "description": "SeqID is an auto-increment integer ID for external API usage", - "type": "integer" - }, - "sort_order": { - "description": "Sort order within the same knowledge base", - "type": "integer" - }, - "tenant_id": { - "description": "Workspace ID", - "type": "integer" - }, - "updated_at": { - "description": "Last updated time", - "type": "string" - } - } - }, "github_com_Tencent_WeKnora_internal_types.ListMembersResponse": { "type": "object", "properties": { @@ -18111,6 +19058,55 @@ } } }, + "github_com_Tencent_WeKnora_internal_types.MemoryConfig": { + "type": "object", + "properties": { + "embedding_model_id": { + "description": "EmbeddingModelID is the single model used to score memory against a\nquestion. It is pinned per workspace: knowledge bases each have their\nown embedding model, and grabbing whichever one happens to be listed\nfirst would mix incomparable vector spaces. Blank means semantic recall\nis off and matching stays lexical.", + "type": "string" + }, + "enabled": { + "description": "Enabled defaults to false. Memory retains user statements across\nsessions, so a workspace admin has to turn it on deliberately.", + "type": "boolean" + }, + "extract_delay_seconds": { + "description": "ExtractDelaySeconds is how long a finished turn waits before\ndistillation runs. Waiting lets one model call cover the several\nmessages a user usually sends in a row. 0 means the default.", + "type": "integer" + }, + "extract_instructions": { + "description": "ExtractInstructions are workspace-specific rules appended to the\ndistillation prompt, for policies the product cannot guess (\"never record\ncustomer names\", \"always note the environment a question is about\").", + "type": "string" + }, + "extract_min_interval_seconds": { + "description": "ExtractMinIntervalSeconds is the floor between two distillation runs for\nthe same person, and exists purely to bound cost. It never drops a turn:\na turn arriving inside the interval is queued and picked up by the next\nrun. 0 means the default.", + "type": "integer" + }, + "extract_model_id": { + "description": "ExtractModelID is the model used by the background extraction task.\nEmpty means \"use the model the conversation itself used\", which is what\nthe settings UI promises, so the extraction task must never fail merely\nbecause this is blank.", + "type": "string" + }, + "interest_threshold": { + "description": "InterestThreshold is how many separate conversations must touch a topic\nbefore it becomes a stored interest. 0 means the default. Setting it to 1\nrecords every topic on first sight, which is usually too noisy.", + "type": "integer" + }, + "max_items": { + "description": "MaxItems caps active items per subject. 0 means DefaultMemoryMaxItems.", + "type": "integer" + }, + "retrieval_conditioning": { + "description": "RetrievalConditioning lets memory shape retrieval — query rewriting and\nper-document ranking — rather than only being appended to the answer\nprompt. This is where memory earns its keep in a knowledge-base product.", + "type": "boolean" + }, + "vector_recall": { + "description": "VectorRecall adds semantic similarity to memory recall. Nil means on\nwhen an embedding model is reachable.\n\nLexical matching alone cannot find a memory the user has re-worded, which\nis most of them: \"回答直接给结论\" and \"别铺垫那么多\" share no tokens. The\ncost is one embedding call per turn, bounded and degraded to lexical on\nfailure, so the feature never becomes a reason a chat is slow.", + "type": "boolean" + }, + "write_mode": { + "description": "WriteMode is MemoryWriteExplicitOnly or MemoryWriteAuto.", + "type": "string" + } + } + }, "github_com_Tencent_WeKnora_internal_types.MentionedItem": { "type": "object", "properties": { @@ -18254,6 +19250,21 @@ "updated_at": { "description": "Last update timestamp", "type": "string" + }, + "usage": { + "description": "LLM token usage aggregated across every round of the turn that produced this\nassistant message. Persisted so history reads can attribute cost after the\nlive stream is gone; NULL (nil) for user messages and pre-feature rows.", + "allOf": [ + { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_types.TokenUsage" + } + ] + }, + "used_memories": { + "description": "UsedMemories records which long-term memories were injected into this\nanswer, so the chat UI can show them and let the user delete one on the\nspot. Persisted rather than only streamed so reopening a conversation\nstill explains what the answer saw.", + "type": "array", + "items": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_types.UsedMemory" + } } } }, @@ -18877,6 +19888,21 @@ } } }, + "github_com_Tencent_WeKnora_internal_types.PromptCacheStatus": { + "type": "string", + "enum": [ + "unsupported", + "unreported", + "miss", + "hit" + ], + "x-enum-varnames": [ + "PromptCacheStatusUnsupported", + "PromptCacheStatusUnreported", + "PromptCacheStatusMiss", + "PromptCacheStatusHit" + ] + }, "github_com_Tencent_WeKnora_internal_types.QuestionGenerationConfig": { "type": "object", "properties": { @@ -19684,6 +20710,31 @@ } } }, + "github_com_Tencent_WeKnora_internal_types.SkillImageConfig": { + "type": "object", + "properties": { + "base_template_id": { + "description": "BaseTemplateID is the template this chain was originally built from;\nthe rebuild path starts over from it.", + "type": "string" + }, + "built_at": { + "description": "BuiltAt records when this generation was produced.", + "type": "string" + }, + "generation": { + "description": "Generation increments on every successful install/remove, for naming\nand troubleshooting.", + "type": "integer" + }, + "owner_fingerprint": { + "description": "OwnerFingerprint identifies the provider account that owns the snapshot.\nSnapshots are invisible across accounts, so a mismatch means \"fall back\nto the base template\" rather than \"fail\".", + "type": "string" + }, + "snapshot_id": { + "description": "SnapshotID is the currently effective snapshot; empty = base template.", + "type": "string" + } + } + }, "github_com_Tencent_WeKnora_internal_types.StarterSuggestionConfig": { "type": "object", "properties": { @@ -20083,6 +21134,14 @@ "description": "ID", "type": "integer" }, + "memory_config": { + "description": "Memory config: workspace switch for cross-session long-term memory", + "allOf": [ + { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_types.MemoryConfig" + } + ] + }, "name": { "description": "Name", "type": "string" @@ -20191,6 +21250,18 @@ "description": "SandboxType selects the sandbox backend. Named configs may use \"cube\",\n\"e2b\", \"docker\", or \"local\". \"disabled\" is reserved for the hidden\nworkspace policy row.", "type": "string" }, + "skill_image": { + "description": "SkillImage points at the snapshot that carries this config's installed\nskills. Empty means \"use the base template\". Written only by the skill\ninstall/remove path: MergeSandboxConfigForUpdate ignores client values\nso a settings-form save cannot wipe or plant the pointer.", + "allOf": [ + { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_types.SkillImageConfig" + } + ] + }, + "skill_rollout": { + "description": "SkillRollout decides whether sessions that already hold a sandbox of\nthis config rebuild after a skill install or removal. Empty and\nSkillRolloutNextTurn rebuild on the next chat turn. SkillRolloutNewSession\nleaves those sandboxes on the previous image; only sessions that start\nafterwards boot the new snapshot.", + "type": "string" + }, "volume_mount": { "description": "VolumeMount configures an optional shared volume mounted into every\nsandbox created for this tenant. Currently used for tenant-installed\nskills, but the configuration itself is skill-agnostic and can serve\nany volume-mount use case (shared datasets, pre-installed toolchains,\netc.).", "allOf": [ @@ -20201,6 +21272,39 @@ } } }, + "github_com_Tencent_WeKnora_internal_types.TokenUsage": { + "type": "object", + "properties": { + "cache_miss_tokens": { + "type": "integer" + }, + "cache_read_tokens": { + "type": "integer" + }, + "cache_reported": { + "type": "boolean" + }, + "cache_status": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_types.PromptCacheStatus" + }, + "cache_write_tokens": { + "type": "integer" + }, + "cached_tokens": { + "description": "CachedTokens is the legacy alias for CacheReadTokens. It remains on the\nwire for compatibility with existing API consumers.", + "type": "integer" + }, + "completion_tokens": { + "type": "integer" + }, + "prompt_tokens": { + "type": "integer" + }, + "total_tokens": { + "type": "integer" + } + } + }, "github_com_Tencent_WeKnora_internal_types.ToolCall": { "type": "object", "properties": { @@ -20337,6 +21441,20 @@ } } }, + "github_com_Tencent_WeKnora_internal_types.UsedMemory": { + "type": "object", + "properties": { + "content": { + "type": "string" + }, + "id": { + "type": "string" + }, + "kind": { + "type": "string" + } + } + }, "github_com_Tencent_WeKnora_internal_types.User": { "type": "object", "properties": { @@ -20915,6 +22033,10 @@ "description": "populated in ego mode", "type": "integer" }, + "familiar_count": { + "description": "FamiliarCount is how many returned nodes are lit up for this person.", + "type": "integer" + }, "mode": { "type": "string" }, @@ -20935,6 +22057,10 @@ "github_com_Tencent_WeKnora_internal_types.WikiGraphNode": { "type": "object", "properties": { + "familiar": { + "description": "Familiar is true when this page was built from a document this person\nkeeps citing in answers. It is a personal overlay, not a property of\nthe page: two people looking at the same wiki see different highlights.", + "type": "boolean" + }, "link_count": { "description": "Number of inbound + outbound links", "type": "integer" @@ -21528,6 +22654,18 @@ } } }, + "internal_handler.CreateSystemUserResponse": { + "type": "object", + "properties": { + "generated_password": { + "description": "GeneratedPassword is the plaintext password when the server\nauto-generated one. Absent when the caller supplied the password.", + "type": "string" + }, + "user": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_types.UserInfo" + } + } + }, "internal_handler.DeleteTagRequest": { "type": "object", "properties": { @@ -22753,6 +23891,23 @@ } } }, + "internal_handler.UpdateKnowledgeRequest": { + "type": "object", + "properties": { + "custom_metadata": { + "type": "array", + "items": { + "type": "integer" + } + }, + "description": { + "type": "string" + }, + "title": { + "type": "string" + } + } + }, "internal_handler.UpdateModelRequest": { "type": "object", "properties": { @@ -23068,6 +24223,24 @@ } } }, + "internal_handler.skillPatchRequest": { + "type": "object", + "properties": { + "enabled": { + "description": "Enabled is a pointer because its absence is a bad request rather than a\nrequest to disable the skill.", + "type": "boolean" + } + } + }, + "internal_handler.skillSourceRequest": { + "type": "object", + "properties": { + "source": { + "description": "Source is a ClawHub/SkillHub slug or page URL, a skills.sh / GitHub /\nGitLab locator, or a direct zip/SKILL.md URL. It must be readable\nanonymously: the fetch carries no credential of any kind.", + "type": "string" + } + } + }, "internal_handler.storageBackendRequest": { "type": "object", "required": [ @@ -23411,4 +24584,4 @@ "in": "header" } } -} +} \ No newline at end of file diff --git a/docs/swagger.yaml b/docs/swagger.yaml index 6ed28308..d8e4f45b 100644 --- a/docs/swagger.yaml +++ b/docs/swagger.yaml @@ -240,6 +240,20 @@ definitions: model_id: type: string type: object + github_com_Tencent_WeKnora_internal_types.AdminCreateUserRequest: + properties: + email: + type: string + password: + type: string + username: + maxLength: 50 + minLength: 2 + type: string + required: + - email + - username + type: object github_com_Tencent_WeKnora_internal_types.AgentStep: properties: iteration: @@ -294,6 +308,7 @@ definitions: - system.admin_promoted - system.admin_revoked - system.user_password_reset + - system.user_created - system.api_key_created - system.api_key_revoked - system.queue_task_retried @@ -357,6 +372,7 @@ definitions: - AuditActionSystemAdminPromoted - AuditActionSystemAdminRevoked - AuditActionSystemUserPasswordReset + - AuditActionSystemUserCreated - AuditActionSystemAPIKeyCreated - AuditActionSystemAPIKeyRevoked - AuditActionSystemQueueTaskRetried @@ -869,6 +885,12 @@ definitions: items: type: string type: array + memory_enabled: + description: |- + Whether this agent may read the user's long-term memory. Nil inherits + the workspace setting; false opts a single agent out of memory even when + the workspace has it on. There is no "on" that overrides the workspace. + type: boolean model_id: description: |- ===== Model Settings ===== @@ -1068,8 +1090,55 @@ definitions: type: object github_com_Tencent_WeKnora_internal_types.DockerSandboxConfig: properties: + cpu_limit: + description: |- + CPULimit is the number of CPU cores one sandbox may use. 0 uses the + built-in default. + type: number + host: + description: |- + Host is the daemon endpoint in DOCKER_HOST form. Empty means the local + unix socket. + type: string + http_timeout_sec: + description: HTTPTimeoutSec bounds each Engine API call. 0 uses the built-in + default. + type: integer + idle_ttl_seconds: + description: |- + IdleTTLSeconds is how long a session container may go unused before it + is reclaimed. The daemon has no idle timeout of its own, so this is what + stops an abandoned session from pinning host memory indefinitely. + type: integer image: type: string + memory_limit_mb: + description: MemoryLimitMB caps one sandbox's memory. 0 uses the built-in + default. + type: integer + network_mode: + description: |- + NetworkMode is the Docker network sandboxes join: "bridge" (default) or + "none" for no egress. Nothing else is accepted — host and container: + modes share another namespace outright, and a named network is usually + the deployment's own compose network, which would put the sandbox next + to Postgres and Redis. + type: string + pids_limit: + description: |- + PidsLimit caps how many processes one sandbox may run. 0 uses the + built-in default. + type: integer + runtime: + description: |- + Runtime selects an alternative OCI runtime such as "runsc" (gVisor). + Empty uses the daemon default. + type: string + tls_cert_path: + description: |- + TLSCertPath is a directory on the WeKnora host containing ca.pem, + cert.pem and key.pem. Required when Host is a TCP endpoint. + type: string type: object github_com_Tencent_WeKnora_internal_types.E2BSandboxConfig: properties: @@ -1464,121 +1533,6 @@ definitions: secret_key: type: string type: object - github_com_Tencent_WeKnora_internal_types.Knowledge: - properties: - channel: - description: Channel indicates through which channel the knowledge was ingested - (web, api, browser_extension, wechat, etc.) - type: string - created_at: - description: Creation time of the knowledge - type: string - custom_metadata: - description: |- - CustomMetadata is user-authored descriptive metadata. It is deliberately - separate from Metadata, which contains internal ingestion state and IDs. - items: - type: integer - type: array - deleted_at: - allOf: - - $ref: '#/definitions/gorm.DeletedAt' - description: Deletion time of the knowledge - description: - description: Description of the knowledge - type: string - embedding_model_id: - description: ID of the embedding model - type: string - enable_status: - description: Enable status of the knowledge - type: string - error_message: - description: Error message of the knowledge - type: string - file_hash: - description: File hash of the knowledge - type: string - file_name: - description: File name of the knowledge - type: string - file_path: - description: File path of the knowledge - type: string - file_size: - description: File size of the knowledge - type: integer - file_type: - description: File type of the knowledge - type: string - folder_path: - description: |- - FolderPath is the canonical relative directory this entry belongs to - inside the knowledge base, e.g. "docs/spec" for a folder upload of - "docs/spec/design.md". Empty means the knowledge base root. It is a - display/navigation concern only: it never affects where the file is - physically stored (see FilePath). - type: string - id: - description: Unique identifier of the knowledge - type: string - knowledge_base_id: - description: ID of the knowledge base - type: string - knowledge_base_name: - description: Knowledge base name (not stored in database, populated on query) - type: string - last_faq_import_result: - description: Last FAQ import result (for FAQ type knowledge only) - items: - type: integer - type: array - metadata: - description: Metadata of the knowledge - items: - type: integer - type: array - parse_status: - description: Parse status of the knowledge - type: string - pending_subtasks_count: - description: |- - PendingSubtasksCount is the outstanding enrichment subtask count - (summary + question + graph chunks). Only meaningful while - ParseStatus == "finalizing"; defaults to 0 in any terminal state. - type: integer - processed_at: - description: Processed time of the knowledge - type: string - source: - description: Source of the knowledge (e.g. URL address for url type, "manual" - for manual type) - type: string - storage_size: - description: Storage size of the knowledge - type: integer - summary_status: - description: Summary status for async summary generation - type: string - tags: - description: Tags holds the tags associated with this knowledge (populated - on query, not persisted directly). - items: - $ref: '#/definitions/github_com_Tencent_WeKnora_internal_types.KnowledgeTag' - type: array - tenant_id: - description: Workspace ID - type: integer - title: - description: Title of the knowledge - type: string - type: - description: Type of the knowledge - type: string - updated_at: - description: Last updated time of the knowledge - type: string - type: object github_com_Tencent_WeKnora_internal_types.KnowledgeBase: properties: asr_config: @@ -1867,36 +1821,6 @@ definitions: vlm_config: $ref: '#/definitions/github_com_Tencent_WeKnora_internal_types.VLMConfig' type: object - github_com_Tencent_WeKnora_internal_types.KnowledgeTag: - properties: - color: - description: Optional display color - type: string - created_at: - description: Creation time - type: string - id: - description: Unique identifier of the tag (UUID) - type: string - knowledge_base_id: - description: Knowledge base ID that this tag belongs to - type: string - name: - description: Tag name, unique within the same knowledge base - type: string - seq_id: - description: SeqID is an auto-increment integer ID for external API usage - type: integer - sort_order: - description: Sort order within the same knowledge base - type: integer - tenant_id: - description: Workspace ID - type: integer - updated_at: - description: Last updated time - type: string - type: object github_com_Tencent_WeKnora_internal_types.ListMembersResponse: properties: members: @@ -2182,6 +2106,76 @@ definitions: tenant_name: type: string type: object + github_com_Tencent_WeKnora_internal_types.MemoryConfig: + properties: + embedding_model_id: + description: |- + EmbeddingModelID is the single model used to score memory against a + question. It is pinned per workspace: knowledge bases each have their + own embedding model, and grabbing whichever one happens to be listed + first would mix incomparable vector spaces. Blank means semantic recall + is off and matching stays lexical. + type: string + enabled: + description: |- + Enabled defaults to false. Memory retains user statements across + sessions, so a workspace admin has to turn it on deliberately. + type: boolean + extract_delay_seconds: + description: |- + ExtractDelaySeconds is how long a finished turn waits before + distillation runs. Waiting lets one model call cover the several + messages a user usually sends in a row. 0 means the default. + type: integer + extract_instructions: + description: |- + ExtractInstructions are workspace-specific rules appended to the + distillation prompt, for policies the product cannot guess ("never record + customer names", "always note the environment a question is about"). + type: string + extract_min_interval_seconds: + description: |- + ExtractMinIntervalSeconds is the floor between two distillation runs for + the same person, and exists purely to bound cost. It never drops a turn: + a turn arriving inside the interval is queued and picked up by the next + run. 0 means the default. + type: integer + extract_model_id: + description: |- + ExtractModelID is the model used by the background extraction task. + Empty means "use the model the conversation itself used", which is what + the settings UI promises, so the extraction task must never fail merely + because this is blank. + type: string + interest_threshold: + description: |- + InterestThreshold is how many separate conversations must touch a topic + before it becomes a stored interest. 0 means the default. Setting it to 1 + records every topic on first sight, which is usually too noisy. + type: integer + max_items: + description: MaxItems caps active items per subject. 0 means DefaultMemoryMaxItems. + type: integer + retrieval_conditioning: + description: |- + RetrievalConditioning lets memory shape retrieval — query rewriting and + per-document ranking — rather than only being appended to the answer + prompt. This is where memory earns its keep in a knowledge-base product. + type: boolean + vector_recall: + description: |- + VectorRecall adds semantic similarity to memory recall. Nil means on + when an embedding model is reachable. + + Lexical matching alone cannot find a memory the user has re-worded, which + is most of them: "回答直接给结论" and "别铺垫那么多" share no tokens. The + cost is one embedding call per turn, bounded and degraded to lexical on + failure, so the feature never becomes a reason a chat is slow. + type: boolean + write_mode: + description: WriteMode is MemoryWriteExplicitOnly or MemoryWriteAuto. + type: string + type: object github_com_Tencent_WeKnora_internal_types.MentionedItem: properties: id: @@ -2302,6 +2296,22 @@ definitions: updated_at: description: Last update timestamp type: string + usage: + allOf: + - $ref: '#/definitions/github_com_Tencent_WeKnora_internal_types.TokenUsage' + description: |- + LLM token usage aggregated across every round of the turn that produced this + assistant message. Persisted so history reads can attribute cost after the + live stream is gone; NULL (nil) for user messages and pre-feature rows. + used_memories: + description: |- + UsedMemories records which long-term memories were injected into this + answer, so the chat UI can show them and let the user delete one on the + spot. Persisted rather than only streamed so reopening a conversation + still explains what the answer saw. + items: + $ref: '#/definitions/github_com_Tencent_WeKnora_internal_types.UsedMemory' + type: array type: object github_com_Tencent_WeKnora_internal_types.MessageArtifact: properties: @@ -2779,6 +2789,18 @@ definitions: nil preserves the parser default; an explicit false disables the mode. type: boolean type: object + github_com_Tencent_WeKnora_internal_types.PromptCacheStatus: + enum: + - unsupported + - unreported + - miss + - hit + type: string + x-enum-varnames: + - PromptCacheStatusUnsupported + - PromptCacheStatusUnreported + - PromptCacheStatusMiss + - PromptCacheStatusHit github_com_Tencent_WeKnora_internal_types.QuestionGenerationConfig: properties: custom_instructions: @@ -3394,6 +3416,32 @@ definitions: - organization_id - permission type: object + github_com_Tencent_WeKnora_internal_types.SkillImageConfig: + properties: + base_template_id: + description: |- + BaseTemplateID is the template this chain was originally built from; + the rebuild path starts over from it. + type: string + built_at: + description: BuiltAt records when this generation was produced. + type: string + generation: + description: |- + Generation increments on every successful install/remove, for naming + and troubleshooting. + type: integer + owner_fingerprint: + description: |- + OwnerFingerprint identifies the provider account that owns the snapshot. + Snapshots are invisible across accounts, so a mismatch means "fall back + to the base template" rather than "fail". + type: string + snapshot_id: + description: SnapshotID is the currently effective snapshot; empty = base + template. + type: string + type: object github_com_Tencent_WeKnora_internal_types.StarterSuggestionConfig: properties: count: @@ -3690,6 +3738,11 @@ definitions: id: description: ID type: integer + memory_config: + allOf: + - $ref: '#/definitions/github_com_Tencent_WeKnora_internal_types.MemoryConfig' + description: 'Memory config: workspace switch for cross-session long-term + memory' name: description: Name type: string @@ -3775,6 +3828,22 @@ definitions: "e2b", "docker", or "local". "disabled" is reserved for the hidden workspace policy row. type: string + skill_image: + allOf: + - $ref: '#/definitions/github_com_Tencent_WeKnora_internal_types.SkillImageConfig' + description: |- + SkillImage points at the snapshot that carries this config's installed + skills. Empty means "use the base template". Written only by the skill + install/remove path: MergeSandboxConfigForUpdate ignores client values + so a settings-form save cannot wipe or plant the pointer. + skill_rollout: + description: |- + SkillRollout decides whether sessions that already hold a sandbox of + this config rebuild after a skill install or removal. Empty and + SkillRolloutNextTurn rebuild on the next chat turn. SkillRolloutNewSession + leaves those sandboxes on the previous image; only sessions that start + afterwards boot the new snapshot. + type: string volume_mount: allOf: - $ref: '#/definitions/github_com_Tencent_WeKnora_internal_types.VolumeMountConfig' @@ -3785,6 +3854,30 @@ definitions: any volume-mount use case (shared datasets, pre-installed toolchains, etc.). type: object + github_com_Tencent_WeKnora_internal_types.TokenUsage: + properties: + cache_miss_tokens: + type: integer + cache_read_tokens: + type: integer + cache_reported: + type: boolean + cache_status: + $ref: '#/definitions/github_com_Tencent_WeKnora_internal_types.PromptCacheStatus' + cache_write_tokens: + type: integer + cached_tokens: + description: |- + CachedTokens is the legacy alias for CacheReadTokens. It remains on the + wire for compatibility with existing API consumers. + type: integer + completion_tokens: + type: integer + prompt_tokens: + type: integer + total_tokens: + type: integer + type: object github_com_Tencent_WeKnora_internal_types.ToolCall: properties: args: @@ -3878,6 +3971,15 @@ definitions: required: - permission type: object + github_com_Tencent_WeKnora_internal_types.UsedMemory: + properties: + content: + type: string + id: + type: string + kind: + type: string + type: object github_com_Tencent_WeKnora_internal_types.User: properties: avatar: @@ -4350,6 +4452,10 @@ definitions: depth: description: populated in ego mode type: integer + familiar_count: + description: FamiliarCount is how many returned nodes are lit up for this + person. + type: integer mode: type: string returned: @@ -4364,6 +4470,12 @@ definitions: type: object github_com_Tencent_WeKnora_internal_types.WikiGraphNode: properties: + familiar: + description: |- + Familiar is true when this page was built from a document this person + keeps citing in answers. It is a personal overlay, not a property of + the page: two people looking at the same wiki see different highlights. + type: boolean link_count: description: Number of inbound + outbound links type: integer @@ -4808,6 +4920,16 @@ definitions: - engine_type - name type: object + internal_handler.CreateSystemUserResponse: + properties: + generated_password: + description: |- + GeneratedPassword is the plaintext password when the server + auto-generated one. Absent when the caller supplied the password. + type: string + user: + $ref: '#/definitions/github_com_Tencent_WeKnora_internal_types.UserInfo' + type: object internal_handler.DeleteTagRequest: properties: exclude_ids: @@ -5668,6 +5790,17 @@ definitions: required: - name type: object + internal_handler.UpdateKnowledgeRequest: + properties: + custom_metadata: + items: + type: integer + type: array + description: + type: string + title: + type: string + type: object internal_handler.UpdateModelRequest: properties: description: @@ -5878,6 +6011,23 @@ definitions: required: - name type: object + internal_handler.skillPatchRequest: + properties: + enabled: + description: |- + Enabled is a pointer because its absence is a bad request rather than a + request to disable the skill. + type: boolean + type: object + internal_handler.skillSourceRequest: + properties: + source: + description: |- + Source is a ClawHub/SkillHub slug or page URL, a skills.sh / GitHub / + GitLab locator, or a direct zip/SKILL.md URL. It must be readable + anonymously: the fetch carries no credential of any kind. + type: string + type: object internal_handler.storageBackendRequest: properties: config: @@ -10018,6 +10168,44 @@ paths: summary: 知识问答 tags: - 问答 + /knowledge-search: + post: + consumes: + - application/json + description: 在知识库中搜索(不使用LLM总结) + parameters: + - description: 搜索请求 + in: body + name: request + required: true + schema: + $ref: '#/definitions/internal_handler_session.SearchKnowledgeRequest' + - default: handle + description: 文件引用形式,public 返回可加载直链 + enum: + - handle + - public + in: query + name: resource_urls + type: string + produces: + - application/json + responses: + "200": + description: 搜索结果 + schema: + additionalProperties: true + type: object + "400": + description: 请求参数错误 + schema: + $ref: '#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError' + security: + - Bearer: [] + - ApiKeyAuth: [] + summary: 知识搜索 + tags: + - 问答 /knowledge/{id}: delete: consumes: @@ -10084,19 +10272,19 @@ paths: put: consumes: - application/json - description: 更新知识条目信息 + description: 部分更新知识条目(标题/描述/自定义元数据);未传字段保持不变,显式传空 description 可清空摘要 parameters: - description: 知识ID in: path name: id required: true type: string - - description: 知识信息 + - description: 更新字段(均可选) in: body name: request required: true schema: - $ref: '#/definitions/github_com_Tencent_WeKnora_internal_types.Knowledge' + $ref: '#/definitions/internal_handler.UpdateKnowledgeRequest' produces: - application/json responses: @@ -10537,12 +10725,15 @@ paths: in: query name: keyword type: string - - description: Offset for pagination + - description: Offset for pagination (minimum 0) in: query + minimum: 0 name: offset type: integer - - description: Limit for pagination (default 20) + - description: Limit for pagination (default 20, maximum 100) in: query + maximum: 100 + minimum: 1 name: limit type: integer - description: Comma-separated file extensions to filter (e.g., csv,xlsx) @@ -11894,6 +12085,365 @@ paths: summary: 获取我的待处理邀请数 tags: - 我的邀请 + /memory/consolidate: + post: + description: 合并意思接近的条目、归档到期事项,不等待每日后台整理 + produces: + - application/json + responses: + "200": + description: 整理结果 + schema: + additionalProperties: true + type: object + security: + - Bearer: [] + summary: 立刻整理我的记忆 + tags: + - 长期记忆 + /memory/documents: + get: + description: 返回当前用户回答里反复引用的文档,次数未达习惯门槛的不展示 + parameters: + - default: 50 + description: 每页条数 + in: query + name: limit + type: integer + - description: 偏移量 + in: query + name: offset + type: integer + produces: + - application/json + responses: + "200": + description: 文档列表 + schema: + additionalProperties: true + type: object + security: + - Bearer: [] + summary: 列出常用资料 + tags: + - 长期记忆 + /memory/documents/{id}: + delete: + description: 删除一条文档亲和度计数,之后检索不再因为这份文档而加权 + parameters: + - description: 亲和度 ID + in: path + name: id + required: true + type: string + produces: + - application/json + responses: + "200": + description: 删除成功 + schema: + additionalProperties: true + type: object + security: + - Bearer: [] + summary: 停止用某份文档做个性化检索 + tags: + - 长期记忆 + /memory/export: + get: + description: 以 JSON 导出当前用户的全部记忆 + produces: + - application/json + responses: + "200": + description: 记忆导出 + schema: + additionalProperties: true + type: object + security: + - Bearer: [] + summary: 导出我的记忆 + tags: + - 长期记忆 + /memory/items: + delete: + description: 永久删除当前用户的全部记忆 + produces: + - application/json + responses: + "200": + description: 清空成功 + schema: + additionalProperties: true + type: object + security: + - Bearer: [] + summary: 清空我的记忆 + tags: + - 长期记忆 + get: + description: 分页返回当前用户的记忆条目,可按状态过滤 + parameters: + - description: 状态过滤 + enum: + - active + - superseded + - archived + - pending + in: query + name: status + type: string + - default: 50 + description: 每页条数 + in: query + name: limit + type: integer + - description: 偏移量 + in: query + name: offset + type: integer + produces: + - application/json + responses: + "200": + description: 记忆列表 + schema: + additionalProperties: true + type: object + security: + - Bearer: [] + summary: 列出我的记忆 + tags: + - 长期记忆 + post: + consumes: + - application/json + description: 手动添加一条长期记忆 + parameters: + - description: 记忆内容 + in: body + name: request + required: true + schema: + type: object + produces: + - application/json + responses: + "200": + description: 新增的记忆 + schema: + additionalProperties: true + type: object + security: + - Bearer: [] + summary: 新增一条记忆 + tags: + - 长期记忆 + /memory/items/{id}: + delete: + description: 永久删除一条记忆 + parameters: + - description: 记忆ID + in: path + name: id + required: true + type: string + produces: + - application/json + responses: + "200": + description: 删除成功 + schema: + additionalProperties: true + type: object + security: + - Bearer: [] + summary: 删除一条记忆 + tags: + - 长期记忆 + put: + consumes: + - application/json + description: 修改记忆内容与重要度,修改后该条记忆不会被后台抽取覆盖 + parameters: + - description: 记忆ID + in: path + name: id + required: true + type: string + - description: 记忆内容 + in: body + name: request + required: true + schema: + type: object + produces: + - application/json + responses: + "200": + description: 更新后的记忆 + schema: + additionalProperties: true + type: object + security: + - Bearer: [] + summary: 修改一条记忆 + tags: + - 长期记忆 + /memory/items/{id}/confirm: + post: + description: 接受系统推断的记忆,使其开始生效 + parameters: + - description: 记忆 ID + in: path + name: id + required: true + type: string + produces: + - application/json + responses: + "200": + description: 确认成功 + schema: + additionalProperties: true + type: object + security: + - Bearer: [] + summary: 确认一条推断出的记忆 + tags: + - 长期记忆 + /memory/items/{id}/reject: + post: + description: 拒绝系统推断的记忆,并记住这次拒绝 + parameters: + - description: 记忆 ID + in: path + name: id + required: true + type: string + produces: + - application/json + responses: + "200": + description: 否决成功 + schema: + additionalProperties: true + type: object + security: + - Bearer: [] + summary: 否决一条推断出的记忆 + tags: + - 长期记忆 + /memory/settings: + get: + description: 返回合并后的记忆开关状态(空间级 + 个人级)与记忆条数 + produces: + - application/json + responses: + "200": + description: 记忆设置 + schema: + additionalProperties: true + type: object + security: + - Bearer: [] + summary: 获取我的记忆设置 + tags: + - 长期记忆 + put: + consumes: + - application/json + description: 开启或关闭当前用户自己的长期记忆 + parameters: + - description: 设置 + in: body + name: request + required: true + schema: + type: object + produces: + - application/json + responses: + "200": + description: 更新后的设置 + schema: + additionalProperties: true + type: object + security: + - Bearer: [] + summary: 更新我的记忆设置 + tags: + - 长期记忆 + /memory/topics: + get: + description: 返回已计数、尚未提升为长期关注的主题,以及距离阈值还差几次 + parameters: + - default: 50 + description: 每页条数 + in: query + name: limit + type: integer + - description: 偏移量 + in: query + name: offset + type: integer + produces: + - application/json + responses: + "200": + description: 主题列表 + schema: + additionalProperties: true + type: object + security: + - Bearer: [] + summary: 列出正在观察的主题 + tags: + - 长期记忆 + /memory/topics/{id}: + delete: + description: 删除尚未提升的主题计数,并记住这次拒绝,之后不会再自动记为长期关注 + parameters: + - description: 主题 ID + in: path + name: id + required: true + type: string + produces: + - application/json + responses: + "200": + description: 删除成功 + schema: + additionalProperties: true + type: object + security: + - Bearer: [] + summary: 停止跟踪一个主题 + tags: + - 长期记忆 + /memory/topics/{id}/promote: + post: + description: 不等待剩余次数,把正在观察的主题提升为一条长期关注记忆 + parameters: + - description: 主题 ID + in: path + name: id + required: true + type: string + produces: + - application/json + responses: + "200": + description: 新增的记忆 + schema: + additionalProperties: true + type: object + security: + - Bearer: [] + summary: 立即记为长期关注 + tags: + - 长期记忆 /messages/{session_id}/{id}: delete: consumes: @@ -13092,6 +13642,300 @@ paths: summary: Inspect sandbox config inventory tags: - SandboxConfig + /sandbox-configs/{id}/skills: + get: + description: List the agent skills installed onto one sandbox config's image. + parameters: + - description: Sandbox config ID + in: path + name: id + required: true + type: string + produces: + - application/json + responses: + "200": + description: Installed skills + schema: + additionalProperties: true + type: object + "401": + description: Unauthorized + schema: + additionalProperties: true + type: object + "404": + description: Sandbox config not found + schema: + $ref: '#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError' + security: + - Bearer: [] + - ApiKeyAuth: [] + summary: List installed skills + tags: + - SandboxConfig + post: + consumes: + - application/json + - multipart/form-data + description: |- + Install a skill onto this sandbox config's image. Send a zip + as multipart form field "file", or JSON {"source":"..."} to + pull from ClawHub, SkillHub, skills.sh, GitHub, GitLab, or a + direct archive URL. The source must be readable anonymously. + The install boots a sandbox and runs for minutes, so the + request is only accepted; follow it via the install-events + stream. + parameters: + - description: Sandbox config ID + in: path + name: id + required: true + type: string + - description: Skill bundle (zip) + in: formData + name: file + type: file + - description: Install from a registry, git host, or archive URL + in: body + name: request + schema: + $ref: '#/definitions/internal_handler.skillSourceRequest' + produces: + - application/json + responses: + "202": + description: Install accepted + schema: + additionalProperties: true + type: object + "400": + description: Missing, oversized or invalid bundle or source + schema: + $ref: '#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError' + "401": + description: Unauthorized + schema: + additionalProperties: true + type: object + "404": + description: Sandbox config not found + schema: + $ref: '#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError' + security: + - Bearer: [] + - ApiKeyAuth: [] + summary: Install a skill + tags: + - SandboxConfig + /sandbox-configs/{id}/skills/{skillId}: + delete: + description: |- + Remove a skill from the config's image. The removal rebuilds + the image and runs for minutes, so it is only accepted; follow + it via the install-events stream. + parameters: + - description: Sandbox config ID + in: path + name: id + required: true + type: string + - description: Skill ID + in: path + name: skillId + required: true + type: string + produces: + - application/json + responses: + "202": + description: Removal accepted + schema: + additionalProperties: true + type: object + "401": + description: Unauthorized + schema: + additionalProperties: true + type: object + "404": + description: Skill not found + schema: + $ref: '#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError' + security: + - Bearer: [] + - ApiKeyAuth: [] + summary: Remove an installed skill + tags: + - SandboxConfig + get: + description: Retrieve one installed skill of a sandbox config. + parameters: + - description: Sandbox config ID + in: path + name: id + required: true + type: string + - description: Skill ID + in: path + name: skillId + required: true + type: string + produces: + - application/json + responses: + "200": + description: Installed skill + schema: + additionalProperties: true + type: object + "401": + description: Unauthorized + schema: + additionalProperties: true + type: object + "404": + description: Skill not found + schema: + $ref: '#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError' + security: + - Bearer: [] + - ApiKeyAuth: [] + summary: Get an installed skill + tags: + - SandboxConfig + patch: + consumes: + - application/json + description: Show or hide an installed skill. The files stay in the image either + way; removal is a separate flow. + parameters: + - description: Sandbox config ID + in: path + name: id + required: true + type: string + - description: Skill ID + in: path + name: skillId + required: true + type: string + - description: Fields to update + in: body + name: request + required: true + schema: + $ref: '#/definitions/internal_handler.skillPatchRequest' + produces: + - application/json + responses: + "200": + description: Updated skill + schema: + additionalProperties: true + type: object + "400": + description: Invalid request + schema: + $ref: '#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError' + "401": + description: Unauthorized + schema: + additionalProperties: true + type: object + "404": + description: Skill not found + schema: + $ref: '#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError' + security: + - Bearer: [] + - ApiKeyAuth: [] + summary: Update an installed skill + tags: + - SandboxConfig + /sandbox-configs/{id}/skills/{skillId}/install-events: + get: + description: |- + Server-sent progress for one install or removal. The stream + always terminates: with the run's own terminal event, with one + derived from the durable status, or with a "detached" frame + when it stops following a run that is still going. + parameters: + - description: Sandbox config ID + in: path + name: id + required: true + type: string + - description: Skill ID + in: path + name: skillId + required: true + type: string + produces: + - text/event-stream + responses: + "200": + description: SSE stream of progress events + schema: + type: string + "401": + description: Unauthorized + schema: + additionalProperties: true + type: object + "404": + description: Skill not found + schema: + $ref: '#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError' + security: + - Bearer: [] + - ApiKeyAuth: [] + summary: Follow an install or removal + tags: + - SandboxConfig + /sandbox-configs/{id}/skills/{skillId}/transcript: + get: + description: |- + Server-sent replay of everything the installer agent did — the + prompt it was given, its thinking, the commands it ran and + their output — followed live while the install is still + running. Frames are the same shape the chat stream uses, so a + console renders an install with the components it renders a + chat turn with. 404 once the event log has expired; the + durable message history is the fallback. + parameters: + - description: Sandbox config ID + in: path + name: id + required: true + type: string + - description: Skill ID + in: path + name: skillId + required: true + type: string + produces: + - text/event-stream + responses: + "200": + description: SSE stream of transcript events + schema: + type: string + "401": + description: Unauthorized + schema: + additionalProperties: true + type: object + "404": + description: Skill or transcript not found + schema: + $ref: '#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError' + security: + - Bearer: [] + - ApiKeyAuth: [] + summary: Follow an install's agent transcript + tags: + - SandboxConfig /sessions: get: consumes: @@ -13610,44 +14454,6 @@ paths: summary: 继续流式响应 tags: - 问答 - /knowledge-search: - post: - consumes: - - application/json - description: 在知识库中搜索(不使用LLM总结) - parameters: - - description: 搜索请求 - in: body - name: request - required: true - schema: - $ref: '#/definitions/internal_handler_session.SearchKnowledgeRequest' - - default: handle - description: 文件引用形式,public 返回可加载直链 - enum: - - handle - - public - in: query - name: resource_urls - type: string - produces: - - application/json - responses: - "200": - description: 搜索结果 - schema: - additionalProperties: true - type: object - "400": - description: 请求参数错误 - schema: - $ref: '#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError' - security: - - Bearer: [] - - ApiKeyAuth: [] - summary: 知识搜索 - tags: - - 问答 /shared-agents: get: description: 返回所有共享给当前用户所在组织的智能体 @@ -13689,7 +14495,12 @@ paths: get: consumes: - application/json - description: 获取所有预装的Agent Skills元数据 + description: 返回指定沙盒配置镜像内、智能体实际能调用的已安装技能(ready 且启用)。不传 sandbox_config_id 时列表为空。 + parameters: + - description: Sandbox config ID + in: query + name: sandbox_config_id + type: string produces: - application/json responses: @@ -13698,14 +14509,10 @@ paths: schema: additionalProperties: true type: object - "500": - description: 服务器错误 - schema: - $ref: '#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError' security: - Bearer: [] - ApiKeyAuth: [] - summary: 获取预装Skills列表 + summary: 获取当前沙盒配置上可执行的 Skills tags: - Skills /storage-backends: @@ -14469,6 +15276,58 @@ paths: summary: Apply the default storage quota to every existing workspace tags: - System Admin + /system/admin/users/create: + post: + consumes: + - application/json + description: |- + Provision a new local user account (SystemAdmin only). + When `password` is omitted or null, a cryptographically random + password is generated (OIDC-style crypto/rand + base64url) + and returned once in the response body. Any provided value, + including empty string, is policy-checked. Tenant provisioning + follows the shared auth.default_tenant_mode policy. + parameters: + - description: User creation request + in: body + name: request + required: true + schema: + $ref: '#/definitions/github_com_Tencent_WeKnora_internal_types.AdminCreateUserRequest' + produces: + - application/json + responses: + "200": + description: Identity already exists, returns the existing user + schema: + $ref: '#/definitions/internal_handler.CreateSystemUserResponse' + "201": + description: User created successfully + schema: + $ref: '#/definitions/internal_handler.CreateSystemUserResponse' + "400": + description: Invalid request or weak password + schema: + additionalProperties: true + type: object + "403": + description: 'Forbidden: not a system admin' + schema: + additionalProperties: true + type: object + "409": + description: Email and username refer to conflicting identities + schema: + additionalProperties: true + type: object + "500": + description: Internal error + schema: + additionalProperties: true + type: object + summary: Create a new user (SystemAdmin) + tags: + - System Admin /system/admin/users/reset-password: post: consumes: diff --git a/frontend/src/api/system/index.ts b/frontend/src/api/system/index.ts index fd91c89c..0a7d541e 100644 --- a/frontend/src/api/system/index.ts +++ b/frontend/src/api/system/index.ts @@ -1038,7 +1038,7 @@ export function uploadConfigSkill( export function installConfigSkillFromSource( configId: string, - payload: { source: string; token?: string }, + payload: { source: string }, ): Promise<{ data: { skill_id: string } }> { return post(`/api/v1/sandbox-configs/${configId}/skills`, payload, { timeout: 2 * 60 * 1000, diff --git a/frontend/src/components/SandboxSkillsPanel.vue b/frontend/src/components/SandboxSkillsPanel.vue index 2a6a222c..15ec24e4 100644 --- a/frontend/src/components/SandboxSkillsPanel.vue +++ b/frontend/src/components/SandboxSkillsPanel.vue @@ -83,18 +83,6 @@ -
{{ $t('settings.sandbox.skillSourceTokenLabel') }}
-{{ $t('settings.sandbox.skillSourceTokenHint') }}
-