Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 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
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
21 changes: 21 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,27 @@

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)

- 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 SOP they will be bound to, and the confirmation page lets the user choose another 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.0 — scheduled task history, an MR node in delivery SOPs and agent CLIs in conversation workspaces

- Scheduled tasks keep an execution history with a session mode, keep conversations per job and gain row actions (#958). AI jobs run with the key of the user who saved them and fall back to the shared key (#966).
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", "", "provider for CLI rollback: codex, codebuddy, or claude-code")
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 @@ -33,6 +33,14 @@ services:
AGENTFLOW_SECURE_COOKIES: ${AGENTFLOW_SECURE_COOKIES:-false}
AGENTFLOW_GITHUB_CLIENT_ID: ${AGENTFLOW_GITHUB_CLIENT_ID:-}
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