Skip to content

The cross-harness, self-improving memory layer for AI agents. Join our community: https://discord.com/invite/zdNChS2fBu

1.6 KB
Raw Blame
package beaconjsonexporter

import "fmt"

const (
	defaultMaxEventBytes  = 64 * 1024
	defaultRotateBytes    = 10 * 1024 * 1024
	defaultRotateArchives = 5
)

// Config controls local JSONL export for Beacon endpoint events.
type Config struct {
	Path                  string `mapstructure:"path"`
	MaxEventBytes         int    `mapstructure:"max_event_bytes"`
	RotateBytes           int64  `mapstructure:"rotate_bytes"`
	RotateArchives        int    `mapstructure:"rotate_archives"`
	RedactSecrets         bool   `mapstructure:"redact_secrets"`
	ContentRetention      string `mapstructure:"content_retention"` // Deprecated no-op; retained for older collector configs.
	IncludeRuntimeMetrics bool   `mapstructure:"include_runtime_metrics"`
	IncludeCodexSpans     bool   `mapstructure:"include_codex_spans"`
	// CaptureModelContext is the --claude-capture-model-context opt-in, the same setting the
	// claude_api_body processor reads; see beaconevent.Options.
	CaptureModelContext bool `mapstructure:"capture_model_context"`
	// PeerUser records each event under the account the beacon_peer processor resolved; set only
	// together with that processor in the pipeline. See beaconevent.Options.PeerUser.
	PeerUser bool `mapstructure:"peer_user"`
}

func createDefaultConfig() *Config {
	return &Config{
		MaxEventBytes:  defaultMaxEventBytes,
		RotateBytes:    defaultRotateBytes,
		RotateArchives: defaultRotateArchives,
		RedactSecrets:  true,
	}
}

func (c *Config) Validate() error {
	if c.Path == "" {
		return fmt.Errorf("path is required")
	}
	if c.MaxEventBytes <= 0 {
		return fmt.Errorf("max_event_bytes must be positive")
	}
	return nil
}