ledger

package
v0.3.7 Latest Latest
Warning

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

Go to latest
Published: May 21, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package ledger persists per-MCP-client session metrics to .remindb/sessions/ as append-only JSONL.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Hash

func Hash(c ClientMeta, transport string) string

Types

type ClientLedger

type ClientLedger struct {
	Hash            string     `json:"hash"`
	Client          ClientMeta `json:"client"`
	Transport       string     `json:"transport"`
	Sessions        int        `json:"sessions"`
	LifetimeSeconds int64      `json:"lifetime_seconds"`
	LastDisconnect  int64      `json:"last_disconnect"`
	ToolCalls       int64      `json:"tool_calls"`
}

type ClientMeta

type ClientMeta struct {
	Name     string `json:"name"`
	Title    string `json:"title,omitempty"`
	Version  string `json:"version"`
	Protocol string `json:"protocol"`
}

type Ledger

type Ledger struct {
	// contains filtered or unexported fields
}

func New

func New(workspace string, logger *slog.Logger) (*Ledger, error)

New opens (and compacts) the ledger under <workspace>/.remindb/sessions.

func (*Ledger) Append

func (l *Ledger) Append(r Record) error

Append writes one session checkpoint line.

func (*Ledger) Client

func (l *Ledger) Client(hash string) (*ClientLedger, error)

Client aggregates the single client file whose name carries hash.

func (*Ledger) Clients

func (l *Ledger) Clients() ([]ClientLedger, error)

Clients aggregates every client file, collapsing each by session_id.

type Record

type Record struct {
	SessionID      string     `json:"session_id"`
	Client         ClientMeta `json:"client"`
	Transport      string     `json:"transport"`
	ConnectedAt    int64      `json:"connected_at"`
	LastSeen       int64      `json:"last_seen"`
	DisconnectedAt int64      `json:"disconnected_at,omitempty"`
	ToolCalls      int64      `json:"tool_calls"`
}

Jump to

Keyboard shortcuts

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