parse

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2026 License: MIT Imports: 5 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 DetectProvider

func DetectProvider(line []byte) (string, error)

DetectProvider picks the best adapter from a line's top-level "type".

Types

type ActionSummary added in v0.1.4

type ActionSummary struct {
	Tool    string
	Summary string
}

ActionSummary is the structured interpretation of a canonical action message.

func ParseActionMessage added in v0.1.4

func ParseActionMessage(message string) ActionSummary

ParseActionMessage extracts a tool/summary pair from a canonical action message. Conventions:

  • "$ cmd" => Bash
  • "text:..." => Think
  • "user:..." => Prompt
  • "Tool detail" => Tool + detail

type CanonicalEvent

type CanonicalEvent struct {
	Provider  string    `json:"provider,omitempty"`
	Type      EventType `json:"type"`
	Message   string    `json:"message"`
	Timestamp time.Time `json:"timestamp"`
	CostUSD   float64   `json:"cost_usd,omitempty"`
	TokensIn  int       `json:"tokens_in,omitempty"`
	TokensOut int       `json:"tokens_out,omitempty"`
}

CanonicalEvent is the provider-agnostic event schema.

type ClaudeAdapter

type ClaudeAdapter struct{}

func (ClaudeAdapter) Parse

func (ClaudeAdapter) Parse(line []byte) ([]CanonicalEvent, error)

type CodexAdapter

type CodexAdapter struct{}

func (CodexAdapter) Parse

func (CodexAdapter) Parse(line []byte) ([]CanonicalEvent, error)

type EventType

type EventType string

EventType is the normalized event kind emitted across providers.

const (
	EventInit     EventType = "init"
	EventAction   EventType = "action"
	EventResult   EventType = "result"
	EventError    EventType = "error"
	EventComplete EventType = "complete"
	EventDelta    EventType = "delta"
)

type LogAdapter

type LogAdapter interface {
	Parse(line []byte) ([]CanonicalEvent, error)
}

LogAdapter parses one NDJSON line into canonical events.

type Registry

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

Registry resolves provider adapters by name.

func NewRegistry

func NewRegistry() *Registry

func (*Registry) AdapterForProvider

func (r *Registry) AdapterForProvider(provider string) (LogAdapter, bool)

func (*Registry) ParseLine

func (r *Registry) ParseLine(line []byte) (string, []CanonicalEvent, error)

ParseLine detects the provider and parses one line with that adapter.

func (*Registry) Register

func (r *Registry) Register(provider string, adapter LogAdapter)

Jump to

Keyboard shortcuts

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