feat: añadir tools wikipedia_search y exchange_rate
- tools/wikipedia/wikipedia.go: tool wikipedia_search que consulta la API pública de Wikipedia (sin auth). Devuelve resumen del artículo. - tools/exchange/exchange.go: 4 tools de tipo de cambio usando exchangerate-api.com: exchange_rate_get, exchange_rate_convert, exchange_rate_list, exchange_rate_historical. - internal/config/schema.go: añadir ExchangeRateToolCfg con Enabled, APIKey, APIKeyEnv y Timeout. - devagents/registry_build.go: registrar ambas tool families. wikipedia_search siempre disponible; exchange rate tools requieren APIKey configurado (deny-by-default con WARN si falta). - devagents/registry_build_test.go: actualizar test de registry build. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -25,6 +25,8 @@ import (
|
||||
toolskills "github.com/enmanuel/agents/tools/skilltools"
|
||||
toolssh "github.com/enmanuel/agents/tools/ssh"
|
||||
toolweather "github.com/enmanuel/agents/tools/weather"
|
||||
toolwikipedia "github.com/enmanuel/agents/tools/wikipedia"
|
||||
toolexchange "github.com/enmanuel/agents/tools/exchange"
|
||||
|
||||
"github.com/enmanuel/agents/shell/matrix"
|
||||
)
|
||||
@@ -187,12 +189,41 @@ func buildToolRegistry(
|
||||
reg.Register(toolweather.NewWeather())
|
||||
logger.Debug("registered weather tool")
|
||||
|
||||
// wikipedia_search tool is always available
|
||||
reg.Register(toolwikipedia.NewWikipediaSearch())
|
||||
logger.Debug("registered wikipedia_search tool")
|
||||
|
||||
// imdb tool (enabled via config)
|
||||
if cfg.Tools.IMDb.Enabled {
|
||||
reg.Register(toolimdb.NewIMDbSearch(cfg.Tools.IMDb))
|
||||
logger.Debug("registered imdb tool")
|
||||
}
|
||||
|
||||
// exchange rate tools (enabled via config)
|
||||
if cfg.Tools.ExchangeRate.Enabled {
|
||||
if t, err := toolexchange.NewExchangeRateGet(cfg.Tools.ExchangeRate); err != nil {
|
||||
logger.Warn("exchange_rate_get disabled: API key not configured", "err", err)
|
||||
} else {
|
||||
reg.Register(t)
|
||||
}
|
||||
if t, err := toolexchange.NewExchangeRateConvert(cfg.Tools.ExchangeRate); err != nil {
|
||||
logger.Warn("exchange_rate_convert disabled: API key not configured", "err", err)
|
||||
} else {
|
||||
reg.Register(t)
|
||||
}
|
||||
if t, err := toolexchange.NewExchangeRateList(cfg.Tools.ExchangeRate); err != nil {
|
||||
logger.Warn("exchange_rate_list disabled: API key not configured", "err", err)
|
||||
} else {
|
||||
reg.Register(t)
|
||||
}
|
||||
if t, err := toolexchange.NewExchangeRateHistorical(cfg.Tools.ExchangeRate); err != nil {
|
||||
logger.Warn("exchange_rate_historical disabled: API key not configured", "err", err)
|
||||
} else {
|
||||
reg.Register(t)
|
||||
}
|
||||
logger.Debug("registered exchange rate tools")
|
||||
}
|
||||
|
||||
// matrix_send is always available
|
||||
reg.Register(toolmatrix.NewMatrixSend(matrixClient, cfg.Tools.Matrix))
|
||||
logger.Debug("registered matrix tool")
|
||||
|
||||
@@ -143,8 +143,8 @@ func TestBuildToolRegistry_ToolCount(t *testing.T) {
|
||||
|
||||
reg := buildToolRegistry(cfg, nil, nil, nil, nil, nil, nil, nil, nil, roomCtx, logger)
|
||||
|
||||
// 3 always-on + 2 HTTP + 1 SSH + 5 file + 1 IMDb = 12
|
||||
expected := 12
|
||||
// 4 always-on (current_time, get_weather, wikipedia_search, matrix_send) + 2 HTTP + 1 SSH + 5 file + 1 IMDb = 13
|
||||
expected := 13
|
||||
if got := reg.Len(); got != expected {
|
||||
t.Errorf("expected %d tools, got %d: %v", expected, got, reg.Names())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user