Documentation
¶
Overview ¶
internal/tools/multi_repo.go
Index ¶
- func IsAuthError(err error) bool
- func NewPersistentRepo(localTools map[string]taskengine.ToolsRepo, dbInstance libdb.DBManager, ...) taskengine.ToolsRepo
- func NewSimpleProvider(tools map[string]taskengine.ToolsRepo) taskengine.ToolsRepo
- func PerformAuthFlow(ctx context.Context, tools *runtimetypes.RemoteTools, client *http.Client) (map[string]ParamArg, error)
- type ArgLocation
- type AuthError
- type MockToolsRepo
- func (m *MockToolsRepo) CallCount() int
- func (m *MockToolsRepo) Exec(ctx context.Context, startingTime time.Time, input any, debug bool, ...) (any, taskengine.DataType, error)
- func (m *MockToolsRepo) GetSchemasForSupportedTools(ctx context.Context) (map[string]*openapi3.T, error)
- func (m *MockToolsRepo) GetToolsForToolsByName(ctx context.Context, name string) ([]taskengine.Tool, error)
- func (m *MockToolsRepo) LastCall() *ToolsCallRecord
- func (m *MockToolsRepo) Reset()
- func (m *MockToolsRepo) Supports(ctx context.Context) ([]string, error)
- func (m *MockToolsRepo) WithErrorSequence(errors ...error) *MockToolsRepo
- func (m *MockToolsRepo) WithResponse(toolsType string, response ToolsResponse) *MockToolsRepo
- type MultiRepo
- func (m *MultiRepo) Exec(ctx context.Context, startingTime time.Time, input any, debug bool, ...) (any, taskengine.DataType, error)
- func (m *MultiRepo) GetSchemasForSupportedTools(ctx context.Context) (map[string]*openapi3.T, error)
- func (m *MultiRepo) GetToolsForToolsByName(ctx context.Context, name string) ([]taskengine.Tool, error)
- func (m *MultiRepo) Supports(ctx context.Context) ([]string, error)
- type OpenAPIToolProtocol
- func (p *OpenAPIToolProtocol) ExecuteTool(ctx context.Context, endpointURL string, httpClient *http.Client, ...) (interface{}, taskengine.DataType, error)
- func (p *OpenAPIToolProtocol) FetchSchema(ctx context.Context, endpointURL string, httpClient *http.Client) (*openapi3.T, error)
- func (p *OpenAPIToolProtocol) FetchTools(ctx context.Context, endpointURL string, injectParams map[string]ParamArg, ...) ([]taskengine.Tool, error)
- type ParamArg
- type PersistentRepo
- func (p *PersistentRepo) Exec(ctx context.Context, startingTime time.Time, input any, debug bool, ...) (any, taskengine.DataType, error)
- func (p *PersistentRepo) GetSchemasForSupportedTools(ctx context.Context) (map[string]*openapi3.T, error)
- func (p *PersistentRepo) GetToolsForToolsByName(ctx context.Context, name string) ([]taskengine.Tool, error)
- func (p *PersistentRepo) Supports(ctx context.Context) ([]string, error)
- type SimpleRepo
- func (m *SimpleRepo) Exec(ctx context.Context, startingTime time.Time, input any, debug bool, ...) (any, taskengine.DataType, error)
- func (m *SimpleRepo) GetSchemasForSupportedTools(ctx context.Context) (map[string]*openapi3.T, error)
- func (m *SimpleRepo) GetToolsForToolsByName(ctx context.Context, name string) ([]taskengine.Tool, error)
- func (m *SimpleRepo) Supports(ctx context.Context) ([]string, error)
- type ToolProtocol
- type ToolsCallRecord
- type ToolsResponse
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsAuthError ¶
func NewPersistentRepo ¶
func NewPersistentRepo( localTools map[string]taskengine.ToolsRepo, dbInstance libdb.DBManager, httpClient *http.Client, messenger libbus.Messenger, tracker libtracker.ActivityTracker, ) taskengine.ToolsRepo
func NewSimpleProvider ¶
func NewSimpleProvider(tools map[string]taskengine.ToolsRepo) taskengine.ToolsRepo
func PerformAuthFlow ¶
func PerformAuthFlow(ctx context.Context, tools *runtimetypes.RemoteTools, client *http.Client) (map[string]ParamArg, error)
Types ¶
type ArgLocation ¶
type ArgLocation int
const ( ArgLocationQuery ArgLocation = iota ArgLocationHeader ArgLocationPath ArgLocationBody )
type MockToolsRepo ¶
type MockToolsRepo struct {
Calls []ToolsCallRecord
ResponseMap map[string]ToolsResponse
DefaultResponse ToolsResponse
ErrorSequence []error
// contains filtered or unexported fields
}
MockToolsRepo is a mock implementation of the ToolsRepo interface.
func NewMockToolsRegistry ¶
func NewMockToolsRegistry() *MockToolsRepo
NewMockToolsRegistry returns a new instance of MockToolsRepo.
func (*MockToolsRepo) CallCount ¶
func (m *MockToolsRepo) CallCount() int
CallCount returns number of times Exec was called
func (*MockToolsRepo) Exec ¶
func (m *MockToolsRepo) Exec( ctx context.Context, startingTime time.Time, input any, debug bool, args *taskengine.ToolsCall, ) (any, taskengine.DataType, error)
Exec simulates execution of a tools call using the new simplified signature.
func (*MockToolsRepo) GetSchemasForSupportedTools ¶
func (m *MockToolsRepo) GetSchemasForSupportedTools(ctx context.Context) (map[string]*openapi3.T, error)
GetSchemasForSupportedTools returns OpenAPI schemas for all mocked tools.
func (*MockToolsRepo) GetToolsForToolsByName ¶
func (m *MockToolsRepo) GetToolsForToolsByName(ctx context.Context, name string) ([]taskengine.Tool, error)
func (*MockToolsRepo) LastCall ¶
func (m *MockToolsRepo) LastCall() *ToolsCallRecord
LastCall returns the most recent tools call
func (*MockToolsRepo) Reset ¶
func (m *MockToolsRepo) Reset()
Reset clears all recorded calls and resets counters
func (*MockToolsRepo) Supports ¶
func (m *MockToolsRepo) Supports(ctx context.Context) ([]string, error)
func (*MockToolsRepo) WithErrorSequence ¶
func (m *MockToolsRepo) WithErrorSequence(errors ...error) *MockToolsRepo
WithErrorSequence sets a sequence of errors to return
func (*MockToolsRepo) WithResponse ¶
func (m *MockToolsRepo) WithResponse(toolsType string, response ToolsResponse) *MockToolsRepo
WithResponse configures a response for a specific tools type using the new simplified ToolsResponse.
type MultiRepo ¶
type MultiRepo struct {
// contains filtered or unexported fields
}
func NewMultiRepo ¶
func NewMultiRepo(repos ...taskengine.ToolsRepo) *MultiRepo
func (*MultiRepo) GetSchemasForSupportedTools ¶
func (*MultiRepo) GetToolsForToolsByName ¶
type OpenAPIToolProtocol ¶
type OpenAPIToolProtocol struct {
SpecSource string // optional; set by remoteprovider when RemoteTools.SpecURL is non-empty
}
OpenAPIToolProtocol implements ToolProtocol using OpenAPI v3 specs. SpecSource, when non-empty, is used as the spec location instead of endpointURL+"/openapi.json". Supported formats:
- https://... or http://... — fetched over HTTP
- file:///abs/path — read from local filesystem
func (*OpenAPIToolProtocol) ExecuteTool ¶
func (p *OpenAPIToolProtocol) ExecuteTool( ctx context.Context, endpointURL string, httpClient *http.Client, injectParams map[string]ParamArg, toolCall taskengine.ToolCall, ) (interface{}, taskengine.DataType, error)
ExecuteTool performs a tool call by making a corresponding HTTP request.
func (*OpenAPIToolProtocol) FetchSchema ¶
func (*OpenAPIToolProtocol) FetchTools ¶
type ParamArg ¶
type ParamArg struct {
Name string
Value string
In ArgLocation
}
type PersistentRepo ¶
type PersistentRepo struct {
// contains filtered or unexported fields
}
PersistentRepo implements taskengine.ToolsRepo using a single OpenAPI-based protocol.
func (*PersistentRepo) Exec ¶
func (p *PersistentRepo) Exec( ctx context.Context, startingTime time.Time, input any, debug bool, args *taskengine.ToolsCall, ) (any, taskengine.DataType, error)
Exec executes a tools by name.
func (*PersistentRepo) GetSchemasForSupportedTools ¶
func (p *PersistentRepo) GetSchemasForSupportedTools(ctx context.Context) (map[string]*openapi3.T, error)
GetSchemasForSupportedTools returns OpenAPI schemas for all remote tools.
func (*PersistentRepo) GetToolsForToolsByName ¶
func (p *PersistentRepo) GetToolsForToolsByName(ctx context.Context, name string) ([]taskengine.Tool, error)
GetToolsForToolsByName returns the list of tools exposed by the named tools.
type SimpleRepo ¶
type SimpleRepo struct {
// contains filtered or unexported fields
}
SimpleRepo holds a map of locally registered tools.
func (*SimpleRepo) Exec ¶
func (m *SimpleRepo) Exec( ctx context.Context, startingTime time.Time, input any, debug bool, args *taskengine.ToolsCall, ) (any, taskengine.DataType, error)
func (*SimpleRepo) GetSchemasForSupportedTools ¶
func (m *SimpleRepo) GetSchemasForSupportedTools(ctx context.Context) (map[string]*openapi3.T, error)
GetSchemasForSupportedTools aggregates the schemas from all registered tools.
func (*SimpleRepo) GetToolsForToolsByName ¶
func (m *SimpleRepo) GetToolsForToolsByName(ctx context.Context, name string) ([]taskengine.Tool, error)
type ToolProtocol ¶
type ToolProtocol interface {
FetchSchema(ctx context.Context, endpointURL string, httpClient *http.Client) (*openapi3.T, error)
FetchTools(ctx context.Context, endpointURL string, injectParams map[string]ParamArg, httpClient *http.Client) ([]taskengine.Tool, error)
ExecuteTool(
ctx context.Context,
endpointURL string,
httpClient *http.Client,
injectParams map[string]ParamArg,
toolCall taskengine.ToolCall,
) (interface{}, taskengine.DataType, error)
}
ToolProtocol defines the methods required to interact with a remote service that exposes tools via a standardized protocol (e.g., OpenAPI). It is responsible for discovering available tools and executing tool calls. ToolProtocol defines the interface for interacting with remote tools via OpenAPI.
type ToolsCallRecord ¶
type ToolsCallRecord struct {
Args taskengine.ToolsCall
Input any
}
ToolsCallRecord now only stores the arguments passed to the tools.
type ToolsResponse ¶
ToolsResponse is simplified to only contain the direct output and optional OpenAPI schema.