microservice

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2026 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AgentConfigResponse

type AgentConfigResponse struct {
	Name         string                 `json:"name"`
	Description  string                 `json:"description"`
	Model        string                 `json:"model"`
	SystemPrompt string                 `json:"system_prompt"`
	Tools        []string               `json:"tools"`
	Memory       MemoryInfo             `json:"memory"`
	DataStore    DataStoreInfo          `json:"datastore"`
	SubAgents    []SubAgentInfo         `json:"sub_agents,omitempty"`
	Features     UIFeatures             `json:"features"`
	UITheme      string                 `json:"ui_theme,omitempty"`
	Metadata     map[string]interface{} `json:"metadata,omitempty"`
}

AgentConfigResponse represents detailed agent configuration

type AgentMicroservice

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

AgentMicroservice represents a microservice wrapping an agent

func CreateMicroservice

func CreateMicroservice(agent *agent.Agent, config Config) (*AgentMicroservice, error)

CreateMicroservice creates a new agent microservice

func (*AgentMicroservice) GetAgent

func (m *AgentMicroservice) GetAgent() *agent.Agent

GetAgent returns the underlying agent

func (*AgentMicroservice) GetPort

func (m *AgentMicroservice) GetPort() int

GetPort returns the port the microservice is running on

func (*AgentMicroservice) GetURL

func (m *AgentMicroservice) GetURL() string

GetURL returns the URL of the microservice

func (*AgentMicroservice) IsRunning

func (m *AgentMicroservice) IsRunning() bool

IsRunning returns true if the microservice is currently running

func (*AgentMicroservice) OnComplete

func (m *AgentMicroservice) OnComplete(handler func()) *AgentMicroservice

OnComplete registers a handler for completion events

func (*AgentMicroservice) OnContent

func (m *AgentMicroservice) OnContent(handler func(string)) *AgentMicroservice

OnContent registers a handler for content events

func (*AgentMicroservice) OnError

func (m *AgentMicroservice) OnError(handler func(error)) *AgentMicroservice

OnError registers a handler for error events

func (*AgentMicroservice) OnThinking

func (m *AgentMicroservice) OnThinking(handler func(string)) *AgentMicroservice

OnThinking registers a handler for thinking events

func (*AgentMicroservice) OnToolCall

func (m *AgentMicroservice) OnToolCall(handler func(*interfaces.ToolCallEvent)) *AgentMicroservice

OnToolCall registers a handler for tool call events

func (*AgentMicroservice) OnToolResult

func (m *AgentMicroservice) OnToolResult(handler func(*interfaces.ToolCallEvent)) *AgentMicroservice

OnToolResult registers a handler for tool result events

func (*AgentMicroservice) RunStream

func (m *AgentMicroservice) RunStream(ctx context.Context, input string) (<-chan interfaces.AgentStreamEvent, error)

RunStream executes the agent with streaming response

func (*AgentMicroservice) Start

func (m *AgentMicroservice) Start() error

Start starts the microservice

func (*AgentMicroservice) Stop

func (m *AgentMicroservice) Stop() error

Stop stops the microservice

func (*AgentMicroservice) Stream

func (m *AgentMicroservice) Stream(ctx context.Context, input string) error

Stream executes the agent with registered event handlers

func (*AgentMicroservice) WaitForReady

func (m *AgentMicroservice) WaitForReady(timeout time.Duration) error

WaitForReady waits for the microservice to be ready to serve requests

type Config

type Config struct {
	Port    int           // Port to run the service on (0 for auto-assign)
	Timeout time.Duration // Request timeout
}

Config holds configuration for creating an agent microservice

type ConversationInfo

type ConversationInfo struct {
	ID           string `json:"id"`
	MessageCount int    `json:"message_count"`
	LastActivity int64  `json:"last_activity"`
	LastMessage  string `json:"last_message,omitempty"`
}

ConversationInfo represents conversation metadata

type DataStoreInfo

type DataStoreInfo struct {
	Type   string `json:"type"`   // "postgres", "supabase", "none"
	Status string `json:"status"` // "active", "inactive"
}

DataStoreInfo represents datastore/database connection information

type DelegateRequest

type DelegateRequest struct {
	SubAgentID     string            `json:"sub_agent_id"`
	Task           string            `json:"task"`
	Context        map[string]string `json:"context,omitempty"`
	ConversationID string            `json:"conversation_id,omitempty"`
}

DelegateRequest represents a request to delegate to a sub-agent

type HTTPServer

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

HTTPServer provides HTTP/SSE endpoints for agent streaming

func NewHTTPServer

func NewHTTPServer(agent *agent.Agent, port int) *HTTPServer

NewHTTPServer creates a new HTTP server for agent streaming

func (*HTTPServer) Start

func (h *HTTPServer) Start() error

Start starts the HTTP server

func (*HTTPServer) Stop

func (h *HTTPServer) Stop(ctx context.Context) error

Stop stops the HTTP server

type HTTPServerWithUI

type HTTPServerWithUI struct {
	HTTPServer // Embed the base HTTPServer
	// contains filtered or unexported fields
}

HTTPServerWithUI extends HTTPServer with embedded UI

func NewHTTPServerWithUI

func NewHTTPServerWithUI(agent *agent.Agent, port int, config *UIConfig) *HTTPServerWithUI

NewHTTPServerWithUI creates a new HTTP server with embedded UI

func (*HTTPServerWithUI) Start

func (h *HTTPServerWithUI) Start() error

Start starts the HTTP server with UI

type MemoryEntry

type MemoryEntry struct {
	ID             string                 `json:"id"`
	Role           string                 `json:"role"`
	Content        string                 `json:"content"`
	Timestamp      int64                  `json:"timestamp"`
	ConversationID string                 `json:"conversation_id,omitempty"`
	Metadata       map[string]interface{} `json:"metadata,omitempty"`
}

MemoryEntry represents a memory entry for the browser

type MemoryInfo

type MemoryInfo struct {
	Type        string `json:"type"`
	Status      string `json:"status"`
	EntryCount  int    `json:"entry_count,omitempty"`
	MaxCapacity int    `json:"max_capacity,omitempty"`
}

MemoryInfo represents memory system information

type MemoryResponse

type MemoryResponse struct {
	Mode           string             `json:"mode"` // "conversations" or "messages"
	Conversations  []ConversationInfo `json:"conversations,omitempty"`
	Messages       []MemoryEntry      `json:"messages,omitempty"`
	Total          int                `json:"total"`
	Limit          int                `json:"limit"`
	Offset         int                `json:"offset"`
	ConversationID string             `json:"conversation_id,omitempty"`
}

MemoryResponse represents the response structure for memory endpoints

type MicroserviceManager

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

MicroserviceManager manages multiple agent microservices

func NewMicroserviceManager

func NewMicroserviceManager() *MicroserviceManager

NewMicroserviceManager creates a new microservice manager

func (*MicroserviceManager) GetService

func (mm *MicroserviceManager) GetService(name string) (*AgentMicroservice, bool)

GetService returns a service by name

func (*MicroserviceManager) ListServices

func (mm *MicroserviceManager) ListServices() []string

ListServices returns all registered service names

func (*MicroserviceManager) RegisterService

func (mm *MicroserviceManager) RegisterService(name string, service *AgentMicroservice) error

RegisterService registers a microservice with the manager

func (*MicroserviceManager) StartAll

func (mm *MicroserviceManager) StartAll() error

StartAll starts all registered services

func (*MicroserviceManager) StartService

func (mm *MicroserviceManager) StartService(name string) error

StartService starts a service by name

func (*MicroserviceManager) StopAll

func (mm *MicroserviceManager) StopAll() error

StopAll stops all running services

func (*MicroserviceManager) StopService

func (mm *MicroserviceManager) StopService(name string) error

StopService stops a service by name

type SSEEvent

type SSEEvent struct {
	Event     string      `json:"event"`
	Data      interface{} `json:"data"`
	ID        string      `json:"id,omitempty"`
	Retry     int         `json:"retry,omitempty"`
	Timestamp int64       `json:"timestamp"`
}

SSEEvent represents a Server-Sent Event

type StreamEventData

type StreamEventData struct {
	Type         string                 `json:"type"`
	Content      string                 `json:"content,omitempty"`
	ThinkingStep string                 `json:"thinking_step,omitempty"`
	ToolCall     *ToolCallData          `json:"tool_call,omitempty"`
	Error        string                 `json:"error,omitempty"`
	Metadata     map[string]interface{} `json:"metadata,omitempty"`
	IsFinal      bool                   `json:"is_final"`
	Timestamp    int64                  `json:"timestamp"`
}

StreamEventData represents the data structure for streaming events

type StreamRequest

type StreamRequest struct {
	Input          string            `json:"input"`
	OrgID          string            `json:"org_id,omitempty"`
	ConversationID string            `json:"conversation_id,omitempty"`
	Context        map[string]string `json:"context,omitempty"`
	MaxIterations  int               `json:"max_iterations,omitempty"`
}

StreamRequest represents the JSON request for streaming

type SubAgentInfo

type SubAgentInfo struct {
	ID           string   `json:"id"`
	Name         string   `json:"name"`
	Description  string   `json:"description"`
	Model        string   `json:"model"`
	Status       string   `json:"status"`
	Tools        []string `json:"tools"`
	Capabilities []string `json:"capabilities,omitempty"`
}

SubAgentInfo represents sub-agent information for UI

type ToolCallData

type ToolCallData struct {
	ID        string `json:"id,omitempty"`
	Name      string `json:"name"`
	Arguments string `json:"arguments,omitempty"`
	Result    string `json:"result,omitempty"`
	Status    string `json:"status"`
}

ToolCallData represents tool call information for HTTP/SSE

type UIConfig

type UIConfig struct {
	Enabled     bool       `json:"enabled"`
	DefaultPath string     `json:"default_path"`
	DevMode     bool       `json:"dev_mode"`
	Theme       string     `json:"theme"`
	Features    UIFeatures `json:"features"`
}

UIConfig represents UI configuration options

type UIFeatures

type UIFeatures struct {
	Chat      bool `json:"chat"`
	Memory    bool `json:"memory"`
	AgentInfo bool `json:"agent_info"`
	Settings  bool `json:"settings"`
	Traces    bool `json:"traces"`
}

UIFeatures represents available UI features

Jump to

Keyboard shortcuts

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