a2a

package
v1.3.2 Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package a2a provides the A2A task store and executor for the SDK.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrTaskNotFound      = errors.New("a2a: task not found")
	ErrTaskAlreadyExists = errors.New("a2a: task already exists")
	ErrInvalidTransition = errors.New("a2a: invalid state transition")
	ErrTaskTerminal      = errors.New("a2a: task is in a terminal state")
)

Task store errors.

Functions

func NewExecutor

func NewExecutor() *rta2a.Executor

NewExecutor returns the shared A2A executor from runtime/a2a.

Types

type InMemoryTaskStore

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

InMemoryTaskStore is a concurrency-safe, in-memory implementation of TaskStore.

func NewInMemoryTaskStore

func NewInMemoryTaskStore() *InMemoryTaskStore

NewInMemoryTaskStore creates a new InMemoryTaskStore.

func (*InMemoryTaskStore) AddArtifacts

func (s *InMemoryTaskStore) AddArtifacts(taskID string, artifacts []rta2a.Artifact) error

AddArtifacts appends artifacts to a task.

func (*InMemoryTaskStore) Cancel

func (s *InMemoryTaskStore) Cancel(taskID string) error

Cancel transitions the task to the canceled state from any non-terminal state.

func (*InMemoryTaskStore) Create

func (s *InMemoryTaskStore) Create(taskID, contextID string) (*rta2a.Task, error)

Create initializes a new task in the submitted state.

func (*InMemoryTaskStore) EvictTerminal

func (s *InMemoryTaskStore) EvictTerminal(cutoff time.Time) []string

EvictTerminal removes tasks in a terminal state whose last status timestamp is older than cutoff. It returns the IDs of evicted tasks.

func (*InMemoryTaskStore) Get

func (s *InMemoryTaskStore) Get(taskID string) (*rta2a.Task, error)

Get retrieves a task by ID.

func (*InMemoryTaskStore) List

func (s *InMemoryTaskStore) List(contextID string, limit, offset int) ([]*rta2a.Task, error)

List returns tasks matching the given contextID with pagination. If contextID is empty, all tasks are returned. Offset and limit control pagination.

func (*InMemoryTaskStore) SetState

func (s *InMemoryTaskStore) SetState(taskID string, state rta2a.TaskState, msg *rta2a.Message) error

SetState transitions the task to a new state with an optional status message.

type TaskStore

type TaskStore interface {
	Create(taskID, contextID string) (*rta2a.Task, error)
	Get(taskID string) (*rta2a.Task, error)
	SetState(taskID string, state rta2a.TaskState, msg *rta2a.Message) error
	AddArtifacts(taskID string, artifacts []rta2a.Artifact) error
	Cancel(taskID string) error
	List(contextID string, limit, offset int) ([]*rta2a.Task, error)

	// EvictTerminal removes tasks in a terminal state whose last status
	// timestamp is older than the given cutoff time. It returns the IDs
	// of evicted tasks so callers can clean up associated resources.
	EvictTerminal(olderThan time.Time) []string
}

TaskStore defines the interface for task persistence and lifecycle management.

Jump to

Keyboard shortcuts

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