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: agent_context_wakes.sql
package store
import (
"context"
)
const listAgentContextsWithWaitingRuns = `-- name: ListAgentContextsWithWaitingRuns :many
SELECT DISTINCT waiting.context_key::text AS context_key
FROM (
SELECT run.context_key FROM agent_local_runs run
WHERE run.status='queued' AND run.created_at<clock_timestamp()-interval '30 seconds'
AND NOT EXISTS (SELECT 1 FROM agent_local_runs active WHERE active.context_key=run.context_key AND active.status='running')
UNION ALL
SELECT input.context_key FROM agent_runtime_inputs input
WHERE input.status='steering' AND input.created_at<clock_timestamp()-interval '30 seconds'
AND input.selection_result->>'selected' IN ('trusted_inbox_notification','runtime_response')
) waiting
JOIN agent_execution_contexts context ON context.context_key=waiting.context_key AND context.terminal_reason IS NULL
ORDER BY 1
LIMIT 1000
`
// The fallback scan for lost run.queued and run.steered hints: Contexts whose
// queued Run has waited 30 seconds with nothing running, or whose Message
// steer has waited as long.
func (q *Queries) ListAgentContextsWithWaitingRuns(ctx context.Context) ([]string, error) {
rows, err := q.db.Query(ctx, listAgentContextsWithWaitingRuns)
if err != nil {
return nil, err
}
defer rows.Close()
items := []string{}
for rows.Next() {
var context_key string
if err := rows.Scan(&context_key); err != nil {
return nil, err
}
items = append(items, context_key)
}
if err := rows.Err(); err != nil {
return nil, err
}
return items, nil
}
const listPresencePreparableContextKeys = `-- name: ListPresencePreparableContextKeys :many
SELECT DISTINCT context.context_key
FROM agent_execution_contexts context
JOIN agent_registrations registration ON registration.agent_management_id = context.agent_management_id
WHERE context.context_key = ANY($1::text[])
AND context.context_kind = 'meta'
AND context.terminal_reason IS NULL
AND registration.status = 'active'
ORDER BY context.context_key
`
// Narrows authorized Inbox recipients to live Meta Contexts of active
// Agents. An active registration always runs on a Local Computer.
func (q *Queries) ListPresencePreparableContextKeys(ctx context.Context, contextKeys []string) ([]string, error) {
rows, err := q.db.Query(ctx, listPresencePreparableContextKeys, contextKeys)
if err != nil {
return nil, err
}
defer rows.Close()
items := []string{}
for rows.Next() {
var context_key string
if err := rows.Scan(&context_key); err != nil {
return nil, err
}
items = append(items, context_key)
}
if err := rows.Err(); err != nil {
return nil, err
}
return items, nil
}
const listRoomPresenceRecipients = `-- name: ListRoomPresenceRecipients :many
SELECT recipient.context_key::text AS context_key,recipient.agent_actor_id::text AS agent_actor_id
FROM agent_inbox_recipients('room:'||$1::text) recipient
ORDER BY recipient.context_key
`
type ListRoomPresenceRecipientsRow struct {
ContextKey string `json:"context_key"`
AgentActorID string `json:"agent_actor_id"`
}
// The Contexts the Room's next Message would reach. The single receive
// predicate stays authoritative, including membership epoch and participation.
func (q *Queries) ListRoomPresenceRecipients(ctx context.Context, roomID string) ([]ListRoomPresenceRecipientsRow, error) {
rows, err := q.db.Query(ctx, listRoomPresenceRecipients, roomID)
if err != nil {
return nil, err
}
defer rows.Close()
items := []ListRoomPresenceRecipientsRow{}
for rows.Next() {
var i ListRoomPresenceRecipientsRow
if err := rows.Scan(&i.ContextKey, &i.AgentActorID); err != nil {
return nil, err
}
items = append(items, i)
}
if err := rows.Err(); err != nil {
return nil, err
}
return items, nil
}