Skip to main content

jamjet_agents/
card.rs

1use serde::{Deserialize, Serialize};
2use std::collections::HashMap;
3
4/// The Agent Card — machine-readable capability manifest for a JamJet agent.
5/// Aligned with the A2A Agent Card specification.
6#[derive(Debug, Clone, Serialize, Deserialize)]
7pub struct AgentCard {
8    pub id: String,
9    pub uri: String,
10    pub name: String,
11    pub description: String,
12    pub version: String,
13    pub capabilities: AgentCapabilities,
14    pub autonomy: AutonomyLevel,
15    pub constraints: Option<AutonomyConstraints>,
16    pub auth: AuthSpec,
17    /// Latency classification for routing decisions.
18    #[serde(default, skip_serializing_if = "Option::is_none")]
19    pub latency_class: Option<LatencyClass>,
20    /// Cost tier for delegation decisions.
21    #[serde(default, skip_serializing_if = "Option::is_none")]
22    pub cost_class: Option<CostClass>,
23    /// Reasoning modes this agent supports (e.g. react, plan-and-execute, critic).
24    #[serde(default, skip_serializing_if = "Vec::is_empty")]
25    pub reasoning_modes: Vec<String>,
26    #[serde(default)]
27    pub labels: HashMap<String, String>,
28}
29
30/// Latency classification for agent routing and SLA matching.
31#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
32#[serde(rename_all = "snake_case")]
33pub enum LatencyClass {
34    /// Sub-second responses (caches, deterministic tools).
35    Realtime,
36    /// Seconds (fast model inference, simple tool calls).
37    Fast,
38    /// Tens of seconds (complex reasoning, multi-step).
39    Medium,
40    /// Minutes+ (research tasks, multi-agent delegation).
41    Slow,
42}
43
44/// Cost tier for delegation budget planning.
45#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
46#[serde(rename_all = "snake_case")]
47pub enum CostClass {
48    /// Free or negligible cost (local tools, cached responses).
49    Free,
50    /// Low cost per invocation (small models, simple APIs).
51    Low,
52    /// Moderate cost (frontier models, paid APIs).
53    Medium,
54    /// High cost (long-running agents, expensive external services).
55    High,
56}
57
58#[derive(Debug, Clone, Serialize, Deserialize)]
59pub struct AgentCapabilities {
60    pub skills: Vec<Skill>,
61    /// Supported protocols: "mcp_server", "mcp_client", "a2a"
62    pub protocols: Vec<String>,
63    /// Tools this agent exposes to others.
64    pub tools_provided: Vec<String>,
65    /// Tools this agent needs from others.
66    pub tools_consumed: Vec<String>,
67}
68
69#[derive(Debug, Clone, Serialize, Deserialize)]
70pub struct Skill {
71    pub name: String,
72    pub description: String,
73    pub input_schema: String,
74    pub output_schema: String,
75}
76
77#[derive(Debug, Clone, Default, Serialize, Deserialize)]
78#[serde(rename_all = "snake_case")]
79pub enum AutonomyLevel {
80    Deterministic,
81    #[default]
82    Guided,
83    BoundedAutonomous,
84    FullyAutonomous,
85}
86
87#[derive(Debug, Clone, Serialize, Deserialize)]
88pub struct AutonomyConstraints {
89    pub max_iterations: Option<u32>,
90    pub max_tool_calls: Option<u32>,
91    pub token_budget: Option<u64>,
92    pub cost_budget_usd: Option<f64>,
93    /// Glob patterns for allowed tools (e.g. "search_*")
94    pub allowed_tools: Vec<String>,
95    /// Glob patterns for blocked tools (e.g. "delete_*")
96    pub blocked_tools: Vec<String>,
97    /// Agent ids this agent is allowed to delegate to.
98    pub allowed_delegations: Vec<String>,
99    /// Operations that require explicit approval before execution.
100    pub require_approval_for: Vec<String>,
101    pub time_budget_secs: Option<u64>,
102}
103
104#[derive(Debug, Clone, Serialize, Deserialize)]
105#[serde(tag = "type", rename_all = "snake_case")]
106pub enum AuthSpec {
107    BearerToken { scopes: Vec<String> },
108    ApiKey { header: String },
109    None,
110}