extevents

package
v1.2.9 Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package extevents is the publishing end of the extension event stream.

The problem it solves is a dependency one. Events have to be published where they happen: a tool call from the agent loop, an MCP handshake from the MCP client, a provider account edit from the configuration package. Those packages cannot import internal/extensions, which is the host side of the extension system and already imports several of them. So the publishing end is this leaf package, which imports nothing but the public contract, and internal/extensions installs itself as the sink at start-up.

Two properties are guaranteed to callers, because a publish sits inside the operation it reports:

  • Publishing never blocks. Events go to a bounded channel and are dropped when it is full, exactly as the configuration bus already drops. An event stream is accounting, and accounting must not be able to stall the work it is accounting for.
  • Publishing costs one atomic load when nothing subscribes, which is every standard build: no sink is installed, so Publish returns immediately and the helpers below do not even build their payload.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ContextFiltered added in v1.2.7

func ContextFiltered(info ContextFilteredInfo)

ContextFiltered reports that the decision model dropped part of the context retrieved for a turn.

func Enabled

func Enabled() bool

Enabled reports whether anything is listening. Call sites that would have to do real work to build a payload check it first; the helpers in this package already do.

func MCPHandshake

func MCPHandshake(server, transport, client string, err error, authNeeded bool)

MCPHandshake reports the outcome of connecting to an MCP server. authNeeded distinguishes "this server would work once somebody signs in" from a plain failure, because the two ask for very different things from an operator.

func ModelRouted added in v1.2.7

func ModelRouted(info ModelRoutedInfo)

ModelRouted reports the model Auto mode picked for a turn, or the failover candidate it moved to (Fallback true).

func PersonaRouted added in v1.2.7

func PersonaRouted(info PersonaRoutedInfo)

PersonaRouted reports the persona the auto-selection applied for a turn.

func ProviderAccountAdded

func ProviderAccountAdded(id, providerType string, disabled bool)

ProviderAccountAdded reports a newly configured provider account.

func ProviderAccountRemoved

func ProviderAccountRemoved(id, providerType string)

ProviderAccountRemoved reports a deleted provider account.

func ProviderAccountUpdated

func ProviderAccountUpdated(id, providerType string, disabled bool)

ProviderAccountUpdated reports an edited provider account, including one that was only enabled or disabled.

func Publish

func Publish(ev extension.Event)

Publish hands one event to the installed sink. It never blocks and never returns an error: with no sink it does nothing, and with a full buffer the event is dropped and counted in the debug log.

func SetSink

func SetSink(ctx context.Context, sink Sink)

SetSink installs sink as the consumer of published events and starts the goroutine that feeds it, stopping when ctx is cancelled. A nil sink detaches the previous one, which is what tests and teardown use.

Calling it again replaces the sink: the previous delivery goroutine drains nothing further and exits.

func SkillActivated

func SkillActivated(sessionID, name, agent, source string)

SkillActivated reports that a skill was switched on for a run.

func ToolCompleted

func ToolCompleted(sessionID, callID, name, agent string, dur time.Duration, err error)

ToolCompleted reports that a tool call finished. A nil err means success; the error text is published because it is the host's own diagnosis of the call, not user content.

func ToolStarted

func ToolStarted(sessionID, callID, name, agent string)

ToolStarted reports that the host handed a tool call to its tool.

Types

type ContextFilteredInfo added in v1.2.7

type ContextFilteredInfo struct {
	SessionID string
	Kept      int
	Dropped   int
	// BySource maps a source ("code", "kb", "events", "memory") to {kept, dropped}.
	BySource       map[string][2]int
	Threshold      float64
	LatencyMs      int64
	RouterProvider string
	RouterModel    string
	Reason         string
}

ContextFilteredInfo describes one relevance filtering of the injected context. Like ModelRoutedInfo it has no field for prompt or snippet text.

type ModelRoutedInfo added in v1.2.7

type ModelRoutedInfo struct {
	SessionID       string
	RouteID         string
	Model           string
	Fallback        bool
	Reason          string
	Probability     float64
	Confidence      float64
	RouterProvider  string
	RouterModel     string
	RouterLatencyMs int64
	RouterCostUSD   *float64
}

ModelRoutedInfo describes one Auto model mode decision. It deliberately has no field for prompt text: this topic leaves the process in some deployments.

type PersonaRoutedInfo added in v1.2.7

type PersonaRoutedInfo struct {
	SessionID   string
	Persona     string
	Source      string
	Reason      string
	Probability float64
	LatencyMs   int64
	CostUSD     *float64
	ErrorClass  string
	Changed     bool
}

PersonaRoutedInfo describes one persona auto-selection decision. Like ModelRoutedInfo it has no field for prompt text.

type Sink

type Sink func(ev extension.Event)

Sink consumes published events. It is called from the package's own delivery goroutine, one event at a time, never from the publisher's goroutine.

Jump to

Keyboard shortcuts

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