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.
// Code generated by sqlc. DO NOT EDIT.
// versions:
// sqlc v1.29.0
// source: task_meta_inbox.sql
package store
import (
"context"
"github.com/jackc/pgx/v5/pgtype"
)
const createTaskMetaMessage = `-- name: CreateTaskMetaMessage :one
INSERT INTO task_meta_messages(
id,tenant_id,task_id,agent_actor_id,meta_seq,author_actor_id,body,segments,source
)
VALUES($1,$2,$3,$4,$5,$6,$7,$8,$9)
RETURNING id,tenant_id,task_id,agent_actor_id,meta_seq,author_actor_id,body,segments,created_at,source
`
type CreateTaskMetaMessageParams struct {
ID string `json:"id"`
TenantID string `json:"tenant_id"`
TaskID string `json:"task_id"`
AgentActorID string `json:"agent_actor_id"`
MetaSeq int64 `json:"meta_seq"`
AuthorActorID string `json:"author_actor_id"`
Body string `json:"body"`
Segments []byte `json:"segments"`
Source string `json:"source"`
}
func (q *Queries) CreateTaskMetaMessage(ctx context.Context, arg CreateTaskMetaMessageParams) (TaskMetaMessage, error) {
row := q.db.QueryRow(ctx, createTaskMetaMessage,
arg.ID,
arg.TenantID,
arg.TaskID,
arg.AgentActorID,
arg.MetaSeq,
arg.AuthorActorID,
arg.Body,
arg.Segments,
arg.Source,
)
var i TaskMetaMessage
err := row.Scan(
&i.ID,
&i.TenantID,
&i.TaskID,
&i.AgentActorID,
&i.MetaSeq,
&i.AuthorActorID,
&i.Body,
&i.Segments,
&i.CreatedAt,
&i.Source,
)
return i, err
}
const ensureTaskMetaInbox = `-- name: EnsureTaskMetaInbox :exec
INSERT INTO task_meta_inboxes(task_id,tenant_id,agent_actor_id)
VALUES($1,$2,$3)
ON CONFLICT(task_id,agent_actor_id) DO NOTHING
`
type EnsureTaskMetaInboxParams struct {
TaskID string `json:"task_id"`
TenantID string `json:"tenant_id"`
AgentActorID string `json:"agent_actor_id"`
}
func (q *Queries) EnsureTaskMetaInbox(ctx context.Context, arg EnsureTaskMetaInboxParams) error {
_, err := q.db.Exec(ctx, ensureTaskMetaInbox, arg.TaskID, arg.TenantID, arg.AgentActorID)
return err
}
const getTaskMetaInboxForUpdate = `-- name: GetTaskMetaInboxForUpdate :one
SELECT task_id,tenant_id,agent_actor_id,through_seq,created_at,updated_at
FROM task_meta_inboxes
WHERE task_id=$1 AND tenant_id=$2 AND agent_actor_id=$3
FOR UPDATE
`
type GetTaskMetaInboxForUpdateParams struct {
TaskID string `json:"task_id"`
TenantID string `json:"tenant_id"`
AgentActorID string `json:"agent_actor_id"`
}
func (q *Queries) GetTaskMetaInboxForUpdate(ctx context.Context, arg GetTaskMetaInboxForUpdateParams) (TaskMetaInbox, error) {
row := q.db.QueryRow(ctx, getTaskMetaInboxForUpdate, arg.TaskID, arg.TenantID, arg.AgentActorID)
var i TaskMetaInbox
err := row.Scan(
&i.TaskID,
&i.TenantID,
&i.AgentActorID,
&i.ThroughSeq,
&i.CreatedAt,
&i.UpdatedAt,
)
return i, err
}
const listTaskConversationCards = `-- name: ListTaskConversationCards :many
SELECT id,room_id,message_id,created_at
FROM decisions
WHERE tenant_id=$1::text AND alter_ego_task_id=$2::text
ORDER BY created_at,id
LIMIT 200
`
type ListTaskConversationCardsParams struct {
TenantID string `json:"tenant_id"`
TaskID string `json:"task_id"`
}
type ListTaskConversationCardsRow struct {
ID string `json:"id"`
RoomID string `json:"room_id"`
MessageID string `json:"message_id"`
CreatedAt pgtype.Timestamptz `json:"created_at"`
}
// Every card the Task's AlterEgo raised, answered or not, by its card Message.
func (q *Queries) ListTaskConversationCards(ctx context.Context, arg ListTaskConversationCardsParams) ([]ListTaskConversationCardsRow, error) {
rows, err := q.db.Query(ctx, listTaskConversationCards, arg.TenantID, arg.TaskID)
if err != nil {
return nil, err
}
defer rows.Close()
items := []ListTaskConversationCardsRow{}
for rows.Next() {
var i ListTaskConversationCardsRow
if err := rows.Scan(
&i.ID,
&i.RoomID,
&i.MessageID,
&i.CreatedAt,
); err != nil {
return nil, err
}
items = append(items, i)
}
if err := rows.Err(); err != nil {
return nil, err
}
return items, nil
}
const listTaskConversationInputs = `-- name: ListTaskConversationInputs :many
SELECT message.id,message.author_actor_id,author.kind AS author_kind,
author.display_name AS author_display_name,message.body,message.source,message.created_at
FROM work_items item
JOIN task_execution_generations generation
ON generation.task_id=item.id AND generation.tenant_id=item.tenant_id
AND generation.generation=item.task_execution_generation
JOIN task_meta_messages message
ON message.task_id=item.id AND message.tenant_id=item.tenant_id
AND message.agent_actor_id=generation.result_agent_actor_id
JOIN actors author ON author.id=message.author_actor_id AND author.tenant_id=message.tenant_id
WHERE item.id=$1::text
ORDER BY message.meta_seq
LIMIT 500
`
type ListTaskConversationInputsRow struct {
ID string `json:"id"`
AuthorActorID string `json:"author_actor_id"`
AuthorKind string `json:"author_kind"`
AuthorDisplayName string `json:"author_display_name"`
Body string `json:"body"`
Source string `json:"source"`
CreatedAt pgtype.Timestamptz `json:"created_at"`
}
// Every input the Task's result Agent received, in delivery order. Other
// participants' inboxes hold their own copies, which are left out.
func (q *Queries) ListTaskConversationInputs(ctx context.Context, taskID string) ([]ListTaskConversationInputsRow, error) {
rows, err := q.db.Query(ctx, listTaskConversationInputs, taskID)
if err != nil {
return nil, err
}
defer rows.Close()
items := []ListTaskConversationInputsRow{}
for rows.Next() {
var i ListTaskConversationInputsRow
if err := rows.Scan(
&i.ID,
&i.AuthorActorID,
&i.AuthorKind,
&i.AuthorDisplayName,
&i.Body,
&i.Source,
&i.CreatedAt,
); err != nil {
return nil, err
}
items = append(items, i)
}
if err := rows.Err(); err != nil {
return nil, err
}
return items, nil
}
const setTaskMetaInboxThroughSeq = `-- name: SetTaskMetaInboxThroughSeq :execrows
UPDATE task_meta_inboxes
SET through_seq=$4,updated_at=now()
WHERE task_id=$1 AND tenant_id=$2 AND agent_actor_id=$3 AND through_seq<$4
`
type SetTaskMetaInboxThroughSeqParams struct {
TaskID string `json:"task_id"`
TenantID string `json:"tenant_id"`
AgentActorID string `json:"agent_actor_id"`
ThroughSeq int64 `json:"through_seq"`
}
func (q *Queries) SetTaskMetaInboxThroughSeq(ctx context.Context, arg SetTaskMetaInboxThroughSeqParams) (int64, error) {
result, err := q.db.Exec(ctx, setTaskMetaInboxThroughSeq,
arg.TaskID,
arg.TenantID,
arg.AgentActorID,
arg.ThroughSeq,
)
if err != nil {
return 0, err
}
return result.RowsAffected(), nil
}