jamjet_worker/
executor.rs1use jamjet_state::backend::WorkItem;
5use serde_json::Value;
6
7pub type StreamEventSender = tokio::sync::mpsc::Sender<Value>;
9
10pub struct ExecutionResult {
11 pub output: Value,
12 pub state_patch: Value,
13 pub duration_ms: u64,
14 pub gen_ai_system: Option<String>,
16 pub gen_ai_model: Option<String>,
18 pub input_tokens: Option<u64>,
20 pub output_tokens: Option<u64>,
22 pub finish_reason: Option<String>,
24}
25
26#[async_trait::async_trait]
28pub trait NodeExecutor: Send + Sync {
29 async fn execute(&self, item: &WorkItem) -> Result<ExecutionResult, String>;
30
31 async fn execute_streaming(
33 &self,
34 item: &WorkItem,
35 _tx: StreamEventSender,
36 ) -> Result<ExecutionResult, String> {
37 self.execute(item).await
38 }
39}