Versions in this module Expand all Collapse all v0 v0.1.0 Jan 10, 2026 Changes in this version + var ErrAlreadyConnected = errors.New("agent already connected") + var ErrAlreadyExists = &AthyrError + var ErrDeadlineExceeded = &AthyrError + var ErrInternal = &AthyrError + var ErrInvalidArgument = &AthyrError + var ErrNotConnected = errors.New("agent not connected") + var ErrNotFound = &AthyrError + var ErrPermissionDenied = &AthyrError + var ErrUnauthenticated = &AthyrError + var ErrUnavailable = &AthyrError + func BadRequest(format string, args ...any) error + func Internal(format string, args ...any) error + func IsAlreadyExists(err error) bool + func IsBadRequest(err error) bool + func IsDeadlineExceeded(err error) bool + func IsInternal(err error) bool + func IsNotFound(err error) bool + func IsPermissionDenied(err error) bool + func IsUnauthenticated(err error) bool + func IsUnavailable(err error) bool + func NotFound(format string, args ...any) error + func RunRaw(ctx context.Context, addr, subject string, handler RawHandler, ...) error + func Run[Req, Resp any](ctx context.Context, addr, subject string, handler Handler[Req, Resp], ...) error + func Unavailable(format string, args ...any) error + type Agent interface + AddHint func(ctx context.Context, sessionID, hint string) error + AgentID func() string + Close func() error + Complete func(ctx context.Context, req CompletionRequest) (*CompletionResponse, error) + CompleteStream func(ctx context.Context, req CompletionRequest, handler StreamHandler) error + Connect func(ctx context.Context) error + Connected func() bool + CreateSession func(ctx context.Context, profile SessionProfile, systemPrompt string) (*Session, error) + DeleteSession func(ctx context.Context, sessionID string) error + GetSession func(ctx context.Context, sessionID string) (*Session, error) + KV func(bucket string) KVBucket + Models func(ctx context.Context) ([]Model, error) + Publish func(ctx context.Context, subject string, data []byte) error + QueueSubscribe func(ctx context.Context, subject, queue string, handler MessageHandler) (Subscription, error) + Request func(ctx context.Context, subject string, data []byte) ([]byte, error) + State func() ConnectionState + Subscribe func(ctx context.Context, subject string, handler MessageHandler) (Subscription, error) + func MustConnect(addr string, opts ...AgentOption) Agent + func NewAgent(addr string, opts ...AgentOption) (Agent, error) + type AgentCard struct + Capabilities []string + Description string + Metadata map[string]string + Name string + Version string + type AgentOption func(*agentOptions) + func WithAgentCard(card AgentCard) AgentOption + func WithAutoReconnect(maxRetries int, baseBackoff time.Duration) AgentOption + func WithCapabilities(caps ...string) AgentOption + func WithConnectionCallback(cb ConnectionCallback) AgentOption + func WithHeartbeatInterval(d time.Duration) AgentOption + func WithInsecure() AgentOption + func WithLogger(logger Logger) AgentOption + func WithMaxBackoff(d time.Duration) AgentOption + func WithRequestTimeout(d time.Duration) AgentOption + func WithSystemTLS() AgentOption + func WithTLS(certFile string) AgentOption + func WithTLSConfig(cfg *tls.Config) AgentOption + type AthyrError struct + Cause error + Code ErrorCode + Message string + Op string + func (e *AthyrError) Error() string + func (e *AthyrError) Is(target error) bool + func (e *AthyrError) Unwrap() error + type CompletionConfig struct + MaxTokens int + Stop []string + Temperature float64 + TopP float64 + type CompletionRequest struct + Config CompletionConfig + IncludeMemory bool + Messages []Message + Model string + SessionID string + ToolChoice string + Tools []Tool + type CompletionResponse struct + Backend string + Content string + FinishReason string + Latency time.Duration + Model string + ToolCalls []ToolCall + Usage TokenUsage + type ConnectionCallback func(state ConnectionState, err error) + type ConnectionState int + const StateConnected + const StateConnecting + const StateDisconnected + const StateReconnecting + func (s ConnectionState) String() string + type Context interface + Agent func() Agent + ReplySubject func() string + Subject func() string + type ErrorCode string + const ErrCodeAlreadyExists + const ErrCodeDeadlineExceeded + const ErrCodeInternal + const ErrCodeInvalidArgument + const ErrCodeNotFound + const ErrCodePermissionDenied + const ErrCodeUnauthenticated + const ErrCodeUnavailable + const ErrCodeUnknown + type Handler func(ctx Context, req Req) (Resp, error) + type KVBucket interface + Delete func(ctx context.Context, key string) error + Get func(ctx context.Context, key string) (*KVEntry, error) + List func(ctx context.Context, prefix string) ([]string, error) + Put func(ctx context.Context, key string, value []byte) (uint64, error) + type KVEntry struct + Revision uint64 + Value []byte + type Logger interface + Debug func(msg string, args ...any) + Error func(msg string, args ...any) + Info func(msg string, args ...any) + Warn func(msg string, args ...any) + type Message struct + Content string + Role string + ToolCallID string + ToolCalls []ToolCall + type MessageHandler func(msg SubscribeMessage) + type MetricsCallback func(subject string, duration time.Duration, err error) + type Middleware func(RawHandler) RawHandler + func Chain(mw ...Middleware) Middleware + func LogRequests(logger *log.Logger) Middleware + func Metrics(callback MetricsCallback) Middleware + func RateLimit(maxConcurrent int) Middleware + func Recover(logger *log.Logger) Middleware + func Retry(maxAttempts int, backoff time.Duration) Middleware + func Timeout(d time.Duration) Middleware + func Validate(validator func(data []byte) error) Middleware + type Model struct + Available bool + Backend string + ID string + Name string + type RawHandler func(ctx Context, data []byte) ([]byte, error) + type Server struct + func Handle[Req, Resp any](s *Server, subject string, handler Handler[Req, Resp], opts ...ServiceOption) *Server + func NewServer(addr string, opts ...ServerOption) *Server + func (s *Server) Add(svc *Service) *Server + func (s *Server) HandleRaw(subject string, handler RawHandler, opts ...ServiceOption) *Server + func (s *Server) Run(ctx context.Context) error + type ServerOption func(*Server) + func WithAgentDescription(desc string) ServerOption + func WithAgentName(name string) ServerOption + func WithMiddleware(mw ...Middleware) ServerOption + func WithServerInsecure() ServerOption + func WithServerTLS(certFile string) ServerOption + func WithServerTLSConfig(cfg *tls.Config) ServerOption + func WithVersion(version string) ServerOption + type Service struct + func NewRawService(subject string, handler RawHandler, opts ...ServiceOption) *Service + func NewService[Req, Resp any](subject string, handler Handler[Req, Resp], opts ...ServiceOption) *Service + func (s *Service) BuildHandler(globalMiddleware []Middleware) RawHandler + type ServiceError struct + Code string + Details any + Message string + func (e *ServiceError) Error() string + type ServiceOption func(*Service) + func WithName(name string) ServiceOption + func WithQueueGroup(group string) ServiceOption + func WithServiceMiddleware(mw ...Middleware) ServiceOption + type Session struct + AgentID string + CreatedAt time.Time + Hints []string + ID string + Messages []SessionMessage + Profile SessionProfile + Summary string + SystemPrompt string + UpdatedAt time.Time + type SessionMessage struct + Content string + Role string + Timestamp time.Time + Tokens int + type SessionProfile struct + MaxTokens int + SummarizationThreshold int + Type string + func DefaultSessionProfile() SessionProfile + type StreamChunk struct + Backend string + Content string + Done bool + Error string + Model string + ToolCalls []ToolCall + Usage *TokenUsage + type StreamError struct + AccumulatedContent string + Backend string + Err error + PartialResponse bool + func (e *StreamError) Error() string + func (e *StreamError) Unwrap() error + type StreamHandler func(chunk StreamChunk) error + type SubscribeMessage struct + Data []byte + Reply string + Subject string + type Subscription interface + Unsubscribe func() error + type TokenUsage struct + CompletionTokens int + PromptTokens int + TotalTokens int + type Tool struct + Description string + Name string + Parameters json.RawMessage + type ToolCall struct + Arguments json.RawMessage + ID string + Name string