Skip to content

Linger is An Open-Source Personal Agent That Runs Fully on Your PC. We aim to break Big Tech’s grip on AI by bringing powerful local AI to everyday computers through efficient model–harness co-design, so everyone can run their own.

3.7 KB
Raw Blame
// Code generated by sqlc. DO NOT EDIT.
// versions:
//   sqlc v1.29.0
// source: agent_send_message.sql

package store

import (
	"context"

	"github.com/jackc/pgx/v5/pgtype"
)

const getAgentSendMessageReplayMessage = `-- name: GetAgentSendMessageReplayMessage :one
SELECT message.id
FROM messages message
WHERE message.id=$1::text
  AND message.tenant_id=$2::text
  AND message.room_id=$3::text
  AND message.author_actor_id=$4::text
`

type GetAgentSendMessageReplayMessageParams struct {
	MessageID    string `json:"message_id"`
	TenantID     string `json:"tenant_id"`
	RoomID       string `json:"room_id"`
	AgentActorID string `json:"agent_actor_id"`
}

func (q *Queries) GetAgentSendMessageReplayMessage(ctx context.Context, arg GetAgentSendMessageReplayMessageParams) (string, error) {
	row := q.db.QueryRow(ctx, getAgentSendMessageReplayMessage,
		arg.MessageID,
		arg.TenantID,
		arg.RoomID,
		arg.AgentActorID,
	)
	var id string
	err := row.Scan(&id)
	return id, err
}

const getAgentSendMessageThreadRoom = `-- name: GetAgentSendMessageThreadRoom :one
SELECT thread_room.id AS room_id,
       thread_room.parent_room_id::text AS parent_room_id,
       thread_room.tenant_id,
       actor.id AS agent_id,
       actor.kind AS agent_kind,
       actor.display_name AS agent_display_name,
       actor.account_id AS agent_account_id,
       actor.handle AS agent_handle,
       actor.created_at AS agent_created_at
FROM rooms thread_room
JOIN room_members membership
  ON membership.room_id=thread_room.parent_room_id
 AND membership.tenant_id=thread_room.tenant_id
JOIN actors actor
  ON actor.id=membership.actor_id
 AND actor.tenant_id=thread_room.tenant_id
WHERE thread_room.id=$1::text
  AND thread_room.tenant_id=$2::text
  AND thread_room.parent_room_id IS NOT NULL
  AND thread_room.deletion_started_at IS NULL
  AND thread_room.deleted_at IS NULL
  AND membership.actor_id=$3::text
  AND actor.kind='agent'
  AND (
      EXISTS (
          SELECT 1
          FROM messages root
          WHERE root.id=thread_room.root_message_id
            AND root.room_id=thread_room.parent_room_id
            AND root.tenant_id=thread_room.tenant_id
            AND root.author_actor_id=membership.actor_id
      ) OR EXISTS (
          SELECT 1
          FROM thread_room_list_actors listed
          WHERE listed.thread_room_id=thread_room.id
            AND listed.actor_id=membership.actor_id
            AND listed.tenant_id=thread_room.tenant_id
      )
  )
FOR SHARE OF thread_room,membership
`

type GetAgentSendMessageThreadRoomParams struct {
	ThreadID     string `json:"thread_id"`
	TenantID     string `json:"tenant_id"`
	AgentActorID string `json:"agent_actor_id"`
}

type GetAgentSendMessageThreadRoomRow struct {
	RoomID           string             `json:"room_id"`
	ParentRoomID     string             `json:"parent_room_id"`
	TenantID         string             `json:"tenant_id"`
	AgentID          string             `json:"agent_id"`
	AgentKind        string             `json:"agent_kind"`
	AgentDisplayName string             `json:"agent_display_name"`
	AgentAccountID   pgtype.Text        `json:"agent_account_id"`
	AgentHandle      pgtype.Text        `json:"agent_handle"`
	AgentCreatedAt   pgtype.Timestamptz `json:"agent_created_at"`
}

func (q *Queries) GetAgentSendMessageThreadRoom(ctx context.Context, arg GetAgentSendMessageThreadRoomParams) (GetAgentSendMessageThreadRoomRow, error) {
	row := q.db.QueryRow(ctx, getAgentSendMessageThreadRoom, arg.ThreadID, arg.TenantID, arg.AgentActorID)
	var i GetAgentSendMessageThreadRoomRow
	err := row.Scan(
		&i.RoomID,
		&i.ParentRoomID,
		&i.TenantID,
		&i.AgentID,
		&i.AgentKind,
		&i.AgentDisplayName,
		&i.AgentAccountID,
		&i.AgentHandle,
		&i.AgentCreatedAt,
	)
	return i, err
}