Documentation
¶
Index ¶
- Constants
- func BuildLegacyDirectAliases(agentID, channel, account, peerID string) []string
- func BuildLegacyMainAlias(agentID string) string
- func BuildLegacyPeerAlias(agentID, channel, peerKind, peerID string) string
- func BuildMainSessionKey(agentID string) string
- func BuildOpaqueSessionKey(alias string) string
- func BuildSessionKey(scope SessionScope) string
- func CanonicalScopeSignature(scope SessionScope) string
- func CanonicalSessionIdentityID(channel, rawID string, identityLinks map[string][]string) string
- func IsExplicitSessionKey(key string) bool
- func IsLegacyAgentSessionKey(key string) bool
- func IsOpaqueSessionKey(key string) bool
- func ResolveAgentID(store any, sessionKey string) string
- type Allocation
- type AllocationInput
- type JSONLBackend
- func (b *JSONLBackend) AddFullMessage(sessionKey string, msg providers.Message)
- func (b *JSONLBackend) AddMessage(sessionKey, role, content string)
- func (b *JSONLBackend) Close() error
- func (b *JSONLBackend) EnsureSessionMetadata(sessionKey string, scope *SessionScope, aliases []string)
- func (b *JSONLBackend) GetHistory(key string) []providers.Message
- func (b *JSONLBackend) GetSessionScope(sessionKey string) *SessionScope
- func (b *JSONLBackend) GetSummary(key string) string
- func (b *JSONLBackend) ListSessions() []string
- func (b *JSONLBackend) ResolveSessionKey(sessionKey string) string
- func (b *JSONLBackend) Save(key string) error
- func (b *JSONLBackend) SetHistory(key string, history []providers.Message)
- func (b *JSONLBackend) SetSummary(key, summary string)
- func (b *JSONLBackend) TruncateHistory(key string, keepLast int)
- type MetadataAwareSessionStore
- type ParsedLegacySessionKey
- type Session
- type SessionManager
- func (sm *SessionManager) AddFullMessage(sessionKey string, msg providers.Message)
- func (sm *SessionManager) AddMessage(sessionKey, role, content string)
- func (sm *SessionManager) Close() error
- func (sm *SessionManager) GetHistory(key string) []providers.Message
- func (sm *SessionManager) GetOrCreate(key string) *Session
- func (sm *SessionManager) GetSummary(key string) string
- func (sm *SessionManager) ListSessions() []string
- func (sm *SessionManager) Save(key string) error
- func (sm *SessionManager) SetHistory(key string, history []providers.Message)
- func (sm *SessionManager) SetSummary(key string, summary string)
- func (sm *SessionManager) TruncateHistory(key string, keepLast int)
- type SessionScope
- type SessionStore
Constants ¶
const ScopeVersionV1 = 1
ScopeVersionV1 is the first structured session-scope schema version.
Variables ¶
This section is empty.
Functions ¶
func BuildLegacyDirectAliases ¶ added in v0.2.7
func BuildLegacyMainAlias ¶ added in v0.2.7
func BuildLegacyPeerAlias ¶ added in v0.2.7
func BuildMainSessionKey ¶ added in v0.2.7
BuildMainSessionKey returns the canonical opaque main-session key for an agent. The corresponding legacy alias remains available via BuildLegacyMainAlias for compatibility and migration logic.
func BuildOpaqueSessionKey ¶ added in v0.2.7
BuildOpaqueSessionKey returns a stable opaque session key derived from a canonical alias string. The alias remains available through metadata for compatibility and migration purposes.
func BuildSessionKey ¶ added in v0.2.7
func BuildSessionKey(scope SessionScope) string
BuildSessionKey returns the current opaque key for a structured session scope.
func CanonicalScopeSignature ¶ added in v0.2.7
func CanonicalScopeSignature(scope SessionScope) string
CanonicalScopeSignature returns a stable serialized representation of scope.
func CanonicalSessionIdentityID ¶ added in v0.2.7
CanonicalSessionIdentityID collapses an identity using identity_links when possible, then returns a normalized lowercase identifier.
func IsExplicitSessionKey ¶ added in v0.2.7
func IsLegacyAgentSessionKey ¶ added in v0.2.7
func IsOpaqueSessionKey ¶ added in v0.2.7
IsOpaqueSessionKey returns true when the key matches the current opaque session-key format.
func ResolveAgentID ¶ added in v0.2.7
ResolveAgentID returns the routed agent ID associated with a session. It prefers structured session scope metadata when available and falls back to legacy agent-scoped session keys for compatibility.
Types ¶
type Allocation ¶ added in v0.2.7
type Allocation struct {
Scope SessionScope
SessionKey string
SessionAliases []string
MainSessionKey string
MainAliases []string
}
Allocation contains the concrete session keys selected for a routed turn. The current implementation intentionally preserves the legacy session-key layout while moving key construction out of the router.
func AllocateRouteSession ¶ added in v0.2.7
func AllocateRouteSession(input AllocationInput) Allocation
AllocateRouteSession maps a route decision onto a structured scope and the current opaque session-key format.
type AllocationInput ¶ added in v0.2.7
type AllocationInput struct {
AgentID string
Context bus.InboundContext
SessionPolicy routing.SessionPolicy
}
AllocationInput contains the routing result and peer context needed to derive the session keys for a turn.
type JSONLBackend ¶ added in v0.2.2
type JSONLBackend struct {
// contains filtered or unexported fields
}
JSONLBackend adapts a memory.Store into the SessionStore interface. Write errors are logged rather than returned, matching the fire-and-forget contract of SessionManager that the agent loop relies on.
func NewJSONLBackend ¶ added in v0.2.2
func NewJSONLBackend(store memory.Store) *JSONLBackend
NewJSONLBackend wraps a memory.Store for use as a SessionStore.
func (*JSONLBackend) AddFullMessage ¶ added in v0.2.2
func (b *JSONLBackend) AddFullMessage(sessionKey string, msg providers.Message)
func (*JSONLBackend) AddMessage ¶ added in v0.2.2
func (b *JSONLBackend) AddMessage(sessionKey, role, content string)
func (*JSONLBackend) Close ¶ added in v0.2.2
func (b *JSONLBackend) Close() error
Close releases resources held by the underlying store.
func (*JSONLBackend) EnsureSessionMetadata ¶ added in v0.2.7
func (b *JSONLBackend) EnsureSessionMetadata(sessionKey string, scope *SessionScope, aliases []string)
EnsureSessionMetadata persists scope and alias metadata for a session.
func (*JSONLBackend) GetHistory ¶ added in v0.2.2
func (b *JSONLBackend) GetHistory(key string) []providers.Message
func (*JSONLBackend) GetSessionScope ¶ added in v0.2.7
func (b *JSONLBackend) GetSessionScope(sessionKey string) *SessionScope
GetSessionScope reads structured scope metadata for a session key or alias.
func (*JSONLBackend) GetSummary ¶ added in v0.2.2
func (b *JSONLBackend) GetSummary(key string) string
func (*JSONLBackend) ListSessions ¶ added in v0.2.6
func (b *JSONLBackend) ListSessions() []string
ListSessions returns all known session keys.
func (*JSONLBackend) ResolveSessionKey ¶ added in v0.2.7
func (b *JSONLBackend) ResolveSessionKey(sessionKey string) string
ResolveSessionKey maps aliases onto their canonical session key when the underlying store supports structured metadata. Unknown aliases fall back to the original input so existing callers remain compatible.
func (*JSONLBackend) Save ¶ added in v0.2.2
func (b *JSONLBackend) Save(key string) error
Save persists session state. Since the JSONL store fsyncs every write immediately, the data is already durable. Save runs compaction to reclaim space from logically truncated messages (no-op when there are none).
func (*JSONLBackend) SetHistory ¶ added in v0.2.2
func (b *JSONLBackend) SetHistory(key string, history []providers.Message)
func (*JSONLBackend) SetSummary ¶ added in v0.2.2
func (b *JSONLBackend) SetSummary(key, summary string)
func (*JSONLBackend) TruncateHistory ¶ added in v0.2.2
func (b *JSONLBackend) TruncateHistory(key string, keepLast int)
type MetadataAwareSessionStore ¶ added in v0.2.7
type MetadataAwareSessionStore interface {
EnsureSessionMetadata(sessionKey string, scope *SessionScope, aliases []string)
ResolveSessionKey(sessionKey string) string
GetSessionScope(sessionKey string) *SessionScope
}
MetadataAwareSessionStore exposes structured session metadata operations.
type ParsedLegacySessionKey ¶ added in v0.2.7
func ParseLegacyAgentSessionKey ¶ added in v0.2.7
func ParseLegacyAgentSessionKey(sessionKey string) *ParsedLegacySessionKey
type SessionManager ¶
type SessionManager struct {
// contains filtered or unexported fields
}
func NewSessionManager ¶
func NewSessionManager(storage string) *SessionManager
func (*SessionManager) AddFullMessage ¶ added in v0.1.1
func (sm *SessionManager) AddFullMessage(sessionKey string, msg providers.Message)
AddFullMessage adds a complete message with tool calls and tool call ID to the session. This is used to save the full conversation flow including tool calls and tool results.
func (*SessionManager) AddMessage ¶
func (sm *SessionManager) AddMessage(sessionKey, role, content string)
func (*SessionManager) Close ¶ added in v0.2.2
func (sm *SessionManager) Close() error
Close is a no-op for the in-memory SessionManager; it satisfies the SessionStore interface so callers can release resources uniformly.
func (*SessionManager) GetHistory ¶
func (sm *SessionManager) GetHistory(key string) []providers.Message
func (*SessionManager) GetOrCreate ¶
func (sm *SessionManager) GetOrCreate(key string) *Session
func (*SessionManager) GetSummary ¶ added in v0.1.1
func (sm *SessionManager) GetSummary(key string) string
func (*SessionManager) ListSessions ¶ added in v0.2.6
func (sm *SessionManager) ListSessions() []string
func (*SessionManager) Save ¶
func (sm *SessionManager) Save(key string) error
func (*SessionManager) SetHistory ¶ added in v0.1.2
func (sm *SessionManager) SetHistory(key string, history []providers.Message)
SetHistory updates the messages of a session.
func (*SessionManager) SetSummary ¶ added in v0.1.1
func (sm *SessionManager) SetSummary(key string, summary string)
func (*SessionManager) TruncateHistory ¶ added in v0.1.1
func (sm *SessionManager) TruncateHistory(key string, keepLast int)
type SessionScope ¶ added in v0.2.7
type SessionScope struct {
Version int `json:"version"`
AgentID string `json:"agent_id"`
Channel string `json:"channel"`
Account string `json:"account"`
Dimensions []string `json:"dimensions"`
Values map[string]string `json:"values"`
}
SessionScope describes the semantic session partition selected for a turn.
func CloneScope ¶ added in v0.2.7
func CloneScope(scope *SessionScope) *SessionScope
CloneScope returns a deep copy of scope.
type SessionStore ¶ added in v0.2.2
type SessionStore interface {
// AddMessage appends a simple role/content message to the session.
AddMessage(sessionKey, role, content string)
// AddFullMessage appends a complete message including tool calls.
AddFullMessage(sessionKey string, msg providers.Message)
// GetHistory returns the full message history for the session.
GetHistory(key string) []providers.Message
// GetSummary returns the conversation summary, or "" if none.
GetSummary(key string) string
// SetSummary replaces the conversation summary.
SetSummary(key, summary string)
// SetHistory replaces the full message history.
SetHistory(key string, history []providers.Message)
// TruncateHistory keeps only the last keepLast messages.
TruncateHistory(key string, keepLast int)
// Save persists any pending state to durable storage.
Save(key string) error
// ListSessions returns all known session keys.
ListSessions() []string
// Close releases resources held by the store.
Close() error
}
SessionStore defines the persistence operations used by the agent loop. Both SessionManager (legacy JSON backend) and JSONLBackend satisfy this interface, allowing the storage layer to be swapped without touching the agent loop code.
Write methods (Add*, Set*, Truncate*) are fire-and-forget: they do not return errors. Implementations should log failures internally. This matches the original SessionManager contract that the agent loop relies on.