Current section
Files
Jump to
Current section
Files
lib/a2a/artifact.ex
defmodule A2A.Artifact do
@moduledoc """
An output produced by an agent in response to a task.
Artifacts contain typed parts representing the result of agent work.
"""
@type t :: %__MODULE__{
artifact_id: String.t(),
name: String.t() | nil,
description: String.t() | nil,
parts: [A2A.Part.t()],
metadata: map()
}
@enforce_keys [:parts]
defstruct [
:artifact_id,
:name,
:description,
parts: [],
metadata: %{}
]
@doc """
Creates a new artifact from parts.
"""
@spec new([A2A.Part.t()], keyword()) :: t()
def new(parts, opts \\ []) do
%__MODULE__{
artifact_id: A2A.ID.generate("art"),
parts: parts,
name: Keyword.get(opts, :name),
description: Keyword.get(opts, :description),
metadata: Keyword.get(opts, :metadata, %{})
}
end
end