agentshare

package
v1.6.24 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2026 License: AGPL-3.0 Imports: 10 Imported by: 0

Documentation

Overview

Package agentshare manages owner-authorized per-agent share lists.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNotAuthorized means the caller is neither the agent owner nor an administrator.
	ErrNotAuthorized = errors.New("not authorized to manage agent share list")
	// ErrAgentNotFound means the requested local agent is unavailable.
	ErrAgentNotFound = errors.New("agent not found")
	// ErrGranteeNotFound means no local account exists for the grantee username.
	ErrGranteeNotFound = errors.New("grantee account not found")
	// ErrInvalidGrantee means the grantee is not a local Lesser username.
	ErrInvalidGrantee = errors.New("grantee must be a local Lesser username")
	// ErrSelfGrant means an owner or acting administrator tried to share with themselves.
	ErrSelfGrant = errors.New("cannot grant agent access to yourself or the agent owner")
	// ErrAgentSelfGrant means an agent was named as its own grantee.
	ErrAgentSelfGrant = errors.New("cannot grant agent access to the agent itself")
	// ErrGrantNotFound means no persisted grant exists to revoke.
	ErrGrantNotFound = errors.New("agent share grant not found")
)

Functions

This section is empty.

Types

type AccountRepository

type AccountRepository interface {
	GetAccount(context.Context, string) (*storage.Account, error)
	GetUser(context.Context, string) (*storage.User, error)
}

AccountRepository resolves local agents and local grantees.

type AuditRepository

type AuditRepository interface {
	StoreAuditEvent(context.Context, string, string, string, string, string, string, string, string, string, bool, string, map[string]interface{}) error
}

AuditRepository records the grant/revoke activity visible in agent activity logs.

type ManageInput

type ManageInput struct {
	AgentUsername   string
	GranteeUsername string
	ActorUsername   string
	ActorIsAdmin    bool
}

ManageInput identifies an agent share-list mutation and its authenticated actor.

type Repository

type Repository interface {
	CreateAgentShareGrant(context.Context, *models.AgentShareGrant) error
	RegrantAgentShareGrant(context.Context, *models.AgentShareGrant) error
	RevokeAgentShareGrant(context.Context, *models.AgentShareGrant) error
	GetAgentShareGrant(context.Context, string, string) (*models.AgentShareGrant, error)
	ListAgentShareGrantsByAgent(context.Context, string) ([]*models.AgentShareGrant, error)
	ListActiveAgentShareGrantsByGrantee(context.Context, string) ([]*models.AgentShareGrant, error)
	IsActiveAgentShareGrant(context.Context, string, string) (bool, error)
}

Repository is the storage contract required by Service.

type Service

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

Service manages per-agent share grants without minting credentials or changing sessions.

func NewService

func NewService(repo Repository, accounts AccountRepository, audit AuditRepository, actorURL func(string) string, logger *zap.Logger) *Service

NewService creates an agent share service.

func (*Service) Grant

func (s *Service) Grant(ctx context.Context, input ManageInput) (*models.AgentShareGrant, error)

Grant creates or refreshes one owner-authorized share grant.

func (*Service) IsActive

func (s *Service) IsActive(ctx context.Context, agentUsername, granteeUsername string) (bool, error)

IsActive performs the repository's uncached direct membership check.

func (*Service) ListByAgent

func (s *Service) ListByAgent(ctx context.Context, agentUsername, actorUsername string, actorIsAdmin bool) ([]*models.AgentShareGrant, error)

ListByAgent returns an owner/admin view including revoked audit history.

func (*Service) ListSharedWith

func (s *Service) ListSharedWith(ctx context.Context, granteeUsername string) ([]*models.AgentShareGrant, error)

ListSharedWith returns active agents shared with the authenticated local account.

func (*Service) Revoke

func (s *Service) Revoke(ctx context.Context, input ManageInput) (*models.AgentShareGrant, error)

Revoke immediately marks one grant inactive and removes it from discovery.

Jump to

Keyboard shortcuts

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