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 ¶
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 AskQuestion ¶
type Attachment ¶
type Compaction ¶
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.
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 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"`
}