Files
ai-agent/internal/wxwork/wxwork.go
T
t 2bbf42b741 refactor(auth): delegate access control to be-system
Remove Agent Desk users, roles, login sessions, tokens, and local permission persistence. Expose the backend as an embeddable ai-agent module with host-provided subject lookup and operation authorization callbacks, and complete the frontend/backend repository split.
2026-08-21 00:41:07 +08:00

46 lines
915 B
Go

package wxwork
import (
"code.tczkiot.com/wlw/ai-agent/internal/pkg/config"
"strings"
"github.com/silenceper/wechat/v2/cache"
"github.com/silenceper/wechat/v2/work"
wxconfig "github.com/silenceper/wechat/v2/work/config"
)
var (
w *work.Work
wxCfg config.WxWorkConfig
)
func Init() {
w = nil
wxCfg = config.WxWorkConfig{}
cfg := config.Current()
if !cfg.WxWork.Enabled {
return
}
wxCfg = cfg.WxWork
if strings.TrimSpace(wxCfg.CorpID) == "" || strings.TrimSpace(wxCfg.CorpSecret) == "" {
return
}
w = work.NewWork(&wxconfig.Config{
CorpID: wxCfg.CorpID,
CorpSecret: wxCfg.CorpSecret,
AgentID: wxCfg.AgentID,
RasPrivateKey: wxCfg.RSAPrivateKey,
Token: wxCfg.Token,
EncodingAESKey: wxCfg.EncodingAESKey,
Cache: cache.NewMemory(),
})
}
func Enabled() bool {
return w != nil && wxCfg.Enabled
}
func GetWorkCli() *work.Work {
return w
}