Documentation
¶
Overview ¶
Package runtime builds and manages Hector agents from configuration.
The runtime is the bridge between declarative config and live agents. It creates LLM providers, tools, and agents based on the configuration.
Index ¶
- func DefaultEmbedderFactory(cfg *config.EmbedderConfig) (embedder.Embedder, error)
- func DefaultLLMFactory(cfg *config.LLMConfig) (model.LLM, error)
- func DefaultToolsetFactory(name string, cfg *config.ToolConfig) (tool.Toolset, error)
- func DefaultWorkingMemoryFactory(opts WorkingMemoryFactoryOptions) (memory.WorkingMemoryStrategy, error)
- type Builder
- func (b *Builder) Build() (*Runtime, error)
- func (b *Builder) WithAgent(name string, ag agent.Agent) *Builder
- func (b *Builder) WithAgentTools(agentName string, agentTools []agent.Agent) *Builder
- func (b *Builder) WithCheckpointManager(mgr *checkpoint.Manager) *Builder
- func (b *Builder) WithConfig(cfg *config.Config) *Builder
- func (b *Builder) WithDBPool(pool *config.DBPool) *Builder
- func (b *Builder) WithDirectTools(agentName string, tools []tool.Tool) *Builder
- func (b *Builder) WithDocumentStore(name string, ds *rag.DocumentStore) *Builder
- func (b *Builder) WithEmbedder(name string, emb embedder.Embedder) *Builder
- func (b *Builder) WithEmbedderFactory(f EmbedderFactory) *Builder
- func (b *Builder) WithIndexService(idx memory.IndexService) *Builder
- func (b *Builder) WithLLM(name string, llm model.LLM) *Builder
- func (b *Builder) WithLLMFactory(f LLMFactory) *Builder
- func (b *Builder) WithObservability(obs *observability.Manager) *Builder
- func (b *Builder) WithSessionService(svc session.Service) *Builder
- func (b *Builder) WithSubAgents(agentName string, subAgents []agent.Agent) *Builder
- func (b *Builder) WithToolset(name string, ts tool.Toolset) *Builder
- func (b *Builder) WithToolsetFactory(f ToolsetFactory) *Builder
- func (b *Builder) WithVectorProvider(name string, vp vector.Provider) *Builder
- type EmbedderFactory
- type LLMFactory
- type Runtime
- func (r *Runtime) CheckpointManager() *checkpoint.Manager
- func (r *Runtime) Close() error
- func (r *Runtime) Config() *config.Config
- func (r *Runtime) DefaultAgent() (agent.Agent, bool)
- func (r *Runtime) DefaultRunnerConfig() (*runner.Config, error)
- func (r *Runtime) DocumentStores() map[string]*rag.DocumentStore
- func (r *Runtime) GetAgent(name string) (agent.Agent, bool)
- func (r *Runtime) GetDocumentStore(name string) (*rag.DocumentStore, bool)
- func (r *Runtime) GetLLM(name string) (model.LLM, bool)
- func (r *Runtime) IndexDocumentStores(ctx context.Context) error
- func (r *Runtime) IndexService() memory.IndexService
- func (r *Runtime) ListAgents() []string
- func (r *Runtime) Metrics() *observability.Metrics
- func (r *Runtime) NewAuthValidator() (auth.TokenValidator, error)
- func (r *Runtime) Notifier() *notification.Notifier
- func (r *Runtime) Observability() *observability.Manager
- func (r *Runtime) RunnerConfig(agentName string) (*runner.Config, error)
- func (r *Runtime) SessionService() session.Service
- func (r *Runtime) StartDocumentStoreWatching(ctx context.Context) error
- func (r *Runtime) StartScheduler()
- func (r *Runtime) StopScheduler()
- func (r *Runtime) Tracer() *observability.Tracer
- type ToolsetFactory
- type WorkingMemoryFactoryOptions
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DefaultEmbedderFactory ¶
func DefaultEmbedderFactory(cfg *config.EmbedderConfig) (embedder.Embedder, error)
DefaultEmbedderFactory creates Embedder instances based on provider type. Uses the builder package as its foundation to ensure a single code path for both configuration-based and programmatic API usage.
func DefaultLLMFactory ¶
DefaultLLMFactory creates LLM instances based on provider type. Uses the builder package as its foundation to ensure a single code path for both configuration-based and programmatic API usage.
func DefaultToolsetFactory ¶
DefaultToolsetFactory creates toolset instances based on tool type. Uses the builder package as its foundation for MCP toolsets to ensure a single code path for both configuration-based and programmatic API usage.
func DefaultWorkingMemoryFactory ¶
func DefaultWorkingMemoryFactory(opts WorkingMemoryFactoryOptions) (memory.WorkingMemoryStrategy, error)
DefaultWorkingMemoryFactory creates a working memory strategy from config. Uses the builder package as its foundation to ensure a single code path for both configuration-based and programmatic API usage. Returns nil if no context config is set or strategy is "none".
Types ¶
type Builder ¶ added in v1.14.0
type Builder struct {
// contains filtered or unexported fields
}
Builder is the foundational API for constructing Runtime instances. It uses a fluent interface pattern for programmatic configuration. Config-based loading is syntactic sugar that internally uses Builder.
func NewBuilder ¶ added in v1.14.0
func NewBuilder() *Builder
NewBuilder creates a new Builder instance.
func (*Builder) Build ¶ added in v1.14.0
Build creates an immutable Runtime from the builder state. This is the ONLY way to create a Runtime.
func (*Builder) WithAgentTools ¶ added in v1.14.0
WithAgentTools adds agents as tools for an agent (Pattern 2: delegation).
func (*Builder) WithCheckpointManager ¶ added in v1.14.0
func (b *Builder) WithCheckpointManager(mgr *checkpoint.Manager) *Builder
WithCheckpointManager sets the checkpoint manager.
func (*Builder) WithConfig ¶ added in v1.14.0
WithConfig sets up the builder from a config file. This is syntactic sugar - internally uses the programmatic API.
func (*Builder) WithDBPool ¶ added in v1.14.0
WithDBPool sets the shared database pool.
func (*Builder) WithDirectTools ¶ added in v1.14.0
WithDirectTools adds tools directly for an agent.
func (*Builder) WithDocumentStore ¶ added in v1.14.0
func (b *Builder) WithDocumentStore(name string, ds *rag.DocumentStore) *Builder
WithDocumentStore registers a document store instance.
func (*Builder) WithEmbedder ¶ added in v1.14.0
WithEmbedder registers an embedder instance.
func (*Builder) WithEmbedderFactory ¶ added in v1.14.0
func (b *Builder) WithEmbedderFactory(f EmbedderFactory) *Builder
WithEmbedderFactory sets a custom embedder factory.
func (*Builder) WithIndexService ¶ added in v1.14.0
func (b *Builder) WithIndexService(idx memory.IndexService) *Builder
WithIndexService sets the index service.
func (*Builder) WithLLMFactory ¶ added in v1.14.0
func (b *Builder) WithLLMFactory(f LLMFactory) *Builder
WithLLMFactory sets a custom LLM factory for config-based building.
func (*Builder) WithObservability ¶ added in v1.14.0
func (b *Builder) WithObservability(obs *observability.Manager) *Builder
WithObservability sets the observability manager.
func (*Builder) WithSessionService ¶ added in v1.14.0
WithSessionService sets the session service.
func (*Builder) WithSubAgents ¶ added in v1.14.0
WithSubAgents adds sub-agents for an agent (Pattern 1: transfer).
func (*Builder) WithToolset ¶ added in v1.14.0
WithToolset registers a toolset instance.
func (*Builder) WithToolsetFactory ¶ added in v1.14.0
func (b *Builder) WithToolsetFactory(f ToolsetFactory) *Builder
WithToolsetFactory sets a custom toolset factory.
type EmbedderFactory ¶
type EmbedderFactory func(cfg *config.EmbedderConfig) (embedder.Embedder, error)
EmbedderFactory creates an Embedder from config.
type LLMFactory ¶
LLMFactory creates an LLM from config.
type Runtime ¶
type Runtime struct {
// contains filtered or unexported fields
}
Runtime manages the lifecycle of Hector agents built from config.
func New ¶
New creates a new Runtime from config. This is a convenience function that delegates to Builder. For programmatic configuration, use NewBuilder() directly.
func (*Runtime) CheckpointManager ¶
func (r *Runtime) CheckpointManager() *checkpoint.Manager
CheckpointManager returns the checkpoint manager. Returns nil if checkpointing is not configured.
func (*Runtime) DefaultAgent ¶
DefaultAgent returns the first agent (primary/default agent).
func (*Runtime) DefaultRunnerConfig ¶
DefaultRunnerConfig creates a runner.Config for the default agent.
func (*Runtime) DocumentStores ¶
func (r *Runtime) DocumentStores() map[string]*rag.DocumentStore
DocumentStores returns all document stores.
func (*Runtime) GetDocumentStore ¶
func (r *Runtime) GetDocumentStore(name string) (*rag.DocumentStore, bool)
GetDocumentStore returns a document store by name.
func (*Runtime) IndexDocumentStores ¶
IndexDocumentStores indexes all document stores. This should be called after runtime initialization to populate the indexes. It can be called asynchronously to avoid blocking startup.
func (*Runtime) IndexService ¶
func (r *Runtime) IndexService() memory.IndexService
IndexService returns the index service.
func (*Runtime) ListAgents ¶
ListAgents returns all agent names.
func (*Runtime) Metrics ¶
func (r *Runtime) Metrics() *observability.Metrics
Metrics returns the metrics recorder. Returns nil if metrics are not enabled.
func (*Runtime) NewAuthValidator ¶
func (r *Runtime) NewAuthValidator() (auth.TokenValidator, error)
NewAuthValidator creates a JWT validator from the server auth config. Returns nil if authentication is not enabled.
func (*Runtime) Notifier ¶ added in v1.15.0
func (r *Runtime) Notifier() *notification.Notifier
Notifier returns the outbound notification dispatcher. Returns nil if no notifications are configured.
func (*Runtime) Observability ¶
func (r *Runtime) Observability() *observability.Manager
Observability returns the observability manager. Returns nil if observability is not configured.
func (*Runtime) RunnerConfig ¶
RunnerConfig creates a runner.Config for the given agent.
func (*Runtime) SessionService ¶
SessionService returns the session service.
func (*Runtime) StartDocumentStoreWatching ¶
StartDocumentStoreWatching starts file watching for all document stores. This enables automatic re-indexing when documents change.
func (*Runtime) StartScheduler ¶ added in v1.13.0
func (r *Runtime) StartScheduler()
StartScheduler starts the trigger scheduler. Call this after the server is ready to receive requests.
func (*Runtime) StopScheduler ¶ added in v1.13.0
func (r *Runtime) StopScheduler()
StopScheduler stops the trigger scheduler gracefully.
func (*Runtime) Tracer ¶
func (r *Runtime) Tracer() *observability.Tracer
Tracer returns the tracer for distributed tracing. Returns nil if tracing is not enabled.
type ToolsetFactory ¶
ToolsetFactory creates a Toolset from config.
type WorkingMemoryFactoryOptions ¶
type WorkingMemoryFactoryOptions struct {
// Config is the context configuration.
Config *config.ContextConfig
// ModelName is the LLM model name for token counting.
ModelName string
// SummarizerLLM is the LLM to use for summarization (summary_buffer only).
// If nil and strategy is summary_buffer, summarization is disabled.
SummarizerLLM model.LLM
}
WorkingMemoryFactoryOptions contains options for creating working memory strategies.