Files
Memoh/internal/db/sqlc/bots.sql.go
T
Acbox Liu ea719f7ca7 refactor: memory provider (#140)
* refactor: memory provider

* fix: migrations

* feat: divide collection from different built-in memory

* feat: add `MEMORY.md` and `PROFILES.md`

* use .env for docker compose. fix #142 (#143)

* feat(web): add brand icons for search providers (#144)

Add custom FontAwesome icon definitions for all 9 search providers:
- Yandex: uses existing faYandex from FA free brands
- Tavily, Jina, Exa, Bocha, Serper: custom icons from brand SVGs
- DuckDuckGo, SearXNG, Sogou: custom icons from Simple Icons

Icons are registered with a custom 'fac' prefix and rendered as
monochrome (currentColor) via FontAwesome's standard rendering.

* fix: resolve multiple UI bugs (#147)

* feat: add email service with multi-adapter support (#146)

* feat: add email service with multi-adapter support

Implement a full-stack email service with global provider management,
per-bot bindings with granular read/write permissions, outbox audit
storage, and MCP tool integration for direct mailbox access.

Backend:
- Email providers: CRUD with dynamic config schema (generic SMTP/IMAP, Mailgun)
- Generic adapter: go-mail (SMTP) + go-imap/v2 (IMAP IDLE real-time push via
  UnilateralDataHandler + UID-based tracking + periodic check fallback)
- Mailgun adapter: mailgun-go/v5 with dual inbound mode (webhook + poll)
- Bot email bindings: per-bot provider binding with independent r/w permissions
- Outbox: outbound email audit log with status tracking
- Trigger: inbound emails push notification to bot_inbox (from/subject only,
  LLM reads full content on demand via MCP tools)
- MailboxReader interface: on-demand IMAP queries for listing/reading emails
- MCP tools: email_accounts, email_send, email_list (paginated mailbox),
  email_read (by UID) — all with multi-binding and provider_id selection
- Webhook: /email/mailgun/webhook/:config_id (JWT-skipped, signature-verified)
- DB migration: 0019_add_email (email_providers, bot_email_bindings, email_outbox)

Frontend:
- Email Providers page: /email-providers with MasterDetailSidebarLayout
- Dynamic config form rendered from ordered provider meta schema with i18n keys
- Bot detail: Email tab with bindings management + outbox audit table
- Sidebar navigation entry
- Full i18n support (en + zh)
- Auto-generated SDK from Swagger

Closes #17

* feat(email): trigger bot conversation immediately on inbound email

Instead of only storing an inbox item and waiting for the next chat,
the email trigger now proactively invokes the conversation resolver
so the bot processes new emails right away — aligned with the
schedule/heartbeat trigger pattern.

* fix: lint

---------

Co-authored-by: Acbox <acbox0328@gmail.com>

* chore: update AGENTS.md

* feat: files preview

* feat(web): improve MCP details page

* refactor(skills): import skill with pure markdown string

* merge main into refactor/memory

* fix: migration

* refactor: temp delete qdrant and bm25 index

* fix: clean merge code

* fix: update memory handler

---------

Co-authored-by: Leohearts <leohearts@leohearts.com>
Co-authored-by: Menci <mencici@msn.com>
Co-authored-by: Quincy <69751197+dqygit@users.noreply.github.com>
Co-authored-by: BBQ <35603386+HoneyBBQ@users.noreply.github.com>
Co-authored-by: Ran <16112591+chen-ran@users.noreply.github.com>
2026-03-03 15:33:50 +08:00

626 lines
21 KiB
Go

// Code generated by sqlc. DO NOT EDIT.
// versions:
// sqlc v1.30.0
// source: bots.sql
package sqlc
import (
"context"
"github.com/jackc/pgx/v5/pgtype"
)
const createBot = `-- name: CreateBot :one
INSERT INTO bots (owner_user_id, type, display_name, avatar_url, is_active, metadata, status)
VALUES ($1, $2, $3, $4, $5, $6, $7)
RETURNING id, owner_user_id, type, display_name, avatar_url, is_active, status, max_context_load_time, max_context_tokens, max_inbox_items, language, allow_guest, reasoning_enabled, reasoning_effort, chat_model_id, search_provider_id, memory_provider_id, heartbeat_enabled, heartbeat_interval, heartbeat_prompt, metadata, created_at, updated_at
`
type CreateBotParams struct {
OwnerUserID pgtype.UUID `json:"owner_user_id"`
Type string `json:"type"`
DisplayName pgtype.Text `json:"display_name"`
AvatarUrl pgtype.Text `json:"avatar_url"`
IsActive bool `json:"is_active"`
Metadata []byte `json:"metadata"`
Status string `json:"status"`
}
type CreateBotRow struct {
ID pgtype.UUID `json:"id"`
OwnerUserID pgtype.UUID `json:"owner_user_id"`
Type string `json:"type"`
DisplayName pgtype.Text `json:"display_name"`
AvatarUrl pgtype.Text `json:"avatar_url"`
IsActive bool `json:"is_active"`
Status string `json:"status"`
MaxContextLoadTime int32 `json:"max_context_load_time"`
MaxContextTokens int32 `json:"max_context_tokens"`
MaxInboxItems int32 `json:"max_inbox_items"`
Language string `json:"language"`
AllowGuest bool `json:"allow_guest"`
ReasoningEnabled bool `json:"reasoning_enabled"`
ReasoningEffort string `json:"reasoning_effort"`
ChatModelID pgtype.UUID `json:"chat_model_id"`
SearchProviderID pgtype.UUID `json:"search_provider_id"`
MemoryProviderID pgtype.UUID `json:"memory_provider_id"`
HeartbeatEnabled bool `json:"heartbeat_enabled"`
HeartbeatInterval int32 `json:"heartbeat_interval"`
HeartbeatPrompt string `json:"heartbeat_prompt"`
Metadata []byte `json:"metadata"`
CreatedAt pgtype.Timestamptz `json:"created_at"`
UpdatedAt pgtype.Timestamptz `json:"updated_at"`
}
func (q *Queries) CreateBot(ctx context.Context, arg CreateBotParams) (CreateBotRow, error) {
row := q.db.QueryRow(ctx, createBot,
arg.OwnerUserID,
arg.Type,
arg.DisplayName,
arg.AvatarUrl,
arg.IsActive,
arg.Metadata,
arg.Status,
)
var i CreateBotRow
err := row.Scan(
&i.ID,
&i.OwnerUserID,
&i.Type,
&i.DisplayName,
&i.AvatarUrl,
&i.IsActive,
&i.Status,
&i.MaxContextLoadTime,
&i.MaxContextTokens,
&i.MaxInboxItems,
&i.Language,
&i.AllowGuest,
&i.ReasoningEnabled,
&i.ReasoningEffort,
&i.ChatModelID,
&i.SearchProviderID,
&i.MemoryProviderID,
&i.HeartbeatEnabled,
&i.HeartbeatInterval,
&i.HeartbeatPrompt,
&i.Metadata,
&i.CreatedAt,
&i.UpdatedAt,
)
return i, err
}
const deleteBotByID = `-- name: DeleteBotByID :exec
DELETE FROM bots WHERE id = $1
`
func (q *Queries) DeleteBotByID(ctx context.Context, id pgtype.UUID) error {
_, err := q.db.Exec(ctx, deleteBotByID, id)
return err
}
const deleteBotMember = `-- name: DeleteBotMember :exec
DELETE FROM bot_members WHERE bot_id = $1 AND user_id = $2
`
type DeleteBotMemberParams struct {
BotID pgtype.UUID `json:"bot_id"`
UserID pgtype.UUID `json:"user_id"`
}
func (q *Queries) DeleteBotMember(ctx context.Context, arg DeleteBotMemberParams) error {
_, err := q.db.Exec(ctx, deleteBotMember, arg.BotID, arg.UserID)
return err
}
const getBotByID = `-- name: GetBotByID :one
SELECT id, owner_user_id, type, display_name, avatar_url, is_active, status, max_context_load_time, max_context_tokens, max_inbox_items, language, allow_guest, reasoning_enabled, reasoning_effort, chat_model_id, search_provider_id, memory_provider_id, heartbeat_enabled, heartbeat_interval, heartbeat_prompt, metadata, created_at, updated_at
FROM bots
WHERE id = $1
`
type GetBotByIDRow struct {
ID pgtype.UUID `json:"id"`
OwnerUserID pgtype.UUID `json:"owner_user_id"`
Type string `json:"type"`
DisplayName pgtype.Text `json:"display_name"`
AvatarUrl pgtype.Text `json:"avatar_url"`
IsActive bool `json:"is_active"`
Status string `json:"status"`
MaxContextLoadTime int32 `json:"max_context_load_time"`
MaxContextTokens int32 `json:"max_context_tokens"`
MaxInboxItems int32 `json:"max_inbox_items"`
Language string `json:"language"`
AllowGuest bool `json:"allow_guest"`
ReasoningEnabled bool `json:"reasoning_enabled"`
ReasoningEffort string `json:"reasoning_effort"`
ChatModelID pgtype.UUID `json:"chat_model_id"`
SearchProviderID pgtype.UUID `json:"search_provider_id"`
MemoryProviderID pgtype.UUID `json:"memory_provider_id"`
HeartbeatEnabled bool `json:"heartbeat_enabled"`
HeartbeatInterval int32 `json:"heartbeat_interval"`
HeartbeatPrompt string `json:"heartbeat_prompt"`
Metadata []byte `json:"metadata"`
CreatedAt pgtype.Timestamptz `json:"created_at"`
UpdatedAt pgtype.Timestamptz `json:"updated_at"`
}
func (q *Queries) GetBotByID(ctx context.Context, id pgtype.UUID) (GetBotByIDRow, error) {
row := q.db.QueryRow(ctx, getBotByID, id)
var i GetBotByIDRow
err := row.Scan(
&i.ID,
&i.OwnerUserID,
&i.Type,
&i.DisplayName,
&i.AvatarUrl,
&i.IsActive,
&i.Status,
&i.MaxContextLoadTime,
&i.MaxContextTokens,
&i.MaxInboxItems,
&i.Language,
&i.AllowGuest,
&i.ReasoningEnabled,
&i.ReasoningEffort,
&i.ChatModelID,
&i.SearchProviderID,
&i.MemoryProviderID,
&i.HeartbeatEnabled,
&i.HeartbeatInterval,
&i.HeartbeatPrompt,
&i.Metadata,
&i.CreatedAt,
&i.UpdatedAt,
)
return i, err
}
const getBotMember = `-- name: GetBotMember :one
SELECT bot_id, user_id, role, created_at
FROM bot_members
WHERE bot_id = $1 AND user_id = $2
LIMIT 1
`
type GetBotMemberParams struct {
BotID pgtype.UUID `json:"bot_id"`
UserID pgtype.UUID `json:"user_id"`
}
func (q *Queries) GetBotMember(ctx context.Context, arg GetBotMemberParams) (BotMember, error) {
row := q.db.QueryRow(ctx, getBotMember, arg.BotID, arg.UserID)
var i BotMember
err := row.Scan(
&i.BotID,
&i.UserID,
&i.Role,
&i.CreatedAt,
)
return i, err
}
const listBotMembers = `-- name: ListBotMembers :many
SELECT bot_id, user_id, role, created_at
FROM bot_members
WHERE bot_id = $1
ORDER BY created_at DESC
`
func (q *Queries) ListBotMembers(ctx context.Context, botID pgtype.UUID) ([]BotMember, error) {
rows, err := q.db.Query(ctx, listBotMembers, botID)
if err != nil {
return nil, err
}
defer rows.Close()
var items []BotMember
for rows.Next() {
var i BotMember
if err := rows.Scan(
&i.BotID,
&i.UserID,
&i.Role,
&i.CreatedAt,
); err != nil {
return nil, err
}
items = append(items, i)
}
if err := rows.Err(); err != nil {
return nil, err
}
return items, nil
}
const listBotsByMember = `-- name: ListBotsByMember :many
SELECT b.id, b.owner_user_id, b.type, b.display_name, b.avatar_url, b.is_active, b.status, b.max_context_load_time, b.max_context_tokens, b.max_inbox_items, b.language, b.allow_guest, b.reasoning_enabled, b.reasoning_effort, b.chat_model_id, b.search_provider_id, b.memory_provider_id, b.heartbeat_enabled, b.heartbeat_interval, b.heartbeat_prompt, b.metadata, b.created_at, b.updated_at
FROM bots b
JOIN bot_members m ON m.bot_id = b.id
WHERE m.user_id = $1
ORDER BY b.created_at DESC
`
type ListBotsByMemberRow struct {
ID pgtype.UUID `json:"id"`
OwnerUserID pgtype.UUID `json:"owner_user_id"`
Type string `json:"type"`
DisplayName pgtype.Text `json:"display_name"`
AvatarUrl pgtype.Text `json:"avatar_url"`
IsActive bool `json:"is_active"`
Status string `json:"status"`
MaxContextLoadTime int32 `json:"max_context_load_time"`
MaxContextTokens int32 `json:"max_context_tokens"`
MaxInboxItems int32 `json:"max_inbox_items"`
Language string `json:"language"`
AllowGuest bool `json:"allow_guest"`
ReasoningEnabled bool `json:"reasoning_enabled"`
ReasoningEffort string `json:"reasoning_effort"`
ChatModelID pgtype.UUID `json:"chat_model_id"`
SearchProviderID pgtype.UUID `json:"search_provider_id"`
MemoryProviderID pgtype.UUID `json:"memory_provider_id"`
HeartbeatEnabled bool `json:"heartbeat_enabled"`
HeartbeatInterval int32 `json:"heartbeat_interval"`
HeartbeatPrompt string `json:"heartbeat_prompt"`
Metadata []byte `json:"metadata"`
CreatedAt pgtype.Timestamptz `json:"created_at"`
UpdatedAt pgtype.Timestamptz `json:"updated_at"`
}
func (q *Queries) ListBotsByMember(ctx context.Context, userID pgtype.UUID) ([]ListBotsByMemberRow, error) {
rows, err := q.db.Query(ctx, listBotsByMember, userID)
if err != nil {
return nil, err
}
defer rows.Close()
var items []ListBotsByMemberRow
for rows.Next() {
var i ListBotsByMemberRow
if err := rows.Scan(
&i.ID,
&i.OwnerUserID,
&i.Type,
&i.DisplayName,
&i.AvatarUrl,
&i.IsActive,
&i.Status,
&i.MaxContextLoadTime,
&i.MaxContextTokens,
&i.MaxInboxItems,
&i.Language,
&i.AllowGuest,
&i.ReasoningEnabled,
&i.ReasoningEffort,
&i.ChatModelID,
&i.SearchProviderID,
&i.MemoryProviderID,
&i.HeartbeatEnabled,
&i.HeartbeatInterval,
&i.HeartbeatPrompt,
&i.Metadata,
&i.CreatedAt,
&i.UpdatedAt,
); err != nil {
return nil, err
}
items = append(items, i)
}
if err := rows.Err(); err != nil {
return nil, err
}
return items, nil
}
const listBotsByOwner = `-- name: ListBotsByOwner :many
SELECT id, owner_user_id, type, display_name, avatar_url, is_active, status, max_context_load_time, max_context_tokens, max_inbox_items, language, allow_guest, reasoning_enabled, reasoning_effort, chat_model_id, search_provider_id, memory_provider_id, heartbeat_enabled, heartbeat_interval, heartbeat_prompt, metadata, created_at, updated_at
FROM bots
WHERE owner_user_id = $1
ORDER BY created_at DESC
`
type ListBotsByOwnerRow struct {
ID pgtype.UUID `json:"id"`
OwnerUserID pgtype.UUID `json:"owner_user_id"`
Type string `json:"type"`
DisplayName pgtype.Text `json:"display_name"`
AvatarUrl pgtype.Text `json:"avatar_url"`
IsActive bool `json:"is_active"`
Status string `json:"status"`
MaxContextLoadTime int32 `json:"max_context_load_time"`
MaxContextTokens int32 `json:"max_context_tokens"`
MaxInboxItems int32 `json:"max_inbox_items"`
Language string `json:"language"`
AllowGuest bool `json:"allow_guest"`
ReasoningEnabled bool `json:"reasoning_enabled"`
ReasoningEffort string `json:"reasoning_effort"`
ChatModelID pgtype.UUID `json:"chat_model_id"`
SearchProviderID pgtype.UUID `json:"search_provider_id"`
MemoryProviderID pgtype.UUID `json:"memory_provider_id"`
HeartbeatEnabled bool `json:"heartbeat_enabled"`
HeartbeatInterval int32 `json:"heartbeat_interval"`
HeartbeatPrompt string `json:"heartbeat_prompt"`
Metadata []byte `json:"metadata"`
CreatedAt pgtype.Timestamptz `json:"created_at"`
UpdatedAt pgtype.Timestamptz `json:"updated_at"`
}
func (q *Queries) ListBotsByOwner(ctx context.Context, ownerUserID pgtype.UUID) ([]ListBotsByOwnerRow, error) {
rows, err := q.db.Query(ctx, listBotsByOwner, ownerUserID)
if err != nil {
return nil, err
}
defer rows.Close()
var items []ListBotsByOwnerRow
for rows.Next() {
var i ListBotsByOwnerRow
if err := rows.Scan(
&i.ID,
&i.OwnerUserID,
&i.Type,
&i.DisplayName,
&i.AvatarUrl,
&i.IsActive,
&i.Status,
&i.MaxContextLoadTime,
&i.MaxContextTokens,
&i.MaxInboxItems,
&i.Language,
&i.AllowGuest,
&i.ReasoningEnabled,
&i.ReasoningEffort,
&i.ChatModelID,
&i.SearchProviderID,
&i.MemoryProviderID,
&i.HeartbeatEnabled,
&i.HeartbeatInterval,
&i.HeartbeatPrompt,
&i.Metadata,
&i.CreatedAt,
&i.UpdatedAt,
); err != nil {
return nil, err
}
items = append(items, i)
}
if err := rows.Err(); err != nil {
return nil, err
}
return items, nil
}
const listHeartbeatEnabledBots = `-- name: ListHeartbeatEnabledBots :many
SELECT id, owner_user_id, heartbeat_enabled, heartbeat_interval, heartbeat_prompt
FROM bots
WHERE heartbeat_enabled = true AND status = 'ready'
`
type ListHeartbeatEnabledBotsRow struct {
ID pgtype.UUID `json:"id"`
OwnerUserID pgtype.UUID `json:"owner_user_id"`
HeartbeatEnabled bool `json:"heartbeat_enabled"`
HeartbeatInterval int32 `json:"heartbeat_interval"`
HeartbeatPrompt string `json:"heartbeat_prompt"`
}
func (q *Queries) ListHeartbeatEnabledBots(ctx context.Context) ([]ListHeartbeatEnabledBotsRow, error) {
rows, err := q.db.Query(ctx, listHeartbeatEnabledBots)
if err != nil {
return nil, err
}
defer rows.Close()
var items []ListHeartbeatEnabledBotsRow
for rows.Next() {
var i ListHeartbeatEnabledBotsRow
if err := rows.Scan(
&i.ID,
&i.OwnerUserID,
&i.HeartbeatEnabled,
&i.HeartbeatInterval,
&i.HeartbeatPrompt,
); err != nil {
return nil, err
}
items = append(items, i)
}
if err := rows.Err(); err != nil {
return nil, err
}
return items, nil
}
const updateBotOwner = `-- name: UpdateBotOwner :one
UPDATE bots
SET owner_user_id = $2,
updated_at = now()
WHERE id = $1
RETURNING id, owner_user_id, type, display_name, avatar_url, is_active, status, max_context_load_time, max_context_tokens, max_inbox_items, language, allow_guest, reasoning_enabled, reasoning_effort, chat_model_id, search_provider_id, memory_provider_id, heartbeat_enabled, heartbeat_interval, heartbeat_prompt, metadata, created_at, updated_at
`
type UpdateBotOwnerParams struct {
ID pgtype.UUID `json:"id"`
OwnerUserID pgtype.UUID `json:"owner_user_id"`
}
type UpdateBotOwnerRow struct {
ID pgtype.UUID `json:"id"`
OwnerUserID pgtype.UUID `json:"owner_user_id"`
Type string `json:"type"`
DisplayName pgtype.Text `json:"display_name"`
AvatarUrl pgtype.Text `json:"avatar_url"`
IsActive bool `json:"is_active"`
Status string `json:"status"`
MaxContextLoadTime int32 `json:"max_context_load_time"`
MaxContextTokens int32 `json:"max_context_tokens"`
MaxInboxItems int32 `json:"max_inbox_items"`
Language string `json:"language"`
AllowGuest bool `json:"allow_guest"`
ReasoningEnabled bool `json:"reasoning_enabled"`
ReasoningEffort string `json:"reasoning_effort"`
ChatModelID pgtype.UUID `json:"chat_model_id"`
SearchProviderID pgtype.UUID `json:"search_provider_id"`
MemoryProviderID pgtype.UUID `json:"memory_provider_id"`
HeartbeatEnabled bool `json:"heartbeat_enabled"`
HeartbeatInterval int32 `json:"heartbeat_interval"`
HeartbeatPrompt string `json:"heartbeat_prompt"`
Metadata []byte `json:"metadata"`
CreatedAt pgtype.Timestamptz `json:"created_at"`
UpdatedAt pgtype.Timestamptz `json:"updated_at"`
}
func (q *Queries) UpdateBotOwner(ctx context.Context, arg UpdateBotOwnerParams) (UpdateBotOwnerRow, error) {
row := q.db.QueryRow(ctx, updateBotOwner, arg.ID, arg.OwnerUserID)
var i UpdateBotOwnerRow
err := row.Scan(
&i.ID,
&i.OwnerUserID,
&i.Type,
&i.DisplayName,
&i.AvatarUrl,
&i.IsActive,
&i.Status,
&i.MaxContextLoadTime,
&i.MaxContextTokens,
&i.MaxInboxItems,
&i.Language,
&i.AllowGuest,
&i.ReasoningEnabled,
&i.ReasoningEffort,
&i.ChatModelID,
&i.SearchProviderID,
&i.MemoryProviderID,
&i.HeartbeatEnabled,
&i.HeartbeatInterval,
&i.HeartbeatPrompt,
&i.Metadata,
&i.CreatedAt,
&i.UpdatedAt,
)
return i, err
}
const updateBotProfile = `-- name: UpdateBotProfile :one
UPDATE bots
SET display_name = $2,
avatar_url = $3,
is_active = $4,
metadata = $5,
updated_at = now()
WHERE id = $1
RETURNING id, owner_user_id, type, display_name, avatar_url, is_active, status, max_context_load_time, max_context_tokens, max_inbox_items, language, allow_guest, reasoning_enabled, reasoning_effort, chat_model_id, search_provider_id, memory_provider_id, heartbeat_enabled, heartbeat_interval, heartbeat_prompt, metadata, created_at, updated_at
`
type UpdateBotProfileParams struct {
ID pgtype.UUID `json:"id"`
DisplayName pgtype.Text `json:"display_name"`
AvatarUrl pgtype.Text `json:"avatar_url"`
IsActive bool `json:"is_active"`
Metadata []byte `json:"metadata"`
}
type UpdateBotProfileRow struct {
ID pgtype.UUID `json:"id"`
OwnerUserID pgtype.UUID `json:"owner_user_id"`
Type string `json:"type"`
DisplayName pgtype.Text `json:"display_name"`
AvatarUrl pgtype.Text `json:"avatar_url"`
IsActive bool `json:"is_active"`
Status string `json:"status"`
MaxContextLoadTime int32 `json:"max_context_load_time"`
MaxContextTokens int32 `json:"max_context_tokens"`
MaxInboxItems int32 `json:"max_inbox_items"`
Language string `json:"language"`
AllowGuest bool `json:"allow_guest"`
ReasoningEnabled bool `json:"reasoning_enabled"`
ReasoningEffort string `json:"reasoning_effort"`
ChatModelID pgtype.UUID `json:"chat_model_id"`
SearchProviderID pgtype.UUID `json:"search_provider_id"`
MemoryProviderID pgtype.UUID `json:"memory_provider_id"`
HeartbeatEnabled bool `json:"heartbeat_enabled"`
HeartbeatInterval int32 `json:"heartbeat_interval"`
HeartbeatPrompt string `json:"heartbeat_prompt"`
Metadata []byte `json:"metadata"`
CreatedAt pgtype.Timestamptz `json:"created_at"`
UpdatedAt pgtype.Timestamptz `json:"updated_at"`
}
func (q *Queries) UpdateBotProfile(ctx context.Context, arg UpdateBotProfileParams) (UpdateBotProfileRow, error) {
row := q.db.QueryRow(ctx, updateBotProfile,
arg.ID,
arg.DisplayName,
arg.AvatarUrl,
arg.IsActive,
arg.Metadata,
)
var i UpdateBotProfileRow
err := row.Scan(
&i.ID,
&i.OwnerUserID,
&i.Type,
&i.DisplayName,
&i.AvatarUrl,
&i.IsActive,
&i.Status,
&i.MaxContextLoadTime,
&i.MaxContextTokens,
&i.MaxInboxItems,
&i.Language,
&i.AllowGuest,
&i.ReasoningEnabled,
&i.ReasoningEffort,
&i.ChatModelID,
&i.SearchProviderID,
&i.MemoryProviderID,
&i.HeartbeatEnabled,
&i.HeartbeatInterval,
&i.HeartbeatPrompt,
&i.Metadata,
&i.CreatedAt,
&i.UpdatedAt,
)
return i, err
}
const updateBotStatus = `-- name: UpdateBotStatus :exec
UPDATE bots
SET status = $2,
updated_at = now()
WHERE id = $1
`
type UpdateBotStatusParams struct {
ID pgtype.UUID `json:"id"`
Status string `json:"status"`
}
func (q *Queries) UpdateBotStatus(ctx context.Context, arg UpdateBotStatusParams) error {
_, err := q.db.Exec(ctx, updateBotStatus, arg.ID, arg.Status)
return err
}
const upsertBotMember = `-- name: UpsertBotMember :one
INSERT INTO bot_members (bot_id, user_id, role)
VALUES ($1, $2, $3)
ON CONFLICT (bot_id, user_id) DO UPDATE SET
role = EXCLUDED.role
RETURNING bot_id, user_id, role, created_at
`
type UpsertBotMemberParams struct {
BotID pgtype.UUID `json:"bot_id"`
UserID pgtype.UUID `json:"user_id"`
Role string `json:"role"`
}
func (q *Queries) UpsertBotMember(ctx context.Context, arg UpsertBotMemberParams) (BotMember, error) {
row := q.db.QueryRow(ctx, upsertBotMember, arg.BotID, arg.UserID, arg.Role)
var i BotMember
err := row.Scan(
&i.BotID,
&i.UserID,
&i.Role,
&i.CreatedAt,
)
return i, err
}