feat(web_search): wire the opt-in Keenable backend

This commit is contained in:
BaaRai
2026-11-17 17:22:35 +01:00
committed by BaaRai
parent 0ec264ddeb
commit b452b13989
14 changed files with 147 additions and 51 deletions
+2
View File
@@ -143,6 +143,8 @@ func (c *ChatAgent) Chat(ctx context.Context, agentKey, sessionID, message strin
WebSearchBackend: ws.Backend,
BraveSearchAPIKey: ws.BraveKey,
TavilySearchAPIKey: ws.TavilyKey,
KeenableSearchAPIKey: ws.KeenableKey,
KeenableSearchTitle: KeenableSearchTitle,
DeepSeekSearchBaseURL: ws.DeepSeekBaseURL,
DeepSeekSearchAPIKey: ws.DeepSeekAPIKey,
DeepSeekSearchModel: ws.DeepSeekModel,
+2
View File
@@ -148,6 +148,8 @@ func (m *MainAgent) Chat(ctx context.Context, taskID int64, mainSeg int, as *db.
WebSearchBackend: m.webSearch.Backend,
BraveSearchAPIKey: m.webSearch.BraveKey,
TavilySearchAPIKey: m.webSearch.TavilyKey,
KeenableSearchAPIKey: m.webSearch.KeenableKey,
KeenableSearchTitle: KeenableSearchTitle,
DeepSeekSearchBaseURL: m.webSearch.DeepSeekBaseURL,
DeepSeekSearchAPIKey: m.webSearch.DeepSeekAPIKey,
DeepSeekSearchModel: m.webSearch.DeepSeekModel,
+2
View File
@@ -541,6 +541,8 @@ func (p *Planner) Plan(ctx context.Context, taskID int64, as *db.AssetStore, ts
WebSearchBackend: p.webSearch.Backend,
BraveSearchAPIKey: p.webSearch.BraveKey,
TavilySearchAPIKey: p.webSearch.TavilyKey,
KeenableSearchAPIKey: p.webSearch.KeenableKey,
KeenableSearchTitle: KeenableSearchTitle,
DeepSeekSearchBaseURL: p.webSearch.DeepSeekBaseURL,
DeepSeekSearchAPIKey: p.webSearch.DeepSeekAPIKey,
DeepSeekSearchModel: p.webSearch.DeepSeekModel,
+12 -5
View File
@@ -40,12 +40,17 @@ import (
// messages API (the web_search_20250305 server tool), so each search consumes one
// model call, and the search request is issued by DeepSeek's servers — it does NOT
// go through the local Proxy, nor into the traffic recording.
// KeenableSearchTitle is the X-Keenable-Title value ARTEX sends. Fixed in v1:
// the title identifies the calling application to the provider.
const KeenableSearchTitle = "ARTEX"
type WebSearchOpts struct {
Enabled bool
Backend string
BraveKey string
TavilyKey string
Proxy string
Enabled bool
Backend string
BraveKey string
TavilyKey string
KeenableKey string
Proxy string
// DeepSeek* comes from the currently active LLM config (only the official
// DeepSeek endpoint in anthropic format) — not configured separately; it follows
// the LLM config switch.
@@ -505,6 +510,8 @@ func (w *Worker) execute(ctx context.Context, name string, taskID int64, as *db.
WebSearchBackend: w.webSearch.Backend,
BraveSearchAPIKey: w.webSearch.BraveKey,
TavilySearchAPIKey: w.webSearch.TavilyKey,
KeenableSearchAPIKey: w.webSearch.KeenableKey,
KeenableSearchTitle: KeenableSearchTitle,
DeepSeekSearchBaseURL: w.webSearch.DeepSeekBaseURL,
DeepSeekSearchAPIKey: w.webSearch.DeepSeekAPIKey,
DeepSeekSearchModel: w.webSearch.DeepSeekModel,
+1 -1
View File
@@ -95,7 +95,7 @@ var (
// secretSettingKeys are the settings stored encrypted, AAD "settings.<key>".
// Every other setting stays in clear.
var secretSettingKeys = []string{"brave_search_api_key", "tavily_search_api_key", "web_search_proxy", "global_proxy"}
var secretSettingKeys = []string{"brave_search_api_key", "tavily_search_api_key", "keenable_search_api_key", "web_search_proxy", "global_proxy"}
func secretSettingColumns() []secretColumn {
out := make([]secretColumn, 0, len(secretSettingKeys))
+8 -7
View File
@@ -56,19 +56,20 @@ func TestSecretBoxCrypto(t *testing.T) {
type secretRows struct{ llm, mcp, cred, ch, task int64 }
var plainSecrets = []string{"sk-plain-llm", "mcp-plain-tok", "plain-pass", "hook-plain-secret", "llmproxy-plain-pass",
"brave-plain", "tavily-plain", "wsproxy-plain-pass", "gproxy-plain-pass"}
"brave-plain", "tavily-plain", "keenable-plain", "wsproxy-plain-pass", "gproxy-plain-pass"}
// secretSettingValues are the four secret settings written by the fixture.
// secretSettingValues are the five secret settings written by the fixture.
var secretSettingValues = map[string]string{
"brave_search_api_key": "brave-plain",
"tavily_search_api_key": "tavily-plain",
"web_search_proxy": "socks5://u:wsproxy-plain-pass@ws.example:1080",
"global_proxy": "http://u:gproxy-plain-pass@gp.example:3128",
"brave_search_api_key": "brave-plain",
"tavily_search_api_key": "tavily-plain",
"keenable_search_api_key": "keenable-plain",
"web_search_proxy": "socks5://u:wsproxy-plain-pass@ws.example:1080",
"global_proxy": "http://u:gproxy-plain-pass@gp.example:3128",
}
const llmProxyPlain = "http://u:llmproxy-plain-pass@llm-proxy.example:3128"
const deleteSecretSettings = `DELETE FROM settings WHERE key IN ('brave_search_api_key','tavily_search_api_key','web_search_proxy','global_proxy')`
const deleteSecretSettings = `DELETE FROM settings WHERE key IN ('brave_search_api_key','tavily_search_api_key','keenable_search_api_key','web_search_proxy','global_proxy')`
// secretFixture writes one secret to each location, through the db API or, for
// a legacy database, as raw plaintext SQL.
+30 -13
View File
@@ -277,12 +277,14 @@ type Manager struct {
active string
trafficOn bool // traffic capture switch (off by default; settings.traffic_capture)
llmRecOn bool // LLM recording switch (off by default; settings.llm_record)
// Web search switch and source (off by default; settings.web_search_*). brave-free needs braveKey; tavily needs tavilyKey.
// Web search switch and source (off by default; settings.web_search_*). brave-free needs braveKey; tavily needs tavilyKey;
// keenable works keyless or with keenableKey.
// webSearchProxy is a separate egress proxy (http/https/socks5), unrelated to the MITM proxy that records traffic.
webSearchOn bool
webSearchBackend string
braveKey string
tavilyKey string
keenableKey string
webSearchProxy string
// globalProxy is the egress proxy all target traffic routes through
// (http/https/socks5, optional user:pass). Empty = direct. When traffic
@@ -299,6 +301,7 @@ const (
settingWebSearchBackend = "web_search_backend"
settingBraveKey = "brave_search_api_key"
settingTavilyKey = "tavily_search_api_key"
settingKeenableKey = "keenable_search_api_key"
settingWebSearchProxy = "web_search_proxy"
// settingGlobalProxy is the global egress proxy for all target traffic
// (http/https/socks5). Empty = direct. Distinct from web_search_proxy (which
@@ -483,6 +486,9 @@ func NewManager(dir, proxyAddr string) (*Manager, error) {
if v, ok, _ := pg.GetSetting(settingTavilyKey); ok {
m.tavilyKey = v
}
if v, ok, _ := pg.GetSetting(settingKeenableKey); ok {
m.keenableKey = v
}
if v, ok, _ := pg.GetSetting(settingWebSearchProxy); ok {
m.webSearchProxy = v
}
@@ -594,30 +600,32 @@ func (m *Manager) SetLLMPoolBindFallback(on bool) error {
}
// WebSearch returns the current web-search config: whether it is enabled, the
// backend ("ddgs" | "brave-free" | "tavily"), the Brave API key, the Tavily API
// key (each empty unless set), and the dedicated egress proxy (empty = direct).
func (m *Manager) WebSearch() (on bool, backend, braveKey, tavilyKey, proxy string) {
// backend ("ddgs" | "brave-free" | "tavily" | "keenable" | "deepseek"), the
// Brave, Tavily and Keenable API keys (each empty unless set), and the
// dedicated egress proxy (empty = direct). The Keenable key is optional: empty
// selects the keyless public endpoint.
func (m *Manager) WebSearch() (on bool, backend, braveKey, tavilyKey, keenableKey, proxy string) {
m.mu.RLock()
defer m.mu.RUnlock()
backend = m.webSearchBackend
if backend == "" {
backend = defaultWebSearchBackend
}
return m.webSearchOn, backend, m.braveKey, m.tavilyKey, m.webSearchProxy
return m.webSearchOn, backend, m.braveKey, m.tavilyKey, m.keenableKey, m.webSearchProxy
}
// WebSearchOpts returns the config as the agent-package struct the server pushes
// into each agent. Disabled when off, or when a keyed backend is selected without
// its key (so a half-configured backend never silently drops the tool at session build).
func (m *Manager) WebSearchOpts() agent.WebSearchOpts {
on, backend, braveKey, tavilyKey, proxy := m.WebSearch()
on, backend, braveKey, tavilyKey, keenableKey, proxy := m.WebSearch()
if on && backend == "brave-free" && strings.TrimSpace(braveKey) == "" {
on = false
}
if on && backend == "tavily" && strings.TrimSpace(tavilyKey) == "" {
on = false
}
o := agent.WebSearchOpts{Enabled: on, Backend: backend, BraveKey: braveKey, TavilyKey: tavilyKey, Proxy: proxy}
o := agent.WebSearchOpts{Enabled: on, Backend: backend, BraveKey: braveKey, TavilyKey: tavilyKey, KeenableKey: keenableKey, Proxy: proxy}
if backend == deepSeekWebSearchBackend {
o.DeepSeekBaseURL, o.DeepSeekAPIKey, o.DeepSeekModel = m.deepSeekSearchCreds()
}
@@ -639,11 +647,11 @@ func (m *Manager) deepSeekSearchCreds() (baseURL, apiKey, model string) {
return p.BaseURL, p.APIKey, p.Model
}
// SetWebSearch persists and applies the web-search settings. braveKey, tavilyKey, and
// proxy are each left untouched when nil (so toggling the switch doesn't wipe a saved
// key/proxy; pass a pointer to "" to clear). Callers must rebuild agents (applyLLM)
// afterwards so the settings take effect.
func (m *Manager) SetWebSearch(on bool, backend string, braveKey, tavilyKey, proxy *string) error {
// SetWebSearch persists and applies the web-search settings. braveKey, tavilyKey,
// keenableKey and proxy are each left untouched when nil (so toggling the switch
// doesn't wipe a saved key/proxy; pass a pointer to "" to clear). Callers must
// rebuild agents (applyLLM) afterwards so the settings take effect.
func (m *Manager) SetWebSearch(on bool, backend string, braveKey, tavilyKey, keenableKey, proxy *string) error {
backend = strings.TrimSpace(backend)
if backend == "" {
backend = defaultWebSearchBackend
@@ -674,6 +682,14 @@ func (m *Manager) SetWebSearch(on bool, backend string, braveKey, tavilyKey, pro
m.tavilyKey = *tavilyKey
m.mu.Unlock()
}
if keenableKey != nil {
if err := m.pg.SetSetting(settingKeenableKey, *keenableKey); err != nil {
return err
}
m.mu.Lock()
m.keenableKey = *keenableKey
m.mu.Unlock()
}
if proxy != nil {
p := strings.TrimSpace(*proxy)
if err := m.pg.SetSetting(settingWebSearchProxy, p); err != nil {
@@ -926,6 +942,7 @@ var searchBackendEndpoints = map[string]string{
"ddgs": "https://html.duckduckgo.com",
"brave-free": "https://api.search.brave.com",
"tavily": "https://api.tavily.com",
"keenable": "https://api.keenable.ai",
}
// targetGateEndpoints lists the endpoints of the platform's own services, which
@@ -939,7 +956,7 @@ func (m *Manager) targetGateEndpoints() []string {
for _, p := range profiles {
out = append(out, p.BaseURL, p.Proxy)
}
on, backend, _, _, searchProxy := m.WebSearch()
on, backend, _, _, _, searchProxy := m.WebSearch()
if on {
out = append(out, searchBackendEndpoints[backend])
}
+6 -5
View File
@@ -152,10 +152,10 @@ func TestProxySecretsAPI(t *testing.T) {
s, _, request := trafficEvidenceServer(t)
pg := s.m.PG()
t.Cleanup(func() {
pg.Exec(`DELETE FROM settings WHERE key IN ('brave_search_api_key','tavily_search_api_key','web_search_proxy','global_proxy')`)
pg.Exec(`DELETE FROM settings WHERE key IN ('brave_search_api_key','tavily_search_api_key','keenable_search_api_key','web_search_proxy','global_proxy')`)
pg.Exec(`DELETE FROM llm_profiles WHERE name='t-proxy'`)
})
secrets := []string{"brave-api-0007", "tavily-api-0008", "wsp-pass-0009", "gp-pass-0010", "llmp-pass-0011"}
secrets := []string{"brave-api-0007", "tavily-api-0008", "keenable-api-0012", "wsp-pass-0009", "gp-pass-0010", "llmp-pass-0011"}
put := func(body string) {
t.Helper()
resp := request("PUT", "/api/settings", body)
@@ -177,7 +177,7 @@ func TestProxySecretsAPI(t *testing.T) {
}
return v
}
put(`{"brave_search_api_key":"brave-api-0007","tavily_search_api_key":"tavily-api-0008",
put(`{"brave_search_api_key":"brave-api-0007","tavily_search_api_key":"tavily-api-0008","keenable_search_api_key":"keenable-api-0012",
"web_search_proxy":"socks5://u:wsp-pass-0009@ws.example:1080","global_proxy":"http://u:gp-pass-0010@gp.example:3128"}`)
var got map[string]any
resp := request("GET", "/api/settings", "")
@@ -191,9 +191,10 @@ func TestProxySecretsAPI(t *testing.T) {
t.Fatalf("proxies not masked with a presence flag: %v", got)
}
put(`{"web_search_proxy":"__masked__","global_proxy":"__masked__","brave_search_api_key":"__masked__"}`)
put(`{"web_search_proxy":"__masked__","global_proxy":"__masked__","brave_search_api_key":"__masked__","keenable_search_api_key":"__masked__"}`)
if setting("web_search_proxy") != "socks5://u:wsp-pass-0009@ws.example:1080" || setting("global_proxy") != "http://u:gp-pass-0010@gp.example:3128" ||
setting("brave_search_api_key") != "brave-api-0007" || setting("tavily_search_api_key") != "tavily-api-0008" {
setting("brave_search_api_key") != "brave-api-0007" || setting("tavily_search_api_key") != "tavily-api-0008" ||
setting("keenable_search_api_key") != "keenable-api-0012" {
t.Fatal("a masked placeholder replaced a stored secret")
}
put(`{"global_proxy":"http://gp2.example:3128","web_search_proxy":""}`)
+21 -13
View File
@@ -3599,7 +3599,7 @@ func (s *Server) getSettings(w http.ResponseWriter, r *http.Request) {
}
func (s *Server) settingsPayload() map[string]any {
on, backend, braveKey, tavilyKey, proxy := s.m.WebSearch()
on, backend, braveKey, tavilyKey, keenableKey, proxy := s.m.WebSearch()
pyStored, _, _ := s.m.pg.GetSetting(settingPythonInterp)
concOn, concLimit := s.m.ConcurrencyLimit()
if concLimit == 0 {
@@ -3614,6 +3614,7 @@ func (s *Server) settingsPayload() map[string]any {
"web_search_backend": backend,
"brave_key_set": strings.TrimSpace(braveKey) != "",
"tavily_key_set": strings.TrimSpace(tavilyKey) != "",
"keenable_key_set": strings.TrimSpace(keenableKey) != "",
"web_search_proxy": maskedSecret(proxy), // proxies may carry user:pass: masked when set, "" = direct
"web_search_proxy_set": proxy != "",
"global_proxy": maskedSecret(s.m.GlobalProxy()), // global egress proxy, masked when set, "" = direct
@@ -3687,12 +3688,14 @@ func (s *Server) putSettings(w http.ResponseWriter, r *http.Request) {
TrafficCapture *bool `json:"traffic_capture"`
AgentTrafficBinding *bool `json:"agent_traffic_binding"`
LLMRecord *bool `json:"llm_record"` // LLM recording switch (default off); takes effect immediately, no agent rebuild needed
// Web search. WebSearchEnabled/Backend toggle the tool + backend; BraveKey/TavilyKey
// are optional — omit (null) to leave a stored key untouched, send "" to clear.
// Web search. WebSearchEnabled/Backend toggle the tool + backend; BraveKey/TavilyKey/KeenableKey
// are optional — omit (null) to leave a stored key untouched, send "" to clear. The Keenable
// key is optional even when its backend is selected: empty uses the keyless public endpoint.
WebSearchEnabled *bool `json:"web_search_enabled"`
WebSearchBackend *string `json:"web_search_backend"`
BraveKey *string `json:"brave_search_api_key"`
TavilyKey *string `json:"tavily_search_api_key"`
KeenableKey *string `json:"keenable_search_api_key"`
WebSearchProxy *string `json:"web_search_proxy"` // dedicated egress proxy (http/https/socks5); null = keep, "" = clear
GlobalProxy *string `json:"global_proxy"` // global egress proxy (http/https/socks5); null = keep, "" = clear (direct)
PythonInterp *string `json:"python_interpreter"` // python interpreter path for the custom script tool
@@ -3739,7 +3742,7 @@ func (s *Server) putSettings(w http.ResponseWriter, r *http.Request) {
egress.SetProfile(noise)
}
// A masked placeholder echoed back keeps the stored secret, like null.
req.BraveKey, req.TavilyKey = keepIfMasked(req.BraveKey), keepIfMasked(req.TavilyKey)
req.BraveKey, req.TavilyKey, req.KeenableKey = keepIfMasked(req.BraveKey), keepIfMasked(req.TavilyKey), keepIfMasked(req.KeenableKey)
req.WebSearchProxy, req.GlobalProxy = keepIfMasked(req.WebSearchProxy), keepIfMasked(req.GlobalProxy)
if req.ConstraintsInjectPlanner != nil {
if err := s.m.pg.SetBool(settingConstraintsInjectPlanner, *req.ConstraintsInjectPlanner); err != nil {
@@ -3891,16 +3894,16 @@ func (s *Server) putSettings(w http.ResponseWriter, r *http.Request) {
}
changed = true // capture-off egress is baked into agents at build time → rebuild
}
if req.WebSearchEnabled != nil || req.WebSearchBackend != nil || req.BraveKey != nil || req.TavilyKey != nil || req.WebSearchProxy != nil {
if req.WebSearchEnabled != nil || req.WebSearchBackend != nil || req.BraveKey != nil || req.TavilyKey != nil || req.KeenableKey != nil || req.WebSearchProxy != nil {
// Fill unspecified fields from current state so a partial PUT doesn't reset them.
on, backend, _, _, _ := s.m.WebSearch()
on, backend, _, _, _, _ := s.m.WebSearch()
if req.WebSearchEnabled != nil {
on = *req.WebSearchEnabled
}
if req.WebSearchBackend != nil {
backend = *req.WebSearchBackend
}
if err := s.m.SetWebSearch(on, backend, req.BraveKey, req.TavilyKey, req.WebSearchProxy); err != nil {
if err := s.m.SetWebSearch(on, backend, req.BraveKey, req.TavilyKey, req.KeenableKey, req.WebSearchProxy); err != nil {
writeErr(w, 500, err.Error())
return
}
@@ -3928,17 +3931,18 @@ func (s *Server) putSettings(w http.ResponseWriter, r *http.Request) {
// not retype them. Always 200 with {ok, error?, count?, backend?}.
func (s *Server) testWebSearch(w http.ResponseWriter, r *http.Request) {
var req struct {
Backend string `json:"web_search_backend"`
Proxy string `json:"web_search_proxy"`
BraveKey string `json:"brave_search_api_key"`
TavilyKey string `json:"tavily_search_api_key"`
Backend string `json:"web_search_backend"`
Proxy string `json:"web_search_proxy"`
BraveKey string `json:"brave_search_api_key"`
TavilyKey string `json:"tavily_search_api_key"`
KeenableKey string `json:"keenable_search_api_key"`
}
// Empty body is fine — fall back entirely to the saved config below.
if err := json.NewDecoder(r.Body).Decode(&req); err != nil && err != io.EOF {
writeErr(w, 400, err.Error())
return
}
_, backend, storedBraveKey, storedTavilyKey, storedProxy := s.m.WebSearch()
_, backend, storedBraveKey, storedTavilyKey, storedKeenableKey, storedProxy := s.m.WebSearch()
if strings.TrimSpace(req.Backend) != "" {
backend = req.Backend
}
@@ -3958,7 +3962,11 @@ func (s *Server) testWebSearch(w http.ResponseWriter, r *http.Request) {
if strings.TrimSpace(req.TavilyKey) != "" {
tavilyKey = req.TavilyKey
}
cfg := actool.WebSearchConfig{Backend: backend, BraveAPIKey: braveKey, TavilyAPIKey: tavilyKey, Proxy: proxy}
keenableKey := storedKeenableKey
if strings.TrimSpace(req.KeenableKey) != "" {
keenableKey = req.KeenableKey
}
cfg := actool.WebSearchConfig{Backend: backend, BraveAPIKey: braveKey, TavilyAPIKey: tavilyKey, KeenableAPIKey: keenableKey, KeenableTitle: agent.KeenableSearchTitle, Proxy: proxy}
// Hard cap so a slow/blocked proxy can't hang the request.
wall := 30 * time.Second
// deepseek's credentials are not in the form; they come from the currently active LLM profile. Each search also runs one
+5 -5
View File
@@ -156,14 +156,14 @@ func TestTargetGateEndpointsFollowConfig(t *testing.T) {
}
}
on, backend, _, _, proxy := g.m.WebSearch()
on, backend, _, _, _, proxy := g.m.WebSearch()
globalProxy := g.m.GlobalProxy()
t.Cleanup(func() {
_ = g.m.SetWebSearch(on, backend, nil, nil, &proxy)
_ = g.m.SetWebSearch(on, backend, nil, nil, nil, &proxy)
_ = g.m.SetGlobalProxy(globalProxy)
})
searchProxy := "http://search-proxy.example.net:8118"
if err := g.m.SetWebSearch(true, "tavily", nil, nil, &searchProxy); err != nil {
if err := g.m.SetWebSearch(true, "tavily", nil, nil, nil, &searchProxy); err != nil {
t.Fatal(err)
}
if err := g.m.SetGlobalProxy("socks5://egress.example.net:1080"); err != nil {
@@ -176,7 +176,7 @@ func TestTargetGateEndpointsFollowConfig(t *testing.T) {
}
// The configuration changes: so do the exemptions.
none := ""
if err := g.m.SetWebSearch(true, "ddgs", nil, nil, &none); err != nil {
if err := g.m.SetWebSearch(true, "ddgs", nil, nil, nil, &none); err != nil {
t.Fatal(err)
}
if err := g.m.SetGlobalProxy(""); err != nil {
@@ -194,7 +194,7 @@ func TestTargetGateEndpointsFollowConfig(t *testing.T) {
}
}
// Search off: its backend is not exempt.
if err := g.m.SetWebSearch(false, "ddgs", nil, nil, nil); err != nil {
if err := g.m.SetWebSearch(false, "ddgs", nil, nil, nil, nil); err != nil {
t.Fatal(err)
}
if has("html.duckduckgo.com:443") {
@@ -27,6 +27,9 @@ export default function SystemSettingsPage() {
const [tavilyKeySet, setTavilyKeySet] = React.useState(false);
const [tavilyKeyInput, setTavilyKeyInput] = React.useState("");
const [savingTavilyKey, setSavingTavilyKey] = React.useState(false);
const [keenableKeySet, setKeenableKeySet] = React.useState(false);
const [keenableKeyInput, setKeenableKeyInput] = React.useState("");
const [savingKeenableKey, setSavingKeenableKey] = React.useState(false);
const [proxyInput, setProxyInput] = React.useState("");
const [savingProxy, setSavingProxy] = React.useState(false);
const [globalProxyInput, setGlobalProxyInput] = React.useState("");
@@ -53,6 +56,7 @@ export default function SystemSettingsPage() {
setBackend(s.web_search_backend || "ddgs");
setBraveKeySet(!!s.brave_key_set);
setTavilyKeySet(!!s.tavily_key_set);
setKeenableKeySet(!!s.keenable_key_set);
setProxyInput(s.web_search_proxy ?? "");
setGlobalProxyInput(s.global_proxy ?? "");
setPyInterp(s.python_interpreter ?? "");
@@ -208,6 +212,19 @@ export default function SystemSettingsPage() {
.finally(() => setSavingTavilyKey(false));
};
const saveKeenableKey = () => {
setSavingKeenableKey(true);
api
.setSettings({ keenable_search_api_key: keenableKeyInput })
.then((s) => {
apply(s);
setKeenableKeyInput("");
toast.success("Saved Keenable API Key");
})
.catch((e) => toast.error("Save failed: " + (e as Error).message))
.finally(() => setSavingKeenableKey(false));
};
const saveProxy = () => {
setSavingProxy(true);
api
@@ -242,6 +259,7 @@ export default function SystemSettingsPage() {
web_search_proxy: proxyInput.trim(),
brave_search_api_key: braveKeyInput,
tavily_search_api_key: tavilyKeyInput,
keenable_search_api_key: keenableKeyInput,
})
.then((r) => {
if (r.ok) toast.success(`Search test succeeded · ${r.backend} returned ${r.count} results`);
@@ -483,6 +501,7 @@ export default function SystemSettingsPage() {
<SelectItem value="ddgs">DuckDuckGo (ddgs · free, no key)</SelectItem>
<SelectItem value="brave-free">Brave (free tier · requires key)</SelectItem>
<SelectItem value="tavily">Tavily (requires key)</SelectItem>
<SelectItem value="keenable">Keenable (keyless, optional key)</SelectItem>
<SelectItem value="deepseek">DeepSeek (official)</SelectItem>
</SelectContent>
</Select>
@@ -576,6 +595,39 @@ export default function SystemSettingsPage() {
</div>
)}
{webSearch && backend === "keenable" && (
<div className="flex flex-col gap-2">
<Label htmlFor="keenable-key" className="text-sm font-normal text-muted-foreground">
Keenable Search API Key (optional)
{keenableKeySet && <span className="ml-2 text-xs text-emerald-500">Configured</span>}
</Label>
<div className="flex items-center gap-2">
<Input
id="keenable-key"
type="password"
autoComplete="off"
placeholder={keenableKeySet ? "Configured (leave empty to keep)" : "Optional: leave empty for the keyless endpoint"}
value={keenableKeyInput}
disabled={!loaded || savingKeenableKey}
onChange={(e) => setKeenableKeyInput(e.target.value)}
/>
<Button
type="button"
onClick={saveKeenableKey}
disabled={!loaded || savingKeenableKey || keenableKeyInput.trim() === ""}
>
Save
</Button>
</div>
<p className="text-muted-foreground text-xs leading-relaxed">
Queries leave this instance and go to api.keenable.ai. The request carries{" "}
<b>X-Keenable-Title: ARTEX</b> so the provider can identify the caller. With no key, the
public endpoint is rate-limited per IP; a key raises the limit, but the backend works
without one.
</p>
</div>
)}
{webSearch && (
<div className="flex flex-col gap-2">
<Label htmlFor="ws-proxy" className="text-sm font-normal text-muted-foreground">
+1
View File
@@ -875,6 +875,7 @@ export const api = {
web_search_proxy?: string;
brave_search_api_key?: string;
tavily_search_api_key?: string;
keenable_search_api_key?: string;
}) => post<{ ok: boolean; error?: string; count?: number; backend?: string }>(`/settings/web-search/test`, patch),
// ---- Vulnerability IM push ----
+1
View File
@@ -3335,6 +3335,7 @@ export const settings: Settings = {
web_search_backend: "ddgs",
brave_key_set: false,
tavily_key_set: true,
keenable_key_set: false,
web_search_proxy: "",
global_proxy: "",
python_interpreter: "/usr/bin/python3",
+4 -2
View File
@@ -977,15 +977,17 @@ export interface Settings {
traffic_capture: boolean;
agent_traffic_binding: boolean; // agents auto-bind traffic evidence, off by default; does not affect manual binding
llm_record: boolean; // LLM recording switch (off by default); when off no LLM calls are recorded
// Web search. brave_key_set / tavily_key_set reflect whether a key is stored
// Web search. brave_key_set / tavily_key_set / keenable_key_set reflect whether a key is stored
// (the values are never returned). On PUT, send the corresponding field to set/clear.
web_search_enabled: boolean;
web_search_backend: string; // "ddgs" | "brave-free" | "tavily" | "deepseek"
web_search_backend: string; // "ddgs" | "brave-free" | "tavily" | "keenable" | "deepseek"
brave_key_set: boolean;
tavily_key_set: boolean;
keenable_key_set: boolean;
// write-only: only sent on PUT to store/clear the key.
brave_search_api_key?: string;
tavily_search_api_key?: string;
keenable_search_api_key?: string;
// Dedicated egress proxy (http/https/socks5) for reaching search endpoints; unrelated to the MITM proxy that records traffic. Empty = direct.
web_search_proxy?: string;
// Global egress proxy (http/https/socks5, may carry user:pass) that all target traffic goes