eventwire

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package eventwire is the shared JSON codec for event.Event streams that cross a process boundary: the remote host serializes typed controller events into the wire form, and the desktop deserializes them back so its tab sink sees the same stream a local controller would emit. The wire shape is field-for-field the one desktop/wire.go and internal/serve/wire.go already exchange with the React frontend, so all three consumers stay contract-compatible.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FromWire

func FromWire(w Event) event.Event

FromWire decodes a wire event back into an event.Event so a desktop-side sink can consume a remote host's stream exactly like a local controller's. It is the inverse of ToWire; the only lossy fields are Pricing (its cost is precomputed into Usage.Cost on the wire) and a TurnDone error's type (a string error is rebuilt).

Types

type Approval

type Approval struct {
	ID      string       `json:"id"`
	Tool    string       `json:"tool"`
	Subject string       `json:"subject"`
	Args    string       `json:"args,omitempty"`
	Changes []FileChange `json:"changes,omitempty"`
}

type Ask

type Ask struct {
	ID        string        `json:"id"`
	Questions []AskQuestion `json:"questions"`
}

type AskOption

type AskOption struct {
	Label       string `json:"label"`
	Description string `json:"description,omitempty"`
}

type AskQuestion

type AskQuestion struct {
	ID      string      `json:"id"`
	Header  string      `json:"header,omitempty"`
	Prompt  string      `json:"prompt"`
	Options []AskOption `json:"options"`
	Multi   bool        `json:"multi,omitempty"`
}

type Attachment

type Attachment struct {
	Path string `json:"path"`
	Kind string `json:"kind"`
}

type Compaction

type Compaction struct {
	Trigger  string `json:"trigger,omitempty"`
	Messages int    `json:"messages,omitempty"`
	Summary  string `json:"summary,omitempty"`
	Archive  string `json:"archive,omitempty"`
}

type Event

type Event struct {
	Kind         string      `json:"kind"`
	Text         string      `json:"text,omitempty"`
	Reasoning    string      `json:"reasoning,omitempty"`
	Level        string      `json:"level,omitempty"`
	Tool         *Tool       `json:"tool,omitempty"`
	Usage        *Usage      `json:"usage,omitempty"`
	Approval     *Approval   `json:"approval,omitempty"`
	Ask          *Ask        `json:"ask,omitempty"`
	Compaction   *Compaction `json:"compaction,omitempty"`
	Err          string      `json:"err,omitempty"`
	RetryAttempt int         `json:"retryAttempt,omitempty"`
	RetryMax     int         `json:"retryMax,omitempty"`
	RetryAfterMs int64       `json:"retryAfterMs,omitempty"`
}

Event is the JSON shape an event.Event takes across the wire.

func ToWire

func ToWire(e event.Event) Event

ToWire converts an event.Event into its wire form. It matches desktop's toWire, including the goal-marker strip on live Message text.

type FileChange

type FileChange struct {
	Path    string `json:"path"`
	Kind    string `json:"kind"` // "create" | "modify" | "delete"
	Added   int    `json:"added"`
	Removed int    `json:"removed"`
	Diff    string `json:"diff"`
}

FileChange is one file within a previewed multi-file approval.

type FileDiff

type FileDiff struct {
	Diff    string `json:"diff"`
	Added   int    `json:"added"`
	Removed int    `json:"removed"`
}

FileDiff is the JSON form of event.FileDiff (empty Diff = nothing to show).

type Profile

type Profile struct {
	Model  string `json:"model,omitempty"`
	Effort string `json:"effort,omitempty"`
}

type Tool

type Tool struct {
	ID          string       `json:"id,omitempty"`
	Name        string       `json:"name"`
	Args        string       `json:"args,omitempty"`
	Output      string       `json:"output,omitempty"`
	Err         string       `json:"err,omitempty"`
	ReadOnly    bool         `json:"readOnly"`
	Truncated   bool         `json:"truncated,omitempty"`
	DurationMs  int64        `json:"durationMs,omitempty"`
	Partial     bool         `json:"partial,omitempty"`
	ParentID    string       `json:"parentId,omitempty"`
	Profile     *Profile     `json:"profile,omitempty"`
	Attachments []Attachment `json:"attachments,omitempty"`
	FileDiff    *FileDiff    `json:"fileDiff,omitempty"`
}

type Usage

type Usage struct {
	PromptTokens     int `json:"promptTokens"`
	CompletionTokens int `json:"completionTokens"`
	TotalTokens      int `json:"totalTokens"`
	CacheHitTokens   int `json:"cacheHitTokens"`
	CacheMissTokens  int `json:"cacheMissTokens"`
	CacheWriteTokens int `json:"cacheWriteTokens"`
	ReasoningTokens  int `json:"reasoningTokens,omitempty"`
	// Session-cumulative cache tokens; mapped back onto event.Event's
	// SessionHit/SessionMiss by FromWire.
	SessionCacheHitTokens  int     `json:"sessionCacheHitTokens"`
	SessionCacheMissTokens int     `json:"sessionCacheMissTokens"`
	Cost                   float64 `json:"cost,omitempty"`
	Currency               string  `json:"currency,omitempty"`
}

Jump to

Keyboard shortcuts

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