agents

package
v1.3.1 Latest Latest
Warning

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

Go to latest
Published: May 12, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package agents handles agent identity registration, token issuance, and lifecycle management.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Agent

type Agent struct {
	ID          string     `json:"id"`
	Name        string     `json:"name"`
	WorkspaceID string     `json:"workspace_id"`
	ProjectID   *string    `json:"project_id,omitempty"`
	CreatedAt   time.Time  `json:"created_at"`
	TokenCount  int        `json:"token_count"`
	LastUsed    *time.Time `json:"last_used"`
}

Agent represents a registered agent identity.

type IssueTokenRequest

type IssueTokenRequest struct {
	Environment string `json:"environment,omitempty"`
	Label       string `json:"label,omitempty"`
	ExpiresIn   string `json:"expires_in,omitempty"`
}

IssueTokenRequest holds data to issue a new token.

type IssueTokenResponse

type IssueTokenResponse struct {
	TokenID   string     `json:"token_id"`
	Token     string     `json:"token"` // The cleartext token
	Label     string     `json:"label,omitempty"`
	ExpiresAt *time.Time `json:"expires_at,omitempty"`
}

IssueTokenResponse is returned when issuing a new token.

type RegisterRequest

type RegisterRequest struct {
	Name        string `json:"name"`
	WorkspaceID string `json:"-"` // used for routing, not sent in body
	ProjectID   string `json:"project_id,omitempty"`
	Environment string `json:"environment,omitempty"` // development, staging, production
	Label       string `json:"label,omitempty"`
	ExpiresIn   string `json:"expires_in,omitempty"` // e.g., "30d"
}

RegisterRequest holds data to register a new agent.

type RegisterResponse

type RegisterResponse struct {
	Agent     Agent      `json:"agent"`
	Token     string     `json:"token"` // The cleartext token (only shown once)
	Label     string     `json:"label,omitempty"`
	ExpiresAt *time.Time `json:"expires_at,omitempty"`
}

RegisterResponse is returned when registering a new agent (contains the cleartext token).

type Service

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

Service provides methods to interact with agent resources.

func NewService

func NewService(client *api.Client) *Service

func (*Service) Delete

func (s *Service) Delete(workspaceID, registrationID string) error

Delete revokes all tokens for an agent then deletes the registration. This first revokes all active tokens then issues a DELETE to the workspace agent route.

func (*Service) GetByName

func (s *Service) GetByName(workspaceID, name string) (*Agent, error)

GetByName returns an agent by its exact name within the given workspace.

func (*Service) List

func (s *Service) List(workspaceID, projectID string) ([]Agent, error)

List returns agents scoped to the given workspace (or project if projectID is non-empty).

func (*Service) Register

func (s *Service) Register(req RegisterRequest) (*RegisterResponse, error)

Register registers a new agent and issues its first token. req.WorkspaceID is required; set req.ProjectID to scope the agent to a project.

func (*Service) TokenIssue

func (s *Service) TokenIssue(workspaceID, registrationID string, req IssueTokenRequest) (*IssueTokenResponse, error)

TokenIssue issues a new token for an existing agent.

func (*Service) TokenList

func (s *Service) TokenList(workspaceID, registrationID string) ([]Token, error)

TokenList lists all tokens for an agent.

func (*Service) TokenRevoke

func (s *Service) TokenRevoke(workspaceID, registrationID string, tokenID string) error

TokenRevoke revokes a single token.

func (*Service) TokenRevokeAll

func (s *Service) TokenRevokeAll(workspaceID, registrationID string) error

TokenRevokeAll revokes all active tokens for an agent by listing then deleting each.

type Token

type Token struct {
	ID        string     `json:"id"`
	AgentID   string     `json:"agent_id"`
	Label     string     `json:"label"`
	CreatedAt time.Time  `json:"created_at"`
	ExpiresAt *time.Time `json:"expires_at,omitempty"`
	LastUsed  *time.Time `json:"last_used,omitempty"`
	Status    string     `json:"status"` // e.g., "active", "revoked", "expired"
}

Token represents a token issued to an agent.

Jump to

Keyboard shortcuts

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