workspace

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrWorkspaceNotFound = errors.New("workspace not found")
)

Functions

This section is empty.

Types

type Chronicler

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

Chronicler persists workspace messages as triples in the graph store.

func NewChronicler

func NewChronicler(adder TripleAdder, logger *zap.SugaredLogger) *Chronicler

NewChronicler creates a new message chronicler.

func (*Chronicler) HandleMessage

func (c *Chronicler) HandleMessage(msg Message)

HandleMessage is a MessageHandler that records messages via the chronicler.

func (*Chronicler) Record

func (c *Chronicler) Record(ctx context.Context, msg Message) error

Record persists a workspace message as graph triples.

type Contribution

type Contribution struct {
	DID        string    `json:"did"`
	Commits    int       `json:"commits"`
	CodeBytes  int64     `json:"codeBytes"`
	Messages   int       `json:"messages"`
	LastActive time.Time `json:"lastActive"`
}

Contribution records a member's contribution to a workspace.

type ContributionTracker

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

ContributionTracker tracks contributions per member per workspace.

func NewContributionTracker

func NewContributionTracker() *ContributionTracker

NewContributionTracker creates a new contribution tracker.

func (*ContributionTracker) Get

func (t *ContributionTracker) Get(workspaceID, did string) *Contribution

Get returns the contribution for a member in a workspace.

func (*ContributionTracker) List

func (t *ContributionTracker) List(workspaceID string) []*Contribution

List returns all contributions for a workspace.

func (*ContributionTracker) RecordCommit

func (t *ContributionTracker) RecordCommit(workspaceID, did string, codeBytes int64)

RecordCommit records a commit contribution.

func (*ContributionTracker) RecordMessage

func (t *ContributionTracker) RecordMessage(workspaceID, did string)

RecordMessage records a message contribution.

func (*ContributionTracker) Remove

func (t *ContributionTracker) Remove(workspaceID string)

Remove deletes all contribution data for a workspace.

type CreateRequest

type CreateRequest struct {
	Name     string            `json:"name"`
	Goal     string            `json:"goal"`
	Metadata map[string]string `json:"metadata,omitempty"`
}

CreateRequest holds parameters for creating a new workspace.

type GossipConfig

type GossipConfig struct {
	PubSub  *pubsub.PubSub
	LocalID peer.ID
	Handler MessageHandler
	Logger  *zap.SugaredLogger
}

GossipConfig configures the workspace gossip.

type Manager

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

Manager manages workspace lifecycle with BoltDB persistence.

func NewManager

func NewManager(cfg ManagerConfig) (*Manager, error)

NewManager creates a new workspace manager.

func (*Manager) Activate

func (m *Manager) Activate(ctx context.Context, workspaceID string) error

Activate transitions a workspace from forming to active.

func (*Manager) AddMember

func (m *Manager) AddMember(ctx context.Context, workspaceID string, member *Member) error

AddMember adds a remote member to a workspace.

func (*Manager) Archive

func (m *Manager) Archive(ctx context.Context, workspaceID string) error

Archive transitions a workspace to archived status.

func (*Manager) Create

func (m *Manager) Create(ctx context.Context, req CreateRequest) (*Workspace, error)

Create creates a new workspace.

func (*Manager) Get

func (m *Manager) Get(ctx context.Context, workspaceID string) (*Workspace, error)

Get returns a workspace by ID.

func (*Manager) Join

func (m *Manager) Join(ctx context.Context, workspaceID string) error

Join adds the local agent to a workspace.

func (*Manager) Leave

func (m *Manager) Leave(ctx context.Context, workspaceID string) error

Leave removes the local agent from a workspace.

func (*Manager) List

func (m *Manager) List(ctx context.Context) ([]*Workspace, error)

List returns all known workspaces.

func (*Manager) Post

func (m *Manager) Post(ctx context.Context, workspaceID string, msg Message) error

Post adds a message to a workspace.

func (*Manager) Read

func (m *Manager) Read(ctx context.Context, workspaceID string, opts ReadOptions) ([]Message, error)

Read returns messages from a workspace.

type ManagerConfig

type ManagerConfig struct {
	DB            *bolt.DB
	LocalDID      string
	MaxWorkspaces int
	Logger        *zap.SugaredLogger
}

ManagerConfig configures the WorkspaceManager.

type Member

type Member struct {
	DID      string    `json:"did"`
	Name     string    `json:"name,omitempty"`
	Role     Role      `json:"role"`
	JoinedAt time.Time `json:"joinedAt"`
}

Member represents a participant in a workspace.

type Message

type Message struct {
	ID          string            `json:"id"`
	Type        MessageType       `json:"type"`
	WorkspaceID string            `json:"workspaceId"`
	SenderDID   string            `json:"senderDid"`
	Content     string            `json:"content"`
	Metadata    map[string]string `json:"metadata,omitempty"`
	ParentID    string            `json:"parentId,omitempty"`
	Timestamp   time.Time         `json:"timestamp"`
}

Message represents a message posted to a workspace.

type MessageHandler

type MessageHandler func(msg Message)

MessageHandler is called when a workspace message is received via GossipSub.

type MessageType

type MessageType string

MessageType identifies the kind of workspace message.

const (
	MessageTypeTaskProposal   MessageType = "TASK_PROPOSAL"
	MessageTypeLogStream      MessageType = "LOG_STREAM"
	MessageTypeCommitSignal   MessageType = "COMMIT_SIGNAL"
	MessageTypeKnowledgeShare MessageType = "KNOWLEDGE_SHARE"
	MessageTypeMemberJoined   MessageType = "MEMBER_JOINED"
	MessageTypeMemberLeft     MessageType = "MEMBER_LEFT"

	// Conflict and branch collaboration message types.
	MessageTypeConflictReport MessageType = "CONFLICT_REPORT"
	MessageTypeBranchCreated  MessageType = "BRANCH_CREATED"
	MessageTypeBranchMerged   MessageType = "BRANCH_MERGED"
	MessageTypeSyncRequest    MessageType = "SYNC_REQUEST"
)

type ReadOptions

type ReadOptions struct {
	Limit     int       `json:"limit,omitempty"`
	Before    time.Time `json:"before,omitempty"`
	After     time.Time `json:"after,omitempty"`
	SenderDID string    `json:"senderDID,omitempty"`
	Types     []string  `json:"types,omitempty"`
	ParentID  string    `json:"parentID,omitempty"`
}

ReadOptions controls workspace message listing.

type Role

type Role string

Role represents a member's role in a workspace.

const (
	RoleCreator Role = "creator"
	RoleMember  Role = "member"
)

type Status

type Status string

Status represents the lifecycle state of a workspace.

const (
	StatusForming  Status = "forming"
	StatusActive   Status = "active"
	StatusArchived Status = "archived"
)

type Triple

type Triple struct {
	Subject   string
	Predicate string
	Object    string
}

Triple represents a subject-predicate-object triple for the graph store.

type TripleAdder

type TripleAdder func(ctx context.Context, triples []Triple) error

TripleAdder persists triples to a graph store.

type Workspace

type Workspace struct {
	ID        string            `json:"id"`
	Name      string            `json:"name"`
	Goal      string            `json:"goal"`
	Status    Status            `json:"status"`
	Members   []*Member         `json:"members"`
	CreatedAt time.Time         `json:"createdAt"`
	UpdatedAt time.Time         `json:"updatedAt"`
	Metadata  map[string]string `json:"metadata,omitempty"`
}

Workspace represents a collaborative workspace where agents share code and messages.

type WorkspaceGossip

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

WorkspaceGossip manages per-workspace GossipSub topics.

func NewWorkspaceGossip

func NewWorkspaceGossip(cfg GossipConfig) *WorkspaceGossip

NewWorkspaceGossip creates a new workspace gossip manager.

func (*WorkspaceGossip) Publish

func (g *WorkspaceGossip) Publish(ctx context.Context, workspaceID string, msg Message) error

Publish sends a message to the workspace's GossipSub topic.

func (*WorkspaceGossip) Stop

func (g *WorkspaceGossip) Stop()

Stop unsubscribes from all workspace topics.

func (*WorkspaceGossip) Subscribe

func (g *WorkspaceGossip) Subscribe(workspaceID string) error

Subscribe joins the GossipSub topic for a workspace and starts listening.

func (*WorkspaceGossip) SubscribedWorkspaces

func (g *WorkspaceGossip) SubscribedWorkspaces() []string

SubscribedWorkspaces returns the list of workspace IDs currently subscribed.

func (*WorkspaceGossip) Unsubscribe

func (g *WorkspaceGossip) Unsubscribe(workspaceID string)

Unsubscribe leaves the GossipSub topic for a workspace.

Jump to

Keyboard shortcuts

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