Add Feishu and DingTalk integration support in robot lifecycle</message>

<message>
- Introduce Feishu and DingTalk adapters in the robot lifecycle for enhanced integration capabilities.
- Update the integration dispatcher to include new adapters for handling events from Feishu and DingTalk.
- Modify the configuration structure to support settings for both Feishu and DingTalk integrations.
- Enhance the integration parsing logic to recognize and process configurations for Feishu and DingTalk.
This commit is contained in:
Max 2026-03-02 07:36:34 +08:00
parent 6c81bab8f2
commit 33efd3e890
34 changed files with 3085 additions and 9 deletions

View file

@ -7,6 +7,8 @@ import (
robotevents "github.com/yaoapp/yao/agent/robot/events"
"github.com/yaoapp/yao/agent/robot/events/integrations"
dtadapter "github.com/yaoapp/yao/agent/robot/events/integrations/dingtalk"
fsadapter "github.com/yaoapp/yao/agent/robot/events/integrations/feishu"
"github.com/yaoapp/yao/agent/robot/events/integrations/telegram"
"github.com/yaoapp/yao/agent/robot/logger"
"github.com/yaoapp/yao/agent/robot/manager"
@ -59,6 +61,8 @@ func Start() error {
// Start integration dispatcher (Telegram polling, webhook subscriptions, etc.)
adapters := map[string]integrations.Adapter{
"telegram": telegram.NewAdapter(),
"feishu": fsadapter.NewAdapter(),
"dingtalk": dtadapter.NewAdapter(),
}
globalDispatcher = integrations.NewDispatcher(globalManager.Cache(), adapters)
if err := globalDispatcher.Start(context.Background()); err != nil {

View file

@ -0,0 +1,44 @@
package dingtalk
import (
"sync"
"time"
)
const (
dedupTTL = 24 * time.Hour
dedupCleanInterval = time.Hour
)
type dedupStore struct {
m sync.Map
}
func newDedupStore() *dedupStore {
return &dedupStore{}
}
func (d *dedupStore) markSeen(key string) bool {
now := time.Now().Unix()
_, loaded := d.m.LoadOrStore(key, now)
return !loaded
}
func (d *dedupStore) cleaner(stopCh <-chan struct{}) {
ticker := time.NewTicker(dedupCleanInterval)
defer ticker.Stop()
for {
select {
case <-stopCh:
return
case <-ticker.C:
cutoff := time.Now().Add(-dedupTTL).Unix()
d.m.Range(func(key, value any) bool {
if ts, ok := value.(int64); ok && ts < cutoff {
d.m.Delete(key)
}
return true
})
}
}
}

View file

@ -0,0 +1,139 @@
package dingtalk
import (
"context"
"sync"
"github.com/yaoapp/yao/agent/robot/logger"
robottypes "github.com/yaoapp/yao/agent/robot/types"
dtapi "github.com/yaoapp/yao/integrations/dingtalk"
)
var log = logger.New("dingtalk")
// Adapter implements the integrations.Adapter interface for DingTalk.
//
// Architecture:
// - One DingTalk Stream client per registered bot for real-time message reception
// - One dedup cleaner goroutine removes expired keys every hour
type Adapter struct {
mu sync.RWMutex
bots map[string]*botEntry // robotID -> *botEntry
appIdx map[string]string // clientID -> robotID
dedup *dedupStore
stopCh chan struct{}
}
// botEntry holds the state for one robot's DingTalk integration.
type botEntry struct {
robotID string
clientID string
bot *dtapi.Bot
cancelFn context.CancelFunc
}
// NewAdapter creates a new DingTalk adapter.
func NewAdapter() *Adapter {
a := &Adapter{
bots: make(map[string]*botEntry),
appIdx: make(map[string]string),
dedup: newDedupStore(),
stopCh: make(chan struct{}),
}
go a.dedup.cleaner(a.stopCh)
return a
}
// Apply is called by the Dispatcher when a robot config is created or updated.
func (a *Adapter) Apply(ctx context.Context, robot *robottypes.Robot) {
dtConf := extractConfig(robot)
log.Debug("Apply robot=%s dtConf=%v", robot.MemberID, dtConf != nil)
if dtConf == nil || !dtConf.Enabled || dtConf.ClientID == "" || dtConf.ClientSecret == "" {
a.removeBot(robot.MemberID)
return
}
a.mu.Lock()
defer a.mu.Unlock()
if existing, ok := a.bots[robot.MemberID]; ok {
if existing.clientID == dtConf.ClientID {
return
}
a.removeBotLocked(robot.MemberID)
}
bot := dtapi.NewBot(dtConf.ClientID, dtConf.ClientSecret)
streamCtx, streamCancel := context.WithCancel(context.Background())
entry := &botEntry{
robotID: robot.MemberID,
clientID: dtConf.ClientID,
bot: bot,
cancelFn: streamCancel,
}
a.bots[robot.MemberID] = entry
a.appIdx[dtConf.ClientID] = robot.MemberID
go a.streamLoop(streamCtx, entry)
log.Info("dingtalk adapter: registered robot=%s client=%s", robot.MemberID, dtConf.ClientID)
}
// Remove is called by the Dispatcher when a robot is deleted.
func (a *Adapter) Remove(ctx context.Context, robotID string) {
a.removeBot(robotID)
}
// Shutdown stops all stream connections and dedup cleaner.
func (a *Adapter) Shutdown() {
close(a.stopCh)
a.mu.Lock()
for _, entry := range a.bots {
if entry.cancelFn != nil {
entry.cancelFn()
}
}
a.mu.Unlock()
log.Info("dingtalk adapter: shutdown complete")
}
func (a *Adapter) removeBot(robotID string) {
a.mu.Lock()
defer a.mu.Unlock()
a.removeBotLocked(robotID)
}
func (a *Adapter) removeBotLocked(robotID string) {
entry, ok := a.bots[robotID]
if !ok {
return
}
if entry.cancelFn != nil {
entry.cancelFn()
}
if entry.clientID != "" {
delete(a.appIdx, entry.clientID)
}
delete(a.bots, robotID)
log.Info("dingtalk adapter: unregistered robot=%s", robotID)
}
func (a *Adapter) resolveByClientID(clientID string) (*botEntry, bool) {
a.mu.RLock()
defer a.mu.RUnlock()
robotID, ok := a.appIdx[clientID]
if !ok {
return nil, false
}
entry, ok := a.bots[robotID]
return entry, ok
}
func extractConfig(robot *robottypes.Robot) *robottypes.DingTalkConfig {
if robot.Config == nil || robot.Config.Integrations == nil {
return nil
}
return robot.Config.Integrations.DingTalk
}

View file

@ -0,0 +1,217 @@
package dingtalk
import (
"context"
"os"
"testing"
"time"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
robottypes "github.com/yaoapp/yao/agent/robot/types"
dtapi "github.com/yaoapp/yao/integrations/dingtalk"
)
var (
dtClientID string
dtClientSecret string
)
func TestMain(m *testing.M) {
dtClientID = os.Getenv("DINGTALK_TEST_CLIENT_ID")
dtClientSecret = os.Getenv("DINGTALK_TEST_CLIENT_SECRET")
os.Exit(m.Run())
}
func skipIfNoCreds(t *testing.T) {
t.Helper()
if dtClientID == "" || dtClientSecret == "" {
t.Skip("DINGTALK_TEST_CLIENT_ID or DINGTALK_TEST_CLIENT_SECRET not set")
}
}
// TestE2E_Adapter_Apply verifies that Apply correctly registers a bot.
func TestE2E_Adapter_Apply(t *testing.T) {
skipIfNoCreds(t)
a := &Adapter{
bots: make(map[string]*botEntry),
appIdx: make(map[string]string),
dedup: newDedupStore(),
stopCh: make(chan struct{}),
}
defer close(a.stopCh)
robot := &robottypes.Robot{
MemberID: "robot_e2e_dt_adapter",
TeamID: "team_e2e_dt",
Config: &robottypes.Config{
Integrations: &robottypes.Integrations{
DingTalk: &robottypes.DingTalkConfig{
Enabled: true,
ClientID: dtClientID,
ClientSecret: dtClientSecret,
},
},
},
}
a.Apply(context.Background(), robot)
a.mu.RLock()
entry, ok := a.bots["robot_e2e_dt_adapter"]
a.mu.RUnlock()
require.True(t, ok, "bot should be registered")
assert.Equal(t, dtClientID, entry.clientID)
assert.NotNil(t, entry.bot)
t.Logf("OK Apply: dingtalk bot registered robot=%s client=%s", robot.MemberID, entry.clientID)
}
// TestE2E_Adapter_Apply_Update verifies re-Apply with same clientID is a no-op.
func TestE2E_Adapter_Apply_Update(t *testing.T) {
skipIfNoCreds(t)
a := &Adapter{
bots: make(map[string]*botEntry),
appIdx: make(map[string]string),
dedup: newDedupStore(),
stopCh: make(chan struct{}),
}
defer close(a.stopCh)
robot := &robottypes.Robot{
MemberID: "robot_e2e_dt_update",
TeamID: "team_e2e_dt",
Config: &robottypes.Config{
Integrations: &robottypes.Integrations{
DingTalk: &robottypes.DingTalkConfig{
Enabled: true,
ClientID: dtClientID,
ClientSecret: dtClientSecret,
},
},
},
}
a.Apply(context.Background(), robot)
a.mu.RLock()
_, ok := a.bots["robot_e2e_dt_update"]
a.mu.RUnlock()
require.True(t, ok)
a.Apply(context.Background(), robot)
a.mu.RLock()
assert.Len(t, a.bots, 1)
a.mu.RUnlock()
a.Remove(context.Background(), "robot_e2e_dt_update")
a.mu.RLock()
_, ok = a.bots["robot_e2e_dt_update"]
a.mu.RUnlock()
assert.False(t, ok, "bot should be removed")
t.Log("OK Apply/Remove lifecycle verified")
}
// TestE2E_Adapter_Dedup verifies deduplication works.
func TestE2E_Adapter_Dedup(t *testing.T) {
a := &Adapter{
bots: make(map[string]*botEntry),
appIdx: make(map[string]string),
dedup: newDedupStore(),
stopCh: make(chan struct{}),
}
defer close(a.stopCh)
key := "dt:test-robot:msg-12345"
assert.True(t, a.dedup.markSeen(key), "first time should return true")
assert.False(t, a.dedup.markSeen(key), "second time should return false (dedup)")
t.Log("OK dedup working correctly")
}
// TestE2E_Adapter_HandleMessages verifies message handling through the adapter.
func TestE2E_Adapter_HandleMessages(t *testing.T) {
skipIfNoCreds(t)
a := &Adapter{
bots: make(map[string]*botEntry),
appIdx: make(map[string]string),
dedup: newDedupStore(),
stopCh: make(chan struct{}),
}
defer close(a.stopCh)
entry := &botEntry{
robotID: "robot_e2e_dt_handle",
clientID: dtClientID,
bot: dtapi.NewBot(dtClientID, dtClientSecret),
}
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
defer cancel()
cms := []*dtapi.ConvertedMessage{
{
MessageID: "test_msg_1",
ConversationID: "test_conv_1",
ConversationType: "1",
SenderID: "test_sender_1",
SenderNick: "Test User",
Text: "Hello from E2E test",
SessionWebhook: "https://oapi.dingtalk.com/robot/sendBySession/xxx",
},
}
a.handleMessages(ctx, entry, cms)
assert.False(t, a.dedup.markSeen("dt:robot_e2e_dt_handle:test_msg_1"),
"message should be marked as seen after handleMessages")
t.Log("OK handleMessages processed 1 message")
}
// TestE2E_Adapter_ApplyDisabled verifies Apply removes bot when disabled.
func TestE2E_Adapter_ApplyDisabled(t *testing.T) {
a := &Adapter{
bots: make(map[string]*botEntry),
appIdx: make(map[string]string),
dedup: newDedupStore(),
stopCh: make(chan struct{}),
}
defer close(a.stopCh)
robot := &robottypes.Robot{
MemberID: "robot_e2e_dt_disabled",
TeamID: "team_e2e_dt",
Config: &robottypes.Config{
Integrations: &robottypes.Integrations{
DingTalk: &robottypes.DingTalkConfig{
Enabled: false,
ClientID: "some_id",
ClientSecret: "some_secret",
},
},
},
}
a.Apply(context.Background(), robot)
a.mu.RLock()
_, ok := a.bots["robot_e2e_dt_disabled"]
a.mu.RUnlock()
assert.False(t, ok, "disabled bot should not be registered")
t.Log("OK disabled config not registered")
}
// TestE2E_Adapter_GetAccessToken verifies real DingTalk credentials work.
func TestE2E_Adapter_GetAccessToken(t *testing.T) {
skipIfNoCreds(t)
b := dtapi.NewBot(dtClientID, dtClientSecret)
ctx, cancel := context.WithTimeout(context.Background(), 15*time.Second)
defer cancel()
token, err := b.GetAccessToken(ctx)
require.NoError(t, err)
assert.NotEmpty(t, token)
t.Logf("OK DingTalk access token obtained, len=%d", len(token))
}

View file

@ -0,0 +1,125 @@
package dingtalk
import (
"context"
"fmt"
"strings"
agentcontext "github.com/yaoapp/yao/agent/context"
events "github.com/yaoapp/yao/agent/robot/events"
"github.com/yaoapp/yao/event"
dtapi "github.com/yaoapp/yao/integrations/dingtalk"
)
// handleMessages processes a batch of DingTalk messages.
func (a *Adapter) handleMessages(ctx context.Context, entry *botEntry, cms []*dtapi.ConvertedMessage) {
if len(cms) == 0 {
return
}
var allParts []interface{}
var lastCM *dtapi.ConvertedMessage
for _, cm := range cms {
if cm == nil {
continue
}
dedupKey := fmt.Sprintf("dt:%s:%s", entry.robotID, cm.MessageID)
if !a.dedup.markSeen(dedupKey) {
continue
}
parts := buildContentParts(cm)
if len(parts) == 0 {
continue
}
allParts = append(allParts, parts...)
lastCM = cm
}
if len(allParts) == 0 || lastCM == nil {
return
}
content := mergeContentParts(allParts)
msgPayload := events.MessagePayload{
RobotID: entry.robotID,
Messages: []agentcontext.Message{
{Role: agentcontext.RoleUser, Content: content},
},
Metadata: &events.MessageMetadata{
Channel: "dingtalk",
MessageID: lastCM.MessageID,
AppID: entry.clientID,
ChatID: lastCM.ConversationID,
SenderID: lastCM.SenderID,
SenderName: lastCM.SenderNick,
Extra: map[string]any{
"session_webhook": lastCM.SessionWebhook,
"conversation_type": lastCM.ConversationType,
"dt_message_id": lastCM.MessageID,
},
},
}
if _, err := event.Push(ctx, events.Message, msgPayload); err != nil {
log.Error("dingtalk adapter: event.Push robot.message failed robot=%s: %v", entry.robotID, err)
}
}
func buildContentParts(cm *dtapi.ConvertedMessage) []interface{} {
var parts []interface{}
if cm.HasText() {
parts = append(parts, map[string]interface{}{
"type": "text",
"text": cm.Text,
})
}
for _, mi := range cm.MediaItems {
if mi.Wrapper == "" && mi.URL == "" {
continue
}
url := mi.Wrapper
if url == "" {
url = mi.URL
}
parts = append(parts, map[string]interface{}{
"type": "file",
"file_url": url,
"mime_type": mi.MimeType,
"file_name": mi.FileName,
})
}
return parts
}
func mergeContentParts(parts []interface{}) interface{} {
allText := true
for _, p := range parts {
m, ok := p.(map[string]interface{})
if !ok || m["type"] != "text" {
allText = false
break
}
}
if allText {
var buf strings.Builder
for i, p := range parts {
if i > 0 {
buf.WriteString("\n")
}
m := p.(map[string]interface{})
buf.WriteString(m["text"].(string))
}
return buf.String()
}
return parts
}

View file

@ -0,0 +1,108 @@
package dingtalk
import (
"context"
"fmt"
"strings"
agentcontext "github.com/yaoapp/yao/agent/context"
events "github.com/yaoapp/yao/agent/robot/events"
dtapi "github.com/yaoapp/yao/integrations/dingtalk"
)
// Reply sends the assistant message back to the originating DingTalk conversation.
func (a *Adapter) Reply(ctx context.Context, msg *agentcontext.Message, metadata *events.MessageMetadata) error {
if msg == nil || metadata == nil {
return fmt.Errorf("nil message or metadata")
}
var sessionWebhook string
if metadata.Extra != nil {
if v, ok := metadata.Extra["session_webhook"]; ok {
if s, ok := v.(string); ok {
sessionWebhook = s
}
}
}
if sessionWebhook == "" {
return fmt.Errorf("no session_webhook in metadata for dingtalk reply")
}
return sendContent(ctx, sessionWebhook, msg.Content)
}
func sendContent(ctx context.Context, sessionWebhook string, content interface{}) error {
switch c := content.(type) {
case string:
if strings.TrimSpace(c) == "" {
return nil
}
return dtapi.SendMarkdownMessage(ctx, sessionWebhook, "Reply", c)
case []interface{}:
return sendParts(ctx, sessionWebhook, c)
default:
parts, ok := toContentParts(content)
if ok {
return sendPartsTyped(ctx, sessionWebhook, parts)
}
return dtapi.SendTextMessage(ctx, sessionWebhook, fmt.Sprintf("%v", content))
}
}
func sendParts(ctx context.Context, sessionWebhook string, parts []interface{}) error {
var textBuf strings.Builder
for _, part := range parts {
m, ok := part.(map[string]interface{})
if !ok {
continue
}
partType, _ := m["type"].(string)
switch partType {
case "text":
if text, ok := m["text"].(string); ok {
textBuf.WriteString(text)
}
case "image_url":
if err := flushText(ctx, sessionWebhook, &textBuf); err != nil {
return err
}
case "file":
if err := flushText(ctx, sessionWebhook, &textBuf); err != nil {
return err
}
}
}
return flushText(ctx, sessionWebhook, &textBuf)
}
func sendPartsTyped(ctx context.Context, sessionWebhook string, parts []agentcontext.ContentPart) error {
var textBuf strings.Builder
for _, part := range parts {
switch part.Type {
case agentcontext.ContentText:
textBuf.WriteString(part.Text)
case agentcontext.ContentImageURL, agentcontext.ContentFile:
if err := flushText(ctx, sessionWebhook, &textBuf); err != nil {
return err
}
}
}
return flushText(ctx, sessionWebhook, &textBuf)
}
func flushText(ctx context.Context, sessionWebhook string, buf *strings.Builder) error {
if buf.Len() == 0 {
return nil
}
text := buf.String()
buf.Reset()
return dtapi.SendMarkdownMessage(ctx, sessionWebhook, "Reply", text)
}
func toContentParts(content interface{}) ([]agentcontext.ContentPart, bool) {
parts, ok := content.([]agentcontext.ContentPart)
return parts, ok
}

View file

@ -0,0 +1,98 @@
package dingtalk
import (
"context"
"strings"
"time"
dingstream "github.com/open-dingtalk/dingtalk-stream-sdk-go/chatbot"
dingclient "github.com/open-dingtalk/dingtalk-stream-sdk-go/client"
dtapi "github.com/yaoapp/yao/integrations/dingtalk"
)
const reconnectDelay = 5 * time.Second
// streamLoop starts the DingTalk Stream client for a single bot.
// It automatically reconnects on failure.
func (a *Adapter) streamLoop(ctx context.Context, entry *botEntry) {
log.Info("dingtalk streamLoop started robot=%s client=%s", entry.robotID, entry.clientID)
for {
select {
case <-ctx.Done():
log.Info("dingtalk streamLoop stopped robot=%s", entry.robotID)
return
case <-a.stopCh:
return
default:
}
err := a.runStreamClient(ctx, entry)
if err != nil {
log.Error("dingtalk stream disconnected robot=%s: %v, reconnecting in %s", entry.robotID, err, reconnectDelay)
}
select {
case <-ctx.Done():
return
case <-a.stopCh:
return
case <-time.After(reconnectDelay):
}
}
}
func (a *Adapter) runStreamClient(ctx context.Context, entry *botEntry) error {
cli := dingclient.NewStreamClient(
dingclient.WithAppCredential(dingclient.NewAppCredentialConfig(entry.clientID, entry.bot.ClientSecret())),
)
cli.RegisterChatBotCallbackRouter(func(c context.Context, data *dingstream.BotCallbackDataModel) ([]byte, error) {
return a.onBotCallback(c, entry, data)
})
errCh := make(chan error, 1)
go func() {
errCh <- cli.Start(ctx)
}()
select {
case <-ctx.Done():
return ctx.Err()
case <-a.stopCh:
return nil
case err := <-errCh:
return err
}
}
func (a *Adapter) onBotCallback(ctx context.Context, entry *botEntry, data *dingstream.BotCallbackDataModel) ([]byte, error) {
if data == nil {
return nil, nil
}
cm := &dtapi.ConvertedMessage{
MessageID: data.MsgId,
ConversationID: data.ConversationId,
ConversationType: data.ConversationType,
SenderID: data.SenderId,
SenderNick: data.SenderNick,
SenderStaffID: data.SenderStaffId,
ChatbotUserID: data.ChatbotUserId,
IsInAtList: data.IsInAtList,
SessionWebhook: data.SessionWebhook,
}
switch data.Msgtype {
case "text":
cm.Text = strings.TrimSpace(data.Text.Content)
}
if cm.HasMedia() {
groups := []string{"dingtalk", entry.robotID}
dtapi.ResolveMedia(ctx, cm, groups)
}
a.handleMessages(ctx, entry, []*dtapi.ConvertedMessage{cm})
return nil, nil
}

View file

@ -178,9 +178,12 @@ func parseIntegrations(intg *robottypes.Integrations) []string {
if intg.Telegram != nil {
keys = append(keys, "telegram")
}
// if intg.Discord != nil { keys = append(keys, "discord") }
// if intg.DingTalk != nil { keys = append(keys, "dingtalk") }
// if intg.Lark != nil { keys = append(keys, "lark") }
if intg.Feishu != nil {
keys = append(keys, "feishu")
}
if intg.DingTalk != nil {
keys = append(keys, "dingtalk")
}
return keys
}

View file

@ -0,0 +1,44 @@
package feishu
import (
"sync"
"time"
)
const (
dedupTTL = 24 * time.Hour
dedupCleanInterval = time.Hour
)
type dedupStore struct {
m sync.Map
}
func newDedupStore() *dedupStore {
return &dedupStore{}
}
func (d *dedupStore) markSeen(key string) bool {
now := time.Now().Unix()
_, loaded := d.m.LoadOrStore(key, now)
return !loaded
}
func (d *dedupStore) cleaner(stopCh <-chan struct{}) {
ticker := time.NewTicker(dedupCleanInterval)
defer ticker.Stop()
for {
select {
case <-stopCh:
return
case <-ticker.C:
cutoff := time.Now().Add(-dedupTTL).Unix()
d.m.Range(func(key, value any) bool {
if ts, ok := value.(int64); ok && ts < cutoff {
d.m.Delete(key)
}
return true
})
}
}
}

View file

@ -0,0 +1,205 @@
package feishu
import (
"context"
"os"
"testing"
"time"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
robottypes "github.com/yaoapp/yao/agent/robot/types"
fsapi "github.com/yaoapp/yao/integrations/feishu"
)
var (
fsAppID string
fsAppSecret string
)
func TestMain(m *testing.M) {
fsAppID = os.Getenv("FEISHU_TEST_APP_ID")
fsAppSecret = os.Getenv("FEISHU_TEST_APP_SECRET")
os.Exit(m.Run())
}
func skipIfNoCreds(t *testing.T) {
t.Helper()
if fsAppID == "" || fsAppSecret == "" {
t.Skip("FEISHU_TEST_APP_ID or FEISHU_TEST_APP_SECRET not set")
}
}
// TestE2E_Adapter_Apply verifies that Apply correctly registers a bot.
func TestE2E_Adapter_Apply(t *testing.T) {
skipIfNoCreds(t)
a := &Adapter{
bots: make(map[string]*botEntry),
appIdx: make(map[string]string),
dedup: newDedupStore(),
stopCh: make(chan struct{}),
}
defer close(a.stopCh)
robot := &robottypes.Robot{
MemberID: "robot_e2e_feishu_adapter",
TeamID: "team_e2e_fs",
Config: &robottypes.Config{
Integrations: &robottypes.Integrations{
Feishu: &robottypes.FeishuConfig{
Enabled: true,
AppID: fsAppID,
AppSecret: fsAppSecret,
},
},
},
}
a.Apply(context.Background(), robot)
a.mu.RLock()
entry, ok := a.bots["robot_e2e_feishu_adapter"]
a.mu.RUnlock()
require.True(t, ok, "bot should be registered")
assert.Equal(t, fsAppID, entry.appID)
assert.NotNil(t, entry.bot)
t.Logf("OK Apply: feishu bot registered robot=%s app=%s", robot.MemberID, entry.appID)
}
// TestE2E_Adapter_Apply_Update verifies re-Apply with same appID is a no-op.
func TestE2E_Adapter_Apply_Update(t *testing.T) {
skipIfNoCreds(t)
a := &Adapter{
bots: make(map[string]*botEntry),
appIdx: make(map[string]string),
dedup: newDedupStore(),
stopCh: make(chan struct{}),
}
defer close(a.stopCh)
robot := &robottypes.Robot{
MemberID: "robot_e2e_feishu_update",
TeamID: "team_e2e_fs",
Config: &robottypes.Config{
Integrations: &robottypes.Integrations{
Feishu: &robottypes.FeishuConfig{
Enabled: true,
AppID: fsAppID,
AppSecret: fsAppSecret,
},
},
},
}
a.Apply(context.Background(), robot)
a.mu.RLock()
_, ok := a.bots["robot_e2e_feishu_update"]
a.mu.RUnlock()
require.True(t, ok)
// Apply again — should be no-op
a.Apply(context.Background(), robot)
a.mu.RLock()
assert.Len(t, a.bots, 1)
a.mu.RUnlock()
// Remove
a.Remove(context.Background(), "robot_e2e_feishu_update")
a.mu.RLock()
_, ok = a.bots["robot_e2e_feishu_update"]
a.mu.RUnlock()
assert.False(t, ok, "bot should be removed")
t.Log("OK Apply/Remove lifecycle verified")
}
// TestE2E_Adapter_Dedup verifies deduplication works.
func TestE2E_Adapter_Dedup(t *testing.T) {
a := &Adapter{
bots: make(map[string]*botEntry),
appIdx: make(map[string]string),
dedup: newDedupStore(),
stopCh: make(chan struct{}),
}
defer close(a.stopCh)
key := "fs:test-robot:msg-12345"
assert.True(t, a.dedup.markSeen(key), "first time should return true")
assert.False(t, a.dedup.markSeen(key), "second time should return false (dedup)")
t.Log("OK dedup working correctly")
}
// TestE2E_Adapter_HandleMessages verifies message handling through the adapter.
func TestE2E_Adapter_HandleMessages(t *testing.T) {
skipIfNoCreds(t)
a := &Adapter{
bots: make(map[string]*botEntry),
appIdx: make(map[string]string),
dedup: newDedupStore(),
stopCh: make(chan struct{}),
}
defer close(a.stopCh)
entry := &botEntry{
robotID: "robot_e2e_feishu_handle",
appID: fsAppID,
bot: fsapi.NewBot(fsAppID, fsAppSecret),
}
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
defer cancel()
cms := []*fsapi.ConvertedMessage{
{
MessageID: "test_msg_1",
ChatID: "test_chat_1",
ChatType: "p2p",
SenderID: "test_sender_1",
Text: "Hello from E2E test",
},
}
// This should not panic even without event bus running
a.handleMessages(ctx, entry, cms)
// Verify dedup: should be marked as seen
assert.False(t, a.dedup.markSeen("fs:robot_e2e_feishu_handle:test_msg_1"),
"message should be marked as seen after handleMessages")
t.Log("OK handleMessages processed 1 message")
}
// TestE2E_Adapter_ApplyDisabled verifies Apply removes bot when disabled.
func TestE2E_Adapter_ApplyDisabled(t *testing.T) {
a := &Adapter{
bots: make(map[string]*botEntry),
appIdx: make(map[string]string),
dedup: newDedupStore(),
stopCh: make(chan struct{}),
}
defer close(a.stopCh)
robot := &robottypes.Robot{
MemberID: "robot_e2e_feishu_disabled",
TeamID: "team_e2e_fs",
Config: &robottypes.Config{
Integrations: &robottypes.Integrations{
Feishu: &robottypes.FeishuConfig{
Enabled: false,
AppID: "some_app",
AppSecret: "some_secret",
},
},
},
}
a.Apply(context.Background(), robot)
a.mu.RLock()
_, ok := a.bots["robot_e2e_feishu_disabled"]
a.mu.RUnlock()
assert.False(t, ok, "disabled bot should not be registered")
t.Log("OK disabled config not registered")
}

View file

@ -0,0 +1,139 @@
package feishu
import (
"context"
"sync"
"github.com/yaoapp/yao/agent/robot/logger"
robottypes "github.com/yaoapp/yao/agent/robot/types"
fsapi "github.com/yaoapp/yao/integrations/feishu"
)
var log = logger.New("feishu")
// Adapter implements the integrations.Adapter interface for Feishu (Lark).
//
// Architecture:
// - One event subscription per registered bot via Feishu SDK's long-poll/callback mechanism
// - One dedup cleaner goroutine removes expired keys every hour
type Adapter struct {
mu sync.RWMutex
bots map[string]*botEntry // robotID -> *botEntry
appIdx map[string]string // appID -> robotID
dedup *dedupStore
stopCh chan struct{}
}
// botEntry holds the state for one robot's Feishu integration.
type botEntry struct {
robotID string
appID string
bot *fsapi.Bot
cancelFn context.CancelFunc // cancels the event subscription goroutine
}
// NewAdapter creates a new Feishu adapter.
func NewAdapter() *Adapter {
a := &Adapter{
bots: make(map[string]*botEntry),
appIdx: make(map[string]string),
dedup: newDedupStore(),
stopCh: make(chan struct{}),
}
go a.dedup.cleaner(a.stopCh)
return a
}
// Apply is called by the Dispatcher when a robot config is created or updated.
func (a *Adapter) Apply(ctx context.Context, robot *robottypes.Robot) {
fsConf := extractConfig(robot)
log.Debug("Apply robot=%s fsConf=%v", robot.MemberID, fsConf != nil)
if fsConf == nil || !fsConf.Enabled || fsConf.AppID == "" || fsConf.AppSecret == "" {
a.removeBot(robot.MemberID)
return
}
a.mu.Lock()
defer a.mu.Unlock()
if existing, ok := a.bots[robot.MemberID]; ok {
if existing.appID == fsConf.AppID {
return
}
a.removeBotLocked(robot.MemberID)
}
bot := fsapi.NewBot(fsConf.AppID, fsConf.AppSecret)
streamCtx, streamCancel := context.WithCancel(context.Background())
entry := &botEntry{
robotID: robot.MemberID,
appID: fsConf.AppID,
bot: bot,
cancelFn: streamCancel,
}
a.bots[robot.MemberID] = entry
a.appIdx[fsConf.AppID] = robot.MemberID
go a.eventLoop(streamCtx, entry)
log.Info("feishu adapter: registered robot=%s app=%s", robot.MemberID, fsConf.AppID)
}
// Remove is called by the Dispatcher when a robot is deleted.
func (a *Adapter) Remove(ctx context.Context, robotID string) {
a.removeBot(robotID)
}
// Shutdown stops all event subscriptions and dedup cleaner.
func (a *Adapter) Shutdown() {
close(a.stopCh)
a.mu.Lock()
for _, entry := range a.bots {
if entry.cancelFn != nil {
entry.cancelFn()
}
}
a.mu.Unlock()
log.Info("feishu adapter: shutdown complete")
}
func (a *Adapter) removeBot(robotID string) {
a.mu.Lock()
defer a.mu.Unlock()
a.removeBotLocked(robotID)
}
func (a *Adapter) removeBotLocked(robotID string) {
entry, ok := a.bots[robotID]
if !ok {
return
}
if entry.cancelFn != nil {
entry.cancelFn()
}
if entry.appID != "" {
delete(a.appIdx, entry.appID)
}
delete(a.bots, robotID)
log.Info("feishu adapter: unregistered robot=%s", robotID)
}
func (a *Adapter) resolveByAppID(appID string) (*botEntry, bool) {
a.mu.RLock()
defer a.mu.RUnlock()
robotID, ok := a.appIdx[appID]
if !ok {
return nil, false
}
entry, ok := a.bots[robotID]
return entry, ok
}
func extractConfig(robot *robottypes.Robot) *robottypes.FeishuConfig {
if robot.Config == nil || robot.Config.Integrations == nil {
return nil
}
return robot.Config.Integrations.Feishu
}

View file

@ -0,0 +1,120 @@
package feishu
import (
"context"
"fmt"
"strings"
agentcontext "github.com/yaoapp/yao/agent/context"
events "github.com/yaoapp/yao/agent/robot/events"
"github.com/yaoapp/yao/event"
fsapi "github.com/yaoapp/yao/integrations/feishu"
)
// handleMessages processes a batch of Feishu messages for one chat.
func (a *Adapter) handleMessages(ctx context.Context, entry *botEntry, cms []*fsapi.ConvertedMessage) {
if len(cms) == 0 {
return
}
var allParts []interface{}
var lastCM *fsapi.ConvertedMessage
for _, cm := range cms {
if cm == nil {
continue
}
dedupKey := fmt.Sprintf("fs:%s:%s", entry.robotID, cm.MessageID)
if !a.dedup.markSeen(dedupKey) {
continue
}
parts := buildContentParts(cm)
if len(parts) == 0 {
continue
}
allParts = append(allParts, parts...)
lastCM = cm
}
if len(allParts) == 0 || lastCM == nil {
return
}
content := mergeContentParts(allParts)
msgPayload := events.MessagePayload{
RobotID: entry.robotID,
Messages: []agentcontext.Message{
{Role: agentcontext.RoleUser, Content: content},
},
Metadata: &events.MessageMetadata{
Channel: "feishu",
MessageID: lastCM.MessageID,
AppID: entry.appID,
ChatID: lastCM.ChatID,
SenderID: lastCM.SenderID,
SenderName: lastCM.SenderName,
Locale: events.NormalizeLocale(lastCM.LanguageCode),
Extra: map[string]any{
"feishu_message_id": lastCM.MessageID,
},
},
}
if _, err := event.Push(ctx, events.Message, msgPayload); err != nil {
log.Error("feishu adapter: event.Push robot.message failed robot=%s: %v", entry.robotID, err)
}
}
func buildContentParts(cm *fsapi.ConvertedMessage) []interface{} {
var parts []interface{}
if cm.HasText() {
parts = append(parts, map[string]interface{}{
"type": "text",
"text": cm.Text,
})
}
for _, mi := range cm.MediaItems {
if mi.Wrapper == "" {
continue
}
parts = append(parts, map[string]interface{}{
"type": "file",
"file_url": mi.Wrapper,
"mime_type": mi.MimeType,
"file_name": mi.FileName,
})
}
return parts
}
func mergeContentParts(parts []interface{}) interface{} {
allText := true
for _, p := range parts {
m, ok := p.(map[string]interface{})
if !ok || m["type"] != "text" {
allText = false
break
}
}
if allText {
var buf strings.Builder
for i, p := range parts {
if i > 0 {
buf.WriteString("\n")
}
m := p.(map[string]interface{})
buf.WriteString(m["text"].(string))
}
return buf.String()
}
return parts
}

View file

@ -0,0 +1,153 @@
package feishu
import (
"context"
"fmt"
"strings"
agentcontext "github.com/yaoapp/yao/agent/context"
events "github.com/yaoapp/yao/agent/robot/events"
"github.com/yaoapp/yao/attachment"
)
// Reply sends the assistant message back to the originating Feishu chat.
func (a *Adapter) Reply(ctx context.Context, msg *agentcontext.Message, metadata *events.MessageMetadata) error {
if msg == nil || metadata == nil {
return fmt.Errorf("nil message or metadata")
}
entry := a.resolveByChat(metadata)
if entry == nil {
return fmt.Errorf("no bot registered for feishu metadata (appID=%s)", metadata.AppID)
}
var replyToMsgID string
if metadata.Extra != nil {
if v, ok := metadata.Extra["feishu_message_id"]; ok {
if s, ok := v.(string); ok {
replyToMsgID = s
}
}
}
return a.sendContent(ctx, entry, metadata.ChatID, replyToMsgID, msg.Content)
}
func (a *Adapter) sendContent(ctx context.Context, entry *botEntry, chatID, replyToMsgID string, content interface{}) error {
switch c := content.(type) {
case string:
if strings.TrimSpace(c) == "" {
return nil
}
if replyToMsgID != "" {
_, err := entry.bot.ReplyTextMessage(ctx, replyToMsgID, c)
return err
}
_, err := entry.bot.SendTextMessage(ctx, chatID, c)
return err
case []interface{}:
return a.sendParts(ctx, entry, chatID, replyToMsgID, c)
default:
parts, ok := toContentParts(content)
if ok {
return a.sendPartsTyped(ctx, entry, chatID, replyToMsgID, parts)
}
text := fmt.Sprintf("%v", content)
_, err := entry.bot.SendTextMessage(ctx, chatID, text)
return err
}
}
func (a *Adapter) sendParts(ctx context.Context, entry *botEntry, chatID, replyToMsgID string, parts []interface{}) error {
var textBuf strings.Builder
for _, part := range parts {
m, ok := part.(map[string]interface{})
if !ok {
continue
}
partType, _ := m["type"].(string)
switch partType {
case "text":
if text, ok := m["text"].(string); ok {
textBuf.WriteString(text)
}
case "image_url":
if err := a.flushText(ctx, entry, chatID, replyToMsgID, &textBuf); err != nil {
return err
}
case "file":
if err := a.flushText(ctx, entry, chatID, replyToMsgID, &textBuf); err != nil {
return err
}
if fileURL, ok := m["file_url"].(string); ok && fileURL != "" {
if err := a.sendFileContent(ctx, entry, chatID, fileURL); err != nil {
log.Error("feishu reply: send file: %v", err)
}
}
}
}
return a.flushText(ctx, entry, chatID, replyToMsgID, &textBuf)
}
func (a *Adapter) sendPartsTyped(ctx context.Context, entry *botEntry, chatID, replyToMsgID string, parts []agentcontext.ContentPart) error {
var textBuf strings.Builder
for _, part := range parts {
switch part.Type {
case agentcontext.ContentText:
textBuf.WriteString(part.Text)
case agentcontext.ContentImageURL, agentcontext.ContentFile:
if err := a.flushText(ctx, entry, chatID, replyToMsgID, &textBuf); err != nil {
return err
}
}
}
return a.flushText(ctx, entry, chatID, replyToMsgID, &textBuf)
}
func (a *Adapter) flushText(ctx context.Context, entry *botEntry, chatID, replyToMsgID string, buf *strings.Builder) error {
if buf.Len() == 0 {
return nil
}
text := buf.String()
buf.Reset()
if replyToMsgID != "" {
_, err := entry.bot.ReplyTextMessage(ctx, replyToMsgID, text)
return err
}
_, err := entry.bot.SendTextMessage(ctx, chatID, text)
return err
}
func (a *Adapter) sendFileContent(ctx context.Context, entry *botEntry, chatID, fileURL string) error {
if strings.Contains(fileURL, "://") && !strings.HasPrefix(fileURL, "http") {
_, fileID, ok := attachment.Parse(fileURL)
if !ok {
return fmt.Errorf("parse wrapper: invalid format %s", fileURL)
}
_, _ = fileID, chatID
log.Warn("feishu: file wrapper send not yet implemented, wrapper=%s", fileURL)
}
return nil
}
func toContentParts(content interface{}) ([]agentcontext.ContentPart, bool) {
parts, ok := content.([]agentcontext.ContentPart)
return parts, ok
}
func (a *Adapter) resolveByChat(metadata *events.MessageMetadata) *botEntry {
if metadata.AppID != "" {
if entry, ok := a.resolveByAppID(metadata.AppID); ok {
return entry
}
}
a.mu.RLock()
defer a.mu.RUnlock()
for _, entry := range a.bots {
return entry
}
return nil
}

View file

@ -0,0 +1,115 @@
package feishu
import (
"context"
"time"
larkcore "github.com/larksuite/oapi-sdk-go/v3/core"
"github.com/larksuite/oapi-sdk-go/v3/event/dispatcher"
larkim "github.com/larksuite/oapi-sdk-go/v3/service/im/v1"
larkws "github.com/larksuite/oapi-sdk-go/v3/ws"
fsapi "github.com/yaoapp/yao/integrations/feishu"
)
const reconnectDelay = 5 * time.Second
// eventLoop starts the Feishu WebSocket event subscription for a single bot.
// It automatically reconnects on failure.
func (a *Adapter) eventLoop(ctx context.Context, entry *botEntry) {
log.Info("feishu eventLoop started robot=%s app=%s", entry.robotID, entry.appID)
for {
select {
case <-ctx.Done():
log.Info("feishu eventLoop stopped robot=%s", entry.robotID)
return
case <-a.stopCh:
return
default:
}
err := a.runWSClient(ctx, entry)
if err != nil {
log.Error("feishu ws disconnected robot=%s: %v, reconnecting in %s", entry.robotID, err, reconnectDelay)
}
select {
case <-ctx.Done():
return
case <-a.stopCh:
return
case <-time.After(reconnectDelay):
}
}
}
func (a *Adapter) runWSClient(ctx context.Context, entry *botEntry) error {
eventHandler := dispatcher.NewEventDispatcher("", "")
eventHandler.OnP2MessageReceiveV1(func(ctx context.Context, event *larkim.P2MessageReceiveV1) error {
return a.onMessageReceive(ctx, entry, event)
})
cli := larkws.NewClient(entry.bot.AppID(), entry.bot.AppSecret(),
larkws.WithEventHandler(eventHandler),
larkws.WithLogLevel(larkcore.LogLevelWarn),
)
errCh := make(chan error, 1)
go func() {
errCh <- cli.Start(ctx)
}()
select {
case <-ctx.Done():
return ctx.Err()
case <-a.stopCh:
return nil
case err := <-errCh:
return err
}
}
func (a *Adapter) onMessageReceive(ctx context.Context, entry *botEntry, event *larkim.P2MessageReceiveV1) error {
if event == nil || event.Event == nil || event.Event.Message == nil {
return nil
}
msg := event.Event.Message
sender := event.Event.Sender
msgType := derefStr(msg.MessageType)
content := derefStr(msg.Content)
messageID := derefStr(msg.MessageId)
chatID := derefStr(msg.ChatId)
chatType := derefStr(msg.ChatType)
text, media := fsapi.ParseMessageContent(msgType, content)
cm := &fsapi.ConvertedMessage{
MessageID: messageID,
ChatID: chatID,
ChatType: chatType,
Text: text,
MediaItems: media,
EventID: event.EventV2Base.Header.EventID,
}
if sender != nil && sender.SenderId != nil {
cm.SenderID = derefStr(sender.SenderId.OpenId)
}
if cm.HasMedia() {
groups := []string{"feishu", entry.robotID}
entry.bot.ResolveMedia(ctx, cm, groups)
}
a.handleMessages(ctx, entry, []*fsapi.ConvertedMessage{cm})
return nil
}
func derefStr(s *string) string {
if s == nil {
return ""
}
return *s
}

View file

@ -25,6 +25,8 @@ type Config struct {
// Integrations holds configuration for external platform integrations.
type Integrations struct {
Telegram *TelegramConfig `json:"telegram,omitempty"`
Feishu *FeishuConfig `json:"feishu,omitempty"`
DingTalk *DingTalkConfig `json:"dingtalk,omitempty"`
}
// TelegramConfig holds Telegram Bot integration settings.
@ -37,6 +39,20 @@ type TelegramConfig struct {
WebhookSecret string `json:"webhook_secret,omitempty"` // sent with SetWebhook, verified on incoming webhooks
}
// FeishuConfig holds Feishu (Lark) Bot integration settings.
type FeishuConfig struct {
Enabled bool `json:"enabled"`
AppID string `json:"app_id"`
AppSecret string `json:"app_secret"`
}
// DingTalkConfig holds DingTalk Bot integration settings.
type DingTalkConfig struct {
Enabled bool `json:"enabled"`
ClientID string `json:"client_id"`
ClientSecret string `json:"client_secret"`
}
// ExecutorConfig - executor settings
type ExecutorConfig struct {
Mode ExecutorMode `json:"mode,omitempty"` // standard | dryrun | sandbox

View file

@ -140,17 +140,19 @@ func (store *Xun) GetMessages(chatID string, filter types.MessageFilter) ([]*typ
qb.Where("type", filter.Type)
}
// When a Limit is specified we want the N most-recent messages (not the
// N oldest). Strategy: query DESC to get the latest rows, then reverse
// When Limit is specified WITHOUT Offset, we want the N most-recent
// messages. Strategy: query DESC to get the latest rows, then reverse
// the slice so the caller receives them in chronological (ASC) order.
// When Offset is also present, the caller is doing forward pagination,
// so we keep ASC order and apply Limit+Offset normally.
needReverse := false
if filter.Limit > 0 {
if filter.Limit > 0 && filter.Offset <= 0 {
qb.Limit(filter.Limit)
if filter.Offset > 0 {
qb.Offset(filter.Offset)
}
qb.OrderBy("id", "desc")
needReverse = true
} else if filter.Limit > 0 && filter.Offset > 0 {
qb.Limit(filter.Limit).Offset(filter.Offset)
qb.OrderBy("id", "asc")
} else {
if filter.Offset > 0 {
qb.Limit(1000000).Offset(filter.Offset)

7
go.mod
View file

@ -58,6 +58,7 @@ require (
github.com/JohannesKaufmann/html-to-markdown/v2 v2.5.0 // indirect
github.com/Microsoft/go-winio v0.6.2 // indirect
github.com/TylerBrock/colorjson v0.0.0-20200706003622-8a50f05110d2 // indirect
github.com/aliyun/credentials-go v1.4.6 // indirect
github.com/andybalholm/cascadia v1.3.3 // indirect
github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.6.10 // indirect
github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.34 // indirect
@ -79,6 +80,7 @@ require (
github.com/charmbracelet/x/ansi v0.10.1 // indirect
github.com/charmbracelet/x/cellbuf v0.0.13-0.20250311204145-2c3ea96c31dd // indirect
github.com/charmbracelet/x/term v0.2.1 // indirect
github.com/clbanning/mxj/v2 v2.5.5 // indirect
github.com/cloudwego/base64x v0.1.5 // indirect
github.com/coder/websocket v1.8.14 // indirect
github.com/containerd/errdefs v1.0.0 // indirect
@ -111,6 +113,7 @@ require (
github.com/go-telegram/bot v1.19.0 // indirect
github.com/goccy/go-json v0.10.5 // indirect
github.com/goccy/go-yaml v1.18.0 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/protobuf v1.5.4 // indirect
github.com/golang/snappy v1.0.0 // indirect
github.com/google/go-github/v30 v30.1.0 // indirect
@ -133,6 +136,7 @@ require (
github.com/kaptinlin/messageformat-go v0.4.6 // indirect
github.com/klauspost/compress v1.18.4 // indirect
github.com/klauspost/cpuid/v2 v2.2.10 // indirect
github.com/larksuite/oapi-sdk-go/v3 v3.5.3 // indirect
github.com/leodido/go-urn v1.4.0 // indirect
github.com/lib/pq v1.10.9 // indirect
github.com/lucasb-eyer/go-colorful v1.3.0 // indirect
@ -153,6 +157,7 @@ require (
github.com/neo4j/neo4j-go-driver/v5 v5.28.1 // indirect
github.com/ogen-go/ogen v1.19.0 // indirect
github.com/oklog/run v1.1.0 // indirect
github.com/open-dingtalk/dingtalk-stream-sdk-go v0.9.1 // indirect
github.com/opencontainers/go-digest v1.0.0 // indirect
github.com/opencontainers/image-spec v1.1.0 // indirect
github.com/pdfcpu/pdfcpu v0.11.0 // indirect
@ -180,6 +185,7 @@ require (
github.com/tidwall/rtred v0.1.2 // indirect
github.com/tidwall/tinyqueue v0.1.1 // indirect
github.com/tiendc/go-deepcopy v1.6.0 // indirect
github.com/tjfoc/gmsm v1.4.1 // indirect
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
github.com/ugorji/go/codec v1.2.12 // indirect
github.com/ulikunitz/xz v0.5.14 // indirect
@ -213,6 +219,7 @@ require (
google.golang.org/genproto/googleapis/rpc v0.0.0-20250825161204-c5933d9347a5 // indirect
google.golang.org/grpc v1.75.1 // indirect
google.golang.org/protobuf v1.36.11 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gotest.tools/v3 v3.5.2 // indirect
rsc.io/qr v0.2.0 // indirect

165
go.sum
View file

@ -1,8 +1,10 @@
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
filippo.io/edwards25519 v1.1.0/go.mod h1:BxyFTGdWcka3PhytdK4V28tE5sGfRvvvRV7EaN4VDT4=
filippo.io/edwards25519 v1.1.1 h1:YpjwWWlNmGIDyXOn8zLzqiD+9TyIlPhGFG96P39uBpw=
filippo.io/edwards25519 v1.1.1/go.mod h1:BxyFTGdWcka3PhytdK4V28tE5sGfRvvvRV7EaN4VDT4=
github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 h1:UQHMgLO+TxOElx5B5HZ4hJQsoJ/PvUvKRhJHDQXO8P8=
github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1/go.mod h1:xomTg63KZ2rFqZQzSB4Vz2SUXa1BpHTVz9L5PTmPC4E=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/JohannesKaufmann/dom v0.2.0 h1:1bragmEb19K8lHAqgFgqCpiPCFEZMTXzOIEjuxkUfLQ=
github.com/JohannesKaufmann/dom v0.2.0/go.mod h1:57iSUl5RKric4bUkgos4zu6Xt5LMHUnw3TF1l5CbGZo=
github.com/JohannesKaufmann/html-to-markdown/v2 v2.5.0 h1:mklaPbT4f/EiDr1Q+zPrEt9lgKAkVrIBtWf33d9GpVA=
@ -13,6 +15,50 @@ github.com/PuerkitoBio/goquery v1.10.3 h1:pFYcNSqHxBD06Fpj/KsbStFRsgRATgnf3LeXiU
github.com/PuerkitoBio/goquery v1.10.3/go.mod h1:tMUX0zDMHXYlAQk6p35XxQMqMweEKB7iK7iLNd4RH4Y=
github.com/TylerBrock/colorjson v0.0.0-20200706003622-8a50f05110d2 h1:ZBbLwSJqkHBuFDA6DUhhse0IGJ7T5bemHyNILUjvOq4=
github.com/TylerBrock/colorjson v0.0.0-20200706003622-8a50f05110d2/go.mod h1:VSw57q4QFiWDbRnjdX8Cb3Ow0SFncRw+bA/ofY6Q83w=
github.com/alibabacloud-go/alibabacloud-gateway-pop v0.0.6/go.mod h1:4EUIoxs/do24zMOGGqYVWgw0s9NtiylnJglOeEB5UJo=
github.com/alibabacloud-go/alibabacloud-gateway-spi v0.0.4/go.mod h1:sCavSAvdzOjul4cEqeVtvlSaSScfNsTQ+46HwlTL1hc=
github.com/alibabacloud-go/alibabacloud-gateway-spi v0.0.5 h1:zE8vH9C7JiZLNJJQ5OwjU9mSi4T9ef9u3BURT6LCLC8=
github.com/alibabacloud-go/alibabacloud-gateway-spi v0.0.5/go.mod h1:tWnyE9AjF8J8qqLk645oUmVUnFybApTQWklQmi5tY6g=
github.com/alibabacloud-go/darabonba-array v0.1.0/go.mod h1:BLKxr0brnggqOJPqT09DFJ8g3fsDshapUD3C3aOEFaI=
github.com/alibabacloud-go/darabonba-encode-util v0.0.2/go.mod h1:JiW9higWHYXm7F4PKuMgEUETNZasrDM6vqVr/Can7H8=
github.com/alibabacloud-go/darabonba-map v0.0.2/go.mod h1:28AJaX8FOE/ym8OUFWga+MtEzBunJwQGceGQlvaPGPc=
github.com/alibabacloud-go/darabonba-openapi/v2 v2.0.12 h1:Dqhik/9iK3/ltjMuVy2kkuuWK3KPRes2vSzxnrehT74=
github.com/alibabacloud-go/darabonba-openapi/v2 v2.0.12/go.mod h1:cgtLEj8i4ddXMcQgq4PnpVQvlzS+y5B+QtdSfmcLM3A=
github.com/alibabacloud-go/darabonba-signature-util v0.0.7/go.mod h1:oUzCYV2fcCH797xKdL6BDH8ADIHlzrtKVjeRtunBNTQ=
github.com/alibabacloud-go/darabonba-string v1.0.2/go.mod h1:93cTfV3vuPhhEwGGpKKqhVW4jLe7tDpo3LUM0i0g6mA=
github.com/alibabacloud-go/debug v0.0.0-20190504072949-9472017b5c68/go.mod h1:6pb/Qy8c+lqua8cFpEy7g39NRRqOWc3rOwAy8m5Y2BY=
github.com/alibabacloud-go/debug v1.0.0/go.mod h1:8gfgZCCAC3+SCzjWtY053FrOcd4/qlH6IHTI4QyICOc=
github.com/alibabacloud-go/debug v1.0.1 h1:MsW9SmUtbb1Fnt3ieC6NNZi6aEwrXfDksD4QA6GSbPg=
github.com/alibabacloud-go/debug v1.0.1/go.mod h1:8gfgZCCAC3+SCzjWtY053FrOcd4/qlH6IHTI4QyICOc=
github.com/alibabacloud-go/dingtalk v1.6.98 h1:7EBiJvGgzm2uT44B5VDMBGC5zdx8co7CNuLr0fafCP8=
github.com/alibabacloud-go/dingtalk v1.6.98/go.mod h1:mUcgNRgMGQzABtiZtTK8a3b6LwQBQ8t9WsDKzklqVpg=
github.com/alibabacloud-go/endpoint-util v1.1.0/go.mod h1:O5FuCALmCKs2Ff7JFJMudHs0I5EBgecXXxZRyswlEjE=
github.com/alibabacloud-go/gateway-dingtalk v1.0.2 h1:+etjmc64QTmYvHlc6eFkH9y2DOc3UPcyD2nF3IXsVqw=
github.com/alibabacloud-go/gateway-dingtalk v1.0.2/go.mod h1:JUvHpkJtlPFpgJcfXqc9Y4mk2JnoRn5XpKbRz38jJho=
github.com/alibabacloud-go/openapi-util v0.1.0/go.mod h1:sQuElr4ywwFRlCCberQwKRFhRzIyG4QTP/P4y1CJ6Ws=
github.com/alibabacloud-go/openapi-util v0.1.1 h1:ujGErJjG8ncRW6XtBBMphzHTvCxn4DjrVw4m04HsS28=
github.com/alibabacloud-go/openapi-util v0.1.1/go.mod h1:/UehBSE2cf1gYT43GV4E+RxTdLRzURImCYY0aRmlXpw=
github.com/alibabacloud-go/tea v1.1.0/go.mod h1:IkGyUSX4Ba1V+k4pCtJUc6jDpZLFph9QMy2VUPTwukg=
github.com/alibabacloud-go/tea v1.1.7/go.mod h1:/tmnEaQMyb4Ky1/5D+SE1BAsa5zj/KeGOFfwYm3N/p4=
github.com/alibabacloud-go/tea v1.1.8/go.mod h1:/tmnEaQMyb4Ky1/5D+SE1BAsa5zj/KeGOFfwYm3N/p4=
github.com/alibabacloud-go/tea v1.1.11/go.mod h1:/tmnEaQMyb4Ky1/5D+SE1BAsa5zj/KeGOFfwYm3N/p4=
github.com/alibabacloud-go/tea v1.1.17/go.mod h1:nXxjm6CIFkBhwW4FQkNrolwbfon8Svy6cujmKFUq98A=
github.com/alibabacloud-go/tea v1.1.20/go.mod h1:nXxjm6CIFkBhwW4FQkNrolwbfon8Svy6cujmKFUq98A=
github.com/alibabacloud-go/tea v1.2.2 h1:aTsR6Rl3ANWPfqeQugPglfurloyBJY85eFy7Gc1+8oU=
github.com/alibabacloud-go/tea v1.2.2/go.mod h1:CF3vOzEMAG+bR4WOql8gc2G9H3EkH3ZLAQdpmpXMgwk=
github.com/alibabacloud-go/tea-utils v1.3.1 h1:iWQeRzRheqCMuiF3+XkfybB3kTgUXkXX+JMrqfLeB2I=
github.com/alibabacloud-go/tea-utils v1.3.1/go.mod h1:EI/o33aBfj3hETm4RLiAxF/ThQdSngxrpF8rKUDJjPE=
github.com/alibabacloud-go/tea-utils/v2 v2.0.1/go.mod h1:U5MTY10WwlquGPS34DOeomUGBB0gXbLueiq5Trwu0C4=
github.com/alibabacloud-go/tea-utils/v2 v2.0.5/go.mod h1:dL6vbUT35E4F4bFTHL845eUloqaerYBYPsdWR2/jhe4=
github.com/alibabacloud-go/tea-utils/v2 v2.0.6 h1:ZkmUlhlQbaDC+Eba/GARMPy6hKdCLiSke5RsN5LcyQ0=
github.com/alibabacloud-go/tea-utils/v2 v2.0.6/go.mod h1:qxn986l+q33J5VkialKMqT/TTs3E+U9MJpd001iWQ9I=
github.com/alibabacloud-go/tea-xml v1.1.3 h1:7LYnm+JbOq2B+T/B0fHC4Ies4/FofC4zHzYtqw7dgt0=
github.com/alibabacloud-go/tea-xml v1.1.3/go.mod h1:Rq08vgCcCAjHyRi/M7xlHKUykZCEtyBy9+DPF6GgEu8=
github.com/aliyun/credentials-go v1.1.2/go.mod h1:ozcZaMR5kLM7pwtCMEpVmQ242suV6qTJya2bDq4X1Tw=
github.com/aliyun/credentials-go v1.3.1/go.mod h1:8jKYhQuDawt8x2+fusqa1Y6mPxemTsBEN04dgcAcYz0=
github.com/aliyun/credentials-go v1.3.6/go.mod h1:1LxUuX7L5YrZUWzBrRyk0SwSdH4OmPrib8NVePL3fxM=
github.com/aliyun/credentials-go v1.4.6 h1:CG8rc/nxCNKfXbZWpWDzI9GjF4Tuu3Es14qT8Y0ClOk=
github.com/aliyun/credentials-go v1.4.6/go.mod h1:Jm6d+xIgwJVLVWT561vy67ZRP4lPTQxMbEYRuT2Ti1U=
github.com/andybalholm/cascadia v1.3.3 h1:AG2YHrzJIm4BZ19iwJ/DAua6Btl3IwJX+VI4kktS1LM=
github.com/andybalholm/cascadia v1.3.3/go.mod h1:xNd9bqTn98Ln4DwST8/nG+H0yuB8Hmgu1YHNnWw0GeA=
github.com/aws/aws-sdk-go-v2 v1.36.3 h1:mJoei2CxPutQVxaATCzDUjcZEjVRdpsiiXi2o38yqWM=
@ -62,6 +108,7 @@ github.com/caarlos0/env/v6 v6.10.1 h1:t1mPSxNpei6M5yAeu1qtRdPAK29Nbcf/n3G7x+b3/I
github.com/caarlos0/env/v6 v6.10.1/go.mod h1:hvp/ryKXKipEkcuYjs9mI4bBCg+UI0Yhgm5Zu0ddvwc=
github.com/cenkalti/backoff/v4 v4.3.0 h1:MyRJ/UdXutAwSAT+s3wNd7MfTIcy71VQueUuFK343L8=
github.com/cenkalti/backoff/v4 v4.3.0/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyYozVcomhLiZE=
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs=
github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
github.com/charmbracelet/bubbletea v1.3.10 h1:otUDHWMMzQSB0Pkc87rm691KZ3SWa4KUlvF9nRvCICw=
@ -76,9 +123,13 @@ github.com/charmbracelet/x/cellbuf v0.0.13-0.20250311204145-2c3ea96c31dd h1:vy0G
github.com/charmbracelet/x/cellbuf v0.0.13-0.20250311204145-2c3ea96c31dd/go.mod h1:xe0nKWGd3eJgtqZRaN9RjMtK7xUYchjzPr7q6kcvCCs=
github.com/charmbracelet/x/term v0.2.1 h1:AQeHeLZ1OqSXhrAWpYUtZyX1T3zVxfpZuEQMIQaGIAQ=
github.com/charmbracelet/x/term v0.2.1/go.mod h1:oQ4enTYFV7QN4m0i9mzHrViD7TQKvNEEkHUMCmsxdUg=
github.com/clbanning/mxj/v2 v2.5.5 h1:oT81vUeEiQQ/DcHbzSytRngP6Ky9O+L+0Bw0zSJag9E=
github.com/clbanning/mxj/v2 v2.5.5/go.mod h1:hNiWqW14h+kc+MdF9C6/YoRfjEJoR3ou6tn/Qo+ve2s=
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
github.com/cloudwego/base64x v0.1.5 h1:XPciSp1xaq2VCSt6lF0phncD4koWyULpl5bUxbfCyP4=
github.com/cloudwego/base64x v0.1.5/go.mod h1:0zlkT4Wn5C6NdauXdJRhSKRlJvmclQ1hhJgA0rcu/8w=
github.com/cloudwego/iasm v0.2.0/go.mod h1:8rXZaNYT2n95jn+zTI1sDr+IgcD2GVs0nlbbQPiEFhY=
github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc=
github.com/coder/websocket v1.8.14 h1:9L0p0iKiNOibykf283eHkKUHHrpG7f65OE3BhhO7v9g=
github.com/coder/websocket v1.8.14/go.mod h1:NX3SzP+inril6yawo5CQXx8+fk145lPDC6pumgx0mVg=
github.com/containerd/errdefs v1.0.0 h1:tg5yIfIlQIrxYtu9ajqY42W3lpS19XqdxRQeEwYG8PI=
@ -114,6 +165,9 @@ github.com/emersion/go-sasl v0.0.0-20200509203442-7bfe0ed36a21/go.mod h1:iL2twTe
github.com/emersion/go-sasl v0.0.0-20241020182733-b788ff22d5a6 h1:oP4q0fw+fOSWn3DfFi4EXdT+B+gTtzx8GC9xsc26Znk=
github.com/emersion/go-sasl v0.0.0-20241020182733-b788ff22d5a6/go.mod h1:iL2twTeMvZnrg54ZoPDNfJaJaqy0xIQFuBdrLsmspwQ=
github.com/emersion/go-textwrapper v0.0.0-20200911093747-65d896831594/go.mod h1:aqO8z8wPrjkscevZJFVE1wXJrLpC5LtJG7fqLOsPb2U=
github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98=
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f h1:Y/CXytFA4m6baUTXGLOoWe4PQhGxaX0KpnayAqC48p4=
github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f/go.mod h1:vw97MGsxSvLiUE2X8qFplwetxpGLQrlU1Q9AUEIzCaM=
github.com/evanw/esbuild v0.25.4 h1:k1bTSim+usBG27w7BfOCorhgx3tO+6bAfMj5pR+6SKg=
@ -177,14 +231,29 @@ github.com/goccy/go-json v0.10.5 h1:Fq85nIqj+gXn/S5ahsiTlK3TmC85qgirsdTP/+DeaC4=
github.com/goccy/go-json v0.10.5/go.mod h1:oq7eo15ShAhp70Anwd5lgX2pLfOS3QCiwU/PULtXL6M=
github.com/goccy/go-yaml v1.18.0 h1:8W7wMFS12Pcas7KU+VVkaiCng+kG8QiFeFwzFb+rwuw=
github.com/goccy/go-yaml v1.18.0/go.mod h1:XBurs7gK8ATbW4ZPGKgcbrY1Br56PdM69F7LkFRi1kA=
github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q=
github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q=
github.com/golang-jwt/jwt/v4 v4.5.2 h1:YtQM7lnr8iZ+j5q71MGKkNw9Mn7AjHM68uc9g5fXeUI=
github.com/golang-jwt/jwt/v4 v4.5.2/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0=
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw=
github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8=
github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA=
github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs=
github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w=
github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0=
github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=
github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek=
github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps=
github.com/golang/snappy v1.0.0 h1:Oy607GVXHs7RtbggtPBnr2RmDArIsAefDwvrdWvRhGs=
github.com/golang/snappy v1.0.0/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
@ -197,6 +266,9 @@ github.com/google/go-querystring v1.1.0/go.mod h1:Kcdr2DB4koayq7X8pmAG4sNG59So17
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY=
github.com/gopherjs/gopherjs v0.0.0-20200217142428-fce0ec30dd00/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY=
github.com/gorilla/websocket v1.5.0/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
github.com/gorilla/websocket v1.5.3 h1:saDtZ6Pbx/0u+bgYQ3q96pZgCzfhKXGPqt7kZ72aNNg=
github.com/gorilla/websocket v1.5.3/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
github.com/gotd/ige v0.2.2 h1:XQ9dJZwBfDnOGSTxKXBGP4gMud3Qku2ekScRjDWWfEk=
@ -239,8 +311,10 @@ github.com/jmoiron/sqlx v1.4.0 h1:1PLqN7S1UYp5t4SrVVnt4nUVNemrDAtxlulVe+Qgm3o=
github.com/jmoiron/sqlx v1.4.0/go.mod h1:ZrZ7UsYB/weZdl2Bxg6jCRO9c3YHl8r3ahlKmRT4JLY=
github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0=
github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4=
github.com/json-iterator/go v1.1.10/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU=
github.com/kaptinlin/go-i18n v0.2.0 h1:8iwjAERQbCVF78c3HxC4MxUDxDRFvQVQlMDvlsO43hU=
github.com/kaptinlin/go-i18n v0.2.0/go.mod h1:gRHEMrTHtQLsAFwulPbJG71TwHjXxkagn88O8FI8FuA=
github.com/kaptinlin/jsonpointer v0.4.6 h1:hAett1YROLwxAOKZS08hsJueXr1w0fTMSvWq2x1IoUA=
@ -251,6 +325,8 @@ github.com/kaptinlin/jsonschema v0.6.1 h1:RNUQ11ZCHTtM80YcVwRm033H5OJS+MpO06d9x7
github.com/kaptinlin/jsonschema v0.6.1/go.mod h1:T8SNWNTRLDS1w+ogMZpGYqIfUXn/8DK9r06mf8XbNLE=
github.com/kaptinlin/messageformat-go v0.4.6 h1:57DUC9en40mGZR7MvqOS+5EYogAl465fjo+loAA1KPg=
github.com/kaptinlin/messageformat-go v0.4.6/go.mod h1:r0PH7FsxJX8jS/n6LAYZon5w3X+yfCLUrquqYd2H7ks=
github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8=
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
github.com/klauspost/compress v1.18.4 h1:RPhnKRAQ4Fh8zU2FY/6ZFDwTVTxgJ/EMydqSTzE9a2c=
github.com/klauspost/compress v1.18.4/go.mod h1:R0h/fSBs8DE4ENlcrlib3PsXS61voFxhIs2DeRhCvJ4=
github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg=
@ -264,6 +340,8 @@ github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/larksuite/oapi-sdk-go/v3 v3.5.3 h1:xvf8Dv29kBXC5/DNDCLhHkAFW8l/0LlQJimO5Zn+JUk=
github.com/larksuite/oapi-sdk-go/v3 v3.5.3/go.mod h1:ZEplY+kwuIrj/nqw5uSCINNATcH3KdxSN7y+UxYY5fI=
github.com/leodido/go-urn v1.4.0 h1:WT9HwE9SGECu3lg4d/dIA+jxlljEa1/ffXKmRjqdmIQ=
github.com/leodido/go-urn v1.4.0/go.mod h1:bvxc+MVxLKB4z00jd1z+Dvzr47oO32F/QSNjSBOlFxI=
github.com/lib/pq v1.10.9 h1:YXG7RB+JIjhP29X+OtkiDnYaXQwpS4JEWq7dtCCRUEw=
@ -302,6 +380,8 @@ github.com/moby/term v0.5.0/go.mod h1:8FzsFHVUBGZdbDsJw/ot+X+d5HLUbvklYLJ9uGfcI3
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg=
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M=
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
github.com/montanaflynn/stats v0.7.1 h1:etflOAAHORrCC44V+aR6Ftzort912ZU+YLiSTuV8eaE=
@ -318,6 +398,7 @@ github.com/muesli/termenv v0.16.0 h1:S5AlUN9dENB57rsbnkPyfdGuWIlkmzJjbFf0Tf5FWUc
github.com/muesli/termenv v0.16.0/go.mod h1:ZRfOIKPFDYQoDFF4Olj7/QJbW60Ol/kL1pU3VfY/Cnk=
github.com/neo4j/neo4j-go-driver/v5 v5.28.1 h1:RKWQW7wTgYAY2fU9S+9LaJ9OwRPbRc0I17tlT7nDmAY=
github.com/neo4j/neo4j-go-driver/v5 v5.28.1/go.mod h1:Vff8OwT7QpLm7L2yYr85XNWe9Rbqlbeb9asNXJTHO4k=
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno=
github.com/nxadm/tail v1.4.8 h1:nPr65rt6Y5JFSKQO7qToXr7pePgD6Gwiw05lkbyAQTE=
github.com/nxadm/tail v1.4.8/go.mod h1:+ncqLTQzXmGhMZNUePPaPqPvBxHAIsmXswZKocGu+AU=
github.com/ogen-go/ogen v1.19.0 h1:YvdNpeQJ8A8dLLpS6Vs4WxXL53BT6tBPxH0VSjfALhA=
@ -330,6 +411,8 @@ github.com/onsi/ginkgo v1.16.5/go.mod h1:+E8gABHa3K6zRBolWtd+ROzc/U5bkGt0FwiG042
github.com/onsi/gomega v1.4.2/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY=
github.com/onsi/gomega v1.18.1 h1:M1GfJqGRrBrrGGsbxzV5dqM2U2ApXefZCQpkukxYRLE=
github.com/onsi/gomega v1.18.1/go.mod h1:0q+aL8jAiMXy9hbwj2mr5GziHiwhAIQpFmmtT5hitRs=
github.com/open-dingtalk/dingtalk-stream-sdk-go v0.9.1 h1:Lb/Uzkiw2Ugt2Xf03J5wmv81PdkYOiWbI8CNBi1boC8=
github.com/open-dingtalk/dingtalk-stream-sdk-go v0.9.1/go.mod h1:ln3IqPYYocZbYvl9TAOrG/cxGR9xcn4pnZRLdCTEGEU=
github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U=
github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM=
github.com/opencontainers/image-spec v1.1.0 h1:8SG7/vwALn54lVB/0yZ/MMwhFrPYtpEHQb2IpWsCzug=
@ -346,6 +429,7 @@ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZb
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/pquerna/otp v1.5.0 h1:NMMR+WrmaqXU4EzdGJEE1aUUI0AMRzsp96fFFWNPwxs=
github.com/pquerna/otp v1.5.0/go.mod h1:dkJfzwRKNiegxyNb54X/3fLwhCynbMspSyWKnvi1AEg=
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
github.com/qdrant/go-client v1.14.0 h1:cyz9OOooAexudw5w69LRe9vKCQFYJvaFvt9icOciI1U=
github.com/qdrant/go-client v1.14.0/go.mod h1:iO8ts78jL4x6LDHFOViyYWELVtIBDTjOykBmiOTHLnQ=
github.com/redis/go-redis/v9 v9.17.2 h1:P2EGsA4qVIM3Pp+aPocCJ7DguDHhqrXNhVcEp4ViluI=
@ -375,6 +459,9 @@ github.com/shopspring/decimal v1.4.0 h1:bxl37RwXBklmTi0C79JfXCEBD1cqqHt0bbgBAGFp
github.com/shopspring/decimal v1.4.0/go.mod h1:gawqmDU56v4yIKSwfBSFip1HdCCXN8/+DMd9qYNcwME=
github.com/sirupsen/logrus v1.9.4 h1:TsZE7l11zFCLZnZ+teH4Umoq5BhEIfIzfRDZ1Uzql2w=
github.com/sirupsen/logrus v1.9.4/go.mod h1:ftWc9WdOfJ0a92nsE2jF5u5ZwH8Bv2zdeOC42RjbV2g=
github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc=
github.com/smartystreets/assertions v1.1.0/go.mod h1:tcbTF8ujkAEcZ8TElKY+i30BzYlVhC/LOxJk7iOWnoo=
github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA=
github.com/spf13/cast v1.9.2 h1:SsGfm7M8QOFtEzumm7UZrZdLLquNdzFYfIbEXntcFbE=
github.com/spf13/cast v1.9.2/go.mod h1:jNfB8QC9IA6ZuY2ZjDp0KtFO2LZZlg4S/7bzP6qqeHo=
github.com/spf13/cobra v1.9.1 h1:CXSaggrXdbHK9CF+8ywj8Amf7PBRmPCOJugH954Nnlo=
@ -382,10 +469,12 @@ github.com/spf13/cobra v1.9.1/go.mod h1:nDyEzZ8ogv936Cinf6g1RU9MRY64Ir93oCnqb9wx
github.com/spf13/pflag v1.0.6 h1:jFzHGLGAlb3ruxLB8MhbI6A8+AQX/2eW4qeyNZXNp2o=
github.com/spf13/pflag v1.0.6/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE=
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.7.2/go.mod h1:R6va5+xMeoiuVRoj+gSkQ7d3FALtqAAGI1FQKckRals=
@ -419,6 +508,9 @@ github.com/tidwall/tinyqueue v0.1.1 h1:SpNEvEggbpyN5DIReaJ2/1ndroY8iyEGxPYxoSaym
github.com/tidwall/tinyqueue v0.1.1/go.mod h1:O/QNHwrnjqr6IHItYrzoHAKYhBkLI67Q096fQP5zMYw=
github.com/tiendc/go-deepcopy v1.6.0 h1:0UtfV/imoCwlLxVsyfUd4hNHnB3drXsfle+wzSCA5Wo=
github.com/tiendc/go-deepcopy v1.6.0/go.mod h1:toXoeQoUqXOOS/X4sKuiAoSk6elIdqc0pN7MTgOOo2I=
github.com/tjfoc/gmsm v1.3.2/go.mod h1:HaUcFuY0auTiaHB9MHFGCPx5IaLhTUd2atbCFBQXn9w=
github.com/tjfoc/gmsm v1.4.1 h1:aMe1GlZb+0bLjn+cKTPEvvn9oUEBlJitaZiiBwsbgho=
github.com/tjfoc/gmsm v1.4.1/go.mod h1:j4INPkHWMrhJb38G+J6W4Tw0AbuN8Thu3PbdVYhVcTE=
github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS4MhqMhdFk5YI=
github.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08=
github.com/ugorji/go/codec v1.2.12 h1:9LC83zGrHhuUA9l16C9AHXAqEV/2wBQ4nkvumAE65EE=
@ -444,6 +536,9 @@ github.com/yosida95/uritemplate/v3 v3.0.2 h1:Ed3Oyj9yrmi9087+NczuL5BwkIc4wvTb5zI
github.com/yosida95/uritemplate/v3 v3.0.2/go.mod h1:ILOh0sOhIJR3+L/8afwt/kE++YT040gmv5BQTMR2HP4=
github.com/youmark/pkcs8 v0.0.0-20240726163527-a2c0da244d78 h1:ilQV1hzziu+LLM3zUTJ0trRztfwgjqKnBWNtSRkbmwM=
github.com/youmark/pkcs8 v0.0.0-20240726163527-a2c0da244d78/go.mod h1:aL8wCCfTfSfmXjznFBSZNN13rSJjlIOI1fUNAtF7rmI=
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.1.30/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
github.com/yuin/goldmark v1.7.16 h1:n+CJdUxaFMiDUNnWC3dMWCIQJSkxH4uz3ZwQBkAlVNE=
github.com/yuin/goldmark v1.7.16/go.mod h1:ip/1k0VRfGynBgxOz0yCqHrbZXhcjxyuS66Brc7iBKg=
@ -480,18 +575,32 @@ go.uber.org/zap v1.27.1/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E=
golang.org/x/arch v0.17.0 h1:4O3dfLzd+lQewptAHqjewQZQDyEdejz3VwgeYwkZneU=
golang.org/x/arch v0.17.0/go.mod h1:bdwinDaKcfZUGpH09BB7ZmOfhalA8lQdzl62l8gGWsk=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20191219195013-becbf705a915/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20200510223506-06a226fb4e37/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20201012173705-84dcc777aaee/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20201221181555-eec23a3978ad/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I=
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/crypto v0.13.0/go.mod h1:y6Z2r+Rw4iayiXXAIxJIDAJ1zMW4yaTpebo8fPOliYc=
golang.org/x/crypto v0.14.0/go.mod h1:MVFd36DqK4CsrnJYDkBA3VC4m2GkXAM0PvzMCn4JQf4=
golang.org/x/crypto v0.18.0/go.mod h1:R0j02AL6hcrfOiy9T4ZYp/rcWeMxM3L6QYxlOuEG1mg=
golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDfU=
golang.org/x/crypto v0.21.0/go.mod h1:0BP7YvVV9gBbVKyeTG0Gyn+gZm94bibOW5BjDEYAOMs=
golang.org/x/crypto v0.23.0/go.mod h1:CKFgDieR+mRhux2Lsu27y0fO304Db0wZe70UKqHu0v8=
golang.org/x/crypto v0.31.0/go.mod h1:kDsLvtWBEx7MV9tJOj9bnXsPbxwJQ6csT/x4KIN4Ssk=
golang.org/x/crypto v0.48.0 h1:/VRzVqiRSggnhY7gNRxPauEQ5Drw9haKdM0jqfcCFts=
golang.org/x/crypto v0.48.0/go.mod h1:r0kV5h3qnFPlQnBSrULhlsRfryS2pmewsg+XfMgkVos=
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20230725093048-515e97ebf090 h1:Di6/M8l0O2lCLc6VVRWhgCiApHV8MnQurBnFSHsQtNY=
golang.org/x/exp v0.0.0-20230725093048-515e97ebf090/go.mod h1:FXUEEKJgO7OQYeo8N01OfiKP8RXMtf6e8aTskBGqWdc=
golang.org/x/image v0.29.0 h1:HcdsyR4Gsuys/Axh0rDEmlBmB68rW1U9BUdB3UVHsas=
golang.org/x/image v0.29.0/go.mod h1:RVJROnf3SLK8d26OW91j4FrIHGbsJ8QnbEocVTOWQDA=
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU=
golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
golang.org/x/mod v0.12.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
@ -500,16 +609,26 @@ golang.org/x/mod v0.17.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
golang.org/x/mod v0.33.0 h1:tHFzIWbBifEmbwtGz65eaWyGiGZatSrT9prnU8DbVL8=
golang.org/x/mod v0.33.0/go.mod h1:swjeQEj+6r7fODbD2cqrnje9PnziFuw4bmLbBZFrQ5w=
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20200506145744-7e3656a0809f/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
golang.org/x/net v0.0.0-20201010224723-4f7140c49acb/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg=
golang.org/x/net v0.15.0/go.mod h1:idbUs1IY1+zTqbi8yxTbhexhEEk5ur9LInksu6HrEpk=
golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE=
golang.org/x/net v0.20.0/go.mod h1:z8BVo6PvndSri0LbOE3hAn0apkU+1YvI6E70E9jsnvY=
golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44=
golang.org/x/net v0.23.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg=
golang.org/x/net v0.25.0/go.mod h1:JkAGAh7GEvH74S6FOH42FLoXpXbE/aqXSrIQjXgsiwM=
golang.org/x/net v0.33.0/go.mod h1:HXLR5J+9DxmrqMwG9qjGCxZ+zKXxBru04zlTvWlWuN4=
golang.org/x/net v0.50.0 h1:ucWh9eiCGyDR3vtzso0WMQinm2Dnt8cFMuQa9K33J60=
@ -519,7 +638,11 @@ golang.org/x/oauth2 v0.0.0-20181106182150-f42d05182288/go.mod h1:N/0e6XlmueqKjAG
golang.org/x/oauth2 v0.30.0 h1:dnDm7JmhM45NNpd8FDDeLhK6FwqbOf4MLCM9zb1BOHI=
golang.org/x/oauth2 v0.30.0/go.mod h1:B++QgG3ZKulg6sRPGD/mqlHQs5rB3Ml9erfeDY7xKlU=
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
@ -529,11 +652,16 @@ golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/sync v0.10.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/sync v0.19.0 h1:vV+1eWNmZ5geRlYjzm2adRgW2/mcpevXNg50YZtPCE4=
golang.org/x/sync v0.19.0/go.mod h1:9KTHXmSnoGruLpwFjVSX0lNNA75CykiMECbovNTZqGI=
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200509044756-6aff5f38e54f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
@ -547,7 +675,10 @@ golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.16.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.28.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.41.0 h1:Ivj+2Cp/ylzLiEU89QhWblYnOE9zerudt9Ftecq2C6k=
@ -559,10 +690,14 @@ golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuX
golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k=
golang.org/x/term v0.8.0/go.mod h1:xPskH00ivmX89bAKVGSKKtLOWNx2+17Eiy94tnKShWo=
golang.org/x/term v0.12.0/go.mod h1:owVbMEjm3cBLCHdkQu9b1opXd4ETQWc3BhuQGKgXgvU=
golang.org/x/term v0.13.0/go.mod h1:LTmsnFJwVN6bCy1rVCoS+qHT1HhALEFxKncY3WNNh4U=
golang.org/x/term v0.16.0/go.mod h1:yn7UURbUtPyrVJPGPq404EukNFxcm/foM+bV/bfcDsY=
golang.org/x/term v0.17.0/go.mod h1:lLRBjIVuehSbZlaOtGMbcMncT+aqLLLmKrsjNrUguwk=
golang.org/x/term v0.18.0/go.mod h1:ILwASektA3OnRv7amZ1xhE/KTR+u50pbXfZ03+6Nx58=
golang.org/x/term v0.20.0/go.mod h1:8UkIAJTvZgivsXaD6/pH6U9ecQzZ45awqEOzuCvwpFY=
golang.org/x/term v0.27.0/go.mod h1:iMsnZpn0cago0GOrHO2+Y7u7JPn5AylBrcoWkElMTSM=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
@ -579,7 +714,15 @@ golang.org/x/text v0.34.0/go.mod h1:homfLqTYRFyVYemLBFl5GgL/DWEiH5wcsQ5gSh1yziA=
golang.org/x/time v0.3.0 h1:rg5rLMjNzMS1RkNLzCG38eapWhnYLFYXDXj2gOlr8j4=
golang.org/x/time v0.3.0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY=
golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.0.0-20200509030707-2212a7e161a5/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU=
golang.org/x/tools v0.13.0/go.mod h1:HvlwmtVNQAhOuCjW7xxvovg8wbNq7LwfXh/k7wXUl58=
@ -587,31 +730,51 @@ golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d/go.mod h1:aiJjzUbINMkxb
golang.org/x/tools v0.42.0 h1:uNgphsn75Tdz5Ji2q36v/nsFSfR/9BRFvqhGBaJGd5k=
golang.org/x/tools v0.42.0/go.mod h1:Ma6lCIwGZvHK6XtgbswSoWroEkhugApmsXyrUmBhfr0=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
gonum.org/v1/gonum v0.16.0 h1:5+ul4Swaf3ESvrOnidPp4GZbzf0mxVQpDCYUQE7OJfk=
gonum.org/v1/gonum v0.16.0/go.mod h1:fef3am4MQ93R2HHpKnLk4/Tbh/s0+wqD5nfa6Pnwy4E=
google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM=
google.golang.org/appengine v1.3.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc=
google.golang.org/genproto/googleapis/api v0.0.0-20250825161204-c5933d9347a5 h1:BIRfGDEjiHRrk0QKZe3Xv2ieMhtgRGeLcZQ0mIVn4EY=
google.golang.org/genproto/googleapis/api v0.0.0-20250825161204-c5933d9347a5/go.mod h1:j3QtIyytwqGr1JUDtYXwtMXWPKsEa5LtzIFN1Wn5WvE=
google.golang.org/genproto/googleapis/rpc v0.0.0-20250825161204-c5933d9347a5 h1:eaY8u2EuxbRv7c3NiGK0/NedzVsCcV6hDuU5qPX5EGE=
google.golang.org/genproto/googleapis/rpc v0.0.0-20250825161204-c5933d9347a5/go.mod h1:M4/wBTSeyLxupu3W3tJtOgB14jILAS/XWPSSa3TAlJc=
google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg=
google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY=
google.golang.org/grpc v1.31.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak=
google.golang.org/grpc v1.75.1 h1:/ODCNEuf9VghjgO3rqLcfg8fiOP0nSluljWFlDxELLI=
google.golang.org/grpc v1.75.1/go.mod h1:JtPAzKiq4v1xcAB2hydNlWI2RnF85XXcV0mhKXr2ecQ=
google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0=
google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM=
google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE=
google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo=
google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
google.golang.org/protobuf v1.36.11 h1:fV6ZwhNocDyBLK0dj+fg8ektcVegBBuEolpbTQyBNVE=
google.golang.org/protobuf v1.36.11/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j23XfzDpco=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys=
gopkg.in/ini.v1 v1.56.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=
gopkg.in/ini.v1 v1.67.0 h1:Dgnx+6+nfE+IfzjUEISNeydPJh9AXNNsWbGP9KzCsOA=
gopkg.in/ini.v1 v1.67.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=
gopkg.in/natefinch/lumberjack.v2 v2.2.1 h1:bBRl1b0OH9s/DuPhuXpNl+VtCaJXFZ5/uEFST95x9zc=
gopkg.in/natefinch/lumberjack.v2 v2.2.1/go.mod h1:YD8tP3GAjkrDg1eZH7EGmyESg/lsYskCTPBJVb9jqSc=
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ=
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw=
gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
@ -619,6 +782,8 @@ gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gotest.tools/v3 v3.5.2 h1:7koQfIKdy+I8UTetycgUqXWSDwpgv193Ka+qRsmBY8Q=
gotest.tools/v3 v3.5.2/go.mod h1:LtdLGcnqToBH83WByAAi/wiwSFCArdFIUV/xxN4pcjA=
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
nhooyr.io/websocket v1.8.17 h1:KEVeLJkUywCKVsnLIDlD/5gtayKp8VoCkksHCGGfT9Y=
nhooyr.io/websocket v1.8.17/go.mod h1:rN9OFWIUwuxg4fR5tELlYC04bXYowCP9GX47ivo2l+c=
nullprogram.com/x/optparse v1.0.0/go.mod h1:KdyPE+Igbe0jQUrVfMqDMeJQIJZEuyV7pjYmp6pbG50=

View file

@ -0,0 +1,133 @@
package dingtalk
import (
"bytes"
"context"
"encoding/json"
"fmt"
"io"
"net/http"
"time"
)
const (
apiBase = "https://api.dingtalk.com"
oauthBase = "https://api.dingtalk.com/v1.0/oauth2/accessToken"
)
// Bot represents a DingTalk bot instance.
type Bot struct {
clientID string
clientSecret string
httpClient *http.Client
accessToken string
tokenExpires time.Time
}
// NewBot creates a Bot bound to DingTalk app credentials.
func NewBot(clientID, clientSecret string) *Bot {
return &Bot{
clientID: clientID,
clientSecret: clientSecret,
httpClient: &http.Client{Timeout: 30 * time.Second},
}
}
// ClientID returns the client ID.
func (b *Bot) ClientID() string { return b.clientID }
// ClientSecret returns the client secret.
func (b *Bot) ClientSecret() string { return b.clientSecret }
// GetAccessToken returns a valid access token, refreshing if necessary.
func (b *Bot) GetAccessToken(ctx context.Context) (string, error) {
if b.accessToken != "" && time.Now().Before(b.tokenExpires) {
return b.accessToken, nil
}
body, _ := json.Marshal(map[string]string{
"appKey": b.clientID,
"appSecret": b.clientSecret,
})
req, err := http.NewRequestWithContext(ctx, "POST", oauthBase, bytes.NewReader(body))
if err != nil {
return "", err
}
req.Header.Set("Content-Type", "application/json")
resp, err := b.httpClient.Do(req)
if err != nil {
return "", fmt.Errorf("dingtalk get token: %w", err)
}
defer resp.Body.Close()
respBody, err := io.ReadAll(resp.Body)
if err != nil {
return "", fmt.Errorf("read token response: %w", err)
}
var result struct {
AccessToken string `json:"accessToken"`
ExpireIn int `json:"expireIn"`
}
if err := json.Unmarshal(respBody, &result); err != nil {
return "", fmt.Errorf("unmarshal token: %w", err)
}
if result.AccessToken == "" {
return "", fmt.Errorf("dingtalk token empty, body=%s", string(respBody))
}
b.accessToken = result.AccessToken
b.tokenExpires = time.Now().Add(time.Duration(result.ExpireIn-60) * time.Second)
return b.accessToken, nil
}
// GetBotInfo verifies the bot credentials by fetching the access token.
func (b *Bot) GetBotInfo(ctx context.Context) error {
_, err := b.GetAccessToken(ctx)
return err
}
// apiRequest makes an authenticated API call to DingTalk.
func (b *Bot) apiRequest(ctx context.Context, method, path string, body interface{}) ([]byte, error) {
token, err := b.GetAccessToken(ctx)
if err != nil {
return nil, err
}
var bodyReader io.Reader
if body != nil {
data, err := json.Marshal(body)
if err != nil {
return nil, err
}
bodyReader = bytes.NewReader(data)
}
url := apiBase + path
req, err := http.NewRequestWithContext(ctx, method, url, bodyReader)
if err != nil {
return nil, err
}
req.Header.Set("Content-Type", "application/json")
req.Header.Set("x-acs-dingtalk-access-token", token)
resp, err := b.httpClient.Do(req)
if err != nil {
return nil, fmt.Errorf("dingtalk api: %w", err)
}
defer resp.Body.Close()
respBody, err := io.ReadAll(resp.Body)
if err != nil {
return nil, fmt.Errorf("read api response: %w", err)
}
if resp.StatusCode >= 400 {
return nil, fmt.Errorf("dingtalk api error: status=%d body=%s", resp.StatusCode, string(respBody))
}
return respBody, nil
}

View file

@ -0,0 +1,15 @@
package dingtalk
import (
"testing"
)
func TestNewBot(t *testing.T) {
b := NewBot("client_id", "client_secret")
if b.ClientID() != "client_id" {
t.Fatalf("expected ClientID client_id, got %s", b.ClientID())
}
if b.ClientSecret() != "client_secret" {
t.Fatalf("expected ClientSecret client_secret, got %s", b.ClientSecret())
}
}

View file

@ -0,0 +1,142 @@
package dingtalk
import (
"encoding/json"
"strings"
)
// ConvertedMessage is the unified output after parsing a DingTalk message.
type ConvertedMessage struct {
MessageID string `json:"message_id"`
ConversationID string `json:"conversation_id"`
ConversationType string `json:"conversation_type"` // "1" = private, "2" = group
SenderID string `json:"sender_id"`
SenderNick string `json:"sender_nick,omitempty"`
SenderStaffID string `json:"sender_staff_id,omitempty"`
Text string `json:"text,omitempty"`
MediaItems []MediaItem `json:"media,omitempty"`
ChatbotUserID string `json:"chatbot_user_id,omitempty"`
IsInAtList bool `json:"is_in_at_list,omitempty"`
SessionWebhook string `json:"session_webhook,omitempty"`
}
// MediaItem describes a single attachment in a DingTalk message.
type MediaItem struct {
Type MediaType `json:"type"`
URL string `json:"url,omitempty"`
MimeType string `json:"mime_type,omitempty"`
FileName string `json:"file_name,omitempty"`
Wrapper string `json:"wrapper,omitempty"`
}
// MediaType indicates the attachment type.
type MediaType string
const (
MediaImage MediaType = "image"
MediaFile MediaType = "file"
MediaAudio MediaType = "audio"
MediaVideo MediaType = "video"
MediaRichText MediaType = "richText"
)
// HasMedia returns true if the message contains media.
func (cm *ConvertedMessage) HasMedia() bool { return len(cm.MediaItems) > 0 }
// HasText returns true if the message contains text.
func (cm *ConvertedMessage) HasText() bool { return cm.Text != "" }
// StreamCallbackData is the data structure from DingTalk stream callback.
type StreamCallbackData struct {
ConversationID string `json:"conversationId"`
ConversationType string `json:"conversationType"`
AtUsers []AtUser `json:"atUsers"`
ChatbotCorpID string `json:"chatbotCorpId"`
ChatbotUserID string `json:"chatbotUserId"`
MsgID string `json:"msgId"`
SenderID string `json:"senderId"`
SenderNick string `json:"senderNick"`
SenderCorpID string `json:"senderCorpId"`
SenderStaffID string `json:"senderStaffId"`
SessionWebhook string `json:"sessionWebhook"`
SessionWebhookExpiredTime int64 `json:"sessionWebhookExpiredTime"`
IsAdmin bool `json:"isAdmin"`
IsInAtList bool `json:"isInAtList"`
Text *TextContent `json:"text,omitempty"`
Msgtype string `json:"msgtype"`
RichText json.RawMessage `json:"richText,omitempty"`
}
// AtUser represents a mentioned user in a DingTalk message.
type AtUser struct {
DingtalkID string `json:"dingtalkId"`
StaffID string `json:"staffId,omitempty"`
}
// TextContent holds plain text content.
type TextContent struct {
Content string `json:"content"`
}
// ConvertStreamData transforms a DingTalk stream callback into a ConvertedMessage.
func ConvertStreamData(data *StreamCallbackData) *ConvertedMessage {
if data == nil {
return nil
}
cm := &ConvertedMessage{
MessageID: data.MsgID,
ConversationID: data.ConversationID,
ConversationType: data.ConversationType,
SenderID: data.SenderID,
SenderNick: data.SenderNick,
SenderStaffID: data.SenderStaffID,
ChatbotUserID: data.ChatbotUserID,
IsInAtList: data.IsInAtList,
SessionWebhook: data.SessionWebhook,
}
switch data.Msgtype {
case "text":
if data.Text != nil {
text := strings.TrimSpace(data.Text.Content)
cm.Text = text
}
case "richText":
if len(data.RichText) > 0 {
text, media := parseRichText(data.RichText)
cm.Text = text
cm.MediaItems = media
}
case "picture":
cm.MediaItems = append(cm.MediaItems, MediaItem{Type: MediaImage})
}
return cm
}
func parseRichText(raw json.RawMessage) (string, []MediaItem) {
var richText struct {
RichText []struct {
Text string `json:"text,omitempty"`
PicURL string `json:"pictureDownloadUrl,omitempty"`
Type string `json:"type,omitempty"`
DownURL string `json:"downloadCode,omitempty"`
} `json:"richText"`
}
if err := json.Unmarshal(raw, &richText); err != nil {
return "", nil
}
var text string
var media []MediaItem
for _, item := range richText.RichText {
if item.Text != "" {
text += item.Text
}
if item.PicURL != "" {
media = append(media, MediaItem{Type: MediaImage, URL: item.PicURL, MimeType: "image/jpeg"})
}
}
return text, media
}

View file

@ -0,0 +1,67 @@
package dingtalk
import (
"testing"
)
func TestConvertStreamData_Text(t *testing.T) {
data := &StreamCallbackData{
MsgID: "msg_001",
ConversationID: "cid_001",
ConversationType: "1",
SenderID: "user_001",
SenderNick: "Test User",
SessionWebhook: "https://oapi.dingtalk.com/robot/sendBySession/xxx",
Msgtype: "text",
Text: &TextContent{Content: " Hello World "},
}
cm := ConvertStreamData(data)
if cm == nil {
t.Fatal("expected non-nil ConvertedMessage")
}
if cm.MessageID != "msg_001" {
t.Errorf("expected msg_001, got %s", cm.MessageID)
}
if cm.Text != "Hello World" {
t.Errorf("expected 'Hello World', got %q", cm.Text)
}
if cm.ConversationID != "cid_001" {
t.Errorf("expected cid_001, got %s", cm.ConversationID)
}
if cm.SenderNick != "Test User" {
t.Errorf("expected 'Test User', got %s", cm.SenderNick)
}
if cm.SessionWebhook == "" {
t.Error("expected non-empty SessionWebhook")
}
}
func TestConvertStreamData_Nil(t *testing.T) {
cm := ConvertStreamData(nil)
if cm != nil {
t.Error("nil input should return nil")
}
}
func TestConvertedMessage_HasText(t *testing.T) {
cm := &ConvertedMessage{}
if cm.HasText() {
t.Error("empty should not have text")
}
cm.Text = "hello"
if !cm.HasText() {
t.Error("should have text")
}
}
func TestConvertedMessage_HasMedia(t *testing.T) {
cm := &ConvertedMessage{}
if cm.HasMedia() {
t.Error("empty should not have media")
}
cm.MediaItems = append(cm.MediaItems, MediaItem{Type: MediaImage, URL: "http://example.com/img.jpg"})
if !cm.HasMedia() {
t.Error("should have media")
}
}

View file

@ -0,0 +1,28 @@
package dingtalk
import (
"os"
"testing"
)
var (
testClientID string
testClientSecret string
)
func TestMain(m *testing.M) {
testClientID = os.Getenv("DINGTALK_TEST_CLIENT_ID")
testClientSecret = os.Getenv("DINGTALK_TEST_CLIENT_SECRET")
os.Exit(m.Run())
}
func skipIfNoCreds(t *testing.T) {
t.Helper()
if testClientID == "" || testClientSecret == "" {
t.Skip("DINGTALK_TEST_CLIENT_ID or DINGTALK_TEST_CLIENT_SECRET not set")
}
}
func testBotInstance() *Bot {
return NewBot(testClientID, testClientSecret)
}

View file

@ -0,0 +1,57 @@
package dingtalk
import (
"context"
"testing"
"time"
)
// TestE2E_01_GetAccessToken verifies the DingTalk credentials by requesting an access token.
func TestE2E_01_GetAccessToken(t *testing.T) {
skipIfNoCreds(t)
b := testBotInstance()
ctx, cancel := context.WithTimeout(context.Background(), 15*time.Second)
defer cancel()
token, err := b.GetAccessToken(ctx)
if err != nil {
t.Fatalf("GetAccessToken: %v", err)
}
if token == "" {
t.Fatal("access token should not be empty")
}
t.Logf("OK access_token=%s... (truncated)", token[:min(20, len(token))])
// Verify token caching
token2, err := b.GetAccessToken(ctx)
if err != nil {
t.Fatalf("GetAccessToken (cached): %v", err)
}
if token2 != token {
t.Error("cached token should be the same")
}
t.Log("OK token caching verified")
}
// TestE2E_02_BotInfo verifies bot credentials via GetBotInfo.
func TestE2E_02_BotInfo(t *testing.T) {
skipIfNoCreds(t)
b := testBotInstance()
ctx, cancel := context.WithTimeout(context.Background(), 15*time.Second)
defer cancel()
err := b.GetBotInfo(ctx)
if err != nil {
t.Fatalf("GetBotInfo: %v", err)
}
t.Log("OK bot credentials verified")
}
func min(a, b int) int {
if a < b {
return a
}
return b
}

View file

@ -0,0 +1,123 @@
package dingtalk
import (
"bytes"
"context"
"crypto/md5"
"encoding/hex"
"fmt"
"io"
"mime/multipart"
"net/http"
"net/textproto"
"strings"
"github.com/yaoapp/kun/log"
"github.com/yaoapp/yao/attachment"
)
const defaultUploader = "__yao.attachment"
// FileResult holds attachment wrapper and metadata.
type FileResult struct {
Wrapper string
MimeType string
FileName string
}
// DownloadAndStoreURL downloads a file from URL and stores it through the
// attachment manager. Uses the URL as fingerprint for dedup.
func DownloadAndStoreURL(ctx context.Context, url, mimeType, fileName string, groups []string) (*FileResult, error) {
manager, exists := attachment.Managers[defaultUploader]
if !exists {
return nil, fmt.Errorf("attachment manager %s not found", defaultUploader)
}
fingerprint := url
probeID := fingerprintKey(fingerprint, groups)
if manager.Exists(ctx, probeID) {
wrapper := fmt.Sprintf("%s://%s", defaultUploader, probeID)
return &FileResult{Wrapper: wrapper, MimeType: mimeType, FileName: fileName}, nil
}
req, err := http.NewRequestWithContext(ctx, "GET", url, nil)
if err != nil {
return nil, fmt.Errorf("create request: %w", err)
}
client := &http.Client{}
resp, err := client.Do(req)
if err != nil {
return nil, fmt.Errorf("download: %w", err)
}
defer resp.Body.Close()
data, err := io.ReadAll(resp.Body)
if err != nil {
return nil, fmt.Errorf("read body: %w", err)
}
if mimeType == "" {
mimeType = resp.Header.Get("Content-Type")
if mimeType == "" {
mimeType = "application/octet-stream"
}
}
if fileName == "" {
fileName = "file"
}
header := &attachment.FileHeader{
FileHeader: &multipart.FileHeader{
Filename: fileName,
Size: int64(len(data)),
Header: make(textproto.MIMEHeader),
},
}
header.Header.Set("Content-Type", mimeType)
header.Header.Set("Content-Fingerprint", fingerprint)
option := attachment.UploadOption{
OriginalFilename: fileName,
Groups: groups,
}
uploaded, err := manager.Upload(ctx, header, bytes.NewReader(data), option)
if err != nil {
return nil, fmt.Errorf("attachment upload: %w", err)
}
wrapper := fmt.Sprintf("%s://%s", defaultUploader, uploaded.ID)
return &FileResult{Wrapper: wrapper, MimeType: mimeType, FileName: fileName}, nil
}
// ResolveMedia downloads and stores all media items in a ConvertedMessage.
func ResolveMedia(ctx context.Context, cm *ConvertedMessage, groups []string) {
if cm == nil {
return
}
for i := range cm.MediaItems {
mi := &cm.MediaItems[i]
if mi.URL == "" {
continue
}
result, err := DownloadAndStoreURL(ctx, mi.URL, mi.MimeType, mi.FileName, groups)
if err != nil {
log.Error("dingtalk ResolveMedia: %s %s: %v", mi.Type, mi.URL, err)
continue
}
mi.Wrapper = result.Wrapper
if result.MimeType != "" {
mi.MimeType = result.MimeType
}
}
}
func fingerprintKey(key string, groups []string) string {
parts := make([]string, 0, len(groups)+1)
parts = append(parts, groups...)
parts = append(parts, key)
storagePath := strings.Join(parts, "/")
hash := md5.Sum([]byte(storagePath))
return hex.EncodeToString(hash[:])
}

View file

@ -0,0 +1,117 @@
package dingtalk
import (
"bytes"
"context"
"encoding/json"
"fmt"
"io"
"net/http"
)
// SendTextMessage sends a text message to a conversation using the session webhook.
func SendTextMessage(ctx context.Context, sessionWebhook, text string) error {
body, _ := json.Marshal(map[string]interface{}{
"msgtype": "text",
"text": map[string]string{
"content": text,
},
})
return postWebhook(ctx, sessionWebhook, body)
}
// SendMarkdownMessage sends a markdown message via session webhook.
func SendMarkdownMessage(ctx context.Context, sessionWebhook, title, text string) error {
body, _ := json.Marshal(map[string]interface{}{
"msgtype": "markdown",
"markdown": map[string]string{
"title": title,
"text": text,
},
})
return postWebhook(ctx, sessionWebhook, body)
}
// SendImageMessage sends an image via session webhook using media_id.
func SendImageMessage(ctx context.Context, sessionWebhook, mediaID string) error {
body, _ := json.Marshal(map[string]interface{}{
"msgtype": "image",
"image": map[string]string{
"mediaId": mediaID,
},
})
return postWebhook(ctx, sessionWebhook, body)
}
// SendFileMessage sends a file via session webhook using media_id.
func SendFileMessage(ctx context.Context, sessionWebhook, mediaID, fileName, fileType string) error {
body, _ := json.Marshal(map[string]interface{}{
"msgtype": "file",
"file": map[string]string{
"mediaId": mediaID,
"fileName": fileName,
"fileType": fileType,
},
})
return postWebhook(ctx, sessionWebhook, body)
}
// ReplyText sends a text reply to a conversation using the Robot OpenAPI.
func (b *Bot) ReplyText(ctx context.Context, openConversationID, text string) error {
token, err := b.GetAccessToken(ctx)
if err != nil {
return err
}
body, _ := json.Marshal(map[string]interface{}{
"robotCode": b.clientID,
"openConversationId": openConversationID,
"msgKey": "sampleText",
"msgParam": fmt.Sprintf(`{"content":"%s"}`, text),
})
req, err := http.NewRequestWithContext(ctx, "POST",
apiBase+"/v1.0/robot/oToMessages/batchSend", bytes.NewReader(body))
if err != nil {
return err
}
req.Header.Set("Content-Type", "application/json")
req.Header.Set("x-acs-dingtalk-access-token", token)
resp, err := b.httpClient.Do(req)
if err != nil {
return fmt.Errorf("dingtalk reply: %w", err)
}
defer resp.Body.Close()
if resp.StatusCode >= 400 {
respBody, _ := io.ReadAll(resp.Body)
return fmt.Errorf("dingtalk reply: status=%d body=%s", resp.StatusCode, string(respBody))
}
return nil
}
func postWebhook(ctx context.Context, webhookURL string, body []byte) error {
if webhookURL == "" {
return fmt.Errorf("empty session webhook URL")
}
req, err := http.NewRequestWithContext(ctx, "POST", webhookURL, bytes.NewReader(body))
if err != nil {
return err
}
req.Header.Set("Content-Type", "application/json")
client := &http.Client{}
resp, err := client.Do(req)
if err != nil {
return fmt.Errorf("dingtalk webhook post: %w", err)
}
defer resp.Body.Close()
if resp.StatusCode >= 400 {
respBody, _ := io.ReadAll(resp.Body)
return fmt.Errorf("dingtalk webhook: status=%d body=%s", resp.StatusCode, string(respBody))
}
return nil
}

View file

@ -0,0 +1,41 @@
package feishu
import (
lark "github.com/larksuite/oapi-sdk-go/v3"
larkcore "github.com/larksuite/oapi-sdk-go/v3/core"
)
// Bot represents a single Feishu bot instance bound to an app.
type Bot struct {
appID string
appSecret string
client *lark.Client
}
// NewBot creates a Bot bound to the given Feishu app credentials.
func NewBot(appID, appSecret string) *Bot {
client := lark.NewClient(appID, appSecret,
lark.WithLogLevel(larkcore.LogLevelWarn),
)
return &Bot{
appID: appID,
appSecret: appSecret,
client: client,
}
}
// AppID returns the app ID.
func (b *Bot) AppID() string { return b.appID }
// AppSecret returns the app secret (needed for WS client).
func (b *Bot) AppSecret() string { return b.appSecret }
// Client returns the underlying Lark SDK client.
func (b *Bot) Client() *lark.Client { return b.client }
func derefStr(s *string) string {
if s == nil {
return ""
}
return *s
}

View file

@ -0,0 +1,18 @@
package feishu
import (
"testing"
)
func TestNewBot(t *testing.T) {
b := NewBot("cli_xxx", "secret_yyy")
if b.AppID() != "cli_xxx" {
t.Fatalf("expected AppID cli_xxx, got %s", b.AppID())
}
if b.AppSecret() != "secret_yyy" {
t.Fatalf("expected AppSecret secret_yyy, got %s", b.AppSecret())
}
if b.Client() == nil {
t.Fatal("Client() should not be nil")
}
}

View file

@ -0,0 +1,154 @@
package feishu
import (
"encoding/json"
)
// ConvertedMessage is the unified output after parsing a Feishu event message.
type ConvertedMessage struct {
MessageID string `json:"message_id"`
ChatID string `json:"chat_id"`
ChatType string `json:"chat_type"` // p2p, group
SenderID string `json:"sender_id"`
SenderName string `json:"sender_name,omitempty"`
Text string `json:"text,omitempty"`
MediaItems []MediaItem `json:"media,omitempty"`
MentionBot bool `json:"mention_bot,omitempty"`
EventID string `json:"event_id,omitempty"`
LanguageCode string `json:"language_code,omitempty"`
}
// MediaItem describes a single media attachment from the message.
type MediaItem struct {
Type MediaType `json:"type"`
Key string `json:"key"`
MimeType string `json:"mime_type,omitempty"`
FileName string `json:"file_name,omitempty"`
FileSize int64 `json:"file_size,omitempty"`
Wrapper string `json:"wrapper,omitempty"`
}
// MediaType indicates the attachment type.
type MediaType string
const (
MediaImage MediaType = "image"
MediaFile MediaType = "file"
MediaAudio MediaType = "audio"
MediaVideo MediaType = "video"
MediaMedia MediaType = "media"
)
// HasMedia returns true if the message contains any media.
func (cm *ConvertedMessage) HasMedia() bool { return len(cm.MediaItems) > 0 }
// HasText returns true if the message contains text.
func (cm *ConvertedMessage) HasText() bool { return cm.Text != "" }
// feishuTextContent is the JSON structure of a text-type message body.
type feishuTextContent struct {
Text string `json:"text"`
}
// feishuImageContent is the JSON structure of an image-type message body.
type feishuImageContent struct {
ImageKey string `json:"image_key"`
}
// feishuFileContent is the JSON structure of a file-type message body.
type feishuFileContent struct {
FileKey string `json:"file_key"`
FileName string `json:"file_name"`
}
// feishuAudioContent is the JSON structure of an audio-type message body.
type feishuAudioContent struct {
FileKey string `json:"file_key"`
Duration int `json:"duration"`
}
// feishuMediaContent is the JSON structure of a media-type message body.
type feishuMediaContent struct {
FileKey string `json:"file_key"`
FileName string `json:"file_name"`
ImageKey string `json:"image_key"`
}
// ParseMessageContent parses a Feishu message body (JSON string) based on its type.
func ParseMessageContent(msgType, content string) (text string, media []MediaItem) {
switch msgType {
case "text":
var tc feishuTextContent
if err := json.Unmarshal([]byte(content), &tc); err == nil {
text = tc.Text
}
case "image":
var ic feishuImageContent
if err := json.Unmarshal([]byte(content), &ic); err == nil && ic.ImageKey != "" {
media = append(media, MediaItem{Type: MediaImage, Key: ic.ImageKey, MimeType: "image/jpeg"})
}
case "file":
var fc feishuFileContent
if err := json.Unmarshal([]byte(content), &fc); err == nil && fc.FileKey != "" {
media = append(media, MediaItem{Type: MediaFile, Key: fc.FileKey, FileName: fc.FileName})
}
case "audio":
var ac feishuAudioContent
if err := json.Unmarshal([]byte(content), &ac); err == nil && ac.FileKey != "" {
media = append(media, MediaItem{Type: MediaAudio, Key: ac.FileKey, MimeType: "audio/ogg"})
}
case "media":
var mc feishuMediaContent
if err := json.Unmarshal([]byte(content), &mc); err == nil && mc.FileKey != "" {
media = append(media, MediaItem{Type: MediaVideo, Key: mc.FileKey, FileName: mc.FileName})
}
case "post":
var post map[string]interface{}
if err := json.Unmarshal([]byte(content), &post); err == nil {
text = extractPostText(post)
}
}
return
}
// extractPostText extracts plain text from a rich-text (post) message.
func extractPostText(post map[string]interface{}) string {
for _, langContent := range post {
lc, ok := langContent.(map[string]interface{})
if !ok {
continue
}
contentArr, ok := lc["content"].([]interface{})
if !ok {
continue
}
var result string
for _, para := range contentArr {
paraArr, ok := para.([]interface{})
if !ok {
continue
}
for _, elem := range paraArr {
elemMap, ok := elem.(map[string]interface{})
if !ok {
continue
}
tag, _ := elemMap["tag"].(string)
if tag == "text" {
if t, ok := elemMap["text"].(string); ok {
result += t
}
} else if tag == "a" {
if t, ok := elemMap["text"].(string); ok {
result += t
}
}
}
result += "\n"
}
if result != "" {
return result
}
}
return ""
}

View file

@ -0,0 +1,126 @@
package feishu
import (
"testing"
)
func TestParseMessageContent_Text(t *testing.T) {
text, media := ParseMessageContent("text", `{"text":"Hello World"}`)
if text != "Hello World" {
t.Errorf("expected 'Hello World', got %q", text)
}
if len(media) != 0 {
t.Errorf("expected 0 media, got %d", len(media))
}
}
func TestParseMessageContent_Image(t *testing.T) {
text, media := ParseMessageContent("image", `{"image_key":"img_abc123"}`)
if text != "" {
t.Errorf("expected empty text, got %q", text)
}
if len(media) != 1 {
t.Fatalf("expected 1 media, got %d", len(media))
}
if media[0].Type != MediaImage {
t.Errorf("expected type %s, got %s", MediaImage, media[0].Type)
}
if media[0].Key != "img_abc123" {
t.Errorf("expected key img_abc123, got %s", media[0].Key)
}
}
func TestParseMessageContent_File(t *testing.T) {
text, media := ParseMessageContent("file", `{"file_key":"file_xyz","file_name":"report.pdf"}`)
if text != "" {
t.Errorf("expected empty text, got %q", text)
}
if len(media) != 1 {
t.Fatalf("expected 1 media, got %d", len(media))
}
if media[0].Type != MediaFile {
t.Errorf("expected type %s, got %s", MediaFile, media[0].Type)
}
if media[0].FileName != "report.pdf" {
t.Errorf("expected filename report.pdf, got %s", media[0].FileName)
}
}
func TestParseMessageContent_Audio(t *testing.T) {
text, media := ParseMessageContent("audio", `{"file_key":"audio_key","duration":30}`)
if text != "" {
t.Errorf("expected empty text, got %q", text)
}
if len(media) != 1 {
t.Fatalf("expected 1 media, got %d", len(media))
}
if media[0].Type != MediaAudio {
t.Errorf("expected type %s, got %s", MediaAudio, media[0].Type)
}
}
func TestParseMessageContent_Media(t *testing.T) {
text, media := ParseMessageContent("media", `{"file_key":"media_key","file_name":"video.mp4","image_key":"cover"}`)
if text != "" {
t.Errorf("expected empty text, got %q", text)
}
if len(media) != 1 {
t.Fatalf("expected 1 media, got %d", len(media))
}
if media[0].Type != MediaVideo {
t.Errorf("expected type %s, got %s", MediaVideo, media[0].Type)
}
}
func TestParseMessageContent_Post(t *testing.T) {
content := `{"zh_cn":{"title":"Test","content":[[{"tag":"text","text":"Hello "},{"tag":"a","text":"World","href":"https://example.com"}]]}}`
text, media := ParseMessageContent("post", content)
if text == "" {
t.Error("expected non-empty text from post message")
}
if len(media) != 0 {
t.Errorf("expected 0 media from text-only post, got %d", len(media))
}
}
func TestParseMessageContent_InvalidJSON(t *testing.T) {
text, media := ParseMessageContent("text", "not json")
if text != "" {
t.Errorf("expected empty text for invalid JSON, got %q", text)
}
if len(media) != 0 {
t.Errorf("expected 0 media for invalid JSON, got %d", len(media))
}
}
func TestParseMessageContent_UnknownType(t *testing.T) {
text, media := ParseMessageContent("unknown", `{"text":"Hello"}`)
if text != "" {
t.Errorf("expected empty text for unknown type, got %q", text)
}
if len(media) != 0 {
t.Errorf("expected 0 media for unknown type, got %d", len(media))
}
}
func TestConvertedMessage_HasMedia(t *testing.T) {
cm := &ConvertedMessage{}
if cm.HasMedia() {
t.Error("empty message should not have media")
}
cm.MediaItems = append(cm.MediaItems, MediaItem{Type: MediaImage, Key: "test"})
if !cm.HasMedia() {
t.Error("message with media should report HasMedia=true")
}
}
func TestConvertedMessage_HasText(t *testing.T) {
cm := &ConvertedMessage{}
if cm.HasText() {
t.Error("empty message should not have text")
}
cm.Text = "hello"
if !cm.HasText() {
t.Error("message with text should report HasText=true")
}
}

View file

@ -0,0 +1,70 @@
package feishu
import (
"context"
"testing"
"time"
)
// TestE2E_01_BotCredentials verifies the Feishu app credentials by
// sending a simple text message send request (if a chat_id is available).
func TestE2E_01_BotCredentials(t *testing.T) {
skipIfNoCreds(t)
b := testBot()
ctx, cancel := context.WithTimeout(context.Background(), 15*time.Second)
defer cancel()
// Verify credentials by attempting to send a message.
// This will fail with a descriptive error if credentials are invalid.
_, err := b.sendMessage(ctx, "open_id", "test_invalid_open_id", "text", `{"text":"e2e test"}`)
if err == nil {
t.Log("message send succeeded (unexpected, but credentials are valid)")
return
}
// We expect a Feishu API error (not a network error), which proves
// the credentials were accepted and the API was reached.
t.Logf("API response (expected error for invalid open_id): %v", err)
}
// TestE2E_02_SendMessage tests sending a real message if FEISHU_TEST_CHAT_ID is set.
func TestE2E_02_SendMessage(t *testing.T) {
skipIfNoCreds(t)
chatID := getChatID(t)
if chatID == "" {
t.Skip("no chat_id available for send test")
}
b := testBot()
ctx, cancel := context.WithTimeout(context.Background(), 15*time.Second)
defer cancel()
msgID, err := b.SendTextMessage(ctx, chatID, "E2E test from Yao integration at "+time.Now().Format(time.RFC3339))
if err != nil {
t.Fatalf("SendTextMessage: %v", err)
}
t.Logf("OK sent message_id=%s to chat=%s", msgID, chatID)
}
// TestE2E_03_SendImage tests sending an image message.
func TestE2E_03_SendImage(t *testing.T) {
skipIfNoCreds(t)
chatID := getChatID(t)
if chatID == "" {
t.Skip("no chat_id available for image send test")
}
// Would need an uploaded image_key. Skip if not available.
t.Skip("image_key upload not implemented yet in test suite")
}
// getChatID attempts to retrieve a test chat ID from environment or skip.
func getChatID(t *testing.T) string {
t.Helper()
// For now we don't have a chat_id mechanism like Telegram's getUpdates.
// A chat_id can be obtained by having the bot in a group or by user messaging the bot first.
return ""
}

View file

@ -0,0 +1,28 @@
package feishu
import (
"os"
"testing"
)
var (
testAppID string
testAppSecret string
)
func TestMain(m *testing.M) {
testAppID = os.Getenv("FEISHU_TEST_APP_ID")
testAppSecret = os.Getenv("FEISHU_TEST_APP_SECRET")
os.Exit(m.Run())
}
func skipIfNoCreds(t *testing.T) {
t.Helper()
if testAppID == "" || testAppSecret == "" {
t.Skip("FEISHU_TEST_APP_ID or FEISHU_TEST_APP_SECRET not set")
}
}
func testBot() *Bot {
return NewBot(testAppID, testAppSecret)
}

169
integrations/feishu/file.go Normal file
View file

@ -0,0 +1,169 @@
package feishu
import (
"bytes"
"context"
"crypto/md5"
"encoding/hex"
"fmt"
"io"
"mime/multipart"
"net/textproto"
"strings"
larkim "github.com/larksuite/oapi-sdk-go/v3/service/im/v1"
"github.com/yaoapp/kun/log"
"github.com/yaoapp/yao/attachment"
)
const defaultUploader = "__yao.attachment"
// FileResult holds the attachment wrapper and metadata for a stored file.
type FileResult struct {
Wrapper string
MimeType string
FileName string
}
// DownloadAndStoreImage downloads a Feishu image by image_key and stores it
// through the attachment manager. Uses image_key as the fingerprint for dedup.
func (b *Bot) DownloadAndStoreImage(ctx context.Context, messageID, imageKey string, groups []string) (*FileResult, error) {
manager, exists := attachment.Managers[defaultUploader]
if !exists {
return nil, fmt.Errorf("attachment manager %s not found", defaultUploader)
}
probeID := fingerprintKey(imageKey, groups)
if manager.Exists(ctx, probeID) {
wrapper := fmt.Sprintf("%s://%s", defaultUploader, probeID)
return &FileResult{Wrapper: wrapper, MimeType: "image/jpeg", FileName: imageKey + ".jpg"}, nil
}
req := larkim.NewGetMessageResourceReqBuilder().
MessageId(messageID).
FileKey(imageKey).
Type("image").
Build()
resp, err := b.client.Im.MessageResource.Get(ctx, req)
if err != nil {
return nil, fmt.Errorf("feishu get image resource: %w", err)
}
if !resp.Success() {
return nil, fmt.Errorf("feishu get image resource: code=%d", resp.Code)
}
data, err := io.ReadAll(resp.File)
if err != nil {
return nil, fmt.Errorf("read image body: %w", err)
}
return storeData(ctx, manager, imageKey, "image/jpeg", imageKey+".jpg", data, groups)
}
// DownloadAndStoreFile downloads a Feishu file by file_key and stores it.
func (b *Bot) DownloadAndStoreFile(ctx context.Context, messageID, fileKey, mimeType, fileName string, groups []string) (*FileResult, error) {
manager, exists := attachment.Managers[defaultUploader]
if !exists {
return nil, fmt.Errorf("attachment manager %s not found", defaultUploader)
}
probeID := fingerprintKey(fileKey, groups)
if manager.Exists(ctx, probeID) {
wrapper := fmt.Sprintf("%s://%s", defaultUploader, probeID)
return &FileResult{Wrapper: wrapper, MimeType: mimeType, FileName: fileName}, nil
}
req := larkim.NewGetMessageResourceReqBuilder().
MessageId(messageID).
FileKey(fileKey).
Type("file").
Build()
resp, err := b.client.Im.MessageResource.Get(ctx, req)
if err != nil {
return nil, fmt.Errorf("feishu get file resource: %w", err)
}
if !resp.Success() {
return nil, fmt.Errorf("feishu get file resource: code=%d", resp.Code)
}
data, err := io.ReadAll(resp.File)
if err != nil {
return nil, fmt.Errorf("read file body: %w", err)
}
if mimeType == "" {
mimeType = "application/octet-stream"
}
if fileName == "" {
fileName = resp.FileName
if fileName == "" {
fileName = fileKey
}
}
return storeData(ctx, manager, fileKey, mimeType, fileName, data, groups)
}
// ResolveMedia downloads and stores all media items in a ConvertedMessage.
func (b *Bot) ResolveMedia(ctx context.Context, cm *ConvertedMessage, groups []string) {
if cm == nil {
return
}
for i := range cm.MediaItems {
mi := &cm.MediaItems[i]
var result *FileResult
var err error
switch mi.Type {
case MediaImage:
result, err = b.DownloadAndStoreImage(ctx, cm.MessageID, mi.Key, groups)
default:
result, err = b.DownloadAndStoreFile(ctx, cm.MessageID, mi.Key, mi.MimeType, mi.FileName, groups)
}
if err != nil {
log.Error("feishu ResolveMedia: %s %s: %v", mi.Type, mi.Key, err)
continue
}
mi.Wrapper = result.Wrapper
if result.MimeType != "" {
mi.MimeType = result.MimeType
}
}
}
func storeData(ctx context.Context, manager *attachment.Manager, fingerprint, mimeType, fileName string, data []byte, groups []string) (*FileResult, error) {
header := &attachment.FileHeader{
FileHeader: &multipart.FileHeader{
Filename: fileName,
Size: int64(len(data)),
Header: make(textproto.MIMEHeader),
},
}
header.Header.Set("Content-Type", mimeType)
header.Header.Set("Content-Fingerprint", fingerprint)
option := attachment.UploadOption{
OriginalFilename: fileName,
Groups: groups,
}
uploaded, err := manager.Upload(ctx, header, bytes.NewReader(data), option)
if err != nil {
return nil, fmt.Errorf("attachment upload: %w", err)
}
wrapper := fmt.Sprintf("%s://%s", defaultUploader, uploaded.ID)
return &FileResult{Wrapper: wrapper, MimeType: mimeType, FileName: fileName}, nil
}
func fingerprintKey(key string, groups []string) string {
parts := make([]string, 0, len(groups)+1)
parts = append(parts, groups...)
parts = append(parts, key)
storagePath := strings.Join(parts, "/")
hash := md5.Sum([]byte(storagePath))
return hex.EncodeToString(hash[:])
}

View file

@ -0,0 +1,84 @@
package feishu
import (
"context"
"encoding/json"
"fmt"
larkim "github.com/larksuite/oapi-sdk-go/v3/service/im/v1"
)
// SendTextMessage sends a text message to a chat.
func (b *Bot) SendTextMessage(ctx context.Context, chatID, text string) (string, error) {
content, _ := json.Marshal(map[string]string{"text": text})
return b.sendMessage(ctx, "chat_id", chatID, "text", string(content))
}
// SendTextToUser sends a text message to a user by open_id.
func (b *Bot) SendTextToUser(ctx context.Context, openID, text string) (string, error) {
content, _ := json.Marshal(map[string]string{"text": text})
return b.sendMessage(ctx, "open_id", openID, "text", string(content))
}
// SendImageMessage sends an image by image_key to a chat.
func (b *Bot) SendImageMessage(ctx context.Context, chatID, imageKey string) (string, error) {
content, _ := json.Marshal(map[string]string{"image_key": imageKey})
return b.sendMessage(ctx, "chat_id", chatID, "image", string(content))
}
// SendFileMessage sends a file by file_key to a chat.
func (b *Bot) SendFileMessage(ctx context.Context, chatID, fileKey string) (string, error) {
content, _ := json.Marshal(map[string]string{"file_key": fileKey})
return b.sendMessage(ctx, "chat_id", chatID, "file", string(content))
}
// ReplyTextMessage replies to a message with text.
func (b *Bot) ReplyTextMessage(ctx context.Context, messageID, text string) (string, error) {
content, _ := json.Marshal(map[string]string{"text": text})
return b.replyMessage(ctx, messageID, "text", string(content))
}
func (b *Bot) sendMessage(ctx context.Context, receiveIDType, receiveID, msgType, content string) (string, error) {
req := larkim.NewCreateMessageReqBuilder().
ReceiveIdType(receiveIDType).
Body(larkim.NewCreateMessageReqBodyBuilder().
ReceiveId(receiveID).
MsgType(msgType).
Content(content).
Build()).
Build()
resp, err := b.client.Im.Message.Create(ctx, req)
if err != nil {
return "", fmt.Errorf("feishu send message: %w", err)
}
if !resp.Success() {
return "", fmt.Errorf("feishu send message: code=%d msg=%s", resp.Code, resp.Msg)
}
if resp.Data != nil && resp.Data.MessageId != nil {
return *resp.Data.MessageId, nil
}
return "", nil
}
func (b *Bot) replyMessage(ctx context.Context, messageID, msgType, content string) (string, error) {
req := larkim.NewReplyMessageReqBuilder().
MessageId(messageID).
Body(larkim.NewReplyMessageReqBodyBuilder().
MsgType(msgType).
Content(content).
Build()).
Build()
resp, err := b.client.Im.Message.Reply(ctx, req)
if err != nil {
return "", fmt.Errorf("feishu reply message: %w", err)
}
if !resp.Success() {
return "", fmt.Errorf("feishu reply message: code=%d msg=%s", resp.Code, resp.Msg)
}
if resp.Data != nil && resp.Data.MessageId != nil {
return *resp.Data.MessageId, nil
}
return "", nil
}