agents

package
v0.21.0 Latest Latest
Warning

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

Go to latest
Published: May 17, 2026 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Overview

Package agents defines the provider interface SuperPlane uses to talk to managed-agent backends, and a service layer that persists sessions and routes streamed events through the event distributor.

Index

Constants

This section is empty.

Variables

View Source
var ErrSessionAlreadyTerminated = errors.New("agent session already terminated")
View Source
var ErrSessionForbidden = errors.New("agent session is owned by another user")

Functions

This section is empty.

Types

type CreateSessionOptions

type CreateSessionOptions struct {
	InitialContext string
}

type CreateSessionResult

type CreateSessionResult struct {
	ProviderSessionID string
}

type Provider

type Provider interface {
	Name() string
	CreateSession(ctx context.Context, opts CreateSessionOptions) (*CreateSessionResult, error)
	SendMessage(ctx context.Context, providerSessionID, message string, opts SendMessageOptions) error
	// StreamEvents blocks until the provider closes the stream, ctx is
	// cancelled, or onEvent errors. Implementations must not call onEvent
	// after returning.
	StreamEvents(ctx context.Context, providerSessionID string, onEvent func(ProviderEvent) error) error
}

type ProviderEvent

type ProviderEvent struct {
	ProviderEventID string
	Type            ProviderEventType
	Text            string
	ToolName        string
	ToolCallID      string
	// ToolInput is a human-readable rendering of the tool's invocation
	// (e.g. the shell command for bash, or compact JSON for other tools).
	ToolInput    string
	ErrorMessage string
}

type ProviderEventType

type ProviderEventType string
const (
	ProviderEventAssistantMessage ProviderEventType = "assistant_message"
	ProviderEventToolUseStarted   ProviderEventType = "tool_use_started"
	ProviderEventToolUseFinished  ProviderEventType = "tool_use_finished"
	ProviderEventTurnCompleted    ProviderEventType = "turn_completed"
	ProviderEventSessionFailed    ProviderEventType = "session_failed"
)

type ProviderSessionCleaner

type ProviderSessionCleaner interface {
	Name() string
	DeleteSession(ctx context.Context, providerSessionID string) error
}

type SendMessageOptions

type SendMessageOptions struct {
	ContextPreamble string
}

SendMessageOptions.ContextPreamble is prepended to the user's message so providers that need caller context inline (e.g. a CLI token on first turn) receive it without a separate system message.

type Service

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

func NewService

func NewService(provider Provider, auth authorization.Authorization, jwtSigner *jwt.Signer, baseURL string) *Service

func (*Service) EnsureSession

func (s *Service) EnsureSession(ctx context.Context, organizationID, userID, canvasID uuid.UUID) (*models.AgentSession, error)

EnsureSession returns the user's single chat session for the given canvas, provisioning it on the upstream provider on first call.

func (*Service) GetSession

func (s *Service) GetSession(organizationID, userID, sessionID uuid.UUID) (*models.AgentSession, error)

func (*Service) ListMessages

func (s *Service) ListMessages(sessionID, beforeID uuid.UUID, limit int) ([]models.AgentSessionMessage, error)

func (*Service) ProviderName

func (s *Service) ProviderName() string

func (*Service) SendMessage

func (s *Service) SendMessage(ctx context.Context, organizationID, userID, sessionID uuid.UUID, content string) (*models.AgentSessionMessage, error)

Directories

Path Synopsis
Package anthropic implements agents.Provider against Anthropic's managed-agents API.
Package anthropic implements agents.Provider against Anthropic's managed-agents API.

Jump to

Keyboard shortcuts

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