Files
picoclaw/pkg/tools/integration_facade.go
T
Junghwan 293477b02a Keep launcher locale changes from mutating shared web-search routing (#2573)
The launcher wired UI language changes into a process-global backend
switch that changed auto web-search provider selection and the
reported current service for every handler in the same process.

This narrows the fix to the validated leak: remove backend sync from
frontend locale changes, drop the now-unused UI endpoint, and make
auto selection fall back to a stable default when the query itself
does not contain a script hint.

Constraint: Keep the patch small and mergeable without redesigning per-user preference storage
Rejected: Add per-user backend language state | larger scope than the validated bug and unclear maintainer preference
Rejected: Persist preferred language in config | still shares mutable state across clients of the same instance
Confidence: high
Scope-risk: narrow
Reversibility: clean
Directive: If locale-aware provider routing is reintroduced later, scope it to explicit config or request context instead of package-global state
Tested: go test ./web/backend/api ./pkg/tools -count=1; pnpm lint; pnpm build
Not-tested: Full make check; live multi-browser manual launcher run after the backend endpoint removal
2026-04-24 13:45:25 +08:00

107 lines
3.9 KiB
Go

package tools
import (
"github.com/modelcontextprotocol/go-sdk/mcp"
"github.com/sipeed/picoclaw/pkg/audio/tts"
"github.com/sipeed/picoclaw/pkg/config"
"github.com/sipeed/picoclaw/pkg/media"
"github.com/sipeed/picoclaw/pkg/skills"
integrationtools "github.com/sipeed/picoclaw/pkg/tools/integration"
)
type (
SendCallbackWithContext = integrationtools.SendCallbackWithContext
ReactionCallback = integrationtools.ReactionCallback
MCPManager = integrationtools.MCPManager
MCPTool = integrationtools.MCPTool
FindSkillsTool = integrationtools.FindSkillsTool
InstallSkillTool = integrationtools.InstallSkillTool
MessageTool = integrationtools.MessageTool
ReactionTool = integrationtools.ReactionTool
SendTTSTool = integrationtools.SendTTSTool
APIKeyPool = integrationtools.APIKeyPool
APIKeyIterator = integrationtools.APIKeyIterator
SearchProvider = integrationtools.SearchProvider
SearchResultItem = integrationtools.SearchResultItem
BraveSearchProvider = integrationtools.BraveSearchProvider
TavilySearchProvider = integrationtools.TavilySearchProvider
SogouSearchProvider = integrationtools.SogouSearchProvider
DuckDuckGoSearchProvider = integrationtools.DuckDuckGoSearchProvider
PerplexitySearchProvider = integrationtools.PerplexitySearchProvider
SearXNGSearchProvider = integrationtools.SearXNGSearchProvider
GLMSearchProvider = integrationtools.GLMSearchProvider
BaiduSearchProvider = integrationtools.BaiduSearchProvider
WebSearchTool = integrationtools.WebSearchTool
WebSearchToolOptions = integrationtools.WebSearchToolOptions
WebFetchTool = integrationtools.WebFetchTool
)
func NewMCPTool(manager MCPManager, serverName string, tool *mcp.Tool) *MCPTool {
return integrationtools.NewMCPTool(manager, serverName, tool)
}
func NewFindSkillsTool(registryMgr *skills.RegistryManager, cache *skills.SearchCache) *FindSkillsTool {
return integrationtools.NewFindSkillsTool(registryMgr, cache)
}
func NewInstallSkillTool(registryMgr *skills.RegistryManager, workspace string) *InstallSkillTool {
return integrationtools.NewInstallSkillTool(registryMgr, workspace)
}
func NewMessageTool() *MessageTool {
return integrationtools.NewMessageTool()
}
func NewReactionTool() *ReactionTool {
return integrationtools.NewReactionTool()
}
func NewSendTTSTool(provider tts.TTSProvider, store media.MediaStore) *SendTTSTool {
return integrationtools.NewSendTTSTool(provider, store)
}
func NewAPIKeyPool(keys []string) *APIKeyPool {
return integrationtools.NewAPIKeyPool(keys)
}
func WebSearchToolOptionsFromConfig(cfg *config.Config) WebSearchToolOptions {
return integrationtools.WebSearchToolOptionsFromConfig(cfg)
}
func WebSearchProviderReady(opts WebSearchToolOptions, name string) bool {
return integrationtools.WebSearchProviderReady(opts, name)
}
func ResolveWebSearchProviderName(opts WebSearchToolOptions, query string) (string, error) {
return integrationtools.ResolveWebSearchProviderName(opts, query)
}
func NewWebSearchTool(opts WebSearchToolOptions) (*WebSearchTool, error) {
return integrationtools.NewWebSearchTool(opts)
}
func NewWebFetchTool(maxChars int, format string, fetchLimitBytes int64) (*WebFetchTool, error) {
return integrationtools.NewWebFetchTool(maxChars, format, fetchLimitBytes)
}
func NewWebFetchToolWithProxy(
maxChars int,
proxy string,
format string,
fetchLimitBytes int64,
privateHostWhitelist []string,
) (*WebFetchTool, error) {
return integrationtools.NewWebFetchToolWithProxy(maxChars, proxy, format, fetchLimitBytes, privateHostWhitelist)
}
func NewWebFetchToolWithConfig(
maxChars int,
proxy string,
format string,
fetchLimitBytes int64,
privateHostWhitelist []string,
) (*WebFetchTool, error) {
return integrationtools.NewWebFetchToolWithConfig(maxChars, proxy, format, fetchLimitBytes, privateHostWhitelist)
}