config

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ConfigProvider

type ConfigProvider interface {
	GetNode(name string) (models.Node, bool)
	GetHost(name string) (models.Host, bool)
	GetIdentity(name string) (models.Identity, bool)
	AddHost(name string, host models.Host)
	AddIdentity(name string, identity models.Identity)
	AddNode(name string, node models.Node)
	DeleteNode(name string)
	ListNodes() map[string]models.Node
	GetNodesByTag(tag string) map[string]models.Node
	ListIdentities() map[string]models.Identity
	DeleteIdentity(name string)
	Find(input string) string
	GetConfig() *Configuration
}

ConfigProvider 定义 Connector 获取配置数据的接口

func NewProvider

func NewProvider(cfg *Configuration) ConfigProvider

NewProvider 创建一个新的配置提供者实例

type Configuration

type Configuration struct {
	Identities *concurrent.Map[string, models.Identity] `yaml:"identities"`
	Hosts      *concurrent.Map[string, models.Host]     `yaml:"hosts"`
	Nodes      *concurrent.Map[string, models.Node]     `yaml:"nodes"`
	Guardrail  *GuardrailConfig                         `yaml:"guardrail,omitempty"`
}

Configuration 对应 yaml 文件的顶层结构

type GuardrailConfig

type GuardrailConfig struct {
	Enabled           bool                        `yaml:"enabled"`
	AuditLog          string                      `yaml:"audit_log,omitempty"`
	ApprovalThreshold string                      `yaml:"approval_threshold,omitempty"` // "safe"|"moderate"|"dangerous"
	BlockedPatterns   []string                    `yaml:"blocked_patterns,omitempty"`
	ProtectedPaths    []string                    `yaml:"protected_paths,omitempty"`
	NodeOverrides     map[string]NodeGuardrailCfg `yaml:"nodes,omitempty"`

	// NoElicitFallback controls behavior when the MCP client does not support
	// Elicitation (e.g. Gemini CLI).
	//   "deny"      — reject all operations that need approval (most secure)
	//   "allow"     — allow all, trust client-side tool approval + ToolAnnotations
	//   "downgrade" — allow moderate, still deny dangerous (recommended default)
	NoElicitFallback string `yaml:"no_elicit_fallback,omitempty"`
}

GuardrailConfig configures the MCP safety guardrail.

type NodeGuardrailCfg

type NodeGuardrailCfg struct {
	ApprovalThreshold string `yaml:"approval_threshold"`
}

NodeGuardrailCfg holds per-node (glob pattern) policy overrides.

type Provider

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

Provider 提供了基础的配置查询和管理功能

func (Provider) AddHost

func (cp Provider) AddHost(hostID string, host models.Host)

func (Provider) AddIdentity

func (cp Provider) AddIdentity(identityID string, identity models.Identity)

func (Provider) AddNode

func (cp Provider) AddNode(nodeID string, node models.Node)

func (Provider) DeleteIdentity

func (cp Provider) DeleteIdentity(name string)

func (Provider) DeleteNode

func (cp Provider) DeleteNode(nodeID string)

func (Provider) Find

func (cp Provider) Find(input string) string

Find 匹配用户输入

func (Provider) GetConfig added in v0.3.0

func (cp Provider) GetConfig() *Configuration

func (Provider) GetHost

func (cp Provider) GetHost(nodeID string) (models.Host, bool)

func (Provider) GetIdentity

func (cp Provider) GetIdentity(nodeID string) (models.Identity, bool)

func (Provider) GetNode

func (cp Provider) GetNode(nodeID string) (models.Node, bool)

func (Provider) GetNodesByTag

func (cp Provider) GetNodesByTag(tag string) map[string]models.Node

func (Provider) ListIdentities

func (cp Provider) ListIdentities() map[string]models.Identity

func (Provider) ListNodes

func (cp Provider) ListNodes() map[string]models.Node

type Store

type Store interface {
	Load() (*Configuration, error)
	Save(cfg *Configuration) error
}

Store 定义了配置存储和持久化的接口

func NewDefaultStore

func NewDefaultStore(path string, keyPath string) Store

NewDefaultStore 创建一个默认的文件系统配置存储实例

Jump to

Keyboard shortcuts

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