session

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Mar 24, 2026 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Overview

Package session tracks advisory state for an MCP server session, including tool call counts, entry adds, and pending updates.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type PendingUpdate

type PendingUpdate struct {
	Type     string
	Content  string
	Attrs    map[string]string
	QueuedAt time.Time
}

PendingUpdate represents a context update awaiting human confirmation.

type State

type State struct {
	ToolCalls     int
	AddsPerformed map[string]int

	PendingFlush []PendingUpdate
	// contains filtered or unexported fields
}

State tracks per-context-dir advisory state.

Session state is keyed by contextDir on the Server struct. It tracks tool call counts, entry additions, and pending context updates that need human review before persisting.

Thread-safety: State is only accessed from the main request loop (single goroutine). If future work introduces concurrent access, a mutex should be added here.

func NewState

func NewState(contextDir string) *State

NewState creates a new session state for the given context directory.

func (*State) PendingCount

func (ss *State) PendingCount() int

PendingCount returns the number of pending updates.

func (*State) QueuePendingUpdate

func (ss *State) QueuePendingUpdate(update PendingUpdate)

QueuePendingUpdate adds an update to the pending flush queue.

func (*State) RecordAdd

func (ss *State) RecordAdd(entryType string)

RecordAdd increments the add counter for the given entry type.

func (*State) RecordToolCall

func (ss *State) RecordToolCall()

RecordToolCall increments the tool call counter.

Jump to

Keyboard shortcuts

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