mirror of
https://github.com/outbackdingo/optimclaw.git
synced 2026-08-26 15:40:18 +00:00
feat: nearai mcp for web search
This commit is contained in:
+2
-5
@@ -34,8 +34,5 @@ trace_*.json
|
||||
.claude/settings.local.json
|
||||
.worktrees/
|
||||
|
||||
# Python cache
|
||||
__pycache__/
|
||||
*.pyc
|
||||
*.pyo
|
||||
*.pyd
|
||||
# JetBrains IDE
|
||||
.idea
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
use secrecy::{ExposeSecret, SecretString};
|
||||
|
||||
use crate::llm::LlmError;
|
||||
use crate::llm::session::SessionManager;
|
||||
|
||||
/// Resolve the active NEAR AI bearer token.
|
||||
///
|
||||
/// Priority order:
|
||||
/// 1. Explicit API key from resolved config
|
||||
/// 2. Existing session token
|
||||
/// 3. Interactive session authentication
|
||||
/// 4. `NEARAI_API_KEY` from runtime environment
|
||||
pub async fn resolve_nearai_bearer_token(
|
||||
api_key: Option<&SecretString>,
|
||||
session: &SessionManager,
|
||||
) -> Result<String, LlmError> {
|
||||
if let Some(api_key) = api_key {
|
||||
return Ok(api_key.expose_secret().to_string());
|
||||
}
|
||||
|
||||
if session.has_token().await {
|
||||
let token = session.get_token().await?;
|
||||
return Ok(token.expose_secret().to_string());
|
||||
}
|
||||
|
||||
session.ensure_authenticated().await?;
|
||||
|
||||
if session.has_token().await {
|
||||
let token = session.get_token().await?;
|
||||
return Ok(token.expose_secret().to_string());
|
||||
}
|
||||
|
||||
if let Ok(key) = std::env::var("NEARAI_API_KEY")
|
||||
&& !key.is_empty()
|
||||
{
|
||||
return Ok(key);
|
||||
}
|
||||
|
||||
Err(LlmError::AuthFailed {
|
||||
provider: "nearai".to_string(),
|
||||
})
|
||||
}
|
||||
@@ -704,10 +704,9 @@ fn normalize_mcp_tool_arguments(tool_name: &str, value: serde_json::Value) -> se
|
||||
.get("ui_lang")
|
||||
.and_then(serde_json::Value::as_str)
|
||||
.map(str::trim)
|
||||
&& (ui_lang.is_empty() || !ui_lang.contains('-'))
|
||||
{
|
||||
if ui_lang.is_empty() || !ui_lang.contains('-') {
|
||||
map.remove("ui_lang");
|
||||
}
|
||||
map.remove("ui_lang");
|
||||
}
|
||||
|
||||
if let Some(freshness) = map
|
||||
|
||||
Reference in New Issue
Block a user