serve

package
v0.0.331 Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2026 License: MIT Imports: 29 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func PlatformContains added in v0.0.320

func PlatformContains(platforms []string, name string) bool

PlatformContains reports whether platforms includes name.

func ResolvePlatforms added in v0.0.320

func ResolvePlatforms(args []string, configPlatforms []string) ([]string, error)

ResolvePlatforms returns the list of platforms to serve. Positional args take precedence; if none are given, configPlatforms (from config.yaml serve.platforms) is used as fallback.

Types

type Options added in v0.0.320

type Options struct {
	Host string
	Port int

	AuthMode    string
	Token       string
	TokenSource string
	BasePath    string
	Title       string

	Platforms []string

	// Runner executes the current serve implementation. It is intentionally a
	// temporary seam: internal packages can be extracted without changing CLI
	// behavior, and cmd/serve.go can already be reduced to constructing a Service
	// and invoking Run.
	Runner func(context.Context) error
}

Options describes the resolved inputs required to run the serve service.

The long-term goal for the serve command is for cmd/ to perform only flag parsing/validation and pass concrete values here. During the extraction, the legacy runner hook keeps behavior stable while serve orchestration is moved behind this package boundary incrementally.

type Platform

type Platform interface {
	// Name returns the platform identifier (e.g. "telegram").
	Name() string
	// NeedsSetup returns true when required configuration is missing.
	NeedsSetup() bool
	// RunSetup runs an interactive wizard to collect and persist configuration.
	RunSetup() error
	// Run starts the platform's message loop, blocking until ctx is cancelled.
	Run(ctx context.Context, cfg *config.Config, settings Settings) error
}

Platform is the interface implemented by each messaging platform adapter.

type Service added in v0.0.320

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

Service owns serve orchestration.

func NewService added in v0.0.320

func NewService(opts Options) (*Service, error)

NewService constructs a serve service from resolved options.

func (*Service) Run added in v0.0.320

func (s *Service) Run(ctx context.Context) error

Run starts the service and blocks until ctx is cancelled or the service exits.

type SessionRuntime added in v0.0.85

type SessionRuntime struct {
	Engine       *llm.Engine
	Provider     llm.Provider
	ProviderName string
	ModelName    string
	Cleanup      func()
}

SessionRuntime is a per-conversation runtime for non-web platforms.

type Settings

type Settings struct {
	SystemPrompt string
	IdleTimeout  time.Duration
	// TelegramCarryoverChars controls how many trailing characters from the
	// previous Telegram session are carried into a replacement session.
	// 0 disables carry-over.
	TelegramCarryoverChars int
	MaxTurns               int
	Debug                  bool
	DebugRaw               bool
	Search                 bool
	// ForceExternalSearch disables provider-native search and uses external
	// web_search/read_url tools instead when search is enabled.
	ForceExternalSearch bool
	Tools               string
	MCP                 string
	Agent               string
	PlatformMessages    agents.PlatformMessagesConfig
	Store               session.Store
	Runner              runpkg.Runner
	// NewSession creates a fresh runtime instance for a new conversation.
	// Called once per platform session (for example, per Telegram chat session).
	NewSession func(context.Context) (*SessionRuntime, error)
}

Settings holds per-platform runtime settings derived from CLI flags and config.

type TelegramPlatform

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

func NewTelegramPlatform

func NewTelegramPlatform(cfg config.TelegramServeConfig) *TelegramPlatform

NewTelegramPlatform creates a new TelegramPlatform with the given config.

func (*TelegramPlatform) Name

func (p *TelegramPlatform) Name() string

func (*TelegramPlatform) NeedsSetup

func (p *TelegramPlatform) NeedsSetup() bool

NeedsSetup returns true when the bot token is missing.

func (*TelegramPlatform) Run

func (p *TelegramPlatform) Run(ctx context.Context, cfg *config.Config, settings Settings) error

Run starts the Telegram bot loop, blocking until ctx is cancelled.

func (*TelegramPlatform) RunSetup

func (p *TelegramPlatform) RunSetup() error

RunSetup runs an interactive wizard that collects and persists bot credentials.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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