extevents

package
v0.703.4 Latest Latest
Warning

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

Go to latest
Published: Sep 7, 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 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 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 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