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.
Content assets represent reusable content with timestamps and LLM integration.
interface ContentAsset : HasContent, Timestamped, PromptContributorInherited Properties:
content: String (from HasContent)timestamp: Instant (from Timestamped)Inherited Methods:
contribution(): String (from PromptContributor)Blog post content with metadata.
data class Blog(
val title: String,
val author: String,
override val content: String,
override val timestamp: Instant = Instant.now(),
val keywords: Set<String> = emptySet(),
val format: String = "markdown"
) : ContentAssetProperties:
title: String - Blog post titleauthor: String - Author namecontent: String - Post content (from HasContent)timestamp: Instant - Post timestamp (from Timestamped), defaults to current timekeywords: Set<String> - Tags/keywords, defaults to empty setformat: String - Content format (e.g., "markdown", "html"), defaults to "markdown"Methods:
contribution(): String - Returns formatted blog for LLM prompts (Title, Author, Content, Date)equals(other: Any?): Boolean - Structural equality (data class)hashCode(): Int - Hash code (data class)toString(): String - String representation (data class)copy(...): Blog` - Create copy with modifications (data class)import com.embabel.agent.domain.library.Blog
import java.time.Instant
// Full specification
val blog = Blog(
title = "Getting Started with Embabel",
author = "Jane Developer",
content = """
# Introduction
Embabel is a framework for authoring agentic flows...
## Key Features
- Sophisticated planning
- Strong typing
""".trimIndent(),
timestamp = Instant.parse("2026-02-06T12:00:00Z"),
keywords = setOf("embabel", "ai", "agents"),
format = "markdown"
)
// Using defaults (timestamp = now, keywords = empty, format = markdown)
val simpleBlog = Blog(
title = "Quick Update",
author = "John Smith",
content = "Project status update..."
)val blog = Blog(
title = "AI Ethics",
author = "Dr. Smith",
content = "AI ethics encompasses...",
keywords = setOf("ai", "ethics")
)
val contribution = blog.contribution()
// Returns:
// Blog Post:
// Title: AI Ethics
// Author: Dr. Smith
// Content: AI ethics encompasses...
// Date: 2026-02-06
val prompt = """
Consider this blog post:
${blog.contribution()}
Summarize the key points.
""".trimIndent()val blogs = listOf(
Blog("Intro to Agents", "Alice", "Agents are..."),
Blog("Advanced Planning", "Bob", "GOAP planning..."),
Blog("Spring Integration", "Charlie", "Using Spring AI...")
)
// Collect contributions
val allContributions = blogs.joinToString("\n\n") { it.contribution() }
// Filter by keywords
val aiBlogs = blogs.filter { "ai" in it.keywords }
// Sort by timestamp
val chronological = blogs.sortedBy { it.timestamp }
// Recent blogs
val recentBlogs = blogs.filter {
it.timestamp.isAfter(Instant.now().minusSeconds(86400 * 7))
}val blog1 = Blog("Title", "Author", "Content")
val blog2 = Blog("Title", "Author", "Content")
// Structural equality
println(blog1 == blog2) // true (same values)
// Copy with modifications
val updated = blog1.copy(
content = blog1.content + "\n\nUpdate: New information added."
)
// Destructuring
val (title, author, content) = blog1import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule
val mapper = jacksonObjectMapper().registerModule(JavaTimeModule())
val blog = Blog(
title = "Getting Started",
author = "Jane Developer",
content = "# Introduction\n\nContent here...",
keywords = setOf("embabel", "ai")
)
// Serialize
val json = mapper.writeValueAsString(blog)
// Deserialize
val deserialized = mapper.readValue(json, Blog::class.java)JSON Format:
{
"title": "Getting Started",
"author": "Jane Developer",
"content": "# Introduction\n\nContent here...",
"timestamp": "2026-02-06T12:00:00Z",
"keywords": ["embabel", "ai"],
"format": "markdown"
}Implement ContentAsset for custom content types:
data class VideoContent(
val title: String,
val creator: String,
override val content: String,
val duration: Int, // seconds
override val timestamp: Instant = Instant.now()
) : ContentAsset {
override fun contribution(): String = """
Video:
Title: $title
Creator: $creator
Duration: ${duration}s
Content Description: $content
Date: ${timestamp.atZone(java.time.ZoneId.systemDefault()).toLocalDate()}
""".trimIndent()
}Custom ContentAsset implementations must:
content: String propertytimestamp: Instant propertycontribution(): String method@JsonCreator or use data class)import com.embabel.agent.domain.library.*
// Blog with person reference
val author = PersonImpl("Dr. Jane Smith")
val blog = Blog(
title = "Understanding AI Agents",
author = author.name,
content = "AI agents are autonomous systems..."
)
// Create summary from blog
fun summarizeBlog(blog: Blog): Summary {
return Summary(
"Blog '${blog.title}' by ${blog.author}: ${blog.content.take(100)}..."
)
}
// Function accepting any ContentAsset
fun processContent(asset: ContentAsset) {
println("Processing content from ${asset.timestamp}")
println("Content length: ${asset.content.length}")
println("For LLM: ${asset.contribution()}")
}
processContent(blog) // Works with Blogtessl i tessl/maven-com-embabel-agent--embabel-agent-domain@0.3.0