Documentation
¶
Index ¶
- func FormatDuration(d time.Duration) string
- func ParseKeyValue(s string) (string, string, error)
- func TruncatePath(path string, maxLen int) string
- type Client
- type Commander
- func (c *Commander) ConfigSet(ctx context.Context, key, value string) error
- func (c *Commander) ConfigShow(ctx context.Context, effective bool) error
- func (c *Commander) ConfigValidate(ctx context.Context) error
- func (c *Commander) DebugSimulate(ctx context.Context, recordingPath, policyDir string) error
- func (c *Commander) MetricsShow(ctx context.Context) error
- func (c *Commander) PolicyDiff(ctx context.Context, oldPath, newPath string) error
- func (c *Commander) PolicyLint(ctx context.Context, path string) error
- func (c *Commander) PolicyTest(ctx context.Context, policyDir, testDir string) error
- func (c *Commander) PolicyValidate(ctx context.Context, path string) error
- func (c *Commander) SessionEvents(ctx context.Context, id string, opts EventsOpts) error
- func (c *Commander) SessionGet(ctx context.Context, id string) error
- func (c *Commander) SessionList(ctx context.Context, opts ListSessionsOpts) error
- func (c *Commander) SessionTerminate(ctx context.Context, id string, force bool, reason string) error
- func (c *Commander) SetJSONOutput(enabled bool)
- func (c *Commander) StatusShow(ctx context.Context) error
- type Debugger
- type DebuggerConfig
- type DiagnosticCollector
- type DiagnosticConfig
- type DiagnosticReport
- type Difference
- type Event
- type EventsOpts
- type LintIssue
- type ListSessionsOpts
- type Metrics
- type PolicyDiff
- type ResourceUsage
- type SessionDetail
- type SessionInfo
- type SimulationResult
- type Status
- type SystemInfo
- type TestFailure
- type TestResults
- type ValidationResult
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FormatDuration ¶
FormatDuration formats a duration nicely.
func ParseKeyValue ¶
ParseKeyValue parses a key=value string.
func TruncatePath ¶
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 ¶
NewCommander creates a new commander.
func (*Commander) ConfigShow ¶
ConfigShow shows the configuration.
func (*Commander) ConfigValidate ¶
ConfigValidate validates the configuration.
func (*Commander) DebugSimulate ¶
DebugSimulate simulates a recording against a policy.
func (*Commander) MetricsShow ¶
MetricsShow shows metrics.
func (*Commander) PolicyDiff ¶
PolicyDiff shows policy differences.
func (*Commander) PolicyLint ¶
PolicyLint lints a policy file.
func (*Commander) PolicyTest ¶
PolicyTest runs policy tests.
func (*Commander) PolicyValidate ¶
PolicyValidate validates a policy file.
func (*Commander) SessionEvents ¶
SessionEvents shows session events.
func (*Commander) SessionGet ¶
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 ¶
SetJSONOutput enables JSON output mode.
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.
type DebuggerConfig ¶
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 ¶
func (d *DiagnosticCollector) Collect(ctx context.Context) (*DiagnosticReport, error)
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 ¶
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 ¶
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 ¶
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.