CtrlK
CommunityDocumentationLog inGet started
Tessl Logo

tessl/maven-com-embabel-agent--embabel-agent-domain

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.

Overview
Eval results
Files

external-types.mddocs/

External Types

Types from embabel-agent-api and embabel-common that embabel-agent-domain depends on.

From embabel-agent-api

Package: com.embabel.agent.domain.library

HasContent

interface HasContent {
    val content: String
}

Interface for objects with a single important text component.

Used by: Summary, Blog, ResearchReport (via ContentAsset)

Page

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

InternetResource

open class InternetResource(
    override val url: String,
    override val summary: String
) : Page

Internet 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.

InternetResources

interface InternetResources : PromptContributor {
    val links: List<InternetResource>
    override fun contribution(): String
}

Container for internet resources.

Used by: ResearchReport

From embabel-common

PromptContributor

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

Timestamped

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)

HasInfoString

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

Usage Examples

Creating InternetResource

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)
)

Using HasContent

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)

Using PromptContributor

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 LLM

Using Timestamped

import 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)

Using HasInfoString

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())

Interface Composition

Many domain types combine multiple external interfaces:

ContentAsset

interface ContentAsset : HasContent, Timestamped, PromptContributor

Combines:

  • HasContent - provides content: String
  • Timestamped - provides timestamp: Instant
  • PromptContributor - provides contribution(): String

ResearchReport

open class ResearchReport(
    val topic: String,
    override val content: String,
    override val links: List<InternetResource>
) : InternetResources, HasInfoString, ContentAsset

Combines:

  • InternetResources - provides links and link contributions
  • HasInfoString - provides infoString() method
  • ContentAsset - provides content, timestamp, and prompt contribution

Utility Functions

Note: embabel-common-util provides utility functions like indentLines() but these are implementation details not needed for API usage.

Import Strategy

All domain types and re-exported external types are in one package:

import com.embabel.agent.domain.library.*

This includes:

  • Domain types (Blog, Summary, Person, etc.)
  • Re-exported InternetResource
  • All interfaces

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

docs

content-types.md

core-concepts.md

external-types.md

index.md

installation.md

integration-patterns.md

json-serialization.md

news-types.md

person-types.md

quick-reference.md

research-types.md

summary-type.md

tile.json