open_agent_id/types.rs
1//! Shared types used across the SDK.
2
3use serde::{Deserialize, Serialize};
4
5/// Public information about a registered agent, as returned by the registry.
6#[derive(Debug, Clone, Serialize, Deserialize)]
7pub struct AgentInfo {
8 /// The agent's DID (`did:oaid:{chain}:{address}`).
9 pub did: String,
10 /// Human-readable display name.
11 #[serde(default)]
12 pub name: Option<String>,
13 /// Base64url-encoded Ed25519 public key.
14 pub public_key: String,
15 /// The owner wallet address.
16 pub wallet_address: String,
17 /// The agent's contract address.
18 pub agent_address: String,
19 /// The chain identifier.
20 pub chain: String,
21 /// Optional list of capabilities.
22 #[serde(default)]
23 pub capabilities: Vec<String>,
24 /// Optional platform metadata.
25 #[serde(default)]
26 pub platform: Option<String>,
27 /// Optional inbox endpoint URL.
28 #[serde(default)]
29 pub endpoint: Option<String>,
30 /// Endpoint type: `"http"`, `"ws"`, or `"registry"`.
31 #[serde(default)]
32 pub endpoint_type: Option<String>,
33 /// Chain anchoring status: `"pending"`, `"submitted"`, or `"anchored"`.
34 pub chain_status: String,
35 /// Whether the agent wallet contract has been deployed.
36 #[serde(default)]
37 pub wallet_deployed: bool,
38 /// Nonce (key rotation counter).
39 #[serde(default)]
40 pub nonce: i64,
41 /// On-chain transaction hash, if submitted or anchored.
42 #[serde(default)]
43 pub chain_tx_hash: Option<String>,
44 /// Block number at which the agent was anchored on-chain.
45 #[serde(default)]
46 pub chain_anchor_block: Option<i64>,
47 /// Number of block confirmations since anchoring.
48 #[serde(default)]
49 pub chain_confirmations: i32,
50 /// Credit score.
51 #[serde(default)]
52 pub credit_score: i32,
53 /// DID of the referring agent, if any.
54 #[serde(default)]
55 pub referred_by: Option<String>,
56 /// Creation timestamp (ISO 8601).
57 pub created_at: String,
58 /// Last update timestamp (ISO 8601).
59 pub updated_at: String,
60}
61
62/// Response from `GET /v1/agents` (list agents).
63#[derive(Debug, Clone, Deserialize)]
64pub struct ListAgentsResponse {
65 /// The list of agents.
66 pub agents: Vec<AgentInfo>,
67 /// Cursor for the next page, if any.
68 pub next_cursor: Option<String>,
69}
70
71/// Credit score information for an agent.
72#[derive(Debug, Clone, Serialize, Deserialize)]
73pub struct CreditInfo {
74 /// The agent's DID.
75 pub did: String,
76 /// Numeric credit score.
77 pub credit_score: i32,
78 /// Credit level (e.g. `"standard"`).
79 pub level: String,
80 /// Whether the agent is verified.
81 pub verified: bool,
82 /// Whether the agent is flagged.
83 pub flagged: bool,
84 /// Number of currently active reports (12-month window).
85 pub reported_1y: i64,
86 /// Total lifetime reports.
87 pub reported_total: i64,
88 /// Number of active verified referrals (12-month window).
89 #[serde(default)]
90 pub referrals_1y: i64,
91 /// Total lifetime referrals.
92 #[serde(default)]
93 pub referrals_total: i64,
94 #[serde(default)]
95 pub reports_submitted: i64,
96 #[serde(default)]
97 /// Registration timestamp (ISO 8601).
98 pub registered_at: String,
99}
100
101/// Request body for registering a new agent.
102#[derive(Debug, Clone, Serialize)]
103pub struct RegistrationRequest {
104 /// Human-readable display name.
105 #[serde(skip_serializing_if = "Option::is_none")]
106 pub name: Option<String>,
107 /// Optional list of capabilities.
108 #[serde(skip_serializing_if = "Option::is_none")]
109 pub capabilities: Option<Vec<String>>,
110 /// Base64url-encoded Ed25519 public key.
111 pub public_key: String,
112}
113
114/// Response from the registration endpoint.
115#[derive(Debug, Clone, Deserialize)]
116pub struct RegistrationResponse {
117 /// The newly assigned DID.
118 pub did: String,
119 /// The computed agent contract address.
120 pub agent_address: String,
121 /// Base64url-encoded Ed25519 public key.
122 pub public_key: String,
123 /// Chain anchoring status.
124 pub chain_status: String,
125 /// Creation timestamp.
126 pub created_at: String,
127}
128
129/// Challenge returned by `POST /v1/auth/challenge`.
130#[derive(Debug, Clone, Deserialize)]
131pub struct Challenge {
132 /// Unique identifier for this challenge.
133 pub challenge_id: String,
134 /// Human-readable text to sign with the wallet.
135 pub challenge: String,
136}
137
138/// Request body for `POST /v1/auth/wallet`.
139#[derive(Debug, Clone, Serialize)]
140pub struct WalletAuthRequest {
141 /// The wallet address (checksummed or lowercase).
142 pub wallet_address: String,
143 /// The challenge ID from the challenge endpoint.
144 pub challenge_id: String,
145 /// The wallet's signature of the challenge text.
146 pub signature: String,
147}
148
149/// Response from `POST /v1/auth/wallet`.
150#[derive(Debug, Clone, Deserialize)]
151pub struct WalletAuthResponse {
152 /// The bearer token (`oaid_...`).
153 pub token: String,
154}
155
156/// Request body for `POST /v1/verify`.
157#[derive(Debug, Clone, Serialize)]
158pub struct VerifyRequest {
159 /// The domain: `"oaid-http/v1"` or `"oaid-msg/v1"`.
160 pub domain: String,
161 /// The canonical payload that was signed.
162 pub payload: String,
163 /// Base64url-encoded Ed25519 signature.
164 pub signature: String,
165 /// The signer's DID.
166 pub did: String,
167}
168
169/// Response from `POST /v1/verify`.
170#[derive(Debug, Clone, Deserialize)]
171pub struct VerifyResponse {
172 /// Whether the signature is valid.
173 pub valid: bool,
174}
175
176/// Request body for `PATCH /v1/agents/{did}` (update agent).
177#[derive(Debug, Clone, Default, Serialize)]
178pub struct UpdateAgentRequest {
179 /// Human-readable display name.
180 #[serde(skip_serializing_if = "Option::is_none")]
181 pub name: Option<String>,
182 /// Inbox endpoint URL.
183 #[serde(skip_serializing_if = "Option::is_none")]
184 pub endpoint: Option<String>,
185 /// Endpoint type: `"http"`, `"ws"`, or `"registry"`.
186 #[serde(skip_serializing_if = "Option::is_none")]
187 pub endpoint_type: Option<String>,
188 /// List of capabilities.
189 #[serde(skip_serializing_if = "Option::is_none")]
190 pub capabilities: Option<Vec<String>>,
191 /// Platform metadata.
192 #[serde(skip_serializing_if = "Option::is_none")]
193 pub platform: Option<String>,
194}
195
196/// Request body for `PUT /v1/agents/{did}/key` (key rotation).
197#[derive(Debug, Clone, Serialize)]
198pub struct RotateKeyRequest {
199 /// The new base64url-encoded Ed25519 public key.
200 pub public_key: String,
201}