Record Class ArtifactEvent

java.lang.Object
java.lang.Record
com.tnsai.events.ArtifactEvent
Record Components:
eventId - unique identifier for this event
timestamp - when the event occurred
artifactId - unique identifier for this artifact
type - the artifact type (code, chart, table, image, file)
title - optional title for the artifact
content - the artifact content
metadata - 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);
 
  • 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 a ArtifactEvent record class.
      Parameters:
      eventId - the value for the eventId record component
      timestamp - the value for the timestamp record component
      artifactId - the value for the artifactId record component
      type - the value for the type record component
      title - the value for the title record component
      content - the value for the content record component
      metadata - the value for the metadata record component
  • Method Details

    • code

      public static ArtifactEvent code(String filename, String language, String content)
      Creates a code artifact event.
      Parameters:
      filename - the filename (for display)
      language - the programming language
      content - the code content
      Returns:
      new ArtifactEvent
    • chart

      public static ArtifactEvent chart(String variant, Object data, Map<String,Object> options)
      Creates a chart artifact event.
      Parameters:
      variant - the chart type (bar, line, pie, etc.)
      data - the chart data
      options - optional chart configuration
      Returns:
      new ArtifactEvent
    • table

      public static ArtifactEvent table(String title, Object columns, Object rows)
      Creates a table artifact event.
      Parameters:
      title - the table title
      columns - the column definitions
      rows - the table data rows
      Returns:
      new ArtifactEvent
    • markdown

      public static ArtifactEvent markdown(String title, String content)
      Creates a markdown artifact event.
      Parameters:
      title - the document title
      content - the markdown content
      Returns:
      new ArtifactEvent
    • mermaid

      public static ArtifactEvent mermaid(String title, String diagram)
      Creates a mermaid diagram artifact event.
      Parameters:
      title - the diagram title
      diagram - the mermaid diagram source
      Returns:
      new ArtifactEvent
    • file

      public static ArtifactEvent file(String filename, String mimeType, Object data)
      Creates a file artifact event.
      Parameters:
      filename - the filename
      mimeType - the MIME type
      data - the file data (bytes or base64)
      Returns:
      new ArtifactEvent
    • toString

      public final String 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.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • 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.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      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 with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • eventId

      public String eventId()
      Returns the value of the eventId record component.
      Specified by:
      eventId in interface TnsAIEvent
      Returns:
      the value of the eventId record component
    • timestamp

      public Instant timestamp()
      Returns the value of the timestamp record component.
      Specified by:
      timestamp in interface TnsAIEvent
      Returns:
      the value of the timestamp record component
    • artifactId

      public String artifactId()
      Returns the value of the artifactId record component.
      Returns:
      the value of the artifactId record component
    • type

      Returns the value of the type record component.
      Returns:
      the value of the type record component
    • title

      public String title()
      Returns the value of the title record component.
      Returns:
      the value of the title record component
    • content

      public Object content()
      Returns the value of the content record component.
      Returns:
      the value of the content record component
    • metadata

      public Map<String,Object> metadata()
      Returns the value of the metadata record component.
      Returns:
      the value of the metadata record component