needs

package
v0.4.0-rc.21 Latest Latest
Warning

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

Go to latest
Published: Jul 6, 2026 License: AGPL-3.0 Imports: 13 Imported by: 0

Documentation

Overview

Package needs owns the agent-need → resource lifecycle for the sluggable resource types (connection, mcp_server, exec_endpoint): 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 CreateForNeed

func CreateForNeed(ctx context.Context, q *dbq.Queries, p authz.Principal, agentID uuid.UUID, typ, slug string) (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. Idempotent: if the need is already bound it returns the bound resource id without creating anything. Callers authorize before calling; this is the pure provisioning step shared by lazy create-on-configure and the explicit "set up a new resource" action.

Types

type Candidate

type Candidate struct {
	ResourceID uuid.UUID
	Name       string
	Slug       string
}

Candidate is a resource that could satisfy a need: shape-compatible and owned by a principal in the caller's grantee set.

type NeedInfo

type NeedInfo struct {
	Type            string
	Slug            string
	Description     string
	Bound           bool
	BoundResourceID uuid.UUID
}

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, logger *zap.Logger) *Service

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 to the need after verifying the caller may bind it (owns it via its grantee set) and that its shape matches the need.

func (*Service) CreateResourceForNeed

func (s *Service) CreateResourceForNeed(ctx context.Context, p authz.Principal, agentID uuid.UUID, typ, slug 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) 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.

Jump to

Keyboard shortcuts

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