presence

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2026 License: Apache-2.0 Imports: 4 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package presence tracks who is connected to a daemon right now (PRD §8.1): MCP sessions, their last tool call, and when they were last seen. It is ephemeral and per daemon, and never written to git.

Index

Constants

View Source
const IdleTimeout = 30 * time.Minute

IdleTimeout drops a session that made no call for this long (a client that went away without closing).

Variables

This section is empty.

Functions

This section is empty.

Types

type Call

type Call struct {
	Method, Tool, Ticket, Error string
}

Call describes one request a session made.

type Change

type Change struct {
	State   string  `json:"state" doc:"connected, active or disconnected."`
	Session Session `json:"session"`
}

Change is the presence.changed payload.

type Session

type Session struct {
	ID         string `json:"id"`
	Actor      string `json:"actor"`
	OnBehalfOf string `json:"on_behalf_of,omitempty"`
	Client     string `json:"client,omitempty" doc:"clientInfo name and version."`
	Transport  string `json:"transport" doc:"mcp-http (directly or through the ka mcp proxy)."`
	Connected  string `json:"connected"`
	LastSeen   string `json:"last_seen"`
	LastMethod string `json:"last_method,omitempty"`
	LastTool   string `json:"last_tool,omitempty"`
	LastTicket string `json:"last_ticket,omitempty"`
	LastError  string `json:"last_error,omitempty" doc:"The error code of the last call, if it failed."`
	Calls      int    `json:"calls"`
}

Session is one connected agent session.

type Tracker

type Tracker struct {
	Now func() time.Time
	// contains filtered or unexported fields
}

Tracker holds the live sessions.

func New

func New(sink engine.EventSink) *Tracker

New returns a tracker that publishes presence.changed events to sink (may be nil).

func (*Tracker) Closed

func (t *Tracker) Closed(id string)

Closed removes a session.

func (*Tracker) List

func (t *Tracker) List() []Session

List returns the live sessions, most recently active first.

func (*Tracker) Seen

func (t *Tracker) Seen(id string, who Session, c Call) bool

Seen records a call. It reports whether the session is new.

func (*Tracker) Sweep

func (t *Tracker) Sweep(idle time.Duration)

Sweep drops sessions not seen for longer than idle (for clients that went away without closing).

Jump to

Keyboard shortcuts

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