Files
Memoh/internal/bots/types.go
T
BBQ 83b6ee608c refactor: bind container lifecycle to bot and improve schedule trigger flow
- Add SetupBotContainer to ContainerLifecycle interface so containers
  are automatically created when a bot is created, matching the existing
  cleanup-on-delete behavior.
- Refactor schedule tools to use bot-scoped API paths and pass identity
  context for proper authorization.
- Introduce dedicated trigger-schedule endpoint in chat resolver with
  explicit schedule payload instead of reusing the generic chat path.
- Generate short-lived JWT tokens for schedule trigger callbacks with
  resolved bot owner identity.
- Validate required parameters in NewLLMClient and NewOpenAIEmbedder
  constructors, returning errors instead of falling back to defaults.
- Add unit tests for schedule token generation and chat resolver.
2026-02-07 12:04:37 +08:00

75 lines
1.9 KiB
Go

package bots
import (
"context"
"time"
)
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"`
Metadata map[string]any `json:"metadata,omitempty"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
type BotMember struct {
BotID string `json:"bot_id"`
UserID string `json:"user_id"`
Role string `json:"role"`
CreatedAt time.Time `json:"created_at"`
}
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"`
}
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"`
}
type TransferBotRequest struct {
OwnerUserID string `json:"owner_user_id"`
}
type UpsertMemberRequest struct {
UserID string `json:"user_id"`
Role string `json:"role,omitempty"`
}
type ListBotsResponse struct {
Items []Bot `json:"items"`
}
type ListMembersResponse struct {
Items []BotMember `json:"items"`
}
// ContainerLifecycle handles container lifecycle events bound to bot operations.
type ContainerLifecycle interface {
SetupBotContainer(ctx context.Context, botID string) error
CleanupBotContainer(ctx context.Context, botID string) error
}
const (
BotTypePersonal = "personal"
BotTypePublic = "public"
)
const (
MemberRoleOwner = "owner"
MemberRoleAdmin = "admin"
MemberRoleMember = "member"
)