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.1 KB
Raw Blame
package agentruntimestate

import (
	"context"
	"errors"

	"github.com/simplexai-labs/linger/apps/teamhub/internal/store"
)

// RuntimeInteractionAuthority is who answers a native Runtime question of a
// live Context and whether its Run may still ask.
type RuntimeInteractionAuthority struct {
	SponsorActorID string
	RuntimeType    string
	Running        bool
}

// InteractionAuthority reads the authority of a native Runtime question. It
// reports pgx.ErrNoRows when the Context is terminated or unknown.
func (s *Service) InteractionAuthority(ctx context.Context, contextKey, runID string) (RuntimeInteractionAuthority, error) {
	row, err := store.New(s.pool).GetRuntimeInteractionAuthority(ctx, store.GetRuntimeInteractionAuthorityParams{
		ContextKey: contextKey, RunID: runID,
	})
	if err != nil {
		return RuntimeInteractionAuthority{}, err
	}
	if !row.LocalRuntimeType.Valid {
		return RuntimeInteractionAuthority{}, errors.New("Agent registration has no Runtime type")
	}
	return RuntimeInteractionAuthority{
		SponsorActorID: row.CreatedByActorID, RuntimeType: row.LocalRuntimeType.String, Running: row.Running,
	}, nil
}