artifact

package
v1.2.2 Latest Latest
Warning

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

Go to latest
Published: Jul 8, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package artifact defines runtime contracts for storing and loading run artifacts produced by tools.

Index

Constants

This section is empty.

Variables

View Source
var ErrNotFound = errors.New("artifact not found")

ErrNotFound reports that an artifact does not exist in the requested agent/run scope.

Functions

This section is empty.

Types

type Content

type Content struct {
	Ref       Ref
	Body      []byte
	Truncated bool
	SizeBytes int64
}

Content carries an artifact body inside the process. Runtime code converts Content to Ref before crossing workflow or hook boundaries.

type ListQuery

type ListQuery struct {
	AgentID  string
	RunID    string
	MimeType string
	Metadata map[string]string
	Limit    int
}

ListQuery filters artifact refs within one agent/run scope.

type LoadQuery

type LoadQuery struct {
	AgentID  string
	RunID    string
	ID       string
	MaxBytes int
}

LoadQuery selects one artifact body and optionally caps returned bytes.

type MemoryStore

type MemoryStore struct {
	// contains filtered or unexported fields
}

MemoryStore is an in-process artifact store for tests and local development. Data is lost when the process exits.

func NewMemoryStore

func NewMemoryStore() *MemoryStore

NewMemoryStore returns an empty in-memory artifact store.

func (*MemoryStore) List

func (s *MemoryStore) List(_ context.Context, query ListQuery) ([]Ref, error)

List returns artifact refs matching query filters in creation order.

func (*MemoryStore) Load

func (s *MemoryStore) Load(_ context.Context, query LoadQuery) (Content, error)

Load returns an artifact body from the requested agent/run scope.

func (*MemoryStore) Save

func (s *MemoryStore) Save(_ context.Context, input SaveInput) (Ref, error)

Save stores an artifact and returns its workflow-safe reference.

type Ref

type Ref struct {
	ID         string            `json:"id"`
	AgentID    string            `json:"agent_id"`
	RunID      string            `json:"run_id"`
	ToolCallID string            `json:"tool_call_id,omitempty"`
	Name       string            `json:"name,omitempty"`
	MimeType   string            `json:"mime_type,omitempty"`
	SizeBytes  int64             `json:"size_bytes"`
	Metadata   map[string]string `json:"metadata,omitempty"`
	CreatedAt  time.Time         `json:"created_at,omitempty"`
}

Ref is the workflow-safe artifact reference carried through planner, hook, and API boundaries. It intentionally contains no artifact body.

type SaveInput

type SaveInput struct {
	AgentID    string
	RunID      string
	ToolCallID string
	Name       string
	MimeType   string
	Metadata   map[string]string
	Body       []byte
}

SaveInput describes one artifact to persist.

type Store

type Store interface {
	Save(ctx context.Context, input SaveInput) (Ref, error)
	List(ctx context.Context, query ListQuery) ([]Ref, error)
	Load(ctx context.Context, query LoadQuery) (Content, error)
}

Store persists artifacts by agent and run. Implementations must be safe for concurrent use and must isolate artifacts across AgentID plus RunID.

Jump to

Keyboard shortcuts

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