Documentation
¶
Index ¶
- Constants
- Variables
- type AccessPolicy
- type Bot
- type BotCheck
- type BotMember
- type ContainerLifecycle
- type CreateBotRequest
- type ListBotsResponse
- type ListChecksResponse
- type ListMembersResponse
- type RuntimeChecker
- type Service
- func (s *Service) AddRuntimeChecker(c RuntimeChecker)
- func (s *Service) AuthorizeAccess(ctx context.Context, userID, botID string, isAdmin bool, policy AccessPolicy) (Bot, error)
- func (s *Service) Create(ctx context.Context, ownerUserID string, req CreateBotRequest) (Bot, error)
- func (s *Service) Delete(ctx context.Context, botID string) error
- func (s *Service) DeleteMember(ctx context.Context, botID, channelIdentityID string) error
- func (s *Service) Get(ctx context.Context, botID string) (Bot, error)
- func (s *Service) GetMember(ctx context.Context, botID, channelIdentityID string) (BotMember, error)
- func (s *Service) IsMember(ctx context.Context, botID, channelIdentityID string) (bool, error)
- func (s *Service) ListAccessible(ctx context.Context, channelIdentityID string) ([]Bot, error)
- func (s *Service) ListByMember(ctx context.Context, channelIdentityID string) ([]Bot, error)
- func (s *Service) ListByOwner(ctx context.Context, ownerUserID string) ([]Bot, error)
- func (s *Service) ListChecks(ctx context.Context, botID string) ([]BotCheck, error)
- func (s *Service) ListMembers(ctx context.Context, botID string) ([]BotMember, error)
- func (s *Service) SetContainerLifecycle(lc ContainerLifecycle)
- func (s *Service) TransferOwner(ctx context.Context, botID string, ownerUserID string) (Bot, error)
- func (s *Service) Update(ctx context.Context, botID string, req UpdateBotRequest) (Bot, error)
- func (s *Service) UpsertMember(ctx context.Context, botID string, req UpsertMemberRequest) (BotMember, error)
- func (s *Service) UpsertMemberSimple(ctx context.Context, botID, channelIdentityID, role string) error
- type TransferBotRequest
- type UpdateBotRequest
- type UpsertMemberRequest
Constants ¶
const ( BotTypePersonal = "personal" BotTypePublic = "public" )
const ( BotStatusCreating = "creating" BotStatusReady = "ready" BotStatusDeleting = "deleting" )
const ( BotCheckStateOK = "ok" BotCheckStateIssue = "issue" BotCheckStateUnknown = "unknown" )
const ( BotCheckStatusOK = "ok" BotCheckStatusWarn = "warn" BotCheckStatusError = "error" BotCheckStatusUnknown = "unknown" )
const ( BotCheckTypeContainerInit = "container.init" BotCheckTypeContainerRecord = "container.record" BotCheckTypeContainerTask = "container.task" BotCheckTypeContainerData = "container.data_path" BotCheckTypeDelete = "bot.delete" BotCheckTypeMCPConnection = "mcp.connection" BotCheckTypeChannelConn = "channel.connection" )
const ( MemberRoleOwner = "owner" MemberRoleAdmin = "admin" MemberRoleMember = "member" )
Variables ¶
Functions ¶
This section is empty.
Types ¶
type AccessPolicy ¶
AccessPolicy controls bot access behavior.
type Bot ¶
type Bot struct {
ID string `json:"id"`
OwnerUserID string `json:"owner_user_id"`
Type string `json:"type"`
DisplayName string `json:"display_name"`
AvatarURL string `json:"avatar_url,omitempty"`
IsActive bool `json:"is_active"`
AllowGuest bool `json:"allow_guest"`
Status string `json:"status"`
CheckState string `json:"check_state"`
CheckIssueCount int32 `json:"check_issue_count"`
Metadata map[string]any `json:"metadata,omitempty"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
Bot represents a bot entity.
type BotCheck ¶
type BotCheck struct {
ID string `json:"id"`
Type string `json:"type"`
TitleKey string `json:"title_key"`
Subtitle string `json:"subtitle,omitempty"`
Status string `json:"status"`
Summary string `json:"summary"`
Detail string `json:"detail,omitempty"`
Metadata map[string]any `json:"metadata,omitempty"`
}
BotCheck represents one resource check row for a bot.
type BotMember ¶
type BotMember struct {
BotID string `json:"bot_id"`
UserID string `json:"user_id"`
Role string `json:"role"`
CreatedAt time.Time `json:"created_at"`
}
BotMember represents a bot membership record.
type ContainerLifecycle ¶
type ContainerLifecycle interface {
SetupBotContainer(ctx context.Context, botID string) error
CleanupBotContainer(ctx context.Context, botID string) error
}
ContainerLifecycle handles container lifecycle events bound to bot operations.
type CreateBotRequest ¶
type CreateBotRequest struct {
Type string `json:"type"`
DisplayName string `json:"display_name,omitempty"`
AvatarURL string `json:"avatar_url,omitempty"`
IsActive *bool `json:"is_active,omitempty"`
Metadata map[string]any `json:"metadata,omitempty"`
}
CreateBotRequest is the input for creating a bot.
type ListBotsResponse ¶
type ListBotsResponse struct {
Items []Bot `json:"items"`
}
ListBotsResponse wraps a list of bots.
type ListChecksResponse ¶
type ListChecksResponse struct {
Items []BotCheck `json:"items"`
}
ListChecksResponse wraps a list of bot checks.
type ListMembersResponse ¶
type ListMembersResponse struct {
Items []BotMember `json:"items"`
}
ListMembersResponse wraps a list of bot members.
type RuntimeChecker ¶
type RuntimeChecker interface {
// ListChecks evaluates dynamic runtime checks for a bot.
ListChecks(ctx context.Context, botID string) []BotCheck
}
RuntimeChecker produces runtime check items for a bot.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service provides bot CRUD and membership management.
func NewService ¶
NewService creates a new bot service.
func (*Service) AddRuntimeChecker ¶
func (s *Service) AddRuntimeChecker(c RuntimeChecker)
AddRuntimeChecker registers an additional runtime checker.
func (*Service) AuthorizeAccess ¶
func (s *Service) AuthorizeAccess(ctx context.Context, userID, botID string, isAdmin bool, policy AccessPolicy) (Bot, error)
AuthorizeAccess checks whether userID may access the given bot.
func (*Service) Create ¶
func (s *Service) Create(ctx context.Context, ownerUserID string, req CreateBotRequest) (Bot, error)
Create creates a new bot owned by owner user.
func (*Service) DeleteMember ¶
DeleteMember removes a member from a bot.
func (*Service) GetMember ¶
func (s *Service) GetMember(ctx context.Context, botID, channelIdentityID string) (BotMember, error)
GetMember returns a specific bot member.
func (*Service) ListAccessible ¶
ListAccessible returns all bots the user can access (owned or member).
func (*Service) ListByMember ¶
ListByMember returns bots where the user is a member.
func (*Service) ListByOwner ¶
ListByOwner returns bots owned by the given user.
func (*Service) ListChecks ¶
ListChecks evaluates runtime resource checks for a bot.
func (*Service) ListMembers ¶
ListMembers returns all members of a bot.
func (*Service) SetContainerLifecycle ¶
func (s *Service) SetContainerLifecycle(lc ContainerLifecycle)
SetContainerLifecycle registers a container lifecycle handler for bot operations.
func (*Service) TransferOwner ¶
TransferOwner transfers bot ownership to another user.
func (*Service) UpsertMember ¶
func (s *Service) UpsertMember(ctx context.Context, botID string, req UpsertMemberRequest) (BotMember, error)
UpsertMember creates or updates a bot membership.
type TransferBotRequest ¶
type TransferBotRequest struct {
OwnerUserID string `json:"owner_user_id"`
}
TransferBotRequest is the input for transferring bot ownership.
type UpdateBotRequest ¶
type UpdateBotRequest struct {
DisplayName *string `json:"display_name,omitempty"`
AvatarURL *string `json:"avatar_url,omitempty"`
IsActive *bool `json:"is_active,omitempty"`
Metadata map[string]any `json:"metadata,omitempty"`
}
UpdateBotRequest is the input for updating a bot.
type UpsertMemberRequest ¶
type UpsertMemberRequest struct {
UserID string `json:"user_id"`
Role string `json:"role,omitempty"`
}
UpsertMemberRequest is the input for upserting a bot member.