Public declaration syntax from forge-rs/crates/forge-contracts/src/comm.rs Original source SHA-256: b2ca753341613777994e11f61a31dcf8444039ef1277e999d03da8ef7dd4219b Function bodies and constant values are omitted. This is not the complete implementation. Source line 45 pub const CONTRACT_VERSION: &str; Source line 71 #[derive(Debug, Clone, Serialize, Deserialize)] pub struct ChannelConfig { /// Human-readable channel name. pub channel_name: String, /// The type of channel (maps to different session semantics). pub channel_type: ChannelType, /// The organization this channel belongs to. pub org_id: String, /// Optional department scope. pub department_id: Option, /// DIDs of agents allowed in this channel. pub participants: Vec, /// Maximum message payload size in bytes. pub max_message_size_bytes: u32, /// How long to retain message history, in hours. `None` = forever. pub history_retention_hours: Option } Source line 96 #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] pub enum ChannelType { /// Organization-wide broadcast channel. OrgWide, /// Department-scoped channel. Department, /// Direct message between two agents. DirectMessage, /// Executive channel (Company Director + root-holder). Executive, /// Root-holder secure channel. RootHolder, /// Custom channel type. Custom(String), } Source line 113 #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] pub struct ChannelHandle { /// Unique channel identifier. pub channel_id: String, /// The underlying Forge session identifier. pub session_id: String, /// The channel name. pub name: String, /// The channel type. pub channel_type: ChannelType, /// Number of participants. pub participant_count: u32 } Source line 134 #[derive(Debug, Clone, Serialize, Deserialize)] pub struct SessionConfig { /// Human-readable session name. pub session_name: String, /// The coordinator agent's DID. pub coordinator_did: String, /// Worker agent DIDs. pub worker_dids: Vec, /// Optional timeout for the session in seconds. pub timeout_seconds: Option, /// Whether to enable shared context for this session. pub shared_context_enabled: bool } Source line 153 #[derive(Debug, Clone, Serialize, Deserialize)] pub struct ChannelMessage { /// The sender's DID. pub sender_did: String, /// The message content type. pub content_type: MessageContentType, /// The message payload as JSON. pub payload: serde_json::Value, /// Optional correlation ID for threading. pub correlation_id: Option, /// Optional reply-to message ID. pub reply_to: Option } Source line 172 #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] pub enum MessageContentType { /// Plain text message. Text, /// Structured data message. Structured, /// Task delegation message. TaskDelegation, /// Task result message. TaskResult, /// Interrupt/signal message. Interrupt, /// Status update message. StatusUpdate, } Source line 189 #[derive(Debug, Clone, Serialize, Deserialize)] pub struct ReceivedMessage { /// Unique message identifier. pub message_id: String, /// The sender's DID. pub sender_did: String, /// The message content type. pub content_type: MessageContentType, /// The message payload. pub payload: serde_json::Value, /// When the message was sent. pub sent_at: DateTime, /// Ed25519 signature from the sender (base64-encoded). pub signature: Option, /// Correlation ID for threading. pub correlation_id: Option } Source line 231 #[async_trait] pub trait CommContract: Send + Sync { /// Creates a new communication channel. /// /// # Arguments /// /// * `config` - The channel configuration. /// /// # Returns /// /// A handle to the created channel. /// /// # Errors /// /// - `ContractError::ChannelError` if creation fails. /// - `ContractError::DidResolutionFailed` if any participant DID /// cannot be resolved. async fn create_channel(&self, config: ChannelConfig) -> ContractResult; /// Sends a message to a channel. /// /// The message is automatically wrapped in an `AgentMessage` envelope, /// signed by the sender, and delivered to all channel participants. /// /// # Arguments /// /// * `channel_id` - The target channel. /// * `message` - The message to send. /// /// # Returns /// /// The message ID assigned by the transport. /// /// # Errors /// /// - `ContractError::ChannelError` if the channel does not exist. /// - `ContractError::AuthorizationDenied` if the sender is not a /// participant. async fn send_message( &self, channel_id: &str, message: ChannelMessage, ) -> ContractResult; /// Receives the next message from a channel. /// /// This is a pull-based interface. For push-based delivery, use /// `subscribe`. /// /// # Arguments /// /// * `channel_id` - The channel to receive from. /// * `agent_did` - The receiving agent's DID. /// /// # Returns /// /// The next unread message, or `None` if no messages are pending. async fn receive_message( &self, channel_id: &str, agent_did: &str, ) -> ContractResult>; /// Closes a channel, cleaning up resources. /// /// # Arguments /// /// * `channel_id` - The channel to close. async fn close_channel(&self, channel_id: &str) -> ContractResult<()>; /// Lists all channels for an organization. /// /// # Arguments /// /// * `org_id` - The organization to query. /// * `department_id` - Optional department filter. async fn list_channels( &self, org_id: &str, department_id: Option<&str>, ) -> ContractResult>; }