cli

package
v0.0.0-...-230ac96 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2026 License: Apache-2.0 Imports: 16 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FormatDuration

func FormatDuration(d time.Duration) string

FormatDuration formats a duration nicely.

func ParseKeyValue

func ParseKeyValue(s string) (string, string, error)

ParseKeyValue parses a key=value string.

func TruncatePath

func TruncatePath(path string, maxLen int) string

TruncatePath truncates a path for display.

Types

type Client

type Client interface {
	// Session operations
	ListSessions(ctx context.Context, opts ListSessionsOpts) ([]SessionInfo, error)
	GetSession(ctx context.Context, id string) (*SessionDetail, error)
	GetSessionLogs(ctx context.Context, id string, follow bool) (io.ReadCloser, error)
	GetSessionEvents(ctx context.Context, id string, opts EventsOpts) ([]Event, error)
	TerminateSession(ctx context.Context, id string, force bool, reason string) error

	// Policy operations
	ValidatePolicy(ctx context.Context, path string) (*ValidationResult, error)
	TestPolicy(ctx context.Context, policyDir, testDir string) (*TestResults, error)
	DiffPolicies(ctx context.Context, oldPath, newPath string) (*PolicyDiff, error)
	LintPolicy(ctx context.Context, path string) ([]LintIssue, error)

	// Debug operations
	TraceSession(ctx context.Context, id string, duration time.Duration) (io.ReadCloser, error)
	SimulateRecording(ctx context.Context, recordingPath, policyDir string) (*SimulationResult, error)

	// Status operations
	GetStatus(ctx context.Context) (*Status, error)
	GetMetrics(ctx context.Context) (*Metrics, error)

	// Config operations
	ValidateConfig(ctx context.Context) error
	GetConfig(ctx context.Context, effective bool) (map[string]any, error)
	SetConfig(ctx context.Context, key, value string) error
}

Client interface for interacting with agentmon server.

type Commander

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

Commander executes CLI commands.

func NewCommander

func NewCommander(client Client, output io.Writer) *Commander

NewCommander creates a new commander.

func (*Commander) ConfigSet

func (c *Commander) ConfigSet(ctx context.Context, key, value string) error

ConfigSet sets a configuration value.

func (*Commander) ConfigShow

func (c *Commander) ConfigShow(ctx context.Context, effective bool) error

ConfigShow shows the configuration.

func (*Commander) ConfigValidate

func (c *Commander) ConfigValidate(ctx context.Context) error

ConfigValidate validates the configuration.

func (*Commander) DebugSimulate

func (c *Commander) DebugSimulate(ctx context.Context, recordingPath, policyDir string) error

DebugSimulate simulates a recording against a policy.

func (*Commander) MetricsShow

func (c *Commander) MetricsShow(ctx context.Context) error

MetricsShow shows metrics.

func (*Commander) PolicyDiff

func (c *Commander) PolicyDiff(ctx context.Context, oldPath, newPath string) error

PolicyDiff shows policy differences.

func (*Commander) PolicyLint

func (c *Commander) PolicyLint(ctx context.Context, path string) error

PolicyLint lints a policy file.

func (*Commander) PolicyTest

func (c *Commander) PolicyTest(ctx context.Context, policyDir, testDir string) error

PolicyTest runs policy tests.

func (*Commander) PolicyValidate

func (c *Commander) PolicyValidate(ctx context.Context, path string) error

PolicyValidate validates a policy file.

func (*Commander) SessionEvents

func (c *Commander) SessionEvents(ctx context.Context, id string, opts EventsOpts) error

SessionEvents shows session events.

func (*Commander) SessionGet

func (c *Commander) SessionGet(ctx context.Context, id string) error

SessionGet gets session details.

func (*Commander) SessionList

func (c *Commander) SessionList(ctx context.Context, opts ListSessionsOpts) error

SessionList lists sessions.

func (*Commander) SessionTerminate

func (c *Commander) SessionTerminate(ctx context.Context, id string, force bool, reason string) error

SessionTerminate terminates a session.

func (*Commander) SetJSONOutput

func (c *Commander) SetJSONOutput(enabled bool)

SetJSONOutput enables JSON output mode.

func (*Commander) StatusShow

func (c *Commander) StatusShow(ctx context.Context) error

StatusShow shows agentmon status.

type Debugger

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

Debugger provides an interactive debugging session.

func NewDebugger

func NewDebugger(config DebuggerConfig) *Debugger

NewDebugger creates a new interactive debugger.

func (*Debugger) IsRunning

func (d *Debugger) IsRunning() bool

IsRunning returns whether the debugger is running.

func (*Debugger) Run

func (d *Debugger) Run(ctx context.Context) error

Run starts the interactive debugger.

type DebuggerConfig

type DebuggerConfig struct {
	Client    Client
	SessionID string
	Output    io.Writer
	Input     io.Reader
}

DebuggerConfig configures the debugger.

type DiagnosticCollector

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

DiagnosticCollector collects diagnostic information.

func NewDiagnosticCollector

func NewDiagnosticCollector(config DiagnosticConfig) *DiagnosticCollector

NewDiagnosticCollector creates a new diagnostic collector.

func (*DiagnosticCollector) Collect

Collect gathers diagnostic information.

func (*DiagnosticCollector) GenerateReport

func (d *DiagnosticCollector) GenerateReport(ctx context.Context, outputPath string) error

GenerateReport collects diagnostics and writes to a file.

func (*DiagnosticCollector) WriteReport

func (d *DiagnosticCollector) WriteReport(report *DiagnosticReport, outputPath string) error

WriteReport writes the report to a file.

type DiagnosticConfig

type DiagnosticConfig struct {
	Client        Client
	Output        io.Writer
	RedactSecrets bool
}

DiagnosticConfig configures the collector.

type DiagnosticReport

type DiagnosticReport struct {
	GeneratedAt  time.Time      `json:"generated_at"`
	Version      string         `json:"version"`
	SystemInfo   SystemInfo     `json:"system_info"`
	Status       *Status        `json:"status,omitempty"`
	Metrics      *Metrics       `json:"metrics,omitempty"`
	Config       map[string]any `json:"config,omitempty"`
	Sessions     []SessionInfo  `json:"sessions,omitempty"`
	RecentEvents []Event        `json:"recent_events,omitempty"`
	Errors       []string       `json:"errors,omitempty"`
}

DiagnosticReport contains all diagnostic information.

type Difference

type Difference struct {
	EventIndex  int    `json:"event_index"`
	Type        string `json:"type"`
	OldDecision string `json:"old_decision"`
	NewDecision string `json:"new_decision"`
}

Difference describes a decision difference.

type Event

type Event struct {
	Timestamp time.Time `json:"timestamp"`
	Type      string    `json:"type"`
	Path      string    `json:"path,omitempty"`
	Decision  string    `json:"decision"`
	Latency   string    `json:"latency,omitempty"`
}

Event is an operation event.

type EventsOpts

type EventsOpts struct {
	Type  string
	Since time.Time
	Limit int
}

EventsOpts are options for getting events.

type LintIssue

type LintIssue struct {
	Level   string `json:"level"` // error, warning, info
	Path    string `json:"path"`
	Line    int    `json:"line,omitempty"`
	Message string `json:"message"`
}

LintIssue is a policy lint issue.

type ListSessionsOpts

type ListSessionsOpts struct {
	Tenant string
	State  string
	Limit  int
}

ListSessionsOpts are options for listing sessions.

type Metrics

type Metrics struct {
	SessionsTotal    int64            `json:"sessions_total"`
	SessionsActive   int64            `json:"sessions_active"`
	OperationsTotal  int64            `json:"operations_total"`
	OperationsByType map[string]int64 `json:"operations_by_type"`
	DecisionsByType  map[string]int64 `json:"decisions_by_type"`
	AvgLatencyMs     float64          `json:"avg_latency_ms"`
	PolicyReloads    int64            `json:"policy_reloads"`
	ErrorsTotal      int64            `json:"errors_total"`
}

Metrics contains operational metrics.

type PolicyDiff

type PolicyDiff struct {
	Added    []string `json:"added,omitempty"`
	Removed  []string `json:"removed,omitempty"`
	Modified []string `json:"modified,omitempty"`
}

PolicyDiff describes differences between policies.

type ResourceUsage

type ResourceUsage struct {
	CPUPercent   float64 `json:"cpu_percent"`
	MemoryMB     int64   `json:"memory_mb"`
	DiskReadMB   int64   `json:"disk_read_mb"`
	DiskWriteMB  int64   `json:"disk_write_mb"`
	NetworkRxMB  int64   `json:"network_rx_mb"`
	NetworkTxMB  int64   `json:"network_tx_mb"`
	ProcessCount int     `json:"process_count"`
}

ResourceUsage tracks resource consumption.

type SessionDetail

type SessionDetail struct {
	SessionInfo
	Workspace     string            `json:"workspace,omitempty"`
	PolicyRef     string            `json:"policy_ref,omitempty"`
	EventCount    int64             `json:"event_count"`
	LastActivity  time.Time         `json:"last_activity,omitempty"`
	ResourceUsage *ResourceUsage    `json:"resource_usage,omitempty"`
	Metadata      map[string]string `json:"metadata,omitempty"`
}

SessionDetail is detailed information about a session.

type SessionInfo

type SessionInfo struct {
	ID        string    `json:"id"`
	AgentID   string    `json:"agent_id,omitempty"`
	TenantID  string    `json:"tenant_id,omitempty"`
	State     string    `json:"state"`
	StartTime time.Time `json:"start_time"`
	Duration  string    `json:"duration,omitempty"`
}

SessionInfo is summary information about a session.

type SimulationResult

type SimulationResult struct {
	TotalEvents int          `json:"total_events"`
	Matched     int          `json:"matched"`
	Differences []Difference `json:"differences,omitempty"`
}

SimulationResult is the result of simulating a recording.

type Status

type Status struct {
	Version        string    `json:"version"`
	Uptime         string    `json:"uptime"`
	StartTime      time.Time `json:"start_time"`
	ActiveSessions int       `json:"active_sessions"`
	Platform       string    `json:"platform"`
	PolicyLoaded   bool      `json:"policy_loaded"`
	Healthy        bool      `json:"healthy"`
}

Status is the agentmon status.

type SystemInfo

type SystemInfo struct {
	OS         string `json:"os"`
	Arch       string `json:"arch"`
	NumCPU     int    `json:"num_cpu"`
	GoVersion  string `json:"go_version"`
	Hostname   string `json:"hostname,omitempty"`
	WorkingDir string `json:"working_dir,omitempty"`
}

SystemInfo contains system information.

type TestFailure

type TestFailure struct {
	Name     string `json:"name"`
	Expected string `json:"expected"`
	Got      string `json:"got"`
	Error    string `json:"error,omitempty"`
}

TestFailure describes a failed test.

type TestResults

type TestResults struct {
	Passed  int           `json:"passed"`
	Failed  int           `json:"failed"`
	Skipped int           `json:"skipped"`
	Total   int           `json:"total"`
	Errors  []TestFailure `json:"errors,omitempty"`
}

TestResults contains policy test results.

type ValidationResult

type ValidationResult struct {
	Valid  bool     `json:"valid"`
	Errors []string `json:"errors,omitempty"`
}

ValidationResult is the result of policy validation.

Jump to

Keyboard shortcuts

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