bootstrap

package
v1.4.6 Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2026 License: MIT Imports: 57 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildAPIKeyHandler

func BuildAPIKeyHandler(db *gorm.DB, logger *zap.Logger) *handlers.APIKeyHandler

BuildAPIKeyHandler creates API key handler when DB is available; otherwise returns nil.

func BuildAgentCheckpointStore

func BuildAgentCheckpointStore(cfg *config.Config, db *gorm.DB, logger *zap.Logger) (agent.CheckpointStore, error)

BuildAgentCheckpointStore builds a single checkpoint store backend from config.

func BuildAgentHandler

func BuildAgentHandler(
	discoveryRegistry discovery.Registry,
	agentRegistry *agent.AgentRegistry,
	logger *zap.Logger,
	resolver ...handlers.AgentResolver,
) *handlers.AgentHandler

BuildAgentHandler creates agent handler with optional resolver.

func BuildAgentRegistries

func BuildAgentRegistries(logger *zap.Logger) (*discovery.CapabilityRegistry, *agent.AgentRegistry)

BuildAgentRegistries creates discovery and agent registries for runtime handlers.

func BuildAuthMiddleware

func BuildAuthMiddleware(serverCfg config.ServerConfig, skipPaths []string, logger *zap.Logger) mw.Middleware

BuildAuthMiddleware selects and creates the HTTP auth middleware. Priority: JWT (if secret or public key configured) > API Key > fail-closed.

func BuildHTTPServerConfig

func BuildHTTPServerConfig(serverCfg config.ServerConfig) server.Config

BuildHTTPServerConfig creates the HTTP server manager configuration.

func BuildMetricsServerConfig

func BuildMetricsServerConfig(serverCfg config.ServerConfig) server.Config

BuildMetricsServerConfig creates the metrics server manager configuration.

func BuildMongoClient

func BuildMongoClient(cfg config.MongoDBConfig, logger *zap.Logger) (*mongoclient.Client, error)

BuildMongoClient creates the MongoDB client used by runtime wiring.

func BuildMultimodalRedisReferenceStore

func BuildMultimodalRedisReferenceStore(
	cfg *config.Config,
	keyPrefix string,
	ttl time.Duration,
	logger *zap.Logger,
) (*redis.Client, handlers.ReferenceStore, error)

BuildMultimodalRedisReferenceStore creates the redis client and reference store for multimodal runtime.

func BuildToolRegistryHandler

func BuildToolRegistryHandler(
	db *gorm.DB,
	runtime handlers.ToolRegistryRuntime,
	logger *zap.Logger,
) *handlers.ToolRegistryHandler

BuildToolRegistryHandler creates DB-backed tool registration handler when runtime is available.

func IsLoopbackHost

func IsLoopbackHost(host string) bool

IsLoopbackHost reports whether host resolves to loopback host/ip form.

func LoadAndValidateConfig

func LoadAndValidateConfig(configPath string) (*config.Config, error)

LoadAndValidateConfig loads application config from defaults, file, and env, then validates the final result.

func NewLogger

func NewLogger(cfg config.LogConfig) *zap.Logger

NewLogger creates the application logger from config. It always returns a usable logger; on build failure it returns zap.NewNop().

func OpenDatabase

func OpenDatabase(dbCfg config.DatabaseConfig, logger *zap.Logger) (*gorm.DB, error)

OpenDatabase opens database connection based on config.

func RegisterDefaultRuntimeAgentFactory

func RegisterDefaultRuntimeAgentFactory(
	agentRegistry *agent.AgentRegistry,
	provider llm.Provider,
	toolProvider llm.Provider,
	logger *zap.Logger,
)

RegisterDefaultRuntimeAgentFactory wires the default runtime-backed agent factory.

func RegisterHTTPRoutes

func RegisterHTTPRoutes(
	mux *http.ServeMux,
	handlers HTTPRouteHandlers,
	version string,
	buildTime string,
	gitCommit string,
	firstAPIKey string,
	logger *zap.Logger,
)

RegisterHTTPRoutes wires all API routes into the provided mux and logs route summary.

func RegisterHotReloadCallbacks

func RegisterHotReloadCallbacks(
	manager *config.HotReloadManager,
	logger *zap.Logger,
	onReload func(oldConfig, newConfig *config.Config),
)

RegisterHotReloadCallbacks wires standard startup callbacks for hot-reload manager.

func ValidateMultimodalReferenceBackend

func ValidateMultimodalReferenceBackend(cfg *config.Config) (string, error)

ValidateMultimodalReferenceBackend validates and normalizes multimodal reference backend.

Types

type AgentToolingOptions

type AgentToolingOptions struct {
	RetrievalStore    rag.VectorStore
	EmbeddingProvider rag.EmbeddingProvider
	MCPServer         mcpproto.MCPServer
	EnableMCPTools    bool
	DB                *gorm.DB
}

AgentToolingOptions carries optional dependencies for agent tool wiring.

type AgentToolingRuntime

type AgentToolingRuntime struct {
	Registry    *hosted.ToolRegistry
	ToolManager agent.ToolManager
	ToolNames   []string
	// contains filtered or unexported fields
}

AgentToolingRuntime groups runtime-managed tools exposed to Agent execution.

func BuildAgentToolingRuntime

func BuildAgentToolingRuntime(opts AgentToolingOptions, logger *zap.Logger) (*AgentToolingRuntime, error)

BuildAgentToolingRuntime creates a hosted tool registry and ToolManager bridge for agent runtime. It supports retrieval (RAG) and optional MCP tool bridging.

func (*AgentToolingRuntime) BaseToolNames

func (r *AgentToolingRuntime) BaseToolNames() []string

BaseToolNames returns built-in runtime target names that registrations may alias.

func (*AgentToolingRuntime) RegisterHostedTool

func (r *AgentToolingRuntime) RegisterHostedTool(tool hosted.HostedTool)

RegisterHostedTool allows application layer to inject custom hosted tools. Newly added tool names are appended into ToolNames for resolver whitelist wiring.

func (*AgentToolingRuntime) ReloadBindings

func (r *AgentToolingRuntime) ReloadBindings(ctx context.Context) error

ReloadBindings reloads DB-managed tool registrations and applies them to the shared registry.

type HTTPMiddlewares

type HTTPMiddlewares struct {
	List                    []mw.Middleware
	RateLimiterCancel       context.CancelFunc
	TenantRateLimiterCancel context.CancelFunc
}

HTTPMiddlewares bundles middleware list and lifecycle cancels.

func BuildHTTPMiddlewares

func BuildHTTPMiddlewares(
	serverCfg config.ServerConfig,
	collector *metrics.Collector,
	logger *zap.Logger,
) HTTPMiddlewares

BuildHTTPMiddlewares creates the default HTTP middleware chain.

type HTTPRouteHandlers

HTTPRouteHandlers groups handler dependencies used by HTTP route registration.

type HotReloadRuntime

type HotReloadRuntime struct {
	Manager    *config.HotReloadManager
	APIHandler *config.ConfigAPIHandler
}

HotReloadRuntime groups hot-reload manager and config API handler.

func BuildHotReloadRuntime

func BuildHotReloadRuntime(cfg *config.Config, configPath string, logger *zap.Logger) *HotReloadRuntime

BuildHotReloadRuntime creates hot-reload manager and config API handler.

type LLMHandlerRuntime

type LLMHandlerRuntime struct {
	Provider      llm.Provider
	ToolProvider  llm.Provider
	BudgetManager *llmpolicy.TokenBudgetManager
	CostTracker   *observability.CostTracker
	Cache         *cache.MultiLevelCache
	Metrics       *observability.Metrics
	PolicyManager *llmpolicy.Manager
}

LLMHandlerRuntime groups LLM-related runtime dependencies used by API handlers.

func BuildLLMHandlerRuntime

func BuildLLMHandlerRuntime(cfg *config.Config, db *gorm.DB, logger *zap.Logger) (*LLMHandlerRuntime, error)

BuildLLMHandlerRuntime creates the LLM runtime required by handler layer. The main provider entry is multi-provider router + routed provider.

type MongoRuntimeWiring

type MongoRuntimeWiring struct {
	AuditLogger    *tools.DefaultAuditLogger
	EnhancedMemory *memory.EnhancedMemorySystem
	ABTester       *evaluation.ABTester
}

MongoRuntimeWiring contains optional runtime capabilities wired from MongoDB stores.

func WireMongoRuntimeStores

func WireMongoRuntimeStores(
	ctx context.Context,
	client *mongoclient.Client,
	resolver *agent.CachingResolver,
	discoveryRegistry *discovery.CapabilityRegistry,
	logger *zap.Logger,
) (*MongoRuntimeWiring, error)

WireMongoRuntimeStores wires resolver/discovery stores and returns optional runtime capabilities.

type MultimodalRuntime

type MultimodalRuntime struct {
	Handler            *handlers.MultimodalHandler
	ReferenceBackend   string
	ImageProviderCount int
	VideoProviderCount int
}

MultimodalRuntime groups multimodal handler and key runtime metadata.

func BuildMultimodalRuntime

func BuildMultimodalRuntime(
	cfg *config.Config,
	chatProvider llm.Provider,
	budgetManager *llmpolicy.TokenBudgetManager,
	referenceStore handlers.ReferenceStore,
	logger *zap.Logger,
) (*MultimodalRuntime, error)

BuildMultimodalRuntime builds multimodal handler runtime from config. If multimodal is disabled, it returns nil.

type ProtocolRuntime

type ProtocolRuntime struct {
	MCPServer mcp.MCPServer
	A2AServer a2a.A2AServer
}

ProtocolRuntime groups protocol servers required by ProtocolHandler.

func BuildProtocolRuntime

func BuildProtocolRuntime(logger *zap.Logger) *ProtocolRuntime

BuildProtocolRuntime creates MCP and A2A servers for HTTP protocol handler.

type RAGHandlerRuntime

type RAGHandlerRuntime struct {
	Store             rag.VectorStore
	EmbeddingProvider rag.EmbeddingProvider
}

RAGHandlerRuntime groups dependencies required by RAGHandler.

func BuildRAGHandlerRuntime

func BuildRAGHandlerRuntime(cfg *config.Config, logger *zap.Logger) (*RAGHandlerRuntime, error)

BuildRAGHandlerRuntime creates dependencies for RAG handler. If no LLM API key is configured, it returns nil.

type ServeRuntime

type ServeRuntime struct {
	Config    *config.Config
	Logger    *zap.Logger
	Telemetry *telemetry.Providers
	DB        *gorm.DB
}

ServeRuntime holds dependencies required by cmd/agentflow serve runtime.

func InitializeServeRuntime

func InitializeServeRuntime(configPath string) (*ServeRuntime, error)

InitializeServeRuntime centralizes startup bootstrapping for the serve command: config loading/validation, logger creation, telemetry init, and DB connection.

type WorkflowAgentResolver

type WorkflowAgentResolver func(ctx context.Context, agentID string) (agent.Agent, error)

WorkflowAgentResolver resolves an agent instance by ID for workflow agent steps.

type WorkflowRuntime

type WorkflowRuntime struct {
	Facade *workflow.Facade
	Parser *dsl.Parser
}

WorkflowRuntime groups parser and executor required by WorkflowHandler.

func BuildWorkflowRuntime

func BuildWorkflowRuntime(logger *zap.Logger, opts ...WorkflowRuntimeOptions) *WorkflowRuntime

BuildWorkflowRuntime creates workflow parser and DAG executor.

type WorkflowRuntimeOptions

type WorkflowRuntimeOptions struct {
	LLMProvider       llm.Provider
	DefaultModel      string
	AgentResolver     WorkflowAgentResolver
	RetrievalStore    rag.VectorStore
	EmbeddingProvider rag.EmbeddingProvider
	CheckpointStore   agent.CheckpointStore
	HITLManager       *hitl.InterruptManager
}

WorkflowRuntimeOptions carries optional runtime integrations for workflow steps.

Jump to

Keyboard shortcuts

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