ai

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2026 License: GPL-3.0 Imports: 14 Imported by: 0

Documentation

Overview

Package ai coordinates provider resolution, route tools, memory, and streaming turns.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNotConfigured means neither a user provider nor the shared config is usable.
	ErrNotConfigured = errors.New("ai: no provider configured")
	// ErrProviderUnsupported means the resolved provider kind has no adapter yet.
	ErrProviderUnsupported = errors.New("ai: provider kind not supported")
)

Functions

func AllowedRisks

func AllowedRisks(mode string, allowDestructive bool) map[plugin.RiskLevel]bool

AllowedRisks maps a connection's AI mode + destructive opt-in to allowed tool risks.

Types

type ProviderFactory

type ProviderFactory func(ctx context.Context, kind models.AIProviderKind, key, baseURL, model string) (engine.Provider, error)

ProviderFactory builds an engine.Provider for a resolved config.

type RunInput

type RunInput struct {
	User             models.User
	ConnID           string
	Protocol         string
	ConnectionTitle  string
	AIMode           string // disabled | read_only | read_write
	AllowDestructive bool
	Scope            Scope
	ConversationID   string // when set (with memory wired), history is persisted
	History          []engine.Message
	UserMessage      string
	RecentOps        []string
	Confirm          tools.Confirmer
}

RunInput is one chat turn's request.

type Scope

type Scope struct {
	ProviderID string
}

Scope selects the provider for a turn. Empty ProviderID means shared AI.

type Service

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

Service is the public AI surface used by transport.

func New

func New(providers *aiconfig.Service, global config.AIConfig, routes tools.RouteSource, invoker tools.Invoker, mem *memory.Store, models *modelreg.Registry) *Service

New wires the config service, global config, route source, secure invoker, conversation memory, and the model-limit registry.

func (*Service) Configured

func (s *Service) Configured(ctx context.Context, userID string) bool

Configured reports whether any provider (user or global) could serve a turn for the user. Used by transport to gate the chat endpoint.

func (*Service) Conversations

func (s *Service) Conversations() *memory.Store

Conversations exposes the conversation/message store for transport CRUD.

func (*Service) Run

func (s *Service) Run(ctx context.Context, in RunInput, sink func(engine.StreamEvent)) error

Run executes one turn and relays every event to sink. The caller cancels ctx to stop the turn cleanly.

func (*Service) WithProviderFactory

func (s *Service) WithProviderFactory(f ProviderFactory) *Service

WithProviderFactory overrides the engine adapter (used in tests).

Directories

Path Synopsis
Package agent builds the system prompt and relays a provider turn to the transport, buffering text deltas so the UI receives smooth, batched updates instead of a flood of tiny frames.
Package agent builds the system prompt and relays a provider turn to the transport, buffering text deltas so the UI receives smooth, batched updates instead of a flood of tiny frames.
Package budget computes a turn's token budgeting.
Package budget computes a turn's token budgeting.
Package aiconfig manages shared and user-scoped AI provider configuration.
Package aiconfig manages shared and user-scoped AI provider configuration.
Package engine defines the framework-agnostic AI provider interfaces.
Package engine defines the framework-agnostic AI provider interfaces.
eino
Package eino is the only package that imports cloudwego/eino; it adapts the framework to the engine.Provider seam with an explicit tool-calling loop so each tool call flows through the risk-gated executor.
Package eino is the only package that imports cloudwego/eino; it adapts the framework to the engine.Provider seam with an explicit tool-calling loop so each tool call flows through the risk-gated executor.
Package memory persists AI conversations and assembles context windows.
Package memory persists AI conversations and assembles context windows.
Package modelreg resolves model token limits from live registries, provider catalogues, static metadata, and finally a safe default.
Package modelreg resolves model token limits from live registries, provider catalogues, static metadata, and finally a safe default.
Package tools exposes risk-gated connection routes as agent tools.
Package tools exposes risk-gated connection routes as agent tools.

Jump to

Keyboard shortcuts

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