Forge documentation
Library referenceKotlin

com.l1fe.forge:forge-comm

Kotlin/JVM forge-comm module.

Kotlin/JVM forge-comm module.

Package contract

FieldValue
Languagekotlin
Source version0.1.0
Manifestforge-kt/forge-comm/build.gradle.kts
Source files6
EvidenceSource reference; registry publication and runtime conformance are separate checks

Import boundary

import com.l1fe.forge.comm.*

Use a source checkout or your verified private registry. Manifest coordinates identify the package; they do not establish that a public registry release exists.

Source reference

Download package reference JSON. Each original source file and generated declaration artifact has its own SHA-256 digest. Function bodies and constant values are omitted from downloads. These are source declaration inventories, not compiler-resolved rustdoc, TypeDoc, DocC, or Dokka output. Private modules can contain public declarations that are not reachable through the package boundary; consult the entry point before importing.

com/l1fe/forge/comm/AgentMessage.kt

Read declaration text · 7 declaration entries

public enum class MessagePriority

public sealed class MessageContent

public data class Text(val text: String) : MessageContent()

/**
* A structured request from one agent to another.
*
* @property action The requested action identifier.
* @property payload The JSON-encoded payload for the action.
*/
@Serializable
@SerialName("request")
public data class Request(
val action: String,
val payload: String,
) : MessageContent()

/**
* A response to a prior request.
*
* @property requestId The ID of the original request message.
* @property payload The JSON-encoded response payload.
* @property success Whether the request was fulfilled successfully.
*/
@Serializable
@SerialName("response")
public data class Response(
@SerialName("request_id")

public data class Request(
val action: String,
val payload: String,
) : MessageContent()

/**
* A response to a prior request.
*
* @property requestId The ID of the original request message.
* @property payload The JSON-encoded response payload.
* @property success Whether the request was fulfilled successfully.
*/
@Serializable
@SerialName("response")
public data class Response(
@SerialName("request_id")
val requestId: String,
val payload: String,
val success: Boolean,
) : MessageContent()

/**
* A broadcast notification to all agents on a channel.
*
* @property topic The notification topic.
* @property payload The JSON-encoded notification payload.

public data class Response(
@SerialName("request_id")
val requestId: String,
val payload: String,
val success: Boolean,
) : MessageContent()

/**
* A broadcast notification to all agents on a channel.
*
* @property topic The notification topic.
* @property payload The JSON-encoded notification payload.
*/
@Serializable
@SerialName("broadcast")
public data class Broadcast(
val topic: String,
val payload: String,
) : MessageContent()
}

/**
* An agent-to-agent message envelope.
*
* Carries sender and recipient identity, routing metadata, priority,
* and a typed content payload. Every message has a unique ID and

public data class Broadcast(
val topic: String,
val payload: String,
) : MessageContent()
}

/**
* An agent-to-agent message envelope.
*
* Carries sender and recipient identity, routing metadata, priority,
* and a typed content payload. Every message has a unique ID and
* timestamp for audit trail purposes.
*
* ANVIL Spec Section 15.1
*
* @property id Unique message identifier.
* @property senderDid The sender agent's OAS DID.
* @property recipientDid The recipient agent's OAS DID (empty for broadcasts).
* @property channelId The communication channel identifier.
* @property content The typed message content.
* @property priority The message priority level.
* @property correlationId Optional correlation ID for request/response threading.
* @property timestamp When the message was created.
* @property metadata Optional key-value metadata.
*/
@Serializable

public data class AgentMessage(
val id: String,
@SerialName("sender_did")
val senderDid: String,
@SerialName("recipient_did")
val recipientDid: String;

com/l1fe/forge/comm/ChannelTransport.kt

Read declaration text · 1 declaration entries

public class ChannelTransport(
private val bufferSize: Int;

com/l1fe/forge/comm/CommError.kt

Read declaration text · 18 declaration entries

public sealed class ForgeCommError(
message: String,
cause: Throwable?;

public class DeliveryFailed(
public val messageId: String,
public val recipientDid: String,
public val reason: String,
) : ForgeCommError(
"message '$messageId' delivery to '$recipientDid' failed: $reason " +
"(see ANVIL Spec SS15.1)"
)

/**
* Transport connection failed.
*
* @property transportType The type of transport that failed.
* @property reason The failure reason.
*/
public class TransportError(
public val transportType: String,
public val reason: String,
cause: Throwable?;

public val messageId: String,
public val recipientDid: String,
public val reason: String,
) : ForgeCommError(
"message '$messageId' delivery to '$recipientDid' failed: $reason " +
"(see ANVIL Spec SS15.1)"
)

/**
* Transport connection failed.
*
* @property transportType The type of transport that failed.
* @property reason The failure reason.
*/
public class TransportError(
public val transportType: String,
public val reason: String,
cause: Throwable?;

public val recipientDid: String,
public val reason: String,
) : ForgeCommError(
"message '$messageId' delivery to '$recipientDid' failed: $reason " +
"(see ANVIL Spec SS15.1)"
)

/**
* Transport connection failed.
*
* @property transportType The type of transport that failed.
* @property reason The failure reason.
*/
public class TransportError(
public val transportType: String,
public val reason: String,
cause: Throwable?;

public val reason: String,
) : ForgeCommError(
"message '$messageId' delivery to '$recipientDid' failed: $reason " +
"(see ANVIL Spec SS15.1)"
)

/**
* Transport connection failed.
*
* @property transportType The type of transport that failed.
* @property reason The failure reason.
*/
public class TransportError(
public val transportType: String,
public val reason: String,
cause: Throwable?;

public class TransportError(
public val transportType: String,
public val reason: String,
cause: Throwable?;

public val transportType: String,
public val reason: String,
cause: Throwable?;

public val reason: String,
cause: Throwable?;

public class NegotiationFailed(
public val senderDid: String,
public val recipientDid: String,
public val offeredProtocols: List<String>,
public val reason: String,
) : ForgeCommError(
"protocol negotiation between '$senderDid' and '$recipientDid' failed: $reason; " +

public val senderDid: String,
public val recipientDid: String,
public val offeredProtocols: List<String>,
public val reason: String,
) : ForgeCommError(
"protocol negotiation between '$senderDid' and '$recipientDid' failed: $reason; " +

public val recipientDid: String,
public val offeredProtocols: List<String>,
public val reason: String,
) : ForgeCommError(
"protocol negotiation between '$senderDid' and '$recipientDid' failed: $reason; " +

public val offeredProtocols: List<String>,
public val reason: String,
) : ForgeCommError(
"protocol negotiation between '$senderDid' and '$recipientDid' failed: $reason; " +

public val reason: String,
) : ForgeCommError(
"protocol negotiation between '$senderDid' and '$recipientDid' failed: $reason; " +

public class ChannelNotFound(
public val channelId: String,
) : ForgeCommError("communication channel '$channelId' not found")

/**
* Message serialization or deserialization failed.
*
* @property context A description of what was being serialized.
* @property reason The failure detail.
*/
public class SerializationError(
public val context: String,
public val reason: String,
cause: Throwable?;

public val channelId: String,
) : ForgeCommError("communication channel '$channelId' not found")

/**
* Message serialization or deserialization failed.
*
* @property context A description of what was being serialized.
* @property reason The failure detail.
*/
public class SerializationError(
public val context: String,
public val reason: String,
cause: Throwable?;

public class SerializationError(
public val context: String,
public val reason: String,
cause: Throwable?;

public val context: String,
public val reason: String,
cause: Throwable?;

public val reason: String,
cause: Throwable?;

com/l1fe/forge/comm/MessageTransport.kt

Read declaration text · 7 declaration entries

public fun interface MessageHandler

public suspend fun onMessage(message: AgentMessage)
}

/**
* Transport interface for agent-to-agent communication.
*
* Implementations handle the mechanics of message delivery:
* serialization, routing, acknowledgment, and error handling.
*
* ANVIL Spec Section 15.3
*/
public interface MessageTransport

public interface MessageTransport

public suspend fun send(message: AgentMessage)

/**
* Subscribe to messages on a specific channel.
*
* The handler will be invoked for each message received on the channel.
*
* @param channelId The channel to subscribe to.
* @param handler The handler to invoke for received messages.
* @throws ForgeCommError.ChannelNotFound if the channel does not exist.
*/
public suspend fun subscribe(channelId: String, handler: MessageHandler)

/**
* Unsubscribe from messages on a specific channel.
*
* @param channelId The channel to unsubscribe from.
*/
public suspend fun unsubscribe(channelId: String)

/**
* Close the transport and release all resources.
*
* After closing, no further send or subscribe operations are valid.
*/
public suspend fun close()

public suspend fun subscribe(channelId: String, handler: MessageHandler)

/**
* Unsubscribe from messages on a specific channel.
*
* @param channelId The channel to unsubscribe from.
*/
public suspend fun unsubscribe(channelId: String)

/**
* Close the transport and release all resources.
*
* After closing, no further send or subscribe operations are valid.
*/
public suspend fun close()
}

public suspend fun unsubscribe(channelId: String)

/**
* Close the transport and release all resources.
*
* After closing, no further send or subscribe operations are valid.
*/
public suspend fun close()
}

public suspend fun close()
}

com/l1fe/forge/comm/NoopTransport.kt

Read declaration text · 1 declaration entries

public object NoopTransport : MessageTransport

com/l1fe/forge/comm/ProtocolNegotiation.kt

Read declaration text · 8 declaration entries

public data class ProtocolCapability(
val name: String,
val version: String,
val features: Set<String>;

public fun qualifiedName(): String;

public data class NegotiationOffer(
@SerialName("sender_did")
val senderDid: String,
val protocols: List<ProtocolCapability>,
)

/**
* A negotiation response from the responder.
*
* ANVIL Spec Section 15.2
*
* @property responderDid The responding agent's OAS DID.
* @property selectedProtocol The protocol selected by the responder, or `null` if none matched.
* @property reason A reason for the selection or rejection.
*/
@Serializable
public data class NegotiationResponse(
@SerialName("responder_did")
val responderDid: String,
@SerialName("selected_protocol")
val selectedProtocol: ProtocolCapability?;

public data class NegotiationResponse(
@SerialName("responder_did")
val responderDid: String,
@SerialName("selected_protocol")
val selectedProtocol: ProtocolCapability?;

public sealed class NegotiationResult

public data class Agreed(val protocol: ProtocolCapability) : NegotiationResult()

/**
* Negotiation failed. No common protocol was found.
*
* @property reason The failure reason.
*/
@Serializable
@SerialName("failed")
public data class Failed(val reason: String) : NegotiationResult()
}

/**
* Negotiates a common protocol between an offer and a set of supported protocols.
*
* Selects the first protocol from the offer that the responder supports,
* matching on name and version. Feature sets must be compatible (the
* responder must support all features required by the offer).
*
* ANVIL Spec Section 15.2
*
* @param offer The negotiation offer from the initiator.
* @param supported The protocols supported by the responder.
* @param responderDid The responder's OAS DID (for the response envelope).
* @return A [NegotiationResponse] with the selected protocol or rejection.
*/

public data class Failed(val reason: String) : NegotiationResult()
}

/**
* Negotiates a common protocol between an offer and a set of supported protocols.
*
* Selects the first protocol from the offer that the responder supports,
* matching on name and version. Feature sets must be compatible (the
* responder must support all features required by the offer).
*
* ANVIL Spec Section 15.2
*
* @param offer The negotiation offer from the initiator.
* @param supported The protocols supported by the responder.
* @param responderDid The responder's OAS DID (for the response envelope).
* @return A [NegotiationResponse] with the selected protocol or rejection.
*/
public fun negotiate(
offer: NegotiationOffer,
supported: List<ProtocolCapability>,
responderDid: String,
): NegotiationResponse

public fun negotiate(
offer: NegotiationOffer,
supported: List<ProtocolCapability>,
responderDid: String,
): NegotiationResponse

Continue

On this page