Core domain type definitions for the Embabel Agent Framework, providing foundational data classes and interfaces for agent-based AI workflows including content assets, research entities, and person types with Jackson serialization and PromptContributor capabilities.
Types from embabel-agent-api and embabel-common that embabel-agent-domain depends on.
Package: com.embabel.agent.domain.library
interface HasContent {
val content: String
}Interface for objects with a single important text component.
Used by: Summary, Blog, ResearchReport (via ContentAsset)
interface Page : PromptContributor {
val url: String
val summary: String
override fun contribution(): String
}Represents a web page with URL and summary.
Used by: NewsStory, InternetResource
open class InternetResource(
override val url: String,
override val summary: String
) : PageInternet resource with URL and summary.
Used by: ResearchReport (in links property)
Note: Defined in embabel-agent-api but re-exported from com.embabel.agent.domain.library for convenience.
interface InternetResources : PromptContributor {
val links: List<InternetResource>
override fun contribution(): String
}Container for internet resources.
Used by: ResearchReport
Package: com.embabel.common.ai.prompt
interface PromptContributor : PromptElement {
fun promptContribution(): PromptContribution
fun contribution(): String
}
interface PromptElement {
val role: String?
val promptContributionLocation: PromptContributionLocation
}
enum class PromptContributionLocation {
BEGINNING,
END
}
data class PromptContribution(
val content: String,
val location: PromptContributionLocation = PromptContributionLocation.BEGINNING,
val role: String? = null
)Contributor to a prompt - returns formatted content for LLM prompts.
Used by: ContentAsset, NewsStory, RelevantNewsStories, and all types implementing these
Key Method: contribution(): String - Returns formatted content for LLM consumption
Package: com.embabel.common.core.types
interface Timestamped {
val timestamp: java.time.Instant
}Interface for types with timestamp.
Used by: ContentAsset (and thus Blog, ResearchReport)
Package: com.embabel.common.core.types
interface HasInfoString {
fun infoString(verbose: Boolean? = null, indent: Int = 0): String
}Interface for types that can provide formatted info strings.
Used by: ResearchReport
import com.embabel.agent.domain.library.InternetResource
val resource = InternetResource(
url = "https://example.com/article",
summary = "Comprehensive guide to AI agents"
)
println(resource.url) // "https://example.com/article"
println(resource.summary) // "Comprehensive guide to AI agents"
// Use with ResearchReport
val report = ResearchReport(
topic = "AI Agents",
content = "...",
links = listOf(resource)
)import com.embabel.agent.domain.library.*
fun processContent(item: HasContent) {
val text = item.content
println("Processing ${text.length} characters")
}
// Works with Summary
val summary = Summary("Brief summary")
processContent(summary)
// Works with Blog
val blog = Blog("Title", "Author", "Content")
processContent(blog)
// Works with ResearchReport
val report = ResearchReport("Topic", "Content", listOf())
processContent(report)import com.embabel.agent.domain.library.*
fun buildPrompt(contributors: List<PromptContributor>): String {
return contributors.joinToString("\n\n") { it.contribution() }
}
val items = listOf<PromptContributor>(
Blog("Title", "Author", "Content"),
NewsStory("https://ex.com", "News Title", "Summary"),
ResearchReport("Topic", "Content", listOf())
)
val prompt = buildPrompt(items)
// Each item formatted appropriately for LLMimport com.embabel.agent.domain.library.*
import java.time.Instant
fun findRecent(assets: List<ContentAsset>): List<ContentAsset> {
val cutoff = Instant.now().minusSeconds(86400 * 7) // 7 days ago
return assets.filter { it.timestamp.isAfter(cutoff) }
}
val blogs = listOf(
Blog("Recent Post", "Author", "Content"),
Blog("Old Post", "Author", "Content", timestamp = Instant.parse("2020-01-01T00:00:00Z"))
)
val recentBlogs = findRecent(blogs)import com.embabel.agent.domain.library.ResearchReport
import com.embabel.agent.domain.library.InternetResource
val report = ResearchReport(
topic = "Quantum Computing",
content = "Quantum computing...",
links = listOf(
InternetResource(
url = "https://ibm.com/quantum",
summary = "IBM Quantum overview"
)
)
)
// Get formatted info string
val info = report.infoString(verbose = false, indent = 0)
println(info)
// toString uses infoString
println(report.toString())Many domain types combine multiple external interfaces:
interface ContentAsset : HasContent, Timestamped, PromptContributorCombines:
HasContent - provides content: StringTimestamped - provides timestamp: InstantPromptContributor - provides contribution(): Stringopen class ResearchReport(
val topic: String,
override val content: String,
override val links: List<InternetResource>
) : InternetResources, HasInfoString, ContentAssetCombines:
InternetResources - provides links and link contributionsHasInfoString - provides infoString() methodContentAsset - provides content, timestamp, and prompt contributionNote: embabel-common-util provides utility functions like indentLines() but these are implementation details not needed for API usage.
All domain types and re-exported external types are in one package:
import com.embabel.agent.domain.library.*This includes:
External interfaces from embabel-common are used through domain types and don't typically need direct import.
tessl i tessl/maven-com-embabel-agent--embabel-agent-domain@0.3.0