Repository navigation
feat(im): Feishu and DingTalk chat Bots, proactive notifications, web-confirmed writes and data retention - #1114
Conversation
Single-branch plan for Feishu and DingTalk on top of the WeCom Bot stack. Version 3 rebases on origin/main@e89cda9 (migrations now 036/037) and fixes the implementation contracts: database-time leases with a dialect helper, physical enabled/version columns, lock order config -> connection -> interaction/delivery, retry terminal states, disable semantics, separate interaction and notification status enums (send_unknown), shared tenant confirmation for Feishu and DingTalk, and the maintenance window order.
Introduce the Channel/Conn/PushSender contract and route the existing WeCom long connection through it without changing user-visible behavior. - channel.go: inbound event, reply route, outbound message and SendResult types; optional progress and card capabilities. - channel_wecom.go: WeCom adapter wrapping dial/stream/cards; send errors are classified by evidence (not written / written without receipt / platform rejection). - inbound.go: common validation and enqueue shared by all adapters. - socket.request records the send phase while keeping error messages and context unwrapping. - notification.New injects CLIProvider.Verify (signed bootstrap only) and a classified wecom-cli push into the WeCom channel. - Fake channel test covers receive, duplicate redelivery, app mismatch, rejection, unknown outcome with reconnect, and reconnect after drop.
Separate module exercising larksuite/oapi-sdk-go v3.13.0 and dingtalk-stream-sdk-go v0.9.1 under Go 1.26.11. Feishu Start returns on context cancel; the DingTalk StreamClient panics with 'send on closed channel' after a pong timeout followed by a late frame, which is why the DingTalk adapter will run its own stream loop.
TestConnectionReconnectsAfterLocalClose incremented a plain int from httptest handler goroutines, which go test -race reported on main as well. Use atomic.Int64; the every-second-attempt rejection and the two-reconnect assertion are unchanged.
Document the probe steps, the panic stack (client.go:165 'send on closed channel' in a processLoop goroutine), the source lines that close the channels while reader and pong goroutines still send, the other rejected StreamClient behaviors, and the requirements for the stage F connection layer. The probe stays a separate diagnostics module and fails once the defect stops reproducing.
Stages B-D of docs/proposals/enterprise-im.md; they change the same repo and service code paths and land together. Stage B - configuration scope and credentials - NotificationBot gains channel, write approval, config/credential versions and tenant state; IdentityScope/ReceiveSlot/LeaseKey keep WeCom keys byte-identical and scope new channels by configuration. - notification_bots physical columns (channel, external_app_id, tenant_key, unique receive_slot, enabled, interaction_enabled, versions); saves are CAS on config_version, retry MySQL deadlock victims, and keep one receiving configuration per application. - internal/credcrypt: AES-256-GCM keyring from AGENTFLOW_CREDENTIAL_KEYS, lf1:<kid>: envelope bound to configuration and channel; legacy plaintext stays readable; -credential-action status|reencrypt (re-entrant). - dbNowUS dialect clock; leases and send windows are *_us columns written and compared on the database clock. - bot_native_sessions mapping written before the CLI starts; a failed write stops the turn. - AGENTFLOW_BOT_WORKERS_ENABLED maintenance switch; migrations 036/037 backfill physical columns, project snapshots and WeCom binding owners (BINARY identifier comparisons; verified twice on MariaDB 10.11). Stage C - fencing and delivery state machine - bot_connections epoch per owner; every interaction write locks config -> connection -> interaction and checks owner, epoch and live lease; zero rows is ErrBotLeaseLost. - ready -> sending -> replied | reply_failed | reply_unknown with a fixed send key, short send lease, 15s lease headroom and 10s call timeout. Not-delivered retries 3x (5s/30s/2m) then fails; unknown retries with the same key inside first send + 55 minutes only for idempotent channels, else reply_unknown. Expired routes fail with route_expired. - Disable keeps ready replies, cancels queued/running and marks sending unknown; delete cancels unsent work, marks in-flight unknown and revokes the configuration's bindings. Notifications gain send_unknown. - Manual confirm/resend APIs with action-key de-duplication; resend is a new generation and key. WeCom fallback send only after proven non-delivery. Stage D - bindings and read-only policy - Challenges carry config, channel and masked sender; confirmation must match the configuration; link issuance is rate limited. - botExecutionUser re-reads configuration, binding and project role. - Read-only exec mode: platform writes hidden and refused, external MCP writes and workspace tools refused, drafts never executed; new Bots default to read-only, legacy WeCom keeps auto. - Natural-language Bot answers no longer need a terminal tool call.
Stage E of docs/proposals/enterprise-im.md (R1 Feishu private-chat loop). - channel_feishu.go: Verify obtains a tenant access token (enterprise query is informational); Connect runs the official long connection (larksuite/oapi-sdk-go v3.13.0, auto reconnect off, service reconnects) and acknowledges an event only after persistence within 2.5s, returning 500 for storage errors so Feishu redelivers; Reply uses Message Reply with the persisted send key as uuid. Transport and platform codes are classified (dial failure / rate limit / token: not delivered; other transport: unknown; other codes: rejected). - Tenant confirmation: the first trusted event records a candidate without bumping config_version and answers with a fixed notice; a Bot manager locks it (CAS on configVersion) via /tenant/confirm; locking does not reconnect; other tenants are dropped; conflicts can be rediscovered. - Inbound: private text only, group events counted and ignored, non-text and over-8000-character input get a notice without reaching the model. - Bot management UI: channel picker (DingTalk shown as in development), write approval for WeCom, credential migration hint, enterprise confirmation step with the platform query, record-page confirm/resend actions. Bind page shows channel, Bot, project and masked sender. - OpenAPI for Bot create/update/delete, tenant and manual actions; docs/im-channels.md (setup, minimum Feishu permissions, maintenance window, R1 acceptance checklist); CHANGELOG notes the WeCom read-only default, fallback-send and disable behavior changes; Go notices bundle.
…migration Found by the MySQL 8.4.13 rehearsal and the multi-process fault test: - Feishu ack: repository calls take no context, so a blocked database held the event callback past Feishu's 3s window. The sink now runs in its own goroutine and the callback answers 500 at 2.5s; the redelivery is stored once and processed once (fault test F2). - 037: the WeCom owner backfill and report selected a non-aggregated column, rejected under ONLY_FULL_GROUP_BY (MySQL 8.4 default, error 1055). - Bot natural answers: only plain text from a successful run is accepted. Protocol JSON whose drafts were filtered during parsing (for example "将创建需求") previously passed as the reply; it now reruns the terminal step like any draft attempt. Matrix test covers read-only and legacy auto Bots, progress-only, empty, protocol JSON, failed CLI and redaction. - internal/botinteraction/feishu_fault_mysql_test.go: real MySQL, receiver child processes killed with SIGKILL, simulated Feishu platform with one-hour uuid de-duplication. F1 duplicate delivery, F2 blocked storage, F3 long-connection drop, F4 crash during the model turn (lease takeover), F5 crash with the reply in flight, F6 lost reply response. - docs/im-channels.md: rollback, fault recovery and the natural-answer behavior change; CHANGELOG entry.
Fixed acceptance commit 57c5450; automated results; MySQL 8.4.13 upgrade and rollback rehearsal with legacy data written by origin/main; natural-answer behavior matrix with baseline comparison; fault tests F1-F6; R1-01..R1-13 status by real-environment criteria with the evidence collected so far and what each item still needs.
The page heading, command palette entry and English copy still described WeCom-only notification channels, which read as if Feishu were missing. The channel picker itself is inside Add channel (step 1).
compose.yaml lists the platform environment explicitly, so AGENTFLOW_CREDENTIAL_KEYS never reached the container and saving a Bot secret failed with credential_key_missing even when .env set it. AGENTFLOW_PUBLIC_URL (chat binding links) and AGENTFLOW_BOT_WORKERS_ENABLED were missing as well. - compose.yaml passes the three variables; the public URL falls back to LOOPFORGE_PUBLIC_URL. - scripts/configure.sh generates a 32-byte key for new .env files and adds one to existing .env files that lack it; an existing key is never replaced. - test-install.py covers generation, upgrade of an old .env, idempotence and the compose wiring.
R1 accepted by yowucai on 2026-11-18. Real-tenant pass: R1-01, R1-02, R1-05; rehearsal pass: R1-13; remaining items not run individually and waived by the acceptance owner, with automated and fault-test evidence.
scripts/check-public.py rejects internal identifiers in tracked files.
Stage F of docs/proposals/enterprise-im.md (R2 DingTalk private-chat loop). - channel_dingtalk.go: own Stream connection layer on gorilla/websocket; only payload frames and the chatbot callback model of dingtalk-stream-sdk-go v0.9.1 are used. One reader, serialized writes, no channel closed under a sender; WebSocket ping every 60s with a read deadline; context-aware dial; no reconnect inside the adapter (the service reconnects with backoff); SYSTEM ping answered, disconnect reconnects; bot callbacks acknowledged after persistence within 2.5s, 500 on storage errors, bounded concurrency. - Verify via /v1.0/oauth2/accessToken; endpoint via connections/open with a no-redirect, bounded HTTP client. - Events: senderStaffId identity, sender/bot corp must match, robotCode checked when present; session webhook accepted only for https://oapi.dingtalk.com/robot/sendBySession. - Session webhook sealed with the credential keyring, bound to the interaction (AAD), cleared on replied, route_expired and Bot delete; expiry in ms -> route_expires_at_us. No idempotency key: unknown outcomes stop at reply_unknown. - Enterprise scope: administrator-entered CorpId; the first matching trusted event locks it (config_version+1, attributed to that admin), another enterprise is a sticky conflict until corrected or rediscovered. - API tenantKey (tenant_required, immutable once locked); UI CorpId field and automatic confirmation step; channel page copy. - Tests: event mapping, stream ping/ack/timeout/disconnect/late-frame/ close/cancel (-race), webhook classification and no redirects, service loop, repo tenant/seal, HTTP save, webtest; multi-process MySQL fault test D1-D5 (duplicate, blocked storage, silent gateway + late frame, crash in send + manual resend, expired webhook).
Fixed acceptance commit f9c94e0, automated results, fault tests D1-D5 and the R2-01..R2-12 real-environment checklist (not run: no DingTalk tenant yet), including the facts to record during the pilot.
DingTalk and Feishu replies are plain text, so the Markdown link syntax was shown verbatim and the auto-linker kept the closing bracket in the URL, which made the binding page reject the token. Put the URL on its own line for these channels and make the page extract the 64-hex token tolerantly. Page title no longer says WeCom.
Stage G, part 1. Feishu (im/v1/messages to open_id, send key as uuid) and DingTalk (robot oToMessages/batchSend, cached app token) implement PushSender; notification delivery routes both through it, also for notification-only configurations. Targets are members bound in a private chat with the Bot. Saving a target first sends a trial message and only a confirmed delivery records target_verified_at on the binding; revocation or re-binding clears it. Deliveries persist send_key, generation and the database start time before the network call: Feishu retries an unknown outcome with the same key inside 55 minutes, DingTalk stops at send_unknown. Admins can confirm receipt or resend (new generation and key), and a target switch with queued notifications requires an explicit cancel or migrate choice.
Stage G, part 2. When a DingTalk session webhook expired before the reply went out (reply_failed / route_expired), an administrator can switch the saved reply to a proactive private message to the original sender. The transaction re-checks the configuration, the failed state and that the sender's binding still belongs to the same platform user with a successful trial send; the HTTP layer also re-checks project permission. The reply goes out as a new generation with a new key via PushSender and the switch, actor and reason are recorded. Without a verified sender the records page offers a trial send to that member instead (POST /api/notification-bots/:id/targets/verify), which leaves the notification recipient unchanged.
Stage G, part 3. WeCom Bots get an optional confirm write mode. The turn runs with platform writes blocked; drafts are frozen in bot_pending_drafts (random ID, parameter hash, 30-minute expiry) and the reply carries a summary plus a /bot-approve.html#draft=<id> link. Only the bound platform user can open or confirm a draft. Confirmation re-checks the configuration, the sender's binding, project permission, expiry and the frozen parameters, then moves the draft from pending to executing in one locked statement, so a repeated click or a second tab returns the current state instead of executing again. Execution reuses resolveAssistantDrafts (preflight warnings stop a draft). A draft left in executing is reported as needs_review and never re-run. Unbinding, deleting the Bot, disabling chat or leaving the confirm mode cancel pending drafts. Feishu and DingTalk stay read-only. Also adds a MySQL/MariaDB integration test for the stage G statements (push targets, two-phase pushes, target switch, push resend, draft confirmation under concurrency).
…ation Manual section 8 (recipients and trial sends, delivery rules, DingTalk push resend, WeCom web confirmation, upgrade), the stage G acceptance record with automated results and the real-environment checklist, CHANGELOG, OpenAPI entries and the implementation notes in the proposal (verification stored on bindings, no business idempotency key).
web/embed.go lists static files explicitly; add bot-approve.html and bot-approve.js and cover both Bot pages in the static route test.
Stage H, part 1. An hourly cleanup (with the binding-request cleanup, batches of 1000, at most ten per category and run) applies two horizons to terminal records, counted from when they finished: - body (default 90 days): message, reply and sealed route of interactions, rendered notification content, frozen write drafts and the native CLI logs of Bot turns are removed; rows stay and can no longer be sent or executed again (body_purged_at, content_source purged); - record (default 180 days): the rows are deleted. Records waiting for someone (queued, running, ready, sending, reply_unknown, pending, awaiting_authorization, send_unknown, executing, needs_review) are never touched. Pending drafts past expiry become expired. AGENTFLOW_BOT_BODY_RETENTION_DAYS and AGENTFLOW_BOT_RECORD_RETENTION_DAYS adjust the horizons; 0 disables one. Native logs are removed only where a finished, due bot_native_sessions mapping points: file names equal to the requested or reported session ID in the user's own CLI home (CodeBuddy, Claude Code; Codex rollouts by thread ID), without following symbolic links and skipping sessions still shared with a running or newer mapping. Each mapping records removed, missing, error or unsupported with the relative paths; mappings are deleted after the record horizon only once their log is settled.
compose.yaml passes AGENTFLOW_BOT_BODY_RETENTION_DAYS and AGENTFLOW_BOT_RECORD_RETENTION_DAYS (90/180 by default); the install test checks every Bot variable is wired; deployment.md lists the chat Bot settings.
Conflicts: go.mod/go.sum (both dependency sets, go mod tidy), internal/repo/models.go (Bot tables plus gitHTTPCredentialRow), web/embed.go (bot-approve files plus kimi-code.png) and the Go notice bundle (regenerated with scripts/collect-go-notices.py --write).
Manual: retention settings, upgrade step to confirm them before the first cleanup, section 9 (retention rules, native log cleanup and monitoring) and section 10 (rollback matrix). Final test record with the automated results on the merged code, the MySQL 8.4 upgrade and rollback rehearsal of the final build (first retention run included) and the IM-01..IM-12 traceability per channel. OpenAPI gains the remaining Bot notification routes and the purge markers; CHANGELOG and the proposal note the retention behaviour. The stage G record now carries the MySQL 8.4 rerun.
Feishu and DingTalk Bots can now choose the 网页确认 write mode, so members can create requirements and dispatch or start SOPs from a private chat: the turn returns an operation summary and a confirmation link, and the bound user confirms on the platform page, where the draft runs at most once with the same re-checks as on WeCom. The link stands on its own line in these plain-text channels. Automatic writes stay WeCom only; saving auto on Feishu or DingTalk is refused.
…etting Projects and SOPs get a "启动前澄清" setting (clarifyBeforeStart: required, skip, or empty on an SOP to follow the project). When it applies and the requirement has no saved conclusion, an SOP start requested in a WeCom, Feishu or DingTalk chat does not start the SOP: - "创建后立即启动" / "确认并启动 SOP", issues_dispatch drafts and dispatches of full-access Bots save the requirement as usual and open the chat clarification in the same conversation, marked to start on save; - its conclusion card offers "确认结论并启动 SOP"; the one save that gets through starts the SOP once and the run reports back to the chat; ending the clarification starts nothing; - starts asked for meanwhile are answered "正在这个会话里澄清". Without the setting the SOP starts at once. "澄清 LOOP-7" stays a separate entry that starts nothing by itself. A start whose chat cannot be found starts nothing and points to the platform. Tests: no start before the conclusion is saved (draft start on Feishu and WeCom, dispatch draft, gateway dispatch, ended clarification), repeated saves start once, SOP override and unset project start at once, manual clarification starts nothing. Docs: manual 8.7, acceptance items L-10..L-12, changelog. Co-authored-by: Cursor <cursoragent@cursor.com>
This reverts commit 84c12a7. Clarifying before an SOP starts is not part of the IM work; only node questions are. Co-authored-by: Cursor <cursoragent@cursor.com>
A node that needs supplementary information (a human decision with actionRequired) sends its question back to the run's Feishu, DingTalk or WeCom conversation. "回答:…" or a reply to the question retries the same node of the same run with the answer as human context, as the platform's "补充信息,重跑当前节点" does. The waiting node is the one pending record: answered questions, ended nodes and cancelled runs refuse answers, and answers run as the sender's bound account with project permission checked. Co-authored-by: Cursor <cursoragent@cursor.com>
…em as text The Feishu question card has an answer input and a submit button (card form) instead of approve and retry; the answer comes back with the click, is checked like a chat answer and locks the card. WeCom template cards have no text input, so a node question goes out as a text message to quote. Fix quote matching of questions longer than the matched prefix. Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com> # Conflicts: # CHANGELOG.md # internal/repo/automigrate.go
Co-authored-by: Cursor <cursoragent@cursor.com> # Conflicts: # docs/api/openapi.yaml # internal/httpapi/bot_interactions.go # internal/httpapi/bot_interactions_test.go # web/app/bots.js
Robert0622
left a comment
There was a problem hiding this comment.
复核了 40663e9。只读 Bot 的澄清写入和 SOP 通知目的地需要优先修复,另有两处节点问答问题及两条必需 CI 用例失败。具体位置见行内评论。
本地模拟的飞书 Bot 用已绑定账号调用 CodeBuddy IOA,固定 deepseek-v4.1-flash 并收到预期回复。Bot、通知、草稿和加密相关 Go 用例通过。Bot 与确认页的前端用例 13 通过、1 失败,另外用本地事件复现了两处群聊问答问题。飞书、钉钉真实租户尚未覆盖。
- Route run notifications by the conversation stored with the run at start (ExecutionContext.BotOriginID) instead of the requirement's recent origin. - Refuse clarification saves on read-only Bots, re-reading the Bot config, for both the text and card paths. - WeCom quotes match the whole message, then the whole question, then the prefix; ambiguous quotes ask for a number. - Feishu group replies to an open node question pass without @; document the group message permission. - Update the bot model picker webtest and drop the removed page-feedback route from the e2e sweep. Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com> # Conflicts: # internal/domain/observability.go
Robert0622
left a comment
There was a problem hiding this comment.
复审了 19c27d38。只读写入、SOP 通知来源、飞书群聊引用和企微双待答的回归用例均通过,Bot/确认页前端 14 项通过,当前 platform、validate、e2e 均通过。企微引用已答问题时仍有一处会误重跑另一节点的边界情况,已在本地复现并标在行内。
A quote of an answered question matched only the remaining open ones, so its prefix could hand the answer to another node. Quotes are now located among all node questions sent to the conversation; an answered or ended one gets the stale notice, and a prefix-only ambiguity asks for a number. Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com> # Conflicts: # CHANGELOG.md
|
复核了 本地额外用例复现了 6 个行为问题,IM 投递使用模拟适配器。现有 Bot 相关 Go 测试、Docker MySQL 8.4 集成测试和前端测试通过。 [P1] 用绑定发起人的身份执行聊天澄清 这个入口复用 [P2] 企微私聊投递前复核发起人的项目权限 本地测试中,先用有权限的成员发起运行,再将该成员移出项目。运行随后首次产生节点问题时,通知仍经企微发送适配器发往该成员的原私聊。请在实际发送这类运行通知前,按原发起人的平台账号复核当前项目访问权限。 service.go:150 [P2] 切换通知接收人时保留原会话投递 这里按 Bot 和目标 ID 更新待发记录,也会匹配 [P2] 收到企微发送结果后再记录已发送
[P2] 保留本代首个可能已送达的飞书请求时间 首发结果未知后,如果下一次重试拨号失败,这里会清空 [P2] 企微自动执行派发时也保存会话来源 聊天来源上下文目前由草稿确认和澄清保存传入。用现有企微自动模式从群聊执行派发草稿,API 返回 201,但新运行的 [P3] 将保留期清理归入各领域 Repo
|
…in delivery and retention - Chat clarification runs as the bound starter; each automatic round re-checks the starter's binding and project access. - WeCom private-chat origin deliveries re-check the sender's binding and project access before sending. - WeCom chat posts are linked to their delivery and marked sent only on the actual send result; failures re-send on retry, unconfirmed sends go to send_unknown. - Switching the notification recipient leaves origin deliveries alone, including rows without an origin. - Feishu keeps the first uncertain send time through a failed retry and stops for review past the de-duplication window. - WeCom auto mode records the chat origin for runs started by write tools and final drafts. - Retention purges move into their domain repos; the retention service orchestrates them. Co-authored-by: Cursor <cursoragent@cursor.com>
|
@crispinhu27 已在 0373177 修复这 7 条:
每条都补了测试。repo、botinteraction、notification、httpapi、domain、engine 的 Go 测试均已通过。 |
Co-authored-by: Cursor <cursoragent@cursor.com> # Conflicts: # CHANGELOG.md
|
复审了 [P2] 在实际发送企微私聊时复核项目权限 现有检查会拦截入队前已被移出项目的发起人。本地用例确认,发起人在通知排队期间被移出项目后,发送 worker 仍向原私聊投递,记录也变成 [P2] 企微「再次发送」应启动新一代投递 第一次推送结果未知后,通知记录里的「再次发送」会把通知重置为待发。 [P2] 飞书重试被拒时保留首发的送达不确定性 首发结果未知、重试拨号失败的用例已通过。如果同一代下一次请求被平台明确拒绝, |
…w-fixes # Conflicts: # CHANGELOG.md # go.sum # internal/repo/opentest.go # web/app/access.js
Robert0622
left a comment
There was a problem hiding this comment.
复审 08b5fbef。企微发送前复核权限、手动重发,以及飞书重试被拒后保留「送达待核对」的定向测试均通过。旧问题引用仍有一处会误重跑其他节点,已在本地复现,见行内评论。
| if quote == "" { | ||
| return d, false, false | ||
| } | ||
| sent := h.botChatNodeQuestions(bot, conv, item.SenderID) |
There was a problem hiding this comment.
[P2] 引用旧问题时避免重跑另一条待答节点
本地在 08b5fbef 复现。一个已回答的问题超出七天查询窗口后,同群还有另一条同前缀的待答问题。用户引用旧消息补充答案时,完整匹配找不到旧问题,前缀匹配却命中另一条,导致该节点重跑。七天内的回归用例已通过。请只在能确定引用指向具体问题时提交答案,只有前缀命中时提示用户按编号选择。
Robert0622
left a comment
There was a problem hiding this comment.
复审 fd92c3fb。原来的同前缀旧引用以及企微全文、多行和飞书卡片回答的回归用例均通过。全文相同的旧引用仍会重跑另一运行,已用本地后端复现,见行内评论。
| return quote == strings.TrimSpace(q.delivery.Content) | ||
| }, | ||
| func(q botNodeQuestion) bool { | ||
| return question == domain.NotificationText(q.question, 1200) |
There was a problem hiding this comment.
[P2] 引用带运行链接时,按该链接限定问题匹配范围
本地在 fd92c3fb 复现。同群的两个运行问了全文一致的问题,旧问题已回答且超出七天查询窗口。引用旧消息仍带旧运行的详情链接,但整条消息比较会因已渲染的链接与库内占位符不同而失败,随后全文匹配忽略链接,唯一命中新运行并让它重跑。请在引用带有效详情链接时,先按链接识别原运行并只在该运行内匹配。无法确认原消息时,提示按编号选择。
Robert0622
left a comment
There was a problem hiding this comment.
复审 0e36b4db。上轮跨运行全文相同的复现用例及已有企微、飞书问答回归均通过。补测发现同一运行内的两个节点仍可能串答,见行内评论。
| return quote == strings.TrimSpace(q.delivery.Content) | ||
| }, | ||
| func(q botNodeQuestion) bool { | ||
| return question == domain.NotificationText(q.question, 1200) |
There was a problem hiding this comment.
[P2] 用原问题的投递身份区分同一运行内的节点
本地在 0e36b4db 复现。同一运行先后由「需求定型」和「验收核对」提出相同问题,前一节点已回答且通知超出七天查询窗口。引用旧通知时,消息仍明确写着「需求定型」,但两个节点共用运行详情链接,全文匹配就把答案提交给仍待答的「验收核对」并重跑。请用能唯一定位节点及尝试次数的投递标识进行自动匹配,或者在引用的节点与候选不一致时要求用户按编号确认。
Robert0622
left a comment
There was a problem hiding this comment.
复审 6e660407。本地后端定向测试通过,覆盖同一运行不同节点、跨运行同文问题、同一节点的不同尝试、跨会话引用、旧通知回退到编号,以及企微文本通知和飞书卡片回答。上轮复现的串答均已修复。
Brings in the upstream wave: Feishu and DingTalk enterprise IM chat Bots and proactive notifications (Tencent#1114), analytics cost accounting fixes (Tencent#1268), embedded VS Code reload loop prevention (Tencent#1256), collapsible schedule job groups (Tencent#1266), native sandbox repo caching (Tencent#1258), Gorilla WebSocket security patch GO-2026-6278 (Tencent#1281), assistant approval reviews with AI decisions and custom reviewers (Tencent#1216), and HTTPS host authorization (Tencent#1232). Conflict resolutions: - compose.yaml: retain AGENTFLOW_CONVERSATION_RELAY_HOST and network settings, bump image tag to 0.4.2 - internal/httpapi/cli_models_probe.go: preserve local DSH and Pi AI catalog merging alongside upstream Connected: true - internal/httpapi/cli_models_probe_test.go: retain all local catalog and Qoder model tests alongside upstream official endpoint probe tests - web/app/workbench.js: combine wizard CLI install action and runtime notices
What changed
Chat Bots now cover three enterprise IM channels instead of WeCom only, following
docs/proposals/enterprise-im.md(v3, stages A–H).网页确认, all three channels): the turn freezes write drafts and replies with a summary and a/bot-approve.html#draft=…link; only the bound user can open it, confirmation re-checks binding, project permission, expiry and parameters, and a draft runs at most once. Automatic writes stay WeCom only. New WeCom Bots default to read-only; existing ones keep automatic execution.uuid; DingTalk stops at “delivery unknown” for manual confirm or resend. Expired DingTalk replies can be resent as a proactive private message.reply_unknowninstead of guessing, manual confirm/resend on the record page, maintenance switchAGENTFLOW_BOT_WORKERS_ENABLED.AGENTFLOW_CREDENTIAL_KEYS,-credential-action status|reencrypt); Compose generates a key.0keeps).Manual:
docs/im-channels.md. Final test record:docs/testing/im-final-test-record.md.Scope
Compatibility
User-visible changes (also in
CHANGELOG.md):AGENTFLOW_BOT_BODY_RETENTION_DAYS/AGENTFLOW_BOT_RECORD_RETENTION_DAYSfirst if longer retention is needed.Upgrade needs a maintenance window (manual section 2): stop all old replicas → start the new version once with
AGENTFLOW_BOT_WORKERS_ENABLED=false(startup DDL adds columns and tables) → runmigrations/036_enterprise_im_channels.sqland037_bot_binding_ownership.sql(idempotent) → configure keys and run-credential-action reencrypt→ confirm retention settings → restart with workers enabled. Afterreencrypt, rolling back to a pre-IM build requires restoring the backup (rollback matrix in manual section 10).New dependencies:
github.com/larksuite/oapi-sdk-go/v3v3.13.0 (Feishu long connection) andgithub.com/open-dingtalk/dingtalk-stream-sdk-gov0.9.1 (only itspayload/chatbotdata types; the connection loop is an in-repo Stream client because the SDK client can crash the process, reproduction in the separate probe modulescripts/im-sdk-probe). Go notices regenerated.Validation
Run locally on the merged code (
origin/main@6f606cfmerged in, no conflicts left):Upgrade and rollback rehearsal on MySQL 8.4.13 from
origin/main@6f606cfto this branch, including the first retention run and restore-backup rollback: see the final test record, section 3.Real tenants: Feishu private chat (R1) and DingTalk private chat (R2) signed off on a staging deployment; stage G signed off without per-item evidence. Feishu/DingTalk web confirmation (W-01..W-04) not yet run in a real tenant.
Not run locally (left to CI): Go coverage gate, real-browser tests,
scan-secrets.sh, Playwright e2e,local/scripts/*.Update 2026-11-22: SOP node questions in chat, merged with main
d0b77af,c0aebf8,docs/im-channels.md8.8): a node that submits ahumandecision withactionRequiredposts its question to the originating Feishu, DingTalk or WeCom conversation. The answer retries the same node of the same run with the answer as human context (one run throughout). IM and the platform act on the same waiting node; answered questions, ended nodes and cancelled runs refuse answers, and answers run as the sender's bound account with project permission checked.84c12a7) is reverted in35d2dd2.maintwice (0ab1315,40663e9). Choices in the Make CodeBuddy optional across platform model workflows #1157 (CodeBuddy optional) overlap:resolveFeatureModeland the new model check; the branch's chat clarification, read-only / web-confirm modes and node answers are kept.036_enterprise_im_channels.sql/037_bot_binding_ownership.sqlshare numbers with main's036_git_http_credentials.sql/037_retire_plain_git_token.sql; run all four when upgrading.go build,go vet,gofmtclean;go test ./...passes except 7 Docker sandbox tests ininternal/runtimethat fail identically on plainmainin a sandbox without a Docker network. Frontend JS tests not run locally (no node); left to CI.Safety