Versions in this module Expand all Collapse all v0 v0.12.1 Nov 20, 2025 v0.12.0 Nov 19, 2025 Changes in this version + type AccessPolicy struct + AdminAllow []string + DeleteAllow []string + Public bool + ReadAllow []string + WriteAllow []string + type AgentConnection struct + Address string + ConflictCount int64 + ConnectionType ConnectionType + ID string + LastHeartbeat time.Time + Metadata map[string]interface{} + Name string + PendingUpdates []StateUpdate + Status ConnectionStatus + SubscribedStates []string + SyncStatus map[string]SyncStatus + type ConflictDetector struct + func NewConflictDetector(eventBus EventBus) *ConflictDetector + func (cd *ConflictDetector) AddRule(rule ConflictRule) + func (cd *ConflictDetector) DetectConflict(event StateEvent, currentState *SharedState) (*ConflictInfo, error) + func (cd *ConflictDetector) ResolveConflict(conflict *ConflictInfo, strategy ConflictResolution) (*SharedState, error) + type ConflictInfo struct + ConflictID string + Description string + Metadata map[string]interface{} + Operations []PendingOperation + Resolution ConflictResolution + ResolvedAt time.Time + ResolvedBy string + States map[string]*SharedState + Type ConflictType + type ConflictResolution string + const ConflictResolutionCustom + const ConflictResolutionLastWrite + const ConflictResolutionMerge + const ConflictResolutionReject + type ConflictRule interface + DetectConflict func(event StateEvent, currentState *SharedState) (*ConflictInfo, error) + ResolveConflict func(conflict *ConflictInfo, strategy ConflictResolution) (*SharedState, error) + type ConflictType string + const ConflictTypeCustom + const ConflictTypeReadWrite + const ConflictTypeSchema + const ConflictTypeVersion + const ConflictTypeWriteWrite + type ConnectionStatus string + const ConnectionStatusConnected + const ConnectionStatusConnecting + const ConnectionStatusDisconnected + const ConnectionStatusError + const ConnectionStatusReconnecting + type ConnectionType string + const ConnectionTypeBidirectional + const ConnectionTypePull + const ConnectionTypePush + type ConsistencyLevel string + const ConsistencyLevelEventual + const ConsistencyLevelStrong + const ConsistencyLevelWeak + type DatabasePersistence struct + func NewDatabasePersistence(config *PersistenceConfig) (*DatabasePersistence, error) + func (dp *DatabasePersistence) Backup(ctx context.Context, path string) error + func (dp *DatabasePersistence) Close() error + func (dp *DatabasePersistence) DeleteState(ctx context.Context, stateID string) error + func (dp *DatabasePersistence) ListStates(ctx context.Context, filters map[string]interface{}) ([]*SharedState, error) + func (dp *DatabasePersistence) LoadState(ctx context.Context, stateID string) (*SharedState, error) + func (dp *DatabasePersistence) Restore(ctx context.Context, path string) error + func (dp *DatabasePersistence) SaveState(ctx context.Context, state *SharedState) error + func (dp *DatabasePersistence) UpdateState(ctx context.Context, state *SharedState) error + type DefaultConflictRule struct + func (dcr *DefaultConflictRule) DetectConflict(event StateEvent, currentState *SharedState) (*ConflictInfo, error) + func (dcr *DefaultConflictRule) ResolveConflict(conflict *ConflictInfo, strategy ConflictResolution) (*SharedState, error) + type Event struct + AgentID string + Content string + Time time.Time + Type string + type EventBus interface + Close func() error + Publish func(event StateEvent) error + PublishAsync func(event StateEvent) error + Subscribe func(eventType EventType, handler EventHandler) error + Unsubscribe func(eventType EventType, handler EventHandler) error + type EventHandler interface + Handle func(ctx context.Context, event StateEvent) error + type EventType string + const EventTypeAgentConnected + const EventTypeAgentDisconnected + const EventTypeAgentHeartbeat + const EventTypeConfigChanged + const EventTypeConflictDetected + const EventTypeConflictResolved + const EventTypeStateCreated + const EventTypeStateDeleted + const EventTypeStateRead + const EventTypeStateUpdated + const EventTypeSyncCompleted + const EventTypeSyncConflict + const EventTypeSyncFailed + const EventTypeSyncStarted + const EventTypeSystemShutdown + const EventTypeSystemStarted + type FilePersistence struct + func NewFilePersistence(config *PersistenceConfig) (*FilePersistence, error) + func (fp *FilePersistence) Backup(ctx context.Context, path string) error + func (fp *FilePersistence) Close() error + func (fp *FilePersistence) DeleteState(ctx context.Context, stateID string) error + func (fp *FilePersistence) ListStates(ctx context.Context, filters map[string]interface{}) ([]*SharedState, error) + func (fp *FilePersistence) LoadState(ctx context.Context, stateID string) (*SharedState, error) + func (fp *FilePersistence) Restore(ctx context.Context, path string) error + func (fp *FilePersistence) SaveState(ctx context.Context, state *SharedState) error + func (fp *FilePersistence) UpdateState(ctx context.Context, state *SharedState) error + type InMemoryEventBus struct + func NewInMemoryEventBus(bufferSize int) *InMemoryEventBus + func (bus *InMemoryEventBus) Close() error + func (bus *InMemoryEventBus) Publish(event StateEvent) error + func (bus *InMemoryEventBus) PublishAsync(event StateEvent) error + func (bus *InMemoryEventBus) Subscribe(eventType EventType, handler EventHandler) error + func (bus *InMemoryEventBus) Unsubscribe(eventType EventType, handler EventHandler) error + type Member struct + AgentID string + Role Role + Tags []string + type MemoryPersistence struct + func NewMemoryPersistence() *MemoryPersistence + func (mp *MemoryPersistence) Backup(ctx context.Context, path string) error + func (mp *MemoryPersistence) Close() error + func (mp *MemoryPersistence) DeleteState(ctx context.Context, stateID string) error + func (mp *MemoryPersistence) ListStates(ctx context.Context, filters map[string]interface{}) ([]*SharedState, error) + func (mp *MemoryPersistence) LoadState(ctx context.Context, stateID string) (*SharedState, error) + func (mp *MemoryPersistence) Restore(ctx context.Context, path string) error + func (mp *MemoryPersistence) SaveState(ctx context.Context, state *SharedState) error + func (mp *MemoryPersistence) UpdateState(ctx context.Context, state *SharedState) error + type Message struct + From string + Text string + Time time.Time + To string + type OperationType string + const OperationTypeCAS + const OperationTypeDelete + const OperationTypeMerge + const OperationTypeSet + type PendingOperation struct + AgentID string + ID string + Key string + Metadata map[string]interface{} + OldValue interface{} + Retry int + Timestamp time.Time + Type OperationType + Value interface{} + type PersistenceConfig struct + BatchSize int + Compression bool + ConnectionString string + Encryption bool + EncryptionKey string + MaxConnections int + Retention map[string]time.Duration + Timeout time.Duration + Type PersistenceType + type PersistenceLayer interface + Backup func(ctx context.Context, path string) error + Close func() error + DeleteState func(ctx context.Context, stateID string) error + ListStates func(ctx context.Context, filters map[string]interface{}) ([]*SharedState, error) + LoadState func(ctx context.Context, stateID string) (*SharedState, error) + Restore func(ctx context.Context, path string) error + SaveState func(ctx context.Context, state *SharedState) error + UpdateState func(ctx context.Context, state *SharedState) error + func NewPersistenceLayer(config *PersistenceConfig) (PersistenceLayer, error) + type PersistenceType string + const PersistenceTypeDatabase + const PersistenceTypeFile + const PersistenceTypeMemory + const PersistenceTypeRedis + type RedisPersistence struct + func NewRedisPersistence(config *PersistenceConfig) (*RedisPersistence, error) + func (rp *RedisPersistence) Backup(ctx context.Context, path string) error + func (rp *RedisPersistence) Close() error + func (rp *RedisPersistence) DeleteState(ctx context.Context, stateID string) error + func (rp *RedisPersistence) ListStates(ctx context.Context, filters map[string]interface{}) ([]*SharedState, error) + func (rp *RedisPersistence) LoadState(ctx context.Context, stateID string) (*SharedState, error) + func (rp *RedisPersistence) Restore(ctx context.Context, path string) error + func (rp *RedisPersistence) SaveState(ctx context.Context, state *SharedState) error + func (rp *RedisPersistence) UpdateState(ctx context.Context, state *SharedState) error + type Role string + const RoleLeader + const RoleWorker + type SharedState struct + AccessPolicy AccessPolicy + Data map[string]interface{} + ID string + LastSync time.Time + Metadata map[string]interface{} + Name string + Owners []string + PendingOps []PendingOperation + Readers []string + SyncStatus SyncStatus + Tags []string + Timestamp time.Time + Type StateType + Version int64 + type Stars struct + func New(cosmos *cosmos.Cosmos, name string) *Stars + func (s *Stars) Broadcast(ctx context.Context, text string) error + func (s *Stars) History() []Message + func (s *Stars) ID() string + func (s *Stars) Join(agentID string, role Role) error + func (s *Stars) Leave(agentID string) error + func (s *Stars) Members() []Member + func (s *Stars) Name() string + func (s *Stars) Run(ctx context.Context, task string) iter.Seq2[*Event, error] + func (s *Stars) Send(ctx context.Context, from, to, text string) error + func (s *Stars) Size() int + type StateEvent struct + AgentID string + Conflict *ConflictInfo + Metadata map[string]interface{} + Operation *PendingOperation + State *SharedState + StateID string + Timestamp time.Time + Type EventType + type StateEventHandler struct + func (seh *StateEventHandler) Handle(ctx context.Context, event StateEvent) error + type StateManager struct + func NewStateManager(config *StateManagerConfig, eventBus EventBus, persistence PersistenceLayer) *StateManager + func (sm *StateManager) CreateState(ctx context.Context, stateID, name string, stateType StateType, ...) (*SharedState, error) + func (sm *StateManager) DeleteState(ctx context.Context, stateID, agentID string) error + func (sm *StateManager) GetMetrics() *StateMetrics + func (sm *StateManager) GetState(stateID string) (*SharedState, error) + func (sm *StateManager) UpdateState(ctx context.Context, stateID string, agentID string, ...) error + type StateManagerConfig struct + ConflictResolution ConflictResolution + ConsistencyLevel ConsistencyLevel + EnableAudit bool + EnableMetrics bool + EnablePersistence bool + FlushInterval time.Duration + MaxRetries int + PersistenceType PersistenceType + RetryDelay time.Duration + SyncInterval time.Duration + type StateMetrics struct + ActiveStates int64 + AverageSyncTime time.Duration + Conflicts int64 + DeleteOps int64 + LastSyncTime time.Time + PendingOperations int64 + ReadOps int64 + SyncErrors int64 + TotalStates int64 + WriteOps int64 + type StateSyncManager struct + func NewStateSyncManager(stateManager *StateManager, eventBus EventBus, config *SyncConfig) *StateSyncManager + func (ssm *StateSyncManager) ConnectAgent(agentID, name, address string, connType ConnectionType, states []string) (*AgentConnection, error) + func (ssm *StateSyncManager) CreateSyncTask(taskType SyncTaskType, stateID string, targetAgents []string, ...) (*SyncTask, error) + func (ssm *StateSyncManager) DisconnectAgent(agentID string) error + func (ssm *StateSyncManager) GetAgentConnection(agentID string) (*AgentConnection, error) + func (ssm *StateSyncManager) GetMetrics() *SyncMetrics + func (ssm *StateSyncManager) ListAgentConnections() map[string]*AgentConnection + type StateType string + const StateTypeAgent + const StateTypeGlobal + const StateTypeResource + const StateTypeSession + const StateTypeTask + const StateTypeWorkflow + type StateUpdate struct + AgentID string + ID string + Key string + Metadata map[string]interface{} + NewValue interface{} + OldValue interface{} + StateID string + Timestamp time.Time + Type OperationType + Version int64 + type SyncConfig struct + BatchSize int + Compression bool + CompressionType string + ConflictStrategy ConflictResolution + ConsistencyLevel ConsistencyLevel + Encryption bool + EncryptionKey string + FlushInterval time.Duration + MaxConcurrentSyncs int + MaxRetries int + QueueBufferSize int + RetryDelay time.Duration + SyncInterval time.Duration + Timeout time.Duration + type SyncMetrics struct + ActiveConnections int64 + AverageLatency time.Duration + Conflicts int64 + FailedSyncs int64 + LastSyncTime time.Time + PendingTasks int64 + SuccessfulSyncs int64 + ThroughputPerSec float64 + TotalSyncs int64 + type SyncStatus string + const SyncStatusConflict + const SyncStatusError + const SyncStatusPending + const SyncStatusSynced + const SyncStatusSyncing + type SyncTask struct + CompletedAt time.Time + CreatedAt time.Time + Error string + ID string + MaxRetries int + Metadata map[string]interface{} + Priority int + RetryCount int + StartedAt time.Time + StateID string + Status TaskStatus + TargetAgents []string + Type SyncTaskType + Updates []StateUpdate + type SyncTaskType string + const SyncTaskTypeBroadcast + const SyncTaskTypeDeltaSync + const SyncTaskTypeFullSync + const SyncTaskTypeMulticast + const SyncTaskTypeUnicast + type TaskStatus string + const TaskStatusCancelled + const TaskStatusCompleted + const TaskStatusFailed + const TaskStatusPending + const TaskStatusRunning