Documentation
¶
Overview ¶
Package eventwire lets the subprocess handlers of one event dispatch share the encoding of an event that no handler changed.
Pi hands every handler of a before_agent_start or tool_call dispatch the same event object (runner.ts emitBeforeAgentStart, emitToolCall), so a handler's edit reaches the next handler. A subprocess handler receives the event as JSON and its edits come back in its reply. A Dispatch counts the changes to the event: the dispatcher calls Changed after a handler that reads Go values and after each edit of its own, and a subprocess handler calls Applied or Changed when it applies a reply. An encoding made at the current version is the encoding of the event the next handler receives.
A context or context_with_system dispatch counts a change when a handler that reads Go values ran or a reply replaced the list: the encoding of the conversation, which grows with the session, is then made once for every handler that follows an unchanged conversation.
Applying a reply assigns the values it carries, so applying the reply applied last again, with no change since, leaves the event as it is: Repeated lets the handler skip it.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Dispatch ¶
type Dispatch struct {
// contains filtered or unexported fields
}
Dispatch is the shared state of one dispatch's handlers. Its methods are safe for concurrent use; on a nil Dispatch they record nothing and find nothing.
func FromContext ¶
FromContext returns the dispatch's Dispatch, or nil.
func WithDispatch ¶
WithDispatch returns ctx carrying a new Dispatch for one event dispatch.
func (*Dispatch) Applied ¶
func (d *Dispatch) Applied(reply []byte, result json.RawMessage)
Applied records that reply, carrying the handler result result, was applied to the event: the event may have changed, and a repeat of reply leaves it as it is now.
func (*Dispatch) Args ¶
Args returns the encoding of the event at the current version, when one was stored.
func (*Dispatch) Changed ¶
func (d *Dispatch) Changed()
Changed records that the event may have changed.
func (*Dispatch) Repeated ¶
func (d *Dispatch) Repeated(reply []byte) (json.RawMessage, bool)
Repeated returns the handler result of the reply applied last when reply has the same bytes and nothing changed since its application: applying reply again would leave the event as it is.