artifact

package
v0.7.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 7, 2026 License: AGPL-3.0 Imports: 2 Imported by: 0

Documentation

Overview

Package artifact defines the extensible Artifact interface and common concrete types used throughout ore. The Artifact interface exposes a public Kind() method to allow custom artifact types to be defined in other packages.

Package artifact defines the extensible Artifact interface and common concrete types used throughout ore.

The Artifact interface exposes a public Kind() method to allow custom artifact types to be defined in other packages. Private marker methods would prevent cross-package extensibility because Go does not allow implementing unexported methods across package boundaries.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Accumulable added in v0.1.0

type Accumulable interface {
	Delta
	AccumulatorKey() string
	MergeInto(acc Artifact) Artifact
}

Accumulable marks delta artifacts that can be merged into complete artifacts by a generic accumulator. Implementations must return a stable AccumulatorKey and define MergeInto to combine the delta with an existing accumulated artifact or seed a new one when acc is nil.

type Artifact

type Artifact interface {
	Kind() string
}

Artifact is the base interface for all LLM response artifacts.

type Delta

type Delta interface {
	Artifact
	IsDelta()
}

Delta marks artifacts that are ephemeral streaming fragments. These must never be persisted to state; only complete artifacts should be.

type Image

type Image struct {
	URL string
}

Image represents an image artifact referenced by URL.

func (Image) Kind

func (i Image) Kind() string

Kind returns the artifact kind identifier.

func (Image) MarshalJSON added in v0.6.0

func (i Image) MarshalJSON() ([]byte, error)

MarshalJSON serializes Image to JSON.

type LLMRenderer added in v0.2.0

type LLMRenderer interface {
	MarshalLLM() string
}

LLMRenderer is implemented by tool result values that know how to serialize themselves for consumption by an LLM provider.

type MarkdownRenderer added in v0.2.0

type MarkdownRenderer interface {
	MarshalMarkdown() string
}

MarkdownRenderer is implemented by tool result values that know how to render themselves as Markdown for human display.

type Reasoning

type Reasoning struct {
	Content string
}

Reasoning represents a reasoning or thinking content artifact.

func (Reasoning) Kind

func (r Reasoning) Kind() string

Kind returns the artifact kind identifier.

func (Reasoning) MarshalJSON added in v0.6.0

func (r Reasoning) MarshalJSON() ([]byte, error)

MarshalJSON serializes Reasoning to JSON.

type ReasoningDelta

type ReasoningDelta struct {
	Content string
}

ReasoningDelta represents a partial chunk of reasoning content for streaming.

func (ReasoningDelta) AccumulatorKey added in v0.1.0

func (d ReasoningDelta) AccumulatorKey() string

AccumulatorKey returns a stable routing key for the generic accumulator. ReasoningDelta accumulates into a single "reasoning" block.

func (ReasoningDelta) IsDelta

func (r ReasoningDelta) IsDelta()

IsDelta marks ReasoningDelta as an ephemeral streaming fragment.

func (ReasoningDelta) Kind

func (r ReasoningDelta) Kind() string

Kind returns the artifact kind identifier.

func (ReasoningDelta) MarshalJSON added in v0.6.0

func (r ReasoningDelta) MarshalJSON() ([]byte, error)

MarshalJSON serializes ReasoningDelta to JSON.

func (ReasoningDelta) MergeInto added in v0.1.0

func (d ReasoningDelta) MergeInto(acc Artifact) Artifact

MergeInto merges the delta into an existing Reasoning artifact or seeds a new one.

type StatusContributor added in v0.4.0

type StatusContributor interface {
	Status() map[string]string
}

StatusContributor is implemented by tool result values that carry ambient metadata to be broadcast to all subscribers via PropertiesEvent.

type Text

type Text struct {
	Content string
}

Text represents a text content artifact.

func (Text) Kind

func (t Text) Kind() string

Kind returns the artifact kind identifier.

func (Text) MarshalJSON added in v0.6.0

func (t Text) MarshalJSON() ([]byte, error)

MarshalJSON serializes Text to JSON.

type TextDelta

type TextDelta struct {
	Content string
}

TextDelta represents a partial chunk of text content for streaming.

func (TextDelta) AccumulatorKey added in v0.1.0

func (d TextDelta) AccumulatorKey() string

AccumulatorKey returns a stable routing key for the generic accumulator. TextDelta accumulates into a single "text" block.

func (TextDelta) IsDelta

func (t TextDelta) IsDelta()

IsDelta marks TextDelta as an ephemeral streaming fragment.

func (TextDelta) Kind

func (t TextDelta) Kind() string

Kind returns the artifact kind identifier.

func (TextDelta) MarshalJSON added in v0.6.0

func (t TextDelta) MarshalJSON() ([]byte, error)

MarshalJSON serializes TextDelta to JSON.

func (TextDelta) MergeInto added in v0.1.0

func (d TextDelta) MergeInto(acc Artifact) Artifact

MergeInto merges the delta into an existing Text artifact or seeds a new one.

type ToolCall

type ToolCall struct {
	ID        string
	Name      string
	Arguments string
	Value     any // NEW
}

ToolCall represents a tool invocation artifact.

func (ToolCall) Kind

func (t ToolCall) Kind() string

Kind returns the artifact kind identifier.

func (ToolCall) LLMString added in v0.4.0

func (t ToolCall) LLMString() string

LLMString returns a string representation of the tool call suitable for consumption by an LLM provider. It prefers the custom LLMRenderer on Value, falls back to json.Marshal of Value, and finally falls back to the raw Arguments string.

func (ToolCall) MarkdownString added in v0.4.0

func (t ToolCall) MarkdownString() string

MarkdownString returns a string representation of the tool call suitable for human display. It prefers the custom MarkdownRenderer on Value, falls back to json.Marshal of Value, and finally falls back to the raw Arguments string.

func (ToolCall) MarshalJSON added in v0.6.0

func (t ToolCall) MarshalJSON() ([]byte, error)

MarshalJSON serializes ToolCall to JSON. The display field is only included when it differs from the raw arguments.

type ToolCallDelta

type ToolCallDelta struct {
	Index     int
	ID        string
	Name      string
	Arguments string
}

ToolCallDelta represents a partial chunk of a tool invocation for streaming. Index identifies which parallel tool call in the current turn this fragment belongs to, enabling the generic accumulator to merge chunks independently.

func (ToolCallDelta) AccumulatorKey added in v0.1.0

func (d ToolCallDelta) AccumulatorKey() string

AccumulatorKey returns a stable routing key for the generic accumulator. ToolCallDelta accumulates per-index: "tool_call:0", "tool_call:1", etc.

func (ToolCallDelta) IsDelta

func (t ToolCallDelta) IsDelta()

IsDelta marks ToolCallDelta as an ephemeral streaming fragment.

func (ToolCallDelta) Kind

func (t ToolCallDelta) Kind() string

Kind returns the artifact kind identifier.

func (ToolCallDelta) MarshalJSON added in v0.6.0

func (t ToolCallDelta) MarshalJSON() ([]byte, error)

MarshalJSON serializes ToolCallDelta to JSON.

func (ToolCallDelta) MergeInto added in v0.1.0

func (d ToolCallDelta) MergeInto(acc Artifact) Artifact

MergeInto merges the delta into an existing ToolCall artifact or seeds a new one. ID uses latest-wins semantics; Name and Arguments are concatenated. Value is not present in deltas and is left nil on seeding.

type ToolResult

type ToolResult struct {
	ToolCallID string `json:"tool_call_id"`
	Content    string `json:"content"`
	Value      any    `json:"-"`
	IsError    bool   `json:"is_error"`
}

ToolResult represents the result of executing a tool call. Content holds a JSON-marshaled fallback string for consumers that do not support custom rendering. Value holds the raw typed result, enabling downstream packages (providers, conduits) to apply custom serialization via LLMRenderer or MarkdownRenderer. When Value is nil or its type is not recognized, consumers fall back to Content.

func (ToolResult) Kind

func (t ToolResult) Kind() string

Kind returns the artifact kind identifier.

func (ToolResult) LLMString added in v0.2.0

func (t ToolResult) LLMString() string

LLMString returns a string representation of the tool result suitable for consumption by an LLM provider. It prefers the custom LLMRenderer on Value, falls back to json.Marshal of Value, and finally falls back to the pre-serialized Content string.

func (ToolResult) MarkdownString added in v0.2.0

func (t ToolResult) MarkdownString() string

MarkdownString returns a string representation of the tool result suitable for human display. It prefers the custom MarkdownRenderer on Value, falls back to json.Marshal of Value, and finally falls back to the pre-serialized Content string.

func (ToolResult) MarshalJSON added in v0.6.0

func (t ToolResult) MarshalJSON() ([]byte, error)

MarshalJSON serializes ToolResult to JSON.

type Usage

type Usage struct {
	PromptTokens     int `json:"prompt_tokens"`
	CompletionTokens int `json:"completion_tokens"`
	TotalTokens      int `json:"total_tokens"`
}

Usage represents token consumption metadata from a provider response.

func (Usage) Kind

func (u Usage) Kind() string

Kind returns the artifact kind identifier.

func (Usage) MarshalJSON added in v0.6.0

func (u Usage) MarshalJSON() ([]byte, error)

MarshalJSON serializes Usage to JSON.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL