microservice

package
v0.2.13 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2025 License: MIT Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AgentConfigResponse added in v0.1.7

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"`
	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 added in v0.0.34

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

OnComplete registers a handler for completion events

func (*AgentMicroservice) OnContent added in v0.0.34

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

OnContent registers a handler for content events

func (*AgentMicroservice) OnError added in v0.0.34

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

OnError registers a handler for error events

func (*AgentMicroservice) OnThinking added in v0.0.34

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

OnThinking registers a handler for thinking events

func (*AgentMicroservice) OnToolCall added in v0.0.34

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

OnToolCall registers a handler for tool call events

func (*AgentMicroservice) OnToolResult added in v0.0.34

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

OnToolResult registers a handler for tool result events

func (*AgentMicroservice) RunStream added in v0.0.34

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 added in v0.0.34

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 added in v0.1.7

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 DelegateRequest added in v0.1.7

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 added in v0.0.34

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

HTTPServer provides HTTP/SSE endpoints for agent streaming

func NewHTTPServer added in v0.0.34

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

NewHTTPServer creates a new HTTP server for agent streaming

func (*HTTPServer) Start added in v0.0.34

func (h *HTTPServer) Start() error

Start starts the HTTP server

func (*HTTPServer) Stop added in v0.0.34

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

Stop stops the HTTP server

type HTTPServerWithUI added in v0.1.7

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

HTTPServerWithUI extends HTTPServer with embedded UI

func NewHTTPServerWithUI added in v0.1.7

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

NewHTTPServerWithUI creates a new HTTP server with embedded UI

func (*HTTPServerWithUI) GetTraceCollector added in v0.1.8

func (h *HTTPServerWithUI) GetTraceCollector() *UITraceCollector

GetTraceCollector returns the UI trace collector if enabled

func (*HTTPServerWithUI) Start added in v0.1.7

func (h *HTTPServerWithUI) Start() error

Start starts the HTTP server with UI

type MemoryEntry added in v0.1.7

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 added in v0.1.7

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 added in v0.1.7

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 added in v0.0.34

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 added in v0.0.34

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 added in v0.0.34

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 added in v0.1.7

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 added in v0.0.34

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 added in v0.1.7

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"`
	Tracing     *UITracingConfig `json:"tracing,omitempty"`
}

UIConfig represents UI configuration options

type UIFeatures added in v0.1.7

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

type UITrace added in v0.1.8

type UITrace struct {
	ID             string                 `json:"id"`
	Name           string                 `json:"name"`
	StartTime      time.Time              `json:"start_time"`
	EndTime        *time.Time             `json:"end_time,omitempty"`
	Duration       int64                  `json:"duration_ms"`
	Status         string                 `json:"status"` // running, completed, error
	Spans          []UITraceSpan          `json:"spans"`
	Metadata       map[string]interface{} `json:"metadata,omitempty"`
	ConversationID string                 `json:"conversation_id,omitempty"`
	OrgID          string                 `json:"org_id,omitempty"`
	SizeBytes      int                    `json:"size_bytes"`
}

UITrace represents a trace in the UI

type UITraceCollector added in v0.1.8

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

UITraceCollector collects traces for the UI

func NewUITraceCollector added in v0.1.8

func NewUITraceCollector(config *UITracingConfig, wrappedTracer interfaces.Tracer, logger logging.Logger) *UITraceCollector

NewUITraceCollector creates a new UI trace collector

func (*UITraceCollector) DeleteTrace added in v0.1.8

func (c *UITraceCollector) DeleteTrace(traceID string) error

DeleteTrace deletes a trace by ID

func (*UITraceCollector) GetStats added in v0.1.8

func (c *UITraceCollector) GetStats() map[string]interface{}

GetStats returns trace statistics

func (*UITraceCollector) GetTrace added in v0.1.8

func (c *UITraceCollector) GetTrace(traceID string) (*UITrace, error)

GetTrace returns a specific trace by ID

func (*UITraceCollector) GetTraces added in v0.1.8

func (c *UITraceCollector) GetTraces(limit, offset int) ([]UITrace, int)

GetTraces returns all traces (newest first)

func (*UITraceCollector) StartSpan added in v0.1.8

func (c *UITraceCollector) StartSpan(ctx context.Context, name string) (context.Context, interfaces.Span)

StartSpan starts a new span and collects it

func (*UITraceCollector) StartTraceSession added in v0.1.8

func (c *UITraceCollector) StartTraceSession(ctx context.Context, contextID string) (context.Context, interfaces.Span)

StartTraceSession starts a root trace session

type UITraceError added in v0.1.8

type UITraceError struct {
	Message    string    `json:"message"`
	Type       string    `json:"type,omitempty"`
	Stacktrace string    `json:"stacktrace,omitempty"`
	Timestamp  time.Time `json:"timestamp"`
}

UITraceError represents an error in a span

type UITraceEvent added in v0.1.8

type UITraceEvent struct {
	Name       string                 `json:"name"`
	Timestamp  time.Time              `json:"timestamp"`
	Attributes map[string]interface{} `json:"attributes,omitempty"`
}

UITraceEvent represents an event in a span

type UITraceSpan added in v0.1.8

type UITraceSpan struct {
	ID         string                 `json:"id"`
	TraceID    string                 `json:"trace_id"`
	ParentID   string                 `json:"parent_id,omitempty"`
	Name       string                 `json:"name"`
	Type       string                 `json:"type"` // generation, tool_call, span, event
	StartTime  time.Time              `json:"start_time"`
	EndTime    *time.Time             `json:"end_time,omitempty"`
	Duration   int64                  `json:"duration_ms"`
	Events     []UITraceEvent         `json:"events,omitempty"`
	Attributes map[string]interface{} `json:"attributes,omitempty"`
	Error      *UITraceError          `json:"error,omitempty"`
	Input      string                 `json:"input,omitempty"`
	Output     string                 `json:"output,omitempty"`
}

UITraceSpan represents a span in a trace

type UITracingConfig added in v0.1.8

type UITracingConfig struct {
	Enabled         bool   `json:"enabled"`
	MaxBufferSizeKB int    `json:"max_buffer_size_kb"` // Default: 10240 (10MB)
	MaxTraceAge     string `json:"max_trace_age"`      // Default: "1h"
	RetentionCount  int    `json:"retention_count"`    // Default: 100 traces
}

UITracingConfig contains configuration for UI tracing

Jump to

Keyboard shortcuts

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