Files
Memoh/internal/db/sqlc/history.sql.go
T
BBQ 6aebbe9279 feat: refactor User/Bot architecture and implement multi-channel gateway
Major changes:
1. Core Architecture: Decoupled Bots from Users. Bots now have independent lifecycles, member management (bot_members), and dedicated configurations.
2. Channel Gateway:
   - Implemented a unified Channel Manager supporting Feishu, Telegram, and Local (Web/CLI) adapters.
   - Added message processing pipeline to normalize interactions across different platforms.
   - Introduced a Contact system for identity binding and guest access policies.
3. Database & Tooling:
   - Consolidated all migrations into 0001_init with updated schema for bots, channels, and contacts.
   - Optimized sqlc.yaml to automatically track the migrations directory.
4. Agent Enhancements:
   - Introduced ToolContext to provide Agents with platform-aware execution capabilities (e.g., messaging, contact lookups).
   - Added tool logging and fallback mechanisms for toolChoice execution.
5. UI & Docs: Updated frontend stores, UI components, and Swagger documentation to align with the new Bot-centric model.
2026-02-04 23:49:50 +08:00

173 lines
4.0 KiB
Go

// Code generated by sqlc. DO NOT EDIT.
// versions:
// sqlc v1.30.0
// source: history.sql
package sqlc
import (
"context"
"github.com/jackc/pgx/v5/pgtype"
)
const createHistory = `-- name: CreateHistory :one
INSERT INTO history (bot_id, session_id, messages, skills, timestamp)
VALUES ($1, $2, $3, $4, $5)
RETURNING id, bot_id, session_id, messages, skills, timestamp
`
type CreateHistoryParams struct {
BotID pgtype.UUID `json:"bot_id"`
SessionID string `json:"session_id"`
Messages []byte `json:"messages"`
Skills []string `json:"skills"`
Timestamp pgtype.Timestamptz `json:"timestamp"`
}
func (q *Queries) CreateHistory(ctx context.Context, arg CreateHistoryParams) (History, error) {
row := q.db.QueryRow(ctx, createHistory,
arg.BotID,
arg.SessionID,
arg.Messages,
arg.Skills,
arg.Timestamp,
)
var i History
err := row.Scan(
&i.ID,
&i.BotID,
&i.SessionID,
&i.Messages,
&i.Skills,
&i.Timestamp,
)
return i, err
}
const deleteHistoryByBotSession = `-- name: DeleteHistoryByBotSession :exec
DELETE FROM history
WHERE bot_id = $1 AND session_id = $2
`
type DeleteHistoryByBotSessionParams struct {
BotID pgtype.UUID `json:"bot_id"`
SessionID string `json:"session_id"`
}
func (q *Queries) DeleteHistoryByBotSession(ctx context.Context, arg DeleteHistoryByBotSessionParams) error {
_, err := q.db.Exec(ctx, deleteHistoryByBotSession, arg.BotID, arg.SessionID)
return err
}
const deleteHistoryByID = `-- name: DeleteHistoryByID :exec
DELETE FROM history
WHERE id = $1
`
func (q *Queries) DeleteHistoryByID(ctx context.Context, id pgtype.UUID) error {
_, err := q.db.Exec(ctx, deleteHistoryByID, id)
return err
}
const getHistoryByID = `-- name: GetHistoryByID :one
SELECT id, bot_id, session_id, messages, skills, timestamp
FROM history
WHERE id = $1
`
func (q *Queries) GetHistoryByID(ctx context.Context, id pgtype.UUID) (History, error) {
row := q.db.QueryRow(ctx, getHistoryByID, id)
var i History
err := row.Scan(
&i.ID,
&i.BotID,
&i.SessionID,
&i.Messages,
&i.Skills,
&i.Timestamp,
)
return i, err
}
const listHistoryByBotSession = `-- name: ListHistoryByBotSession :many
SELECT id, bot_id, session_id, messages, skills, timestamp
FROM history
WHERE bot_id = $1 AND session_id = $2
ORDER BY timestamp DESC
LIMIT $3
`
type ListHistoryByBotSessionParams struct {
BotID pgtype.UUID `json:"bot_id"`
SessionID string `json:"session_id"`
Limit int32 `json:"limit"`
}
func (q *Queries) ListHistoryByBotSession(ctx context.Context, arg ListHistoryByBotSessionParams) ([]History, error) {
rows, err := q.db.Query(ctx, listHistoryByBotSession, arg.BotID, arg.SessionID, arg.Limit)
if err != nil {
return nil, err
}
defer rows.Close()
var items []History
for rows.Next() {
var i History
if err := rows.Scan(
&i.ID,
&i.BotID,
&i.SessionID,
&i.Messages,
&i.Skills,
&i.Timestamp,
); err != nil {
return nil, err
}
items = append(items, i)
}
if err := rows.Err(); err != nil {
return nil, err
}
return items, nil
}
const listHistoryByBotSessionSince = `-- name: ListHistoryByBotSessionSince :many
SELECT id, bot_id, session_id, messages, skills, timestamp
FROM history
WHERE bot_id = $1 AND session_id = $2 AND timestamp >= $3
ORDER BY timestamp ASC
`
type ListHistoryByBotSessionSinceParams struct {
BotID pgtype.UUID `json:"bot_id"`
SessionID string `json:"session_id"`
Timestamp pgtype.Timestamptz `json:"timestamp"`
}
func (q *Queries) ListHistoryByBotSessionSince(ctx context.Context, arg ListHistoryByBotSessionSinceParams) ([]History, error) {
rows, err := q.db.Query(ctx, listHistoryByBotSessionSince, arg.BotID, arg.SessionID, arg.Timestamp)
if err != nil {
return nil, err
}
defer rows.Close()
var items []History
for rows.Next() {
var i History
if err := rows.Scan(
&i.ID,
&i.BotID,
&i.SessionID,
&i.Messages,
&i.Skills,
&i.Timestamp,
); err != nil {
return nil, err
}
items = append(items, i)
}
if err := rows.Err(); err != nil {
return nil, err
}
return items, nil
}