Documentation
¶
Index ¶
- Constants
- type AgentParticipant
- type Client
- type Config
- type ConversationCompletedData
- type ConversationErrorData
- type ConversationStartedData
- type Emitter
- func (e *Emitter) EmitConversationCompleted(status string, totalMessages int, totalTurns int, totalTokens int, ...)
- func (e *Emitter) EmitConversationError(errorMessage string, errorType string, agentType string)
- func (e *Emitter) EmitConversationStarted(mode string, initialPrompt string, maxTurns int, agents []AgentParticipant)
- func (e *Emitter) EmitMessageCreated(agentType string, agentName string, content string, model string, ...)
- func (e *Emitter) GetConversationID() string
- type Event
- type EventType
- type MessageCreatedData
- type SystemInfo
- type UTCTime
Constants ¶
const DefaultURL = "http://localhost:3000"
DefaultURL is the default base URL for development builds
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AgentParticipant ¶
type AgentParticipant struct {
AgentType string `json:"agent_type"`
Model string `json:"model,omitempty"`
Name string `json:"name,omitempty"`
Prompt string `json:"prompt,omitempty"`
CLIVersion string `json:"cli_version,omitempty"`
}
AgentParticipant contains information about an agent participating in the conversation
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is an HTTP client for sending streaming events to AgentPipe Web
func (*Client) SendEvent ¶
SendEvent sends an event to the streaming endpoint with retry logic Returns an error if all retry attempts fail, but logs errors instead of failing the conversation
func (*Client) SendEventAsync ¶
SendEventAsync sends an event asynchronously in a goroutine (non-blocking) Errors are logged at debug level but do not block or fail the conversation
type Config ¶
type Config struct {
Enabled bool `mapstructure:"enabled"`
URL string `mapstructure:"url"`
APIKey string `mapstructure:"api_key"`
TimeoutMs int `mapstructure:"timeout_ms"`
RetryAttempts int `mapstructure:"retry_attempts"`
LogLevel string `mapstructure:"log_level"`
}
Config holds the configuration for the bridge streaming functionality
func LoadConfig ¶
func LoadConfig() *Config
LoadConfig loads bridge configuration from viper, environment variables, and defaults Precedence: environment variables > viper config > defaults
type ConversationCompletedData ¶
type ConversationCompletedData struct {
ConversationID string `json:"conversation_id"`
Status string `json:"status"` // "completed", "interrupted", "error"
TotalMessages int `json:"total_messages,omitempty"`
TotalTurns int `json:"total_turns,omitempty"`
TotalTokens int `json:"total_tokens,omitempty"`
TotalCost float64 `json:"total_cost,omitempty"`
DurationSeconds float64 `json:"duration_seconds,omitempty"`
}
ConversationCompletedData contains data for conversation.completed events
type ConversationErrorData ¶
type ConversationErrorData struct {
ConversationID string `json:"conversation_id"`
ErrorMessage string `json:"error_message"`
ErrorType string `json:"error_type,omitempty"`
AgentType string `json:"agent_type,omitempty"`
}
ConversationErrorData contains data for conversation.error events
type ConversationStartedData ¶
type ConversationStartedData struct {
ConversationID string `json:"conversation_id"`
Mode string `json:"mode"`
InitialPrompt string `json:"initial_prompt"`
MaxTurns int `json:"max_turns,omitempty"`
Agents []AgentParticipant `json:"agents"`
SystemInfo SystemInfo `json:"system_info"`
}
ConversationStartedData contains data for conversation.started events
type Emitter ¶
type Emitter struct {
// contains filtered or unexported fields
}
Emitter provides high-level methods for emitting streaming events
func NewEmitter ¶
NewEmitter creates a new event emitter for a conversation
func (*Emitter) EmitConversationCompleted ¶
func (e *Emitter) EmitConversationCompleted( status string, totalMessages int, totalTurns int, totalTokens int, totalCost float64, duration time.Duration, )
EmitConversationCompleted emits a conversation.completed event
func (*Emitter) EmitConversationError ¶
EmitConversationError emits a conversation.error event
func (*Emitter) EmitConversationStarted ¶
func (e *Emitter) EmitConversationStarted( mode string, initialPrompt string, maxTurns int, agents []AgentParticipant, )
EmitConversationStarted emits a conversation.started event
func (*Emitter) EmitMessageCreated ¶
func (e *Emitter) EmitMessageCreated( agentType string, agentName string, content string, model string, turnNumber int, tokensUsed int, inputTokens int, outputTokens int, cost float64, duration time.Duration, )
EmitMessageCreated emits a message.created event
func (*Emitter) GetConversationID ¶
GetConversationID returns the conversation ID for this emitter
type Event ¶
type Event struct {
Type EventType `json:"type"`
Timestamp UTCTime `json:"timestamp"`
Data interface{} `json:"data"`
}
Event represents a streaming event sent to the web app
type EventType ¶
type EventType string
EventType represents the type of streaming event
const ( // EventConversationStarted is emitted when a conversation begins EventConversationStarted EventType = "conversation.started" // EventMessageCreated is emitted after each agent completes a message EventMessageCreated EventType = "message.created" // EventConversationCompleted is emitted when conversation ends normally or reaches max turns EventConversationCompleted EventType = "conversation.completed" // EventConversationError is emitted when an error occurs during the conversation EventConversationError EventType = "conversation.error" )
type MessageCreatedData ¶
type MessageCreatedData struct {
ConversationID string `json:"conversation_id"`
MessageID string `json:"message_id"`
AgentType string `json:"agent_type"`
AgentName string `json:"agent_name,omitempty"`
Content string `json:"content"`
SequenceNumber int `json:"sequence_number,omitempty"`
TurnNumber int `json:"turn_number,omitempty"`
TokensUsed int `json:"tokens_used,omitempty"`
InputTokens int `json:"input_tokens,omitempty"`
OutputTokens int `json:"output_tokens,omitempty"`
Cost float64 `json:"cost,omitempty"`
Model string `json:"model,omitempty"`
DurationMs int64 `json:"duration_ms,omitempty"`
}
MessageCreatedData contains data for message.created events
type SystemInfo ¶
type SystemInfo struct {
AgentPipeVersion string `json:"agentpipe_version"`
OS string `json:"os"`
OSVersion string `json:"os_version"`
GoVersion string `json:"go_version"`
Architecture string `json:"architecture"`
}
SystemInfo contains system information collected for streaming events
func CollectSystemInfo ¶
func CollectSystemInfo(version string) SystemInfo
CollectSystemInfo collects system information for the current environment
type UTCTime ¶ added in v0.3.2
UTCTime wraps time.Time to ensure JSON marshaling always uses UTC with Z suffix
func (UTCTime) MarshalJSON ¶ added in v0.3.2
MarshalJSON implements json.Marshaler to output time in UTC with Z suffix