jsonmode

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 7, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package jsonmode emits NDJSON events for bee's --json output mode.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Emitter

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

Emitter writes NDJSON events to an io.Writer, safe for concurrent use.

func New

func New(w io.Writer) *Emitter

New returns an Emitter that writes one JSON line per Emit call to w.

func (*Emitter) Emit

func (e *Emitter) Emit(ev Event)

Emit serializes ev to a single JSON line. Errors are silently ignored — the run is effectively over if stdout is broken.

type Event

type Event struct {
	Type    string `json:"type"`
	Delta   string `json:"delta,omitempty"`
	Name    string `json:"name,omitempty"`
	Input   any    `json:"input,omitempty"`
	UseID   string `json:"use_id,omitempty"`
	Content string `json:"content,omitempty"`
	Error   bool   `json:"error,omitempty"`
	Message string `json:"message,omitempty"`
	Usage   *Usage `json:"usage,omitempty"`
}

Event is one NDJSON record.

type Usage

type Usage struct {
	Input  int `json:"input"`
	Output int `json:"output"`
}

Usage mirrors llm.Usage but stays decoupled to avoid an import cycle.

Jump to

Keyboard shortcuts

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