Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 10 additions & 7 deletions docs/interactive-capabilities/capabilities.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"title": "OpenBitFun Playbook",
"origin": "https://playbook.openbitfun.com",
"source": "src/shared/interactive-capabilities/catalog.json",
"digest": "6ae2eeaa19e6342f9dcf7ff33b7c0fa94547ee1c02fc1835f6f4471caab6fbb3",
"digest": "0917ed10617abd8b8c0aa33e872ae7f43f849df66d8181e62390d3ae42f94335",
"ownerDigest": "3cc6d7d869b2c90c2161494a854b5ff7eb72ea69a1a28e40ccd42065fb3382e2",
"searchAcceptance": [
{
Expand Down Expand Up @@ -31228,6 +31228,7 @@
"Exa",
"Tavily",
"DeepSeek",
"Keenable",
"搜索服务",
"API Key",
"自定义端点"
Expand All @@ -31238,6 +31239,7 @@
"Exa",
"Tavily",
"DeepSeek",
"Keenable",
"search provider",
"API key",
"custom endpoint"
Expand All @@ -31255,13 +31257,13 @@
"items": [
{
"id": "provider",
"titleZh": "在免费 Exa MCP、Exa Search API、Tavily、DeepSeek 与 OpenBitFun Search HTTP Protocol 之间选择运行时服务",
"titleEn": "Choose free Exa MCP, Exa Search API, Tavily, DeepSeek, or OpenBitFun Search HTTP Protocol as the runtime provider",
"titleZh": "在免费 Exa MCP、Exa Search API、Tavily、DeepSeek、Keenable 与 OpenBitFun Search HTTP Protocol 之间选择运行时服务",
"titleEn": "Choose free Exa MCP, Exa Search API, Tavily, DeepSeek, Keenable, or OpenBitFun Search HTTP Protocol as the runtime provider",
"control": {
"kind": "open",
"reasonCode": "unstructuredInteraction",
"reasonZh": "“在免费 Exa MCP、Exa Search API、Tavily、DeepSeek 与 OpenBitFun Search HTTP Protocol 之间选择运行时服务”与各服务的配置状态相关,目前没有一个能安全完成选择、检查和保存整个流程的单一结构化 Command;智能体会打开精确设置入口,由用户确认配置。",
"reasonEn": "“Choose free Exa MCP, Exa Search API, Tavily, DeepSeek, or OpenBitFun Search HTTP Protocol as the runtime provider” depends on provider-specific configuration state, and no single structured Command can safely complete selection, validation, and saving; the Agent opens the exact settings entry for user confirmation."
"reasonZh": "“在免费 Exa MCP、Exa Search API、Tavily、DeepSeek、Keenable 与 OpenBitFun Search HTTP Protocol 之间选择运行时服务”与各服务的配置状态相关,目前没有一个能安全完成选择、检查和保存整个流程的单一结构化 Command;智能体会打开精确设置入口,由用户确认配置。",
"reasonEn": "“Choose free Exa MCP, Exa Search API, Tavily, DeepSeek, Keenable, or OpenBitFun Search HTTP Protocol as the runtime provider” depends on provider-specific configuration state, and no single structured Command can safely complete selection, validation, and saving; the Agent opens the exact settings entry for user confirmation."
}
},
{
Expand Down Expand Up @@ -31332,6 +31334,7 @@
"Exa",
"Tavily",
"DeepSeek",
"Keenable",
"搜索服务",
"API Key",
"自定义端点",
Expand All @@ -31345,8 +31348,8 @@
"Switch the WebSearch runtime provider",
"Store device credentials encrypted on the execution host",
"Configure and inspect OpenBitFun Search HTTP Protocol v1",
"在免费 Exa MCP、Exa Search API、Tavily、DeepSeek 与 OpenBitFun Search HTTP Protocol 之间选择运行时服务",
"Choose free Exa MCP, Exa Search API, Tavily, DeepSeek, or OpenBitFun Search HTTP Protocol as the runtime provider",
"在免费 Exa MCP、Exa Search API、Tavily、DeepSeek、Keenable 与 OpenBitFun Search HTTP Protocol 之间选择运行时服务",
"Choose free Exa MCP, Exa Search API, Tavily, DeepSeek, Keenable, or OpenBitFun Search HTTP Protocol as the runtime provider",
"为 OpenBitFun Search HTTP Protocol 配置端点、认证方式和受限凭据 Header",
"Configure the endpoint, authentication mode, and restricted credential header for OpenBitFun Search HTTP Protocol",
"查看当前执行主机的凭据状态,并保存、替换或清除 API Key/Secret",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ Choose the search provider used by the WebSearch tool at runtime and configure c

## 完整功能清单 / Everything included

- **智能体可定位入口,需交互完成 / Agent opens; interaction required** · 在免费 Exa MCP、Exa Search API、Tavily、DeepSeek 与 OpenBitFun Search HTTP Protocol 之间选择运行时服务
- Choose free Exa MCP, Exa Search API, Tavily, DeepSeek, or OpenBitFun Search HTTP Protocol as the runtime provider
- **智能体可定位入口,需交互完成 / Agent opens; interaction required** · 在免费 Exa MCP、Exa Search API、Tavily、DeepSeek、Keenable 与 OpenBitFun Search HTTP Protocol 之间选择运行时服务
- Choose free Exa MCP, Exa Search API, Tavily, DeepSeek, Keenable, or OpenBitFun Search HTTP Protocol as the runtime provider
- **智能体可定位入口,需交互完成 / Agent opens; interaction required** · 为 OpenBitFun Search HTTP Protocol 配置端点、认证方式和受限凭据 Header
- Configure the endpoint, authentication mode, and restricted credential header for OpenBitFun Search HTTP Protocol
- **智能体可定位入口,需交互完成 / Agent opens; interaction required** · 查看当前执行主机的凭据状态,并保存、替换或清除 API Key/Secret
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"schemaVersion": 1,
"generatedFrom": "src/shared/interactive-capabilities/catalog.json",
"catalogDigest": "6ae2eeaa19e6342f9dcf7ff33b7c0fa94547ee1c02fc1835f6f4471caab6fbb3",
"catalogDigest": "0917ed10617abd8b8c0aa33e872ae7f43f849df66d8181e62390d3ae42f94335",
"count": 205,
"reasonCounts": {
"externalAuth": 4,
Expand Down Expand Up @@ -3166,11 +3166,11 @@
{
"capabilityId": "setting.tools.web-search",
"itemId": "provider",
"titleZh": "在免费 Exa MCP、Exa Search API、Tavily、DeepSeek 与 OpenBitFun Search HTTP Protocol 之间选择运行时服务",
"titleEn": "Choose free Exa MCP, Exa Search API, Tavily, DeepSeek, or OpenBitFun Search HTTP Protocol as the runtime provider",
"titleZh": "在免费 Exa MCP、Exa Search API、Tavily、DeepSeek、Keenable 与 OpenBitFun Search HTTP Protocol 之间选择运行时服务",
"titleEn": "Choose free Exa MCP, Exa Search API, Tavily, DeepSeek, Keenable, or OpenBitFun Search HTTP Protocol as the runtime provider",
"reasonCode": "unstructuredInteraction",
"reasonZh": "“在免费 Exa MCP、Exa Search API、Tavily、DeepSeek 与 OpenBitFun Search HTTP Protocol 之间选择运行时服务”与各服务的配置状态相关,目前没有一个能安全完成选择、检查和保存整个流程的单一结构化 Command;智能体会打开精确设置入口,由用户确认配置。",
"reasonEn": "“Choose free Exa MCP, Exa Search API, Tavily, DeepSeek, or OpenBitFun Search HTTP Protocol as the runtime provider” depends on provider-specific configuration state, and no single structured Command can safely complete selection, validation, and saving; the Agent opens the exact settings entry for user confirmation.",
"reasonZh": "“在免费 Exa MCP、Exa Search API、Tavily、DeepSeek、Keenable 与 OpenBitFun Search HTTP Protocol 之间选择运行时服务”与各服务的配置状态相关,目前没有一个能安全完成选择、检查和保存整个流程的单一结构化 Command;智能体会打开精确设置入口,由用户确认配置。",
"reasonEn": "“Choose free Exa MCP, Exa Search API, Tavily, DeepSeek, Keenable, or OpenBitFun Search HTTP Protocol as the runtime provider” depends on provider-specific configuration state, and no single structured Command can safely complete selection, validation, and saving; the Agent opens the exact settings entry for user confirmation.",
"presentationTarget": {
"kind": "settings",
"pageId": "tools.webSearch"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"schemaVersion": 2,
"generatedFrom": "src/shared/interactive-capabilities/catalog.json",
"catalogDigest": "6ae2eeaa19e6342f9dcf7ff33b7c0fa94547ee1c02fc1835f6f4471caab6fbb3",
"catalogDigest": "0917ed10617abd8b8c0aa33e872ae7f43f849df66d8181e62390d3ae42f94335",
"commandCount": 709,
"coverage": {
"commandCount": 709,
Expand Down
69 changes: 59 additions & 10 deletions src/crates/assembly/core/src/service/web_search.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ use openbitfun_runtime_ports::{
};
use openbitfun_services_core::credential_vault::CredentialVault;
use openbitfun_services_integrations::web_tools::{
DeepSeekSearchProvider, ExaSearchApiProvider, FreeExaMcpProvider, OpenBitFunSearchHttpAuth,
OpenBitFunSearchHttpProvider, TavilySearchProvider,
DeepSeekSearchProvider, ExaSearchApiProvider, FreeExaMcpProvider, KeenableSearchProvider,
OpenBitFunSearchHttpAuth, OpenBitFunSearchHttpProvider, TavilySearchProvider,
};
use serde::{Deserialize, Serialize};
use std::path::Path;
Expand Down Expand Up @@ -97,19 +97,28 @@ fn credential_entry_id(credential_id: &str) -> OpenBitFunResult<&str> {
}

async fn read_credential(vault: &CredentialVault, credential_id: &str) -> OpenBitFunResult<String> {
let credential_id = credential_entry_id(credential_id)?;
let bytes = vault
.get(credential_id)
.await
.map_err(|error| {
OpenBitFunError::config(format!("Failed to read WebSearch credential: {error}"))
})?
read_optional_credential(vault, credential_id)
.await?
.ok_or_else(|| {
OpenBitFunError::config(
"WebSearch credential is not configured on this device".to_string(),
)
})?;
})
}

async fn read_optional_credential(
vault: &CredentialVault,
credential_id: &str,
) -> OpenBitFunResult<Option<String>> {
let credential_id = credential_entry_id(credential_id)?;
let Some(bytes) = vault.get(credential_id).await.map_err(|error| {
OpenBitFunError::config(format!("Failed to read WebSearch credential: {error}"))
})?
else {
return Ok(None);
};
String::from_utf8(bytes)
.map(Some)
.map_err(|_| OpenBitFunError::config("WebSearch credential is not valid UTF-8".to_string()))
}

Expand Down Expand Up @@ -143,6 +152,14 @@ async fn resolve_provider(config: &WebSearchConfig) -> Arc<dyn WebSearchProvider
read_credential(&vault, &config.providers.deepseek.credential_id).await?;
Ok(Arc::new(DeepSeekSearchProvider::new(secret)) as Arc<dyn WebSearchProvider>)
}
WebSearchProviderId::KEENABLE => {
// Keenable works without a key; a saved key only lifts rate limits.
let vault = credential_vault()?;
let api_key =
read_optional_credential(&vault, &config.providers.keenable.credential_id)
.await?;
Ok(Arc::new(KeenableSearchProvider::new(api_key)) as Arc<dyn WebSearchProvider>)
}
WebSearchProviderId::OPENBITFUN_SEARCH_HTTP => {
let http = &config.providers.openbitfun_search_http;
if http.endpoint.trim().is_empty() {
Expand Down Expand Up @@ -249,6 +266,7 @@ fn credential_id_for_provider<'a>(
}
WebSearchProviderId::TAVILY => Ok(config.providers.tavily.credential_id.as_str()),
WebSearchProviderId::DEEPSEEK => Ok(config.providers.deepseek.credential_id.as_str()),
WebSearchProviderId::KEENABLE => Ok(config.providers.keenable.credential_id.as_str()),
WebSearchProviderId::OPENBITFUN_SEARCH_HTTP => {
if matches!(
config.providers.openbitfun_search_http.auth.mode.trim(),
Expand Down Expand Up @@ -487,6 +505,7 @@ mod tests {
for provider in [
WebSearchProviderId::EXA_SEARCH_API,
WebSearchProviderId::DEEPSEEK,
WebSearchProviderId::KEENABLE,
] {
let credential_id =
credential_id_for_provider(&config, provider).expect("Search API credential id");
Expand Down Expand Up @@ -521,6 +540,36 @@ mod tests {
}
}

#[tokio::test]
async fn optional_credential_is_absent_until_saved() {
std::fs::create_dir_all("E:/tmp").expect("E:/tmp should be available for tests");
let directory = Builder::new()
.prefix("openbitfun-web-search-vault-optional-")
.tempdir_in("E:/tmp")
.expect("create WebSearch test directory");
let vault = credential_vault_in(directory.path());
let config = WebSearchConfig::default();
let credential_id = credential_id_for_provider(&config, WebSearchProviderId::KEENABLE)
.expect("Keenable credential id");

assert_eq!(
read_optional_credential(&vault, credential_id)
.await
.expect("read absent optional credential"),
None
);
store_credential(&vault, credential_id, "keenable-test-key")
.await
.expect("save credential");
assert_eq!(
read_optional_credential(&vault, credential_id)
.await
.expect("read saved optional credential")
.as_deref(),
Some("keenable-test-key")
);
}

#[tokio::test]
async fn credential_helpers_normalize_entry_id_without_changing_secret() {
std::fs::create_dir_all("E:/tmp").expect("E:/tmp should be available for tests");
Expand Down
45 changes: 45 additions & 0 deletions src/crates/contracts/config-contracts/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1396,6 +1396,10 @@ fn default_deepseek_credential_id() -> String {
"deepseek-search-api".to_string()
}

fn default_keenable_credential_id() -> String {
"keenable-search-api".to_string()
}

fn default_openbitfun_search_http_credential_id() -> String {
"openbitfun-search-http".to_string()
}
Expand Down Expand Up @@ -1430,6 +1434,7 @@ pub struct WebSearchProviderConfigs {
pub exa_search_api: WebSearchCredentialProviderConfig,
pub tavily: WebSearchCredentialProviderConfig,
pub deepseek: WebSearchCredentialProviderConfig,
pub keenable: WebSearchCredentialProviderConfig,
pub openbitfun_search_http: OpenBitFunSearchHttpConfig,
#[serde(flatten)]
pub unknown: serde_json::Map<String, serde_json::Value>,
Expand All @@ -1450,6 +1455,10 @@ impl Default for WebSearchProviderConfigs {
credential_id: default_deepseek_credential_id(),
unknown: serde_json::Map::new(),
},
keenable: WebSearchCredentialProviderConfig {
credential_id: default_keenable_credential_id(),
unknown: serde_json::Map::new(),
},
openbitfun_search_http: OpenBitFunSearchHttpConfig::default(),
unknown: serde_json::Map::new(),
}
Expand Down Expand Up @@ -4560,6 +4569,10 @@ mod tests {
config.web_search.providers.deepseek.credential_id,
"deepseek-search-api"
);
assert_eq!(
config.web_search.providers.keenable.credential_id,
"keenable-search-api"
);
assert_eq!(
config.web_search.providers.exa_search_api.credential_id,
"exa-search-api"
Expand Down Expand Up @@ -4598,6 +4611,38 @@ mod tests {
assert_eq!(restored, config);
}

#[test]
fn web_search_keenable_config_preserves_legacy_payload_and_unknown_options() {
let legacy = serde_json::json!({
"provider": "deepseek",
"providers": {"deepseek": {"credentialId": "existing-deepseek"}},
"selectionRevision": 3
});
let mut config: WebSearchConfig = serde_json::from_value(legacy.clone()).unwrap();
assert_eq!(
config.providers.keenable.credential_id,
"keenable-search-api"
);
let round_trip = serde_json::to_value(&config).unwrap();
assert_eq!(round_trip["provider"], legacy["provider"]);
assert_eq!(
round_trip["providers"]["deepseek"],
legacy["providers"]["deepseek"]
);
assert_eq!(round_trip["selectionRevision"], legacy["selectionRevision"]);

config.provider = "keenable".to_string();
config.providers.keenable.credential_id = "custom-keenable-ref".to_string();
config
.providers
.keenable
.unknown
.insert("futureOption".to_string(), serde_json::json!(true));
let restored: WebSearchConfig =
serde_json::from_value(serde_json::to_value(&config).unwrap()).unwrap();
assert_eq!(restored, config);
}

#[test]
fn web_search_config_preserves_unknown_provider_and_fields() {
let config: WebSearchConfig = serde_json::from_value(serde_json::json!({
Expand Down
Loading