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.
Generation parameter pointers (Temperature, TopP, etc.) are only set when the user has explicitly configured them via CLI flag, environment variable, or global config file. This allows per-model defaults from modelSettings and customModels to fill in unset parameters downstream.
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
// DisableCoreTools, when true, prevents loading any core tools.
// If both DisableCoreTools is true and CoreTools is empty, the agent
// will have no tools (useful for simple chat completions).
DisableCoreTools bool
// 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
// AuthHandler handles OAuth authorization for remote MCP servers.
// When set, remote transports are configured with OAuth support.
AuthHandler tools.MCPAuthHandler
// TokenStoreFactory, if non-nil, creates a custom token store for each
// remote MCP server's OAuth tokens. When nil, the default file-based
// token store is used.
TokenStoreFactory tools.TokenStoreFactory
// OnMCPServerLoaded, if non-nil, is called when each MCP server finishes
// loading (successfully or with error). Called from the background goroutine.
OnMCPServerLoaded func(serverName string, toolCount int, err error)
}
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.