mirror of
https://github.com/outbackdingo/optimclaw.git
synced 2026-08-31 00:29:24 +00:00
Merge branch 'nearai:staging' into staging
This commit is contained in:
@@ -34,6 +34,8 @@ pub struct Capabilities {
|
||||
pub secrets: Option<SecretsCapability>,
|
||||
/// Webhook authentication and signature verification.
|
||||
pub webhook: Option<WebhookCapability>,
|
||||
/// Arbitrary websocket configuration preserved from capabilities JSON.
|
||||
pub websocket: Option<serde_json::Value>,
|
||||
}
|
||||
|
||||
impl Capabilities {
|
||||
@@ -341,6 +343,7 @@ mod tests {
|
||||
assert!(caps.tool_invoke.is_none());
|
||||
assert!(caps.secrets.is_none());
|
||||
assert!(caps.webhook.is_none());
|
||||
assert!(caps.websocket.is_none());
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -75,6 +75,10 @@ pub struct CapabilitiesFile {
|
||||
#[serde(default)]
|
||||
pub webhook: Option<WebhookCapabilitySchema>,
|
||||
|
||||
/// Arbitrary websocket configuration preserved for runtime consumers.
|
||||
#[serde(default)]
|
||||
pub websocket: Option<serde_json::Value>,
|
||||
|
||||
/// Authentication setup instructions.
|
||||
/// Used by `optimclaw config` to guide users through auth setup.
|
||||
#[serde(default)]
|
||||
@@ -155,6 +159,7 @@ impl CapabilitiesFile {
|
||||
self.tool_invoke = self.tool_invoke.or(inner.tool_invoke);
|
||||
self.workspace = self.workspace.or(inner.workspace);
|
||||
self.webhook = self.webhook.or(inner.webhook);
|
||||
self.websocket = self.websocket.or(inner.websocket);
|
||||
self.auth = self.auth.or(inner.auth);
|
||||
self.setup = self.setup.or(inner.setup);
|
||||
}
|
||||
@@ -250,6 +255,8 @@ impl CapabilitiesFile {
|
||||
caps.webhook = Some(webhook.to_webhook_capability());
|
||||
}
|
||||
|
||||
caps.websocket = self.websocket.clone();
|
||||
|
||||
caps
|
||||
}
|
||||
}
|
||||
@@ -745,6 +752,8 @@ fn default_tool_setup_field_input_type() -> ToolSetupFieldInputType {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use serde_json::json;
|
||||
|
||||
use crate::tools::wasm::capabilities_schema::{CapabilitiesFile, CredentialLocationSchema};
|
||||
|
||||
#[test]
|
||||
@@ -1402,6 +1411,48 @@ mod tests {
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_discord_websocket_config_preserved_in_runtime_capabilities() {
|
||||
let json = r#"{
|
||||
"capabilities": {
|
||||
"http": {
|
||||
"allowlist": [{ "host": "discord.com", "path_prefix": "/api/v10" }]
|
||||
},
|
||||
"websocket": {
|
||||
"url": "wss://gateway.discord.gg/?v=10&encoding=json",
|
||||
"connect_on_start": true,
|
||||
"identify": {
|
||||
"intents": 513,
|
||||
"properties": {
|
||||
"os": "linux",
|
||||
"browser": "ironclaw",
|
||||
"device": "ironclaw"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}"#;
|
||||
|
||||
let file = CapabilitiesFile::from_json(json).unwrap();
|
||||
let caps = file.to_capabilities();
|
||||
|
||||
assert_eq!(
|
||||
caps.websocket,
|
||||
Some(json!({
|
||||
"url": "wss://gateway.discord.gg/?v=10&encoding=json",
|
||||
"connect_on_start": true,
|
||||
"identify": {
|
||||
"intents": 513,
|
||||
"properties": {
|
||||
"os": "linux",
|
||||
"browser": "ironclaw",
|
||||
"device": "ironclaw"
|
||||
}
|
||||
}
|
||||
}))
|
||||
);
|
||||
}
|
||||
|
||||
// ── Tool description ────────────────────────────────────────────────
|
||||
|
||||
#[test]
|
||||
|
||||
Reference in New Issue
Block a user