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_progress.sql
package store
import (
"context"
"github.com/jackc/pgx/v5/pgtype"
)
const getActorLastRoomMessageAt = `-- name: GetActorLastRoomMessageAt :one
SELECT message.created_at FROM messages message
WHERE message.room_id=$1::text AND message.author_actor_id=$2::text
AND message.message_kind='conversation'
ORDER BY message.created_at DESC,message.id DESC
LIMIT 1
`
type GetActorLastRoomMessageAtParams struct {
RoomID string `json:"room_id"`
ActorID string `json:"actor_id"`
}
// When the actor last said something people see in the Room.
func (q *Queries) GetActorLastRoomMessageAt(ctx context.Context, arg GetActorLastRoomMessageAtParams) (pgtype.Timestamptz, error) {
row := q.db.QueryRow(ctx, getActorLastRoomMessageAt, arg.RoomID, arg.ActorID)
var created_at pgtype.Timestamptz
err := row.Scan(&created_at)
return created_at, err
}
const listCoordinatorActiveTasks = `-- name: ListCoordinatorActiveTasks :many
SELECT item.id AS task_id,item.title,coalesce(run.run_id,'')::text AS run_id
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
LEFT JOIN LATERAL (
SELECT latest.run_id FROM agent_execution_contexts context
JOIN agent_local_runs latest ON latest.context_key=context.context_key AND latest.status<>'queued'
WHERE context.context_kind='alter_ego' AND context.agent_actor_id=generation.result_agent_actor_id
AND context.task_id=item.id
ORDER BY latest.created_at DESC,latest.run_id DESC LIMIT 1
) run ON true
WHERE item.tenant_id=$1::text
AND item.kind='task'
AND item.archived_at IS NULL
AND item.task_execution_status IN ('running','waiting_for_approval')
AND generation.coordinator_context_key=$2::text
ORDER BY item.created_at,item.id
`
type ListCoordinatorActiveTasksParams struct {
TenantID string `json:"tenant_id"`
CoordinatorContextKey string `json:"coordinator_context_key"`
}
type ListCoordinatorActiveTasksRow struct {
TaskID string `json:"task_id"`
Title string `json:"title"`
RunID string `json:"run_id"`
}
// The Tasks one Meta Context coordinates that are still at work, oldest
// first, with the latest Run of each that has started.
func (q *Queries) ListCoordinatorActiveTasks(ctx context.Context, arg ListCoordinatorActiveTasksParams) ([]ListCoordinatorActiveTasksRow, error) {
rows, err := q.db.Query(ctx, listCoordinatorActiveTasks, arg.TenantID, arg.CoordinatorContextKey)
if err != nil {
return nil, err
}
defer rows.Close()
items := []ListCoordinatorActiveTasksRow{}
for rows.Next() {
var i ListCoordinatorActiveTasksRow
if err := rows.Scan(&i.TaskID, &i.Title, &i.RunID); err != nil {
return nil, err
}
items = append(items, i)
}
if err := rows.Err(); err != nil {
return nil, err
}
return items, nil
}
const listRunProgressEvents = `-- name: ListRunProgressEvents :many
SELECT progress.local_run_id,progress.event_type,progress.payload,progress.created_at,
coalesce(output.body,'')::text AS output_body
FROM (
SELECT event.local_run_id,event.event_type,event.payload,event.created_at,event.event_ordinal,
row_number() OVER (PARTITION BY event.local_run_id,event.event_type ORDER BY event.event_ordinal DESC) AS recency
FROM agent_runtime_status_events event
WHERE event.local_run_id=ANY($1::text[])
AND event.event_type IN ('status.changed','plan.updated','presentation.output_created')
) progress
LEFT JOIN messages output
ON progress.event_type='presentation.output_created' AND output.id=progress.payload->>'output_id'
WHERE (progress.event_type='status.changed' AND progress.recency<=24)
OR (progress.event_type='plan.updated' AND progress.recency=1)
OR (progress.event_type='presentation.output_created' AND progress.recency<=2)
ORDER BY progress.local_run_id,progress.event_ordinal
`
type ListRunProgressEventsRow struct {
LocalRunID string `json:"local_run_id"`
EventType string `json:"event_type"`
Payload []byte `json:"payload"`
CreatedAt pgtype.Timestamptz `json:"created_at"`
OutputBody string `json:"output_body"`
}
// What each Run reported: its latest status changes, latest plan and latest
// output Messages, oldest first.
func (q *Queries) ListRunProgressEvents(ctx context.Context, runIds []string) ([]ListRunProgressEventsRow, error) {
rows, err := q.db.Query(ctx, listRunProgressEvents, runIds)
if err != nil {
return nil, err
}
defer rows.Close()
items := []ListRunProgressEventsRow{}
for rows.Next() {
var i ListRunProgressEventsRow
if err := rows.Scan(
&i.LocalRunID,
&i.EventType,
&i.Payload,
&i.CreatedAt,
&i.OutputBody,
); err != nil {
return nil, err
}
items = append(items, i)
}
if err := rows.Err(); err != nil {
return nil, err
}
return items, nil
}