Documentation
¶
Index ¶
- func IsMCPToolName(name string) bool
- func RemapLegacyAdvisorToolName(toolName string) string
- func ScenarioFromContext(ctx context.Context) (typ.RuleScenario, bool)
- type AdvisorHook
- type DefaultExecutor
- type Executor
- type Hook
- type HookDeps
- type Pipeline
- type RuntimeCaller
- type ToolCall
- type ToolProvider
- type VirtualToolRegistry
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsMCPToolName ¶
IsMCPToolName reports whether name looks like a normalized MCP tool name (i.e. it parses successfully via ParseNormalizedToolName).
func RemapLegacyAdvisorToolName ¶
RemapLegacyAdvisorToolName normalises the legacy "advisor" source ID to "builtin". All other tool names pass through unchanged.
func ScenarioFromContext ¶
func ScenarioFromContext(ctx context.Context) (typ.RuleScenario, bool)
ScenarioFromContext reads the scenario stored under client.ScenarioContextKey. Useful for HookDeps.GetScenarioSink implementations.
Types ¶
type AdvisorHook ¶
type AdvisorHook struct{}
AdvisorHook injects AdvisorContext before an advisor tool call. Exported for test compatibility in packages that alias this type.
func (AdvisorHook) Match ¶
func (h AdvisorHook) Match(toolName string) bool
func (AdvisorHook) PrepareContext ¶
type DefaultExecutor ¶
type DefaultExecutor struct {
// contains filtered or unexported fields
}
DefaultExecutor is the standard implementation of Executor.
func NewDefaultExecutor ¶
func NewDefaultExecutor(rt RuntimeCaller, deps HookDeps) *DefaultExecutor
NewDefaultExecutor creates a DefaultExecutor with no hooks. Use Pipeline.NewExecutor to get an executor with registered tool hooks.
type Executor ¶
type Executor interface {
Execute(ctx context.Context, call ToolCall) (context.Context, coretool.ToolResult, error)
}
Executor executes a single MCP tool call through the full pipeline: name validation, legacy remapping, callable guard, hooks, and dispatch.
type Hook ¶
type Hook interface {
Match(toolName string) bool
PrepareContext(deps HookDeps, ctx context.Context, messages []map[string]any) context.Context
}
Hook prepares runtime context for a specific MCP servertool call. Hooks run after the worker response arrives and before local tool execution.
type HookDeps ¶
type HookDeps interface {
// GetAdvisorMaxUses returns the configured maximum advisor calls per request.
GetAdvisorMaxUses() int
// GetScenarioSink returns an enabled recording sink for the given scenario, or nil.
GetScenarioSink(ctx context.Context) *obs.Sink
}
HookDeps provides the server-level dependencies that hooks may need.
type Pipeline ¶
type Pipeline struct {
// contains filtered or unexported fields
}
Pipeline owns all registered ToolProviders and builds executors with the correct hook set. Construct once at server startup; call Register for each tool, then RegisterInto to populate the VirtualToolRegistry.
func (*Pipeline) NewExecutor ¶
func (p *Pipeline) NewExecutor(rt RuntimeCaller, deps HookDeps) *DefaultExecutor
NewExecutor returns a DefaultExecutor wired with the current hook list.
func (*Pipeline) Register ¶
func (p *Pipeline) Register(provider ToolProvider)
Register adds a ToolProvider to the pipeline. If provider.Hook() is non-nil it is appended to the hook list.
func (*Pipeline) RegisterInto ¶
func (p *Pipeline) RegisterInto(registry VirtualToolRegistry)
RegisterInto writes all provider descriptors into registry. Call once after all providers have been registered.
type RuntimeCaller ¶
type RuntimeCaller interface {
CallTool(ctx context.Context, normalizedName, arguments string) (coretool.ToolResult, error)
ListCallableServerToolNames(ctx context.Context) map[string]struct{}
GetAdvisorMaxUses() int
}
RuntimeCaller is the subset of the tool runtime used by DefaultExecutor.
type ToolProvider ¶
type ToolProvider interface {
// Descriptor returns the VirtualTool to register in the runtime registry.
Descriptor() coretool.VirtualTool
// Hook returns a pre-call context hook, or nil if not needed.
Hook() Hook
}
ToolProvider is implemented by each virtual server tool. Register once; Pipeline derives hooks and registry entries from it.
type VirtualToolRegistry ¶
type VirtualToolRegistry interface {
Register(coretool.VirtualTool)
}