appinit

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BuildResult

type BuildResult struct {
	Tools          []*agent.Tool
	Components     []lifecycle.ComponentEntry
	CatalogEntries []CatalogEntry
	Resolver       Resolver
	ModuleTiming   []ModuleTimingEntry `json:"moduleTiming,omitempty"`
}

BuildResult holds the aggregated output from all initialized modules.

type Builder

type Builder struct {
	// contains filtered or unexported fields
}

Builder collects modules and orchestrates their initialization.

func NewBuilder

func NewBuilder() *Builder

NewBuilder creates an empty Builder.

func (*Builder) AddModule

func (b *Builder) AddModule(m Module) *Builder

AddModule appends a module and returns the builder for chaining.

func (*Builder) Build

func (b *Builder) Build(ctx context.Context) (*BuildResult, error)

Build sorts modules by dependency order, initializes each in sequence, and returns the aggregated tools, components, and resolver.

type CatalogEntry added in v0.6.0

type CatalogEntry struct {
	Category    string
	Description string
	ConfigKey   string
	Enabled     bool
	Tools       []*agent.Tool
}

CatalogEntry associates tools with a named category for tool catalog registration.

type Module

type Module interface {
	Name() string
	Provides() []Provides
	DependsOn() []Provides
	Enabled() bool
	Init(ctx context.Context, resolver Resolver) (*ModuleResult, error)
}

Module represents an initialization unit.

func TopoSort

func TopoSort(modules []Module) ([]Module, error)

TopoSort returns modules in dependency order. Disabled modules are excluded. If module A depends on key K and module B provides K, B appears before A. Dependencies on keys not provided by any enabled module are silently ignored. Returns an error if a dependency cycle is detected.

type ModuleResult

type ModuleResult struct {
	// Tools are agent tools contributed by this module.
	Tools []*agent.Tool
	// Components are lifecycle components that need Start/Stop management.
	Components []lifecycle.ComponentEntry
	// Values are named values this module provides to other modules via Resolver.
	Values map[Provides]interface{}
	// CatalogEntries register tools under named categories for dynamic discovery.
	CatalogEntries []CatalogEntry
}

ModuleResult is what Init returns.

type ModuleTimingEntry added in v0.7.0

type ModuleTimingEntry struct {
	Module   string        `json:"module"`
	Duration time.Duration `json:"duration"`
}

ModuleTimingEntry records the duration of a module initialization.

type Provides

type Provides string

Provides identifies what a module provides to other modules.

const (
	ProvidesSupervisor    Provides = "supervisor"
	ProvidesSessionStore  Provides = "session_store"
	ProvidesSecurity      Provides = "security"
	ProvidesKnowledge     Provides = "knowledge"
	ProvidesMemory        Provides = "memory"
	ProvidesEmbedding     Provides = "embedding"
	ProvidesGraph         Provides = "graph"
	ProvidesPayment       Provides = "payment"
	ProvidesP2P           Provides = "p2p"
	ProvidesLibrarian     Provides = "librarian"
	ProvidesAutomation    Provides = "automation"
	ProvidesGateway       Provides = "gateway"
	ProvidesAgent         Provides = "agent"
	ProvidesSkills        Provides = "skills"
	ProvidesEconomy       Provides = "economy"
	ProvidesContract      Provides = "contract"
	ProvidesSmartAccount  Provides = "smart_account"
	ProvidesObservability Provides = "observability"
	ProvidesMCP           Provides = "mcp"
	ProvidesRunLedger     Provides = "run_ledger"
	ProvidesProvenance    Provides = "provenance"
	ProvidesWorkspace     Provides = "workspace"
	ProvidesBaseTools     Provides = "base_tools"
)

Well-known module provides keys.

type Resolver

type Resolver interface {
	// Resolve returns the value registered by a module for the given key.
	// Returns nil if the key hasn't been provided yet.
	Resolve(key Provides) interface{}
}

Resolver provides access to initialized module results.

Jump to

Keyboard shortcuts

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