client

package
v1.252.0 Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewClientFromEnv added in v1.229.0

func NewClientFromEnv() (*Client, *Config, error)

NewClientFromEnv creates a new client from environment variables

Types

type Client

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

Client represents an agentapi-proxy client

func NewClient

func NewClient(baseURL string, opts ...ClientOption) *Client

NewClient creates a new agentapi-proxy client with options

func (*Client) CreateTask added in v1.249.0

func (c *Client) CreateTask(ctx context.Context, sessionID string, req *CreateTaskRequest) (*TaskResponse, error)

CreateTask creates a new task associated with the given session. sessionID is required and will be embedded in the request body.

func (*Client) DeleteSession added in v0.11.0

func (c *Client) DeleteSession(ctx context.Context, sessionID string) (*DeleteResponse, error)

DeleteSession terminates and deletes a session

func (*Client) DeleteTask added in v1.249.0

func (c *Client) DeleteTask(ctx context.Context, taskID string) error

DeleteTask deletes a task by its ID

func (*Client) GetMessages

func (c *Client) GetMessages(ctx context.Context, sessionID string) (*MessagesResponse, error)

GetMessages retrieves conversation history from an agentapi session

func (*Client) GetStatus

func (c *Client) GetStatus(ctx context.Context, sessionID string) (*StatusResponse, error)

GetStatus retrieves the current agent status from an agentapi session

func (*Client) GetTask added in v1.249.0

func (c *Client) GetTask(ctx context.Context, taskID string) (*TaskResponse, error)

GetTask retrieves a task by its ID

func (*Client) ListTasks added in v1.249.0

func (c *Client) ListTasks(ctx context.Context, opts *ListTasksOptions) (*TaskListResponse, error)

ListTasks retrieves a list of tasks with optional filters

func (*Client) Search

func (c *Client) Search(ctx context.Context, status string) (*SearchResponse, error)

Search lists and filters sessions

func (*Client) SearchWithTags added in v0.5.0

func (c *Client) SearchWithTags(ctx context.Context, status string, tags map[string]string) (*SearchResponse, error)

SearchWithTags lists and filters sessions with tag support

func (*Client) SendMessage

func (c *Client) SendMessage(ctx context.Context, sessionID string, message *Message) (*MessageResponse, error)

SendMessage sends a message to an agentapi session

func (*Client) Start

func (c *Client) Start(ctx context.Context, req *StartRequest) (*StartResponse, error)

Start creates a new agentapi session

func (*Client) StreamEvents

func (c *Client) StreamEvents(ctx context.Context, sessionID string) (<-chan string, <-chan error)

StreamEvents subscribes to Server-Sent Events (SSE) from an agentapi session

func (*Client) UpdateTask added in v1.249.0

func (c *Client) UpdateTask(ctx context.Context, taskID string, req *UpdateTaskRequest) (*TaskResponse, error)

UpdateTask partially updates an existing task

type ClientOption added in v1.229.0

type ClientOption func(*Client)

ClientOption is a function that configures a Client

func WithAPIKeyAuth added in v1.229.0

func WithAPIKeyAuth(apiKey string) ClientOption

WithAPIKeyAuth adds API key authentication middleware

func WithHTTPClient added in v1.229.0

func WithHTTPClient(httpClient HTTPClient) ClientOption

WithHTTPClient sets a custom HTTP client

func WithRequestMiddleware added in v1.229.0

func WithRequestMiddleware(middleware RequestMiddleware) ClientOption

WithRequestMiddleware adds a custom request middleware

type Config added in v1.229.0

type Config struct {
	Endpoint  string
	SessionID string
	APIKey    string
}

Config holds the client configuration

func ConfigFromEnv added in v1.229.0

func ConfigFromEnv() (*Config, error)

ConfigFromEnv creates a client configuration from environment variables

type CreateTaskRequest added in v1.249.0

type CreateTaskRequest struct {
	Title       string     `json:"title"`
	Description string     `json:"description,omitempty"`
	TaskType    string     `json:"task_type"`         // "user" or "agent"
	Scope       string     `json:"scope"`             // "user" or "team"
	TeamID      string     `json:"team_id,omitempty"` // required when scope=="team"
	GroupID     string     `json:"group_id,omitempty"`
	SessionID   string     `json:"session_id"` // set from function argument
	Links       []TaskLink `json:"links,omitempty"`
}

CreateTaskRequest represents the request body for creating a new task. SessionID is set automatically from the sessionID function argument.

type DeleteResponse added in v0.11.0

type DeleteResponse struct {
	Message   string `json:"message"`
	SessionID string `json:"session_id"`
}

DeleteResponse represents the response from deleting a session

type HTTPClient added in v1.229.0

type HTTPClient interface {
	Do(req *http.Request) (*http.Response, error)
}

HTTPClient defines the interface for making HTTP requests

type ListTasksOptions added in v1.249.0

type ListTasksOptions struct {
	Scope    string // "user" or "team"
	TeamID   string
	GroupID  string
	Status   string // "todo" or "done"
	TaskType string // "user" or "agent"
}

ListTasksOptions specifies optional filters for listing tasks

type Message

type Message struct {
	Content   string    `json:"content"`
	Type      string    `json:"type"` // "user" or "raw"
	Role      string    `json:"role,omitempty"`
	Timestamp time.Time `json:"timestamp,omitempty"`
	ID        string    `json:"id,omitempty"`
}

Message represents an agentapi message

type MessageResponse

type MessageResponse struct {
	OK bool `json:"ok"`
}

MessageResponse represents the response from sending a message

type MessagesResponse

type MessagesResponse struct {
	Messages []Message `json:"messages"`
}

MessagesResponse represents the response from getting messages

type RequestMiddleware added in v1.229.0

type RequestMiddleware func(*http.Request) error

RequestMiddleware is a function that modifies an HTTP request

type SearchResponse

type SearchResponse struct {
	Sessions []SessionInfo `json:"sessions"`
}

SearchResponse represents the response from searching sessions

type SessionInfo

type SessionInfo struct {
	SessionID string            `json:"session_id"`
	UserID    string            `json:"user_id"`
	Status    string            `json:"status"`
	StartedAt time.Time         `json:"started_at"`
	Port      int               `json:"port"`
	Tags      map[string]string `json:"tags,omitempty"`
}

SessionInfo represents information about a session

type StartRequest

type StartRequest struct {
	Environment map[string]string `json:"environment,omitempty"`
	Tags        map[string]string `json:"tags,omitempty"`
}

StartRequest represents the request body for starting a new agentapi server

type StartResponse

type StartResponse struct {
	SessionID string `json:"session_id"`
}

StartResponse represents the response from starting a new agentapi server

type StatusResponse

type StatusResponse struct {
	Status string `json:"status"` // "stable" or "running"
}

StatusResponse represents the agent status

type TaskLink struct {
	ID    string `json:"id,omitempty"`
	URL   string `json:"url"`
	Title string `json:"title,omitempty"`
}

TaskLink represents a link associated with a task

type TaskListResponse added in v1.249.0

type TaskListResponse struct {
	Tasks []*TaskResponse `json:"tasks"`
	Total int             `json:"total"`
}

TaskListResponse represents a list of tasks

type TaskResponse added in v1.249.0

type TaskResponse struct {
	ID          string     `json:"id"`
	Title       string     `json:"title"`
	Description string     `json:"description,omitempty"`
	Status      string     `json:"status"`
	TaskType    string     `json:"task_type"`
	Scope       string     `json:"scope"`
	OwnerID     string     `json:"owner_id"`
	TeamID      string     `json:"team_id,omitempty"`
	GroupID     string     `json:"group_id,omitempty"`
	SessionID   string     `json:"session_id,omitempty"`
	Links       []TaskLink `json:"links"`
	CreatedAt   string     `json:"created_at"`
	UpdatedAt   string     `json:"updated_at"`
}

TaskResponse represents a single task returned by the API

type UpdateTaskRequest added in v1.249.0

type UpdateTaskRequest struct {
	Title       *string     `json:"title,omitempty"`
	Description *string     `json:"description,omitempty"`
	Status      *string     `json:"status,omitempty"` // "todo" or "done"
	GroupID     *string     `json:"group_id,omitempty"`
	SessionID   *string     `json:"session_id,omitempty"`
	Links       *[]TaskLink `json:"links,omitempty"`
}

UpdateTaskRequest represents the request body for partially updating a task. Only non-nil fields are updated.

Jump to

Keyboard shortcuts

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