needs

package
v0.6.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 2, 2026 License: AGPL-3.0 Imports: 17 Imported by: 0

Documentation

Overview

Package needs owns the agent-need → resource lifecycle for connections and MCP servers: instantiating a resource from a need's declared shape, binding an existing resource to a need, and listing the resources that could satisfy a need.

A resource is always born from a need — the need's spec is the only source of the integration shape; a user supplies only credentials and ownership. So every create is "instantiate THIS need", never a freeform resource.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConnectionCompatible

func ConnectionCompatible(needSpec []byte, connection dbq.Connection) bool

ConnectionCompatible reports structural compatibility without considering OAuth scope readiness.

func CreateForNeed

func CreateForNeed(ctx context.Context, q *dbq.Queries, p authz.Principal, agentID uuid.UUID, typ, slug, displayName string, createNew bool) (uuid.UUID, error)

CreateForNeed instantiates the resource an agent's need declares — from the need's frozen spec — as a NEW resource owned by p, and binds it to the need. Unless createNew is set, an existing binding is targeted. createNew always instantiates a UUID-named resource and replaces the binding for non-OAuth resources; OAuth resources stay provisional until callback succeeds.

func MCPCompatible

func MCPCompatible(needSpec []byte, server dbq.AgentMcpServer) bool

MCPCompatible reports structural compatibility without considering OAuth scope readiness.

Types

type Candidate

type Candidate struct {
	ResourceID   uuid.UUID
	Name         string
	DisplayName  string
	Slug         string
	Readiness    string
	Authorized   bool
	Configured   bool
	AgentCount   int32
	Required     []string
	Missing      []string
	Capabilities []string
}

Candidate is a shape-compatible resource the caller may bind through ownership or a resource grant.

type ConnectorTargetGroupCandidate added in v0.6.1

type ConnectorTargetGroupCandidate struct {
	Group                      dbq.ConnectorTargetGroup
	MemberCount                int32
	ReadyMemberCount           int32
	CompatibleReadyMemberCount int32
	Eligible                   bool
	Reason                     string
}

type NeedInfo

type NeedInfo struct {
	Type                    string
	Slug                    string
	Description             string
	Bound                   bool
	BoundResourceID         uuid.UUID
	ConnectorContractID     string
	ConnectorCommands       []connectorssvc.Command
	ConnectorDirectories    []connectorssvc.Directory
	ConnectorMultiple       bool
	BoundConnectorID        uuid.UUID
	BoundConnectorGroupID   uuid.UUID
	BoundConnectorGroupName string
}

NeedInfo is one of an agent's declared needs and whether it's bound yet.

type Service

type Service struct {
	// contains filtered or unexported fields
}

Service exposes the operator-facing need lifecycle: create a resource for a need, bind an existing one, and list compatible candidates.

func NewService

func NewService(database *db.DB, refresh func(context.Context, uuid.UUID) error, logger *zap.Logger) *Service

func (*Service) BindConnectorGroup added in v0.6.1

func (s *Service) BindConnectorGroup(ctx context.Context, p authz.Principal, agentID uuid.UUID, slug string, groupID uuid.UUID) error

func (*Service) BindExisting

func (s *Service) BindExisting(ctx context.Context, p authz.Principal, agentID uuid.UUID, typ, slug string, resourceID uuid.UUID) error

BindExisting binds an existing resource after checking agent admin, resource bind capability, and shape compatibility in one transaction.

func (*Service) CreateResourceForNeed

func (s *Service) CreateResourceForNeed(ctx context.Context, p authz.Principal, agentID uuid.UUID, typ, slug, displayName string) (uuid.UUID, error)

CreateResourceForNeed instantiates a new resource for the need, owned by the caller, and binds it. Agent-admin gated.

func (*Service) ListCandidates

func (s *Service) ListCandidates(ctx context.Context, p authz.Principal, agentID uuid.UUID, typ, slug string) ([]Candidate, error)

ListCandidates returns the caller's resources (owned by its grantee set) whose frozen shape matches the need — the resources it can bind for reuse.

func (*Service) ListConnectorTargetGroupCandidates added in v0.6.1

func (s *Service) ListConnectorTargetGroupCandidates(ctx context.Context, p authz.Principal, agentID uuid.UUID, slug string) ([]ConnectorTargetGroupCandidate, error)

func (*Service) ListNeeds

func (s *Service) ListNeeds(ctx context.Context, p authz.Principal, agentID uuid.UUID) ([]NeedInfo, error)

ListNeeds returns the agent's declared resource needs and their binding status — the UI's entry point for wiring resources up. Member-readable.

func (*Service) Unbind

func (s *Service) Unbind(ctx context.Context, p authz.Principal, agentID uuid.UUID, typ, slug string) error

Unbind clears one need's binding without mutating or authorizing against the resource. The operation changes only the agent and requires agent admin.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL