kitsetup

package
v0.38.0 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package kitsetup contains agent creation logic used by both the CLI binary and the SDK's kit.New(). It is internal — external SDK consumers should use kit.New() which delegates here.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildProviderConfig

func BuildProviderConfig() (*models.ProviderConfig, string, error)

BuildProviderConfig creates a *models.ProviderConfig from the current viper state. All entry points (root, script, SDK) converge through this function.

Types

type AgentSetupOptions

type AgentSetupOptions struct {
	// MCPConfig is the MCP server configuration. Required.
	MCPConfig *config.Config
	// ShowSpinner shows a loading spinner for Ollama models.
	ShowSpinner bool
	// SpinnerFunc provides the spinner implementation (nil = no spinner).
	SpinnerFunc agent.SpinnerFunc
	// UseBufferedLogger captures debug messages for later display (root
	// non-interactive path). When false a simple logger is used instead.
	UseBufferedLogger bool
	// Quiet suppresses output. Replaces the cmd package's quietFlag variable.
	Quiet bool
	// CoreTools overrides the default core tool set. If empty, core.AllTools()
	// is used. Allows SDK users to pass custom tools (e.g. with WithWorkDir).
	CoreTools []fantasy.AgentTool
	// ExtraTools are additional tools added alongside core, MCP, and extension
	// tools. They do not replace the defaults — they extend them.
	ExtraTools []fantasy.AgentTool
	// ToolWrapper is an optional function that wraps tools after extension
	// wrapping. Used by the SDK hook system. Both wrappers compose:
	// extension wrapper runs first (inner), then this wrapper (outer).
	ToolWrapper func([]fantasy.AgentTool) []fantasy.AgentTool

	// ProviderConfig, when non-nil, is used directly instead of calling
	// BuildProviderConfig(). Callers that already hold viperInitMu can
	// pre-build this and release the lock before calling SetupAgent, so the
	// slow agent/MCP initialisation runs concurrently with other New() calls.
	ProviderConfig *models.ProviderConfig
	// Debug enables debug logging. When zero-value, viper is consulted.
	// Only meaningful when ProviderConfig is also set.
	Debug bool
	// NoExtensions skips extension loading. When false, viper is consulted.
	// Only meaningful when ProviderConfig is also set.
	NoExtensions bool
	// MaxSteps overrides the agent step limit. 0 means use viper value.
	// Only meaningful when ProviderConfig is also set.
	MaxSteps int
	// StreamingEnabled controls streaming. Only meaningful when ProviderConfig
	// is also set.
	StreamingEnabled bool
}

AgentSetupOptions configures agent creation.

type AgentSetupResult

type AgentSetupResult struct {
	Agent          *agent.Agent
	BufferedLogger *tools.BufferedDebugLogger
	// ExtRunner is the extension runner (nil when --no-extensions or no
	// extensions were discovered).
	ExtRunner *extensions.Runner
}

AgentSetupResult bundles the created agent and any debug logger so the caller can flush buffered messages when appropriate.

func SetupAgent

func SetupAgent(ctx context.Context, opts AgentSetupOptions) (*AgentSetupResult, error)

SetupAgent creates an agent from the current viper state + the provided options. It wraps BuildProviderConfig and agent.CreateAgent.

Jump to

Keyboard shortcuts

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