botagents

package
v0.20.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	RuntimeACP          = "acp"
	RuntimeCodex        = string(runtimekind.Codex)
	RuntimeClaudeCode   = string(runtimekind.ClaudeCode)
	MetadataProviderKey = "provider"
)

BotAgent runtimes: RuntimeACP is bot-agent-domain vocabulary (the ACP row kind, distinct from the session runtime "acp_agent"); the direct kinds are pinned to the shared runtime vocabulary — a direct agent's runtime IS its session runtime type.

Variables

View Source
var (
	ErrNotFound        = errors.New("bot agent not found")
	ErrNameTaken       = errors.New("bot agent name already taken")
	ErrInvalidRuntime  = errors.New("invalid bot agent runtime")
	ErrInvalidMetadata = errors.New("invalid bot agent metadata")
	ErrDefaultInUse    = errors.New("default bot agent cannot be disabled or deleted")
	ErrUnavailable     = errors.New("bot agent is unavailable")
	// ErrProviderDirectRuntime rejects new ACP agents for providers that now
	// run as direct runtimes (migration 0144 retired the old built-in rows).
	ErrProviderDirectRuntime = errors.New("this provider runs as a direct runtime; create the agent with runtime codex or claude-code")
)

Functions

func AcceptsCredential added in v0.20.0

func AcceptsCredential(agent BotAgent, authKind string) bool

func ValidateConfigurationWithStore added in v0.20.0

func ValidateConfigurationWithStore(agent BotAgent, botMetadata map[string]any, credentialAuthKind string) error

ValidateConfigurationWithStore validates the shared per-provider bot metadata without consulting the legacy metadata enabled flag. BotAgent.Enabled is the availability source of truth.

Types

type BotAgent

type BotAgent struct {
	ID      string `json:"id"`
	BotID   string `json:"bot_id"`
	Name    string `json:"name"`
	Runtime string `json:"runtime"`
	Enabled bool   `json:"enabled"`
	// AgentCredentialID points at the encrypted credential this instance uses;
	// empty means not connected (legacy metadata path).
	AgentCredentialID string         `json:"agent_credential_id,omitempty"`
	Metadata          map[string]any `json:"metadata"`
	// Dependency comes from the runtime driver at read time. It is not
	// persisted and is omitted for runtimes without a declaration (ACP).
	Dependency *DependencyRequirement `json:"dependency,omitempty"`
	CreatedAt  time.Time              `json:"created_at"`
	UpdatedAt  time.Time              `json:"updated_at"`
	DeletedAt  *time.Time             `json:"deleted_at,omitempty"`
}

BotAgent is a user-managed Agent entry attached to a bot. Native is the built-in fallback and is intentionally represented by the absence of a row.

type ConfigurationError

type ConfigurationError struct {
	Field string
}

func (*ConfigurationError) Error

func (e *ConfigurationError) Error() string

type CreateRequest

type CreateRequest struct {
	Name    string `json:"name"`
	Runtime string `json:"runtime"`
	// Enabled defaults to true when omitted. The web passes false for direct
	// runtimes so the dependency preflight runs before the agent goes live.
	Enabled  *bool          `json:"enabled,omitempty"`
	Metadata map[string]any `json:"metadata"`
}

type DependencyRequirement added in v0.20.0

type DependencyRequirement struct {
	DependencyID string `json:"dependency_id"`
}

DependencyRequirement names the managed workspace dependency a direct runtime needs. No version is declared: the dependency manager installs whatever version the user asks for (latest by default). The web preflight (POST /bots/{bot_id}/dependencies/preflight) keys on the id.

type Descriptor

type Descriptor struct {
	BotAgentID string
	Runtime    string
	Provider   string
}

Descriptor is the stable runtime selection projected into a session. The provider is temporary ACP compatibility metadata, not a first-class model.

func DescriptorFor

func DescriptorFor(agent BotAgent) (Descriptor, error)

type ListResponse

type ListResponse struct {
	Items []BotAgent `json:"items"`
}

type Service

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

func NewService

func NewService(log *slog.Logger, q queries) *Service

func (*Service) Create

func (s *Service) Create(ctx context.Context, botID string, req CreateRequest) (BotAgent, error)

func (*Service) Delete

func (s *Service) Delete(ctx context.Context, botID, id string, beforeCommit func(BotAgent) error) error

func (*Service) FindActiveByProvider

func (s *Service) FindActiveByProvider(ctx context.Context, botID, provider string) (BotAgent, error)

func (*Service) Get

func (s *Service) Get(ctx context.Context, botID, id string) (BotAgent, error)

func (*Service) GetActive

func (s *Service) GetActive(ctx context.Context, botID, id string) (BotAgent, error)

GetActive is used for new defaults and new sessions. Existing sessions may keep using Get so disabling an Agent does not terminate established work.

func (*Service) List

func (s *Service) List(ctx context.Context, botID string) ([]BotAgent, error)

func (*Service) SetCredentialResolver added in v0.20.0

func (s *Service) SetCredentialResolver(resolver func(ctx context.Context, botID, botAgentID string) string)

SetCredentialVerifier installs the per-instance decryptability check used by preflight. It must actually open the ciphertext: after a restart with a different-but-valid encryption key the credential row still exists and the key shape is fine, but every runtime start would fail — preflight has to fail the same way instead of deferring the error.

func (*Service) Update

func (s *Service) Update(ctx context.Context, botID, id string, req UpdateRequest) (BotAgent, error)

func (*Service) ValidateConfiguration added in v0.20.0

func (s *Service) ValidateConfiguration(ctx context.Context, agent BotAgent, botMetadata map[string]any) error

ValidateConfiguration is the credential-store-aware preflight; see the package-level ValidateConfigurationWithStore for the pure form.

type UpdateRequest

type UpdateRequest struct {
	Name     *string        `json:"name,omitempty"`
	Enabled  *bool          `json:"enabled,omitempty"`
	Metadata map[string]any `json:"metadata,omitempty"`
}

Jump to

Keyboard shortcuts

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