use crate::config::configurable::Configurable;
use crate::host::plugin_handle::PluginHandle;
use crate::plugin::trigger::keyword_trigger_match;
use crate::plugin::types::{PanelInteraction, PluginContext, PluginError, Query, QueryResponse};
use async_trait::async_trait;
use std::sync::Arc;
#[async_trait]
pub trait Plugin: Configurable {
async fn init(
&self,
ctx: &PluginContext,
handle: Option<Arc<PluginHandle>>,
) -> Result<(), PluginError>;
async fn query(&self, ctx: &PluginContext, query: &Query)
-> Result<QueryResponse, PluginError>;
async fn execute_action(
&self,
ctx: &PluginContext,
action_id: &str,
payload: serde_json::Value,
) -> Result<(), PluginError>;
fn interaction_policy(&self) -> PanelInteraction {
PanelInteraction::default()
}
async fn match_query(&self, raw_query: &str, declared_trigger_keywords: &[String]) -> bool {
keyword_trigger_match(declared_trigger_keywords, raw_query).is_some()
}
}