Documentation
¶
Index ¶
- Constants
- Variables
- func AcceptsCredential(agent BotAgent, authKind string) bool
- func SessionRuntime(runtime string) string
- func SignsInOnAgent(agent BotAgent) bool
- func ValidateConfigurationWithStore(agent BotAgent, botMetadata map[string]any, credentialAuthKind string) error
- type BotAgent
- type ConfigurationError
- type CreateRequest
- type DependencyRequirement
- type Descriptor
- type ListResponse
- type ProviderDirectRuntimeError
- type Service
- func (s *Service) Create(ctx context.Context, botID string, req CreateRequest) (BotAgent, error)
- func (s *Service) Delete(ctx context.Context, botID, id string, beforeCommit func(BotAgent) error) error
- func (s *Service) FindActiveByProvider(ctx context.Context, botID, provider string) (BotAgent, error)
- func (s *Service) Get(ctx context.Context, botID, id string) (BotAgent, error)
- func (s *Service) GetActive(ctx context.Context, botID, id string) (BotAgent, error)
- func (s *Service) GetActiveACP(ctx context.Context, botID, id, provider string) (BotAgent, error)
- func (s *Service) List(ctx context.Context, botID string) ([]BotAgent, error)
- func (s *Service) ResolveACPSetup(ctx context.Context, botID, botAgentID, provider string, ...) (acpprofile.AgentSetup, error)
- func (s *Service) SetCredentialResolver(resolver func(ctx context.Context, botID, botAgentID string) string)
- func (s *Service) Update(ctx context.Context, botID, id string, req UpdateRequest) (BotAgent, error)
- func (s *Service) ValidateConfiguration(ctx context.Context, agent BotAgent, botMetadata map[string]any) error
- type UpdateRequest
Constants ¶
const ( RuntimeACP = "acp" RuntimeCodex = string(runtimekind.Codex) RuntimeClaudeCode = string(runtimekind.ClaudeCode) RuntimeGrokBuild = string(runtimekind.GrokBuild) 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 ¶
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") // 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") )
Functions ¶
func AcceptsCredential ¶ added in v0.20.0
func SessionRuntime ¶ added in v0.22.0
SessionRuntime is the session runtime type an agent's turns dispatch to.
func SignsInOnAgent ¶ added in v1.0.2
SignsInOnAgent reports whether a direct Agent's auth mode is an account the Agent's own runtime signs in to, rather than a credential Memoh stores.
func ValidateConfigurationWithStore ¶ added in v0.20.0
func ValidateConfigurationWithStore(agent BotAgent, botMetadata map[string]any, credentialAuthKind string) error
ValidateConfigurationWithStore validates the instance's configuration 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"`
// ReportsQuota is decided at read time: the Agent's own account login
// reports its plan usage (GET .../quota).
ReportsQuota bool `json:"reports_quota,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.
func WithACPSetup ¶ added in v0.22.0
WithACPSetup fills in the managed fields an ACP instance launches with when it does not carry its own yet, so clients read one shape for every instance and saving it back is what gives a legacy instance its own setup.
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 ¶
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 ProviderDirectRuntimeError ¶ added in v0.22.0
type ProviderDirectRuntimeError struct{ Runtime string }
ProviderDirectRuntimeError carries the direct runtime a rejected ACP provider now runs as. It matches ErrProviderDirectRuntime.
func (*ProviderDirectRuntimeError) Error ¶ added in v0.22.0
func (e *ProviderDirectRuntimeError) Error() string
func (*ProviderDirectRuntimeError) Unwrap ¶ added in v0.22.0
func (*ProviderDirectRuntimeError) Unwrap() error
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
func NewService ¶
func (*Service) FindActiveByProvider ¶
func (*Service) GetActive ¶
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) GetActiveACP ¶ added in v0.22.0
GetActiveACP admits new work on an ACP instance of provider. ResolveACPSetup cannot do it: it also serves established sessions, which outlive their Agent being disabled or deleted.
func (*Service) ResolveACPSetup ¶ added in v0.22.0
func (s *Service) ResolveACPSetup(ctx context.Context, botID, botAgentID, provider string, botMetadata map[string]any) (acpprofile.AgentSetup, error)
ResolveACPSetup returns the setup an ACP session launches with. A session bound before agents became instances names only the provider and runs as the bot's oldest active instance of it; a bot with no instance at all still reads the legacy profile slot on its own metadata.
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) 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.