Documentation
¶
Index ¶
- Constants
- type AgentParticipant
- type BridgeConnectedData
- type BridgeEmitter
- type BridgeTestData
- type Client
- type CommandInfo
- type Config
- type ConversationCompletedData
- type ConversationErrorData
- type ConversationStartedData
- type Emitter
- func (e *Emitter) Close() error
- 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(agentID string, agentType string, agentName string, content string, ...)
- func (e *Emitter) GetConversationID() string
- type Event
- type EventStore
- type EventType
- type LogEntryData
- type LogEntryMetrics
- type MessageCreatedData
- type StdoutEmitter
- func (e *StdoutEmitter) Close() error
- func (e *StdoutEmitter) EmitConversationCompleted(status string, totalMessages int, totalTurns int, totalTokens int, ...)
- func (e *StdoutEmitter) EmitConversationError(errorMessage string, errorType string, agentType string)
- func (e *StdoutEmitter) EmitConversationStarted(mode string, initialPrompt string, maxTurns int, ...)
- func (e *StdoutEmitter) EmitLogEntry(level string, agentID string, agentName string, agentType string, ...)
- func (e *StdoutEmitter) EmitMessageCreated(agentID string, agentType string, agentName string, content string, ...)
- func (e *StdoutEmitter) GetConversationID() string
- type SummaryMetadata
- type SystemInfo
- type UTCTime
- type ZerologJSONWriter
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 {
AgentID string `json:"agent_id"` // Unique identifier for this agent instance
AgentType string `json:"agent_type"` // Type of agent (e.g., "claude", "gemini")
Model string `json:"model,omitempty"` // Model used by the agent
Name string `json:"name,omitempty"` // Display name of the agent
Prompt string `json:"prompt,omitempty"` // System prompt for the agent
CLIVersion string `json:"cli_version,omitempty"` // Version of the agent CLI
}
AgentParticipant contains information about an agent participating in the conversation
type BridgeConnectedData ¶ added in v0.4.0
type BridgeConnectedData struct {
SystemInfo SystemInfo `json:"system_info"`
ConnectedAt string `json:"connected_at"`
}
BridgeConnectedData contains data for bridge.connected events
type BridgeEmitter ¶ added in v0.5.3
type BridgeEmitter interface {
GetConversationID() string
EmitConversationStarted(
mode string,
initialPrompt string,
maxTurns int,
participants []AgentParticipant,
commandInfo *CommandInfo,
)
EmitMessageCreated(
agentID string,
agentType string,
agentName string,
content string,
model string,
turnNumber int,
tokensUsed int,
inputTokens int,
outputTokens int,
cost float64,
duration time.Duration,
)
EmitConversationCompleted(
status string,
totalMessages int,
totalTurns int,
totalTokens int,
totalCost float64,
duration time.Duration,
summary *SummaryMetadata,
)
EmitConversationError(errorMessage string, errorType string, agentType string)
Close() error
}
BridgeEmitter is the interface for emitting conversation events. Both the HTTP-based Emitter and the stdout-based StdoutEmitter implement this interface.
type BridgeTestData ¶ added in v0.3.4
type BridgeTestData struct {
Message string `json:"message"`
SystemInfo SystemInfo `json:"system_info"`
}
BridgeTestData contains data for bridge.test events
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 CommandInfo ¶ added in v0.4.1
type CommandInfo struct {
FullCommand string `json:"full_command"` // Complete command as executed
Args []string `json:"args,omitempty"` // Command arguments
Mode string `json:"mode,omitempty"` // Orchestrator mode
MaxTurns int `json:"max_turns,omitempty"` // Maximum turns
InitialPrompt string `json:"initial_prompt,omitempty"` // Initial prompt
ConfigFile string `json:"config_file,omitempty"` // Config file path
TUIEnabled bool `json:"tui_enabled"` // TUI mode enabled
LoggingEnabled bool `json:"logging_enabled"` // Logging enabled
ShowMetrics bool `json:"show_metrics"` // Show metrics
Timeout int `json:"timeout,omitempty"` // Timeout in seconds
Options map[string]string `json:"options,omitempty"` // Additional options
}
CommandInfo contains information about the agentpipe command that was run
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"` // Includes summary tokens
TotalCost float64 `json:"total_cost,omitempty"` // Includes summary cost
DurationSeconds float64 `json:"duration_seconds,omitempty"` // Does not include summary generation time
Summary *SummaryMetadata `json:"summary,omitempty"` // AI-generated conversation summary with metadata
}
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"`
Participants []AgentParticipant `json:"participants"`
SystemInfo SystemInfo `json:"system_info"`
Command *CommandInfo `json:"command,omitempty"` // Command that started the conversation
}
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 Automatically sends a bridge.connected event to announce the connection
func (*Emitter) EmitConversationCompleted ¶
func (e *Emitter) EmitConversationCompleted( status string, totalMessages int, totalTurns int, totalTokens int, totalCost float64, duration time.Duration, summary *SummaryMetadata, )
EmitConversationCompleted emits a conversation.completed event Uses synchronous send to ensure the event is fully sent before program exit
func (*Emitter) EmitConversationError ¶
EmitConversationError emits a conversation.error event Uses synchronous send to ensure the event is fully sent before program exit
func (*Emitter) EmitConversationStarted ¶
func (e *Emitter) EmitConversationStarted( mode string, initialPrompt string, maxTurns int, agents []AgentParticipant, commandInfo *CommandInfo, )
EmitConversationStarted emits a conversation.started event
func (*Emitter) EmitMessageCreated ¶
func (e *Emitter) EmitMessageCreated( agentID string, 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
func LoadEventsFromFile ¶ added in v0.4.1
LoadEventsFromFile reads events from a JSON Lines file
type EventStore ¶ added in v0.4.1
type EventStore struct {
// contains filtered or unexported fields
}
EventStore handles local storage of events for later upload
func NewEventStore ¶ added in v0.4.1
func NewEventStore(conversationID string, logDir string) (*EventStore, error)
NewEventStore creates a new event store that saves events to a JSON file
func (*EventStore) Close ¶ added in v0.4.1
func (s *EventStore) Close() error
Close closes the event log file
func (*EventStore) GetEvents ¶ added in v0.4.1
func (s *EventStore) GetEvents() []*Event
GetEvents returns all events stored in memory
func (*EventStore) GetFilePath ¶ added in v0.4.1
func (s *EventStore) GetFilePath() string
GetFilePath returns the path to the event log file
func (*EventStore) SaveEvent ¶ added in v0.4.1
func (s *EventStore) SaveEvent(event *Event) error
SaveEvent saves an event to the local store (JSON Lines format)
type EventType ¶
type EventType string
EventType represents the type of streaming event
const ( // EventBridgeConnected is emitted when the bridge connection is established EventBridgeConnected EventType = "bridge.connected" // 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" // EventBridgeTest is emitted when testing the bridge connection EventBridgeTest EventType = "bridge.test" // EventLogEntry is emitted for log messages (messages, errors, system messages) EventLogEntry EventType = "log.entry" )
type LogEntryData ¶ added in v0.5.4
type LogEntryData struct {
ConversationID string `json:"conversation_id"`
Level string `json:"level"` // "message", "error", "system"
AgentID string `json:"agent_id,omitempty"`
AgentName string `json:"agent_name,omitempty"`
AgentType string `json:"agent_type,omitempty"`
Content string `json:"content"`
Role string `json:"role,omitempty"` // "assistant", "system", "user"
Metrics *LogEntryMetrics `json:"metrics,omitempty"`
Metadata map[string]interface{} `json:"metadata,omitempty"` // Additional context
}
LogEntryData contains data for log.entry events
type LogEntryMetrics ¶ added in v0.5.4
type LogEntryMetrics struct {
DurationSeconds float64 `json:"duration_seconds,omitempty"`
TotalTokens int `json:"total_tokens,omitempty"`
Cost float64 `json:"cost,omitempty"`
}
LogEntryMetrics contains metrics for log entries (if applicable)
type MessageCreatedData ¶
type MessageCreatedData struct {
ConversationID string `json:"conversation_id"`
MessageID string `json:"message_id"`
AgentID string `json:"agent_id"` // Unique identifier for the agent instance
AgentType string `json:"agent_type"` // Type of agent (e.g., "claude", "gemini")
AgentName string `json:"agent_name,omitempty"` // Display name of the agent
Content string `json:"content"` // Message 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 StdoutEmitter ¶ added in v0.5.3
type StdoutEmitter struct {
// contains filtered or unexported fields
}
StdoutEmitter emits events to stdout as JSON lines (JSONL format) This is useful for programmatic consumption and CI/CD pipelines
func NewStdoutEmitter ¶ added in v0.5.3
func NewStdoutEmitter(version string) *StdoutEmitter
NewStdoutEmitter creates a new stdout emitter
func (*StdoutEmitter) Close ¶ added in v0.5.3
func (e *StdoutEmitter) Close() error
Close is a no-op for StdoutEmitter (no resources to clean up)
func (*StdoutEmitter) EmitConversationCompleted ¶ added in v0.5.3
func (e *StdoutEmitter) EmitConversationCompleted( status string, totalMessages int, totalTurns int, totalTokens int, totalCost float64, duration time.Duration, summary *SummaryMetadata, )
EmitConversationCompleted emits a conversation.completed event
func (*StdoutEmitter) EmitConversationError ¶ added in v0.5.3
func (e *StdoutEmitter) EmitConversationError(errorMessage string, errorType string, agentType string)
EmitConversationError emits a conversation.error event
func (*StdoutEmitter) EmitConversationStarted ¶ added in v0.5.3
func (e *StdoutEmitter) EmitConversationStarted( mode string, initialPrompt string, maxTurns int, participants []AgentParticipant, commandInfo *CommandInfo, )
EmitConversationStarted emits a conversation.started event
func (*StdoutEmitter) EmitLogEntry ¶ added in v0.5.4
func (e *StdoutEmitter) EmitLogEntry( level string, agentID string, agentName string, agentType string, content string, role string, metrics *LogEntryMetrics, metadata map[string]interface{}, )
EmitLogEntry emits a log.entry event for log messages
func (*StdoutEmitter) EmitMessageCreated ¶ added in v0.5.3
func (e *StdoutEmitter) EmitMessageCreated( agentID string, 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 (*StdoutEmitter) GetConversationID ¶ added in v0.5.3
func (e *StdoutEmitter) GetConversationID() string
GetConversationID returns the conversation ID
type SummaryMetadata ¶ added in v0.4.1
type SummaryMetadata struct {
ShortText string `json:"short_text"` // Short 1-2 sentence summary
Text string `json:"text"` // Comprehensive detailed summary
AgentType string `json:"agent_type"` // Type of agent used to generate summary (e.g., "gemini")
Model string `json:"model,omitempty"` // Model used for summary generation
InputTokens int `json:"input_tokens,omitempty"` // Tokens used for input (conversation)
OutputTokens int `json:"output_tokens,omitempty"` // Tokens used for output (summary)
TotalTokens int `json:"total_tokens,omitempty"` // Total tokens used
Cost float64 `json:"cost,omitempty"` // Cost of generating the summary
DurationMs int64 `json:"duration_ms,omitempty"` // Time taken to generate summary
}
SummaryMetadata contains information about the AI-generated conversation summary
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
type ZerologJSONWriter ¶ added in v0.5.4
type ZerologJSONWriter struct {
// contains filtered or unexported fields
}
ZerologJSONWriter is a zerolog writer that emits log entries as log.entry JSON events
func NewZerologJSONWriter ¶ added in v0.5.4
func NewZerologJSONWriter(emitter *StdoutEmitter) *ZerologJSONWriter
NewZerologJSONWriter creates a new zerolog writer that emits JSON events