2bbf42b741
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.
49 lines
1.2 KiB
Go
49 lines
1.2 KiB
Go
package bootstrap
|
|
|
|
import (
|
|
"code.tczkiot.com/wlw/ai-agent/internal/ai/rag/vectordb"
|
|
"code.tczkiot.com/wlw/ai-agent/internal/pkg/config"
|
|
"code.tczkiot.com/wlw/ai-agent/internal/pkg/i18nx"
|
|
"code.tczkiot.com/wlw/ai-agent/internal/pkg/logx"
|
|
"code.tczkiot.com/wlw/ai-agent/internal/services/cronx"
|
|
"code.tczkiot.com/wlw/ai-agent/internal/wxwork"
|
|
"log/slog"
|
|
|
|
_ "code.tczkiot.com/wlw/ai-agent/internal/services/event_handlers"
|
|
)
|
|
|
|
func Init(configPath string) error {
|
|
cfg, err := config.Load(configPath)
|
|
if err != nil {
|
|
slog.Error("init config failed", "error", err)
|
|
return err
|
|
}
|
|
config.SetCurrent(cfg)
|
|
i18nx.SetDefaultLocale(cfg.LanguageOrDefault())
|
|
|
|
logx.Init(logx.Config{
|
|
Level: cfg.Logger.Level,
|
|
Format: cfg.Logger.Format,
|
|
AddSource: cfg.Logger.AddSource,
|
|
})
|
|
|
|
if _, err := InitDB(cfg.DB); err != nil {
|
|
slog.Error("init db failed", "error", err)
|
|
return err
|
|
}
|
|
if err := InitMigrations(); err != nil {
|
|
slog.Error("init migrations failed", "error", err)
|
|
return err
|
|
}
|
|
if err := vectordb.Init(&cfg.VectorDB); err != nil {
|
|
slog.Error("init vector db failed", "error", err)
|
|
return err
|
|
}
|
|
|
|
// 启动任务调度器
|
|
cronx.Init()
|
|
|
|
wxwork.Init()
|
|
return nil
|
|
}
|