app

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: May 24, 2026 License: MIT Imports: 160 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FormatUserError added in v0.5.0

func FormatUserError(err error) string

FormatUserError converts an error into a user-friendly message. If the error is an *adk.AgentError, its structured UserMessage is used. Otherwise, a generic message is returned.

Types

type App

type App struct {
	Config *config.Config

	// Core Components
	Agent   *adk.Agent
	Gateway *gateway.Server
	Store   session.Store

	// Browser (optional, io.Closer)
	Browser io.Closer

	// Security Components (optional)
	Crypto  security.CryptoProvider
	Keys    *security.KeyRegistry
	Secrets *security.SecretsStore

	// Approval Provider (composite, routes to channel-specific providers)
	ApprovalProvider approval.Provider
	GrantStore       *approval.GrantStore
	ApprovalHistory  *approval.HistoryStore

	// Self-Learning Components
	KnowledgeStore            *knowledge.Store
	LearningEngine            *learning.Engine
	LearningSuggestionEmitter *learning.SuggestionEmitter
	SkillRegistry             *skill.Registry

	// Agent Memory Components (optional, per-agent persistent memory)
	AgentMemoryStore agentmemory.Store

	// Observational Memory Components (optional)
	MemoryStore  *memory.Store
	MemoryBuffer *memory.Buffer

	// Conversation Analysis Components (optional)
	AnalysisBuffer *learning.AnalysisBuffer

	// Compaction Components (optional, Phase 3 background hygiene)
	CompactionBuffer *session.CompactionBuffer

	// ExtensionRegistry holds the set of installed extension packs
	// discovered at startup. nil when the subsystem is disabled or the
	// extensions directory does not exist.
	ExtensionRegistry *extension.Registry

	// Proactive Librarian Components (optional)
	LibrarianInquiryStore    *librarian.InquiryStore
	LibrarianProactiveBuffer *librarian.ProactiveBuffer

	// Graph Components (optional)
	GraphStore  graph.Store
	GraphBuffer *graph.GraphBuffer

	// Payment Components (optional)
	WalletProvider  wallet.WalletProvider
	PaymentService  *payment.Service
	X402Interceptor *x402pkg.Interceptor
	ReceiptStore    *receipts.Store

	// Cron Scheduling Components (optional)
	CronScheduler *cronpkg.Scheduler

	// Background Task Components (optional)
	BackgroundManager *background.Manager
	AgentRunStore     agentrt.AgentRunStore

	// Workflow Engine Components (optional)
	WorkflowEngine *workflow.Engine

	// Economy Components (optional, P2P economy layer)
	EconomyBudget      *budget.Engine
	EconomyRisk        *risk.Engine
	EconomyPricing     *pricing.Engine
	EconomyNegotiation *negotiation.Engine
	EconomyEscrow      *escrow.Engine

	// Smart Account Components (optional, ERC-7579 modular accounts)
	SmartAccountManager    sa.AccountManager
	SmartAccountComponents *smartAccountComponents // full components for CLI access

	// Output Store (compressed tool output retrieval)
	OutputStore *tooloutput.OutputStore

	// Gatekeeper (response sanitizer)
	Sanitizer *gatekeeper.Sanitizer

	// Turn Runtime (shared execution + durable traces)
	TurnRunner     *turnrunner.Runner
	TurnTraceStore turntrace.Store

	// RunLedger Components (optional, Task OS durable execution)
	RunLedgerStore runledger.RunLedgerStore
	RunLedgerPEV   *runledger.PEVEngine

	// Mission Components (optional, durable mission lifecycle)
	MissionStore   mission.Store
	MissionService *mission.Service

	// Proposal Components (optional, transient proactive proposal lifecycle)
	ProposalRegistry *proposal.Registry
	ProposalPreparer proposal.Preparer
	ProposalService  *proposal.Service

	// Loop projection readers (optional, narrow first-slice surfaces)
	LoopMissionReader    LoopMissionReader
	LoopProposalReader   LoopProposalReader
	LoopInquiryReader    LoopInquiryReader
	LoopDeadLetterReader LoopDeadLetterReader
	LoopCronReader       LoopCronReader

	// Collaboration readers (optional, narrow local coworking surfaces)
	CollaborationMissionLinkReader CollaborationMissionLinkReader
	CollaborationAgentRunReader    CollaborationAgentRunReader
	CollaborationDelegationReader  CollaborationDelegationReader
	CollaborationRuntimeReader     CollaborationRuntimeReader

	// Provenance Components (optional)
	ProvenanceCheckpoints *provenance.CheckpointService
	ProvenanceSessionTree *provenance.SessionTree
	ProvenanceAttribution *provenance.AttributionService
	ProvenanceBundle      *provenance.BundleService

	// MCP Components (optional, external MCP server integration)
	MCPManager *mcp.ServerManager

	// Observability Components (optional)
	MetricsCollector *observability.MetricsCollector
	HealthRegistry   *health.Registry
	TokenStore       *token.EntTokenStore
	TracerShutdown   func(context.Context) error

	// Tool Catalog (built-in tool discovery + dynamic dispatch)
	ToolCatalog *toolcatalog.Catalog

	// P2P Components (optional)
	P2PNode            *p2p.Node
	P2PAgentPool       *agentpool.Pool
	P2PTeamCoordinator *team.Coordinator
	P2PAgentProvider   agentpool.DynamicAgentProvider

	// Event Bus (app-level, for hooks and cross-component communication)
	EventBus *eventbus.Bus

	// Agent Registry (dynamic agent definitions)
	AgentRegistry *agentregistry.Registry

	// Hook Registry (tool execution hooks)
	HookRegistry *toolchain.HookRegistry

	// FeatureStatuses holds aggregated init diagnostics for context subsystems.
	FeatureStatuses *StatusCollector

	// Channels
	Channels []Channel
	// contains filtered or unexported fields
}

App is the root application structure

func New

func New(boot *bootstrap.Result, opts ...AppOption) (*App, error)

New creates a new application instance from a bootstrap result.

func (*App) Start

func (a *App) Start(ctx context.Context) error

Start starts the application services using the lifecycle registry.

func (*App) Stop

func (a *App) Stop(ctx context.Context) error

Stop stops the application services and waits for all goroutines to exit.

type AppMode added in v0.7.0

type AppMode int

AppMode determines the application operating mode.

const (
	// AppModeServer is the default mode — starts all components including
	// gateway, channels, automation, and network.
	AppModeServer AppMode = iota

	// AppModeLocalChat starts only core components (Infra, Core, Buffer)
	// and skips network/automation/gateway/channel lifecycle. Used for
	// interactive TUI chat.
	AppModeLocalChat

	// AppModeCockpit starts core + buffer components and optionally initializes
	// channels (if configured), but skips the HTTP gateway and automation lifecycle.
	// Channel Start/Stop is managed externally by the caller (e.g., runCockpit).
	AppModeCockpit
)

type AppOption added in v0.7.0

type AppOption func(*appOptions)

AppOption configures optional behavior for App construction.

func WithCockpit added in v0.7.0

func WithCockpit() AppOption

WithCockpit creates an App in cockpit mode. Core components start normally, channels are initialized if configured, but gateway and automation are skipped.

func WithLocalChat added in v0.7.0

func WithLocalChat() AppOption

WithLocalChat creates an App in local-chat mode. Network, automation, gateway, and channel lifecycle components are not started.

type Channel

type Channel interface {
	Name() string
	Start(ctx context.Context) error
	Stop(ctx context.Context) error
}

Channel represents a communication channel (Telegram, Discord, Slack)

type CollaborationAgentRunReader added in v0.8.0

type CollaborationAgentRunReader interface {
	ListAgentRuns() []collabview.CollaborationAgentRunView
}

type CollaborationAgentRunView added in v0.8.0

type CollaborationAgentRunView = collabview.CollaborationAgentRunView

type CollaborationBudgetRecord added in v0.8.0

type CollaborationBudgetRecord = collabview.CollaborationBudgetRecord

type CollaborationDelegationReader added in v0.8.0

type CollaborationDelegationReader interface {
	ListDelegationsForSession(ctx context.Context, sessionKey string) ([]collabview.CollaborationDelegationRecord, error)
}

type CollaborationDelegationRecord added in v0.8.0

type CollaborationDelegationRecord = collabview.CollaborationDelegationRecord
type CollaborationMissionExecutionLink = collabview.CollaborationMissionExecutionLink

type CollaborationMissionLinkReader added in v0.8.0

type CollaborationMissionLinkReader interface {
	ListMissionExecutionLinks(ctx context.Context, missionID string) ([]collabview.CollaborationMissionExecutionLink, error)
}

type CollaborationRecoveryRecord added in v0.8.0

type CollaborationRecoveryRecord = collabview.CollaborationRecoveryRecord

type CollaborationRuntimeReader added in v0.8.0

type CollaborationRuntimeReader interface {
	ListBudgetSignals(missionID string) []collabview.CollaborationBudgetRecord
	ListRecoverySignals(missionID string) []collabview.CollaborationRecoveryRecord
}

type ExtendableDeadline added in v0.5.0

type ExtendableDeadline = deadline.ExtendableDeadline

ExtendableDeadline is an alias for backward compatibility within the app package.

func NewExtendableDeadline added in v0.5.0

func NewExtendableDeadline(parent context.Context, baseTimeout, maxTimeout time.Duration) (context.Context, *ExtendableDeadline)

NewExtendableDeadline creates a new ExtendableDeadline. Deprecated: Use deadline.New directly.

type LoopCronReader added in v0.8.0

type LoopCronReader interface {
	List(ctx context.Context) ([]cronpkg.Job, error)
	ListHistory(ctx context.Context, jobID string, limit int) ([]cronpkg.HistoryEntry, error)
}

type LoopDeadLetterReader added in v0.8.0

type LoopDeadLetterReader interface {
	ListCurrentDeadLetters(ctx context.Context) ([]postadjudicationstatus.DeadLetterBacklogEntry, error)
}

type LoopInquiryReader added in v0.8.0

type LoopInquiryReader interface {
	ListPendingInquiries(ctx context.Context, sessionKey string, limit int) ([]librarian.Inquiry, error)
}

type LoopMissionReader added in v0.8.0

type LoopMissionReader interface {
	ListMissionsBySession(ctx context.Context, sessionKey string, limit int) ([]*mission.Mission, error)
}

type LoopProposalReader added in v0.8.0

type LoopProposalReader interface {
	ListBySession(sessionKey string) []proposal.Proposal
}

type StatusCollector added in v0.7.0

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

StatusCollector aggregates FeatureStatus from wiring functions.

func NewStatusCollector added in v0.7.0

func NewStatusCollector() *StatusCollector

NewStatusCollector creates an empty StatusCollector.

func (*StatusCollector) Add added in v0.7.0

func (c *StatusCollector) Add(s *types.FeatureStatus)

Add appends a feature status. Nil pointers are ignored.

func (*StatusCollector) All added in v0.7.0

func (c *StatusCollector) All() []types.FeatureStatus

All returns a copy of all collected statuses.

func (*StatusCollector) SilentDisabledCount added in v0.7.0

func (c *StatusCollector) SilentDisabledCount() int

SilentDisabledCount returns the number of features that are disabled with a non-empty reason — i.e., features the user likely didn't intend to disable but that are off due to missing dependencies.

type TeamMetrics added in v0.8.0

type TeamMetrics struct {
	Delegations    atomic.Int64
	TotalWorkers   atomic.Int64
	TotalSuccesses atomic.Int64
	TotalFailures  atomic.Int64
}

TeamMetrics holds in-memory counters for team task delegation analysis.

Jump to

Keyboard shortcuts

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