feat: add media asset system, channel lifecycle refactor, and chat attachments (#54)

This commit is contained in:
BBQ
2026-02-17 19:06:46 +08:00
committed by GitHub
parent 0bdc31311c
commit df7876a30c
106 changed files with 7942 additions and 1274 deletions
+62 -12
View File
@@ -11,8 +11,23 @@ import (
"github.com/jackc/pgx/v5/pgtype"
)
const deleteBotChannelConfig = `-- name: DeleteBotChannelConfig :exec
DELETE FROM bot_channel_configs
WHERE bot_id = $1 AND channel_type = $2
`
type DeleteBotChannelConfigParams struct {
BotID pgtype.UUID `json:"bot_id"`
ChannelType string `json:"channel_type"`
}
func (q *Queries) DeleteBotChannelConfig(ctx context.Context, arg DeleteBotChannelConfigParams) error {
_, err := q.db.Exec(ctx, deleteBotChannelConfig, arg.BotID, arg.ChannelType)
return err
}
const getBotChannelConfig = `-- name: GetBotChannelConfig :one
SELECT id, bot_id, channel_type, credentials, external_identity, self_identity, routing, capabilities, status, verified_at, created_at, updated_at
SELECT id, bot_id, channel_type, credentials, external_identity, self_identity, routing, capabilities, disabled, verified_at, created_at, updated_at
FROM bot_channel_configs
WHERE bot_id = $1 AND channel_type = $2
LIMIT 1
@@ -35,7 +50,7 @@ func (q *Queries) GetBotChannelConfig(ctx context.Context, arg GetBotChannelConf
&i.SelfIdentity,
&i.Routing,
&i.Capabilities,
&i.Status,
&i.Disabled,
&i.VerifiedAt,
&i.CreatedAt,
&i.UpdatedAt,
@@ -44,7 +59,7 @@ func (q *Queries) GetBotChannelConfig(ctx context.Context, arg GetBotChannelConf
}
const getBotChannelConfigByExternalIdentity = `-- name: GetBotChannelConfigByExternalIdentity :one
SELECT id, bot_id, channel_type, credentials, external_identity, self_identity, routing, capabilities, status, verified_at, created_at, updated_at
SELECT id, bot_id, channel_type, credentials, external_identity, self_identity, routing, capabilities, disabled, verified_at, created_at, updated_at
FROM bot_channel_configs
WHERE channel_type = $1 AND external_identity = $2
LIMIT 1
@@ -67,7 +82,7 @@ func (q *Queries) GetBotChannelConfigByExternalIdentity(ctx context.Context, arg
&i.SelfIdentity,
&i.Routing,
&i.Capabilities,
&i.Status,
&i.Disabled,
&i.VerifiedAt,
&i.CreatedAt,
&i.UpdatedAt,
@@ -102,7 +117,7 @@ func (q *Queries) GetUserChannelBinding(ctx context.Context, arg GetUserChannelB
}
const listBotChannelConfigsByType = `-- name: ListBotChannelConfigsByType :many
SELECT id, bot_id, channel_type, credentials, external_identity, self_identity, routing, capabilities, status, verified_at, created_at, updated_at
SELECT id, bot_id, channel_type, credentials, external_identity, self_identity, routing, capabilities, disabled, verified_at, created_at, updated_at
FROM bot_channel_configs
WHERE channel_type = $1
ORDER BY created_at DESC
@@ -126,7 +141,7 @@ func (q *Queries) ListBotChannelConfigsByType(ctx context.Context, channelType s
&i.SelfIdentity,
&i.Routing,
&i.Capabilities,
&i.Status,
&i.Disabled,
&i.VerifiedAt,
&i.CreatedAt,
&i.UpdatedAt,
@@ -175,9 +190,44 @@ func (q *Queries) ListUserChannelBindingsByPlatform(ctx context.Context, channel
return items, nil
}
const updateBotChannelConfigDisabled = `-- name: UpdateBotChannelConfigDisabled :one
UPDATE bot_channel_configs
SET
disabled = $3,
updated_at = now()
WHERE bot_id = $1 AND channel_type = $2
RETURNING id, bot_id, channel_type, credentials, external_identity, self_identity, routing, capabilities, disabled, verified_at, created_at, updated_at
`
type UpdateBotChannelConfigDisabledParams struct {
BotID pgtype.UUID `json:"bot_id"`
ChannelType string `json:"channel_type"`
Disabled bool `json:"disabled"`
}
func (q *Queries) UpdateBotChannelConfigDisabled(ctx context.Context, arg UpdateBotChannelConfigDisabledParams) (BotChannelConfig, error) {
row := q.db.QueryRow(ctx, updateBotChannelConfigDisabled, arg.BotID, arg.ChannelType, arg.Disabled)
var i BotChannelConfig
err := row.Scan(
&i.ID,
&i.BotID,
&i.ChannelType,
&i.Credentials,
&i.ExternalIdentity,
&i.SelfIdentity,
&i.Routing,
&i.Capabilities,
&i.Disabled,
&i.VerifiedAt,
&i.CreatedAt,
&i.UpdatedAt,
)
return i, err
}
const upsertBotChannelConfig = `-- name: UpsertBotChannelConfig :one
INSERT INTO bot_channel_configs (
bot_id, channel_type, credentials, external_identity, self_identity, routing, capabilities, status, verified_at
bot_id, channel_type, credentials, external_identity, self_identity, routing, capabilities, disabled, verified_at
)
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9)
ON CONFLICT (bot_id, channel_type)
@@ -187,10 +237,10 @@ DO UPDATE SET
self_identity = EXCLUDED.self_identity,
routing = EXCLUDED.routing,
capabilities = EXCLUDED.capabilities,
status = EXCLUDED.status,
disabled = EXCLUDED.disabled,
verified_at = EXCLUDED.verified_at,
updated_at = now()
RETURNING id, bot_id, channel_type, credentials, external_identity, self_identity, routing, capabilities, status, verified_at, created_at, updated_at
RETURNING id, bot_id, channel_type, credentials, external_identity, self_identity, routing, capabilities, disabled, verified_at, created_at, updated_at
`
type UpsertBotChannelConfigParams struct {
@@ -201,7 +251,7 @@ type UpsertBotChannelConfigParams struct {
SelfIdentity []byte `json:"self_identity"`
Routing []byte `json:"routing"`
Capabilities []byte `json:"capabilities"`
Status string `json:"status"`
Disabled bool `json:"disabled"`
VerifiedAt pgtype.Timestamptz `json:"verified_at"`
}
@@ -214,7 +264,7 @@ func (q *Queries) UpsertBotChannelConfig(ctx context.Context, arg UpsertBotChann
arg.SelfIdentity,
arg.Routing,
arg.Capabilities,
arg.Status,
arg.Disabled,
arg.VerifiedAt,
)
var i BotChannelConfig
@@ -227,7 +277,7 @@ func (q *Queries) UpsertBotChannelConfig(ctx context.Context, arg UpsertBotChann
&i.SelfIdentity,
&i.Routing,
&i.Capabilities,
&i.Status,
&i.Disabled,
&i.VerifiedAt,
&i.CreatedAt,
&i.UpdatedAt,
+527
View File
@@ -0,0 +1,527 @@
// Code generated by sqlc. DO NOT EDIT.
// versions:
// sqlc v1.30.0
// source: media.sql
package sqlc
import (
"context"
"github.com/jackc/pgx/v5/pgtype"
)
const createMediaAsset = `-- name: CreateMediaAsset :one
INSERT INTO media_assets (
bot_id, storage_provider_id, content_hash, media_type, mime,
size_bytes, storage_key, original_name, width, height, duration_ms, metadata
)
VALUES (
$1,
$2::uuid,
$3,
$4,
$5,
$6,
$7,
$8::text,
$9::integer,
$10::integer,
$11::bigint,
$12
)
ON CONFLICT (bot_id, content_hash) DO UPDATE SET
bot_id = media_assets.bot_id
RETURNING id, bot_id, storage_provider_id, content_hash, media_type, mime, size_bytes, storage_key, original_name, width, height, duration_ms, metadata, created_at
`
type CreateMediaAssetParams struct {
BotID pgtype.UUID `json:"bot_id"`
StorageProviderID pgtype.UUID `json:"storage_provider_id"`
ContentHash string `json:"content_hash"`
MediaType string `json:"media_type"`
Mime string `json:"mime"`
SizeBytes int64 `json:"size_bytes"`
StorageKey string `json:"storage_key"`
OriginalName pgtype.Text `json:"original_name"`
Width pgtype.Int4 `json:"width"`
Height pgtype.Int4 `json:"height"`
DurationMs pgtype.Int8 `json:"duration_ms"`
Metadata []byte `json:"metadata"`
}
func (q *Queries) CreateMediaAsset(ctx context.Context, arg CreateMediaAssetParams) (MediaAsset, error) {
row := q.db.QueryRow(ctx, createMediaAsset,
arg.BotID,
arg.StorageProviderID,
arg.ContentHash,
arg.MediaType,
arg.Mime,
arg.SizeBytes,
arg.StorageKey,
arg.OriginalName,
arg.Width,
arg.Height,
arg.DurationMs,
arg.Metadata,
)
var i MediaAsset
err := row.Scan(
&i.ID,
&i.BotID,
&i.StorageProviderID,
&i.ContentHash,
&i.MediaType,
&i.Mime,
&i.SizeBytes,
&i.StorageKey,
&i.OriginalName,
&i.Width,
&i.Height,
&i.DurationMs,
&i.Metadata,
&i.CreatedAt,
)
return i, err
}
const createMessageAsset = `-- name: CreateMessageAsset :one
INSERT INTO bot_history_message_assets (message_id, asset_id, role, ordinal)
VALUES ($1, $2, $3, $4)
ON CONFLICT (message_id, asset_id) DO UPDATE SET
role = EXCLUDED.role,
ordinal = EXCLUDED.ordinal
RETURNING id, message_id, asset_id, role, ordinal, created_at
`
type CreateMessageAssetParams struct {
MessageID pgtype.UUID `json:"message_id"`
AssetID pgtype.UUID `json:"asset_id"`
Role string `json:"role"`
Ordinal int32 `json:"ordinal"`
}
func (q *Queries) CreateMessageAsset(ctx context.Context, arg CreateMessageAssetParams) (BotHistoryMessageAsset, error) {
row := q.db.QueryRow(ctx, createMessageAsset,
arg.MessageID,
arg.AssetID,
arg.Role,
arg.Ordinal,
)
var i BotHistoryMessageAsset
err := row.Scan(
&i.ID,
&i.MessageID,
&i.AssetID,
&i.Role,
&i.Ordinal,
&i.CreatedAt,
)
return i, err
}
const createStorageProvider = `-- name: CreateStorageProvider :one
INSERT INTO storage_providers (name, provider, config)
VALUES ($1, $2, $3)
RETURNING id, name, provider, config, created_at, updated_at
`
type CreateStorageProviderParams struct {
Name string `json:"name"`
Provider string `json:"provider"`
Config []byte `json:"config"`
}
func (q *Queries) CreateStorageProvider(ctx context.Context, arg CreateStorageProviderParams) (StorageProvider, error) {
row := q.db.QueryRow(ctx, createStorageProvider, arg.Name, arg.Provider, arg.Config)
var i StorageProvider
err := row.Scan(
&i.ID,
&i.Name,
&i.Provider,
&i.Config,
&i.CreatedAt,
&i.UpdatedAt,
)
return i, err
}
const deleteMediaAsset = `-- name: DeleteMediaAsset :exec
DELETE FROM media_assets WHERE id = $1
`
func (q *Queries) DeleteMediaAsset(ctx context.Context, id pgtype.UUID) error {
_, err := q.db.Exec(ctx, deleteMediaAsset, id)
return err
}
const deleteMessageAssets = `-- name: DeleteMessageAssets :exec
DELETE FROM bot_history_message_assets WHERE message_id = $1
`
func (q *Queries) DeleteMessageAssets(ctx context.Context, messageID pgtype.UUID) error {
_, err := q.db.Exec(ctx, deleteMessageAssets, messageID)
return err
}
const getBotStorageBinding = `-- name: GetBotStorageBinding :one
SELECT id, bot_id, storage_provider_id, base_path, created_at, updated_at FROM bot_storage_bindings WHERE bot_id = $1
`
func (q *Queries) GetBotStorageBinding(ctx context.Context, botID pgtype.UUID) (BotStorageBinding, error) {
row := q.db.QueryRow(ctx, getBotStorageBinding, botID)
var i BotStorageBinding
err := row.Scan(
&i.ID,
&i.BotID,
&i.StorageProviderID,
&i.BasePath,
&i.CreatedAt,
&i.UpdatedAt,
)
return i, err
}
const getMediaAssetByHash = `-- name: GetMediaAssetByHash :one
SELECT id, bot_id, storage_provider_id, content_hash, media_type, mime, size_bytes, storage_key, original_name, width, height, duration_ms, metadata, created_at FROM media_assets
WHERE bot_id = $1 AND content_hash = $2
`
type GetMediaAssetByHashParams struct {
BotID pgtype.UUID `json:"bot_id"`
ContentHash string `json:"content_hash"`
}
func (q *Queries) GetMediaAssetByHash(ctx context.Context, arg GetMediaAssetByHashParams) (MediaAsset, error) {
row := q.db.QueryRow(ctx, getMediaAssetByHash, arg.BotID, arg.ContentHash)
var i MediaAsset
err := row.Scan(
&i.ID,
&i.BotID,
&i.StorageProviderID,
&i.ContentHash,
&i.MediaType,
&i.Mime,
&i.SizeBytes,
&i.StorageKey,
&i.OriginalName,
&i.Width,
&i.Height,
&i.DurationMs,
&i.Metadata,
&i.CreatedAt,
)
return i, err
}
const getMediaAssetByID = `-- name: GetMediaAssetByID :one
SELECT id, bot_id, storage_provider_id, content_hash, media_type, mime, size_bytes, storage_key, original_name, width, height, duration_ms, metadata, created_at FROM media_assets WHERE id = $1
`
func (q *Queries) GetMediaAssetByID(ctx context.Context, id pgtype.UUID) (MediaAsset, error) {
row := q.db.QueryRow(ctx, getMediaAssetByID, id)
var i MediaAsset
err := row.Scan(
&i.ID,
&i.BotID,
&i.StorageProviderID,
&i.ContentHash,
&i.MediaType,
&i.Mime,
&i.SizeBytes,
&i.StorageKey,
&i.OriginalName,
&i.Width,
&i.Height,
&i.DurationMs,
&i.Metadata,
&i.CreatedAt,
)
return i, err
}
const getStorageProviderByID = `-- name: GetStorageProviderByID :one
SELECT id, name, provider, config, created_at, updated_at FROM storage_providers WHERE id = $1
`
func (q *Queries) GetStorageProviderByID(ctx context.Context, id pgtype.UUID) (StorageProvider, error) {
row := q.db.QueryRow(ctx, getStorageProviderByID, id)
var i StorageProvider
err := row.Scan(
&i.ID,
&i.Name,
&i.Provider,
&i.Config,
&i.CreatedAt,
&i.UpdatedAt,
)
return i, err
}
const getStorageProviderByName = `-- name: GetStorageProviderByName :one
SELECT id, name, provider, config, created_at, updated_at FROM storage_providers WHERE name = $1
`
func (q *Queries) GetStorageProviderByName(ctx context.Context, name string) (StorageProvider, error) {
row := q.db.QueryRow(ctx, getStorageProviderByName, name)
var i StorageProvider
err := row.Scan(
&i.ID,
&i.Name,
&i.Provider,
&i.Config,
&i.CreatedAt,
&i.UpdatedAt,
)
return i, err
}
const listMediaAssetsByBotID = `-- name: ListMediaAssetsByBotID :many
SELECT id, bot_id, storage_provider_id, content_hash, media_type, mime, size_bytes, storage_key, original_name, width, height, duration_ms, metadata, created_at FROM media_assets
WHERE bot_id = $1
ORDER BY created_at DESC
`
func (q *Queries) ListMediaAssetsByBotID(ctx context.Context, botID pgtype.UUID) ([]MediaAsset, error) {
rows, err := q.db.Query(ctx, listMediaAssetsByBotID, botID)
if err != nil {
return nil, err
}
defer rows.Close()
var items []MediaAsset
for rows.Next() {
var i MediaAsset
if err := rows.Scan(
&i.ID,
&i.BotID,
&i.StorageProviderID,
&i.ContentHash,
&i.MediaType,
&i.Mime,
&i.SizeBytes,
&i.StorageKey,
&i.OriginalName,
&i.Width,
&i.Height,
&i.DurationMs,
&i.Metadata,
&i.CreatedAt,
); err != nil {
return nil, err
}
items = append(items, i)
}
if err := rows.Err(); err != nil {
return nil, err
}
return items, nil
}
const listMessageAssets = `-- name: ListMessageAssets :many
SELECT
ma.id AS rel_id,
ma.message_id,
ma.asset_id,
ma.role,
ma.ordinal,
a.media_type,
a.mime,
a.size_bytes,
a.storage_key,
a.original_name,
a.width,
a.height,
a.duration_ms,
a.metadata AS asset_metadata
FROM bot_history_message_assets ma
JOIN media_assets a ON a.id = ma.asset_id
WHERE ma.message_id = $1
ORDER BY ma.ordinal ASC
`
type ListMessageAssetsRow struct {
RelID pgtype.UUID `json:"rel_id"`
MessageID pgtype.UUID `json:"message_id"`
AssetID pgtype.UUID `json:"asset_id"`
Role string `json:"role"`
Ordinal int32 `json:"ordinal"`
MediaType string `json:"media_type"`
Mime string `json:"mime"`
SizeBytes int64 `json:"size_bytes"`
StorageKey string `json:"storage_key"`
OriginalName pgtype.Text `json:"original_name"`
Width pgtype.Int4 `json:"width"`
Height pgtype.Int4 `json:"height"`
DurationMs pgtype.Int8 `json:"duration_ms"`
AssetMetadata []byte `json:"asset_metadata"`
}
func (q *Queries) ListMessageAssets(ctx context.Context, messageID pgtype.UUID) ([]ListMessageAssetsRow, error) {
rows, err := q.db.Query(ctx, listMessageAssets, messageID)
if err != nil {
return nil, err
}
defer rows.Close()
var items []ListMessageAssetsRow
for rows.Next() {
var i ListMessageAssetsRow
if err := rows.Scan(
&i.RelID,
&i.MessageID,
&i.AssetID,
&i.Role,
&i.Ordinal,
&i.MediaType,
&i.Mime,
&i.SizeBytes,
&i.StorageKey,
&i.OriginalName,
&i.Width,
&i.Height,
&i.DurationMs,
&i.AssetMetadata,
); err != nil {
return nil, err
}
items = append(items, i)
}
if err := rows.Err(); err != nil {
return nil, err
}
return items, nil
}
const listMessageAssetsBatch = `-- name: ListMessageAssetsBatch :many
SELECT
ma.id AS rel_id,
ma.message_id,
ma.asset_id,
ma.role,
ma.ordinal,
a.media_type,
a.mime,
a.size_bytes,
a.storage_key,
a.original_name,
a.width,
a.height,
a.duration_ms,
a.metadata AS asset_metadata
FROM bot_history_message_assets ma
JOIN media_assets a ON a.id = ma.asset_id
WHERE ma.message_id = ANY($1::uuid[])
ORDER BY ma.message_id, ma.ordinal ASC
`
type ListMessageAssetsBatchRow struct {
RelID pgtype.UUID `json:"rel_id"`
MessageID pgtype.UUID `json:"message_id"`
AssetID pgtype.UUID `json:"asset_id"`
Role string `json:"role"`
Ordinal int32 `json:"ordinal"`
MediaType string `json:"media_type"`
Mime string `json:"mime"`
SizeBytes int64 `json:"size_bytes"`
StorageKey string `json:"storage_key"`
OriginalName pgtype.Text `json:"original_name"`
Width pgtype.Int4 `json:"width"`
Height pgtype.Int4 `json:"height"`
DurationMs pgtype.Int8 `json:"duration_ms"`
AssetMetadata []byte `json:"asset_metadata"`
}
func (q *Queries) ListMessageAssetsBatch(ctx context.Context, messageIds []pgtype.UUID) ([]ListMessageAssetsBatchRow, error) {
rows, err := q.db.Query(ctx, listMessageAssetsBatch, messageIds)
if err != nil {
return nil, err
}
defer rows.Close()
var items []ListMessageAssetsBatchRow
for rows.Next() {
var i ListMessageAssetsBatchRow
if err := rows.Scan(
&i.RelID,
&i.MessageID,
&i.AssetID,
&i.Role,
&i.Ordinal,
&i.MediaType,
&i.Mime,
&i.SizeBytes,
&i.StorageKey,
&i.OriginalName,
&i.Width,
&i.Height,
&i.DurationMs,
&i.AssetMetadata,
); err != nil {
return nil, err
}
items = append(items, i)
}
if err := rows.Err(); err != nil {
return nil, err
}
return items, nil
}
const listStorageProviders = `-- name: ListStorageProviders :many
SELECT id, name, provider, config, created_at, updated_at FROM storage_providers ORDER BY created_at DESC
`
func (q *Queries) ListStorageProviders(ctx context.Context) ([]StorageProvider, error) {
rows, err := q.db.Query(ctx, listStorageProviders)
if err != nil {
return nil, err
}
defer rows.Close()
var items []StorageProvider
for rows.Next() {
var i StorageProvider
if err := rows.Scan(
&i.ID,
&i.Name,
&i.Provider,
&i.Config,
&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 upsertBotStorageBinding = `-- name: UpsertBotStorageBinding :one
INSERT INTO bot_storage_bindings (bot_id, storage_provider_id, base_path)
VALUES ($1, $2, $3)
ON CONFLICT (bot_id) DO UPDATE SET
storage_provider_id = EXCLUDED.storage_provider_id,
base_path = EXCLUDED.base_path,
updated_at = now()
RETURNING id, bot_id, storage_provider_id, base_path, created_at, updated_at
`
type UpsertBotStorageBindingParams struct {
BotID pgtype.UUID `json:"bot_id"`
StorageProviderID pgtype.UUID `json:"storage_provider_id"`
BasePath string `json:"base_path"`
}
func (q *Queries) UpsertBotStorageBinding(ctx context.Context, arg UpsertBotStorageBindingParams) (BotStorageBinding, error) {
row := q.db.QueryRow(ctx, upsertBotStorageBinding, arg.BotID, arg.StorageProviderID, arg.BasePath)
var i BotStorageBinding
err := row.Scan(
&i.ID,
&i.BotID,
&i.StorageProviderID,
&i.BasePath,
&i.CreatedAt,
&i.UpdatedAt,
)
return i, err
}
+54 -10
View File
@@ -37,7 +37,7 @@ type BotChannelConfig struct {
SelfIdentity []byte `json:"self_identity"`
Routing []byte `json:"routing"`
Capabilities []byte `json:"capabilities"`
Status string `json:"status"`
Disabled bool `json:"disabled"`
VerifiedAt pgtype.Timestamptz `json:"verified_at"`
CreatedAt pgtype.Timestamptz `json:"created_at"`
UpdatedAt pgtype.Timestamptz `json:"updated_at"`
@@ -72,6 +72,15 @@ type BotHistoryMessage struct {
CreatedAt pgtype.Timestamptz `json:"created_at"`
}
type BotHistoryMessageAsset struct {
ID pgtype.UUID `json:"id"`
MessageID pgtype.UUID `json:"message_id"`
AssetID pgtype.UUID `json:"asset_id"`
Role string `json:"role"`
Ordinal int32 `json:"ordinal"`
CreatedAt pgtype.Timestamptz `json:"created_at"`
}
type BotMember struct {
BotID pgtype.UUID `json:"bot_id"`
UserID pgtype.UUID `json:"user_id"`
@@ -89,6 +98,15 @@ type BotPreauthKey struct {
CreatedAt pgtype.Timestamptz `json:"created_at"`
}
type BotStorageBinding struct {
ID pgtype.UUID `json:"id"`
BotID pgtype.UUID `json:"bot_id"`
StorageProviderID pgtype.UUID `json:"storage_provider_id"`
BasePath string `json:"base_path"`
CreatedAt pgtype.Timestamptz `json:"created_at"`
UpdatedAt pgtype.Timestamptz `json:"updated_at"`
}
type ChannelIdentity struct {
ID pgtype.UUID `json:"id"`
UserID pgtype.UUID `json:"user_id"`
@@ -167,16 +185,33 @@ type McpConnection struct {
UpdatedAt pgtype.Timestamptz `json:"updated_at"`
}
type MediaAsset struct {
ID pgtype.UUID `json:"id"`
BotID pgtype.UUID `json:"bot_id"`
StorageProviderID pgtype.UUID `json:"storage_provider_id"`
ContentHash string `json:"content_hash"`
MediaType string `json:"media_type"`
Mime string `json:"mime"`
SizeBytes int64 `json:"size_bytes"`
StorageKey string `json:"storage_key"`
OriginalName pgtype.Text `json:"original_name"`
Width pgtype.Int4 `json:"width"`
Height pgtype.Int4 `json:"height"`
DurationMs pgtype.Int8 `json:"duration_ms"`
Metadata []byte `json:"metadata"`
CreatedAt pgtype.Timestamptz `json:"created_at"`
}
type Model struct {
ID pgtype.UUID `json:"id"`
ModelID string `json:"model_id"`
Name pgtype.Text `json:"name"`
LlmProviderID pgtype.UUID `json:"llm_provider_id"`
Dimensions pgtype.Int4 `json:"dimensions"`
IsMultimodal bool `json:"is_multimodal"`
Type string `json:"type"`
CreatedAt pgtype.Timestamptz `json:"created_at"`
UpdatedAt pgtype.Timestamptz `json:"updated_at"`
ID pgtype.UUID `json:"id"`
ModelID string `json:"model_id"`
Name pgtype.Text `json:"name"`
LlmProviderID pgtype.UUID `json:"llm_provider_id"`
Dimensions pgtype.Int4 `json:"dimensions"`
InputModalities []string `json:"input_modalities"`
Type string `json:"type"`
CreatedAt pgtype.Timestamptz `json:"created_at"`
UpdatedAt pgtype.Timestamptz `json:"updated_at"`
}
type ModelVariant struct {
@@ -221,6 +256,15 @@ type Snapshot struct {
CreatedAt pgtype.Timestamptz `json:"created_at"`
}
type StorageProvider struct {
ID pgtype.UUID `json:"id"`
Name string `json:"name"`
Provider string `json:"provider"`
Config []byte `json:"config"`
CreatedAt pgtype.Timestamptz `json:"created_at"`
UpdatedAt pgtype.Timestamptz `json:"updated_at"`
}
type Subagent struct {
ID pgtype.UUID `json:"id"`
Name string `json:"name"`
+45 -45
View File
@@ -98,7 +98,7 @@ func (q *Queries) CreateLlmProvider(ctx context.Context, arg CreateLlmProviderPa
}
const createModel = `-- name: CreateModel :one
INSERT INTO models (model_id, name, llm_provider_id, dimensions, is_multimodal, type)
INSERT INTO models (model_id, name, llm_provider_id, dimensions, input_modalities, type)
VALUES (
$1,
$2,
@@ -107,16 +107,16 @@ VALUES (
$5,
$6
)
RETURNING id, model_id, name, llm_provider_id, dimensions, is_multimodal, type, created_at, updated_at
RETURNING id, model_id, name, llm_provider_id, dimensions, input_modalities, type, created_at, updated_at
`
type CreateModelParams struct {
ModelID string `json:"model_id"`
Name pgtype.Text `json:"name"`
LlmProviderID pgtype.UUID `json:"llm_provider_id"`
Dimensions pgtype.Int4 `json:"dimensions"`
IsMultimodal bool `json:"is_multimodal"`
Type string `json:"type"`
ModelID string `json:"model_id"`
Name pgtype.Text `json:"name"`
LlmProviderID pgtype.UUID `json:"llm_provider_id"`
Dimensions pgtype.Int4 `json:"dimensions"`
InputModalities []string `json:"input_modalities"`
Type string `json:"type"`
}
func (q *Queries) CreateModel(ctx context.Context, arg CreateModelParams) (Model, error) {
@@ -125,7 +125,7 @@ func (q *Queries) CreateModel(ctx context.Context, arg CreateModelParams) (Model
arg.Name,
arg.LlmProviderID,
arg.Dimensions,
arg.IsMultimodal,
arg.InputModalities,
arg.Type,
)
var i Model
@@ -135,7 +135,7 @@ func (q *Queries) CreateModel(ctx context.Context, arg CreateModelParams) (Model
&i.Name,
&i.LlmProviderID,
&i.Dimensions,
&i.IsMultimodal,
&i.InputModalities,
&i.Type,
&i.CreatedAt,
&i.UpdatedAt,
@@ -249,7 +249,7 @@ func (q *Queries) GetLlmProviderByName(ctx context.Context, name string) (LlmPro
}
const getModelByID = `-- name: GetModelByID :one
SELECT id, model_id, name, llm_provider_id, dimensions, is_multimodal, type, created_at, updated_at FROM models WHERE id = $1
SELECT id, model_id, name, llm_provider_id, dimensions, input_modalities, type, created_at, updated_at FROM models WHERE id = $1
`
func (q *Queries) GetModelByID(ctx context.Context, id pgtype.UUID) (Model, error) {
@@ -261,7 +261,7 @@ func (q *Queries) GetModelByID(ctx context.Context, id pgtype.UUID) (Model, erro
&i.Name,
&i.LlmProviderID,
&i.Dimensions,
&i.IsMultimodal,
&i.InputModalities,
&i.Type,
&i.CreatedAt,
&i.UpdatedAt,
@@ -270,7 +270,7 @@ func (q *Queries) GetModelByID(ctx context.Context, id pgtype.UUID) (Model, erro
}
const getModelByModelID = `-- name: GetModelByModelID :one
SELECT id, model_id, name, llm_provider_id, dimensions, is_multimodal, type, created_at, updated_at FROM models WHERE model_id = $1
SELECT id, model_id, name, llm_provider_id, dimensions, input_modalities, type, created_at, updated_at FROM models WHERE model_id = $1
`
func (q *Queries) GetModelByModelID(ctx context.Context, modelID string) (Model, error) {
@@ -282,7 +282,7 @@ func (q *Queries) GetModelByModelID(ctx context.Context, modelID string) (Model,
&i.Name,
&i.LlmProviderID,
&i.Dimensions,
&i.IsMultimodal,
&i.InputModalities,
&i.Type,
&i.CreatedAt,
&i.UpdatedAt,
@@ -394,7 +394,7 @@ func (q *Queries) ListModelVariantsByModelUUID(ctx context.Context, modelUuid pg
}
const listModels = `-- name: ListModels :many
SELECT id, model_id, name, llm_provider_id, dimensions, is_multimodal, type, created_at, updated_at FROM models
SELECT id, model_id, name, llm_provider_id, dimensions, input_modalities, type, created_at, updated_at FROM models
ORDER BY created_at DESC
`
@@ -413,7 +413,7 @@ func (q *Queries) ListModels(ctx context.Context) ([]Model, error) {
&i.Name,
&i.LlmProviderID,
&i.Dimensions,
&i.IsMultimodal,
&i.InputModalities,
&i.Type,
&i.CreatedAt,
&i.UpdatedAt,
@@ -429,7 +429,7 @@ func (q *Queries) ListModels(ctx context.Context) ([]Model, error) {
}
const listModelsByClientType = `-- name: ListModelsByClientType :many
SELECT m.id, m.model_id, m.name, m.llm_provider_id, m.dimensions, m.is_multimodal, m.type, m.created_at, m.updated_at FROM models AS m
SELECT m.id, m.model_id, m.name, m.llm_provider_id, m.dimensions, m.input_modalities, m.type, m.created_at, m.updated_at FROM models AS m
JOIN llm_providers AS p ON p.id = m.llm_provider_id
WHERE p.client_type = $1
ORDER BY m.created_at DESC
@@ -450,7 +450,7 @@ func (q *Queries) ListModelsByClientType(ctx context.Context, clientType string)
&i.Name,
&i.LlmProviderID,
&i.Dimensions,
&i.IsMultimodal,
&i.InputModalities,
&i.Type,
&i.CreatedAt,
&i.UpdatedAt,
@@ -466,7 +466,7 @@ func (q *Queries) ListModelsByClientType(ctx context.Context, clientType string)
}
const listModelsByProviderID = `-- name: ListModelsByProviderID :many
SELECT id, model_id, name, llm_provider_id, dimensions, is_multimodal, type, created_at, updated_at FROM models
SELECT id, model_id, name, llm_provider_id, dimensions, input_modalities, type, created_at, updated_at FROM models
WHERE llm_provider_id = $1
ORDER BY created_at DESC
`
@@ -486,7 +486,7 @@ func (q *Queries) ListModelsByProviderID(ctx context.Context, llmProviderID pgty
&i.Name,
&i.LlmProviderID,
&i.Dimensions,
&i.IsMultimodal,
&i.InputModalities,
&i.Type,
&i.CreatedAt,
&i.UpdatedAt,
@@ -502,7 +502,7 @@ func (q *Queries) ListModelsByProviderID(ctx context.Context, llmProviderID pgty
}
const listModelsByProviderIDAndType = `-- name: ListModelsByProviderIDAndType :many
SELECT id, model_id, name, llm_provider_id, dimensions, is_multimodal, type, created_at, updated_at FROM models
SELECT id, model_id, name, llm_provider_id, dimensions, input_modalities, type, created_at, updated_at FROM models
WHERE llm_provider_id = $1
AND type = $2
ORDER BY created_at DESC
@@ -528,7 +528,7 @@ func (q *Queries) ListModelsByProviderIDAndType(ctx context.Context, arg ListMod
&i.Name,
&i.LlmProviderID,
&i.Dimensions,
&i.IsMultimodal,
&i.InputModalities,
&i.Type,
&i.CreatedAt,
&i.UpdatedAt,
@@ -544,7 +544,7 @@ func (q *Queries) ListModelsByProviderIDAndType(ctx context.Context, arg ListMod
}
const listModelsByType = `-- name: ListModelsByType :many
SELECT id, model_id, name, llm_provider_id, dimensions, is_multimodal, type, created_at, updated_at FROM models
SELECT id, model_id, name, llm_provider_id, dimensions, input_modalities, type, created_at, updated_at FROM models
WHERE type = $1
ORDER BY created_at DESC
`
@@ -564,7 +564,7 @@ func (q *Queries) ListModelsByType(ctx context.Context, type_ string) ([]Model,
&i.Name,
&i.LlmProviderID,
&i.Dimensions,
&i.IsMultimodal,
&i.InputModalities,
&i.Type,
&i.CreatedAt,
&i.UpdatedAt,
@@ -630,20 +630,20 @@ SET
name = $1,
llm_provider_id = $2,
dimensions = $3,
is_multimodal = $4,
input_modalities = $4,
type = $5,
updated_at = now()
WHERE id = $6
RETURNING id, model_id, name, llm_provider_id, dimensions, is_multimodal, type, created_at, updated_at
RETURNING id, model_id, name, llm_provider_id, dimensions, input_modalities, type, created_at, updated_at
`
type UpdateModelParams struct {
Name pgtype.Text `json:"name"`
LlmProviderID pgtype.UUID `json:"llm_provider_id"`
Dimensions pgtype.Int4 `json:"dimensions"`
IsMultimodal bool `json:"is_multimodal"`
Type string `json:"type"`
ID pgtype.UUID `json:"id"`
Name pgtype.Text `json:"name"`
LlmProviderID pgtype.UUID `json:"llm_provider_id"`
Dimensions pgtype.Int4 `json:"dimensions"`
InputModalities []string `json:"input_modalities"`
Type string `json:"type"`
ID pgtype.UUID `json:"id"`
}
func (q *Queries) UpdateModel(ctx context.Context, arg UpdateModelParams) (Model, error) {
@@ -651,7 +651,7 @@ func (q *Queries) UpdateModel(ctx context.Context, arg UpdateModelParams) (Model
arg.Name,
arg.LlmProviderID,
arg.Dimensions,
arg.IsMultimodal,
arg.InputModalities,
arg.Type,
arg.ID,
)
@@ -662,7 +662,7 @@ func (q *Queries) UpdateModel(ctx context.Context, arg UpdateModelParams) (Model
&i.Name,
&i.LlmProviderID,
&i.Dimensions,
&i.IsMultimodal,
&i.InputModalities,
&i.Type,
&i.CreatedAt,
&i.UpdatedAt,
@@ -677,21 +677,21 @@ SET
name = $2,
llm_provider_id = $3,
dimensions = $4,
is_multimodal = $5,
input_modalities = $5,
type = $6,
updated_at = now()
WHERE model_id = $7
RETURNING id, model_id, name, llm_provider_id, dimensions, is_multimodal, type, created_at, updated_at
RETURNING id, model_id, name, llm_provider_id, dimensions, input_modalities, type, created_at, updated_at
`
type UpdateModelByModelIDParams struct {
NewModelID string `json:"new_model_id"`
Name pgtype.Text `json:"name"`
LlmProviderID pgtype.UUID `json:"llm_provider_id"`
Dimensions pgtype.Int4 `json:"dimensions"`
IsMultimodal bool `json:"is_multimodal"`
Type string `json:"type"`
ModelID string `json:"model_id"`
NewModelID string `json:"new_model_id"`
Name pgtype.Text `json:"name"`
LlmProviderID pgtype.UUID `json:"llm_provider_id"`
Dimensions pgtype.Int4 `json:"dimensions"`
InputModalities []string `json:"input_modalities"`
Type string `json:"type"`
ModelID string `json:"model_id"`
}
func (q *Queries) UpdateModelByModelID(ctx context.Context, arg UpdateModelByModelIDParams) (Model, error) {
@@ -700,7 +700,7 @@ func (q *Queries) UpdateModelByModelID(ctx context.Context, arg UpdateModelByMod
arg.Name,
arg.LlmProviderID,
arg.Dimensions,
arg.IsMultimodal,
arg.InputModalities,
arg.Type,
arg.ModelID,
)
@@ -711,7 +711,7 @@ func (q *Queries) UpdateModelByModelID(ctx context.Context, arg UpdateModelByMod
&i.Name,
&i.LlmProviderID,
&i.Dimensions,
&i.IsMultimodal,
&i.InputModalities,
&i.Type,
&i.CreatedAt,
&i.UpdatedAt,