24 lines
715 B
Go
24 lines
715 B
Go
package app
|
||
|
||
import (
|
||
"agent-system-backend/internal/settings"
|
||
"agent-system-backend/internal/store"
|
||
)
|
||
|
||
const tavilySecretService = "tools.tavily"
|
||
|
||
type activeSecretSource interface {
|
||
ActiveSecret(owner, service string) (string, bool)
|
||
}
|
||
|
||
// tavilyKeyPool 解析 Tavily 密钥池:默认属主受管密钥 → 系统行受管密钥
|
||
// (owner=settings.OwnerSystemRow)→ 设置明文 tools.tavily.apiKeys。
|
||
func tavilyKeyPool(secrets activeSecretSource, plaintext string) []string {
|
||
for _, owner := range []string{store.OwnerDefault, settings.OwnerSystemRow} {
|
||
if active, ok := secrets.ActiveSecret(owner, tavilySecretService); ok {
|
||
return splitKeyPool(active)
|
||
}
|
||
}
|
||
return splitKeyPool(plaintext)
|
||
}
|