1use serde::{Deserialize, Serialize};
2use std::collections::HashMap;
3
4#[cfg(test)]
5#[path = "types_test.rs"]
6mod types_test;
7
8pub type WorkflowId = String;
10
11pub type EventId = String;
13
14pub type EventOffset = u64;
16
17pub type JsonValue = serde_json::Value;
19
20#[derive(Debug, Clone, Serialize, Deserialize)]
22pub struct AgentInput {
23 pub data: JsonValue,
24 pub metadata: AgentInputMetadata,
25}
26
27#[derive(Debug, Clone, Serialize, Deserialize)]
28pub struct AgentInputMetadata {
29 pub step_index: usize,
30 pub previous_agent: Option<String>,
31}
32
33#[derive(Debug, Clone, Serialize, Deserialize)]
35pub struct AgentOutput {
36 pub data: JsonValue,
37 pub metadata: AgentOutputMetadata,
38}
39
40#[derive(Debug, Clone, Serialize, Deserialize)]
41pub struct AgentOutputMetadata {
42 pub agent_name: String,
43 pub execution_time_ms: u64,
44 pub tool_calls_count: usize,
45}
46
47pub type AgentResult = Result<AgentOutput, AgentError>;
49
50#[derive(Debug, Clone, Serialize, Deserialize, thiserror::Error)]
52pub enum AgentError {
53 #[error("Tool execution failed: {0}")]
54 ToolError(String),
55
56 #[error("Invalid input: {0}")]
57 InvalidInput(String),
58
59 #[error("Execution failed: {0}")]
60 ExecutionError(String),
61}
62
63#[derive(Debug, Clone, Serialize, Deserialize)]
65pub struct ToolCall {
66 pub tool_name: String,
67 pub parameters: HashMap<String, JsonValue>,
68}
69
70#[derive(Debug, Clone, Serialize, Deserialize)]
72pub struct ToolResult {
73 pub output: JsonValue,
74 pub duration_ms: u64,
75}
76
77pub type ToolExecutionResult = Result<ToolResult, ToolError>;
79
80#[derive(Debug, Clone, Serialize, Deserialize, thiserror::Error)]
82pub enum ToolError {
83 #[error("Invalid parameters: {0}")]
84 InvalidParameters(String),
85
86 #[error("Execution failed: {0}")]
87 ExecutionFailed(String),
88}