Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
99834b3
docs(im): add enterprise IM rollout proposal v3
Nov 18, 2026
e8f24e3
refactor(im): define channel contracts and wrap wecom
Nov 18, 2026
edd060a
test(im): pin Feishu and DingTalk SDK probes
Nov 18, 2026
386a7b1
test(im): count reconnect attempts atomically
Nov 18, 2026
addcaa1
docs(im): record DingTalk StreamClient crash reproduction
Nov 18, 2026
7fc24c1
feat(im): scope bot configs, fence delivery and enforce read-only bots
Nov 18, 2026
5d52656
feat(im): connect feishu private chats
Nov 18, 2026
57c5450
fix(im): bound Feishu acks, accept only plain bot answers, MySQL 8.4 …
Nov 18, 2026
a02bd86
docs(im): record R1 acceptance baseline and results
Nov 18, 2026
b533691
fix(im): describe Feishu on the channel management page
Nov 18, 2026
e148fe1
fix(im): pass Bot credential key and public URL to Compose deployments
Nov 18, 2026
308bf78
docs(im): record R1-01, R1-02 and R1-05 real-tenant results
Nov 18, 2026
57adbf2
docs(im): record R1 sign-off
Nov 18, 2026
c9ea35e
docs(im): drop personal login from the R1 sign-off record
Nov 18, 2026
f9c94e0
feat(im): connect dingtalk stream chats
Nov 18, 2026
f077c20
docs(im): add R2 DingTalk acceptance record
Nov 18, 2026
64e1619
fix(im): send bare binding links on plain-text channels
Nov 19, 2026
0c5209a
docs(im): record R2 DingTalk sign-off
Nov 19, 2026
32e8eea
feat(im): proactive Feishu and DingTalk notifications
Nov 19, 2026
03f9541
feat(im): resend expired DingTalk replies as private messages
Nov 19, 2026
74bbc34
feat(im): confirm WeCom Bot writes on the platform page
Nov 19, 2026
5a43e06
docs(im): document stage G notifications, push resend and web confirm…
Nov 19, 2026
f86881a
fix(im): embed the Bot approval page in the binary
Nov 19, 2026
0342311
docs(im): pin the stage G acceptance commit
Nov 19, 2026
88b6efa
docs(im): record stage G sign-off
Nov 19, 2026
859e0bf
feat(im): retention cleanup for Bot data and native CLI logs
Nov 19, 2026
96efdf8
chore(im): pass retention settings through Compose and document them
Nov 19, 2026
6df93df
Merge origin/main into feature/enterprise-im
Nov 19, 2026
f4eba52
docs(im): stage H manual, final test record and API entries
Nov 19, 2026
d83dc7c
feat(im): web-confirmed writes for Feishu and DingTalk Bots
Nov 19, 2026
c1800f6
feat(im): pick the SOP of requirements created from chat
Nov 20, 2026
564224f
feat(im): action cards for Feishu and DingTalk notifications
Nov 20, 2026
16516b9
feat(im): Feishu confirmation cards, group @ replies and the answer m…
Nov 20, 2026
c78b940
feat(im): offer the project default SOP on the confirmation page
Nov 20, 2026
fe63301
test(e2e): reach eight more API routes and set a credential key in lo…
Nov 20, 2026
2d17dad
test(im): use low-entropy send keys in Bot tests
Nov 20, 2026
1c94840
feat(im): pick the SOP on the Feishu card, answer clicks where asked,…
Nov 20, 2026
4baf65c
test(engine): wait for the second holder before checking keyed lock e…
Nov 20, 2026
1922437
feat(im): report chat-started runs back to their chat, clarify requir…
Nov 20, 2026
da57d9c
feat(im): pick the repository of requirements created from chat
Nov 20, 2026
73e9078
feat(im): WeCom matches Feishu: confirmation cards, run progress back…
Nov 20, 2026
84c12a7
feat(im): clarify before starting an SOP from chat, per project/SOP s…
Nov 20, 2026
35d2dd2
revert(im): drop the project/SOP clarify-before-start setting
Nov 20, 2026
d0b77af
feat(im): answer SOP node questions in the chat the run came from
Nov 20, 2026
c0aebf8
feat(im): answer node questions in a Feishu card input; WeCom gets th…
Nov 21, 2026
0ab1315
Merge remote-tracking branch 'origin/main' into feature/enterprise-im
Nov 21, 2026
40663e9
Merge remote-tracking branch 'origin/main' into feature/enterprise-im
Nov 22, 2026
ed2aaf0
fix(im): address PR #1114 review
Nov 22, 2026
19c27d3
Merge remote-tracking branch 'origin/main' into feature/enterprise-im
Nov 22, 2026
beb1cee
fix(im): locate WeCom quotes among answered node questions too
Nov 23, 2026
f9b0398
Merge remote-tracking branch 'origin/main' into feature/enterprise-im
Nov 23, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,31 @@

Platform releases use `vX.Y.Z` tags and publish `ghcr.io/tencent/loopforge`. LoopForge Local packages use `local-vX.Y.Z` tags and are published by manually running the `release-local` workflow.

## Unreleased — enterprise IM channels (Feishu and DingTalk chats, proactive notifications, data retention)

- Runs started from a Feishu or DingTalk chat (confirm and start, dispatch, or save-and-start after a chat clarification) report back to that conversation without any SOP notification binding: a failed or waiting node arrives as an action card, the end of the run as a short message. Group runs report to the group, where any bound project member can use the card buttons as themselves; the card then names who acted and locks. Feishu sends group messages by `chat_id`, DingTalk through the robot group message API and `IM_GROUP` cards. The starting conversation is stored with the run when it is created; a later run of the same requirement started on the platform is not sent to the chat.
- A node that needs supplementary information (a `human` decision with `actionRequired`) sends its question to the chat the run was started from. Answering in that chat (“回答:…”, or a reply to the question in Feishu and WeCom) retries the same node of the same run with the answer as human context, like “补充信息,重跑当前节点” on the platform. On Feishu the question card has an answer input and a “提交答案” button instead of approve and retry; WeCom template cards have no text input, so WeCom gets the question as a text message to quote. IM and the platform act on the same waiting node: an answered question, an ended node or a cancelled run refuses further answers, and answers run as the sender’s bound account with the project permission checked. A WeCom quote matches the whole question message first; a quote matching several open questions asks for a number instead of answering one. In Feishu groups a reply to the question needs no @ when the application has the “read all group messages” permission. See `docs/im-channels.md` section 8.8.
- WeCom Bots with chat enabled match Feishu: write confirmations come with a card (a multiple-choice card with repository, SOP and operation drop-downs for a new requirement, otherwise buttons), runs started from a WeCom chat report back to it over the long connection, and requirements can be clarified in WeCom chats with button cards.
- Requirements can be clarified in Feishu and DingTalk chats: “澄清 LOOP-7” runs the platform clarification in the background and posts each round's numbered questions into the conversation. In groups any bound member may answer; numbered answers and quotes of the question card count, other messages are judged by a small model, and when it is unsure the speaker is asked to confirm. The next round starts when all questions are answered, on request, or three minutes after the last answer. A conclusion is written into the requirement (and back to TAPD or 工蜂) only when the responsible person, the starter or a project maintainer saves it, once; a read-only Bot refuses to save. New tables `bot_chat_origins` and `bot_clarify_sessions` and the columns `notification_deliveries.origin` and `bot_interactions.reply_to` are added by the startup DDL. See `docs/im-channels.md` sections 8.6 and 8.7.
- Feishu and DingTalk notifications of waiting or failed nodes are action cards when the Bot has chat enabled: approve, retry, rework or pass directly in the chat, with the same checks as WeCom cards; the result comes back as a private message. Feishu needs the `card.action.trigger` callback on the long connection; DingTalk needs an interactive card template ID in the Bot settings (empty keeps text notifications).
- Feishu and DingTalk Bots answer in group chats when @-mentioned (Feishu needs the “read @-bot messages in groups” permission); other group messages are ignored. Each group has its own shared context and every message runs as the sender's bound account.
- Feishu write confirmations are a card with “确认执行 / 确认并启动 SOP / 取消” buttons instead of a bare link; only the requester can use them and the result arrives as a private message. The Bot form labels the model field “回答模型” and keeps “默认” selectable.
- Requirements created from chat show the repository and the SOP they will be bound to (the project defaults unless named in the chat); the Feishu confirmation card and the confirmation page let the user choose another repository and SOP of the project and start it right after creation.
- **Chat Bot data now has a retention period.** An hourly cleanup removes the text of finished conversation turns, notification deliveries and web-confirmation drafts, and the native CLI logs of Bot turns, 90 days after they finished, and deletes the finished records after 180 days. This also applies to existing WeCom conversation and notification records on the first start after upgrading. Records still waiting for someone (in progress, ready to send, delivery unknown) are kept. Set `AGENTFLOW_BOT_BODY_RETENTION_DAYS` and `AGENTFLOW_BOT_RECORD_RETENTION_DAYS` (0 keeps forever) before enabling the Bot workers if you need longer. Records whose text was removed show “正文已按保留期清理” and cannot be sent again. See `docs/im-channels.md` sections 9 and 10.
- Feishu and DingTalk Bots send SOP notifications (completed, failed, waiting) as private messages to one member who bound an account in a private chat with the Bot; notification-only configurations (chat disabled) work too. Saving the recipient first sends a trial message and only a confirmed delivery is accepted; unbinding clears it. Feishu unknown outcomes are retried with the same uuid for 55 minutes, DingTalk ones stop at 送达待核对, where managers can confirm receipt or send again. Switching the recipient with queued notifications asks whether to move or cancel them. See `docs/im-channels.md` section 8.
- A DingTalk reply whose session webhook expired can be sent to the original sender as a proactive private message from the record page, after that member passed a trial send.
- WeCom Bots gain the 网页确认 write mode: writes come back as a summary and a confirmation link, the bound user confirms on the platform page, and a draft runs at most once. Feishu and DingTalk Bots can use the same mode (they cannot write automatically), so requirements can be created and SOPs dispatched or started from a private chat after a confirmation on the platform page.
- DingTalk enterprise internal applications can be added as Bots over Stream mode: private text chats, account binding and read-only queries, replies through each message's session webhook. The administrator enters the enterprise CorpId; the first matching message confirms it automatically, another enterprise stops processing as a conflict. The Stream connection is implemented by the platform (only data types of `open-dingtalk/dingtalk-stream-sdk-go` v0.9.1 are used) because the SDK's client can crash the process after a heartbeat timeout. Session webhooks are stored encrypted and cleared when used or expired; replies whose webhook expired stay on the record page as 会话回复授权已过期. See `docs/im-channels.md` section 4A.

- Feishu self-built applications can be added as Bots: private text chats, account binding and read-only project queries over the official long connection (`larksuite/oapi-sdk-go` v3.13.0). The first message from a new application records its enterprise; a Bot manager confirms it before any request is processed, and messages from other enterprises are dropped. See `docs/im-channels.md`.
- **New WeCom Bots default to read-only.** A Bot created from now on answers queries but does not write; writes are refused with a pointer to the platform page. Existing WeCom Bots keep automatic execution. Managers choose the mode under 执行权限.
- **WeCom fallback send changed.** A reply whose stream fails is sent again as a proactive message only when the stream provably did not go out (stream unavailable, request never written, or rejected by WeCom). A stream that may have been delivered but had no receipt is no longer sent twice: the record shows 送达待核对, and a manager chooses 确认已收到 or 再次发送 (a new delivery that may duplicate) on the record page.
- **Disabling a Bot keeps generated replies.** Queued and running turns are cancelled, replies already generated wait and are sent after the Bot is enabled again, and a send in progress becomes 送达待核对. Deleting a Bot cancels unsent work, moves in-flight sends to 待核对, and revokes the Bot's chat bindings.
- Bot secrets are encrypted with AES-256-GCM using `AGENTFLOW_CREDENTIAL_KEYS`. Compose installations get a generated key in `.env` (added to existing `.env` files on the next `./start.sh`), and `compose.yaml` now passes `AGENTFLOW_CREDENTIAL_KEYS`, `AGENTFLOW_PUBLIC_URL` and `AGENTFLOW_BOT_WORKERS_ENABLED` to the platform container. Back up `.env` together with the database. Existing plaintext secrets stay readable; `agentflow -credential-action status|reencrypt` reports and migrates them. Without a key, saving a new secret returns `credential_key_missing`.
- **Bot chats accept a plain natural-language answer.** Before, a Bot turn could only end through `submit_assistant_reply`, which refuses replies without drafts, so plain query answers ran the model three times and failed with 助手未提交回复. Now plain text from a successful run is the reply; protocol JSON, progress-only text, empty output and failed runs still go through the terminal retry. Writes still need drafts or the tool gateway. Applies to WeCom and Feishu Bots, not to the web assistant or SOP nodes.
- Receiving leases, send windows and retries are judged on the database clock with an epoch per owner, so a replica that lost its lease can no longer overwrite a reply or send it twice. Notification deliveries gain the state `send_unknown`.
- Upgrading needs a maintenance window: stop every old replica, start the new version once with `AGENTFLOW_BOT_WORKERS_ENABLED=false`, run `migrations/036_enterprise_im_channels.sql` and `migrations/037_bot_binding_ownership.sql`, run `-credential-action reencrypt`, then restart with workers enabled. Bots not backfilled by 036 do not receive messages.

## 0.4.1 — Git and MCP credentials, SOP orchestration and conversation workspaces

- Configure HTTPS Git credentials per host, authorize the IP addresses of self-hosted HTTPS Git servers, and distribute trusted SSH host keys to execution machines. MCP servers, market items and SOP nodes can use configured credentials.
Expand Down
39 changes: 39 additions & 0 deletions cmd/agentflow/credentials.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package main

import (
"agentflow/internal/repo"
"errors"
"fmt"
"io"
)

// runCredentialAction implements -credential-action. status counts plaintext
// and sealed Bot credentials per key id; reencrypt seals plaintext and
// rewraps old key ids with the current key, one row at a time. Only counts
// and key ids are printed, never secret values. reencrypt is re-entrant.
func runCredentialAction(s *repo.Store, action string, out io.Writer) error {
var report repo.CredentialReport
var err error
switch action {
case "status":
report, err = s.BotCredentialStatus()
case "reencrypt":
report, err = s.ReencryptBotCredentials()
default:
return errors.New("-credential-action must be status or reencrypt")
}
if err != nil && !errors.Is(err, repo.ErrCredentialKeyMissing) {
return err
}
fmt.Fprintf(out, "bot credentials %s: %s\n", action, report)
for _, failure := range report.Failed {
fmt.Fprintf(out, "failed %s\n", failure)
}
if err != nil {
return fmt.Errorf("AGENTFLOW_CREDENTIAL_KEYS is required for reencrypt: %w", err)
}
if len(report.Failed) > 0 {
return fmt.Errorf("%d credential(s) failed", len(report.Failed))
}
return nil
}
20 changes: 19 additions & 1 deletion cmd/agentflow/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
"time"

"agentflow/internal/config"
"agentflow/internal/credcrypt"
"agentflow/internal/engine"
"agentflow/internal/httpapi"
"agentflow/internal/managedcli"
Expand Down Expand Up @@ -95,6 +96,7 @@ func main() {
cliProvider := flag.String("cli-provider", "", "managed CLI provider to roll back")
cliTimeout := flag.Duration("cli-timeout", 80*time.Minute, "total managed CLI operation timeout")
browserImage := flag.Bool("browser-image", false, "build or pull the agent browser sidecar image, print its name and exit")
credentialAction := flag.String("credential-action", "", "Bot credential administration: status or reencrypt; exits without starting services")
flag.Parse()
loadDotEnv()
if *browserImage {
Expand All @@ -107,7 +109,7 @@ func main() {
fmt.Println(image)
return
}
if os.Getenv("AGENTFLOW_SESSION_SECRET") == "" && *cliAction == "" {
if os.Getenv("AGENTFLOW_SESSION_SECRET") == "" && *cliAction == "" && *credentialAction == "" {
log.Fatal("AGENTFLOW_SESSION_SECRET is required; generate with openssl rand -hex 32")
}
if os.Getenv("AGENTFLOW_AUTH_REQUIRED") == "" {
Expand Down Expand Up @@ -137,6 +139,22 @@ func main() {
if err != nil {
log.Fatal(err)
}
keyring, err := credcrypt.FromEnv()
if err != nil {
log.Fatal(err)
}
s.SetCredentialKeyring(keyring)
if *credentialAction != "" {
if err := runCredentialAction(s, *credentialAction, os.Stdout); err != nil {
log.Fatal(err)
}
return
}
if keyring == nil {
log.Printf("%s is not set: stored plaintext Bot secrets stay readable, saving a new secret returns credential_key_missing", credcrypt.EnvKeys)
} else {
log.Printf("bot credential keyring current_kid=%s", keyring.CurrentKID())
}
log.Printf("storage driver=%v database=%v role=%s", s.StorageInfo()["driver"], s.StorageInfo()["database"], role)
e := engine.New(s, runtime.NewManagerWithLimit(root, *workerConcurrency))
runtime.PrebuildIsolatedImage()
Expand Down
8 changes: 8 additions & 0 deletions compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,14 @@ services:
AGENTFLOW_TAPD_HOST: ${AGENTFLOW_TAPD_HOST:-}
AGENTFLOW_MCP_TOKEN: ${AGENTFLOW_MCP_TOKEN:-}
AGENTFLOW_GIT_SSH_KNOWN_HOSTS: ${AGENTFLOW_GIT_SSH_KNOWN_HOSTS:-}
# Chat Bots: keys sealing Bot secrets (scripts/configure.sh adds one),
# the address users open from chat links, the maintenance switch and
# the retention of chat text and records in days (0 keeps forever).
AGENTFLOW_CREDENTIAL_KEYS: ${AGENTFLOW_CREDENTIAL_KEYS:-}
AGENTFLOW_PUBLIC_URL: ${AGENTFLOW_PUBLIC_URL:-${LOOPFORGE_PUBLIC_URL:-}}
AGENTFLOW_BOT_WORKERS_ENABLED: ${AGENTFLOW_BOT_WORKERS_ENABLED:-true}
AGENTFLOW_BOT_BODY_RETENTION_DAYS: ${AGENTFLOW_BOT_BODY_RETENTION_DAYS:-90}
AGENTFLOW_BOT_RECORD_RETENTION_DAYS: ${AGENTFLOW_BOT_RECORD_RETENTION_DAYS:-180}
AGENTFLOW_ASSISTANT_SESSION_DIR: /data/assistant
AGENTFLOW_CONVERSATION_DIR: ${LOOPFORGE_DATA_DIR}/conversations
AGENTFLOW_CLARIFY_SESSION_DIR: /data/clarify
Expand Down
Loading
Loading