ingest

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CleanupOldLogs

func CleanupOldLogs(logsDir string, retentionDays int, referenceDate string) (int, error)

CleanupOldLogs removes date directories older than retentionDays from logsDir. referenceDate is in YYYY-MM-DD format. Returns count of removed directories.

func IngestFromReader

func IngestFromReader(r io.Reader, paths config.Paths, cfg config.Config) error

IngestFromReader reads a single JSON hook payload from r, normalizes it, and writes it to the log. It first tries forwarding to the daemon socket; on failure, falls back to direct file write.

func WriteToPath

func WriteToPath(filePath string, event Event) error

WriteToPath appends a single event to a specific file path. Used for fallback when the daemon is unreachable.

Types

type Event

type Event struct {
	Timestamp           time.Time              `json:"timestamp"`
	SessionID           string                 `json:"session_id"`
	Harness             string                 `json:"harness"`
	EventType           string                 `json:"event_type"`
	Source              string                 `json:"source,omitempty"`
	ToolName            string                 `json:"tool_name,omitempty"`
	ToolInput           map[string]interface{} `json:"tool_input,omitempty"`
	ToolResponseSummary string                 `json:"tool_response_summary,omitempty"`
	ExitCode            *int                   `json:"exit_code,omitempty"`
	WorkingDirectory    string                 `json:"working_directory"`
	Error               string                 `json:"error,omitempty"`
	Reason              string                 `json:"reason,omitempty"`
	SessionDurationMs   int64                  `json:"session_duration_ms,omitempty"`
	NumTurns            int                    `json:"num_turns,omitempty"`
	Metrics             *EventMetrics          `json:"metrics,omitempty"`
	BootstrapSource     string                 `json:"source_type,omitempty"`
}

Event is the normalized AgentJIT event schema.

func NormalizeEvent

func NormalizeEvent(raw []byte, maxResponseBytes int) (Event, error)

NormalizeEvent converts a raw Claude Code hook JSON payload into a normalized Event. maxResponseBytes controls truncation of tool_response.

func (Event) DateKey

func (e Event) DateKey() string

DateKey returns the date string (YYYY-MM-DD) for partitioning logs.

type EventMetrics

type EventMetrics struct {
	ExecutionDurationMs int64 `json:"execution_duration_ms,omitempty"`
}

EventMetrics holds optional performance metrics for an event.

type Writer

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

Writer appends normalized events to date/session-partitioned JSONL files.

func NewWriter

func NewWriter(paths config.Paths) *Writer

NewWriter creates a Writer that stores logs under the given paths.

func (*Writer) Write

func (w *Writer) Write(event Event) error

Write appends a single event to the appropriate JSONL file.

Jump to

Keyboard shortcuts

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