runtime

package
v1.21.1 Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2026 License: MIT Imports: 41 Imported by: 0

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

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

func DefaultLLMFactory(cfg *config.LLMConfig) (model.LLM, error)

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

func DefaultToolsetFactory(name string, cfg *config.ToolConfig) (tool.Toolset, error)

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

func (b *Builder) Build() (*Runtime, error)

Build creates an immutable Runtime from the builder state. This is the ONLY way to create a Runtime.

func (*Builder) WithAgent added in v1.14.0

func (b *Builder) WithAgent(name string, ag agent.Agent) *Builder

WithAgent registers an agent instance.

func (*Builder) WithAgentTools added in v1.14.0

func (b *Builder) WithAgentTools(agentName string, agentTools []agent.Agent) *Builder

WithAgentTools adds agents as tools for an agent (Pattern 2: delegation).

func (*Builder) WithAppID added in v1.21.0

func (b *Builder) WithAppID(id string) *Builder

WithAppID sets the application ID.

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

func (b *Builder) WithConfig(cfg *config.AppConfig) *Builder

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

func (b *Builder) WithDBPool(pool *config.DBPool) *Builder

WithDBPool sets the shared database pool.

func (*Builder) WithDatabaseDSN added in v1.21.0

func (b *Builder) WithDatabaseDSN(dsn string) *Builder

WithDatabaseDSN sets the database DSN for session/task services.

func (*Builder) WithDirectTools added in v1.14.0

func (b *Builder) WithDirectTools(agentName string, tools []tool.Tool) *Builder

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

func (b *Builder) WithEmbedder(name string, emb embedder.Embedder) *Builder

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) WithLLM added in v1.14.0

func (b *Builder) WithLLM(name string, llm model.LLM) *Builder

WithLLM registers an LLM instance.

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

func (b *Builder) WithSessionService(svc session.Service) *Builder

WithSessionService sets the session service.

func (*Builder) WithSubAgents added in v1.14.0

func (b *Builder) WithSubAgents(agentName string, subAgents []agent.Agent) *Builder

WithSubAgents adds sub-agents for an agent (Pattern 1: transfer).

func (*Builder) WithToolset added in v1.14.0

func (b *Builder) WithToolset(name string, ts tool.Toolset) *Builder

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.

func (*Builder) WithVectorProvider added in v1.14.0

func (b *Builder) WithVectorProvider(name string, vp vector.Provider) *Builder

WithVectorProvider registers a vector provider instance.

type EmbedderFactory

type EmbedderFactory func(cfg *config.EmbedderConfig) (embedder.Embedder, error)

EmbedderFactory creates an Embedder from config.

type LLMFactory

type LLMFactory func(cfg *config.LLMConfig) (model.LLM, error)

LLMFactory creates an LLM from config.

type Runtime

type Runtime struct {
	// AppID is the unique identifier for the application (tenant).
	// This is used for data isolation (sessions, tasks, etc).
	AppID string
	// contains filtered or unexported fields
}

Runtime manages the lifecycle of Hector agents built from config.

func New

func New(cfg *config.AppConfig) (*Runtime, error)

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) Close

func (r *Runtime) Close() error

Close shuts down the runtime and releases resources.

func (*Runtime) Config

func (r *Runtime) Config() *config.AppConfig

Config returns the runtime's configuration.

func (*Runtime) DefaultAgent

func (r *Runtime) DefaultAgent() (agent.Agent, bool)

DefaultAgent returns the first agent (primary/default agent).

func (*Runtime) DefaultRunnerConfig

func (r *Runtime) DefaultRunnerConfig() (*runner.Config, error)

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) GetAgent

func (r *Runtime) GetAgent(name string) (agent.Agent, bool)

GetAgent returns an agent by name.

func (*Runtime) GetDocumentStore

func (r *Runtime) GetDocumentStore(name string) (*rag.DocumentStore, bool)

GetDocumentStore returns a document store by name.

func (*Runtime) GetLLM

func (r *Runtime) GetLLM(name string) (model.LLM, bool)

GetLLM returns an LLM by name.

func (*Runtime) IndexDocumentStores

func (r *Runtime) IndexDocumentStores(ctx context.Context) error

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

func (r *Runtime) ListAgents() []string

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) 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

func (r *Runtime) RunnerConfig(agentName string) (*runner.Config, error)

RunnerConfig creates a runner.Config for the given agent.

func (*Runtime) SessionService

func (r *Runtime) SessionService() session.Service

SessionService returns the session service.

func (*Runtime) StartDocumentStoreWatching

func (r *Runtime) StartDocumentStoreWatching(ctx context.Context) error

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

type ToolsetFactory func(name string, cfg *config.ToolConfig) (tool.Toolset, error)

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.

Jump to

Keyboard shortcuts

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