Documentation
¶
Index ¶
- Constants
- func AddInternalService(reg Registry, s svc.Service)
- func InjectVirtualAgentTools(reg Registry, agents []*agent.Agent, domain string)
- func RewriteContainerDataSourceRefs(c types.Container, nameMap map[string]string) types.Container
- func WithPolicy(ctx context.Context, p *Policy) context.Context
- type ActivationSpec
- type AskFunc
- type DataFeed
- type DataSource
- type DataSources
- type Feed
- type FeedSpec
- type FeedSpecs
- type Handler
- type MatchSpec
- type Policy
- type Registry
- type Source
- type TimeoutResolver
Constants ¶
const ( ModeAsk = "ask" // ask user for every tool call ModeAuto = "auto" // execute automatically ModeDeny = "deny" // refuse tool execution )
Mode constants for tool execution behaviour.
Variables ¶
This section is empty.
Functions ¶
func AddInternalService ¶ added in v0.2.6
AddInternalService attempts to register a service as an internal MCP client on the default registry.
func InjectVirtualAgentTools ¶ added in v0.2.6
InjectVirtualAgentTools exposes agents as virtual tools when supported by the registry implementation.
func RewriteContainerDataSourceRefs ¶ added in v0.2.1
RewriteContainerDataSourceRefs returns a copy of the container with every dataSourceRef rewritten according to the provided name mapping. Keys are original names; values are transformed names.
Types ¶
type ActivationSpec ¶ added in v0.2.1
type ActivationSpec struct {
// Kind selects the activation mode: "history" or "tool_call".
Kind string `yaml:"kind,omitempty" json:"kind,omitempty"`
// Scope controls how many recorded calls are considered when kind==history:
// - "last" (default): only the most recent matching call is used
// - "all": aggregate data from all matching calls in the turn
Scope string `yaml:"scope,omitempty" json:"scope,omitempty"`
// Optional explicit tool to invoke when kind==tool_call. When omitted,
// match.service/method may be used as a fallback by the consumer.
Service string `yaml:"service,omitempty" json:"service,omitempty"`
Method string `yaml:"method,omitempty" json:"method,omitempty"`
Args map[string]interface{} `yaml:"args,omitempty" json:"args,omitempty"`
}
type AskFunc ¶
AskFunc is invoked when policy.Mode==ModeAsk. It should return true to approve the call, false to reject. It can optionally mutate the policy (for example to switch to auto mode after user confirmation).
type DataFeed ¶ added in v0.2.1
type DataFeed struct {
Name string `json:"name" yaml:"name"`
Data interface{} `json:"data" yaml:"data"`
RawSelector string `json:"rawSelector" yaml:"rawSelector"`
}
DataFeed carries a resolved value and the raw selector used to obtain it. The type of Data is intentionally interface{} to support both object and collection values (e.g., a map with explanation/steps or a []map rows list).
type DataSource ¶ added in v0.2.1
type DataSource struct {
types.DataSource `yaml:",inline"`
Source string `json:"source" yaml:"source"`
Name string `json:"name" yaml:"name"`
}
func (*DataSource) HasSource ¶ added in v0.2.1
func (d *DataSource) HasSource() bool
type DataSources ¶ added in v0.2.1
type DataSources map[string]*DataSource
func (DataSources) FeedDataSource ¶ added in v0.2.1
func (s DataSources) FeedDataSource() (*DataSource, error)
func (DataSources) Normalize ¶ added in v0.2.1
func (s DataSources) Normalize() map[string]*types.DataSource
Normalize returns normalized datasourcse
func (DataSources) Transform ¶ added in v0.2.1
func (s DataSources) Transform(hash string) (map[string]*types.DataSource, map[string]string)
Transform returns a normalized map of DataSources with keys suffixed by the provided hash, and a mapping from original name -> transformed name. Any internal DataSourceRef fields that reference other data sources are also rewritten using the mapping.
type Feed ¶ added in v0.2.1
type Feed struct {
ID string `json:"id" yaml:"id"`
// Data holds resolved data blocks keyed by data-source or container name.
Data DataFeed `json:"dataFeed" yaml:"dataFeed"`
// UI carries a renderable container definition for Forge-based UIs.
UI *types.Container `json:"ui" yaml:"ui"`
// DataSources defines UI data sources
DataSources map[string]*types.DataSource `yaml:"dataSources,omitempty" json:"dataSources,omitempty"`
Invoked bool `json:"-" yaml:"-"`
}
Feed describes a single matched rule and its extracted data. It is used as the payload for tool feeds rendered by the UI.
type FeedSpec ¶ added in v0.2.1
type FeedSpec struct {
ID string `yaml:"id,omitempty" json:"id,omitempty"`
Title string `yaml:"title,omitempty" json:"title,omitempty"`
Priority int `yaml:"priority,omitempty" json:"priority,omitempty"`
Match MatchSpec `yaml:"match" json:"match"`
Activation ActivationSpec `yaml:"activation" json:"activation"`
DataSources DataSources `yaml:"dataSource,omitempty" json:"dataSource,omitempty"`
UI types.Container `yaml:"ui" json:"ui"`
}
func (*FeedSpec) InvokeServiceMethod ¶ added in v0.2.1
InvokeServiceMethod returns the effective (service, method) to invoke for this spec, preferring Activation overrides and falling back to Match when empty.
func (*FeedSpec) ShallInvokeTool ¶ added in v0.2.1
ShallInvokeTool indicates whether this spec should trigger a direct tool invocation.
func (*FeedSpec) ShallUseHistory ¶ added in v0.2.1
ShallUseHistory indicates whether this spec should evaluate history (default when kind is empty) or explicitly when kind==history.
type FeedSpecs ¶ added in v0.2.1
type FeedSpecs []*FeedSpec
FeedSpecs is a convenience slice alias for helpers.
type MatchSpec ¶ added in v0.2.1
type MatchSpec struct {
Service string `yaml:"service,omitempty" json:"service,omitempty"`
Method string `yaml:"method,omitempty" json:"method,omitempty"`
}
type Policy ¶
type Policy struct {
Mode string // ask, auto or deny
AllowList []string // optional set of allowed tools (empty => all)
BlockList []string // optional set of blocked tools
Ask AskFunc // optional callback when Mode==ask
}
Policy controls runtime behaviour of tool execution.
func FromContext ¶
FromContext retrieves policy from context; may be nil.
type Registry ¶
type Registry interface {
// Definitions returns the merged list of available tool definitions.
Definitions() []llm.ToolDefinition
//MatchDefinition matches tool definition based on pattern
MatchDefinition(pattern string) []*llm.ToolDefinition
// GetDefinition fetches the definition for the given tool name. The second
// result value indicates whether the definition exists.
GetDefinition(name string) (*llm.ToolDefinition, bool)
// MustHaveTools converts a set of patterns into the LLM toolkit slice used by
// generation prompts.
MustHaveTools(patterns []string) ([]llm.Tool, error)
// Execute invokes the given tool with the supplied arguments and returns
// its textual result.
Execute(ctx context.Context, name string, args map[string]interface{}) (string, error)
// SetDebugLogger attaches a writer that receives every executed tool call
// for debugging.
SetDebugLogger(w io.Writer)
// Initialize allows registry implementations to perform optional
// one-time discovery or warm-up (e.g., preload MCP servers/tools).
// Implementations should be idempotent. Callers may safely ignore it.
Initialize(ctx context.Context)
}
Registry defines the minimal interface required by the rest of the code-base. Previous consumers used a concrete *Registry struct; moving to an interface allows alternative implementations (remote catalogues, mocks, etc.) while retaining backward-compatibility.
func NewDefaultRegistry ¶ added in v0.2.6
NewDefaultRegistry constructs the default MCP-backed tool registry with built-ins.
func WithConversation ¶ added in v0.2.0
WithConversation returns a Registry that guarantees ctx carries convID for every Execute call. All other methods delegate to the underlying registry.
type Source ¶ added in v0.2.1
type Source struct {
Service string `json:"service" yaml:"service"`
Method string `json:"method" yaml:"method"`
}
Source identifies the tool that produced the output observed by the rule.
type TimeoutResolver ¶ added in v0.2.10
TimeoutResolver may be implemented by registries that can suggest per-tool execution timeouts. The returned duration should be >0 to take effect; the boolean indicates whether a suggestion is available for the given name.