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.

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

package store

import (
	"context"
)

const isRunStartedByDirectChatHuman = `-- name: IsRunStartedByDirectChatHuman :one
SELECT EXISTS (
  SELECT 1
  FROM agent_local_runs run
  JOIN agent_execution_contexts context ON context.context_key=run.context_key
  JOIN agent_local_run_inputs relation ON relation.run_id=run.run_id
  JOIN agent_runtime_inputs input
    ON input.context_key=relation.context_key AND input.input_id=relation.input_id
  JOIN messages message ON message.room_id=$1::text
   AND (input.source_message_id=message.id
        OR jsonb_typeof(input.payload->'invocationMessageIds')='array'
           AND input.payload->'invocationMessageIds' @> to_jsonb(message.id))
  WHERE run.run_id=$2::text AND run.status='running'
    AND run.status_room_id=$1::text
    AND context.tenant_id=$3::text
    AND context.agent_actor_id=$4::text
    AND message.author_actor_id=$5::text
    AND (
      message.message_kind='conversation' AND message.card_context_message_id IS NULL
      OR EXISTS (
        SELECT 1 FROM decisions decision
        WHERE decision.message_id=message.card_context_message_id
          AND decision.room_id=message.room_id
          AND decision.decided_by_actor_id=$5::text
      )
    )
)::boolean
`

type IsRunStartedByDirectChatHumanParams struct {
	RoomID       string `json:"room_id"`
	RunID        string `json:"run_id"`
	TenantID     string `json:"tenant_id"`
	AgentActorID string `json:"agent_actor_id"`
	HumanActorID string `json:"human_actor_id"`
}

// Whether the Agent's running Run in its direct chat carries something the
// Human did there: a Message they wrote, or the result of a card they
// decided themselves. TeamHub also writes Messages in the Human's name with a
// card's context, such as a reminder about a card still pending, so a card's
// context alone proves nothing; its decision must name the Human. Quiet
// wakes, Routine fires and Task callbacks carry neither. A Room input names
// the Messages it carries in payload invocationMessageIds.
func (q *Queries) IsRunStartedByDirectChatHuman(ctx context.Context, arg IsRunStartedByDirectChatHumanParams) (bool, error) {
	row := q.db.QueryRow(ctx, isRunStartedByDirectChatHuman,
		arg.RoomID,
		arg.RunID,
		arg.TenantID,
		arg.AgentActorID,
		arg.HumanActorID,
	)
	var column_1 bool
	err := row.Scan(&column_1)
	return column_1, err
}