@@ -91,29 +91,108 @@ pub enum AgentRegistryInstruction {
9191}
9292
9393/// Maximum length constants (from the on-chain program)
94+ /// These limits are enforced by the Solana AI Registries program to ensure
95+ /// efficient storage and consistent behavior across the network.
96+ ///
97+ /// **References:**
98+ /// - On-chain program constraints: [Agent Registry Program Documentation](https://docs.solana-ai-registries.org/program/agent-registry)
99+ /// - Program source: `programs/agent-registry/src/lib.rs`
100+
101+ /// Maximum length for agent ID field (64 bytes)
102+ /// This allows for reasonably descriptive identifiers while keeping storage efficient.
103+ /// Must be unique within the owner's namespace.
94104pub const MAX_AGENT_ID_LEN : usize = 64 ;
105+
106+ /// Maximum length for agent name field (128 bytes)
107+ /// Provides space for human-readable agent names and titles.
95108pub const MAX_AGENT_NAME_LEN : usize = 128 ;
109+
110+ /// Maximum length for agent description field (512 bytes)
111+ /// Allows for detailed descriptions while preventing excessive storage costs.
96112pub const MAX_AGENT_DESCRIPTION_LEN : usize = 512 ;
113+
114+ /// Maximum length for agent version string (32 bytes)
115+ /// Follows semantic versioning conventions (e.g., "1.2.3-beta").
97116pub const MAX_AGENT_VERSION_LEN : usize = 32 ;
117+
118+ /// Maximum length for provider name field (128 bytes)
119+ /// Name of the organization or individual providing the agent.
98120pub const MAX_PROVIDER_NAME_LEN : usize = 128 ;
121+
122+ /// Maximum length for provider URL field (256 bytes)
123+ /// URL to the provider's website or profile page.
99124pub const MAX_PROVIDER_URL_LEN : usize = 256 ;
125+
126+ /// Maximum length for documentation URL field (256 bytes)
127+ /// URL pointing to the agent's documentation or API reference.
100128pub const MAX_DOCUMENTATION_URL_LEN : usize = 256 ;
129+
130+ /// Maximum number of service endpoints per agent (3 endpoints)
131+ /// Supports primary, fallback, and development endpoints without excessive complexity.
101132pub const MAX_SERVICE_ENDPOINTS : usize = 3 ;
133+
134+ /// Maximum length for service endpoint protocol field (64 bytes)
135+ /// e.g., "http", "https", "websocket", "grpc"
102136pub const MAX_ENDPOINT_PROTOCOL_LEN : usize = 64 ;
137+
138+ /// Maximum length for service endpoint URL field (256 bytes)
139+ /// Full URL including protocol, domain, port, and path.
103140pub const MAX_ENDPOINT_URL_LEN : usize = 256 ;
141+
142+ /// Maximum number of supported input/output modes per agent (5 modes)
143+ /// Balances flexibility with storage efficiency.
104144pub const MAX_SUPPORTED_MODES : usize = 5 ;
145+
146+ /// Maximum length for input/output mode strings (64 bytes)
147+ /// e.g., "text", "json", "image", "audio"
105148pub const MAX_MODE_LEN : usize = 64 ;
149+
150+ /// Maximum number of skills per agent (10 skills)
151+ /// Allows comprehensive skill representation while preventing abuse.
106152pub const MAX_SKILLS : usize = 10 ;
153+
154+ /// Maximum length for skill ID field (64 bytes)
155+ /// Unique identifier for the skill within the agent.
107156pub const MAX_SKILL_ID_LEN : usize = 64 ;
157+
158+ /// Maximum length for skill name field (128 bytes)
159+ /// Human-readable name for the skill.
108160pub const MAX_SKILL_NAME_LEN : usize = 128 ;
161+
162+ /// Maximum number of tags per skill (5 tags)
163+ /// Enables categorization and discovery without overwhelming metadata.
109164pub const MAX_SKILL_TAGS : usize = 5 ;
165+
166+ /// Maximum length for skill tag strings (32 bytes)
167+ /// e.g., "nlp", "vision", "reasoning"
110168pub const MAX_SKILL_TAG_LEN : usize = 32 ;
169+
170+ /// Maximum length for security info URI field (256 bytes)
171+ /// URL pointing to security audit reports or vulnerability disclosures.
111172pub const MAX_SECURITY_INFO_URI_LEN : usize = 256 ;
173+
174+ /// Maximum length for AEA (Autonomous Economic Agent) address field (128 bytes)
175+ /// Address format specific to the AEA framework.
112176pub const MAX_AEA_ADDRESS_LEN : usize = 128 ;
177+
178+ /// Maximum length for economic intent summary field (256 bytes)
179+ /// Brief description of the agent's economic model and objectives.
113180pub const MAX_ECONOMIC_INTENT_LEN : usize = 256 ;
181+
182+ /// Maximum length for extended metadata URI field (256 bytes)
183+ /// URL pointing to additional metadata stored off-chain.
114184pub const MAX_EXTENDED_METADATA_URI_LEN : usize = 256 ;
185+
186+ /// Maximum number of tags per agent (10 tags)
187+ /// Enables rich categorization for discovery and filtering.
115188pub const MAX_AGENT_TAGS : usize = 10 ;
189+
190+ /// Maximum length for agent tag strings (32 bytes)
191+ /// e.g., "chatbot", "trading", "analytics"
116192pub const MAX_AGENT_TAG_LEN : usize = 32 ;
193+
194+ /// Hash size for content addressing (32 bytes)
195+ /// SHA-256 hash size used for content verification.
117196pub const HASH_SIZE : usize = 32 ;
118197
119198/// Agent status values
@@ -345,15 +424,7 @@ pub struct AgentEntry {
345424impl AgentEntry {
346425 /// Try to deserialize from account data
347426 pub fn try_from_account_data ( data : & [ u8 ] ) -> SdkResult < Self > {
348- // Skip the 8-byte discriminator used by Anchor
349- if data. len ( ) < 8 {
350- return Err ( SdkError :: InvalidAccountData ) ;
351- }
352-
353- let account_data = & data[ 8 ..] ;
354- Self :: try_from_slice ( account_data) . map_err ( |e| {
355- SdkError :: DeserializationError ( format ! ( "Failed to deserialize agent entry: {}" , e) )
356- } )
427+ crate :: client:: deserialize_account_data ( data, "agent entry" )
357428 }
358429}
359430
0 commit comments