mirror of
https://github.com/memohai/Memoh.git
synced 2026-04-27 07:16:19 +09:00
7d7d0e4b51
* refactor: introduce multi-session chat support (#session)
Replace the single-context-per-bot model with multiple chat sessions.
Database:
- Add bot_sessions table (route_id, channel_type, title, metadata, soft delete)
- Migrate bot_history_messages from (route_id, channel_type) to session_id
- Add active_session_id to bot_channel_routes
- Migration 0036 handles data migration from existing messages
Backend:
- New internal/session service for session CRUD
- Update message service/types to use session_id instead of route_id
- Update conversation flow (resolver, history, store) for session context
- Channel inbound auto-creates/retrieves active session via SessionEnsurer
- New REST endpoints: /bots/:bot_id/sessions (CRUD)
- WebSocket and message handlers accept optional session_id
- Wire session service into FX dependency graph (agent + memoh)
Frontend:
- Refactor chat store: sessions replaces chats, sessionId replaces chatId
- Session-aware message loading, sending, and pagination
- WebSocket sends include session_id
- New session sidebar component with select/delete
- Chat area header shows active session title + new session button
- API layer updated: fetchSessions, createSession, deleteSession
- i18n strings for session management (en + zh)
SDK:
- Regenerated TypeScript SDK and Swagger docs with session endpoints
* fix: update tests for session refactoring (RouteID → SessionID)
Remove references to removed RouteID and Platform fields from
PersistInput/Message in channel_test.go and service_integration_test.go.
* fix: restore accidentally deleted SDK files and guard migration 0032
- Restore packages/sdk/src/container-stream.ts and extra/index.ts that
were accidentally removed during SDK regeneration
- Wrap migration 0032 route_id index creation in a column existence check
to avoid failure on fresh databases where 0001_init.up.sql no longer
has route_id
* fix: guard migration 0036 data steps for fresh databases
Wrap steps 3-7 (which reference route_id/channel_type on
bot_history_messages) in a column existence check so the migration
is safe on fresh databases where 0001_init.up.sql already reflects
the final schema without those columns.
* feat: add title model setting and auto-generate session titles on user input
- Add title_model_id to bots table (migration 0037) and bot settings API
- Implement async title generation triggered at user message time (not after
assistant response) for faster title availability
- Publish session_title_updated events via SSE event hub for real-time
frontend updates without page refresh
- Fix SSE message event parsing: use direct JSON.parse instead of
normalizeStreamEvent which silently dropped non-chat-stream event types
- Add title model selector in bot settings UI with i18n support
* fix: session-scoped message filtering and URL-based chat routing
- Filter realtime SSE messages by session_id to prevent cross-session
message leakage after page refresh
- Add /chat/:sessionId? route with bidirectional URL ↔ store sync
- Visiting /chat shows a clean state with no bot or session pre-selected
- Visiting /chat/:sessionId loads the specific session directly
- Session switches from sidebar automatically update the URL
- Fix stale RouteID field in dedupe test (removed during session refactor)
* fix: skip cross-channel stream events to prevent session leakage
The bot-level web stream pushes events from all channels (Telegram,
Discord, etc.) without session_id context. Previously these were
rendered inline in the current chat view regardless of session.
Now cross-channel events are ignored in handleLocalStreamEvent;
persisted messages arrive via the SSE message events stream with
proper session_id filtering through appendRealtimeMessage.
* feat: show IM avatars and platform badges on session sidebar
- Add sender_avatar_url to route metadata from identity resolution
- Resolve group avatar and handle via directory adapter for group chats
- JOIN bot_channel_routes in ListSessionsByBot to return route metadata
- Display avatar with ChannelBadge on IM session items (group avatar
for groups, sender avatar for private chats)
- Show @groupname or @username as session sub-label
* fix: clean up RunConfig unused fields, fix skill system and copy bug
- Remove unused RunConfig fields: Tools, Channels, CurrentChannel,
ActiveContextTime
- Remove unused SessionContext fields: DisplayName, ConversationType
- Fix EnabledSkillNames copy bug: make([]string, 0, n) + copy copies
zero elements; changed to make([]string, n)
- Fix prepareRunConfig dead code: remove no-op loop over
CurrentPlatform runes; compute supportsImageInput from model's
InputModalities
- Fix EnabledSkills always nil in system prompt: resolve enabled skill
entries from EnabledSkillNames + Skills
- Fix use_skill tool returning empty response: now returns full skill
content (description + instructions) so LLM gets it in the same turn
- Skip use_skill tool registration when no skills are available
- Conditionally render Skills section in system prompt (hidden when
no skills exist)
* feat: add session type field and bind sessions to heartbeat/schedule executions
- Add `type` column to `bot_sessions` (chat | heartbeat | schedule)
- Add `session_id` to `bot_heartbeat_logs` for per-execution session tracking
- Create `schedule_logs` table binding schedule_id + session_id
- Heartbeat and schedule runs now create independent sessions and persist
agent messages via storeRound, enabling full conversation replay
- Add schedule logs API endpoints (list by bot, list by schedule, delete)
- Update Triggerer interfaces to return TriggerResult with status/usage/model
* refactor: modular system prompts per session type (chat/heartbeat/schedule)
Split the monolithic system.md into three type-specific system prompts
with shared fragments via {{include:_xxx}} syntax, so each session type
gets a focused prompt without irrelevant instructions.
* fix: prevent message duplication after task completion
message_created events from Persist() had an empty platform field because
toMessageFromCreate() didn't extract it from the session. This caused
appendRealtimeMessage to fail the platform === 'web' guard, and
hasMessageWithId to fail because local IDs differ from server UUIDs,
resulting in all messages being appended as duplicates.
- Extract platform from metadata in toMessageFromCreate so published events
carry the correct value
- Pass channel_type: 'web' when creating sessions from the web frontend so
List queries return the correct platform via the session JOIN
* fix: use per-message usage from SDK instead of misaligned step-level usages
Previously, token usage was stored via a separate per-step usages array
that didn't align with messages (off-by-one from prepending user message,
step count != message count). This caused:
- User messages incorrectly receiving usage data
- Usage values shifted across messages in multi-step rounds
- Last assistant message getting the accumulated total instead of its own step usage
- InputTokenDetails/OutputTokenDetails lost during manual accumulation
Now each sdk.Message carries its own per-step Usage (set by the SDK in
buildStepMessages), which is extracted in sdkMessagesToModelMessages and
stored directly via ModelMessage.Usage. The storeRound/storeMessages path
no longer needs external usage/usages parameters.
Also fixes the totalUsage accumulation in runStream to include all detail
fields (InputTokenDetails, OutputTokenDetails).
* feat: add /new slash command to create a new active session from IM channels
Users in Telegram/Discord/Feishu can now send /new to start a fresh
conversation, resetting the session context for the current chat thread.
The command resolves the channel route, creates a new session, sets it as
the active session on the route, and replies with a confirmation message.
* feat: distinguish heartbeat and schedule sessions with dedicated icons in sidebar
Heartbeat sessions show a heart-pulse icon (rose), schedule sessions
show a clock icon (amber), and both display a type label beneath the
session title.
* refactor: remove enabledSkills system prompt injection, keep sorted skill listing
use_skill now returns skill content directly as tool output, so there is
no need to inject enabled skill body text into the system prompt. Remove
the entire enabledSkills tracking chain (RunConfig.EnabledSkillNames,
StreamEvent.Skills, GenerateResult.Skills, ChatRequest/Response.Skills,
enableSkill closures in runStream/runGenerate, prepareRunConfig matching).
Keep a lightweight skills listing (name + description only) in the system
prompt so the model knows which skills are available. Sort entries by name
to guarantee deterministic ordering and maximize KV cache reuse.
* refactor: remove inbox system, persist passive messages directly to history
Replace the bot_inbox table and service with direct writes to
bot_history_messages for group conversations where the bot is not
@mentioned. Trigger-path messages continue to be persisted after the
agent responds (unchanged).
- Drop bot_inbox table and max_inbox_items column (migration 0039)
- Delete internal/inbox/, handlers/inbox.go, command/inbox.go,
agent/tools/inbox.go and the MCP message provider
- Add persistPassiveMessage() in channel inbound to write user
messages into the active session immediately
- Rewrite ListObservedConversationsByChannelIdentity to query
bot_history_messages + bot_sessions instead of bot_inbox
- Extract shared send/react logic into internal/messaging/executor.go;
agent/tools/message.go is now a thin SDK adapter
- Clean up all inbox references from agent prompts, flow resolver,
email trigger, settings, commands, DI wiring, and frontend
- Regenerate sqlc, swagger, and SDK
* feat: add list_sessions and search_messages agent tools
Provide agents with the ability to query session metadata and search
message history across all sessions. search_messages supports filtering
by time range, keyword (JSONB-aware ILIKE), session, contact, and role,
with a default 7-day lookback when no start_time is given.
* feat: inject last_heartbeat time and improve heartbeat search guidance
Query the previous heartbeat's started_at timestamp and pass it through
TriggerPayload into the heartbeat prompt template. Update system prompt
and HEARTBEAT.md checklist to guide agents to use search_messages with
start_time=last_heartbeat for efficient cross-session message review.
* fix: pass BridgeProvider to FSClient and store full heartbeat prompt
FSClient was always created with nil provider, causing all container
file reads (IDENTITY.md, SOUL.md, MEMORY.md, HEARTBEAT.md, etc.) to
silently return empty strings. Expose Agent.BridgeProvider() and wire
it into Resolver. Also fix heartbeat trigger to store the full prompt
template as the user message instead of the literal "heartbeat" string.
* feat: add line numbers to container file read output
Move line-number formatting from the bridge gRPC server to the agent
tool layer so that the raw content stored and transmitted via gRPC
remains clean, while the read_file tool output includes numbered lines
for easier reference by the agent.
* chore(deps): update twilight-ai to v0.3.2
* fix: lint, test
478 lines
21 KiB
Go
478 lines
21 KiB
Go
// Code generated by sqlc. DO NOT EDIT.
|
|
// versions:
|
|
// sqlc v1.30.0
|
|
|
|
package sqlc
|
|
|
|
import (
|
|
"github.com/jackc/pgx/v5/pgtype"
|
|
)
|
|
|
|
type Bot struct {
|
|
ID pgtype.UUID `json:"id"`
|
|
OwnerUserID pgtype.UUID `json:"owner_user_id"`
|
|
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"`
|
|
Language string `json:"language"`
|
|
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"`
|
|
HeartbeatModelID pgtype.UUID `json:"heartbeat_model_id"`
|
|
TitleModelID pgtype.UUID `json:"title_model_id"`
|
|
TtsModelID pgtype.UUID `json:"tts_model_id"`
|
|
BrowserContextID pgtype.UUID `json:"browser_context_id"`
|
|
Metadata []byte `json:"metadata"`
|
|
CreatedAt pgtype.Timestamptz `json:"created_at"`
|
|
UpdatedAt pgtype.Timestamptz `json:"updated_at"`
|
|
}
|
|
|
|
type BotAclRule struct {
|
|
ID pgtype.UUID `json:"id"`
|
|
BotID pgtype.UUID `json:"bot_id"`
|
|
Action string `json:"action"`
|
|
Effect string `json:"effect"`
|
|
SubjectKind string `json:"subject_kind"`
|
|
UserID pgtype.UUID `json:"user_id"`
|
|
ChannelIdentityID pgtype.UUID `json:"channel_identity_id"`
|
|
SourceChannel pgtype.Text `json:"source_channel"`
|
|
SourceConversationType pgtype.Text `json:"source_conversation_type"`
|
|
SourceConversationID pgtype.Text `json:"source_conversation_id"`
|
|
SourceThreadID pgtype.Text `json:"source_thread_id"`
|
|
CreatedByUserID pgtype.UUID `json:"created_by_user_id"`
|
|
CreatedAt pgtype.Timestamptz `json:"created_at"`
|
|
UpdatedAt pgtype.Timestamptz `json:"updated_at"`
|
|
}
|
|
|
|
type BotChannelConfig struct {
|
|
ID pgtype.UUID `json:"id"`
|
|
BotID pgtype.UUID `json:"bot_id"`
|
|
ChannelType string `json:"channel_type"`
|
|
Credentials []byte `json:"credentials"`
|
|
ExternalIdentity pgtype.Text `json:"external_identity"`
|
|
SelfIdentity []byte `json:"self_identity"`
|
|
Routing []byte `json:"routing"`
|
|
Capabilities []byte `json:"capabilities"`
|
|
Disabled bool `json:"disabled"`
|
|
VerifiedAt pgtype.Timestamptz `json:"verified_at"`
|
|
CreatedAt pgtype.Timestamptz `json:"created_at"`
|
|
UpdatedAt pgtype.Timestamptz `json:"updated_at"`
|
|
}
|
|
|
|
type BotChannelRoute struct {
|
|
ID pgtype.UUID `json:"id"`
|
|
BotID pgtype.UUID `json:"bot_id"`
|
|
ChannelType string `json:"channel_type"`
|
|
ChannelConfigID pgtype.UUID `json:"channel_config_id"`
|
|
ExternalConversationID string `json:"external_conversation_id"`
|
|
ExternalThreadID pgtype.Text `json:"external_thread_id"`
|
|
ConversationType pgtype.Text `json:"conversation_type"`
|
|
DefaultReplyTarget pgtype.Text `json:"default_reply_target"`
|
|
ActiveSessionID pgtype.UUID `json:"active_session_id"`
|
|
Metadata []byte `json:"metadata"`
|
|
CreatedAt pgtype.Timestamptz `json:"created_at"`
|
|
UpdatedAt pgtype.Timestamptz `json:"updated_at"`
|
|
}
|
|
|
|
type BotEmailBinding struct {
|
|
ID pgtype.UUID `json:"id"`
|
|
BotID pgtype.UUID `json:"bot_id"`
|
|
EmailProviderID pgtype.UUID `json:"email_provider_id"`
|
|
EmailAddress string `json:"email_address"`
|
|
CanRead bool `json:"can_read"`
|
|
CanWrite bool `json:"can_write"`
|
|
CanDelete bool `json:"can_delete"`
|
|
Config []byte `json:"config"`
|
|
CreatedAt pgtype.Timestamptz `json:"created_at"`
|
|
UpdatedAt pgtype.Timestamptz `json:"updated_at"`
|
|
}
|
|
|
|
type BotHeartbeatLog struct {
|
|
ID pgtype.UUID `json:"id"`
|
|
BotID pgtype.UUID `json:"bot_id"`
|
|
SessionID pgtype.UUID `json:"session_id"`
|
|
Status string `json:"status"`
|
|
ResultText string `json:"result_text"`
|
|
ErrorMessage string `json:"error_message"`
|
|
Usage []byte `json:"usage"`
|
|
ModelID pgtype.UUID `json:"model_id"`
|
|
StartedAt pgtype.Timestamptz `json:"started_at"`
|
|
CompletedAt pgtype.Timestamptz `json:"completed_at"`
|
|
}
|
|
|
|
type BotHistoryMessage struct {
|
|
ID pgtype.UUID `json:"id"`
|
|
BotID pgtype.UUID `json:"bot_id"`
|
|
SessionID pgtype.UUID `json:"session_id"`
|
|
SenderChannelIdentityID pgtype.UUID `json:"sender_channel_identity_id"`
|
|
SenderAccountUserID pgtype.UUID `json:"sender_account_user_id"`
|
|
SourceMessageID pgtype.Text `json:"source_message_id"`
|
|
SourceReplyToMessageID pgtype.Text `json:"source_reply_to_message_id"`
|
|
Role string `json:"role"`
|
|
Content []byte `json:"content"`
|
|
Metadata []byte `json:"metadata"`
|
|
Usage []byte `json:"usage"`
|
|
ModelID pgtype.UUID `json:"model_id"`
|
|
CreatedAt pgtype.Timestamptz `json:"created_at"`
|
|
}
|
|
|
|
type BotHistoryMessageAsset struct {
|
|
ID pgtype.UUID `json:"id"`
|
|
MessageID pgtype.UUID `json:"message_id"`
|
|
Role string `json:"role"`
|
|
Ordinal int32 `json:"ordinal"`
|
|
ContentHash string `json:"content_hash"`
|
|
Name string `json:"name"`
|
|
Metadata []byte `json:"metadata"`
|
|
CreatedAt pgtype.Timestamptz `json:"created_at"`
|
|
}
|
|
|
|
type BotSession struct {
|
|
ID pgtype.UUID `json:"id"`
|
|
BotID pgtype.UUID `json:"bot_id"`
|
|
RouteID pgtype.UUID `json:"route_id"`
|
|
ChannelType pgtype.Text `json:"channel_type"`
|
|
Type string `json:"type"`
|
|
Title string `json:"title"`
|
|
Metadata []byte `json:"metadata"`
|
|
CreatedAt pgtype.Timestamptz `json:"created_at"`
|
|
UpdatedAt pgtype.Timestamptz `json:"updated_at"`
|
|
DeletedAt pgtype.Timestamptz `json:"deleted_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 BrowserContext struct {
|
|
ID pgtype.UUID `json:"id"`
|
|
Name string `json:"name"`
|
|
Config []byte `json:"config"`
|
|
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"`
|
|
ChannelType string `json:"channel_type"`
|
|
ChannelSubjectID string `json:"channel_subject_id"`
|
|
DisplayName pgtype.Text `json:"display_name"`
|
|
AvatarUrl pgtype.Text `json:"avatar_url"`
|
|
Metadata []byte `json:"metadata"`
|
|
CreatedAt pgtype.Timestamptz `json:"created_at"`
|
|
UpdatedAt pgtype.Timestamptz `json:"updated_at"`
|
|
}
|
|
|
|
type ChannelIdentityBindCode struct {
|
|
ID pgtype.UUID `json:"id"`
|
|
Token string `json:"token"`
|
|
IssuedByUserID pgtype.UUID `json:"issued_by_user_id"`
|
|
ChannelType pgtype.Text `json:"channel_type"`
|
|
ExpiresAt pgtype.Timestamptz `json:"expires_at"`
|
|
UsedAt pgtype.Timestamptz `json:"used_at"`
|
|
UsedByChannelIdentityID pgtype.UUID `json:"used_by_channel_identity_id"`
|
|
CreatedAt pgtype.Timestamptz `json:"created_at"`
|
|
}
|
|
|
|
type Container struct {
|
|
ID pgtype.UUID `json:"id"`
|
|
BotID pgtype.UUID `json:"bot_id"`
|
|
ContainerID string `json:"container_id"`
|
|
ContainerName string `json:"container_name"`
|
|
Image string `json:"image"`
|
|
Status string `json:"status"`
|
|
Namespace string `json:"namespace"`
|
|
AutoStart bool `json:"auto_start"`
|
|
ContainerPath string `json:"container_path"`
|
|
CreatedAt pgtype.Timestamptz `json:"created_at"`
|
|
UpdatedAt pgtype.Timestamptz `json:"updated_at"`
|
|
LastStartedAt pgtype.Timestamptz `json:"last_started_at"`
|
|
LastStoppedAt pgtype.Timestamptz `json:"last_stopped_at"`
|
|
}
|
|
|
|
type ContainerVersion struct {
|
|
ID pgtype.UUID `json:"id"`
|
|
ContainerID string `json:"container_id"`
|
|
SnapshotID pgtype.UUID `json:"snapshot_id"`
|
|
Version int32 `json:"version"`
|
|
CreatedAt pgtype.Timestamptz `json:"created_at"`
|
|
}
|
|
|
|
type EmailOauthToken struct {
|
|
ID pgtype.UUID `json:"id"`
|
|
EmailProviderID pgtype.UUID `json:"email_provider_id"`
|
|
EmailAddress string `json:"email_address"`
|
|
AccessToken string `json:"access_token"`
|
|
RefreshToken string `json:"refresh_token"`
|
|
ExpiresAt pgtype.Timestamptz `json:"expires_at"`
|
|
Scope string `json:"scope"`
|
|
State string `json:"state"`
|
|
CreatedAt pgtype.Timestamptz `json:"created_at"`
|
|
UpdatedAt pgtype.Timestamptz `json:"updated_at"`
|
|
}
|
|
|
|
type EmailOutbox struct {
|
|
ID pgtype.UUID `json:"id"`
|
|
ProviderID pgtype.UUID `json:"provider_id"`
|
|
BotID pgtype.UUID `json:"bot_id"`
|
|
MessageID string `json:"message_id"`
|
|
FromAddress string `json:"from_address"`
|
|
ToAddresses []byte `json:"to_addresses"`
|
|
Subject string `json:"subject"`
|
|
BodyText string `json:"body_text"`
|
|
BodyHtml string `json:"body_html"`
|
|
Attachments []byte `json:"attachments"`
|
|
Status string `json:"status"`
|
|
Error string `json:"error"`
|
|
SentAt pgtype.Timestamptz `json:"sent_at"`
|
|
CreatedAt pgtype.Timestamptz `json:"created_at"`
|
|
}
|
|
|
|
type EmailProvider 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 LifecycleEvent struct {
|
|
ID string `json:"id"`
|
|
ContainerID string `json:"container_id"`
|
|
EventType string `json:"event_type"`
|
|
Payload []byte `json:"payload"`
|
|
CreatedAt pgtype.Timestamptz `json:"created_at"`
|
|
}
|
|
|
|
type LlmProvider struct {
|
|
ID pgtype.UUID `json:"id"`
|
|
Name string `json:"name"`
|
|
BaseUrl string `json:"base_url"`
|
|
ApiKey string `json:"api_key"`
|
|
Metadata []byte `json:"metadata"`
|
|
CreatedAt pgtype.Timestamptz `json:"created_at"`
|
|
UpdatedAt pgtype.Timestamptz `json:"updated_at"`
|
|
}
|
|
|
|
type McpConnection struct {
|
|
ID pgtype.UUID `json:"id"`
|
|
BotID pgtype.UUID `json:"bot_id"`
|
|
Name string `json:"name"`
|
|
Type string `json:"type"`
|
|
Config []byte `json:"config"`
|
|
IsActive bool `json:"is_active"`
|
|
Status string `json:"status"`
|
|
ToolsCache []byte `json:"tools_cache"`
|
|
LastProbedAt pgtype.Timestamptz `json:"last_probed_at"`
|
|
StatusMessage string `json:"status_message"`
|
|
AuthType string `json:"auth_type"`
|
|
CreatedAt pgtype.Timestamptz `json:"created_at"`
|
|
UpdatedAt pgtype.Timestamptz `json:"updated_at"`
|
|
}
|
|
|
|
type McpOauthToken struct {
|
|
ID pgtype.UUID `json:"id"`
|
|
ConnectionID pgtype.UUID `json:"connection_id"`
|
|
ResourceMetadataUrl string `json:"resource_metadata_url"`
|
|
AuthorizationServerUrl string `json:"authorization_server_url"`
|
|
AuthorizationEndpoint string `json:"authorization_endpoint"`
|
|
TokenEndpoint string `json:"token_endpoint"`
|
|
RegistrationEndpoint string `json:"registration_endpoint"`
|
|
ScopesSupported []string `json:"scopes_supported"`
|
|
ClientID string `json:"client_id"`
|
|
ClientSecret string `json:"client_secret"`
|
|
AccessToken string `json:"access_token"`
|
|
RefreshToken string `json:"refresh_token"`
|
|
TokenType string `json:"token_type"`
|
|
ExpiresAt pgtype.Timestamptz `json:"expires_at"`
|
|
Scope string `json:"scope"`
|
|
PkceCodeVerifier string `json:"pkce_code_verifier"`
|
|
StateParam string `json:"state_param"`
|
|
ResourceUri string `json:"resource_uri"`
|
|
RedirectUri string `json:"redirect_uri"`
|
|
CreatedAt pgtype.Timestamptz `json:"created_at"`
|
|
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 MemoryProvider struct {
|
|
ID pgtype.UUID `json:"id"`
|
|
Name string `json:"name"`
|
|
Provider string `json:"provider"`
|
|
Config []byte `json:"config"`
|
|
IsDefault bool `json:"is_default"`
|
|
CreatedAt pgtype.Timestamptz `json:"created_at"`
|
|
UpdatedAt pgtype.Timestamptz `json:"updated_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"`
|
|
ClientType pgtype.Text `json:"client_type"`
|
|
Dimensions pgtype.Int4 `json:"dimensions"`
|
|
InputModalities []string `json:"input_modalities"`
|
|
SupportsReasoning bool `json:"supports_reasoning"`
|
|
Type string `json:"type"`
|
|
CreatedAt pgtype.Timestamptz `json:"created_at"`
|
|
UpdatedAt pgtype.Timestamptz `json:"updated_at"`
|
|
}
|
|
|
|
type ModelVariant struct {
|
|
ID pgtype.UUID `json:"id"`
|
|
ModelUuid pgtype.UUID `json:"model_uuid"`
|
|
VariantID string `json:"variant_id"`
|
|
Weight int32 `json:"weight"`
|
|
Metadata []byte `json:"metadata"`
|
|
CreatedAt pgtype.Timestamptz `json:"created_at"`
|
|
UpdatedAt pgtype.Timestamptz `json:"updated_at"`
|
|
}
|
|
|
|
type Schedule struct {
|
|
ID pgtype.UUID `json:"id"`
|
|
Name string `json:"name"`
|
|
Description string `json:"description"`
|
|
Pattern string `json:"pattern"`
|
|
MaxCalls pgtype.Int4 `json:"max_calls"`
|
|
CurrentCalls int32 `json:"current_calls"`
|
|
CreatedAt pgtype.Timestamptz `json:"created_at"`
|
|
UpdatedAt pgtype.Timestamptz `json:"updated_at"`
|
|
Enabled bool `json:"enabled"`
|
|
Command string `json:"command"`
|
|
BotID pgtype.UUID `json:"bot_id"`
|
|
}
|
|
|
|
type ScheduleLog struct {
|
|
ID pgtype.UUID `json:"id"`
|
|
ScheduleID pgtype.UUID `json:"schedule_id"`
|
|
BotID pgtype.UUID `json:"bot_id"`
|
|
SessionID pgtype.UUID `json:"session_id"`
|
|
Status string `json:"status"`
|
|
ResultText string `json:"result_text"`
|
|
ErrorMessage string `json:"error_message"`
|
|
Usage []byte `json:"usage"`
|
|
ModelID pgtype.UUID `json:"model_id"`
|
|
StartedAt pgtype.Timestamptz `json:"started_at"`
|
|
CompletedAt pgtype.Timestamptz `json:"completed_at"`
|
|
}
|
|
|
|
type SearchProvider 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 Snapshot struct {
|
|
ID pgtype.UUID `json:"id"`
|
|
ContainerID string `json:"container_id"`
|
|
RuntimeSnapshotName string `json:"runtime_snapshot_name"`
|
|
DisplayName pgtype.Text `json:"display_name"`
|
|
ParentRuntimeSnapshotName pgtype.Text `json:"parent_runtime_snapshot_name"`
|
|
Snapshotter string `json:"snapshotter"`
|
|
Source string `json:"source"`
|
|
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"`
|
|
Description string `json:"description"`
|
|
CreatedAt pgtype.Timestamptz `json:"created_at"`
|
|
UpdatedAt pgtype.Timestamptz `json:"updated_at"`
|
|
Deleted bool `json:"deleted"`
|
|
DeletedAt pgtype.Timestamptz `json:"deleted_at"`
|
|
BotID pgtype.UUID `json:"bot_id"`
|
|
Messages []byte `json:"messages"`
|
|
Metadata []byte `json:"metadata"`
|
|
Skills []byte `json:"skills"`
|
|
Usage []byte `json:"usage"`
|
|
}
|
|
|
|
type TtsModel struct {
|
|
ID pgtype.UUID `json:"id"`
|
|
ModelID string `json:"model_id"`
|
|
Name pgtype.Text `json:"name"`
|
|
TtsProviderID pgtype.UUID `json:"tts_provider_id"`
|
|
Config []byte `json:"config"`
|
|
CreatedAt pgtype.Timestamptz `json:"created_at"`
|
|
UpdatedAt pgtype.Timestamptz `json:"updated_at"`
|
|
}
|
|
|
|
type TtsProvider 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 User struct {
|
|
ID pgtype.UUID `json:"id"`
|
|
Username pgtype.Text `json:"username"`
|
|
Email pgtype.Text `json:"email"`
|
|
PasswordHash pgtype.Text `json:"password_hash"`
|
|
Role string `json:"role"`
|
|
DisplayName pgtype.Text `json:"display_name"`
|
|
AvatarUrl pgtype.Text `json:"avatar_url"`
|
|
DataRoot pgtype.Text `json:"data_root"`
|
|
LastLoginAt pgtype.Timestamptz `json:"last_login_at"`
|
|
IsActive bool `json:"is_active"`
|
|
Metadata []byte `json:"metadata"`
|
|
CreatedAt pgtype.Timestamptz `json:"created_at"`
|
|
UpdatedAt pgtype.Timestamptz `json:"updated_at"`
|
|
}
|
|
|
|
type UserChannelBinding struct {
|
|
ID pgtype.UUID `json:"id"`
|
|
UserID pgtype.UUID `json:"user_id"`
|
|
ChannelType string `json:"channel_type"`
|
|
Config []byte `json:"config"`
|
|
CreatedAt pgtype.Timestamptz `json:"created_at"`
|
|
UpdatedAt pgtype.Timestamptz `json:"updated_at"`
|
|
}
|