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.

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

package store

import (
	"context"

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

const getAnotherMeChat = `-- name: GetAnotherMeChat :one
SELECT registration.actor_id AS agent_actor_id,room.id AS room_id
FROM agent_registrations registration
LEFT JOIN rooms room
  ON room.tenant_id=registration.tenant_id
 AND room.direct_human_actor_id=registration.represented_human_actor_id
 AND room.direct_agent_actor_id=registration.actor_id
 AND room.deletion_started_at IS NULL
WHERE registration.tenant_id=$1::text
  AND registration.represented_human_actor_id=$2::text
  AND registration.agent_type='anotherme'
  AND registration.status='active'
`

type GetAnotherMeChatParams struct {
	TenantID     string `json:"tenant_id"`
	HumanActorID string `json:"human_actor_id"`
}

type GetAnotherMeChatRow struct {
	AgentActorID string      `json:"agent_actor_id"`
	RoomID       pgtype.Text `json:"room_id"`
}

// The Human's Another Me and its live direct Room with them. The Room is
// absent while the pair has no live Room.
func (q *Queries) GetAnotherMeChat(ctx context.Context, arg GetAnotherMeChatParams) (GetAnotherMeChatRow, error) {
	row := q.db.QueryRow(ctx, getAnotherMeChat, arg.TenantID, arg.HumanActorID)
	var i GetAnotherMeChatRow
	err := row.Scan(&i.AgentActorID, &i.RoomID)
	return i, err
}

const getAnotherMeRegistration = `-- name: GetAnotherMeRegistration :one
SELECT registration.actor_id,registration.tenant_id,registration.agent_management_id,registration.status,
       registration.instructions,registration.runtime_model,registration.created_by_actor_id,
       registration.created_at,registration.updated_at,registration.computer_id,
       registration.local_runtime_type,registration.workspace_grant_id,registration.visibility_scope,
       registration.description,registration.configuration_revision,registration.agent_type,
       registration.represented_human_actor_id,
       registration.user_artifact_owner_actor_id,registration.runtime_reasoning_effort,
       registration.avatar_key,registration.runtime_configuration_revision,registration.assignment_revision
FROM agent_registrations registration
WHERE registration.tenant_id=$1::text
  AND registration.represented_human_actor_id=$2::text
  AND registration.agent_type='anotherme'
  AND registration.status='active'
`

type GetAnotherMeRegistrationParams struct {
	TenantID                string `json:"tenant_id"`
	RepresentedHumanActorID string `json:"represented_human_actor_id"`
}

type GetAnotherMeRegistrationRow struct {
	ActorID                      string             `json:"actor_id"`
	TenantID                     string             `json:"tenant_id"`
	AgentManagementID            pgtype.Text        `json:"agent_management_id"`
	Status                       string             `json:"status"`
	Instructions                 string             `json:"instructions"`
	RuntimeModel                 string             `json:"runtime_model"`
	CreatedByActorID             string             `json:"created_by_actor_id"`
	CreatedAt                    pgtype.Timestamptz `json:"created_at"`
	UpdatedAt                    pgtype.Timestamptz `json:"updated_at"`
	ComputerID                   pgtype.Text        `json:"computer_id"`
	LocalRuntimeType             pgtype.Text        `json:"local_runtime_type"`
	WorkspaceGrantID             pgtype.Text        `json:"workspace_grant_id"`
	VisibilityScope              string             `json:"visibility_scope"`
	Description                  string             `json:"description"`
	ConfigurationRevision        int64              `json:"configuration_revision"`
	AgentType                    string             `json:"agent_type"`
	RepresentedHumanActorID      pgtype.Text        `json:"represented_human_actor_id"`
	UserArtifactOwnerActorID     pgtype.Text        `json:"user_artifact_owner_actor_id"`
	RuntimeReasoningEffort       pgtype.Text        `json:"runtime_reasoning_effort"`
	AvatarKey                    pgtype.Text        `json:"avatar_key"`
	RuntimeConfigurationRevision int64              `json:"runtime_configuration_revision"`
	AssignmentRevision           int64              `json:"assignment_revision"`
}

func (q *Queries) GetAnotherMeRegistration(ctx context.Context, arg GetAnotherMeRegistrationParams) (GetAnotherMeRegistrationRow, error) {
	row := q.db.QueryRow(ctx, getAnotherMeRegistration, arg.TenantID, arg.RepresentedHumanActorID)
	var i GetAnotherMeRegistrationRow
	err := row.Scan(
		&i.ActorID,
		&i.TenantID,
		&i.AgentManagementID,
		&i.Status,
		&i.Instructions,
		&i.RuntimeModel,
		&i.CreatedByActorID,
		&i.CreatedAt,
		&i.UpdatedAt,
		&i.ComputerID,
		&i.LocalRuntimeType,
		&i.WorkspaceGrantID,
		&i.VisibilityScope,
		&i.Description,
		&i.ConfigurationRevision,
		&i.AgentType,
		&i.RepresentedHumanActorID,
		&i.UserArtifactOwnerActorID,
		&i.RuntimeReasoningEffort,
		&i.AvatarKey,
		&i.RuntimeConfigurationRevision,
		&i.AssignmentRevision,
	)
	return i, err
}

const listAnotherMePlacements = `-- name: ListAnotherMePlacements :many
SELECT registration.tenant_id,
       registration.represented_human_actor_id::text AS owner_actor_id,
       registration.agent_management_id::text AS agent_id,
       registration.actor_id AS agent_actor_id,
       registration.computer_id::text AS computer_id,
       registration.local_runtime_type::text AS local_runtime_type,
       registration.status
FROM agent_registrations registration
WHERE registration.agent_type='anotherme'
  AND registration.status='active'
  AND registration.represented_human_actor_id IS NOT NULL
  AND registration.agent_management_id IS NOT NULL
  AND registration.computer_id IS NOT NULL
  AND registration.local_runtime_type IS NOT NULL
  AND ($1::text='' OR registration.tenant_id=$1::text)
  AND ($2::text='' OR registration.represented_human_actor_id=$2::text)
ORDER BY registration.tenant_id,registration.represented_human_actor_id
LIMIT 1000
`

type ListAnotherMePlacementsParams struct {
	TenantID     string `json:"tenant_id"`
	OwnerActorID string `json:"owner_actor_id"`
}

type ListAnotherMePlacementsRow struct {
	TenantID         string `json:"tenant_id"`
	OwnerActorID     string `json:"owner_actor_id"`
	AgentID          string `json:"agent_id"`
	AgentActorID     string `json:"agent_actor_id"`
	ComputerID       string `json:"computer_id"`
	LocalRuntimeType string `json:"local_runtime_type"`
	Status           string `json:"status"`
}

// The Agent Service runs a Human's background model calls on the Computer of
// that Human's Another Me. An empty filter matches every tenant or owner.
func (q *Queries) ListAnotherMePlacements(ctx context.Context, arg ListAnotherMePlacementsParams) ([]ListAnotherMePlacementsRow, error) {
	rows, err := q.db.Query(ctx, listAnotherMePlacements, arg.TenantID, arg.OwnerActorID)
	if err != nil {
		return nil, err
	}
	defer rows.Close()
	items := []ListAnotherMePlacementsRow{}
	for rows.Next() {
		var i ListAnotherMePlacementsRow
		if err := rows.Scan(
			&i.TenantID,
			&i.OwnerActorID,
			&i.AgentID,
			&i.AgentActorID,
			&i.ComputerID,
			&i.LocalRuntimeType,
			&i.Status,
		); err != nil {
			return nil, err
		}
		items = append(items, i)
	}
	if err := rows.Err(); err != nil {
		return nil, err
	}
	return items, nil
}