app

package
v0.0.0-...-d8a54d3 Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2026 License: MIT Imports: 27 Imported by: 0

Documentation

Overview

Package app provides application initialization and lifecycle management.

App is the core container that holds all application components. Created by Setup, released by Close.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type App

type App struct {
	Config        *config.Config
	Genkit        *genkit.Genkit
	Embedder      ai.Embedder
	DBPool        *pgxpool.Pool
	DocStore      *postgresql.DocStore
	Retriever     ai.Retriever
	SessionStore  *session.Store
	MemoryStore   *memory.Store
	PathValidator *security.Path
	Tools         []ai.Tool // Pre-registered Genkit tools (for chat agent)

	// Concrete toolsets shared by CLI and MCP entry points.
	File      *tools.File
	System    *tools.System
	Network   *tools.Network
	Knowledge *tools.Knowledge // nil if retriever unavailable
	// contains filtered or unexported fields
}

App is the application instance. Created by Setup, closed by Close. All entry points (CLI, HTTP, MCP) use this struct to access shared resources.

func Setup

func Setup(ctx context.Context, cfg *config.Config) (_ *App, retErr error)

Setup creates and initializes the application. Returns an App with embedded cleanup — call Close() to release.

func (*App) Close

func (a *App) Close() error

Close gracefully shuts down all resources. Safe for concurrent and repeated calls — cleanup runs exactly once via sync.Once.

Shutdown order:

  1. Cancel context (signals background tasks to stop)
  2. Wait for background goroutines (scheduler) to exit
  3. Close DB pool
  4. Flush OTel spans

func (*App) CreateAgent

func (a *App) CreateAgent() (*chat.Agent, error)

CreateAgent creates a Chat Agent using pre-registered tools. Tools are registered once at Setup (not lazily). Setup guarantees all dependencies are non-nil.

Jump to

Keyboard shortcuts

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