latest

package
v1.16.0 Latest Latest
Warning

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

Go to latest
Published: Dec 30, 2025 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const Version = "3"

Variables

This section is empty.

Functions

func UpgradeIfNeeded

func UpgradeIfNeeded(c any) (any, error)

Types

type APIToolConfig

type APIToolConfig struct {
	Instruction string            `json:"instruction,omitempty"`
	Name        string            `json:"name,omitempty"`
	Required    []string          `json:"required,omitempty"`
	Args        map[string]any    `json:"args,omitempty"`
	Endpoint    string            `json:"endpoint,omitempty"`
	Method      string            `json:"method,omitempty"`
	Headers     map[string]string `json:"headers,omitempty"`
	// OutputSchema optionally describes the API response as JSON Schema for MCP/Code Mode consumers; runtime still returns the raw string body.
	OutputSchema map[string]any `json:"output_schema,omitempty"`
}

type AgentConfig

type AgentConfig struct {
	Model              string            `json:"model,omitempty"`
	Description        string            `json:"description,omitempty"`
	WelcomeMessage     string            `json:"welcome_message,omitempty"`
	Toolsets           []Toolset         `json:"toolsets,omitempty"`
	Instruction        string            `json:"instruction,omitempty"`
	SubAgents          []string          `json:"sub_agents,omitempty"`
	Handoffs           []string          `json:"handoffs,omitempty"`
	RAG                []string          `json:"rag,omitempty"`
	AddDate            bool              `json:"add_date,omitempty"`
	AddEnvironmentInfo bool              `json:"add_environment_info,omitempty"`
	CodeModeTools      bool              `json:"code_mode_tools,omitempty"`
	MaxIterations      int               `json:"max_iterations,omitempty"`
	NumHistoryItems    int               `json:"num_history_items,omitempty"`
	AddPromptFiles     []string          `json:"add_prompt_files,omitempty" yaml:"add_prompt_files,omitempty"`
	Commands           types.Commands    `json:"commands,omitempty"`
	StructuredOutput   *StructuredOutput `json:"structured_output,omitempty"`
	Skills             *bool             `json:"skills,omitempty"`
}

AgentConfig represents a single agent configuration

type Config

type Config struct {
	Version  string                 `json:"version,omitempty"`
	Agents   map[string]AgentConfig `json:"agents,omitempty"`
	Models   map[string]ModelConfig `json:"models,omitempty"`
	RAG      map[string]RAGConfig   `json:"rag,omitempty"`
	Metadata Metadata               `json:"metadata,omitempty"`
}

Config represents the entire configuration file

func Parse

func Parse(data []byte) (Config, error)

func (*Config) UnmarshalYAML

func (t *Config) UnmarshalYAML(unmarshal func(any) error) error

type DeferConfig added in v1.9.24

type DeferConfig struct {
	// DeferAll is true when all tools should be deferred
	DeferAll bool `json:"-"`
	// Tools is the list of specific tool names to defer (empty if DeferAll is true)
	Tools []string `json:"-"`
}

DeferConfig represents the deferred loading configuration for a toolset. It can be either a boolean (true to defer all tools) or a slice of strings (list of tool names to defer).

func (DeferConfig) IsEmpty added in v1.9.24

func (d DeferConfig) IsEmpty() bool

func (DeferConfig) MarshalYAML added in v1.9.24

func (d DeferConfig) MarshalYAML() ([]byte, error)

func (*DeferConfig) UnmarshalYAML added in v1.9.24

func (d *DeferConfig) UnmarshalYAML(unmarshal func(any) error) error

type Metadata

type Metadata struct {
	Author  string `json:"author,omitempty"`
	License string `json:"license,omitempty"`
	Readme  string `json:"readme,omitempty"`
	Version string `json:"version,omitempty"`
}

type ModelConfig

type ModelConfig struct {
	Provider          string   `json:"provider,omitempty"`
	Model             string   `json:"model,omitempty"`
	Temperature       *float64 `json:"temperature,omitempty"`
	MaxTokens         *int64   `json:"max_tokens,omitempty"`
	TopP              *float64 `json:"top_p,omitempty"`
	FrequencyPenalty  *float64 `json:"frequency_penalty,omitempty"`
	PresencePenalty   *float64 `json:"presence_penalty,omitempty"`
	BaseURL           string   `json:"base_url,omitempty"`
	ParallelToolCalls *bool    `json:"parallel_tool_calls,omitempty"`
	TokenKey          string   `json:"token_key,omitempty"`
	// ProviderOpts allows provider-specific options.
	ProviderOpts map[string]any `json:"provider_opts,omitempty"`
	TrackUsage   *bool          `json:"track_usage,omitempty"`
	// ThinkingBudget controls reasoning effort/budget:
	// - For OpenAI: accepts string levels "minimal", "low", "medium", "high"
	// - For Anthropic: accepts integer token budget (1024-32000)
	// - For other providers: may be ignored
	ThinkingBudget *ThinkingBudget `json:"thinking_budget,omitempty"`
}

ModelConfig represents the configuration for a model

type PostEditConfig

type PostEditConfig struct {
	Path string `json:"path"`
	Cmd  string `json:"cmd"`
}

PostEditConfig represents a post-edit command configuration

type RAGChunkingConfig

type RAGChunkingConfig struct {
	Size                  int  `json:"size,omitempty"`
	Overlap               int  `json:"overlap,omitempty"`
	RespectWordBoundaries bool `json:"respect_word_boundaries,omitempty"`
	// CodeAware enables code-aware chunking for source files. When true, the
	// chunking strategy uses tree-sitter for AST-based chunking, producing
	// semantically aligned chunks (e.g., whole functions). Falls back to
	// plain text chunking for unsupported languages.
	CodeAware bool `json:"code_aware,omitempty"`
}

RAGChunkingConfig represents text chunking configuration

func (*RAGChunkingConfig) UnmarshalYAML

func (c *RAGChunkingConfig) UnmarshalYAML(unmarshal func(any) error) error

UnmarshalYAML implements custom unmarshaling to apply sensible defaults for chunking

type RAGConfig

type RAGConfig struct {
	Tool       RAGToolConfig       `json:"tool,omitempty"`        // Tool configuration
	Docs       []string            `json:"docs,omitempty"`        // Shared documents across all strategies
	RespectVCS *bool               `json:"respect_vcs,omitempty"` // Whether to respect VCS ignore files like .gitignore (default: true)
	Strategies []RAGStrategyConfig `json:"strategies,omitempty"`  // Array of strategy configurations
	Results    RAGResultsConfig    `json:"results,omitempty"`
}

RAGConfig represents a RAG (Retrieval-Augmented Generation) configuration Uses a unified strategies array for flexible, extensible configuration

func (*RAGConfig) GetRespectVCS added in v1.9.30

func (c *RAGConfig) GetRespectVCS() bool

GetRespectVCS returns whether VCS ignore files should be respected, defaulting to true

func (*RAGConfig) UnmarshalYAML

func (c *RAGConfig) UnmarshalYAML(unmarshal func(any) error) error

UnmarshalYAML for RAGConfig ensures that the Results field is always initialized with defaults, even when the `results` block is omitted.

type RAGDatabaseConfig

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

RAGDatabaseConfig represents database configuration for RAG strategies. Currently it only supports a single string value which is interpreted as the path to a SQLite database file.

func (*RAGDatabaseConfig) AsString

func (d *RAGDatabaseConfig) AsString() (string, error)

AsString returns the database config as a connection string For simple string configs, returns as-is For structured configs, builds connection string based on type

func (*RAGDatabaseConfig) IsEmpty

func (d *RAGDatabaseConfig) IsEmpty() bool

IsEmpty returns true if no database is configured

func (*RAGDatabaseConfig) UnmarshalYAML

func (d *RAGDatabaseConfig) UnmarshalYAML(unmarshal func(any) error) error

UnmarshalYAML implements custom unmarshaling for DatabaseConfig

type RAGFusionConfig

type RAGFusionConfig struct {
	Strategy string             `json:"strategy,omitempty"` // Fusion strategy: "rrf" (Reciprocal Rank Fusion), "weighted", "max"
	K        int                `json:"k,omitempty"`        // RRF parameter k (default: 60)
	Weights  map[string]float64 `json:"weights,omitempty"`  // Strategy weights for weighted fusion
}

RAGFusionConfig represents configuration for combining multi-strategy results

type RAGRerankingConfig

type RAGRerankingConfig struct {
	Model     string  `json:"model"`               // Model reference for reranking (e.g., "hf.co/ggml-org/Qwen3-Reranker-0.6B-Q8_0-GGUF")
	TopK      int     `json:"top_k,omitempty"`     // Optional: only rerank top K results (0 = rerank all)
	Threshold float64 `json:"threshold,omitempty"` // Optional: minimum score threshold after reranking (default: 0.5)
	Criteria  string  `json:"criteria,omitempty"`  // Optional: domain-specific relevance criteria to guide scoring
}

RAGRerankingConfig represents reranking configuration

func (*RAGRerankingConfig) UnmarshalYAML

func (r *RAGRerankingConfig) UnmarshalYAML(unmarshal func(any) error) error

UnmarshalYAML implements custom unmarshaling to apply sensible defaults for reranking

type RAGResultsConfig

type RAGResultsConfig struct {
	Limit             int                 `json:"limit,omitempty"`               // Maximum number of results to return (top K)
	Fusion            *RAGFusionConfig    `json:"fusion,omitempty"`              // How to combine results from multiple strategies
	Reranking         *RAGRerankingConfig `json:"reranking,omitempty"`           // Optional reranking configuration
	Deduplicate       bool                `json:"deduplicate,omitempty"`         // Remove duplicate documents across strategies
	IncludeScore      bool                `json:"include_score,omitempty"`       // Include relevance scores in results
	ReturnFullContent bool                `json:"return_full_content,omitempty"` // Return full document content instead of just matched chunks
}

RAGResultsConfig represents result post-processing configuration (common across strategies)

func (*RAGResultsConfig) UnmarshalYAML

func (r *RAGResultsConfig) UnmarshalYAML(unmarshal func(any) error) error

UnmarshalYAML implements custom unmarshaling so we can apply sensible defaults

type RAGStrategyConfig

type RAGStrategyConfig struct {
	Type     string            `json:"type"`               // Strategy type: "chunked-embeddings", "bm25", etc.
	Docs     []string          `json:"docs,omitempty"`     // Strategy-specific documents (augments shared docs)
	Database RAGDatabaseConfig `json:"database,omitempty"` // Database configuration
	Chunking RAGChunkingConfig `json:"chunking,omitempty"` // Chunking configuration
	Limit    int               `json:"limit,omitempty"`    // Max results from this strategy (for fusion input)

	// Strategy-specific parameters (arbitrary key-value pairs)
	// Examples:
	// - chunked-embeddings: embedding_model, similarity_metric, threshold, vector_dimensions
	// - bm25: k1, b, threshold
	Params map[string]any // Flattened into parent JSON
}

RAGStrategyConfig represents a single retrieval strategy configuration Strategy-specific fields are stored in Params (validated by strategy implementation)

func (RAGStrategyConfig) MarshalJSON added in v1.9.24

func (s RAGStrategyConfig) MarshalJSON() ([]byte, error)

MarshalJSON implements custom marshaling to flatten Params into parent level This ensures JSON and YAML have the same flattened format for consistency

func (RAGStrategyConfig) MarshalYAML added in v1.9.24

func (s RAGStrategyConfig) MarshalYAML() ([]byte, error)

MarshalYAML implements custom marshaling to flatten Params into parent level

func (*RAGStrategyConfig) UnmarshalJSON added in v1.9.24

func (s *RAGStrategyConfig) UnmarshalJSON(data []byte) error

UnmarshalJSON implements custom unmarshaling to capture all extra fields into Params This ensures JSON and YAML have the same flattened format for consistency

func (*RAGStrategyConfig) UnmarshalYAML

func (s *RAGStrategyConfig) UnmarshalYAML(unmarshal func(any) error) error

UnmarshalYAML implements custom unmarshaling to capture all extra fields into Params This allows strategies to have flexible, strategy-specific configuration parameters without requiring changes to the core config schema

type RAGToolConfig added in v1.9.26

type RAGToolConfig struct {
	Name        string `json:"name,omitempty"`        // Custom name for the tool (defaults to RAG source name if empty)
	Description string `json:"description,omitempty"` // Tool description (what the tool does)
	Instruction string `json:"instruction,omitempty"` // Tool instruction (how to use the tool effectively)
}

RAGToolConfig represents tool-specific configuration for a RAG source

type Remote

type Remote struct {
	URL           string            `json:"url"`
	TransportType string            `json:"transport_type,omitempty"`
	Headers       map[string]string `json:"headers,omitempty"`
}

type ScriptShellToolConfig

type ScriptShellToolConfig struct {
	Cmd         string `json:"cmd"`
	Description string `json:"description"`

	// Args is directly passed as "properties" in the JSON schema
	Args map[string]any `json:"args,omitempty"`

	// Required is directly passed as "required" in the JSON schema
	Required []string `json:"required"`

	Env        map[string]string `json:"env,omitempty"`
	WorkingDir string            `json:"working_dir,omitempty"`
}

ScriptShellToolConfig represents a custom shell tool configuration

type StructuredOutput

type StructuredOutput struct {
	// Name is the name of the response format
	Name string `json:"name"`
	// Description is optional description of the response format
	Description string `json:"description,omitempty"`
	// Schema is a JSON schema object defining the structure
	Schema map[string]any `json:"schema"`
	// Strict enables strict schema adherence (OpenAI only)
	Strict bool `json:"strict,omitempty"`
}

StructuredOutput defines a JSON schema for structured output

type ThinkingBudget

type ThinkingBudget struct {
	// Effort stores string-based reasoning effort levels
	Effort string `json:"effort,omitempty"`
	// Tokens stores integer-based token budgets
	Tokens int `json:"tokens,omitempty"`
}

ThinkingBudget represents reasoning budget configuration. It accepts either a string effort level or an integer token budget: - String: "minimal", "low", "medium", "high" (for OpenAI) - Integer: token count (for Anthropic, range 1024-32768)

func (ThinkingBudget) MarshalJSON added in v1.9.24

func (t ThinkingBudget) MarshalJSON() ([]byte, error)

MarshalJSON implements custom marshaling to output simple string or int format This ensures JSON and YAML have the same flattened format for consistency

func (ThinkingBudget) MarshalYAML added in v1.9.24

func (t ThinkingBudget) MarshalYAML() ([]byte, error)

MarshalYAML implements custom marshaling to output simple string or int format

func (*ThinkingBudget) UnmarshalJSON added in v1.9.24

func (t *ThinkingBudget) UnmarshalJSON(data []byte) error

UnmarshalJSON implements custom unmarshaling to accept simple string or int format This ensures JSON and YAML have the same flattened format for consistency

func (*ThinkingBudget) UnmarshalYAML

func (t *ThinkingBudget) UnmarshalYAML(unmarshal func(any) error) error

type Toolset

type Toolset struct {
	Type        string   `json:"type,omitempty"`
	Tools       []string `json:"tools,omitempty"`
	Instruction string   `json:"instruction,omitempty"`
	Toon        string   `json:"toon,omitempty"`

	Defer DeferConfig `json:"defer,omitempty" yaml:"defer,omitempty"`

	// For the `mcp` tool
	Command string   `json:"command,omitempty"`
	Args    []string `json:"args,omitempty"`
	Ref     string   `json:"ref,omitempty"`
	Remote  Remote   `json:"remote,omitempty"`
	Config  any      `json:"config,omitempty"`

	// For the `a2a` tool
	Name string `json:"name,omitempty"`
	URL  string `json:"url,omitempty"`

	// For `shell`, `script` or `mcp` tools
	Env map[string]string `json:"env,omitempty"`

	// For the `todo` tool
	Shared bool `json:"shared,omitempty"`

	// For the `memory` tool
	Path string `json:"path,omitempty"`

	// For the `script` tool
	Shell map[string]ScriptShellToolConfig `json:"shell,omitempty"`

	// For the `filesystem` tool - post-edit commands
	PostEdit []PostEditConfig `json:"post_edit,omitempty"`

	APIConfig APIToolConfig `json:"api_config"`

	// For the `filesystem` tool - VCS integration
	IgnoreVCS *bool `json:"ignore_vcs,omitempty"`

	// For the `fetch` tool
	Timeout int `json:"timeout,omitempty"`
}

Toolset represents a tool configuration

func (*Toolset) UnmarshalYAML

func (t *Toolset) UnmarshalYAML(unmarshal func(any) error) error

Jump to

Keyboard shortcuts

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