Package com.tnsai.events
Record Class ArtifactEvent
java.lang.Object
java.lang.Record
com.tnsai.events.ArtifactEvent
- Record Components:
eventId- unique identifier for this eventtimestamp- when the event occurredartifactId- unique identifier for this artifacttype- the artifact type (code, chart, table, image, file)title- optional title for the artifactcontent- the artifact contentmetadata- additional metadata (language, format, options)
- All Implemented Interfaces:
TnsAIEvent
public record ArtifactEvent(String eventId, Instant timestamp, String artifactId, ArtifactEvent.ArtifactType type, String title, Object content, Map<String,Object> metadata)
extends Record
implements TnsAIEvent
Event representing the creation of an artifact by the agent.
Artifacts are structured outputs that can be rendered in the frontend:
- Code blocks (with syntax highlighting)
- Charts and visualizations
- Tables with data
- Images or diagrams
- Files (for download)
Example:
ArtifactEvent codeArtifact = ArtifactEvent.code("Example.java", "java", codeContent);
ArtifactEvent chartArtifact = ArtifactEvent.chart("bar", chartData, chartOptions);
-
Nested Class Summary
Nested Classes -
Constructor Summary
ConstructorsConstructorDescriptionArtifactEvent(String eventId, Instant timestamp, String artifactId, ArtifactEvent.ArtifactType type, String title, Object content, Map<String, Object> metadata) Creates an instance of aArtifactEventrecord class. -
Method Summary
Modifier and TypeMethodDescriptionReturns the value of theartifactIdrecord component.static ArtifactEventCreates a chart artifact event.static ArtifactEventCreates a code artifact event.content()Returns the value of thecontentrecord component.final booleanIndicates whether some other object is "equal to" this one.eventId()Returns the value of theeventIdrecord component.static ArtifactEventCreates a file artifact event.final inthashCode()Returns a hash code value for this object.static ArtifactEventCreates a markdown artifact event.static ArtifactEventCreates a mermaid diagram artifact event.metadata()Returns the value of themetadatarecord component.static ArtifactEventCreates a table artifact event.Returns the value of thetimestamprecord component.title()Returns the value of thetitlerecord component.final StringtoString()Returns a string representation of this record class.type()Returns the value of thetyperecord component.Methods inherited from interface com.tnsai.events.TnsAIEvent
eventType
-
Constructor Details
-
ArtifactEvent
public ArtifactEvent(String eventId, Instant timestamp, String artifactId, ArtifactEvent.ArtifactType type, String title, Object content, Map<String, Object> metadata) Creates an instance of aArtifactEventrecord class.- Parameters:
eventId- the value for theeventIdrecord componenttimestamp- the value for thetimestamprecord componentartifactId- the value for theartifactIdrecord componenttype- the value for thetyperecord componenttitle- the value for thetitlerecord componentcontent- the value for thecontentrecord componentmetadata- the value for themetadatarecord component
-
-
Method Details
-
code
Creates a code artifact event.- Parameters:
filename- the filename (for display)language- the programming languagecontent- the code content- Returns:
- new ArtifactEvent
-
chart
Creates a chart artifact event.- Parameters:
variant- the chart type (bar, line, pie, etc.)data- the chart dataoptions- optional chart configuration- Returns:
- new ArtifactEvent
-
table
Creates a table artifact event.- Parameters:
title- the table titlecolumns- the column definitionsrows- the table data rows- Returns:
- new ArtifactEvent
-
markdown
Creates a markdown artifact event.- Parameters:
title- the document titlecontent- the markdown content- Returns:
- new ArtifactEvent
-
mermaid
Creates a mermaid diagram artifact event.- Parameters:
title- the diagram titlediagram- the mermaid diagram source- Returns:
- new ArtifactEvent
-
file
Creates a file artifact event.- Parameters:
filename- the filenamemimeType- the MIME typedata- the file data (bytes or base64)- Returns:
- new ArtifactEvent
-
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared withObjects::equals(Object,Object). -
eventId
Returns the value of theeventIdrecord component.- Specified by:
eventIdin interfaceTnsAIEvent- Returns:
- the value of the
eventIdrecord component
-
timestamp
Returns the value of thetimestamprecord component.- Specified by:
timestampin interfaceTnsAIEvent- Returns:
- the value of the
timestamprecord component
-
artifactId
Returns the value of theartifactIdrecord component.- Returns:
- the value of the
artifactIdrecord component
-
type
Returns the value of thetyperecord component.- Returns:
- the value of the
typerecord component
-
title
Returns the value of thetitlerecord component.- Returns:
- the value of the
titlerecord component
-
content
Returns the value of thecontentrecord component.- Returns:
- the value of the
contentrecord component
-
metadata
Returns the value of themetadatarecord component.- Returns:
- the value of the
metadatarecord component
-