Documentation
¶
Overview ¶
Package brain composes an agent session server with application-owned harnesses and tools. Session requests select installed implementations; they never install code.
Index ¶
- func Validate(o Options) error
- type BindingContext
- type Call
- type Config
- type Content
- type CreateSession
- type CredentialInput
- type CredentialKeys
- type Event
- type Grant
- type Handler
- type Harness
- type HarnessFactory
- type HarnessOptions
- type HarnessProvider
- type HostPool
- type HostPoolLimits
- type KeyConfig
- type Limits
- type ManagedTool
- type Media
- type Message
- type ModelContext
- type ModelCredential
- type ModelProvider
- type ModelRequest
- type ModelUsage
- type NativeFile
- type Options
- type Persistence
- type PiPlugin
- type ProcessConfig
- type ProcessFactory
- type ProviderUnavailable
- type Result
- type Server
- func (s *Server) DeleteSession(ctx context.Context, tenant, id string) error
- func (s *Server) Handler() http.Handler
- func (s *Server) ReadEvents(ctx context.Context, tenant, id, after string, limit int) ([]Event, error)
- func (s *Server) ReadSession(ctx context.Context, tenant, id string) (Session, error)
- func (s *Server) RevokeCredential(ctx context.Context, tenant, sessionID, binding string) error
- func (s *Server) RevokeModelCredential(ctx context.Context, tenant, sessionID string) error
- func (s *Server) RotateCredentials(ctx context.Context, tenant, sessionID string) error
- func (s *Server) Run(ctx context.Context) error
- func (s *Server) Serve(ctx context.Context, listener net.Listener) error
- func (s *Server) Shutdown(ctx context.Context) error
- type Session
- type SessionConfig
- type Token
- type Tool
- type ToolBinding
- type ToolProvider
- type ToolRequest
- type ToolScope
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type BindingContext ¶
type BindingContext = tools.BindingContext
type CreateSession ¶
type CreateSession = core.CreateSession
type CredentialInput ¶
type CredentialInput = core.CredentialInput
type CredentialKeys ¶
type CredentialKeys = credentials.Keys
type HarnessFactory ¶
type HarnessOptions ¶
type HarnessProvider ¶
type HostPool ¶
func NewHostPool ¶
func NewHostPool(limits HostPoolLimits) (*HostPool, error)
type HostPoolLimits ¶
type HostPoolLimits = harness.PoolLimits
type ManagedTool ¶
type ModelContext ¶
type ModelContext struct {
Tenant, Session, Model string
Credential *ModelCredential
}
ModelContext carries authenticated scope, never model-supplied arguments.
type ModelCredential ¶
type ModelCredential = core.ModelCredential
func APIKey ¶
func APIKey(value string) *ModelCredential
func CredentialReference ¶
func CredentialReference(value string) *ModelCredential
type ModelProvider ¶
type ModelProvider struct {
APIKey, BaseURL, API string
Authorize func(context.Context, ModelContext) error
Resolve func(context.Context, ModelContext) (string, error)
}
ModelProvider installs endpoint policy and an optional startup key. Authorize applies to defaults and overrides on admission and before each turn. Resolve resolves references in the supplied tenant scope; errors never select defaults.
func NewModelProvider ¶
func NewModelProvider(apiKey string) ModelProvider
type ModelRequest ¶
type ModelRequest = core.ModelRequest
type ModelUsage ¶
type ModelUsage = core.ModelUsage
type NativeFile ¶
type NativeFile = core.NativeFile
type Options ¶
type Options struct {
Config Config
Models map[string]ModelProvider
HostPool *HostPool
Tools []ManagedTool
Authenticate func(*http.Request) (Grant, bool)
Harnesses map[string]HarnessFactory
Providers map[string]ToolProvider
Keys CredentialKeys
Logger *slog.Logger
}
type Persistence ¶
type Persistence = persistence.Settings
type ProcessConfig ¶
type ProcessFactory ¶
type ProcessFactory = harness.ProcessFactory
func Codex ¶
func Codex(command []string) *ProcessFactory
func OpenCode ¶
func OpenCode(command []string) *ProcessFactory
type ProviderUnavailable ¶
type ProviderUnavailable = tools.Unavailable
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server owns opened resources. Call Shutdown even when serving through Handler.
func (*Server) DeleteSession ¶
func (*Server) ReadEvents ¶
func (*Server) ReadSession ¶
func (*Server) RevokeCredential ¶
func (*Server) RevokeModelCredential ¶
RevokeModelCredential retains a recovery tombstone like tool revocation.
func (*Server) RotateCredentials ¶
RotateCredentials re-encrypts live overrides using the application's active key. Keep old keys until every retained checkpoint that needs them has expired.
type SessionConfig ¶
type ToolBinding ¶
type ToolBinding = core.ToolBinding
type ToolProvider ¶
type ToolRequest ¶
Directories
¶
| Path | Synopsis |
|---|---|
|
cmd
|
|
|
brain
command
|
|
|
generate
command
Command generate derives wire declarations and OpenAPI from Go types/routes.
|
Command generate derives wire declarations and OpenAPI from Go types/routes. |
|
mcp-tools
command
mcp-tools discovers selected remote tools and prints static Brain bindings.
|
mcp-tools discovers selected remote tools and prints static Brain bindings. |
|
resource-tools
command
|
|
|
examples
|
|
|
application
command
A Brain application with a trusted, session-bound function provider.
|
A Brain application with a trusted, session-bound function provider. |
|
platforms/sessiontools
Package sessiontools is an example platform-owned session inspection policy.
|
Package sessiontools is an example platform-owned session inspection policy. |
|
tools
command
A separate local tool service.
|
A separate local tool service. |
|
Package integrations supplies optional managed provider constructors.
|
Package integrations supplies optional managed provider constructors. |
|
internal
|
|
|
api
Package api exposes authenticated sessions and event streams over HTTP.
|
Package api exposes authenticated sessions and event streams over HTTP. |
|
config
Package config validates host-owned configuration before opening a listener.
|
Package config validates host-owned configuration before opening a listener. |
|
core
Package core contains the public session and tool data shared by adapters.
|
Package core contains the public session and tool data shared by adapters. |
|
credentials
Package credentials encrypts private binding values before they reach storage.
|
Package credentials encrypts private binding values before they reach storage. |
|
harness
Package harness isolates native agent loops from the Brain coordinator.
|
Package harness isolates native agent loops from the Brain coordinator. |
|
persistence
Package persistence publishes immutable checkpoints outside the hot path.
|
Package persistence publishes immutable checkpoints outside the hot path. |
|
session
Package session coordinates local sessions without implementing an agent loop.
|
Package session coordinates local sessions without implementing an agent loop. |
|
store
Package store owns local metadata and append-only event files.
|
Package store owns local metadata and append-only event files. |
|
telemetry
Package telemetry configures bounded OpenTelemetry exporters and instruments.
|
Package telemetry configures bounded OpenTelemetry exporters and instruments. |
|
tools
Package tools validates and transports calls.
|
Package tools validates and transports calls. |
|
toolservice
Package toolservice implements optional external tools, outside the runtime.
|
Package toolservice implements optional external tools, outside the runtime. |