agentshare

package
v1.6.16 Latest Latest
Warning

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

Go to latest
Published: Aug 13, 2026 License: AGPL-3.0 Imports: 10 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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