mirror of
https://github.com/tiennm99/goclaw.git
synced 2026-10-20 00:15:16 +00:00
feat: Introduce agent summoning flow with a dedicated modal and updated bootstrap process for predefined agents.
This commit is contained in:
1 parent
abaaf8fc83
commit
08ced252b2
35 files changed
+1142
-147
No files matched your search
+10
-15
@@ -557,7 +557,7 @@ func runGateway() {
|
||||
}
|
||||
|
||||
wireManagedExtras(managedStores, agentRouter, providerRegistry, msgBus, sessStore, toolsReg, toolPE, skillsLoader, hasMemory, traceCollector, workspace, cfg.Gateway.InjectionAction, cfg, sandboxMgr, dynamicLoader)
|
||||
agentsH, skillsH, tracesH, mcpH, customToolsH, channelInstancesH, providersH := wireManagedHTTP(managedStores, cfg.Gateway.Token, msgBus, toolsReg)
|
||||
agentsH, skillsH, tracesH, mcpH, customToolsH, channelInstancesH, providersH := wireManagedHTTP(managedStores, cfg.Gateway.Token, msgBus, toolsReg, providerRegistry)
|
||||
if agentsH != nil {
|
||||
server.SetAgentsHandler(agentsH)
|
||||
}
|
||||
@@ -614,7 +614,6 @@ func runGateway() {
|
||||
|
||||
// Managed mode: load channel instances from DB first.
|
||||
var instanceLoader *channels.InstanceLoader
|
||||
var loadedNames map[string]struct{}
|
||||
if managedStores != nil && managedStores.ChannelInstances != nil {
|
||||
instanceLoader = channels.NewInstanceLoader(managedStores.ChannelInstances, managedStores.Agents, channelMgr, msgBus, pairingStore)
|
||||
instanceLoader.RegisterFactory("telegram", telegram.FactoryWithAgentStore(managedStores.Agents))
|
||||
@@ -625,21 +624,17 @@ func runGateway() {
|
||||
if err := instanceLoader.LoadAll(context.Background()); err != nil {
|
||||
slog.Error("failed to load channel instances from DB", "error", err)
|
||||
}
|
||||
loadedNames = instanceLoader.LoadedNames()
|
||||
}
|
||||
|
||||
// Register config-based channels as fallback.
|
||||
// Telegram: kept for backward compat (only channel with production data).
|
||||
// Other channels: skip config registration in managed mode if any DB instances loaded.
|
||||
if cfg.Channels.Telegram.Enabled && cfg.Channels.Telegram.Token != "" {
|
||||
if _, loaded := loadedNames["telegram"]; !loaded {
|
||||
tg, err := telegram.New(cfg.Channels.Telegram, msgBus, pairingStore, nil)
|
||||
if err != nil {
|
||||
slog.Error("failed to initialize telegram channel", "error", err)
|
||||
} else {
|
||||
channelMgr.RegisterChannel("telegram", tg)
|
||||
slog.Info("telegram channel enabled (config)")
|
||||
}
|
||||
// Register config-based channels as fallback (standalone mode only).
|
||||
// In managed mode, channels are loaded from DB via instanceLoader — skip config-based registration.
|
||||
if cfg.Channels.Telegram.Enabled && cfg.Channels.Telegram.Token != "" && instanceLoader == nil {
|
||||
tg, err := telegram.New(cfg.Channels.Telegram, msgBus, pairingStore, nil)
|
||||
if err != nil {
|
||||
slog.Error("failed to initialize telegram channel", "error", err)
|
||||
} else {
|
||||
channelMgr.RegisterChannel("telegram", tg)
|
||||
slog.Info("telegram channel enabled (config)")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -271,7 +271,7 @@ func wireManagedExtras(
|
||||
}
|
||||
|
||||
// wireManagedHTTP creates managed-mode HTTP handlers (agents + skills + traces + MCP + custom tools + channel instances + providers).
|
||||
func wireManagedHTTP(stores *store.Stores, token string, msgBus *bus.MessageBus, toolsReg *tools.Registry) (*httpapi.AgentsHandler, *httpapi.SkillsHandler, *httpapi.TracesHandler, *httpapi.MCPHandler, *httpapi.CustomToolsHandler, *httpapi.ChannelInstancesHandler, *httpapi.ProvidersHandler) {
|
||||
func wireManagedHTTP(stores *store.Stores, token string, msgBus *bus.MessageBus, toolsReg *tools.Registry, providerReg *providers.Registry) (*httpapi.AgentsHandler, *httpapi.SkillsHandler, *httpapi.TracesHandler, *httpapi.MCPHandler, *httpapi.CustomToolsHandler, *httpapi.ChannelInstancesHandler, *httpapi.ProvidersHandler) {
|
||||
var agentsH *httpapi.AgentsHandler
|
||||
var skillsH *httpapi.SkillsHandler
|
||||
var tracesH *httpapi.TracesHandler
|
||||
@@ -281,7 +281,11 @@ func wireManagedHTTP(stores *store.Stores, token string, msgBus *bus.MessageBus,
|
||||
var providersH *httpapi.ProvidersHandler
|
||||
|
||||
if stores != nil && stores.Agents != nil {
|
||||
agentsH = httpapi.NewAgentsHandler(stores.Agents, token, msgBus)
|
||||
var summoner *httpapi.AgentSummoner
|
||||
if providerReg != nil {
|
||||
summoner = httpapi.NewAgentSummoner(stores.Agents, providerReg, msgBus)
|
||||
}
|
||||
agentsH = httpapi.NewAgentsHandler(stores.Agents, token, msgBus, summoner)
|
||||
}
|
||||
|
||||
if stores != nil && stores.Skills != nil {
|
||||
|
||||
Reference in new issue
Block a user