direct

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Feb 3, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package direct provides a gateway that implements ToolGateway by directly delegating to toolindex, tooldocs, and toolrun components. This gateway runs in-process with no isolation boundary.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrToolCallLimitExceeded is returned when MaxToolCalls is exceeded.
	ErrToolCallLimitExceeded = errors.New("tool call limit exceeded")

	// ErrChainStepLimitExceeded is returned when MaxChainSteps is exceeded.
	ErrChainStepLimitExceeded = errors.New("chain step limit exceeded")
)

Errors for limit enforcement

Functions

This section is empty.

Types

type Config

type Config struct {
	// Index is the tool index for search and lookup.
	Index index.Index

	// Docs is the documentation store.
	Docs tooldoc.Store

	// Runner is the tool execution runner.
	Runner run.Runner

	// MaxToolCalls limits the total number of tool invocations.
	// Zero means unlimited.
	MaxToolCalls int

	// MaxChainSteps limits the number of steps in a chain.
	// Zero means unlimited.
	MaxChainSteps int
}

Config configures a direct gateway.

type Gateway

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

Gateway implements ToolGateway by directly delegating to the index, docs, and runner components.

func New

func New(cfg Config) *Gateway

New creates a new direct gateway with the given configuration.

func (*Gateway) DescribeTool

func (g *Gateway) DescribeTool(ctx context.Context, id string, level tooldoc.DetailLevel) (tooldoc.ToolDoc, error)

DescribeTool delegates to the docs store.

func (*Gateway) GetToolCalls

func (g *Gateway) GetToolCalls() []runtime.ToolCallRecord

GetToolCalls returns a copy of all recorded tool calls.

func (*Gateway) ListNamespaces

func (g *Gateway) ListNamespaces(ctx context.Context) ([]string, error)

ListNamespaces delegates to the index.

func (*Gateway) ListToolExamples

func (g *Gateway) ListToolExamples(ctx context.Context, id string, maxExamples int) ([]tooldoc.ToolExample, error)

ListToolExamples delegates to the docs store.

func (*Gateway) Reset

func (g *Gateway) Reset()

Reset clears recorded tool calls and resets the call counter.

func (*Gateway) RunChain

func (g *Gateway) RunChain(ctx context.Context, steps []run.ChainStep) (run.RunResult, []run.StepResult, error)

RunChain delegates to the runner and records the calls.

func (*Gateway) RunTool

func (g *Gateway) RunTool(ctx context.Context, id string, args map[string]any) (run.RunResult, error)

RunTool delegates to the runner and records the call.

func (*Gateway) SearchTools

func (g *Gateway) SearchTools(ctx context.Context, query string, limit int) ([]index.Summary, error)

SearchTools delegates to the index.

Jump to

Keyboard shortcuts

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