mirror of
https://github.com/mudler/LocalAI.git
synced 2026-11-04 03:24:43 -05:00
Warn before the standalone pool starts root agents with user auth enabled. Count root agents, collections, skills, and configured skill repositories. Document the auth transition, bootstrap rules, and agent key behavior. Addresses the warning and documentation step of #12665. Admin visibility and data migration remain separate work. Assisted-by: Codex:GPT-6 Co-authored-by: localai-org-maint-bot <306269227+localai-org-maint-bot@users.noreply.github.com>
56 lines
1.9 KiB
Go
56 lines
1.9 KiB
Go
// SPDX-License-Identifier: MIT
|
|
package agentpool
|
|
|
|
import (
|
|
"strings"
|
|
|
|
skillsManager "github.com/mudler/LocalAI/core/services/skills"
|
|
skillgit "github.com/mudler/skillserver/pkg/git"
|
|
"github.com/mudler/xlog"
|
|
)
|
|
|
|
func (s *AgentPoolService) warnLegacyAuthData() {
|
|
if !s.appConfig.Auth.Enabled {
|
|
return
|
|
}
|
|
|
|
rootAgents := 0
|
|
for _, name := range s.localAGI.pool.List() {
|
|
if !strings.Contains(name, ":") {
|
|
rootAgents++
|
|
}
|
|
}
|
|
rootCollections, err := s.collectionsBackend.ListCollections()
|
|
if err != nil {
|
|
xlog.Warn("Could not check root collections after enabling user authentication", "error", err)
|
|
}
|
|
|
|
skillCount, repoCount := 0, 0
|
|
if s.localAGI.skillsService != nil {
|
|
manager := skillsManager.NewFilesystemManager(s.localAGI.skillsService)
|
|
rootSkills, err := manager.List()
|
|
if err != nil {
|
|
xlog.Warn("Could not check root skills after enabling user authentication", "error", err)
|
|
} else {
|
|
skillCount = len(rootSkills)
|
|
}
|
|
// Count disabled and not-yet-cloned repositories too; the skill index
|
|
// contains only skills that are already available on disk.
|
|
repos, err := skillgit.NewConfigManager(s.localAGI.skillsService.GetSkillsDir()).LoadConfig()
|
|
if err != nil {
|
|
xlog.Warn("Could not check root skill repositories after enabling user authentication", "error", err)
|
|
} else {
|
|
repoCount = len(repos)
|
|
}
|
|
}
|
|
|
|
if rootAgents+len(rootCollections)+skillCount+repoCount == 0 {
|
|
return
|
|
}
|
|
xlog.Warn("User authentication is enabled but root agent data has no owner",
|
|
"agents", rootAgents, "collections", len(rootCollections), "skills", skillCount, "git_repositories", repoCount,
|
|
"stateDir", s.stateDir,
|
|
"details", "Existing data is not migrated to a user. Root agents still start and may run scheduled tasks; their API calls require valid credentials.",
|
|
"docs", "https://localai.io/features/authentication/#enabling-auth-on-an-existing-instance")
|
|
}
|