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.

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

package store

import (
	"context"

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

const getRuntimeInteractionAuthority = `-- name: GetRuntimeInteractionAuthority :one
SELECT registration.created_by_actor_id,
       registration.local_runtime_type,
       EXISTS(
         SELECT 1 FROM agent_local_runs run
         WHERE run.run_id=$1::text AND run.context_key=$2::text
           AND run.status='running' AND NOT run.cancellation_requested
       )::boolean AS running
FROM agent_execution_contexts context
JOIN agent_registrations registration
  ON registration.actor_id=context.agent_actor_id AND registration.tenant_id=context.tenant_id
WHERE context.context_key=$2::text AND context.terminal_reason IS NULL
`

type GetRuntimeInteractionAuthorityParams struct {
	RunID      string `json:"run_id"`
	ContextKey string `json:"context_key"`
}

type GetRuntimeInteractionAuthorityRow struct {
	CreatedByActorID string      `json:"created_by_actor_id"`
	LocalRuntimeType pgtype.Text `json:"local_runtime_type"`
	Running          bool        `json:"running"`
}

// The Sponsor and Runtime of a live Context's Agent, and whether the Run is
// still running without a cancellation request.
func (q *Queries) GetRuntimeInteractionAuthority(ctx context.Context, arg GetRuntimeInteractionAuthorityParams) (GetRuntimeInteractionAuthorityRow, error) {
	row := q.db.QueryRow(ctx, getRuntimeInteractionAuthority, arg.RunID, arg.ContextKey)
	var i GetRuntimeInteractionAuthorityRow
	err := row.Scan(&i.CreatedByActorID, &i.LocalRuntimeType, &i.Running)
	return i, err
}