protocol

package
v0.12.17 Latest Latest
Warning

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

Go to latest
Published: Mar 24, 2026 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Overview

Package protocol provides the IPC protocol types for agnt daemon communication.

This package extends go-cli-server/protocol with agnt-specific verbs and types. The core protocol infrastructure (Parser, Writer, Command, Response) comes from go-cli-server, while this package adds agnt-specific extensions.

Index

Constants

View Source
const (
	VerbProxy       = "PROXY"
	VerbProxyLog    = "PROXYLOG"
	VerbCurrentPage = "CURRENTPAGE"
	VerbTunnel      = "TUNNEL"
	VerbBrowser     = "BROWSER"
	VerbAutomation  = "AUTOMATION" // chromedp-based browser automation sessions
	VerbChaos       = "CHAOS"
	VerbDetect      = "DETECT"
	VerbOverlay     = "OVERLAY"
	VerbStatus      = "STATUS" // Full daemon status (Hub's INFO is minimal)
	VerbStore       = "STORE"
	VerbAutomate    = "AUTOMATE" // Agent-based automation processing
	VerbAlerts      = "ALERTS"   // Process output alert queries
	VerbScript      = "SCRIPT"   // Script registry queries and control
)

Agnt-specific command verbs (beyond those in go-cli-server).

View Source
const (
	SubVerbExec          = "EXEC"
	SubVerbToast         = "TOAST"
	SubVerbQuery         = "QUERY"
	SubVerbStats         = "STATS"
	SubVerbActivity      = "ACTIVITY"
	SubVerbOutputPreview = "OUTPUT-PREVIEW"
	SubVerbEnable        = "ENABLE"
	SubVerbDisable       = "DISABLE"
	SubVerbAddRule       = "ADD-RULE"
	SubVerbRemoveRule    = "REMOVE-RULE"
	SubVerbListRules     = "LIST-RULES"
	SubVerbPreset        = "PRESET"
	SubVerbReset         = "RESET"
	SubVerbSend          = "SEND"
	SubVerbSchedule      = "SCHEDULE"
	SubVerbCancel        = "CANCEL"
	SubVerbTasks         = "TASKS"
	SubVerbFind          = "FIND"
	SubVerbAttach        = "ATTACH"
	SubVerbURL           = "URL"         // Report detected URL from agnt run session
	SubVerbGetAll        = "GET-ALL"     // Get all entries in a scope
	SubVerbDelete        = "DELETE"      // Delete an entry from a scope
	SubVerbProcess       = "PROCESS"     // Process a single automation task
	SubVerbBatch         = "BATCH"       // Process multiple automation tasks
	SubVerbRestart       = "RESTART"     // Restart a process or proxy
	SubVerbScreenshot    = "SCREENSHOT"  // Take screenshot in automation session
	SubVerbNavigate      = "NAVIGATE"    // Navigate to URL in automation session
	SubVerbEvaluate      = "EVALUATE"    // Evaluate JavaScript in automation session
	SubVerbReport        = "REPORT"      // Report alert matches from agnt run
	SubVerbStartupLog    = "STARTUP-LOG" // Query startup log (successes and failures)
)

Agnt-specific sub-verbs (beyond those in go-cli-server).

View Source
const (
	ResponseOK    = hubprotocol.ResponseOK
	ResponseErr   = hubprotocol.ResponseErr
	ResponseData  = hubprotocol.ResponseData
	ResponseJSON  = hubprotocol.ResponseJSON
	ResponseChunk = hubprotocol.ResponseChunk
	ResponseEnd   = hubprotocol.ResponseEnd
	ResponsePong  = hubprotocol.ResponsePong
)

Re-export response type constants.

View Source
const (
	ErrNotFound       = hubprotocol.ErrNotFound
	ErrAlreadyExists  = hubprotocol.ErrAlreadyExists
	ErrInvalidState   = hubprotocol.ErrInvalidState
	ErrShuttingDown   = hubprotocol.ErrShuttingDown
	ErrPortInUse      = hubprotocol.ErrPortInUse
	ErrInvalidArgs    = hubprotocol.ErrInvalidArgs
	ErrInvalidAction  = hubprotocol.ErrInvalidAction
	ErrInvalidCommand = hubprotocol.ErrInvalidCommand
	ErrMissingParam   = hubprotocol.ErrMissingParam
	ErrTimeout        = hubprotocol.ErrTimeout
	ErrInternal       = hubprotocol.ErrInternal
)

Re-export error code constants.

View Source
const (
	CommandTerminator = hubprotocol.CommandTerminator
	DataMarker        = hubprotocol.DataMarker
)

Re-export protocol constants.

View Source
const (
	VerbRun      = hubprotocol.VerbRun
	VerbRunJSON  = hubprotocol.VerbRunJSON
	VerbProc     = hubprotocol.VerbProc
	VerbSession  = hubprotocol.VerbSession
	VerbPing     = hubprotocol.VerbPing
	VerbInfo     = hubprotocol.VerbInfo
	VerbShutdown = hubprotocol.VerbShutdown
)

Re-export core verb constants from hub.

View Source
const (
	SubVerbStatus      = hubprotocol.SubVerbStatus
	SubVerbOutput      = hubprotocol.SubVerbOutput
	SubVerbStop        = hubprotocol.SubVerbStop
	SubVerbList        = hubprotocol.SubVerbList
	SubVerbCleanupPort = hubprotocol.SubVerbCleanupPort
	SubVerbRegister    = hubprotocol.SubVerbRegister
	SubVerbUnregister  = hubprotocol.SubVerbUnregister
	SubVerbHeartbeat   = hubprotocol.SubVerbHeartbeat
	SubVerbGet         = hubprotocol.SubVerbGet
	SubVerbStart       = hubprotocol.SubVerbStart
	SubVerbClear       = hubprotocol.SubVerbClear
	SubVerbSet         = hubprotocol.SubVerbSet
)

Re-export core sub-verb constants from hub.

Variables

View Source
var (
	NewParser             = hubprotocol.NewParser
	NewParserWithRegistry = hubprotocol.NewParserWithRegistry
	NewWriter             = hubprotocol.NewWriter
	NewVerbRegistry       = hubprotocol.NewVerbRegistry
	FormatCommand         = hubprotocol.FormatCommand
	FormatOK              = hubprotocol.FormatOK
	FormatErr             = hubprotocol.FormatErr
	FormatPong            = hubprotocol.FormatPong
	FormatJSON            = hubprotocol.FormatJSON
	FormatData            = hubprotocol.FormatData
	FormatChunk           = hubprotocol.FormatChunk
	FormatEnd             = hubprotocol.FormatEnd
	ParseLengthPrefixed   = hubprotocol.ParseLengthPrefixed

	// ErrJSONInsteadOfCommand indicates JSON was sent instead of a protocol command.
	ErrJSONInsteadOfCommand = hubprotocol.ErrJSONInsteadOfCommand

	// DefaultRegistry is the global verb registry.
	DefaultRegistry = hubprotocol.DefaultRegistry
)

Re-export functions from hub.

Functions

This section is empty.

Types

type AlertQueryFilter added in v0.12.0

type AlertQueryFilter struct {
	Since     string `json:"since,omitempty"`      // RFC3339 or duration like "5m"
	ProcessID string `json:"process_id,omitempty"` // Filter to specific process
	Severity  string `json:"severity,omitempty"`   // Filter by severity
	Limit     int    `json:"limit,omitempty"`      // Max results (0 = all)
}

AlertQueryFilter filters for ALERTS QUERY.

type AlertReportPayload added in v0.12.0

type AlertReportPayload struct {
	PatternID   string `json:"pattern_id"`
	Severity    string `json:"severity"`    // "error", "warning", "info"
	Category    string `json:"category"`    // "go", "dotnet", "webpack", "generic", "custom"
	Description string `json:"description"` // Pattern description
	Line        string `json:"line"`        // Matched output line
	ScriptID    string `json:"script_id"`   // Process that produced the line
	Timestamp   string `json:"timestamp"`   // RFC3339
}

AlertReportPayload is sent from agnt run to daemon when alert patterns match.

type AutomateBatchRequest added in v0.8.0

type AutomateBatchRequest struct {
	Tasks []AutomateProcessRequest `json:"tasks"`
}

AutomateBatchRequest represents an AUTOMATE BATCH command.

type AutomateOptions added in v0.8.0

type AutomateOptions struct {
	Model       string  `json:"model,omitempty"`       // Model to use (haiku, sonnet)
	MaxTokens   int     `json:"max_tokens,omitempty"`  // Max response tokens
	Temperature float64 `json:"temperature,omitempty"` // 0.0-1.0
}

AutomateOptions configures automation task processing.

type AutomateProcessRequest added in v0.8.0

type AutomateProcessRequest struct {
	Type    string                 `json:"type"`    // Task type (audit_process, summarize, etc.)
	Data    map[string]interface{} `json:"data"`    // Task-specific input data
	Context map[string]interface{} `json:"context"` // Additional context
	Options AutomateOptions        `json:"options,omitempty"`
}

AutomateProcessRequest represents an AUTOMATE PROCESS command.

type AutomateProcessResponse added in v0.8.0

type AutomateProcessResponse struct {
	Success  bool        `json:"success"`
	Result   interface{} `json:"result,omitempty"`
	Error    string      `json:"error,omitempty"`
	Tokens   int         `json:"tokens_used"`
	CostUSD  float64     `json:"cost_usd"`
	Duration string      `json:"duration"`
}

AutomateProcessResponse represents the response from AUTOMATE PROCESS.

type AutomationEvaluateConfig added in v0.11.1

type AutomationEvaluateConfig struct {
	SessionID string `json:"session_id"` // Session ID (required)
	Script    string `json:"script"`     // JavaScript to evaluate (required)
}

AutomationEvaluateConfig represents configuration for an AUTOMATION EVALUATE command.

type AutomationNavigateConfig added in v0.11.1

type AutomationNavigateConfig struct {
	SessionID string `json:"session_id"` // Session ID (required)
	URL       string `json:"url"`        // URL to navigate to (required)
}

AutomationNavigateConfig represents configuration for an AUTOMATION NAVIGATE command.

type AutomationScreenshotConfig added in v0.11.1

type AutomationScreenshotConfig struct {
	SessionID string  `json:"session_id"`         // Session ID (required)
	Type      string  `json:"type,omitempty"`     // viewport, fullpage, element, clip
	Label     string  `json:"label,omitempty"`    // Optional label for filename
	Selector  string  `json:"selector,omitempty"` // CSS selector for element type
	Viewport  string  `json:"viewport,omitempty"` // Viewport preset name
	X         float64 `json:"x,omitempty"`        // Clip X
	Y         float64 `json:"y,omitempty"`        // Clip Y
	Width     float64 `json:"width,omitempty"`    // Clip width
	Height    float64 `json:"height,omitempty"`   // Clip height
}

AutomationScreenshotConfig represents configuration for an AUTOMATION SCREENSHOT command.

type AutomationStartConfig added in v0.11.1

type AutomationStartConfig struct {
	ID       string `json:"id,omitempty"`       // Session ID (auto-generated if empty)
	URL      string `json:"url,omitempty"`      // URL to open
	ProxyID  string `json:"proxy_id,omitempty"` // Proxy to use
	Headless *bool  `json:"headless,omitempty"` // Default: true
}

AutomationStartConfig represents configuration for an AUTOMATION START command.

type BrowserStartConfig added in v0.11.1

type BrowserStartConfig struct {
	ID         string `json:"id,omitempty"`          // Browser ID (auto-generated if empty)
	URL        string `json:"url,omitempty"`         // URL to open
	ProxyID    string `json:"proxy_id,omitempty"`    // Proxy to use (auto-starts if needed)
	Headless   *bool  `json:"headless,omitempty"`    // Default: true
	BinaryPath string `json:"binary_path,omitempty"` // Optional Chrome path
}

BrowserStartConfig represents configuration for a BROWSER START command.

type ChaosConfigPayload

type ChaosConfigPayload struct {
	Enabled     bool               `json:"enabled"`
	Rules       []*ChaosRuleConfig `json:"rules,omitempty"`
	GlobalOdds  float64            `json:"global_odds,omitempty"`  // 0.0-1.0
	Seed        int64              `json:"seed,omitempty"`         // For reproducible chaos
	LoggingMode int                `json:"logging_mode,omitempty"` // 0=silent, 1=testing, 2=coordinated
}

ChaosConfigPayload represents the full chaos configuration for SET command.

type ChaosRuleConfig

type ChaosRuleConfig struct {
	ID          string   `json:"id"`
	Name        string   `json:"name,omitempty"`
	Type        string   `json:"type"` // latency, out_of_order, slow_drip, disconnect, http_error, truncate, etc.
	Enabled     bool     `json:"enabled"`
	URLPattern  string   `json:"url_pattern,omitempty"`
	Methods     []string `json:"methods,omitempty"`
	Probability float64  `json:"probability,omitempty"` // 0.0-1.0, default 1.0

	// Latency config
	MinLatencyMs int `json:"min_latency_ms,omitempty"`
	MaxLatencyMs int `json:"max_latency_ms,omitempty"`
	JitterMs     int `json:"jitter_ms,omitempty"`

	// Slow-drip config
	BytesPerMs int `json:"bytes_per_ms,omitempty"`
	ChunkSize  int `json:"chunk_size,omitempty"`

	// Connection drop config
	DropAfterPercent float64 `json:"drop_after_percent,omitempty"`
	DropAfterBytes   int64   `json:"drop_after_bytes,omitempty"`

	// Error injection config
	ErrorCodes   []int  `json:"error_codes,omitempty"`
	ErrorMessage string `json:"error_message,omitempty"`

	// Truncation config
	TruncatePercent float64 `json:"truncate_percent,omitempty"`

	// Out-of-order config
	ReorderMinRequests int `json:"reorder_min_requests,omitempty"`
	ReorderMaxWaitMs   int `json:"reorder_max_wait_ms,omitempty"`

	// Stale config
	StaleDelayMs int64 `json:"stale_delay_ms,omitempty"`
}

ChaosRuleConfig represents configuration for a CHAOS ADD-RULE command.

type Command

type Command = hubprotocol.Command

Command represents a parsed command from the client.

type DirectoryFilter

type DirectoryFilter = hubprotocol.DirectoryFilter

DirectoryFilter represents directory scoping for list operations.

type ErrUnknownCommand

type ErrUnknownCommand = hubprotocol.ErrUnknownCommand

ErrUnknownCommand indicates an unknown command verb was sent.

type ErrorCode

type ErrorCode = hubprotocol.ErrorCode

ErrorCode represents daemon error codes.

type LogQueryFilter

type LogQueryFilter struct {
	Types       []string `json:"types,omitempty"`
	Methods     []string `json:"methods,omitempty"`
	URLPattern  string   `json:"url_pattern,omitempty"`
	StatusCodes []int    `json:"status_codes,omitempty"`
	Since       string   `json:"since,omitempty"`
	Until       string   `json:"until,omitempty"`
	Limit       int      `json:"limit,omitempty"`
}

LogQueryFilter represents filters for PROXYLOG QUERY command.

type OutputFilter

type OutputFilter = hubprotocol.OutputFilter

OutputFilter represents filters for PROC OUTPUT command.

type Parser

type Parser = hubprotocol.Parser

Parser handles parsing of protocol commands and responses.

type ProxyStartConfig

type ProxyStartConfig struct {
	ID          string        `json:"id"`
	TargetURL   string        `json:"target_url"`
	Port        int           `json:"port"`
	MaxLogSize  int           `json:"max_log_size,omitempty"`
	BindAddress string        `json:"bind_address,omitempty"` // "127.0.0.1" (default) or "0.0.0.0" (all interfaces)
	PublicURL   string        `json:"public_url,omitempty"`   // Public URL for tunnels (e.g., "https://abc.trycloudflare.com")
	Tunnel      *TunnelConfig `json:"tunnel,omitempty"`
}

ProxyStartConfig represents configuration for a PROXY START command.

type Response

type Response = hubprotocol.Response

Response represents a response from the daemon.

type ResponseType

type ResponseType = hubprotocol.ResponseType

ResponseType indicates the type of response.

type RunConfig

type RunConfig = hubprotocol.RunConfig

RunConfig represents configuration for a RUN command.

type SessionRegisterConfig added in v0.7.0

type SessionRegisterConfig struct {
	OverlayPath string   `json:"overlay_path"`   // Unix socket path for overlay
	ProjectPath string   `json:"project_path"`   // Directory where session was started
	Command     string   `json:"command"`        // Command being run (e.g., "claude")
	Args        []string `json:"args,omitempty"` // Command arguments
}

SessionRegisterConfig represents configuration for a SESSION REGISTER command. This extends the base hub SessionRegisterConfig with agnt-specific fields.

type SessionScheduleConfig added in v0.7.0

type SessionScheduleConfig struct {
	SessionCode string `json:"session_code"` // Target session
	Duration    string `json:"duration"`     // Go duration string (e.g., "5m", "1h30m")
	Message     string `json:"message"`      // Message to deliver
	ProjectPath string `json:"project_path"` // For project-scoped storage
}

SessionScheduleConfig represents configuration for a SESSION SCHEDULE command.

type StoreClearRequest added in v0.8.0

type StoreClearRequest struct {
	Scope    string `json:"scope"`
	ScopeKey string `json:"scope_key"`
}

StoreClearRequest represents a STORE CLEAR command.

type StoreDeleteRequest added in v0.8.0

type StoreDeleteRequest struct {
	Scope    string `json:"scope"`
	ScopeKey string `json:"scope_key"`
	Key      string `json:"key"`
}

StoreDeleteRequest represents a STORE DELETE command.

type StoreGetAllRequest added in v0.8.0

type StoreGetAllRequest struct {
	Scope    string `json:"scope"`
	ScopeKey string `json:"scope_key"`
}

StoreGetAllRequest represents a STORE GET_ALL command.

type StoreGetRequest added in v0.8.0

type StoreGetRequest struct {
	Scope    string `json:"scope"`
	ScopeKey string `json:"scope_key"`
	Key      string `json:"key"`
}

StoreGetRequest represents a STORE GET command.

type StoreListRequest added in v0.8.0

type StoreListRequest struct {
	Scope    string `json:"scope"`
	ScopeKey string `json:"scope_key"`
}

StoreListRequest represents a STORE LIST command.

type StoreSetRequest added in v0.8.0

type StoreSetRequest struct {
	Scope    string         `json:"scope"`
	ScopeKey string         `json:"scope_key"`
	Key      string         `json:"key"`
	Value    interface{}    `json:"value"`
	Metadata map[string]any `json:"metadata,omitempty"`
}

StoreSetRequest represents a STORE SET command.

type StructuredError

type StructuredError = hubprotocol.StructuredError

StructuredError contains programmatic error details.

type ToastConfig

type ToastConfig struct {
	Type     string `json:"type"`               // success, error, warning, info
	Title    string `json:"title,omitempty"`    // Toast title (optional)
	Message  string `json:"message"`            // Toast message
	Duration int    `json:"duration,omitempty"` // Duration in ms (0 for default)
}

ToastConfig represents configuration for a PROXY TOAST command.

type TunnelConfig

type TunnelConfig struct {
	// Provider is the tunnel provider: "ngrok", "cloudflared", "tailscale", or "custom"
	Provider string `json:"provider"`
	// Command is used when Provider is "custom" - the full command to run
	Command string `json:"command,omitempty"`
	// Args are additional arguments for the tunnel command
	Args []string `json:"args,omitempty"`
	// AuthToken is the authentication token (for ngrok)
	AuthToken string `json:"auth_token,omitempty"`
	// Region is the tunnel region (optional)
	Region string `json:"region,omitempty"`
}

TunnelConfig represents configuration for starting a tunnel alongside a proxy.

type TunnelStartConfig

type TunnelStartConfig struct {
	ID         string `json:"id"`                    // Tunnel ID (usually same as proxy ID)
	Provider   string `json:"provider"`              // "cloudflare" or "ngrok"
	LocalPort  int    `json:"local_port"`            // Local port to tunnel
	LocalHost  string `json:"local_host,omitempty"`  // Local host (default: localhost)
	BinaryPath string `json:"binary_path,omitempty"` // Optional path to tunnel binary
	ProxyID    string `json:"proxy_id,omitempty"`    // Optional proxy ID to auto-configure public_url
}

TunnelStartConfig represents configuration for a TUNNEL START command.

type VerbRegistry added in v0.8.0

type VerbRegistry = hubprotocol.VerbRegistry

VerbRegistry tracks registered command verbs.

type Writer

type Writer = hubprotocol.Writer

Writer provides methods for writing protocol messages.

Jump to

Keyboard shortcuts

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