Commit Graph

3300 Commits (bccb4b151bae403508da77fbb174efc79dc47c1a)

Author SHA1 Message Date
hailongzhao bccb4b151b fix(embed): 内嵌网页只传图片不输入文字时不再返回 400
内嵌网页的输入框允许只带图片或附件就点击发送,但 CreateKnowledgeQARequest.Query
带有 binding:"required",parseQARequest 也拒绝空 query,于是只传图片直接返回
400 "Query content cannot be empty"。

入口处理:去掉 binding:"required";文字为空但带有内联图片数据或内联附件时,
用 types.UploadOnlyQuestion 生成一句替用户提问的问题(中文界面为「请根据我
上传的内容回答。」,其他语言为英文),交给模型、检索、标题、会话历史索引、
追问建议和记忆使用。只有 URL 的图片不算上传,因为客户端传入的图片 URL 会被
清掉;预上传的 attachment_ids 也不算,这类文件在流开始后才解析,可能失败或
超时,届时模型没有任何内容可答。其余空 query 仍返回 400。

存储与显示:qaRequestContext 新增 userInput,保存用户消息时只存用户实际
输入,只传图片时为空,刷新后与发送当下显示一致;query 仍是给模型的问题。
steer 追问复制上一轮的请求上下文,显式设置 userInput,避免在只传图片的一轮
之后把追问存成空消息。

会话历史:文字为空但带图片或附件的用户消息,在两处历史重建里补上同一句
问题。知识问答流水线(loadAndProcessHistory)原先会整轮丢弃;Agent 历史
(LoadAgentHistory)原先会发出空的用户消息,被 SanitizeMessages 剔除后
前后两条回答被合并。

去掉 binding 标签会让 gofmt 重新对齐整个 CreateKnowledgeQARequest 的行尾
注释,这些既有的超长行因此会被 PR 的增量 lint 视为新增。按仓库惯例把字段
注释移到字段上一行(注释文字不变,swagger 描述不受影响),并把 Go 字段
KnowledgeIds 改名为 KnowledgeIDs(JSON 名仍是 knowledge_ids,接口不变)。

同步更新 swagger 文档,query 不再是必填字段。
2026-09-30 15:26:51 +08:00
wizardchen 75fc0ad159 feat(docparser): upgrade AnyDoc to 0.2.4 and parse assets once 2026-09-30 15:25:01 +08:00
linus-liu-web 1dbe9d0c1a
fix(gitlab): 仓库文件下载补体积上限,超限报错而不是无界读入 (#3887)
* fix(gitlab): 仓库文件下载没有体积上限,超限改为显式报错

getRaw 直接用 io.ReadAll 缓冲整个 blob,get/getPage 的 JSON 读取同样无界。
GitLab 的 tree/compare 接口不返回 blob 大小,下载处是唯一能拦的地方,所以
同步一个音频或大 PDF 就会把一个完整 blob 读进进程内存。

对齐兄弟 connector(钉钉 16MiB JSON 上限、飞书 512MiB 下载上限):

- maxJSONResponseBytes(16 MiB)用于 get/getPage;
- maxRawFileBytes(512 MiB,与飞书 maxFeishuDownloadBytes 对齐)用于 getRaw;
- base64 回退走 getCapped,其请求体是 base64 后的 blob(约 4/3)加信封。

超限返回错误而不是截断:截断的正文会被当成完整文档入库。非 2xx 状态先于
读取判定,避免超大错误页把真实状态码盖掉。

* fix(gitlab): 将 compare 响应上限与元数据分开

compare 正文包含完整提交和 patch,沿用 16MiB 元数据上限会中断增量同步且游标无法前进。超限错误改为带上未编码的仓库路径。

---------

Co-authored-by: linus-liu-web <11640009+linus-liu-web@users.noreply.github.com>
Co-authored-by: wizardchen <wizardchen@tencent.com>
2026-09-30 14:33:15 +08:00
linus-liu-web b71b31c897 fix(ima): 笔记正文被清空后旧正文仍留在知识库
fetchNote 在正文为空时返回 fetchSkipped,walk 只把该 key 记进增量游标而
不产出任何 item。于是重新读到一篇已被清空的笔记时,入库层收不到「内容变
空」的信号:旧正文既不会被替换,游标还把它记为已同步。

Notion(b9be7d0d)与 Confluence 早就是这个写法:正文为空时仍然产出只有
标题的 markdown,让入库去替换旧正文。这里对齐同一写法,空正文改成
"# <title>\n" 照常走 fetchOK。
2026-09-30 13:43:55 +08:00
linus-liu-web 2ec1774623 fix(auth): 令牌写入失败不再当成登录成功,查询失败不再谎称已撤销
generateTokensForTenant 把两次 CreateToken 的错误都丢给了 `_`,然后照常返回
token 对。签发出去的 JWT 签名正确、语法合法,但 auth_tokens 里没有行,
ValidateToken / RefreshToken 在下一次请求就把它拒掉——用户看到的是"刚登录就掉
线,反复登录都一样"。更糟的是校验侧把"查不到"和"已撤销"合并成同一个分支:

    if err != nil || tokenRecord == nil || tokenRecord.IsRevoked {
        return nil, 0, errors.New("token is revoked")
    }

于是真实的插入错误既没有落日志,也被贴上了一个从未发生过的原因("token is
revoked"),把排查方向引向"会话被踢"。触发条件只是常规基础设施抖动:语句超时、
连接池耗尽、连接被重置。

同文件的对照写得很清楚:SwitchTenant 对同类写入 `return fmt.Errorf(...)`("a
200 response is also a durable landing-preference update"),Logout 直接返回
RevokeTokensByUserID 的错误;这两处是全文件唯一"写完不检查"的地方。

改动:
- 两次 CreateToken 都检查错误,失败即 `persist access token/refresh token: %w`
  返回,保证"登录成功"一定对应已持久化。正常路径不变:两行都写成功才返回令牌对。
- ValidateToken / RefreshToken 把查询错误与"已撤销/不存在"拆开:查询失败按基础
  设施错误上报(`look up token: %w`),`IsRevoked` 仍然报 "token is revoked",
  不再用一句假话掩盖查询失败。

新增用例(internal/application/service/user_token_persistence_test.go):
- 写入失败时 Login 必须 Success=false 且不下发任何令牌;
- 访问令牌/刷新令牌任一写入失败都不得返回令牌;
- 正常路径回归:两行都落库、access token 随后能通过 ValidateToken;
- 查询失败如实上报(errors.Is 命中原始错误,且不含 "token is revoked");
- 真的被撤销时 "token is revoked" 仍然保留。

L2 复现(假 token repo 返回写失败):修复前 Login 返回 success=true、
tokenIssued=true,紧接着用该 token 请求得到 "token is revoked";修复后 Login
返回 success=false、message="Login failed"、不下发令牌。去掉 user.go 的改动后
新增用例 5 个子用例全红,两条正常路径回归用例仍绿。整个 service 包
`go test ./internal/application/service/` 通过,scoped golangci-lint 0 issues。
2026-09-30 13:40:51 +08:00
lizijing98 dba9127558 docs(api): 补充模型复制接口说明 2026-09-30 13:34:18 +08:00
hailongzhao 176aa0d02b fix(sandbox): build real arm64 sandbox images and ship arm64 Cube variants
The global `ARG TARGETPLATFORM=linux/amd64` in Dockerfile.sandbox overrode
the per-platform value BuildKit injects, so the multi-platform CI build ran
every platform on the amd64 rootfs and only relabeled the arm64 config.
The published arm64 entries of main, latest and main-desktop are byte-for-byte
the amd64 layers. The stage-level `ARG TARGETARCH=amd64` had the same effect,
so the cube "amd64 only" guard could never fire.

- Declare TARGETPLATFORM without a default and fall back to linux/amd64 in
  FROM only when it is empty (legacy builder).
- Fail the runtime stage when the rootfs architecture differs from
  TARGETARCH.
- cubesandbox-base:2026.16 publishes linux/arm64 as well, and Cube runs on
  arm64 bare-metal KVM (PVM stays x86_64-only). Follow TARGETPLATFORM for
  cube-base, replace the amd64-only guard with an envd-vs-rootfs check, and
  build cube / desktop-cube for linux/amd64,linux/arm64 in CI and
  build_images.sh.
2026-09-30 13:34:01 +08:00
lyingbug 5225edc0f7
feat(auth): 新增仅限邀请注册档位 (#3900)
* feat(auth): add invitation registration mode

* fix(auth): resolve registration mode lint errors
2026-09-30 13:32:55 +08:00
LL_Ricky 9842e51d40
fix(frontend): 修复复制模型时模型名称被改写的问题 (#3830)
* fix(frontend): 修复复制模型时模型名称被改写的问题

* fix(model): preserve model name and credentials when copying a config

Copying rewrote the upstream model name and posted redacted parameters, so the duplicate could not authenticate. Clone the stored row, cap the display name, and skip a new download when the local model is already active.

* fix(lint): clear new golangci-lint findings on model copy

Check c.Error results, wrap the long test line, and format the stub. The pull request lint range also includes the new HTTP error test, whose unused request parameter failed revive.

---------

Co-authored-by: wizardchen <wizardchen@tencent.com>
2026-09-29 19:32:08 +08:00
dajiaohuang 0c6b30cfa7 fix(docs): spawn nested npm through Node on Windows 2026-09-29 17:19:25 +08:00
dajiaohuang 75d2c1b583 fix(frontend): normalize style guard paths 2026-09-29 17:16:54 +08:00
hailongzhao f46c990567 fix(embed): 开启 Host context 后点击追问建议不再返回 400
嵌入渠道调用 WeKnora.setContext 后,前端 buildQueryWithHostContext 会把
query 包成 "[Host context]\n<k: v 行>\n\n<问题>" 再发出,而
ValidateAttribution 用 TrimSpace 后的全文与建议文本做精确比较,带信封的
query 永远不相等,于是每次点击追问建议都返回 400
"invalid suggestion attribution"。

后端:新增 queryMatchesSuggestionText,精确匹配失败时识别 host context
信封——要求以 "[Host context]\n" 开头、信封内容非空、以空行结束,且空行后
紧跟的正好是被点击的建议文本。宿主传入的 value 可以含换行甚至空行,所以用
建议文本从尾部锚定切分,而不是取第一个 "\n\n"。不校验信封里每行的 key/value
形态:前端对 key 不做约束(带空格、空 key、value 以换行开头都会原样拼进去),
校验只会误伤合法 context,而归因只用于统计点击与实际发送,不涉及权限。
在信封与问题之间或问题之后夹带额外文本、任意前缀、空信封仍会被拒绝。

前端:handleFollowUpSelect 原先在回复生成中点击建议时也会写入待发送归因,
但跳过发送,归因会泄漏到用户下一条手动输入的消息上,同样导致 400。改为只在
真正发送时写入归因,click 事件照常上报。

Fixes #3820
2026-09-29 12:16:46 +08:00
linus-liu-web 1912ba26c5 test(weaviate): 让并发建表的用例真的每个 worker 都去创建,消掉随机失败
TestEnsureCollectionToleratesConcurrentCreation 用 barrier 让 8 个 worker 都先探到
"class 不存在",再一起冲创建,最后断言 server.creates == workers。但假服务器的 GET
分支是「先等 barrier、再采样 s.exists」:barrier 一放开,赢家的 POST 可能已经把
exists 置为 true,排在后面的 worker 采样到"已存在",就在创建之前返回了,从来没去
尝试创建。实际创建数取决于调度(本地 100 次里挂 1 次;CI 上是 4 或 6),断言于是
随机失败 —— main 自己的 CI 与多个 PR 都挂在这条上。

把采样挪到 barrier 之前:每个 worker 读到的是它到达时的状态(此刻必然为 false),
8 个创建请求全部到达服务端,断言稳定。测试注释里写的意图本来就是"让每个 worker 都
看到 class 缺失",这里只是让实现与意图一致。

只改测试,不碰生产代码。
2026-09-29 01:32:23 +08:00
linus-liu-web e39043f34b fix(repository): 关键词 LIKE/ILIKE 检索补显式 ESCAPE,修复 Lite 上静默漏结果
SQLite(Lite 版所用数据库)没有默认的 LIKE 转义字符,而 Postgres 的默认转义字符是
反斜杠。escapeLikeKeyword / escapeLikePattern 会把关键词里的 %、_、\ 转义成 \%、\_,
但只有在 SQL 中显式声明 ESCAPE 时才有意义:缺少 ESCAPE 时 SQLite 会把反斜杠当成普通
字符,于是任何含 _ 或 % 的关键词(如 IMG_2534、100%)都匹配 0 行——不报错、不打日志,
total 同样为 0,前端只显示"暂无数据"。Postgres 因默认反斜杠转义而表现正常,所以问题
只在 Lite / SQLite 上静默出现。

本次修改统一在 LIKE 表达式后补 ESCAPE,并把 escape 字符作为参数传入(Postgres 的
ILIKE 分支同样处理),写法对齐 message.go / message_artifact.go / chunk_image_assets.go
中已有的正确站点,转义字符复用 knowledge.go 既有的 likeEscapeChar 常量。

修复站点:
- knowledge.go applyKnowledgeListFilter 文档列表关键词过滤
  (agent 工具 list_documents、mcp-server tools_retrieve 复用)
- knowledge.go SearchKnowledge
- knowledge.go SearchKnowledgeInScopes(GET /api/v1/knowledge/search)
- tag.go ListByKB 标签搜索(count 与 data 两条查询)
- tenant.go SearchTenants 租户搜索(带/不带 tenantID 两个分支)
- tenant_member.go CountFilteredByTenant / ListPagedByTenant 成员邮箱、用户名搜索
- session.go QueryPaged 会话列表/侧栏标题搜索(LOWER LIKE 与 Postgres ILIKE 分支)
- chunk.go ListPagedChunksByKnowledgeID 分块/FAQ 搜索

chunk.go 属反向错误:关键词完全没有转义,% 和 _ 被当作通配符导致多匹配。这里同样改为
escapeLikeKeyword + ESCAPE,而不是把别处的转义去掉——关键词里的 % 和 _ 是用户想按字面
匹配的字符(文档名 IMG_2534、进度 100% 都很常见),去掉转义会让它们又变成通配符、匹配
到无关结果;只有显式 ESCAPE 才能让 Postgres 与 SQLite 行为一致。

顺带把 escapeLikePattern 收敛为 escapeLikeKeyword 的薄封装(wiki_page.go 一处),
两者原本是逐字符等价的重复实现,调用点语义不变。转义字符常量仍复用 likeEscapeChar,
未新增常量。

新增 SQLite 回归测试 internal/application/repository/like_escape_sqlite_test.go,覆盖上述
全部站点:每个用例同时埋入"字面命中行"和"通配符诱饵行",缺 ESCAPE 会因 0 行失败,缺
转义会因多匹配失败。已逐站点反向验证:去掉 ESCAPE(或去掉 chunk.go 的转义)后测试确实
失败,随后逐字节还原。

注:organization.go ListSearchable 与 user.go SearchUsers 的关键词同样未转义,但它们是
Postgres 专用路径(ILIKE / ::text),属另一类问题,不在本次改动范围内。
2026-09-29 01:31:37 +08:00
linus-liu-web 436d02fdf3 fix(compaction): 流因取消而关闭时不得当成空摘要成功返回
streamSummary 的 select 里 ctx.Done() 分支与 stream 关闭分支会同时就绪,
select 在就绪分支之间随机选择:已经取消的调用有一半概率走关闭分支返回 nil,
被报成"成功返回空摘要",另一半才返回 context.Canceled。CI 上因此偶发:

--- FAIL: TestSummarizationIsNotRetriedOnceTheTurnIsCancelled (0.00s)
    stream_test.go:122: Error: Should be true
FAIL	github.com/Tencent/WeKnora/internal/agent/compaction

这不只是测试问题。流因取消而关闭被当成成功,会让调用方把中途被截断的摘要
当有效 checkpoint 落盘(成功路径会走到 saveContextCheckpoint),而
validateSummary 只拦得住空摘要和 finish_reason 为 length 的截断。

修复:在流关闭分支返回成功之前先查 ctx.Err()。既纠正语义(取消就是取消,
不是空摘要),也消除两个分支同时就绪时的随机性。streamErr 的优先级仍在
ctx.Err() 之前,因为供应商报的错更具体;ctx 未取消、流自然关闭的正常完成
仍返回内容加 nil,stall 与重试逻辑未动。

回归用例 TestSummarizationIsCancelledWhenTheStreamCloses:假模型同步返回
一个已经关闭的 channel,传入已取消的 ctx,两个分支必然同时就绪。修复前
-count=50 有 20 次 FAIL,修复后 -count=50 全 PASS;既有 flaky 用例
TestSummarizationIsNotRetriedOnceTheTurnIsCancelled -count=100 全 PASS。
2026-09-29 01:30:01 +08:00
Victor Maznyuk cf079b8dcd fix(models): keep Retry-After on HTTPError and honour it in agent LLM retries
Endpoint.Do turns a non-2xx reply into &HTTPError{StatusCode, Body} and
drops the response headers. A caller that retries a 429 or 503 therefore
cannot see the provider's Retry-After and falls back to its own guess: the
agent retry loop waits 1s, 2s, 3s, which against a provider asking for, say,
20s spends every attempt inside the rate-limit window and then fails the
turn.

- HTTPError carries the reply's Header, and RetryAfter() parses the header
  in both forms (delay-seconds and HTTP-date); absent, malformed or past
  values give zero.
- The agent retry loop waits max(linear backoff, Retry-After), with the
  vendor's value capped at 30s so a large Retry-After cannot hold a turn
  indefinitely.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-09-29 01:22:15 +08:00
yeliheng-010 15d4845521 fix(rss): 修复全文回退后增量同步不重试 2026-09-29 00:53:27 +08:00
yeliheng-010 b9be7d0d0d fix(notion): 修复页面清空后旧正文残留 2026-09-29 00:52:07 +08:00
linus-liu-web a282d1091e
fix(feishu): 云盘分页补上 #3645 给 wiki 加的重复 page token 防护 (#3770)
ListDriveFilesAllPages 只以 next_page_token 是否为空作为终止条件,既不看
has_more,也没有重复 token 检测;同一文件里同一厂商的 ListWikiSpaces /
ListWikiNodes 已在 #3645 修过,云盘这两条防护都漏了。

厂商返回 has_more=false 但残留非空 token,或返回重复的 page_token 时,循环会
拿同一个 token 反复请求同一页:定时同步任务会在 asynq 的 2h 超时前一直打 API
(scheduler 侧 MaxRetry 5),资源选择器
GET /api/v1/datasources/:id/resources 永不返回,同时 all 每轮 append 不断增长。

按 #3645 的既有写法原样修复:listDriveFiles 透出 has_more,循环改为
if !hasMore || next == "" 才退出,并用 seenPageTokens 记录已用过的 token,重复即
返回 "feishu drive file pagination repeated page token" 错误。正常多页语义不变
(仍返回完整列表),只是不再空转。

测试:TestClientDriveListFilesPagination(drive 包)用 httptest 覆盖重复 token、
has_more=false 带残留 token、正常两页三种情况;注释掉守卫后该用例在 2s 内发出
4 万+ 次请求并以 context deadline exceeded 失败。

Co-authored-by: linus-liu-web <11640009+linus-liu-web@users.noreply.github.com>
2026-09-29 00:51:19 +08:00
yeliheng-010 72e105f46a fix(gitlab): 按提交快照比较增量同步变更 2026-09-29 00:50:05 +08:00
linus-liu-web 7d1d71e50d
fix(datasource/dingtalk): 块级渲染不再静默丢内容(列表按线上真实形状渲染 + 未建模块类型可见) (#3822)
* fix(datasource/dingtalk): 块级渲染不再静默丢内容(列表按契约渲染 + 未建模块类型可见)

渲染器有三处会无声地丢正文:

- 列表块只在 inline 子节点渲染结果为空时才递归子块,于是 children 里既有
  inline 又有块级元素时,块级子节点的文本永远不渲染 —— 而且连 unknown 标记
  都不设,完全无痕;块级列表项还会被 strings.Fields 折叠进同一个 bullet 行;
- 未建模的块类型(code / attachment / slot / sheet / unknown …)payload 解析
  不出来,正文整块丢失,只剩类型名写进文档 metadata,全仓没有一行日志;
- 未建模的 inline 元素类型(slot 等,官方文档里文本放在 children)在默认分支
  只写 text 字段,children 里的正文直接消失。

改动:

- 列表按官方契约渲染:一个列表块 = 一个列表项,缩进用 list.level(0-based),
  同一列表的多项是共享 listId 的兄弟块(扁平模型),不假设结构嵌套;契约外的
  块级子节点仍然逐个渲染,作为防御,不再二选一、不再塌行;
- 未建模的 inline 元素在自身没有文本时渲染 children,避免整段消失;
- 未建模块类型在 Fetch 路径上显式暴露(这一层同时拿得到 ctx 与节点身份):
  collectUnknownBlockTypes 产出可测值,同时喂给 logger.Warnf 与
  common.PipelineWarn;文档 metadata 保持不变。

code / attachment / sheet / slot 的正文渲染不在本次范围:它们的块级 JSON 形状
仍无可靠证据(官方与公开 CLI 参考的键名互相冲突),先靠告警把真实 payload
找出来再按形状补,免得用猜测的字段把"可见的丢失"变回"静默的丢失"。

* fix(datasource/dingtalk): 按实测形状补 code / attachment / unknown 三类块的渲染

只读探针在真实 adoc 文档上取到的形状(不再依赖公开参考里互相冲突的键名):

- code: {"syntax":"bash","text":"...","title":"..."},title 有时缺;语言键是
  syntax 而不是 language;
- attachment: {"name":..,"size":..,"type":..,"viewType":..,"resourceId":..},
  resourceId 有时缺,payload 里没有任何下载 URL;
- unknown: {"rawType":"..."},只有真实类型名,没有正文;
- table.cells 的读取路径与实测一致,未改动。

改动:

- code 渲染成围栏代码块:语言取 syntax(含反引号或换行这类无法作为 info string
  的值时省略),围栏长度取 max(3, 正文最长反引号串+1),避免正文自带的围栏把代码块
  提前截断;title 非空时在围栏前输出一行加粗标题;text 为空不输出空围栏,仍按未建模
  类型记录并告警;
- attachment 渲染成一行纯文本 Attachment: <name> (<size>):名称做 Markdown 转义,
  size 按 1024 进制保留一位小数(B/KB/MB/GB),size<=0 时省略括号;payload 没有可
  解析的下载地址,因此不拿 resourceId 拼任何链接;名称为空不输出,仍按未建模类型
  记录并告警;
- unknown:default 分支在 rawType 非空时把标记写成 "unknown:"+rawType,使
  unknown_block_types metadata 与 warnUnknownBlockTypes 的日志/pipeline 事件直接
  带真实类型名,而不是无信息量的 "unknown"(字段名、签名与调用位置均未动),
  children 仍逐层递归。

既有普通块(段落/标题/引用/表格/列表)的输出逐字节不变,回归用例
TestRenderDocumentKeepsOrdinaryBlocksStable 未修改即通过。原先拿 code/attachment
当“未建模”夹具的两个用例改用空载荷的同类块与带 rawType 的 unknown 块,覆盖新的
“渲染不出内容仍要告警”语义。

* fix(datasource/dingtalk): 列表按线上真实形状渲染(块自带 text)

线上 Blocks API 返回的是一个列表项一个块,正文在块自带的 text 字段里,
没有 children、没有 list.level、也没有 listId。列表是唯一一类没有回退到
「块自带 text」的正文块 —— paragraph / heading / blockquote 都有
renderInlines(children) 取不到就取自身 text 的回退,列表直接进
renderListBlock,而那个函数只遍历 children,于是列表正文被整条丢弃;
又因为 blockType 是已知类型,switch 命中了它,连 unknown_block_types
都不会记一笔。

同一形状问题还影响 unknown:sdt 块(文档目录)的正文就在 unknown.text 里,
此前只写标记不渲染正文。

夹具取自线上 payload(markdown_live_shape_test.go),不按转述的契约自造。

---------

Co-authored-by: linus-liu-web <11640009+linus-liu-web@users.noreply.github.com>
2026-09-29 00:48:20 +08:00
linus-liu-web 08f7e702cf fix(datasource/dingtalk): 跳过不再静默,展开叶子不再报错
同步过去只保留能读的内容:没有 ingest 路径的节点被直接丢掉,日志里
一个字都没有,一个 19 个文件的库只同步出 14 个也无从得知。现在

- scanWorkspace 把「看到了但读不了」的节点一并以 skipped 返回,
  sync 逐个打印身份与原因(视频/媒体是刻意不下载,原生类型是还没实现),
  每个 scope 再补一行 total/synced/skipped/failed 汇总,partial sync
  再也装不成一次干净的运行;
- 可重试的失败仍按失败计(不计入 skipped),并显式记一条 warn,
  与确定性跳过区分开;
- 资源选择器展开一个其实没有子节点的条目(document)时返回空列表而不是
  ErrResourceNotFound:叶子本来就没有子节点,而前端把 error 渲染成
  展开失败的气泡,会让一次同步完全正常的操作看起来出错。前端
  DataSourceEditorDialog 收到空列表后会把该行 has_children 置 false 并
  保留,因此第二次展开不会再发一次空请求(该逻辑已在上游 main 中)。

跳过只在日志里报告:FetchedItem 没有 skip 字段,也不打算为它新增。
2026-09-29 00:47:02 +08:00
Fei.Chen ec0ca46334
fix(server): run ResourceCleaner on signal shutdown instead of racing Fatalf exit (#3804)
* fix(server): signal shutdown raced Fatalf exit before ResourceCleaner ran

The signal goroutine closed the listener before calling server.Shutdown,
so Serve returned the raw accept error ('use of closed network connection')
instead of ErrServerClosed. The invoke error path then hit logger.Fatalf
(os.Exit(1)) in the same millisecond, killing the process before the
shutdown goroutine reached resourceCleaner.Cleanup. Every registered
cleaner — BrowserSkill daemon, sandbox reapers, IMService, AntsPool,
Langfuse — was skipped on every SIGTERM/SIGINT, leaking the shared bsk
daemon process and its temp home on each restart.

Two changes:
- Drop the manual listener.Close(): Shutdown closes all listeners as its
  first step, releasing the port just as fast without racing Serve.
- Give resourceCleaner.Cleanup its own fresh timeout context so a slow
  connection drain cannot leave Cleanup with an already-expired context,
  which made it skip every entry without running any.

* fix(server): keep signal cleanup inside one grace period

Desktop quit still closed the listener before Shutdown and returned
before ResourceCleaner finished, so Fatalf could skip every hook.
Share ShutdownTimeout between drain and cleanup, run BrowserSkill
first, and do not drop later hooks when the deadline expires.

* fix(server): satisfy errcheck and line-length lint

---------

Co-authored-by: vicfei <vicfei@users.noreply.github.com>
Co-authored-by: wizardchen <wizardchen@tencent.com>
2026-09-28 23:37:36 +08:00
wizardchen c819abd958 fix(wiki): bound outstanding follow-up tasks 2026-09-28 22:02:07 +08:00
Duke 4ba85e2edf fix(wiki): fan out follow-up triggers so backlogs drain at ingest_max_inflight
Since Phase 3 the consumption side (disjoint claiming, per-slug locks,
the inflight cap) fully supports concurrent batches, but nothing created
more than one trigger per completed batch: once uploads stopped, a KB
with a standing backlog drained at 1 batch x batch-size per cycle
regardless of ingest_max_inflight, leaving the wiki pool and the model
server idle.

followUpTriggerCount now re-arms min(batches the remaining rows still
need, slots that could be free when the triggers fire). The caller's
own slot releases right after scheduleFollowUp returns, hence the +1.
activeInflightSlots is a read-mostly Lua companion to the reserve
script (purge expired, then ZCARD); -1 means unknown (no Redis / Redis
error) and collapses to a single follow-up, as do maxInflight <= 1 and
Lite mode (liteLocks serialize per KB anyway). Fan-out is deliberately
skipped on a rate-limited exit so a 429 storm is not amplified.

Over-issued triggers are harmless: the ones that cannot get a slot are
acked and coalesced by scheduleCappedRetry's fixed TaskID. The slot
count renders as "unknown" in the log when it was not consulted.
2026-09-28 22:02:07 +08:00
Victor Maznyuk bad7afa6ae fix(sandbox): pass desktop slot timing to the renew goroutine
renewDesktopSlot read desktopSlotRenew and desktopSlotLease from its own
goroutine. release() stops that goroutine without waiting for it, so the
read is unordered with the test cleanup that restores the values, and
`go test -race ./internal/handler/session/` fails in
TestDesktopSlotCancelsHoldWhenKeyExpires on every run.

acquireDesktopSlot now reads both durations before starting the goroutine
and passes them in; the go statement orders the reads, and the renew loop
no longer touches the package variables. Behaviour is unchanged.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-09-28 22:01:39 +08:00
Perfecto 675b06addc test: consolidate table summary regressions 2026-09-28 21:24:02 +08:00
Perfecto d270a844ac fix: reject empty table-summary model responses 2026-09-28 21:24:02 +08:00
Perfecto d528d1fc3c fix: skip table-summary tasks for missing documents 2026-09-28 21:22:45 +08:00
bigdu332 bdad5eea2b fix(chat): clear stale KB scope on session restore 2026-09-28 21:20:12 +08:00
Victor Maznyuk 157fb4d3c1 fix(frontend): label host-sandbox skill secret cards like the sandbox cards
The sandbox cards on the environment-variable settings page already pass the
localized host label to configLabel, so the host config shows as "This
computer". The skill secret cards call configLabel without it and show the
raw backend name of the host config instead (本机), in every locale.

skillSecretCards now takes the same optional hostLabel and forwards it;
EnvVarSettings passes t('settings.skills.hostTarget') as it does for the
sandbox cards. Without a label the behaviour is unchanged.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-09-28 21:10:02 +08:00
kwsYegar 9cab226853 docs: extract active tenant ID in the API quickstart 2026-09-28 21:08:33 +08:00
Victor Maznyuk 0b463e459a test(skills): wait for the host install to release its lock before asserting
TestHostInstallActivatesVersionAndMarksReady waited for the row to reach
ready and then read the fake tree and installer. runHostInstall records
ready while it still holds the skill lock; pruning old versions, unbinding
the install session and unlocking come after, so the test could observe
tree.pruned as nil or installer.bound still populated, and the race
detector reported the unsynchronised reads.

The fake tree now counts runs between Lock and unlock, and the wait
helpers block until no run holds it. The run unlocks last, so everything
it wrote is visible once the wait returns. waitRemoveDone had the same
gap (the row is deleted before the stale marks are recorded) and uses the
same wait.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-09-28 21:07:04 +08:00
Victor Maznyuk 5bf2ae1cc2 fix(faq): actually clean FAQ entry payloads before validation and storage
sanitizeFAQEntryPayload called meta.Normalize() and discarded the result.
Normalize returns a normalized copy for hashing and indexing and does not
touch its receiver, so no cleaning happened: blank, whitespace-only and
duplicate similar/negative questions and answers were stored as sent, two
empty similar questions were reported as a duplicate, and answers: ["  "]
passed the "at least one answer" check.

Call meta.Sanitize(), the in-place method meant for storage (trim, drop
empties, de-duplicate, keep the original text).

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-09-28 20:29:29 +08:00
linus-liu-web a570dffcfa test(wiki): 表格夹具改用合成数据
`certLedgerRow` / `certLedgerBlock` 里的机构名、页面标题与行数都取自某一份具体
数据,而回归测试需要的只是形状:一张有很多行的 markdown 表格 + 表头 + 分隔行。
取值换成中性的示例数据 —— 机构名 `示例科技有限公司`、行标识 `成员 N`、标题
`证书台账`、行数 90(切 1..61 + 62..90),断言里的 92 = 90 行 + 表头 + 分隔行。

断言逻辑一行未动,5 个续写/上限/哨兵用例全 PASS。
2026-09-28 20:19:52 +08:00
lyingbug 9114e4e4f9
fix(citations): 修复原文定位、高亮范围与 DocReader 启动失败 (#3794)
* fix(citations): verify source locations and recover document previews

* chore: exclude local research notes from pull request
2026-09-27 20:32:26 +08:00
wizardchen 4df7ccbb4f fix(chat): drop stale minimap-target class binding
The question-outline flash (minimapTargetId, its timer and CSS) was
removed in #3427, but #3469 brought back the :class binding on user
message rows. Vue then warned that minimapTargetId was accessed during
render on every render. data-message-id stays: the minimap uses it to
find jump targets.
2026-09-26 19:07:54 +08:00
wizardchen 9fcc2c6743 fix(dev): propagate dev.sh exit status and pull MinIO from pgsty/minio
scripts/dev.sh ended with an unconditional `exit 0`, so a failed
`make dev-start` (e.g. an image pull error) printed "服务启动失败" but still
reported success to callers and CI. Drop it so the script exits with the
status of the dispatched command; help still exits 0, unknown commands 1.

MinIO closed anonymous pulls on quay.io on 2026-09-24 (Docker Hub was
already gone), so quay.io/minio/minio now answers 401 for every tag and a
fresh `dev-start` fails. No registry serves RELEASE.2025-09-07T16-13-09Z
anonymously any more. Switch compose and Helm to the community rebuild
pgsty/minio, pinning RELEASE.2026-08-04T00-00-00Z where a tag was pinned
before, and update the docs that named quay.io.
2026-09-26 15:30:27 +08:00
wizardchen 6c83d7ab47 revert: take the plugin system back out of main
Reverts the eleven plugin system PRs merged on 2026-09-26 so they can be
reviewed before landing:

* a829d7cc9 agent tools served by plugins (#3733)
* 4f5d475c3 Jira example plugin (#3730)
* 01222aac8 dynamic form options, OAuth connections and resource limits (#3729)
* cf502ba46 event delivery and webhooks (#3728)
* 996696057 sandboxed plugin pages (#3727)
* da4ef68d9 standalone plugin hosts (#3725)
* 728007ada remote runtime, Python SDK (#3724)
* ff49f9491 Host API and document parsers (#3721)
* 4328ab26a code plugins (#3720)
* ed63e35cc declarative plugins (#3716)
* c91a8d11f plugin system foundation (#3711)

The tree is back to 47773b5bd, migrations included: no environment ran
the plugin migrations (versioned 000115-000119, sqlite 000034-000038).
2026-09-26 14:58:18 +08:00
lyingbug a829d7cc9c
feat(plugin): agent tools served by plugins, with result views (P2 batch 8) (#3733)
* feat(plugin): agent tools served by plugins, with result views
* fix(plugin): expand plugin tool views in place in the agent stream
2026-09-26 14:48:37 +08:00
lyingbug 4f5d475c3e
feat(examples): Jira Cloud plugin with OAuth, dynamic options and a skill (#3730)
* feat(examples): Jira Cloud plugin with OAuth, dynamic options and a skill
2026-09-26 14:48:00 +08:00
lyingbug 01222aac8e
feat(plugin): dynamic form options, OAuth connections and resource limits (P2 batch 7) (#3729)
* feat(plugin): dynamic form options, OAuth connections and resource limits
* fix(plugin): show what an options list waits for as a hint, not an error
2026-09-26 14:47:37 +08:00
lyingbug cf502ba46a
feat(plugin): event delivery and webhooks for plugins (P2 batch 6) (#3728)
* feat(plugin): event delivery and webhooks for plugins
2026-09-26 14:47:13 +08:00
lyingbug 996696057f
feat(plugin): sandboxed plugin pages and the @weknora/plugin-ui bridge (P2 batch 5) (#3727)
* feat(plugin): sandboxed plugin pages and the @weknora/plugin-ui bridge
* ci(pluginsdk): run the Python job's steps in bash on Windows too
2026-09-26 14:46:49 +08:00
lyingbug da4ef68d9d
feat(plugin): standalone plugin hosts with Redis discovery (P2 batch 4) (#3725)
* feat(plugin): standalone plugin hosts with Redis discovery
2026-09-26 14:46:26 +08:00
lyingbug 728007ada9
feat(plugin): remote runtime, Python SDK and python host plugins (P2 batch 3) (#3724)
* feat(plugin): remote runtime
* feat(plugin): Python SDK and python host plugins
* fix(pluginsdk): skip reverse DNS when a Python plugin binds
2026-09-26 14:46:03 +08:00
lyingbug ff49f9491d
feat(plugin): Host API with a key-value store, and document parsers from plugins (#3721)
* feat(plugin): Host API with plugin tokens and a key-value store
* feat(plugin): document parsers from code plugins
* docs(pluginsdk): parsers and the Host API
2026-09-26 14:45:39 +08:00
lyingbug 4328ab26a9
feat(plugin): code plugins — extension protocol, Go SDK, plugin host, web search and data source adapters (#3720)
* feat(pluginsdk): extension protocol v1, Go SDK and conformance suite
* feat(plugin): run code plugins in an embedded plugin host
* feat(plugin): remote adapters for web search and data sources
* fix(plugin): show plugin errors by their message
* feat(frontend): plugin connectors and web search providers in the UI
* docs(pluginsdk): how to write, package, test and install a plugin
* fix(plugin): gofmt two files and read openapi.yaml line-ending agnostic
* fix(plugin): mark a host plugin ready before Activate returns
2026-09-26 14:45:15 +08:00
lyingbug ed63e35cc7
feat(plugin): install declarative plugins — MCP servers, skills and model vendors (#3716)
* feat(plugin): install declarative plugin packages across nodes
* feat(plugin): serve installed plugins' MCP servers in each workspace
* feat(plugin): let installed plugins contribute skills and model vendors
* feat(plugin): register plugin skills into the workspace skill catalog
* feat(frontend): manage installed plugins and their configuration
* test(weaviate): read the class state before the probe barrier
* fix(plugin): keep MCP tool directories reachable behind the plugin wrapper
* test(plugin): wrap a long line
2026-09-26 14:44:34 +08:00
lyingbug c91a8d11f8
feat(plugin): plugin system foundation — builtin plugins, config schemas and workspace switches (#3711)
* feat(plugin): add plugin manifest, registry and builtin catalog
* feat(plugin): add config schemas with unified secret handling
* feat(frontend): render config schemas with SchemaForm
* feat(datasource): serve connector credential forms from the backend
* feat(im): describe IM platforms and credentials from the backend
* feat(frontend): render model vendor extra fields from the config schema
* feat(frontend): build the settings modal from an extension registry
* refactor(agent): register builtin tools and their chat views
* feat(plugin): let workspaces enable and disable plugins
* feat(plugin): add the runtime driver interface and gather builtins
2026-09-26 14:43:28 +08:00